summaryrefslogtreecommitdiffstats
path: root/tests/basic/test_one_shot_keys.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/basic/test_one_shot_keys.cpp')
-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;