| 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 190f5edb44dbb4ac5e808739cd052ce8e465be13..b59d82c632333787029ebce69a21c5252434a223 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
|
| @@ -36,6 +36,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
|
| @@ -1115,6 +1117,103 @@ 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[] = {
|
| + {300, 200},
|
| + {399, 200},
|
| + {500, 200},
|
| + {400, 200},
|
| + {300, 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,
|
| +};
|
| +
|
| +COMPILE_ASSERT(
|
| + arraysize(kDragPoints) == arraysize(kDeviceScaleFactorExpectations),
|
| + kDragPoints_and_kDeviceScaleFactorExpectations_must_have_same_size);
|
| +
|
| +// Drags tab to |kDragPoints[index]|, then calls the next step function.
|
| +void CursorDeviceScaleFactorStep(
|
| + DifferentDeviceScaleFactorDisplayTabDragControllerTest* test,
|
| + TabStrip* not_attached_tab_strip,
|
| + size_t index) {
|
| + ASSERT_FALSE(not_attached_tab_strip->IsDragSessionActive());
|
| + ASSERT_TRUE(TabDragController::IsActive());
|
| +
|
| + if (index < arraysize(kDragPoints)) {
|
| + EXPECT_EQ(kDeviceScaleFactorExpectations[index],
|
| + test->GetCursorDeviceScaleFactor());
|
| + const DragPoint p = kDragPoints[index];
|
| + ASSERT_TRUE(test->DragInputToNotifyWhenDone(
|
| + p.x, p.y, base::Bind(&CursorDeviceScaleFactorStep,
|
| + test, not_attached_tab_strip, index + 1)));
|
| + } else {
|
| + // Finishes a serise of CursorDeviceScaleFactorStep calls and ends drag.
|
| + 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.
|
| + 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,
|
| + this, tab_strip, 0)));
|
| + QuitWhenNotDragging();
|
| +}
|
| +
|
| namespace {
|
|
|
| class DetachToBrowserInSeparateDisplayAndCancelTabDragControllerTest
|
| @@ -1271,6 +1370,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
|
|
|