diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/basic/test_tapping.cpp | 69 | ||||
-rw-r--r-- | tests/caps_word/test_caps_word.cpp | 53 | ||||
-rw-r--r-- | tests/tap_hold_configurations/quick_tap/config.h (renamed from tests/tap_hold_configurations/tapping_force_hold/config.h) | 2 | ||||
-rw-r--r-- | tests/tap_hold_configurations/quick_tap/test.mk (renamed from tests/tap_hold_configurations/tapping_force_hold/test.mk) | 0 | ||||
-rw-r--r-- | tests/tap_hold_configurations/quick_tap/test_action_layer.cpp (renamed from tests/tap_hold_configurations/tapping_force_hold/test_action_layer.cpp) | 2 | ||||
-rw-r--r-- | tests/tap_hold_configurations/quick_tap/test_quick_tap.cpp | 290 | ||||
-rw-r--r-- | tests/tap_hold_configurations/tapping_force_hold/test_tap_hold.cpp | 213 |
7 files changed, 414 insertions, 215 deletions
diff --git a/tests/basic/test_tapping.cpp b/tests/basic/test_tapping.cpp index 6ff9cfe22b..faf9b9fe91 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(); + testing::Mock::VerifyAndClearExpectations(&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(); + testing::Mock::VerifyAndClearExpectations(&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(); + testing::Mock::VerifyAndClearExpectations(&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(); + testing::Mock::VerifyAndClearExpectations(&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(); + testing::Mock::VerifyAndClearExpectations(&driver); +} diff --git a/tests/caps_word/test_caps_word.cpp b/tests/caps_word/test_caps_word.cpp index 3d0735d8c2..e5ecbb844e 100644 --- a/tests/caps_word/test_caps_word.cpp +++ b/tests/caps_word/test_caps_word.cpp @@ -591,6 +591,57 @@ INSTANTIATE_TEST_CASE_P( ), CapsWordDoubleTapShiftParams::GetName ); -// clang-format on +// Tests that holding a OSL keeps caps word active and shifts keys on the layer that need to be shifted. +TEST_F(CapsWord, IgnoresOSLHold) { + TestDriver driver; + KeymapKey key_a(0, 0, 0, KC_A); + KeymapKey key_osl(0, 1, 0, OSL(1)); + KeymapKey key_b(1, 0, 0, KC_B); + set_keymap({key_a, key_osl, key_b}); + + // Allow any number of reports with no keys or only modifiers. + // clang-format off + EXPECT_CALL(driver, send_keyboard_mock(AnyOf( + KeyboardReport(), + KeyboardReport(KC_LSFT)))) + .Times(AnyNumber()); + + EXPECT_REPORT(driver, (KC_LSFT, KC_B)); + caps_word_on(); + + key_osl.press(); + run_one_scan_loop(); + tap_key(key_b); + key_osl.release(); + run_one_scan_loop(); + + testing::Mock::VerifyAndClearExpectations(&driver); +} + +// Tests that tapping a OSL keeps caps word active and shifts keys on the layer that need to be shifted. +TEST_F(CapsWord, IgnoresOSLTap) { + TestDriver driver; + KeymapKey key_a(0, 0, 0, KC_A); + KeymapKey key_osl(0, 1, 0, OSL(1)); + KeymapKey key_b(1, 0, 0, KC_B); + set_keymap({key_a, key_osl, key_b}); + + // Allow any number of reports with no keys or only modifiers. + // clang-format off + EXPECT_CALL(driver, send_keyboard_mock(AnyOf( + KeyboardReport(), + KeyboardReport(KC_LSFT)))) + .Times(AnyNumber()); + + EXPECT_REPORT(driver, (KC_LSFT, KC_B)); + caps_word_on(); + + tap_key(key_osl); + tap_key(key_b); + run_one_scan_loop(); + + testing::Mock::VerifyAndClearExpectations(&driver); +} +// clang-format on } // namespace diff --git a/tests/tap_hold_configurations/tapping_force_hold/config.h b/tests/tap_hold_configurations/quick_tap/config.h index 3b4646338a..cd82d3b5a5 100644 --- a/tests/tap_hold_configurations/tapping_force_hold/config.h +++ b/tests/tap_hold_configurations/quick_tap/config.h @@ -18,4 +18,4 @@ #include "test_common.h" -#define TAPPING_FORCE_HOLD
\ No newline at end of file +#define QUICK_TAP_TERM 100 diff --git a/tests/tap_hold_configurations/tapping_force_hold/test.mk b/tests/tap_hold_configurations/quick_tap/test.mk index efecca2c22..efecca2c22 100644 --- a/tests/tap_hold_configurations/tapping_force_hold/test.mk +++ b/tests/tap_hold_configurations/quick_tap/test.mk diff --git a/tests/tap_hold_configurations/tapping_force_hold/test_action_layer.cpp b/tests/tap_hold_configurations/quick_tap/test_action_layer.cpp index 965c702d7a..9c3b38050a 100644 --- a/tests/tap_hold_configurations/tapping_force_hold/test_action_layer.cpp +++ b/tests/tap_hold_configurations/quick_tap/test_action_layer.cpp @@ -40,6 +40,8 @@ TEST_F(ActionLayer, LayerTapToggleWithToggleWithKeypress) { run_one_scan_loop(); expect_layer_state(0); + idle_for(QUICK_TAP_TERM + 10); + layer_key.press(); run_one_scan_loop(); layer_key.release(); diff --git a/tests/tap_hold_configurations/quick_tap/test_quick_tap.cpp b/tests/tap_hold_configurations/quick_tap/test_quick_tap.cpp new file mode 100644 index 0000000000..e2f8c51340 --- /dev/null +++ b/tests/tap_hold_configurations/quick_tap/test_quick_tap.cpp @@ -0,0 +1,290 @@ +/* Copyright 2021 Stefan Kerkmann + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include "config.h" +#include "keyboard_report_util.hpp" +#include "keycode.h" +#include "test_common.hpp" +#include "action_tapping.h" +#include "test_fixture.hpp" +#include "test_keymap_key.hpp" + +using testing::_; +using testing::InSequence; + +class QuickTap : public TestFixture {}; + +TEST_F(QuickTap, tap_regular_key_while_mod_tap_key_is_held) { + TestDriver driver; + InSequence s; + auto mod_tap_key = KeymapKey(0, 1, 0, SFT_T(KC_P)); + auto regular_key = KeymapKey(0, 2, 0, KC_A); + + set_keymap({mod_tap_key, regular_key}); + + /* Press mod-tap key. */ + EXPECT_NO_REPORT(driver); + mod_tap_key.press(); + run_one_scan_loop(); + testing::Mock::VerifyAndClearExpectations(&driver); + + /* Press regular key. */ + EXPECT_NO_REPORT(driver); + regular_key.press(); + run_one_scan_loop(); + testing::Mock::VerifyAndClearExpectations(&driver); + + /* Release regular key. */ + EXPECT_NO_REPORT(driver); + regular_key.release(); + run_one_scan_loop(); + testing::Mock::VerifyAndClearExpectations(&driver); + + /* Release mod-tap key. */ + EXPECT_REPORT(driver, (KC_LSFT)); + mod_tap_key.release(); + run_one_scan_loop(); + testing::Mock::VerifyAndClearExpectations(&driver); + + /* Idle for tapping term of mod tap hold key. */ + EXPECT_REPORT(driver, (KC_LSFT, KC_A)); + EXPECT_REPORT(driver, (KC_LSFT)); + EXPECT_EMPTY_REPORT(driver); + idle_for(TAPPING_TERM - 3); + testing::Mock::VerifyAndClearExpectations(&driver); +} + +TEST_F(QuickTap, tap_mod_tap_key_while_mod_tap_key_is_held) { + TestDriver driver; + InSequence s; + auto first_mod_tap_key = KeymapKey(0, 1, 0, SFT_T(KC_P)); + auto second_mod_tap_key = KeymapKey(0, 2, 0, RSFT_T(KC_A)); + + set_keymap({first_mod_tap_key, second_mod_tap_key}); + + /* Press first mod-tap key */ + EXPECT_NO_REPORT(driver); + first_mod_tap_key.press(); + run_one_scan_loop(); + testing::Mock::VerifyAndClearExpectations(&driver); + + /* Press second mod-tap key */ + EXPECT_NO_REPORT(driver); + second_mod_tap_key.press(); + run_one_scan_loop(); + testing::Mock::VerifyAndClearExpectations(&driver); + + /* Release second tap-hold key */ + EXPECT_NO_REPORT(driver); + second_mod_tap_key.release(); + run_one_scan_loop(); + testing::Mock::VerifyAndClearExpectations(&driver); + + /* Release first mod-tap key */ + EXPECT_REPORT(driver, (KC_LSFT)); + first_mod_tap_key.release(); + run_one_scan_loop(); + testing::Mock::VerifyAndClearExpectations(&driver); + + /* Idle for tapping term of first mod-tap key. */ + EXPECT_REPORT(driver, (KC_LSFT, KC_A)); + EXPECT_REPORT(driver, (KC_LSFT)); + EXPECT_EMPTY_REPORT(driver); + idle_for(TAPPING_TERM - 3); + testing::Mock::VerifyAndClearExpectations(&driver); +} + +TEST_F(QuickTap, tap_regular_key_while_layer_tap_key_is_held) { + TestDriver driver; + InSequence s; + auto layer_tap_key = KeymapKey(0, 1, 0, LT(1, KC_P)); + auto regular_key = KeymapKey(0, 2, 0, KC_A); + auto layer_key = KeymapKey(1, 2, 0, KC_B); + + set_keymap({layer_tap_key, regular_key, layer_key}); + + /* Press layer-tap key */ + EXPECT_NO_REPORT(driver); + layer_tap_key.press(); + run_one_scan_loop(); + testing::Mock::VerifyAndClearExpectations(&driver); + + /* Press regular key */ + EXPECT_NO_REPORT(driver); + regular_key.press(); + run_one_scan_loop(); + testing::Mock::VerifyAndClearExpectations(&driver); + + /* Release regular key */ + EXPECT_NO_REPORT(driver); + regular_key.release(); + run_one_scan_loop(); + testing::Mock::VerifyAndClearExpectations(&driver); + + /* Release layer-tap key */ + EXPECT_REPORT(driver, (KC_P)); + EXPECT_REPORT(driver, (KC_A, KC_P)); + EXPECT_REPORT(driver, (KC_P)); + EXPECT_EMPTY_REPORT(driver); + layer_tap_key.release(); + run_one_scan_loop(); + testing::Mock::VerifyAndClearExpectations(&driver); +} + +TEST_F(QuickTap, tap_key_and_tap_again_before_quick_tap_term) { + TestDriver driver; + InSequence s; + auto mod_tap_key = KeymapKey(0, 1, 0, SFT_T(KC_P)); + + set_keymap({mod_tap_key}); + + /* Press mod-tap key. */ + EXPECT_NO_REPORT(driver); + mod_tap_key.press(); + run_one_scan_loop(); + testing::Mock::VerifyAndClearExpectations(&driver); + + /* Release mod-tap key. */ + EXPECT_REPORT(driver, (KC_P)); + EXPECT_EMPTY_REPORT(driver); + mod_tap_key.release(); + idle_for(QUICK_TAP_TERM - 10); + run_one_scan_loop(); + testing::Mock::VerifyAndClearExpectations(&driver); + + /* Press and tap mod-tap key again. */ + EXPECT_REPORT(driver, (KC_P)); + mod_tap_key.press(); + run_one_scan_loop(); + testing::Mock::VerifyAndClearExpectations(&driver); + + /* Release mod-tap key. */ + EXPECT_EMPTY_REPORT(driver); + mod_tap_key.release(); + run_one_scan_loop(); + testing::Mock::VerifyAndClearExpectations(&driver); +} + +TEST_F(QuickTap, tap_key_and_hold_again_before_quick_tap_term) { + TestDriver driver; + InSequence s; + auto mod_tap_key = KeymapKey(0, 1, 0, SFT_T(KC_P)); + + set_keymap({mod_tap_key}); + + /* Press mod-tap key. */ + EXPECT_NO_REPORT(driver); + mod_tap_key.press(); + run_one_scan_loop(); + testing::Mock::VerifyAndClearExpectations(&driver); + + /* Release mod-tap key. */ + EXPECT_REPORT(driver, (KC_P)); + EXPECT_EMPTY_REPORT(driver); + mod_tap_key.release(); + idle_for(QUICK_TAP_TERM - 10); + testing::Mock::VerifyAndClearExpectations(&driver); + + /* Press and hold mod-tap key again. */ + EXPECT_REPORT(driver, (KC_P)); + mod_tap_key.press(); + run_one_scan_loop(); + testing::Mock::VerifyAndClearExpectations(&driver); + + /* Wait until tapping term expired */ + EXPECT_NO_REPORT(driver); + idle_for(TAPPING_TERM); + testing::Mock::VerifyAndClearExpectations(&driver); + + /* Release mod-tap key. */ + EXPECT_EMPTY_REPORT(driver); + mod_tap_key.release(); + run_one_scan_loop(); + testing::Mock::VerifyAndClearExpectations(&driver); +} + +TEST_F(QuickTap, tap_key_and_tap_again_after_quick_tap_term) { + TestDriver driver; + InSequence s; + auto mod_tap_key = KeymapKey(0, 1, 0, SFT_T(KC_P)); + + set_keymap({mod_tap_key}); + + /* Press mod-tap key. */ + EXPECT_NO_REPORT(driver); + mod_tap_key.press(); + run_one_scan_loop(); + testing::Mock::VerifyAndClearExpectations(&driver); + + /* Release mod-tap key. */ + EXPECT_REPORT(driver, (KC_P)); + EXPECT_EMPTY_REPORT(driver); + mod_tap_key.release(); + idle_for(QUICK_TAP_TERM + 10); + run_one_scan_loop(); + testing::Mock::VerifyAndClearExpectations(&driver); + + /* Press mod-tap key again. */ + EXPECT_NO_REPORT(driver); + mod_tap_key.press(); + run_one_scan_loop(); + testing::Mock::VerifyAndClearExpectations(&driver); + + /* Release mod-tap key. */ + EXPECT_REPORT(driver, (KC_P)); + EXPECT_EMPTY_REPORT(driver); + mod_tap_key.release(); + run_one_scan_loop(); + testing::Mock::VerifyAndClearExpectations(&driver); +} + +TEST_F(QuickTap, tap_key_and_hold_again_after_quick_tap_term) { + TestDriver driver; + InSequence s; + auto mod_tap_key = KeymapKey(0, 1, 0, SFT_T(KC_P)); + + set_keymap({mod_tap_key}); + + /* Press mod-tap key. */ + EXPECT_NO_REPORT(driver); + mod_tap_key.press(); + run_one_scan_loop(); + testing::Mock::VerifyAndClearExpectations(&driver); + + /* Release mod-tap key. */ + EXPECT_REPORT(driver, (KC_P)); + EXPECT_EMPTY_REPORT(driver); + mod_tap_key.release(); + idle_for(QUICK_TAP_TERM + 10); + testing::Mock::VerifyAndClearExpectations(&driver); + + /* Press and hold mod-tap key again. */ + EXPECT_NO_REPORT(driver); + mod_tap_key.press(); + run_one_scan_loop(); + testing::Mock::VerifyAndClearExpectations(&driver); + + /* Wait until tapping term expired */ + EXPECT_REPORT(driver, (KC_LSFT)); + idle_for(TAPPING_TERM); + testing::Mock::VerifyAndClearExpectations(&driver); + + /* Release mod-tap key. */ + EXPECT_EMPTY_REPORT(driver); + mod_tap_key.release(); + run_one_scan_loop(); + testing::Mock::VerifyAndClearExpectations(&driver); +} 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 deleted file mode 100644 index 604f9a4a54..0000000000 --- a/tests/tap_hold_configurations/tapping_force_hold/test_tap_hold.cpp +++ /dev/null @@ -1,213 +0,0 @@ - -/* Copyright 2021 Stefan Kerkmann - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include "keyboard_report_util.hpp" -#include "keycode.h" -#include "test_common.hpp" -#include "action_tapping.h" -#include "test_fixture.hpp" -#include "test_keymap_key.hpp" - -using testing::_; -using testing::InSequence; - -class TappingForceHold : public TestFixture {}; - -TEST_F(TappingForceHold, tap_regular_key_while_mod_tap_key_is_held) { - TestDriver driver; - InSequence s; - auto mod_tap_hold_key = KeymapKey(0, 1, 0, SFT_T(KC_P)); - auto regular_key = KeymapKey(0, 2, 0, KC_A); - - set_keymap({mod_tap_hold_key, regular_key}); - - /* Press mod-tap-hold key. */ - EXPECT_NO_REPORT(driver); - mod_tap_hold_key.press(); - run_one_scan_loop(); - testing::Mock::VerifyAndClearExpectations(&driver); - - /* Press regular key. */ - EXPECT_NO_REPORT(driver); - regular_key.press(); - run_one_scan_loop(); - testing::Mock::VerifyAndClearExpectations(&driver); - - /* Release regular key. */ - EXPECT_NO_REPORT(driver); - regular_key.release(); - run_one_scan_loop(); - testing::Mock::VerifyAndClearExpectations(&driver); - - /* Release mod-tap-hold key. */ - EXPECT_REPORT(driver, (KC_LSFT)); - mod_tap_hold_key.release(); - run_one_scan_loop(); - testing::Mock::VerifyAndClearExpectations(&driver); - - /* Idle for tapping term of mod tap hold key. */ - EXPECT_REPORT(driver, (KC_LSFT, KC_A)); - EXPECT_REPORT(driver, (KC_LSFT)); - EXPECT_EMPTY_REPORT(driver); - idle_for(TAPPING_TERM - 3); - testing::Mock::VerifyAndClearExpectations(&driver); -} - -TEST_F(TappingForceHold, tap_mod_tap_key_while_mod_tap_key_is_held) { - TestDriver driver; - InSequence s; - auto first_mod_tap_hold_key = KeymapKey(0, 1, 0, SFT_T(KC_P)); - auto second_mod_tap_hold_key = KeymapKey(0, 2, 0, RSFT_T(KC_A)); - - set_keymap({first_mod_tap_hold_key, second_mod_tap_hold_key}); - - /* Press first mod-tap-hold key */ - EXPECT_NO_REPORT(driver); - first_mod_tap_hold_key.press(); - run_one_scan_loop(); - testing::Mock::VerifyAndClearExpectations(&driver); - - /* Press second tap-hold key */ - EXPECT_NO_REPORT(driver); - second_mod_tap_hold_key.press(); - run_one_scan_loop(); - testing::Mock::VerifyAndClearExpectations(&driver); - - /* Release second tap-hold key */ - EXPECT_NO_REPORT(driver); - second_mod_tap_hold_key.release(); - run_one_scan_loop(); - testing::Mock::VerifyAndClearExpectations(&driver); - - /* Release first mod-tap-hold key */ - EXPECT_REPORT(driver, (KC_LSFT)); - first_mod_tap_hold_key.release(); - run_one_scan_loop(); - testing::Mock::VerifyAndClearExpectations(&driver); - - /* Idle for tapping term of first mod tap hold key. */ - EXPECT_REPORT(driver, (KC_LSFT, KC_A)); - EXPECT_REPORT(driver, (KC_LSFT)); - EXPECT_EMPTY_REPORT(driver); - idle_for(TAPPING_TERM - 3); - testing::Mock::VerifyAndClearExpectations(&driver); -} - -TEST_F(TappingForceHold, tap_regular_key_while_layer_tap_key_is_held) { - TestDriver driver; - InSequence s; - auto layer_tap_hold_key = KeymapKey(0, 1, 0, LT(1, KC_P)); - auto regular_key = KeymapKey(0, 2, 0, KC_A); - auto layer_key = KeymapKey(1, 2, 0, KC_B); - - set_keymap({layer_tap_hold_key, regular_key, layer_key}); - - /* Press layer-tap-hold key */ - EXPECT_NO_REPORT(driver); - layer_tap_hold_key.press(); - run_one_scan_loop(); - testing::Mock::VerifyAndClearExpectations(&driver); - - /* Press regular key */ - EXPECT_NO_REPORT(driver); - regular_key.press(); - run_one_scan_loop(); - testing::Mock::VerifyAndClearExpectations(&driver); - - /* Release regular key */ - EXPECT_NO_REPORT(driver); - regular_key.release(); - run_one_scan_loop(); - testing::Mock::VerifyAndClearExpectations(&driver); - - /* Release layer-tap-hold key */ - EXPECT_REPORT(driver, (KC_P)); - EXPECT_REPORT(driver, (KC_A, KC_P)); - EXPECT_REPORT(driver, (KC_P)); - EXPECT_EMPTY_REPORT(driver); - layer_tap_hold_key.release(); - run_one_scan_loop(); - testing::Mock::VerifyAndClearExpectations(&driver); -} - -TEST_F(TappingForceHold, tap_mod_tap_hold_key_two_times) { - TestDriver driver; - InSequence s; - auto mod_tap_hold_key = KeymapKey(0, 1, 0, SFT_T(KC_P)); - - set_keymap({mod_tap_hold_key}); - - /* Press mod-tap-hold key. */ - EXPECT_NO_REPORT(driver); - mod_tap_hold_key.press(); - run_one_scan_loop(); - testing::Mock::VerifyAndClearExpectations(&driver); - - /* Release mod-tap-hold key. */ - EXPECT_REPORT(driver, (KC_P)); - EXPECT_EMPTY_REPORT(driver); - mod_tap_hold_key.release(); - run_one_scan_loop(); - testing::Mock::VerifyAndClearExpectations(&driver); - - /* Press mod-tap-hold key again. */ - EXPECT_NO_REPORT(driver); - mod_tap_hold_key.press(); - run_one_scan_loop(); - testing::Mock::VerifyAndClearExpectations(&driver); - - /* Release mod-tap-hold key. */ - EXPECT_REPORT(driver, (KC_P)); - EXPECT_EMPTY_REPORT(driver); - mod_tap_hold_key.release(); - run_one_scan_loop(); - testing::Mock::VerifyAndClearExpectations(&driver); -} - -TEST_F(TappingForceHold, tap_mod_tap_hold_key_twice_and_hold_on_second_time) { - TestDriver driver; - InSequence s; - auto mod_tap_hold_key = KeymapKey(0, 1, 0, SFT_T(KC_P)); - - set_keymap({mod_tap_hold_key}); - - /* Press mod-tap-hold key. */ - EXPECT_NO_REPORT(driver); - mod_tap_hold_key.press(); - run_one_scan_loop(); - testing::Mock::VerifyAndClearExpectations(&driver); - - /* Release mod-tap-hold key. */ - EXPECT_REPORT(driver, (KC_P)); - EXPECT_EMPTY_REPORT(driver); - mod_tap_hold_key.release(); - run_one_scan_loop(); - testing::Mock::VerifyAndClearExpectations(&driver); - - /* Press mod-tap-hold key again. */ - EXPECT_NO_REPORT(driver); - mod_tap_hold_key.press(); - idle_for(TAPPING_TERM); - testing::Mock::VerifyAndClearExpectations(&driver); - - /* Release mod-tap-hold key. */ - EXPECT_REPORT(driver, (KC_LEFT_SHIFT)); - EXPECT_EMPTY_REPORT(driver); - mod_tap_hold_key.release(); - run_one_scan_loop(); - testing::Mock::VerifyAndClearExpectations(&driver); -} |