summaryrefslogtreecommitdiff
path: root/tests/basic
diff options
context:
space:
mode:
Diffstat (limited to 'tests/basic')
-rw-r--r--tests/basic/test_action_layer.cpp66
-rw-r--r--tests/basic/test_keycode_util.cpp52
-rw-r--r--tests/basic/test_keypress.cpp32
-rw-r--r--tests/basic/test_one_shot_keys.cpp32
-rw-r--r--tests/basic/test_tapping.cpp69
5 files changed, 186 insertions, 65 deletions
diff --git a/tests/basic/test_action_layer.cpp b/tests/basic/test_action_layer.cpp
index d0a28d42c0..883d99b404 100644
--- a/tests/basic/test_action_layer.cpp
+++ b/tests/basic/test_action_layer.cpp
@@ -28,7 +28,7 @@ TEST_F(ActionLayer, LayerStateDBG) {
layer_state_set(0);
- testing::Mock::VerifyAndClearExpectations(&driver);
+ VERIFY_AND_CLEAR(driver);
}
TEST_F(ActionLayer, LayerStateSet) {
@@ -39,7 +39,7 @@ TEST_F(ActionLayer, LayerStateSet) {
layer_state_set(0b001100);
EXPECT_EQ(layer_state, 0b001100);
- testing::Mock::VerifyAndClearExpectations(&driver);
+ VERIFY_AND_CLEAR(driver);
}
TEST_F(ActionLayer, LayerStateIs) {
@@ -56,7 +56,7 @@ TEST_F(ActionLayer, LayerStateIs) {
EXPECT_EQ(layer_state_is(1), true);
EXPECT_EQ(layer_state_is(2), false);
- testing::Mock::VerifyAndClearExpectations(&driver);
+ VERIFY_AND_CLEAR(driver);
}
TEST_F(ActionLayer, LayerStateCmp) {
@@ -76,7 +76,7 @@ TEST_F(ActionLayer, LayerStateCmp) {
EXPECT_EQ(layer_state_cmp(prev_layer, 1), true);
EXPECT_EQ(layer_state_cmp(prev_layer, 2), false);
- testing::Mock::VerifyAndClearExpectations(&driver);
+ VERIFY_AND_CLEAR(driver);
}
TEST_F(ActionLayer, LayerClear) {
@@ -85,7 +85,7 @@ TEST_F(ActionLayer, LayerClear) {
layer_clear();
EXPECT_EQ(layer_state, 0);
- testing::Mock::VerifyAndClearExpectations(&driver);
+ VERIFY_AND_CLEAR(driver);
}
TEST_F(ActionLayer, LayerMove) {
@@ -96,7 +96,7 @@ TEST_F(ActionLayer, LayerMove) {
layer_move(3);
EXPECT_EQ(layer_state, 0b1000);
- testing::Mock::VerifyAndClearExpectations(&driver);
+ VERIFY_AND_CLEAR(driver);
}
TEST_F(ActionLayer, LayerOn) {
@@ -108,7 +108,7 @@ TEST_F(ActionLayer, LayerOn) {
layer_on(3);
EXPECT_EQ(layer_state, 0b1010);
- testing::Mock::VerifyAndClearExpectations(&driver);
+ VERIFY_AND_CLEAR(driver);
}
TEST_F(ActionLayer, LayerOff) {
@@ -121,7 +121,7 @@ TEST_F(ActionLayer, LayerOff) {
layer_off(2);
EXPECT_EQ(layer_state, 0b0010);
- testing::Mock::VerifyAndClearExpectations(&driver);
+ VERIFY_AND_CLEAR(driver);
}
TEST_F(ActionLayer, MomentaryLayerDoesNothing) {
@@ -134,12 +134,12 @@ TEST_F(ActionLayer, MomentaryLayerDoesNothing) {
EXPECT_NO_REPORT(driver);
layer_key.press();
run_one_scan_loop();
- testing::Mock::VerifyAndClearExpectations(&driver);
+ VERIFY_AND_CLEAR(driver);
EXPECT_NO_REPORT(driver);
layer_key.release();
run_one_scan_loop();
- testing::Mock::VerifyAndClearExpectations(&driver);
+ VERIFY_AND_CLEAR(driver);
}
TEST_F(ActionLayer, MomentaryLayerWithKeypress) {
@@ -155,28 +155,28 @@ TEST_F(ActionLayer, MomentaryLayerWithKeypress) {
layer_key.press();
run_one_scan_loop();
EXPECT_TRUE(layer_state_is(1));
- testing::Mock::VerifyAndClearExpectations(&driver);
+ VERIFY_AND_CLEAR(driver);
/* Press key on layer 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);
+ VERIFY_AND_CLEAR(driver);
/* Release key on layer 1 */
EXPECT_EMPTY_REPORT(driver);
regular_key.release();
run_one_scan_loop();
EXPECT_TRUE(layer_state_is(1));
- testing::Mock::VerifyAndClearExpectations(&driver);
+ VERIFY_AND_CLEAR(driver);
/* Release MO */
EXPECT_NO_REPORT(driver);
layer_key.release();
run_one_scan_loop();
EXPECT_TRUE(layer_state_is(0));
- testing::Mock::VerifyAndClearExpectations(&driver);
+ VERIFY_AND_CLEAR(driver);
}
TEST_F(ActionLayer, ToggleLayerDoesNothing) {
@@ -192,14 +192,14 @@ TEST_F(ActionLayer, ToggleLayerDoesNothing) {
layer_key.press();
run_one_scan_loop();
EXPECT_TRUE(layer_state_is(1));
- testing::Mock::VerifyAndClearExpectations(&driver);
+ VERIFY_AND_CLEAR(driver);
/* Release TG. */
EXPECT_NO_REPORT(driver);
layer_key.release();
run_one_scan_loop();
EXPECT_TRUE(layer_state_is(1));
- testing::Mock::VerifyAndClearExpectations(&driver);
+ VERIFY_AND_CLEAR(driver);
}
TEST_F(ActionLayer, ToggleLayerUpAndDown) {
@@ -216,26 +216,26 @@ TEST_F(ActionLayer, ToggleLayerUpAndDown) {
toggle_layer_1_on_layer_0.press();
run_one_scan_loop();
EXPECT_TRUE(layer_state_is(1));
- testing::Mock::VerifyAndClearExpectations(&driver);
+ VERIFY_AND_CLEAR(driver);
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);
+ VERIFY_AND_CLEAR(driver);
/* Toggle Layer 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);
+ VERIFY_AND_CLEAR(driver);
EXPECT_NO_REPORT(driver);
toggle_layer_0_on_layer_1.release();
run_one_scan_loop();
EXPECT_TRUE(layer_state_is(0));
- testing::Mock::VerifyAndClearExpectations(&driver);
+ VERIFY_AND_CLEAR(driver);
}
TEST_F(ActionLayer, LayerTapToggleDoesNothing) {
@@ -251,13 +251,13 @@ TEST_F(ActionLayer, LayerTapToggleDoesNothing) {
layer_key.press();
run_one_scan_loop();
EXPECT_TRUE(layer_state_is(1));
- testing::Mock::VerifyAndClearExpectations(&driver);
+ VERIFY_AND_CLEAR(driver);
EXPECT_NO_REPORT(driver);
layer_key.release();
run_one_scan_loop();
EXPECT_TRUE(layer_state_is(0));
- testing::Mock::VerifyAndClearExpectations(&driver);
+ VERIFY_AND_CLEAR(driver);
}
TEST_F(ActionLayer, LayerTapToggleWithKeypress) {
@@ -275,25 +275,25 @@ TEST_F(ActionLayer, LayerTapToggleWithKeypress) {
layer_key.press();
run_one_scan_loop();
EXPECT_TRUE(layer_state_is(1));
- testing::Mock::VerifyAndClearExpectations(&driver);
+ VERIFY_AND_CLEAR(driver);
EXPECT_REPORT(driver, (KC_B)).Times(1);
regular_key.press();
run_one_scan_loop();
EXPECT_TRUE(layer_state_is(1));
- testing::Mock::VerifyAndClearExpectations(&driver);
+ VERIFY_AND_CLEAR(driver);
EXPECT_EMPTY_REPORT(driver);
regular_key.release();
run_one_scan_loop();
EXPECT_TRUE(layer_state_is(1));
- testing::Mock::VerifyAndClearExpectations(&driver);
+ VERIFY_AND_CLEAR(driver);
EXPECT_NO_REPORT(driver);
layer_key.release();
run_one_scan_loop();
EXPECT_TRUE(layer_state_is(0));
- testing::Mock::VerifyAndClearExpectations(&driver);
+ VERIFY_AND_CLEAR(driver);
}
TEST_F(ActionLayer, LayerTapToggleWithToggleWithKeypress) {
@@ -344,19 +344,19 @@ TEST_F(ActionLayer, LayerTapToggleWithToggleWithKeypress) {
run_one_scan_loop();
EXPECT_TRUE(layer_state_is(1));
- testing::Mock::VerifyAndClearExpectations(&driver);
+ VERIFY_AND_CLEAR(driver);
EXPECT_REPORT(driver, (KC_B)).Times(1);
regular_key.press();
run_one_scan_loop();
EXPECT_TRUE(layer_state_is(1));
- testing::Mock::VerifyAndClearExpectations(&driver);
+ VERIFY_AND_CLEAR(driver);
EXPECT_EMPTY_REPORT(driver);
regular_key.release();
run_one_scan_loop();
EXPECT_TRUE(layer_state_is(1));
- testing::Mock::VerifyAndClearExpectations(&driver);
+ VERIFY_AND_CLEAR(driver);
}
TEST_F(ActionLayer, LayerTapReleasedBeforeKeypressReleaseWithModifiers) {
@@ -373,7 +373,7 @@ TEST_F(ActionLayer, LayerTapReleasedBeforeKeypressReleaseWithModifiers) {
layer_0_key_0.press();
idle_for(TAPPING_TERM);
EXPECT_TRUE(layer_state_is(0));
- testing::Mock::VerifyAndClearExpectations(&driver);
+ VERIFY_AND_CLEAR(driver);
/* Press key with layer 1 mapping, result basically expected
* altough more reports are send then necessary. */
@@ -382,14 +382,14 @@ TEST_F(ActionLayer, LayerTapReleasedBeforeKeypressReleaseWithModifiers) {
layer_1_key_1.press();
run_one_scan_loop();
EXPECT_TRUE(layer_state_is(1));
- testing::Mock::VerifyAndClearExpectations(&driver);
+ VERIFY_AND_CLEAR(driver);
/* Release layer tap key, no report is send because key is still held. */
EXPECT_NO_REPORT(driver);
layer_0_key_0.release();
run_one_scan_loop();
EXPECT_TRUE(layer_state_is(0));
- testing::Mock::VerifyAndClearExpectations(&driver);
+ VERIFY_AND_CLEAR(driver);
/* Unregister keycode and modifier. */
EXPECT_REPORT(driver, (KC_RALT)).Times(1);
@@ -397,5 +397,5 @@ TEST_F(ActionLayer, LayerTapReleasedBeforeKeypressReleaseWithModifiers) {
layer_1_key_1.release();
run_one_scan_loop();
EXPECT_TRUE(layer_state_is(0));
- testing::Mock::VerifyAndClearExpectations(&driver);
+ VERIFY_AND_CLEAR(driver);
}
diff --git a/tests/basic/test_keycode_util.cpp b/tests/basic/test_keycode_util.cpp
new file mode 100644
index 0000000000..693334676e
--- /dev/null
+++ b/tests/basic/test_keycode_util.cpp
@@ -0,0 +1,52 @@
+// Copyright 2022 Stefan Kerkmann
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include "test_common.hpp"
+
+class KeycodeToIdentifierSuite : public ::testing::TestWithParam<std::pair<std::uint16_t, std::string>> {};
+
+TEST_P(KeycodeToIdentifierSuite, ConversionTests) {
+ ASSERT_EQ(get_keycode_identifier_or_default(GetParam().first), GetParam().second);
+}
+
+INSTANTIATE_TEST_CASE_P(ConversionTestsP, KeycodeToIdentifierSuite,
+ // clang-format off
+::testing::Values(
+ // Goto layer
+ std::make_pair(TO(0), "TO(0)"),
+ std::make_pair(TO(0x1F), "TO(31)"),
+ // Momentary switch layer
+ std::make_pair(MO(0), "MO(0)"),
+ std::make_pair(MO(0x1F), "MO(31)"),
+ // Set default layer
+ std::make_pair(DF(0), "DF(0)"),
+ std::make_pair(DF(0x1F), "DF(31)"),
+ // Toggle layer
+ std::make_pair(TG(0), "TG(0)"),
+ std::make_pair(TG(0x1F), "TG(31)"),
+ // One-shot layer
+ std::make_pair(OSL(0), "OSL(0)"),
+ std::make_pair(OSL(0x1F), "OSL(31)"),
+ // One-shot mod
+ std::make_pair(OSM(MOD_LSFT), "OSM(MOD_LSFT)"),
+ std::make_pair(OSM(MOD_LSFT | MOD_LCTL), "OSM(MOD_LCTL | MOD_LSFT)"),
+ // Layer Mod
+ std::make_pair(LM(0, MOD_LSFT), "LM(0, MOD_LSFT)"),
+ std::make_pair(LM(0xF, MOD_LSFT), "LM(15, MOD_LSFT)"),
+ std::make_pair(LM(0xF, MOD_LSFT | MOD_LCTL), "LM(15, MOD_LCTL | MOD_LSFT)"),
+ // Layer tap toggle
+ std::make_pair(TT(0), "TT(0)"),
+ std::make_pair(TT(0x1F), "TT(31)"),
+ // Layer tap
+ std::make_pair(LT(0, KC_A), "LT(0, KC_A)"),
+ std::make_pair(LT(0xF, KC_SPACE), "LT(15, KC_SPACE)"),
+ std::make_pair(LT(1, KC_SPC), "LT(1, KC_SPACE)"),
+ // Mod tap
+ std::make_pair(MT(MOD_LCTL, KC_A), "MT(MOD_LCTL, KC_A)"),
+ std::make_pair(MT(MOD_LCTL | MOD_LSFT, KC_A), "MT(MOD_LCTL | MOD_LSFT, KC_A)"),
+ std::make_pair(ALT_T(KC_TAB), "MT(MOD_LALT, KC_TAB)"),
+ // Mods
+ std::make_pair(LCTL(KC_A), "QK_MODS(KC_A, QK_LCTL)"),
+ std::make_pair(HYPR(KC_SPACE), "QK_MODS(KC_SPACE, QK_LCTL | QK_LSFT | QK_LALT | QK_LGUI)")
+));
+// clang-format on
diff --git a/tests/basic/test_keypress.cpp b/tests/basic/test_keypress.cpp
index 6d5b502a00..34682654b0 100644
--- a/tests/basic/test_keypress.cpp
+++ b/tests/basic/test_keypress.cpp
@@ -175,23 +175,23 @@ TEST_F(KeyPress, PressPlusEqualReleaseBeforePress) {
EXPECT_REPORT(driver, (KC_LEFT_SHIFT));
EXPECT_REPORT(driver, (KC_LEFT_SHIFT, KC_EQUAL));
run_one_scan_loop();
- testing::Mock::VerifyAndClearExpectations(&driver);
+ VERIFY_AND_CLEAR(driver);
key_plus.release();
EXPECT_REPORT(driver, (KC_LEFT_SHIFT));
EXPECT_EMPTY_REPORT(driver);
run_one_scan_loop();
- testing::Mock::VerifyAndClearExpectations(&driver);
+ VERIFY_AND_CLEAR(driver);
key_eql.press();
EXPECT_REPORT(driver, (key_eql.report_code));
run_one_scan_loop();
- testing::Mock::VerifyAndClearExpectations(&driver);
+ VERIFY_AND_CLEAR(driver);
key_eql.release();
EXPECT_EMPTY_REPORT(driver);
run_one_scan_loop();
- testing::Mock::VerifyAndClearExpectations(&driver);
+ VERIFY_AND_CLEAR(driver);
}
TEST_F(KeyPress, PressPlusEqualDontReleaseBeforePress) {
@@ -206,24 +206,24 @@ TEST_F(KeyPress, PressPlusEqualDontReleaseBeforePress) {
EXPECT_REPORT(driver, (KC_LEFT_SHIFT));
EXPECT_REPORT(driver, (KC_LEFT_SHIFT, KC_EQUAL));
run_one_scan_loop();
- testing::Mock::VerifyAndClearExpectations(&driver);
+ VERIFY_AND_CLEAR(driver);
key_eql.press();
EXPECT_EMPTY_REPORT(driver);
EXPECT_REPORT(driver, (KC_EQUAL));
run_one_scan_loop();
- testing::Mock::VerifyAndClearExpectations(&driver);
+ VERIFY_AND_CLEAR(driver);
key_plus.release();
// BUG: Should really still return KC_EQUAL, but this is fine too
EXPECT_EMPTY_REPORT(driver);
run_one_scan_loop();
- testing::Mock::VerifyAndClearExpectations(&driver);
+ VERIFY_AND_CLEAR(driver);
key_eql.release();
EXPECT_NO_REPORT(driver);
run_one_scan_loop();
- testing::Mock::VerifyAndClearExpectations(&driver);
+ VERIFY_AND_CLEAR(driver);
}
TEST_F(KeyPress, PressEqualPlusReleaseBeforePress) {
@@ -237,24 +237,24 @@ TEST_F(KeyPress, PressEqualPlusReleaseBeforePress) {
key_eql.press();
EXPECT_REPORT(driver, (KC_EQUAL));
run_one_scan_loop();
- testing::Mock::VerifyAndClearExpectations(&driver);
+ VERIFY_AND_CLEAR(driver);
key_eql.release();
EXPECT_EMPTY_REPORT(driver);
run_one_scan_loop();
- testing::Mock::VerifyAndClearExpectations(&driver);
+ VERIFY_AND_CLEAR(driver);
key_plus.press();
EXPECT_REPORT(driver, (KC_LEFT_SHIFT));
EXPECT_REPORT(driver, (KC_LEFT_SHIFT, KC_EQUAL));
run_one_scan_loop();
- testing::Mock::VerifyAndClearExpectations(&driver);
+ VERIFY_AND_CLEAR(driver);
key_plus.release();
EXPECT_REPORT(driver, (KC_LEFT_SHIFT));
EXPECT_EMPTY_REPORT(driver);
run_one_scan_loop();
- testing::Mock::VerifyAndClearExpectations(&driver);
+ VERIFY_AND_CLEAR(driver);
}
TEST_F(KeyPress, PressEqualPlusDontReleaseBeforePress) {
@@ -268,7 +268,7 @@ TEST_F(KeyPress, PressEqualPlusDontReleaseBeforePress) {
key_eql.press();
EXPECT_REPORT(driver, (KC_EQUAL));
run_one_scan_loop();
- testing::Mock::VerifyAndClearExpectations(&driver);
+ VERIFY_AND_CLEAR(driver);
key_plus.press();
// BUG: The sequence is a bit strange, but it works, the end result is that
@@ -277,16 +277,16 @@ TEST_F(KeyPress, PressEqualPlusDontReleaseBeforePress) {
EXPECT_REPORT(driver, (KC_LEFT_SHIFT));
EXPECT_REPORT(driver, (KC_LEFT_SHIFT, KC_EQUAL));
run_one_scan_loop();
- testing::Mock::VerifyAndClearExpectations(&driver);
+ VERIFY_AND_CLEAR(driver);
key_eql.release();
// I guess it's fine to still report shift here
EXPECT_REPORT(driver, (KC_LEFT_SHIFT));
run_one_scan_loop();
- testing::Mock::VerifyAndClearExpectations(&driver);
+ VERIFY_AND_CLEAR(driver);
key_plus.release();
EXPECT_EMPTY_REPORT(driver);
run_one_scan_loop();
- testing::Mock::VerifyAndClearExpectations(&driver);
+ VERIFY_AND_CLEAR(driver);
}
diff --git a/tests/basic/test_one_shot_keys.cpp b/tests/basic/test_one_shot_keys.cpp
index bb14221140..2401c2c837 100644
--- a/tests/basic/test_one_shot_keys.cpp
+++ b/tests/basic/test_one_shot_keys.cpp
@@ -36,12 +36,12 @@ TEST_F(OneShot, OSMWithoutAdditionalKeypressDoesNothing) {
run_one_scan_loop();
osm_key.release();
run_one_scan_loop();
- testing::Mock::VerifyAndClearExpectations(&driver);
+ VERIFY_AND_CLEAR(driver);
/* OSM are added when an actual report is send */
EXPECT_REPORT(driver, (osm_key.report_code));
send_keyboard_report();
- testing::Mock::VerifyAndClearExpectations(&driver);
+ VERIFY_AND_CLEAR(driver);
/* Make unit-test pass */
clear_oneshot_mods();
@@ -62,19 +62,19 @@ TEST_P(OneShotParametrizedTestFixture, OSMExpiredDoesNothing) {
run_one_scan_loop();
osm_key.release();
idle_for(ONESHOT_TIMEOUT);
- testing::Mock::VerifyAndClearExpectations(&driver);
+ VERIFY_AND_CLEAR(driver);
/* Press regular key */
EXPECT_REPORT(driver, (regular_key.report_code)).Times(1);
regular_key.press();
run_one_scan_loop();
- testing::Mock::VerifyAndClearExpectations(&driver);
+ VERIFY_AND_CLEAR(driver);
/* Release regular key */
EXPECT_EMPTY_REPORT(driver);
regular_key.release();
run_one_scan_loop();
- testing::Mock::VerifyAndClearExpectations(&driver);
+ VERIFY_AND_CLEAR(driver);
}
#endif
@@ -92,19 +92,19 @@ TEST_P(OneShotParametrizedTestFixture, OSMWithAdditionalKeypress) {
run_one_scan_loop();
osm_key.release();
run_one_scan_loop();
- testing::Mock::VerifyAndClearExpectations(&driver);
+ VERIFY_AND_CLEAR(driver);
/* Press regular key */
EXPECT_REPORT(driver, (osm_key.report_code, regular_key.report_code)).Times(1);
regular_key.press();
run_one_scan_loop();
- testing::Mock::VerifyAndClearExpectations(&driver);
+ VERIFY_AND_CLEAR(driver);
/* Release regular key */
EXPECT_EMPTY_REPORT(driver);
regular_key.release();
run_one_scan_loop();
- testing::Mock::VerifyAndClearExpectations(&driver);
+ VERIFY_AND_CLEAR(driver);
}
TEST_P(OneShotParametrizedTestFixture, OSMAsRegularModifierWithAdditionalKeypress) {
@@ -120,26 +120,26 @@ TEST_P(OneShotParametrizedTestFixture, OSMAsRegularModifierWithAdditionalKeypres
EXPECT_NO_REPORT(driver);
osm_key.press();
run_one_scan_loop();
- testing::Mock::VerifyAndClearExpectations(&driver);
+ VERIFY_AND_CLEAR(driver);
/* Press regular key */
EXPECT_NO_REPORT(driver);
regular_key.press();
run_one_scan_loop();
- testing::Mock::VerifyAndClearExpectations(&driver);
+ VERIFY_AND_CLEAR(driver);
/* Release regular key */
EXPECT_NO_REPORT(driver);
regular_key.release();
run_one_scan_loop();
- testing::Mock::VerifyAndClearExpectations(&driver);
+ VERIFY_AND_CLEAR(driver);
/* Release OSM */
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);
+ VERIFY_AND_CLEAR(driver);
}
// clang-format off
@@ -172,24 +172,24 @@ TEST_F(OneShot, OSLWithAdditionalKeypress) {
EXPECT_NO_REPORT(driver);
osl_key.press();
run_one_scan_loop();
- testing::Mock::VerifyAndClearExpectations(&driver);
+ VERIFY_AND_CLEAR(driver);
/* Release OSL key */
EXPECT_NO_REPORT(driver);
osl_key.release();
run_one_scan_loop();
- testing::Mock::VerifyAndClearExpectations(&driver);
+ VERIFY_AND_CLEAR(driver);
/* Press regular key */
EXPECT_REPORT(driver, (regular_key.report_code)).Times(1);
EXPECT_EMPTY_REPORT(driver);
regular_key.press();
run_one_scan_loop();
- testing::Mock::VerifyAndClearExpectations(&driver);
+ VERIFY_AND_CLEAR(driver);
/* Release regular key */
EXPECT_NO_REPORT(driver);
regular_key.release();
run_one_scan_loop();
- testing::Mock::VerifyAndClearExpectations(&driver);
+ VERIFY_AND_CLEAR(driver);
}
diff --git a/tests/basic/test_tapping.cpp b/tests/basic/test_tapping.cpp
index 6ff9cfe22b..3246f9cdfb 100644
--- a/tests/basic/test_tapping.cpp
+++ b/tests/basic/test_tapping.cpp
@@ -121,3 +121,72 @@ TEST_F(Tapping, ANewTapWithinTappingTermIsBuggy) {
key_shift_hold_p_tap.release();
run_one_scan_loop();
}
+
+TEST_F(Tapping, TapA_CTL_T_KeyWhileReleasingShift) {
+ TestDriver driver;
+ InSequence s;
+ auto shift_key = KeymapKey(0, 7, 0, KC_LSFT);
+ auto mod_tap_hold_key = KeymapKey(0, 8, 0, CTL_T(KC_P));
+
+ set_keymap({shift_key, mod_tap_hold_key});
+
+ shift_key.press();
+ // Shift is reported
+ EXPECT_REPORT(driver, (KC_LSFT));
+ run_one_scan_loop();
+ VERIFY_AND_CLEAR(driver);
+
+ mod_tap_hold_key.press();
+ // Tapping keys does nothing on press
+ EXPECT_NO_REPORT(driver);
+ run_one_scan_loop();
+
+ shift_key.release();
+ // Releasing shift is delayed while tapping is in progress
+ EXPECT_NO_REPORT(driver);
+ run_one_scan_loop();
+ VERIFY_AND_CLEAR(driver);
+
+ mod_tap_hold_key.release();
+ // Releasing mod-tap key reports the tap and releases shift
+ EXPECT_REPORT(driver, (KC_LSFT, KC_P));
+ EXPECT_REPORT(driver, (KC_P));
+ EXPECT_EMPTY_REPORT(driver);
+ run_one_scan_loop();
+ VERIFY_AND_CLEAR(driver);
+}
+
+TEST_F(Tapping, TapA_CTL_T_KeyWhileReleasingLayer) {
+ TestDriver driver;
+ InSequence s;
+ auto layer_key = KeymapKey(0, 7, 0, MO(1));
+ auto trans_key = KeymapKey(1, 7, 0, KC_TRNS);
+ auto mod_tap_hold_key0 = KeymapKey(0, 8, 0, CTL_T(KC_P));
+ auto mod_tap_hold_key1 = KeymapKey(1, 8, 0, CTL_T(KC_Q));
+
+ set_keymap({layer_key, trans_key, mod_tap_hold_key0, mod_tap_hold_key1});
+
+ layer_key.press();
+ // Pressing the layer key does nothing
+ EXPECT_NO_REPORT(driver);
+ run_one_scan_loop();
+
+ mod_tap_hold_key1.press();
+ // Tapping layer 1 mod-tap key does nothing on press
+ EXPECT_NO_REPORT(driver);
+ run_one_scan_loop();
+
+ layer_key.release();
+ // Releasing layer is delayed while tapping is in progress
+ EXPECT_NO_REPORT(driver);
+ run_one_scan_loop();
+ VERIFY_AND_CLEAR(driver);
+
+ mod_tap_hold_key1.release();
+ // Releasing mod-tap key reports the tap of the layer 1 key
+ // If delayed layer release is broken, this reports the layer 0 key
+ EXPECT_REPORT(driver, (KC_Q));
+ EXPECT_EMPTY_REPORT(driver);
+ run_one_scan_loop();
+ VERIFY_AND_CLEAR(driver);
+}