diff options
Diffstat (limited to 'tests/basic/test_tapping.cpp')
| -rw-r--r-- | tests/basic/test_tapping.cpp | 50 |
1 files changed, 38 insertions, 12 deletions
diff --git a/tests/basic/test_tapping.cpp b/tests/basic/test_tapping.cpp index 88ab97eb6..e4a7e4a9f 100644 --- a/tests/basic/test_tapping.cpp +++ b/tests/basic/test_tapping.cpp | |||
| @@ -14,8 +14,11 @@ | |||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 15 | */ | 15 | */ |
| 16 | 16 | ||
| 17 | #include "keyboard_report_util.hpp" | ||
| 18 | #include "keycode.h" | ||
| 17 | #include "test_common.hpp" | 19 | #include "test_common.hpp" |
| 18 | #include "action_tapping.h" | 20 | #include "action_tapping.h" |
| 21 | #include "test_keymap_key.hpp" | ||
| 19 | 22 | ||
| 20 | using testing::_; | 23 | using testing::_; |
| 21 | using testing::InSequence; | 24 | using testing::InSequence; |
| @@ -25,14 +28,19 @@ class Tapping : public TestFixture {}; | |||
| 25 | TEST_F(Tapping, TapA_SHFT_T_KeyReportsKey) { | 28 | TEST_F(Tapping, TapA_SHFT_T_KeyReportsKey) { |
| 26 | TestDriver driver; | 29 | TestDriver driver; |
| 27 | InSequence s; | 30 | InSequence s; |
| 31 | auto key_shift_hold_p_tap = KeymapKey(0, 7, 0, SFT_T(KC_P)); | ||
| 32 | |||
| 33 | set_keymap({key_shift_hold_p_tap}); | ||
| 28 | 34 | ||
| 29 | press_key(7, 0); | ||
| 30 | // Tapping keys does nothing on press | 35 | // Tapping keys does nothing on press |
| 36 | key_shift_hold_p_tap.press(); | ||
| 31 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 37 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); |
| 32 | run_one_scan_loop(); | 38 | run_one_scan_loop(); |
| 33 | release_key(7, 0); | 39 | |
| 34 | // First we get the key press | 40 | // First we get the key press |
| 41 | key_shift_hold_p_tap.release(); | ||
| 35 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_P))); | 42 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_P))); |
| 43 | |||
| 36 | // Then the release | 44 | // Then the release |
| 37 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())); | 45 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())); |
| 38 | run_one_scan_loop(); | 46 | run_one_scan_loop(); |
| @@ -41,12 +49,21 @@ TEST_F(Tapping, TapA_SHFT_T_KeyReportsKey) { | |||
| 41 | TEST_F(Tapping, HoldA_SHFT_T_KeyReportsShift) { | 49 | TEST_F(Tapping, HoldA_SHFT_T_KeyReportsShift) { |
| 42 | TestDriver driver; | 50 | TestDriver driver; |
| 43 | InSequence s; | 51 | InSequence s; |
| 52 | auto mod_tap_hold_key = KeymapKey(0, 7, 0, SFT_T(KC_P)); | ||
| 53 | |||
| 54 | set_keymap({mod_tap_hold_key}); | ||
| 55 | |||
| 56 | mod_tap_hold_key.press(); | ||
| 44 | 57 | ||
| 45 | press_key(7, 0); | ||
| 46 | // Tapping keys does nothing on press | 58 | // Tapping keys does nothing on press |
| 47 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 59 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); |
| 48 | idle_for(TAPPING_TERM); | 60 | idle_for(TAPPING_TERM); |
| 49 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT))); | 61 | |
| 62 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT))); | ||
| 63 | run_one_scan_loop(); | ||
| 64 | |||
| 65 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())); | ||
| 66 | mod_tap_hold_key.release(); | ||
| 50 | run_one_scan_loop(); | 67 | run_one_scan_loop(); |
| 51 | } | 68 | } |
| 52 | 69 | ||
| @@ -54,12 +71,16 @@ TEST_F(Tapping, ANewTapWithinTappingTermIsBuggy) { | |||
| 54 | // See issue #1478 for more information | 71 | // See issue #1478 for more information |
| 55 | TestDriver driver; | 72 | TestDriver driver; |
| 56 | InSequence s; | 73 | InSequence s; |
| 74 | auto key_shift_hold_p_tap = KeymapKey(0, 7, 0, SFT_T(KC_P)); | ||
| 75 | |||
| 76 | set_keymap({key_shift_hold_p_tap}); | ||
| 57 | 77 | ||
| 58 | press_key(7, 0); | ||
| 59 | // Tapping keys does nothing on press | 78 | // Tapping keys does nothing on press |
| 79 | key_shift_hold_p_tap.press(); | ||
| 60 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 80 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); |
| 61 | run_one_scan_loop(); | 81 | run_one_scan_loop(); |
| 62 | release_key(7, 0); | 82 | key_shift_hold_p_tap.release(); |
| 83 | |||
| 63 | // First we get the key press | 84 | // First we get the key press |
| 64 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_P))); | 85 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_P))); |
| 65 | // Then the release | 86 | // Then the release |
| @@ -67,19 +88,20 @@ TEST_F(Tapping, ANewTapWithinTappingTermIsBuggy) { | |||
| 67 | run_one_scan_loop(); | 88 | run_one_scan_loop(); |
| 68 | 89 | ||
| 69 | // This sends KC_P, even if it should do nothing | 90 | // This sends KC_P, even if it should do nothing |
| 70 | press_key(7, 0); | 91 | key_shift_hold_p_tap.press(); |
| 71 | // This test should not succed if everything works correctly | 92 | // This test should not succed if everything works correctly |
| 72 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_P))); | 93 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_P))); |
| 73 | run_one_scan_loop(); | 94 | run_one_scan_loop(); |
| 74 | release_key(7, 0); | 95 | |
| 96 | key_shift_hold_p_tap.release(); | ||
| 75 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())); | 97 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())); |
| 76 | idle_for(TAPPING_TERM + 1); | 98 | idle_for(TAPPING_TERM + 1); |
| 77 | 99 | ||
| 78 | // 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 |
| 79 | press_key(7, 0); | 101 | key_shift_hold_p_tap.press(); |
| 80 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 102 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); |
| 81 | run_one_scan_loop(); | 103 | run_one_scan_loop(); |
| 82 | release_key(7, 0); | 104 | key_shift_hold_p_tap.release(); |
| 83 | 105 | ||
| 84 | // First we get the key press | 106 | // First we get the key press |
| 85 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_P))); | 107 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_P))); |
| @@ -90,8 +112,12 @@ TEST_F(Tapping, ANewTapWithinTappingTermIsBuggy) { | |||
| 90 | // 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 |
| 91 | // But the stranges part is: | 113 | // But the stranges part is: |
| 92 | // 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 |
| 93 | press_key(7, 0); | 115 | key_shift_hold_p_tap.press(); |
| 94 | // Shouldn't be called here really | 116 | // Shouldn't be called here really |
| 95 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT))).Times(1); | 117 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT))).Times(1); |
| 96 | idle_for(TAPPING_TERM); | 118 | idle_for(TAPPING_TERM); |
| 97 | } | 119 | |
| 120 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())); | ||
| 121 | key_shift_hold_p_tap.release(); | ||
| 122 | run_one_scan_loop(); | ||
| 123 | } \ No newline at end of file | ||
