summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/basic/test_one_shot_keys.cpp144
-rw-r--r--tests/tap_hold_configurations/default_mod_tap/config.h2
-rw-r--r--tests/tap_hold_configurations/quick_tap/test_quick_tap.cpp80
-rw-r--r--tests/test_common/test_fixture.cpp1
4 files changed, 144 insertions, 83 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;
diff --git a/tests/tap_hold_configurations/default_mod_tap/config.h b/tests/tap_hold_configurations/default_mod_tap/config.h
index f22448845e..6d872dd57b 100644
--- a/tests/tap_hold_configurations/default_mod_tap/config.h
+++ b/tests/tap_hold_configurations/default_mod_tap/config.h
@@ -17,5 +17,3 @@
#pragma once
#include "test_common.h"
-
-#define IGNORE_MOD_TAP_INTERRUPT
diff --git a/tests/tap_hold_configurations/quick_tap/test_quick_tap.cpp b/tests/tap_hold_configurations/quick_tap/test_quick_tap.cpp
index 8ec6ea62a3..dda58463fb 100644
--- a/tests/tap_hold_configurations/quick_tap/test_quick_tap.cpp
+++ b/tests/tap_hold_configurations/quick_tap/test_quick_tap.cpp
@@ -27,86 +27,6 @@ using testing::InSequence;
class QuickTap : public TestFixture {};
-TEST_F(QuickTap, tap_regular_key_while_mod_tap_key_is_held) {
- TestDriver driver;
- InSequence s;
- auto mod_tap_key = KeymapKey(0, 1, 0, SFT_T(KC_P));
- auto regular_key = KeymapKey(0, 2, 0, KC_A);
-
- set_keymap({mod_tap_key, regular_key});
-
- /* Press mod-tap key. */
- EXPECT_NO_REPORT(driver);
- mod_tap_key.press();
- run_one_scan_loop();
- VERIFY_AND_CLEAR(driver);
-
- /* Press regular key. */
- EXPECT_NO_REPORT(driver);
- regular_key.press();
- run_one_scan_loop();
- VERIFY_AND_CLEAR(driver);
-
- /* Release regular key. */
- EXPECT_NO_REPORT(driver);
- regular_key.release();
- run_one_scan_loop();
- VERIFY_AND_CLEAR(driver);
-
- /* Release mod-tap key. */
- EXPECT_REPORT(driver, (KC_LSFT));
- mod_tap_key.release();
- run_one_scan_loop();
- VERIFY_AND_CLEAR(driver);
-
- /* Idle for tapping term of mod tap hold key. */
- EXPECT_REPORT(driver, (KC_LSFT, KC_A));
- EXPECT_REPORT(driver, (KC_LSFT));
- EXPECT_EMPTY_REPORT(driver);
- idle_for(TAPPING_TERM - 3);
- VERIFY_AND_CLEAR(driver);
-}
-
-TEST_F(QuickTap, tap_mod_tap_key_while_mod_tap_key_is_held) {
- TestDriver driver;
- InSequence s;
- auto first_mod_tap_key = KeymapKey(0, 1, 0, SFT_T(KC_P));
- auto second_mod_tap_key = KeymapKey(0, 2, 0, RSFT_T(KC_A));
-
- set_keymap({first_mod_tap_key, second_mod_tap_key});
-
- /* Press first mod-tap key */
- EXPECT_NO_REPORT(driver);
- first_mod_tap_key.press();
- run_one_scan_loop();
- VERIFY_AND_CLEAR(driver);
-
- /* Press second mod-tap key */
- EXPECT_NO_REPORT(driver);
- second_mod_tap_key.press();
- run_one_scan_loop();
- VERIFY_AND_CLEAR(driver);
-
- /* Release second tap-hold key */
- EXPECT_NO_REPORT(driver);
- second_mod_tap_key.release();
- run_one_scan_loop();
- VERIFY_AND_CLEAR(driver);
-
- /* Release first mod-tap key */
- EXPECT_REPORT(driver, (KC_LSFT));
- first_mod_tap_key.release();
- run_one_scan_loop();
- VERIFY_AND_CLEAR(driver);
-
- /* Idle for tapping term of first mod-tap key. */
- EXPECT_REPORT(driver, (KC_LSFT, KC_A));
- EXPECT_REPORT(driver, (KC_LSFT));
- EXPECT_EMPTY_REPORT(driver);
- idle_for(TAPPING_TERM - 3);
- VERIFY_AND_CLEAR(driver);
-}
-
TEST_F(QuickTap, tap_regular_key_while_layer_tap_key_is_held) {
TestDriver driver;
InSequence s;
diff --git a/tests/test_common/test_fixture.cpp b/tests/test_common/test_fixture.cpp
index 76daa625ad..72763d0bc0 100644
--- a/tests/test_common/test_fixture.cpp
+++ b/tests/test_common/test_fixture.cpp
@@ -22,7 +22,6 @@ extern "C" {
#include "debug.h"
#include "eeconfig.h"
#include "keyboard.h"
-#include "keymap.h"
void set_time(uint32_t t);
void advance_time(uint32_t ms);