summaryrefslogtreecommitdiffstats
path: root/tests/basic/test_macro.cpp
diff options
context:
space:
mode:
authorStefan Kerkmann <karlk90@pm.me>2021-11-22 22:15:04 +0100
committerGitHub <noreply@github.com>2021-11-23 08:15:04 +1100
commitb6054c0206609f3755f71d819643644d250288b0 (patch)
tree4f6f33040bb5184d47144090058eb089d2782b6c /tests/basic/test_macro.cpp
parentf4966a19d69a7f3bbefeea0537071d7d7c2abbdd (diff)
[Tests] Increase QMK test coverage (#13789)
* Add per-test keymaps * Add better trace and info logs for failed unit-tests * Add layer state assertion with tracing message * Use individual test binaries configuration options * Add basic qmk functionality tests * Add tap hold configurations tests * Add auto shift tests * `qmk format-c * Fix tests Co-authored-by: Nick Brassel <nick@tzarc.org>
Diffstat (limited to 'tests/basic/test_macro.cpp')
-rw-r--r--tests/basic/test_macro.cpp19
1 files changed, 18 insertions, 1 deletions
diff --git a/tests/basic/test_macro.cpp b/tests/basic/test_macro.cpp
index 1ac6f473fc..ae2f3b32e3 100644
--- a/tests/basic/test_macro.cpp
+++ b/tests/basic/test_macro.cpp
@@ -24,10 +24,25 @@ class Macro : public TestFixture {};
#define AT_TIME(t) WillOnce(InvokeWithoutArgs([current_time]() { EXPECT_EQ(timer_elapsed32(current_time), t); }))
+extern "C" const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) {
+ if (record->event.pressed) {
+ switch (id) {
+ case 0:
+ return MACRO(D(LSFT), T(H), U(LSFT), T(E), T(L), T(L), T(O), T(SPACE), W(100), D(LSFT), T(W), U(LSFT), I(10), T(O), T(R), T(L), T(D), D(LSFT), T(1), U(LSFT), END);
+ }
+ }
+ return MACRO_NONE;
+};
+
TEST_F(Macro, PlayASimpleMacro) {
TestDriver driver;
InSequence s;
- press_key(8, 0);
+ auto key_macro = KeymapKey(0, 8, 0, M(0));
+
+ set_keymap({key_macro});
+
+ key_macro.press();
+
uint32_t current_time = timer_read32();
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT))).AT_TIME(0);
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT, KC_H))).AT_TIME(0);
@@ -68,4 +83,6 @@ TEST_F(Macro, PlayASimpleMacro) {
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT))).AT_TIME(210);
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).AT_TIME(220);
run_one_scan_loop();
+
+ key_macro.release();
}