| OLD | NEW |
| 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 Loading... |
| 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::ViewModel<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 Loading... |
| 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::ViewModel<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::ViewModel<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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 SimulateUpdateDrag(FolderGridView(), AppsGridView::MOUSE, dragged, point); | 267 SimulateUpdateDrag(FolderGridView(), AppsGridView::MOUSE, dragged, point); |
| 267 SimulateUpdateDrag(FolderGridView(), AppsGridView::MOUSE, dragged, point); | 268 SimulateUpdateDrag(FolderGridView(), AppsGridView::MOUSE, dragged, point); |
| 268 base::RunLoop().RunUntilIdle(); | 269 base::RunLoop().RunUntilIdle(); |
| 269 | 270 |
| 270 // Drop it. | 271 // Drop it. |
| 271 FolderGridView()->EndDrag(false); | 272 FolderGridView()->EndDrag(false); |
| 272 base::RunLoop().RunUntilIdle(); | 273 base::RunLoop().RunUntilIdle(); |
| 273 | 274 |
| 274 // Folder icon view should be gone and there is only one item view. | 275 // Folder icon view should be gone and there is only one item view. |
| 275 EXPECT_EQ(1, RootViewModel()->view_size()); | 276 EXPECT_EQ(1, RootViewModel()->view_size()); |
| 276 EXPECT_EQ(AppListItemView::kViewClassName, | 277 EXPECT_EQ( |
| 277 RootViewModel()->view_at(0)->GetClassName()); | 278 AppListItemView::kViewClassName, |
| 279 static_cast<views::View*>(RootViewModel()->view_at(0))->GetClassName()); |
| 278 | 280 |
| 279 // The item view should be in slot 1 instead of slot 2 where it is dropped. | 281 // The item view should be in slot 1 instead of slot 2 where it is dropped. |
| 280 AppsGridViewTestApi root_grid_view_test_api(RootGridView()); | 282 AppsGridViewTestApi root_grid_view_test_api(RootGridView()); |
| 281 root_grid_view_test_api.LayoutToIdealBounds(); | 283 root_grid_view_test_api.LayoutToIdealBounds(); |
| 282 EXPECT_EQ(first_slot_tile, RootViewModel()->view_at(0)->bounds()); | 284 EXPECT_EQ(first_slot_tile, RootViewModel()->view_at(0)->bounds()); |
| 283 | 285 |
| 284 // Single item folder should be auto removed. | 286 // Single item folder should be auto removed. |
| 285 EXPECT_EQ(NULL, | 287 EXPECT_EQ(NULL, |
| 286 delegate_->GetTestModel()->FindFolderItem("single_item_folder")); | 288 delegate_->GetTestModel()->FindFolderItem("single_item_folder")); |
| 287 } | 289 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 304 | 306 |
| 305 // Additional mouse move operations should be ignored. | 307 // Additional mouse move operations should be ignored. |
| 306 gfx::Point point(1, 1); | 308 gfx::Point point(1, 1); |
| 307 SimulateUpdateDrag(FolderGridView(), AppsGridView::MOUSE, dragged, point); | 309 SimulateUpdateDrag(FolderGridView(), AppsGridView::MOUSE, dragged, point); |
| 308 EXPECT_FALSE(RootGridView()->has_dragged_view()); | 310 EXPECT_FALSE(RootGridView()->has_dragged_view()); |
| 309 EXPECT_FALSE(FolderGridView()->has_dragged_view()); | 311 EXPECT_FALSE(FolderGridView()->has_dragged_view()); |
| 310 } | 312 } |
| 311 | 313 |
| 312 } // namespace test | 314 } // namespace test |
| 313 } // namespace app_list | 315 } // namespace app_list |
| OLD | NEW |