| 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 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 634 ASSERT_TRUE(DragInputTo(tab_0_center)); | 634 ASSERT_TRUE(DragInputTo(tab_0_center)); |
| 635 ASSERT_TRUE(ReleaseInput()); | 635 ASSERT_TRUE(ReleaseInput()); |
| 636 EXPECT_EQ("1 0", IDString(model)); | 636 EXPECT_EQ("1 0", IDString(model)); |
| 637 EXPECT_FALSE(TabDragController::IsActive()); | 637 EXPECT_FALSE(TabDragController::IsActive()); |
| 638 EXPECT_FALSE(tab_strip->IsDragSessionActive()); | 638 EXPECT_FALSE(tab_strip->IsDragSessionActive()); |
| 639 } | 639 } |
| 640 #endif // USE_AURA | 640 #endif // USE_AURA |
| 641 | 641 |
| 642 namespace { | 642 namespace { |
| 643 | 643 |
| 644 // Invoked from the nested message loop. | 644 // Invoked from the nested run loop. |
| 645 void DragToSeparateWindowStep2(DetachToBrowserTabDragControllerTest* test, | 645 void DragToSeparateWindowStep2(DetachToBrowserTabDragControllerTest* test, |
| 646 TabStrip* not_attached_tab_strip, | 646 TabStrip* not_attached_tab_strip, |
| 647 TabStrip* target_tab_strip) { | 647 TabStrip* target_tab_strip) { |
| 648 ASSERT_FALSE(not_attached_tab_strip->IsDragSessionActive()); | 648 ASSERT_FALSE(not_attached_tab_strip->IsDragSessionActive()); |
| 649 ASSERT_FALSE(target_tab_strip->IsDragSessionActive()); | 649 ASSERT_FALSE(target_tab_strip->IsDragSessionActive()); |
| 650 ASSERT_TRUE(TabDragController::IsActive()); | 650 ASSERT_TRUE(TabDragController::IsActive()); |
| 651 | 651 |
| 652 // Drag to target_tab_strip. This should stop the nested loop from dragging | 652 // Drag to target_tab_strip. This should stop the nested loop from dragging |
| 653 // the window. | 653 // the window. |
| 654 gfx::Point target_point(target_tab_strip->width() -1, | 654 gfx::Point target_point(target_tab_strip->width() -1, |
| (...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1351 const gfx::Rect final_bounds = browser()->window()->GetBounds(); | 1351 const gfx::Rect final_bounds = browser()->window()->GetBounds(); |
| 1352 // Size unchanged, but it should have moved down. | 1352 // Size unchanged, but it should have moved down. |
| 1353 EXPECT_EQ(initial_bounds.size(), final_bounds.size()); | 1353 EXPECT_EQ(initial_bounds.size(), final_bounds.size()); |
| 1354 EXPECT_EQ(initial_bounds.origin().x(), final_bounds.origin().x()); | 1354 EXPECT_EQ(initial_bounds.origin().x(), final_bounds.origin().x()); |
| 1355 EXPECT_EQ(initial_bounds.origin().y() + GetDetachY(tab_strip), | 1355 EXPECT_EQ(initial_bounds.origin().y() + GetDetachY(tab_strip), |
| 1356 final_bounds.origin().y()); | 1356 final_bounds.origin().y()); |
| 1357 } | 1357 } |
| 1358 | 1358 |
| 1359 namespace { | 1359 namespace { |
| 1360 | 1360 |
| 1361 // Invoked from the nested message loop. | 1361 // Invoked from the nested run loop. |
| 1362 void DragAllToSeparateWindowStep2(DetachToBrowserTabDragControllerTest* test, | 1362 void DragAllToSeparateWindowStep2(DetachToBrowserTabDragControllerTest* test, |
| 1363 TabStrip* attached_tab_strip, | 1363 TabStrip* attached_tab_strip, |
| 1364 TabStrip* target_tab_strip, | 1364 TabStrip* target_tab_strip, |
| 1365 const BrowserList* browser_list) { | 1365 const BrowserList* browser_list) { |
| 1366 ASSERT_TRUE(attached_tab_strip->IsDragSessionActive()); | 1366 ASSERT_TRUE(attached_tab_strip->IsDragSessionActive()); |
| 1367 ASSERT_FALSE(target_tab_strip->IsDragSessionActive()); | 1367 ASSERT_FALSE(target_tab_strip->IsDragSessionActive()); |
| 1368 ASSERT_TRUE(TabDragController::IsActive()); | 1368 ASSERT_TRUE(TabDragController::IsActive()); |
| 1369 ASSERT_EQ(2u, browser_list->size()); | 1369 ASSERT_EQ(2u, browser_list->size()); |
| 1370 | 1370 |
| 1371 // Drag to target_tab_strip. This should stop the nested loop from dragging | 1371 // Drag to target_tab_strip. This should stop the nested loop from dragging |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1423 EXPECT_EQ("100 0 1", IDString(browser2->tab_strip_model())); | 1423 EXPECT_EQ("100 0 1", IDString(browser2->tab_strip_model())); |
| 1424 | 1424 |
| 1425 EXPECT_FALSE(GetIsDragged(browser2)); | 1425 EXPECT_FALSE(GetIsDragged(browser2)); |
| 1426 | 1426 |
| 1427 // Remaining browser window should not be maximized | 1427 // Remaining browser window should not be maximized |
| 1428 EXPECT_FALSE(browser2->window()->IsMaximized()); | 1428 EXPECT_FALSE(browser2->window()->IsMaximized()); |
| 1429 } | 1429 } |
| 1430 | 1430 |
| 1431 namespace { | 1431 namespace { |
| 1432 | 1432 |
| 1433 // Invoked from the nested message loop. | 1433 // Invoked from the nested run loop. |
| 1434 void DragAllToSeparateWindowAndCancelStep2( | 1434 void DragAllToSeparateWindowAndCancelStep2( |
| 1435 DetachToBrowserTabDragControllerTest* test, | 1435 DetachToBrowserTabDragControllerTest* test, |
| 1436 TabStrip* attached_tab_strip, | 1436 TabStrip* attached_tab_strip, |
| 1437 TabStrip* target_tab_strip, | 1437 TabStrip* target_tab_strip, |
| 1438 const BrowserList* browser_list) { | 1438 const BrowserList* browser_list) { |
| 1439 ASSERT_TRUE(attached_tab_strip->IsDragSessionActive()); | 1439 ASSERT_TRUE(attached_tab_strip->IsDragSessionActive()); |
| 1440 ASSERT_FALSE(target_tab_strip->IsDragSessionActive()); | 1440 ASSERT_FALSE(target_tab_strip->IsDragSessionActive()); |
| 1441 ASSERT_TRUE(TabDragController::IsActive()); | 1441 ASSERT_TRUE(TabDragController::IsActive()); |
| 1442 ASSERT_EQ(2u, browser_list->size()); | 1442 ASSERT_EQ(2u, browser_list->size()); |
| 1443 | 1443 |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1615 EXPECT_TRUE(IsWindowPositionManaged(browser2->window()->GetNativeWindow())); | 1615 EXPECT_TRUE(IsWindowPositionManaged(browser2->window()->GetNativeWindow())); |
| 1616 EXPECT_FALSE(HasUserChangedWindowPositionOrSize( | 1616 EXPECT_FALSE(HasUserChangedWindowPositionOrSize( |
| 1617 browser2->window()->GetNativeWindow())); | 1617 browser2->window()->GetNativeWindow())); |
| 1618 // Also make sure that the drag to window position has not changed. | 1618 // Also make sure that the drag to window position has not changed. |
| 1619 EXPECT_EQ(initial_bounds.ToString(), | 1619 EXPECT_EQ(initial_bounds.ToString(), |
| 1620 browser2->window()->GetBounds().ToString()); | 1620 browser2->window()->GetBounds().ToString()); |
| 1621 } | 1621 } |
| 1622 | 1622 |
| 1623 namespace { | 1623 namespace { |
| 1624 | 1624 |
| 1625 // Invoked from the nested message loop. | 1625 // Invoked from the nested run loop. |
| 1626 void CancelOnNewTabWhenDraggingStep2( | 1626 void CancelOnNewTabWhenDraggingStep2( |
| 1627 DetachToBrowserTabDragControllerTest* test, | 1627 DetachToBrowserTabDragControllerTest* test, |
| 1628 const BrowserList* browser_list) { | 1628 const BrowserList* browser_list) { |
| 1629 ASSERT_TRUE(TabDragController::IsActive()); | 1629 ASSERT_TRUE(TabDragController::IsActive()); |
| 1630 ASSERT_EQ(2u, browser_list->size()); | 1630 ASSERT_EQ(2u, browser_list->size()); |
| 1631 | 1631 |
| 1632 chrome::AddTabAt(browser_list->GetLastActive(), GURL(url::kAboutBlankURL), | 1632 chrome::AddTabAt(browser_list->GetLastActive(), GURL(url::kAboutBlankURL), |
| 1633 0, false); | 1633 0, false); |
| 1634 } | 1634 } |
| 1635 | 1635 |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1837 EXPECT_EQ("0", IDString(new_browser->tab_strip_model())); | 1837 EXPECT_EQ("0", IDString(new_browser->tab_strip_model())); |
| 1838 EXPECT_EQ("1", IDString(browser()->tab_strip_model())); | 1838 EXPECT_EQ("1", IDString(browser()->tab_strip_model())); |
| 1839 | 1839 |
| 1840 // Both windows should not be maximized | 1840 // Both windows should not be maximized |
| 1841 EXPECT_FALSE(browser()->window()->IsMaximized()); | 1841 EXPECT_FALSE(browser()->window()->IsMaximized()); |
| 1842 EXPECT_FALSE(new_browser->window()->IsMaximized()); | 1842 EXPECT_FALSE(new_browser->window()->IsMaximized()); |
| 1843 } | 1843 } |
| 1844 | 1844 |
| 1845 namespace { | 1845 namespace { |
| 1846 | 1846 |
| 1847 // Invoked from the nested message loop. | 1847 // Invoked from the nested run loop. |
| 1848 void DragTabToWindowInSeparateDisplayStep2( | 1848 void DragTabToWindowInSeparateDisplayStep2( |
| 1849 DetachToBrowserTabDragControllerTest* test, | 1849 DetachToBrowserTabDragControllerTest* test, |
| 1850 TabStrip* not_attached_tab_strip, | 1850 TabStrip* not_attached_tab_strip, |
| 1851 TabStrip* target_tab_strip) { | 1851 TabStrip* target_tab_strip) { |
| 1852 ASSERT_FALSE(not_attached_tab_strip->IsDragSessionActive()); | 1852 ASSERT_FALSE(not_attached_tab_strip->IsDragSessionActive()); |
| 1853 ASSERT_FALSE(target_tab_strip->IsDragSessionActive()); | 1853 ASSERT_FALSE(target_tab_strip->IsDragSessionActive()); |
| 1854 ASSERT_TRUE(TabDragController::IsActive()); | 1854 ASSERT_TRUE(TabDragController::IsActive()); |
| 1855 | 1855 |
| 1856 // Drag to target_tab_strip. This should stop the nested loop from dragging | 1856 // Drag to target_tab_strip. This should stop the nested loop from dragging |
| 1857 // the window. | 1857 // the window. |
| (...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2261 DCHECK(TabDragController::IsActive()); | 2261 DCHECK(TabDragController::IsActive()); |
| 2262 test::QuitWhenNotDraggingImpl(); | 2262 test::QuitWhenNotDraggingImpl(); |
| 2263 base::RunLoop().Run(); | 2263 base::RunLoop().Run(); |
| 2264 } | 2264 } |
| 2265 | 2265 |
| 2266 private: | 2266 private: |
| 2267 DISALLOW_COPY_AND_ASSIGN( | 2267 DISALLOW_COPY_AND_ASSIGN( |
| 2268 DetachToBrowserInSeparateDisplayAndCancelTabDragControllerTest); | 2268 DetachToBrowserInSeparateDisplayAndCancelTabDragControllerTest); |
| 2269 }; | 2269 }; |
| 2270 | 2270 |
| 2271 // Invoked from the nested message loop. | 2271 // Invoked from the nested run loop. |
| 2272 void CancelDragTabToWindowInSeparateDisplayStep3( | 2272 void CancelDragTabToWindowInSeparateDisplayStep3( |
| 2273 TabStrip* tab_strip, | 2273 TabStrip* tab_strip, |
| 2274 const BrowserList* browser_list) { | 2274 const BrowserList* browser_list) { |
| 2275 ASSERT_FALSE(tab_strip->IsDragSessionActive()); | 2275 ASSERT_FALSE(tab_strip->IsDragSessionActive()); |
| 2276 ASSERT_TRUE(TabDragController::IsActive()); | 2276 ASSERT_TRUE(TabDragController::IsActive()); |
| 2277 ASSERT_EQ(2u, browser_list->size()); | 2277 ASSERT_EQ(2u, browser_list->size()); |
| 2278 | 2278 |
| 2279 // Switching display mode should cancel the drag operation. | 2279 // Switching display mode should cancel the drag operation. |
| 2280 display::DisplayManager* display_manager = | 2280 display::DisplayManager* display_manager = |
| 2281 ash::Shell::Get()->display_manager(); | 2281 ash::Shell::Get()->display_manager(); |
| 2282 display_manager->AddRemoveDisplay(); | 2282 display_manager->AddRemoveDisplay(); |
| 2283 } | 2283 } |
| 2284 | 2284 |
| 2285 // Invoked from the nested message loop. | 2285 // Invoked from the nested run loop. |
| 2286 void CancelDragTabToWindowInSeparateDisplayStep2( | 2286 void CancelDragTabToWindowInSeparateDisplayStep2( |
| 2287 DetachToBrowserInSeparateDisplayAndCancelTabDragControllerTest* test, | 2287 DetachToBrowserInSeparateDisplayAndCancelTabDragControllerTest* test, |
| 2288 TabStrip* tab_strip, | 2288 TabStrip* tab_strip, |
| 2289 aura::Window* current_root, | 2289 aura::Window* current_root, |
| 2290 gfx::Point final_destination, | 2290 gfx::Point final_destination, |
| 2291 const BrowserList* browser_list) { | 2291 const BrowserList* browser_list) { |
| 2292 ASSERT_FALSE(tab_strip->IsDragSessionActive()); | 2292 ASSERT_FALSE(tab_strip->IsDragSessionActive()); |
| 2293 ASSERT_TRUE(TabDragController::IsActive()); | 2293 ASSERT_TRUE(TabDragController::IsActive()); |
| 2294 ASSERT_EQ(2u, browser_list->size()); | 2294 ASSERT_EQ(2u, browser_list->size()); |
| 2295 | 2295 |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2464 DetachToBrowserTabDragControllerTest, | 2464 DetachToBrowserTabDragControllerTest, |
| 2465 ::testing::Values("mouse", "touch")); | 2465 ::testing::Values("mouse", "touch")); |
| 2466 INSTANTIATE_TEST_CASE_P(TabDragging, | 2466 INSTANTIATE_TEST_CASE_P(TabDragging, |
| 2467 DetachToBrowserTabDragControllerTestTouch, | 2467 DetachToBrowserTabDragControllerTestTouch, |
| 2468 ::testing::Values("touch")); | 2468 ::testing::Values("touch")); |
| 2469 #else | 2469 #else |
| 2470 INSTANTIATE_TEST_CASE_P(TabDragging, | 2470 INSTANTIATE_TEST_CASE_P(TabDragging, |
| 2471 DetachToBrowserTabDragControllerTest, | 2471 DetachToBrowserTabDragControllerTest, |
| 2472 ::testing::Values("mouse")); | 2472 ::testing::Values("mouse")); |
| 2473 #endif | 2473 #endif |
| OLD | NEW |