| 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/property_util.h" | 7 #include "ash/wm/property_util.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" |
| 11 #include "base/run_loop.h" | 11 #include "base/run_loop.h" |
| 12 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
| 13 #include "chrome/browser/ui/browser.h" | 13 #include "chrome/browser/ui/browser.h" |
| 14 #include "chrome/browser/ui/browser_list.h" | 14 #include "chrome/browser/ui/browser_iterator.h" |
| 15 #include "chrome/browser/ui/browser_list_impl.h" |
| 16 #include "chrome/browser/ui/host_desktop.h" |
| 15 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 17 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 16 #include "chrome/browser/ui/views/frame/browser_view.h" | 18 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 17 #include "chrome/browser/ui/views/tabs/tab.h" | 19 #include "chrome/browser/ui/views/tabs/tab.h" |
| 18 #include "chrome/browser/ui/views/tabs/tab_drag_controller.h" | 20 #include "chrome/browser/ui/views/tabs/tab_drag_controller.h" |
| 19 #include "chrome/browser/ui/views/tabs/tab_strip.h" | 21 #include "chrome/browser/ui/views/tabs/tab_strip.h" |
| 20 #include "chrome/common/chrome_notification_types.h" | 22 #include "chrome/common/chrome_notification_types.h" |
| 21 #include "chrome/common/chrome_switches.h" | 23 #include "chrome/common/chrome_switches.h" |
| 22 #include "chrome/test/base/in_process_browser_test.h" | 24 #include "chrome/test/base/in_process_browser_test.h" |
| 23 #include "chrome/test/base/interactive_test_utils.h" | 25 #include "chrome/test/base/interactive_test_utils.h" |
| 24 #include "chrome/test/base/ui_controls.h" | 26 #include "chrome/test/base/ui_controls.h" |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 } | 135 } |
| 134 | 136 |
| 135 } // namespace test | 137 } // namespace test |
| 136 | 138 |
| 137 using test::GetCenterInScreenCoordinates; | 139 using test::GetCenterInScreenCoordinates; |
| 138 using test::SetID; | 140 using test::SetID; |
| 139 using test::ResetIDs; | 141 using test::ResetIDs; |
| 140 using test::IDString; | 142 using test::IDString; |
| 141 using test::GetTabStripForBrowser; | 143 using test::GetTabStripForBrowser; |
| 142 | 144 |
| 143 TabDragControllerTest::TabDragControllerTest() { | 145 TabDragControllerTest::TabDragControllerTest() |
| 146 : native_browser_list(chrome::BrowserListImpl::GetInstance( |
| 147 chrome::HOST_DESKTOP_TYPE_NATIVE)) { |
| 144 } | 148 } |
| 145 | 149 |
| 146 TabDragControllerTest::~TabDragControllerTest() { | 150 TabDragControllerTest::~TabDragControllerTest() { |
| 147 } | 151 } |
| 148 | 152 |
| 149 void TabDragControllerTest::StopAnimating(TabStrip* tab_strip) { | 153 void TabDragControllerTest::StopAnimating(TabStrip* tab_strip) { |
| 150 tab_strip->StopAnimating(true); | 154 tab_strip->StopAnimating(true); |
| 151 } | 155 } |
| 152 | 156 |
| 153 void TabDragControllerTest::AddTabAndResetBrowser(Browser* browser) { | 157 void TabDragControllerTest::AddTabAndResetBrowser(Browser* browser) { |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 438 if (input_source() == INPUT_SOURCE_MOUSE) { | 442 if (input_source() == INPUT_SOURCE_MOUSE) { |
| 439 ASSERT_TRUE(ReleaseMouseAsync()); | 443 ASSERT_TRUE(ReleaseMouseAsync()); |
| 440 QuitWhenNotDragging(); | 444 QuitWhenNotDragging(); |
| 441 } | 445 } |
| 442 | 446 |
| 443 // Should no longer be dragging. | 447 // Should no longer be dragging. |
| 444 ASSERT_FALSE(tab_strip->IsDragSessionActive()); | 448 ASSERT_FALSE(tab_strip->IsDragSessionActive()); |
| 445 ASSERT_FALSE(TabDragController::IsActive()); | 449 ASSERT_FALSE(TabDragController::IsActive()); |
| 446 | 450 |
| 447 // There should now be another browser. | 451 // There should now be another browser. |
| 448 ASSERT_EQ(2u, BrowserList::size()); | 452 ASSERT_EQ(2u, native_browser_list->size()); |
| 449 Browser* new_browser = *(++BrowserList::begin()); | 453 Browser* new_browser = native_browser_list->get(1); |
| 450 ASSERT_TRUE(new_browser->window()->IsActive()); | 454 ASSERT_TRUE(new_browser->window()->IsActive()); |
| 451 TabStrip* tab_strip2 = GetTabStripForBrowser(new_browser); | 455 TabStrip* tab_strip2 = GetTabStripForBrowser(new_browser); |
| 452 ASSERT_FALSE(tab_strip2->IsDragSessionActive()); | 456 ASSERT_FALSE(tab_strip2->IsDragSessionActive()); |
| 453 | 457 |
| 454 EXPECT_EQ("0", IDString(new_browser->tab_strip_model())); | 458 EXPECT_EQ("0", IDString(new_browser->tab_strip_model())); |
| 455 EXPECT_EQ("1", IDString(browser()->tab_strip_model())); | 459 EXPECT_EQ("1", IDString(browser()->tab_strip_model())); |
| 456 | 460 |
| 457 // The bounds of the initial window should not have changed. | 461 // The bounds of the initial window should not have changed. |
| 458 EXPECT_EQ(initial_bounds.ToString(), | 462 EXPECT_EQ(initial_bounds.ToString(), |
| 459 browser()->window()->GetBounds().ToString()); | 463 browser()->window()->GetBounds().ToString()); |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 552 ASSERT_FALSE(tab_strip->IsDragSessionActive()); | 556 ASSERT_FALSE(tab_strip->IsDragSessionActive()); |
| 553 ASSERT_FALSE(TabDragController::IsActive()); | 557 ASSERT_FALSE(TabDragController::IsActive()); |
| 554 | 558 |
| 555 EXPECT_EQ("1", IDString(browser()->tab_strip_model())); | 559 EXPECT_EQ("1", IDString(browser()->tab_strip_model())); |
| 556 | 560 |
| 557 EXPECT_TRUE(GetTrackedByWorkspace(browser())); | 561 EXPECT_TRUE(GetTrackedByWorkspace(browser())); |
| 558 } | 562 } |
| 559 | 563 |
| 560 namespace { | 564 namespace { |
| 561 | 565 |
| 562 void DeleteSourceDetachedStep2(WebContents* tab) { | 566 void DeleteSourceDetachedStep2(WebContents* tab, |
| 563 ASSERT_EQ(2u, BrowserList::size()); | 567 const chrome::BrowserListImpl* browser_list) { |
| 564 Browser* new_browser = *(++BrowserList::begin()); | 568 ASSERT_EQ(2u, browser_list->size()); |
| 569 Browser* new_browser = browser_list->get(1); |
| 565 // This ends up closing the source window. | 570 // This ends up closing the source window. |
| 566 delete tab; | 571 delete tab; |
| 567 // Cancel the drag. | 572 // Cancel the drag. |
| 568 ui_controls::SendKeyPress(new_browser->window()->GetNativeWindow(), | 573 ui_controls::SendKeyPress(new_browser->window()->GetNativeWindow(), |
| 569 ui::VKEY_ESCAPE, false, false, false, false); | 574 ui::VKEY_ESCAPE, false, false, false, false); |
| 570 } | 575 } |
| 571 | 576 |
| 572 } // namespace | 577 } // namespace |
| 573 | 578 |
| 574 // Detaches a tab and while detached deletes a tab from the source so that the | 579 // Detaches a tab and while detached deletes a tab from the source so that the |
| 575 // source window closes then presses escape to cancel the drag. | 580 // source window closes then presses escape to cancel the drag. |
| 576 IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest, | 581 IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest, |
| 577 DeleteSourceDetached) { | 582 DeleteSourceDetached) { |
| 578 // Add another tab. | 583 // Add another tab. |
| 579 AddTabAndResetBrowser(browser()); | 584 AddTabAndResetBrowser(browser()); |
| 580 TabStrip* tab_strip = GetTabStripForBrowser(browser()); | 585 TabStrip* tab_strip = GetTabStripForBrowser(browser()); |
| 581 | 586 |
| 582 // Move to the first tab and drag it enough so that it detaches. | 587 // Move to the first tab and drag it enough so that it detaches. |
| 583 gfx::Point tab_0_center(GetCenterInScreenCoordinates(tab_strip->tab_at(0))); | 588 gfx::Point tab_0_center(GetCenterInScreenCoordinates(tab_strip->tab_at(0))); |
| 584 WebContents* to_delete = browser()->tab_strip_model()->GetWebContentsAt(1); | 589 WebContents* to_delete = browser()->tab_strip_model()->GetWebContentsAt(1); |
| 585 ASSERT_TRUE(PressInput(tab_0_center)); | 590 ASSERT_TRUE(PressInput(tab_0_center)); |
| 586 ASSERT_TRUE(DragInputToNotifyWhenDone( | 591 ASSERT_TRUE(DragInputToNotifyWhenDone( |
| 587 tab_0_center.x(), tab_0_center.y() + GetDetachY(tab_strip), | 592 tab_0_center.x(), tab_0_center.y() + GetDetachY(tab_strip), |
| 588 base::Bind(&DeleteSourceDetachedStep2, to_delete))); | 593 base::Bind(&DeleteSourceDetachedStep2, to_delete, native_browser_list))); |
| 589 QuitWhenNotDragging(); | 594 QuitWhenNotDragging(); |
| 590 | 595 |
| 591 // Should not be dragging. | 596 // Should not be dragging. |
| 592 ASSERT_EQ(1u, BrowserList::size()); | 597 ASSERT_EQ(1u, native_browser_list->size()); |
| 593 Browser* new_browser = *BrowserList::begin(); | 598 Browser* new_browser = native_browser_list->get(0); |
| 594 ASSERT_FALSE(GetTabStripForBrowser(new_browser)->IsDragSessionActive()); | 599 ASSERT_FALSE(GetTabStripForBrowser(new_browser)->IsDragSessionActive()); |
| 595 ASSERT_FALSE(TabDragController::IsActive()); | 600 ASSERT_FALSE(TabDragController::IsActive()); |
| 596 | 601 |
| 597 EXPECT_EQ("0", IDString(new_browser->tab_strip_model())); | 602 EXPECT_EQ("0", IDString(new_browser->tab_strip_model())); |
| 598 | 603 |
| 599 EXPECT_TRUE(GetTrackedByWorkspace(new_browser)); | 604 EXPECT_TRUE(GetTrackedByWorkspace(new_browser)); |
| 600 } | 605 } |
| 601 | 606 |
| 602 namespace { | 607 namespace { |
| 603 | 608 |
| 604 void PressEscapeWhileDetachedStep2() { | 609 void PressEscapeWhileDetachedStep2( |
| 605 ASSERT_EQ(2u, BrowserList::size()); | 610 const chrome::BrowserListImpl* browser_list) { |
| 606 Browser* new_browser = *(++BrowserList::begin()); | 611 ASSERT_EQ(2u, browser_list->size()); |
| 612 Browser* new_browser = browser_list->get(1); |
| 607 ui_controls::SendKeyPress( | 613 ui_controls::SendKeyPress( |
| 608 new_browser->window()->GetNativeWindow(), ui::VKEY_ESCAPE, false, false, | 614 new_browser->window()->GetNativeWindow(), ui::VKEY_ESCAPE, false, false, |
| 609 false, false); | 615 false, false); |
| 610 } | 616 } |
| 611 | 617 |
| 612 } // namespace | 618 } // namespace |
| 613 | 619 |
| 614 // This is disabled until NativeViewHost::Detach really detaches. | 620 // This is disabled until NativeViewHost::Detach really detaches. |
| 615 // Detaches a tab and while detached presses escape to revert the drag. | 621 // Detaches a tab and while detached presses escape to revert the drag. |
| 616 IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest, | 622 IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest, |
| 617 PressEscapeWhileDetached) { | 623 PressEscapeWhileDetached) { |
| 618 // Add another tab. | 624 // Add another tab. |
| 619 AddTabAndResetBrowser(browser()); | 625 AddTabAndResetBrowser(browser()); |
| 620 TabStrip* tab_strip = GetTabStripForBrowser(browser()); | 626 TabStrip* tab_strip = GetTabStripForBrowser(browser()); |
| 621 | 627 |
| 622 // Move to the first tab and drag it enough so that it detaches. | 628 // Move to the first tab and drag it enough so that it detaches. |
| 623 gfx::Point tab_0_center(GetCenterInScreenCoordinates(tab_strip->tab_at(0))); | 629 gfx::Point tab_0_center(GetCenterInScreenCoordinates(tab_strip->tab_at(0))); |
| 624 ASSERT_TRUE(PressInput(tab_0_center)); | 630 ASSERT_TRUE(PressInput(tab_0_center)); |
| 625 ASSERT_TRUE(DragInputToNotifyWhenDone( | 631 ASSERT_TRUE(DragInputToNotifyWhenDone( |
| 626 tab_0_center.x(), tab_0_center.y() + GetDetachY(tab_strip), | 632 tab_0_center.x(), tab_0_center.y() + GetDetachY(tab_strip), |
| 627 base::Bind(&PressEscapeWhileDetachedStep2))); | 633 base::Bind(&PressEscapeWhileDetachedStep2, native_browser_list))); |
| 628 QuitWhenNotDragging(); | 634 QuitWhenNotDragging(); |
| 629 | 635 |
| 630 // Should not be dragging. | 636 // Should not be dragging. |
| 631 ASSERT_FALSE(tab_strip->IsDragSessionActive()); | 637 ASSERT_FALSE(tab_strip->IsDragSessionActive()); |
| 632 ASSERT_FALSE(TabDragController::IsActive()); | 638 ASSERT_FALSE(TabDragController::IsActive()); |
| 633 | 639 |
| 634 // And there should only be one window. | 640 // And there should only be one window. |
| 635 EXPECT_EQ(1u, BrowserList::size()); | 641 EXPECT_EQ(1u, native_browser_list->size()); |
| 636 | 642 |
| 637 EXPECT_EQ("0 1", IDString(browser()->tab_strip_model())); | 643 EXPECT_EQ("0 1", IDString(browser()->tab_strip_model())); |
| 638 } | 644 } |
| 639 | 645 |
| 640 namespace { | 646 namespace { |
| 641 | 647 |
| 642 void DragAllStep2(DetachToBrowserTabDragControllerTest* test) { | 648 void DragAllStep2(DetachToBrowserTabDragControllerTest* test, |
| 649 const chrome::BrowserListImpl* browser_list) { |
| 643 // Should only be one window. | 650 // Should only be one window. |
| 644 ASSERT_EQ(1u, BrowserList::size()); | 651 ASSERT_EQ(1u, browser_list->size()); |
| 645 if (test->input_source() == INPUT_SOURCE_TOUCH) { | 652 if (test->input_source() == INPUT_SOURCE_TOUCH) { |
| 646 ASSERT_TRUE(test->ReleaseInput()); | 653 ASSERT_TRUE(test->ReleaseInput()); |
| 647 } else { | 654 } else { |
| 648 ASSERT_TRUE(test->ReleaseMouseAsync()); | 655 ASSERT_TRUE(test->ReleaseMouseAsync()); |
| 649 } | 656 } |
| 650 } | 657 } |
| 651 | 658 |
| 652 } // namespace | 659 } // namespace |
| 653 | 660 |
| 654 // Selects multiple tabs and starts dragging the window. | 661 // Selects multiple tabs and starts dragging the window. |
| 655 IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest, DragAll) { | 662 IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest, DragAll) { |
| 656 // Add another tab. | 663 // Add another tab. |
| 657 AddTabAndResetBrowser(browser()); | 664 AddTabAndResetBrowser(browser()); |
| 658 TabStrip* tab_strip = GetTabStripForBrowser(browser()); | 665 TabStrip* tab_strip = GetTabStripForBrowser(browser()); |
| 659 browser()->tab_strip_model()->AddTabAtToSelection(0); | 666 browser()->tab_strip_model()->AddTabAtToSelection(0); |
| 660 browser()->tab_strip_model()->AddTabAtToSelection(1); | 667 browser()->tab_strip_model()->AddTabAtToSelection(1); |
| 661 | 668 |
| 662 // Move to the first tab and drag it enough so that it would normally | 669 // Move to the first tab and drag it enough so that it would normally |
| 663 // detach. | 670 // detach. |
| 664 gfx::Point tab_0_center(GetCenterInScreenCoordinates(tab_strip->tab_at(0))); | 671 gfx::Point tab_0_center(GetCenterInScreenCoordinates(tab_strip->tab_at(0))); |
| 665 ASSERT_TRUE(PressInput(tab_0_center)); | 672 ASSERT_TRUE(PressInput(tab_0_center)); |
| 666 ASSERT_TRUE(DragInputToNotifyWhenDone( | 673 ASSERT_TRUE(DragInputToNotifyWhenDone( |
| 667 tab_0_center.x(), tab_0_center.y() + GetDetachY(tab_strip), | 674 tab_0_center.x(), tab_0_center.y() + GetDetachY(tab_strip), |
| 668 base::Bind(&DragAllStep2, this))); | 675 base::Bind(&DragAllStep2, this, native_browser_list))); |
| 669 QuitWhenNotDragging(); | 676 QuitWhenNotDragging(); |
| 670 | 677 |
| 671 // Should not be dragging. | 678 // Should not be dragging. |
| 672 ASSERT_FALSE(tab_strip->IsDragSessionActive()); | 679 ASSERT_FALSE(tab_strip->IsDragSessionActive()); |
| 673 ASSERT_FALSE(TabDragController::IsActive()); | 680 ASSERT_FALSE(TabDragController::IsActive()); |
| 674 | 681 |
| 675 // And there should only be one window. | 682 // And there should only be one window. |
| 676 EXPECT_EQ(1u, BrowserList::size()); | 683 EXPECT_EQ(1u, native_browser_list->size()); |
| 677 | 684 |
| 678 EXPECT_EQ("0 1", IDString(browser()->tab_strip_model())); | 685 EXPECT_EQ("0 1", IDString(browser()->tab_strip_model())); |
| 679 | 686 |
| 680 EXPECT_TRUE(GetTrackedByWorkspace(browser())); | 687 EXPECT_TRUE(GetTrackedByWorkspace(browser())); |
| 681 } | 688 } |
| 682 | 689 |
| 683 namespace { | 690 namespace { |
| 684 | 691 |
| 685 // Invoked from the nested message loop. | 692 // Invoked from the nested message loop. |
| 686 void DragAllToSeparateWindowStep2(DetachToBrowserTabDragControllerTest* test, | 693 void DragAllToSeparateWindowStep2(DetachToBrowserTabDragControllerTest* test, |
| 687 TabStrip* attached_tab_strip, | 694 TabStrip* attached_tab_strip, |
| 688 TabStrip* target_tab_strip) { | 695 TabStrip* target_tab_strip, |
| 696 const chrome::BrowserListImpl* browser_list) { |
| 689 ASSERT_TRUE(attached_tab_strip->IsDragSessionActive()); | 697 ASSERT_TRUE(attached_tab_strip->IsDragSessionActive()); |
| 690 ASSERT_FALSE(target_tab_strip->IsDragSessionActive()); | 698 ASSERT_FALSE(target_tab_strip->IsDragSessionActive()); |
| 691 ASSERT_TRUE(TabDragController::IsActive()); | 699 ASSERT_TRUE(TabDragController::IsActive()); |
| 692 ASSERT_EQ(2u, BrowserList::size()); | 700 ASSERT_EQ(2u, browser_list->size()); |
| 693 | 701 |
| 694 // Drag to target_tab_strip. This should stop the nested loop from dragging | 702 // Drag to target_tab_strip. This should stop the nested loop from dragging |
| 695 // the window. | 703 // the window. |
| 696 gfx::Point target_point(target_tab_strip->width() - 1, | 704 gfx::Point target_point(target_tab_strip->width() - 1, |
| 697 target_tab_strip->height() / 2); | 705 target_tab_strip->height() / 2); |
| 698 views::View::ConvertPointToScreen(target_tab_strip, &target_point); | 706 views::View::ConvertPointToScreen(target_tab_strip, &target_point); |
| 699 ASSERT_TRUE(test->DragInputToAsync(target_point)); | 707 ASSERT_TRUE(test->DragInputToAsync(target_point)); |
| 700 } | 708 } |
| 701 | 709 |
| 702 } // namespace | 710 } // namespace |
| (...skipping 13 matching lines...) Expand all Loading... |
| 716 browser()->tab_strip_model()->AddTabAtToSelection(0); | 724 browser()->tab_strip_model()->AddTabAtToSelection(0); |
| 717 browser()->tab_strip_model()->AddTabAtToSelection(1); | 725 browser()->tab_strip_model()->AddTabAtToSelection(1); |
| 718 | 726 |
| 719 // Move to the first tab and drag it enough so that it detaches, but not | 727 // Move to the first tab and drag it enough so that it detaches, but not |
| 720 // enough that it attaches to browser2. | 728 // enough that it attaches to browser2. |
| 721 gfx::Point tab_0_center( | 729 gfx::Point tab_0_center( |
| 722 GetCenterInScreenCoordinates(tab_strip->tab_at(0))); | 730 GetCenterInScreenCoordinates(tab_strip->tab_at(0))); |
| 723 ASSERT_TRUE(PressInput(tab_0_center)); | 731 ASSERT_TRUE(PressInput(tab_0_center)); |
| 724 ASSERT_TRUE(DragInputToNotifyWhenDone( | 732 ASSERT_TRUE(DragInputToNotifyWhenDone( |
| 725 tab_0_center.x(), tab_0_center.y() + GetDetachY(tab_strip), | 733 tab_0_center.x(), tab_0_center.y() + GetDetachY(tab_strip), |
| 726 base::Bind(&DragAllToSeparateWindowStep2, this, tab_strip, tab_strip2))); | 734 base::Bind(&DragAllToSeparateWindowStep2, this, tab_strip, tab_strip2, |
| 735 native_browser_list))); |
| 727 QuitWhenNotDragging(); | 736 QuitWhenNotDragging(); |
| 728 | 737 |
| 729 // Should now be attached to tab_strip2. | 738 // Should now be attached to tab_strip2. |
| 730 ASSERT_TRUE(tab_strip2->IsDragSessionActive()); | 739 ASSERT_TRUE(tab_strip2->IsDragSessionActive()); |
| 731 ASSERT_TRUE(TabDragController::IsActive()); | 740 ASSERT_TRUE(TabDragController::IsActive()); |
| 732 ASSERT_EQ(1u, BrowserList::size()); | 741 ASSERT_EQ(1u, native_browser_list->size()); |
| 733 | 742 |
| 734 // Release the mouse, stopping the drag session. | 743 // Release the mouse, stopping the drag session. |
| 735 ASSERT_TRUE(ReleaseInput()); | 744 ASSERT_TRUE(ReleaseInput()); |
| 736 ASSERT_FALSE(tab_strip2->IsDragSessionActive()); | 745 ASSERT_FALSE(tab_strip2->IsDragSessionActive()); |
| 737 ASSERT_FALSE(TabDragController::IsActive()); | 746 ASSERT_FALSE(TabDragController::IsActive()); |
| 738 EXPECT_EQ("100 0 1", IDString(browser2->tab_strip_model())); | 747 EXPECT_EQ("100 0 1", IDString(browser2->tab_strip_model())); |
| 739 | 748 |
| 740 EXPECT_TRUE(GetTrackedByWorkspace(browser2)); | 749 EXPECT_TRUE(GetTrackedByWorkspace(browser2)); |
| 741 } | 750 } |
| 742 | 751 |
| 743 namespace { | 752 namespace { |
| 744 | 753 |
| 745 // Invoked from the nested message loop. | 754 // Invoked from the nested message loop. |
| 746 void DragAllToSeparateWindowAndCancelStep2( | 755 void DragAllToSeparateWindowAndCancelStep2( |
| 747 DetachToBrowserTabDragControllerTest* test, | 756 DetachToBrowserTabDragControllerTest* test, |
| 748 TabStrip* attached_tab_strip, | 757 TabStrip* attached_tab_strip, |
| 749 TabStrip* target_tab_strip) { | 758 TabStrip* target_tab_strip, |
| 759 const chrome::BrowserListImpl* browser_list) { |
| 750 ASSERT_TRUE(attached_tab_strip->IsDragSessionActive()); | 760 ASSERT_TRUE(attached_tab_strip->IsDragSessionActive()); |
| 751 ASSERT_FALSE(target_tab_strip->IsDragSessionActive()); | 761 ASSERT_FALSE(target_tab_strip->IsDragSessionActive()); |
| 752 ASSERT_TRUE(TabDragController::IsActive()); | 762 ASSERT_TRUE(TabDragController::IsActive()); |
| 753 ASSERT_EQ(2u, BrowserList::size()); | 763 ASSERT_EQ(2u, browser_list->size()); |
| 754 | 764 |
| 755 // Drag to target_tab_strip. This should stop the nested loop from dragging | 765 // Drag to target_tab_strip. This should stop the nested loop from dragging |
| 756 // the window. | 766 // the window. |
| 757 gfx::Point target_point(target_tab_strip->width() - 1, | 767 gfx::Point target_point(target_tab_strip->width() - 1, |
| 758 target_tab_strip->height() / 2); | 768 target_tab_strip->height() / 2); |
| 759 views::View::ConvertPointToScreen(target_tab_strip, &target_point); | 769 views::View::ConvertPointToScreen(target_tab_strip, &target_point); |
| 760 ASSERT_TRUE(test->DragInputToAsync(target_point)); | 770 ASSERT_TRUE(test->DragInputToAsync(target_point)); |
| 761 } | 771 } |
| 762 | 772 |
| 763 } // namespace | 773 } // namespace |
| (...skipping 15 matching lines...) Expand all Loading... |
| 779 browser()->tab_strip_model()->AddTabAtToSelection(1); | 789 browser()->tab_strip_model()->AddTabAtToSelection(1); |
| 780 | 790 |
| 781 // Move to the first tab and drag it enough so that it detaches, but not | 791 // Move to the first tab and drag it enough so that it detaches, but not |
| 782 // enough that it attaches to browser2. | 792 // enough that it attaches to browser2. |
| 783 gfx::Point tab_0_center( | 793 gfx::Point tab_0_center( |
| 784 GetCenterInScreenCoordinates(tab_strip->tab_at(0))); | 794 GetCenterInScreenCoordinates(tab_strip->tab_at(0))); |
| 785 ASSERT_TRUE(PressInput(tab_0_center)); | 795 ASSERT_TRUE(PressInput(tab_0_center)); |
| 786 ASSERT_TRUE(DragInputToNotifyWhenDone( | 796 ASSERT_TRUE(DragInputToNotifyWhenDone( |
| 787 tab_0_center.x(), tab_0_center.y() + GetDetachY(tab_strip), | 797 tab_0_center.x(), tab_0_center.y() + GetDetachY(tab_strip), |
| 788 base::Bind(&DragAllToSeparateWindowAndCancelStep2, this, | 798 base::Bind(&DragAllToSeparateWindowAndCancelStep2, this, |
| 789 tab_strip, tab_strip2))); | 799 tab_strip, tab_strip2, native_browser_list))); |
| 790 QuitWhenNotDragging(); | 800 QuitWhenNotDragging(); |
| 791 | 801 |
| 792 // Should now be attached to tab_strip2. | 802 // Should now be attached to tab_strip2. |
| 793 ASSERT_TRUE(tab_strip2->IsDragSessionActive()); | 803 ASSERT_TRUE(tab_strip2->IsDragSessionActive()); |
| 794 ASSERT_TRUE(TabDragController::IsActive()); | 804 ASSERT_TRUE(TabDragController::IsActive()); |
| 795 ASSERT_EQ(1u, BrowserList::size()); | 805 ASSERT_EQ(1u, native_browser_list->size()); |
| 796 | 806 |
| 797 // Cancel the drag. | 807 // Cancel the drag. |
| 798 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( | 808 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( |
| 799 browser2, ui::VKEY_ESCAPE, false, false, false, false)); | 809 browser2, ui::VKEY_ESCAPE, false, false, false, false)); |
| 800 | 810 |
| 801 ASSERT_FALSE(tab_strip2->IsDragSessionActive()); | 811 ASSERT_FALSE(tab_strip2->IsDragSessionActive()); |
| 802 ASSERT_FALSE(TabDragController::IsActive()); | 812 ASSERT_FALSE(TabDragController::IsActive()); |
| 803 EXPECT_EQ("100 0 1", IDString(browser2->tab_strip_model())); | 813 EXPECT_EQ("100 0 1", IDString(browser2->tab_strip_model())); |
| 804 | 814 |
| 805 // browser() will have been destroyed, but browser2 should remain. | 815 // browser() will have been destroyed, but browser2 should remain. |
| 806 ASSERT_EQ(1u, BrowserList::size()); | 816 ASSERT_EQ(1u, native_browser_list->size()); |
| 807 | 817 |
| 808 EXPECT_TRUE(GetTrackedByWorkspace(browser2)); | 818 EXPECT_TRUE(GetTrackedByWorkspace(browser2)); |
| 809 } | 819 } |
| 810 | 820 |
| 811 // Creates two browsers, drags from first into the second in such a way that | 821 // Creates two browsers, drags from first into the second in such a way that |
| 812 // no detaching should happen. | 822 // no detaching should happen. |
| 813 IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest, | 823 IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest, |
| 814 DragDirectlyToSecondWindow) { | 824 DragDirectlyToSecondWindow) { |
| 815 TabStrip* tab_strip = GetTabStripForBrowser(browser()); | 825 TabStrip* tab_strip = GetTabStripForBrowser(browser()); |
| 816 | 826 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 865 TabStrip* tab_strip2 = GetTabStripForBrowser(browser2); | 875 TabStrip* tab_strip2 = GetTabStripForBrowser(browser2); |
| 866 const gfx::Rect initial_bounds(browser2->window()->GetBounds()); | 876 const gfx::Rect initial_bounds(browser2->window()->GetBounds()); |
| 867 | 877 |
| 868 // Move to the first tab and drag it enough so that it detaches, but not | 878 // Move to the first tab and drag it enough so that it detaches, but not |
| 869 // enough that it attaches to browser2. | 879 // enough that it attaches to browser2. |
| 870 gfx::Point tab_0_center( | 880 gfx::Point tab_0_center( |
| 871 GetCenterInScreenCoordinates(tab_strip->tab_at(0))); | 881 GetCenterInScreenCoordinates(tab_strip->tab_at(0))); |
| 872 ASSERT_TRUE(PressInput(tab_0_center)); | 882 ASSERT_TRUE(PressInput(tab_0_center)); |
| 873 ASSERT_TRUE(DragInputToNotifyWhenDone( | 883 ASSERT_TRUE(DragInputToNotifyWhenDone( |
| 874 tab_0_center.x(), tab_0_center.y() + GetDetachY(tab_strip), | 884 tab_0_center.x(), tab_0_center.y() + GetDetachY(tab_strip), |
| 875 base::Bind(&DragAllToSeparateWindowStep2, this, tab_strip, tab_strip2))); | 885 base::Bind(&DragAllToSeparateWindowStep2, this, tab_strip, tab_strip2, |
| 886 native_browser_list))); |
| 876 QuitWhenNotDragging(); | 887 QuitWhenNotDragging(); |
| 877 | 888 |
| 878 // Should now be attached to tab_strip2. | 889 // Should now be attached to tab_strip2. |
| 879 ASSERT_TRUE(tab_strip2->IsDragSessionActive()); | 890 ASSERT_TRUE(tab_strip2->IsDragSessionActive()); |
| 880 ASSERT_TRUE(TabDragController::IsActive()); | 891 ASSERT_TRUE(TabDragController::IsActive()); |
| 881 ASSERT_EQ(1u, BrowserList::size()); | 892 ASSERT_EQ(1u, native_browser_list->size()); |
| 882 | 893 |
| 883 // Release the mouse, stopping the drag session. | 894 // Release the mouse, stopping the drag session. |
| 884 ASSERT_TRUE(ReleaseInput()); | 895 ASSERT_TRUE(ReleaseInput()); |
| 885 ASSERT_FALSE(tab_strip2->IsDragSessionActive()); | 896 ASSERT_FALSE(tab_strip2->IsDragSessionActive()); |
| 886 ASSERT_FALSE(TabDragController::IsActive()); | 897 ASSERT_FALSE(TabDragController::IsActive()); |
| 887 EXPECT_EQ("100 0", IDString(browser2->tab_strip_model())); | 898 EXPECT_EQ("100 0", IDString(browser2->tab_strip_model())); |
| 888 | 899 |
| 889 EXPECT_TRUE(GetTrackedByWorkspace(browser2)); | 900 EXPECT_TRUE(GetTrackedByWorkspace(browser2)); |
| 890 // Make sure that the window is still managed and not user moved. | 901 // Make sure that the window is still managed and not user moved. |
| 891 EXPECT_TRUE(IsWindowPositionManaged(browser2->window()->GetNativeWindow())); | 902 EXPECT_TRUE(IsWindowPositionManaged(browser2->window()->GetNativeWindow())); |
| 892 EXPECT_FALSE(HasUserChangedWindowPositionOrSize( | 903 EXPECT_FALSE(HasUserChangedWindowPositionOrSize( |
| 893 browser2->window()->GetNativeWindow())); | 904 browser2->window()->GetNativeWindow())); |
| 894 // Also make sure that the drag to window position has not changed. | 905 // Also make sure that the drag to window position has not changed. |
| 895 EXPECT_EQ(initial_bounds.ToString(), | 906 EXPECT_EQ(initial_bounds.ToString(), |
| 896 browser2->window()->GetBounds().ToString()); | 907 browser2->window()->GetBounds().ToString()); |
| 897 } | 908 } |
| 898 | 909 |
| 899 namespace { | 910 namespace { |
| 900 | 911 |
| 901 // Invoked from the nested message loop. | 912 // Invoked from the nested message loop. |
| 902 void CancelOnNewTabWhenDraggingStep2( | 913 void CancelOnNewTabWhenDraggingStep2( |
| 903 DetachToBrowserTabDragControllerTest* test) { | 914 DetachToBrowserTabDragControllerTest* test, |
| 915 const chrome::BrowserListImpl* browser_list) { |
| 904 ASSERT_TRUE(TabDragController::IsActive()); | 916 ASSERT_TRUE(TabDragController::IsActive()); |
| 905 ASSERT_EQ(2u, BrowserList::size()); | 917 ASSERT_EQ(2u, browser_list->size()); |
| 906 | 918 |
| 907 // Add another tab. This shoudl trigger exiting the nested loop. | 919 // Add another tab. This should trigger exiting the nested loop. |
| 908 test->AddBlankTabAndShow(*BrowserList::begin_last_active()); | 920 test->AddBlankTabAndShow(browser_list->GetLastActive()); |
| 909 } | 921 } |
| 910 | 922 |
| 911 } // namespace | 923 } // namespace |
| 912 | 924 |
| 913 // Adds another tab, detaches into separate window, adds another tab and | 925 // Adds another tab, detaches into separate window, adds another tab and |
| 914 // verifies the run loop ends. | 926 // verifies the run loop ends. |
| 915 IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest, | 927 IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest, |
| 916 CancelOnNewTabWhenDragging) { | 928 CancelOnNewTabWhenDragging) { |
| 917 TabStrip* tab_strip = GetTabStripForBrowser(browser()); | 929 TabStrip* tab_strip = GetTabStripForBrowser(browser()); |
| 918 | 930 |
| 919 // Add another tab to browser(). | 931 // Add another tab to browser(). |
| 920 AddTabAndResetBrowser(browser()); | 932 AddTabAndResetBrowser(browser()); |
| 921 | 933 |
| 922 // Move to the first tab and drag it enough so that it detaches. | 934 // Move to the first tab and drag it enough so that it detaches. |
| 923 gfx::Point tab_0_center( | 935 gfx::Point tab_0_center( |
| 924 GetCenterInScreenCoordinates(tab_strip->tab_at(0))); | 936 GetCenterInScreenCoordinates(tab_strip->tab_at(0))); |
| 925 ASSERT_TRUE(PressInput(tab_0_center)); | 937 ASSERT_TRUE(PressInput(tab_0_center)); |
| 926 ASSERT_TRUE(DragInputToNotifyWhenDone( | 938 ASSERT_TRUE(DragInputToNotifyWhenDone( |
| 927 tab_0_center.x(), tab_0_center.y() + GetDetachY(tab_strip), | 939 tab_0_center.x(), tab_0_center.y() + GetDetachY(tab_strip), |
| 928 base::Bind(&CancelOnNewTabWhenDraggingStep2, this))); | 940 base::Bind(&CancelOnNewTabWhenDraggingStep2, this, native_browser_list))); |
| 929 QuitWhenNotDragging(); | 941 QuitWhenNotDragging(); |
| 930 | 942 |
| 931 // Should be two windows and not dragging. | 943 // Should be two windows and not dragging. |
| 932 ASSERT_FALSE(TabDragController::IsActive()); | 944 ASSERT_FALSE(TabDragController::IsActive()); |
| 933 ASSERT_EQ(2u, BrowserList::size()); | 945 ASSERT_EQ(2u, native_browser_list->size()); |
| 934 for (BrowserList::const_iterator i = BrowserList::begin(); | 946 for (chrome::BrowserIterator it; !it.done(); it.Next()) |
| 935 i != BrowserList::end(); ++i) { | 947 EXPECT_TRUE(GetTrackedByWorkspace(*it)); |
| 936 EXPECT_TRUE(GetTrackedByWorkspace(*i)); | |
| 937 } | |
| 938 } | 948 } |
| 939 | 949 |
| 940 #if defined(USE_ASH) && !defined(OS_WIN) // TODO(win_ash) | 950 #if defined(USE_ASH) && !defined(OS_WIN) // TODO(win_ash) |
| 941 | 951 |
| 942 namespace { | 952 namespace { |
| 943 | 953 |
| 944 void DragInMaximizedWindowStep2(DetachToBrowserTabDragControllerTest* test, | 954 void DragInMaximizedWindowStep2(DetachToBrowserTabDragControllerTest* test, |
| 945 Browser* browser, | 955 Browser* browser, |
| 946 TabStrip* tab_strip) { | 956 TabStrip* tab_strip, |
| 957 const chrome::BrowserListImpl* browser_list) { |
| 947 // There should be another browser. | 958 // There should be another browser. |
| 948 ASSERT_EQ(2u, BrowserList::size()); | 959 ASSERT_EQ(2u, browser_list->size()); |
| 949 Browser* new_browser = *(++BrowserList::begin()); | 960 Browser* new_browser = browser_list->get(1); |
| 950 EXPECT_NE(browser, new_browser); | 961 EXPECT_NE(browser, new_browser); |
| 951 ASSERT_TRUE(new_browser->window()->IsActive()); | 962 ASSERT_TRUE(new_browser->window()->IsActive()); |
| 952 TabStrip* tab_strip2 = GetTabStripForBrowser(new_browser); | 963 TabStrip* tab_strip2 = GetTabStripForBrowser(new_browser); |
| 953 | 964 |
| 954 ASSERT_TRUE(tab_strip2->IsDragSessionActive()); | 965 ASSERT_TRUE(tab_strip2->IsDragSessionActive()); |
| 955 ASSERT_FALSE(tab_strip->IsDragSessionActive()); | 966 ASSERT_FALSE(tab_strip->IsDragSessionActive()); |
| 956 | 967 |
| 957 // Both windows should be visible. | 968 // Both windows should be visible. |
| 958 EXPECT_TRUE(tab_strip->GetWidget()->IsVisible()); | 969 EXPECT_TRUE(tab_strip->GetWidget()->IsVisible()); |
| 959 EXPECT_TRUE(tab_strip2->GetWidget()->IsVisible()); | 970 EXPECT_TRUE(tab_strip2->GetWidget()->IsVisible()); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 971 browser()->window()->Maximize(); | 982 browser()->window()->Maximize(); |
| 972 | 983 |
| 973 TabStrip* tab_strip = GetTabStripForBrowser(browser()); | 984 TabStrip* tab_strip = GetTabStripForBrowser(browser()); |
| 974 | 985 |
| 975 // Move to the first tab and drag it enough so that it detaches. | 986 // Move to the first tab and drag it enough so that it detaches. |
| 976 gfx::Point tab_0_center( | 987 gfx::Point tab_0_center( |
| 977 GetCenterInScreenCoordinates(tab_strip->tab_at(0))); | 988 GetCenterInScreenCoordinates(tab_strip->tab_at(0))); |
| 978 ASSERT_TRUE(PressInput(tab_0_center)); | 989 ASSERT_TRUE(PressInput(tab_0_center)); |
| 979 ASSERT_TRUE(DragInputToNotifyWhenDone( | 990 ASSERT_TRUE(DragInputToNotifyWhenDone( |
| 980 tab_0_center.x(), tab_0_center.y() + GetDetachY(tab_strip), | 991 tab_0_center.x(), tab_0_center.y() + GetDetachY(tab_strip), |
| 981 base::Bind(&DragInMaximizedWindowStep2, this, browser(), tab_strip))); | 992 base::Bind(&DragInMaximizedWindowStep2, this, browser(), tab_strip, |
| 993 native_browser_list))); |
| 982 QuitWhenNotDragging(); | 994 QuitWhenNotDragging(); |
| 983 | 995 |
| 984 ASSERT_FALSE(TabDragController::IsActive()); | 996 ASSERT_FALSE(TabDragController::IsActive()); |
| 985 | 997 |
| 986 // Should be two browsers. | 998 // Should be two browsers. |
| 987 ASSERT_EQ(2u, BrowserList::size()); | 999 ASSERT_EQ(2u, native_browser_list->size()); |
| 988 Browser* new_browser = *(++BrowserList::begin()); | 1000 Browser* new_browser = native_browser_list->get(1); |
| 989 ASSERT_TRUE(new_browser->window()->IsActive()); | 1001 ASSERT_TRUE(new_browser->window()->IsActive()); |
| 990 | 1002 |
| 991 // Only the new browser should be visible. | 1003 // Only the new browser should be visible. |
| 992 EXPECT_FALSE(browser()->window()->GetNativeWindow()->IsVisible()); | 1004 EXPECT_FALSE(browser()->window()->GetNativeWindow()->IsVisible()); |
| 993 EXPECT_TRUE(new_browser->window()->GetNativeWindow()->IsVisible()); | 1005 EXPECT_TRUE(new_browser->window()->GetNativeWindow()->IsVisible()); |
| 994 | 1006 |
| 995 EXPECT_TRUE(GetTrackedByWorkspace(browser())); | 1007 EXPECT_TRUE(GetTrackedByWorkspace(browser())); |
| 996 EXPECT_TRUE(GetTrackedByWorkspace(new_browser)); | 1008 EXPECT_TRUE(GetTrackedByWorkspace(new_browser)); |
| 997 } | 1009 } |
| 998 | 1010 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1045 if (input_source() == INPUT_SOURCE_MOUSE) { | 1057 if (input_source() == INPUT_SOURCE_MOUSE) { |
| 1046 ASSERT_TRUE(ReleaseMouseAsync()); | 1058 ASSERT_TRUE(ReleaseMouseAsync()); |
| 1047 QuitWhenNotDragging(); | 1059 QuitWhenNotDragging(); |
| 1048 } | 1060 } |
| 1049 | 1061 |
| 1050 // Should no longer be dragging. | 1062 // Should no longer be dragging. |
| 1051 ASSERT_FALSE(tab_strip->IsDragSessionActive()); | 1063 ASSERT_FALSE(tab_strip->IsDragSessionActive()); |
| 1052 ASSERT_FALSE(TabDragController::IsActive()); | 1064 ASSERT_FALSE(TabDragController::IsActive()); |
| 1053 | 1065 |
| 1054 // There should now be another browser. | 1066 // There should now be another browser. |
| 1055 ASSERT_EQ(2u, BrowserList::size()); | 1067 ASSERT_EQ(2u, native_browser_list->size()); |
| 1056 Browser* new_browser = *(++BrowserList::begin()); | 1068 Browser* new_browser = native_browser_list->get(1); |
| 1057 ASSERT_TRUE(new_browser->window()->IsActive()); | 1069 ASSERT_TRUE(new_browser->window()->IsActive()); |
| 1058 TabStrip* tab_strip2 = GetTabStripForBrowser(new_browser); | 1070 TabStrip* tab_strip2 = GetTabStripForBrowser(new_browser); |
| 1059 ASSERT_FALSE(tab_strip2->IsDragSessionActive()); | 1071 ASSERT_FALSE(tab_strip2->IsDragSessionActive()); |
| 1060 | 1072 |
| 1061 EXPECT_EQ("0", IDString(new_browser->tab_strip_model())); | 1073 EXPECT_EQ("0", IDString(new_browser->tab_strip_model())); |
| 1062 EXPECT_EQ("1", IDString(browser()->tab_strip_model())); | 1074 EXPECT_EQ("1", IDString(browser()->tab_strip_model())); |
| 1063 } | 1075 } |
| 1064 | 1076 |
| 1065 namespace { | 1077 namespace { |
| 1066 | 1078 |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1259 MessageLoop::current()->Run(); | 1271 MessageLoop::current()->Run(); |
| 1260 } | 1272 } |
| 1261 | 1273 |
| 1262 private: | 1274 private: |
| 1263 DISALLOW_COPY_AND_ASSIGN( | 1275 DISALLOW_COPY_AND_ASSIGN( |
| 1264 DetachToBrowserInSeparateDisplayAndCancelTabDragControllerTest); | 1276 DetachToBrowserInSeparateDisplayAndCancelTabDragControllerTest); |
| 1265 }; | 1277 }; |
| 1266 | 1278 |
| 1267 // Invoked from the nested message loop. | 1279 // Invoked from the nested message loop. |
| 1268 void CancelDragTabToWindowInSeparateDisplayStep3( | 1280 void CancelDragTabToWindowInSeparateDisplayStep3( |
| 1269 TabStrip* tab_strip) { | 1281 TabStrip* tab_strip, |
| 1282 const chrome::BrowserListImpl* browser_list) { |
| 1270 ASSERT_FALSE(tab_strip->IsDragSessionActive()); | 1283 ASSERT_FALSE(tab_strip->IsDragSessionActive()); |
| 1271 ASSERT_TRUE(TabDragController::IsActive()); | 1284 ASSERT_TRUE(TabDragController::IsActive()); |
| 1272 ASSERT_EQ(2u, BrowserList::size()); | 1285 ASSERT_EQ(2u, browser_list->size()); |
| 1273 | 1286 |
| 1274 // Switching display mode should cancel the drag operation. | 1287 // Switching display mode should cancel the drag operation. |
| 1275 ash::internal::DisplayManager::CycleDisplay(); | 1288 ash::internal::DisplayManager::CycleDisplay(); |
| 1276 } | 1289 } |
| 1277 | 1290 |
| 1278 // Invoked from the nested message loop. | 1291 // Invoked from the nested message loop. |
| 1279 void CancelDragTabToWindowInSeparateDisplayStep2( | 1292 void CancelDragTabToWindowInSeparateDisplayStep2( |
| 1280 DetachToBrowserInSeparateDisplayAndCancelTabDragControllerTest* test, | 1293 DetachToBrowserInSeparateDisplayAndCancelTabDragControllerTest* test, |
| 1281 TabStrip* tab_strip, | 1294 TabStrip* tab_strip, |
| 1282 aura::RootWindow* current_root, | 1295 aura::RootWindow* current_root, |
| 1283 gfx::Point final_destination) { | 1296 gfx::Point final_destination, |
| 1297 const chrome::BrowserListImpl* browser_list) { |
| 1284 ASSERT_FALSE(tab_strip->IsDragSessionActive()); | 1298 ASSERT_FALSE(tab_strip->IsDragSessionActive()); |
| 1285 ASSERT_TRUE(TabDragController::IsActive()); | 1299 ASSERT_TRUE(TabDragController::IsActive()); |
| 1286 ASSERT_EQ(2u, BrowserList::size()); | 1300 ASSERT_EQ(2u, browser_list->size()); |
| 1287 | 1301 |
| 1288 Browser* new_browser = *(++BrowserList::begin()); | 1302 Browser* new_browser = browser_list->get(1); |
| 1289 EXPECT_EQ(current_root, | 1303 EXPECT_EQ(current_root, |
| 1290 new_browser->window()->GetNativeWindow()->GetRootWindow()); | 1304 new_browser->window()->GetNativeWindow()->GetRootWindow()); |
| 1291 | 1305 |
| 1292 ASSERT_TRUE(test->DragTabAndExecuteTaskWhenDone( | 1306 ASSERT_TRUE(test->DragTabAndExecuteTaskWhenDone( |
| 1293 final_destination, | 1307 final_destination, |
| 1294 base::Bind(&CancelDragTabToWindowInSeparateDisplayStep3, | 1308 base::Bind(&CancelDragTabToWindowInSeparateDisplayStep3, |
| 1295 tab_strip))); | 1309 tab_strip, browser_list))); |
| 1296 } | 1310 } |
| 1297 | 1311 |
| 1298 } // namespace | 1312 } // namespace |
| 1299 | 1313 |
| 1300 // Drags from browser to a second display and releases input. | 1314 // Drags from browser to a second display and releases input. |
| 1301 IN_PROC_BROWSER_TEST_F( | 1315 IN_PROC_BROWSER_TEST_F( |
| 1302 DetachToBrowserInSeparateDisplayAndCancelTabDragControllerTest, | 1316 DetachToBrowserInSeparateDisplayAndCancelTabDragControllerTest, |
| 1303 CancelDragTabToWindowIn2ndDisplay) { | 1317 CancelDragTabToWindowIn2ndDisplay) { |
| 1304 // Add another tab. | 1318 // Add another tab. |
| 1305 AddTabAndResetBrowser(browser()); | 1319 AddTabAndResetBrowser(browser()); |
| 1306 TabStrip* tab_strip = GetTabStripForBrowser(browser()); | 1320 TabStrip* tab_strip = GetTabStripForBrowser(browser()); |
| 1307 | 1321 |
| 1308 EXPECT_EQ("0 1", IDString(browser()->tab_strip_model())); | 1322 EXPECT_EQ("0 1", IDString(browser()->tab_strip_model())); |
| 1309 | 1323 |
| 1310 // Move the second browser to the second display. | 1324 // Move the second browser to the second display. |
| 1311 std::vector<aura::RootWindow*> roots(ash::Shell::GetAllRootWindows()); | 1325 std::vector<aura::RootWindow*> roots(ash::Shell::GetAllRootWindows()); |
| 1312 ASSERT_EQ(2u, roots.size()); | 1326 ASSERT_EQ(2u, roots.size()); |
| 1313 gfx::Point final_destination = | 1327 gfx::Point final_destination = |
| 1314 gfx::Screen::GetNativeScreen()->GetDisplayNearestWindow( | 1328 gfx::Screen::GetNativeScreen()->GetDisplayNearestWindow( |
| 1315 roots[1]).work_area().CenterPoint(); | 1329 roots[1]).work_area().CenterPoint(); |
| 1316 | 1330 |
| 1317 // Move to the first tab and drag it enough so that it detaches, but not | 1331 // Move to the first tab and drag it enough so that it detaches, but not |
| 1318 // enough to move to another display. | 1332 // enough to move to another display. |
| 1319 gfx::Point tab_0_dst(GetCenterInScreenCoordinates(tab_strip->tab_at(0))); | 1333 gfx::Point tab_0_dst(GetCenterInScreenCoordinates(tab_strip->tab_at(0))); |
| 1320 ASSERT_TRUE(Press(tab_0_dst)); | 1334 ASSERT_TRUE(Press(tab_0_dst)); |
| 1321 tab_0_dst.Offset(0, GetDetachY(tab_strip)); | 1335 tab_0_dst.Offset(0, GetDetachY(tab_strip)); |
| 1322 ASSERT_TRUE(DragTabAndExecuteTaskWhenDone( | 1336 ASSERT_TRUE(DragTabAndExecuteTaskWhenDone( |
| 1323 tab_0_dst, base::Bind(&CancelDragTabToWindowInSeparateDisplayStep2, | 1337 tab_0_dst, base::Bind(&CancelDragTabToWindowInSeparateDisplayStep2, |
| 1324 this, tab_strip, roots[0], final_destination))); | 1338 this, tab_strip, roots[0], final_destination, |
| 1339 native_browser_list))); |
| 1325 QuitWhenNotDragging(); | 1340 QuitWhenNotDragging(); |
| 1326 | 1341 |
| 1327 ASSERT_EQ(1u, BrowserList::size()); | 1342 ASSERT_EQ(1u, native_browser_list->size()); |
| 1328 ASSERT_FALSE(tab_strip->IsDragSessionActive()); | 1343 ASSERT_FALSE(tab_strip->IsDragSessionActive()); |
| 1329 ASSERT_FALSE(TabDragController::IsActive()); | 1344 ASSERT_FALSE(TabDragController::IsActive()); |
| 1330 EXPECT_EQ("0 1", IDString(browser()->tab_strip_model())); | 1345 EXPECT_EQ("0 1", IDString(browser()->tab_strip_model())); |
| 1331 | 1346 |
| 1332 // Release the mouse | 1347 // Release the mouse |
| 1333 ASSERT_TRUE(ui_test_utils::SendMouseEventsSync( | 1348 ASSERT_TRUE(ui_test_utils::SendMouseEventsSync( |
| 1334 ui_controls::LEFT, ui_controls::UP)); | 1349 ui_controls::LEFT, ui_controls::UP)); |
| 1335 } | 1350 } |
| 1336 | 1351 |
| 1337 // Drags from browser from a second display to primary and releases input. | 1352 // Drags from browser from a second display to primary and releases input. |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1358 gfx::Screen::GetNativeScreen()->GetDisplayNearestWindow( | 1373 gfx::Screen::GetNativeScreen()->GetDisplayNearestWindow( |
| 1359 roots[0]).work_area().CenterPoint(); | 1374 roots[0]).work_area().CenterPoint(); |
| 1360 | 1375 |
| 1361 // Move to the first tab and drag it enough so that it detaches, but not | 1376 // Move to the first tab and drag it enough so that it detaches, but not |
| 1362 // enough to move to another display. | 1377 // enough to move to another display. |
| 1363 gfx::Point tab_0_dst(GetCenterInScreenCoordinates(tab_strip->tab_at(0))); | 1378 gfx::Point tab_0_dst(GetCenterInScreenCoordinates(tab_strip->tab_at(0))); |
| 1364 ASSERT_TRUE(Press(tab_0_dst)); | 1379 ASSERT_TRUE(Press(tab_0_dst)); |
| 1365 tab_0_dst.Offset(0, GetDetachY(tab_strip)); | 1380 tab_0_dst.Offset(0, GetDetachY(tab_strip)); |
| 1366 ASSERT_TRUE(DragTabAndExecuteTaskWhenDone( | 1381 ASSERT_TRUE(DragTabAndExecuteTaskWhenDone( |
| 1367 tab_0_dst, base::Bind(&CancelDragTabToWindowInSeparateDisplayStep2, | 1382 tab_0_dst, base::Bind(&CancelDragTabToWindowInSeparateDisplayStep2, |
| 1368 this, tab_strip, roots[1], final_destination))); | 1383 this, tab_strip, roots[1], final_destination, |
| 1384 native_browser_list))); |
| 1369 QuitWhenNotDragging(); | 1385 QuitWhenNotDragging(); |
| 1370 | 1386 |
| 1371 ASSERT_EQ(1u, BrowserList::size()); | 1387 ASSERT_EQ(1u, native_browser_list->size()); |
| 1372 ASSERT_FALSE(tab_strip->IsDragSessionActive()); | 1388 ASSERT_FALSE(tab_strip->IsDragSessionActive()); |
| 1373 ASSERT_FALSE(TabDragController::IsActive()); | 1389 ASSERT_FALSE(TabDragController::IsActive()); |
| 1374 EXPECT_EQ("0 1", IDString(browser()->tab_strip_model())); | 1390 EXPECT_EQ("0 1", IDString(browser()->tab_strip_model())); |
| 1375 | 1391 |
| 1376 // Release the mouse | 1392 // Release the mouse |
| 1377 ASSERT_TRUE(ui_test_utils::SendMouseEventsSync( | 1393 ASSERT_TRUE(ui_test_utils::SendMouseEventsSync( |
| 1378 ui_controls::LEFT, ui_controls::UP)); | 1394 ui_controls::LEFT, ui_controls::UP)); |
| 1379 } | 1395 } |
| 1380 | 1396 |
| 1381 #endif | 1397 #endif |
| 1382 | 1398 |
| 1383 #if defined(USE_ASH) && !defined(OS_WIN) // TODO(win_ash) | 1399 #if defined(USE_ASH) && !defined(OS_WIN) // TODO(win_ash) |
| 1384 INSTANTIATE_TEST_CASE_P(TabDragging, | 1400 INSTANTIATE_TEST_CASE_P(TabDragging, |
| 1385 DetachToBrowserInSeparateDisplayTabDragControllerTest, | 1401 DetachToBrowserInSeparateDisplayTabDragControllerTest, |
| 1386 ::testing::Values("mouse", "touch")); | 1402 ::testing::Values("mouse", "touch")); |
| 1387 INSTANTIATE_TEST_CASE_P(TabDragging, | 1403 INSTANTIATE_TEST_CASE_P(TabDragging, |
| 1388 DifferentDeviceScaleFactorDisplayTabDragControllerTest, | 1404 DifferentDeviceScaleFactorDisplayTabDragControllerTest, |
| 1389 ::testing::Values("mouse")); | 1405 ::testing::Values("mouse")); |
| 1390 INSTANTIATE_TEST_CASE_P(TabDragging, | 1406 INSTANTIATE_TEST_CASE_P(TabDragging, |
| 1391 DetachToBrowserTabDragControllerTest, | 1407 DetachToBrowserTabDragControllerTest, |
| 1392 ::testing::Values("mouse", "touch")); | 1408 ::testing::Values("mouse", "touch")); |
| 1393 #else | 1409 #else |
| 1394 INSTANTIATE_TEST_CASE_P(TabDragging, | 1410 INSTANTIATE_TEST_CASE_P(TabDragging, |
| 1395 DetachToBrowserTabDragControllerTest, | 1411 DetachToBrowserTabDragControllerTest, |
| 1396 ::testing::Values("mouse")); | 1412 ::testing::Values("mouse")); |
| 1397 #endif | 1413 #endif |
| OLD | NEW |