Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(489)

Unified Diff: chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest.cc

Issue 1747803003: MacViews: Implement Tab Dragging (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..cf55d1c5d8b6367499e9b226be4bc6ede828a376 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,19 @@
using content::WebContents;
+void DragAndDrop(const gfx::Point& from,
+ const gfx::Point& to,
+ base::TimeDelta delay = base::TimeDelta()) {
+#if defined(OS_MACOSX)
+ ui_test_utils::DragAndDrop(from, to, delay);
+#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 +184,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 +198,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 +258,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 +817,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();
tapted 2016/03/01 08:11:58 did GetDisplayNearestWindow() not work?
themblsha 2016/03/09 17:40:22 GetDisplayNearestWindow() expects NativeView, but
tapted 2016/03/10 11:51:18 oh weird. There's platform_util::GetViewForWindow
browser()->window()->SetBounds(work_area);
const gfx::Rect initial_bounds(browser()->window()->GetBounds());
// Add another tab.
@@ -1135,6 +1149,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 +1160,7 @@ void DragAllStep2(DetachToBrowserTabDragControllerTest* test,
ASSERT_TRUE(test->ReleaseMouseAsync());
}
}
+#endif // !OS_MACOSX
} // namespace
@@ -1162,15 +1178,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.
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() + GetDetachY(tab_strip)));
// Should not be dragging.
ASSERT_FALSE(tab_strip->IsDragSessionActive());
@@ -1185,6 +1200,8 @@ IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest, MAYBE_DragAll) {
// Remaining browser window should not be maximized
EXPECT_FALSE(browser()->window()->IsMaximized());
+
+ EXPECT_NE(initial_bounds, browser()->window()->GetBounds());
}
namespace {
@@ -2362,3 +2379,6 @@ INSTANTIATE_TEST_CASE_P(TabDragging,
DetachToBrowserTabDragControllerTest,
::testing::Values("mouse"));
#endif
+INSTANTIATE_TEST_CASE_P(TabDragging,
+ DetachToBrowserTabDragControllerTest,
+ ::testing::Values("mouse"));

Powered by Google App Engine
This is Rietveld 408576698