From b6054c0206609f3755f71d819643644d250288b0 Mon Sep 17 00:00:00 2001 From: Stefan Kerkmann Date: Mon, 22 Nov 2021 22:15:04 +0100 Subject: [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 --- tests/basic/test_macro.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'tests/basic/test_macro.cpp') 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(); } -- cgit v1.2.3