diff options
| author | Kasimir Pihlasviita <kasimir@pihlasviita.fi> | 2023-04-03 08:38:44 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-04-03 15:38:44 +1000 |
| commit | 46844347c4f4b5f8b50ea22dd06c7555a86fc94b (patch) | |
| tree | c2e331ae9c46e9dc2764a0992fe3fa9f0b083104 /tests | |
| parent | 1899793f27c9b165b55b28b086bd989f12baf137 (diff) | |
Fix OSMs getting stuck (#20034)
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/basic/test_one_shot_keys.cpp | 144 |
1 files changed, 144 insertions, 0 deletions
diff --git a/tests/basic/test_one_shot_keys.cpp b/tests/basic/test_one_shot_keys.cpp index 2401c2c837..2a3434bf16 100644 --- a/tests/basic/test_one_shot_keys.cpp +++ b/tests/basic/test_one_shot_keys.cpp | |||
| @@ -160,6 +160,150 @@ INSTANTIATE_TEST_CASE_P( | |||
| 160 | )); | 160 | )); |
| 161 | // clang-format on | 161 | // clang-format on |
| 162 | 162 | ||
| 163 | TEST_F(OneShot, OSMChainingTwoOSMs) { | ||
| 164 | TestDriver driver; | ||
| 165 | InSequence s; | ||
| 166 | KeymapKey osm_key1 = KeymapKey{0, 0, 0, OSM(MOD_LSFT), KC_LSFT}; | ||
| 167 | KeymapKey osm_key2 = KeymapKey{0, 0, 1, OSM(MOD_LCTL), KC_LCTL}; | ||
| 168 | KeymapKey regular_key = KeymapKey{0, 1, 0, KC_A}; | ||
| 169 | |||
| 170 | set_keymap({osm_key1, osm_key2, regular_key}); | ||
| 171 | |||
| 172 | /* Press and release OSM1 */ | ||
| 173 | EXPECT_NO_REPORT(driver); | ||
| 174 | osm_key1.press(); | ||
| 175 | run_one_scan_loop(); | ||
| 176 | osm_key1.release(); | ||
| 177 | run_one_scan_loop(); | ||
| 178 | VERIFY_AND_CLEAR(driver); | ||
| 179 | |||
| 180 | /* Press and relesea OSM2 */ | ||
| 181 | EXPECT_NO_REPORT(driver); | ||
| 182 | osm_key2.press(); | ||
| 183 | run_one_scan_loop(); | ||
| 184 | osm_key2.release(); | ||
| 185 | run_one_scan_loop(); | ||
| 186 | VERIFY_AND_CLEAR(driver); | ||
| 187 | |||
| 188 | /* Press regular key */ | ||
| 189 | EXPECT_REPORT(driver, (osm_key1.report_code, osm_key2.report_code, regular_key.report_code)).Times(1); | ||
| 190 | regular_key.press(); | ||
| 191 | run_one_scan_loop(); | ||
| 192 | VERIFY_AND_CLEAR(driver); | ||
| 193 | |||
| 194 | /* Release regular key */ | ||
| 195 | EXPECT_EMPTY_REPORT(driver); | ||
| 196 | regular_key.release(); | ||
| 197 | run_one_scan_loop(); | ||
| 198 | VERIFY_AND_CLEAR(driver); | ||
| 199 | } | ||
| 200 | |||
| 201 | TEST_F(OneShot, OSMDoubleTapNotLockingOSMs) { | ||
| 202 | TestDriver driver; | ||
| 203 | InSequence s; | ||
| 204 | KeymapKey osm_key1 = KeymapKey{0, 0, 0, OSM(MOD_LSFT), KC_LSFT}; | ||
| 205 | KeymapKey osm_key2 = KeymapKey{0, 0, 1, OSM(MOD_LCTL), KC_LCTL}; | ||
| 206 | KeymapKey regular_key = KeymapKey{0, 1, 0, KC_A}; | ||
| 207 | |||
| 208 | set_keymap({osm_key1, osm_key2, regular_key}); | ||
| 209 | |||
| 210 | /* Press and release OSM1 */ | ||
| 211 | EXPECT_NO_REPORT(driver); | ||
| 212 | osm_key1.press(); | ||
| 213 | run_one_scan_loop(); | ||
| 214 | osm_key1.release(); | ||
| 215 | run_one_scan_loop(); | ||
| 216 | VERIFY_AND_CLEAR(driver); | ||
| 217 | |||
| 218 | /* Press and release OSM2 twice */ | ||
| 219 | EXPECT_NO_REPORT(driver); | ||
| 220 | osm_key2.press(); | ||
| 221 | run_one_scan_loop(); | ||
| 222 | osm_key2.release(); | ||
| 223 | run_one_scan_loop(); | ||
| 224 | osm_key2.press(); | ||
| 225 | run_one_scan_loop(); | ||
| 226 | osm_key2.release(); | ||
| 227 | run_one_scan_loop(); | ||
| 228 | VERIFY_AND_CLEAR(driver); | ||
| 229 | |||
| 230 | /* Press regular key */ | ||
| 231 | EXPECT_REPORT(driver, (osm_key1.report_code, osm_key2.report_code, regular_key.report_code)).Times(1); | ||
| 232 | regular_key.press(); | ||
| 233 | run_one_scan_loop(); | ||
| 234 | VERIFY_AND_CLEAR(driver); | ||
| 235 | |||
| 236 | /* Release regular key */ | ||
| 237 | EXPECT_EMPTY_REPORT(driver); | ||
| 238 | regular_key.release(); | ||
| 239 | run_one_scan_loop(); | ||
| 240 | VERIFY_AND_CLEAR(driver); | ||
| 241 | |||
| 242 | /* Press regular key */ | ||
| 243 | EXPECT_REPORT(driver, (regular_key.report_code)).Times(1); | ||
| 244 | regular_key.press(); | ||
| 245 | run_one_scan_loop(); | ||
| 246 | VERIFY_AND_CLEAR(driver); | ||
| 247 | |||
| 248 | /* Release regular key */ | ||
| 249 | EXPECT_EMPTY_REPORT(driver); | ||
| 250 | regular_key.release(); | ||
| 251 | run_one_scan_loop(); | ||
| 252 | VERIFY_AND_CLEAR(driver); | ||
| 253 | } | ||
| 254 | |||
| 255 | TEST_F(OneShot, OSMHoldNotLockingOSMs) { | ||
| 256 | TestDriver driver; | ||
| 257 | InSequence s; | ||
| 258 | KeymapKey osm_key1 = KeymapKey{0, 0, 0, OSM(MOD_LSFT), KC_LSFT}; | ||
| 259 | KeymapKey osm_key2 = KeymapKey{0, 0, 1, OSM(MOD_LCTL), KC_LCTL}; | ||
| 260 | KeymapKey regular_key = KeymapKey{0, 1, 0, KC_A}; | ||
| 261 | |||
| 262 | set_keymap({osm_key1, osm_key2, regular_key}); | ||
| 263 | |||
| 264 | /* Press and release OSM1 */ | ||
| 265 | EXPECT_NO_REPORT(driver); | ||
| 266 | osm_key1.press(); | ||
| 267 | run_one_scan_loop(); | ||
| 268 | osm_key1.release(); | ||
| 269 | run_one_scan_loop(); | ||
| 270 | VERIFY_AND_CLEAR(driver); | ||
| 271 | |||
| 272 | /* Press and hold OSM2 */ | ||
| 273 | EXPECT_REPORT(driver, (osm_key1.report_code, osm_key2.report_code)).Times(1); | ||
| 274 | osm_key2.press(); | ||
| 275 | run_one_scan_loop(); | ||
| 276 | idle_for(TAPPING_TERM); | ||
| 277 | VERIFY_AND_CLEAR(driver); | ||
| 278 | |||
| 279 | /* Press and release regular key */ | ||
| 280 | EXPECT_REPORT(driver, (osm_key1.report_code, osm_key2.report_code, regular_key.report_code)).Times(1); | ||
| 281 | EXPECT_REPORT(driver, (osm_key2.report_code)).Times(1); | ||
| 282 | regular_key.press(); | ||
| 283 | run_one_scan_loop(); | ||
| 284 | regular_key.release(); | ||
| 285 | run_one_scan_loop(); | ||
| 286 | VERIFY_AND_CLEAR(driver); | ||
| 287 | |||
| 288 | /* Release OSM2 */ | ||
| 289 | EXPECT_EMPTY_REPORT(driver); | ||
| 290 | osm_key2.release(); | ||
| 291 | run_one_scan_loop(); | ||
| 292 | VERIFY_AND_CLEAR(driver); | ||
| 293 | |||
| 294 | /* Press regular key */ | ||
| 295 | EXPECT_REPORT(driver, (regular_key.report_code)).Times(1); | ||
| 296 | regular_key.press(); | ||
| 297 | run_one_scan_loop(); | ||
| 298 | VERIFY_AND_CLEAR(driver); | ||
| 299 | |||
| 300 | /* Release regular key */ | ||
| 301 | EXPECT_EMPTY_REPORT(driver); | ||
| 302 | regular_key.release(); | ||
| 303 | run_one_scan_loop(); | ||
| 304 | VERIFY_AND_CLEAR(driver); | ||
| 305 | } | ||
| 306 | |||
| 163 | TEST_F(OneShot, OSLWithAdditionalKeypress) { | 307 | TEST_F(OneShot, OSLWithAdditionalKeypress) { |
| 164 | TestDriver driver; | 308 | TestDriver driver; |
| 165 | InSequence s; | 309 | InSequence s; |
