summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Getreuer <50221757+getreuer@users.noreply.github.com>2022-06-05 00:14:02 -0700
committerGitHub <noreply@github.com>2022-06-05 09:14:02 +0200
commit95d20e6d8bb1ffaf3024af793daf789ee0b75727 (patch)
tree95d0bb0c179d6f42a3dafa1952caf8a4299b67ac
parent787165718de4ba532417fb3e04b321c950279237 (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>
-rw-r--r--quantum/process_keycode/process_unicode_common.c1
-rw-r--r--quantum/quantum.c6
-rw-r--r--tests/auto_shift/test_auto_shift.cpp16
-rw-r--r--tests/basic/test_action_layer.cpp54
-rw-r--r--tests/basic/test_keypress.cpp96
-rw-r--r--tests/basic/test_one_shot_keys.cpp36
-rw-r--r--tests/basic/test_tapping.cpp34
-rw-r--r--tests/caps_word/caps_word_autoshift/config.h22
-rw-r--r--tests/caps_word/caps_word_autoshift/test.mk18
-rw-r--r--tests/caps_word/caps_word_autoshift/test_caps_word_autoshift.cpp101
-rw-r--r--tests/caps_word/caps_word_unicodemap/config.h20
-rw-r--r--tests/caps_word/caps_word_unicodemap/test.mk18
-rw-r--r--tests/caps_word/caps_word_unicodemap/test_caps_word_unicodemap.cpp121
-rw-r--r--tests/caps_word/test_caps_word.cpp68
-rw-r--r--tests/secure/test_secure.cpp81
-rw-r--r--tests/tap_hold_configurations/default_mod_tap/test_tap_hold.cpp66
-rw-r--r--tests/tap_hold_configurations/ignore_mod_tap_interrupt/test_tap_hold.cpp18
-rw-r--r--tests/tap_hold_configurations/permissive_hold/test_one_shot_keys.cpp6
-rw-r--r--tests/tap_hold_configurations/permissive_hold/test_tap_hold.cpp16
-rw-r--r--tests/tap_hold_configurations/permissive_hold_ignore_mod_tap_interrupt/test_tap_hold.cpp16
-rw-r--r--tests/tap_hold_configurations/retro_tapping/test_tap_hold.cpp4
-rw-r--r--tests/tap_hold_configurations/retro_tapping/test_tapping.cpp10
-rw-r--r--tests/tap_hold_configurations/tapping_force_hold/test_action_layer.cpp4
-rw-r--r--tests/tap_hold_configurations/tapping_force_hold/test_tap_hold.cpp26
-rw-r--r--tests/test_common/test_driver.cpp35
-rw-r--r--tests/test_common/test_driver.hpp62
-rw-r--r--tests/test_common/test_fixture.cpp9
-rw-r--r--tests/test_common/test_fixture.hpp17
28 files changed, 683 insertions, 298 deletions
diff --git a/quantum/process_keycode/process_unicode_common.c b/quantum/process_keycode/process_unicode_common.c
index 652becbc9a..6cb2ba8dbb 100644
--- a/quantum/process_keycode/process_unicode_common.c
+++ b/quantum/process_keycode/process_unicode_common.c
@@ -95,6 +95,7 @@ __attribute__((weak)) void unicode_input_start(void) {
unicode_saved_mods = get_mods(); // Save current mods
clear_mods(); // Unregister mods to start from a clean state
+ clear_weak_mods();
switch (unicode_config.input_mode) {
case UC_MAC:
diff --git a/quantum/quantum.c b/quantum/quantum.c
index ac3e2d90b4..33121f6b95 100644
--- a/quantum/quantum.c
+++ b/quantum/quantum.c
@@ -289,6 +289,9 @@ bool process_record_quantum(keyrecord_t *record) {
#ifdef TAP_DANCE_ENABLE
process_tap_dance(keycode, record) &&
#endif
+#ifdef CAPS_WORD_ENABLE
+ process_caps_word(keycode, record) &&
+#endif
#if defined(UNICODE_COMMON_ENABLE)
process_unicode_common(keycode, record) &&
#endif
@@ -307,9 +310,6 @@ bool process_record_quantum(keyrecord_t *record) {
#ifdef TERMINAL_ENABLE
process_terminal(keycode, record) &&
#endif
-#ifdef CAPS_WORD_ENABLE
- process_caps_word(keycode, record) &&
-#endif
#ifdef SPACE_CADET_ENABLE
process_space_cadet(keycode, record) &&
#endif
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) {
set_keymap({regular_key});
/* Press regular key */
- EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
+ EXPECT_NO_REPORT(driver);
regular_key.press();
run_one_scan_loop();
testing::Mock::VerifyAndClearExpectations(&driver);
/* Release regular key */
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_A)));
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
+ EXPECT_REPORT(driver, (KC_A));
+ EXPECT_EMPTY_REPORT(driver);
regular_key.release();
run_one_scan_loop();
testing::Mock::VerifyAndClearExpectations(&driver);
@@ -55,16 +55,16 @@ TEST_F(AutoShift, key_release_after_timeout) {
set_keymap({regular_key});
/* Press regular key */
- EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
+ EXPECT_NO_REPORT(driver);
regular_key.press();
idle_for(AUTO_SHIFT_TIMEOUT);
testing::Mock::VerifyAndClearExpectations(&driver);
/* Release regular key */
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT, KC_A)));
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT)));
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
+ EXPECT_REPORT(driver, (KC_LSFT, KC_A));
+ EXPECT_REPORT(driver, (KC_LSFT));
+ EXPECT_EMPTY_REPORT(driver);
regular_key.release();
run_one_scan_loop();
testing::Mock::VerifyAndClearExpectations(&driver);
-} \ No newline at end of file
+}
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) {
set_keymap({layer_key});
/* Press and release MO, nothing should happen. */
- EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
+ EXPECT_NO_REPORT(driver);
layer_key.press();
run_one_scan_loop();
testing::Mock::VerifyAndClearExpectations(&driver);
- EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
+ EXPECT_NO_REPORT(driver);
layer_key.release();
run_one_scan_loop();
testing::Mock::VerifyAndClearExpectations(&driver);
@@ -151,28 +151,28 @@ TEST_F(ActionLayer, MomentaryLayerWithKeypress) {
set_keymap({layer_key, regular_key, KeymapKey{1, 1, 0, KC_B}});
/* Press MO. */
- EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
+ EXPECT_NO_REPORT(driver);
layer_key.press();
run_one_scan_loop();
EXPECT_TRUE(layer_state_is(1));
testing::Mock::VerifyAndClearExpectations(&driver);
/* Press key on layer 1 */
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_B))).Times(1);
+ EXPECT_REPORT(driver, (KC_B)).Times(1);
regular_key.press();
run_one_scan_loop();
EXPECT_TRUE(layer_state_is(1));
testing::Mock::VerifyAndClearExpectations(&driver);
/* Release key on layer 1 */
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).Times(1);
+ EXPECT_EMPTY_REPORT(driver);
regular_key.release();
run_one_scan_loop();
EXPECT_TRUE(layer_state_is(1));
testing::Mock::VerifyAndClearExpectations(&driver);
/* Release MO */
- EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
+ EXPECT_NO_REPORT(driver);
layer_key.release();
run_one_scan_loop();
EXPECT_TRUE(layer_state_is(0));
@@ -188,14 +188,14 @@ TEST_F(ActionLayer, ToggleLayerDoesNothing) {
set_keymap({layer_key});
/* Press TG. Layer state should not change as it's applied on release. */
- EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
+ EXPECT_NO_REPORT(driver);
layer_key.press();
run_one_scan_loop();
EXPECT_TRUE(layer_state_is(1));
testing::Mock::VerifyAndClearExpectations(&driver);
/* Release TG. */
- EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
+ EXPECT_NO_REPORT(driver);
layer_key.release();
run_one_scan_loop();
EXPECT_TRUE(layer_state_is(1));
@@ -212,26 +212,26 @@ TEST_F(ActionLayer, ToggleLayerUpAndDown) {
set_keymap({toggle_layer_1_on_layer_0, toggle_layer_0_on_layer_1});
/* Toggle Layer 1. */
- EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
+ EXPECT_NO_REPORT(driver);
toggle_layer_1_on_layer_0.press();
run_one_scan_loop();
EXPECT_TRUE(layer_state_is(1));
testing::Mock::VerifyAndClearExpectations(&driver);
- EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
+ EXPECT_NO_REPORT(driver);
toggle_layer_1_on_layer_0.release();
run_one_scan_loop();
EXPECT_TRUE(layer_state_is(1));
testing::Mock::VerifyAndClearExpectations(&driver);
/* Toggle Layer 0. */
- EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
+ EXPECT_NO_REPORT(driver);
toggle_layer_0_on_layer_1.press();
run_one_scan_loop();
EXPECT_TRUE(layer_state_is(0));
testing::Mock::VerifyAndClearExpectations(&driver);
- EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
+ EXPECT_NO_REPORT(driver);
toggle_layer_0_on_layer_1.release();
run_one_scan_loop();
EXPECT_TRUE(layer_state_is(0));
@@ -247,13 +247,13 @@ TEST_F(ActionLayer, LayerTapToggleDoesNothing) {
set_keymap({layer_key});
/* Press and release TT. */
- EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
+ EXPECT_NO_REPORT(driver);
layer_key.press();
run_one_scan_loop();
EXPECT_TRUE(layer_state_is(1));
testing::Mock::VerifyAndClearExpectations(&driver);
- EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
+ EXPECT_NO_REPORT(driver);
layer_key.release();
run_one_scan_loop();
EXPECT_TRUE(layer_state_is(0));
@@ -271,25 +271,25 @@ TEST_F(ActionLayer, LayerTapToggleWithKeypress) {
set_keymap({layer_key, regular_key, KeymapKey{1, 1, 0, KC_B}});
/* Press TT. */
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).Times(0);
+ EXPECT_NO_REPORT(driver);
layer_key.press();
run_one_scan_loop();
EXPECT_TRUE(layer_state_is(1));
testing::Mock::VerifyAndClearExpectations(&driver);
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_B))).Times(1);
+ EXPECT_REPORT(driver, (KC_B)).Times(1);
regular_key.press();
run_one_scan_loop();
EXPECT_TRUE(layer_state_is(1));
testing::Mock::VerifyAndClearExpectations(&driver);
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).Times(1);
+ EXPECT_EMPTY_REPORT(driver);
regular_key.release();
run_one_scan_loop();
EXPECT_TRUE(layer_state_is(1));
testing::Mock::VerifyAndClearExpectations(&driver);
- EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
+ EXPECT_NO_REPORT(driver);
layer_key.release();
run_one_scan_loop();
EXPECT_TRUE(layer_state_is(0));
@@ -307,7 +307,7 @@ TEST_F(ActionLayer, LayerTapToggleWithToggleWithKeypress) {
set_keymap({layer_key, regular_key, KeymapKey{1, 1, 0, KC_B}});
/* Tap TT five times . */
- EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
+ EXPECT_NO_REPORT(driver);
layer_key.press();
run_one_scan_loop();
@@ -346,13 +346,13 @@ TEST_F(ActionLayer, LayerTapToggleWithToggleWithKeypress) {
testing::Mock::VerifyAndClearExpectations(&driver);
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_B))).Times(1);
+ EXPECT_REPORT(driver, (KC_B)).Times(1);
regular_key.press();
run_one_scan_loop();
EXPECT_TRUE(layer_state_is(1));
testing::Mock::VerifyAndClearExpectations(&driver);
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).Times(1);
+ EXPECT_EMPTY_REPORT(driver);
regular_key.release();
run_one_scan_loop();
EXPECT_TRUE(layer_state_is(1));
@@ -370,7 +370,7 @@ TEST_F(ActionLayer, LayerTapReleasedBeforeKeypressReleaseWithModifiers) {
set_keymap({layer_0_key_0, layer_1_key_1});
/* Press layer tap and wait for tapping term to switch to layer 1 */
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).Times(0);
+ EXPECT_NO_REPORT(driver);
layer_0_key_0.press();
idle_for(TAPPING_TERM);
EXPECT_TRUE(layer_state_is(0));
@@ -378,23 +378,23 @@ TEST_F(ActionLayer, LayerTapReleasedBeforeKeypressReleaseWithModifiers) {
/* Press key with layer 1 mapping, result basically expected
* altough more reports are send then necessary. */
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_RALT))).Times(1);
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_RALT, KC_9))).Times(1);
+ EXPECT_REPORT(driver, (KC_RALT)).Times(1);
+ EXPECT_REPORT(driver, (KC_RALT, KC_9)).Times(1);
layer_1_key_1.press();
run_one_scan_loop();
EXPECT_TRUE(layer_state_is(1));
testing::Mock::VerifyAndClearExpectations(&driver);
/* Release layer tap key, no report is send because key is still held. */
- EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
+ EXPECT_NO_REPORT(driver);
layer_0_key_0.release();
run_one_scan_loop();
EXPECT_TRUE(layer_state_is(0));
testing::Mock::VerifyAndClearExpectations(&driver);
/* Unregister keycode and modifier. */
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_RALT))).Times(1);
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).Times(1);
+ EXPECT_REPORT(driver, (KC_RALT)).Times(1);
+ EXPECT_EMPTY_REPORT(driver);
layer_1_key_1.release();
run_one_scan_loop();
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 {};
TEST_F(KeyPress, SendKeyboardIsNotCalledWhenNoKeyIsPressed) {
TestDriver driver;
- EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
+ EXPECT_NO_REPORT(driver);
keyboard_task();
}
@@ -35,11 +35,11 @@ TEST_F(KeyPress, CorrectKeyIsReportedWhenPressed) {
set_keymap({key});
key.press();
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(key.report_code)));
+ EXPECT_REPORT(driver, (key.report_code));
keyboard_task();
key.release();
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
+ EXPECT_EMPTY_REPORT(driver);
keyboard_task();
}
@@ -50,7 +50,7 @@ TEST_F(KeyPress, ANonMappedKeyDoesNothing) {
set_keymap({key});
key.press();
- EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
+ EXPECT_NO_REPORT(driver);
keyboard_task();
keyboard_task();
}
@@ -66,19 +66,19 @@ TEST_F(KeyPress, CorrectKeysAreReportedWhenTwoKeysArePressed) {
key_c.press();
// Note that QMK only processes one key at a time
// See issue #1476 for more information
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(key_b.report_code)));
+ EXPECT_REPORT(driver, (key_b.report_code));
keyboard_task();
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(key_b.report_code, key_c.report_code)));
+ EXPECT_REPORT(driver, (key_b.report_code, key_c.report_code));
keyboard_task();
key_b.release();
key_c.release();
// Note that the first key released is the first one in the matrix order
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(key_c.report_code)));
+ EXPECT_REPORT(driver, (key_c.report_code));
keyboard_task();
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
+ EXPECT_EMPTY_REPORT(driver);
keyboard_task();
}
@@ -94,17 +94,17 @@ TEST_F(KeyPress, LeftShiftIsReportedCorrectly) {
// Unfortunately modifiers are also processed in the wrong order
// See issue #1476 for more information
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(key_a.report_code)));
+ EXPECT_REPORT(driver, (key_a.report_code));
keyboard_task();
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(key_a.report_code, key_lsft.report_code)));
+ EXPECT_REPORT(driver, (key_a.report_code, key_lsft.report_code));
keyboard_task();
key_a.release();
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(key_lsft.report_code)));
+ EXPECT_REPORT(driver, (key_lsft.report_code));
keyboard_task();
key_lsft.release();
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
+ EXPECT_EMPTY_REPORT(driver);
keyboard_task();
}
@@ -120,19 +120,19 @@ TEST_F(KeyPress, PressLeftShiftAndControl) {
// Unfortunately modifiers are also processed in the wrong order
// See issue #1476 for more information
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(key_lsft.report_code)));
+ EXPECT_REPORT(driver, (key_lsft.report_code));
keyboard_task();
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(key_lsft.report_code, key_lctrl.report_code)));
+ EXPECT_REPORT(driver, (key_lsft.report_code, key_lctrl.report_code));
keyboard_task();
key_lsft.release();
key_lctrl.release();
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(key_lctrl.report_code)));
+ EXPECT_REPORT(driver, (key_lctrl.report_code));
keyboard_task();
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
+ EXPECT_EMPTY_REPORT(driver);
keyboard_task();
}
@@ -147,19 +147,19 @@ TEST_F(KeyPress, LeftAndRightShiftCanBePressedAtTheSameTime) {
key_rsft.press();
// Unfortunately modifiers are also processed in the wrong order
// See issue #1476 for more information
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(key_lsft.report_code)));
+ EXPECT_REPORT(driver, (key_lsft.report_code));
keyboard_task();
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(key_lsft.report_code, key_rsft.report_code)));
+ EXPECT_REPORT(driver, (key_lsft.report_code, key_rsft.report_code));
keyboard_task();
key_lsft.release();
key_rsft.release();
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(key_rsft.report_code)));
+ EXPECT_REPORT(driver, (key_rsft.report_code));
keyboard_task();
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
+ EXPECT_EMPTY_REPORT(driver);
keyboard_task();
}
@@ -175,13 +175,13 @@ TEST_F(KeyPress, RightShiftLeftControlAndCharWithTheSameKey) {
// The underlying cause is that we use only one bit to represent the right hand
// modifiers.
combo_key.press();
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_RIGHT_SHIFT, KC_RIGHT_CTRL)));
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_RIGHT_SHIFT, KC_RIGHT_CTRL, KC_O)));
+ EXPECT_REPORT(driver, (KC_RIGHT_SHIFT, KC_RIGHT_CTRL));
+ EXPECT_REPORT(driver, (KC_RIGHT_SHIFT, KC_RIGHT_CTRL, KC_O));
keyboard_task();
combo_key.release();
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_RIGHT_SHIFT, KC_RIGHT_CTRL)));
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
+ EXPECT_REPORT(driver, (KC_RIGHT_SHIFT, KC_RIGHT_CTRL));
+ EXPECT_EMPTY_REPORT(driver);
keyboard_task();
}
@@ -194,24 +194,24 @@ TEST_F(KeyPress, PressPlusEqualReleaseBeforePress) {
set_keymap({key_plus, key_eql});
key_plus.press();
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT)));
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT, KC_EQUAL)));
+ EXPECT_REPORT(driver, (KC_LEFT_SHIFT));
+ EXPECT_REPORT(driver, (KC_LEFT_SHIFT, KC_EQUAL));
run_one_scan_loop();
testing::Mock::VerifyAndClearExpectations(&driver);
key_plus.release();
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT)));
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
+ EXPECT_REPORT(driver, (KC_LEFT_SHIFT));
+ EXPECT_EMPTY_REPORT(driver);
run_one_scan_loop();
testing::Mock::VerifyAndClearExpectations(&driver);
key_eql.press();
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(key_eql.report_code)));
+ EXPECT_REPORT(driver, (key_eql.report_code));
run_one_scan_loop();
testing::Mock::VerifyAndClearExpectations(&driver);
key_eql.release();
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
+ EXPECT_EMPTY_REPORT(driver);
run_one_scan_loop();
testing::Mock::VerifyAndClearExpectations(&driver);
}
@@ -225,25 +225,25 @@ TEST_F(KeyPress, PressPlusEqualDontReleaseBeforePress) {
set_keymap({key_plus, key_eql});
key_plus.press();
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT)));
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT, KC_EQUAL)));
+ EXPECT_REPORT(driver, (KC_LEFT_SHIFT));
+ EXPECT_REPORT(driver, (KC_LEFT_SHIFT, KC_EQUAL));
run_one_scan_loop();
testing::Mock::VerifyAndClearExpectations(&driver);
key_eql.press();
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_EQUAL)));
+ EXPECT_EMPTY_REPORT(driver);
+ EXPECT_REPORT(driver, (KC_EQUAL));
run_one_scan_loop();
testing::Mock::VerifyAndClearExpectations(&driver);
key_plus.release();
// BUG: Should really still return KC_EQUAL, but this is fine too
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).Times(1);
+ EXPECT_EMPTY_REPORT(driver);
run_one_scan_loop();
testing::Mock::VerifyAndClearExpectations(&driver);
key_eql.release();
- EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
+ EXPECT_NO_REPORT(driver);
run_one_scan_loop();
testing::Mock::VerifyAndClearExpectations(&driver);
}
@@ -257,24 +257,24 @@ TEST_F(KeyPress, PressEqualPlusReleaseBeforePress) {
set_keymap({key_plus, key_eql});
key_eql.press();
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_EQUAL)));
+ EXPECT_REPORT(driver, (KC_EQUAL));
run_one_scan_loop();
testing::Mock::VerifyAndClearExpectations(&driver);
key_eql.release();
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
+ EXPECT_EMPTY_REPORT(driver);
run_one_scan_loop();
testing::Mock::VerifyAndClearExpectations(&driver);
key_plus.press();
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT)));
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT, KC_EQUAL)));
+ EXPECT_REPORT(driver, (KC_LEFT_SHIFT));
+ EXPECT_REPORT(driver, (KC_LEFT_SHIFT, KC_EQUAL));
run_one_scan_loop();
testing::Mock::VerifyAndClearExpectations(&driver);
key_plus.release();
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT)));
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
+ EXPECT_REPORT(driver, (KC_LEFT_SHIFT));
+ EXPECT_EMPTY_REPORT(driver);
run_one_scan_loop();
testing::Mock::VerifyAndClearExpectations(&driver);
}
@@ -288,27 +288,27 @@ TEST_F(KeyPress, PressEqualPlusDontReleaseBeforePress) {
set_keymap({key_plus, key_eql});
key_eql.press();
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_EQUAL)));
+ EXPECT_REPORT(driver, (KC_EQUAL));
run_one_scan_loop();
testing::Mock::VerifyAndClearExpectations(&driver);
key_plus.press();
// BUG: The sequence is a bit strange, but it works, the end result is that
// KC_PLUS is sent
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT, KC_EQUAL)));
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT)));
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT, KC_EQUAL)));
+ EXPECT_REPORT(driver, (KC_LEFT_SHIFT, KC_EQUAL));
+ EXPECT_REPORT(driver, (KC_LEFT_SHIFT));
+ EXPECT_REPORT(driver, (KC_LEFT_SHIFT, KC_EQUAL));
run_one_scan_loop();
testing::Mock::VerifyAndClearExpectations(&driver);
key_eql.release();
// I guess it's fine to still report shift here
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT)));
+ EXPECT_REPORT(driver, (KC_LEFT_SHIFT));
run_one_scan_loop();
testing::Mock::VerifyAndClearExpectations(&driver);
key_plus.release();
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
+ EXPECT_EMPTY_REPORT(driver);
run_one_scan_loop();
testing::Mock::VerifyAndClearExpectations(&driver);
}
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) {
set_keymap({osm_key});
/* Press and release OSM key*/
- EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
+ EXPECT_NO_REPORT(driver);
osm_key.press();
run_one_scan_loop();
osm_key.release();
@@ -39,7 +39,7 @@ TEST_F(OneShot, OSMWithoutAdditionalKeypressDoesNothing) {
testing::Mock::VerifyAndClearExpectations(&driver);
/* OSM are added when an actual report is send */
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(osm_key.report_code)));
+ EXPECT_REPORT(driver, (osm_key.report_code));
send_keyboard_report();
testing::Mock::VerifyAndClearExpectations(&driver);
@@ -57,7 +57,7 @@ TEST_P(OneShotParametrizedTestFixture, OSMExpiredDoesNothing) {
set_keymap({osm_key, regular_key});
/* Press and release OSM */
- EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
+ EXPECT_NO_REPORT(driver);
osm_key.press();
run_one_scan_loop();
osm_key.release();
@@ -65,13 +65,13 @@ TEST_P(OneShotParametrizedTestFixture, OSMExpiredDoesNothing) {
testing::Mock::VerifyAndClearExpectations(&driver);
/* Press regular key */
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(regular_key.report_code))).Times(1);
+ EXPECT_REPORT(driver, (regular_key.report_code)).Times(1);
regular_key.press();
run_one_scan_loop();
testing::Mock::VerifyAndClearExpectations(&driver);
/* Release regular key */
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
+ EXPECT_EMPTY_REPORT(driver);
regular_key.release();
run_one_scan_loop();
testing::Mock::VerifyAndClearExpectations(&driver);
@@ -87,7 +87,7 @@ TEST_P(OneShotParametrizedTestFixture, OSMWithAdditionalKeypress) {
set_keymap({osm_key, regular_key});
/* Press and release OSM */
- EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
+ EXPECT_NO_REPORT(driver);
osm_key.press();
run_one_scan_loop();
osm_key.release();
@@ -95,13 +95,13 @@ TEST_P(OneShotParametrizedTestFixture, OSMWithAdditionalKeypress) {
testing::Mock::VerifyAndClearExpectations(&driver);
/* Press regular key */
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(osm_key.report_code, regular_key.report_code))).Times(1);
+ EXPECT_REPORT(driver, (osm_key.report_code, regular_key.report_code)).Times(1);
regular_key.press();
run_one_scan_loop();
testing::Mock::VerifyAndClearExpectations(&driver);
/* Release regular key */
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
+ EXPECT_EMPTY_REPORT(driver);
regular_key.release();
run_one_scan_loop();
testing::Mock::VerifyAndClearExpectations(&driver);
@@ -117,26 +117,26 @@ TEST_P(OneShotParametrizedTestFixture, OSMAsRegularModifierWithAdditionalKeypres
set_keymap({osm_key, regular_key});
/* Press OSM */
- EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
+ EXPECT_NO_REPORT(driver);
osm_key.press();
run_one_scan_loop();
testing::Mock::VerifyAndClearExpectations(&driver);
/* Press regular key */
- EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
+ EXPECT_NO_REPORT(driver);
regular_key.press();
run_one_scan_loop();
testing::Mock::VerifyAndClearExpectations(&driver);
/* Release regular key */
- EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
+ EXPECT_NO_REPORT(driver);
regular_key.release();
run_one_scan_loop();
testing::Mock::VerifyAndClearExpectations(&driver);
/* Release OSM */
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(regular_key.report_code, osm_key.report_code))).Times(1);
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).Times(1);
+ EXPECT_REPORT(driver, (regular_key.report_code, osm_key.report_code)).Times(1);
+ EXPECT_EMPTY_REPORT(driver);
osm_key.release();
run_one_scan_loop();
testing::Mock::VerifyAndClearExpectations(&driver);
@@ -169,26 +169,26 @@ TEST_F(OneShot, OSLWithAdditionalKeypress) {
set_keymap({osl_key, regular_key});
/* Press OSL key */
- EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
+ EXPECT_NO_REPORT(driver);
osl_key.press();
run_one_scan_loop();
testing::Mock::VerifyAndClearExpectations(&driver);
/* Release OSL key */
- EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
+ EXPECT_NO_REPORT(driver);
osl_key.release();
run_one_scan_loop();
testing::Mock::VerifyAndClearExpectations(&driver);
/* Press regular key */
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(regular_key.report_code))).Times(1);
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
+ EXPECT_REPORT(driver, (regular_key.report_code)).Times(1);
+ EXPECT_EMPTY_REPORT(driver);
regular_key.press();
run_one_scan_loop();
testing::Mock::VerifyAndClearExpectations(&driver);
/* Release regular key */
- EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
+ EXPECT_NO_REPORT(driver);
regular_key.release();
run_one_scan_loop();
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) {
// Tapping keys does nothing on press
key_shift_hold_p_tap.press();
- EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
+ EXPECT_NO_REPORT(driver);
run_one_scan_loop();
// First we get the key press
key_shift_hold_p_tap.release();
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_P)));
+ EXPECT_REPORT(driver, (KC_P));
// Then the release
- EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));