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

Side by Side Diff: ui/app_list/views/app_list_main_view_unittest.cc

Issue 583263004: Fix app list duplication on drag. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@start_page_padding
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « no previous file | ui/app_list/views/apps_grid_view.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 // The item view should be in slot 1 instead of slot 2 where it is dropped. 279 // The item view should be in slot 1 instead of slot 2 where it is dropped.
280 AppsGridViewTestApi root_grid_view_test_api(RootGridView()); 280 AppsGridViewTestApi root_grid_view_test_api(RootGridView());
281 root_grid_view_test_api.LayoutToIdealBounds(); 281 root_grid_view_test_api.LayoutToIdealBounds();
282 EXPECT_EQ(first_slot_tile, RootViewModel()->view_at(0)->bounds()); 282 EXPECT_EQ(first_slot_tile, RootViewModel()->view_at(0)->bounds());
283 283
284 // Single item folder should be auto removed. 284 // Single item folder should be auto removed.
285 EXPECT_EQ(NULL, 285 EXPECT_EQ(NULL,
286 delegate_->GetTestModel()->FindFolderItem("single_item_folder")); 286 delegate_->GetTestModel()->FindFolderItem("single_item_folder"));
287 } 287 }
288 288
289 // Tests dragging an item out of a single item folder and dropping it onto the
290 // page switcher. Regression test for http://crbug.com/415530/.
291 TEST_F(AppListMainViewTest, DragReparentItemOntoPageSwitcher) {
292 AppListItemView* folder_item_view = CreateAndOpenSingleItemFolder();
293 const gfx::Rect first_slot_tile = folder_item_view->bounds();
294
295 const int kInitialApps = 20;
tapted 2014/09/22 06:47:02 nit: I'd just drop this var and put 20 on the next
calamity 2014/09/23 01:06:22 Done.
296 delegate_->GetTestModel()->PopulateApps(kInitialApps);
297
298 EXPECT_EQ(1, FolderViewModel()->view_size());
299 EXPECT_EQ(21, RootViewModel()->view_size());
300
301 AppListItemView* dragged = StartDragForReparent(0);
302
303 gfx::Rect main_view_bounds = main_view_->bounds();
304 // Drag the reparent item to the page switcher.
305 gfx::Point point =
306 gfx::Point(main_view_bounds.width() / 2,
307 main_view_bounds.bottom() - first_slot_tile.height());
308 SimulateUpdateDrag(FolderGridView(), AppsGridView::MOUSE, dragged, point);
tapted 2014/09/22 06:47:02 Why two? (comment?). But I'm pretty sure you can d
calamity 2014/09/23 01:06:22 Indeed.
309 SimulateUpdateDrag(FolderGridView(), AppsGridView::MOUSE, dragged, point);
310 base::RunLoop().RunUntilIdle();
tapted 2014/09/22 06:47:02 yeah - as discussed - probably don't need these.
calamity 2014/09/23 01:06:22 Done.
311
312 // Drop it.
313 FolderGridView()->EndDrag(false);
314 base::RunLoop().RunUntilIdle();
315
316 // The folder should be destroyed.
317 EXPECT_EQ(21, RootViewModel()->view_size());
318 EXPECT_EQ(NULL,
319 delegate_->GetTestModel()->FindFolderItem("single_item_folder"));
320 }
321
289 // Test that an interrupted drag while reparenting an item from a folder, when 322 // Test that an interrupted drag while reparenting an item from a folder, when
290 // canceled via the root grid, correctly forwards the cancelation to the drag 323 // canceled via the root grid, correctly forwards the cancelation to the drag
291 // ocurring from the folder. 324 // ocurring from the folder.
292 TEST_F(AppListMainViewTest, MouseDragItemOutOfFolderWithCancel) { 325 TEST_F(AppListMainViewTest, MouseDragItemOutOfFolderWithCancel) {
293 CreateAndOpenSingleItemFolder(); 326 CreateAndOpenSingleItemFolder();
294 AppListItemView* dragged = StartDragForReparent(0); 327 AppListItemView* dragged = StartDragForReparent(0);
295 328
296 // Now add an item to the model, not in any folder, e.g., as if by Sync. 329 // Now add an item to the model, not in any folder, e.g., as if by Sync.
297 EXPECT_TRUE(RootGridView()->has_dragged_view()); 330 EXPECT_TRUE(RootGridView()->has_dragged_view());
298 EXPECT_TRUE(FolderGridView()->has_dragged_view()); 331 EXPECT_TRUE(FolderGridView()->has_dragged_view());
299 delegate_->GetTestModel()->CreateAndAddItem("Extra"); 332 delegate_->GetTestModel()->CreateAndAddItem("Extra");
300 333
301 // The drag operation should get canceled. 334 // The drag operation should get canceled.
302 EXPECT_FALSE(RootGridView()->has_dragged_view()); 335 EXPECT_FALSE(RootGridView()->has_dragged_view());
303 EXPECT_FALSE(FolderGridView()->has_dragged_view()); 336 EXPECT_FALSE(FolderGridView()->has_dragged_view());
304 337
305 // Additional mouse move operations should be ignored. 338 // Additional mouse move operations should be ignored.
306 gfx::Point point(1, 1); 339 gfx::Point point(1, 1);
307 SimulateUpdateDrag(FolderGridView(), AppsGridView::MOUSE, dragged, point); 340 SimulateUpdateDrag(FolderGridView(), AppsGridView::MOUSE, dragged, point);
308 EXPECT_FALSE(RootGridView()->has_dragged_view()); 341 EXPECT_FALSE(RootGridView()->has_dragged_view());
309 EXPECT_FALSE(FolderGridView()->has_dragged_view()); 342 EXPECT_FALSE(FolderGridView()->has_dragged_view());
310 } 343 }
311 344
312 } // namespace test 345 } // namespace test
313 } // namespace app_list 346 } // namespace app_list
OLDNEW
« no previous file with comments | « no previous file | ui/app_list/views/apps_grid_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698