Commit 744929e6 authored by Charlene Yan's avatar Charlene Yan Committed by Commit Bot

[Tab Scrolling] Check tab bounds when dragged to new window.

When a tab is dragged into a new window, its bounds should be the same.
This is a regression test/check for crbug.com/1140808

Because tabs can be different widths by one pixel, we need the test to
get the width of the tab before dragging then when the tab is detached,
verify this width is the same.

Bug: 1140808, 1141674
Change-Id: I2ed53d6101ea50999b706a6e050e5c732bbd9ce7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2539251Reviewed-by: default avatarCharlene Yan <cyan@chromium.org>
Reviewed-by: default avatarTaylor Bergquist <tbergquist@chromium.org>
Commit-Queue: Charlene Yan <cyan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#830805}
parent 6a923c88
...@@ -556,7 +556,7 @@ class DetachToBrowserTabDragControllerTest ...@@ -556,7 +556,7 @@ class DetachToBrowserTabDragControllerTest
#endif #endif
} }
void ReleaseInputAfterWindowDetached() { void ReleaseInputAfterWindowDetached(int first_dragged_tab_width) {
// On macOS, we want to avoid generating the input event [which requires an // On macOS, we want to avoid generating the input event [which requires an
// associated window] until the window has been detached. Failure to do so // associated window] until the window has been detached. Failure to do so
// causes odd behavior [e.g. on macOS 10.10, the mouse-up will reactivate // causes odd behavior [e.g. on macOS 10.10, the mouse-up will reactivate
...@@ -566,11 +566,16 @@ class DetachToBrowserTabDragControllerTest ...@@ -566,11 +566,16 @@ class DetachToBrowserTabDragControllerTest
FROM_HERE, FROM_HERE,
base::BindOnce(&DetachToBrowserTabDragControllerTest:: base::BindOnce(&DetachToBrowserTabDragControllerTest::
ReleaseInputAfterWindowDetached, ReleaseInputAfterWindowDetached,
base::Unretained(this)), base::Unretained(this), first_dragged_tab_width),
base::TimeDelta::FromMilliseconds(1)); base::TimeDelta::FromMilliseconds(1));
return; return;
} }
// The tab getting dragged into the new browser should have the same width
// as before it was dragged.
EXPECT_EQ(first_dragged_tab_width,
GetTabStripForBrowser(browser_list->get(1))->tab_at(0)->width());
// Windows hangs if you use a sync mouse event here. // Windows hangs if you use a sync mouse event here.
ASSERT_TRUE(ReleaseInput(0, true)); ASSERT_TRUE(ReleaseInput(0, true));
} }
...@@ -1556,10 +1561,11 @@ IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest, ...@@ -1556,10 +1561,11 @@ IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest,
TabStrip* tab_strip = GetTabStripForBrowser(browser()); TabStrip* tab_strip = GetTabStripForBrowser(browser());
// Move to the first tab and drag it enough so that it detaches. // Move to the first tab and drag it enough so that it detaches.
int tab_0_width = tab_strip->tab_at(0)->width();
DragTabAndNotify(tab_strip, DragTabAndNotify(tab_strip,
base::BindOnce(&DetachToBrowserTabDragControllerTest:: base::BindOnce(&DetachToBrowserTabDragControllerTest::
ReleaseInputAfterWindowDetached, ReleaseInputAfterWindowDetached,
base::Unretained(this))); base::Unretained(this), tab_0_width));
// Should no longer be dragging. // Should no longer be dragging.
ASSERT_FALSE(tab_strip->GetDragContext()->IsDragSessionActive()); ASSERT_FALSE(tab_strip->GetDragContext()->IsDragSessionActive());
...@@ -1622,10 +1628,11 @@ IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest, ...@@ -1622,10 +1628,11 @@ IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest,
TabStrip* tab_strip = GetTabStripForBrowser(browser()); TabStrip* tab_strip = GetTabStripForBrowser(browser());
// Move to the first tab and drag it enough so that it detaches. // Move to the first tab and drag it enough so that it detaches.
int tab_0_width = tab_strip->tab_at(0)->width();
DragTabAndNotify(tab_strip, DragTabAndNotify(tab_strip,
base::BindOnce(&DetachToBrowserTabDragControllerTest:: base::BindOnce(&DetachToBrowserTabDragControllerTest::
ReleaseInputAfterWindowDetached, ReleaseInputAfterWindowDetached,
base::Unretained(this))); base::Unretained(this), tab_0_width));
// Should no longer be dragging. // Should no longer be dragging.
ASSERT_FALSE(tab_strip->GetDragContext()->IsDragSessionActive()); ASSERT_FALSE(tab_strip->GetDragContext()->IsDragSessionActive());
...@@ -1672,10 +1679,11 @@ IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest, ...@@ -1672,10 +1679,11 @@ IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest,
TabStrip* tab_strip = GetTabStripForBrowser(browser()); TabStrip* tab_strip = GetTabStripForBrowser(browser());
// Move to the first tab and drag it enough so that it detaches. // Move to the first tab and drag it enough so that it detaches.
int tab_0_width = tab_strip->tab_at(0)->width();
DragTabAndNotify(tab_strip, DragTabAndNotify(tab_strip,
base::BindOnce(&DetachToBrowserTabDragControllerTest:: base::BindOnce(&DetachToBrowserTabDragControllerTest::
ReleaseInputAfterWindowDetached, ReleaseInputAfterWindowDetached,
base::Unretained(this))); base::Unretained(this), tab_0_width));
// Should no longer be dragging. // Should no longer be dragging.
ASSERT_FALSE(tab_strip->GetDragContext()->IsDragSessionActive()); ASSERT_FALSE(tab_strip->GetDragContext()->IsDragSessionActive());
...@@ -1729,10 +1737,11 @@ IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest, ...@@ -1729,10 +1737,11 @@ IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest,
TabStrip* tab_strip = GetTabStripForBrowser(browser()); TabStrip* tab_strip = GetTabStripForBrowser(browser());
// Move to the first tab and drag it enough so that it detaches. // Move to the first tab and drag it enough so that it detaches.
int tab_0_width = tab_strip->tab_at(0)->width();
DragTabAndNotify(tab_strip, DragTabAndNotify(tab_strip,
base::BindOnce(&DetachToBrowserTabDragControllerTest:: base::BindOnce(&DetachToBrowserTabDragControllerTest::
ReleaseInputAfterWindowDetached, ReleaseInputAfterWindowDetached,
base::Unretained(this))); base::Unretained(this), tab_0_width));
// Should no longer be dragging. // Should no longer be dragging.
ASSERT_FALSE(tab_strip->GetDragContext()->IsDragSessionActive()); ASSERT_FALSE(tab_strip->GetDragContext()->IsDragSessionActive());
...@@ -3417,11 +3426,12 @@ IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTestWithTabbedSystemApp, ...@@ -3417,11 +3426,12 @@ IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTestWithTabbedSystemApp,
AddTabsAndResetBrowser(browser(), 1, GetAppUrl()); AddTabsAndResetBrowser(browser(), 1, GetAppUrl());
TabStrip* tab_strip = GetTabStripForBrowser(browser()); TabStrip* tab_strip = GetTabStripForBrowser(browser());
// Drag tab to create a new browser. // Move to the first tab and drag it enough so that it detaches.
int tab_0_width = tab_strip->tab_at(0)->width();
DragTabAndNotify(tab_strip, DragTabAndNotify(tab_strip,
base::BindOnce(&DetachToBrowserTabDragControllerTest:: base::BindOnce(&DetachToBrowserTabDragControllerTest::
ReleaseInputAfterWindowDetached, ReleaseInputAfterWindowDetached,
base::Unretained(this))); base::Unretained(this), tab_0_width));
// New browser should be TYPE_APP. // New browser should be TYPE_APP.
ASSERT_EQ(2u, browser_list->size()); ASSERT_EQ(2u, browser_list->size());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment