Chromium Code Reviews| 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..def366542ba1d3394895853fabc089950111b43c 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,112 @@ 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[N]|, then calls the next step function. |
| +template <int N> |
|
sky
2012/10/17 21:29:42
Ugh. Why do we need the templates here? Can't we j
mazda
2012/10/17 23:44:29
Rewrote it without using template.
|
| +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>, |
| + 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 |
| @@ -1271,6 +1379,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 |