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

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

Issue 598013003: Added views::ViewModelT<T>, a type-safe template version of ViewModel. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@appsgridview-static-casts
Patch Set: Fix browser_test compile on ChromeOS (missing include). Created 6 years, 2 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
« no previous file with comments | « ui/app_list/views/app_list_folder_view.h ('k') | ui/app_list/views/apps_grid_view.h » ('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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/app_list_main_view.h" 5 #include "ui/app_list/views/app_list_main_view.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "base/time/time.h" 9 #include "base/time/time.h"
10 #include "base/timer/timer.h" 10 #include "base/timer/timer.h"
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 91
92 virtual void TearDown() OVERRIDE { 92 virtual void TearDown() OVERRIDE {
93 widget_->Close(); 93 widget_->Close();
94 views::ViewsTestBase::TearDown(); 94 views::ViewsTestBase::TearDown();
95 delegate_.reset(); 95 delegate_.reset();
96 } 96 }
97 97
98 // |point| is in |grid_view|'s coordinates. 98 // |point| is in |grid_view|'s coordinates.
99 AppListItemView* GetItemViewAtPointInGrid(AppsGridView* grid_view, 99 AppListItemView* GetItemViewAtPointInGrid(AppsGridView* grid_view,
100 const gfx::Point& point) { 100 const gfx::Point& point) {
101 const views::ViewModel* view_model = grid_view->view_model_for_test(); 101 const views::ViewModelT<AppListItemView>* view_model =
102 grid_view->view_model_for_test();
102 for (int i = 0; i < view_model->view_size(); ++i) { 103 for (int i = 0; i < view_model->view_size(); ++i) {
103 views::View* view = view_model->view_at(i); 104 views::View* view = view_model->view_at(i);
104 if (view->bounds().Contains(point)) { 105 if (view->bounds().Contains(point)) {
105 return static_cast<AppListItemView*>(view); 106 return static_cast<AppListItemView*>(view);
106 } 107 }
107 } 108 }
108 109
109 return NULL; 110 return NULL;
110 } 111 }
111 112
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 } 155 }
155 156
156 AppListFolderView* FolderView() { 157 AppListFolderView* FolderView() {
157 return main_view_->contents_view() 158 return main_view_->contents_view()
158 ->apps_container_view() 159 ->apps_container_view()
159 ->app_list_folder_view(); 160 ->app_list_folder_view();
160 } 161 }
161 162
162 AppsGridView* FolderGridView() { return FolderView()->items_grid_view(); } 163 AppsGridView* FolderGridView() { return FolderView()->items_grid_view(); }
163 164
164 const views::ViewModel* RootViewModel() { 165 const views::ViewModelT<AppListItemView>* RootViewModel() {
165 return RootGridView()->view_model_for_test(); 166 return RootGridView()->view_model_for_test();
166 } 167 }
167 168
168 const views::ViewModel* FolderViewModel() { 169 const views::ViewModelT<AppListItemView>* FolderViewModel() {
169 return FolderGridView()->view_model_for_test(); 170 return FolderGridView()->view_model_for_test();
170 } 171 }
171 172
172 AppListItemView* CreateAndOpenSingleItemFolder() { 173 AppListItemView* CreateAndOpenSingleItemFolder() {
173 // Prepare single folder with a single item in it. 174 // Prepare single folder with a single item in it.
174 AppListFolderItem* folder_item = 175 AppListFolderItem* folder_item =
175 delegate_->GetTestModel()->CreateSingleItemFolder("single_item_folder", 176 delegate_->GetTestModel()->CreateSingleItemFolder("single_item_folder",
176 "single"); 177 "single");
177 EXPECT_EQ(folder_item, 178 EXPECT_EQ(folder_item,
178 delegate_->GetTestModel()->FindFolderItem("single_item_folder")); 179 delegate_->GetTestModel()->FindFolderItem("single_item_folder"));
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 gfx::Rect drop_target_tile(first_slot_tile); 264 gfx::Rect drop_target_tile(first_slot_tile);
264 drop_target_tile.Offset(first_slot_tile.width() * 2, 0); 265 drop_target_tile.Offset(first_slot_tile.width() * 2, 0);
265 gfx::Point point = drop_target_tile.CenterPoint(); 266 gfx::Point point = drop_target_tile.CenterPoint();
266 SimulateUpdateDrag(FolderGridView(), AppsGridView::MOUSE, dragged, point); 267 SimulateUpdateDrag(FolderGridView(), AppsGridView::MOUSE, dragged, point);
267 268
268 // Drop it. 269 // Drop it.
269 FolderGridView()->EndDrag(false); 270 FolderGridView()->EndDrag(false);
270 271
271 // Folder icon view should be gone and there is only one item view. 272 // Folder icon view should be gone and there is only one item view.
272 EXPECT_EQ(1, RootViewModel()->view_size()); 273 EXPECT_EQ(1, RootViewModel()->view_size());
273 EXPECT_EQ(AppListItemView::kViewClassName, 274 EXPECT_EQ(
274 RootViewModel()->view_at(0)->GetClassName()); 275 AppListItemView::kViewClassName,
276 static_cast<views::View*>(RootViewModel()->view_at(0))->GetClassName());
275 277
276 // The item view should be in slot 1 instead of slot 2 where it is dropped. 278 // The item view should be in slot 1 instead of slot 2 where it is dropped.
277 AppsGridViewTestApi root_grid_view_test_api(RootGridView()); 279 AppsGridViewTestApi root_grid_view_test_api(RootGridView());
278 root_grid_view_test_api.LayoutToIdealBounds(); 280 root_grid_view_test_api.LayoutToIdealBounds();
279 EXPECT_EQ(first_slot_tile, RootViewModel()->view_at(0)->bounds()); 281 EXPECT_EQ(first_slot_tile, RootViewModel()->view_at(0)->bounds());
280 282
281 // Single item folder should be auto removed. 283 // Single item folder should be auto removed.
282 EXPECT_EQ(NULL, 284 EXPECT_EQ(NULL,
283 delegate_->GetTestModel()->FindFolderItem("single_item_folder")); 285 delegate_->GetTestModel()->FindFolderItem("single_item_folder"));
284 } 286 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 332
331 // Additional mouse move operations should be ignored. 333 // Additional mouse move operations should be ignored.
332 gfx::Point point(1, 1); 334 gfx::Point point(1, 1);
333 SimulateUpdateDrag(FolderGridView(), AppsGridView::MOUSE, dragged, point); 335 SimulateUpdateDrag(FolderGridView(), AppsGridView::MOUSE, dragged, point);
334 EXPECT_FALSE(RootGridView()->has_dragged_view()); 336 EXPECT_FALSE(RootGridView()->has_dragged_view());
335 EXPECT_FALSE(FolderGridView()->has_dragged_view()); 337 EXPECT_FALSE(FolderGridView()->has_dragged_view());
336 } 338 }
337 339
338 } // namespace test 340 } // namespace test
339 } // namespace app_list 341 } // namespace app_list
OLDNEW
« no previous file with comments | « ui/app_list/views/app_list_folder_view.h ('k') | ui/app_list/views/apps_grid_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698