diff options
| author | QMK Bot <hello@qmk.fm> | 2020-03-13 18:44:56 +0000 |
|---|---|---|
| committer | QMK Bot <hello@qmk.fm> | 2020-03-13 18:44:56 +0000 |
| commit | 5e98eaaaff8fde1ce25b9bad6c00a982718cb467 (patch) | |
| tree | 6af5516366a2a35b29ee7710c33eb47c2ead5718 /tests | |
| parent | 9e8767917d628afd3dc43759d1d50151c61944a1 (diff) | |
| download | qmk_firmware-5e98eaaaff8fde1ce25b9bad6c00a982718cb467.tar.gz qmk_firmware-5e98eaaaff8fde1ce25b9bad6c00a982718cb467.zip | |
format code according to conventions [skip ci]
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/basic/keymap.c | 1 | ||||
| -rw-r--r-- | tests/basic/test_keypress.cpp | 208 |
2 files changed, 104 insertions, 105 deletions
diff --git a/tests/basic/keymap.c b/tests/basic/keymap.c index 951ce8e0c..2b5747abb 100644 --- a/tests/basic/keymap.c +++ b/tests/basic/keymap.c | |||
| @@ -43,4 +43,3 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) { | |||
| 43 | } | 43 | } |
| 44 | return MACRO_NONE; | 44 | return MACRO_NONE; |
| 45 | }; | 45 | }; |
| 46 | |||
diff --git a/tests/basic/test_keypress.cpp b/tests/basic/test_keypress.cpp index 551458a0d..ecd6e98e4 100644 --- a/tests/basic/test_keypress.cpp +++ b/tests/basic/test_keypress.cpp | |||
| @@ -17,8 +17,8 @@ | |||
| 17 | #include "test_common.hpp" | 17 | #include "test_common.hpp" |
| 18 | 18 | ||
| 19 | using testing::_; | 19 | using testing::_; |
| 20 | using testing::Return; | ||
| 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 | ||
| @@ -125,116 +125,116 @@ TEST_F(KeyPress, RightShiftLeftControlAndCharWithTheSameKey) { | |||
| 125 | } | 125 | } |
| 126 | 126 | ||
| 127 | TEST_F(KeyPress, PressPlusEqualReleaseBeforePress) { | 127 | TEST_F(KeyPress, PressPlusEqualReleaseBeforePress) { |
| 128 | TestDriver driver; | 128 | TestDriver driver; |
| 129 | InSequence s; | 129 | InSequence s; |
| 130 | 130 | ||
| 131 | press_key(1, 1); // KC_PLUS | 131 | press_key(1, 1); // KC_PLUS |
| 132 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT))); | 132 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT))); |
| 133 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT, KC_EQL))); | 133 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT, KC_EQL))); |
| 134 | run_one_scan_loop(); | 134 | run_one_scan_loop(); |
| 135 | testing::Mock::VerifyAndClearExpectations(&driver); | 135 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 136 | 136 | ||
| 137 | release_key(1, 1); // KC_PLUS | 137 | release_key(1, 1); // KC_PLUS |
| 138 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT))); | 138 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT))); |
| 139 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())); | 139 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())); |
| 140 | run_one_scan_loop(); | 140 | run_one_scan_loop(); |
| 141 | testing::Mock::VerifyAndClearExpectations(&driver); | 141 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 142 | 142 | ||
| 143 | press_key(0, 1); // KC_EQL | 143 | press_key(0, 1); // KC_EQL |
| 144 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_EQL))); | 144 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_EQL))); |
| 145 | run_one_scan_loop(); | 145 | run_one_scan_loop(); |
| 146 | testing::Mock::VerifyAndClearExpectations(&driver); | 146 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 147 | 147 | ||
| 148 | release_key(0, 1); // KC_EQL | 148 | release_key(0, 1); // KC_EQL |
| 149 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())); | 149 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())); |
| 150 | run_one_scan_loop(); | 150 | run_one_scan_loop(); |
| 151 | testing::Mock::VerifyAndClearExpectations(&driver); | 151 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 152 | } | 152 | } |
| 153 | 153 | ||
| 154 | TEST_F(KeyPress, PressPlusEqualDontReleaseBeforePress) { | 154 | TEST_F(KeyPress, PressPlusEqualDontReleaseBeforePress) { |
| 155 | TestDriver driver; | 155 | TestDriver driver; |
| 156 | InSequence s; | 156 | InSequence s; |
| 157 | 157 | ||
| 158 | press_key(1, 1); // KC_PLUS | 158 | press_key(1, 1); // KC_PLUS |
| 159 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT))); | 159 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT))); |
| 160 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT, KC_EQL))); | 160 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT, KC_EQL))); |
| 161 | run_one_scan_loop(); | 161 | run_one_scan_loop(); |
| 162 | testing::Mock::VerifyAndClearExpectations(&driver); | 162 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 163 | 163 | ||
| 164 | press_key(0, 1); // KC_EQL | 164 | press_key(0, 1); // KC_EQL |
| 165 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())); | 165 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())); |
| 166 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_EQL))); | 166 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_EQL))); |
| 167 | run_one_scan_loop(); | 167 | run_one_scan_loop(); |
| 168 | testing::Mock::VerifyAndClearExpectations(&driver); | 168 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 169 | 169 | ||
| 170 | release_key(1, 1); //KC_PLS | 170 | release_key(1, 1); // KC_PLS |
| 171 | // BUG: Should really still return KC_EQL, but this is fine too | 171 | // BUG: Should really still return KC_EQL, but this is fine too |
| 172 | // It's also called twice for some reason | 172 | // It's also called twice for some reason |
| 173 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).Times(2); | 173 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).Times(2); |
| 174 | run_one_scan_loop(); | 174 | run_one_scan_loop(); |
| 175 | testing::Mock::VerifyAndClearExpectations(&driver); | 175 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 176 | 176 | ||
| 177 | release_key(0, 1); // KC_EQL | 177 | release_key(0, 1); // KC_EQL |
| 178 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())); | 178 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())); |
| 179 | run_one_scan_loop(); | 179 | run_one_scan_loop(); |
| 180 | testing::Mock::VerifyAndClearExpectations(&driver); | 180 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 181 | } | 181 | } |
| 182 | 182 | ||
| 183 | TEST_F(KeyPress, PressEqualPlusReleaseBeforePress) { | 183 | TEST_F(KeyPress, PressEqualPlusReleaseBeforePress) { |
| 184 | TestDriver driver; | 184 | TestDriver driver; |
| 185 | InSequence s; | 185 | InSequence s; |
| 186 | 186 | ||
| 187 | press_key(0, 1); // KC_EQL | 187 | press_key(0, 1); // KC_EQL |
| 188 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_EQL))); | 188 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_EQL))); |
| 189 | run_one_scan_loop(); | 189 | run_one_scan_loop(); |
| 190 | testing::Mock::VerifyAndClearExpectations(&driver); | 190 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 191 | 191 | ||
| 192 | release_key(0, 1); // KQ_EQL | 192 | release_key(0, 1); // KQ_EQL |
| 193 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())); | 193 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())); |
| 194 | run_one_scan_loop(); | 194 | run_one_scan_loop(); |
| 195 | testing::Mock::VerifyAndClearExpectations(&driver); | 195 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 196 | 196 | ||
| 197 | press_key(1, 1); // KC_PLUS | 197 | press_key(1, 1); // KC_PLUS |
| 198 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT))); | 198 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT))); |
| 199 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT, KC_EQL))); | 199 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT, KC_EQL))); |
| 200 | run_one_scan_loop(); | 200 | run_one_scan_loop(); |
| 201 | testing::Mock::VerifyAndClearExpectations(&driver); | 201 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 202 | 202 | ||
| 203 | release_key(1, 1); // KC_PLUS | 203 | release_key(1, 1); // KC_PLUS |
| 204 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT))); | 204 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT))); |
| 205 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())); | 205 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())); |
| 206 | run_one_scan_loop(); | 206 | run_one_scan_loop(); |
| 207 | testing::Mock::VerifyAndClearExpectations(&driver); | 207 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 208 | } | 208 | } |
| 209 | 209 | ||
| 210 | TEST_F(KeyPress, PressEqualPlusDontReleaseBeforePress) { | 210 | TEST_F(KeyPress, PressEqualPlusDontReleaseBeforePress) { |
| 211 | TestDriver driver; | 211 | TestDriver driver; |
| 212 | InSequence s; | 212 | InSequence s; |
| 213 | 213 | ||
| 214 | press_key(0, 1); // KC_EQL | 214 | press_key(0, 1); // KC_EQL |
| 215 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_EQL))); | 215 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_EQL))); |
| 216 | run_one_scan_loop(); | 216 | run_one_scan_loop(); |
| 217 | testing::Mock::VerifyAndClearExpectations(&driver); | 217 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 218 | 218 | ||
| 219 | press_key(1, 1); // KC_PLUS | 219 | press_key(1, 1); // KC_PLUS |
| 220 | // 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 |
| 221 | // KC_PLUS is sent | 221 | // KC_PLUS is sent |
| 222 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT, KC_EQL))); | 222 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT, KC_EQL))); |
| 223 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT))); | 223 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT))); |
| 224 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT, KC_EQL))); | 224 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT, KC_EQL))); |
| 225 | run_one_scan_loop(); | 225 | run_one_scan_loop(); |
| 226 | testing::Mock::VerifyAndClearExpectations(&driver); | 226 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 227 | 227 | ||
| 228 | release_key(0, 1); //KC_EQL | 228 | release_key(0, 1); // KC_EQL |
| 229 | // I guess it's fine to still report shift here | 229 | // I guess it's fine to still report shift here |
| 230 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT))); | 230 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT))); |
| 231 | run_one_scan_loop(); | 231 | run_one_scan_loop(); |
| 232 | testing::Mock::VerifyAndClearExpectations(&driver); | 232 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 233 | 233 | ||
| 234 | release_key(1, 1); // KC_PLUS | 234 | release_key(1, 1); // KC_PLUS |
| 235 | // This report is not needed | 235 | // This report is not needed |
| 236 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT))); | 236 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT))); |
| 237 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())); | 237 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())); |
| 238 | run_one_scan_loop(); | 238 | run_one_scan_loop(); |
| 239 | testing::Mock::VerifyAndClearExpectations(&driver); | 239 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 240 | } | 240 | } |
