qmk_firmware/quantum
Pascal Getreuer 95d20e6d8b
Fix and add unit tests for Caps Word to work with Unicode Map, Auto Shift, Retro Shift. (#17284)
* Fix Caps Word and Unicode Map

* Tests for Caps Word + Auto Shift and Unicode Map.

* Fix formatting

* Add additional keyboard report expectation macros

This commit defines five test utilities, EXPECT_REPORT, EXPECT_UNICODE,
EXPECT_EMPTY_REPORT, EXPECT_ANY_REPORT and EXPECT_NO_REPORT for use with
TestDriver.

EXPECT_REPORT sets a gmock expectation that a given keyboard report will
be sent. For instance,

  EXPECT_REPORT(driver, (KC_LSFT, KC_A));

is shorthand for

  EXPECT_CALL(driver,
      send_keyboard_mock(KeyboardReport(KC_LSFT, KC_A)));

EXPECT_UNICODE sets a gmock expectation that a given Unicode code point
will be sent using UC_LNX input mode. For instance for U+2013,

  EXPECT_UNICODE(driver, 0x2013);

expects the sequence of keys:

  "Ctrl+Shift+U, 2, 0, 1, 3, space".

EXPECT_EMPTY_REPORT sets a gmock expectation that a given keyboard
report will be sent. For instance

  EXPECT_EMPTY_REPORT(driver);

expects a single report without keypresses or modifiers.

EXPECT_ANY_REPORT sets a gmock expectation that a arbitrary keyboard
report will be sent, without matching its contents. For instance

  EXPECT_ANY_REPORT(driver).Times(1);

expects a single arbitrary keyboard report will be sent.

EXPECT_NO_REPORT sets a gmock expectation that no keyboard report will
be sent at all.

* Add tap_key() and tap_keys() to TestFixture.

This commit adds a `tap_key(key)` method to TestFixture that taps a
given KeymapKey, optionally with a specified delay between press and
release.

Similarly, the method `tap_keys(key_a, key_b, key_c)` taps a sequence of
KeymapKeys.

* Use EXPECT_REPORT, tap_keys, etc. in most tests.

This commit uses EXPECT_REPORT, EXPECT_UNICODE, EXPECT_EMPTY_REPORT,
EXPECT_NO_REPORT, tap_key() and tap_keys() test utilities from the
previous two commits in most tests. Particularly the EXPECT_REPORT
macro is frequently useful and makes a nice reduction in boilerplate
needed to express many tests.

Co-authored-by: David Kosorin <david@kosorin.net>
2022-06-05 09:14:02 +02:00
..
audio Format code according to conventions (#16322) 2022-02-12 18:29:31 +00:00
backlight Fix AVR backlight breathing: low brightness limit & exceeding breathing table max index (#16770) 2022-04-22 17:33:59 +10:00
bootmagic Format code according to conventions (#16322) 2022-02-12 18:29:31 +00:00
debounce Format code according to conventions (#16322) 2022-02-12 18:29:31 +00:00
encoder/tests Asymmetric encoders, encoder tests. (#16068) 2022-03-08 16:58:05 +11:00
keymap_extras Rename keymap_extras headers for consistency (#16939) 2022-05-15 21:27:01 +10:00
led_matrix Merge remote-tracking branch 'upstream/master' into develop 2022-02-19 04:27:09 +11:00
logging Format code according to conventions (#16322) 2022-02-12 18:29:31 +00:00
painter [QP] Check BPP capabilities before loading the palette (#16863) 2022-04-17 08:30:51 +10:00
process_keycode Fix and add unit tests for Caps Word to work with Unicode Map, Auto Shift, Retro Shift. (#17284) 2022-06-05 09:14:02 +02:00
rgb_matrix Fixes #16705 : digital rain follows val (#16716) 2022-04-19 21:02:21 +10:00
rgblight Remove ARM pgm_read_word workaround in rgblight (#16961) 2022-04-28 23:58:55 -07:00
sequencer Format code according to conventions (#16322) 2022-02-12 18:29:31 +00:00
split_common [Core] Use a mutex guard for split shared memory (#16647) 2022-04-19 20:56:16 +10:00
action.c Fix one-shot locked modifiers (#16114) 2022-04-18 02:12:25 -07:00
action.h Format code according to conventions (#16421) 2022-02-21 08:29:54 -08:00
action_code.h Rip out old macro and action_function system (#16025) 2022-01-24 21:22:20 +00:00
action_layer.c Missed some erroneous prints. (#16597) 2022-03-10 05:43:12 +11:00
action_layer.h Migrate platform independent code from tmk_core -> quantum (#13673) 2021-08-18 00:18:58 +01:00
action_tapping.c Add GET_TAPPING_TERM macro to reduce duplicate code (#16681) 2022-04-16 11:24:09 -07:00
action_tapping.h Add GET_TAPPING_TERM macro to reduce duplicate code (#16681) 2022-04-16 11:24:09 -07:00
action_util.c Fix oneshot toggle logic (#16630) 2022-03-14 01:11:42 +00:00
action_util.h Format code according to conventions (#16322) 2022-02-12 18:29:31 +00:00
bitwise.c Format code according to conventions (#16322) 2022-02-12 18:29:31 +00:00
bitwise.h Migrate some tmk_core files to quantum (#11791) 2021-02-07 23:16:15 +00:00
caps_word.c [Core] Add Caps Word feature to core (#16588) 2022-05-14 16:00:32 +10:00
caps_word.h [Core] Add Caps Word feature to core (#16588) 2022-05-14 16:00:32 +10:00
color.c Format code according to conventions (#16322) 2022-02-12 18:29:31 +00:00
color.h fixed typo in orange HSV colors decalartion (#15976) 2022-01-22 06:12:14 +00:00
command.c Format code according to conventions (#16322) 2022-02-12 18:29:31 +00:00
command.h Refactor quantum/command.{c,h} for code size & {read,maintain}ability (#11842) 2021-08-07 17:12:57 +10:00
config_common.h Remove deprecated KEYMAP alias (#15037) 2021-11-03 12:18:11 +11:00
crc.c Add CRC8 calculation subsystem to quantum (#12641) 2021-06-18 00:09:43 +01:00
crc.h Add CRC8 calculation subsystem to quantum (#12641) 2021-06-18 00:09:43 +01:00
debounce.h [Core] Remove matrix_is_modified() and debounce_is_active() (#15349) 2021-11-29 08:22:10 -08:00
deferred_exec.c Format code according to conventions (#16322) 2022-02-12 18:29:31 +00:00
deferred_exec.h Advanced deferred_exec for core-side code. (#15579) 2022-01-10 18:26:46 +00:00
digitizer.c Format code according to conventions (#16322) 2022-02-12 18:29:31 +00:00
digitizer.h Digitizer HID interface : absolute coordinates for mouse cursor (#12851) 2021-08-18 04:52:44 +10:00
dip_switch.c Format code according to conventions (#16322) 2022-02-12 18:29:31 +00:00
dip_switch.h Convert Dip Switch callbacks to boolean functions (#13399) 2021-07-01 08:22:21 -07:00
dynamic_keymap.c Fix missing definition for non-encoder case. (#16593) 2022-03-09 21:06:33 +11:00
dynamic_keymap.h Add support for encoder mapping. (#13286) 2022-03-09 19:29:00 +11:00
dynamic_macro.h [Core] Convert Dynamic Macro to a Core Feature (#5948) 2019-11-04 22:59:13 -08:00
eeconfig.c Fix oneshot toggle logic (#16630) 2022-03-14 01:11:42 +00:00
eeconfig.h Fix oneshot toggle logic (#16630) 2022-03-14 01:11:42 +00:00
encoder.c Add support for encoder mapping. (#13286) 2022-03-09 19:29:00 +11:00
encoder.h Add support for encoder mapping. (#13286) 2022-03-09 19:29:00 +11:00
haptic.c [Feature] Add support for multiple switchs/solenoids to Haptic Feedback engine (#15657) 2022-05-15 21:24:35 +10:00
haptic.h haptic: Feature to disable it when usb port is not configured or suspended. (#12692) 2021-11-02 16:54:29 +11:00
joystick.c Joystick feature updates (#16732) 2022-03-26 18:38:09 +00:00
joystick.h Joystick: Simplify report descriptor and clean up error messages (#16926) 2022-04-26 08:54:34 +10:00
keyboard.c [Core] Add Caps Word feature to core (#16588) 2022-05-14 16:00:32 +10:00
keyboard.h Rename TICK to TICK_EVENT to prevent naming conflicts (#16649) 2022-03-14 20:06:21 +00:00
keycode.h Format code according to conventions (#16322) 2022-02-12 18:29:31 +00:00
keycode_config.c Basic keycode overhaul (#14726) 2021-11-03 22:22:17 -07:00
keycode_config.h Fix oneshot toggle logic (#16630) 2022-03-14 01:11:42 +00:00
keycode_legacy.h Basic keycode overhaul (#14726) 2021-11-03 22:22:17 -07:00
keymap.h Add support for encoder mapping. (#13286) 2022-03-09 19:29:00 +11:00
keymap_common.c Add support for encoder mapping. (#13286) 2022-03-09 19:29:00 +11:00
led.c Format code according to conventions (#16322) 2022-02-12 18:29:31 +00:00
led.h Align location of some host led logic (#15954) 2022-01-22 21:17:02 +00:00
led_tables.c Remove unused LED_BREATHING_TABLE 2020-03-06 22:29:01 -08:00
led_tables.h Change include guards in quantum/ to pragma once (#11239) 2020-12-26 15:53:12 +11:00
main.c Quantum Painter (#10174) 2022-04-13 18:00:18 +10:00
matrix.c Format code according to conventions (#16322) 2022-02-12 18:29:31 +00:00
matrix.h Custom matrix lite support for split keyboards (#14674) 2021-12-27 21:03:40 +11:00
matrix_common.c Remove matrix_key_count() (#16603) 2022-03-10 12:18:07 +00:00
mousekey.c Revert "Fix kinetic mouse mode (#16951)" (#17095) 2022-05-14 13:03:07 -07:00
mousekey.h Adjust mouse key defaults (#15883) 2022-01-21 22:09:44 -08:00
pointing_device.c [Core] Move has_mouse_report_changed function to report.c (#16543) 2022-03-14 00:01:47 +00:00
pointing_device.h [Core] Move has_mouse_report_changed function to report.c (#16543) 2022-03-14 00:01:47 +00:00
pointing_device_drivers.c Add support for multiple sensors to pmw3360 (#15996) 2022-04-19 20:29:17 +10:00
programmable_button.c Format code according to conventions (#16322) 2022-02-12 18:29:31 +00:00
programmable_button.h Add Support for USB programmable buttons (#12950) 2021-09-15 08:40:22 -07:00
quantum.c Fix and add unit tests for Caps Word to work with Unicode Map, Auto Shift, Retro Shift. (#17284) 2022-06-05 09:14:02 +02:00
quantum.h [Core] Add Caps Word feature to core (#16588) 2022-05-14 16:00:32 +10:00
quantum_keycodes.h Enhancement and fixes of "Secure" feature (#16958) 2022-05-14 23:07:08 +01:00
quantum_keycodes_legacy.h Rename some Quantum keycodes (#15968) 2022-01-22 03:34:15 +00:00
raw_hid.h Relocate protocol files within tmk_core/common/ (#14972) 2021-10-28 22:31:59 +01:00
ring_buffer.h Format code according to conventions (#16322) 2022-02-12 18:29:31 +00:00
secure.c Enhancement and fixes of "Secure" feature (#16958) 2022-05-14 23:07:08 +01:00
secure.h Enhancement and fixes of "Secure" feature (#16958) 2022-05-14 23:07:08 +01:00
send_string.c Format code according to conventions (#16322) 2022-02-12 18:29:31 +00:00
send_string.h Remove hex_to_keycode and move tap_random_base64 to send_string.c (#12079) 2021-03-12 18:03:44 +11:00
send_string_keycodes.h Sendstring keycode overhaul (#16941) 2022-04-29 09:36:48 +10:00
sync_timer.c Format code according to conventions (#16322) 2022-02-12 18:29:31 +00:00
sync_timer.h Relocate protocol files within tmk_core/common/ (#14972) 2021-10-28 22:31:59 +01:00
utf8.c Quantum Painter (#10174) 2022-04-13 18:00:18 +10:00
utf8.h Quantum Painter (#10174) 2022-04-13 18:00:18 +10:00
util.h Asymmetric encoders, encoder tests. (#16068) 2022-03-08 16:58:05 +11:00
variable_trace.c clang-format changes 2019-08-30 15:01:52 -07:00
variable_trace.h Change include guards in quantum/ to pragma once (#11239) 2020-12-26 15:53:12 +11:00
velocikey.c Format code according to conventions (#16322) 2022-02-12 18:29:31 +00:00
velocikey.h Change include guards in quantum/ to pragma once (#11239) 2020-12-26 15:53:12 +11:00
via.c Add hacky via support for RGB Matrix (#16086) 2022-04-19 21:18:28 +10:00
via.h Format code according to conventions (#16322) 2022-02-12 18:29:31 +00:00
via_ensure_keycode.h Rename some Quantum keycodes (#15968) 2022-01-22 03:34:15 +00:00
virtser.h Relocate protocol files within tmk_core/common/ (#14972) 2021-10-28 22:31:59 +01:00
wpm.c Format code according to conventions (#16322) 2022-02-12 18:29:31 +00:00
wpm.h Fixes potential wpm sampling overflow, along with code comment fixes (#15277) 2021-12-27 11:52:56 +11:00