| 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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 AppsGridView::Pointer pointer, | 147 AppsGridView::Pointer pointer, |
| 148 AppListItemView* drag_view, | 148 AppListItemView* drag_view, |
| 149 const gfx::Point& point) { | 149 const gfx::Point& point) { |
| 150 DCHECK(drag_view); | 150 DCHECK(drag_view); |
| 151 gfx::Point translated = | 151 gfx::Point translated = |
| 152 gfx::PointAtOffsetFromOrigin(point - drag_view->bounds().origin()); | 152 gfx::PointAtOffsetFromOrigin(point - drag_view->bounds().origin()); |
| 153 ui::MouseEvent drag_event(ui::ET_MOUSE_DRAGGED, translated, point, 0, 0); | 153 ui::MouseEvent drag_event(ui::ET_MOUSE_DRAGGED, translated, point, 0, 0); |
| 154 grid_view->UpdateDragFromItem(pointer, drag_event); | 154 grid_view->UpdateDragFromItem(pointer, drag_event); |
| 155 } | 155 } |
| 156 | 156 |
| 157 ContentsView* ContentsView() { return main_view_->contents_view(); } | 157 ContentsView* GetContentsView() { return main_view_->contents_view(); } |
| 158 | 158 |
| 159 AppsGridView* RootGridView() { | 159 AppsGridView* RootGridView() { |
| 160 return ContentsView()->apps_container_view()->apps_grid_view(); | 160 return GetContentsView()->apps_container_view()->apps_grid_view(); |
| 161 } | 161 } |
| 162 | 162 |
| 163 AppListFolderView* FolderView() { | 163 AppListFolderView* FolderView() { |
| 164 return ContentsView()->apps_container_view()->app_list_folder_view(); | 164 return GetContentsView()->apps_container_view()->app_list_folder_view(); |
| 165 } | 165 } |
| 166 | 166 |
| 167 AppsGridView* FolderGridView() { return FolderView()->items_grid_view(); } | 167 AppsGridView* FolderGridView() { return FolderView()->items_grid_view(); } |
| 168 | 168 |
| 169 const views::ViewModelT<AppListItemView>* RootViewModel() { | 169 const views::ViewModelT<AppListItemView>* RootViewModel() { |
| 170 return RootGridView()->view_model_for_test(); | 170 return RootGridView()->view_model_for_test(); |
| 171 } | 171 } |
| 172 | 172 |
| 173 const views::ViewModelT<AppListItemView>* FolderViewModel() { | 173 const views::ViewModelT<AppListItemView>* FolderViewModel() { |
| 174 return FolderGridView()->view_model_for_test(); | 174 return FolderGridView()->view_model_for_test(); |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 } | 291 } |
| 292 | 292 |
| 293 // Tests dragging an item out of a single item folder and dropping it onto the | 293 // Tests dragging an item out of a single item folder and dropping it onto the |
| 294 // page switcher. Regression test for http://crbug.com/415530/. | 294 // page switcher. Regression test for http://crbug.com/415530/. |
| 295 TEST_F(AppListMainViewTest, DragReparentItemOntoPageSwitcher) { | 295 TEST_F(AppListMainViewTest, DragReparentItemOntoPageSwitcher) { |
| 296 // Number of apps to populate. Should provide more than 1 page of apps (6*4 = | 296 // Number of apps to populate. Should provide more than 1 page of apps (6*4 = |
| 297 // 24). | 297 // 24). |
| 298 const int kNumApps = 30; | 298 const int kNumApps = 30; |
| 299 | 299 |
| 300 // Ensure we are on the apps grid view page. | 300 // Ensure we are on the apps grid view page. |
| 301 app_list::ContentsView* contents_view = ContentsView(); | 301 app_list::ContentsView* contents_view = GetContentsView(); |
| 302 contents_view->SetActivePage( | 302 contents_view->SetActivePage( |
| 303 contents_view->GetPageIndexForState(AppListModel::STATE_APPS)); | 303 contents_view->GetPageIndexForState(AppListModel::STATE_APPS)); |
| 304 contents_view->Layout(); | 304 contents_view->Layout(); |
| 305 | 305 |
| 306 AppListItemView* folder_item_view = CreateAndOpenSingleItemFolder(); | 306 AppListItemView* folder_item_view = CreateAndOpenSingleItemFolder(); |
| 307 const gfx::Rect first_slot_tile = folder_item_view->bounds(); | 307 const gfx::Rect first_slot_tile = folder_item_view->bounds(); |
| 308 | 308 |
| 309 delegate_->GetTestModel()->PopulateApps(kNumApps); | 309 delegate_->GetTestModel()->PopulateApps(kNumApps); |
| 310 | 310 |
| 311 EXPECT_EQ(1, FolderViewModel()->view_size()); | 311 EXPECT_EQ(1, FolderViewModel()->view_size()); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 // The app list model should remain unchanged. | 377 // The app list model should remain unchanged. |
| 378 EXPECT_EQ(1, FolderViewModel()->view_size()); | 378 EXPECT_EQ(1, FolderViewModel()->view_size()); |
| 379 EXPECT_EQ(2, RootViewModel()->view_size()); | 379 EXPECT_EQ(2, RootViewModel()->view_size()); |
| 380 EXPECT_EQ(folder_id, RootGridView()->GetItemViewAt(0)->item()->id()); | 380 EXPECT_EQ(folder_id, RootGridView()->GetItemViewAt(0)->item()->id()); |
| 381 EXPECT_NE(nullptr, | 381 EXPECT_NE(nullptr, |
| 382 delegate_->GetTestModel()->FindFolderItem("single_item_folder")); | 382 delegate_->GetTestModel()->FindFolderItem("single_item_folder")); |
| 383 } | 383 } |
| 384 | 384 |
| 385 } // namespace test | 385 } // namespace test |
| 386 } // namespace app_list | 386 } // namespace app_list |
| OLD | NEW |