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