diff options
author | Pete Sevander <pete.sevander@gmail.com> | 2023-05-10 18:59:52 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-10 17:59:52 +0200 |
commit | 8a332e6f0105d2db9239e3c3f997bae754522804 (patch) | |
tree | fb8d79bf1d0bbfde46384227992d7bfd70942b96 /tests/combo | |
parent | 6f2a1e4e17fcba9183c6f4f126383d99d9d714f8 (diff) |
Fix Mod-Tap combo regression (#20669)
* Add keyevent for combo keyrecord
* Fix formatting
* Update quantum/process_keycode/process_combo.c
Co-authored-by: Sergey Vlasov <sigprof@gmail.com>
* Add combo unit-tests and hot-fix process_record_tap_hint
...as this function tries to lookup the combo keys passed in. This will
be refactored in a later pr.
---------
Co-authored-by: Sergey Vlasov <sigprof@gmail.com>
Co-authored-by: Stefan Kerkmann <karlk90@pm.me>
Diffstat (limited to 'tests/combo')
-rw-r--r-- | tests/combo/config.h | 8 | ||||
-rw-r--r-- | tests/combo/test.mk | 4 | ||||
-rw-r--r-- | tests/combo/test_combo.cpp | 72 |
3 files changed, 84 insertions, 0 deletions
diff --git a/tests/combo/config.h b/tests/combo/config.h new file mode 100644 index 0000000000..8052932634 --- /dev/null +++ b/tests/combo/config.h @@ -0,0 +1,8 @@ +// Copyright 2023 Stefan Kerkmann (@KarlK90) +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include "test_common.h" + +#define TAPPING_TERM 200 diff --git a/tests/combo/test.mk b/tests/combo/test.mk new file mode 100644 index 0000000000..ce6f9fc2b0 --- /dev/null +++ b/tests/combo/test.mk @@ -0,0 +1,4 @@ +# Copyright 2023 Stefan Kerkmann (@KarlK90) +# SPDX-License-Identifier: GPL-2.0-or-later + +COMBO_ENABLE = yes diff --git a/tests/combo/test_combo.cpp b/tests/combo/test_combo.cpp new file mode 100644 index 0000000000..b7aea27f4c --- /dev/null +++ b/tests/combo/test_combo.cpp @@ -0,0 +1,72 @@ +// Copyright 2023 Stefan Kerkmann (@KarlK90) +// Copyright 2023 @filterpaper +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "keyboard_report_util.hpp" +#include "quantum.h" +#include "keycode.h" +#include "test_common.h" +#include "test_driver.hpp" +#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; + +class Combo : public TestFixture {}; + +TEST_F(Combo, combo_modtest_tapped) { + TestDriver driver; + KeymapKey key_y(0, 0, 1, KC_Y); + KeymapKey key_u(0, 0, 2, KC_U); + set_keymap({key_y, key_u}); + + EXPECT_REPORT(driver, (KC_SPACE)); + EXPECT_EMPTY_REPORT(driver); + tap_combo({key_y, key_u}); + VERIFY_AND_CLEAR(driver); +} + +TEST_F(Combo, combo_modtest_held_longer_than_tapping_term) { + TestDriver driver; + KeymapKey key_y(0, 0, 1, KC_Y); + KeymapKey key_u(0, 0, 2, KC_U); + set_keymap({key_y, key_u}); + + EXPECT_REPORT(driver, (KC_RIGHT_SHIFT)); + EXPECT_EMPTY_REPORT(driver); + tap_combo({key_y, key_u}, TAPPING_TERM + 1); + VERIFY_AND_CLEAR(driver); +} + +TEST_F(Combo, combo_osmshift_tapped) { + TestDriver driver; + KeymapKey key_z(0, 0, 1, KC_Z); + KeymapKey key_x(0, 0, 2, KC_X); + KeymapKey key_i(0, 0, 3, KC_I); + set_keymap({key_z, key_x, key_i}); + + EXPECT_NO_REPORT(driver); + tap_combo({key_z, key_x}); + VERIFY_AND_CLEAR(driver); + + EXPECT_REPORT(driver, (KC_I, KC_LEFT_SHIFT)); + EXPECT_EMPTY_REPORT(driver); + tap_key(key_i); + VERIFY_AND_CLEAR(driver); +} |