summaryrefslogtreecommitdiff
path: root/tests/test_common
diff options
context:
space:
mode:
authorInigoGutierrez <inigogf.95@gmail.com>2022-09-25 16:02:54 +0200
committerInigoGutierrez <inigogf.95@gmail.com>2022-09-25 16:02:54 +0200
commit6afdd9d74da250e47ac64d6690bd19d037045e99 (patch)
tree661f6cfb244c02bcd1fbfe8fb9b2bd9242a91394 /tests/test_common
parent93a55e61b59d20f7cd842cce02e5b18a63a23612 (diff)
parent1bdf4cdc22ae57d111efb2f7d71e405e5c7b3f11 (diff)
downloadqmk_firmware-6afdd9d74da250e47ac64d6690bd19d037045e99.tar.gz
qmk_firmware-6afdd9d74da250e47ac64d6690bd19d037045e99.zip
Merge branch 'master' into taamas
Diffstat (limited to 'tests/test_common')
-rw-r--r--tests/test_common/test_fixture.cpp16
-rw-r--r--tests/test_common/test_fixture.hpp7
2 files changed, 23 insertions, 0 deletions
diff --git a/tests/test_common/test_fixture.cpp b/tests/test_common/test_fixture.cpp
index 5fc6964054..44694cd390 100644
--- a/tests/test_common/test_fixture.cpp
+++ b/tests/test_common/test_fixture.cpp
@@ -108,6 +108,22 @@ void TestFixture::tap_key(KeymapKey key, unsigned delay_ms) {
run_one_scan_loop();
}
+void TestFixture::tap_combo(const std::vector<KeymapKey>& chord_keys, unsigned delay_ms) {
+ for (KeymapKey key : chord_keys) { // Press each key.
+ key.press();
+ run_one_scan_loop();
+ }
+
+ if (delay_ms > 1) {
+ idle_for(delay_ms - 1);
+ }
+
+ for (KeymapKey key : chord_keys) { // Release each key.
+ key.release();
+ run_one_scan_loop();
+ }
+}
+
void TestFixture::set_keymap(std::initializer_list<KeymapKey> keys) {
this->keymap.clear();
for (auto& key : keys) {
diff --git a/tests/test_common/test_fixture.hpp b/tests/test_common/test_fixture.hpp
index 81906f76c7..2590acd006 100644
--- a/tests/test_common/test_fixture.hpp
+++ b/tests/test_common/test_fixture.hpp
@@ -53,6 +53,13 @@ class TestFixture : public testing::Test {
}
}
+ /**
+ * @brief Taps a combo with `delay_ms` delay between press and release.
+ *
+ * Example: `tap_combo({key_a, key_b})` to tap the chord A + B.
+ */
+ void tap_combo(const std::vector<KeymapKey>& chord_keys, unsigned delay_ms = 1);
+
void run_one_scan_loop();
void idle_for(unsigned ms);