Index: ash/display/display_controller_unittest.cc |
diff --git a/ash/display/display_controller_unittest.cc b/ash/display/display_controller_unittest.cc |
index 15b9852832128d5ed082f7c9bf4f4924b2b300a6..fd1c9129ad7599b856ffdf40ef4299b045a93801 100644 |
--- a/ash/display/display_controller_unittest.cc |
+++ b/ash/display/display_controller_unittest.cc |
@@ -110,12 +110,10 @@ class TestEventHandler : public ui::EventHandler { |
virtual ~TestEventHandler() {} |
virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE { |
- aura::Window* target = static_cast<aura::Window*>(event->target()); |
- // Only record when the target is the background which covers |
- // entire root window. |
- if (target->name() != kDesktopBackgroundView) |
+ if (event->flags() & ui::EF_IS_SYNTHESIZED) |
return; |
- mouse_location_ = event->location(); |
+ aura::Window* target = static_cast<aura::Window*>(event->target()); |
+ mouse_location_ = event->root_location(); |
target_root_ = target->GetRootWindow(); |
event->StopPropagation(); |
} |
@@ -183,6 +181,14 @@ float GetStoredUIScale(int64 id) { |
return Shell::GetInstance()->display_manager()->GetDisplayInfo(id).ui_scale(); |
} |
+void MoveMouseToInHostCoord(aura::RootWindow* root_window, |
+ int host_x, |
+ int host_y) { |
+ gfx::Point move_point(host_x, host_y); |
+ ui::MouseEvent mouseev(ui::ET_MOUSE_MOVED, move_point, move_point, 0); |
+ root_window->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouseev); |
+} |
+ |
} // namespace |
typedef test::AshTestBase DisplayControllerTest; |
@@ -420,7 +426,7 @@ TEST_F(DisplayControllerTest, SwapPrimary) { |
EXPECT_EQ("left, -50", inverted_layout.ToString()); |
EXPECT_EQ(secondary_display.id(), |
- Shell::GetScreen()->GetPrimaryDisplay().id()); |
+ Shell::GetScreen()->GetPrimaryDisplay().id()); |
EXPECT_EQ(primary_display.id(), ScreenAsh::GetSecondaryDisplay().id()); |
EXPECT_EQ(secondary_display.id(), |
Shell::GetScreen()->GetDisplayNearestPoint( |
@@ -726,8 +732,14 @@ TEST_F(DisplayControllerTest, MAYBE_OverscanInsets) { |
// SetTransform updates the window using the orignal host window |
// size. |
#define MAYBE_Rotate DISABLED_Rotate |
+#define MAYBE_ScaleRootWindow DISABLED_ScaleRootWindow |
+#define MAYBE_TouchScale DISABLED_TouchScale |
+#define MAYBE_ConvertHostToRootCoords DISABLED_ConvertHostToRootCoords |
#else |
#define MAYBE_Rotate Rotate |
+#define MAYBE_ScaleRootWindow ScaleRootWindow |
+#define MAYBE_TouchScale TouchScale |
+#define MAYBE_ConvertHostToRootCoords ConvertHostToRootCoords |
#endif |
TEST_F(DisplayControllerTest, MAYBE_Rotate) { |
@@ -798,15 +810,6 @@ TEST_F(DisplayControllerTest, MAYBE_Rotate) { |
Shell::GetInstance()->RemovePreTargetHandler(&event_handler); |
} |
-#if defined(OS_WIN) |
-// On Win8 bots, the host window can't be resized and |
-// SetTransform updates the window using the orignal host window |
-// size. |
-#define MAYBE_ScaleRootWindow DISABLED_ScaleRootWindow |
-#else |
-#define MAYBE_ScaleRootWindow ScaleRootWindow |
-#endif |
- |
TEST_F(DisplayControllerTest, MAYBE_ScaleRootWindow) { |
TestEventHandler event_handler; |
Shell::GetInstance()->AddPreTargetHandler(&event_handler); |
@@ -840,16 +843,6 @@ TEST_F(DisplayControllerTest, MAYBE_ScaleRootWindow) { |
Shell::GetInstance()->RemovePreTargetHandler(&event_handler); |
} |
- |
-#if defined(OS_WIN) |
-// On Win8 bots, the host window can't be resized and |
-// SetTransform updates the window using the orignal host window |
-// size. |
-#define MAYBE_TouchScale DISABLED_TouchScale |
-#else |
-#define MAYBE_TouchScale TouchScale |
-#endif |
- |
TEST_F(DisplayControllerTest, MAYBE_TouchScale) { |
TestEventHandler event_handler; |
Shell::GetInstance()->AddPreTargetHandler(&event_handler); |
@@ -879,5 +872,29 @@ TEST_F(DisplayControllerTest, MAYBE_TouchScale) { |
Shell::GetInstance()->RemovePreTargetHandler(&event_handler); |
} |
+TEST_F(DisplayControllerTest, MAYBE_ConvertHostToRootCoords) { |
+ TestEventHandler event_handler; |
+ Shell::GetInstance()->AddPreTargetHandler(&event_handler); |
+ |
+ UpdateDisplay("600x400*2/r@1.5"); |
+ |
+ gfx::Display display1 = Shell::GetScreen()->GetPrimaryDisplay(); |
+ Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
+ EXPECT_EQ("0,0 300x450", display1.bounds().ToString()); |
+ EXPECT_EQ("0,0 300x450", root_windows[0]->bounds().ToString()); |
+ EXPECT_EQ(1.5f, GetStoredUIScale(display1.id())); |
+ |
+ MoveMouseToInHostCoord(root_windows[0], 0, 0); |
+ EXPECT_EQ("0,449", event_handler.GetLocationAndReset()); |
+ MoveMouseToInHostCoord(root_windows[0], 599, 0); |
+ EXPECT_EQ("0,0", event_handler.GetLocationAndReset()); |
+ MoveMouseToInHostCoord(root_windows[0], 599, 399); |
+ EXPECT_EQ("299,0", event_handler.GetLocationAndReset()); |
+ MoveMouseToInHostCoord(root_windows[0], 0, 399); |
+ EXPECT_EQ("299,449", event_handler.GetLocationAndReset()); |
+ |
+ Shell::GetInstance()->RemovePreTargetHandler(&event_handler); |
+} |
+ |
} // namespace test |
} // namespace ash |