aboutsummaryrefslogtreecommitdiff
path: root/tests/tap_hold_configurations/permissive_hold/test_one_shot_keys.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/tap_hold_configurations/permissive_hold/test_one_shot_keys.cpp')
-rw-r--r--tests/tap_hold_configurations/permissive_hold/test_one_shot_keys.cpp76
1 files changed, 76 insertions, 0 deletions
diff --git a/tests/tap_hold_configurations/permissive_hold/test_one_shot_keys.cpp b/tests/tap_hold_configurations/permissive_hold/test_one_shot_keys.cpp
new file mode 100644
index 000000000..aa71ec397
--- /dev/null
+++ b/tests/tap_hold_configurations/permissive_hold/test_one_shot_keys.cpp
@@ -0,0 +1,76 @@
1/* Copyright 2021 Stefan Kerkmann
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include "action_util.h"
18#include "keyboard_report_util.hpp"
19#include "test_common.hpp"
20
21using testing::_;
22using testing::InSequence;
23
24class OneShot : public TestFixture {};
25class OneShotParametrizedTestFixture : public ::testing::WithParamInterface<std::pair<KeymapKey, KeymapKey>>, public OneShot {};
26
27TEST_P(OneShotParametrizedTestFixture, OSMAsRegularModifierWithAdditionalKeypress) {
28 TestDriver driver;
29 KeymapKey osm_key = GetParam().first;
30 KeymapKey regular_key = GetParam().second;
31
32 set_keymap({osm_key, regular_key});
33
34 /* Press OSM */
35 EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
36 osm_key.press();
37 run_one_scan_loop();
38 testing::Mock::VerifyAndClearExpectations(&driver);
39
40 /* Press regular key */
41 EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
42 regular_key.press();
43 run_one_scan_loop();
44 testing::Mock::VerifyAndClearExpectations(&driver);
45
46 /* Release regular key */
47 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(osm_key.report_code))).Times(2);
48 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(regular_key.report_code, osm_key.report_code))).Times(1);
49 regular_key.release();
50 run_one_scan_loop();
51 testing::Mock::VerifyAndClearExpectations(&driver);
52
53 /* Release OSM */
54 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).Times(1);
55 osm_key.release();
56 run_one_scan_loop();
57 testing::Mock::VerifyAndClearExpectations(&driver);
58}
59
60// clang-format off
61
62INSTANTIATE_TEST_CASE_P(
63 OneShotModifierTests,
64 OneShotParametrizedTestFixture,
65 ::testing::Values(
66 /* first is osm key, second is regular key. */
67 std::make_pair(KeymapKey{0, 0, 0, OSM(MOD_LSFT), KC_LSFT}, KeymapKey{0, 1, 1, KC_A}),
68 std::make_pair(KeymapKey{0, 0, 0, OSM(MOD_LCTL), KC_LCTL}, KeymapKey{0, 1, 1, KC_A}),
69 std::make_pair(KeymapKey{0, 0, 0, OSM(MOD_LALT), KC_LALT}, KeymapKey{0, 1, 1, KC_A}),
70 std::make_pair(KeymapKey{0, 0, 0, OSM(MOD_LGUI), KC_LGUI}, KeymapKey{0, 1, 1, KC_A}),
71 std::make_pair(KeymapKey{0, 0, 0, OSM(MOD_RCTL), KC_RCTL}, KeymapKey{0, 1, 1, KC_A}),
72 std::make_pair(KeymapKey{0, 0, 0, OSM(MOD_RSFT), KC_RSFT}, KeymapKey{0, 1, 1, KC_A}),
73 std::make_pair(KeymapKey{0, 0, 0, OSM(MOD_RALT), KC_RALT}, KeymapKey{0, 1, 1, KC_A}),
74 std::make_pair(KeymapKey{0, 0, 0, OSM(MOD_RGUI), KC_RGUI}, KeymapKey{0, 1, 1, KC_A})
75 ));
76// clang-format on \ No newline at end of file