summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorNick Brassel <nick@tzarc.org>2023-05-15 22:27:37 +1000
committerGitHub <noreply@github.com>2023-05-15 22:27:37 +1000
commit5faa23d54ca1e3ab83097f2a07922f48800616e6 (patch)
tree6ed05e5492f3fc8dda210a75b897dd9d4ed8df38 /tests
parent433dc6068603e61d466e755aedcea0be96664f95 (diff)
Keymap introspection for combos. (#19670)
Diffstat (limited to 'tests')
-rw-r--r--tests/caps_word/caps_word_combo/test.mk1
-rw-r--r--tests/caps_word/caps_word_combo/test_caps_word_combo.cpp23
-rw-r--r--tests/caps_word/caps_word_combo/test_combos.c20
-rw-r--r--tests/combo/test.mk2
-rw-r--r--tests/combo/test_combo.cpp15
-rw-r--r--tests/combo/test_combos.c17
-rw-r--r--tests/test_common/keycode_util.hpp1
7 files changed, 41 insertions, 38 deletions
diff --git a/tests/caps_word/caps_word_combo/test.mk b/tests/caps_word/caps_word_combo/test.mk
index 9f2e157189..c294864113 100644
--- a/tests/caps_word/caps_word_combo/test.mk
+++ b/tests/caps_word/caps_word_combo/test.mk
@@ -17,3 +17,4 @@ CAPS_WORD_ENABLE = yes
COMBO_ENABLE = yes
AUTO_SHIFT_ENABLE = yes
+INTROSPECTION_KEYMAP_C = test_combos.c
diff --git a/tests/caps_word/caps_word_combo/test_caps_word_combo.cpp b/tests/caps_word/caps_word_combo/test_caps_word_combo.cpp
index 0876cc91a3..2cee203dfd 100644
--- a/tests/caps_word/caps_word_combo/test_caps_word_combo.cpp
+++ b/tests/caps_word/caps_word_combo/test_caps_word_combo.cpp
@@ -38,29 +38,6 @@ using ::testing::AnyOf;
using ::testing::InSequence;
using ::testing::TestParamInfo;
-extern "C" {
-// Define some combos to use for the test, including overlapping combos and
-// combos that chord tap-hold keys.
-enum combo_events { AB_COMBO, BC_COMBO, AD_COMBO, DE_COMBO, FGHI_COMBO, COMBO_LENGTH };
-uint16_t COMBO_LEN = COMBO_LENGTH;
-
-const uint16_t ab_combo[] PROGMEM = {KC_A, KC_B, COMBO_END};
-const uint16_t bc_combo[] PROGMEM = {KC_B, KC_C, COMBO_END};
-const uint16_t ad_combo[] PROGMEM = {KC_A, LCTL_T(KC_D), COMBO_END};
-const uint16_t de_combo[] PROGMEM = {LCTL_T(KC_D), LT(1, KC_E), COMBO_END};
-const uint16_t fghi_combo[] PROGMEM = {KC_F, KC_G, KC_H, KC_I, COMBO_END};
-
-// clang-format off
-combo_t key_combos[] = {
- [AB_COMBO] = COMBO(ab_combo, KC_SPC), // KC_A + KC_B = KC_SPC
- [BC_COMBO] = COMBO(bc_combo, KC_X), // KC_B + KC_C = KC_X
- [AD_COMBO] = COMBO(ad_combo, KC_Y), // KC_A + LCTL_T(KC_D) = KC_Y
- [DE_COMBO] = COMBO(de_combo, KC_Z), // LCTL_T(KC_D) + LT(1, KC_E) = KC_Z
- [FGHI_COMBO] = COMBO(fghi_combo, KC_W) // KC_F + KC_G + KC_H + KC_I = KC_W
-};
-// clang-format on
-} // extern "C"
-
namespace {
// To test combos thorougly, we test them with pressing the chord keys with
diff --git a/tests/caps_word/caps_word_combo/test_combos.c b/tests/caps_word/caps_word_combo/test_combos.c
new file mode 100644
index 0000000000..1d07118d50
--- /dev/null
+++ b/tests/caps_word/caps_word_combo/test_combos.c
@@ -0,0 +1,20 @@
+#include <quantum.h>
+
+// Define some combos to use for the test, including overlapping combos and
+// combos that chord tap-hold keys.
+enum combo_events { AB_COMBO, BC_COMBO, AD_COMBO, DE_COMBO, FGHI_COMBO };
+
+const uint16_t ab_combo[] PROGMEM = {KC_A, KC_B, COMBO_END};
+const uint16_t bc_combo[] PROGMEM = {KC_B, KC_C, COMBO_END};
+const uint16_t ad_combo[] PROGMEM = {KC_A, LCTL_T(KC_D), COMBO_END};
+const uint16_t de_combo[] PROGMEM = {LCTL_T(KC_D), LT(1, KC_E), COMBO_END};
+const uint16_t fghi_combo[] PROGMEM = {KC_F, KC_G, KC_H, KC_I, COMBO_END};
+
+// clang-format off
+combo_t key_combos[] = {
+ [AB_COMBO] = COMBO(ab_combo, KC_SPC), // KC_A + KC_B = KC_SPC
+ [BC_COMBO] = COMBO(bc_combo, KC_X), // KC_B + KC_C = KC_X
+ [AD_COMBO] = COMBO(ad_combo, KC_Y), // KC_A + LCTL_T(KC_D) = KC_Y
+ [DE_COMBO] = COMBO(de_combo, KC_Z), // LCTL_T(KC_D) + LT(1, KC_E) = KC_Z
+ [FGHI_COMBO] = COMBO(fghi_combo, KC_W) // KC_F + KC_G + KC_H + KC_I = KC_W
+};
diff --git a/tests/combo/test.mk b/tests/combo/test.mk
index ce6f9fc2b0..4776b9d0c4 100644
--- a/tests/combo/test.mk
+++ b/tests/combo/test.mk
@@ -2,3 +2,5 @@
# SPDX-License-Identifier: GPL-2.0-or-later
COMBO_ENABLE = yes
+
+INTROSPECTION_KEYMAP_C = test_combos.c
diff --git a/tests/combo/test_combo.cpp b/tests/combo/test_combo.cpp
index b7aea27f4c..ac852f9d16 100644
--- a/tests/combo/test_combo.cpp
+++ b/tests/combo/test_combo.cpp
@@ -10,21 +10,6 @@
#include "test_fixture.hpp"
#include "test_keymap_key.hpp"
-extern "C" {
-enum combos { modtest, osmshift, COMBO_LENGTH };
-uint16_t COMBO_LEN = COMBO_LENGTH;
-
-uint16_t const modtest_combo[] = {KC_Y, KC_U, COMBO_END};
-uint16_t const osmshift_combo[] = {KC_Z, KC_X, COMBO_END};
-
-// clang-format off
-combo_t key_combos[] = {
- [modtest] = COMBO(modtest_combo, RSFT_T(KC_SPACE)),
- [osmshift] = COMBO(osmshift_combo, OSM(MOD_LSFT))
-};
-// clang-format on
-}
-
using testing::_;
using testing::InSequence;
diff --git a/tests/combo/test_combos.c b/tests/combo/test_combos.c
new file mode 100644
index 0000000000..8dcb364c6e
--- /dev/null
+++ b/tests/combo/test_combos.c
@@ -0,0 +1,17 @@
+// Copyright 2023 Stefan Kerkmann (@KarlK90)
+// Copyright 2023 @filterpaper
+// Copyright 2023 Nick Brassel (@tzarc)
+// SPDX-License-Identifier: GPL-2.0-or-later
+#include "quantum.h"
+
+enum combos { modtest, osmshift };
+
+uint16_t const modtest_combo[] = {KC_Y, KC_U, COMBO_END};
+uint16_t const osmshift_combo[] = {KC_Z, KC_X, COMBO_END};
+
+// clang-format off
+combo_t key_combos[] = {
+ [modtest] = COMBO(modtest_combo, RSFT_T(KC_SPACE)),
+ [osmshift] = COMBO(osmshift_combo, OSM(MOD_LSFT))
+};
+// clang-format on
diff --git a/tests/test_common/keycode_util.hpp b/tests/test_common/keycode_util.hpp
index d5a520d4b2..3143ab364e 100644
--- a/tests/test_common/keycode_util.hpp
+++ b/tests/test_common/keycode_util.hpp
@@ -1,5 +1,6 @@
#pragma once
+#include <cstdint>
#include <string>
std::string get_keycode_identifier_or_default(uint16_t keycode);