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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/laser/laser_pointer_controller.h" 5 #include "ash/laser/laser_pointer_controller.h"
6 #include "ash/laser/laser_pointer_controller_test_api.h" 6 #include "ash/laser/laser_pointer_controller_test_api.h"
7 #include "ash/laser/laser_pointer_view.h" 7 #include "ash/laser/laser_pointer_view.h"
8 #include "ash/shell.h" 8 #include "ash/shell.h"
9 #include "ash/test/ash_test_base.h" 9 #include "ash/test/ash_test_base.h"
10 #include "ui/events/test/event_generator.h" 10 #include "ui/events/test/event_generator.h"
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 // Verify that the laser pointer does not get shown if points are not coming 104 // Verify that the laser pointer does not get shown if points are not coming
105 // from the stylus, even when enabled. 105 // from the stylus, even when enabled.
106 GetEventGenerator().ExitPenPointerMode(); 106 GetEventGenerator().ExitPenPointerMode();
107 controller_test_api_.SetEnabled(true); 107 controller_test_api_.SetEnabled(true);
108 GetEventGenerator().PressTouch(); 108 GetEventGenerator().PressTouch();
109 GetEventGenerator().MoveTouch(gfx::Point(10, 10)); 109 GetEventGenerator().MoveTouch(gfx::Point(10, 10));
110 GetEventGenerator().MoveTouch(gfx::Point(11, 11)); 110 GetEventGenerator().MoveTouch(gfx::Point(11, 11));
111 EXPECT_FALSE(controller_test_api_.IsShowingLaserPointer()); 111 EXPECT_FALSE(controller_test_api_.IsShowingLaserPointer());
112 GetEventGenerator().ReleaseTouch(); 112 GetEventGenerator().ReleaseTouch();
113 } 113 }
114
115 // Test to ensure the class responsible for drawing the laser pointer handles
116 // prediction as expected when it receives points from stylus movements.
117 TEST_F(LaserPointerControllerTest, LaserPointerPrediction) {
118 LaserPointerControllerTestApi controller_test_api_(controller_.get());
119
120 controller_test_api_.SetEnabled(true);
121 // The laser pointer mode only works with stylus.
122 GetEventGenerator().EnterPenPointerMode();
123 GetEventGenerator().PressTouch();
124 EXPECT_TRUE(controller_test_api_.IsShowingLaserPointer());
125
126 EXPECT_EQ(1, controller_test_api_.laser_points().GetNumberOfPoints());
127 // Initial press event shouldn't generate any predicted points as there's no
128 // history to use for prediction.
129 EXPECT_EQ(0,
130 controller_test_api_.predicted_laser_points().GetNumberOfPoints());
131
132 // Verify dragging the stylus 3 times will add some predicted points.
133 GetEventGenerator().MoveTouch(gfx::Point(10, 10));
134 GetEventGenerator().MoveTouch(gfx::Point(20, 20));
135 GetEventGenerator().MoveTouch(gfx::Point(30, 30));
136 EXPECT_NE(0,
137 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.
138
139 // Verify releasing the stylus removes predicted points.
140 GetEventGenerator().ReleaseTouch();
141 EXPECT_TRUE(controller_test_api_.IsShowingLaserPointer());
142 EXPECT_TRUE(controller_test_api_.IsFadingAway());
143 EXPECT_EQ(0,
144 controller_test_api_.predicted_laser_points().GetNumberOfPoints());
145 }
146
114 } // namespace ash 147 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698