OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/normalizing_input_filter_cros.h" | 5 #include "remoting/client/normalizing_input_filter_cros.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include "remoting/proto/event.pb.h" | 9 #include "remoting/proto/event.pb.h" |
10 #include "remoting/protocol/protocol_mock_objects.h" | 10 #include "remoting/protocol/protocol_mock_objects.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 // Test OSKey press/release. | 60 // Test OSKey press/release. |
61 TEST(NormalizingInputFilterCrosTest, PressReleaseOsKey) { | 61 TEST(NormalizingInputFilterCrosTest, PressReleaseOsKey) { |
62 MockInputStub stub; | 62 MockInputStub stub; |
63 std::unique_ptr<protocol::InputFilter> processor( | 63 std::unique_ptr<protocol::InputFilter> processor( |
64 new NormalizingInputFilterCros(&stub)); | 64 new NormalizingInputFilterCros(&stub)); |
65 | 65 |
66 { | 66 { |
67 InSequence s; | 67 InSequence s; |
68 | 68 |
69 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEventWithNumLock( | 69 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEventWithNumLock( |
70 ui::DomCode::OS_LEFT, true))); | 70 ui::DomCode::META_LEFT, true))); |
71 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEventWithNumLock( | 71 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEventWithNumLock( |
72 ui::DomCode::OS_LEFT, false))); | 72 ui::DomCode::META_LEFT, false))); |
73 | 73 |
74 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEventWithNumLock( | 74 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEventWithNumLock( |
75 ui::DomCode::OS_RIGHT, true))); | 75 ui::DomCode::META_RIGHT, true))); |
76 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEventWithNumLock( | 76 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEventWithNumLock( |
77 ui::DomCode::OS_RIGHT, false))); | 77 ui::DomCode::META_RIGHT, false))); |
78 } | 78 } |
79 | 79 |
80 // Inject press & release events for left & right OSKeys. | 80 // Inject press & release events for left & right OSKeys. |
81 PressAndReleaseKey(processor.get(), ui::DomCode::OS_LEFT); | 81 PressAndReleaseKey(processor.get(), ui::DomCode::META_LEFT); |
82 PressAndReleaseKey(processor.get(), ui::DomCode::OS_RIGHT); | 82 PressAndReleaseKey(processor.get(), ui::DomCode::META_RIGHT); |
83 } | 83 } |
84 | 84 |
85 // Test OSKey key repeat switches it to "modifying" mode. | 85 // Test OSKey key repeat switches it to "modifying" mode. |
86 TEST(NormalizingInputFilterCrosTest, OSKeyRepeats) { | 86 TEST(NormalizingInputFilterCrosTest, OSKeyRepeats) { |
87 MockInputStub stub; | 87 MockInputStub stub; |
88 std::unique_ptr<protocol::InputFilter> processor( | 88 std::unique_ptr<protocol::InputFilter> processor( |
89 new NormalizingInputFilterCros(&stub)); | 89 new NormalizingInputFilterCros(&stub)); |
90 | 90 |
91 { | 91 { |
92 InSequence s; | 92 InSequence s; |
93 | 93 |
94 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEventWithNumLock( | 94 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEventWithNumLock( |
95 ui::DomCode::OS_LEFT, true))); | 95 ui::DomCode::META_LEFT, true))); |
96 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEventWithNumLock( | 96 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEventWithNumLock( |
97 ui::DomCode::OS_LEFT, true))); | 97 ui::DomCode::META_LEFT, true))); |
98 EXPECT_CALL(stub,InjectKeyEvent(EqualsKeyEventWithNumLock( | 98 EXPECT_CALL(stub,InjectKeyEvent(EqualsKeyEventWithNumLock( |
99 ui::DomCode::OS_LEFT, true))); | 99 ui::DomCode::META_LEFT, true))); |
100 } | 100 } |
101 | 101 |
102 // Inject a press and repeats for the left OSKey, but don't release it, and | 102 // Inject a press and repeats for the left OSKey, but don't release it, and |
103 // verify that the repeats result in press events. | 103 // verify that the repeats result in press events. |
104 processor->InjectKeyEvent(MakeKeyEvent(ui::DomCode::OS_LEFT, true)); | 104 processor->InjectKeyEvent(MakeKeyEvent(ui::DomCode::META_LEFT, true)); |
105 processor->InjectKeyEvent(MakeKeyEvent(ui::DomCode::OS_LEFT, true)); | 105 processor->InjectKeyEvent(MakeKeyEvent(ui::DomCode::META_LEFT, true)); |
106 processor->InjectKeyEvent(MakeKeyEvent(ui::DomCode::OS_LEFT, true)); | 106 processor->InjectKeyEvent(MakeKeyEvent(ui::DomCode::META_LEFT, true)); |
107 } | 107 } |
108 | 108 |
109 // Test OSKey press followed by function key press and release results in | 109 // Test OSKey press followed by function key press and release results in |
110 // just the function key events. | 110 // just the function key events. |
111 TEST(NormalizingInputFilterCrosTest, FunctionKey) { | 111 TEST(NormalizingInputFilterCrosTest, FunctionKey) { |
112 MockInputStub stub; | 112 MockInputStub stub; |
113 std::unique_ptr<protocol::InputFilter> processor( | 113 std::unique_ptr<protocol::InputFilter> processor( |
114 new NormalizingInputFilterCros(&stub)); | 114 new NormalizingInputFilterCros(&stub)); |
115 | 115 |
116 { | 116 { |
117 InSequence s; | 117 InSequence s; |
118 | 118 |
119 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEventWithNumLock( | 119 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEventWithNumLock( |
120 ui::DomCode::F1, true))); | 120 ui::DomCode::F1, true))); |
121 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEventWithNumLock( | 121 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEventWithNumLock( |
122 ui::DomCode::F1, false))); | 122 ui::DomCode::F1, false))); |
123 } | 123 } |
124 | 124 |
125 // Hold the left OSKey while pressing & releasing the function key. | 125 // Hold the left OSKey while pressing & releasing the function key. |
126 processor->InjectKeyEvent(MakeKeyEvent(ui::DomCode::OS_LEFT, true)); | 126 processor->InjectKeyEvent(MakeKeyEvent(ui::DomCode::META_LEFT, true)); |
127 PressAndReleaseKey(processor.get(), ui::DomCode::F1); | 127 PressAndReleaseKey(processor.get(), ui::DomCode::F1); |
128 processor->InjectKeyEvent(MakeKeyEvent(ui::DomCode::OS_LEFT, false)); | 128 processor->InjectKeyEvent(MakeKeyEvent(ui::DomCode::META_LEFT, false)); |
129 } | 129 } |
130 | 130 |
131 // Test OSKey press followed by extended key press and release results in | 131 // Test OSKey press followed by extended key press and release results in |
132 // just the function key events. | 132 // just the function key events. |
133 TEST(NormalizingInputFilterCrosTest, ExtendedKey) { | 133 TEST(NormalizingInputFilterCrosTest, ExtendedKey) { |
134 MockInputStub stub; | 134 MockInputStub stub; |
135 std::unique_ptr<protocol::InputFilter> processor( | 135 std::unique_ptr<protocol::InputFilter> processor( |
136 new NormalizingInputFilterCros(&stub)); | 136 new NormalizingInputFilterCros(&stub)); |
137 | 137 |
138 { | 138 { |
139 InSequence s; | 139 InSequence s; |
140 | 140 |
141 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEventWithNumLock( | 141 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEventWithNumLock( |
142 ui::DomCode::INSERT, true))); | 142 ui::DomCode::INSERT, true))); |
143 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEventWithNumLock( | 143 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEventWithNumLock( |
144 ui::DomCode::INSERT, false))); | 144 ui::DomCode::INSERT, false))); |
145 } | 145 } |
146 | 146 |
147 // Hold the left OSKey while pressing & releasing the function key. | 147 // Hold the left OSKey while pressing & releasing the function key. |
148 processor->InjectKeyEvent(MakeKeyEvent(ui::DomCode::OS_LEFT, true)); | 148 processor->InjectKeyEvent(MakeKeyEvent(ui::DomCode::META_LEFT, true)); |
149 PressAndReleaseKey(processor.get(), ui::DomCode::INSERT); | 149 PressAndReleaseKey(processor.get(), ui::DomCode::INSERT); |
150 processor->InjectKeyEvent(MakeKeyEvent(ui::DomCode::OS_LEFT, false)); | 150 processor->InjectKeyEvent(MakeKeyEvent(ui::DomCode::META_LEFT, false)); |
151 } | 151 } |
152 | 152 |
153 // Test OSKey press followed by non-function, non-extended key press and release | 153 // Test OSKey press followed by non-function, non-extended key press and release |
154 // results in normal-looking sequence. We use the Tab key arbitrarily for this | 154 // results in normal-looking sequence. We use the Tab key arbitrarily for this |
155 // test. | 155 // test. |
156 TEST(NormalizingInputFilterCrosTest, OtherKey) { | 156 TEST(NormalizingInputFilterCrosTest, OtherKey) { |
157 MockInputStub stub; | 157 MockInputStub stub; |
158 std::unique_ptr<protocol::InputFilter> processor( | 158 std::unique_ptr<protocol::InputFilter> processor( |
159 new NormalizingInputFilterCros(&stub)); | 159 new NormalizingInputFilterCros(&stub)); |
160 | 160 |
161 { | 161 { |
162 InSequence s; | 162 InSequence s; |
163 | 163 |
164 EXPECT_CALL(stub,InjectKeyEvent(EqualsKeyEventWithNumLock( | 164 EXPECT_CALL(stub,InjectKeyEvent(EqualsKeyEventWithNumLock( |
165 ui::DomCode::OS_LEFT, true))); | 165 ui::DomCode::META_LEFT, true))); |
166 EXPECT_CALL(stub,InjectKeyEvent(EqualsKeyEventWithNumLock( | 166 EXPECT_CALL(stub,InjectKeyEvent(EqualsKeyEventWithNumLock( |
167 ui::DomCode::TAB, true))); | 167 ui::DomCode::TAB, true))); |
168 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEventWithNumLock( | 168 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEventWithNumLock( |
169 ui::DomCode::TAB, false))); | 169 ui::DomCode::TAB, false))); |
170 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEventWithNumLock( | 170 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEventWithNumLock( |
171 ui::DomCode::OS_LEFT, false))); | 171 ui::DomCode::META_LEFT, false))); |
172 } | 172 } |
173 | 173 |
174 // Hold the left OSKey while pressing & releasing the function key. | 174 // Hold the left OSKey while pressing & releasing the function key. |
175 processor->InjectKeyEvent(MakeKeyEvent(ui::DomCode::OS_LEFT, true)); | 175 processor->InjectKeyEvent(MakeKeyEvent(ui::DomCode::META_LEFT, true)); |
176 PressAndReleaseKey(processor.get(), ui::DomCode::TAB); | 176 PressAndReleaseKey(processor.get(), ui::DomCode::TAB); |
177 processor->InjectKeyEvent(MakeKeyEvent(ui::DomCode::OS_LEFT, false)); | 177 processor->InjectKeyEvent(MakeKeyEvent(ui::DomCode::META_LEFT, false)); |
178 } | 178 } |
179 | 179 |
180 // Test OSKey press followed by extended key press, then normal key press | 180 // Test OSKey press followed by extended key press, then normal key press |
181 // results in OSKey switching to modifying mode for the normal key. | 181 // results in OSKey switching to modifying mode for the normal key. |
182 TEST(NormalizingInputFilterCrosTest, ExtendedThenOtherKey) { | 182 TEST(NormalizingInputFilterCrosTest, ExtendedThenOtherKey) { |
183 MockInputStub stub; | 183 MockInputStub stub; |
184 std::unique_ptr<protocol::InputFilter> processor( | 184 std::unique_ptr<protocol::InputFilter> processor( |
185 new NormalizingInputFilterCros(&stub)); | 185 new NormalizingInputFilterCros(&stub)); |
186 | 186 |
187 { | 187 { |
188 InSequence s; | 188 InSequence s; |
189 | 189 |
190 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEventWithNumLock( | 190 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEventWithNumLock( |
191 ui::DomCode::INSERT, true))); | 191 ui::DomCode::INSERT, true))); |
192 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEventWithNumLock( | 192 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEventWithNumLock( |
193 ui::DomCode::INSERT, false))); | 193 ui::DomCode::INSERT, false))); |
194 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEventWithNumLock( | 194 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEventWithNumLock( |
195 ui::DomCode::OS_LEFT, true))); | 195 ui::DomCode::META_LEFT, true))); |
196 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEventWithNumLock( | 196 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEventWithNumLock( |
197 ui::DomCode::TAB, true))); | 197 ui::DomCode::TAB, true))); |
198 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEventWithNumLock( | 198 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEventWithNumLock( |
199 ui::DomCode::TAB, false))); | 199 ui::DomCode::TAB, false))); |
200 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEventWithNumLock( | 200 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEventWithNumLock( |
201 ui::DomCode::OS_LEFT, false))); | 201 ui::DomCode::META_LEFT, false))); |
202 } | 202 } |
203 | 203 |
204 // Hold the left OSKey while pressing & releasing the function key. | 204 // Hold the left OSKey while pressing & releasing the function key. |
205 processor->InjectKeyEvent(MakeKeyEvent(ui::DomCode::OS_LEFT, true)); | 205 processor->InjectKeyEvent(MakeKeyEvent(ui::DomCode::META_LEFT, true)); |
206 PressAndReleaseKey(processor.get(), ui::DomCode::INSERT); | 206 PressAndReleaseKey(processor.get(), ui::DomCode::INSERT); |
207 PressAndReleaseKey(processor.get(), ui::DomCode::TAB); | 207 PressAndReleaseKey(processor.get(), ui::DomCode::TAB); |
208 processor->InjectKeyEvent(MakeKeyEvent(ui::DomCode::OS_LEFT, false)); | 208 processor->InjectKeyEvent(MakeKeyEvent(ui::DomCode::META_LEFT, false)); |
209 } | 209 } |
210 | 210 |
211 // Test OSKey press followed by mouse event puts the OSKey into modifying mode. | 211 // Test OSKey press followed by mouse event puts the OSKey into modifying mode. |
212 TEST(NormalizingInputFilterCrosTest, MouseEvent) { | 212 TEST(NormalizingInputFilterCrosTest, MouseEvent) { |
213 MockInputStub stub; | 213 MockInputStub stub; |
214 std::unique_ptr<protocol::InputFilter> processor( | 214 std::unique_ptr<protocol::InputFilter> processor( |
215 new NormalizingInputFilterCros(&stub)); | 215 new NormalizingInputFilterCros(&stub)); |
216 | 216 |
217 { | 217 { |
218 InSequence s; | 218 InSequence s; |
219 | 219 |
220 EXPECT_CALL(stub,InjectKeyEvent(EqualsKeyEventWithNumLock( | 220 EXPECT_CALL(stub,InjectKeyEvent(EqualsKeyEventWithNumLock( |
221 ui::DomCode::OS_LEFT, true))); | 221 ui::DomCode::META_LEFT, true))); |
222 EXPECT_CALL(stub, InjectMouseEvent(EqualsMouseMoveEvent(0, 0))); | 222 EXPECT_CALL(stub, InjectMouseEvent(EqualsMouseMoveEvent(0, 0))); |
223 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEventWithNumLock( | 223 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEventWithNumLock( |
224 ui::DomCode::OS_LEFT, false))); | 224 ui::DomCode::META_LEFT, false))); |
225 } | 225 } |
226 | 226 |
227 // Hold the left OSKey while pressing & releasing the function key. | 227 // Hold the left OSKey while pressing & releasing the function key. |
228 processor->InjectKeyEvent(MakeKeyEvent(ui::DomCode::OS_LEFT, true)); | 228 processor->InjectKeyEvent(MakeKeyEvent(ui::DomCode::META_LEFT, true)); |
229 processor->InjectMouseEvent(MakeMouseMoveEvent(0, 0)); | 229 processor->InjectMouseEvent(MakeMouseMoveEvent(0, 0)); |
230 processor->InjectKeyEvent(MakeKeyEvent(ui::DomCode::OS_LEFT, false)); | 230 processor->InjectKeyEvent(MakeKeyEvent(ui::DomCode::META_LEFT, false)); |
231 } | 231 } |
232 | 232 |
233 // Test left alt + right click is remapped to left alt + left click. | 233 // Test left alt + right click is remapped to left alt + left click. |
234 TEST(NormalizingInputFilterCrosTest, LeftAltClick) { | 234 TEST(NormalizingInputFilterCrosTest, LeftAltClick) { |
235 MockInputStub stub; | 235 MockInputStub stub; |
236 std::unique_ptr<protocol::InputFilter> processor( | 236 std::unique_ptr<protocol::InputFilter> processor( |
237 new NormalizingInputFilterCros(&stub)); | 237 new NormalizingInputFilterCros(&stub)); |
238 | 238 |
239 { | 239 { |
240 InSequence s; | 240 InSequence s; |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 | 344 |
345 // Repeat the test for the right Alt key. | 345 // Repeat the test for the right Alt key. |
346 processor->InjectKeyEvent(MakeKeyEvent(ui::DomCode::ALT_RIGHT, true)); | 346 processor->InjectKeyEvent(MakeKeyEvent(ui::DomCode::ALT_RIGHT, true)); |
347 PressAndReleaseKey(processor.get(), ui::DomCode::PAGE_UP); | 347 PressAndReleaseKey(processor.get(), ui::DomCode::PAGE_UP); |
348 PressAndReleaseKey(processor.get(), ui::DomCode::PAGE_DOWN); | 348 PressAndReleaseKey(processor.get(), ui::DomCode::PAGE_DOWN); |
349 PressAndReleaseKey(processor.get(), ui::DomCode::DEL); | 349 PressAndReleaseKey(processor.get(), ui::DomCode::DEL); |
350 processor->InjectKeyEvent(MakeKeyEvent(ui::DomCode::ALT_RIGHT, false)); | 350 processor->InjectKeyEvent(MakeKeyEvent(ui::DomCode::ALT_RIGHT, false)); |
351 } | 351 } |
352 | 352 |
353 } // namespace remoting | 353 } // namespace remoting |
OLD | NEW |