diff options
| author | Pascal Getreuer <50221757+getreuer@users.noreply.github.com> | 2022-06-05 00:14:02 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-06-05 09:14:02 +0200 |
| commit | 95d20e6d8bb1ffaf3024af793daf789ee0b75727 (patch) | |
| tree | 95d0bb0c179d6f42a3dafa1952caf8a4299b67ac /tests | |
| parent | 787165718de4ba532417fb3e04b321c950279237 (diff) | |
Fix and add unit tests for Caps Word to work with Unicode Map, Auto Shift, Retro Shift. (#17284)
* Fix Caps Word and Unicode Map
* Tests for Caps Word + Auto Shift and Unicode Map.
* Fix formatting
* Add additional keyboard report expectation macros
This commit defines five test utilities, EXPECT_REPORT, EXPECT_UNICODE,
EXPECT_EMPTY_REPORT, EXPECT_ANY_REPORT and EXPECT_NO_REPORT for use with
TestDriver.
EXPECT_REPORT sets a gmock expectation that a given keyboard report will
be sent. For instance,
EXPECT_REPORT(driver, (KC_LSFT, KC_A));
is shorthand for
EXPECT_CALL(driver,
send_keyboard_mock(KeyboardReport(KC_LSFT, KC_A)));
EXPECT_UNICODE sets a gmock expectation that a given Unicode code point
will be sent using UC_LNX input mode. For instance for U+2013,
EXPECT_UNICODE(driver, 0x2013);
expects the sequence of keys:
"Ctrl+Shift+U, 2, 0, 1, 3, space".
EXPECT_EMPTY_REPORT sets a gmock expectation that a given keyboard
report will be sent. For instance
EXPECT_EMPTY_REPORT(driver);
expects a single report without keypresses or modifiers.
EXPECT_ANY_REPORT sets a gmock expectation that a arbitrary keyboard
report will be sent, without matching its contents. For instance
EXPECT_ANY_REPORT(driver).Times(1);
expects a single arbitrary keyboard report will be sent.
EXPECT_NO_REPORT sets a gmock expectation that no keyboard report will
be sent at all.
* Add tap_key() and tap_keys() to TestFixture.
This commit adds a `tap_key(key)` method to TestFixture that taps a
given KeymapKey, optionally with a specified delay between press and
release.
Similarly, the method `tap_keys(key_a, key_b, key_c)` taps a sequence of
KeymapKeys.
* Use EXPECT_REPORT, tap_keys, etc. in most tests.
This commit uses EXPECT_REPORT, EXPECT_UNICODE, EXPECT_EMPTY_REPORT,
EXPECT_NO_REPORT, tap_key() and tap_keys() test utilities from the
previous two commits in most tests. Particularly the EXPECT_REPORT
macro is frequently useful and makes a nice reduction in boilerplate
needed to express many tests.
Co-authored-by: David Kosorin <david@kosorin.net>
Diffstat (limited to 'tests')
26 files changed, 679 insertions, 295 deletions
diff --git a/tests/auto_shift/test_auto_shift.cpp b/tests/auto_shift/test_auto_shift.cpp index a19b5dfa82..a83f436c33 100644 --- a/tests/auto_shift/test_auto_shift.cpp +++ b/tests/auto_shift/test_auto_shift.cpp | |||
| @@ -34,14 +34,14 @@ TEST_F(AutoShift, key_release_before_timeout) { | |||
| 34 | set_keymap({regular_key}); | 34 | set_keymap({regular_key}); |
| 35 | 35 | ||
| 36 | /* Press regular key */ | 36 | /* Press regular key */ |
| 37 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 37 | EXPECT_NO_REPORT(driver); |
| 38 | regular_key.press(); | 38 | regular_key.press(); |
| 39 | run_one_scan_loop(); | 39 | run_one_scan_loop(); |
| 40 | testing::Mock::VerifyAndClearExpectations(&driver); | 40 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 41 | 41 | ||
| 42 | /* Release regular key */ | 42 | /* Release regular key */ |
| 43 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_A))); | 43 | EXPECT_REPORT(driver, (KC_A)); |
| 44 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())); | 44 | EXPECT_EMPTY_REPORT(driver); |
| 45 | regular_key.release(); | 45 | regular_key.release(); |
| 46 | run_one_scan_loop(); | 46 | run_one_scan_loop(); |
| 47 | testing::Mock::VerifyAndClearExpectations(&driver); | 47 | testing::Mock::VerifyAndClearExpectations(&driver); |
| @@ -55,16 +55,16 @@ TEST_F(AutoShift, key_release_after_timeout) { | |||
| 55 | set_keymap({regular_key}); | 55 | set_keymap({regular_key}); |
| 56 | 56 | ||
| 57 | /* Press regular key */ | 57 | /* Press regular key */ |
| 58 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 58 | EXPECT_NO_REPORT(driver); |
| 59 | regular_key.press(); | 59 | regular_key.press(); |
| 60 | idle_for(AUTO_SHIFT_TIMEOUT); | 60 | idle_for(AUTO_SHIFT_TIMEOUT); |
| 61 | testing::Mock::VerifyAndClearExpectations(&driver); | 61 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 62 | 62 | ||
| 63 | /* Release regular key */ | 63 | /* Release regular key */ |
| 64 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT, KC_A))); | 64 | EXPECT_REPORT(driver, (KC_LSFT, KC_A)); |
| 65 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT))); | 65 | EXPECT_REPORT(driver, (KC_LSFT)); |
| 66 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())); | 66 | EXPECT_EMPTY_REPORT(driver); |
| 67 | regular_key.release(); | 67 | regular_key.release(); |
| 68 | run_one_scan_loop(); | 68 | run_one_scan_loop(); |
| 69 | testing::Mock::VerifyAndClearExpectations(&driver); | 69 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 70 | } \ No newline at end of file | 70 | } |
diff --git a/tests/basic/test_action_layer.cpp b/tests/basic/test_action_layer.cpp index fe5c729f7c..fa339a3375 100644 --- a/tests/basic/test_action_layer.cpp +++ b/tests/basic/test_action_layer.cpp | |||
| @@ -131,12 +131,12 @@ TEST_F(ActionLayer, MomentaryLayerDoesNothing) { | |||
| 131 | set_keymap({layer_key}); | 131 | set_keymap({layer_key}); |
| 132 | 132 | ||
| 133 | /* Press and release MO, nothing should happen. */ | 133 | /* Press and release MO, nothing should happen. */ |
| 134 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 134 | EXPECT_NO_REPORT(driver); |
| 135 | layer_key.press(); | 135 | layer_key.press(); |
| 136 | run_one_scan_loop(); | 136 | run_one_scan_loop(); |
| 137 | testing::Mock::VerifyAndClearExpectations(&driver); | 137 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 138 | 138 | ||
| 139 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 139 | EXPECT_NO_REPORT(driver); |
| 140 | layer_key.release(); | 140 | layer_key.release(); |
| 141 | run_one_scan_loop(); | 141 | run_one_scan_loop(); |
| 142 | testing::Mock::VerifyAndClearExpectations(&driver); | 142 | testing::Mock::VerifyAndClearExpectations(&driver); |
| @@ -151,28 +151,28 @@ TEST_F(ActionLayer, MomentaryLayerWithKeypress) { | |||
| 151 | set_keymap({layer_key, regular_key, KeymapKey{1, 1, 0, KC_B}}); | 151 | set_keymap({layer_key, regular_key, KeymapKey{1, 1, 0, KC_B}}); |
| 152 | 152 | ||
| 153 | /* Press MO. */ | 153 | /* Press MO. */ |
| 154 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 154 | EXPECT_NO_REPORT(driver); |
| 155 | layer_key.press(); | 155 | layer_key.press(); |
| 156 | run_one_scan_loop(); | 156 | run_one_scan_loop(); |
| 157 | EXPECT_TRUE(layer_state_is(1)); | 157 | EXPECT_TRUE(layer_state_is(1)); |
| 158 | testing::Mock::VerifyAndClearExpectations(&driver); | 158 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 159 | 159 | ||
| 160 | /* Press key on layer 1 */ | 160 | /* Press key on layer 1 */ |
| 161 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_B))).Times(1); | 161 | EXPECT_REPORT(driver, (KC_B)).Times(1); |
| 162 | regular_key.press(); | 162 | regular_key.press(); |
| 163 | run_one_scan_loop(); | 163 | run_one_scan_loop(); |
| 164 | EXPECT_TRUE(layer_state_is(1)); | 164 | EXPECT_TRUE(layer_state_is(1)); |
| 165 | testing::Mock::VerifyAndClearExpectations(&driver); | 165 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 166 | 166 | ||
| 167 | /* Release key on layer 1 */ | 167 | /* Release key on layer 1 */ |
| 168 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).Times(1); | 168 | EXPECT_EMPTY_REPORT(driver); |
| 169 | regular_key.release(); | 169 | regular_key.release(); |
| 170 | run_one_scan_loop(); | 170 | run_one_scan_loop(); |
| 171 | EXPECT_TRUE(layer_state_is(1)); | 171 | EXPECT_TRUE(layer_state_is(1)); |
| 172 | testing::Mock::VerifyAndClearExpectations(&driver); | 172 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 173 | 173 | ||
| 174 | /* Release MO */ | 174 | /* Release MO */ |
| 175 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 175 | EXPECT_NO_REPORT(driver); |
| 176 | layer_key.release(); | 176 | layer_key.release(); |
| 177 | run_one_scan_loop(); | 177 | run_one_scan_loop(); |
| 178 | EXPECT_TRUE(layer_state_is(0)); | 178 | EXPECT_TRUE(layer_state_is(0)); |
| @@ -188,14 +188,14 @@ TEST_F(ActionLayer, ToggleLayerDoesNothing) { | |||
| 188 | set_keymap({layer_key}); | 188 | set_keymap({layer_key}); |
| 189 | 189 | ||
| 190 | /* Press TG. Layer state should not change as it's applied on release. */ | 190 | /* Press TG. Layer state should not change as it's applied on release. */ |
| 191 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 191 | EXPECT_NO_REPORT(driver); |
| 192 | layer_key.press(); | 192 | layer_key.press(); |
| 193 | run_one_scan_loop(); | 193 | run_one_scan_loop(); |
| 194 | EXPECT_TRUE(layer_state_is(1)); | 194 | EXPECT_TRUE(layer_state_is(1)); |
| 195 | testing::Mock::VerifyAndClearExpectations(&driver); | 195 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 196 | 196 | ||
| 197 | /* Release TG. */ | 197 | /* Release TG. */ |
| 198 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 198 | EXPECT_NO_REPORT(driver); |
| 199 | layer_key.release(); | 199 | layer_key.release(); |
| 200 | run_one_scan_loop(); | 200 | run_one_scan_loop(); |
| 201 | EXPECT_TRUE(layer_state_is(1)); | 201 | EXPECT_TRUE(layer_state_is(1)); |
| @@ -212,26 +212,26 @@ TEST_F(ActionLayer, ToggleLayerUpAndDown) { | |||
| 212 | set_keymap({toggle_layer_1_on_layer_0, toggle_layer_0_on_layer_1}); | 212 | set_keymap({toggle_layer_1_on_layer_0, toggle_layer_0_on_layer_1}); |
| 213 | 213 | ||
| 214 | /* Toggle Layer 1. */ | 214 | /* Toggle Layer 1. */ |
| 215 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 215 | EXPECT_NO_REPORT(driver); |
| 216 | toggle_layer_1_on_layer_0.press(); | 216 | toggle_layer_1_on_layer_0.press(); |
| 217 | run_one_scan_loop(); | 217 | run_one_scan_loop(); |
| 218 | EXPECT_TRUE(layer_state_is(1)); | 218 | EXPECT_TRUE(layer_state_is(1)); |
| 219 | testing::Mock::VerifyAndClearExpectations(&driver); | 219 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 220 | 220 | ||
| 221 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 221 | EXPECT_NO_REPORT(driver); |
| 222 | toggle_layer_1_on_layer_0.release(); | 222 | toggle_layer_1_on_layer_0.release(); |
| 223 | run_one_scan_loop(); | 223 | run_one_scan_loop(); |
| 224 | EXPECT_TRUE(layer_state_is(1)); | 224 | EXPECT_TRUE(layer_state_is(1)); |
| 225 | testing::Mock::VerifyAndClearExpectations(&driver); | 225 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 226 | 226 | ||
| 227 | /* Toggle Layer 0. */ | 227 | /* Toggle Layer 0. */ |
| 228 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 228 | EXPECT_NO_REPORT(driver); |
| 229 | toggle_layer_0_on_layer_1.press(); | 229 | toggle_layer_0_on_layer_1.press(); |
| 230 | run_one_scan_loop(); | 230 | run_one_scan_loop(); |
| 231 | EXPECT_TRUE(layer_state_is(0)); | 231 | EXPECT_TRUE(layer_state_is(0)); |
| 232 | testing::Mock::VerifyAndClearExpectations(&driver); | 232 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 233 | 233 | ||
| 234 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 234 | EXPECT_NO_REPORT(driver); |
| 235 | toggle_layer_0_on_layer_1.release(); | 235 | toggle_layer_0_on_layer_1.release(); |
| 236 | run_one_scan_loop(); | 236 | run_one_scan_loop(); |
| 237 | EXPECT_TRUE(layer_state_is(0)); | 237 | EXPECT_TRUE(layer_state_is(0)); |
| @@ -247,13 +247,13 @@ TEST_F(ActionLayer, LayerTapToggleDoesNothing) { | |||
| 247 | set_keymap({layer_key}); | 247 | set_keymap({layer_key}); |
| 248 | 248 | ||
| 249 | /* Press and release TT. */ | 249 | /* Press and release TT. */ |
| 250 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 250 | EXPECT_NO_REPORT(driver); |
| 251 | layer_key.press(); | 251 | layer_key.press(); |
| 252 | run_one_scan_loop(); | 252 | run_one_scan_loop(); |
| 253 | EXPECT_TRUE(layer_state_is(1)); | 253 | EXPECT_TRUE(layer_state_is(1)); |
| 254 | testing::Mock::VerifyAndClearExpectations(&driver); | 254 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 255 | 255 | ||
| 256 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 256 | EXPECT_NO_REPORT(driver); |
| 257 | layer_key.release(); | 257 | layer_key.release(); |
| 258 | run_one_scan_loop(); | 258 | run_one_scan_loop(); |
| 259 | EXPECT_TRUE(layer_state_is(0)); | 259 | EXPECT_TRUE(layer_state_is(0)); |
| @@ -271,25 +271,25 @@ TEST_F(ActionLayer, LayerTapToggleWithKeypress) { | |||
| 271 | set_keymap({layer_key, regular_key, KeymapKey{1, 1, 0, KC_B}}); | 271 | set_keymap({layer_key, regular_key, KeymapKey{1, 1, 0, KC_B}}); |
| 272 | 272 | ||
| 273 | /* Press TT. */ | 273 | /* Press TT. */ |
| 274 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).Times(0); | 274 | EXPECT_NO_REPORT(driver); |
| 275 | layer_key.press(); | 275 | layer_key.press(); |
| 276 | run_one_scan_loop(); | 276 | run_one_scan_loop(); |
| 277 | EXPECT_TRUE(layer_state_is(1)); | 277 | EXPECT_TRUE(layer_state_is(1)); |
| 278 | testing::Mock::VerifyAndClearExpectations(&driver); | 278 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 279 | 279 | ||
| 280 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_B))).Times(1); | 280 | EXPECT_REPORT(driver, (KC_B)).Times(1); |
| 281 | regular_key.press(); | 281 | regular_key.press(); |
| 282 | run_one_scan_loop(); | 282 | run_one_scan_loop(); |
| 283 | EXPECT_TRUE(layer_state_is(1)); | 283 | EXPECT_TRUE(layer_state_is(1)); |
| 284 | testing::Mock::VerifyAndClearExpectations(&driver); | 284 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 285 | 285 | ||
| 286 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).Times(1); | 286 | EXPECT_EMPTY_REPORT(driver); |
| 287 | regular_key.release(); | 287 | regular_key.release(); |
| 288 | run_one_scan_loop(); | 288 | run_one_scan_loop(); |
| 289 | EXPECT_TRUE(layer_state_is(1)); | 289 | EXPECT_TRUE(layer_state_is(1)); |
| 290 | testing::Mock::VerifyAndClearExpectations(&driver); | 290 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 291 | 291 | ||
| 292 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 292 | EXPECT_NO_REPORT(driver); |
| 293 | layer_key.release(); | 293 | layer_key.release(); |
| 294 | run_one_scan_loop(); | 294 | run_one_scan_loop(); |
| 295 | EXPECT_TRUE(layer_state_is(0)); | 295 | EXPECT_TRUE(layer_state_is(0)); |
| @@ -307,7 +307,7 @@ TEST_F(ActionLayer, LayerTapToggleWithToggleWithKeypress) { | |||
| 307 | set_keymap({layer_key, regular_key, KeymapKey{1, 1, 0, KC_B}}); | 307 | set_keymap({layer_key, regular_key, KeymapKey{1, 1, 0, KC_B}}); |
| 308 | 308 | ||
| 309 | /* Tap TT five times . */ | 309 | /* Tap TT five times . */ |
| 310 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 310 | EXPECT_NO_REPORT(driver); |
| 311 | 311 | ||
| 312 | layer_key.press(); | 312 | layer_key.press(); |
| 313 | run_one_scan_loop(); | 313 | run_one_scan_loop(); |
| @@ -346,13 +346,13 @@ TEST_F(ActionLayer, LayerTapToggleWithToggleWithKeypress) { | |||
| 346 | 346 | ||
| 347 | testing::Mock::VerifyAndClearExpectations(&driver); | 347 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 348 | 348 | ||
| 349 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_B))).Times(1); | 349 | EXPECT_REPORT(driver, (KC_B)).Times(1); |
| 350 | regular_key.press(); | 350 | regular_key.press(); |
| 351 | run_one_scan_loop(); | 351 | run_one_scan_loop(); |
| 352 | EXPECT_TRUE(layer_state_is(1)); | 352 | EXPECT_TRUE(layer_state_is(1)); |
| 353 | testing::Mock::VerifyAndClearExpectations(&driver); | 353 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 354 | 354 | ||
| 355 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).Times(1); | 355 | EXPECT_EMPTY_REPORT(driver); |
| 356 | regular_key.release(); | 356 | regular_key.release(); |
| 357 | run_one_scan_loop(); | 357 | run_one_scan_loop(); |
| 358 | EXPECT_TRUE(layer_state_is(1)); | 358 | EXPECT_TRUE(layer_state_is(1)); |
| @@ -370,7 +370,7 @@ TEST_F(ActionLayer, LayerTapReleasedBeforeKeypressReleaseWithModifiers) { | |||
| 370 | set_keymap({layer_0_key_0, layer_1_key_1}); | 370 | set_keymap({layer_0_key_0, layer_1_key_1}); |
| 371 | 371 | ||
| 372 | /* Press layer tap and wait for tapping term to switch to layer 1 */ | 372 | /* Press layer tap and wait for tapping term to switch to layer 1 */ |
| 373 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).Times(0); | 373 | EXPECT_NO_REPORT(driver); |
| 374 | layer_0_key_0.press(); | 374 | layer_0_key_0.press(); |
| 375 | idle_for(TAPPING_TERM); | 375 | idle_for(TAPPING_TERM); |
| 376 | EXPECT_TRUE(layer_state_is(0)); | 376 | EXPECT_TRUE(layer_state_is(0)); |
| @@ -378,23 +378,23 @@ TEST_F(ActionLayer, LayerTapReleasedBeforeKeypressReleaseWithModifiers) { | |||
| 378 | 378 | ||
| 379 | /* Press key with layer 1 mapping, result basically expected | 379 | /* Press key with layer 1 mapping, result basically expected |
| 380 | * altough more reports are send then necessary. */ | 380 | * altough more reports are send then necessary. */ |
| 381 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_RALT))).Times(1); | 381 | EXPECT_REPORT(driver, (KC_RALT)).Times(1); |
| 382 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_RALT, KC_9))).Times(1); | 382 | EXPECT_REPORT(driver, (KC_RALT, KC_9)).Times(1); |
| 383 | layer_1_key_1.press(); | 383 | layer_1_key_1.press(); |
| 384 | run_one_scan_loop(); | 384 | run_one_scan_loop(); |
| 385 | EXPECT_TRUE(layer_state_is(1)); | 385 | EXPECT_TRUE(layer_state_is(1)); |
| 386 | testing::Mock::VerifyAndClearExpectations(&driver); | 386 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 387 | 387 | ||
| 388 | /* Release layer tap key, no report is send because key is still held. */ | 388 | /* Release layer tap key, no report is send because key is still held. */ |
| 389 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 389 | EXPECT_NO_REPORT(driver); |
| 390 | layer_0_key_0.release(); | 390 | layer_0_key_0.release(); |
| 391 | run_one_scan_loop(); | 391 | run_one_scan_loop(); |
| 392 | EXPECT_TRUE(layer_state_is(0)); | 392 | EXPECT_TRUE(layer_state_is(0)); |
| 393 | testing::Mock::VerifyAndClearExpectations(&driver); | 393 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 394 | 394 | ||
| 395 | /* Unregister keycode and modifier. */ | 395 | /* Unregister keycode and modifier. */ |
| 396 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_RALT))).Times(1); | 396 | EXPECT_REPORT(driver, (KC_RALT)).Times(1); |
| 397 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).Times(1); | 397 | EXPECT_EMPTY_REPORT(driver); |
| 398 | layer_1_key_1.release(); | 398 | layer_1_key_1.release(); |
| 399 | run_one_scan_loop(); | 399 | run_one_scan_loop(); |
| 400 | EXPECT_TRUE(layer_state_is(0)); | 400 | EXPECT_TRUE(layer_state_is(0)); |
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 | ||
| 25 | TEST_F(KeyPress, SendKeyboardIsNotCalledWhenNoKeyIsPressed) { | 25 | TEST_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 | } |
diff --git a/tests/basic/test_one_shot_keys.cpp b/tests/basic/test_one_shot_keys.cpp index 43fc3e1ba3..bb14221140 100644 --- a/tests/basic/test_one_shot_keys.cpp +++ b/tests/basic/test_one_shot_keys.cpp | |||
| @@ -31,7 +31,7 @@ TEST_F(OneShot, OSMWithoutAdditionalKeypressDoesNothing) { | |||
| 31 | set_keymap({osm_key}); | 31 | set_keymap({osm_key}); |
| 32 | 32 | ||
| 33 | /* Press and release OSM key*/ | 33 | /* Press and release OSM key*/ |
| 34 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 34 | EXPECT_NO_REPORT(driver); |
| 35 | osm_key.press(); | 35 | osm_key.press(); |
| 36 | run_one_scan_loop(); | 36 | run_one_scan_loop(); |
| 37 | osm_key.release(); | 37 | osm_key.release(); |
| @@ -39,7 +39,7 @@ TEST_F(OneShot, OSMWithoutAdditionalKeypressDoesNothing) { | |||
| 39 | testing::Mock::VerifyAndClearExpectations(&driver); | 39 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 40 | 40 | ||
| 41 | /* OSM are added when an actual report is send */ | 41 | /* OSM are added when an actual report is send */ |
| 42 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(osm_key.report_code))); | 42 | EXPECT_REPORT(driver, (osm_key.report_code)); |
| 43 | send_keyboard_report(); | 43 | send_keyboard_report(); |
| 44 | testing::Mock::VerifyAndClearExpectations(&driver); | 44 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 45 | 45 | ||
| @@ -57,7 +57,7 @@ TEST_P(OneShotParametrizedTestFixture, OSMExpiredDoesNothing) { | |||
| 57 | set_keymap({osm_key, regular_key}); | 57 | set_keymap({osm_key, regular_key}); |
| 58 | 58 | ||
| 59 | /* Press and release OSM */ | 59 | /* Press and release OSM */ |
| 60 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 60 | EXPECT_NO_REPORT(driver); |
| 61 | osm_key.press(); | 61 | osm_key.press(); |
| 62 | run_one_scan_loop(); | 62 | run_one_scan_loop(); |
| 63 | osm_key.release(); | 63 | osm_key.release(); |
| @@ -65,13 +65,13 @@ TEST_P(OneShotParametrizedTestFixture, OSMExpiredDoesNothing) { | |||
| 65 | testing::Mock::VerifyAndClearExpectations(&driver); | 65 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 66 | 66 | ||
| 67 | /* Press regular key */ | 67 | /* Press regular key */ |
| 68 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(regular_key.report_code))).Times(1); | 68 | EXPECT_REPORT(driver, (regular_key.report_code)).Times(1); |
| 69 | regular_key.press(); | 69 | regular_key.press(); |
| 70 | run_one_scan_loop(); | 70 | run_one_scan_loop(); |
| 71 | testing::Mock::VerifyAndClearExpectations(&driver); | 71 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 72 | 72 | ||
| 73 | /* Release regular key */ | 73 | /* Release regular key */ |
| 74 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())); | 74 | EXPECT_EMPTY_REPORT(driver); |
| 75 | regular_key.release(); | 75 | regular_key.release(); |
| 76 | run_one_scan_loop(); | 76 | run_one_scan_loop(); |
| 77 | testing::Mock::VerifyAndClearExpectations(&driver); | 77 | testing::Mock::VerifyAndClearExpectations(&driver); |
| @@ -87,7 +87,7 @@ TEST_P(OneShotParametrizedTestFixture, OSMWithAdditionalKeypress) { | |||
| 87 | set_keymap({osm_key, regular_key}); | 87 | set_keymap({osm_key, regular_key}); |
| 88 | 88 | ||
| 89 | /* Press and release OSM */ | 89 | /* Press and release OSM */ |
| 90 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 90 | EXPECT_NO_REPORT(driver); |
| 91 | osm_key.press(); | 91 | osm_key.press(); |
| 92 | run_one_scan_loop(); | 92 | run_one_scan_loop(); |
| 93 | osm_key.release(); | 93 | osm_key.release(); |
| @@ -95,13 +95,13 @@ TEST_P(OneShotParametrizedTestFixture, OSMWithAdditionalKeypress) { | |||
| 95 | testing::Mock::VerifyAndClearExpectations(&driver); | 95 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 96 | 96 | ||
| 97 | /* Press regular key */ | 97 | /* Press regular key */ |
| 98 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(osm_key.report_code, regular_key.report_code))).Times(1); | 98 | EXPECT_REPORT(driver, (osm_key.report_code, regular_key.report_code)).Times(1); |
| 99 | regular_key.press(); | 99 | regular_key.press(); |
| 100 | run_one_scan_loop(); | 100 | run_one_scan_loop(); |
| 101 | testing::Mock::VerifyAndClearExpectations(&driver); | 101 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 102 | 102 | ||
| 103 | /* Release regular key */ | 103 | /* Release regular key */ |
| 104 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())); | 104 | EXPECT_EMPTY_REPORT(driver); |
| 105 | regular_key.release(); | 105 | regular_key.release(); |
| 106 | run_one_scan_loop(); | 106 | run_one_scan_loop(); |
| 107 | testing::Mock::VerifyAndClearExpectations(&driver); | 107 | testing::Mock::VerifyAndClearExpectations(&driver); |
| @@ -117,26 +117,26 @@ TEST_P(OneShotParametrizedTestFixture, OSMAsRegularModifierWithAdditionalKeypres | |||
| 117 | set_keymap({osm_key, regular_key}); | 117 | set_keymap({osm_key, regular_key}); |
| 118 | 118 | ||
| 119 | /* Press OSM */ | 119 | /* Press OSM */ |
| 120 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 120 | EXPECT_NO_REPORT(driver); |
| 121 | osm_key.press(); | 121 | osm_key.press(); |
| 122 | run_one_scan_loop(); | 122 | run_one_scan_loop(); |
| 123 | testing::Mock::VerifyAndClearExpectations(&driver); | 123 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 124 | 124 | ||
| 125 | /* Press regular key */ | 125 | /* Press regular key */ |
| 126 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 126 | EXPECT_NO_REPORT(driver); |
| 127 | regular_key.press(); | 127 | regular_key.press(); |
| 128 | run_one_scan_loop(); | 128 | run_one_scan_loop(); |
| 129 | testing::Mock::VerifyAndClearExpectations(&driver); | 129 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 130 | 130 | ||
| 131 | /* Release regular key */ | 131 | /* Release regular key */ |
| 132 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 132 | EXPECT_NO_REPORT(driver); |
| 133 | regular_key.release(); | 133 | regular_key.release(); |
| 134 | run_one_scan_loop(); | 134 | run_one_scan_loop(); |
| 135 | testing::Mock::VerifyAndClearExpectations(&driver); | 135 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 136 | 136 | ||
| 137 | /* Release OSM */ | 137 | /* Release OSM */ |
| 138 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(regular_key.report_code, osm_key.report_code))).Times(1); | 138 | EXPECT_REPORT(driver, (regular_key.report_code, osm_key.report_code)).Times(1); |
| 139 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).Times(1); | 139 | EXPECT_EMPTY_REPORT(driver); |
| 140 | osm_key.release(); | 140 | osm_key.release(); |
| 141 | run_one_scan_loop(); | 141 | run_one_scan_loop(); |
| 142 | testing::Mock::VerifyAndClearExpectations(&driver); | 142 | testing::Mock::VerifyAndClearExpectations(&driver); |
| @@ -169,26 +169,26 @@ TEST_F(OneShot, OSLWithAdditionalKeypress) { | |||
| 169 | set_keymap({osl_key, regular_key}); | 169 | set_keymap({osl_key, regular_key}); |
| 170 | 170 | ||
| 171 | /* Press OSL key */ | 171 | /* Press OSL key */ |
| 172 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 172 | EXPECT_NO_REPORT(driver); |
| 173 | osl_key.press(); | 173 | osl_key.press(); |
| 174 | run_one_scan_loop(); | 174 | run_one_scan_loop(); |
| 175 | testing::Mock::VerifyAndClearExpectations(&driver); | 175 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 176 | 176 | ||
| 177 | /* Release OSL key */ | 177 | /* Release OSL key */ |
| 178 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 178 | EXPECT_NO_REPORT(driver); |
| 179 | osl_key.release(); | 179 | osl_key.release(); |
| 180 | run_one_scan_loop(); | 180 | run_one_scan_loop(); |
| 181 | testing::Mock::VerifyAndClearExpectations(&driver); | 181 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 182 | 182 | ||
| 183 | /* Press regular key */ | 183 | /* Press regular key */ |
| 184 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(regular_key.report_code))).Times(1); | 184 | EXPECT_REPORT(driver, (regular_key.report_code)).Times(1); |
| 185 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())); | 185 | EXPECT_EMPTY_REPORT(driver); |
| 186 | regular_key.press(); | 186 | regular_key.press(); |
| 187 | run_one_scan_loop(); | 187 | run_one_scan_loop(); |
| 188 | testing::Mock::VerifyAndClearExpectations(&driver); | 188 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 189 | 189 | ||
| 190 | /* Release regular key */ | 190 | /* Release regular key */ |
| 191 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 191 | EXPECT_NO_REPORT(driver); |
| 192 | regular_key.release(); | 192 | regular_key.release(); |
| 193 | run_one_scan_loop(); | 193 | run_one_scan_loop(); |
| 194 | testing::Mock::VerifyAndClearExpectations(&driver); | 194 | testing::Mock::VerifyAndClearExpectations(&driver); |
diff --git a/tests/basic/test_tapping.cpp b/tests/basic/test_tapping.cpp index e4a7e4a9f3..6ff9cfe22b 100644 --- a/tests/basic/test_tapping.cpp +++ b/tests/basic/test_tapping.cpp | |||
| @@ -34,15 +34,15 @@ TEST_F(Tapping, TapA_SHFT_T_KeyReportsKey) { | |||
| 34 | 34 | ||
| 35 | // Tapping keys does nothing on press | 35 | // Tapping keys does nothing on press |
| 36 | key_shift_hold_p_tap.press(); | 36 | key_shift_hold_p_tap.press(); |
| 37 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 37 | EXPECT_NO_REPORT(driver); |
| 38 | run_one_scan_loop(); | 38 | run_one_scan_loop(); |
| 39 | 39 | ||
| 40 | // First we get the key press | 40 | // First we get the key press |
| 41 | key_shift_hold_p_tap.release(); | 41 | key_shift_hold_p_tap.release(); |
| 42 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_P))); | 42 | EXPECT_REPORT(driver, (KC_P)); |
| 43 | 43 | ||
| 44 | // Then the release | 44 | // Then the release |
| 45 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())); | 45 | EXPECT_EMPTY_REPORT(driver); |
| 46 | run_one_scan_loop(); | 46 | run_one_scan_loop(); |
| 47 | } | 47 | } |
| 48 | 48 | ||
| @@ -56,13 +56,13 @@ TEST_F(Tapping, HoldA_SHFT_T_KeyReportsShift) { | |||
| 56 | mod_tap_hold_key.press(); | 56 | mod_tap_hold_key.press(); |
| 57 | 57 | ||
| 58 | // Tapping keys does nothing on press | 58 | // Tapping keys does nothing on press |
| 59 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 59 | EXPECT_NO_REPORT(driver); |
| 60 | idle_for(TAPPING_TERM); | 60 | idle_for(TAPPING_TERM); |
| 61 | 61 | ||
| 62 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT))); | 62 | EXPECT_REPORT(driver, (KC_LSFT)); |
| 63 | run_one_scan_loop(); | 63 | run_one_scan_loop(); |
| 64 | 64 | ||
| 65 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())); | 65 | EXPECT_EMPTY_REPORT(driver); |
| 66 | mod_tap_hold_key.release(); | 66 | mod_tap_hold_key.release(); |
| 67 | run_one_scan_loop(); | 67 | run_one_scan_loop(); |
| 68 | } | 68 | } |
| @@ -77,36 +77,36 @@ TEST_F(Tapping, ANewTapWithinTappingTermIsBuggy) { | |||
| 77 | 77 | ||
| 78 | // Tapping keys does nothing on press | 78 | // Tapping keys does nothing on press |
| 79 | key_shift_hold_p_tap.press(); | 79 | key_shift_hold_p_tap.press(); |
| 80 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 80 | EXPECT_NO_REPORT(driver); |
| 81 | run_one_scan_loop(); | 81 | run_one_scan_loop(); |
| 82 | key_shift_hold_p_tap.release(); | 82 | key_shift_hold_p_tap.release(); |
| 83 | 83 | ||
| 84 | // First we get the key press | 84 | // First we get the key press |
| 85 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_P))); | 85 | EXPECT_REPORT(driver, (KC_P)); |
| 86 | // Then the release | 86 | // Then the release |
| 87 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())); | 87 | EXPECT_EMPTY_REPORT(driver); |
| 88 | run_one_scan_loop(); | 88 | run_one_scan_loop(); |
| 89 | 89 | ||
| 90 | // This sends KC_P, even if it should do nothing | 90 | // This sends KC_P, even if it should do nothing |
| 91 | key_shift_hold_p_tap.press(); | 91 | key_shift_hold_p_tap.press(); |
| 92 | // This test should not succed if everything works correctly | 92 | // This test should not succed if everything works correctly |
| 93 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_P))); | 93 | EXPECT_REPORT(driver, (KC_P)); |
| 94 | run_one_scan_loop(); | 94 | run_one_scan_loop(); |
| 95 | 95 | ||
| 96 | key_shift_hold_p_tap.release(); | 96 | key_shift_hold_p_tap.release(); |
| 97 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())); | 97 | EXPECT_EMPTY_REPORT(driver); |
| 98 | idle_for(TAPPING_TERM + 1); | 98 | idle_for(TAPPING_TERM + 1); |
| 99 | 99 | ||
| 100 | // On the other hand, nothing is sent if we are outside the tapping term | 100 | // On the other hand, nothing is sent if we are outside the tapping term |
| 101 | key_shift_hold_p_tap.press(); | 101 | key_shift_hold_p_tap.press(); |
| 102 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 102 | EXPECT_NO_REPORT(driver); |
| 103 | run_one_scan_loop(); | 103 | run_one_scan_loop(); |
| 104 | key_shift_hold_p_tap.release(); | 104 | key_shift_hold_p_tap.release(); |
| 105 | 105 | ||
| 106 | // First we get the key press | 106 | // First we get the key press |
| 107 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_P))); | 107 | EXPECT_REPORT(driver, (KC_P)); |
| 108 | // Then the release | 108 | // Then the release |
| 109 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())); | 109 | EXPECT_EMPTY_REPORT(driver); |
| 110 | idle_for(TAPPING_TERM + 1); | 110 | idle_for(TAPPING_TERM + 1); |
| 111 | 111 | ||
| 112 | // Now we are geting into strange territory, as the hold registers too early here | 112 | // Now we are geting into strange territory, as the hold registers too early here |
| @@ -114,10 +114,10 @@ TEST_F(Tapping, ANewTapWithinTappingTermIsBuggy) { | |||
| 114 | // If TAPPING_TERM + 1 above is changed to TAPPING_TERM or TAPPING_TERM + 2 it doesn't | 114 | // If TAPPING_TERM + 1 above is changed to TAPPING_TERM or TAPPING_TERM + 2 it doesn't |
| 115 | key_shift_hold_p_tap.press(); | 115 | key_shift_hold_p_tap.press(); |
| 116 | // Shouldn't be called here really | 116 | // Shouldn't be called here really |
| 117 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT))).Times(1); | 117 | EXPECT_REPORT(driver, (KC_LEFT_SHIFT)).Times(1); |
| 118 | idle_for(TAPPING_TERM); | 118 | idle_for(TAPPING_TERM); |
| 119 | 119 | ||
| 120 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())); | 120 | EXPECT_EMPTY_REPORT(driver); |
| 121 | key_shift_hold_p_tap.release(); | 121 | key_shift_hold_p_tap.release(); |
| 122 | run_one_scan_loop(); | 122 | run_one_scan_loop(); |
| 123 | } \ No newline at end of file | 123 | } |
diff --git a/tests/caps_word/caps_word_autoshift/config.h b/tests/caps_word/caps_word_autoshift/config.h new file mode 100644 index 0000000000..b80f53b9dd --- /dev/null +++ b/tests/caps_word/caps_word_autoshift/config.h | |||
| @@ -0,0 +1,22 @@ | |||
| 1 | // Copyright 2022 Google LLC | ||
| 2 | // | ||
| 3 | // This program is free software: you can redistribute it and/or modify | ||
| 4 | // it under the terms of the GNU General Public License as published by | ||
| 5 | // the Free Software Foundation, either version 2 of the License, or | ||
| 6 | // (at your option) any later version. | ||
| 7 | // | ||
| 8 | // This program is distributed in the hope that it will be useful, | ||
| 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | // GNU General Public License for more details. | ||
| 12 | // | ||
| 13 | // You should have received a copy of the GNU General Public License | ||
| 14 | // along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | |||
| 16 | #pragma once | ||
| 17 | |||
| 18 | #include "test_common.h" | ||
| 19 | |||
| 20 | #define TAPPING_TERM 200 | ||
| 21 | #define AUTO_SHIFT_TIMEOUT 150 | ||
| 22 | #define RETRO_SHIFT 500 | ||
diff --git a/tests/caps_word/caps_word_autoshift/test.mk b/tests/caps_word/caps_word_autoshift/test.mk new file mode 100644 index 0000000000..7f717d7fc1 --- /dev/null +++ b/tests/caps_word/caps_word_autoshift/test.mk | |||
| @@ -0,0 +1,18 @@ | |||
| 1 | # Copyright 2022 Google LLC | ||
| 2 | # | ||
| 3 | # This program is free software: you can redistribute it and/or modify | ||
| 4 | # it under the terms of the GNU General Public License as published by | ||
| 5 | # the Free Software Foundation, either version 2 of the License, or | ||
| 6 | # (at your option) any later version. | ||
| 7 | # | ||
| 8 | # This program is distributed in the hope that it will be useful, | ||
| 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | # GNU General Public License for more details. | ||
| 12 | # | ||
| 13 | # You should have received a copy of the GNU General Public License | ||
| 14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | |||
| 16 | CAPS_WORD_ENABLE = yes | ||
| 17 | AUTO_SHIFT_ENABLE = yes | ||
| 18 | |||
diff --git a/tests/caps_word/caps_word_autoshift/test_caps_word_autoshift.cpp b/tests/caps_word/caps_word_autoshift/test_caps_word_autoshift.cpp new file mode 100644 index 0000000000..deb4d95766 --- /dev/null +++ b/tests/caps_word/caps_word_autoshift/test_caps_word_autoshift.cpp | |||
| @@ -0,0 +1,101 @@ | |||
| 1 | // Copyright 2022 Google LLC | ||
| 2 | // | ||
| 3 | // This program is free software: you can redistribute it and/or modify | ||
| 4 | // it under the terms of the GNU General Public License as published by | ||
| 5 | // the Free Software Foundation, either version 2 of the License, or | ||
| 6 | // (at your option) any later version. | ||
| 7 | // | ||
| 8 | // This program is distributed in the hope that it will be useful, | ||
| 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | // GNU General Public License for more details. | ||
| 12 | // | ||
| 13 | // You should have received a copy of the GNU General Public License | ||
| 14 | // along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | |||
| 16 | #include "keyboard_report_util.hpp" | ||
| 17 | #include "keycode.h" | ||
| 18 | #include "test_common.hpp" | ||
| 19 | #include "test_fixture.hpp" | ||
| 20 | #include "test_keymap_key.hpp" | ||
| 21 | |||
| 22 | using ::testing::_; | ||
| 23 | using ::testing::AnyNumber; | ||
| 24 | using ::testing::AnyOf; | ||
| 25 | using ::testing::InSequence; | ||
| 26 | |||
| 27 | class CapsWord : public TestFixture { | ||
| 28 | public: | ||
| 29 | void SetUp() override { | ||
| 30 | caps_word_off(); | ||
| 31 | } | ||
| 32 | }; | ||
| 33 | |||
| 34 | // Tests that with Auto Shift, letter keys are shifted by Caps Word | ||
| 35 | // regardless of whether they are released before AUTO_SHIFT_TIMEOUT. | ||
| 36 | TEST_F(CapsWord, AutoShiftKeys) { | ||
| 37 | TestDriver driver; | ||
| 38 | KeymapKey key_a(0, 0, 0, KC_A); | ||
| 39 | KeymapKey key_spc(0, 1, 0, KC_SPC); | ||
| 40 | set_keymap({key_a, key_spc}); | ||
| 41 | |||
| 42 | // Allow any number of reports with no keys or only KC_LSFT. | ||
| 43 | // clang-format off | ||
| 44 | EXPECT_CALL(driver, send_keyboard_mock(AnyOf( | ||
| 45 | KeyboardReport(), | ||
| 46 | KeyboardReport(KC_LSFT)))) | ||
| 47 | .Times(AnyNumber()); | ||
| 48 | // clang-format on | ||
| 49 | { // Expect: "A, A, space, a". | ||
| 50 | InSequence s; | ||
| 51 | EXPECT_REPORT(driver, (KC_LSFT, KC_A)); | ||
| 52 | EXPECT_REPORT(driver, (KC_LSFT, KC_A)); | ||
| 53 | EXPECT_REPORT(driver, (KC_SPC)); | ||
| 54 | EXPECT_REPORT(driver, (KC_A)); | ||
| 55 | } | ||
| 56 | |||
| 57 | // Turn on Caps Word and type "A (quick tap), A (long press), space, A". | ||
| 58 | caps_word_on(); | ||
| 59 | |||
| 60 | tap_key(key_a); // Tap A quickly. | ||
| 61 | tap_key(key_a, AUTO_SHIFT_TIMEOUT + 1); // Long press A. | ||
| 62 | tap_key(key_spc); | ||
| 63 | tap_key(key_a); | ||
| 64 | |||
| 65 | testing::Mock::VerifyAndClearExpectations(&driver); | ||
| 66 | } | ||
| 67 | |||
| 68 | // Tests that with tap-hold keys with Retro Shift, letter keys are shifted by | ||
| 69 | // Caps Word regardless of whether they are retroshifted. | ||
| 70 | TEST_F(CapsWord, RetroShiftKeys) { | ||
| 71 | TestDriver driver; | ||
| 72 | KeymapKey key_modtap_a(0, 0, 0, LCTL_T(KC_A)); | ||
| 73 | KeymapKey key_layertap_b(0, 1, 0, LT(1, KC_B)); | ||
| 74 | set_keymap({key_modtap_a, key_layertap_b}); | ||
| 75 | |||
| 76 | // Allow any number of reports with no keys or only KC_LSFT. | ||
| 77 | // clang-format off | ||
| 78 | EXPECT_CALL(driver, send_keyboard_mock(AnyOf( | ||
| 79 | KeyboardReport(), | ||
| 80 | KeyboardReport(KC_LSFT)))) | ||
| 81 | .Times(AnyNumber()); | ||
| 82 | // clang-format on | ||
| 83 | { // Expect: "B, A, B, A". | ||
| 84 | InSequence s; | ||
| 85 | EXPECT_REPORT(driver, (KC_LSFT, KC_B)); | ||
| 86 | EXPECT_REPORT(driver, (KC_LSFT, KC_A)); | ||
| 87 | EXPECT_REPORT(driver, (KC_LSFT, KC_B)); | ||
| 88 | EXPECT_REPORT(driver, (KC_LSFT, KC_A)); | ||
| 89 | } | ||
| 90 | |||
| 91 | // Turn on Caps Word and type "B, A (long press), B (long press), A". | ||
| 92 | caps_word_on(); | ||
| 93 | |||
| 94 | tap_key(key_layertap_b); // Tap B quickly. | ||
| 95 | tap_key(key_modtap_a, TAPPING_TERM + 1); // Long press A. | ||
| 96 | tap_key(key_layertap_b, TAPPING_TERM + 1); // Long press B. | ||
| 97 | tap_key(key_modtap_a); // Tap A quickly. | ||
| 98 | |||
| 99 | EXPECT_EQ(is_caps_word_on(), true); | ||
| 100 | testing::Mock::VerifyAndClearExpectations(&driver); | ||
| 101 | } | ||
diff --git a/tests/caps_word/caps_word_unicodemap/config.h b/tests/caps_word/caps_word_unicodemap/config.h new file mode 100644 index 0000000000..89fd7924d4 --- /dev/null +++ b/tests/caps_word/caps_word_unicodemap/config.h | |||
| @@ -0,0 +1,20 @@ | |||
| 1 | // Copyright 2022 Google LLC | ||
| 2 | // | ||
| 3 | // This program is free software: you can redistribute it and/or modify | ||
| 4 | // it under the terms of the GNU General Public License as published by | ||
| 5 | // the Free Software Foundation, either version 2 of the License, or | ||
| 6 | // (at your option) any later version. | ||
| 7 | // | ||
| 8 | // This program is distributed in the hope that it will be useful, | ||
| 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | // GNU General Public License for more details. | ||
| 12 | // | ||
| 13 | // You should have received a copy of the GNU General Public License | ||
| 14 | // along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | |||
| 16 | #pragma once | ||
| 17 | |||
| 18 | #include "test_common.h" | ||
| 19 | |||
| 20 | #define UNICODE_SELECTED_MODES UC_LNX | ||
diff --git a/tests/caps_word/caps_word_unicodemap/test.mk b/tests/caps_word/caps_word_unicodemap/test.mk new file mode 100644 index 0000000000..92bcba762c --- /dev/null +++ b/tests/caps_word/caps_word_unicodemap/test.mk | |||
| @@ -0,0 +1,18 @@ | |||
| 1 | # Copyright 2022 Google LLC | ||
| 2 | # | ||
| 3 | # This program is free software: you can redistribute it and/or modify | ||
| 4 | # it under the terms of the GNU General Public License as published by | ||
| 5 | # the Free Software Foundation, either version 2 of the License, or | ||
| 6 | # (at your option) any later version. | ||
| 7 | # | ||
| 8 | # This program is distributed in the hope that it will be useful, | ||
| 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | # GNU General Public License for more details. | ||
| 12 | # | ||
| 13 | # You should have received a copy of the GNU General Public License | ||
| 14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | |||
| 16 | CAPS_WORD_ENABLE = yes | ||
| 17 | UNICODEMAP_ENABLE = yes | ||
| 18 | |||
diff --git a/tests/caps_word/caps_word_unicodemap/test_caps_word_unicodemap.cpp b/tests/caps_word/caps_word_unicodemap/test_caps_word_unicodemap.cpp new file mode 100644 index 0000000000..fb8f9333bb --- /dev/null +++ b/tests/caps_word/caps_word_unicodemap/test_caps_word_unicodemap.cpp | |||
| @@ -0,0 +1,121 @@ | |||
| 1 | // Copyright 2022 Google LLC | ||
| 2 | // | ||
| 3 | // This program is free software: you can redistribute it and/or modify | ||
| 4 | // it under the terms of the GNU General Public License as published by | ||
| 5 | // the Free Software Foundation, either version 2 of the License, or | ||
| 6 | // (at your option) any later version. | ||
| 7 | // | ||
| 8 | // This program is distributed in the hope that it will be useful, | ||
| 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | // GNU General Public License for more details. | ||
| 12 | // | ||
| 13 | // You should have received a copy of the GNU General Public License | ||
| 14 | // along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | |||
| 16 | #include "keyboard_report_util.hpp" | ||
| 17 | #include "keycode.h" | ||
| 18 | #include "test_common.hpp" | ||
| 19 | #include "test_fixture.hpp" | ||
| 20 | #include "test_keymap_key.hpp" | ||
| 21 | |||
| 22 | using ::testing::_; | ||
| 23 | using ::testing::AnyNumber; | ||
| 24 | using ::testing::AnyOf; | ||
| 25 | using ::testing::InSequence; | ||
| 26 | |||
| 27 | extern "C" { | ||
| 28 | enum unicode_names { | ||
| 29 | ENDASH, | ||
| 30 | EMDASH, | ||
| 31 | DELTA_LOWERCASE, | ||
| 32 | DELTA_UPPERCASE, | ||
| 33 | }; | ||
| 34 | |||
| 35 | const uint32_t unicode_map[] PROGMEM = { | ||
| 36 | [ENDASH] = 0x2013, | ||
| 37 | [EMDASH] = 0x2014, | ||
| 38 | [DELTA_LOWERCASE] = 0x03b4, | ||
| 39 | [DELTA_UPPERCASE] = 0x0394, | ||
| 40 | }; | ||
| 41 | |||
| 42 | #define U_DASH XP(ENDASH, EMDASH) | ||
| 43 | #define U_DELTA XP(DELTA_LOWERCASE, DELTA_UPPERCASE) | ||
| 44 | |||
| 45 | bool caps_word_press_user(uint16_t keycode) { | ||
| 46 | switch (keycode) { | ||
| 47 | // Keycodes that continue Caps Word, with shift applied. | ||
| 48 | case U_DELTA: | ||
| 49 | add_weak_mods(MOD_BIT(KC_LSFT)); // Apply shift to next key. | ||
| 50 | return true; | ||
| 51 | |||
| 52 | // Keycodes that continue Caps Word, without shifting. | ||
| 53 | case U_DASH: | ||
| 54 | return true; | ||
| 55 | |||
| 56 | default: | ||
| 57 | return false; // Deactivate Caps Word. | ||
| 58 | } | ||
| 59 | } | ||
| 60 | } // extern "C" | ||
| 61 | |||
| 62 | class CapsWord : public TestFixture { | ||
| 63 | public: | ||
| 64 | void SetUp() override { | ||
| 65 | caps_word_off(); | ||
| 66 | } | ||
| 67 | }; | ||
| 68 | |||
| 69 | // Tests that typing U_DELTA while Caps Word is on sends the uppercase Delta. | ||
| 70 | TEST_F(CapsWord, ShiftedUnicodeMapKey) { | ||
| 71 | TestDriver driver; | ||
| 72 | KeymapKey key_delta(0, 0, 0, U_DELTA); | ||
| 73 | KeymapKey key_spc(0, 1, 0, KC_SPC); | ||
| 74 | set_keymap({key_delta, key_spc}); | ||
| 75 | |||
| 76 | // Allow any number of reports with no keys or only KC_LSFT and KC_LCTL. | ||
| 77 | // clang-format off | ||
| 78 | EXPECT_CALL(driver, send_keyboard_mock(AnyOf( | ||
| 79 | KeyboardReport(), | ||
| 80 | KeyboardReport(KC_LSFT), | ||
| 81 | KeyboardReport(KC_LCTL, KC_LSFT)))) | ||
| 82 | .Times(AnyNumber()); | ||
| 83 | // clang-format on | ||
| 84 | { // Expect: "Uppercase Delta, space, lowercase delta". | ||
| 85 | InSequence s; | ||
| 86 | EXPECT_UNICODE(driver, unicode_map[DELTA_UPPERCASE]); | ||
| 87 | EXPECT_REPORT(driver, (KC_SPC)); | ||
| 88 | EXPECT_UNICODE(driver, unicode_map[DELTA_LOWERCASE]); | ||
| 89 | } | ||
| 90 | |||
| 91 | // Turn on Caps Word and tap "delta, space, delta". | ||
| 92 | caps_word_on(); | ||
| 93 | tap_keys(key_delta, key_spc, key_delta); | ||
| 94 | |||
| 95 | EXPECT_EQ(is_caps_word_on(), false); | ||
| 96 | testing::Mock::VerifyAndClearExpectations(&driver); | ||
| 97 | } | ||
| 98 | |||
| 99 | // Tests typing U_ENDASH while Caps Word is on. | ||
| 100 | TEST_F(CapsWord, UnshiftedUnicodeMapKey) { | ||
| 101 | TestDriver driver; | ||
| 102 | KeymapKey key_dash(0, 0, 0, U_DASH); | ||
| 103 | set_keymap({key_dash}); | ||
| 104 | |||
| 105 | // Allow any number of reports with no keys or only KC_LSFT and KC_LCTL. | ||
| 106 | // clang-format off | ||
| 107 | EXPECT_CALL(driver, send_keyboard_mock(AnyOf( | ||
| 108 | KeyboardReport(), | ||
| 109 | KeyboardReport(KC_LSFT), | ||
| 110 | KeyboardReport(KC_LCTL, KC_LSFT)))) | ||
| 111 | .Times(AnyNumber()); | ||
| 112 | // clang-format on | ||
| 113 | EXPECT_UNICODE(driver, unicode_map[ENDASH]); | ||
| 114 | |||
| 115 | // Turn on Caps Word and tap U_DASH key. | ||
| 116 | caps_word_on(); | ||
| 117 | tap_key(key_dash); | ||
| 118 | |||
| 119 | EXPECT_EQ(is_caps_word_on(), true); | ||
| 120 | testing::Mock::VerifyAndClearExpectations(&driver); | ||
| 121 | } | ||
diff --git a/tests/caps_word/test_caps_word.cpp b/tests/caps_word/test_caps_word.cpp index f611d4c104..0af4b0175d 100644 --- a/tests/caps_word/test_caps_word.cpp +++ b/tests/caps_word/test_caps_word.cpp | |||
| @@ -30,22 +30,6 @@ class CapsWord : public TestFixture { | |||
| 30 | void SetUp() override { | 30 | void SetUp() override { |
| 31 | caps_word_off(); | 31 | caps_word_off(); |
| 32 | } | 32 | } |
| 33 | |||
| 34 | // Convenience function to tap `key`. | ||
| 35 | void TapKey(KeymapKey key) { | ||
| 36 | key.press(); | ||
| 37 | run_one_scan_loop(); | ||
| 38 | key.release(); | ||
| 39 | run_one_scan_loop(); | ||
| 40 | } | ||
| 41 | |||
| 42 | // Taps in order each key in `keys`. | ||
| 43 | template <typename... Ts> | ||
| 44 | void TapKeys(Ts... keys) { | ||
| 45 | for (KeymapKey key : {keys...}) { | ||
| 46 | TapKey(key); | ||
| 47 | } | ||
| 48 | } | ||
| 49 | }; | 33 | }; |
| 50 | 34 | ||
| 51 | // Tests caps_word_on(), _off(), and _toggle() functions. | 35 | // Tests caps_word_on(), _off(), and _toggle() functions. |
| @@ -104,12 +88,12 @@ TEST_F(CapsWord, CapswrdKey) { | |||
| 104 | set_keymap({key_capswrd}); | 88 | set_keymap({key_capswrd}); |
| 105 | 89 | ||
| 106 | // No keyboard reports should be sent. | 90 | // No keyboard reports should be sent. |
| 107 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 91 | EXPECT_NO_REPORT(driver); |
| 108 | 92 | ||
| 109 | TapKey(key_capswrd); // Tap the CAPSWRD key. | 93 | tap_key(key_capswrd); // Tap the CAPSWRD key. |
| 110 | EXPECT_EQ(is_caps_word_on(), true); | 94 | EXPECT_EQ(is_caps_word_on(), true); |
| 111 | 95 | ||
| 112 | TapKey(key_capswrd); // Tap the CAPSWRD key again. | 96 | tap_key(key_capswrd); // Tap the CAPSWRD key again. |
| 113 | EXPECT_EQ(is_caps_word_on(), false); | 97 | EXPECT_EQ(is_caps_word_on(), false); |
| 114 | 98 | ||
| 115 | testing::Mock::VerifyAndClearExpectations(&driver); | 99 | testing::Mock::VerifyAndClearExpectations(&driver); |
| @@ -130,11 +114,11 @@ TEST_F(CapsWord, IdleTimeout) { | |||
| 130 | // clang-format on | 114 | // clang-format on |
| 131 | 115 | ||
| 132 | // Expect "Shift+A". | 116 | // Expect "Shift+A". |
| 133 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT, KC_A))); | 117 | EXPECT_REPORT(driver, (KC_LSFT, KC_A)); |
| 134 | 118 | ||
| 135 | // Turn on Caps Word and tap "A". | 119 | // Turn on Caps Word and tap "A". |
| 136 | caps_word_on(); | 120 | caps_word_on(); |
| 137 | TapKey(key_a); | 121 | tap_key(key_a); |
| 138 | 122 | ||
| 139 | testing::Mock::VerifyAndClearExpectations(&driver); | 123 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 140 | 124 | ||
| @@ -145,10 +129,10 @@ TEST_F(CapsWord, IdleTimeout) { | |||
| 145 | EXPECT_EQ(is_caps_word_on(), false); | 129 | EXPECT_EQ(is_caps_word_on(), false); |
| 146 | EXPECT_EQ(get_mods() | get_weak_mods(), 0); | 130 | EXPECT_EQ(get_mods() | get_weak_mods(), 0); |
| 147 | 131 | ||
| 148 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).Times(AnyNumber()); | 132 | EXPECT_EMPTY_REPORT(driver).Times(AnyNumber()); |
| 149 | // Expect unshifted "A". | 133 | // Expect unshifted "A". |
| 150 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_A))); | 134 | EXPECT_REPORT(driver, (KC_A)); |
| 151 | TapKey(key_a); | 135 | tap_key(key_a); |
| 152 | 136 | ||
| 153 | testing::Mock::VerifyAndClearExpectations(&driver); | 137 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 154 | } | 138 | } |
| @@ -170,15 +154,15 @@ TEST_F(CapsWord, ShiftsLettersButNotDigits) { | |||
| 170 | 154 | ||
| 171 | { // Expect: "Shift+A, 4, Shift+A, 4". | 155 | { // Expect: "Shift+A, 4, Shift+A, 4". |
| 172 | InSequence s; | 156 | InSequence s; |
| 173 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT, KC_A))); | 157 | EXPECT_REPORT(driver, (KC_LSFT, KC_A)); |
| 174 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_4))); | 158 | EXPECT_REPORT(driver, (KC_4)); |
| 175 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT, KC_A))); | 159 | EXPECT_REPORT(driver, (KC_LSFT, KC_A)); |
| 176 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_4))); | 160 | EXPECT_REPORT(driver, (KC_4)); |
| 177 | } | 161 | } |
| 178 | 162 | ||
| 179 | // Turn on Caps Word and tap "A, 4, A, 4". | 163 | // Turn on Caps Word and tap "A, 4, A, 4". |
| 180 | caps_word_on(); | 164 | caps_word_on(); |
| 181 | TapKeys(key_a, key_4, key_a, key_4); | 165 | tap_keys(key_a, key_4, key_a, key_4); |
| 182 | 166 | ||
| 183 | testing::Mock::VerifyAndClearExpectations(&driver); | 167 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 184 | } | 168 | } |
| @@ -200,14 +184,14 @@ TEST_F(CapsWord, SpaceTurnsOffCapsWord) { | |||
| 200 | 184 | ||
| 201 | { // Expect: "Shift+A, Space, A". | 185 | { // Expect: "Shift+A, Space, A". |
| 202 | InSequence seq; | 186 | InSequence seq; |
| 203 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT, KC_A))); | 187 | EXPECT_REPORT(driver, (KC_LSFT, KC_A)); |
| 204 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_SPC))); | 188 | EXPECT_REPORT(driver, (KC_SPC)); |
| 205 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_A))); | 189 | EXPECT_REPORT(driver, (KC_A)); |
| 206 | } | 190 | } |
| 207 | 191 | ||
| 208 | // Turn on Caps Word and tap "A, Space, A". | 192 | // Turn on Caps Word and tap "A, Space, A". |
| 209 | caps_word_on(); | 193 | caps_word_on(); |
| 210 | TapKeys(key_a, key_spc, key_a); | 194 | tap_keys(key_a, key_spc, key_a); |
| 211 | 195 | ||
| 212 | testing::Mock::VerifyAndClearExpectations(&driver); | 196 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 213 | } | 197 | } |
| @@ -226,8 +210,8 @@ TEST_F(CapsWord, ShiftsAltGrSymbols) { | |||
| 226 | KeyboardReport(KC_RALT), | 210 | KeyboardReport(KC_RALT), |
| 227 | KeyboardReport(KC_LSFT, KC_RALT)))) | 211 | KeyboardReport(KC_LSFT, KC_RALT)))) |
| 228 | .Times(AnyNumber()); | 212 | .Times(AnyNumber()); |
| 229 | // Expect "Shift + AltGr + A, Space". | 213 | // Expect "Shift + AltGr + A". |
| 230 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT, KC_RALT, KC_A))); | 214 | EXPECT_REPORT(driver, (KC_LSFT, KC_RALT, KC_A)); |
| 231 | // clang-format on | 215 | // clang-format on |
| 232 | 216 | ||
| 233 | // Turn on Caps Word and type "AltGr + A". | 217 | // Turn on Caps Word and type "AltGr + A". |
| @@ -235,7 +219,7 @@ TEST_F(CapsWord, ShiftsAltGrSymbols) { | |||
| 235 | 219 | ||
| 236 | key_altgr.press(); | 220 | key_altgr.press(); |
| 237 | run_one_scan_loop(); | 221 | run_one_scan_loop(); |
| 238 | TapKeys(key_a); | 222 | tap_key(key_a); |
| 239 | run_one_scan_loop(); | 223 | run_one_scan_loop(); |
| 240 | key_altgr.release(); | 224 | key_altgr.release(); |
| 241 | 225 | ||
| @@ -376,9 +360,9 @@ TEST_P(CapsWordDoubleTapShift, Activation) { | |||
| 376 | EXPECT_EQ(is_caps_word_on(), false); | 360 | EXPECT_EQ(is_caps_word_on(), false); |
| 377 | 361 | ||
| 378 | // Tapping shift twice within the tapping term turns on Caps Word. | 362 | // Tapping shift twice within the tapping term turns on Caps Word. |
| 379 | TapKey(left_shift); | 363 | tap_key(left_shift); |
| 380 | idle_for(TAPPING_TERM - 10); | 364 | idle_for(TAPPING_TERM - 10); |
| 381 | TapKey(left_shift); | 365 | tap_key(left_shift); |
| 382 | 366 | ||
| 383 | EXPECT_EQ(is_caps_word_on(), true); | 367 | EXPECT_EQ(is_caps_word_on(), true); |
| 384 | 368 | ||
| @@ -403,13 +387,13 @@ TEST_P(CapsWordDoubleTapShift, Interrupted) { | |||
| 403 | left_shift.press(); | 387 | left_shift.press(); |
| 404 | run_one_scan_loop(); | 388 | run_one_scan_loop(); |
| 405 | 389 | ||
| 406 | TapKey(key_a); // 'A' key interrupts the double tap. | 390 | tap_key(key_a); // 'A' key interrupts the double tap. |
| 407 | 391 | ||
| 408 | left_shift.release(); | 392 | left_shift.release(); |
| 409 | run_one_scan_loop(); | 393 | run_one_scan_loop(); |
| 410 | 394 | ||
| 411 | idle_for(TAPPING_TERM - 10); | 395 | idle_for(TAPPING_TERM - 10); |
| 412 | TapKey(left_shift); | 396 | tap_key(left_shift); |
| 413 | 397 | ||
| 414 | EXPECT_EQ(is_caps_word_on(), false); // Caps Word is still off. | 398 | EXPECT_EQ(is_caps_word_on(), false); // Caps Word is still off. |
| 415 | clear_oneshot_mods(); | 399 | clear_oneshot_mods(); |
| @@ -430,9 +414,9 @@ TEST_P(CapsWordDoubleTapShift, SlowTaps) { | |||
| 430 | .Times(AnyNumber()); | 414 | .Times(AnyNumber()); |
| 431 | // clang-format on | 415 | // clang-format on |
| 432 | 416 | ||
| 433 | TapKey(left_shift); | 417 | tap_key(left_shift); |
| 434 | idle_for(TAPPING_TERM + 1); | 418 | idle_for(TAPPING_TERM + 1); |
| 435 | TapKey(left_shift); | 419 | tap_key(left_shift); |
| 436 | 420 | ||
| 437 | EXPECT_EQ(is_caps_word_on(), false); // Caps Word is still off. | 421 | EXPECT_EQ(is_caps_word_on(), false); // Caps Word is still off. |
| 438 | clear_oneshot_mods(); | 422 | clear_oneshot_mods(); |
diff --git a/tests/secure/test_secure.cpp b/tests/secure/test_secure.cpp index b7c51b0bd2..6ca98d78f3 100644 --- a/tests/secure/test_secure.cpp +++ b/tests/secure/test_secure.cpp | |||
| @@ -27,28 +27,13 @@ class Secure : public TestFixture { | |||
| 27 | void SetUp() override { | 27 | void SetUp() override { |
| 28 | secure_lock(); | 28 | secure_lock(); |
| 29 | } | 29 | } |
| 30 | // Convenience function to tap `key`. | ||
| 31 | void TapKey(KeymapKey key) { | ||
| 32 | key.press(); | ||
| 33 | run_one_scan_loop(); | ||
| 34 | key.release(); | ||
| 35 | run_one_scan_loop(); | ||
| 36 | } | ||
| 37 | |||
| 38 | // Taps in order each key in `keys`. | ||
| 39 | template <typename... Ts> | ||
| 40 | void TapKeys(Ts... keys) { | ||
| 41 | for (KeymapKey key : {keys...}) { | ||
| 42 | TapKey(key); | ||
| 43 | } | ||
| 44 | } | ||
| 45 | }; | 30 | }; |
| 46 | 31 | ||
| 47 | TEST_F(Secure, test_lock) { | 32 | TEST_F(Secure, test_lock) { |
| 48 | TestDriver driver; | 33 | TestDriver driver; |
| 49 | 34 | ||
| 50 | // Allow any number of empty reports. | 35 | // Don't allow empty reports. |
| 51 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).Times(0); | 36 | EXPECT_NO_REPORT(driver); |
| 52 | 37 | ||
| 53 | EXPECT_FALSE(secure_is_unlocked()); | 38 | EXPECT_FALSE(secure_is_unlocked()); |
| 54 | secure_unlock(); | 39 | secure_unlock(); |
| @@ -64,8 +49,8 @@ TEST_F(Secure, test_lock) { | |||
| 64 | TEST_F(Secure, test_unlock_timeout) { | 49 | TEST_F(Secure, test_unlock_timeout) { |
| 65 | TestDriver driver; | 50 | TestDriver driver; |
| 66 | 51 | ||
| 67 | // Allow any number of empty reports. | 52 | // Don't allow empty reports. |
| 68 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).Times(0); | 53 | EXPECT_NO_REPORT(driver); |
| 69 | 54 | ||
| 70 | EXPECT_FALSE(secure_is_unlocked()); | 55 | EXPECT_FALSE(secure_is_unlocked()); |
| 71 | secure_unlock(); | 56 | secure_unlock(); |
| @@ -86,13 +71,13 @@ TEST_F(Secure, test_unlock_request) { | |||
| 86 | 71 | ||
| 87 | set_keymap({key_mo, key_a, key_b, key_c, key_d}); | 72 | set_keymap({key_mo, key_a, key_b, key_c, key_d}); |
| 88 | 73 | ||
| 89 | // Allow any number of empty reports. | 74 | // Don't allow empty reports. |
| 90 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).Times(0); | 75 | EXPECT_NO_REPORT(driver); |
| 91 | 76 | ||
| 92 | EXPECT_TRUE(secure_is_locked()); | 77 | EXPECT_TRUE(secure_is_locked()); |
| 93 | secure_request_unlock(); | 78 | secure_request_unlock(); |
| 94 | EXPECT_TRUE(secure_is_unlocking()); | 79 | EXPECT_TRUE(secure_is_unlocking()); |
| 95 | TapKeys(key_a, key_b, key_c, key_d); | 80 | tap_keys(key_a, key_b, key_c, key_d); |
| 96 | EXPECT_TRUE(secure_is_unlocked()); | 81 | EXPECT_TRUE(secure_is_unlocked()); |
| 97 | 82 | ||
| 98 | testing::Mock::VerifyAndClearExpectations(&driver); | 83 | testing::Mock::VerifyAndClearExpectations(&driver); |
| @@ -109,18 +94,18 @@ TEST_F(Secure, test_unlock_request_fail) { | |||
| 109 | set_keymap({key_e, key_a, key_b, key_c, key_d}); | 94 | set_keymap({key_e, key_a, key_b, key_c, key_d}); |
| 110 | 95 | ||
| 111 | // Allow any number of empty reports. | 96 | // Allow any number of empty reports. |
| 112 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).Times(AnyNumber()); | 97 | EXPECT_EMPTY_REPORT(driver).Times(AnyNumber()); |
| 113 | { // Expect the following reports in this order. | 98 | { // Expect the following reports in this order. |
| 114 | InSequence s; | 99 | InSequence s; |
| 115 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_A))); | 100 | EXPECT_REPORT(driver, (KC_A)); |
| 116 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_B))); | 101 | EXPECT_REPORT(driver, (KC_B)); |
| 117 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_C))); | 102 | EXPECT_REPORT(driver, (KC_C)); |
| 118 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_D))); | 103 | EXPECT_REPORT(driver, (KC_D)); |
| 119 | } | 104 | } |
| 120 | EXPECT_TRUE(secure_is_locked()); | 105 | EXPECT_TRUE(secure_is_locked()); |
| 121 | secure_request_unlock(); | 106 | secure_request_unlock(); |
| 122 | EXPECT_TRUE(secure_is_unlocking()); | 107 | EXPECT_TRUE(secure_is_unlocking()); |
| 123 | TapKeys(key_e, key_a, key_b, key_c, key_d); | 108 | tap_keys(key_e, key_a, key_b, key_c, key_d); |
| 124 | EXPECT_FALSE(secure_is_unlocked()); | 109 | EXPECT_FALSE(secure_is_unlocked()); |
| 125 | 110 | ||
| 126 | testing::Mock::VerifyAndClearExpectations(&driver); | 111 | testing::Mock::VerifyAndClearExpectations(&driver); |
| @@ -129,8 +114,8 @@ TEST_F(Secure, test_unlock_request_fail) { | |||
| 129 | TEST_F(Secure, test_unlock_request_timeout) { | 114 | TEST_F(Secure, test_unlock_request_timeout) { |
| 130 | TestDriver driver; | 115 | TestDriver driver; |
| 131 | 116 | ||
| 132 | // Allow any number of empty reports. | 117 | // Don't allow empty reports. |
| 133 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).Times(0); | 118 | EXPECT_NO_REPORT(driver); |
| 134 | 119 | ||
| 135 | EXPECT_FALSE(secure_is_unlocked()); | 120 | EXPECT_FALSE(secure_is_unlocked()); |
| 136 | secure_request_unlock(); | 121 | secure_request_unlock(); |
| @@ -153,16 +138,16 @@ TEST_F(Secure, test_unlock_request_fail_mid) { | |||
| 153 | set_keymap({key_e, key_a, key_b, key_c, key_d}); | 138 | set_keymap({key_e, key_a, key_b, key_c, key_d}); |
| 154 | 139 | ||
| 155 | // Allow any number of empty reports. | 140 | // Allow any number of empty reports. |
| 156 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).Times(AnyNumber()); | 141 | EXPECT_EMPTY_REPORT(driver).Times(AnyNumber()); |
| 157 | { // Expect the following reports in this order. | 142 | { // Expect the following reports in this order. |
| 158 | InSequence s; | 143 | InSequence s; |
| 159 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_C))); | 144 | EXPECT_REPORT(driver, (KC_C)); |
| 160 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_D))); | 145 | EXPECT_REPORT(driver, (KC_D)); |
| 161 | } | 146 | } |
| 162 | EXPECT_FALSE(secure_is_unlocked()); | 147 | EXPECT_FALSE(secure_is_unlocked()); |
| 163 | secure_request_unlock(); | 148 | secure_request_unlock(); |
| 164 | EXPECT_TRUE(secure_is_unlocking()); | 149 | EXPECT_TRUE(secure_is_unlocking()); |
| 165 | TapKeys(key_a, key_b, key_e, key_c, key_d); | 150 | tap_keys(key_a, key_b, key_e, key_c, key_d); |
| 166 | EXPECT_FALSE(secure_is_unlocking()); | 151 | EXPECT_FALSE(secure_is_unlocking()); |
| 167 | EXPECT_FALSE(secure_is_unlocked()); | 152 | EXPECT_FALSE(secure_is_unlocked()); |
| 168 | 153 | ||
| @@ -180,16 +165,16 @@ TEST_F(Secure, test_unlock_request_fail_out_of_order) { | |||
| 180 | set_keymap({key_e, key_a, key_b, key_c, key_d}); | 165 | set_keymap({key_e, key_a, key_b, key_c, key_d}); |
| 181 | 166 | ||
| 182 | // Allow any number of empty reports. | 167 | // Allow any number of empty reports. |
| 183 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).Times(AnyNumber()); | 168 | EXPECT_EMPTY_REPORT(driver).Times(AnyNumber()); |
| 184 | { // Expect the following reports in this order. | 169 | { // Expect the following reports in this order. |
| 185 | InSequence s; | 170 | InSequence s; |
| 186 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_B))); | 171 | EXPECT_REPORT(driver, (KC_B)); |
| 187 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_C))); | 172 | EXPECT_REPORT(driver, (KC_C)); |
| 188 | } | 173 | } |
| 189 | EXPECT_FALSE(secure_is_unlocked()); | 174 | EXPECT_FALSE(secure_is_unlocked()); |
| 190 | secure_request_unlock(); | 175 | secure_request_unlock(); |
| 191 | EXPECT_TRUE(secure_is_unlocking()); | 176 | EXPECT_TRUE(secure_is_unlocking()); |
| 192 | TapKeys(key_a, key_d, key_b, key_c); | 177 | tap_keys(key_a, key_d, key_b, key_c); |
| 193 | EXPECT_TRUE(secure_is_locked()); | 178 | EXPECT_TRUE(secure_is_locked()); |
| 194 | EXPECT_FALSE(secure_is_unlocking()); | 179 | EXPECT_FALSE(secure_is_unlocking()); |
| 195 | EXPECT_FALSE(secure_is_unlocked()); | 180 | EXPECT_FALSE(secure_is_unlocked()); |
| @@ -207,8 +192,8 @@ TEST_F(Secure, test_unlock_request_on_layer) { | |||
| 207 | 192 | ||
| 208 | set_keymap({key_mo, key_a, key_b, key_c, key_d}); | 193 | set_keymap({key_mo, key_a, key_b, key_c, key_d}); |
| 209 | 194 | ||
| 210 | // Allow any number of empty reports. | 195 | // Don't allow empty reports. |
| 211 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).Times(0); | 196 | EXPECT_NO_REPORT(driver); |
| 212 | 197 | ||
| 213 | EXPECT_TRUE(secure_is_locked()); | 198 | EXPECT_TRUE(secure_is_locked()); |
| 214 | key_mo.press(); | 199 | key_mo.press(); |
| @@ -217,7 +202,7 @@ TEST_F(Secure, test_unlock_request_on_layer) { | |||
| 217 | key_mo.release(); | 202 | key_mo.release(); |
| 218 | run_one_scan_loop(); | 203 | run_one_scan_loop(); |
| 219 | EXPECT_TRUE(secure_is_unlocking()); | 204 | EXPECT_TRUE(secure_is_unlocking()); |
| 220 | TapKeys(key_a, key_b, key_c, key_d); | 205 | tap_keys(key_a, key_b, key_c, key_d); |
| 221 | EXPECT_TRUE(secure_is_unlocked()); | 206 | EXPECT_TRUE(secure_is_unlocked()); |
| 222 | EXPECT_FALSE(layer_state_is(1)); | 207 | EXPECT_FALSE(layer_state_is(1)); |
| 223 | 208 | ||
| @@ -234,9 +219,8 @@ TEST_F(Secure, test_unlock_request_mid_stroke) { | |||
| 234 | 219 | ||
| 235 | set_keymap({key_e, key_a, key_b, key_c, key_d}); | 220 | set_keymap({key_e, key_a, key_b, key_c, key_d}); |
| 236 | 221 | ||
| 237 | // Allow any number of empty reports. | 222 | EXPECT_REPORT(driver, (KC_E)); |
| 238 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_E))); | 223 | EXPECT_EMPTY_REPORT(driver); |
| 239 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())); | ||
| 240 | EXPECT_TRUE(secure_is_locked()); | 224 | EXPECT_TRUE(secure_is_locked()); |
| 241 | key_e.press(); | 225 | key_e.press(); |
| 242 | run_one_scan_loop(); | 226 | run_one_scan_loop(); |
| @@ -244,7 +228,7 @@ TEST_F(Secure, test_unlock_request_mid_stroke) { | |||
| 244 | key_e.release(); | 228 | key_e.release(); |
| 245 | run_one_scan_loop(); | 229 | run_one_scan_loop(); |
| 246 | EXPECT_TRUE(secure_is_unlocking()); | 230 | EXPECT_TRUE(secure_is_unlocking()); |
| 247 | TapKeys(key_a, key_b, key_c, key_d); | 231 | tap_keys(key_a, key_b, key_c, key_d); |
| 248 | EXPECT_TRUE(secure_is_unlocked()); | 232 | EXPECT_TRUE(secure_is_unlocked()); |
| 249 | 233 | ||
| 250 | testing::Mock::VerifyAndClearExpectations(&driver); | 234 | testing::Mock::VerifyAndClearExpectations(&driver); |
| @@ -260,9 +244,8 @@ TEST_F(Secure, test_unlock_request_mods) { | |||
| 260 | 244 | ||
| 261 | set_keymap({key_lsft, key_a, key_b, key_c, key_d}); | 245 | set_keymap({key_lsft, key_a, key_b, key_c, key_d}); |
| 262 | 246 | ||
| 263 | // Allow any number of empty reports. | 247 | EXPECT_REPORT(driver, (key_lsft.report_code)); |
| 264 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(key_lsft.report_code))); | 248 | EXPECT_EMPTY_REPORT(driver); |
| 265 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())); | ||
| 266 | EXPECT_TRUE(secure_is_locked()); | 249 | EXPECT_TRUE(secure_is_locked()); |
| 267 | key_lsft.press(); | 250 | key_lsft.press(); |
| 268 | run_one_scan_loop(); | 251 | run_one_scan_loop(); |
| @@ -270,7 +253,7 @@ TEST_F(Secure, test_unlock_request_mods) { | |||
| 270 | key_lsft.release(); | 253 | key_lsft.release(); |
| 271 | run_one_scan_loop(); | 254 | run_one_scan_loop(); |
| 272 | EXPECT_TRUE(secure_is_unlocking()); | 255 | EXPECT_TRUE(secure_is_unlocking()); |
| 273 | TapKeys(key_a, key_b, key_c, key_d); | 256 | tap_keys(key_a, key_b, key_c, key_d); |
| 274 | EXPECT_TRUE(secure_is_unlocked()); | 257 | EXPECT_TRUE(secure_is_unlocked()); |
| 275 | 258 | ||
| 276 | testing::Mock::VerifyAndClearExpectations(&driver); | 259 | testing::Mock::VerifyAndClearExpectations(&driver); |
diff --git a/tests/tap_hold_configurations/default_mod_tap/test_tap_hold.cpp b/tests/tap_hold_configurations/default_mod_tap/test_tap_hold.cpp index 90befcdffd..ecb79c2560 100644 --- a/tests/tap_hold_configurations/default_mod_tap/test_tap_hold.cpp +++ b/tests/tap_hold_configurations/default_mod_tap/test_tap_hold.cpp | |||
| @@ -35,28 +35,28 @@ TEST_F(DefaultTapHold, tap_regular_key_while_mod_tap_key_is_held) { | |||
| 35 | set_keymap({mod_tap_hold_key, regular_key}); | 35 | set_keymap({mod_tap_hold_key, regular_key}); |
| 36 | 36 | ||
| 37 | /* Press mod-tap-hold key. */ | 37 | /* Press mod-tap-hold key. */ |
| 38 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 38 | EXPECT_NO_REPORT(driver); |
| 39 | mod_tap_hold_key.press(); | 39 | mod_tap_hold_key.press(); |
| 40 | run_one_scan_loop(); | 40 | run_one_scan_loop(); |
| 41 | testing::Mock::VerifyAndClearExpectations(&driver); | 41 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 42 | 42 | ||
| 43 | /* Press regular key. */ | 43 | /* Press regular key. */ |
| 44 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 44 | EXPECT_NO_REPORT(driver); |
| 45 | regular_key.press(); | 45 | regular_key.press(); |
| 46 | run_one_scan_loop(); | 46 | run_one_scan_loop(); |
| 47 | testing::Mock::VerifyAndClearExpectations(&driver); | 47 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 48 | 48 | ||
| 49 | /* Release regular key. */ | 49 | /* Release regular key. */ |
| 50 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 50 | EXPECT_NO_REPORT(driver); |
| 51 | regular_key.release(); | 51 | regular_key.release(); |
| 52 | run_one_scan_loop(); | 52 | run_one_scan_loop(); |
| 53 | testing::Mock::VerifyAndClearExpectations(&driver); | 53 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 54 | 54 | ||
| 55 | /* Release mod-tap-hold key. */ | 55 | /* Release mod-tap-hold key. */ |
| 56 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_P))); | 56 | EXPECT_REPORT(driver, (KC_P)); |
| 57 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_P, KC_A))); | 57 | EXPECT_REPORT(driver, (KC_P, KC_A)); |
| 58 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_P))); | 58 | EXPECT_REPORT(driver, (KC_P)); |
| 59 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())); | 59 | EXPECT_EMPTY_REPORT(driver); |
| 60 | mod_tap_hold_key.release(); | 60 | mod_tap_hold_key.release(); |
| 61 | run_one_scan_loop(); | 61 | run_one_scan_loop(); |
| 62 | testing::Mock::VerifyAndClearExpectations(&driver); | 62 | testing::Mock::VerifyAndClearExpectations(&driver); |
| @@ -75,28 +75,28 @@ TEST_F(DefaultTapHold, tap_mod_tap_key_while_mod_tap_key_is_held) { | |||
| 75 | set_keymap({first_mod_tap_hold_key, second_mod_tap_hold_key}); | 75 | set_keymap({first_mod_tap_hold_key, second_mod_tap_hold_key}); |
| 76 | 76 | ||
| 77 | /* Press first mod-tap-hold key */ | 77 | /* Press first mod-tap-hold key */ |
| 78 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 78 | EXPECT_NO_REPORT(driver); |
| 79 | first_mod_tap_hold_key.press(); | 79 | first_mod_tap_hold_key.press(); |
| 80 | run_one_scan_loop(); | 80 | run_one_scan_loop(); |
| 81 | testing::Mock::VerifyAndClearExpectations(&driver); | 81 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 82 | 82 | ||
| 83 | /* Press second tap-hold key */ | 83 | /* Press second tap-hold key */ |
| 84 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 84 | EXPECT_NO_REPORT(driver); |
| 85 | second_mod_tap_hold_key.press(); | 85 | second_mod_tap_hold_key.press(); |
| 86 | run_one_scan_loop(); | 86 | run_one_scan_loop(); |
| 87 | testing::Mock::VerifyAndClearExpectations(&driver); | 87 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 88 | 88 | ||
| 89 | /* Release second tap-hold key */ | 89 | /* Release second tap-hold key */ |
| 90 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 90 | EXPECT_NO_REPORT(driver); |
| 91 | second_mod_tap_hold_key.release(); | 91 | second_mod_tap_hold_key.release(); |
| 92 | run_one_scan_loop(); | 92 | run_one_scan_loop(); |
| 93 | testing::Mock::VerifyAndClearExpectations(&driver); | 93 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 94 | 94 | ||
| 95 | /* Release first mod-tap-hold key */ | 95 | /* Release first mod-tap-hold key */ |
| 96 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_P))); | 96 | EXPECT_REPORT(driver, (KC_P)); |
| 97 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_P, KC_A))); | 97 | EXPECT_REPORT(driver, (KC_P, KC_A)); |
| 98 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_P))); | 98 | EXPECT_REPORT(driver, (KC_P)); |
| 99 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())); | 99 | EXPECT_EMPTY_REPORT(driver); |
| 100 | first_mod_tap_hold_key.release(); | 100 | first_mod_tap_hold_key.release(); |
| 101 | run_one_scan_loop(); | 101 | run_one_scan_loop(); |
| 102 | testing::Mock::VerifyAndClearExpectations(&driver); | 102 | testing::Mock::VerifyAndClearExpectations(&driver); |
| @@ -112,27 +112,27 @@ TEST_F(DefaultTapHold, tap_regular_key_while_layer_tap_key_is_held) { | |||
| 112 | set_keymap({layer_tap_hold_key, regular_key, layer_key}); | 112 | set_keymap({layer_tap_hold_key, regular_key, layer_key}); |
| 113 | 113 | ||
| 114 | /* Press layer-tap-hold key */ | 114 | /* Press layer-tap-hold key */ |
| 115 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 115 | EXPECT_NO_REPORT(driver); |
| 116 | layer_tap_hold_key.press(); | 116 | layer_tap_hold_key.press(); |
| 117 | run_one_scan_loop(); | 117 | run_one_scan_loop(); |
| 118 | testing::Mock::VerifyAndClearExpectations(&driver); | 118 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 119 | 119 | ||
| 120 | /* Press regular key */ | 120 | /* Press regular key */ |
| 121 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 121 | EXPECT_NO_REPORT(driver); |
| 122 | regular_key.press(); | 122 | regular_key.press(); |
| 123 | run_one_scan_loop(); | 123 | run_one_scan_loop(); |
| 124 | testing::Mock::VerifyAndClearExpectations(&driver); | 124 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 125 | 125 | ||
| 126 | /* Release regular key */ | 126 | /* Release regular key */ |
| 127 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 127 | EXPECT_NO_REPORT(driver); |
| 128 | regular_key.release(); | 128 | regular_key.release(); |
| 129 | run_one_scan_loop(); | 129 | run_one_scan_loop(); |
| 130 | testing::Mock::VerifyAndClearExpectations(&driver); | 130 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 131 | 131 | ||
| 132 | /* Release layer-tap-hold key */ | 132 | /* Release layer-tap-hold key */ |
| 133 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_P))); | 133 | EXPECT_REPORT(driver, (KC_P)); |
| 134 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_A, KC_P))); | 134 | EXPECT_REPORT(driver, (KC_P, KC_A)); |
| 135 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_P))); | 135 | EXPECT_REPORT(driver, (KC_P)); |
| 136 | EXPECT_CALL(driver, send_keyboard_mock(_)); | 136 | EXPECT_CALL(driver, send_keyboard_mock(_)); |
| 137 | layer_tap_hold_key.release(); | 137 | layer_tap_hold_key.release(); |
| 138 | run_one_scan_loop(); | 138 | run_one_scan_loop(); |
| @@ -149,26 +149,26 @@ TEST_F(DefaultTapHold, tap_mod_tap_hold_key_two_times) { | |||
| 149 | set_keymap({mod_tap_hold_key}); | 149 | set_keymap({mod_tap_hold_key}); |
| 150 | 150 | ||
| 151 | /* Press mod-tap-hold key. */ | 151 | /* Press mod-tap-hold key. */ |
| 152 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 152 | EXPECT_NO_REPORT(driver); |
| 153 | mod_tap_hold_key.press(); | 153 | mod_tap_hold_key.press(); |
| 154 | run_one_scan_loop(); | 154 | run_one_scan_loop(); |
| 155 | testing::Mock::VerifyAndClearExpectations(&driver); | 155 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 156 | 156 | ||
| 157 | /* Release mod-tap-hold key. */ | 157 | /* Release mod-tap-hold key. */ |
| 158 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_P))); | 158 | EXPECT_REPORT(driver, (KC_P)); |
| 159 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())); | 159 | EXPECT_EMPTY_REPORT(driver); |
| 160 | mod_tap_hold_key.release(); | 160 | mod_tap_hold_key.release(); |
| 161 | run_one_scan_loop(); | 161 | run_one_scan_loop(); |
| 162 | testing::Mock::VerifyAndClearExpectations(&driver); | 162 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 163 | 163 | ||
| 164 | /* Press mod-tap-hold key again. */ | 164 | /* Press mod-tap-hold key again. */ |
| 165 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_P))); | 165 | EXPECT_REPORT(driver, (KC_P)); |
| 166 | mod_tap_hold_key.press(); | 166 | mod_tap_hold_key.press(); |
| 167 | idle_for(TAPPING_TERM); | 167 | idle_for(TAPPING_TERM); |
| 168 | testing::Mock::VerifyAndClearExpectations(&driver); | 168 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 169 | 169 | ||
| 170 | /* Release mod-tap-hold key. */ | 170 | /* Release mod-tap-hold key. */ |
| 171 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())); | 171 | EXPECT_EMPTY_REPORT(driver); |
| 172 | mod_tap_hold_key.release(); | 172 | mod_tap_hold_key.release(); |
| 173 | run_one_scan_loop(); | 173 | run_one_scan_loop(); |
| 174 | testing::Mock::VerifyAndClearExpectations(&driver); | 174 | testing::Mock::VerifyAndClearExpectations(&driver); |
| @@ -184,26 +184,26 @@ TEST_F(DefaultTapHold, tap_mod_tap_hold_key_twice_and_hold_on_second_time) { | |||
| 184 | set_keymap({mod_tap_hold_key}); | 184 | set_keymap({mod_tap_hold_key}); |
| 185 | 185 | ||
| 186 | /* Press mod-tap-hold key. */ | 186 | /* Press mod-tap-hold key. */ |
| 187 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 187 | EXPECT_NO_REPORT(driver); |
| 188 | mod_tap_hold_key.press(); | 188 | mod_tap_hold_key.press(); |
| 189 | run_one_scan_loop(); | 189 | run_one_scan_loop(); |
| 190 | testing::Mock::VerifyAndClearExpectations(&driver); | 190 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 191 | 191 | ||
| 192 | /* Release mod-tap-hold key. */ | 192 | /* Release mod-tap-hold key. */ |
| 193 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_P))); | 193 | EXPECT_REPORT(driver, (KC_P)); |
| 194 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())); | 194 | EXPECT_EMPTY_REPORT(driver); |
| 195 | mod_tap_hold_key.release(); | 195 | mod_tap_hold_key.release(); |
| 196 | run_one_scan_loop(); | 196 | run_one_scan_loop(); |
| 197 | testing::Mock::VerifyAndClearExpectations(&driver); | 197 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 198 | 198 | ||
| 199 | /* Press mod-tap-hold key again. */ | 199 | /* Press mod-tap-hold key again. */ |
| 200 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_P))); | 200 | EXPECT_REPORT(driver, (KC_P)); |
| 201 | mod_tap_hold_key.press(); | 201 | mod_tap_hold_key.press(); |
| 202 | idle_for(TAPPING_TERM); | 202 | idle_for(TAPPING_TERM); |
| 203 | testing::Mock::VerifyAndClearExpectations(&driver); | 203 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 204 | 204 | ||
| 205 | /* Release mod-tap-hold key. */ | 205 | /* Release mod-tap-hold key. */ |
| 206 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())); | 206 | EXPECT_EMPTY_REPORT(driver); |
| 207 | mod_tap_hold_key.release(); | 207 | mod_tap_hold_key.release(); |
| 208 | run_one_scan_loop(); | 208 | run_one_scan_loop(); |
| 209 | testing::Mock::VerifyAndClearExpectations(&driver); | 209 | testing::Mock::VerifyAndClearExpectations(&driver); |
| @@ -217,14 +217,14 @@ TEST_F(DefaultTapHold, tap_and_hold_mod_tap_hold_key) { | |||
| 217 | set_keymap({mod_tap_hold_key}); | 217 | set_keymap({mod_tap_hold_key}); |
| 218 | 218 | ||
| 219 | /* Press mod-tap-hold key. */ | 219 | /* Press mod-tap-hold key. */ |
| 220 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSHIFT))); | 220 | EXPECT_REPORT(driver, (KC_LSHIFT)); |
| 221 | mod_tap_hold_key.press(); | 221 | mod_tap_hold_key.press(); |
| 222 | idle_for(TAPPING_TERM + 1); | 222 | idle_for(TAPPING_TERM + 1); |
| 223 | testing::Mock::VerifyAndClearExpectations(&driver); | 223 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 224 | 224 | ||
| 225 | /* Release mod-tap-hold key. */ | 225 | /* Release mod-tap-hold key. */ |
| 226 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())); | 226 | EXPECT_EMPTY_REPORT(driver); |
| 227 | mod_tap_hold_key.release(); | 227 | mod_tap_hold_key.release(); |
| 228 | run_one_scan_loop(); | 228 | run_one_scan_loop(); |
| 229 | testing::Mock::VerifyAndClearExpectations(&driver); | 229 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 230 | } \ No newline at end of file | 230 | } |
diff --git a/tests/tap_hold_configurations/ignore_mod_tap_interrupt/test_tap_hold.cpp b/tests/tap_hold_configurations/ignore_mod_tap_interrupt/test_tap_hold.cpp index 1702d604d3..5ece124c1d 100644 --- a/tests/tap_hold_configurations/ignore_mod_tap_interrupt/test_tap_hold.cpp +++ b/tests/tap_hold_configurations/ignore_mod_tap_interrupt/test_tap_hold.cpp | |||
| @@ -35,19 +35,19 @@ TEST_F(IgnoreModTapInterrupt, tap_regular_key_while_mod_tap_key_is_held) { | |||
| 35 | set_keymap({mod_tap_hold_key, regular_key}); | 35 | set_keymap({mod_tap_hold_key, regular_key}); |
| 36 | 36 | ||
| 37 | /* Press mod-tap-hold key */ | 37 | /* Press mod-tap-hold key */ |
| 38 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 38 | EXPECT_NO_REPORT(driver); |
| 39 | mod_tap_hold_key.press(); | 39 | mod_tap_hold_key.press(); |
| 40 | run_one_scan_loop(); | 40 | run_one_scan_loop(); |
| 41 | testing::Mock::VerifyAndClearExpectations(&driver); | 41 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 42 | 42 | ||
| 43 | /* Press regular key */ | 43 | /* Press regular key */ |
| 44 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 44 | EXPECT_NO_REPORT(driver); |
| 45 | regular_key.press(); | 45 | regular_key.press(); |
| 46 | run_one_scan_loop(); | 46 | run_one_scan_loop(); |
| 47 | testing::Mock::VerifyAndClearExpectations(&driver); | 47 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 48 | 48 | ||
| 49 | /* Release regular key */ | 49 | /* Release regular key */ |
| 50 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 50 | EXPECT_NO_REPORT(driver); |
| 51 | regular_key.release(); | 51 | regular_key.release(); |
| 52 | run_one_scan_loop(); | 52 | run_one_scan_loop(); |
| 53 | testing::Mock::VerifyAndClearExpectations(&driver); | 53 | testing::Mock::VerifyAndClearExpectations(&driver); |
| @@ -71,19 +71,19 @@ TEST_F(IgnoreModTapInterrupt, tap_mod_tap_key_while_mod_tap_key_is_held) { | |||
| 71 | set_keymap({first_mod_tap_hold_key, second_mod_tap_hold_key}); | 71 | set_keymap({first_mod_tap_hold_key, second_mod_tap_hold_key}); |
| 72 | 72 | ||
| 73 | /* Press first mod-tap-hold key */ | 73 | /* Press first mod-tap-hold key */ |
| 74 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 74 | EXPECT_NO_REPORT(driver); |
| 75 | first_mod_tap_hold_key.press(); | 75 | first_mod_tap_hold_key.press(); |
| 76 | run_one_scan_loop(); | 76 | run_one_scan_loop(); |
| 77 | testing::Mock::VerifyAndClearExpectations(&driver); | 77 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 78 | 78 | ||
| 79 | /* Press second tap-hold key */ | 79 | /* Press second tap-hold key */ |
| 80 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 80 | EXPECT_NO_REPORT(driver); |
| 81 | second_mod_tap_hold_key.press(); | 81 | second_mod_tap_hold_key.press(); |
| 82 | run_one_scan_loop(); | 82 | run_one_scan_loop(); |
| 83 | testing::Mock::VerifyAndClearExpectations(&driver); | 83 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 84 | 84 | ||
| 85 | /* Release second tap-hold key */ | 85 | /* Release second tap-hold key */ |
| 86 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 86 | EXPECT_NO_REPORT(driver); |
| 87 | second_mod_tap_hold_key.release(); | 87 | second_mod_tap_hold_key.release(); |
| 88 | run_one_scan_loop(); | 88 | run_one_scan_loop(); |
| 89 | testing::Mock::VerifyAndClearExpectations(&driver); | 89 | testing::Mock::VerifyAndClearExpectations(&driver); |
| @@ -108,19 +108,19 @@ TEST_F(IgnoreModTapInterrupt, tap_regular_key_while_layer_tap_key_is_held) { | |||
| 108 | set_keymap({layer_tap_hold_key, regular_key, layer_key}); | 108 | set_keymap({layer_tap_hold_key, regular_key, layer_key}); |
| 109 | 109 | ||
| 110 | /* Press layer-tap-hold key */ | 110 | /* Press layer-tap-hold key */ |
| 111 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 111 | EXPECT_NO_REPORT(driver); |
| 112 | layer_tap_hold_key.press(); | 112 | layer_tap_hold_key.press(); |
| 113 | run_one_scan_loop(); | 113 | run_one_scan_loop(); |
| 114 | testing::Mock::VerifyAndClearExpectations(&driver); | 114 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 115 | 115 | ||
| 116 | /* Press regular key */ | 116 | /* Press regular key */ |
| 117 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 117 | EXPECT_NO_REPORT(driver); |
| 118 | regular_key.press(); | 118 | regular_key.press(); |
| 119 | run_one_scan_loop(); | 119 | run_one_scan_loop(); |
| 120 | testing::Mock::VerifyAndClearExpectations(&driver); | 120 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 121 | 121 | ||
| 122 | /* Release regular key */ | 122 | /* Release regular key */ |
| 123 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 123 | EXPECT_NO_REPORT(driver); |
| 124 | regular_key.release(); | 124 | regular_key.release(); |
| 125 | run_one_scan_loop(); | 125 | run_one_scan_loop(); |
| 126 | testing::Mock::VerifyAndClearExpectations(&driver); | 126 | testing::Mock::VerifyAndClearExpectations(&driver); |
diff --git a/tests/tap_hold_configurations/permissive_hold/test_one_shot_keys.cpp b/tests/tap_hold_configurations/permissive_hold/test_one_shot_keys.cpp index aa71ec397f..64a6ff58e6 100644 --- a/tests/tap_hold_configurations/permissive_hold/test_one_shot_keys.cpp +++ b/tests/tap_hold_configurations/permissive_hold/test_one_shot_keys.cpp | |||
| @@ -32,13 +32,13 @@ TEST_P(OneShotParametrizedTestFixture, OSMAsRegularModifierWithAdditionalKeypres | |||
| 32 | set_keymap({osm_key, regular_key}); | 32 | set_keymap({osm_key, regular_key}); |
| 33 | 33 | ||
| 34 | /* Press OSM */ | 34 | /* Press OSM */ |
| 35 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 35 | EXPECT_NO_REPORT(driver); |
| 36 | osm_key.press(); | 36 | osm_key.press(); |
| 37 | run_one_scan_loop(); | 37 | run_one_scan_loop(); |
| 38 | testing::Mock::VerifyAndClearExpectations(&driver); | 38 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 39 | 39 | ||
| 40 | /* Press regular key */ | 40 | /* Press regular key */ |
| 41 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 41 | EXPECT_NO_REPORT(driver); |
| 42 | regular_key.press(); | 42 | regular_key.press(); |
| 43 | run_one_scan_loop(); | 43 | run_one_scan_loop(); |
| 44 | testing::Mock::VerifyAndClearExpectations(&driver); | 44 | testing::Mock::VerifyAndClearExpectations(&driver); |
| @@ -73,4 +73,4 @@ INSTANTIATE_TEST_CASE_P( | |||
| 73 | std::make_pair(KeymapKey{0, 0, 0, OSM(MOD_RALT), KC_RALT}, KeymapKey{0, 1, 1, KC_A}), | 73 | std::make_pair(KeymapKey{0, 0, 0, OSM(MOD_RALT), KC_RALT}, KeymapKey{0, 1, 1, KC_A}), |
| 74 | std::make_pair(KeymapKey{0, 0, 0, OSM(MOD_RGUI), KC_RGUI}, KeymapKey{0, 1, 1, KC_A}) | 74 | std::make_pair(KeymapKey{0, 0, 0, OSM(MOD_RGUI), KC_RGUI}, KeymapKey{0, 1, 1, KC_A}) |
| 75 | )); | 75 | )); |
| 76 | // clang-format on \ No newline at end of file | 76 | // clang-format on |
diff --git a/tests/tap_hold_configurations/permissive_hold/test_tap_hold.cpp b/tests/tap_hold_configurations/permissive_hold/test_tap_hold.cpp index 00c2b33cb7..28fb17ca66 100644 --- a/tests/tap_hold_configurations/permissive_hold/test_tap_hold.cpp +++ b/tests/tap_hold_configurations/permissive_hold/test_tap_hold.cpp | |||
| @@ -34,13 +34,13 @@ TEST_F(PermissiveHold, tap_regular_key_while_mod_tap_key_is_held) { | |||
| 34 | set_keymap({mod_tap_hold_key, regular_key}); | 34 | set_keymap({mod_tap_hold_key, regular_key}); |
| 35 | 35 | ||
| 36 | /* Press mod-tap-hold key */ | 36 | /* Press mod-tap-hold key */ |
| 37 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 37 | EXPECT_NO_REPORT(driver); |
| 38 | mod_tap_hold_key.press(); | 38 | mod_tap_hold_key.press(); |
| 39 | run_one_scan_loop(); | 39 | run_one_scan_loop(); |
| 40 | testing::Mock::VerifyAndClearExpectations(&driver); | 40 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 41 | 41 | ||
| 42 | /* Press regular key */ | 42 | /* Press regular key */ |
| 43 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 43 | EXPECT_NO_REPORT(driver); |
| 44 | regular_key.press(); | 44 | regular_key.press(); |
| 45 | run_one_scan_loop(); | 45 | run_one_scan_loop(); |
| 46 | testing::Mock::VerifyAndClearExpectations(&driver); | 46 | testing::Mock::VerifyAndClearExpectations(&driver); |
| @@ -69,13 +69,13 @@ TEST_F(PermissiveHold, tap_mod_tap_key_while_mod_tap_key_is_held) { | |||
| 69 | set_keymap({first_mod_tap_hold_key, second_mod_tap_hold_key}); | 69 | set_keymap({first_mod_tap_hold_key, second_mod_tap_hold_key}); |
| 70 | 70 | ||
| 71 | /* Press first mod-tap-hold key */ | 71 | /* Press first mod-tap-hold key */ |
| 72 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 72 | EXPECT_NO_REPORT(driver); |
| 73 | first_mod_tap_hold_key.press(); | 73 | first_mod_tap_hold_key.press(); |
| 74 | run_one_scan_loop(); | 74 | run_one_scan_loop(); |
| 75 | testing::Mock::VerifyAndClearExpectations(&driver); | 75 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 76 | 76 | ||
| 77 | /* Press second mod-tap-hold key */ | 77 | /* Press second mod-tap-hold key */ |
| 78 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 78 | EXPECT_NO_REPORT(driver); |
| 79 | second_mod_tap_hold_key.press(); | 79 | second_mod_tap_hold_key.press(); |
| 80 | run_one_scan_loop(); | 80 | run_one_scan_loop(); |
| 81 | testing::Mock::VerifyAndClearExpectations(&driver); | 81 | testing::Mock::VerifyAndClearExpectations(&driver); |
| @@ -105,13 +105,13 @@ TEST_F(PermissiveHold, tap_regular_key_while_layer_tap_key_is_held) { | |||
| 105 | set_keymap({layer_tap_hold_key, regular_key, layer_key}); | 105 | set_keymap({layer_tap_hold_key, regular_key, layer_key}); |
| 106 | 106 | ||
| 107 | /* Press layer-tap-hold key */ | 107 | /* Press layer-tap-hold key */ |
| 108 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 108 | EXPECT_NO_REPORT(driver); |
| 109 | layer_tap_hold_key.press(); | 109 | layer_tap_hold_key.press(); |
| 110 | run_one_scan_loop(); | 110 | run_one_scan_loop(); |
| 111 | testing::Mock::VerifyAndClearExpectations(&driver); | 111 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 112 | 112 | ||
| 113 | /* Press regular key */ | 113 | /* Press regular key */ |
| 114 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 114 | EXPECT_NO_REPORT(driver); |
| 115 | regular_key.press(); | 115 | regular_key.press(); |
| 116 | run_one_scan_loop(); | 116 | run_one_scan_loop(); |
| 117 | testing::Mock::VerifyAndClearExpectations(&driver); | 117 | testing::Mock::VerifyAndClearExpectations(&driver); |
| @@ -124,8 +124,8 @@ TEST_F(PermissiveHold, tap_regular_key_while_layer_tap_key_is_held) { | |||
| 124 | testing::Mock::VerifyAndClearExpectations(&driver); | 124 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 125 | 125 | ||
| 126 | /* Release layer-tap-hold key */ | 126 | /* Release layer-tap-hold key */ |
| 127 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 127 | EXPECT_NO_REPORT(driver); |
| 128 | layer_tap_hold_key.release(); | 128 | layer_tap_hold_key.release(); |
| 129 | run_one_scan_loop(); | 129 | run_one_scan_loop(); |
| 130 | testing::Mock::VerifyAndClearExpectations(&driver); | 130 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 131 | } \ No newline at end of file | 131 | } |
diff --git a/tests/tap_hold_configurations/permissive_hold_ignore_mod_tap_interrupt/test_tap_hold.cpp b/tests/tap_hold_configurations/permissive_hold_ignore_mod_tap_interrupt/test_tap_hold.cpp index 67706f80dc..f2d576e875 100644 --- a/tests/tap_hold_configurations/permissive_hold_ignore_mod_tap_interrupt/test_tap_hold.cpp +++ b/tests/tap_hold_configurations/permissive_hold_ignore_mod_tap_interrupt/test_tap_hold.cpp | |||
| @@ -36,13 +36,13 @@ TEST_F(PermissiveHold_IgnoreModTapInterrupt, tap_regular_key_while_mod_tap_key_i | |||
| 36 | set_keymap({mod_tap_hold_key, regular_key}); | 36 | set_keymap({mod_tap_hold_key, regular_key}); |
| 37 | 37 | ||
| 38 | /* Press mod-tap-hold key */ | 38 | /* Press mod-tap-hold key */ |
| 39 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 39 | EXPECT_NO_REPORT(driver); |
| 40 | mod_tap_hold_key.press(); | 40 | mod_tap_hold_key.press(); |
| 41 | run_one_scan_loop(); | 41 | run_one_scan_loop(); |
| 42 | testing::Mock::VerifyAndClearExpectations(&driver); | 42 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 43 | 43 | ||
| 44 | /* Press regular key */ | 44 | /* Press regular key */ |
| 45 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 45 | EXPECT_NO_REPORT(driver); |
| 46 | regular_key.press(); | 46 | regular_key.press(); |
| 47 | run_one_scan_loop(); | 47 | run_one_scan_loop(); |
| 48 | testing::Mock::VerifyAndClearExpectations(&driver); | 48 | testing::Mock::VerifyAndClearExpectations(&driver); |
| @@ -71,13 +71,13 @@ TEST_F(PermissiveHold_IgnoreModTapInterrupt, tap_mod_tap_key_while_mod_tap_key_i | |||
| 71 | set_keymap({first_mod_tap_hold_key, second_mod_tap_hold_key}); | 71 | set_keymap({first_mod_tap_hold_key, second_mod_tap_hold_key}); |
| 72 | 72 | ||
| 73 | /* Press first mod-tap-hold key */ | 73 | /* Press first mod-tap-hold key */ |
| 74 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 74 | EXPECT_NO_REPORT(driver); |
| 75 | first_mod_tap_hold_key.press(); | 75 | first_mod_tap_hold_key.press(); |
| 76 | run_one_scan_loop(); | 76 | run_one_scan_loop(); |
| 77 | testing::Mock::VerifyAndClearExpectations(&driver); | 77 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 78 | 78 | ||
| 79 | /* Press second tap-hold key */ | 79 | /* Press second tap-hold key */ |
| 80 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 80 | EXPECT_NO_REPORT(driver); |
| 81 | second_mod_tap_hold_key.press(); | 81 | second_mod_tap_hold_key.press(); |
| 82 | run_one_scan_loop(); | 82 | run_one_scan_loop(); |
| 83 | testing::Mock::VerifyAndClearExpectations(&driver); | 83 | testing::Mock::VerifyAndClearExpectations(&driver); |
| @@ -107,13 +107,13 @@ TEST_F(PermissiveHold_IgnoreModTapInterrupt, tap_regular_key_while_layer_tap_key | |||
| 107 | set_keymap({layer_tap_hold_key, regular_key, layer_key}); | 107 | set_keymap({layer_tap_hold_key, regular_key, layer_key}); |
| 108 | 108 | ||
| 109 | /* Press layer-tap-hold key */ | 109 | /* Press layer-tap-hold key */ |
| 110 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 110 | EXPECT_NO_REPORT(driver); |
| 111 | layer_tap_hold_key.press(); | 111 | layer_tap_hold_key.press(); |
| 112 | run_one_scan_loop(); | 112 | run_one_scan_loop(); |
| 113 | testing::Mock::VerifyAndClearExpectations(&driver); | 113 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 114 | 114 | ||
| 115 | /* Press regular key */ | 115 | /* Press regular key */ |
| 116 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 116 | EXPECT_NO_REPORT(driver); |
| 117 | regular_key.press(); | 117 | regular_key.press(); |
| 118 | run_one_scan_loop(); | 118 | run_one_scan_loop(); |
| 119 | testing::Mock::VerifyAndClearExpectations(&driver); | 119 | testing::Mock::VerifyAndClearExpectations(&driver); |
| @@ -126,8 +126,8 @@ TEST_F(PermissiveHold_IgnoreModTapInterrupt, tap_regular_key_while_layer_tap_key | |||
| 126 | testing::Mock::VerifyAndClearExpectations(&driver); | 126 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 127 | 127 | ||
| 128 | /* Release layer-tap-hold key */ | 128 | /* Release layer-tap-hold key */ |
| 129 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 129 | EXPECT_NO_REPORT(driver); |
| 130 | layer_tap_hold_key.release(); | 130 | layer_tap_hold_key.release(); |
| 131 | run_one_scan_loop(); | 131 | run_one_scan_loop(); |
| 132 | testing::Mock::VerifyAndClearExpectations(&driver); | 132 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 133 | } \ No newline at end of file | 133 | } |
diff --git a/tests/tap_hold_configurations/retro_tapping/test_tap_hold.cpp b/tests/tap_hold_configurations/retro_tapping/test_tap_hold.cpp index 59ae77f781..b3d4e520f6 100644 --- a/tests/tap_hold_configurations/retro_tapping/test_tap_hold.cpp +++ b/tests/tap_hold_configurations/retro_tapping/test_tap_hold.cpp | |||
| @@ -35,7 +35,7 @@ TEST_F(RetroTapping, tap_and_hold_mod_tap_hold_key) { | |||
| 35 | set_keymap({mod_tap_hold_key}); | 35 | set_keymap({mod_tap_hold_key}); |
| 36 | 36 | ||
| 37 | /* Press mod-tap-hold key. */ | 37 | /* Press mod-tap-hold key. */ |
| 38 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 38 | EXPECT_NO_REPORT(driver); |
| 39 | mod_tap_hold_key.press(); | 39 | mod_tap_hold_key.press(); |
| 40 | idle_for(TAPPING_TERM); | 40 | idle_for(TAPPING_TERM); |
| 41 | testing::Mock::VerifyAndClearExpectations(&driver); | 41 | testing::Mock::VerifyAndClearExpectations(&driver); |
| @@ -49,4 +49,4 @@ TEST_F(RetroTapping, tap_and_hold_mod_tap_hold_key) { | |||
| 49 | mod_tap_hold_key.release(); | 49 | mod_tap_hold_key.release(); |
| 50 | run_one_scan_loop(); | 50 | run_one_scan_loop(); |
| 51 | testing::Mock::VerifyAndClearExpectations(&driver); | 51 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 52 | } \ No newline at end of file | 52 | } |
diff --git a/tests/tap_hold_configurations/retro_tapping/test_tapping.cpp b/tests/tap_hold_configurations/retro_tapping/test_tapping.cpp index cf23df8317..cd73f1e784 100644 --- a/tests/tap_hold_configurations/retro_tapping/test_tapping.cpp +++ b/tests/tap_hold_configurations/retro_tapping/test_tapping.cpp | |||
| @@ -32,7 +32,7 @@ TEST_F(Tapping, HoldA_SHFT_T_KeyReportsShift) { | |||
| 32 | 32 | ||
| 33 | set_keymap({mod_tap_hold_key}); | 33 | set_keymap({mod_tap_hold_key}); |
| 34 | 34 | ||
| 35 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 35 | EXPECT_NO_REPORT(driver); |
| 36 | mod_tap_hold_key.press(); | 36 | mod_tap_hold_key.press(); |
| 37 | idle_for(TAPPING_TERM); | 37 | idle_for(TAPPING_TERM); |
| 38 | testing::Mock::VerifyAndClearExpectations(&driver); | 38 | testing::Mock::VerifyAndClearExpectations(&driver); |
| @@ -57,7 +57,7 @@ TEST_F(Tapping, ANewTapWithinTappingTermIsBuggy) { | |||
| 57 | set_keymap({key_shift_hold_p_tap}); | 57 | set_keymap({key_shift_hold_p_tap}); |
| 58 | 58 | ||
| 59 | /* Press mod_tap_hold key */ | 59 | /* Press mod_tap_hold key */ |
| 60 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 60 | EXPECT_NO_REPORT(driver); |
| 61 | key_shift_hold_p_tap.press(); | 61 | key_shift_hold_p_tap.press(); |
| 62 | run_one_scan_loop(); | 62 | run_one_scan_loop(); |
| 63 | testing::Mock::VerifyAndClearExpectations(&driver); | 63 | testing::Mock::VerifyAndClearExpectations(&driver); |
| @@ -82,7 +82,7 @@ TEST_F(Tapping, ANewTapWithinTappingTermIsBuggy) { | |||
| 82 | testing::Mock::VerifyAndClearExpectations(&driver); | 82 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 83 | 83 | ||
| 84 | /* Press mod_tap_hold key again */ | 84 | /* Press mod_tap_hold key again */ |
| 85 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 85 | EXPECT_NO_REPORT(driver); |
| 86 | key_shift_hold_p_tap.press(); | 86 | key_shift_hold_p_tap.press(); |
| 87 | run_one_scan_loop(); | 87 | run_one_scan_loop(); |
| 88 | testing::Mock::VerifyAndClearExpectations(&driver); | 88 | testing::Mock::VerifyAndClearExpectations(&driver); |
| @@ -95,7 +95,7 @@ TEST_F(Tapping, ANewTapWithinTappingTermIsBuggy) { | |||
| 95 | testing::Mock::VerifyAndClearExpectations(&driver); | 95 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 96 | 96 | ||
| 97 | /* Press mod_tap_hold key again */ | 97 | /* Press mod_tap_hold key again */ |
| 98 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 98 | EXPECT_NO_REPORT(driver); |
| 99 | key_shift_hold_p_tap.press(); | 99 | key_shift_hold_p_tap.press(); |
| 100 | idle_for(TAPPING_TERM); | 100 | idle_for(TAPPING_TERM); |
| 101 | testing::Mock::VerifyAndClearExpectations(&driver); | 101 | testing::Mock::VerifyAndClearExpectations(&driver); |
| @@ -109,4 +109,4 @@ TEST_F(Tapping, ANewTapWithinTappingTermIsBuggy) { | |||
| 109 | key_shift_hold_p_tap.release(); | 109 | key_shift_hold_p_tap.release(); |
| 110 | run_one_scan_loop(); | 110 | run_one_scan_loop(); |
| 111 | testing::Mock::VerifyAndClearExpectations(&driver); | 111 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 112 | } \ No newline at end of file | 112 | } |
diff --git a/tests/tap_hold_configurations/tapping_force_hold/test_action_layer.cpp b/tests/tap_hold_configurations/tapping_force_hold/test_action_layer.cpp index 54e7daa22c..a67c6629e0 100644 --- a/tests/tap_hold_configurations/tapping_force_hold/test_action_layer.cpp +++ b/tests/tap_hold_configurations/tapping_force_hold/test_action_layer.cpp | |||
| @@ -32,7 +32,7 @@ TEST_F(ActionLayer, LayerTapToggleWithToggleWithKeypress) { | |||
| 32 | 32 | ||
| 33 | /* Tap TT five times . */ | 33 | /* Tap TT five times . */ |
| 34 | /* TODO: Tapping Force Hold breaks TT */ | 34 | /* TODO: Tapping Force Hold breaks TT */ |
| 35 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 35 | EXPECT_NO_REPORT(driver); |
| 36 | 36 | ||
| 37 | layer_key.press(); | 37 | layer_key.press(); |
| 38 | run_one_scan_loop(); | 38 | run_one_scan_loop(); |
| @@ -77,4 +77,4 @@ TEST_F(ActionLayer, LayerTapToggleWithToggleWithKeypress) { | |||
| 77 | run_one_scan_loop(); | 77 | run_one_scan_loop(); |
| 78 | expect_layer_state(0); | 78 | expect_layer_state(0); |
| 79 | testing::Mock::VerifyAndClearExpectations(&driver); | 79 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 80 | } \ No newline at end of file | 80 | } |
diff --git a/tests/tap_hold_configurations/tapping_force_hold/test_tap_hold.cpp b/tests/tap_hold_configurations/tapping_force_hold/test_tap_hold.cpp index 3ae7c4ccfd..04e66a02d9 100644 --- a/tests/tap_hold_configurations/tapping_force_hold/test_tap_hold.cpp +++ b/tests/tap_hold_configurations/tapping_force_hold/test_tap_hold.cpp | |||
| @@ -36,19 +36,19 @@ TEST_F(TappingForceHold, tap_regular_key_while_mod_tap_key_is_held) { | |||
| 36 | set_keymap({mod_tap_hold_key, regular_key}); | 36 | set_keymap({mod_tap_hold_key, regular_key}); |
| 37 | 37 | ||
| 38 | /* Press mod-tap-hold key. */ | 38 | /* Press mod-tap-hold key. */ |
| 39 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 39 | EXPECT_NO_REPORT(driver); |
| 40 | mod_tap_hold_key.press(); | 40 | mod_tap_hold_key.press(); |
| 41 | run_one_scan_loop(); | 41 | run_one_scan_loop(); |
| 42 | testing::Mock::VerifyAndClearExpectations(&driver); | 42 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 43 | 43 | ||
| 44 | /* Press regular key. */ | 44 | /* Press regular key. */ |
| 45 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 45 | EXPECT_NO_REPORT(driver); |
| 46 | regular_key.press(); | 46 | regular_key.press(); |
| 47 | run_one_scan_loop(); | 47 | run_one_scan_loop(); |
| 48 | testing::Mock::VerifyAndClearExpectations(&driver); | 48 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 49 | 49 | ||
| 50 | /* Release regular key. */ | 50 | /* Release regular key. */ |
| 51 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 51 | EXPECT_NO_REPORT(driver); |
| 52 | regular_key.release(); | 52 | regular_key.release(); |
| 53 | run_one_scan_loop(); | 53 | run_one_scan_loop(); |
| 54 | testing::Mock::VerifyAndClearExpectations(&driver); | 54 | testing::Mock::VerifyAndClearExpectations(&driver); |
| @@ -76,19 +76,19 @@ TEST_F(TappingForceHold, tap_mod_tap_key_while_mod_tap_key_is_held) { | |||
| 76 | set_keymap({first_mod_tap_hold_key, second_mod_tap_hold_key}); | 76 | set_keymap({first_mod_tap_hold_key, second_mod_tap_hold_key}); |
| 77 | 77 | ||
| 78 | /* Press first mod-tap-hold key */ | 78 | /* Press first mod-tap-hold key */ |
| 79 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 79 | EXPECT_NO_REPORT(driver); |
| 80 | first_mod_tap_hold_key.press(); | 80 | first_mod_tap_hold_key.press(); |
| 81 | run_one_scan_loop(); | 81 | run_one_scan_loop(); |
| 82 | testing::Mock::VerifyAndClearExpectations(&driver); | 82 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 83 | 83 | ||
| 84 | /* Press second tap-hold key */ | 84 | /* Press second tap-hold key */ |
| 85 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 85 | EXPECT_NO_REPORT(driver); |
| 86 | second_mod_tap_hold_key.press(); | 86 | second_mod_tap_hold_key.press(); |
| 87 | run_one_scan_loop(); | 87 | run_one_scan_loop(); |
| 88 | testing::Mock::VerifyAndClearExpectations(&driver); | 88 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 89 | 89 | ||
| 90 | /* Release second tap-hold key */ | 90 | /* Release second tap-hold key */ |
| 91 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 91 | EXPECT_NO_REPORT(driver); |
| 92 | second_mod_tap_hold_key.release(); | 92 | second_mod_tap_hold_key.release(); |
| 93 | run_one_scan_loop(); | 93 | run_one_scan_loop(); |
| 94 | testing::Mock::VerifyAndClearExpectations(&driver); | 94 | testing::Mock::VerifyAndClearExpectations(&driver); |
| @@ -117,19 +117,19 @@ TEST_F(TappingForceHold, tap_regular_key_while_layer_tap_key_is_held) { | |||
| 117 | set_keymap({layer_tap_hold_key, regular_key, layer_key}); | 117 | set_keymap({layer_tap_hold_key, regular_key, layer_key}); |
| 118 | 118 | ||
| 119 | /* Press layer-tap-hold key */ | 119 | /* Press layer-tap-hold key */ |
| 120 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 120 | EXPECT_NO_REPORT(driver); |
| 121 | layer_tap_hold_key.press(); | 121 | layer_tap_hold_key.press(); |
| 122 | run_one_scan_loop(); | 122 | run_one_scan_loop(); |
| 123 | testing::Mock::VerifyAndClearExpectations(&driver); | 123 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 124 | 124 | ||
| 125 | /* Press regular key */ | 125 | /* Press regular key */ |
| 126 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 126 | EXPECT_NO_REPORT(driver); |
| 127 | regular_key.press(); | 127 | regular_key.press(); |
| 128 | run_one_scan_loop(); | 128 | run_one_scan_loop(); |
| 129 | testing::Mock::VerifyAndClearExpectations(&driver); | 129 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 130 | 130 | ||
| 131 | /* Release regular key */ | 131 | /* Release regular key */ |
| 132 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 132 | EXPECT_NO_REPORT(driver); |
| 133 | regular_key.release(); | 133 | regular_key.release(); |
| 134 | run_one_scan_loop(); | 134 | run_one_scan_loop(); |
| 135 | testing::Mock::VerifyAndClearExpectations(&driver); | 135 | testing::Mock::VerifyAndClearExpectations(&driver); |
| @@ -152,7 +152,7 @@ TEST_F(TappingForceHold, tap_mod_tap_hold_key_two_times) { | |||
| 152 | set_keymap({mod_tap_hold_key}); | 152 | set_keymap({mod_tap_hold_key}); |
| 153 | 153 | ||
| 154 | /* Press mod-tap-hold key. */ | 154 | /* Press mod-tap-hold key. */ |
| 155 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 155 | EXPECT_NO_REPORT(driver); |
| 156 | mod_tap_hold_key.press(); | 156 | mod_tap_hold_key.press(); |
| 157 | run_one_scan_loop(); | 157 | run_one_scan_loop(); |
| 158 | testing::Mock::VerifyAndClearExpectations(&driver); | 158 | testing::Mock::VerifyAndClearExpectations(&driver); |
| @@ -165,7 +165,7 @@ TEST_F(TappingForceHold, tap_mod_tap_hold_key_two_times) { | |||
| 165 | testing::Mock::VerifyAndClearExpectations(&driver); | 165 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 166 | 166 | ||
| 167 | /* Press mod-tap-hold key again. */ | 167 | /* Press mod-tap-hold key again. */ |
| 168 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 168 | EXPECT_NO_REPORT(driver); |
| 169 | mod_tap_hold_key.press(); | 169 | mod_tap_hold_key.press(); |
| 170 | run_one_scan_loop(); | 170 | run_one_scan_loop(); |
| 171 | testing::Mock::VerifyAndClearExpectations(&driver); | 171 | testing::Mock::VerifyAndClearExpectations(&driver); |
| @@ -186,7 +186,7 @@ TEST_F(TappingForceHold, tap_mod_tap_hold_key_twice_and_hold_on_second_time) { | |||
| 186 | set_keymap({mod_tap_hold_key}); | 186 | set_keymap({mod_tap_hold_key}); |
| 187 | 187 | ||
| 188 | /* Press mod-tap-hold key. */ | 188 | /* Press mod-tap-hold key. */ |
| 189 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 189 | EXPECT_NO_REPORT(driver); |
| 190 | mod_tap_hold_key.press(); | 190 | mod_tap_hold_key.press(); |
| 191 | run_one_scan_loop(); | 191 | run_one_scan_loop(); |
| 192 | testing::Mock::VerifyAndClearExpectations(&driver); | 192 | testing::Mock::VerifyAndClearExpectations(&driver); |
| @@ -199,7 +199,7 @@ TEST_F(TappingForceHold, tap_mod_tap_hold_key_twice_and_hold_on_second_time) { | |||
| 199 | testing::Mock::VerifyAndClearExpectations(&driver); | 199 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 200 | 200 | ||
| 201 | /* Press mod-tap-hold key again. */ | 201 | /* Press mod-tap-hold key again. */ |
| 202 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 202 | EXPECT_NO_REPORT(driver); |
| 203 | mod_tap_hold_key.press(); | 203 | mod_tap_hold_key.press(); |
| 204 | idle_for(TAPPING_TERM); | 204 | idle_for(TAPPING_TERM); |
| 205 | testing::Mock::VerifyAndClearExpectations(&driver); | 205 | testing::Mock::VerifyAndClearExpectations(&driver); |
diff --git a/tests/test_common/test_driver.cpp b/tests/test_common/test_driver.cpp index 68f1dfd17d..86644ab6bd 100644 --- a/tests/test_common/test_driver.cpp +++ b/tests/test_common/test_driver.cpp | |||
| @@ -18,6 +18,19 @@ | |||
| 18 | 18 | ||
| 19 | TestDriver* TestDriver::m_this = nullptr; | 19 | TestDriver* TestDriver::m_this = nullptr; |
| 20 | 20 | ||
| 21 | namespace { | ||
| 22 | // Given a hex digit between 0 and 15, returns the corresponding keycode. | ||
| 23 | uint8_t hex_digit_to_keycode(uint8_t digit) { | ||
| 24 | // clang-format off | ||
| 25 | static const uint8_t hex_keycodes[] = { | ||
| 26 | KC_0, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, | ||
| 27 | KC_8, KC_9, KC_A, KC_B, KC_C, KC_D, KC_E, KC_F | ||
| 28 | }; | ||
| 29 | // clang-format on | ||
| 30 | return hex_keycodes[digit]; | ||
| 31 | } | ||
| 32 | } // namespace | ||
| 33 | |||
| 21 | TestDriver::TestDriver() : m_driver{&TestDriver::keyboard_leds, &TestDriver::send_keyboard, &TestDriver::send_mouse, &TestDriver::send_system, &TestDriver::send_consumer} { | 34 | TestDriver::TestDriver() : m_driver{&TestDriver::keyboard_leds, &TestDriver::send_keyboard, &TestDriver::send_mouse, &TestDriver::send_system, &TestDriver::send_consumer} { |
| 22 | host_set_driver(&m_driver); | 35 | host_set_driver(&m_driver); |
| 23 | m_this = this; | 36 | m_this = this; |
| @@ -47,3 +60,25 @@ void TestDriver::send_system(uint16_t data) { | |||
| 47 | void TestDriver::send_consumer(uint16_t data) { | 60 | void TestDriver::send_consumer(uint16_t data) { |
| 48 | m_this->send_consumer(data); | 61 | m_this->send_consumer(data); |
| 49 | } | 62 | } |
| 63 | |||
| 64 | namespace internal { | ||
| 65 | void expect_unicode_code_point(TestDriver& driver, uint32_t code_point) { | ||
| 66 | testing::InSequence seq; | ||
| 67 | EXPECT_REPORT(driver, (KC_LCTL, KC_LSFT, KC_U)); | ||
| 68 | |||
| 69 | bool print_zero = false; | ||
| 70 | for (int i = 7; i >= 0; --i) { | ||
| 71 | if (i <= 3) { | ||
| 72 | print_zero = true; | ||
| 73 | } | ||
| 74 | |||
| 75 | const uint8_t digit = (code_point >> (i * 4)) & 0xf; | ||
| 76 | if (digit || print_zero) { | ||
| 77 | EXPECT_REPORT(driver, (hex_digit_to_keycode(digit))); | ||
| 78 | print_zero = true; | ||
| 79 | } | ||
| 80 | } | ||
| 81 | |||
| 82 | EXPECT_REPORT(driver, (KC_SPC)); | ||
| 83 | } | ||
| 84 | } // namespace internal | ||
diff --git a/tests/test_common/test_driver.hpp b/tests/test_common/test_driver.hpp index f9197b3634..b58cfd1ebc 100644 --- a/tests/test_common/test_driver.hpp +++ b/tests/test_common/test_driver.hpp | |||
| @@ -26,7 +26,9 @@ class TestDriver { | |||
| 26 | public: | 26 | public: |
| 27 | TestDriver(); | 27 | TestDriver(); |
| 28 | ~TestDriver(); | 28 | ~TestDriver(); |
| 29 | void set_leds(uint8_t leds) { m_leds = leds; } | 29 | void set_leds(uint8_t leds) { |
| 30 | m_leds = leds; | ||
| 31 | } | ||
| 30 | 32 | ||
| 31 | MOCK_METHOD1(send_keyboard_mock, void(report_keyboard_t&)); | 33 | MOCK_METHOD1(send_keyboard_mock, void(report_keyboard_t&)); |
| 32 | MOCK_METHOD1(send_mouse_mock, void(report_mouse_t&)); | 34 | MOCK_METHOD1(send_mouse_mock, void(report_mouse_t&)); |
| @@ -43,3 +45,61 @@ class TestDriver { | |||
| 43 | uint8_t m_leds = 0; | 45 | uint8_t m_leds = 0; |
| 44 | static TestDriver* m_this; | 46 | static TestDriver* m_this; |
| 45 | }; | 47 | }; |
| 48 | |||
| 49 | /** | ||
| 50 | * @brief Sets gmock expectation that a keyboard report of `report` keys will be sent. | ||
| 51 | * For this macro to parse correctly, the `report` arg must be surrounded by | ||
| 52 | * parentheses ( ). For instance, | ||
| 53 | * | ||
| 54 | * // Expect that a report of "KC_LSFT + KC_A" is sent to the host. | ||
| 55 | * EXPECT_REPORT(driver, (KC_LSFT, KC_A)); | ||
| 56 | * | ||
| 57 | * is shorthand for | ||
| 58 | * | ||
| 59 | * EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT, KC_A))); | ||
| 60 | * | ||
| 61 | * It is possible to use .Times() and other gmock APIS with EXPECT_REPORT, for instance, | ||
| 62 | * allow only single report to be sent: | ||
| 63 | * | ||
| 64 | * EXPECT_REPORT(driver, (KC_LSFT, KC_A)).Times(1); | ||
| 65 | */ | ||
| 66 | #define EXPECT_REPORT(driver, report) EXPECT_CALL((driver), send_keyboard_mock(KeyboardReport report)) | ||
| 67 | |||
| 68 | /** | ||
| 69 | * @brief Sets gmock expectation that Unicode `code_point` is sent with UC_LNX input | ||
| 70 | * mode. For instance for U+2013, | ||
| 71 | * | ||
| 72 | * EXPECT_UNICODE(driver, 0x2013); | ||
| 73 | * | ||
| 74 | * expects the sequence of keys: | ||
| 75 | * | ||
| 76 | * "Ctrl+Shift+U, 2, 0, 1, 3, space". | ||
| 77 | */ | ||
| 78 | #define EXPECT_UNICODE(driver, code_point) internal::expect_unicode_code_point((driver), (code_point)) | ||
| 79 | |||
| 80 | /** | ||
| 81 | * @brief Sets gmock expectation that a empty keyboard report will be sent. | ||
| 82 | * It is possible to use .Times() and other gmock APIS with EXPECT_EMPTY_REPORT, for instance, | ||
| 83 | * allow any number of empty reports with: | ||
| 84 | * | ||
| 85 | * EXPECT_EMPTY_REPORT(driver).Times(AnyNumber()); | ||
| 86 | */ | ||
| 87 | #define EXPECT_EMPTY_REPORT(driver) EXPECT_REPORT(driver, ()) | ||
| 88 | |||
| 89 | /** | ||
| 90 | * @brief Sets gmock expectation that a keyboard report will be sent, without matching its content. | ||
| 91 | * It is possible to use .Times() and other gmock APIS with EXPECT_ANY_REPORT, for instance, | ||
| 92 | * allow a single arbitrary report with: | ||
| 93 | * | ||
| 94 | * EXPECT_ANY_REPORT(driver).Times(1); | ||
| 95 | */ | ||
| 96 | #define EXPECT_ANY_REPORT(driver) EXPECT_CALL((driver), send_keyboard_mock(_)) | ||
| 97 | |||
| 98 | /** | ||
| 99 | * @brief Sets gmock expectation that no keyboard report will be sent at all. | ||
| 100 | */ | ||
| 101 | #define EXPECT_NO_REPORT(driver) EXPECT_ANY_REPORT(driver).Times(0) | ||
| 102 | |||
| 103 | namespace internal { | ||
| 104 | void expect_unicode_code_point(TestDriver& driver, uint32_t code_point); | ||
| 105 | } // namespace internal | ||
diff --git a/tests/test_common/test_fixture.cpp b/tests/test_common/test_fixture.cpp index c98a679554..5fc6964054 100644 --- a/tests/test_common/test_fixture.cpp +++ b/tests/test_common/test_fixture.cpp | |||
| @@ -82,7 +82,7 @@ TestFixture::~TestFixture() { | |||
| 82 | testing::Mock::VerifyAndClearExpectations(&driver); | 82 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 83 | 83 | ||
| 84 | /* Verify that the matrix really is cleared */ | 84 | /* Verify that the matrix really is cleared */ |
| 85 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 85 | EXPECT_NO_REPORT(driver); |
| 86 | idle_for(TAPPING_TERM * 10); | 86 | idle_for(TAPPING_TERM * 10); |
| 87 | testing::Mock::VerifyAndClearExpectations(&driver); | 87 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 88 | 88 | ||
| @@ -101,6 +101,13 @@ void TestFixture::add_key(KeymapKey key) { | |||
| 101 | this->keymap.push_back(key); | 101 | this->keymap.push_back(key); |
| 102 | } | 102 | } |
| 103 | 103 | ||
| 104 | void TestFixture::tap_key(KeymapKey key, unsigned delay_ms) { | ||
| 105 | key.press(); | ||
| 106 | idle_for(delay_ms); | ||
| 107 | key.release(); | ||
| 108 | run_one_scan_loop(); | ||
| 109 | } | ||
| 110 | |||
| 104 | void TestFixture::set_keymap(std::initializer_list<KeymapKey> keys) { | 111 | void TestFixture::set_keymap(std::initializer_list<KeymapKey> keys) { |
| 105 | this->keymap.clear(); | 112 | this->keymap.clear(); |
| 106 | for (auto& key : keys) { | 113 | for (auto& key : keys) { |
diff --git a/tests/test_common/test_fixture.hpp b/tests/test_common/test_fixture.hpp index 73b5d8d3e8..81906f76c7 100644 --- a/tests/test_common/test_fixture.hpp +++ b/tests/test_common/test_fixture.hpp | |||
| @@ -36,7 +36,22 @@ class TestFixture : public testing::Test { | |||
| 36 | void add_key(const KeymapKey key); | 36 | void add_key(const KeymapKey key); |
| 37 | 37 | ||
| 38 | const KeymapKey* find_key(const layer_t layer_t, const keypos_t position) const; | 38 | const KeymapKey* find_key(const layer_t layer_t, const keypos_t position) const; |
| 39 | void get_keycode(const layer_t layer, const keypos_t position, uint16_t* result) const; | 39 | void get_keycode(const layer_t layer, const keypos_t position, uint16_t* result) const; |
| 40 | |||
| 41 | /** | ||
| 42 | * @brief Taps `key` with `delay_ms` delay between press and release. | ||
| 43 | */ | ||
| 44 | void tap_key(KeymapKey key, unsigned delay_ms = 1); | ||
| 45 | |||
| 46 | /** | ||
| 47 | * @brief Taps multiple KeymapKey keys in order, e.g. `tap_keys(key_a, key_b)`. | ||
| 48 | */ | ||
| 49 | template <typename... Ts> | ||
| 50 | void tap_keys(Ts... keys) { | ||
| 51 | for (KeymapKey key : {keys...}) { | ||
| 52 | tap_key(key); | ||
| 53 | } | ||
| 54 | } | ||
| 40 | 55 | ||
| 41 | void run_one_scan_loop(); | 56 | void run_one_scan_loop(); |
| 42 | void idle_for(unsigned ms); | 57 | void idle_for(unsigned ms); |
