summaryrefslogtreecommitdiff
path: root/tests/basic/test_keypress.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/basic/test_keypress.cpp')
-rw-r--r--tests/basic/test_keypress.cpp55
1 files changed, 26 insertions, 29 deletions
diff --git a/tests/basic/test_keypress.cpp b/tests/basic/test_keypress.cpp
index 1c175c9d56..044fc29378 100644
--- a/tests/basic/test_keypress.cpp
+++ b/tests/basic/test_keypress.cpp
@@ -85,7 +85,7 @@ TEST_F(KeyPress, CorrectKeysAreReportedWhenTwoKeysArePressed) {
85TEST_F(KeyPress, LeftShiftIsReportedCorrectly) { 85TEST_F(KeyPress, LeftShiftIsReportedCorrectly) {
86 TestDriver driver; 86 TestDriver driver;
87 auto key_a = KeymapKey(0, 0, 0, KC_A); 87 auto key_a = KeymapKey(0, 0, 0, KC_A);
88 auto key_lsft = KeymapKey(0, 3, 0, KC_LSFT); 88 auto key_lsft = KeymapKey(0, 3, 0, KC_LEFT_SHIFT);
89 89
90 set_keymap({key_a, key_lsft}); 90 set_keymap({key_a, key_lsft});
91 91
@@ -110,8 +110,8 @@ TEST_F(KeyPress, LeftShiftIsReportedCorrectly) {
110 110
111TEST_F(KeyPress, PressLeftShiftAndControl) { 111TEST_F(KeyPress, PressLeftShiftAndControl) {
112 TestDriver driver; 112 TestDriver driver;
113 auto key_lsft = KeymapKey(0, 3, 0, KC_LSFT); 113 auto key_lsft = KeymapKey(0, 3, 0, KC_LEFT_SHIFT);
114 auto key_lctrl = KeymapKey(0, 5, 0, KC_LCTRL); 114 auto key_lctrl = KeymapKey(0, 5, 0, KC_LEFT_CTRL);
115 115
116 set_keymap({key_lctrl, key_lsft}); 116 set_keymap({key_lctrl, key_lsft});
117 117
@@ -138,8 +138,8 @@ TEST_F(KeyPress, PressLeftShiftAndControl) {
138 138
139TEST_F(KeyPress, LeftAndRightShiftCanBePressedAtTheSameTime) { 139TEST_F(KeyPress, LeftAndRightShiftCanBePressedAtTheSameTime) {
140 TestDriver driver; 140 TestDriver driver;
141 auto key_lsft = KeymapKey(0, 3, 0, KC_LSFT); 141 auto key_lsft = KeymapKey(0, 3, 0, KC_LEFT_SHIFT);
142 auto key_rsft = KeymapKey(0, 4, 0, KC_RSFT); 142 auto key_rsft = KeymapKey(0, 4, 0, KC_RIGHT_SHIFT);
143 143
144 set_keymap({key_rsft, key_lsft}); 144 set_keymap({key_rsft, key_lsft});
145 145
@@ -175,12 +175,12 @@ TEST_F(KeyPress, RightShiftLeftControlAndCharWithTheSameKey) {
175 // The underlying cause is that we use only one bit to represent the right hand 175 // The underlying cause is that we use only one bit to represent the right hand
176 // modifiers. 176 // modifiers.
177 combo_key.press(); 177 combo_key.press();
178 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_RSFT, KC_RCTRL))); 178 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_RIGHT_SHIFT, KC_RIGHT_CTRL)));
179 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_RSFT, KC_RCTRL, KC_O))); 179 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_RIGHT_SHIFT, KC_RIGHT_CTRL, KC_O)));
180 keyboard_task(); 180 keyboard_task();
181 181
182 combo_key.release(); 182 combo_key.release();
183 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_RSFT, KC_RCTRL))); 183 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_RIGHT_SHIFT, KC_RIGHT_CTRL)));
184 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())); 184 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
185 keyboard_task(); 185 keyboard_task();
186} 186}
@@ -189,18 +189,18 @@ TEST_F(KeyPress, PressPlusEqualReleaseBeforePress) {
189 TestDriver driver; 189 TestDriver driver;
190 InSequence s; 190 InSequence s;
191 auto key_plus = KeymapKey(0, 1, 1, KC_PLUS); 191 auto key_plus = KeymapKey(0, 1, 1, KC_PLUS);
192 auto key_eql = KeymapKey(0, 0, 1, KC_EQL); 192 auto key_eql = KeymapKey(0, 0, 1, KC_EQUAL);
193 193
194 set_keymap({key_plus, key_eql}); 194 set_keymap({key_plus, key_eql});
195 195
196 key_plus.press(); 196 key_plus.press();
197 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT))); 197 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT)));
198 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT, KC_EQL))); 198 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT, KC_EQUAL)));
199 run_one_scan_loop(); 199 run_one_scan_loop();
200 testing::Mock::VerifyAndClearExpectations(&driver); 200 testing::Mock::VerifyAndClearExpectations(&driver);
201 201
202 key_plus.release(); 202 key_plus.release();
203 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT))); 203 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT)));
204 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())); 204 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
205 run_one_scan_loop(); 205 run_one_scan_loop();
206 testing::Mock::VerifyAndClearExpectations(&driver); 206 testing::Mock::VerifyAndClearExpectations(&driver);
@@ -220,13 +220,13 @@ TEST_F(KeyPress, PressPlusEqualDontReleaseBeforePress) {
220 TestDriver driver; 220 TestDriver driver;
221 InSequence s; 221 InSequence s;
222 auto key_plus = KeymapKey(0, 1, 1, KC_PLUS); 222 auto key_plus = KeymapKey(0, 1, 1, KC_PLUS);
223 auto key_eql = KeymapKey(0, 0, 1, KC_EQL); 223 auto key_eql = KeymapKey(0, 0, 1, KC_EQUAL);
224 224
225 set_keymap({key_plus, key_eql}); 225 set_keymap({key_plus, key_eql});
226 226
227 key_plus.press(); 227 key_plus.press();
228 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT))); 228 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT)));
229 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT, KC_EQL))); 229 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT, KC_EQUAL)));
230 run_one_scan_loop(); 230 run_one_scan_loop();
231 testing::Mock::VerifyAndClearExpectations(&driver); 231 testing::Mock::VerifyAndClearExpectations(&driver);
232 232
@@ -237,14 +237,13 @@ TEST_F(KeyPress, PressPlusEqualDontReleaseBeforePress) {
237 testing::Mock::VerifyAndClearExpectations(&driver); 237 testing::Mock::VerifyAndClearExpectations(&driver);
238 238
239 key_plus.release(); 239 key_plus.release();
240 // BUG: Should really still return KC_EQL, but this is fine too 240 // BUG: Should really still return KC_EQUAL, but this is fine too
241 // It's also called twice for some reason 241 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).Times(1);
242 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).Times(2);
243 run_one_scan_loop(); 242 run_one_scan_loop();
244 testing::Mock::VerifyAndClearExpectations(&driver); 243 testing::Mock::VerifyAndClearExpectations(&driver);
245 244
246 key_eql.release(); 245 key_eql.release();
247 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())); 246 EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
248 run_one_scan_loop(); 247 run_one_scan_loop();
249 testing::Mock::VerifyAndClearExpectations(&driver); 248 testing::Mock::VerifyAndClearExpectations(&driver);
250} 249}
@@ -253,12 +252,12 @@ TEST_F(KeyPress, PressEqualPlusReleaseBeforePress) {
253 TestDriver driver; 252 TestDriver driver;
254 InSequence s; 253 InSequence s;
255 auto key_plus = KeymapKey(0, 1, 1, KC_PLUS); 254 auto key_plus = KeymapKey(0, 1, 1, KC_PLUS);
256 auto key_eql = KeymapKey(0, 0, 1, KC_EQL); 255 auto key_eql = KeymapKey(0, 0, 1, KC_EQUAL);
257 256
258 set_keymap({key_plus, key_eql}); 257 set_keymap({key_plus, key_eql});
259 258
260 key_eql.press(); 259 key_eql.press();
261 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_EQL))); 260 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_EQUAL)));
262 run_one_scan_loop(); 261 run_one_scan_loop();
263 testing::Mock::VerifyAndClearExpectations(&driver); 262 testing::Mock::VerifyAndClearExpectations(&driver);
264 263
@@ -268,13 +267,13 @@ TEST_F(KeyPress, PressEqualPlusReleaseBeforePress) {
268 testing::Mock::VerifyAndClearExpectations(&driver); 267 testing::Mock::VerifyAndClearExpectations(&driver);
269 268
270 key_plus.press(); 269 key_plus.press();
271 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT))); 270 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT)));
272 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT, KC_EQL))); 271 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT, KC_EQUAL)));
273 run_one_scan_loop(); 272 run_one_scan_loop();
274 testing::Mock::VerifyAndClearExpectations(&driver); 273 testing::Mock::VerifyAndClearExpectations(&driver);
275 274
276 key_plus.release(); 275 key_plus.release();
277 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT))); 276 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT)));
278 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())); 277 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
279 run_one_scan_loop(); 278 run_one_scan_loop();
280 testing::Mock::VerifyAndClearExpectations(&driver); 279 testing::Mock::VerifyAndClearExpectations(&driver);
@@ -284,12 +283,12 @@ TEST_F(KeyPress, PressEqualPlusDontReleaseBeforePress) {
284 TestDriver driver; 283 TestDriver driver;
285 InSequence s; 284 InSequence s;
286 auto key_plus = KeymapKey(0, 1, 1, KC_PLUS); 285 auto key_plus = KeymapKey(0, 1, 1, KC_PLUS);
287 auto key_eql = KeymapKey(0, 0, 1, KC_EQL); 286 auto key_eql = KeymapKey(0, 0, 1, KC_EQUAL);
288 287
289 set_keymap({key_plus, key_eql}); 288 set_keymap({key_plus, key_eql});
290 289
291 key_eql.press(); 290 key_eql.press();
292 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_EQL))); 291 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_EQUAL)));
293 run_one_scan_loop(); 292 run_one_scan_loop();
294 testing::Mock::VerifyAndClearExpectations(&driver); 293 testing::Mock::VerifyAndClearExpectations(&driver);
295 294
@@ -309,9 +308,7 @@ TEST_F(KeyPress, PressEqualPlusDontReleaseBeforePress) {
309 testing::Mock::VerifyAndClearExpectations(&driver); 308 testing::Mock::VerifyAndClearExpectations(&driver);
310 309
311 key_plus.release(); 310 key_plus.release();
312 // This report is not needed
313 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT)));
314 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())); 311 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
315 run_one_scan_loop(); 312 run_one_scan_loop();
316 testing::Mock::VerifyAndClearExpectations(&driver); 313 testing::Mock::VerifyAndClearExpectations(&driver);
317} \ No newline at end of file 314}