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] Increase QMK test coverage #13789

Merged
merged 10 commits into from
Nov 22, 2021
Prev Previous commit
Next Next commit
Merge branch 'develop' into add-qmk-unit-tests
  • Loading branch information
tzarc authored Nov 22, 2021
commit a2ae62b9959ea2c18a3dc50cbd24d5f676f40dba
42 changes: 21 additions & 21 deletions tests/basic/test_keypress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ TEST_F(KeyPress, CorrectKeysAreReportedWhenTwoKeysArePressed) {
TEST_F(KeyPress, LeftShiftIsReportedCorrectly) {
TestDriver driver;
auto key_a = KeymapKey(0, 0, 0, KC_A);
auto key_lsft = KeymapKey(0, 3, 0, KC_LSFT);
auto key_lsft = KeymapKey(0, 3, 0, KC_LEFT_SHIFT);

set_keymap({key_a, key_lsft});

Expand All @@ -111,8 +111,8 @@ TEST_F(KeyPress, LeftShiftIsReportedCorrectly) {

TEST_F(KeyPress, PressLeftShiftAndControl) {
TestDriver driver;
auto key_lsft = KeymapKey(0, 3, 0, KC_LSFT);
auto key_lctrl = KeymapKey(0, 5, 0, KC_LCTRL);
auto key_lsft = KeymapKey(0, 3, 0, KC_LEFT_SHIFT);
auto key_lctrl = KeymapKey(0, 5, 0, KC_LEFT_CTRL);

set_keymap({key_lctrl, key_lsft});

Expand All @@ -139,8 +139,8 @@ TEST_F(KeyPress, PressLeftShiftAndControl) {

TEST_F(KeyPress, LeftAndRightShiftCanBePressedAtTheSameTime) {
TestDriver driver;
auto key_lsft = KeymapKey(0, 3, 0, KC_LSFT);
auto key_rsft = KeymapKey(0, 4, 0, KC_RSFT);
auto key_lsft = KeymapKey(0, 3, 0, KC_LEFT_SHIFT);
auto key_rsft = KeymapKey(0, 4, 0, KC_RIGHT_SHIFT);

set_keymap({key_rsft, key_lsft});

Expand Down Expand Up @@ -176,12 +176,12 @@ TEST_F(KeyPress, RightShiftLeftControlAndCharWithTheSameKey) {
// The underlying cause is that we use only one bit to represent the right hand
// modifiers.
combo_key.press();
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_RSFT, KC_RCTRL)));
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_RSFT, KC_RCTRL, KC_O)));
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_RIGHT_SHIFT, KC_RIGHT_CTRL)));
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_RIGHT_SHIFT, KC_RIGHT_CTRL, KC_O)));
keyboard_task();

combo_key.release();
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_RSFT, KC_RCTRL)));
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_RIGHT_SHIFT, KC_RIGHT_CTRL)));
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
keyboard_task();
}
Expand All @@ -195,13 +195,13 @@ TEST_F(KeyPress, PressPlusEqualReleaseBeforePress) {
set_keymap({key_plus, key_eql});

key_plus.press();
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT)));
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT, KC_EQL)));
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT)));
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT, KC_EQUAL)));
run_one_scan_loop();
testing::Mock::VerifyAndClearExpectations(&driver);

key_plus.release();
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT)));
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT)));
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
run_one_scan_loop();
testing::Mock::VerifyAndClearExpectations(&driver);
Expand All @@ -221,13 +221,13 @@ TEST_F(KeyPress, PressPlusEqualDontReleaseBeforePress) {
TestDriver driver;
InSequence s;
auto key_plus = KeymapKey(0, 1, 1, KC_PLUS);
auto key_eql = KeymapKey(0, 0, 1, KC_EQL);
auto key_eql = KeymapKey(0, 0, 1, KC_EQUAL);

set_keymap({key_plus, key_eql});

key_plus.press();
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT)));
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT, KC_EQL)));
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT)));
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT, KC_EQUAL)));
run_one_scan_loop();
testing::Mock::VerifyAndClearExpectations(&driver);

Expand All @@ -238,7 +238,7 @@ TEST_F(KeyPress, PressPlusEqualDontReleaseBeforePress) {
testing::Mock::VerifyAndClearExpectations(&driver);

key_plus.release();
// BUG: Should really still return KC_EQL, but this is fine too
// BUG: Should really still return KC_EQUAL, but this is fine too
// It's also called twice for some reason
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).Times(2);
run_one_scan_loop();
Expand All @@ -254,12 +254,12 @@ TEST_F(KeyPress, PressEqualPlusReleaseBeforePress) {
TestDriver driver;
InSequence s;
auto key_plus = KeymapKey(0, 1, 1, KC_PLUS);
auto key_eql = KeymapKey(0, 0, 1, KC_EQL);
auto key_eql = KeymapKey(0, 0, 1, KC_EQUAL);

set_keymap({key_plus, key_eql});

key_eql.press();
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_EQL)));
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_EQUAL)));
run_one_scan_loop();
testing::Mock::VerifyAndClearExpectations(&driver);

Expand All @@ -269,13 +269,13 @@ TEST_F(KeyPress, PressEqualPlusReleaseBeforePress) {
testing::Mock::VerifyAndClearExpectations(&driver);

key_plus.press();
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT)));
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT, KC_EQL)));
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT)));
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT, KC_EQUAL)));
run_one_scan_loop();
testing::Mock::VerifyAndClearExpectations(&driver);

key_plus.release();
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT)));
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT)));
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
run_one_scan_loop();
testing::Mock::VerifyAndClearExpectations(&driver);
Expand All @@ -290,7 +290,7 @@ TEST_F(KeyPress, PressEqualPlusDontReleaseBeforePress) {
set_keymap({key_plus, key_eql});

key_eql.press();
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_EQL)));
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_EQUAL)));
run_one_scan_loop();
testing::Mock::VerifyAndClearExpectations(&driver);

Expand Down
2 changes: 1 addition & 1 deletion tests/basic/test_tapping.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ TEST_F(Tapping, HoldA_SHFT_T_KeyReportsShift) {
EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
idle_for(TAPPING_TERM);

EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT)));
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT)));
run_one_scan_loop();

EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.