Chromium Code Reviews| Index: chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest.cc |
| diff --git a/chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest.cc b/chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest.cc |
| index 2be43e7226aed1485f753da9d097cd3b88c7a762..105b42270bacab677c6523701d17ea8b9afa03f0 100644 |
| --- a/chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest.cc |
| +++ b/chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest.cc |
| @@ -46,6 +46,7 @@ |
| #include "ash/display/display_controller.h" |
| #include "ash/display/display_manager.h" |
| #include "ash/shell.h" |
| +#include "ash/shell_window_ids.h" |
| #include "ash/test/cursor_manager_test_api.h" |
| #include "ash/wm/coordinate_conversion.h" |
| #include "ash/wm/window_util.h" |
| @@ -680,7 +681,7 @@ IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest, |
| EXPECT_TRUE(GetTrackedByWorkspace(browser())); |
| EXPECT_TRUE(GetTrackedByWorkspace(new_browser)); |
| - // After this both windows should still be managable. |
| + // After this both windows should still be manageable. |
| EXPECT_TRUE(IsWindowPositionManaged(browser()->window()->GetNativeWindow())); |
| EXPECT_TRUE(IsWindowPositionManaged( |
| new_browser->window()->GetNativeWindow())); |
| @@ -738,7 +739,7 @@ IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest, |
| EXPECT_TRUE(GetTrackedByWorkspace(browser())); |
| EXPECT_TRUE(GetTrackedByWorkspace(new_browser)); |
| - // After this both windows should still be managable. |
| + // After this both windows should still be manageable. |
| EXPECT_TRUE(IsWindowPositionManaged(browser()->window()->GetNativeWindow())); |
| EXPECT_TRUE(IsWindowPositionManaged( |
| new_browser->window()->GetNativeWindow())); |
| @@ -2034,6 +2035,110 @@ IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTestTouch, |
| new_browser->window()->GetNativeWindow()->bounds().ToString()); |
| } |
| +// Subclass of DetachToBrowserTabDragControllerTest that runs tests with |
| +// docked windows enabled and disabled. |
| +class DetachToDockedTabDragControllerTest |
| + : public DetachToBrowserTabDragControllerTest { |
| + public: |
| + DetachToDockedTabDragControllerTest() {} |
|
oshima
2013/10/25 16:12:32
virtual dtor.
varkha
2013/10/25 17:05:04
Done. Here and for other derivatives of DetachToBr
|
| + |
| + private: |
| + DISALLOW_COPY_AND_ASSIGN(DetachToDockedTabDragControllerTest); |
| +}; |
| + |
| +namespace { |
| + |
| +void DetachToDockedWindowNextStep( |
| + DetachToDockedTabDragControllerTest* test, |
| + const gfx::Point& target_point, |
| + int iteration) { |
| + ASSERT_EQ(2u, test->native_browser_list->size()); |
| + Browser* new_browser = test->native_browser_list->get(1); |
| + ASSERT_TRUE(new_browser->window()->IsActive()); |
| + |
| + if (!iteration) { |
| + ASSERT_TRUE(test->ReleaseInput()); |
| + return; |
| + } |
| + ASSERT_TRUE(test->DragInputToNotifyWhenDone( |
| + target_point.x(), target_point.y(), |
| + base::Bind(&DetachToDockedWindowNextStep, |
| + test, |
| + gfx::Point(target_point.x(), 1 + target_point.y()), |
| + iteration - 1))); |
| +} |
| + |
| +} |
| + |
| +// Drags from browser to separate window, docks that window and releases mouse. |
| +IN_PROC_BROWSER_TEST_P(DetachToDockedTabDragControllerTest, |
| + DetachToDockedWindowFromMaximizedWindow) { |
| + if (!TabDragController::ShouldDetachIntoNewBrowser()) { |
| + VLOG(1) |
| + << "Skipping DetachToDockedWindowFromMaximizedWindow on this platform."; |
| + return; |
| + } |
| + |
| + // Maximize the initial browser window. |
| + browser()->window()->Maximize(); |
| + ASSERT_TRUE(browser()->window()->IsMaximized()); |
| + |
| + // Add another tab. |
| + AddTabAndResetBrowser(browser()); |
| + TabStrip* tab_strip = GetTabStripForBrowser(browser()); |
| + |
| + // Move to the first tab and drag it enough so that it detaches. |
| + gfx::Point tab_0_center( |
| + GetCenterInScreenCoordinates(tab_strip->tab_at(0))); |
| + ASSERT_TRUE(PressInput(tab_0_center)); |
| + |
| + // The following matches kMovesBeforeAdjust in snap_sizer.cc |
| + const int kNumIterations = 25 * 5 + 10; |
| + ASSERT_TRUE(DragInputToNotifyWhenDone( |
| + tab_0_center.x(), tab_0_center.y() + GetDetachY(tab_strip), |
| + base::Bind(&DetachToDockedWindowNextStep, this, |
| + gfx::Point(0, tab_0_center.y() + GetDetachY(tab_strip)), |
| + kNumIterations))); |
| + // Continue dragging enough times to go through snapping sequence and dock |
| + // the window. |
| + QuitWhenNotDragging(); |
| + // Should no longer be dragging. |
| + ASSERT_FALSE(tab_strip->IsDragSessionActive()); |
| + ASSERT_FALSE(TabDragController::IsActive()); |
| + |
| + // There should now be another browser. |
| + ASSERT_EQ(2u, native_browser_list->size()); |
| + Browser* new_browser = native_browser_list->get(1); |
| + ASSERT_TRUE(new_browser->window()->IsActive()); |
| + TabStrip* tab_strip2 = GetTabStripForBrowser(new_browser); |
| + ASSERT_FALSE(tab_strip2->IsDragSessionActive()); |
| + |
| + EXPECT_EQ("0", IDString(new_browser->tab_strip_model())); |
| + EXPECT_EQ("1", IDString(browser()->tab_strip_model())); |
| + |
| + // The bounds of the initial window should not have changed. |
| + EXPECT_TRUE(browser()->window()->IsMaximized()); |
| + |
| + EXPECT_TRUE(GetTrackedByWorkspace(browser())); |
| + EXPECT_TRUE(GetTrackedByWorkspace(new_browser)); |
| + // After this both windows should still be manageable. |
| + EXPECT_TRUE(IsWindowPositionManaged(browser()->window()->GetNativeWindow())); |
| + EXPECT_TRUE(IsWindowPositionManaged( |
| + new_browser->window()->GetNativeWindow())); |
| + |
| + // The new window should be docked and not maximized if docking is allowed. |
| + if (docked_windows_enabled()) { |
| + EXPECT_FALSE(new_browser->window()->IsMaximized()); |
| + EXPECT_EQ(ash::internal::kShellWindowId_DockedContainer, |
| + new_browser->window()->GetNativeWindow()->parent()->id()); |
| + } else { |
| + EXPECT_TRUE(new_browser->window()->IsMaximized()); |
| + EXPECT_EQ(ash::internal::kShellWindowId_DefaultContainer, |
| + new_browser->window()->GetNativeWindow()->parent()->id()); |
| + } |
| +} |
| + |
| + |
| #endif |
| #if defined(USE_ASH) && !defined(OS_WIN) // TODO(win_ash) |
| @@ -2047,6 +2152,9 @@ INSTANTIATE_TEST_CASE_P(TabDragging, |
| DetachToBrowserTabDragControllerTest, |
| ::testing::Values("mouse", "touch")); |
| INSTANTIATE_TEST_CASE_P(TabDragging, |
| + DetachToDockedTabDragControllerTest, |
| + ::testing::Values("mouse", "mouse docked")); |
| +INSTANTIATE_TEST_CASE_P(TabDragging, |
| DetachToBrowserTabDragControllerTestTouch, |
| ::testing::Values("touch", "touch docked")); |
| #else |