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

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

Issue 10909043: Cancel drag if display configuration changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 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 ddd65431d0425cb1c51928ab151390cb4e46d7e6..eae2c2bdef709b4680dd3f999bb999f2be14d65e 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
@@ -33,6 +33,7 @@
#if defined(USE_ASH)
#include "ash/display/display_controller.h"
+#include "ash/display/multi_display_manager.h"
#include "ash/shell.h"
#include "ui/aura/test/event_generator.h"
#include "ui/aura/root_window.h"
@@ -940,8 +941,7 @@ IN_PROC_BROWSER_TEST_P(DetachToBrowserInSeparateDisplayTabDragControllerTest,
ResetIDs(browser2->tab_strip_model(), 100);
// Move the second browser to the second display.
- std::vector<aura::RootWindow*> roots(
- ash::Shell::GetInstance()->display_controller()->GetAllRootWindows());
+ std::vector<aura::RootWindow*> roots(ash::Shell::GetAllRootWindows());
ASSERT_EQ(2u, roots.size());
aura::RootWindow* second_root = roots[1];
gfx::Rect work_area = gfx::Screen::GetDisplayNearestWindow(
@@ -974,6 +974,89 @@ IN_PROC_BROWSER_TEST_P(DetachToBrowserInSeparateDisplayTabDragControllerTest,
EXPECT_EQ("1", IDString(browser()->tab_strip_model()));
}
+namespace {
+
+// Invoked from the nested message loop.
+void CancelDragTabToWindowInSeparateDisplayStep3(
+ DetachToBrowserTabDragControllerTest* test,
+ TabStrip* tab_strip) {
+ ASSERT_FALSE(tab_strip->IsDragSessionActive());
+ ASSERT_TRUE(TabDragController::IsActive());
+ ASSERT_EQ(2u, BrowserList::size());
+
+ // Switching display mode should cancel the drag operation.
+ ash::internal::MultiDisplayManager::CycleDisplay();
+}
+
+// Invoked from the nested message loop.
+void CancelDragTabToWindowInSeparateDisplayStep2(
+ DetachToBrowserTabDragControllerTest* test,
+ TabStrip* tab_strip,
+ gfx::Point final_destination) {
+ ASSERT_FALSE(tab_strip->IsDragSessionActive());
+ ASSERT_TRUE(TabDragController::IsActive());
+ ASSERT_EQ(2u, BrowserList::size());
+
+ Browser* new_browser = *(++BrowserList::begin());
+ EXPECT_EQ(ash::Shell::GetPrimaryRootWindow(),
+ new_browser->window()->GetNativeWindow()->GetRootWindow());
+
+ ASSERT_TRUE(test->DragInputToNotifyWhenDone(
+ final_destination.x(), final_destination.y(),
+ base::Bind(&CancelDragTabToWindowInSeparateDisplayStep3,
+ test, tab_strip)));
+}
+
+} // namespace
+
+// Drags from browser to a second display and releases input.
+IN_PROC_BROWSER_TEST_P(DetachToBrowserInSeparateDisplayTabDragControllerTest,
+ CancelDragTabToWindowInSeparateDisplay) {
+ // Add another tab.
+ AddTabAndResetBrowser(browser());
+ TabStrip* tab_strip = GetTabStripForBrowser(browser());
+
+ EXPECT_EQ("0 1", IDString(browser()->tab_strip_model()));
+
+ // Move the second browser to the second display.
+ std::vector<aura::RootWindow*> roots(ash::Shell::GetAllRootWindows());
+ ASSERT_EQ(2u, roots.size());
+ gfx::Point final_destination =
+ gfx::Screen::GetDisplayNearestWindow(roots[1]).work_area().CenterPoint();
+
+ // Move to the first tab and drag it enough so that it detaches, but not
+ // enough to move to another display.
+ 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(&CancelDragTabToWindowInSeparateDisplayStep2,
+ this, tab_strip, final_destination)));
+ QuitWhenNotDragging();
+
+ // Drag operation must have been cancelled.
+ if (input_source() == INPUT_SOURCE_TOUCH) {
+ // A window capture is reset to NULL when merging two root
+ // windows, and that capture event completes the touch based
+ // drag operation, instead of cancelling it.
+ ASSERT_EQ(2u, BrowserList::size());
+ ASSERT_FALSE(tab_strip->IsDragSessionActive());
+ ASSERT_FALSE(TabDragController::IsActive());
+ EXPECT_EQ("1", IDString(browser()->tab_strip_model()));
+ Browser* new_browser = *(++BrowserList::begin());
+ EXPECT_EQ("0", IDString(new_browser->tab_strip_model()));
+ } else {
+ // Mouse operation doesn't get cancelled when the capture is
+ // lost, and removing the display correctly cancel the operation.
+ ASSERT_EQ(1u, BrowserList::size());
+ ASSERT_FALSE(tab_strip->IsDragSessionActive());
+ ASSERT_FALSE(TabDragController::IsActive());
+ EXPECT_EQ("0 1", IDString(browser()->tab_strip_model()));
+ }
+ // Release the mouse
+ ASSERT_TRUE(ReleaseInput());
+}
+
#endif
#if defined(USE_ASH)

Powered by Google App Engine
This is Rietveld 408576698