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 "chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest.h" | 5 #include "chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest.h" |
6 | 6 |
7 #include "ash/wm/property_util.h" | 7 #include "ash/wm/property_util.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 #include "ui/ui_controls/ui_controls.h" | 31 #include "ui/ui_controls/ui_controls.h" |
32 #include "ui/views/view.h" | 32 #include "ui/views/view.h" |
33 #include "ui/views/widget/widget.h" | 33 #include "ui/views/widget/widget.h" |
34 | 34 |
35 #if defined(USE_ASH) | 35 #if defined(USE_ASH) |
36 #include "ash/display/display_controller.h" | 36 #include "ash/display/display_controller.h" |
37 #include "ash/display/multi_display_manager.h" | 37 #include "ash/display/multi_display_manager.h" |
38 #include "ash/shell.h" | 38 #include "ash/shell.h" |
39 #include "ash/test/cursor_manager_test_api.h" | 39 #include "ash/test/cursor_manager_test_api.h" |
40 #include "ash/wm/cursor_manager.h" | 40 #include "ash/wm/cursor_manager.h" |
| 41 #include "ash/wm/window_util.h" |
41 #include "ui/aura/test/event_generator.h" | 42 #include "ui/aura/test/event_generator.h" |
42 #include "ui/aura/root_window.h" | 43 #include "ui/aura/root_window.h" |
43 #endif | 44 #endif |
44 | 45 |
45 namespace test { | 46 namespace test { |
46 | 47 |
47 namespace { | 48 namespace { |
48 | 49 |
49 const char kTabDragControllerInteractiveUITestUserDataKey[] = | 50 const char kTabDragControllerInteractiveUITestUserDataKey[] = |
50 "TabDragControllerInteractiveUITestUserData"; | 51 "TabDragControllerInteractiveUITestUserData"; |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 EXPECT_TRUE(GetTrackedByWorkspace(browser2)); | 393 EXPECT_TRUE(GetTrackedByWorkspace(browser2)); |
393 } | 394 } |
394 | 395 |
395 namespace { | 396 namespace { |
396 | 397 |
397 void DetachToOwnWindowStep2(DetachToBrowserTabDragControllerTest* test) { | 398 void DetachToOwnWindowStep2(DetachToBrowserTabDragControllerTest* test) { |
398 if (test->input_source() == INPUT_SOURCE_TOUCH) | 399 if (test->input_source() == INPUT_SOURCE_TOUCH) |
399 ASSERT_TRUE(test->ReleaseInput()); | 400 ASSERT_TRUE(test->ReleaseInput()); |
400 } | 401 } |
401 | 402 |
| 403 #if defined(USE_ASH) |
| 404 bool IsWindowPositionManaged(aura::Window* window) { |
| 405 return ash::wm::IsWindowPositionManaged(window); |
| 406 } |
| 407 bool HasUserChangedWindowPositionOrSize(aura::Window* window) { |
| 408 return ash::wm::HasUserChangedWindowPositionOrSize(window); |
| 409 } |
| 410 #else |
| 411 bool IsWindowPositionManaged(gfx::NativeWindow window) { |
| 412 return true; |
| 413 } |
| 414 bool HasUserChangedWindowPositionOrSize(gfx::NativeWindow window) { |
| 415 return false; |
| 416 } |
| 417 #endif |
| 418 |
402 } // namespace | 419 } // namespace |
403 | 420 |
404 // Drags from browser to separate window and releases mouse. | 421 // Drags from browser to separate window and releases mouse. |
405 IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest, | 422 IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest, |
406 DetachToOwnWindow) { | 423 DetachToOwnWindow) { |
407 const gfx::Rect initial_bounds(browser()->window()->GetBounds()); | 424 const gfx::Rect initial_bounds(browser()->window()->GetBounds()); |
408 // Add another tab. | 425 // Add another tab. |
409 AddTabAndResetBrowser(browser()); | 426 AddTabAndResetBrowser(browser()); |
410 TabStrip* tab_strip = GetTabStripForBrowser(browser()); | 427 TabStrip* tab_strip = GetTabStripForBrowser(browser()); |
411 | 428 |
(...skipping 22 matching lines...) Expand all Loading... |
434 | 451 |
435 EXPECT_EQ("0", IDString(new_browser->tab_strip_model())); | 452 EXPECT_EQ("0", IDString(new_browser->tab_strip_model())); |
436 EXPECT_EQ("1", IDString(browser()->tab_strip_model())); | 453 EXPECT_EQ("1", IDString(browser()->tab_strip_model())); |
437 | 454 |
438 // The bounds of the initial window should not have changed. | 455 // The bounds of the initial window should not have changed. |
439 EXPECT_EQ(initial_bounds.ToString(), | 456 EXPECT_EQ(initial_bounds.ToString(), |
440 browser()->window()->GetBounds().ToString()); | 457 browser()->window()->GetBounds().ToString()); |
441 | 458 |
442 EXPECT_TRUE(GetTrackedByWorkspace(browser())); | 459 EXPECT_TRUE(GetTrackedByWorkspace(browser())); |
443 EXPECT_TRUE(GetTrackedByWorkspace(new_browser)); | 460 EXPECT_TRUE(GetTrackedByWorkspace(new_browser)); |
| 461 // After this both windows should still be managable. |
| 462 EXPECT_TRUE(IsWindowPositionManaged(browser()->window()->GetNativeWindow())); |
| 463 EXPECT_TRUE(IsWindowPositionManaged( |
| 464 new_browser->window()->GetNativeWindow())); |
444 } | 465 } |
445 | 466 |
446 // Deletes a tab being dragged before the user moved enough to start a drag. | 467 // Deletes a tab being dragged before the user moved enough to start a drag. |
447 IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest, | 468 IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest, |
448 DeleteBeforeStartedDragging) { | 469 DeleteBeforeStartedDragging) { |
449 // Add another tab. | 470 // Add another tab. |
450 AddTabAndResetBrowser(browser()); | 471 AddTabAndResetBrowser(browser()); |
451 TabStrip* tab_strip = GetTabStripForBrowser(browser()); | 472 TabStrip* tab_strip = GetTabStripForBrowser(browser()); |
452 | 473 |
453 // Click on the first tab, but don't move it. | 474 // Click on the first tab, but don't move it. |
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
849 // second browser. | 870 // second browser. |
850 IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest, | 871 IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest, |
851 DragSingleTabToSeparateWindow) { | 872 DragSingleTabToSeparateWindow) { |
852 TabStrip* tab_strip = GetTabStripForBrowser(browser()); | 873 TabStrip* tab_strip = GetTabStripForBrowser(browser()); |
853 | 874 |
854 ResetIDs(browser()->tab_strip_model(), 0); | 875 ResetIDs(browser()->tab_strip_model(), 0); |
855 | 876 |
856 // Create another browser. | 877 // Create another browser. |
857 Browser* browser2 = CreateAnotherWindowBrowserAndRelayout(); | 878 Browser* browser2 = CreateAnotherWindowBrowserAndRelayout(); |
858 TabStrip* tab_strip2 = GetTabStripForBrowser(browser2); | 879 TabStrip* tab_strip2 = GetTabStripForBrowser(browser2); |
| 880 const gfx::Rect initial_bounds(browser2->window()->GetBounds()); |
859 | 881 |
860 // Move to the first tab and drag it enough so that it detaches, but not | 882 // Move to the first tab and drag it enough so that it detaches, but not |
861 // enough that it attaches to browser2. | 883 // enough that it attaches to browser2. |
862 gfx::Point tab_0_center( | 884 gfx::Point tab_0_center( |
863 GetCenterInScreenCoordinates(tab_strip->tab_at(0))); | 885 GetCenterInScreenCoordinates(tab_strip->tab_at(0))); |
864 ASSERT_TRUE(PressInput(tab_0_center)); | 886 ASSERT_TRUE(PressInput(tab_0_center)); |
865 ASSERT_TRUE(DragInputToNotifyWhenDone( | 887 ASSERT_TRUE(DragInputToNotifyWhenDone( |
866 tab_0_center.x(), tab_0_center.y() + GetDetachY(tab_strip), | 888 tab_0_center.x(), tab_0_center.y() + GetDetachY(tab_strip), |
867 base::Bind(&DragAllToSeparateWindowStep2, this, tab_strip, tab_strip2))); | 889 base::Bind(&DragAllToSeparateWindowStep2, this, tab_strip, tab_strip2))); |
868 QuitWhenNotDragging(); | 890 QuitWhenNotDragging(); |
869 | 891 |
870 // Should now be attached to tab_strip2. | 892 // Should now be attached to tab_strip2. |
871 ASSERT_TRUE(tab_strip2->IsDragSessionActive()); | 893 ASSERT_TRUE(tab_strip2->IsDragSessionActive()); |
872 ASSERT_TRUE(TabDragController::IsActive()); | 894 ASSERT_TRUE(TabDragController::IsActive()); |
873 ASSERT_EQ(1u, BrowserList::size()); | 895 ASSERT_EQ(1u, BrowserList::size()); |
874 | 896 |
875 // Release the mouse, stopping the drag session. | 897 // Release the mouse, stopping the drag session. |
876 ASSERT_TRUE(ReleaseInput()); | 898 ASSERT_TRUE(ReleaseInput()); |
877 ASSERT_FALSE(tab_strip2->IsDragSessionActive()); | 899 ASSERT_FALSE(tab_strip2->IsDragSessionActive()); |
878 ASSERT_FALSE(TabDragController::IsActive()); | 900 ASSERT_FALSE(TabDragController::IsActive()); |
879 EXPECT_EQ("100 0", IDString(browser2->tab_strip_model())); | 901 EXPECT_EQ("100 0", IDString(browser2->tab_strip_model())); |
880 | 902 |
881 EXPECT_TRUE(GetTrackedByWorkspace(browser2)); | 903 EXPECT_TRUE(GetTrackedByWorkspace(browser2)); |
| 904 // Make sure that the window is still managed and not user moved. |
| 905 EXPECT_TRUE(IsWindowPositionManaged(browser2->window()->GetNativeWindow())); |
| 906 EXPECT_FALSE(HasUserChangedWindowPositionOrSize( |
| 907 browser2->window()->GetNativeWindow())); |
| 908 // Also make sure that the drag to window position has not changed. |
| 909 EXPECT_EQ(initial_bounds.ToString(), |
| 910 browser2->window()->GetBounds().ToString()); |
882 } | 911 } |
883 | 912 |
884 namespace { | 913 namespace { |
885 | 914 |
886 // Invoked from the nested message loop. | 915 // Invoked from the nested message loop. |
887 void CancelOnNewTabWhenDraggingStep2( | 916 void CancelOnNewTabWhenDraggingStep2( |
888 DetachToBrowserTabDragControllerTest* test) { | 917 DetachToBrowserTabDragControllerTest* test) { |
889 ASSERT_TRUE(TabDragController::IsActive()); | 918 ASSERT_TRUE(TabDragController::IsActive()); |
890 ASSERT_EQ(2u, BrowserList::size()); | 919 ASSERT_EQ(2u, BrowserList::size()); |
891 | 920 |
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1373 DifferentDeviceScaleFactorDisplayTabDragControllerTest, | 1402 DifferentDeviceScaleFactorDisplayTabDragControllerTest, |
1374 ::testing::Values("mouse")); | 1403 ::testing::Values("mouse")); |
1375 INSTANTIATE_TEST_CASE_P(TabDragging, | 1404 INSTANTIATE_TEST_CASE_P(TabDragging, |
1376 DetachToBrowserTabDragControllerTest, | 1405 DetachToBrowserTabDragControllerTest, |
1377 ::testing::Values("mouse", "touch")); | 1406 ::testing::Values("mouse", "touch")); |
1378 #else | 1407 #else |
1379 INSTANTIATE_TEST_CASE_P(TabDragging, | 1408 INSTANTIATE_TEST_CASE_P(TabDragging, |
1380 DetachToBrowserTabDragControllerTest, | 1409 DetachToBrowserTabDragControllerTest, |
1381 ::testing::Values("mouse")); | 1410 ::testing::Values("mouse")); |
1382 #endif | 1411 #endif |
OLD | NEW |