summaryrefslogtreecommitdiff
path: root/tests/basic
diff options
context:
space:
mode:
Diffstat (limited to 'tests/basic')
-rw-r--r--tests/basic/test_action_layer.cpp3
-rw-r--r--tests/basic/test_one_shot_keys.cpp144
2 files changed, 146 insertions, 1 deletions
diff --git a/tests/basic/test_action_layer.cpp b/tests/basic/test_action_layer.cpp
index b7ecfa52ef..0aa4b78007 100644
--- a/tests/basic/test_action_layer.cpp
+++ b/tests/basic/test_action_layer.cpp
@@ -365,9 +365,10 @@ TEST_F(ActionLayer, LayerTapReleasedBeforeKeypressReleaseWithModifiers) {
InSequence s;
KeymapKey layer_0_key_0 = KeymapKey{0, 0, 0, LT(1, KC_T)};
+ KeymapKey layer_0_key_1 = KeymapKey{0, 1, 0, KC_X};
KeymapKey layer_1_key_1 = KeymapKey{1, 1, 0, RALT(KC_9)};
- set_keymap({layer_0_key_0, layer_1_key_1});
+ set_keymap({layer_0_key_0, layer_0_key_1, layer_1_key_1});
/* Press layer tap and wait for tapping term to switch to layer 1 */
EXPECT_NO_REPORT(driver);
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;