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

Side by Side Diff: chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest.cc

Issue 38073004: Not moving a docked window when restoring a previously maximized window (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Not moving a docked window when restoring a previously maximized window (IsDocked moved to namespac… Created 7 years, 1 month 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 | « chrome/browser/ui/views/tabs/tab_drag_controller.cc ('k') | ui/views/widget/root_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 (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 30 matching lines...) Expand all
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/test/cursor_manager_test_api.h" 49 #include "ash/test/cursor_manager_test_api.h"
50 #include "ash/wm/coordinate_conversion.h" 50 #include "ash/wm/coordinate_conversion.h"
51 #include "ash/wm/window_state.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;
59 60
60 namespace test { 61 namespace test {
(...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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 561 matching lines...) Expand 10 before | Expand all | Expand 10 after
1313 // The new window should be maximized. 1314 // The new window should be maximized.
1314 EXPECT_TRUE(new_browser->window()->IsMaximized()); 1315 EXPECT_TRUE(new_browser->window()->IsMaximized());
1315 } 1316 }
1316 1317
1317 // Subclass of DetachToBrowserTabDragControllerTest that 1318 // Subclass of DetachToBrowserTabDragControllerTest that
1318 // creates multiple displays. 1319 // creates multiple displays.
1319 class DetachToBrowserInSeparateDisplayTabDragControllerTest 1320 class DetachToBrowserInSeparateDisplayTabDragControllerTest
1320 : public DetachToBrowserTabDragControllerTest { 1321 : public DetachToBrowserTabDragControllerTest {
1321 public: 1322 public:
1322 DetachToBrowserInSeparateDisplayTabDragControllerTest() {} 1323 DetachToBrowserInSeparateDisplayTabDragControllerTest() {}
1324 virtual ~DetachToBrowserInSeparateDisplayTabDragControllerTest() {}
1323 1325
1324 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 1326 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
1325 DetachToBrowserTabDragControllerTest::SetUpCommandLine(command_line); 1327 DetachToBrowserTabDragControllerTest::SetUpCommandLine(command_line);
1326 // Make screens sufficiently wide to host 2 browsers side by side. 1328 // Make screens sufficiently wide to host 2 browsers side by side.
1327 command_line->AppendSwitchASCII("ash-host-window-bounds", 1329 command_line->AppendSwitchASCII("ash-host-window-bounds",
1328 "0+0-600x600,601+0-600x600"); 1330 "0+0-600x600,601+0-600x600");
1329 } 1331 }
1330 1332
1331 private: 1333 private:
1332 DISALLOW_COPY_AND_ASSIGN( 1334 DISALLOW_COPY_AND_ASSIGN(
1333 DetachToBrowserInSeparateDisplayTabDragControllerTest); 1335 DetachToBrowserInSeparateDisplayTabDragControllerTest);
1334 }; 1336 };
1335 1337
1336 // Subclass of DetachToBrowserTabDragControllerTest that runs tests only with 1338 // Subclass of DetachToBrowserTabDragControllerTest that runs tests only with
1337 // touch input. 1339 // touch input.
1338 class DetachToBrowserTabDragControllerTestTouch 1340 class DetachToBrowserTabDragControllerTestTouch
1339 : public DetachToBrowserTabDragControllerTest { 1341 : public DetachToBrowserTabDragControllerTest {
1340 public: 1342 public:
1341 DetachToBrowserTabDragControllerTestTouch() {} 1343 DetachToBrowserTabDragControllerTestTouch() {}
1344 virtual ~DetachToBrowserTabDragControllerTestTouch() {}
1342 1345
1343 private: 1346 private:
1344 DISALLOW_COPY_AND_ASSIGN(DetachToBrowserTabDragControllerTestTouch); 1347 DISALLOW_COPY_AND_ASSIGN(DetachToBrowserTabDragControllerTestTouch);
1345 }; 1348 };
1346 1349
1347 namespace { 1350 namespace {
1348 1351
1349 void DragSingleTabToSeparateWindowInSecondDisplayStep3( 1352 void DragSingleTabToSeparateWindowInSecondDisplayStep3(
1350 DetachToBrowserTabDragControllerTest* test) { 1353 DetachToBrowserTabDragControllerTest* test) {
1351 ASSERT_TRUE(test->ReleaseInput()); 1354 ASSERT_TRUE(test->ReleaseInput());
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
1682 // no longer be revealed. 1685 // no longer be revealed.
1683 BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser()); 1686 BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser());
1684 EXPECT_FALSE(browser_view->immersive_mode_controller()->IsEnabled()); 1687 EXPECT_FALSE(browser_view->immersive_mode_controller()->IsEnabled());
1685 1688
1686 EXPECT_TRUE(immersive_controller2->IsEnabled()); 1689 EXPECT_TRUE(immersive_controller2->IsEnabled());
1687 EXPECT_FALSE(immersive_controller2->IsRevealed()); 1690 EXPECT_FALSE(immersive_controller2->IsRevealed());
1688 EXPECT_TRUE(tab_strip2->IsImmersiveStyle()); 1691 EXPECT_TRUE(tab_strip2->IsImmersiveStyle());
1689 } 1692 }
1690 #endif // OS_CHROMEOS 1693 #endif // OS_CHROMEOS
1691 1694
1695 // Subclass of DetachToBrowserTabDragControllerTest that
1696 // creates multiple displays with different device scale factors.
1692 class DifferentDeviceScaleFactorDisplayTabDragControllerTest 1697 class DifferentDeviceScaleFactorDisplayTabDragControllerTest
1693 : public DetachToBrowserTabDragControllerTest { 1698 : public DetachToBrowserTabDragControllerTest {
1694 public: 1699 public:
1695 DifferentDeviceScaleFactorDisplayTabDragControllerTest() {} 1700 DifferentDeviceScaleFactorDisplayTabDragControllerTest() {}
1701 virtual ~DifferentDeviceScaleFactorDisplayTabDragControllerTest() {}
1696 1702
1697 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 1703 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
1698 DetachToBrowserTabDragControllerTest::SetUpCommandLine(command_line); 1704 DetachToBrowserTabDragControllerTest::SetUpCommandLine(command_line);
1699 command_line->AppendSwitchASCII("ash-host-window-bounds", 1705 command_line->AppendSwitchASCII("ash-host-window-bounds",
1700 "400x400,0+400-800x800*2"); 1706 "400x400,0+400-800x800*2");
1701 } 1707 }
1702 1708
1703 float GetCursorDeviceScaleFactor() const { 1709 float GetCursorDeviceScaleFactor() const {
1704 ash::test::CursorManagerTestApi cursor_test_api( 1710 ash::test::CursorManagerTestApi cursor_test_api(
1705 ash::Shell::GetInstance()->cursor_manager()); 1711 ash::Shell::GetInstance()->cursor_manager());
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
2027 // There should now be another browser. 2033 // There should now be another browser.
2028 ASSERT_EQ(2u, native_browser_list->size()); 2034 ASSERT_EQ(2u, native_browser_list->size());
2029 Browser* new_browser = native_browser_list->get(1); 2035 Browser* new_browser = native_browser_list->get(1);
2030 ASSERT_TRUE(new_browser->window()->IsActive()); 2036 ASSERT_TRUE(new_browser->window()->IsActive());
2031 // The sequence of drags should successfully move the browser window. 2037 // The sequence of drags should successfully move the browser window.
2032 bounds += gfx::Vector2d(5 - 2, 1 + 1 + GetDetachY(tab_strip)); 2038 bounds += gfx::Vector2d(5 - 2, 1 + 1 + GetDetachY(tab_strip));
2033 EXPECT_EQ(bounds.ToString(), 2039 EXPECT_EQ(bounds.ToString(),
2034 new_browser->window()->GetNativeWindow()->bounds().ToString()); 2040 new_browser->window()->GetNativeWindow()->bounds().ToString());
2035 } 2041 }
2036 2042
2043 // Subclass of DetachToBrowserTabDragControllerTest that runs tests with
2044 // docked windows enabled and disabled.
2045 class DetachToDockedTabDragControllerTest
2046 : public DetachToBrowserTabDragControllerTest {
2047 public:
2048 DetachToDockedTabDragControllerTest() {}
2049 virtual ~DetachToDockedTabDragControllerTest() {}
2050
2051 private:
2052 DISALLOW_COPY_AND_ASSIGN(DetachToDockedTabDragControllerTest);
2053 };
2054
2055 namespace {
2056
2057 void DetachToDockedWindowNextStep(
2058 DetachToDockedTabDragControllerTest* test,
2059 const gfx::Point& target_point,
2060 int iteration) {
2061 ASSERT_EQ(2u, test->native_browser_list->size());
2062 Browser* new_browser = test->native_browser_list->get(1);
2063 ASSERT_TRUE(new_browser->window()->IsActive());
2064
2065 if (!iteration) {
2066 ASSERT_TRUE(test->ReleaseInput());
2067 return;
2068 }
2069 ASSERT_TRUE(test->DragInputToNotifyWhenDone(
2070 target_point.x(), target_point.y(),
2071 base::Bind(&DetachToDockedWindowNextStep,
2072 test,
2073 gfx::Point(target_point.x(), 1 + target_point.y()),
2074 iteration - 1)));
2075 }
2076
2077 } // namespace
2078
2079 // Drags from browser to separate window, docks that window and releases mouse.
2080 IN_PROC_BROWSER_TEST_P(DetachToDockedTabDragControllerTest,
2081 DetachToDockedWindowFromMaximizedWindow) {
2082 if (!TabDragController::ShouldDetachIntoNewBrowser()) {
2083 VLOG(1)
2084 << "Skipping DetachToDockedWindowFromMaximizedWindow on this platform.";
2085 return;
2086 }
2087
2088 // Maximize the initial browser window.
2089 browser()->window()->Maximize();
2090 ASSERT_TRUE(browser()->window()->IsMaximized());
2091
2092 // Add another tab.
2093 AddTabAndResetBrowser(browser());
2094 TabStrip* tab_strip = GetTabStripForBrowser(browser());
2095
2096 // Move to the first tab and drag it enough so that it detaches.
2097 gfx::Point tab_0_center(
2098 GetCenterInScreenCoordinates(tab_strip->tab_at(0)));
2099 ASSERT_TRUE(PressInput(tab_0_center));
2100
2101 // The following matches kMovesBeforeAdjust in snap_sizer.cc
2102 const int kNumIterations = 25 * 5 + 10;
2103 ASSERT_TRUE(DragInputToNotifyWhenDone(
2104 tab_0_center.x(), tab_0_center.y() + GetDetachY(tab_strip),
2105 base::Bind(&DetachToDockedWindowNextStep, this,
2106 gfx::Point(0, tab_0_center.y() + GetDetachY(tab_strip)),
2107 kNumIterations)));
2108 // Continue dragging enough times to go through snapping sequence and dock
2109 // the window.
2110 QuitWhenNotDragging();
2111 // Should no longer be dragging.
2112 ASSERT_FALSE(tab_strip->IsDragSessionActive());
2113 ASSERT_FALSE(TabDragController::IsActive());
2114
2115 // There should now be another browser.
2116 ASSERT_EQ(2u, native_browser_list->size());
2117 Browser* new_browser = native_browser_list->get(1);
2118 ASSERT_TRUE(new_browser->window()->IsActive());
2119 TabStrip* tab_strip2 = GetTabStripForBrowser(new_browser);
2120 ASSERT_FALSE(tab_strip2->IsDragSessionActive());
2121
2122 EXPECT_EQ("0", IDString(new_browser->tab_strip_model()));
2123 EXPECT_EQ("1", IDString(browser()->tab_strip_model()));
2124
2125 // The bounds of the initial window should not have changed.
2126 EXPECT_TRUE(browser()->window()->IsMaximized());
2127
2128 EXPECT_TRUE(GetTrackedByWorkspace(browser()));
2129 EXPECT_TRUE(GetTrackedByWorkspace(new_browser));
2130 // After this both windows should still be manageable.
2131 EXPECT_TRUE(IsWindowPositionManaged(browser()->window()->GetNativeWindow()));
2132 EXPECT_TRUE(IsWindowPositionManaged(
2133 new_browser->window()->GetNativeWindow()));
2134
2135 // The new window should be docked and not maximized if docking is allowed.
2136 ash::wm::WindowState* window_state =
2137 ash::wm::GetWindowState(new_browser->window()->GetNativeWindow());
2138 if (docked_windows_enabled()) {
2139 EXPECT_FALSE(new_browser->window()->IsMaximized());
2140 EXPECT_TRUE(window_state->IsDocked());
2141 } else {
2142 EXPECT_TRUE(new_browser->window()->IsMaximized());
2143 EXPECT_FALSE(window_state->IsDocked());
2144 }
2145 }
2146
2147
2037 #endif 2148 #endif
2038 2149
2039 #if defined(USE_ASH) && !defined(OS_WIN) // TODO(win_ash) 2150 #if defined(USE_ASH) && !defined(OS_WIN) // TODO(win_ash)
2040 INSTANTIATE_TEST_CASE_P(TabDragging, 2151 INSTANTIATE_TEST_CASE_P(TabDragging,
2041 DetachToBrowserInSeparateDisplayTabDragControllerTest, 2152 DetachToBrowserInSeparateDisplayTabDragControllerTest,
2042 ::testing::Values("mouse", "touch")); 2153 ::testing::Values("mouse", "touch"));
2043 INSTANTIATE_TEST_CASE_P(TabDragging, 2154 INSTANTIATE_TEST_CASE_P(TabDragging,
2044 DifferentDeviceScaleFactorDisplayTabDragControllerTest, 2155 DifferentDeviceScaleFactorDisplayTabDragControllerTest,
2045 ::testing::Values("mouse")); 2156 ::testing::Values("mouse"));
2046 INSTANTIATE_TEST_CASE_P(TabDragging, 2157 INSTANTIATE_TEST_CASE_P(TabDragging,
2047 DetachToBrowserTabDragControllerTest, 2158 DetachToBrowserTabDragControllerTest,
2048 ::testing::Values("mouse", "touch")); 2159 ::testing::Values("mouse", "touch"));
2049 INSTANTIATE_TEST_CASE_P(TabDragging, 2160 INSTANTIATE_TEST_CASE_P(TabDragging,
2161 DetachToDockedTabDragControllerTest,
2162 ::testing::Values("mouse", "mouse docked"));
2163 INSTANTIATE_TEST_CASE_P(TabDragging,
2050 DetachToBrowserTabDragControllerTestTouch, 2164 DetachToBrowserTabDragControllerTestTouch,
2051 ::testing::Values("touch", "touch docked")); 2165 ::testing::Values("touch", "touch docked"));
2052 #else 2166 #else
2053 INSTANTIATE_TEST_CASE_P(TabDragging, 2167 INSTANTIATE_TEST_CASE_P(TabDragging,
2054 DetachToBrowserTabDragControllerTest, 2168 DetachToBrowserTabDragControllerTest,
2055 ::testing::Values("mouse")); 2169 ::testing::Values("mouse"));
2056 #endif 2170 #endif
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/tabs/tab_drag_controller.cc ('k') | ui/views/widget/root_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698