| 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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 } | 123 } |
| 124 } | 124 } |
| 125 | 125 |
| 126 return NULL; | 126 return NULL; |
| 127 } | 127 } |
| 128 | 128 |
| 129 void SimulateClick(views::View* view) { | 129 void SimulateClick(views::View* view) { |
| 130 gfx::Point center = view->GetLocalBounds().CenterPoint(); | 130 gfx::Point center = view->GetLocalBounds().CenterPoint(); |
| 131 view->OnMousePressed(ui::MouseEvent( | 131 view->OnMousePressed(ui::MouseEvent( |
| 132 ui::ET_MOUSE_PRESSED, center, center, ui::EventTimeForNow(), | 132 ui::ET_MOUSE_PRESSED, center, center, ui::EventTimeForNow(), |
| 133 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 133 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON, |
| 134 ui::PointerEventDetails(ui::EventPointerType::POINTER_TYPE_MOUSE))); |
| 134 view->OnMouseReleased(ui::MouseEvent( | 135 view->OnMouseReleased(ui::MouseEvent( |
| 135 ui::ET_MOUSE_RELEASED, center, center, ui::EventTimeForNow(), | 136 ui::ET_MOUSE_RELEASED, center, center, ui::EventTimeForNow(), |
| 136 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 137 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON, |
| 138 ui::PointerEventDetails(ui::EventPointerType::POINTER_TYPE_MOUSE))); |
| 137 } | 139 } |
| 138 | 140 |
| 139 // |point| is in |grid_view|'s coordinates. | 141 // |point| is in |grid_view|'s coordinates. |
| 140 AppListItemView* SimulateInitiateDrag(AppsGridView* grid_view, | 142 AppListItemView* SimulateInitiateDrag(AppsGridView* grid_view, |
| 141 AppsGridView::Pointer pointer, | 143 AppsGridView::Pointer pointer, |
| 142 const gfx::Point& point) { | 144 const gfx::Point& point) { |
| 143 AppListItemView* view = GetItemViewAtPointInGrid(grid_view, point); | 145 AppListItemView* view = GetItemViewAtPointInGrid(grid_view, point); |
| 144 DCHECK(view); | 146 DCHECK(view); |
| 145 | 147 |
| 146 gfx::Point translated = | 148 gfx::Point translated = |
| 147 gfx::PointAtOffsetFromOrigin(point - view->bounds().origin()); | 149 gfx::PointAtOffsetFromOrigin(point - view->bounds().origin()); |
| 148 ui::MouseEvent pressed_event(ui::ET_MOUSE_PRESSED, translated, point, | 150 ui::MouseEvent pressed_event( |
| 149 ui::EventTimeForNow(), 0, 0); | 151 ui::ET_MOUSE_PRESSED, translated, point, ui::EventTimeForNow(), 0, 0, |
| 152 ui::PointerEventDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)); |
| 150 grid_view->InitiateDrag(view, pointer, pressed_event); | 153 grid_view->InitiateDrag(view, pointer, pressed_event); |
| 151 return view; | 154 return view; |
| 152 } | 155 } |
| 153 | 156 |
| 154 // |point| is in |grid_view|'s coordinates. | 157 // |point| is in |grid_view|'s coordinates. |
| 155 void SimulateUpdateDrag(AppsGridView* grid_view, | 158 void SimulateUpdateDrag(AppsGridView* grid_view, |
| 156 AppsGridView::Pointer pointer, | 159 AppsGridView::Pointer pointer, |
| 157 AppListItemView* drag_view, | 160 AppListItemView* drag_view, |
| 158 const gfx::Point& point) { | 161 const gfx::Point& point) { |
| 159 DCHECK(drag_view); | 162 DCHECK(drag_view); |
| 160 gfx::Point translated = | 163 gfx::Point translated = |
| 161 gfx::PointAtOffsetFromOrigin(point - drag_view->bounds().origin()); | 164 gfx::PointAtOffsetFromOrigin(point - drag_view->bounds().origin()); |
| 162 ui::MouseEvent drag_event(ui::ET_MOUSE_DRAGGED, translated, point, | 165 ui::MouseEvent drag_event( |
| 163 ui::EventTimeForNow(), 0, 0); | 166 ui::ET_MOUSE_DRAGGED, translated, point, ui::EventTimeForNow(), 0, 0, |
| 167 ui::PointerEventDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)); |
| 164 grid_view->UpdateDragFromItem(pointer, drag_event); | 168 grid_view->UpdateDragFromItem(pointer, drag_event); |
| 165 } | 169 } |
| 166 | 170 |
| 167 ContentsView* GetContentsView() { return main_view_->contents_view(); } | 171 ContentsView* GetContentsView() { return main_view_->contents_view(); } |
| 168 | 172 |
| 169 AppsGridView* RootGridView() { | 173 AppsGridView* RootGridView() { |
| 170 return GetContentsView()->apps_container_view()->apps_grid_view(); | 174 return GetContentsView()->apps_container_view()->apps_grid_view(); |
| 171 } | 175 } |
| 172 | 176 |
| 173 AppListFolderView* FolderView() { | 177 AppListFolderView* FolderView() { |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 // The app list model should remain unchanged. | 458 // The app list model should remain unchanged. |
| 455 EXPECT_EQ(1, FolderViewModel()->view_size()); | 459 EXPECT_EQ(1, FolderViewModel()->view_size()); |
| 456 EXPECT_EQ(2, RootViewModel()->view_size()); | 460 EXPECT_EQ(2, RootViewModel()->view_size()); |
| 457 EXPECT_EQ(folder_id, RootGridView()->GetItemViewAt(0)->item()->id()); | 461 EXPECT_EQ(folder_id, RootGridView()->GetItemViewAt(0)->item()->id()); |
| 458 EXPECT_NE(nullptr, | 462 EXPECT_NE(nullptr, |
| 459 delegate_->GetTestModel()->FindFolderItem("single_item_folder")); | 463 delegate_->GetTestModel()->FindFolderItem("single_item_folder")); |
| 460 } | 464 } |
| 461 | 465 |
| 462 } // namespace test | 466 } // namespace test |
| 463 } // namespace app_list | 467 } // namespace app_list |
| OLD | NEW |