diff options
Diffstat (limited to 'tests/basic/test_keypress.cpp')
| -rw-r--r-- | tests/basic/test_keypress.cpp | 185 |
1 files changed, 54 insertions, 131 deletions
diff --git a/tests/basic/test_keypress.cpp b/tests/basic/test_keypress.cpp index 70613bbd6..cf839f8c1 100644 --- a/tests/basic/test_keypress.cpp +++ b/tests/basic/test_keypress.cpp | |||
| @@ -14,11 +14,11 @@ | |||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 15 | */ | 15 | */ |
| 16 | 16 | ||
| 17 | #include "keycode.h" | ||
| 18 | #include "test_common.hpp" | 17 | #include "test_common.hpp" |
| 19 | 18 | ||
| 20 | using testing::_; | 19 | using testing::_; |
| 21 | using testing::InSequence; | 20 | using testing::InSequence; |
| 21 | using testing::Return; | ||
| 22 | 22 | ||
| 23 | class KeyPress : public TestFixture {}; | 23 | class KeyPress : public TestFixture {}; |
| 24 | 24 | ||
| @@ -30,156 +30,95 @@ TEST_F(KeyPress, SendKeyboardIsNotCalledWhenNoKeyIsPressed) { | |||
| 30 | 30 | ||
| 31 | TEST_F(KeyPress, CorrectKeyIsReportedWhenPressed) { | 31 | TEST_F(KeyPress, CorrectKeyIsReportedWhenPressed) { |
| 32 | TestDriver driver; | 32 | TestDriver driver; |
| 33 | auto key = KeymapKey(0, 0, 0, KC_A); | 33 | press_key(0, 0); |
| 34 | 34 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_A))); | |
| 35 | set_keymap({key}); | ||
| 36 | |||
| 37 | key.press(); | ||
| 38 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(key.report_code))); | ||
| 39 | keyboard_task(); | 35 | keyboard_task(); |
| 40 | 36 | release_key(0, 0); | |
| 41 | key.release(); | ||
| 42 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())); | 37 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())); |
| 43 | keyboard_task(); | 38 | keyboard_task(); |
| 44 | } | 39 | } |
| 45 | 40 | ||
| 46 | TEST_F(KeyPress, ANonMappedKeyDoesNothing) { | ||
| 47 | TestDriver driver; | ||
| 48 | auto key = KeymapKey(0, 0, 0, KC_NO); | ||
| 49 | |||
| 50 | set_keymap({key}); | ||
| 51 | |||
| 52 | key.press(); | ||
| 53 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | ||
| 54 | keyboard_task(); | ||
| 55 | keyboard_task(); | ||
| 56 | } | ||
| 57 | |||
| 58 | TEST_F(KeyPress, CorrectKeysAreReportedWhenTwoKeysArePressed) { | 41 | TEST_F(KeyPress, CorrectKeysAreReportedWhenTwoKeysArePressed) { |
| 59 | TestDriver driver; | 42 | TestDriver driver; |
| 60 | auto key_b = KeymapKey(0, 0, 0, KC_B); | 43 | press_key(1, 0); |
| 61 | auto key_c = KeymapKey(0, 1, 1, KC_C); | 44 | press_key(0, 3); |
| 62 | |||
| 63 | set_keymap({key_b, key_c}); | ||
| 64 | |||
| 65 | key_b.press(); | ||
| 66 | key_c.press(); | ||
| 67 | // Note that QMK only processes one key at a time | 45 | // Note that QMK only processes one key at a time |
| 68 | // See issue #1476 for more information | 46 | // See issue #1476 for more information |
| 69 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(key_b.report_code))); | 47 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_B))); |
| 70 | keyboard_task(); | 48 | keyboard_task(); |
| 71 | 49 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_B, KC_C))); | |
| 72 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(key_b.report_code, key_c.report_code))); | ||
| 73 | keyboard_task(); | 50 | keyboard_task(); |
| 74 | 51 | release_key(1, 0); | |
| 75 | key_b.release(); | 52 | release_key(0, 3); |
| 76 | key_c.release(); | ||
| 77 | // Note that the first key released is the first one in the matrix order | 53 | // Note that the first key released is the first one in the matrix order |
| 78 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(key_c.report_code))); | 54 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_C))); |
| 79 | keyboard_task(); | 55 | keyboard_task(); |
| 80 | |||
| 81 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())); | 56 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())); |
| 82 | keyboard_task(); | 57 | keyboard_task(); |
| 83 | } | 58 | } |
| 84 | 59 | ||
| 85 | TEST_F(KeyPress, LeftShiftIsReportedCorrectly) { | 60 | TEST_F(KeyPress, ANonMappedKeyDoesNothing) { |
| 86 | TestDriver driver; | 61 | TestDriver driver; |
| 87 | auto key_a = KeymapKey(0, 0, 0, KC_A); | 62 | press_key(2, 0); |
| 88 | auto key_lsft = KeymapKey(0, 3, 0, KC_LEFT_SHIFT); | 63 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); |
| 89 | 64 | keyboard_task(); | |
| 90 | set_keymap({key_a, key_lsft}); | 65 | keyboard_task(); |
| 91 | 66 | } | |
| 92 | key_lsft.press(); | ||
| 93 | key_a.press(); | ||
| 94 | 67 | ||
| 68 | TEST_F(KeyPress, LeftShiftIsReportedCorrectly) { | ||
| 69 | TestDriver driver; | ||
| 70 | press_key(3, 0); | ||
| 71 | press_key(0, 0); | ||
| 95 | // Unfortunately modifiers are also processed in the wrong order | 72 | // Unfortunately modifiers are also processed in the wrong order |
| 96 | // See issue #1476 for more information | 73 | // See issue #1476 for more information |
| 97 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(key_a.report_code))); | 74 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_A))); |
| 98 | keyboard_task(); | 75 | keyboard_task(); |
| 99 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(key_a.report_code, key_lsft.report_code))); | 76 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_A, KC_LEFT_SHIFT))); |
| 100 | keyboard_task(); | 77 | keyboard_task(); |
| 101 | 78 | release_key(0, 0); | |
| 102 | key_a.release(); | 79 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT))); |
| 103 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(key_lsft.report_code))); | ||
| 104 | keyboard_task(); | 80 | keyboard_task(); |
| 105 | 81 | release_key(3, 0); | |
| 106 | key_lsft.release(); | ||
| 107 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())); | 82 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())); |
| 108 | keyboard_task(); | 83 | keyboard_task(); |
| 109 | } | 84 | } |
| 110 | 85 | ||
| 111 | TEST_F(KeyPress, PressLeftShiftAndControl) { | 86 | TEST_F(KeyPress, PressLeftShiftAndControl) { |
| 112 | TestDriver driver; | 87 | TestDriver driver; |
| 113 | auto key_lsft = KeymapKey(0, 3, 0, KC_LEFT_SHIFT); | 88 | press_key(3, 0); |
| 114 | auto key_lctrl = KeymapKey(0, 5, 0, KC_LEFT_CTRL); | 89 | press_key(5, 0); |
| 115 | |||
| 116 | set_keymap({key_lctrl, key_lsft}); | ||
| 117 | |||
| 118 | key_lsft.press(); | ||
| 119 | key_lctrl.press(); | ||
| 120 | |||
| 121 | // Unfortunately modifiers are also processed in the wrong order | 90 | // Unfortunately modifiers are also processed in the wrong order |
| 122 | // See issue #1476 for more information | 91 | // See issue #1476 for more information |
| 123 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(key_lsft.report_code))); | 92 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT))); |
| 124 | keyboard_task(); | ||
| 125 | |||
| 126 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(key_lsft.report_code, key_lctrl.report_code))); | ||
| 127 | keyboard_task(); | ||
| 128 | |||
| 129 | key_lsft.release(); | ||
| 130 | key_lctrl.release(); | ||
| 131 | |||
| 132 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(key_lctrl.report_code))); | ||
| 133 | keyboard_task(); | 93 | keyboard_task(); |
| 134 | 94 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT, KC_LEFT_CTRL))); | |
| 135 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())); | ||
| 136 | keyboard_task(); | 95 | keyboard_task(); |
| 137 | } | 96 | } |
| 138 | 97 | ||
| 139 | TEST_F(KeyPress, LeftAndRightShiftCanBePressedAtTheSameTime) { | 98 | TEST_F(KeyPress, LeftAndRightShiftCanBePressedAtTheSameTime) { |
| 140 | TestDriver driver; | 99 | TestDriver driver; |
| 141 | auto key_lsft = KeymapKey(0, 3, 0, KC_LEFT_SHIFT); | 100 | press_key(3, 0); |
| 142 | auto key_rsft = KeymapKey(0, 4, 0, KC_RIGHT_SHIFT); | 101 | press_key(4, 0); |
| 143 | |||
| 144 | set_keymap({key_rsft, key_lsft}); | ||
| 145 | |||
| 146 | key_lsft.press(); | ||
| 147 | key_rsft.press(); | ||
| 148 | // Unfortunately modifiers are also processed in the wrong order | 102 | // Unfortunately modifiers are also processed in the wrong order |
| 149 | // See issue #1476 for more information | 103 | // See issue #1476 for more information |
| 150 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(key_lsft.report_code))); | 104 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT))); |
| 151 | keyboard_task(); | ||
| 152 | |||
| 153 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(key_lsft.report_code, key_rsft.report_code))); | ||
| 154 | keyboard_task(); | ||
| 155 | |||
| 156 | key_lsft.release(); | ||
| 157 | key_rsft.release(); | ||
| 158 | |||
| 159 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(key_rsft.report_code))); | ||
| 160 | keyboard_task(); | 105 | keyboard_task(); |
| 161 | 106 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT, KC_RIGHT_SHIFT))); | |
| 162 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())); | ||
| 163 | keyboard_task(); | 107 | keyboard_task(); |
| 164 | } | 108 | } |
| 165 | 109 | ||
| 166 | TEST_F(KeyPress, RightShiftLeftControlAndCharWithTheSameKey) { | 110 | TEST_F(KeyPress, RightShiftLeftControlAndCharWithTheSameKey) { |
| 167 | TestDriver driver; | 111 | TestDriver driver; |
| 168 | auto combo_key = KeymapKey(0, 0, 0, RSFT(LCTL(KC_O))); | 112 | press_key(6, 0); |
| 169 | |||
| 170 | set_keymap({combo_key}); | ||
| 171 | |||
| 172 | // BUG: The press is split into two reports | 113 | // BUG: The press is split into two reports |
| 173 | // BUG: It reports RSFT instead of LSFT | 114 | // BUG: It reports RSFT instead of LSFT |
| 174 | // See issue #524 for more information | 115 | // See issue #524 for more information |
| 175 | // The underlying cause is that we use only one bit to represent the right hand | 116 | // The underlying cause is that we use only one bit to represent the right hand |
| 176 | // modifiers. | 117 | // modifiers. |
| 177 | combo_key.press(); | ||
| 178 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_RIGHT_SHIFT, KC_RIGHT_CTRL))); | 118 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_RIGHT_SHIFT, KC_RIGHT_CTRL))); |
| 179 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_RIGHT_SHIFT, KC_RIGHT_CTRL, KC_O))); | 119 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_RIGHT_SHIFT, KC_RIGHT_CTRL, KC_O))); |
| 180 | keyboard_task(); | 120 | keyboard_task(); |
| 181 | 121 | release_key(6, 0); | |
| 182 | combo_key.release(); | ||
| 183 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_RIGHT_SHIFT, KC_RIGHT_CTRL))); | 122 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_RIGHT_SHIFT, KC_RIGHT_CTRL))); |
| 184 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())); | 123 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())); |
| 185 | keyboard_task(); | 124 | keyboard_task(); |
| @@ -188,29 +127,25 @@ TEST_F(KeyPress, RightShiftLeftControlAndCharWithTheSameKey) { | |||
| 188 | TEST_F(KeyPress, PressPlusEqualReleaseBeforePress) { | 127 | TEST_F(KeyPress, PressPlusEqualReleaseBeforePress) { |
| 189 | TestDriver driver; | 128 | TestDriver driver; |
| 190 | InSequence s; | 129 | InSequence s; |
| 191 | auto key_plus = KeymapKey(0, 1, 1, KC_PLUS); | ||
| 192 | auto key_eql = KeymapKey(0, 0, 1, KC_EQL); | ||
| 193 | |||
| 194 | set_keymap({key_plus, key_eql}); | ||
| 195 | 130 | ||
| 196 | key_plus.press(); | 131 | press_key(1, 1); // KC_PLUS |
| 197 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT))); | 132 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT))); |
| 198 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT, KC_EQUAL))); | 133 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT, KC_EQUAL))); |
| 199 | run_one_scan_loop(); | 134 | run_one_scan_loop(); |
| 200 | testing::Mock::VerifyAndClearExpectations(&driver); | 135 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 201 | 136 | ||
| 202 | key_plus.release(); | 137 | release_key(1, 1); // KC_PLUS |
| 203 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT))); | 138 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT))); |
| 204 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())); | 139 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())); |
| 205 | run_one_scan_loop(); | 140 | run_one_scan_loop(); |
| 206 | testing::Mock::VerifyAndClearExpectations(&driver); | 141 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 207 | 142 | ||
| 208 | key_eql.press(); | 143 | press_key(0, 1); // KC_EQUAL |
| 209 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(key_eql.report_code))); | 144 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_EQUAL))); |
| 210 | run_one_scan_loop(); | 145 | run_one_scan_loop(); |
| 211 | testing::Mock::VerifyAndClearExpectations(&driver); | 146 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 212 | 147 | ||
| 213 | key_eql.release(); | 148 | release_key(0, 1); // KC_EQUAL |
| 214 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())); | 149 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())); |
| 215 | run_one_scan_loop(); | 150 | run_one_scan_loop(); |
| 216 | testing::Mock::VerifyAndClearExpectations(&driver); | 151 | testing::Mock::VerifyAndClearExpectations(&driver); |
| @@ -219,31 +154,27 @@ TEST_F(KeyPress, PressPlusEqualReleaseBeforePress) { | |||
| 219 | TEST_F(KeyPress, PressPlusEqualDontReleaseBeforePress) { | 154 | TEST_F(KeyPress, PressPlusEqualDontReleaseBeforePress) { |
| 220 | TestDriver driver; | 155 | TestDriver driver; |
| 221 | InSequence s; | 156 | InSequence s; |
| 222 | auto key_plus = KeymapKey(0, 1, 1, KC_PLUS); | ||
| 223 | auto key_eql = KeymapKey(0, 0, 1, KC_EQUAL); | ||
| 224 | |||
| 225 | set_keymap({key_plus, key_eql}); | ||
| 226 | 157 | ||
| 227 | key_plus.press(); | 158 | press_key(1, 1); // KC_PLUS |
| 228 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT))); | 159 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT))); |
| 229 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT, KC_EQUAL))); | 160 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT, KC_EQUAL))); |
| 230 | run_one_scan_loop(); | 161 | run_one_scan_loop(); |
| 231 | testing::Mock::VerifyAndClearExpectations(&driver); | 162 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 232 | 163 | ||
| 233 | key_eql.press(); | 164 | press_key(0, 1); // KC_EQUAL |
| 234 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())); | 165 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())); |
| 235 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_EQUAL))); | 166 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_EQUAL))); |
| 236 | run_one_scan_loop(); | 167 | run_one_scan_loop(); |
| 237 | testing::Mock::VerifyAndClearExpectations(&driver); | 168 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 238 | 169 | ||
| 239 | key_plus.release(); | 170 | release_key(1, 1); // KC_PLUS |
| 240 | // BUG: Should really still return KC_EQUAL, but this is fine too | 171 | // BUG: Should really still return KC_EQUAL, but this is fine too |
| 241 | // It's also called twice for some reason | 172 | // It's also called twice for some reason |
| 242 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).Times(2); | 173 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).Times(2); |
| 243 | run_one_scan_loop(); | 174 | run_one_scan_loop(); |
| 244 | testing::Mock::VerifyAndClearExpectations(&driver); | 175 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 245 | 176 | ||
| 246 | key_eql.release(); | 177 | release_key(0, 1); // KC_EQUAL |
| 247 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())); | 178 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())); |
| 248 | run_one_scan_loop(); | 179 | run_one_scan_loop(); |
| 249 | testing::Mock::VerifyAndClearExpectations(&driver); | 180 | testing::Mock::VerifyAndClearExpectations(&driver); |
| @@ -252,28 +183,24 @@ TEST_F(KeyPress, PressPlusEqualDontReleaseBeforePress) { | |||
| 252 | TEST_F(KeyPress, PressEqualPlusReleaseBeforePress) { | 183 | TEST_F(KeyPress, PressEqualPlusReleaseBeforePress) { |
| 253 | TestDriver driver; | 184 | TestDriver driver; |
| 254 | InSequence s; | 185 | InSequence s; |
| 255 | auto key_plus = KeymapKey(0, 1, 1, KC_PLUS); | ||
| 256 | auto key_eql = KeymapKey(0, 0, 1, KC_EQUAL); | ||
| 257 | 186 | ||
| 258 | set_keymap({key_plus, key_eql}); | 187 | press_key(0, 1); // KC_EQUAL |
| 259 | |||
| 260 | key_eql.press(); | ||
| 261 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_EQUAL))); | 188 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_EQUAL))); |
| 262 | run_one_scan_loop(); | 189 | run_one_scan_loop(); |
| 263 | testing::Mock::VerifyAndClearExpectations(&driver); | 190 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 264 | 191 | ||
| 265 | key_eql.release(); | 192 | release_key(0, 1); // KC_EQUAL |
| 266 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())); | 193 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())); |
| 267 | run_one_scan_loop(); | 194 | run_one_scan_loop(); |
| 268 | testing::Mock::VerifyAndClearExpectations(&driver); | 195 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 269 | 196 | ||
| 270 | key_plus.press(); | 197 | press_key(1, 1); // KC_PLUS |
| 271 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT))); | 198 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT))); |
| 272 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT, KC_EQUAL))); | 199 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT, KC_EQUAL))); |
| 273 | run_one_scan_loop(); | 200 | run_one_scan_loop(); |
| 274 | testing::Mock::VerifyAndClearExpectations(&driver); | 201 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 275 | 202 | ||
| 276 | key_plus.release(); | 203 | release_key(1, 1); // KC_PLUS |
| 277 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT))); | 204 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT))); |
| 278 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())); | 205 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())); |
| 279 | run_one_scan_loop(); | 206 | run_one_scan_loop(); |
| @@ -283,17 +210,13 @@ TEST_F(KeyPress, PressEqualPlusReleaseBeforePress) { | |||
| 283 | TEST_F(KeyPress, PressEqualPlusDontReleaseBeforePress) { | 210 | TEST_F(KeyPress, PressEqualPlusDontReleaseBeforePress) { |
| 284 | TestDriver driver; | 211 | TestDriver driver; |
| 285 | InSequence s; | 212 | InSequence s; |
| 286 | auto key_plus = KeymapKey(0, 1, 1, KC_PLUS); | ||
| 287 | auto key_eql = KeymapKey(0, 0, 1, KC_EQL); | ||
| 288 | |||
| 289 | set_keymap({key_plus, key_eql}); | ||
| 290 | 213 | ||
| 291 | key_eql.press(); | 214 | press_key(0, 1); // KC_EQUAL |
| 292 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_EQUAL))); | 215 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_EQUAL))); |
| 293 | run_one_scan_loop(); | 216 | run_one_scan_loop(); |
| 294 | testing::Mock::VerifyAndClearExpectations(&driver); | 217 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 295 | 218 | ||
| 296 | key_plus.press(); | 219 | press_key(1, 1); // KC_PLUS |
| 297 | // BUG: The sequence is a bit strange, but it works, the end result is that | 220 | // BUG: The sequence is a bit strange, but it works, the end result is that |
| 298 | // KC_PLUS is sent | 221 | // KC_PLUS is sent |
| 299 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT, KC_EQUAL))); | 222 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT, KC_EQUAL))); |
| @@ -302,16 +225,16 @@ TEST_F(KeyPress, PressEqualPlusDontReleaseBeforePress) { | |||
| 302 | run_one_scan_loop(); | 225 | run_one_scan_loop(); |
| 303 | testing::Mock::VerifyAndClearExpectations(&driver); | 226 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 304 | 227 | ||
| 305 | key_eql.release(); | 228 | release_key(0, 1); // KC_EQUAL |
| 306 | // I guess it's fine to still report shift here | 229 | // I guess it's fine to still report shift here |
| 307 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT))); | 230 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT))); |
| 308 | run_one_scan_loop(); | 231 | run_one_scan_loop(); |
| 309 | testing::Mock::VerifyAndClearExpectations(&driver); | 232 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 310 | 233 | ||
| 311 | key_plus.release(); | 234 | release_key(1, 1); // KC_PLUS |
| 312 | // This report is not needed | 235 | // This report is not needed |
| 313 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT))); | 236 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT))); |
| 314 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())); | 237 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())); |
| 315 | run_one_scan_loop(); | 238 | run_one_scan_loop(); |
| 316 | testing::Mock::VerifyAndClearExpectations(&driver); | 239 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 317 | } \ No newline at end of file | 240 | } |
