Chromium Code Reviews| Index: ash/laser/laser_pointer_controller_unittest.cc |
| diff --git a/ash/laser/laser_pointer_controller_unittest.cc b/ash/laser/laser_pointer_controller_unittest.cc |
| index 8f2486ac219fc1e60076e4ac3e9ab43815bee488..9e67da4dc1fd4c84f8bef393e105362f14190253 100644 |
| --- a/ash/laser/laser_pointer_controller_unittest.cc |
| +++ b/ash/laser/laser_pointer_controller_unittest.cc |
| @@ -111,4 +111,37 @@ TEST_F(LaserPointerControllerTest, LaserPointerRenderer) { |
| EXPECT_FALSE(controller_test_api_.IsShowingLaserPointer()); |
| GetEventGenerator().ReleaseTouch(); |
| } |
| + |
| +// Test to ensure the class responsible for drawing the laser pointer handles |
| +// prediction as expected when it receives points from stylus movements. |
| +TEST_F(LaserPointerControllerTest, LaserPointerPrediction) { |
| + LaserPointerControllerTestApi controller_test_api_(controller_.get()); |
| + |
| + controller_test_api_.SetEnabled(true); |
| + // The laser pointer mode only works with stylus. |
| + GetEventGenerator().EnterPenPointerMode(); |
| + GetEventGenerator().PressTouch(); |
| + EXPECT_TRUE(controller_test_api_.IsShowingLaserPointer()); |
| + |
| + EXPECT_EQ(1, controller_test_api_.laser_points().GetNumberOfPoints()); |
| + // Initial press event shouldn't generate any predicted points as there's no |
| + // history to use for prediction. |
| + EXPECT_EQ(0, |
| + controller_test_api_.predicted_laser_points().GetNumberOfPoints()); |
| + |
| + // Verify dragging the stylus 3 times will add some predicted points. |
| + GetEventGenerator().MoveTouch(gfx::Point(10, 10)); |
| + GetEventGenerator().MoveTouch(gfx::Point(20, 20)); |
| + GetEventGenerator().MoveTouch(gfx::Point(30, 30)); |
| + EXPECT_NE(0, |
| + controller_test_api_.predicted_laser_points().GetNumberOfPoints()); |
|
Daniel Erat
2017/03/16 20:18:30
i hope you add some tests that verify the actual p
reveman
2017/03/16 20:42:49
Added to latest patch.
|
| + |
| + // Verify releasing the stylus removes predicted points. |
| + GetEventGenerator().ReleaseTouch(); |
| + EXPECT_TRUE(controller_test_api_.IsShowingLaserPointer()); |
| + EXPECT_TRUE(controller_test_api_.IsFadingAway()); |
| + EXPECT_EQ(0, |
| + controller_test_api_.predicted_laser_points().GetNumberOfPoints()); |
| +} |
| + |
| } // namespace ash |