summaryrefslogtreecommitdiff
path: root/tests/basic/test_keypress.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/basic/test_keypress.cpp')
-rw-r--r--tests/basic/test_keypress.cpp96
1 files changed, 48 insertions, 48 deletions
diff --git a/tests/basic/test_keypress.cpp b/tests/basic/test_keypress.cpp
index 044fc29378..bb68ced557 100644
--- a/tests/basic/test_keypress.cpp
+++ b/tests/basic/test_keypress.cpp
@@ -24,7 +24,7 @@ class KeyPress : public TestFixture {};
24 24
25TEST_F(KeyPress, SendKeyboardIsNotCalledWhenNoKeyIsPressed) { 25TEST_F(KeyPress, SendKeyboardIsNotCalledWhenNoKeyIsPressed) {
26 TestDriver driver; 26 TestDriver driver;
27 EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); 27 EXPECT_NO_REPORT(driver);
28 keyboard_task(); 28 keyboard_task();
29} 29}
30 30
@@ -35,11 +35,11 @@ TEST_F(KeyPress, CorrectKeyIsReportedWhenPressed) {
35 set_keymap({key}); 35 set_keymap({key});
36 36
37 key.press(); 37 key.press();
38 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(key.report_code))); 38 EXPECT_REPORT(driver, (key.report_code));
39 keyboard_task(); 39 keyboard_task();
40 40
41 key.release(); 41 key.release();
42 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())); 42 EXPECT_EMPTY_REPORT(driver);
43 keyboard_task(); 43 keyboard_task();
44} 44}
45 45
@@ -50,7 +50,7 @@ TEST_F(KeyPress, ANonMappedKeyDoesNothing) {
50 set_keymap({key}); 50 set_keymap({key});
51 51
52 key.press(); 52 key.press();
53 EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); 53 EXPECT_NO_REPORT(driver);
54 keyboard_task(); 54 keyboard_task();
55 keyboard_task(); 55 keyboard_task();
56} 56}
@@ -66,19 +66,19 @@ TEST_F(KeyPress, CorrectKeysAreReportedWhenTwoKeysArePressed) {
66 key_c.press(); 66 key_c.press();
67 // Note that QMK only processes one key at a time 67 // Note that QMK only processes one key at a time
68 // See issue #1476 for more information 68 // See issue #1476 for more information
69 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(key_b.report_code))); 69 EXPECT_REPORT(driver, (key_b.report_code));
70 keyboard_task(); 70 keyboard_task();
71 71
72 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(key_b.report_code, key_c.report_code))); 72 EXPECT_REPORT(driver, (key_b.report_code, key_c.report_code));
73 keyboard_task(); 73 keyboard_task();
74 74
75 key_b.release(); 75 key_b.release();
76 key_c.release(); 76 key_c.release();
77 // Note that the first key released is the first one in the matrix order 77 // Note that the first key released is the first one in the matrix order
78 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(key_c.report_code))); 78 EXPECT_REPORT(driver, (key_c.report_code));
79 keyboard_task(); 79 keyboard_task();
80 80
81 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())); 81 EXPECT_EMPTY_REPORT(driver);
82 keyboard_task(); 82 keyboard_task();
83} 83}
84 84
@@ -94,17 +94,17 @@ TEST_F(KeyPress, LeftShiftIsReportedCorrectly) {
94 94
95 // Unfortunately modifiers are also processed in the wrong order 95 // Unfortunately modifiers are also processed in the wrong order
96 // See issue #1476 for more information 96 // See issue #1476 for more information
97 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(key_a.report_code))); 97 EXPECT_REPORT(driver, (key_a.report_code));
98 keyboard_task(); 98 keyboard_task();
99 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(key_a.report_code, key_lsft.report_code))); 99 EXPECT_REPORT(driver, (key_a.report_code, key_lsft.report_code));
100 keyboard_task(); 100 keyboard_task();
101 101
102 key_a.release(); 102 key_a.release();
103 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(key_lsft.report_code))); 103 EXPECT_REPORT(driver, (key_lsft.report_code));
104 keyboard_task(); 104 keyboard_task();
105 105
106 key_lsft.release(); 106 key_lsft.release();
107 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())); 107 EXPECT_EMPTY_REPORT(driver);
108 keyboard_task(); 108 keyboard_task();
109} 109}
110 110
@@ -120,19 +120,19 @@ TEST_F(KeyPress, PressLeftShiftAndControl) {
120 120
121 // Unfortunately modifiers are also processed in the wrong order 121 // Unfortunately modifiers are also processed in the wrong order
122 // See issue #1476 for more information 122 // See issue #1476 for more information
123 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(key_lsft.report_code))); 123 EXPECT_REPORT(driver, (key_lsft.report_code));
124 keyboard_task(); 124 keyboard_task();
125 125
126 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(key_lsft.report_code, key_lctrl.report_code))); 126 EXPECT_REPORT(driver, (key_lsft.report_code, key_lctrl.report_code));
127 keyboard_task(); 127 keyboard_task();
128 128
129 key_lsft.release(); 129 key_lsft.release();
130 key_lctrl.release(); 130 key_lctrl.release();
131 131
132 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(key_lctrl.report_code))); 132 EXPECT_REPORT(driver, (key_lctrl.report_code));
133 keyboard_task(); 133 keyboard_task();
134 134
135 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())); 135 EXPECT_EMPTY_REPORT(driver);
136 keyboard_task(); 136 keyboard_task();
137} 137}
138 138
@@ -147,19 +147,19 @@ TEST_F(KeyPress, LeftAndRightShiftCanBePressedAtTheSameTime) {
147 key_rsft.press(); 147 key_rsft.press();
148 // Unfortunately modifiers are also processed in the wrong order 148 // Unfortunately modifiers are also processed in the wrong order
149 // See issue #1476 for more information 149 // See issue #1476 for more information
150 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(key_lsft.report_code))); 150 EXPECT_REPORT(driver, (key_lsft.report_code));
151 keyboard_task(); 151 keyboard_task();
152 152
153 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(key_lsft.report_code, key_rsft.report_code))); 153 EXPECT_REPORT(driver, (key_lsft.report_code, key_rsft.report_code));
154 keyboard_task(); 154 keyboard_task();
155 155
156 key_lsft.release(); 156 key_lsft.release();
157 key_rsft.release(); 157 key_rsft.release();
158 158
159 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(key_rsft.report_code))); 159 EXPECT_REPORT(driver, (key_rsft.report_code));
160 keyboard_task(); 160 keyboard_task();
161 161
162 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())); 162 EXPECT_EMPTY_REPORT(driver);
163 keyboard_task(); 163 keyboard_task();
164} 164}
165 165
@@ -175,13 +175,13 @@ TEST_F(KeyPress, RightShiftLeftControlAndCharWithTheSameKey) {
175 // The underlying cause is that we use only one bit to represent the right hand 175 // The underlying cause is that we use only one bit to represent the right hand
176 // modifiers. 176 // modifiers.
177 combo_key.press(); 177 combo_key.press();
178 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_RIGHT_SHIFT, KC_RIGHT_CTRL))); 178 EXPECT_REPORT(driver, (KC_RIGHT_SHIFT, KC_RIGHT_CTRL));
179 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_RIGHT_SHIFT, KC_RIGHT_CTRL, KC_O))); 179 EXPECT_REPORT(driver, (KC_RIGHT_SHIFT, KC_RIGHT_CTRL, KC_O));
180 keyboard_task(); 180 keyboard_task();
181 181
182 combo_key.release(); 182 combo_key.release();
183 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_RIGHT_SHIFT, KC_RIGHT_CTRL))); 183 EXPECT_REPORT(driver, (KC_RIGHT_SHIFT, KC_RIGHT_CTRL));
184 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())); 184 EXPECT_EMPTY_REPORT(driver);
185 keyboard_task(); 185 keyboard_task();
186} 186}
187 187
@@ -194,24 +194,24 @@ TEST_F(KeyPress, PressPlusEqualReleaseBeforePress) {
194 set_keymap({key_plus, key_eql}); 194 set_keymap({key_plus, key_eql});
195 195
196 key_plus.press(); 196 key_plus.press();
197 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT))); 197 EXPECT_REPORT(driver, (KC_LEFT_SHIFT));
198 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT, KC_EQUAL))); 198 EXPECT_REPORT(driver, (KC_LEFT_SHIFT, KC_EQUAL));
199 run_one_scan_loop(); 199 run_one_scan_loop();
200 testing::Mock::VerifyAndClearExpectations(&driver); 200 testing::Mock::VerifyAndClearExpectations(&driver);
201 201
202 key_plus.release(); 202 key_plus.release();
203 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT))); 203 EXPECT_REPORT(driver, (KC_LEFT_SHIFT));
204 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())); 204 EXPECT_EMPTY_REPORT(driver);
205 run_one_scan_loop(); 205 run_one_scan_loop();
206 testing::Mock::VerifyAndClearExpectations(&driver); 206 testing::Mock::VerifyAndClearExpectations(&driver);
207 207
208 key_eql.press(); 208 key_eql.press();
209 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(key_eql.report_code))); 209 EXPECT_REPORT(driver, (key_eql.report_code));
210 run_one_scan_loop(); 210 run_one_scan_loop();
211 testing::Mock::VerifyAndClearExpectations(&driver); 211 testing::Mock::VerifyAndClearExpectations(&driver);
212 212
213 key_eql.release(); 213 key_eql.release();
214 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())); 214 EXPECT_EMPTY_REPORT(driver);
215 run_one_scan_loop(); 215 run_one_scan_loop();
216 testing::Mock::VerifyAndClearExpectations(&driver); 216 testing::Mock::VerifyAndClearExpectations(&driver);
217} 217}
@@ -225,25 +225,25 @@ TEST_F(KeyPress, PressPlusEqualDontReleaseBeforePress) {
225 set_keymap({key_plus, key_eql}); 225 set_keymap({key_plus, key_eql});
226 226
227 key_plus.press(); 227 key_plus.press();
228 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT))); 228 EXPECT_REPORT(driver, (KC_LEFT_SHIFT));
229 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT, KC_EQUAL))); 229 EXPECT_REPORT(driver, (KC_LEFT_SHIFT, KC_EQUAL));
230 run_one_scan_loop(); 230 run_one_scan_loop();
231 testing::Mock::VerifyAndClearExpectations(&driver); 231 testing::Mock::VerifyAndClearExpectations(&driver);
232 232
233 key_eql.press(); 233 key_eql.press();
234 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())); 234 EXPECT_EMPTY_REPORT(driver);
235 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_EQUAL))); 235 EXPECT_REPORT(driver, (KC_EQUAL));
236 run_one_scan_loop(); 236 run_one_scan_loop();
237 testing::Mock::VerifyAndClearExpectations(&driver); 237 testing::Mock::VerifyAndClearExpectations(&driver);
238 238
239 key_plus.release(); 239 key_plus.release();
240 // BUG: Should really still return KC_EQUAL, but this is fine too 240 // BUG: Should really still return KC_EQUAL, but this is fine too
241 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).Times(1); 241 EXPECT_EMPTY_REPORT(driver);
242 run_one_scan_loop(); 242 run_one_scan_loop();
243 testing::Mock::VerifyAndClearExpectations(&driver); 243 testing::Mock::VerifyAndClearExpectations(&driver);
244 244
245 key_eql.release(); 245 key_eql.release();
246 EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); 246 EXPECT_NO_REPORT(driver);
247 run_one_scan_loop(); 247 run_one_scan_loop();
248 testing::Mock::VerifyAndClearExpectations(&driver); 248 testing::Mock::VerifyAndClearExpectations(&driver);
249} 249}
@@ -257,24 +257,24 @@ TEST_F(KeyPress, PressEqualPlusReleaseBeforePress) {
257 set_keymap({key_plus, key_eql}); 257 set_keymap({key_plus, key_eql});
258 258
259 key_eql.press(); 259 key_eql.press();
260 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_EQUAL))); 260 EXPECT_REPORT(driver, (KC_EQUAL));
261 run_one_scan_loop(); 261 run_one_scan_loop();
262 testing::Mock::VerifyAndClearExpectations(&driver); 262 testing::Mock::VerifyAndClearExpectations(&driver);
263 263
264 key_eql.release(); 264 key_eql.release();
265 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())); 265 EXPECT_EMPTY_REPORT(driver);
266 run_one_scan_loop(); 266 run_one_scan_loop();
267 testing::Mock::VerifyAndClearExpectations(&driver); 267 testing::Mock::VerifyAndClearExpectations(&driver);
268 268
269 key_plus.press(); 269 key_plus.press();
270 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT))); 270 EXPECT_REPORT(driver, (KC_LEFT_SHIFT));
271 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT, KC_EQUAL))); 271 EXPECT_REPORT(driver, (KC_LEFT_SHIFT, KC_EQUAL));
272 run_one_scan_loop(); 272 run_one_scan_loop();
273 testing::Mock::VerifyAndClearExpectations(&driver); 273 testing::Mock::VerifyAndClearExpectations(&driver);
274 274
275 key_plus.release(); 275 key_plus.release();
276 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT))); 276 EXPECT_REPORT(driver, (KC_LEFT_SHIFT));
277 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())); 277 EXPECT_EMPTY_REPORT(driver);
278 run_one_scan_loop(); 278 run_one_scan_loop();
279 testing::Mock::VerifyAndClearExpectations(&driver); 279 testing::Mock::VerifyAndClearExpectations(&driver);
280} 280}
@@ -288,27 +288,27 @@ TEST_F(KeyPress, PressEqualPlusDontReleaseBeforePress) {
288 set_keymap({key_plus, key_eql}); 288 set_keymap({key_plus, key_eql});
289 289
290 key_eql.press(); 290 key_eql.press();
291 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_EQUAL))); 291 EXPECT_REPORT(driver, (KC_EQUAL));
292 run_one_scan_loop(); 292 run_one_scan_loop();
293 testing::Mock::VerifyAndClearExpectations(&driver); 293 testing::Mock::VerifyAndClearExpectations(&driver);
294 294
295 key_plus.press(); 295 key_plus.press();
296 // BUG: The sequence is a bit strange, but it works, the end result is that 296 // BUG: The sequence is a bit strange, but it works, the end result is that
297 // KC_PLUS is sent 297 // KC_PLUS is sent
298 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT, KC_EQUAL))); 298 EXPECT_REPORT(driver, (KC_LEFT_SHIFT, KC_EQUAL));
299 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT))); 299 EXPECT_REPORT(driver, (KC_LEFT_SHIFT));
300 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT, KC_EQUAL))); 300 EXPECT_REPORT(driver, (KC_LEFT_SHIFT, KC_EQUAL));
301 run_one_scan_loop(); 301 run_one_scan_loop();
302 testing::Mock::VerifyAndClearExpectations(&driver); 302 testing::Mock::VerifyAndClearExpectations(&driver);
303 303
304 key_eql.release(); 304 key_eql.release();
305 // I guess it's fine to still report shift here 305 // I guess it's fine to still report shift here
306 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT))); 306 EXPECT_REPORT(driver, (KC_LEFT_SHIFT));
307 run_one_scan_loop(); 307 run_one_scan_loop();
308 testing::Mock::VerifyAndClearExpectations(&driver); 308 testing::Mock::VerifyAndClearExpectations(&driver);
309 309
310 key_plus.release(); 310 key_plus.release();
311 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())); 311 EXPECT_EMPTY_REPORT(driver);
312 run_one_scan_loop(); 312 run_one_scan_loop();
313 testing::Mock::VerifyAndClearExpectations(&driver); 313 testing::Mock::VerifyAndClearExpectations(&driver);
314} 314}