summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorprecondition <57645186+precondition@users.noreply.github.com>2022-12-12 22:16:12 +0100
committerGitHub <noreply@github.com>2022-12-12 22:16:12 +0100
commit454edf68d1035cfabbcd3e4a7b7e9768085e17e5 (patch)
treef83c66b54b6ce14e94336305e517732334407b5f
parent008f1312bbddd281378b680f723a01d135f7e948 (diff)
Tests that caps word stays active after use of OSL (#19303)
-rw-r--r--tests/caps_word/test_caps_word.cpp53
1 files changed, 52 insertions, 1 deletions
diff --git a/tests/caps_word/test_caps_word.cpp b/tests/caps_word/test_caps_word.cpp
index 3d0735d8c2..e5ecbb844e 100644
--- a/tests/caps_word/test_caps_word.cpp
+++ b/tests/caps_word/test_caps_word.cpp
@@ -591,6 +591,57 @@ INSTANTIATE_TEST_CASE_P(
),
CapsWordDoubleTapShiftParams::GetName
);
-// clang-format on
+// Tests that holding a OSL keeps caps word active and shifts keys on the layer that need to be shifted.
+TEST_F(CapsWord, IgnoresOSLHold) {
+ TestDriver driver;
+ KeymapKey key_a(0, 0, 0, KC_A);
+ KeymapKey key_osl(0, 1, 0, OSL(1));
+ KeymapKey key_b(1, 0, 0, KC_B);
+ set_keymap({key_a, key_osl, key_b});
+
+ // Allow any number of reports with no keys or only modifiers.
+ // clang-format off
+ EXPECT_CALL(driver, send_keyboard_mock(AnyOf(
+ KeyboardReport(),
+ KeyboardReport(KC_LSFT))))
+ .Times(AnyNumber());
+
+ EXPECT_REPORT(driver, (KC_LSFT, KC_B));
+ caps_word_on();
+
+ key_osl.press();
+ run_one_scan_loop();
+ tap_key(key_b);
+ key_osl.release();
+ run_one_scan_loop();
+
+ testing::Mock::VerifyAndClearExpectations(&driver);
+}
+
+// Tests that tapping a OSL keeps caps word active and shifts keys on the layer that need to be shifted.
+TEST_F(CapsWord, IgnoresOSLTap) {
+ TestDriver driver;
+ KeymapKey key_a(0, 0, 0, KC_A);
+ KeymapKey key_osl(0, 1, 0, OSL(1));
+ KeymapKey key_b(1, 0, 0, KC_B);
+ set_keymap({key_a, key_osl, key_b});
+
+ // Allow any number of reports with no keys or only modifiers.
+ // clang-format off
+ EXPECT_CALL(driver, send_keyboard_mock(AnyOf(
+ KeyboardReport(),
+ KeyboardReport(KC_LSFT))))
+ .Times(AnyNumber());
+
+ EXPECT_REPORT(driver, (KC_LSFT, KC_B));
+ caps_word_on();
+
+ tap_key(key_osl);
+ tap_key(key_b);
+ run_one_scan_loop();
+
+ testing::Mock::VerifyAndClearExpectations(&driver);
+}
+// clang-format on
} // namespace