Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2961)

Unified Diff: ash/laser/laser_pointer_controller_unittest.cc

Issue 2745953002: ash: Add basic prediction code to the laser pointer. (Closed)
Patch Set: Add unit test and fix nits Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698