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

Side by Side Diff: remoting/client/plugin/normalizing_input_filter_cros_unittest.cc

Issue 985863002: Move all protocol event matchers to test_event_matchers.h (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased Created 5 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "remoting/client/plugin/normalizing_input_filter_cros.h" 5 #include "remoting/client/plugin/normalizing_input_filter_cros.h"
6 6
7 #include "remoting/proto/event.pb.h" 7 #include "remoting/proto/event.pb.h"
8 #include "remoting/protocol/protocol_mock_objects.h" 8 #include "remoting/protocol/protocol_mock_objects.h"
9 #include "remoting/protocol/test_event_matchers.h"
9 #include "testing/gmock/include/gmock/gmock.h" 10 #include "testing/gmock/include/gmock/gmock.h"
10 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
11 12
12 using ::testing::InSequence; 13 using ::testing::InSequence;
13 using remoting::protocol::InputStub; 14 using remoting::protocol::InputStub;
14 using remoting::protocol::KeyEvent; 15 using remoting::protocol::KeyEvent;
15 using remoting::protocol::MockInputStub; 16 using remoting::protocol::MockInputStub;
16 using remoting::protocol::MouseEvent; 17 using remoting::protocol::MouseEvent;
18 using remoting::protocol::test::EqualsKeyEventWithNumLock;
19 using remoting::protocol::test::EqualsMouseButtonEvent;
20 using remoting::protocol::test::EqualsMouseMoveEvent;
17 21
18 namespace remoting { 22 namespace remoting {
19 23
20 namespace { 24 namespace {
21 25
22 const unsigned int kUsbLeftOsKey = 0x0700e3; 26 const unsigned int kUsbLeftOsKey = 0x0700e3;
23 const unsigned int kUsbRightOsKey = 0x0700e7; 27 const unsigned int kUsbRightOsKey = 0x0700e7;
24 const unsigned int kUsbLeftAltKey = 0x0700e2; 28 const unsigned int kUsbLeftAltKey = 0x0700e2;
25 const unsigned int kUsbRightAltKey = 0x0700e6; 29 const unsigned int kUsbRightAltKey = 0x0700e6;
26 30
27 const unsigned int kUsbFunctionKey = 0x07003a; // F1 31 const unsigned int kUsbFunctionKey = 0x07003a; // F1
28 const unsigned int kUsbExtendedKey = 0x070049; // Insert 32 const unsigned int kUsbExtendedKey = 0x070049; // Insert
29 const unsigned int kUsbOtherKey = 0x07002b; // Tab 33 const unsigned int kUsbOtherKey = 0x07002b; // Tab
30 34
31 // A hardcoded value used to verify |lock_states| is preserved.
32 static const uint32 kTestLockStates = protocol::KeyEvent::LOCK_STATES_NUMLOCK;
33
34 MATCHER_P2(EqualsKeyEvent, usb_keycode, pressed, "") {
35 return arg.usb_keycode() == static_cast<uint32>(usb_keycode) &&
36 arg.pressed() == pressed &&
37 arg.lock_states() == kTestLockStates;
38 }
39
40 KeyEvent MakeKeyEvent(uint32 keycode, bool pressed) { 35 KeyEvent MakeKeyEvent(uint32 keycode, bool pressed) {
41 KeyEvent event; 36 KeyEvent event;
42 event.set_usb_keycode(keycode); 37 event.set_usb_keycode(keycode);
43 event.set_pressed(pressed); 38 event.set_pressed(pressed);
44 event.set_lock_states(kTestLockStates); 39 event.set_lock_states(protocol::KeyEvent::LOCK_STATES_NUMLOCK);
45 return event; 40 return event;
46 } 41 }
47 42
48 void PressAndReleaseKey(InputStub* input_stub, uint32 keycode) { 43 void PressAndReleaseKey(InputStub* input_stub, uint32 keycode) {
49 input_stub->InjectKeyEvent(MakeKeyEvent(keycode, true)); 44 input_stub->InjectKeyEvent(MakeKeyEvent(keycode, true));
50 input_stub->InjectKeyEvent(MakeKeyEvent(keycode, false)); 45 input_stub->InjectKeyEvent(MakeKeyEvent(keycode, false));
51 } 46 }
52 47
53 MATCHER_P2(EqualsMouseMoveEvent, x, y, "") {
54 return arg.x() == x && arg.y() == y;
55 }
56
57 MATCHER_P2(EqualsMouseButtonEvent, button, button_down, "") {
58 return arg.button() == button && arg.button_down() == button_down;
59 }
60
61 static MouseEvent MakeMouseMoveEvent(int x, int y) { 48 static MouseEvent MakeMouseMoveEvent(int x, int y) {
62 MouseEvent event; 49 MouseEvent event;
63 event.set_x(x); 50 event.set_x(x);
64 event.set_y(y); 51 event.set_y(y);
65 return event; 52 return event;
66 } 53 }
67 54
68 static MouseEvent MakeMouseButtonEvent(MouseEvent::MouseButton button, 55 static MouseEvent MakeMouseButtonEvent(MouseEvent::MouseButton button,
69 bool button_down) { 56 bool button_down) {
70 MouseEvent event; 57 MouseEvent event;
71 event.set_button(button); 58 event.set_button(button);
72 event.set_button_down(button_down); 59 event.set_button_down(button_down);
73 return event; 60 return event;
74 } 61 }
75 62
76 } // namespace 63 } // namespace
77 64
78 // Test OSKey press/release. 65 // Test OSKey press/release.
79 TEST(NormalizingInputFilterCrosTest, PressReleaseOsKey) { 66 TEST(NormalizingInputFilterCrosTest, PressReleaseOsKey) {
80 MockInputStub stub; 67 MockInputStub stub;
81 scoped_ptr<protocol::InputFilter> processor( 68 scoped_ptr<protocol::InputFilter> processor(
82 new NormalizingInputFilterCros(&stub)); 69 new NormalizingInputFilterCros(&stub));
83 70
84 { 71 {
85 InSequence s; 72 InSequence s;
86 73
87 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEvent(kUsbLeftOsKey, true))); 74 EXPECT_CALL(stub,
88 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEvent(kUsbLeftOsKey, false))); 75 InjectKeyEvent(EqualsKeyEventWithNumLock(kUsbLeftOsKey, true)));
76 EXPECT_CALL(
77 stub, InjectKeyEvent(EqualsKeyEventWithNumLock(kUsbLeftOsKey, false)));
89 78
90 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEvent(kUsbRightOsKey, true))); 79 EXPECT_CALL(
91 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEvent(kUsbRightOsKey, false))); 80 stub, InjectKeyEvent(EqualsKeyEventWithNumLock(kUsbRightOsKey, true)));
81 EXPECT_CALL(
82 stub, InjectKeyEvent(EqualsKeyEventWithNumLock(kUsbRightOsKey, false)));
92 } 83 }
93 84
94 // Inject press & release events for left & right OSKeys. 85 // Inject press & release events for left & right OSKeys.
95 PressAndReleaseKey(processor.get(), kUsbLeftOsKey); 86 PressAndReleaseKey(processor.get(), kUsbLeftOsKey);
96 PressAndReleaseKey(processor.get(), kUsbRightOsKey); 87 PressAndReleaseKey(processor.get(), kUsbRightOsKey);
97 } 88 }
98 89
99 // Test OSKey key repeat switches it to "modifying" mode. 90 // Test OSKey key repeat switches it to "modifying" mode.
100 TEST(NormalizingInputFilterCrosTest, OSKeyRepeats) { 91 TEST(NormalizingInputFilterCrosTest, OSKeyRepeats) {
101 MockInputStub stub; 92 MockInputStub stub;
102 scoped_ptr<protocol::InputFilter> processor( 93 scoped_ptr<protocol::InputFilter> processor(
103 new NormalizingInputFilterCros(&stub)); 94 new NormalizingInputFilterCros(&stub));
104 95
105 { 96 {
106 InSequence s; 97 InSequence s;
107 98
108 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEvent(kUsbLeftOsKey, true))); 99 EXPECT_CALL(stub,
109 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEvent(kUsbLeftOsKey, true))); 100 InjectKeyEvent(EqualsKeyEventWithNumLock(kUsbLeftOsKey, true)));
110 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEvent(kUsbLeftOsKey, true))); 101 EXPECT_CALL(stub,
102 InjectKeyEvent(EqualsKeyEventWithNumLock(kUsbLeftOsKey, true)));
103 EXPECT_CALL(stub,
104 InjectKeyEvent(EqualsKeyEventWithNumLock(kUsbLeftOsKey, true)));
111 } 105 }
112 106
113 // Inject a press and repeats for the left OSKey, but don't release it, and 107 // Inject a press and repeats for the left OSKey, but don't release it, and
114 // verify that the repeats result in press events. 108 // verify that the repeats result in press events.
115 processor->InjectKeyEvent(MakeKeyEvent(kUsbLeftOsKey, true)); 109 processor->InjectKeyEvent(MakeKeyEvent(kUsbLeftOsKey, true));
116 processor->InjectKeyEvent(MakeKeyEvent(kUsbLeftOsKey, true)); 110 processor->InjectKeyEvent(MakeKeyEvent(kUsbLeftOsKey, true));
117 processor->InjectKeyEvent(MakeKeyEvent(kUsbLeftOsKey, true)); 111 processor->InjectKeyEvent(MakeKeyEvent(kUsbLeftOsKey, true));
118 } 112 }
119 113
120 // Test OSKey press followed by function key press and release results in 114 // Test OSKey press followed by function key press and release results in
121 // just the function key events. 115 // just the function key events.
122 TEST(NormalizingInputFilterCrosTest, FunctionKey) { 116 TEST(NormalizingInputFilterCrosTest, FunctionKey) {
123 MockInputStub stub; 117 MockInputStub stub;
124 scoped_ptr<protocol::InputFilter> processor( 118 scoped_ptr<protocol::InputFilter> processor(
125 new NormalizingInputFilterCros(&stub)); 119 new NormalizingInputFilterCros(&stub));
126 120
127 { 121 {
128 InSequence s; 122 InSequence s;
129 123
130 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEvent(kUsbFunctionKey, true))); 124 EXPECT_CALL(
131 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEvent(kUsbFunctionKey, false))); 125 stub, InjectKeyEvent(EqualsKeyEventWithNumLock(kUsbFunctionKey, true)));
126 EXPECT_CALL(stub, InjectKeyEvent(
127 EqualsKeyEventWithNumLock(kUsbFunctionKey, false)));
132 } 128 }
133 129
134 // Hold the left OSKey while pressing & releasing the function key. 130 // Hold the left OSKey while pressing & releasing the function key.
135 processor->InjectKeyEvent(MakeKeyEvent(kUsbLeftOsKey, true)); 131 processor->InjectKeyEvent(MakeKeyEvent(kUsbLeftOsKey, true));
136 PressAndReleaseKey(processor.get(), kUsbFunctionKey); 132 PressAndReleaseKey(processor.get(), kUsbFunctionKey);
137 processor->InjectKeyEvent(MakeKeyEvent(kUsbLeftOsKey, false)); 133 processor->InjectKeyEvent(MakeKeyEvent(kUsbLeftOsKey, false));
138 } 134 }
139 135
140 // Test OSKey press followed by extended key press and release results in 136 // Test OSKey press followed by extended key press and release results in
141 // just the function key events. 137 // just the function key events.
142 TEST(NormalizingInputFilterCrosTest, ExtendedKey) { 138 TEST(NormalizingInputFilterCrosTest, ExtendedKey) {
143 MockInputStub stub; 139 MockInputStub stub;
144 scoped_ptr<protocol::InputFilter> processor( 140 scoped_ptr<protocol::InputFilter> processor(
145 new NormalizingInputFilterCros(&stub)); 141 new NormalizingInputFilterCros(&stub));
146 142
147 { 143 {
148 InSequence s; 144 InSequence s;
149 145
150 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEvent(kUsbExtendedKey, true))); 146 EXPECT_CALL(
151 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEvent(kUsbExtendedKey, false))); 147 stub, InjectKeyEvent(EqualsKeyEventWithNumLock(kUsbExtendedKey, true)));
148 EXPECT_CALL(stub, InjectKeyEvent(
149 EqualsKeyEventWithNumLock(kUsbExtendedKey, false)));
152 } 150 }
153 151
154 // Hold the left OSKey while pressing & releasing the function key. 152 // Hold the left OSKey while pressing & releasing the function key.
155 processor->InjectKeyEvent(MakeKeyEvent(kUsbLeftOsKey, true)); 153 processor->InjectKeyEvent(MakeKeyEvent(kUsbLeftOsKey, true));
156 PressAndReleaseKey(processor.get(), kUsbExtendedKey); 154 PressAndReleaseKey(processor.get(), kUsbExtendedKey);
157 processor->InjectKeyEvent(MakeKeyEvent(kUsbLeftOsKey, false)); 155 processor->InjectKeyEvent(MakeKeyEvent(kUsbLeftOsKey, false));
158 } 156 }
159 157
160 // Test OSKey press followed by non-function, non-extended key press and release 158 // Test OSKey press followed by non-function, non-extended key press and release
161 // results in normal-looking sequence. 159 // results in normal-looking sequence.
162 TEST(NormalizingInputFilterCrosTest, OtherKey) { 160 TEST(NormalizingInputFilterCrosTest, OtherKey) {
163 MockInputStub stub; 161 MockInputStub stub;
164 scoped_ptr<protocol::InputFilter> processor( 162 scoped_ptr<protocol::InputFilter> processor(
165 new NormalizingInputFilterCros(&stub)); 163 new NormalizingInputFilterCros(&stub));
166 164
167 { 165 {
168 InSequence s; 166 InSequence s;
169 167
170 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEvent(kUsbLeftOsKey, true))); 168 EXPECT_CALL(stub,
171 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEvent(kUsbOtherKey, true))); 169 InjectKeyEvent(EqualsKeyEventWithNumLock(kUsbLeftOsKey, true)));
172 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEvent(kUsbOtherKey, false))); 170 EXPECT_CALL(stub,
173 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEvent(kUsbLeftOsKey, false))); 171 InjectKeyEvent(EqualsKeyEventWithNumLock(kUsbOtherKey, true)));
172 EXPECT_CALL(stub,
173 InjectKeyEvent(EqualsKeyEventWithNumLock(kUsbOtherKey, false)));
174 EXPECT_CALL(
175 stub, InjectKeyEvent(EqualsKeyEventWithNumLock(kUsbLeftOsKey, false)));
174 } 176 }
175 177
176 // Hold the left OSKey while pressing & releasing the function key. 178 // Hold the left OSKey while pressing & releasing the function key.
177 processor->InjectKeyEvent(MakeKeyEvent(kUsbLeftOsKey, true)); 179 processor->InjectKeyEvent(MakeKeyEvent(kUsbLeftOsKey, true));
178 PressAndReleaseKey(processor.get(), kUsbOtherKey); 180 PressAndReleaseKey(processor.get(), kUsbOtherKey);
179 processor->InjectKeyEvent(MakeKeyEvent(kUsbLeftOsKey, false)); 181 processor->InjectKeyEvent(MakeKeyEvent(kUsbLeftOsKey, false));
180 } 182 }
181 183
182 // Test OSKey press followed by extended key press, then normal key press 184 // Test OSKey press followed by extended key press, then normal key press
183 // results in OSKey switching to modifying mode for the normal key. 185 // results in OSKey switching to modifying mode for the normal key.
184 TEST(NormalizingInputFilterCrosTest, ExtendedThenOtherKey) { 186 TEST(NormalizingInputFilterCrosTest, ExtendedThenOtherKey) {
185 MockInputStub stub; 187 MockInputStub stub;
186 scoped_ptr<protocol::InputFilter> processor( 188 scoped_ptr<protocol::InputFilter> processor(
187 new NormalizingInputFilterCros(&stub)); 189 new NormalizingInputFilterCros(&stub));
188 190
189 { 191 {
190 InSequence s; 192 InSequence s;
191 193
192 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEvent(kUsbExtendedKey, true))); 194 EXPECT_CALL(
193 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEvent(kUsbExtendedKey, false))); 195 stub, InjectKeyEvent(EqualsKeyEventWithNumLock(kUsbExtendedKey, true)));
194 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEvent(kUsbLeftOsKey, true))); 196 EXPECT_CALL(stub, InjectKeyEvent(
195 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEvent(kUsbOtherKey, true))); 197 EqualsKeyEventWithNumLock(kUsbExtendedKey, false)));
196 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEvent(kUsbOtherKey, false))); 198 EXPECT_CALL(stub,
197 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEvent(kUsbLeftOsKey, false))); 199 InjectKeyEvent(EqualsKeyEventWithNumLock(kUsbLeftOsKey, true)));
200 EXPECT_CALL(stub,
201 InjectKeyEvent(EqualsKeyEventWithNumLock(kUsbOtherKey, true)));
202 EXPECT_CALL(stub,
203 InjectKeyEvent(EqualsKeyEventWithNumLock(kUsbOtherKey, false)));
204 EXPECT_CALL(
205 stub, InjectKeyEvent(EqualsKeyEventWithNumLock(kUsbLeftOsKey, false)));
198 } 206 }
199 207
200 // Hold the left OSKey while pressing & releasing the function key. 208 // Hold the left OSKey while pressing & releasing the function key.
201 processor->InjectKeyEvent(MakeKeyEvent(kUsbLeftOsKey, true)); 209 processor->InjectKeyEvent(MakeKeyEvent(kUsbLeftOsKey, true));
202 PressAndReleaseKey(processor.get(), kUsbExtendedKey); 210 PressAndReleaseKey(processor.get(), kUsbExtendedKey);
203 PressAndReleaseKey(processor.get(), kUsbOtherKey); 211 PressAndReleaseKey(processor.get(), kUsbOtherKey);
204 processor->InjectKeyEvent(MakeKeyEvent(kUsbLeftOsKey, false)); 212 processor->InjectKeyEvent(MakeKeyEvent(kUsbLeftOsKey, false));
205 } 213 }
206 214
207 // Test OSKey press followed by mouse event puts the OSKey into modifying mode. 215 // Test OSKey press followed by mouse event puts the OSKey into modifying mode.
208 TEST(NormalizingInputFilterCrosTest, MouseEvent) { 216 TEST(NormalizingInputFilterCrosTest, MouseEvent) {
209 MockInputStub stub; 217 MockInputStub stub;
210 scoped_ptr<protocol::InputFilter> processor( 218 scoped_ptr<protocol::InputFilter> processor(
211 new NormalizingInputFilterCros(&stub)); 219 new NormalizingInputFilterCros(&stub));
212 220
213 { 221 {
214 InSequence s; 222 InSequence s;
215 223
216 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEvent(kUsbLeftOsKey, true))); 224 EXPECT_CALL(stub,
225 InjectKeyEvent(EqualsKeyEventWithNumLock(kUsbLeftOsKey, true)));
217 EXPECT_CALL(stub, InjectMouseEvent(EqualsMouseMoveEvent(0, 0))); 226 EXPECT_CALL(stub, InjectMouseEvent(EqualsMouseMoveEvent(0, 0)));
218 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEvent(kUsbLeftOsKey, false))); 227 EXPECT_CALL(
228 stub, InjectKeyEvent(EqualsKeyEventWithNumLock(kUsbLeftOsKey, false)));
219 } 229 }
220 230
221 // Hold the left OSKey while pressing & releasing the function key. 231 // Hold the left OSKey while pressing & releasing the function key.
222 processor->InjectKeyEvent(MakeKeyEvent(kUsbLeftOsKey, true)); 232 processor->InjectKeyEvent(MakeKeyEvent(kUsbLeftOsKey, true));
223 processor->InjectMouseEvent(MakeMouseMoveEvent(0, 0)); 233 processor->InjectMouseEvent(MakeMouseMoveEvent(0, 0));
224 processor->InjectKeyEvent(MakeKeyEvent(kUsbLeftOsKey, false)); 234 processor->InjectKeyEvent(MakeKeyEvent(kUsbLeftOsKey, false));
225 } 235 }
226 236
227 // Test left alt + right click is remapped to left alt + left click. 237 // Test left alt + right click is remapped to left alt + left click.
228 TEST(NormalizingInputFilterCrosTest, LeftAltClick) { 238 TEST(NormalizingInputFilterCrosTest, LeftAltClick) {
229 MockInputStub stub; 239 MockInputStub stub;
230 scoped_ptr<protocol::InputFilter> processor( 240 scoped_ptr<protocol::InputFilter> processor(
231 new NormalizingInputFilterCros(&stub)); 241 new NormalizingInputFilterCros(&stub));
232 242
233 { 243 {
234 InSequence s; 244 InSequence s;
235 245
236 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEvent(kUsbLeftAltKey, true))); 246 EXPECT_CALL(
237 EXPECT_CALL(stub, InjectMouseEvent( 247 stub, InjectKeyEvent(EqualsKeyEventWithNumLock(kUsbLeftAltKey, true)));
238 EqualsMouseButtonEvent(MouseEvent::BUTTON_LEFT, true))); 248 EXPECT_CALL(stub, InjectMouseEvent(EqualsMouseButtonEvent(
239 EXPECT_CALL(stub, InjectMouseEvent( 249 MouseEvent::BUTTON_LEFT, true)));
240 EqualsMouseButtonEvent(MouseEvent::BUTTON_LEFT, false))); 250 EXPECT_CALL(stub, InjectMouseEvent(EqualsMouseButtonEvent(
241 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEvent(kUsbLeftAltKey, false))); 251 MouseEvent::BUTTON_LEFT, false)));
252 EXPECT_CALL(
253 stub, InjectKeyEvent(EqualsKeyEventWithNumLock(kUsbLeftAltKey, false)));
242 } 254 }
243 255
244 // Hold the left alt key while left-clicking. ChromeOS will rewrite this as 256 // Hold the left alt key while left-clicking. ChromeOS will rewrite this as
245 // Alt+RightClick 257 // Alt+RightClick
246 processor->InjectKeyEvent(MakeKeyEvent(kUsbLeftAltKey, true)); 258 processor->InjectKeyEvent(MakeKeyEvent(kUsbLeftAltKey, true));
247 processor->InjectMouseEvent( 259 processor->InjectMouseEvent(
248 MakeMouseButtonEvent(MouseEvent::BUTTON_RIGHT, true)); 260 MakeMouseButtonEvent(MouseEvent::BUTTON_RIGHT, true));
249 processor->InjectMouseEvent( 261 processor->InjectMouseEvent(
250 MakeMouseButtonEvent(MouseEvent::BUTTON_RIGHT, false)); 262 MakeMouseButtonEvent(MouseEvent::BUTTON_RIGHT, false));
251 processor->InjectKeyEvent(MakeKeyEvent(kUsbLeftAltKey, false)); 263 processor->InjectKeyEvent(MakeKeyEvent(kUsbLeftAltKey, false));
252 } 264 }
253 265
254 // Test that right alt + right click is unchanged. 266 // Test that right alt + right click is unchanged.
255 TEST(NormalizingInputFilterCrosTest, RightAltClick) { 267 TEST(NormalizingInputFilterCrosTest, RightAltClick) {
256 MockInputStub stub; 268 MockInputStub stub;
257 scoped_ptr<protocol::InputFilter> processor( 269 scoped_ptr<protocol::InputFilter> processor(
258 new NormalizingInputFilterCros(&stub)); 270 new NormalizingInputFilterCros(&stub));
259 271
260 { 272 {
261 InSequence s; 273 InSequence s;
262 274
263 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEvent(kUsbRightAltKey, true))); 275 EXPECT_CALL(
264 EXPECT_CALL(stub, InjectMouseEvent( 276 stub, InjectKeyEvent(EqualsKeyEventWithNumLock(kUsbRightAltKey, true)));
265 EqualsMouseButtonEvent(MouseEvent::BUTTON_RIGHT, true))); 277 EXPECT_CALL(stub, InjectMouseEvent(EqualsMouseButtonEvent(
266 EXPECT_CALL(stub, InjectMouseEvent( 278 MouseEvent::BUTTON_RIGHT, true)));
267 EqualsMouseButtonEvent(MouseEvent::BUTTON_RIGHT, false))); 279 EXPECT_CALL(stub, InjectMouseEvent(EqualsMouseButtonEvent(
268 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEvent(kUsbRightAltKey, false))); 280 MouseEvent::BUTTON_RIGHT, false)));
281 EXPECT_CALL(stub, InjectKeyEvent(
282 EqualsKeyEventWithNumLock(kUsbRightAltKey, false)));
269 } 283 }
270 284
271 // Hold the right alt key while left-clicking. ChromeOS will rewrite this as 285 // Hold the right alt key while left-clicking. ChromeOS will rewrite this as
272 // Alt+RightClick 286 // Alt+RightClick
273 processor->InjectKeyEvent(MakeKeyEvent(kUsbRightAltKey, true)); 287 processor->InjectKeyEvent(MakeKeyEvent(kUsbRightAltKey, true));
274 processor->InjectMouseEvent( 288 processor->InjectMouseEvent(
275 MakeMouseButtonEvent(MouseEvent::BUTTON_RIGHT, true)); 289 MakeMouseButtonEvent(MouseEvent::BUTTON_RIGHT, true));
276 processor->InjectMouseEvent( 290 processor->InjectMouseEvent(
277 MakeMouseButtonEvent(MouseEvent::BUTTON_RIGHT, false)); 291 MakeMouseButtonEvent(MouseEvent::BUTTON_RIGHT, false));
278 processor->InjectKeyEvent(MakeKeyEvent(kUsbRightAltKey, false)); 292 processor->InjectKeyEvent(MakeKeyEvent(kUsbRightAltKey, false));
279 } 293 }
280 294
281 } // namespace remoting 295 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/client/key_event_mapper_unittest.cc ('k') | remoting/client/plugin/normalizing_input_filter_mac_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698