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

Unified Diff: ui/app_list/views/apps_grid_view_unittest.cc

Issue 553753003: Rework app list item drag zones. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@fasdaj
Patch Set: fix test Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/app_list/views/apps_grid_view.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/app_list/views/apps_grid_view_unittest.cc
diff --git a/ui/app_list/views/apps_grid_view_unittest.cc b/ui/app_list/views/apps_grid_view_unittest.cc
index c6fd60b50d2e303a10d854db12167a69d69d1738..febc17cc1fa5eb59854760a1cd36b2274761e4ed 100644
--- a/ui/app_list/views/apps_grid_view_unittest.cc
+++ b/ui/app_list/views/apps_grid_view_unittest.cc
@@ -420,25 +420,59 @@ TEST_F(AppsGridViewTest, MouseDragItemReorder) {
// This test assumes Folders are enabled.
EnsureFoldersEnabled();
- size_t kTotalItems = 2;
- model_->PopulateApps(kTotalItems);
- EXPECT_EQ(2u, model_->top_level_item_list()->item_count());
- EXPECT_EQ(std::string("Item 0,Item 1"), model_->GetModelContent());
+ model_->PopulateApps(4);
+ EXPECT_EQ(4u, model_->top_level_item_list()->item_count());
+ EXPECT_EQ(std::string("Item 0,Item 1,Item 2,Item 3"),
+ model_->GetModelContent());
- gfx::Point from = GetItemTileRectAt(0, 1).CenterPoint();
- int reorder_offset = (GetItemTileRectAt(0, 1).CenterPoint() -
- GetItemTileRectAt(0, 0).CenterPoint()).Length() -
- kReorderDroppingCircleRadius - kGridIconDimension / 2 +
- 5;
- gfx::Point to = gfx::Point(from.x() - reorder_offset, from.y());
+ // Dragging an item towards its neighbours should not reorder until the drag
+ // is past the folder drop point.
+ gfx::Point top_right = GetItemTileRectAt(0, 1).CenterPoint();
+ gfx::Vector2d drag_vector;
+ int half_tile_width =
+ (GetItemTileRectAt(0, 1).x() - GetItemTileRectAt(0, 0).x()) / 2;
+ int tile_height = GetItemTileRectAt(1, 0).y() - GetItemTileRectAt(0, 0).y();
+
+ // Drag left but stop before the folder dropping circle.
+ drag_vector.set_x(-half_tile_width - 5);
+ SimulateDrag(AppsGridView::MOUSE, top_right, top_right + drag_vector);
+ apps_grid_view_->EndDrag(false);
+ EXPECT_EQ(std::string("Item 0,Item 1,Item 2,Item 3"),
+ model_->GetModelContent());
- // Dragging item_1 closing to item_0 should leads to re-ordering these two
- // items.
- SimulateDrag(AppsGridView::MOUSE, from, to);
+ // Drag left, past the folder dropping circle.
+ drag_vector.set_x(-3 * half_tile_width + 5);
+ SimulateDrag(AppsGridView::MOUSE, top_right, top_right + drag_vector);
apps_grid_view_->EndDrag(false);
- EXPECT_EQ(2u, model_->top_level_item_list()->item_count());
- EXPECT_EQ(std::string("Item 1,Item 0"), model_->GetModelContent());
- test_api_->LayoutToIdealBounds();
+ EXPECT_EQ(std::string("Item 1,Item 0,Item 2,Item 3"),
+ model_->GetModelContent());
+
+ // Drag down, between apps 2 and 3. The gap should open up, making space for
+ // app 0 in the bottom left.
+ drag_vector.set_x(-half_tile_width);
+ drag_vector.set_y(tile_height);
+ SimulateDrag(AppsGridView::MOUSE, top_right, top_right + drag_vector);
+ apps_grid_view_->EndDrag(false);
+ EXPECT_EQ(std::string("Item 1,Item 2,Item 0,Item 3"),
+ model_->GetModelContent());
+
+ // Drag up, between apps 1 and 2. The gap should open up, making space for app
+ // 0 in the top right.
+ gfx::Point bottom_left = GetItemTileRectAt(1, 0).CenterPoint();
+ drag_vector.set_x(half_tile_width);
+ drag_vector.set_y(-tile_height);
+ SimulateDrag(AppsGridView::MOUSE, bottom_left, bottom_left + drag_vector);
+ apps_grid_view_->EndDrag(false);
+ EXPECT_EQ(std::string("Item 1,Item 0,Item 2,Item 3"),
+ model_->GetModelContent());
+
+ // Dragging down past the last app should reorder to the last position.
+ drag_vector.set_x(half_tile_width);
+ drag_vector.set_y(2 * tile_height);
+ SimulateDrag(AppsGridView::MOUSE, top_right, top_right + drag_vector);
+ apps_grid_view_->EndDrag(false);
+ EXPECT_EQ(std::string("Item 1,Item 2,Item 3,Item 0"),
+ model_->GetModelContent());
}
TEST_F(AppsGridViewTest, MouseDragFolderReorder) {
« no previous file with comments | « ui/app_list/views/apps_grid_view.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698