summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAlbert Y <76888457+filterpaper@users.noreply.github.com>2022-12-12 23:52:22 +0800
committerGitHub <noreply@github.com>2022-12-12 16:52:22 +0100
commitcbabc8dbe6a8476d3082e8bc649d330f87e7b904 (patch)
tree55e73275367047981295d046867d9f70352814c7 /tests
parent8698d109d7c2f4554e0f3c01b017738a0a47f162 (diff)
[Core] Replace Tapping Force Hold feature with Quick Tap Term (#17007)
* Replace Tapping Force Hold feature with Quick Tap Term * Replace keyboard level TAPPING_FORCE_HOLD with QUICK_TAP_TERM 0 * Deprecate force hold in info_config.json * Before and after quick tap term unit tests * Quick tap unit tests iteration * Keymap config.h correction * Remove TAPPING_FORCE_HOLD_PER_KEY macros that were missed * Add two more test cases for quick tap * Replace TAPPING_FORCE_HOLD with QUICK_TAP_TERM in configs #2 * Replace TAPPING_FORCE_HOLD_PER_KEY with QUICK_TAP_TERM_PER_KEY in configs #2 * Add function declaration for get_quick_tap_term Co-authored-by: Stefan Kerkmann <karlk90@pm.me>
Diffstat (limited to 'tests')
-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 (renamed from tests/tap_hold_configurations/tapping_force_hold/test_tap_hold.cpp)180
4 files changed, 132 insertions, 52 deletions
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 @@
18 18
19#include "test_common.h" 19#include "test_common.h"
20 20
21#define TAPPING_FORCE_HOLD \ No newline at end of file 21#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) {
40 run_one_scan_loop(); 40 run_one_scan_loop();
41 expect_layer_state(0); 41 expect_layer_state(0);
42 42
43 idle_for(QUICK_TAP_TERM + 10);
44
43 layer_key.press(); 45 layer_key.press();
44 run_one_scan_loop(); 46 run_one_scan_loop();
45 layer_key.release(); 47 layer_key.release();
diff --git a/tests/tap_hold_configurations/tapping_force_hold/test_tap_hold.cpp b/tests/tap_hold_configurations/quick_tap/test_quick_tap.cpp
index 604f9a4a54..be43f8e6c4 100644
--- a/tests/tap_hold_configurations/tapping_force_hold/test_tap_hold.cpp
+++ b/tests/tap_hold_configurations/quick_tap/test_quick_tap.cpp
@@ -1,4 +1,3 @@
1
2/* Copyright 2021 Stefan Kerkmann 1/* Copyright 2021 Stefan Kerkmann
3 * 2 *
4 * This program is free software: you can redistribute it and/or modify 3 * This program is free software: you can redistribute it and/or modify
@@ -15,6 +14,7 @@
15 * 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/>.
16 */ 15 */
17 16
17#include "config.h"
18#include "keyboard_report_util.hpp" 18#include "keyboard_report_util.hpp"
19#include "keycode.h" 19#include "keycode.h"
20#include "test_common.hpp" 20#include "test_common.hpp"
@@ -25,19 +25,19 @@
25using testing::_; 25using testing::_;
26using testing::InSequence; 26using testing::InSequence;
27 27
28class TappingForceHold : public TestFixture {}; 28class QuickTap : public TestFixture {};
29 29
30TEST_F(TappingForceHold, tap_regular_key_while_mod_tap_key_is_held) { 30TEST_F(QuickTap, tap_regular_key_while_mod_tap_key_is_held) {
31 TestDriver driver; 31 TestDriver driver;
32 InSequence s; 32 InSequence s;
33 auto mod_tap_hold_key = KeymapKey(0, 1, 0, SFT_T(KC_P)); 33 auto mod_tap_key = KeymapKey(0, 1, 0, SFT_T(KC_P));
34 auto regular_key = KeymapKey(0, 2, 0, KC_A); 34 auto regular_key = KeymapKey(0, 2, 0, KC_A);
35 35
36 set_keymap({mod_tap_hold_key, regular_key}); 36 set_keymap({mod_tap_key, regular_key});
37 37
38 /* Press mod-tap-hold key. */ 38 /* Press mod-tap key. */
39 EXPECT_NO_REPORT(driver); 39 EXPECT_NO_REPORT(driver);
40 mod_tap_hold_key.press(); 40 mod_tap_key.press();
41 run_one_scan_loop(); 41 run_one_scan_loop();
42 testing::Mock::VerifyAndClearExpectations(&driver); 42 testing::Mock::VerifyAndClearExpectations(&driver);
43 43
@@ -53,9 +53,9 @@ TEST_F(TappingForceHold, tap_regular_key_while_mod_tap_key_is_held) {
53 run_one_scan_loop(); 53 run_one_scan_loop();
54 testing::Mock::VerifyAndClearExpectations(&driver); 54 testing::Mock::VerifyAndClearExpectations(&driver);
55 55
56 /* Release mod-tap-hold key. */ 56 /* Release mod-tap key. */
57 EXPECT_REPORT(driver, (KC_LSFT)); 57 EXPECT_REPORT(driver, (KC_LSFT));
58 mod_tap_hold_key.release(); 58 mod_tap_key.release();
59 run_one_scan_loop(); 59 run_one_scan_loop();
60 testing::Mock::VerifyAndClearExpectations(&driver); 60 testing::Mock::VerifyAndClearExpectations(&driver);
61 61
@@ -67,39 +67,39 @@ TEST_F(TappingForceHold, tap_regular_key_while_mod_tap_key_is_held) {
67 testing::Mock::VerifyAndClearExpectations(&driver); 67 testing::Mock::VerifyAndClearExpectations(&driver);
68} 68}
69 69
70TEST_F(TappingForceHold, tap_mod_tap_key_while_mod_tap_key_is_held) { 70TEST_F(QuickTap, tap_mod_tap_key_while_mod_tap_key_is_held) {
71 TestDriver driver; 71 TestDriver driver;
72 InSequence s; 72 InSequence s;
73 auto first_mod_tap_hold_key = KeymapKey(0, 1, 0, SFT_T(KC_P)); 73 auto first_mod_tap_key = KeymapKey(0, 1, 0, SFT_T(KC_P));
74 auto second_mod_tap_hold_key = KeymapKey(0, 2, 0, RSFT_T(KC_A)); 74 auto second_mod_tap_key = KeymapKey(0, 2, 0, RSFT_T(KC_A));
75 75
76 set_keymap({first_mod_tap_hold_key, second_mod_tap_hold_key}); 76 set_keymap({first_mod_tap_key, second_mod_tap_key});
77 77
78 /* Press first mod-tap-hold key */ 78 /* Press first mod-tap key */
79 EXPECT_NO_REPORT(driver); 79 EXPECT_NO_REPORT(driver);
80 first_mod_tap_hold_key.press(); 80 first_mod_tap_key.press();
81 run_one_scan_loop(); 81 run_one_scan_loop();
82 testing::Mock::VerifyAndClearExpectations(&driver); 82 testing::Mock::VerifyAndClearExpectations(&driver);
83 83
84 /* Press second tap-hold key */ 84 /* Press second mod-tap key */
85 EXPECT_NO_REPORT(driver); 85 EXPECT_NO_REPORT(driver);
86 second_mod_tap_hold_key.press(); 86 second_mod_tap_key.press();
87 run_one_scan_loop(); 87 run_one_scan_loop();
88 testing::Mock::VerifyAndClearExpectations(&driver); 88 testing::Mock::VerifyAndClearExpectations(&driver);
89 89
90 /* Release second tap-hold key */ 90 /* Release second tap-hold key */
91 EXPECT_NO_REPORT(driver); 91 EXPECT_NO_REPORT(driver);
92 second_mod_tap_hold_key.release(); 92 second_mod_tap_key.release();
93 run_one_scan_loop(); 93 run_one_scan_loop();
94 testing::Mock::VerifyAndClearExpectations(&driver); 94 testing::Mock::VerifyAndClearExpectations(&driver);
95 95
96 /* Release first mod-tap-hold key */ 96 /* Release first mod-tap key */
97 EXPECT_REPORT(driver, (KC_LSFT)); 97 EXPECT_REPORT(driver, (KC_LSFT));
98 first_mod_tap_hold_key.release(); 98 first_mod_tap_key.release();
99 run_one_scan_loop(); 99 run_one_scan_loop();
100 testing::Mock::VerifyAndClearExpectations(&driver); 100 testing::Mock::VerifyAndClearExpectations(&driver);
101 101
102 /* Idle for tapping term of first mod tap hold key. */ 102 /* Idle for tapping term of first mod-tap key. */
103 EXPECT_REPORT(driver, (KC_LSFT, KC_A)); 103 EXPECT_REPORT(driver, (KC_LSFT, KC_A));
104 EXPECT_REPORT(driver, (KC_LSFT)); 104 EXPECT_REPORT(driver, (KC_LSFT));
105 EXPECT_EMPTY_REPORT(driver); 105 EXPECT_EMPTY_REPORT(driver);
@@ -107,18 +107,18 @@ TEST_F(TappingForceHold, tap_mod_tap_key_while_mod_tap_key_is_held) {
107 testing::Mock::VerifyAndClearExpectations(&driver); 107 testing::Mock::VerifyAndClearExpectations(&driver);
108} 108}
109 109
110TEST_F(TappingForceHold, tap_regular_key_while_layer_tap_key_is_held) { 110TEST_F(QuickTap, tap_regular_key_while_layer_tap_key_is_held) {
111 TestDriver driver; 111 TestDriver driver;
112 InSequence s; 112 InSequence s;
113 auto layer_tap_hold_key = KeymapKey(0, 1, 0, LT(1, KC_P)); 113 auto layer_tap_key = KeymapKey(0, 1, 0, LT(1, KC_P));
114 auto regular_key = KeymapKey(0, 2, 0, KC_A); 114 auto regular_key = KeymapKey(0, 2, 0, KC_A);
115 auto layer_key = KeymapKey(1, 2, 0, KC_B); 115 auto layer_key = KeymapKey(1, 2, 0, KC_B);
116 116
117 set_keymap({layer_tap_hold_key, regular_key, layer_key}); 117 set_keymap({layer_tap_key, regular_key, layer_key});
118 118
119 /* Press layer-tap-hold key */ 119 /* Press layer-tap key */
120 EXPECT_NO_REPORT(driver); 120 EXPECT_NO_REPORT(driver);
121 layer_tap_hold_key.press(); 121 layer_tap_key.press();
122 run_one_scan_loop(); 122 run_one_scan_loop();
123 testing::Mock::VerifyAndClearExpectations(&driver); 123 testing::Mock::VerifyAndClearExpectations(&driver);
124 124
@@ -134,80 +134,158 @@ TEST_F(TappingForceHold, tap_regular_key_while_layer_tap_key_is_held) {
134 run_one_scan_loop(); 134 run_one_scan_loop();
135 testing::Mock::VerifyAndClearExpectations(&driver); 135 testing::Mock::VerifyAndClearExpectations(&driver);
136 136
137 /* Release layer-tap-hold key */ 137 /* Release layer-tap key */
138 EXPECT_REPORT(driver, (KC_P)); 138 EXPECT_REPORT(driver, (KC_P));
139 EXPECT_REPORT(driver, (KC_A, KC_P)); 139 EXPECT_REPORT(driver, (KC_A, KC_P));
140 EXPECT_REPORT(driver, (KC_P)); 140 EXPECT_REPORT(driver, (KC_P));
141 EXPECT_EMPTY_REPORT(driver); 141 EXPECT_EMPTY_REPORT(driver);
142 layer_tap_hold_key.release(); 142 layer_tap_key.release();
143 run_one_scan_loop(); 143 run_one_scan_loop();
144 testing::Mock::VerifyAndClearExpectations(&driver); 144 testing::Mock::VerifyAndClearExpectations(&driver);
145} 145}
146 146
147TEST_F(TappingForceHold, tap_mod_tap_hold_key_two_times) { 147TEST_F(QuickTap, tap_key_and_tap_again_before_quick_tap_term) {
148 TestDriver driver; 148 TestDriver driver;
149 InSequence s; 149 InSequence s;
150 auto mod_tap_hold_key = KeymapKey(0, 1, 0, SFT_T(KC_P)); 150 auto mod_tap_key = KeymapKey(0, 1, 0, SFT_T(KC_P));
151 151
152 set_keymap({mod_tap_hold_key}); 152 set_keymap({mod_tap_key});
153 153
154 /* Press mod-tap-hold key. */ 154 /* Press mod-tap key. */
155 EXPECT_NO_REPORT(driver); 155 EXPECT_NO_REPORT(driver);
156 mod_tap_hold_key.press(); 156 mod_tap_key.press();
157 run_one_scan_loop(); 157 run_one_scan_loop();
158 testing::Mock::VerifyAndClearExpectations(&driver); 158 testing::Mock::VerifyAndClearExpectations(&driver);
159 159
160 /* Release mod-tap-hold key. */ 160 /* Release mod-tap key. */
161 EXPECT_REPORT(driver, (KC_P)); 161 EXPECT_REPORT(driver, (KC_P));
162 EXPECT_EMPTY_REPORT(driver); 162 EXPECT_EMPTY_REPORT(driver);
163 mod_tap_hold_key.release(); 163 mod_tap_key.release();
164 idle_for(QUICK_TAP_TERM - 10);
164 run_one_scan_loop(); 165 run_one_scan_loop();
165 testing::Mock::VerifyAndClearExpectations(&driver); 166 testing::Mock::VerifyAndClearExpectations(&driver);
166 167
167 /* Press mod-tap-hold key again. */ 168 /* Press and tap mod-tap key again. */
169 EXPECT_REPORT(driver, (KC_P));
170 mod_tap_key.press();
171 run_one_scan_loop();
172 testing::Mock::VerifyAndClearExpectations(&driver);
173
174 /* Release mod-tap key. */
175 EXPECT_EMPTY_REPORT(driver);
176 mod_tap_key.release();
177 run_one_scan_loop();
178 testing::Mock::VerifyAndClearExpectations(&driver);
179}
180
181TEST_F(QuickTap, tap_key_and_hold_again_before_quick_tap_term) {
182 TestDriver driver;
183 InSequence s;
184 auto mod_tap_key = KeymapKey(0, 1, 0, SFT_T(KC_P));
185
186 set_keymap({mod_tap_key});
187
188 /* Press mod-tap key. */
168 EXPECT_NO_REPORT(driver); 189 EXPECT_NO_REPORT(driver);
169 mod_tap_hold_key.press(); 190 mod_tap_key.press();
170 run_one_scan_loop(); 191 run_one_scan_loop();
171 testing::Mock::VerifyAndClearExpectations(&driver); 192 testing::Mock::VerifyAndClearExpectations(&driver);
172 193
173 /* Release mod-tap-hold key. */ 194 /* Release mod-tap key. */
174 EXPECT_REPORT(driver, (KC_P)); 195 EXPECT_REPORT(driver, (KC_P));
175 EXPECT_EMPTY_REPORT(driver); 196 EXPECT_EMPTY_REPORT(driver);
176 mod_tap_hold_key.release(); 197 mod_tap_key.release();
198 idle_for(QUICK_TAP_TERM - 10);
199 testing::Mock::VerifyAndClearExpectations(&driver);
200
201 /* Press and hold mod-tap key again. */
202 EXPECT_REPORT(driver, (KC_P));
203 mod_tap_key.press();
204 run_one_scan_loop();
205 testing::Mock::VerifyAndClearExpectations(&driver);
206
207 /* Wait until tapping term expired */
208 EXPECT_NO_REPORT(driver);
209 idle_for(TAPPING_TERM);
210 testing::Mock::VerifyAndClearExpectations(&driver);
211
212 /* Release mod-tap key. */
213 EXPECT_EMPTY_REPORT(driver);
214 mod_tap_key.release();
177 run_one_scan_loop(); 215 run_one_scan_loop();
178 testing::Mock::VerifyAndClearExpectations(&driver); 216 testing::Mock::VerifyAndClearExpectations(&driver);
179} 217}
180 218
181TEST_F(TappingForceHold, tap_mod_tap_hold_key_twice_and_hold_on_second_time) { 219
220TEST_F(QuickTap, tap_key_and_tap_again_after_quick_tap_term) {
182 TestDriver driver; 221 TestDriver driver;
183 InSequence s; 222 InSequence s;
184 auto mod_tap_hold_key = KeymapKey(0, 1, 0, SFT_T(KC_P)); 223 auto mod_tap_key = KeymapKey(0, 1, 0, SFT_T(KC_P));
185 224
186 set_keymap({mod_tap_hold_key}); 225 set_keymap({mod_tap_key});
187 226
188 /* Press mod-tap-hold key. */ 227 /* Press mod-tap key. */
189 EXPECT_NO_REPORT(driver); 228 EXPECT_NO_REPORT(driver);
190 mod_tap_hold_key.press(); 229 mod_tap_key.press();
191 run_one_scan_loop(); 230 run_one_scan_loop();
192 testing::Mock::VerifyAndClearExpectations(&driver); 231 testing::Mock::VerifyAndClearExpectations(&driver);
193 232
194 /* Release mod-tap-hold key. */ 233 /* Release mod-tap key. */
195 EXPECT_REPORT(driver, (KC_P)); 234 EXPECT_REPORT(driver, (KC_P));
196 EXPECT_EMPTY_REPORT(driver); 235 EXPECT_EMPTY_REPORT(driver);
197 mod_tap_hold_key.release(); 236 mod_tap_key.release();
237 idle_for(QUICK_TAP_TERM + 10);
198 run_one_scan_loop(); 238 run_one_scan_loop();
199 testing::Mock::VerifyAndClearExpectations(&driver); 239 testing::Mock::VerifyAndClearExpectations(&driver);
200 240
201 /* Press mod-tap-hold key again. */ 241 /* Press mod-tap key again. */
202 EXPECT_NO_REPORT(driver); 242 EXPECT_NO_REPORT(driver);
203 mod_tap_hold_key.press(); 243 mod_tap_key.press();
244 run_one_scan_loop();
245 testing::Mock::VerifyAndClearExpectations(&driver);
246
247 /* Release mod-tap key. */
248 EXPECT_REPORT(driver, (KC_P));
249 EXPECT_EMPTY_REPORT(driver);
250 mod_tap_key.release();
251 run_one_scan_loop();
252 testing::Mock::VerifyAndClearExpectations(&driver);
253}
254
255TEST_F(QuickTap, tap_key_and_hold_again_after_quick_tap_term) {
256 TestDriver driver;
257 InSequence s;
258 auto mod_tap_key = KeymapKey(0, 1, 0, SFT_T(KC_P));
259
260 set_keymap({mod_tap_key});
261
262 /* Press mod-tap key. */
263 EXPECT_NO_REPORT(driver);
264 mod_tap_key.press();
265 run_one_scan_loop();
266 testing::Mock::VerifyAndClearExpectations(&driver);
267
268 /* Release mod-tap key. */
269 EXPECT_REPORT(driver, (KC_P));
270 EXPECT_EMPTY_REPORT(driver);
271 mod_tap_key.release();
272 idle_for(QUICK_TAP_TERM + 10);
273 testing::Mock::VerifyAndClearExpectations(&driver);
274
275 /* Press and hold mod-tap key again. */
276 EXPECT_NO_REPORT(driver);
277 mod_tap_key.press();
278 run_one_scan_loop();
279 testing::Mock::VerifyAndClearExpectations(&driver);
280
281 /* Wait until tapping term expired */
282 EXPECT_REPORT(driver, (KC_LSFT));
204 idle_for(TAPPING_TERM); 283 idle_for(TAPPING_TERM);
205 testing::Mock::VerifyAndClearExpectations(&driver); 284 testing::Mock::VerifyAndClearExpectations(&driver);
206 285
207 /* Release mod-tap-hold key. */ 286 /* Release mod-tap key. */
208 EXPECT_REPORT(driver, (KC_LEFT_SHIFT));
209 EXPECT_EMPTY_REPORT(driver); 287 EXPECT_EMPTY_REPORT(driver);
210 mod_tap_hold_key.release(); 288 mod_tap_key.release();
211 run_one_scan_loop(); 289 run_one_scan_loop();
212 testing::Mock::VerifyAndClearExpectations(&driver); 290 testing::Mock::VerifyAndClearExpectations(&driver);
213} 291}