Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1274)

Side by Side Diff: ui/app_list/views/apps_grid_view_unittest.cc

Issue 14061025: ui: Use base::MessageLoop. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/app_list/pagination_model_unittest.cc ('k') | ui/app_list/views/search_result_list_view.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/app_list/views/apps_grid_view.h" 5 #include "ui/app_list/views/apps_grid_view.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 16 matching lines...) Expand all
27 const int kIconDimension = 48; 27 const int kIconDimension = 48;
28 const int kCols = 2; 28 const int kCols = 2;
29 const int kRows = 2; 29 const int kRows = 2;
30 const int kTilesPerPage = kCols * kRows; 30 const int kTilesPerPage = kCols * kRows;
31 31
32 const int kWidth = 320; 32 const int kWidth = 320;
33 const int kHeight = 240; 33 const int kHeight = 240;
34 34
35 class PageFlipWaiter : public PaginationModelObserver { 35 class PageFlipWaiter : public PaginationModelObserver {
36 public: 36 public:
37 PageFlipWaiter(MessageLoopForUI* ui_loop, 37 PageFlipWaiter(base::MessageLoopForUI* ui_loop, PaginationModel* model)
38 PaginationModel* model) 38 : ui_loop_(ui_loop), model_(model), wait_(false), page_changed_(false) {
39 : ui_loop_(ui_loop),
40 model_(model),
41 wait_(false),
42 page_changed_(false) {
43 model_->AddObserver(this); 39 model_->AddObserver(this);
44 } 40 }
45 41
46 virtual ~PageFlipWaiter() { 42 virtual ~PageFlipWaiter() {
47 model_->RemoveObserver(this); 43 model_->RemoveObserver(this);
48 } 44 }
49 45
50 bool Wait(int time_out_ms) { 46 bool Wait(int time_out_ms) {
51 DCHECK(!wait_); 47 DCHECK(!wait_);
52 wait_ = true; 48 wait_ = true;
(...skipping 17 matching lines...) Expand all
70 } 66 }
71 virtual void SelectedPageChanged(int old_selected, 67 virtual void SelectedPageChanged(int old_selected,
72 int new_selected) OVERRIDE { 68 int new_selected) OVERRIDE {
73 page_changed_ = true; 69 page_changed_ = true;
74 if (wait_) 70 if (wait_)
75 ui_loop_->Quit(); 71 ui_loop_->Quit();
76 } 72 }
77 virtual void TransitionChanged() OVERRIDE { 73 virtual void TransitionChanged() OVERRIDE {
78 } 74 }
79 75
80 MessageLoopForUI* ui_loop_; 76 base::MessageLoopForUI* ui_loop_;
81 PaginationModel* model_; 77 PaginationModel* model_;
82 bool wait_; 78 bool wait_;
83 bool page_changed_; 79 bool page_changed_;
84 base::OneShotTimer<PageFlipWaiter> wait_timer_; 80 base::OneShotTimer<PageFlipWaiter> wait_timer_;
85 81
86 DISALLOW_COPY_AND_ASSIGN(PageFlipWaiter); 82 DISALLOW_COPY_AND_ASSIGN(PageFlipWaiter);
87 }; 83 };
88 84
89 } // namespace 85 } // namespace
90 86
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 void SimulateKeyPress(ui::KeyboardCode key_code) { 154 void SimulateKeyPress(ui::KeyboardCode key_code) {
159 ui::KeyEvent key_event(ui::ET_KEY_PRESSED, key_code, 0, false); 155 ui::KeyEvent key_event(ui::ET_KEY_PRESSED, key_code, 0, false);
160 apps_grid_view_->OnKeyPressed(key_event); 156 apps_grid_view_->OnKeyPressed(key_event);
161 } 157 }
162 158
163 scoped_ptr<AppListTestModel> model_; 159 scoped_ptr<AppListTestModel> model_;
164 scoped_ptr<PaginationModel> pagination_model_; 160 scoped_ptr<PaginationModel> pagination_model_;
165 scoped_ptr<AppsGridView> apps_grid_view_; 161 scoped_ptr<AppsGridView> apps_grid_view_;
166 scoped_ptr<AppsGridViewTestApi> test_api_; 162 scoped_ptr<AppsGridViewTestApi> test_api_;
167 163
168 MessageLoopForUI message_loop_; 164 base::MessageLoopForUI message_loop_;
169 165
170 private: 166 private:
171 DISALLOW_COPY_AND_ASSIGN(AppsGridViewTest); 167 DISALLOW_COPY_AND_ASSIGN(AppsGridViewTest);
172 }; 168 };
173 169
174 TEST_F(AppsGridViewTest, CreatePage) { 170 TEST_F(AppsGridViewTest, CreatePage) {
175 // Fully populates a page. 171 // Fully populates a page.
176 const int kPages = 1; 172 const int kPages = 1;
177 model_->PopulateApps(kPages * kTilesPerPage); 173 model_->PopulateApps(kPages * kTilesPerPage);
178 EXPECT_EQ(kPages, pagination_model_->total_pages()); 174 EXPECT_EQ(kPages, pagination_model_->total_pages());
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 // After page switch, arrow keys select first item on current page. 383 // After page switch, arrow keys select first item on current page.
388 apps_grid_view_->SetSelectedView(GetItemViewAt(first_index)); 384 apps_grid_view_->SetSelectedView(GetItemViewAt(first_index));
389 pagination_model_->SelectPage(1, false); 385 pagination_model_->SelectPage(1, false);
390 SimulateKeyPress(ui::VKEY_UP); 386 SimulateKeyPress(ui::VKEY_UP);
391 EXPECT_TRUE(apps_grid_view_->IsSelectedView(GetItemViewAt( 387 EXPECT_TRUE(apps_grid_view_->IsSelectedView(GetItemViewAt(
392 first_index_on_page2))); 388 first_index_on_page2)));
393 } 389 }
394 390
395 } // namespace test 391 } // namespace test
396 } // namespace app_list 392 } // namespace app_list
OLDNEW
« no previous file with comments | « ui/app_list/pagination_model_unittest.cc ('k') | ui/app_list/views/search_result_list_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698