aboutsummaryrefslogtreecommitdiff
path: root/tests/tap_hold_configurations/retro_tapping/test_tapping.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/tap_hold_configurations/retro_tapping/test_tapping.cpp')
-rw-r--r--tests/tap_hold_configurations/retro_tapping/test_tapping.cpp112
1 files changed, 112 insertions, 0 deletions
diff --git a/tests/tap_hold_configurations/retro_tapping/test_tapping.cpp b/tests/tap_hold_configurations/retro_tapping/test_tapping.cpp
new file mode 100644
index 000000000..cf23df831
--- /dev/null
+++ b/tests/tap_hold_configurations/retro_tapping/test_tapping.cpp
@@ -0,0 +1,112 @@
1/* Copyright 2021 Stefan Kerkmann
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
17#include "keyboard_report_util.hpp"
18#include "keycode.h"
19#include "test_common.hpp"
20#include "action_tapping.h"
21#include "test_keymap_key.hpp"
22
23using testing::_;
24using testing::InSequence;
25
26class Tapping : public TestFixture {};
27
28TEST_F(Tapping, HoldA_SHFT_T_KeyReportsShift) {
29 TestDriver driver;
30 InSequence s;
31 auto mod_tap_hold_key = KeymapKey(0, 7, 0, SFT_T(KC_P));
32
33 set_keymap({mod_tap_hold_key});
34
35 EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
36 mod_tap_hold_key.press();
37 idle_for(TAPPING_TERM);
38 testing::Mock::VerifyAndClearExpectations(&driver);
39
40 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT)));
41 run_one_scan_loop();
42 testing::Mock::VerifyAndClearExpectations(&driver);
43
44 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
45 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_P)));
46 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
47 mod_tap_hold_key.release();
48 run_one_scan_loop();
49 testing::Mock::VerifyAndClearExpectations(&driver);
50}
51
52TEST_F(Tapping, ANewTapWithinTappingTermIsBuggy) {
53 TestDriver driver;
54 InSequence s;
55 auto key_shift_hold_p_tap = KeymapKey(0, 7, 0, SFT_T(KC_P));
56
57 set_keymap({key_shift_hold_p_tap});
58
59 /* Press mod_tap_hold key */
60 EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
61 key_shift_hold_p_tap.press();
62 run_one_scan_loop();
63 testing::Mock::VerifyAndClearExpectations(&driver);
64
65 /* Release mod_tap_hold key */
66 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_P)));
67 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
68 key_shift_hold_p_tap.release();
69 run_one_scan_loop();
70 testing::Mock::VerifyAndClearExpectations(&driver);
71
72 /* Press mod_tap_hold key again */
73 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_P)));
74 key_shift_hold_p_tap.press();
75 run_one_scan_loop();
76 testing::Mock::VerifyAndClearExpectations(&driver);
77
78 /* Release mod_tap_hold key again */
79 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
80 key_shift_hold_p_tap.release();
81 idle_for(TAPPING_TERM + 1);
82 testing::Mock::VerifyAndClearExpectations(&driver);
83
84 /* Press mod_tap_hold key again */
85 EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
86 key_shift_hold_p_tap.press();
87 run_one_scan_loop();
88 testing::Mock::VerifyAndClearExpectations(&driver);
89
90 /* Release mod_tap_hold key again */
91 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_P)));
92 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
93 key_shift_hold_p_tap.release();
94 idle_for(TAPPING_TERM + 1);
95 testing::Mock::VerifyAndClearExpectations(&driver);
96
97 /* Press mod_tap_hold key again */
98 EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
99 key_shift_hold_p_tap.press();
100 idle_for(TAPPING_TERM);
101 testing::Mock::VerifyAndClearExpectations(&driver);
102
103 /* Release mod_tap_hold key again */
104 /* TODO: Why is KC_LSFT send? */
105 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT)));
106 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
107 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_P)));
108 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
109 key_shift_hold_p_tap.release();
110 run_one_scan_loop();
111 testing::Mock::VerifyAndClearExpectations(&driver);
112} \ No newline at end of file