| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 StopAnimating(GetTabStripForBrowser(browser)); | 181 StopAnimating(GetTabStripForBrowser(browser)); |
| 182 ResetIDs(browser->tab_strip_model(), 0); | 182 ResetIDs(browser->tab_strip_model(), 0); |
| 183 } | 183 } |
| 184 | 184 |
| 185 Browser* TabDragControllerTest::CreateAnotherWindowBrowserAndRelayout() { | 185 Browser* TabDragControllerTest::CreateAnotherWindowBrowserAndRelayout() { |
| 186 // Create another browser. | 186 // Create another browser. |
| 187 Browser* browser2 = CreateBrowser(browser()->profile()); | 187 Browser* browser2 = CreateBrowser(browser()->profile()); |
| 188 ResetIDs(browser2->tab_strip_model(), 100); | 188 ResetIDs(browser2->tab_strip_model(), 100); |
| 189 | 189 |
| 190 // Resize the two windows so they're right next to each other. | 190 // Resize the two windows so they're right next to each other. |
| 191 gfx::Rect work_area = gfx::Screen::GetNativeScreen()->GetDisplayNearestWindow( | 191 gfx::Rect work_area = |
| 192 browser()->window()->GetNativeWindow()).work_area(); | 192 gfx::Screen::GetScreen() |
| 193 ->GetDisplayNearestWindow(browser()->window()->GetNativeWindow()) |
| 194 .work_area(); |
| 193 gfx::Size half_size = | 195 gfx::Size half_size = |
| 194 gfx::Size(work_area.width() / 3 - 10, work_area.height() / 2 - 10); | 196 gfx::Size(work_area.width() / 3 - 10, work_area.height() / 2 - 10); |
| 195 browser()->window()->SetBounds(gfx::Rect(work_area.origin(), half_size)); | 197 browser()->window()->SetBounds(gfx::Rect(work_area.origin(), half_size)); |
| 196 browser2->window()->SetBounds(gfx::Rect( | 198 browser2->window()->SetBounds(gfx::Rect( |
| 197 work_area.x() + half_size.width(), work_area.y(), | 199 work_area.x() + half_size.width(), work_area.y(), |
| 198 half_size.width(), half_size.height())); | 200 half_size.width(), half_size.height())); |
| 199 return browser2; | 201 return browser2; |
| 200 } | 202 } |
| 201 | 203 |
| 202 namespace { | 204 namespace { |
| (...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 801 #define MAYBE_DetachFromFullsizeWindow DISABLED_DetachFromFullsizeWindow | 803 #define MAYBE_DetachFromFullsizeWindow DISABLED_DetachFromFullsizeWindow |
| 802 #else | 804 #else |
| 803 #define MAYBE_DetachFromFullsizeWindow DetachFromFullsizeWindow | 805 #define MAYBE_DetachFromFullsizeWindow DetachFromFullsizeWindow |
| 804 #endif | 806 #endif |
| 805 // Tests that a tab can be dragged from a browser window that is resized to full | 807 // Tests that a tab can be dragged from a browser window that is resized to full |
| 806 // screen. | 808 // screen. |
| 807 IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest, | 809 IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest, |
| 808 MAYBE_DetachFromFullsizeWindow) { | 810 MAYBE_DetachFromFullsizeWindow) { |
| 809 // Resize the browser window so that it is as big as the work area. | 811 // Resize the browser window so that it is as big as the work area. |
| 810 gfx::Rect work_area = | 812 gfx::Rect work_area = |
| 811 gfx::Screen::GetNativeScreen() | 813 gfx::Screen::GetScreen() |
| 812 ->GetDisplayNearestWindow(browser()->window()->GetNativeWindow()) | 814 ->GetDisplayNearestWindow(browser()->window()->GetNativeWindow()) |
| 813 .work_area(); | 815 .work_area(); |
| 814 browser()->window()->SetBounds(work_area); | 816 browser()->window()->SetBounds(work_area); |
| 815 const gfx::Rect initial_bounds(browser()->window()->GetBounds()); | 817 const gfx::Rect initial_bounds(browser()->window()->GetBounds()); |
| 816 // Add another tab. | 818 // Add another tab. |
| 817 AddTabAndResetBrowser(browser()); | 819 AddTabAndResetBrowser(browser()); |
| 818 TabStrip* tab_strip = GetTabStripForBrowser(browser()); | 820 TabStrip* tab_strip = GetTabStripForBrowser(browser()); |
| 819 | 821 |
| 820 // Move to the first tab and drag it enough so that it detaches. | 822 // Move to the first tab and drag it enough so that it detaches. |
| 821 gfx::Point tab_0_center(GetCenterInScreenCoordinates(tab_strip->tab_at(0))); | 823 gfx::Point tab_0_center(GetCenterInScreenCoordinates(tab_strip->tab_at(0))); |
| (...skipping 889 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1711 | 1713 |
| 1712 // Create another browser. | 1714 // Create another browser. |
| 1713 Browser* browser2 = CreateBrowser(browser()->profile()); | 1715 Browser* browser2 = CreateBrowser(browser()->profile()); |
| 1714 TabStrip* tab_strip2 = GetTabStripForBrowser(browser2); | 1716 TabStrip* tab_strip2 = GetTabStripForBrowser(browser2); |
| 1715 ResetIDs(browser2->tab_strip_model(), 100); | 1717 ResetIDs(browser2->tab_strip_model(), 100); |
| 1716 | 1718 |
| 1717 // Move the second browser to the second display. | 1719 // Move the second browser to the second display. |
| 1718 aura::Window::Windows roots = ash::Shell::GetAllRootWindows(); | 1720 aura::Window::Windows roots = ash::Shell::GetAllRootWindows(); |
| 1719 ASSERT_EQ(2u, roots.size()); | 1721 ASSERT_EQ(2u, roots.size()); |
| 1720 aura::Window* second_root = roots[1]; | 1722 aura::Window* second_root = roots[1]; |
| 1721 gfx::Rect work_area = gfx::Screen::GetNativeScreen()->GetDisplayNearestWindow( | 1723 gfx::Rect work_area = gfx::Screen::GetScreen() |
| 1722 second_root).work_area(); | 1724 ->GetDisplayNearestWindow(second_root) |
| 1725 .work_area(); |
| 1723 browser2->window()->SetBounds(work_area); | 1726 browser2->window()->SetBounds(work_area); |
| 1724 EXPECT_EQ(second_root, | 1727 EXPECT_EQ(second_root, |
| 1725 browser2->window()->GetNativeWindow()->GetRootWindow()); | 1728 browser2->window()->GetNativeWindow()->GetRootWindow()); |
| 1726 | 1729 |
| 1727 // Move to the first tab and drag it enough so that it detaches, but not | 1730 // Move to the first tab and drag it enough so that it detaches, but not |
| 1728 // enough that it attaches to browser2. | 1731 // enough that it attaches to browser2. |
| 1729 gfx::Point tab_0_center(GetCenterInScreenCoordinates(tab_strip->tab_at(0))); | 1732 gfx::Point tab_0_center(GetCenterInScreenCoordinates(tab_strip->tab_at(0))); |
| 1730 ASSERT_TRUE(PressInput(tab_0_center)); | 1733 ASSERT_TRUE(PressInput(tab_0_center)); |
| 1731 ASSERT_TRUE(DragInputToNotifyWhenDone( | 1734 ASSERT_TRUE(DragInputToNotifyWhenDone( |
| 1732 tab_0_center.x(), tab_0_center.y() + GetDetachY(tab_strip), | 1735 tab_0_center.x(), tab_0_center.y() + GetDetachY(tab_strip), |
| (...skipping 28 matching lines...) Expand all Loading... |
| 1761 | 1764 |
| 1762 // Create another browser. | 1765 // Create another browser. |
| 1763 Browser* browser2 = CreateBrowser(browser()->profile()); | 1766 Browser* browser2 = CreateBrowser(browser()->profile()); |
| 1764 TabStrip* tab_strip2 = GetTabStripForBrowser(browser2); | 1767 TabStrip* tab_strip2 = GetTabStripForBrowser(browser2); |
| 1765 ResetIDs(browser2->tab_strip_model(), 100); | 1768 ResetIDs(browser2->tab_strip_model(), 100); |
| 1766 | 1769 |
| 1767 // Move both browsers to the second display. | 1770 // Move both browsers to the second display. |
| 1768 aura::Window::Windows roots = ash::Shell::GetAllRootWindows(); | 1771 aura::Window::Windows roots = ash::Shell::GetAllRootWindows(); |
| 1769 ASSERT_EQ(2u, roots.size()); | 1772 ASSERT_EQ(2u, roots.size()); |
| 1770 aura::Window* second_root = roots[1]; | 1773 aura::Window* second_root = roots[1]; |
| 1771 gfx::Rect work_area = gfx::Screen::GetNativeScreen()->GetDisplayNearestWindow( | 1774 gfx::Rect work_area = gfx::Screen::GetScreen() |
| 1772 second_root).work_area(); | 1775 ->GetDisplayNearestWindow(second_root) |
| 1776 .work_area(); |
| 1773 browser()->window()->SetBounds(work_area); | 1777 browser()->window()->SetBounds(work_area); |
| 1774 | 1778 |
| 1775 // position both browser windows side by side on the second screen. | 1779 // position both browser windows side by side on the second screen. |
| 1776 gfx::Rect work_area2(work_area); | 1780 gfx::Rect work_area2(work_area); |
| 1777 work_area.set_width(work_area.width()/2); | 1781 work_area.set_width(work_area.width()/2); |
| 1778 browser()->window()->SetBounds(work_area); | 1782 browser()->window()->SetBounds(work_area); |
| 1779 work_area2.set_x(work_area2.x() + work_area2.width()/2); | 1783 work_area2.set_x(work_area2.x() + work_area2.width()/2); |
| 1780 work_area2.set_width(work_area2.width()/2); | 1784 work_area2.set_width(work_area2.width()/2); |
| 1781 browser2->window()->SetBounds(work_area2); | 1785 browser2->window()->SetBounds(work_area2); |
| 1782 EXPECT_EQ(second_root, | 1786 EXPECT_EQ(second_root, |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1821 // Add another tab. | 1825 // Add another tab. |
| 1822 AddTabAndResetBrowser(browser()); | 1826 AddTabAndResetBrowser(browser()); |
| 1823 browser()->window()->Maximize(); | 1827 browser()->window()->Maximize(); |
| 1824 TabStrip* tab_strip = GetTabStripForBrowser(browser()); | 1828 TabStrip* tab_strip = GetTabStripForBrowser(browser()); |
| 1825 | 1829 |
| 1826 // Create another browser on the second display. | 1830 // Create another browser on the second display. |
| 1827 aura::Window::Windows roots = ash::Shell::GetAllRootWindows(); | 1831 aura::Window::Windows roots = ash::Shell::GetAllRootWindows(); |
| 1828 ASSERT_EQ(2u, roots.size()); | 1832 ASSERT_EQ(2u, roots.size()); |
| 1829 aura::Window* first_root = roots[0]; | 1833 aura::Window* first_root = roots[0]; |
| 1830 aura::Window* second_root = roots[1]; | 1834 aura::Window* second_root = roots[1]; |
| 1831 gfx::Rect work_area = gfx::Screen::GetNativeScreen()->GetDisplayNearestWindow( | 1835 gfx::Rect work_area = gfx::Screen::GetScreen() |
| 1832 second_root).work_area(); | 1836 ->GetDisplayNearestWindow(second_root) |
| 1837 .work_area(); |
| 1833 work_area.Inset(20, 20, 20, 60); | 1838 work_area.Inset(20, 20, 20, 60); |
| 1834 Browser::CreateParams params(browser()->profile(), | 1839 Browser::CreateParams params(browser()->profile(), |
| 1835 browser()->host_desktop_type()); | 1840 browser()->host_desktop_type()); |
| 1836 params.initial_show_state = ui::SHOW_STATE_NORMAL; | 1841 params.initial_show_state = ui::SHOW_STATE_NORMAL; |
| 1837 params.initial_bounds = work_area; | 1842 params.initial_bounds = work_area; |
| 1838 Browser* browser2 = new Browser(params); | 1843 Browser* browser2 = new Browser(params); |
| 1839 AddBlankTabAndShow(browser2); | 1844 AddBlankTabAndShow(browser2); |
| 1840 | 1845 |
| 1841 TabStrip* tab_strip2 = GetTabStripForBrowser(browser2); | 1846 TabStrip* tab_strip2 = GetTabStripForBrowser(browser2); |
| 1842 ResetIDs(browser2->tab_strip_model(), 100); | 1847 ResetIDs(browser2->tab_strip_model(), 100); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1891 | 1896 |
| 1892 // Create another browser. | 1897 // Create another browser. |
| 1893 Browser* browser2 = CreateBrowser(browser()->profile()); | 1898 Browser* browser2 = CreateBrowser(browser()->profile()); |
| 1894 TabStrip* tab_strip2 = GetTabStripForBrowser(browser2); | 1899 TabStrip* tab_strip2 = GetTabStripForBrowser(browser2); |
| 1895 ResetIDs(browser2->tab_strip_model(), 100); | 1900 ResetIDs(browser2->tab_strip_model(), 100); |
| 1896 | 1901 |
| 1897 // Move the second browser to the second display. | 1902 // Move the second browser to the second display. |
| 1898 aura::Window::Windows roots = ash::Shell::GetAllRootWindows(); | 1903 aura::Window::Windows roots = ash::Shell::GetAllRootWindows(); |
| 1899 ASSERT_EQ(2u, roots.size()); | 1904 ASSERT_EQ(2u, roots.size()); |
| 1900 aura::Window* second_root = roots[1]; | 1905 aura::Window* second_root = roots[1]; |
| 1901 gfx::Rect work_area = gfx::Screen::GetNativeScreen()->GetDisplayNearestWindow( | 1906 gfx::Rect work_area = gfx::Screen::GetScreen() |
| 1902 second_root).work_area(); | 1907 ->GetDisplayNearestWindow(second_root) |
| 1908 .work_area(); |
| 1903 browser2->window()->SetBounds(work_area); | 1909 browser2->window()->SetBounds(work_area); |
| 1904 EXPECT_EQ(second_root, | 1910 EXPECT_EQ(second_root, |
| 1905 browser2->window()->GetNativeWindow()->GetRootWindow()); | 1911 browser2->window()->GetNativeWindow()->GetRootWindow()); |
| 1906 | 1912 |
| 1907 // Put the second browser into immersive fullscreen. | 1913 // Put the second browser into immersive fullscreen. |
| 1908 BrowserView* browser_view2 = BrowserView::GetBrowserViewForBrowser(browser2); | 1914 BrowserView* browser_view2 = BrowserView::GetBrowserViewForBrowser(browser2); |
| 1909 ImmersiveModeController* immersive_controller2 = | 1915 ImmersiveModeController* immersive_controller2 = |
| 1910 browser_view2->immersive_mode_controller(); | 1916 browser_view2->immersive_mode_controller(); |
| 1911 immersive_controller2->SetupForTest(); | 1917 immersive_controller2->SetupForTest(); |
| 1912 chrome::ToggleFullscreenMode(browser2); | 1918 chrome::ToggleFullscreenMode(browser2); |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2137 DISABLED_CancelDragTabToWindowIn2ndDisplay) { | 2143 DISABLED_CancelDragTabToWindowIn2ndDisplay) { |
| 2138 // Add another tab. | 2144 // Add another tab. |
| 2139 AddTabAndResetBrowser(browser()); | 2145 AddTabAndResetBrowser(browser()); |
| 2140 TabStrip* tab_strip = GetTabStripForBrowser(browser()); | 2146 TabStrip* tab_strip = GetTabStripForBrowser(browser()); |
| 2141 | 2147 |
| 2142 EXPECT_EQ("0 1", IDString(browser()->tab_strip_model())); | 2148 EXPECT_EQ("0 1", IDString(browser()->tab_strip_model())); |
| 2143 | 2149 |
| 2144 // Move the second browser to the second display. | 2150 // Move the second browser to the second display. |
| 2145 aura::Window::Windows roots = ash::Shell::GetAllRootWindows(); | 2151 aura::Window::Windows roots = ash::Shell::GetAllRootWindows(); |
| 2146 ASSERT_EQ(2u, roots.size()); | 2152 ASSERT_EQ(2u, roots.size()); |
| 2147 gfx::Point final_destination = | 2153 gfx::Point final_destination = gfx::Screen::GetScreen() |
| 2148 gfx::Screen::GetNativeScreen()->GetDisplayNearestWindow( | 2154 ->GetDisplayNearestWindow(roots[1]) |
| 2149 roots[1]).work_area().CenterPoint(); | 2155 .work_area() |
| 2156 .CenterPoint(); |
| 2150 | 2157 |
| 2151 // Move to the first tab and drag it enough so that it detaches, but not | 2158 // Move to the first tab and drag it enough so that it detaches, but not |
| 2152 // enough to move to another display. | 2159 // enough to move to another display. |
| 2153 gfx::Point tab_0_dst(GetCenterInScreenCoordinates(tab_strip->tab_at(0))); | 2160 gfx::Point tab_0_dst(GetCenterInScreenCoordinates(tab_strip->tab_at(0))); |
| 2154 ASSERT_TRUE(Press(tab_0_dst)); | 2161 ASSERT_TRUE(Press(tab_0_dst)); |
| 2155 tab_0_dst.Offset(0, GetDetachY(tab_strip)); | 2162 tab_0_dst.Offset(0, GetDetachY(tab_strip)); |
| 2156 ASSERT_TRUE(DragTabAndExecuteTaskWhenDone( | 2163 ASSERT_TRUE(DragTabAndExecuteTaskWhenDone( |
| 2157 tab_0_dst, base::Bind(&CancelDragTabToWindowInSeparateDisplayStep2, | 2164 tab_0_dst, base::Bind(&CancelDragTabToWindowInSeparateDisplayStep2, |
| 2158 this, tab_strip, roots[0], final_destination, | 2165 this, tab_strip, roots[0], final_destination, |
| 2159 native_browser_list))); | 2166 native_browser_list))); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 2176 aura::Window::Windows roots = ash::Shell::GetAllRootWindows(); | 2183 aura::Window::Windows roots = ash::Shell::GetAllRootWindows(); |
| 2177 ASSERT_EQ(2u, roots.size()); | 2184 ASSERT_EQ(2u, roots.size()); |
| 2178 | 2185 |
| 2179 // Add another tab. | 2186 // Add another tab. |
| 2180 AddTabAndResetBrowser(browser()); | 2187 AddTabAndResetBrowser(browser()); |
| 2181 TabStrip* tab_strip = GetTabStripForBrowser(browser()); | 2188 TabStrip* tab_strip = GetTabStripForBrowser(browser()); |
| 2182 | 2189 |
| 2183 EXPECT_EQ("0 1", IDString(browser()->tab_strip_model())); | 2190 EXPECT_EQ("0 1", IDString(browser()->tab_strip_model())); |
| 2184 EXPECT_EQ(roots[0], browser()->window()->GetNativeWindow()->GetRootWindow()); | 2191 EXPECT_EQ(roots[0], browser()->window()->GetNativeWindow()->GetRootWindow()); |
| 2185 | 2192 |
| 2186 gfx::Rect work_area = gfx::Screen::GetNativeScreen()-> | 2193 gfx::Rect work_area = |
| 2187 GetDisplayNearestWindow(roots[1]).work_area(); | 2194 gfx::Screen::GetScreen()->GetDisplayNearestWindow(roots[1]).work_area(); |
| 2188 browser()->window()->SetBounds(work_area); | 2195 browser()->window()->SetBounds(work_area); |
| 2189 EXPECT_EQ(roots[1], browser()->window()->GetNativeWindow()->GetRootWindow()); | 2196 EXPECT_EQ(roots[1], browser()->window()->GetNativeWindow()->GetRootWindow()); |
| 2190 | 2197 |
| 2191 // Move the second browser to the display. | 2198 // Move the second browser to the display. |
| 2192 gfx::Point final_destination = | 2199 gfx::Point final_destination = gfx::Screen::GetScreen() |
| 2193 gfx::Screen::GetNativeScreen()->GetDisplayNearestWindow( | 2200 ->GetDisplayNearestWindow(roots[0]) |
| 2194 roots[0]).work_area().CenterPoint(); | 2201 .work_area() |
| 2202 .CenterPoint(); |
| 2195 | 2203 |
| 2196 // Move to the first tab and drag it enough so that it detaches, but not | 2204 // Move to the first tab and drag it enough so that it detaches, but not |
| 2197 // enough to move to another display. | 2205 // enough to move to another display. |
| 2198 gfx::Point tab_0_dst(GetCenterInScreenCoordinates(tab_strip->tab_at(0))); | 2206 gfx::Point tab_0_dst(GetCenterInScreenCoordinates(tab_strip->tab_at(0))); |
| 2199 ASSERT_TRUE(Press(tab_0_dst)); | 2207 ASSERT_TRUE(Press(tab_0_dst)); |
| 2200 tab_0_dst.Offset(0, GetDetachY(tab_strip)); | 2208 tab_0_dst.Offset(0, GetDetachY(tab_strip)); |
| 2201 ASSERT_TRUE(DragTabAndExecuteTaskWhenDone( | 2209 ASSERT_TRUE(DragTabAndExecuteTaskWhenDone( |
| 2202 tab_0_dst, base::Bind(&CancelDragTabToWindowInSeparateDisplayStep2, | 2210 tab_0_dst, base::Bind(&CancelDragTabToWindowInSeparateDisplayStep2, |
| 2203 this, tab_strip, roots[1], final_destination, | 2211 this, tab_strip, roots[1], final_destination, |
| 2204 native_browser_list))); | 2212 native_browser_list))); |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2357 DetachToBrowserTabDragControllerTest, | 2365 DetachToBrowserTabDragControllerTest, |
| 2358 ::testing::Values("mouse", "touch")); | 2366 ::testing::Values("mouse", "touch")); |
| 2359 INSTANTIATE_TEST_CASE_P(TabDragging, | 2367 INSTANTIATE_TEST_CASE_P(TabDragging, |
| 2360 DetachToBrowserTabDragControllerTestTouch, | 2368 DetachToBrowserTabDragControllerTestTouch, |
| 2361 ::testing::Values("touch")); | 2369 ::testing::Values("touch")); |
| 2362 #elif defined(USE_ASH) | 2370 #elif defined(USE_ASH) |
| 2363 INSTANTIATE_TEST_CASE_P(TabDragging, | 2371 INSTANTIATE_TEST_CASE_P(TabDragging, |
| 2364 DetachToBrowserTabDragControllerTest, | 2372 DetachToBrowserTabDragControllerTest, |
| 2365 ::testing::Values("mouse")); | 2373 ::testing::Values("mouse")); |
| 2366 #endif | 2374 #endif |
| OLD | NEW |