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 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/callback.h" | 12 #include "base/callback.h" |
13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
15 #include "base/memory/ptr_util.h" | 15 #include "base/memory/ptr_util.h" |
16 #include "base/run_loop.h" | 16 #include "base/run_loop.h" |
17 #include "base/strings/string_number_conversions.h" | 17 #include "base/strings/string_number_conversions.h" |
18 #include "build/build_config.h" | 18 #include "build/build_config.h" |
19 #include "chrome/browser/chrome_notification_types.h" | 19 #include "chrome/browser/chrome_notification_types.h" |
| 20 #include "chrome/browser/platform_util.h" |
20 #include "chrome/browser/ui/browser.h" | 21 #include "chrome/browser/ui/browser.h" |
21 #include "chrome/browser/ui/browser_commands.h" | 22 #include "chrome/browser/ui/browser_commands.h" |
22 #include "chrome/browser/ui/browser_list.h" | 23 #include "chrome/browser/ui/browser_list.h" |
23 #include "chrome/browser/ui/browser_tabstrip.h" | 24 #include "chrome/browser/ui/browser_tabstrip.h" |
24 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 25 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
25 #include "chrome/browser/ui/views/frame/browser_view.h" | 26 #include "chrome/browser/ui/views/frame/browser_view.h" |
26 #include "chrome/browser/ui/views/frame/native_browser_frame_factory.h" | 27 #include "chrome/browser/ui/views/frame/native_browser_frame_factory.h" |
27 #include "chrome/browser/ui/views/tabs/tab.h" | 28 #include "chrome/browser/ui/views/tabs/tab.h" |
28 #include "chrome/browser/ui/views/tabs/tab_drag_controller.h" | 29 #include "chrome/browser/ui/views/tabs/tab_drag_controller.h" |
29 #include "chrome/browser/ui/views/tabs/tab_strip.h" | 30 #include "chrome/browser/ui/views/tabs/tab_strip.h" |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 } | 179 } |
179 | 180 |
180 Browser* TabDragControllerTest::CreateAnotherWindowBrowserAndRelayout() { | 181 Browser* TabDragControllerTest::CreateAnotherWindowBrowserAndRelayout() { |
181 // Create another browser. | 182 // Create another browser. |
182 Browser* browser2 = CreateBrowser(browser()->profile()); | 183 Browser* browser2 = CreateBrowser(browser()->profile()); |
183 ResetIDs(browser2->tab_strip_model(), 100); | 184 ResetIDs(browser2->tab_strip_model(), 100); |
184 | 185 |
185 // Resize the two windows so they're right next to each other. | 186 // Resize the two windows so they're right next to each other. |
186 gfx::Rect work_area = | 187 gfx::Rect work_area = |
187 display::Screen::GetScreen() | 188 display::Screen::GetScreen() |
188 ->GetDisplayNearestWindow(browser()->window()->GetNativeWindow()) | 189 ->GetDisplayNearestWindow(platform_util::GetViewForWindow( |
| 190 browser()->window()->GetNativeWindow())) |
189 .work_area(); | 191 .work_area(); |
190 gfx::Size half_size = | 192 gfx::Size half_size = |
191 gfx::Size(work_area.width() / 3 - 10, work_area.height() / 2 - 10); | 193 gfx::Size(work_area.width() / 3 - 10, work_area.height() / 2 - 10); |
192 browser()->window()->SetBounds(gfx::Rect(work_area.origin(), half_size)); | 194 browser()->window()->SetBounds(gfx::Rect(work_area.origin(), half_size)); |
193 browser2->window()->SetBounds(gfx::Rect( | 195 browser2->window()->SetBounds(gfx::Rect( |
194 work_area.x() + half_size.width(), work_area.y(), | 196 work_area.x() + half_size.width(), work_area.y(), |
195 half_size.width(), half_size.height())); | 197 half_size.width(), half_size.height())); |
196 return browser2; | 198 return browser2; |
197 } | 199 } |
198 | 200 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 } | 248 } |
247 | 249 |
248 private: | 250 private: |
249 aura::Window* root_window_; | 251 aura::Window* root_window_; |
250 | 252 |
251 DISALLOW_COPY_AND_ASSIGN(ScreenEventGeneratorDelegate); | 253 DISALLOW_COPY_AND_ASSIGN(ScreenEventGeneratorDelegate); |
252 }; | 254 }; |
253 | 255 |
254 #endif | 256 #endif |
255 | 257 |
256 #if !defined(OS_CHROMEOS) | 258 #if !defined(OS_CHROMEOS) && defined(USE_AURA) |
257 | 259 |
258 // Following classes verify a crash scenario. Specifically on Windows when focus | 260 // Following classes verify a crash scenario. Specifically on Windows when focus |
259 // changes it can trigger capture being lost. This was causing a crash in tab | 261 // changes it can trigger capture being lost. This was causing a crash in tab |
260 // dragging as it wasn't set up to handle this scenario. These classes | 262 // dragging as it wasn't set up to handle this scenario. These classes |
261 // synthesize this scenario. | 263 // synthesize this scenario. |
262 | 264 |
263 // Allows making ClearNativeFocus() invoke ReleaseCapture(). | 265 // Allows making ClearNativeFocus() invoke ReleaseCapture(). |
264 class TestDesktopBrowserFrameAura : public DesktopBrowserFrameAura { | 266 class TestDesktopBrowserFrameAura : public DesktopBrowserFrameAura { |
265 public: | 267 public: |
266 TestDesktopBrowserFrameAura( | 268 TestDesktopBrowserFrameAura( |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 : public TabDragControllerTest, | 371 : public TabDragControllerTest, |
370 public ::testing::WithParamInterface<const char*> { | 372 public ::testing::WithParamInterface<const char*> { |
371 public: | 373 public: |
372 DetachToBrowserTabDragControllerTest() {} | 374 DetachToBrowserTabDragControllerTest() {} |
373 | 375 |
374 void SetUpOnMainThread() override { | 376 void SetUpOnMainThread() override { |
375 #if defined(OS_CHROMEOS) | 377 #if defined(OS_CHROMEOS) |
376 event_generator_.reset( | 378 event_generator_.reset( |
377 new ui::test::EventGenerator(ash::Shell::GetPrimaryRootWindow())); | 379 new ui::test::EventGenerator(ash::Shell::GetPrimaryRootWindow())); |
378 #endif | 380 #endif |
| 381 #if defined(OS_MACOSX) |
| 382 // Currently MacViews' browser windows are shown in the background and could |
| 383 // be obscured by other windows if there are any. This should be fixed in |
| 384 // order to be consistent with other platforms. |
| 385 EXPECT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); |
| 386 #endif // OS_MACOSX |
379 } | 387 } |
380 | 388 |
381 InputSource input_source() const { | 389 InputSource input_source() const { |
382 return strstr(GetParam(), "mouse") ? | 390 return strstr(GetParam(), "mouse") ? |
383 INPUT_SOURCE_MOUSE : INPUT_SOURCE_TOUCH; | 391 INPUT_SOURCE_MOUSE : INPUT_SOURCE_TOUCH; |
384 } | 392 } |
385 | 393 |
386 // Set root window from a point in screen coordinates | 394 // Set root window from a point in screen coordinates |
387 void SetEventGeneratorRootWindow(const gfx::Point& point) { | 395 void SetEventGeneratorRootWindow(const gfx::Point& point) { |
388 if (input_source() == INPUT_SOURCE_MOUSE) | 396 if (input_source() == INPUT_SOURCE_MOUSE) |
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
846 // Both windows should not be maximized | 854 // Both windows should not be maximized |
847 EXPECT_FALSE(browser()->window()->IsMaximized()); | 855 EXPECT_FALSE(browser()->window()->IsMaximized()); |
848 EXPECT_FALSE(new_browser->window()->IsMaximized()); | 856 EXPECT_FALSE(new_browser->window()->IsMaximized()); |
849 | 857 |
850 // The tab strip should no longer have capture because the drag was ended and | 858 // The tab strip should no longer have capture because the drag was ended and |
851 // mouse/touch was released. | 859 // mouse/touch was released. |
852 EXPECT_FALSE(tab_strip->GetWidget()->HasCapture()); | 860 EXPECT_FALSE(tab_strip->GetWidget()->HasCapture()); |
853 EXPECT_FALSE(tab_strip2->GetWidget()->HasCapture()); | 861 EXPECT_FALSE(tab_strip2->GetWidget()->HasCapture()); |
854 } | 862 } |
855 | 863 |
856 #if defined(OS_CHROMEOS) || defined(OS_LINUX) | 864 #if defined(OS_CHROMEOS) || defined(OS_LINUX) || defined(OS_MACOSX) |
857 // TODO(sky,sad): Disabled as it fails due to resize locks with a real | 865 // TODO(sky,sad): Disabled as it fails due to resize locks with a real |
858 // compositor. crbug.com/331924 | 866 // compositor. crbug.com/331924 |
| 867 // TODO(tapted,mblsha): Disabled as the Mac IsMaximized() behavior is not |
| 868 // consistent with other platforms. crbug.com/603562 |
859 #define MAYBE_DetachFromFullsizeWindow DISABLED_DetachFromFullsizeWindow | 869 #define MAYBE_DetachFromFullsizeWindow DISABLED_DetachFromFullsizeWindow |
860 #else | 870 #else |
861 #define MAYBE_DetachFromFullsizeWindow DetachFromFullsizeWindow | 871 #define MAYBE_DetachFromFullsizeWindow DetachFromFullsizeWindow |
862 #endif | 872 #endif |
863 // Tests that a tab can be dragged from a browser window that is resized to full | 873 // Tests that a tab can be dragged from a browser window that is resized to full |
864 // screen. | 874 // screen. |
865 IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest, | 875 IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest, |
866 MAYBE_DetachFromFullsizeWindow) { | 876 MAYBE_DetachFromFullsizeWindow) { |
867 // Resize the browser window so that it is as big as the work area. | 877 // Resize the browser window so that it is as big as the work area. |
868 gfx::Rect work_area = | 878 gfx::Rect work_area = |
869 display::Screen::GetScreen() | 879 display::Screen::GetScreen() |
870 ->GetDisplayNearestWindow(browser()->window()->GetNativeWindow()) | 880 ->GetDisplayNearestWindow(platform_util::GetViewForWindow( |
| 881 browser()->window()->GetNativeWindow())) |
871 .work_area(); | 882 .work_area(); |
872 browser()->window()->SetBounds(work_area); | 883 browser()->window()->SetBounds(work_area); |
873 const gfx::Rect initial_bounds(browser()->window()->GetBounds()); | 884 const gfx::Rect initial_bounds(browser()->window()->GetBounds()); |
874 // Add another tab. | 885 // Add another tab. |
875 AddTabAndResetBrowser(browser()); | 886 AddTabAndResetBrowser(browser()); |
876 TabStrip* tab_strip = GetTabStripForBrowser(browser()); | 887 TabStrip* tab_strip = GetTabStripForBrowser(browser()); |
877 | 888 |
878 // Move to the first tab and drag it enough so that it detaches. | 889 // Move to the first tab and drag it enough so that it detaches. |
879 gfx::Point tab_0_center(GetCenterInScreenCoordinates(tab_strip->tab_at(0))); | 890 gfx::Point tab_0_center(GetCenterInScreenCoordinates(tab_strip->tab_at(0))); |
880 ASSERT_TRUE(PressInput(tab_0_center)); | 891 ASSERT_TRUE(PressInput(tab_0_center)); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
914 // Only second window should be maximized. | 925 // Only second window should be maximized. |
915 EXPECT_FALSE(browser()->window()->IsMaximized()); | 926 EXPECT_FALSE(browser()->window()->IsMaximized()); |
916 EXPECT_TRUE(new_browser->window()->IsMaximized()); | 927 EXPECT_TRUE(new_browser->window()->IsMaximized()); |
917 | 928 |
918 // The tab strip should no longer have capture because the drag was ended and | 929 // The tab strip should no longer have capture because the drag was ended and |
919 // mouse/touch was released. | 930 // mouse/touch was released. |
920 EXPECT_FALSE(tab_strip->GetWidget()->HasCapture()); | 931 EXPECT_FALSE(tab_strip->GetWidget()->HasCapture()); |
921 EXPECT_FALSE(tab_strip2->GetWidget()->HasCapture()); | 932 EXPECT_FALSE(tab_strip2->GetWidget()->HasCapture()); |
922 } | 933 } |
923 | 934 |
924 #if defined(OS_CHROMEOS) || defined(OS_LINUX) | 935 #if defined(OS_CHROMEOS) || defined(OS_LINUX) || defined(OS_MACOSX) |
925 // TODO(sky,sad): Disabled as it fails due to resize locks with a real | 936 // TODO(sky,sad): Disabled as it fails due to resize locks with a real |
926 // compositor. crbug.com/331924 | 937 // compositor. crbug.com/331924 |
| 938 // TODO(tapted,mblsha): Disabled as the Mac IsMaximized() behavior is not |
| 939 // consistent with other platforms. crbug.com/603562 |
927 #define MAYBE_DetachToOwnWindowFromMaximizedWindow \ | 940 #define MAYBE_DetachToOwnWindowFromMaximizedWindow \ |
928 DISABLED_DetachToOwnWindowFromMaximizedWindow | 941 DISABLED_DetachToOwnWindowFromMaximizedWindow |
929 #else | 942 #else |
930 #define MAYBE_DetachToOwnWindowFromMaximizedWindow \ | 943 #define MAYBE_DetachToOwnWindowFromMaximizedWindow \ |
931 DetachToOwnWindowFromMaximizedWindow | 944 DetachToOwnWindowFromMaximizedWindow |
932 #endif | 945 #endif |
933 // Drags from browser to a separate window and releases mouse. | 946 // Drags from browser to a separate window and releases mouse. |
934 IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest, | 947 IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest, |
935 MAYBE_DetachToOwnWindowFromMaximizedWindow) { | 948 MAYBE_DetachToOwnWindowFromMaximizedWindow) { |
936 // Maximize the initial browser window. | 949 // Maximize the initial browser window. |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1276 #else | 1289 #else |
1277 #define MAYBE_DragAll DragAll | 1290 #define MAYBE_DragAll DragAll |
1278 #endif | 1291 #endif |
1279 // Selects multiple tabs and starts dragging the window. | 1292 // Selects multiple tabs and starts dragging the window. |
1280 IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest, MAYBE_DragAll) { | 1293 IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest, MAYBE_DragAll) { |
1281 // Add another tab. | 1294 // Add another tab. |
1282 AddTabAndResetBrowser(browser()); | 1295 AddTabAndResetBrowser(browser()); |
1283 TabStrip* tab_strip = GetTabStripForBrowser(browser()); | 1296 TabStrip* tab_strip = GetTabStripForBrowser(browser()); |
1284 browser()->tab_strip_model()->AddTabAtToSelection(0); | 1297 browser()->tab_strip_model()->AddTabAtToSelection(0); |
1285 browser()->tab_strip_model()->AddTabAtToSelection(1); | 1298 browser()->tab_strip_model()->AddTabAtToSelection(1); |
| 1299 const gfx::Rect initial_bounds = browser()->window()->GetBounds(); |
1286 | 1300 |
1287 // Move to the first tab and drag it enough so that it would normally | 1301 // Move to the first tab and drag it enough so that it would normally |
1288 // detach. | 1302 // detach. |
1289 gfx::Point tab_0_center(GetCenterInScreenCoordinates(tab_strip->tab_at(0))); | 1303 gfx::Point tab_0_center(GetCenterInScreenCoordinates(tab_strip->tab_at(0))); |
1290 ASSERT_TRUE(PressInput(tab_0_center)); | 1304 ASSERT_TRUE(PressInput(tab_0_center)); |
1291 ASSERT_TRUE(DragInputToNotifyWhenDone( | 1305 ASSERT_TRUE(DragInputToNotifyWhenDone( |
1292 tab_0_center.x(), tab_0_center.y() + GetDetachY(tab_strip), | 1306 tab_0_center.x(), tab_0_center.y() + GetDetachY(tab_strip), |
1293 base::Bind(&DragAllStep2, this, browser_list))); | 1307 base::Bind(&DragAllStep2, this, browser_list))); |
1294 QuitWhenNotDragging(); | 1308 QuitWhenNotDragging(); |
1295 | 1309 |
1296 // Should not be dragging. | 1310 // Should not be dragging. |
1297 ASSERT_FALSE(tab_strip->IsDragSessionActive()); | 1311 ASSERT_FALSE(tab_strip->IsDragSessionActive()); |
1298 ASSERT_FALSE(TabDragController::IsActive()); | 1312 ASSERT_FALSE(TabDragController::IsActive()); |
1299 | 1313 |
1300 // And there should only be one window. | 1314 // And there should only be one window. |
1301 EXPECT_EQ(1u, browser_list->size()); | 1315 EXPECT_EQ(1u, browser_list->size()); |
1302 | 1316 |
1303 EXPECT_EQ("0 1", IDString(browser()->tab_strip_model())); | 1317 EXPECT_EQ("0 1", IDString(browser()->tab_strip_model())); |
1304 | 1318 |
1305 EXPECT_FALSE(GetIsDragged(browser())); | 1319 EXPECT_FALSE(GetIsDragged(browser())); |
1306 | 1320 |
1307 // Remaining browser window should not be maximized | 1321 // Remaining browser window should not be maximized |
1308 EXPECT_FALSE(browser()->window()->IsMaximized()); | 1322 EXPECT_FALSE(browser()->window()->IsMaximized()); |
| 1323 |
| 1324 const gfx::Rect final_bounds = browser()->window()->GetBounds(); |
| 1325 // Size unchanged, but it should have moved down. |
| 1326 EXPECT_EQ(initial_bounds.size(), final_bounds.size()); |
| 1327 EXPECT_EQ(initial_bounds.origin().x(), final_bounds.origin().x()); |
| 1328 EXPECT_EQ(initial_bounds.origin().y() + GetDetachY(tab_strip), |
| 1329 final_bounds.origin().y()); |
1309 } | 1330 } |
1310 | 1331 |
| 1332 #if defined(OS_MACOSX) |
| 1333 // Makes sure we can drag the window using CocoaWindowMoveLoop by dragging on a |
| 1334 // tab. |
| 1335 // |
| 1336 // All other tests move the windows without relying on the CocoaWindowMoveLoop, |
| 1337 // because BridgedNativeWidget::RunMoveLoop() immediately offsets the window on |
| 1338 // first mouse drag. If we generate more mouse move events after that, it's |
| 1339 // presumed that the CocoaWindowMoveLoop will move the window. |
| 1340 // |
| 1341 // If the CocoaWindowMoveLoop fails to move the window, the final window bounds |
| 1342 // won't match the expected ones. |
| 1343 |
| 1344 // Test dragging all the tabs in the window, this should move the entire window. |
| 1345 IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest, |
| 1346 MacDragsWindowUsingCocoaMoveLoop) { |
| 1347 // Add another tab. |
| 1348 AddTabAndResetBrowser(browser()); |
| 1349 |
| 1350 TabStrip* tab_strip = GetTabStripForBrowser(browser()); |
| 1351 browser()->tab_strip_model()->AddTabAtToSelection(0); |
| 1352 browser()->tab_strip_model()->AddTabAtToSelection(1); |
| 1353 const gfx::Rect initial_bounds = browser()->window()->GetBounds(); |
| 1354 |
| 1355 // Move to the first tab and drag it enough so that it would normally |
| 1356 // detach. |
| 1357 gfx::Point tab_0_center(GetCenterInScreenCoordinates(tab_strip->tab_at(0))); |
| 1358 |
| 1359 // We need to move the window using multiple intermediate events in order |
| 1360 // to verify that CocoaWindowMoveLoop is working correctly. |
| 1361 const int steps = 10; |
| 1362 ui_test_utils::DragAndDrop( |
| 1363 tab_0_center, |
| 1364 gfx::Point(tab_0_center.x(), tab_0_center.y() + GetDetachY(tab_strip)), |
| 1365 steps); |
| 1366 |
| 1367 // Should not be dragging. |
| 1368 EXPECT_FALSE(tab_strip->IsDragSessionActive()); |
| 1369 EXPECT_FALSE(TabDragController::IsActive()); |
| 1370 EXPECT_FALSE(GetIsDragged(browser())); |
| 1371 |
| 1372 // And there should only be one window. |
| 1373 EXPECT_EQ(1u, browser_list->size()); |
| 1374 EXPECT_EQ("0 1", IDString(browser()->tab_strip_model())); |
| 1375 |
| 1376 // Remaining browser window should not be maximized |
| 1377 EXPECT_FALSE(browser()->window()->IsMaximized()); |
| 1378 |
| 1379 const gfx::Rect final_bounds = browser()->window()->GetBounds(); |
| 1380 EXPECT_EQ(initial_bounds.size(), final_bounds.size()); |
| 1381 EXPECT_EQ(initial_bounds.origin().x(), final_bounds.origin().x()); |
| 1382 EXPECT_EQ(initial_bounds.origin().y() + GetDetachY(tab_strip), |
| 1383 final_bounds.origin().y()); |
| 1384 } |
| 1385 |
| 1386 // Tests that when the first mouse event that starts RunMoveLoop does not |
| 1387 // overlap the Mac menu bar. BridgedNativeWidget::RunMoveLoop() shifts both the |
| 1388 // mouse position and the expected window frame after detachment. |
| 1389 IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest, |
| 1390 MacDetachesWindowAtTopOfScreen) { |
| 1391 // Add another tab. |
| 1392 AddTabAndResetBrowser(browser()); |
| 1393 |
| 1394 // Make sure there's enough space to trigger detachment. |
| 1395 TabStrip* tab_strip = GetTabStripForBrowser(browser()); |
| 1396 browser()->window()->SetBounds(gfx::Rect(100, 200, 400, 200)); |
| 1397 DCHECK_GT(browser()->window()->GetBounds().y(), GetDetachY(tab_strip)); |
| 1398 |
| 1399 gfx::Point tab_0_center(GetCenterInScreenCoordinates(tab_strip->tab_at(0))); |
| 1400 gfx::Point at_top_of_screen(tab_0_center.x(), 0); |
| 1401 gfx::Point below_top_of_screen(tab_0_center.x(), 100); |
| 1402 |
| 1403 using ui_test_utils::DragAndDropOperation; |
| 1404 std::list<DragAndDropOperation> operations; |
| 1405 operations.push_back(DragAndDropOperation::Move(tab_0_center)); |
| 1406 operations.push_back(DragAndDropOperation::MouseDown()); |
| 1407 operations.push_back(DragAndDropOperation::Move(at_top_of_screen)); |
| 1408 operations.push_back(DragAndDropOperation::Move(below_top_of_screen)); |
| 1409 operations.push_back(DragAndDropOperation::MouseUp()); |
| 1410 ui_test_utils::DragAndDropSequence(operations); |
| 1411 |
| 1412 // Should not be dragging. |
| 1413 EXPECT_FALSE(tab_strip->IsDragSessionActive()); |
| 1414 EXPECT_FALSE(TabDragController::IsActive()); |
| 1415 EXPECT_FALSE(GetIsDragged(browser())); |
| 1416 |
| 1417 // Second tab should successfully detach. |
| 1418 EXPECT_EQ(2u, browser_list->size()); |
| 1419 EXPECT_EQ("1", IDString(browser()->tab_strip_model())); |
| 1420 |
| 1421 Browser* browser2 = browser_list->get(1); |
| 1422 EXPECT_EQ(browser2->window()->GetBounds().size(), |
| 1423 browser()->window()->GetBounds().size()); |
| 1424 } |
| 1425 #endif // OS_MACOSX |
| 1426 |
1311 namespace { | 1427 namespace { |
1312 | 1428 |
1313 // Invoked from the nested message loop. | 1429 // Invoked from the nested message loop. |
1314 void DragAllToSeparateWindowStep2(DetachToBrowserTabDragControllerTest* test, | 1430 void DragAllToSeparateWindowStep2(DetachToBrowserTabDragControllerTest* test, |
1315 TabStrip* attached_tab_strip, | 1431 TabStrip* attached_tab_strip, |
1316 TabStrip* target_tab_strip, | 1432 TabStrip* target_tab_strip, |
1317 const BrowserList* browser_list) { | 1433 const BrowserList* browser_list) { |
1318 ASSERT_TRUE(attached_tab_strip->IsDragSessionActive()); | 1434 ASSERT_TRUE(attached_tab_strip->IsDragSessionActive()); |
1319 ASSERT_FALSE(target_tab_strip->IsDragSessionActive()); | 1435 ASSERT_FALSE(target_tab_strip->IsDragSessionActive()); |
1320 ASSERT_TRUE(TabDragController::IsActive()); | 1436 ASSERT_TRUE(TabDragController::IsActive()); |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1574 | 1690 |
1575 namespace { | 1691 namespace { |
1576 | 1692 |
1577 // Invoked from the nested message loop. | 1693 // Invoked from the nested message loop. |
1578 void CancelOnNewTabWhenDraggingStep2( | 1694 void CancelOnNewTabWhenDraggingStep2( |
1579 DetachToBrowserTabDragControllerTest* test, | 1695 DetachToBrowserTabDragControllerTest* test, |
1580 const BrowserList* browser_list) { | 1696 const BrowserList* browser_list) { |
1581 ASSERT_TRUE(TabDragController::IsActive()); | 1697 ASSERT_TRUE(TabDragController::IsActive()); |
1582 ASSERT_EQ(2u, browser_list->size()); | 1698 ASSERT_EQ(2u, browser_list->size()); |
1583 | 1699 |
1584 // Add another tab. This should trigger exiting the nested loop. Add at the | |
1585 // to exercise past crash when model/tabstrip got out of sync (474082). | |
1586 content::WindowedNotificationObserver observer( | |
1587 content::NOTIFICATION_LOAD_STOP, | |
1588 content::NotificationService::AllSources()); | |
1589 chrome::AddTabAt(browser_list->GetLastActive(), GURL(url::kAboutBlankURL), | 1700 chrome::AddTabAt(browser_list->GetLastActive(), GURL(url::kAboutBlankURL), |
1590 0, false); | 1701 0, false); |
1591 observer.Wait(); | |
1592 } | 1702 } |
1593 | 1703 |
1594 } // namespace | 1704 } // namespace |
1595 | 1705 |
1596 #if defined(OS_CHROMEOS) || defined(OS_LINUX) | 1706 #if defined(OS_CHROMEOS) || defined(OS_LINUX) |
1597 // TODO(sky,sad): Disabled as it fails due to resize locks with a real | 1707 // TODO(sky,sad): Disabled as it fails due to resize locks with a real |
1598 // compositor. crbug.com/331924 | 1708 // compositor. crbug.com/331924 |
1599 #define MAYBE_CancelOnNewTabWhenDragging DISABLED_CancelOnNewTabWhenDragging | 1709 #define MAYBE_CancelOnNewTabWhenDragging DISABLED_CancelOnNewTabWhenDragging |
1600 #else | 1710 #else |
1601 #define MAYBE_CancelOnNewTabWhenDragging CancelOnNewTabWhenDragging | 1711 #define MAYBE_CancelOnNewTabWhenDragging CancelOnNewTabWhenDragging |
1602 #endif | 1712 #endif |
1603 // Adds another tab, detaches into separate window, adds another tab and | 1713 // Adds another tab, detaches into separate window, adds another tab and |
1604 // verifies the run loop ends. | 1714 // verifies the run loop ends. |
1605 IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest, | 1715 IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest, |
1606 MAYBE_CancelOnNewTabWhenDragging) { | 1716 MAYBE_CancelOnNewTabWhenDragging) { |
1607 TabStrip* tab_strip = GetTabStripForBrowser(browser()); | 1717 TabStrip* tab_strip = GetTabStripForBrowser(browser()); |
1608 | 1718 |
1609 // Add another tab to browser(). | 1719 // Add another tab to browser(). |
1610 AddTabAndResetBrowser(browser()); | 1720 AddTabAndResetBrowser(browser()); |
1611 | 1721 |
1612 // Move to the first tab and drag it enough so that it detaches. | 1722 // Move to the first tab and drag it enough so that it detaches. |
1613 gfx::Point tab_0_center( | 1723 gfx::Point tab_0_center( |
1614 GetCenterInScreenCoordinates(tab_strip->tab_at(0))); | 1724 GetCenterInScreenCoordinates(tab_strip->tab_at(0))); |
1615 ASSERT_TRUE(PressInput(tab_0_center)); | 1725 ASSERT_TRUE(PressInput(tab_0_center)); |
| 1726 |
| 1727 // Add another tab. This should trigger exiting the nested loop. Add at the |
| 1728 // beginning to exercise past crash when model/tabstrip got out of sync. |
| 1729 // crbug.com/474082 |
| 1730 content::WindowedNotificationObserver observer( |
| 1731 content::NOTIFICATION_LOAD_STOP, |
| 1732 content::NotificationService::AllSources()); |
1616 ASSERT_TRUE(DragInputToNotifyWhenDone( | 1733 ASSERT_TRUE(DragInputToNotifyWhenDone( |
1617 tab_0_center.x(), tab_0_center.y() + GetDetachY(tab_strip), | 1734 tab_0_center.x(), tab_0_center.y() + GetDetachY(tab_strip), |
1618 base::Bind(&CancelOnNewTabWhenDraggingStep2, this, browser_list))); | 1735 base::Bind(&CancelOnNewTabWhenDraggingStep2, this, browser_list))); |
1619 QuitWhenNotDragging(); | 1736 observer.Wait(); |
1620 | 1737 |
1621 // Should be two windows and not dragging. | 1738 // Should be two windows and not dragging. |
| 1739 ASSERT_FALSE(tab_strip->IsDragSessionActive()); |
1622 ASSERT_FALSE(TabDragController::IsActive()); | 1740 ASSERT_FALSE(TabDragController::IsActive()); |
1623 ASSERT_EQ(2u, browser_list->size()); | 1741 ASSERT_EQ(2u, browser_list->size()); |
1624 for (auto* browser : *BrowserList::GetInstance()) { | 1742 for (auto* browser : *BrowserList::GetInstance()) { |
1625 EXPECT_FALSE(GetIsDragged(browser)); | 1743 EXPECT_FALSE(GetIsDragged(browser)); |
1626 // Should not be maximized | 1744 // Should not be maximized |
1627 EXPECT_FALSE(browser->window()->IsMaximized()); | 1745 EXPECT_FALSE(browser->window()->IsMaximized()); |
1628 } | 1746 } |
1629 } | 1747 } |
1630 | 1748 |
1631 #if defined(OS_CHROMEOS) | 1749 #if defined(OS_CHROMEOS) |
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2195 ui_controls::DOWN); | 2313 ui_controls::DOWN); |
2196 } | 2314 } |
2197 | 2315 |
2198 bool DragTabAndExecuteTaskWhenDone(const gfx::Point& position, | 2316 bool DragTabAndExecuteTaskWhenDone(const gfx::Point& position, |
2199 const base::Closure& task) { | 2317 const base::Closure& task) { |
2200 return ui_controls::SendMouseMoveNotifyWhenDone( | 2318 return ui_controls::SendMouseMoveNotifyWhenDone( |
2201 position.x(), position.y(), task); | 2319 position.x(), position.y(), task); |
2202 } | 2320 } |
2203 | 2321 |
2204 void QuitWhenNotDragging() { | 2322 void QuitWhenNotDragging() { |
| 2323 DCHECK(TabDragController::IsActive()); |
2205 test::QuitWhenNotDraggingImpl(); | 2324 test::QuitWhenNotDraggingImpl(); |
2206 base::MessageLoop::current()->Run(); | 2325 base::MessageLoop::current()->Run(); |
2207 } | 2326 } |
2208 | 2327 |
2209 private: | 2328 private: |
2210 DISALLOW_COPY_AND_ASSIGN( | 2329 DISALLOW_COPY_AND_ASSIGN( |
2211 DetachToBrowserInSeparateDisplayAndCancelTabDragControllerTest); | 2330 DetachToBrowserInSeparateDisplayAndCancelTabDragControllerTest); |
2212 }; | 2331 }; |
2213 | 2332 |
2214 // Invoked from the nested message loop. | 2333 // Invoked from the nested message loop. |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2473 DetachToBrowserTabDragControllerTest, | 2592 DetachToBrowserTabDragControllerTest, |
2474 ::testing::Values("mouse", "touch")); | 2593 ::testing::Values("mouse", "touch")); |
2475 INSTANTIATE_TEST_CASE_P(TabDragging, | 2594 INSTANTIATE_TEST_CASE_P(TabDragging, |
2476 DetachToBrowserTabDragControllerTestTouch, | 2595 DetachToBrowserTabDragControllerTestTouch, |
2477 ::testing::Values("touch")); | 2596 ::testing::Values("touch")); |
2478 #else | 2597 #else |
2479 INSTANTIATE_TEST_CASE_P(TabDragging, | 2598 INSTANTIATE_TEST_CASE_P(TabDragging, |
2480 DetachToBrowserTabDragControllerTest, | 2599 DetachToBrowserTabDragControllerTest, |
2481 ::testing::Values("mouse")); | 2600 ::testing::Values("mouse")); |
2482 #endif | 2601 #endif |
OLD | NEW |