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

Side by Side Diff: ash/laser/laser_pointer_controller_unittest.cc

Issue 2752303002: views/mus: Install a mus-friend ContextFactory for tests. (Closed)
Patch Set: . 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
« no previous file with comments | « no previous file | ash/mus/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
7 #include "ash/common/wm_shell.h"
6 #include "ash/laser/laser_pointer_controller_test_api.h" 8 #include "ash/laser/laser_pointer_controller_test_api.h"
7 #include "ash/laser/laser_pointer_view.h" 9 #include "ash/laser/laser_pointer_view.h"
8 #include "ash/shell.h" 10 #include "ash/shell.h"
9 #include "ash/test/ash_test_base.h" 11 #include "ash/test/ash_test_base.h"
10 #include "ui/events/test/event_generator.h" 12 #include "ui/events/test/event_generator.h"
11 13
12 namespace ash { 14 namespace ash {
13 namespace { 15 namespace {
14 16
15 class LaserPointerControllerTest : public test::AshTestBase { 17 class LaserPointerControllerTest : public test::AshTestBase {
(...skipping 18 matching lines...) Expand all
34 36
35 private: 37 private:
36 DISALLOW_COPY_AND_ASSIGN(LaserPointerControllerTest); 38 DISALLOW_COPY_AND_ASSIGN(LaserPointerControllerTest);
37 }; 39 };
38 40
39 } // namespace 41 } // namespace
40 42
41 // Test to ensure the class responsible for drawing the laser pointer receives 43 // Test to ensure the class responsible for drawing the laser pointer receives
42 // points from stylus movements as expected. 44 // points from stylus movements as expected.
43 TEST_F(LaserPointerControllerTest, LaserPointerRenderer) { 45 TEST_F(LaserPointerControllerTest, LaserPointerRenderer) {
46 // Crashes in mash mode: crbug.com/702657
47 if (WmShell::Get()->IsRunningInMash())
48 return;
44 LaserPointerControllerTestApi controller_test_api_(controller_.get()); 49 LaserPointerControllerTestApi controller_test_api_(controller_.get());
45 50
46 // The laser pointer mode only works with stylus. 51 // The laser pointer mode only works with stylus.
47 GetEventGenerator().EnterPenPointerMode(); 52 GetEventGenerator().EnterPenPointerMode();
48 53
49 // When disabled the laser pointer should not be showing. 54 // When disabled the laser pointer should not be showing.
50 GetEventGenerator().MoveTouch(gfx::Point(1, 1)); 55 GetEventGenerator().MoveTouch(gfx::Point(1, 1));
51 EXPECT_FALSE(controller_test_api_.IsShowingLaserPointer()); 56 EXPECT_FALSE(controller_test_api_.IsShowingLaserPointer());
52 57
53 // Verify that by enabling the mode, the laser pointer should still not be 58 // Verify that by enabling the mode, the laser pointer should still not be
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 GetEventGenerator().PressTouch(); 113 GetEventGenerator().PressTouch();
109 GetEventGenerator().MoveTouch(gfx::Point(10, 10)); 114 GetEventGenerator().MoveTouch(gfx::Point(10, 10));
110 GetEventGenerator().MoveTouch(gfx::Point(11, 11)); 115 GetEventGenerator().MoveTouch(gfx::Point(11, 11));
111 EXPECT_FALSE(controller_test_api_.IsShowingLaserPointer()); 116 EXPECT_FALSE(controller_test_api_.IsShowingLaserPointer());
112 GetEventGenerator().ReleaseTouch(); 117 GetEventGenerator().ReleaseTouch();
113 } 118 }
114 119
115 // Test to ensure the class responsible for drawing the laser pointer handles 120 // Test to ensure the class responsible for drawing the laser pointer handles
116 // prediction as expected when it receives points from stylus movements. 121 // prediction as expected when it receives points from stylus movements.
117 TEST_F(LaserPointerControllerTest, LaserPointerPrediction) { 122 TEST_F(LaserPointerControllerTest, LaserPointerPrediction) {
123 // Crashes in mash mode: crbug.com/702657
124 if (WmShell::Get()->IsRunningInMash())
125 return;
118 LaserPointerControllerTestApi controller_test_api_(controller_.get()); 126 LaserPointerControllerTestApi controller_test_api_(controller_.get());
119 127
120 controller_test_api_.SetEnabled(true); 128 controller_test_api_.SetEnabled(true);
121 // The laser pointer mode only works with stylus. 129 // The laser pointer mode only works with stylus.
122 GetEventGenerator().EnterPenPointerMode(); 130 GetEventGenerator().EnterPenPointerMode();
123 GetEventGenerator().PressTouch(); 131 GetEventGenerator().PressTouch();
124 EXPECT_TRUE(controller_test_api_.IsShowingLaserPointer()); 132 EXPECT_TRUE(controller_test_api_.IsShowingLaserPointer());
125 133
126 EXPECT_EQ(1, controller_test_api_.laser_points().GetNumberOfPoints()); 134 EXPECT_EQ(1, controller_test_api_.laser_points().GetNumberOfPoints());
127 // Initial press event shouldn't generate any predicted points as there's no 135 // Initial press event shouldn't generate any predicted points as there's no
(...skipping 16 matching lines...) Expand all
144 152
145 // Verify releasing the stylus removes predicted points. 153 // Verify releasing the stylus removes predicted points.
146 GetEventGenerator().ReleaseTouch(); 154 GetEventGenerator().ReleaseTouch();
147 EXPECT_TRUE(controller_test_api_.IsShowingLaserPointer()); 155 EXPECT_TRUE(controller_test_api_.IsShowingLaserPointer());
148 EXPECT_TRUE(controller_test_api_.IsFadingAway()); 156 EXPECT_TRUE(controller_test_api_.IsFadingAway());
149 EXPECT_EQ(0, 157 EXPECT_EQ(0,
150 controller_test_api_.predicted_laser_points().GetNumberOfPoints()); 158 controller_test_api_.predicted_laser_points().GetNumberOfPoints());
151 } 159 }
152 160
153 } // namespace ash 161 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ash/mus/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698