Skip to content

Commit

Permalink
Add test for a combo key
Browse files Browse the repository at this point in the history
  • Loading branch information
fredizzimo authored and jackhumbert committed Jul 9, 2017
1 parent cae7a9c commit a62f449
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 5 deletions.
13 changes: 8 additions & 5 deletions tests/basic/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,15 @@

// Don't rearrange keys as existing tests might rely on the order
// Col2, Row 0 has to be KC_NO, because tests rely on it

#define COMBO1 RSFT(LCTL(KC_O))

const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[0] = {
// 0 1 2 3 4 5 6 7 8 9
{KC_A, KC_B, KC_NO, KC_LSFT, KC_RSFT, KC_LCTL, KC_NO, KC_NO, KC_NO, KC_NO},
{KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO},
{KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO},
{KC_C, KC_D, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO},
// 0 1 2 3 4 5 6 7 8 9
{KC_A, KC_B, KC_NO, KC_LSFT, KC_RSFT, KC_LCTL, COMBO1, KC_NO, KC_NO, KC_NO},
{KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO},
{KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO},
{KC_C, KC_D, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO},
},
};
36 changes: 36 additions & 0 deletions tests/basic/keypress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,40 @@ TEST_F(KeyPress, LeftShiftIsReportedCorrectly) {
release_key(3, 0);
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
keyboard_task();
}

TEST_F(KeyPress, PressLeftShiftAndControl) {
TestDriver driver;
press_key(3, 0);
press_key(5, 0);
// Unfortunately modifiers are also processed in the wrong order
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT)));
keyboard_task();
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT, KC_LCTRL)));
keyboard_task();
}

TEST_F(KeyPress, LeftAndRightShiftCanBePressedAtTheSameTime) {
TestDriver driver;
press_key(3, 0);
press_key(4, 0);
// Unfortunately modifiers are also processed in the wrong order
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT)));
keyboard_task();
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT, KC_RSFT)));
keyboard_task();
}

TEST_F(KeyPress, RightShiftLeftControlAndCharWithTheSameKey) {
TestDriver driver;
press_key(6, 0);
// BUG: The press is split into two reports
// BUG: It reports RSFT instead of LSFT
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_RSFT, KC_RCTRL)));
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_RSFT, KC_RCTRL, KC_O)));
keyboard_task();
release_key(6, 0);
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_RSFT, KC_RCTRL)));
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
keyboard_task();
}

0 comments on commit a62f449

Please sign in to comment.