From 26a1fdafa67a08124415eb2078dabdcc9468294f Mon Sep 17 00:00:00 2001 From: Jari Meevis Date: Wed, 23 Apr 2025 22:12:15 +0200 Subject: [PATCH] wip(fix tests) --- quantum/action.c | 2 +- tests/basic/test_one_shot_keys.cpp | 33 ++++++++++++++++++------------ 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/quantum/action.c b/quantum/action.c index d76012226be..6e623a65f0d 100644 --- a/quantum/action.c +++ b/quantum/action.c @@ -463,7 +463,7 @@ void process_action(keyrecord_t *record, action_t action) { } else { if (event.pressed) { if (tap_count == 0) { - // Not a tap, but a hold: register the held mod + // Not a tap, but a hold: register the mods, replacing the oneshots ac_dprintf("MODS_TAP: Oneshot: 0\n"); register_mods(mods); del_oneshot_mods(mods); diff --git a/tests/basic/test_one_shot_keys.cpp b/tests/basic/test_one_shot_keys.cpp index 1730d6cbb7d..83a878e2094 100644 --- a/tests/basic/test_one_shot_keys.cpp +++ b/tests/basic/test_one_shot_keys.cpp @@ -16,9 +16,7 @@ #include "action_util.h" #include "config.h" -#include "keyboard_report_util.hpp" #include "test_common.hpp" -#include #include using testing::_; @@ -275,7 +273,7 @@ TEST_F(OneShot, OSMHoldNotLockingOSMs) { VERIFY_AND_CLEAR(driver); } -TEST_F(OneShot, OSMTapThenHoldNotLockingOSMs) { +TEST_F(OneShot, OSMTapThenHoldShouldSendEmptyReport) { TestDriver driver; InSequence s; KeymapKey osm_key = KeymapKey{0, 0, 0, OSM(MOD_LSFT), KC_LSFT}; @@ -283,36 +281,45 @@ TEST_F(OneShot, OSMTapThenHoldNotLockingOSMs) { set_keymap({osm_key, regular_key}); + /* + * for some reason, none of the OSM keys are registered + * */ + /* Press and release OSM */ EXPECT_NO_REPORT(driver); tap_key(osm_key); + EXPECT_EQ(get_oneshot_mods(), 0x02); // verify oneshots are turned on VERIFY_AND_CLEAR(driver); - /* Press and hold OSM */ - EXPECT_REPORT(driver, (osm_key.report_code)).Times(1); + /* Press OSM */ + EXPECT_NO_REPORT(driver); osm_key.press(); - run_one_scan_loop(); - idle_for(TAPPING_TERM); - // EXPECT_EQ(get_oneshot_mods(), b02); // one shot mods should be disabled + run_one_scan_loop(); // not yet registered VERIFY_AND_CLEAR(driver); - /* Release OSM1 */ - EXPECT_EMPTY_REPORT(driver); + /* Hold OSM */ + EXPECT_REPORT(driver, (osm_key.report_code)).Times(1); // report should be send now + idle_for(TAPPING_TERM); + EXPECT_EQ(get_oneshot_mods(), 0x00); // key registered as hold, OSM should be disabled + VERIFY_AND_CLEAR(driver); + + /* Release OSM */ + EXPECT_EMPTY_REPORT(driver); // key released so we expect empty report (i.e. no key pressed) osm_key.release(); run_one_scan_loop(); - // EXPECT_EQ(get_oneshot_mods(), 0); // one shot mods should be disabled + EXPECT_EQ(get_oneshot_mods(), 0x00); // one shot mods should still be disabled VERIFY_AND_CLEAR(driver); /* Press regular key */ - EXPECT_REPORT(driver, (regular_key.report_code)).Times(1); // no mod regular_key.press(); run_one_scan_loop(); + EXPECT_REPORT(driver, (regular_key.report_code)).Times(1); // should not be modded VERIFY_AND_CLEAR(driver); /* Release regular key */ - EXPECT_EMPTY_REPORT(driver); regular_key.release(); run_one_scan_loop(); + EXPECT_EMPTY_REPORT(driver); VERIFY_AND_CLEAR(driver); }