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/window_state.h" | 7 #include "ash/wm/window_state.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 28 matching lines...) Expand all Loading... | |
39 #if defined(USE_AURA) && !defined(OS_CHROMEOS) | 39 #if defined(USE_AURA) && !defined(OS_CHROMEOS) |
40 #include "chrome/browser/ui/views/frame/desktop_browser_frame_aura.h" | 40 #include "chrome/browser/ui/views/frame/desktop_browser_frame_aura.h" |
41 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" | 41 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" |
42 #endif | 42 #endif |
43 | 43 |
44 #if defined(USE_ASH) | 44 #if defined(USE_ASH) |
45 #include "ash/ash_switches.h" | 45 #include "ash/ash_switches.h" |
46 #include "ash/display/display_controller.h" | 46 #include "ash/display/display_controller.h" |
47 #include "ash/display/display_manager.h" | 47 #include "ash/display/display_manager.h" |
48 #include "ash/shell.h" | 48 #include "ash/shell.h" |
49 #include "ash/shell_window_ids.h" | |
49 #include "ash/test/cursor_manager_test_api.h" | 50 #include "ash/test/cursor_manager_test_api.h" |
50 #include "ash/wm/coordinate_conversion.h" | 51 #include "ash/wm/coordinate_conversion.h" |
51 #include "ash/wm/window_util.h" | 52 #include "ash/wm/window_util.h" |
52 #include "chrome/browser/ui/views/frame/immersive_mode_controller_ash.h" | 53 #include "chrome/browser/ui/views/frame/immersive_mode_controller_ash.h" |
53 #include "ui/aura/client/screen_position_client.h" | 54 #include "ui/aura/client/screen_position_client.h" |
54 #include "ui/aura/root_window.h" | 55 #include "ui/aura/root_window.h" |
55 #include "ui/aura/test/event_generator.h" | 56 #include "ui/aura/test/event_generator.h" |
56 #endif | 57 #endif |
57 | 58 |
58 using content::WebContents; | 59 using content::WebContents; |
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
673 | 674 |
674 EXPECT_EQ("0", IDString(new_browser->tab_strip_model())); | 675 EXPECT_EQ("0", IDString(new_browser->tab_strip_model())); |
675 EXPECT_EQ("1", IDString(browser()->tab_strip_model())); | 676 EXPECT_EQ("1", IDString(browser()->tab_strip_model())); |
676 | 677 |
677 // The bounds of the initial window should not have changed. | 678 // The bounds of the initial window should not have changed. |
678 EXPECT_EQ(initial_bounds.ToString(), | 679 EXPECT_EQ(initial_bounds.ToString(), |
679 browser()->window()->GetBounds().ToString()); | 680 browser()->window()->GetBounds().ToString()); |
680 | 681 |
681 EXPECT_TRUE(GetTrackedByWorkspace(browser())); | 682 EXPECT_TRUE(GetTrackedByWorkspace(browser())); |
682 EXPECT_TRUE(GetTrackedByWorkspace(new_browser)); | 683 EXPECT_TRUE(GetTrackedByWorkspace(new_browser)); |
683 // After this both windows should still be managable. | 684 // After this both windows should still be manageable. |
684 EXPECT_TRUE(IsWindowPositionManaged(browser()->window()->GetNativeWindow())); | 685 EXPECT_TRUE(IsWindowPositionManaged(browser()->window()->GetNativeWindow())); |
685 EXPECT_TRUE(IsWindowPositionManaged( | 686 EXPECT_TRUE(IsWindowPositionManaged( |
686 new_browser->window()->GetNativeWindow())); | 687 new_browser->window()->GetNativeWindow())); |
687 | 688 |
688 // Both windows should not be maximized | 689 // Both windows should not be maximized |
689 EXPECT_FALSE(browser()->window()->IsMaximized()); | 690 EXPECT_FALSE(browser()->window()->IsMaximized()); |
690 EXPECT_FALSE(new_browser->window()->IsMaximized()); | 691 EXPECT_FALSE(new_browser->window()->IsMaximized()); |
691 } | 692 } |
692 | 693 |
693 // Drags from browser to separate window and releases mouse. | 694 // Drags from browser to separate window and releases mouse. |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
731 ASSERT_FALSE(tab_strip2->IsDragSessionActive()); | 732 ASSERT_FALSE(tab_strip2->IsDragSessionActive()); |
732 | 733 |
733 EXPECT_EQ("0", IDString(new_browser->tab_strip_model())); | 734 EXPECT_EQ("0", IDString(new_browser->tab_strip_model())); |
734 EXPECT_EQ("1", IDString(browser()->tab_strip_model())); | 735 EXPECT_EQ("1", IDString(browser()->tab_strip_model())); |
735 | 736 |
736 // The bounds of the initial window should not have changed. | 737 // The bounds of the initial window should not have changed. |
737 EXPECT_TRUE(browser()->window()->IsMaximized()); | 738 EXPECT_TRUE(browser()->window()->IsMaximized()); |
738 | 739 |
739 EXPECT_TRUE(GetTrackedByWorkspace(browser())); | 740 EXPECT_TRUE(GetTrackedByWorkspace(browser())); |
740 EXPECT_TRUE(GetTrackedByWorkspace(new_browser)); | 741 EXPECT_TRUE(GetTrackedByWorkspace(new_browser)); |
741 // After this both windows should still be managable. | 742 // After this both windows should still be manageable. |
742 EXPECT_TRUE(IsWindowPositionManaged(browser()->window()->GetNativeWindow())); | 743 EXPECT_TRUE(IsWindowPositionManaged(browser()->window()->GetNativeWindow())); |
743 EXPECT_TRUE(IsWindowPositionManaged( | 744 EXPECT_TRUE(IsWindowPositionManaged( |
744 new_browser->window()->GetNativeWindow())); | 745 new_browser->window()->GetNativeWindow())); |
745 | 746 |
746 // The new window should be maximized. | 747 // The new window should be maximized. |
747 EXPECT_TRUE(new_browser->window()->IsMaximized()); | 748 EXPECT_TRUE(new_browser->window()->IsMaximized()); |
748 } | 749 } |
749 | 750 |
750 // Deletes a tab being dragged before the user moved enough to start a drag. | 751 // Deletes a tab being dragged before the user moved enough to start a drag. |
751 IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest, | 752 IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest, |
(...skipping 1275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2027 // There should now be another browser. | 2028 // There should now be another browser. |
2028 ASSERT_EQ(2u, native_browser_list->size()); | 2029 ASSERT_EQ(2u, native_browser_list->size()); |
2029 Browser* new_browser = native_browser_list->get(1); | 2030 Browser* new_browser = native_browser_list->get(1); |
2030 ASSERT_TRUE(new_browser->window()->IsActive()); | 2031 ASSERT_TRUE(new_browser->window()->IsActive()); |
2031 // The sequence of drags should successfully move the browser window. | 2032 // The sequence of drags should successfully move the browser window. |
2032 bounds += gfx::Vector2d(5 - 2, 1 + 1 + GetDetachY(tab_strip)); | 2033 bounds += gfx::Vector2d(5 - 2, 1 + 1 + GetDetachY(tab_strip)); |
2033 EXPECT_EQ(bounds.ToString(), | 2034 EXPECT_EQ(bounds.ToString(), |
2034 new_browser->window()->GetNativeWindow()->bounds().ToString()); | 2035 new_browser->window()->GetNativeWindow()->bounds().ToString()); |
2035 } | 2036 } |
2036 | 2037 |
2038 // Subclass of DetachToBrowserTabDragControllerTest that runs tests with | |
2039 // docked windows enabled and disabled. | |
2040 class DetachToDockedTabDragControllerTest | |
2041 : public DetachToBrowserTabDragControllerTest { | |
2042 public: | |
2043 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
| |
2044 | |
2045 private: | |
2046 DISALLOW_COPY_AND_ASSIGN(DetachToDockedTabDragControllerTest); | |
2047 }; | |
2048 | |
2049 namespace { | |
2050 | |
2051 void DetachToDockedWindowNextStep( | |
2052 DetachToDockedTabDragControllerTest* test, | |
2053 const gfx::Point& target_point, | |
2054 int iteration) { | |
2055 ASSERT_EQ(2u, test->native_browser_list->size()); | |
2056 Browser* new_browser = test->native_browser_list->get(1); | |
2057 ASSERT_TRUE(new_browser->window()->IsActive()); | |
2058 | |
2059 if (!iteration) { | |
2060 ASSERT_TRUE(test->ReleaseInput()); | |
2061 return; | |
2062 } | |
2063 ASSERT_TRUE(test->DragInputToNotifyWhenDone( | |
2064 target_point.x(), target_point.y(), | |
2065 base::Bind(&DetachToDockedWindowNextStep, | |
2066 test, | |
2067 gfx::Point(target_point.x(), 1 + target_point.y()), | |
2068 iteration - 1))); | |
2069 } | |
2070 | |
2071 } | |
2072 | |
2073 // Drags from browser to separate window, docks that window and releases mouse. | |
2074 IN_PROC_BROWSER_TEST_P(DetachToDockedTabDragControllerTest, | |
2075 DetachToDockedWindowFromMaximizedWindow) { | |
2076 if (!TabDragController::ShouldDetachIntoNewBrowser()) { | |
2077 VLOG(1) | |
2078 << "Skipping DetachToDockedWindowFromMaximizedWindow on this platform."; | |
2079 return; | |
2080 } | |
2081 | |
2082 // Maximize the initial browser window. | |
2083 browser()->window()->Maximize(); | |
2084 ASSERT_TRUE(browser()->window()->IsMaximized()); | |
2085 | |
2086 // Add another tab. | |
2087 AddTabAndResetBrowser(browser()); | |
2088 TabStrip* tab_strip = GetTabStripForBrowser(browser()); | |
2089 | |
2090 // Move to the first tab and drag it enough so that it detaches. | |
2091 gfx::Point tab_0_center( | |
2092 GetCenterInScreenCoordinates(tab_strip->tab_at(0))); | |
2093 ASSERT_TRUE(PressInput(tab_0_center)); | |
2094 | |
2095 // The following matches kMovesBeforeAdjust in snap_sizer.cc | |
2096 const int kNumIterations = 25 * 5 + 10; | |
2097 ASSERT_TRUE(DragInputToNotifyWhenDone( | |
2098 tab_0_center.x(), tab_0_center.y() + GetDetachY(tab_strip), | |
2099 base::Bind(&DetachToDockedWindowNextStep, this, | |
2100 gfx::Point(0, tab_0_center.y() + GetDetachY(tab_strip)), | |
2101 kNumIterations))); | |
2102 // Continue dragging enough times to go through snapping sequence and dock | |
2103 // the window. | |
2104 QuitWhenNotDragging(); | |
2105 // Should no longer be dragging. | |
2106 ASSERT_FALSE(tab_strip->IsDragSessionActive()); | |
2107 ASSERT_FALSE(TabDragController::IsActive()); | |
2108 | |
2109 // There should now be another browser. | |
2110 ASSERT_EQ(2u, native_browser_list->size()); | |
2111 Browser* new_browser = native_browser_list->get(1); | |
2112 ASSERT_TRUE(new_browser->window()->IsActive()); | |
2113 TabStrip* tab_strip2 = GetTabStripForBrowser(new_browser); | |
2114 ASSERT_FALSE(tab_strip2->IsDragSessionActive()); | |
2115 | |
2116 EXPECT_EQ("0", IDString(new_browser->tab_strip_model())); | |
2117 EXPECT_EQ("1", IDString(browser()->tab_strip_model())); | |
2118 | |
2119 // The bounds of the initial window should not have changed. | |
2120 EXPECT_TRUE(browser()->window()->IsMaximized()); | |
2121 | |
2122 EXPECT_TRUE(GetTrackedByWorkspace(browser())); | |
2123 EXPECT_TRUE(GetTrackedByWorkspace(new_browser)); | |
2124 // After this both windows should still be manageable. | |
2125 EXPECT_TRUE(IsWindowPositionManaged(browser()->window()->GetNativeWindow())); | |
2126 EXPECT_TRUE(IsWindowPositionManaged( | |
2127 new_browser->window()->GetNativeWindow())); | |
2128 | |
2129 // The new window should be docked and not maximized if docking is allowed. | |
2130 if (docked_windows_enabled()) { | |
2131 EXPECT_FALSE(new_browser->window()->IsMaximized()); | |
2132 EXPECT_EQ(ash::internal::kShellWindowId_DockedContainer, | |
2133 new_browser->window()->GetNativeWindow()->parent()->id()); | |
2134 } else { | |
2135 EXPECT_TRUE(new_browser->window()->IsMaximized()); | |
2136 EXPECT_EQ(ash::internal::kShellWindowId_DefaultContainer, | |
2137 new_browser->window()->GetNativeWindow()->parent()->id()); | |
2138 } | |
2139 } | |
2140 | |
2141 | |
2037 #endif | 2142 #endif |
2038 | 2143 |
2039 #if defined(USE_ASH) && !defined(OS_WIN) // TODO(win_ash) | 2144 #if defined(USE_ASH) && !defined(OS_WIN) // TODO(win_ash) |
2040 INSTANTIATE_TEST_CASE_P(TabDragging, | 2145 INSTANTIATE_TEST_CASE_P(TabDragging, |
2041 DetachToBrowserInSeparateDisplayTabDragControllerTest, | 2146 DetachToBrowserInSeparateDisplayTabDragControllerTest, |
2042 ::testing::Values("mouse", "touch")); | 2147 ::testing::Values("mouse", "touch")); |
2043 INSTANTIATE_TEST_CASE_P(TabDragging, | 2148 INSTANTIATE_TEST_CASE_P(TabDragging, |
2044 DifferentDeviceScaleFactorDisplayTabDragControllerTest, | 2149 DifferentDeviceScaleFactorDisplayTabDragControllerTest, |
2045 ::testing::Values("mouse")); | 2150 ::testing::Values("mouse")); |
2046 INSTANTIATE_TEST_CASE_P(TabDragging, | 2151 INSTANTIATE_TEST_CASE_P(TabDragging, |
2047 DetachToBrowserTabDragControllerTest, | 2152 DetachToBrowserTabDragControllerTest, |
2048 ::testing::Values("mouse", "touch")); | 2153 ::testing::Values("mouse", "touch")); |
2049 INSTANTIATE_TEST_CASE_P(TabDragging, | 2154 INSTANTIATE_TEST_CASE_P(TabDragging, |
2155 DetachToDockedTabDragControllerTest, | |
2156 ::testing::Values("mouse", "mouse docked")); | |
2157 INSTANTIATE_TEST_CASE_P(TabDragging, | |
2050 DetachToBrowserTabDragControllerTestTouch, | 2158 DetachToBrowserTabDragControllerTestTouch, |
2051 ::testing::Values("touch", "touch docked")); | 2159 ::testing::Values("touch", "touch docked")); |
2052 #else | 2160 #else |
2053 INSTANTIATE_TEST_CASE_P(TabDragging, | 2161 INSTANTIATE_TEST_CASE_P(TabDragging, |
2054 DetachToBrowserTabDragControllerTest, | 2162 DetachToBrowserTabDragControllerTest, |
2055 ::testing::Values("mouse")); | 2163 ::testing::Values("mouse")); |
2056 #endif | 2164 #endif |
OLD | NEW |