Index: ash/magnifier/magnification_controller_unittest.cc |
=================================================================== |
--- ash/magnifier/magnification_controller_unittest.cc (revision 199610) |
+++ ash/magnifier/magnification_controller_unittest.cc (working copy) |
@@ -53,12 +53,6 @@ |
return Shell::GetPrimaryRootWindow(); |
} |
- |
- void MoveCursorWithEvent(gfx::Point point) { |
- aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); |
- generator.MoveMouseTo(point.x(), point.y()); |
- } |
- |
std::string GetHostMouseLocation() { |
gfx::Point point; |
GetRootWindow()->QueryMouseLocationForTest(&point); |
@@ -178,26 +172,29 @@ |
} |
TEST_F(MagnificationControllerTest, PointOfInterest) { |
- MoveCursorWithEvent(gfx::Point(0, 0)); |
+ aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); |
+ |
+ generator.MoveMouseToInHost(gfx::Point(0, 0)); |
EXPECT_EQ("0,0", CurrentPointOfInterest()); |
- MoveCursorWithEvent(gfx::Point(799, 599)); |
+ generator.MoveMouseToInHost(gfx::Point(799, 599)); |
EXPECT_EQ("799,599", CurrentPointOfInterest()); |
- MoveCursorWithEvent(gfx::Point(400, 300)); |
+ generator.MoveMouseToInHost(gfx::Point(400, 300)); |
EXPECT_EQ("400,300", CurrentPointOfInterest()); |
GetMagnificationController()->SetEnabled(true); |
EXPECT_EQ("400,300", CurrentPointOfInterest()); |
- MoveCursorWithEvent(gfx::Point(500, 400)); |
+ generator.MoveMouseToInHost(gfx::Point(500, 400)); |
EXPECT_EQ("450,350", CurrentPointOfInterest()); |
} |
TEST_F(MagnificationControllerTest, PanWindow2xLeftToRight) { |
const aura::Env* env = aura::Env::GetInstance(); |
+ aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); |
- MoveCursorWithEvent(gfx::Point(0, 0)); |
+ generator.MoveMouseToInHost(gfx::Point(0, 0)); |
EXPECT_EQ(1.f, GetMagnificationController()->GetScale()); |
EXPECT_EQ("0,0 800x600", GetViewport().ToString()); |
EXPECT_EQ("0,0", env->last_mouse_location().ToString()); |
@@ -207,100 +204,101 @@ |
EXPECT_EQ(2.0f, GetMagnificationController()->GetScale()); |
GetMagnificationController()->MoveWindow(0, 0, false); |
- MoveCursorWithEvent(gfx::Point(0, 0)); |
+ generator.MoveMouseToInHost(gfx::Point(0, 0)); |
EXPECT_EQ("0,0", env->last_mouse_location().ToString()); |
EXPECT_EQ("0,0 400x300", GetViewport().ToString()); |
- MoveCursorWithEvent(gfx::Point(300, 150)); |
+ generator.MoveMouseToInHost(gfx::Point(300, 150)); |
EXPECT_EQ("150,75", env->last_mouse_location().ToString()); |
EXPECT_EQ("0,0 400x300", GetViewport().ToString()); |
- MoveCursorWithEvent(gfx::Point(700, 150)); |
+ generator.MoveMouseToInHost(gfx::Point(700, 150)); |
EXPECT_EQ("350,75", env->last_mouse_location().ToString()); |
EXPECT_EQ("0,0 400x300", GetViewport().ToString()); |
- MoveCursorWithEvent(gfx::Point(701, 150)); |
+ generator.MoveMouseToInHost(gfx::Point(701, 150)); |
EXPECT_EQ("350,75", env->last_mouse_location().ToString()); |
EXPECT_EQ("0,0 400x300", GetViewport().ToString()); |
- MoveCursorWithEvent(gfx::Point(702, 150)); |
+ generator.MoveMouseToInHost(gfx::Point(702, 150)); |
EXPECT_EQ("351,75", env->last_mouse_location().ToString()); |
EXPECT_EQ("1,0 400x300", GetViewport().ToString()); |
- MoveCursorWithEvent(gfx::Point(703, 150)); |
+ generator.MoveMouseToInHost(gfx::Point(703, 150)); |
EXPECT_EQ("352,75", env->last_mouse_location().ToString()); |
EXPECT_EQ("2,0 400x300", GetViewport().ToString()); |
- MoveCursorWithEvent(gfx::Point(704, 150)); |
+ generator.MoveMouseToInHost(gfx::Point(704, 150)); |
EXPECT_EQ("354,75", env->last_mouse_location().ToString()); |
EXPECT_EQ("4,0 400x300", GetViewport().ToString()); |
- MoveCursorWithEvent(gfx::Point(712, 150)); |
+ generator.MoveMouseToInHost(gfx::Point(712, 150)); |
EXPECT_EQ("360,75", env->last_mouse_location().ToString()); |
EXPECT_EQ("10,0 400x300", GetViewport().ToString()); |
- MoveCursorWithEvent(gfx::Point(600, 150)); |
+ generator.MoveMouseToInHost(gfx::Point(600, 150)); |
EXPECT_EQ("310,75", env->last_mouse_location().ToString()); |
EXPECT_EQ("10,0 400x300", GetViewport().ToString()); |
- MoveCursorWithEvent(gfx::Point(720, 150)); |
+ generator.MoveMouseToInHost(gfx::Point(720, 150)); |
EXPECT_EQ("370,75", env->last_mouse_location().ToString()); |
EXPECT_EQ("20,0 400x300", GetViewport().ToString()); |
- MoveCursorWithEvent(gfx::Point(780, 150)); |
+ generator.MoveMouseToInHost(gfx::Point(780, 150)); |
EXPECT_EQ("410,75", env->last_mouse_location().ToString()); |
EXPECT_EQ("410,75", CurrentPointOfInterest()); |
EXPECT_EQ("60,0 400x300", GetViewport().ToString()); |
- MoveCursorWithEvent(gfx::Point(799, 150)); |
+ generator.MoveMouseToInHost(gfx::Point(799, 150)); |
EXPECT_EQ("459,75", env->last_mouse_location().ToString()); |
EXPECT_EQ("109,0 400x300", GetViewport().ToString()); |
- MoveCursorWithEvent(gfx::Point(702, 150)); |
+ generator.MoveMouseToInHost(gfx::Point(702, 150)); |
EXPECT_EQ("460,75", env->last_mouse_location().ToString()); |
EXPECT_EQ("110,0 400x300", GetViewport().ToString()); |
- MoveCursorWithEvent(gfx::Point(780, 150)); |
+ generator.MoveMouseToInHost(gfx::Point(780, 150)); |
EXPECT_EQ("500,75", env->last_mouse_location().ToString()); |
EXPECT_EQ("150,0 400x300", GetViewport().ToString()); |
- MoveCursorWithEvent(gfx::Point(780, 150)); |
+ generator.MoveMouseToInHost(gfx::Point(780, 150)); |
EXPECT_EQ("540,75", env->last_mouse_location().ToString()); |
EXPECT_EQ("190,0 400x300", GetViewport().ToString()); |
- MoveCursorWithEvent(gfx::Point(780, 150)); |
+ generator.MoveMouseToInHost(gfx::Point(780, 150)); |
EXPECT_EQ("580,75", env->last_mouse_location().ToString()); |
EXPECT_EQ("230,0 400x300", GetViewport().ToString()); |
- MoveCursorWithEvent(gfx::Point(780, 150)); |
+ generator.MoveMouseToInHost(gfx::Point(780, 150)); |
EXPECT_EQ("620,75", env->last_mouse_location().ToString()); |
EXPECT_EQ("270,0 400x300", GetViewport().ToString()); |
- MoveCursorWithEvent(gfx::Point(780, 150)); |
+ generator.MoveMouseToInHost(gfx::Point(780, 150)); |
EXPECT_EQ("660,75", env->last_mouse_location().ToString()); |
EXPECT_EQ("310,0 400x300", GetViewport().ToString()); |
- MoveCursorWithEvent(gfx::Point(780, 150)); |
+ generator.MoveMouseToInHost(gfx::Point(780, 150)); |
EXPECT_EQ("700,75", env->last_mouse_location().ToString()); |
EXPECT_EQ("350,0 400x300", GetViewport().ToString()); |
- MoveCursorWithEvent(gfx::Point(780, 150)); |
+ generator.MoveMouseToInHost(gfx::Point(780, 150)); |
EXPECT_EQ("740,75", env->last_mouse_location().ToString()); |
EXPECT_EQ("390,0 400x300", GetViewport().ToString()); |
- MoveCursorWithEvent(gfx::Point(780, 150)); |
+ generator.MoveMouseToInHost(gfx::Point(780, 150)); |
EXPECT_EQ("780,75", env->last_mouse_location().ToString()); |
EXPECT_EQ("400,0 400x300", GetViewport().ToString()); |
- MoveCursorWithEvent(gfx::Point(799, 150)); |
+ generator.MoveMouseToInHost(gfx::Point(799, 150)); |
EXPECT_EQ("799,75", env->last_mouse_location().ToString()); |
EXPECT_EQ("400,0 400x300", GetViewport().ToString()); |
} |
TEST_F(MagnificationControllerTest, PanWindow2xRightToLeft) { |
const aura::Env* env = aura::Env::GetInstance(); |
+ aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); |
- MoveCursorWithEvent(gfx::Point(799, 300)); |
+ generator.MoveMouseToInHost(gfx::Point(799, 300)); |
EXPECT_EQ(1.f, GetMagnificationController()->GetScale()); |
EXPECT_EQ("0,0 800x600", GetViewport().ToString()); |
EXPECT_EQ("799,300", env->last_mouse_location().ToString()); |
@@ -308,51 +306,52 @@ |
// Enables magnifier and confirm the viewport is at center. |
GetMagnificationController()->SetEnabled(true); |
- MoveCursorWithEvent(gfx::Point(799, 300)); |
+ generator.MoveMouseToInHost(gfx::Point(799, 300)); |
EXPECT_EQ("798,300", env->last_mouse_location().ToString()); |
EXPECT_EQ("400,150 400x300", GetViewport().ToString()); |
- MoveCursorWithEvent(gfx::Point(0, 300)); |
+ generator.MoveMouseToInHost(gfx::Point(0, 300)); |
EXPECT_EQ("400,300", env->last_mouse_location().ToString()); |
EXPECT_EQ("350,150 400x300", GetViewport().ToString()); |
- MoveCursorWithEvent(gfx::Point(0, 300)); |
+ generator.MoveMouseToInHost(gfx::Point(0, 300)); |
EXPECT_EQ("350,300", env->last_mouse_location().ToString()); |
EXPECT_EQ("300,150 400x300", GetViewport().ToString()); |
- MoveCursorWithEvent(gfx::Point(0, 300)); |
+ generator.MoveMouseToInHost(gfx::Point(0, 300)); |
EXPECT_EQ("300,300", env->last_mouse_location().ToString()); |
EXPECT_EQ("250,150 400x300", GetViewport().ToString()); |
- MoveCursorWithEvent(gfx::Point(0, 300)); |
+ generator.MoveMouseToInHost(gfx::Point(0, 300)); |
EXPECT_EQ("250,300", env->last_mouse_location().ToString()); |
EXPECT_EQ("200,150 400x300", GetViewport().ToString()); |
- MoveCursorWithEvent(gfx::Point(0, 300)); |
+ generator.MoveMouseToInHost(gfx::Point(0, 300)); |
EXPECT_EQ("200,300", env->last_mouse_location().ToString()); |
EXPECT_EQ("150,150 400x300", GetViewport().ToString()); |
- MoveCursorWithEvent(gfx::Point(0, 300)); |
+ generator.MoveMouseToInHost(gfx::Point(0, 300)); |
EXPECT_EQ("150,300", env->last_mouse_location().ToString()); |
EXPECT_EQ("100,150 400x300", GetViewport().ToString()); |
- MoveCursorWithEvent(gfx::Point(0, 300)); |
+ generator.MoveMouseToInHost(gfx::Point(0, 300)); |
EXPECT_EQ("100,300", env->last_mouse_location().ToString()); |
EXPECT_EQ("50,150 400x300", GetViewport().ToString()); |
- MoveCursorWithEvent(gfx::Point(0, 300)); |
+ generator.MoveMouseToInHost(gfx::Point(0, 300)); |
EXPECT_EQ("50,300", env->last_mouse_location().ToString()); |
EXPECT_EQ("0,150 400x300", GetViewport().ToString()); |
- MoveCursorWithEvent(gfx::Point(0, 300)); |
+ generator.MoveMouseToInHost(gfx::Point(0, 300)); |
EXPECT_EQ("0,300", env->last_mouse_location().ToString()); |
EXPECT_EQ("0,150 400x300", GetViewport().ToString()); |
} |
TEST_F(MagnificationControllerTest, PanWindowToRight) { |
const aura::Env* env = aura::Env::GetInstance(); |
+ aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); |
- MoveCursorWithEvent(gfx::Point(400, 300)); |
+ generator.MoveMouseToInHost(gfx::Point(400, 300)); |
EXPECT_EQ(1.f, GetMagnificationController()->GetScale()); |
EXPECT_EQ("0,0 800x600", GetViewport().ToString()); |
EXPECT_EQ("400,300", env->last_mouse_location().ToString()); |
@@ -366,38 +365,39 @@ |
scale *= kMagnificationScaleFactor; |
GetMagnificationController()->SetScale(scale, false); |
EXPECT_FLOAT_EQ(2.3784142, GetMagnificationController()->GetScale()); |
- MoveCursorWithEvent(gfx::Point(400, 300)); |
+ generator.MoveMouseToInHost(gfx::Point(400, 300)); |
EXPECT_EQ("400,300", env->last_mouse_location().ToString()); |
- MoveCursorWithEvent(gfx::Point(799, 300)); |
+ generator.MoveMouseToInHost(gfx::Point(799, 300)); |
EXPECT_EQ("566,299", env->last_mouse_location().ToString()); |
EXPECT_EQ("705,300", GetHostMouseLocation()); |
scale *= kMagnificationScaleFactor; |
GetMagnificationController()->SetScale(scale, false); |
EXPECT_FLOAT_EQ(2.8284268, GetMagnificationController()->GetScale()); |
- MoveCursorWithEvent(gfx::Point(799, 300)); |
+ generator.MoveMouseToInHost(gfx::Point(799, 300)); |
EXPECT_EQ("599,299", env->last_mouse_location().ToString()); |
EXPECT_EQ("702,300", GetHostMouseLocation()); |
scale *= kMagnificationScaleFactor; |
GetMagnificationController()->SetScale(scale, false); |
EXPECT_FLOAT_EQ(3.3635852, GetMagnificationController()->GetScale()); |
- MoveCursorWithEvent(gfx::Point(799, 300)); |
+ generator.MoveMouseToInHost(gfx::Point(799, 300)); |
EXPECT_EQ("627,298", env->last_mouse_location().ToString()); |
EXPECT_EQ("707,300", GetHostMouseLocation()); |
scale *= kMagnificationScaleFactor; |
GetMagnificationController()->SetScale(scale, false); |
EXPECT_FLOAT_EQ(4.f, GetMagnificationController()->GetScale()); |
- MoveCursorWithEvent(gfx::Point(799, 300)); |
+ generator.MoveMouseToInHost(gfx::Point(799, 300)); |
EXPECT_EQ("649,298", env->last_mouse_location().ToString()); |
EXPECT_EQ("704,300", GetHostMouseLocation()); |
} |
TEST_F(MagnificationControllerTest, PanWindowToLeft) { |
const aura::Env* env = aura::Env::GetInstance(); |
+ aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); |
- MoveCursorWithEvent(gfx::Point(400, 300)); |
+ generator.MoveMouseToInHost(gfx::Point(400, 300)); |
EXPECT_EQ(1.f, GetMagnificationController()->GetScale()); |
EXPECT_EQ("0,0 800x600", GetViewport().ToString()); |
EXPECT_EQ("400,300", env->last_mouse_location().ToString()); |
@@ -411,30 +411,30 @@ |
scale *= kMagnificationScaleFactor; |
GetMagnificationController()->SetScale(scale, false); |
EXPECT_FLOAT_EQ(2.3784142, GetMagnificationController()->GetScale()); |
- MoveCursorWithEvent(gfx::Point(400, 300)); |
+ generator.MoveMouseToInHost(gfx::Point(400, 300)); |
EXPECT_EQ("400,300", env->last_mouse_location().ToString()); |
- MoveCursorWithEvent(gfx::Point(0, 300)); |
+ generator.MoveMouseToInHost(gfx::Point(0, 300)); |
EXPECT_EQ("231,299", env->last_mouse_location().ToString()); |
EXPECT_EQ("100,300", GetHostMouseLocation()); |
scale *= kMagnificationScaleFactor; |
GetMagnificationController()->SetScale(scale, false); |
EXPECT_FLOAT_EQ(2.8284268, GetMagnificationController()->GetScale()); |
- MoveCursorWithEvent(gfx::Point(0, 300)); |
+ generator.MoveMouseToInHost(gfx::Point(0, 300)); |
EXPECT_EQ("195,299", env->last_mouse_location().ToString()); |
EXPECT_EQ("99,300", GetHostMouseLocation()); |
scale *= kMagnificationScaleFactor; |
GetMagnificationController()->SetScale(scale, false); |
EXPECT_FLOAT_EQ(3.3635852, GetMagnificationController()->GetScale()); |
- MoveCursorWithEvent(gfx::Point(0, 300)); |
+ generator.MoveMouseToInHost(gfx::Point(0, 300)); |
EXPECT_EQ("165,298", env->last_mouse_location().ToString()); |
EXPECT_EQ("98,300", GetHostMouseLocation()); |
scale *= kMagnificationScaleFactor; |
GetMagnificationController()->SetScale(scale, false); |
EXPECT_FLOAT_EQ(4.f, GetMagnificationController()->GetScale()); |
- MoveCursorWithEvent(gfx::Point(0, 300)); |
+ generator.MoveMouseToInHost(gfx::Point(0, 300)); |
EXPECT_EQ("140,298", env->last_mouse_location().ToString()); |
EXPECT_EQ("100,300", GetHostMouseLocation()); |
} |