| Index: chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest.cc
|
| diff --git a/chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest.cc b/chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest.cc
|
| index 95124488d210556fb43d7709f036a3211940235b..5d34ec7de5774357cf5c7ccf5a93dcc4ecfcefbb 100644
|
| --- a/chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest.cc
|
| +++ b/chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest.cc
|
| @@ -68,6 +68,21 @@
|
|
|
| using content::WebContents;
|
|
|
| +void DragAndDrop(const gfx::Point& from,
|
| + const gfx::Point& to,
|
| + base::TimeDelta delay = base::TimeDelta()) {
|
| +#if defined(OS_MACOSX)
|
| + const unsigned int steps = 2; // use anything greater than 1 to verify that
|
| + // CocoaWindowMoveLoop is working correctly
|
| + ui_test_utils::DragAndDrop(from, to, delay, steps);
|
| +#else
|
| + ASSERT_TRUE(PressInput(from));
|
| + ASSERT_TRUE(DragInputToNotifyWhenDone(to.x(), to.y()));
|
| + base::Bind(&DragAllStep2, this, browser_list)));
|
| + QuitWhenNotDragging();
|
| +#endif
|
| +}
|
| +
|
| namespace test {
|
|
|
| namespace {
|
| @@ -171,6 +186,11 @@ void TabDragControllerTest::AddTabAndResetBrowser(Browser* browser) {
|
| AddBlankTabAndShow(browser);
|
| StopAnimating(GetTabStripForBrowser(browser));
|
| ResetIDs(browser->tab_strip_model(), 0);
|
| +
|
| + // On Macs if we try to drag on an inactive window it won't work. Two
|
| + // solutions are either to activate the window explicitly, or to click on a
|
| + // window once before starting dragging.
|
| + EXPECT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser));
|
| }
|
|
|
| Browser* TabDragControllerTest::CreateAnotherWindowBrowserAndRelayout() {
|
| @@ -180,9 +200,7 @@ Browser* TabDragControllerTest::CreateAnotherWindowBrowserAndRelayout() {
|
|
|
| // Resize the two windows so they're right next to each other.
|
| gfx::Rect work_area =
|
| - gfx::Screen::GetScreen()
|
| - ->GetDisplayNearestWindow(browser()->window()->GetNativeWindow())
|
| - .work_area();
|
| + gfx::Screen::GetScreen()->GetPrimaryDisplay().work_area();
|
| gfx::Size half_size =
|
| gfx::Size(work_area.width() / 3 - 10, work_area.height() / 2 - 10);
|
| browser()->window()->SetBounds(gfx::Rect(work_area.origin(), half_size));
|
| @@ -242,7 +260,7 @@ class ScreenEventGeneratorDelegate
|
|
|
| #endif
|
|
|
| -#if !defined(OS_CHROMEOS)
|
| +#if !defined(OS_CHROMEOS) && !defined(OS_MACOSX)
|
|
|
| // Following classes verify a crash scenario. Specifically on Windows when focus
|
| // changes it can trigger capture being lost. This was causing a crash in tab
|
| @@ -801,9 +819,7 @@ IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest,
|
| MAYBE_DetachFromFullsizeWindow) {
|
| // Resize the browser window so that it is as big as the work area.
|
| gfx::Rect work_area =
|
| - gfx::Screen::GetScreen()
|
| - ->GetDisplayNearestWindow(browser()->window()->GetNativeWindow())
|
| - .work_area();
|
| + gfx::Screen::GetScreen()->GetPrimaryDisplay().work_area();
|
| browser()->window()->SetBounds(work_area);
|
| const gfx::Rect initial_bounds(browser()->window()->GetBounds());
|
| // Add another tab.
|
| @@ -1135,6 +1151,7 @@ IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest,
|
|
|
| namespace {
|
|
|
| +#if !defined(OS_MACOSX)
|
| void DragAllStep2(DetachToBrowserTabDragControllerTest* test,
|
| const BrowserList* browser_list) {
|
| // Should only be one window.
|
| @@ -1145,6 +1162,7 @@ void DragAllStep2(DetachToBrowserTabDragControllerTest* test,
|
| ASSERT_TRUE(test->ReleaseMouseAsync());
|
| }
|
| }
|
| +#endif // !OS_MACOSX
|
|
|
| } // namespace
|
|
|
| @@ -1162,15 +1180,14 @@ IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest, MAYBE_DragAll) {
|
| TabStrip* tab_strip = GetTabStripForBrowser(browser());
|
| browser()->tab_strip_model()->AddTabAtToSelection(0);
|
| browser()->tab_strip_model()->AddTabAtToSelection(1);
|
| + const gfx::Rect initial_bounds = browser()->window()->GetBounds();
|
|
|
| // Move to the first tab and drag it enough so that it would normally
|
| // detach.
|
| + const int delta_y = GetDetachY(tab_strip);
|
| gfx::Point tab_0_center(GetCenterInScreenCoordinates(tab_strip->tab_at(0)));
|
| - ASSERT_TRUE(PressInput(tab_0_center));
|
| - ASSERT_TRUE(DragInputToNotifyWhenDone(
|
| - tab_0_center.x(), tab_0_center.y() + GetDetachY(tab_strip),
|
| - base::Bind(&DragAllStep2, this, browser_list)));
|
| - QuitWhenNotDragging();
|
| + DragAndDrop(tab_0_center,
|
| + gfx::Point(tab_0_center.x(), tab_0_center.y() + delta_y));
|
|
|
| // Should not be dragging.
|
| ASSERT_FALSE(tab_strip->IsDragSessionActive());
|
| @@ -1185,6 +1202,11 @@ IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest, MAYBE_DragAll) {
|
|
|
| // Remaining browser window should not be maximized
|
| EXPECT_FALSE(browser()->window()->IsMaximized());
|
| +
|
| + const gfx::Rect final_bounds = browser()->window()->GetBounds();
|
| + EXPECT_EQ(initial_bounds.size(), final_bounds.size());
|
| + EXPECT_EQ(initial_bounds.origin().x(), final_bounds.origin().x());
|
| + EXPECT_EQ(initial_bounds.origin().y() + delta_y, final_bounds.origin().y());
|
| }
|
|
|
| namespace {
|
| @@ -2362,3 +2384,6 @@ INSTANTIATE_TEST_CASE_P(TabDragging,
|
| DetachToBrowserTabDragControllerTest,
|
| ::testing::Values("mouse"));
|
| #endif
|
| +INSTANTIATE_TEST_CASE_P(TabDragging,
|
| + DetachToBrowserTabDragControllerTest,
|
| + ::testing::Values("mouse"));
|
|
|