From bbf7a20b33de2d203518687cb5cd1aa85005ea27 Mon Sep 17 00:00:00 2001 From: Ryan Date: Mon, 13 Feb 2023 03:19:02 +1100 Subject: Refactor Leader key feature (#19632) Co-authored-by: Drashna Jaelre --- tests/leader/leader_per_key_timeout/config.h | 5 +++ tests/leader/leader_per_key_timeout/test.mk | 7 ++++ .../test_leader_per_key_timeout.cpp | 40 ++++++++++++++++++++++ 3 files changed, 52 insertions(+) create mode 100644 tests/leader/leader_per_key_timeout/config.h create mode 100644 tests/leader/leader_per_key_timeout/test.mk create mode 100644 tests/leader/leader_per_key_timeout/test_leader_per_key_timeout.cpp (limited to 'tests/leader/leader_per_key_timeout') diff --git a/tests/leader/leader_per_key_timeout/config.h b/tests/leader/leader_per_key_timeout/config.h new file mode 100644 index 0000000000..045e7c1a57 --- /dev/null +++ b/tests/leader/leader_per_key_timeout/config.h @@ -0,0 +1,5 @@ +#pragma once + +#include "test_common.h" + +#define LEADER_PER_KEY_TIMING diff --git a/tests/leader/leader_per_key_timeout/test.mk b/tests/leader/leader_per_key_timeout/test.mk new file mode 100644 index 0000000000..635c04ee92 --- /dev/null +++ b/tests/leader/leader_per_key_timeout/test.mk @@ -0,0 +1,7 @@ +# -------------------------------------------------------------------------------- +# Keep this file, even if it is empty, as a marker that this folder contains tests +# -------------------------------------------------------------------------------- + +LEADER_ENABLE = yes + +SRC += ../leader_sequences.c diff --git a/tests/leader/leader_per_key_timeout/test_leader_per_key_timeout.cpp b/tests/leader/leader_per_key_timeout/test_leader_per_key_timeout.cpp new file mode 100644 index 0000000000..a1e9eb3c77 --- /dev/null +++ b/tests/leader/leader_per_key_timeout/test_leader_per_key_timeout.cpp @@ -0,0 +1,40 @@ +// Copyright 2023 QMK +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "keyboard_report_util.hpp" +#include "keycode.h" +#include "test_common.hpp" +#include "test_keymap_key.hpp" + +using testing::_; + +class Leader : public TestFixture {}; + +TEST_F(Leader, does_not_timeout_during_sequence) { + TestDriver driver; + + auto key_leader = KeymapKey(0, 0, 0, QK_LEADER); + auto key_a = KeymapKey(0, 1, 0, KC_A); + auto key_b = KeymapKey(0, 2, 0, KC_B); + auto key_c = KeymapKey(0, 3, 0, KC_C); + + set_keymap({key_leader, key_a, key_b, key_c}); + + tap_key(key_leader); + + EXPECT_NO_REPORT(driver); + tap_key(key_a); + + idle_for(150); + + EXPECT_NO_REPORT(driver); + tap_key(key_b); + + idle_for(150); + + EXPECT_REPORT(driver, (KC_3)); + EXPECT_EMPTY_REPORT(driver); + tap_key(key_c); + + idle_for(300); +} -- cgit v1.2.3