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

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

Issue 11033038: Fix the issue of cursor's device scale factor when using monitors with differnt device scale factor. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 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
« no previous file with comments | « ash/wm/workspace/workspace_window_resizer_unittest.cc ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 11d183bf1b02d7b267a10f99032985e50072c0c0..66bcae96164d022060596151e475e8c0a99de79a 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
@@ -35,6 +35,8 @@
#include "ash/display/display_controller.h"
#include "ash/display/multi_display_manager.h"
#include "ash/shell.h"
+#include "ash/test/cursor_manager_test_api.h"
+#include "ash/wm/cursor_manager.h"
#include "ui/aura/test/event_generator.h"
#include "ui/aura/root_window.h"
#endif
@@ -1033,6 +1035,108 @@ IN_PROC_BROWSER_TEST_P(DetachToBrowserInSeparateDisplayTabDragControllerTest,
EXPECT_EQ("1", IDString(browser()->tab_strip_model()));
}
+class DifferentDeviceScaleFactorDisplayTabDragControllerTest
+ : public DetachToBrowserTabDragControllerTest {
+ public:
+ DifferentDeviceScaleFactorDisplayTabDragControllerTest() {}
+
+ virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
+ DetachToBrowserTabDragControllerTest::SetUpCommandLine(command_line);
+ command_line->AppendSwitchASCII("aura-host-window-size",
+ "400x400,800x800*2");
+ }
+
+ float GetCursorDeviceScaleFactor() const {
+ ash::test::CursorManagerTestApi cursor_test_api(
+ ash::Shell::GetInstance()->cursor_manager());
+ return cursor_test_api.GetDeviceScaleFactor();
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(
+ DifferentDeviceScaleFactorDisplayTabDragControllerTest);
+};
+
+namespace {
+
+// The points where a tab is dragged in CursorDeviceScaleFactorStep.
+const struct DragPoint {
+ int x;
+ int y;
+} kDragPoints[] = {
+ {390, 200},
+ {399, 200},
+ {410, 200},
+ {400, 200},
+ {390, 200},
+};
+
+// The expected device scale factors before the cursor is moved to the
+// corresponding kDragPoints in CursorDeviceScaleFactorStep.
+const float kDeviceScaleFactorExpectations[] = {
+ 1.0f,
+ 1.0f,
+ 2.0f,
+ 2.0f,
+ 1.0f,
+};
oshima 2012/10/05 21:20:59 can you add COMPILE_ASSERT to make sure they have
mazda 2012/10/05 21:34:43 Done.
+
+// Drags tab to |kDragPoints[N]|, then calls the next step function.
+template <int N>
+void CursorDeviceScaleFactorStep(
+ DifferentDeviceScaleFactorDisplayTabDragControllerTest* test,
+ TabStrip* not_attached_tab_strip) {
+ ASSERT_FALSE(not_attached_tab_strip->IsDragSessionActive());
+ ASSERT_TRUE(TabDragController::IsActive());
+
+ EXPECT_EQ(kDeviceScaleFactorExpectations[N],
+ test->GetCursorDeviceScaleFactor());
+
+ const DragPoint p = kDragPoints[N];
+ ASSERT_TRUE(test->DragInputToNotifyWhenDone(
+ p.x, p.y, base::Bind(&CursorDeviceScaleFactorStep<N+1>,
oshima 2012/10/05 21:20:59 N + 1
mazda 2012/10/05 21:34:43 Done.
+ test, not_attached_tab_strip)));
+}
+
+// Finishes a serise of CursorDeviceScaleFactorStep<N> calls and ends drag.
+template <>
+void CursorDeviceScaleFactorStep<arraysize(kDragPoints)>(
+ DifferentDeviceScaleFactorDisplayTabDragControllerTest* test,
+ TabStrip* not_attached_tab_strip) {
+ ASSERT_FALSE(not_attached_tab_strip->IsDragSessionActive());
+ ASSERT_TRUE(TabDragController::IsActive());
+
+ EXPECT_EQ(1.0f, test->GetCursorDeviceScaleFactor());
+
+ ASSERT_TRUE(ui_test_utils::SendMouseEventsSync(
+ ui_controls::LEFT, ui_controls::UP));
+}
+
+} // namespace
+
+// Verifies cursor's device scale factor is updated when a tab is moved across
+// displays with different device scale factors (http://crbug.com/154183).
+IN_PROC_BROWSER_TEST_P(DifferentDeviceScaleFactorDisplayTabDragControllerTest,
+ CursorDeviceScaleFactor) {
+ // Add another tab.
+ AddTabAndResetBrowser(browser());
+ TabStrip* tab_strip = GetTabStripForBrowser(browser());
+
+ // Move the second browser to the second display.
+ std::vector<aura::RootWindow*> roots(ash::Shell::GetAllRootWindows());
+ ASSERT_EQ(2u, roots.size());
+
+ // Move to the first tab and drag it enough so that it detaches, but not
+ // enough that it attaches to browser2.
+ 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(&CursorDeviceScaleFactorStep<0>,
+ this, tab_strip)));
+ QuitWhenNotDragging();
+}
+
namespace {
class DetachToBrowserInSeparateDisplayAndCancelTabDragControllerTest
@@ -1187,6 +1291,9 @@ INSTANTIATE_TEST_CASE_P(TabDragging,
DetachToBrowserInSeparateDisplayTabDragControllerTest,
::testing::Values("mouse", "touch"));
INSTANTIATE_TEST_CASE_P(TabDragging,
+ DifferentDeviceScaleFactorDisplayTabDragControllerTest,
+ ::testing::Values("mouse"));
+INSTANTIATE_TEST_CASE_P(TabDragging,
DetachToBrowserTabDragControllerTest,
::testing::Values("mouse", "touch"));
#else
« no previous file with comments | « ash/wm/workspace/workspace_window_resizer_unittest.cc ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698