1 /* Copyright 2017 Fred Sundvik
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 #include "test_common.hpp"
20 using testing::Return;
22 class KeyPress : public TestFixture {};
24 TEST_F(KeyPress, SendKeyboardIsNotCalledWhenNoKeyIsPressed) {
26 EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
30 TEST_F(KeyPress, CorrectKeyIsReportedWhenPressed) {
33 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_A)));
36 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
40 TEST_F(KeyPress, CorrectKeysAreReportedWhenTwoKeysArePressed) {
44 //Note that QMK only processes one key at a time
45 //See issue #1476 for more information
46 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_B)));
48 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_B, KC_C)));
52 //Note that the first key released is the first one in the matrix order
53 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_C)));
55 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
59 TEST_F(KeyPress, ANonMappedKeyDoesNothing) {
62 EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
67 TEST_F(KeyPress, LeftShiftIsReportedCorrectly) {
71 // Unfortunately modifiers are also processed in the wrong order
72 // See issue #1476 for more information
73 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_A)));
75 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_A, KC_LSFT)));
78 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT)));
81 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
85 TEST_F(KeyPress, PressLeftShiftAndControl) {
89 // Unfortunately modifiers are also processed in the wrong order
90 // See issue #1476 for more information
91 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT)));
93 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT, KC_LCTRL)));
97 TEST_F(KeyPress, LeftAndRightShiftCanBePressedAtTheSameTime) {
101 // Unfortunately modifiers are also processed in the wrong order
102 // See issue #1476 for more information
103 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT)));
105 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT, KC_RSFT)));
109 TEST_F(KeyPress, RightShiftLeftControlAndCharWithTheSameKey) {
112 // BUG: The press is split into two reports
113 // BUG: It reports RSFT instead of LSFT
114 // See issue #524 for more information
115 // The underlying cause is that we use only one bit to represent the right hand
117 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_RSFT, KC_RCTRL)));
118 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_RSFT, KC_RCTRL, KC_O)));
121 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_RSFT, KC_RCTRL)));
122 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));