summaryrefslogtreecommitdiffstats
path: root/tests/basic
diff options
context:
space:
mode:
authorKasimir Pihlasviita <kasimir@pihlasviita.fi>2023-04-03 08:38:44 +0300
committerGitHub <noreply@github.com>2023-04-03 15:38:44 +1000
commit46844347c4f4b5f8b50ea22dd06c7555a86fc94b (patch)
treec2e331ae9c46e9dc2764a0992fe3fa9f0b083104 /tests/basic
parent1899793f27c9b165b55b28b086bd989f12baf137 (diff)
Fix OSMs getting stuck (#20034)
Diffstat (limited to 'tests/basic')
-rw-r--r--tests/basic/test_one_shot_keys.cpp144
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(
));
// clang-format on
+TEST_F(OneShot, OSMChainingTwoOSMs) {
+ TestDriver driver;
+ InSequence s;
+ KeymapKey osm_key1 = KeymapKey{0, 0, 0, OSM(MOD_LSFT), KC_LSFT};
+ KeymapKey osm_key2 = KeymapKey{0, 0, 1, OSM(MOD_LCTL), KC_LCTL};
+ KeymapKey regular_key = KeymapKey{0, 1, 0, KC_A};
+
+ set_keymap({osm_key1, osm_key2, regular_key});
+
+ /* Press and release OSM1 */
+ EXPECT_NO_REPORT(driver);
+ osm_key1.press();
+ run_one_scan_loop();
+ osm_key1.release();
+ run_one_scan_loop();
+ VERIFY_AND_CLEAR(driver);
+
+ /* Press and relesea OSM2 */
+ EXPECT_NO_REPORT(driver);
+ osm_key2.press();
+ run_one_scan_loop();
+ osm_key2.release();
+ run_one_scan_loop();
+ VERIFY_AND_CLEAR(driver);
+
+ /* Press regular key */
+ EXPECT_REPORT(driver, (osm_key1.report_code, osm_key2.report_code, regular_key.report_code)).Times(1);
+ regular_key.press();
+ run_one_scan_loop();
+ VERIFY_AND_CLEAR(driver);
+
+ /* Release regular key */
+ EXPECT_EMPTY_REPORT(driver);
+ regular_key.release();
+ run_one_scan_loop();
+ VERIFY_AND_CLEAR(driver);
+}
+
+TEST_F(OneShot, OSMDoubleTapNotLockingOSMs) {
+ TestDriver driver;
+ InSequence s;
+ KeymapKey osm_key1 = KeymapKey{0, 0, 0, OSM(MOD_LSFT), KC_LSFT};
+ KeymapKey osm_key2 = KeymapKey{0, 0, 1, OSM(MOD_LCTL), KC_LCTL};
+ KeymapKey regular_key = KeymapKey{0, 1, 0, KC_A};
+
+ set_keymap({osm_key1, osm_key2, regular_key});
+
+ /* Press and release OSM1 */
+ EXPECT_NO_REPORT(driver);
+ osm_key1.press();
+ run_one_scan_loop();
+ osm_key1.release();
+ run_one_scan_loop();
+ VERIFY_AND_CLEAR(driver);
+
+ /* Press and release OSM2 twice */
+ EXPECT_NO_REPORT(driver);
+ osm_key2.press();
+ run_one_scan_loop();
+ osm_key2.release();
+ run_one_scan_loop();
+ osm_key2.press();
+ run_one_scan_loop();
+ osm_key2.release();
+ run_one_scan_loop();
+ VERIFY_AND_CLEAR(driver);
+
+ /* Press regular key */
+ EXPECT_REPORT(driver, (osm_key1.report_code, osm_key2.report_code, regular_key.report_code)).Times(1);
+ regular_key.press();
+ run_one_scan_loop();
+ VERIFY_AND_CLEAR(driver);
+
+ /* Release regular key */
+ EXPECT_EMPTY_REPORT(driver);
+ regular_key.release();
+ run_one_scan_loop();
+ VERIFY_AND_CLEAR(driver);
+
+ /* Press regular key */
+ EXPECT_REPORT(driver, (regular_key.report_code)).Times(1);
+ regular_key.press();
+ run_one_scan_loop();
+ VERIFY_AND_CLEAR(driver);
+
+ /* Release regular key */
+ EXPECT_EMPTY_REPORT(driver);
+ regular_key.release();
+ run_one_scan_loop();
+ VERIFY_AND_CLEAR(driver);
+}
+
+TEST_F(OneShot, OSMHoldNotLockingOSMs) {
+ TestDriver driver;
+ InSequence s;
+ KeymapKey osm_key1 = KeymapKey{0, 0, 0, OSM(MOD_LSFT), KC_LSFT};
+ KeymapKey osm_key2 = KeymapKey{0, 0, 1, OSM(MOD_LCTL), KC_LCTL};
+ KeymapKey regular_key = KeymapKey{0, 1, 0, KC_A};
+
+ set_keymap({osm_key1, osm_key2, regular_key});
+
+ /* Press and release OSM1 */
+ EXPECT_NO_REPORT(driver);
+ osm_key1.press();
+ run_one_scan_loop();
+ osm_key1.release();
+ run_one_scan_loop();
+ VERIFY_AND_CLEAR(driver);
+
+ /* Press and hold OSM2 */
+ EXPECT_REPORT(driver, (osm_key1.report_code, osm_key2.report_code)).Times(1);
+ osm_key2.press();
+ run_one_scan_loop();
+ idle_for(TAPPING_TERM);
+ VERIFY_AND_CLEAR(driver);
+
+ /* Press and release regular key */
+ EXPECT_REPORT(driver, (osm_key1.report_code, osm_key2.report_code, regular_key.report_code)).Times(1);
+ EXPECT_REPORT(driver, (osm_key2.report_code)).Times(1);
+ regular_key.press();
+ run_one_scan_loop();
+ regular_key.release();
+ run_one_scan_loop();
+ VERIFY_AND_CLEAR(driver);
+
+ /* Release OSM2 */
+ EXPECT_EMPTY_REPORT(driver);
+ osm_key2.release();
+ run_one_scan_loop();
+ VERIFY_AND_CLEAR(driver);
+
+ /* Press regular key */
+ EXPECT_REPORT(driver, (regular_key.report_code)).Times(1);
+ regular_key.press();
+ run_one_scan_loop();
+ VERIFY_AND_CLEAR(driver);
+
+ /* Release regular key */
+ EXPECT_EMPTY_REPORT(driver);
+ regular_key.release();
+ run_one_scan_loop();
+ VERIFY_AND_CLEAR(driver);
+}
+
TEST_F(OneShot, OSLWithAdditionalKeypress) {
TestDriver driver;
InSequence s;