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

Unified Diff: ash/laser/laser_pointer_controller_unittest.cc

Issue 2745953002: ash: Add basic prediction code to the laser pointer. (Closed)
Patch Set: more tests and 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
« no previous file with comments | « ash/laser/laser_pointer_controller_test_api.cc ('k') | ash/laser/laser_pointer_points.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..0b284fa3924f3e87a9a0eb673a838e531da685aa 100644
--- a/ash/laser/laser_pointer_controller_unittest.cc
+++ b/ash/laser/laser_pointer_controller_unittest.cc
@@ -111,4 +111,43 @@ 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());
+ // Verify predicted points are in the right direction.
+ for (const auto& point :
+ controller_test_api_.predicted_laser_points().laser_points()) {
+ EXPECT_LT(30, point.location.x());
+ EXPECT_LT(30, point.location.y());
+ }
+
+ // 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
« no previous file with comments | « ash/laser/laser_pointer_controller_test_api.cc ('k') | ash/laser/laser_pointer_points.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698