| OLD | NEW |
| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 return apps_grid_view_->pagination_model(); | 140 return apps_grid_view_->pagination_model(); |
| 141 } | 141 } |
| 142 | 142 |
| 143 // Points are in |apps_grid_view_|'s coordinates. | 143 // Points are in |apps_grid_view_|'s coordinates. |
| 144 AppListItemView* SimulateDrag(AppsGridView::Pointer pointer, | 144 AppListItemView* SimulateDrag(AppsGridView::Pointer pointer, |
| 145 const gfx::Point& from, | 145 const gfx::Point& from, |
| 146 const gfx::Point& to) { | 146 const gfx::Point& to) { |
| 147 AppListItemView* view = GetItemViewForPoint(from); | 147 AppListItemView* view = GetItemViewForPoint(from); |
| 148 DCHECK(view); | 148 DCHECK(view); |
| 149 | 149 |
| 150 gfx::Point translated_from = gfx::PointAtOffsetFromOrigin( | 150 gfx::Point translated_from = |
| 151 from - view->bounds().origin()); | 151 gfx::PointAtOffsetFromOrigin(from - view->origin()); |
| 152 gfx::Point translated_to = gfx::PointAtOffsetFromOrigin( | 152 gfx::Point translated_to = |
| 153 to - view->bounds().origin()); | 153 gfx::PointAtOffsetFromOrigin(to - view->origin()); |
| 154 | 154 |
| 155 ui::MouseEvent pressed_event(ui::ET_MOUSE_PRESSED, translated_from, from, | 155 ui::MouseEvent pressed_event(ui::ET_MOUSE_PRESSED, translated_from, from, |
| 156 ui::EventTimeForNow(), 0, 0); | 156 ui::EventTimeForNow(), 0, 0); |
| 157 apps_grid_view_->InitiateDrag(view, pointer, pressed_event); | 157 apps_grid_view_->InitiateDrag(view, pointer, pressed_event); |
| 158 | 158 |
| 159 ui::MouseEvent drag_event(ui::ET_MOUSE_DRAGGED, translated_to, to, | 159 ui::MouseEvent drag_event(ui::ET_MOUSE_DRAGGED, translated_to, to, |
| 160 ui::EventTimeForNow(), 0, 0); | 160 ui::EventTimeForNow(), 0, 0); |
| 161 apps_grid_view_->UpdateDragFromItem(pointer, drag_event); | 161 apps_grid_view_->UpdateDragFromItem(pointer, drag_event); |
| 162 return view; | 162 return view; |
| 163 } | 163 } |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 test_api_->LayoutToIdealBounds(); | 434 test_api_->LayoutToIdealBounds(); |
| 435 | 435 |
| 436 // The grid now looks like | blank | folder |. | 436 // The grid now looks like | blank | folder |. |
| 437 EXPECT_EQ(NULL, GetItemViewForPoint(GetItemTileRectAt(0, 0).CenterPoint())); | 437 EXPECT_EQ(NULL, GetItemViewForPoint(GetItemTileRectAt(0, 0).CenterPoint())); |
| 438 EXPECT_EQ(folder_view, | 438 EXPECT_EQ(folder_view, |
| 439 GetItemViewForPoint(GetItemTileRectAt(0, 1).CenterPoint())); | 439 GetItemViewForPoint(GetItemTileRectAt(0, 1).CenterPoint())); |
| 440 | 440 |
| 441 // Move onto the folder and end the drag. | 441 // Move onto the folder and end the drag. |
| 442 to = GetItemTileRectAt(0, 1).CenterPoint(); | 442 to = GetItemTileRectAt(0, 1).CenterPoint(); |
| 443 gfx::Point translated_to = | 443 gfx::Point translated_to = |
| 444 gfx::PointAtOffsetFromOrigin(to - dragged_view->bounds().origin()); | 444 gfx::PointAtOffsetFromOrigin(to - dragged_view->origin()); |
| 445 ui::MouseEvent drag_event(ui::ET_MOUSE_DRAGGED, translated_to, to, | 445 ui::MouseEvent drag_event(ui::ET_MOUSE_DRAGGED, translated_to, to, |
| 446 ui::EventTimeForNow(), 0, 0); | 446 ui::EventTimeForNow(), 0, 0); |
| 447 apps_grid_view_->UpdateDragFromItem(AppsGridView::MOUSE, drag_event); | 447 apps_grid_view_->UpdateDragFromItem(AppsGridView::MOUSE, drag_event); |
| 448 apps_grid_view_->EndDrag(false); | 448 apps_grid_view_->EndDrag(false); |
| 449 | 449 |
| 450 // The item should not have moved into the folder. | 450 // The item should not have moved into the folder. |
| 451 EXPECT_EQ(2u, model_->top_level_item_list()->item_count()); | 451 EXPECT_EQ(2u, model_->top_level_item_list()->item_count()); |
| 452 EXPECT_EQ(kMaxFolderItems, folder_item->ChildItemCount()); | 452 EXPECT_EQ(kMaxFolderItems, folder_item->ChildItemCount()); |
| 453 test_api_->LayoutToIdealBounds(); | 453 test_api_->LayoutToIdealBounds(); |
| 454 } | 454 } |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 768 AppListItemView* item_view = GetItemViewAt(0); | 768 AppListItemView* item_view = GetItemViewAt(0); |
| 769 ASSERT_TRUE(item_view); | 769 ASSERT_TRUE(item_view); |
| 770 const views::Label* title_label = item_view->title(); | 770 const views::Label* title_label = item_view->title(); |
| 771 EXPECT_FALSE(title_label->GetTooltipText( | 771 EXPECT_FALSE(title_label->GetTooltipText( |
| 772 title_label->bounds().CenterPoint(), &actual_tooltip)); | 772 title_label->bounds().CenterPoint(), &actual_tooltip)); |
| 773 EXPECT_EQ(title, base::UTF16ToUTF8(title_label->text())); | 773 EXPECT_EQ(title, base::UTF16ToUTF8(title_label->text())); |
| 774 } | 774 } |
| 775 | 775 |
| 776 } // namespace test | 776 } // namespace test |
| 777 } // namespace app_list | 777 } // namespace app_list |
| OLD | NEW |