Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests that caps word stays active after use of OSL #19303

Merged
merged 1 commit into from
Dec 12, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 52 additions & 1 deletion tests/caps_word/test_caps_word.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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