summaryrefslogtreecommitdiff
path: root/tests/auto_shift
diff options
context:
space:
mode:
authorIsaac Elenbaas <isaacelenbaas@gmail.com>2023-09-24 22:45:49 -0400
committerGitHub <noreply@github.com>2023-09-25 12:45:49 +1000
commitdd94877ec6d2ee5c4cdb0e71287abd76585b0268 (patch)
tree26ded3ce8338286243d1b59d597f41329fea6ef4 /tests/auto_shift
parent1fb02d5ad87e69d459ae63235bbb3057083866ef (diff)
Improve test invocation, fix Retro Shift bugs, and add Auto+Retro Shift test cases (#15889)
Diffstat (limited to 'tests/auto_shift')
-rw-r--r--tests/auto_shift/auto_shift_repeat/auto_shift_no_auto_repeat/config.h22
-rw-r--r--tests/auto_shift/auto_shift_repeat/auto_shift_no_auto_repeat/test.mk20
-rw-r--r--tests/auto_shift/auto_shift_repeat/auto_shift_no_auto_repeat/test_auto_shift.cpp105
-rw-r--r--tests/auto_shift/auto_shift_repeat/config.h21
-rw-r--r--tests/auto_shift/auto_shift_repeat/test.mk20
-rw-r--r--tests/auto_shift/auto_shift_repeat/test_auto_shift.cpp107
-rw-r--r--tests/auto_shift/config.h2
-rw-r--r--tests/auto_shift/retro_shift/tap_hold_configurations/default_mod_tap/config.h24
-rw-r--r--tests/auto_shift/retro_shift/tap_hold_configurations/default_mod_tap/no_timeout/config.h21
-rw-r--r--tests/auto_shift/retro_shift/tap_hold_configurations/default_mod_tap/no_timeout/test.mk20
-rw-r--r--tests/auto_shift/retro_shift/tap_hold_configurations/default_mod_tap/no_timeout/test_retro_shift.cpp57
-rw-r--r--tests/auto_shift/retro_shift/tap_hold_configurations/default_mod_tap/test.mk20
-rw-r--r--tests/auto_shift/retro_shift/tap_hold_configurations/default_mod_tap/test_retro_shift.cpp485
-rw-r--r--tests/auto_shift/retro_shift/tap_hold_configurations/hold_on_other_key_press/config.h26
-rw-r--r--tests/auto_shift/retro_shift/tap_hold_configurations/hold_on_other_key_press/test.mk20
-rw-r--r--tests/auto_shift/retro_shift/tap_hold_configurations/hold_on_other_key_press/test_retro_shift.cpp442
-rw-r--r--tests/auto_shift/retro_shift/tap_hold_configurations/permissive_hold/config.h26
-rw-r--r--tests/auto_shift/retro_shift/tap_hold_configurations/permissive_hold/test.mk20
-rw-r--r--tests/auto_shift/retro_shift/tap_hold_configurations/permissive_hold/test_retro_shift.cpp419
-rw-r--r--tests/auto_shift/retro_shift/tap_hold_configurations/permissive_hold_hold_on_other_key_press/config.h27
-rw-r--r--tests/auto_shift/retro_shift/tap_hold_configurations/permissive_hold_hold_on_other_key_press/test.mk20
-rw-r--r--tests/auto_shift/retro_shift/tap_hold_configurations/permissive_hold_hold_on_other_key_press/test_retro_shift.cpp442
-rw-r--r--tests/auto_shift/test.mk2
23 files changed, 2366 insertions, 2 deletions
diff --git a/tests/auto_shift/auto_shift_repeat/auto_shift_no_auto_repeat/config.h b/tests/auto_shift/auto_shift_repeat/auto_shift_no_auto_repeat/config.h
new file mode 100644
index 0000000000..973e04582f
--- /dev/null
+++ b/tests/auto_shift/auto_shift_repeat/auto_shift_no_auto_repeat/config.h
@@ -0,0 +1,22 @@
1/* Copyright 2022 Isaac Elenbaas
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#pragma once
18
19#include "test_common.h"
20
21#define AUTO_SHIFT_REPEAT
22#define AUTO_SHIFT_NO_AUTO_REPEAT
diff --git a/tests/auto_shift/auto_shift_repeat/auto_shift_no_auto_repeat/test.mk b/tests/auto_shift/auto_shift_repeat/auto_shift_no_auto_repeat/test.mk
new file mode 100644
index 0000000000..b687332005
--- /dev/null
+++ b/tests/auto_shift/auto_shift_repeat/auto_shift_no_auto_repeat/test.mk
@@ -0,0 +1,20 @@
1# Copyright 2022 Isaac Elenbaas
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# Keep this file, even if it is empty, as a marker that this folder contains tests
18# --------------------------------------------------------------------------------
19
20AUTO_SHIFT_ENABLE = yes
diff --git a/tests/auto_shift/auto_shift_repeat/auto_shift_no_auto_repeat/test_auto_shift.cpp b/tests/auto_shift/auto_shift_repeat/auto_shift_no_auto_repeat/test_auto_shift.cpp
new file mode 100644
index 0000000000..cd219a5474
--- /dev/null
+++ b/tests/auto_shift/auto_shift_repeat/auto_shift_no_auto_repeat/test_auto_shift.cpp
@@ -0,0 +1,105 @@
1/* Copyright 2022 Isaac Elenbaas
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 "keyboard_report_util.hpp"
18#include "keycode.h"
19#include "test_common.hpp"
20#include "action_tapping.h"
21#include "test_fixture.hpp"
22#include "test_keymap_key.hpp"
23
24using testing::_;
25using testing::AnyNumber;
26using testing::AnyOf;
27using testing::InSequence;
28
29class AutoShiftNoAutoRepeat : public TestFixture {};
30
31TEST_F(AutoShiftNoAutoRepeat, no_auto_repeat) {
32 TestDriver driver;
33 InSequence s;
34 auto repeat_key = KeymapKey(0, 1, 0, KC_A);
35
36 set_keymap({repeat_key});
37
38 /* Press repeat key. */
39 EXPECT_NO_REPORT(driver);
40 repeat_key.press();
41 run_one_scan_loop();
42 testing::Mock::VerifyAndClearExpectations(&driver);
43
44 /* Idle for auto-repeat to (not) kick in. */
45 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT))).Times(AnyNumber());
46 EXPECT_REPORT(driver, (KC_LSFT, KC_A));
47 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT))).Times(AnyNumber());
48 EXPECT_EMPTY_REPORT(driver);
49 idle_for(AUTO_SHIFT_TIMEOUT);
50 run_one_scan_loop();
51 testing::Mock::VerifyAndClearExpectations(&driver);
52
53 /* Release repeat key. */
54 EXPECT_NO_REPORT(driver);
55 repeat_key.release();
56 run_one_scan_loop();
57 testing::Mock::VerifyAndClearExpectations(&driver);
58}
59
60TEST_F(AutoShiftNoAutoRepeat, tap_regular_key_while_another_key_repeats) {
61 TestDriver driver;
62 InSequence s;
63 auto repeat_key = KeymapKey(0, 1, 0, KC_P);
64 auto regular_key = KeymapKey(0, 2, 0, KC_A);
65
66 set_keymap({repeat_key, regular_key});
67
68 /* Press repeat key. */
69 EXPECT_NO_REPORT(driver);
70 repeat_key.press();
71 run_one_scan_loop();
72 testing::Mock::VerifyAndClearExpectations(&driver);
73
74 /* Release repeat key. */
75 EXPECT_REPORT(driver, (KC_P));
76 EXPECT_EMPTY_REPORT(driver);
77 repeat_key.release();
78 run_one_scan_loop();
79 testing::Mock::VerifyAndClearExpectations(&driver);
80
81 /* Press repeat key. */
82 EXPECT_REPORT(driver, (KC_P));
83 repeat_key.press();
84 run_one_scan_loop();
85 testing::Mock::VerifyAndClearExpectations(&driver);
86
87 /* Press regular key. */
88 EXPECT_NO_REPORT(driver);
89 regular_key.press();
90 run_one_scan_loop();
91 testing::Mock::VerifyAndClearExpectations(&driver);
92
93 /* Release regular key. */
94 EXPECT_REPORT(driver, (KC_P, KC_A));
95 EXPECT_REPORT(driver, (KC_P));
96 regular_key.release();
97 run_one_scan_loop();
98 testing::Mock::VerifyAndClearExpectations(&driver);
99
100 /* Release repeat key. */
101 EXPECT_EMPTY_REPORT(driver);
102 repeat_key.release();
103 run_one_scan_loop();
104 testing::Mock::VerifyAndClearExpectations(&driver);
105}
diff --git a/tests/auto_shift/auto_shift_repeat/config.h b/tests/auto_shift/auto_shift_repeat/config.h
new file mode 100644
index 0000000000..fb4c506b20
--- /dev/null
+++ b/tests/auto_shift/auto_shift_repeat/config.h
@@ -0,0 +1,21 @@
1/* Copyright 2022 Isaac Elenbaas
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#pragma once
18
19#include "test_common.h"
20
21#define AUTO_SHIFT_REPEAT
diff --git a/tests/auto_shift/auto_shift_repeat/test.mk b/tests/auto_shift/auto_shift_repeat/test.mk
new file mode 100644
index 0000000000..b687332005
--- /dev/null
+++ b/tests/auto_shift/auto_shift_repeat/test.mk
@@ -0,0 +1,20 @@
1# Copyright 2022 Isaac Elenbaas
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# Keep this file, even if it is empty, as a marker that this folder contains tests
18# --------------------------------------------------------------------------------
19
20AUTO_SHIFT_ENABLE = yes
diff --git a/tests/auto_shift/auto_shift_repeat/test_auto_shift.cpp b/tests/auto_shift/auto_shift_repeat/test_auto_shift.cpp
new file mode 100644
index 0000000000..4a7569ea90
--- /dev/null
+++ b/tests/auto_shift/auto_shift_repeat/test_auto_shift.cpp
@@ -0,0 +1,107 @@
1/* Copyright 2022 Isaac Elenbaas
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 "keyboard_report_util.hpp"
18#include "keycode.h"
19#include "test_common.hpp"
20#include "action_tapping.h"
21#include "test_fixture.hpp"
22#include "test_keymap_key.hpp"
23
24using testing::_;
25using testing::AnyNumber;
26using testing::InSequence;
27
28class AutoShiftRepeat : public TestFixture {};
29
30TEST_F(AutoShiftRepeat, tap_regular_key_cancelling_another_key_hold) {
31 TestDriver driver;
32 InSequence s;
33 auto repeat_key = KeymapKey(0, 1, 0, KC_P);
34 auto regular_key = KeymapKey(0, 2, 0, KC_A);
35
36 set_keymap({repeat_key, regular_key});
37
38 /* Press repeat key. */
39 EXPECT_NO_REPORT(driver);
40 repeat_key.press();
41 run_one_scan_loop();
42 testing::Mock::VerifyAndClearExpectations(&driver);
43
44 /* Press regular key. */
45 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).Times(testing::AnyNumber());
46 EXPECT_REPORT(driver, (KC_P));
47 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).Times(testing::AnyNumber());
48 regular_key.press();
49 run_one_scan_loop();
50 testing::Mock::VerifyAndClearExpectations(&driver);
51
52 /* Release regular key. */
53 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).Times(testing::AnyNumber());
54 EXPECT_REPORT(driver, (KC_A));
55 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).Times(testing::AnyNumber());
56 regular_key.release();
57 run_one_scan_loop();
58 testing::Mock::VerifyAndClearExpectations(&driver);
59
60 /* Release repeat key. */
61 EXPECT_NO_REPORT(driver);
62 repeat_key.release();
63 run_one_scan_loop();
64 testing::Mock::VerifyAndClearExpectations(&driver);
65}
66
67TEST_F(AutoShiftRepeat, tap_regular_key_while_another_key_is_held) {
68 TestDriver driver;
69 InSequence s;
70 auto repeat_key = KeymapKey(0, 1, 0, KC_P);
71 auto regular_key = KeymapKey(0, 2, 0, KC_A);
72
73 set_keymap({repeat_key, regular_key});
74
75 /* Press repeat key. */
76 EXPECT_NO_REPORT(driver);
77 repeat_key.press();
78 run_one_scan_loop();
79 testing::Mock::VerifyAndClearExpectations(&driver);
80
81 /* Idle for auto-repeat to kick in. */
82 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT))).Times(AnyNumber());
83 EXPECT_REPORT(driver, (KC_LSFT, KC_P));
84 idle_for(AUTO_SHIFT_TIMEOUT);
85 run_one_scan_loop();
86 testing::Mock::VerifyAndClearExpectations(&driver);
87
88 /* Press regular key. */
89 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT))).Times(AnyNumber());
90 EXPECT_NO_REPORT(driver);
91 regular_key.press();
92 run_one_scan_loop();
93 testing::Mock::VerifyAndClearExpectations(&driver);
94
95 /* Release regular key. */
96 EXPECT_REPORT(driver, (KC_P, KC_A));
97 EXPECT_REPORT(driver, (KC_P));
98 regular_key.release();
99 run_one_scan_loop();
100 testing::Mock::VerifyAndClearExpectations(&driver);
101
102 /* Release repeat key. */
103 EXPECT_EMPTY_REPORT(driver);
104 repeat_key.release();
105 run_one_scan_loop();
106 testing::Mock::VerifyAndClearExpectations(&driver);
107}
diff --git a/tests/auto_shift/config.h b/tests/auto_shift/config.h
index 4f343b4529..6d872dd57b 100644
--- a/tests/auto_shift/config.h
+++ b/tests/auto_shift/config.h
@@ -16,4 +16,4 @@
16 16
17#pragma once 17#pragma once
18 18
19#include "test_common.h" \ No newline at end of file 19#include "test_common.h"
diff --git a/tests/auto_shift/retro_shift/tap_hold_configurations/default_mod_tap/config.h b/tests/auto_shift/retro_shift/tap_hold_configurations/default_mod_tap/config.h
new file mode 100644
index 0000000000..0de9845d9d
--- /dev/null
+++ b/tests/auto_shift/retro_shift/tap_hold_configurations/default_mod_tap/config.h
@@ -0,0 +1,24 @@
1/* Copyright 2022 Isaac Elenbaas
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#pragma once
18
19#include "test_common.h"
20
21#define RETRO_SHIFT 2 * TAPPING_TERM
22// releases between AUTO_SHIFT_TIMEOUT and TAPPING_TERM are not tested
23#define AUTO_SHIFT_TIMEOUT TAPPING_TERM
24#define AUTO_SHIFT_MODIFIERS
diff --git a/tests/auto_shift/retro_shift/tap_hold_configurations/default_mod_tap/no_timeout/config.h b/tests/auto_shift/retro_shift/tap_hold_configurations/default_mod_tap/no_timeout/config.h
new file mode 100644
index 0000000000..dc9dc28cab
--- /dev/null
+++ b/tests/auto_shift/retro_shift/tap_hold_configurations/default_mod_tap/no_timeout/config.h
@@ -0,0 +1,21 @@
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#pragma once
18
19#include "test_common.h"
20
21#define RETRO_SHIFT
diff --git a/tests/auto_shift/retro_shift/tap_hold_configurations/default_mod_tap/no_timeout/test.mk b/tests/auto_shift/retro_shift/tap_hold_configurations/default_mod_tap/no_timeout/test.mk
new file mode 100644
index 0000000000..b687332005
--- /dev/null
+++ b/tests/auto_shift/retro_shift/tap_hold_configurations/default_mod_tap/no_timeout/test.mk
@@ -0,0 +1,20 @@
1# Copyright 2022 Isaac Elenbaas
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# Keep this file, even if it is empty, as a marker that this folder contains tests
18# --------------------------------------------------------------------------------
19
20AUTO_SHIFT_ENABLE = yes
diff --git a/tests/auto_shift/retro_shift/tap_hold_configurations/default_mod_tap/no_timeout/test_retro_shift.cpp b/tests/auto_shift/retro_shift/tap_hold_configurations/default_mod_tap/no_timeout/test_retro_shift.cpp
new file mode 100644
index 0000000000..6d7d06427c
--- /dev/null
+++ b/tests/auto_shift/retro_shift/tap_hold_configurations/default_mod_tap/no_timeout/test_retro_shift.cpp
@@ -0,0 +1,57 @@
1/* Copyright 2022 Isaac Elenbaas
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 "keyboard_report_util.hpp"
18#include "keycode.h"
19#include "test_common.hpp"
20#include "action_tapping.h"
21#include "test_fixture.hpp"
22#include "test_keymap_key.hpp"
23
24bool get_auto_shifted_key(uint16_t keycode, keyrecord_t *record) {
25 return true;
26}
27
28using testing::_;
29using testing::AnyNumber;
30using testing::AnyOf;
31using testing::InSequence;
32
33class RetroShiftDefaultTapHold : public TestFixture {};
34
35TEST_F(RetroShiftDefaultTapHold, hold_mod_tap_key_for_long) {
36 TestDriver driver;
37 InSequence s;
38 auto mod_tap_hold_key = KeymapKey(0, 0, 0, CTL_T(KC_A));
39
40 set_keymap({mod_tap_hold_key});
41
42 /* Press mod-tap-hold key. */
43 EXPECT_NO_REPORT(driver);
44 mod_tap_hold_key.press();
45 run_one_scan_loop();
46 idle_for(4 * TAPPING_TERM);
47 testing::Mock::VerifyAndClearExpectations(&driver);
48
49 /* Release mod-tap-hold key. */
50 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT))).Times(AnyNumber());
51 EXPECT_REPORT(driver, (KC_LSFT, KC_A));
52 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT))).Times(AnyNumber());
53 EXPECT_EMPTY_REPORT(driver);
54 mod_tap_hold_key.release();
55 run_one_scan_loop();
56 testing::Mock::VerifyAndClearExpectations(&driver);
57}
diff --git a/tests/auto_shift/retro_shift/tap_hold_configurations/default_mod_tap/test.mk b/tests/auto_shift/retro_shift/tap_hold_configurations/default_mod_tap/test.mk
new file mode 100644
index 0000000000..b687332005
--- /dev/null
+++ b/tests/auto_shift/retro_shift/tap_hold_configurations/default_mod_tap/test.mk
@@ -0,0 +1,20 @@
1# Copyright 2022 Isaac Elenbaas
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# Keep this file, even if it is empty, as a marker that this folder contains tests
18# --------------------------------------------------------------------------------
19
20AUTO_SHIFT_ENABLE = yes
diff --git a/tests/auto_shift/retro_shift/tap_hold_configurations/default_mod_tap/test_retro_shift.cpp b/tests/auto_shift/retro_shift/tap_hold_configurations/default_mod_tap/test_retro_shift.cpp
new file mode 100644
index 0000000000..f85a511632
--- /dev/null
+++ b/tests/auto_shift/retro_shift/tap_hold_configurations/default_mod_tap/test_retro_shift.cpp
@@ -0,0 +1,485 @@
1/* Copyright 2022 Isaac Elenbaas
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 "keyboard_report_util.hpp"
18#include "keycode.h"
19#include "test_common.hpp"
20#include "action_tapping.h"
21#include "test_fixture.hpp"
22#include "test_keymap_key.hpp"
23
24bool get_auto_shifted_key(uint16_t keycode, keyrecord_t *record) {
25 return true;
26}
27
28using testing::_;
29using testing::AnyNumber;
30using testing::AnyOf;
31using testing::InSequence;
32
33class RetroShiftDefaultTapHold : public TestFixture {};
34
35TEST_F(RetroShiftDefaultTapHold, tap_mod_tap_key) {
36 TestDriver driver;
37 InSequence s;
38 auto mod_tap_hold_key = KeymapKey(0, 0, 0, CTL_T(KC_A));
39
40 set_keymap({mod_tap_hold_key});
41
42 /* Press mod-tap-hold key. */
43 EXPECT_NO_REPORT(driver);
44 mod_tap_hold_key.press();
45 run_one_scan_loop();
46 testing::Mock::VerifyAndClearExpectations(&driver);
47
48 /* Release mod-tap-hold key. */
49 EXPECT_REPORT(driver, (KC_A));
50 EXPECT_EMPTY_REPORT(driver);
51 mod_tap_hold_key.release();
52 run_one_scan_loop();
53 testing::Mock::VerifyAndClearExpectations(&driver);
54}
55
56TEST_F(RetroShiftDefaultTapHold, hold_mod_tap_key_under_retro_shift) {
57 TestDriver driver;
58 InSequence s;
59 auto mod_tap_hold_key = KeymapKey(0, 0, 0, CTL_T(KC_A));
60
61 set_keymap({mod_tap_hold_key});
62
63 /* Press mod-tap-hold key. */
64 EXPECT_NO_REPORT(driver);
65 mod_tap_hold_key.press();
66 run_one_scan_loop();
67 idle_for(AUTO_SHIFT_TIMEOUT);
68 testing::Mock::VerifyAndClearExpectations(&driver);
69
70 /* Release mod-tap-hold key. */
71 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT))).Times(AnyNumber());
72 EXPECT_REPORT(driver, (KC_LSFT, KC_A));
73 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT))).Times(AnyNumber());
74 EXPECT_EMPTY_REPORT(driver);
75 mod_tap_hold_key.release();
76 run_one_scan_loop();
77 testing::Mock::VerifyAndClearExpectations(&driver);
78}
79
80TEST_F(RetroShiftDefaultTapHold, hold_mod_tap_key_over_retro_shift) {
81 TestDriver driver;
82 InSequence s;
83 auto mod_tap_hold_key = KeymapKey(0, 0, 0, CTL_T(KC_A));
84
85 set_keymap({mod_tap_hold_key});
86
87 /* Press mod-tap-hold key. */
88 EXPECT_REPORT(driver, (KC_LCTL));
89 mod_tap_hold_key.press();
90 run_one_scan_loop();
91 idle_for(RETRO_SHIFT);
92 testing::Mock::VerifyAndClearExpectations(&driver);
93
94 /* Release mod-tap-hold key. */
95 EXPECT_EMPTY_REPORT(driver);
96 mod_tap_hold_key.release();
97 run_one_scan_loop();
98 testing::Mock::VerifyAndClearExpectations(&driver);
99}
100
101TEST_F(RetroShiftDefaultTapHold, tap_regular_key_while_mod_tap_key_is_held_under_tapping_term) {
102 TestDriver driver;
103 InSequence s;
104 auto mod_tap_hold_key = KeymapKey(0, 0, 0, CTL_T(KC_P));
105 auto regular_key = KeymapKey(0, 1, 0, KC_A);
106
107 set_keymap({mod_tap_hold_key, regular_key});
108
109 /* Press mod-tap-hold key. */
110 EXPECT_NO_REPORT(driver);
111 mod_tap_hold_key.press();
112 run_one_scan_loop();
113 testing::Mock::VerifyAndClearExpectations(&driver);
114
115 /* Press regular key. */
116 EXPECT_NO_REPORT(driver);
117 regular_key.press();
118 run_one_scan_loop();
119 testing::Mock::VerifyAndClearExpectations(&driver);
120
121 /* Release regular key. */
122 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LCTL))).Times(AnyNumber());
123 EXPECT_REPORT(driver, (KC_LCTL, KC_A));
124 EXPECT_REPORT(driver, (KC_LCTL));
125 regular_key.release();
126 run_one_scan_loop();
127 testing::Mock::VerifyAndClearExpectations(&driver);
128
129 /* Release mod-tap-hold key. */
130 EXPECT_EMPTY_REPORT(driver);
131 mod_tap_hold_key.release();
132 run_one_scan_loop();
133 testing::Mock::VerifyAndClearExpectations(&driver);
134}
135
136TEST_F(RetroShiftDefaultTapHold, tap_mod_tap_key_while_mod_tap_key_is_held_under_tapping_term) {
137 TestDriver driver;
138 InSequence s;
139 auto mod_tap_hold_key = KeymapKey(0, 0, 0, CTL_T(KC_P));
140 auto mod_tap_regular_key = KeymapKey(0, 1, 0, ALT_T(KC_A));
141
142 set_keymap({mod_tap_hold_key, mod_tap_regular_key});
143
144 /* Press mod-tap-hold key. */
145 EXPECT_NO_REPORT(driver);
146 mod_tap_hold_key.press();
147 run_one_scan_loop();
148 testing::Mock::VerifyAndClearExpectations(&driver);
149
150 /* Press mod-tap-regular key. */
151 EXPECT_NO_REPORT(driver);
152 mod_tap_regular_key.press();
153 run_one_scan_loop();
154 testing::Mock::VerifyAndClearExpectations(&driver);
155
156 /* Release mod-tap-regular key. */
157 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LCTL))).Times(AnyNumber());
158 EXPECT_REPORT(driver, (KC_LCTL, KC_A));
159 EXPECT_REPORT(driver, (KC_LCTL));
160 mod_tap_regular_key.release();
161 run_one_scan_loop();
162 testing::Mock::VerifyAndClearExpectations(&driver);
163
164 /* Release mod-tap-hold key. */
165 EXPECT_EMPTY_REPORT(driver);
166 mod_tap_hold_key.release();
167 run_one_scan_loop();
168 testing::Mock::VerifyAndClearExpectations(&driver);
169}
170
171TEST_F(RetroShiftDefaultTapHold, tap_regular_key_while_mod_tap_key_is_held_over_tapping_term) {
172 TestDriver driver;
173 InSequence s;
174 auto mod_tap_hold_key = KeymapKey(0, 0, 0, CTL_T(KC_P));
175 auto regular_key = KeymapKey(0, 1, 0, KC_A);
176
177 set_keymap({mod_tap_hold_key, regular_key});
178
179 /* Press mod-tap-hold key. */
180 EXPECT_NO_REPORT(driver);
181 mod_tap_hold_key.press();
182 run_one_scan_loop();
183 testing::Mock::VerifyAndClearExpectations(&driver);
184
185 /* Press regular key. */
186 EXPECT_NO_REPORT(driver);
187 regular_key.press();
188 run_one_scan_loop();
189 testing::Mock::VerifyAndClearExpectations(&driver);
190
191 /* Release regular key. */
192 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LCTL))).Times(AnyNumber());
193 EXPECT_REPORT(driver, (KC_LCTL, KC_A));
194 EXPECT_REPORT(driver, (KC_LCTL));
195 regular_key.release();
196 run_one_scan_loop();
197 idle_for(TAPPING_TERM);
198 testing::Mock::VerifyAndClearExpectations(&driver);
199
200 /* Release mod-tap-hold key. */
201 EXPECT_EMPTY_REPORT(driver);
202 mod_tap_hold_key.release();
203 run_one_scan_loop();
204 testing::Mock::VerifyAndClearExpectations(&driver);
205}
206
207TEST_F(RetroShiftDefaultTapHold, tap_mod_tap_key_while_mod_tap_key_is_held_over_tapping_term) {
208 TestDriver driver;
209 InSequence s;
210 auto mod_tap_hold_key = KeymapKey(0, 0, 0, CTL_T(KC_P));
211 auto mod_tap_regular_key = KeymapKey(0, 1, 0, ALT_T(KC_A));
212
213 set_keymap({mod_tap_hold_key, mod_tap_regular_key});
214
215 /* Press mod-tap-hold key. */
216 EXPECT_NO_REPORT(driver);
217 mod_tap_hold_key.press();
218 run_one_scan_loop();
219 testing::Mock::VerifyAndClearExpectations(&driver);
220
221 /* Press mod-tap-regular key. */
222 EXPECT_NO_REPORT(driver);
223 mod_tap_regular_key.press();
224 run_one_scan_loop();
225 testing::Mock::VerifyAndClearExpectations(&driver);
226
227 /* Release mod-tap-regular key. */
228 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LCTL))).Times(AnyNumber());
229 EXPECT_REPORT(driver, (KC_LCTL, KC_A));
230 EXPECT_REPORT(driver, (KC_LCTL));
231 mod_tap_regular_key.release();
232 run_one_scan_loop();
233 idle_for(TAPPING_TERM);
234 testing::Mock::VerifyAndClearExpectations(&driver);
235
236 /* Release mod-tap-hold key. */
237 EXPECT_EMPTY_REPORT(driver);
238 mod_tap_hold_key.release();
239 run_one_scan_loop();
240 testing::Mock::VerifyAndClearExpectations(&driver);
241}
242
243TEST_F(RetroShiftDefaultTapHold, hold_regular_key_while_mod_tap_key_is_held_over_tapping_term) {
244 TestDriver driver;
245 InSequence s;
246 auto mod_tap_hold_key = KeymapKey(0, 0, 0, CTL_T(KC_P));
247 auto regular_key = KeymapKey(0, 1, 0, KC_A);
248
249 set_keymap({mod_tap_hold_key, regular_key});
250
251 /* Press mod-tap-hold key. */
252 EXPECT_NO_REPORT(driver);
253 mod_tap_hold_key.press();
254 run_one_scan_loop();
255 testing::Mock::VerifyAndClearExpectations(&driver);
256
257 /* Press regular key. */
258 EXPECT_NO_REPORT(driver);
259 regular_key.press();
260 run_one_scan_loop();
261 idle_for(AUTO_SHIFT_TIMEOUT);
262 testing::Mock::VerifyAndClearExpectations(&driver);
263
264 /* Release regular key. */
265 // clang-format off
266 EXPECT_CALL(driver, send_keyboard_mock(AnyOf(
267 KeyboardReport(KC_LCTL, KC_LSFT),
268 KeyboardReport(KC_LSFT),
269 KeyboardReport(KC_LCTL))))
270 .Times(AnyNumber());
271 // clang-format on
272 EXPECT_REPORT(driver, (KC_LCTL, KC_LSFT, KC_A));
273 // clang-format off
274 EXPECT_CALL(driver, send_keyboard_mock(AnyOf(
275 KeyboardReport(KC_LCTL, KC_LSFT),
276 KeyboardReport(KC_LSFT))))
277 .Times(AnyNumber());
278 // clang-format on
279 EXPECT_REPORT(driver, (KC_LCTL));
280 regular_key.release();
281 run_one_scan_loop();
282 testing::Mock::VerifyAndClearExpectations(&driver);
283
284 /* Release mod-tap-hold key. */
285 EXPECT_EMPTY_REPORT(driver);
286 mod_tap_hold_key.release();
287 run_one_scan_loop();
288 testing::Mock::VerifyAndClearExpectations(&driver);
289}
290
291TEST_F(RetroShiftDefaultTapHold, hold_mod_tap_key_while_mod_tap_key_is_held_over_tapping_term) {
292 TestDriver driver;
293 InSequence s;
294 auto mod_tap_hold_key = KeymapKey(0, 0, 0, CTL_T(KC_P));
295 auto mod_tap_regular_key = KeymapKey(0, 1, 0, ALT_T(KC_A));
296
297 set_keymap({mod_tap_hold_key, mod_tap_regular_key});
298
299 /* Press mod-tap-hold key. */
300 EXPECT_NO_REPORT(driver);
301 mod_tap_hold_key.press();
302 run_one_scan_loop();
303 testing::Mock::VerifyAndClearExpectations(&driver);
304
305 /* Press mod-tap-regular key. */
306 EXPECT_NO_REPORT(driver);
307 mod_tap_regular_key.press();
308 run_one_scan_loop();
309 idle_for(AUTO_SHIFT_TIMEOUT);
310 testing::Mock::VerifyAndClearExpectations(&driver);
311
312 /* Release mod-tap-regular key. */
313 // clang-format off
314 EXPECT_CALL(driver, send_keyboard_mock(AnyOf(
315 KeyboardReport(KC_LCTL, KC_LSFT),
316 KeyboardReport(KC_LSFT),
317 KeyboardReport(KC_LCTL))))
318 .Times(AnyNumber());
319 // clang-format on
320 EXPECT_REPORT(driver, (KC_LCTL, KC_LSFT, KC_A));
321 // clang-format off
322 EXPECT_CALL(driver, send_keyboard_mock(AnyOf(
323 KeyboardReport(KC_LCTL, KC_LSFT),
324 KeyboardReport(KC_LSFT))))
325 .Times(AnyNumber());
326 // clang-format on
327 EXPECT_REPORT(driver, (KC_LCTL));
328 mod_tap_regular_key.release();
329 run_one_scan_loop();
330 idle_for(TAPPING_TERM);
331 testing::Mock::VerifyAndClearExpectations(&driver);
332
333 /* Release mod-tap-hold key. */
334 EXPECT_EMPTY_REPORT(driver);
335 mod_tap_hold_key.release();
336 run_one_scan_loop();
337 testing::Mock::VerifyAndClearExpectations(&driver);
338}
339
340TEST_F(RetroShiftDefaultTapHold, roll_tap_regular_key_while_mod_tap_key_is_held_under_tapping_term) {
341 TestDriver driver;
342 InSequence s;
343 auto mod_tap_hold_key = KeymapKey(0, 0, 0, CTL_T(KC_P));
344 auto regular_key = KeymapKey(0, 1, 0, KC_A);
345
346 set_keymap({mod_tap_hold_key, regular_key});
347
348 /* Press mod-tap-hold key. */
349 EXPECT_NO_REPORT(driver);
350 mod_tap_hold_key.press();
351 run_one_scan_loop();
352 testing::Mock::VerifyAndClearExpectations(&driver);
353
354 /* Press regular key. */
355 EXPECT_NO_REPORT(driver);
356 regular_key.press();
357 run_one_scan_loop();
358 testing::Mock::VerifyAndClearExpectations(&driver);
359
360 /* Release mod-tap-hold key. */
361 EXPECT_REPORT(driver, (KC_P));
362 EXPECT_EMPTY_REPORT(driver);
363 mod_tap_hold_key.release();
364 run_one_scan_loop();
365 testing::Mock::VerifyAndClearExpectations(&driver);
366
367 /* Release regular key. */
368 EXPECT_REPORT(driver, (KC_A));
369 EXPECT_EMPTY_REPORT(driver);
370 regular_key.release();
371 run_one_scan_loop();
372 testing::Mock::VerifyAndClearExpectations(&driver);
373}
374
375TEST_F(RetroShiftDefaultTapHold, roll_tap_mod_tap_key_while_mod_tap_key_is_held_under_tapping_term) {
376 TestDriver driver;
377 InSequence s;
378 auto mod_tap_hold_key = KeymapKey(0, 0, 0, CTL_T(KC_P));
379 auto mod_tap_regular_key = KeymapKey(0, 1, 0, ALT_T(KC_A));
380
381 set_keymap({mod_tap_hold_key, mod_tap_regular_key});
382
383 /* Press mod-tap-hold key. */
384 EXPECT_NO_REPORT(driver);
385 mod_tap_hold_key.press();
386 run_one_scan_loop();
387 testing::Mock::VerifyAndClearExpectations(&driver);
388
389 /* Press mod-tap-regular key. */
390 EXPECT_NO_REPORT(driver);
391 mod_tap_regular_key.press();
392 run_one_scan_loop();
393 testing::Mock::VerifyAndClearExpectations(&driver);
394
395 /* Release mod-tap-hold key. */
396 EXPECT_REPORT(driver, (KC_P));
397 EXPECT_EMPTY_REPORT(driver);
398 mod_tap_hold_key.release();
399 run_one_scan_loop();
400 testing::Mock::VerifyAndClearExpectations(&driver);
401
402 /* Release mod-tap-regular key. */
403 EXPECT_REPORT(driver, (KC_A));
404 EXPECT_EMPTY_REPORT(driver);
405 mod_tap_regular_key.release();
406 run_one_scan_loop();
407 testing::Mock::VerifyAndClearExpectations(&driver);
408}
409
410TEST_F(RetroShiftDefaultTapHold, roll_hold_regular_key_while_mod_tap_key_is_held_under_tapping_term) {
411 TestDriver driver;
412 InSequence s;
413 auto mod_tap_hold_key = KeymapKey(0, 0, 0, CTL_T(KC_P));
414 auto regular_key = KeymapKey(0, 1, 0, KC_A);
415
416 set_keymap({mod_tap_hold_key, regular_key});
417
418 /* Press mod-tap-hold key. */
419 EXPECT_NO_REPORT(driver);
420 mod_tap_hold_key.press();
421 run_one_scan_loop();
422 testing::Mock::VerifyAndClearExpectations(&driver);
423
424 /* Press regular key. */
425 EXPECT_NO_REPORT(driver);
426 regular_key.press();
427 run_one_scan_loop();
428 testing::Mock::VerifyAndClearExpectations(&driver);
429
430 /* Release mod-tap-hold key. */
431 EXPECT_REPORT(driver, (KC_P));
432 EXPECT_EMPTY_REPORT(driver);
433 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT))).Times(AnyNumber());
434 EXPECT_REPORT(driver, (KC_LSFT, KC_A));
435 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT))).Times(AnyNumber());
436 EXPECT_EMPTY_REPORT(driver);
437 mod_tap_hold_key.release();
438 run_one_scan_loop();
439 idle_for(AUTO_SHIFT_TIMEOUT);
440 testing::Mock::VerifyAndClearExpectations(&driver);
441
442 /* Release regular key. */
443 EXPECT_NO_REPORT(driver);
444 regular_key.release();
445 run_one_scan_loop();
446 testing::Mock::VerifyAndClearExpectations(&driver);
447}
448
449TEST_F(RetroShiftDefaultTapHold, roll_hold_mod_tap_key_while_mod_tap_key_is_held_under_tapping_term) {
450 TestDriver driver;
451 InSequence s;
452 auto mod_tap_hold_key = KeymapKey(0, 0, 0, CTL_T(KC_P));
453 auto mod_tap_regular_key = KeymapKey(0, 1, 0, ALT_T(KC_A));
454
455 set_keymap({mod_tap_hold_key, mod_tap_regular_key});
456
457 /* Press mod-tap-hold key. */
458 EXPECT_NO_REPORT(driver);
459 mod_tap_hold_key.press();
460 run_one_scan_loop();
461 testing::Mock::VerifyAndClearExpectations(&driver);
462
463 /* Press mod-tap-regular key. */
464 EXPECT_NO_REPORT(driver);
465 mod_tap_regular_key.press();
466 run_one_scan_loop();
467 testing::Mock::VerifyAndClearExpectations(&driver);
468
469 /* Release mod-tap-hold key. */
470 EXPECT_REPORT(driver, (KC_P));
471 EXPECT_EMPTY_REPORT(driver);
472 mod_tap_hold_key.release();
473 run_one_scan_loop();
474 testing::Mock::VerifyAndClearExpectations(&driver);
475
476 /* Release mod-tap-regular key. */
477 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT))).Times(AnyNumber());
478 EXPECT_REPORT(driver, (KC_LSFT, KC_A));
479 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT))).Times(AnyNumber());
480 EXPECT_EMPTY_REPORT(driver);
481 idle_for(AUTO_SHIFT_TIMEOUT);
482 mod_tap_regular_key.release();
483 run_one_scan_loop();
484 testing::Mock::VerifyAndClearExpectations(&driver);
485}
diff --git a/tests/auto_shift/retro_shift/tap_hold_configurations/hold_on_other_key_press/config.h b/tests/auto_shift/retro_shift/tap_hold_configurations/hold_on_other_key_press/config.h
new file mode 100644
index 0000000000..396683963d
--- /dev/null
+++ b/tests/auto_shift/retro_shift/tap_hold_configurations/hold_on_other_key_press/config.h
@@ -0,0 +1,26 @@
1/* Copyright 2022 Isaac Elenbaas
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#pragma once
18
19#include "test_common.h"
20
21#define HOLD_ON_OTHER_KEY_PRESS
22
23#define RETRO_SHIFT 2 * TAPPING_TERM
24// releases between AUTO_SHIFT_TIMEOUT and TAPPING_TERM are not tested
25#define AUTO_SHIFT_TIMEOUT TAPPING_TERM
26#define AUTO_SHIFT_MODIFIERS
diff --git a/tests/auto_shift/retro_shift/tap_hold_configurations/hold_on_other_key_press/test.mk b/tests/auto_shift/retro_shift/tap_hold_configurations/hold_on_other_key_press/test.mk
new file mode 100644
index 0000000000..b687332005
--- /dev/null
+++ b/tests/auto_shift/retro_shift/tap_hold_configurations/hold_on_other_key_press/test.mk
@@ -0,0 +1,20 @@
1# Copyright 2022 Isaac Elenbaas
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# Keep this file, even if it is empty, as a marker that this folder contains tests
18# --------------------------------------------------------------------------------
19
20AUTO_SHIFT_ENABLE = yes
diff --git a/tests/auto_shift/retro_shift/tap_hold_configurations/hold_on_other_key_press/test_retro_shift.cpp b/tests/auto_shift/retro_shift/tap_hold_configurations/hold_on_other_key_press/test_retro_shift.cpp
new file mode 100644
index 0000000000..52fc082ea3
--- /dev/null
+++ b/tests/auto_shift/retro_shift/tap_hold_configurations/hold_on_other_key_press/test_retro_shift.cpp
@@ -0,0 +1,442 @@
1/* Copyright 2022 Isaac Elenbaas
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 "keyboard_report_util.hpp"
18#include "keycode.h"
19#include "test_common.hpp"
20#include "action_tapping.h"
21#include "test_fixture.hpp"
22#include "test_keymap_key.hpp"
23
24bool get_auto_shifted_key(uint16_t keycode, keyrecord_t *record) {
25 return true;
26}
27
28using testing::_;
29using testing::AnyNumber;
30using testing::AnyOf;
31using testing::InSequence;
32
33class RetroShiftHoldOnOtherKeyPress : public TestFixture {};
34
35TEST_F(RetroShiftHoldOnOtherKeyPress, tap_regular_key_while_mod_tap_key_is_held_under_tapping_term) {
36 TestDriver driver;
37 InSequence s;
38 auto mod_tap_hold_key = KeymapKey(0, 0, 0, CTL_T(KC_P));
39 auto regular_key = KeymapKey(0, 1, 0, KC_A);
40
41 set_keymap({mod_tap_hold_key, regular_key});
42
43 /* Press mod-tap-hold key. */
44 EXPECT_NO_REPORT(driver);
45 mod_tap_hold_key.press();
46 run_one_scan_loop();
47 testing::Mock::VerifyAndClearExpectations(&driver);
48
49 /* Press regular key. */
50 EXPECT_NO_REPORT(driver);
51 regular_key.press();
52 run_one_scan_loop();
53 testing::Mock::VerifyAndClearExpectations(&driver);
54
55 /* Release regular key. */
56 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LCTL))).Times(AnyNumber());
57 EXPECT_REPORT(driver, (KC_LCTL, KC_A));
58 EXPECT_REPORT(driver, (KC_LCTL));
59 regular_key.release();
60 run_one_scan_loop();
61 testing::Mock::VerifyAndClearExpectations(&driver);
62
63 /* Release mod-tap-hold key. */
64 EXPECT_EMPTY_REPORT(driver);
65 mod_tap_hold_key.release();
66 run_one_scan_loop();
67 testing::Mock::VerifyAndClearExpectations(&driver);
68}
69
70TEST_F(RetroShiftHoldOnOtherKeyPress, tap_mod_tap_key_while_mod_tap_key_is_held_under_tapping_term) {
71 TestDriver driver;
72 InSequence s;
73 auto mod_tap_hold_key = KeymapKey(0, 0, 0, CTL_T(KC_P));
74 auto mod_tap_regular_key = KeymapKey(0, 1, 0, ALT_T(KC_A));
75
76 set_keymap({mod_tap_hold_key, mod_tap_regular_key});
77
78 /* Press mod-tap-hold key. */
79 EXPECT_NO_REPORT(driver);
80 mod_tap_hold_key.press();
81 run_one_scan_loop();
82 testing::Mock::VerifyAndClearExpectations(&driver);
83
84 /* Press mod-tap-regular key. */
85 EXPECT_NO_REPORT(driver);
86 mod_tap_regular_key.press();
87 run_one_scan_loop();
88 testing::Mock::VerifyAndClearExpectations(&driver);
89
90 /* Release mod-tap-regular key. */
91 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LCTL))).Times(AnyNumber());
92 EXPECT_REPORT(driver, (KC_LCTL, KC_A));
93 EXPECT_REPORT(driver, (KC_LCTL));
94 mod_tap_regular_key.release();
95 run_one_scan_loop();
96 testing::Mock::VerifyAndClearExpectations(&driver);
97
98 /* Release mod-tap-hold key. */
99 EXPECT_EMPTY_REPORT(driver);
100 mod_tap_hold_key.release();
101 run_one_scan_loop();
102 testing::Mock::VerifyAndClearExpectations(&driver);
103}
104
105TEST_F(RetroShiftHoldOnOtherKeyPress, tap_regular_key_while_mod_tap_key_is_held_over_tapping_term) {
106 TestDriver driver;
107 InSequence s;
108 auto mod_tap_hold_key = KeymapKey(0, 0, 0, CTL_T(KC_P));
109 auto regular_key = KeymapKey(0, 1, 0, KC_A);
110
111 set_keymap({mod_tap_hold_key, regular_key});
112
113 /* Press mod-tap-hold key. */
114 EXPECT_NO_REPORT(driver);
115 mod_tap_hold_key.press();
116 run_one_scan_loop();
117 testing::Mock::VerifyAndClearExpectations(&driver);
118
119 /* Press regular key. */
120 EXPECT_NO_REPORT(driver);
121 regular_key.press();
122 run_one_scan_loop();
123 testing::Mock::VerifyAndClearExpectations(&driver);
124
125 /* Release regular key. */
126 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LCTL))).Times(AnyNumber());
127 EXPECT_REPORT(driver, (KC_LCTL, KC_A));
128 EXPECT_REPORT(driver, (KC_LCTL));
129 regular_key.release();
130 run_one_scan_loop();
131 idle_for(TAPPING_TERM);
132 testing::Mock::VerifyAndClearExpectations(&driver);
133
134 /* Release mod-tap-hold key. */
135 EXPECT_EMPTY_REPORT(driver);
136 mod_tap_hold_key.release();
137 run_one_scan_loop();
138 testing::Mock::VerifyAndClearExpectations(&driver);
139}
140
141TEST_F(RetroShiftHoldOnOtherKeyPress, tap_mod_tap_key_while_mod_tap_key_is_held_over_tapping_term) {
142 TestDriver driver;
143 InSequence s;
144 auto mod_tap_hold_key = KeymapKey(0, 0, 0, CTL_T(KC_P));
145 auto mod_tap_regular_key = KeymapKey(0, 1, 0, ALT_T(KC_A));
146
147 set_keymap({mod_tap_hold_key, mod_tap_regular_key});
148
149 /* Press mod-tap-hold key. */
150 EXPECT_NO_REPORT(driver);
151 mod_tap_hold_key.press();
152 run_one_scan_loop();
153 testing::Mock::VerifyAndClearExpectations(&driver);
154
155 /* Press mod-tap-regular key. */
156 EXPECT_NO_REPORT(driver);
157 mod_tap_regular_key.press();
158 run_one_scan_loop();
159 testing::Mock::VerifyAndClearExpectations(&driver);
160
161 /* Release mod-tap-regular key. */
162 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LCTL))).Times(AnyNumber());
163 EXPECT_REPORT(driver, (KC_LCTL, KC_A));
164 EXPECT_REPORT(driver, (KC_LCTL));
165 mod_tap_regular_key.release();
166 run_one_scan_loop();
167 idle_for(TAPPING_TERM);
168 testing::Mock::VerifyAndClearExpectations(&driver);
169
170 /* Release mod-tap-hold key. */
171 EXPECT_EMPTY_REPORT(driver);
172 mod_tap_hold_key.release();
173 run_one_scan_loop();
174 testing::Mock::VerifyAndClearExpectations(&driver);
175}
176
177TEST_F(RetroShiftHoldOnOtherKeyPress, hold_regular_key_while_mod_tap_key_is_held_over_tapping_term) {
178 TestDriver driver;
179 InSequence s;
180 auto mod_tap_hold_key = KeymapKey(0, 0, 0, CTL_T(KC_P));
181 auto regular_key = KeymapKey(0, 1, 0, KC_A);
182
183 set_keymap({mod_tap_hold_key, regular_key});
184
185 /* Press mod-tap-hold key. */
186 EXPECT_NO_REPORT(driver);
187 mod_tap_hold_key.press();
188 run_one_scan_loop();
189 testing::Mock::VerifyAndClearExpectations(&driver);
190
191 /* Press regular key. */
192 EXPECT_NO_REPORT(driver);
193 regular_key.press();
194 run_one_scan_loop();
195 idle_for(AUTO_SHIFT_TIMEOUT);
196 testing::Mock::VerifyAndClearExpectations(&driver);
197
198 /* Release regular key. */
199 // clang-format off
200 EXPECT_CALL(driver, send_keyboard_mock(AnyOf(
201 KeyboardReport(KC_LCTL, KC_LSFT),
202 KeyboardReport(KC_LSFT),
203 KeyboardReport(KC_LCTL))))
204 .Times(AnyNumber());
205 // clang-format on
206 EXPECT_REPORT(driver, (KC_LCTL, KC_LSFT, KC_A));
207 // clang-format off
208 EXPECT_CALL(driver, send_keyboard_mock(AnyOf(
209 KeyboardReport(KC_LCTL, KC_LSFT),
210 KeyboardReport(KC_LSFT))))
211 .Times(AnyNumber());
212 // clang-format on
213 EXPECT_REPORT(driver, (KC_LCTL));
214 regular_key.release();
215 run_one_scan_loop();
216 testing::Mock::VerifyAndClearExpectations(&driver);
217
218 /* Release mod-tap-hold key. */
219 EXPECT_EMPTY_REPORT(driver);
220 mod_tap_hold_key.release();
221 run_one_scan_loop();
222 testing::Mock::VerifyAndClearExpectations(&driver);
223}
224
225TEST_F(RetroShiftHoldOnOtherKeyPress, hold_mod_tap_key_while_mod_tap_key_is_held_over_tapping_term) {
226 TestDriver driver;
227 InSequence s;
228 auto mod_tap_hold_key = KeymapKey(0, 0, 0, CTL_T(KC_P));
229 auto mod_tap_regular_key = KeymapKey(0, 1, 0, ALT_T(KC_A));
230
231 set_keymap({mod_tap_hold_key, mod_tap_regular_key});
232
233 /* Press mod-tap-hold key. */
234 EXPECT_NO_REPORT(driver);
235 mod_tap_hold_key.press();
236 run_one_scan_loop();
237 testing::Mock::VerifyAndClearExpectations(&driver);
238
239 /* Press mod-tap-regular key. */
240 EXPECT_NO_REPORT(driver);
241 mod_tap_regular_key.press();
242 run_one_scan_loop();
243 idle_for(AUTO_SHIFT_TIMEOUT);
244 testing::Mock::VerifyAndClearExpectations(&driver);
245
246 /* Release mod-tap-regular key. */
247 // clang-format off
248 EXPECT_CALL(driver, send_keyboard_mock(AnyOf(
249 KeyboardReport(KC_LCTL, KC_LSFT),
250 KeyboardReport(KC_LSFT),
251 KeyboardReport(KC_LCTL))))
252 .Times(AnyNumber());
253 // clang-format on
254 EXPECT_REPORT(driver, (KC_LCTL, KC_LSFT, KC_A));
255 // clang-format off
256 EXPECT_CALL(driver, send_keyboard_mock(AnyOf(
257 KeyboardReport(KC_LCTL, KC_LSFT),
258 KeyboardReport(KC_LSFT))))
259 .Times(AnyNumber());
260 // clang-format on
261 EXPECT_REPORT(driver, (KC_LCTL));
262 mod_tap_regular_key.release();
263 run_one_scan_loop();
264 idle_for(TAPPING_TERM);
265 testing::Mock::VerifyAndClearExpectations(&driver);
266
267 /* Release mod-tap-hold key. */
268 EXPECT_EMPTY_REPORT(driver);
269 mod_tap_hold_key.release();
270 run_one_scan_loop();
271 testing::Mock::VerifyAndClearExpectations(&driver);
272}
273
274TEST_F(RetroShiftHoldOnOtherKeyPress, roll_tap_regular_key_while_mod_tap_key_is_held_under_tapping_term) {
275 TestDriver driver;
276 InSequence s;
277 auto mod_tap_hold_key = KeymapKey(0, 0, 0, CTL_T(KC_P));
278 auto regular_key = KeymapKey(0, 1, 0, KC_A);
279
280 set_keymap({mod_tap_hold_key, regular_key});
281
282 /* Press mod-tap-hold key. */
283 EXPECT_NO_REPORT(driver);
284 mod_tap_hold_key.press();
285 run_one_scan_loop();
286 testing::Mock::VerifyAndClearExpectations(&driver);
287
288 /* Press regular key. */
289 EXPECT_NO_REPORT(driver);
290 regular_key.press();
291 run_one_scan_loop();
292 testing::Mock::VerifyAndClearExpectations(&driver);
293
294 /* Release mod-tap-hold key. */
295 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LCTL))).Times(AnyNumber());
296 mod_tap_hold_key.release();
297 run_one_scan_loop();
298 testing::Mock::VerifyAndClearExpectations(&driver);
299
300 /* Release regular key. */
301 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LCTL))).Times(AnyNumber());
302 EXPECT_REPORT(driver, (KC_LCTL, KC_A));
303 EXPECT_REPORT(driver, (KC_LCTL));
304 EXPECT_EMPTY_REPORT(driver);
305 regular_key.release();
306 run_one_scan_loop();
307 testing::Mock::VerifyAndClearExpectations(&driver);
308}
309
310TEST_F(RetroShiftHoldOnOtherKeyPress, roll_tap_mod_tap_key_while_mod_tap_key_is_held_under_tapping_term) {
311 TestDriver driver;
312 InSequence s;
313 auto mod_tap_hold_key = KeymapKey(0, 0, 0, CTL_T(KC_P));
314 auto mod_tap_regular_key = KeymapKey(0, 1, 0, ALT_T(KC_A));
315
316 set_keymap({mod_tap_hold_key, mod_tap_regular_key});
317
318 /* Press mod-tap-hold key. */
319 EXPECT_NO_REPORT(driver);
320 mod_tap_hold_key.press();
321 run_one_scan_loop();
322 testing::Mock::VerifyAndClearExpectations(&driver);
323
324 /* Press mod-tap-regular key. */
325 EXPECT_NO_REPORT(driver);
326 mod_tap_regular_key.press();
327 run_one_scan_loop();
328 testing::Mock::VerifyAndClearExpectations(&driver);
329
330 /* Release mod-tap-hold key. */
331 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LCTL))).Times(AnyNumber());
332 mod_tap_hold_key.release();
333 run_one_scan_loop();
334 testing::Mock::VerifyAndClearExpectations(&driver);
335
336 /* Release mod-tap-regular key. */
337 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LCTL))).Times(AnyNumber());
338 EXPECT_REPORT(driver, (KC_LCTL, KC_A));
339 EXPECT_REPORT(driver, (KC_LCTL));
340 EXPECT_EMPTY_REPORT(driver);
341 mod_tap_regular_key.release();
342 run_one_scan_loop();
343 testing::Mock::VerifyAndClearExpectations(&driver);
344}
345
346TEST_F(RetroShiftHoldOnOtherKeyPress, roll_hold_regular_key_while_mod_tap_key_is_held_under_tapping_term) {
347 TestDriver driver;
348 InSequence s;
349 auto mod_tap_hold_key = KeymapKey(0, 0, 0, CTL_T(KC_P));
350 auto regular_key = KeymapKey(0, 1, 0, KC_A);
351
352 set_keymap({mod_tap_hold_key, regular_key});
353
354 /* Press mod-tap-hold key. */
355 EXPECT_NO_REPORT(driver);
356 mod_tap_hold_key.press();
357 run_one_scan_loop();
358 testing::Mock::VerifyAndClearExpectations(&driver);
359
360 /* Press regular key. */
361 EXPECT_NO_REPORT(driver);
362 regular_key.press();
363 run_one_scan_loop();
364 testing::Mock::VerifyAndClearExpectations(&driver);
365
366 /* Release mod-tap-hold key. */
367 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LCTL))).Times(AnyNumber());
368 mod_tap_hold_key.release();
369 run_one_scan_loop();
370 testing::Mock::VerifyAndClearExpectations(&driver);
371
372 /* Release regular key. */
373 // clang-format off
374 EXPECT_CALL(driver, send_keyboard_mock(AnyOf(
375 KeyboardReport(KC_LCTL, KC_LSFT),
376 KeyboardReport(KC_LSFT),
377 KeyboardReport(KC_LCTL))))
378 .Times(AnyNumber());
379 // clang-format on
380 EXPECT_REPORT(driver, (KC_LCTL, KC_LSFT, KC_A));
381 // clang-format off
382 EXPECT_CALL(driver, send_keyboard_mock(AnyOf(
383 KeyboardReport(KC_LCTL, KC_LSFT),
384 KeyboardReport(KC_LSFT),
385 KeyboardReport(KC_LCTL))))
386 .Times(AnyNumber());
387 // clang-format on
388 EXPECT_EMPTY_REPORT(driver);
389 idle_for(AUTO_SHIFT_TIMEOUT);
390 regular_key.release();
391 run_one_scan_loop();
392 testing::Mock::VerifyAndClearExpectations(&driver);
393}
394
395TEST_F(RetroShiftHoldOnOtherKeyPress, roll_hold_mod_tap_key_while_mod_tap_key_is_held_under_tapping_term) {
396 TestDriver driver;
397 InSequence s;
398 auto mod_tap_hold_key = KeymapKey(0, 0, 0, CTL_T(KC_P));
399 auto mod_tap_regular_key = KeymapKey(0, 1, 0, ALT_T(KC_A));
400
401 set_keymap({mod_tap_hold_key, mod_tap_regular_key});
402
403 /* Press mod-tap-hold key. */
404 EXPECT_NO_REPORT(driver);
405 mod_tap_hold_key.press();
406 run_one_scan_loop();
407 testing::Mock::VerifyAndClearExpectations(&driver);
408
409 /* Press mod-tap-regular key. */
410 EXPECT_NO_REPORT(driver);
411 mod_tap_regular_key.press();
412 run_one_scan_loop();
413 testing::Mock::VerifyAndClearExpectations(&driver);
414
415 /* Release mod-tap-hold key. */
416 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LCTL))).Times(AnyNumber());
417 mod_tap_hold_key.release();
418 run_one_scan_loop();
419 testing::Mock::VerifyAndClearExpectations(&driver);
420
421 /* Release mod-tap-regular key. */
422 // clang-format off
423 EXPECT_CALL(driver, send_keyboard_mock(AnyOf(
424 KeyboardReport(KC_LCTL, KC_LSFT),
425 KeyboardReport(KC_LSFT),
426 KeyboardReport(KC_LCTL))))
427 .Times(AnyNumber());
428 // clang-format on
429 EXPECT_REPORT(driver, (KC_LCTL, KC_LSFT, KC_A));
430 // clang-format off
431 EXPECT_CALL(driver, send_keyboard_mock(AnyOf(
432 KeyboardReport(KC_LCTL, KC_LSFT),
433 KeyboardReport(KC_LSFT),
434 KeyboardReport(KC_LCTL))))
435 .Times(AnyNumber());
436 // clang-format on
437 EXPECT_EMPTY_REPORT(driver);
438 idle_for(AUTO_SHIFT_TIMEOUT);
439 mod_tap_regular_key.release();
440 run_one_scan_loop();
441 testing::Mock::VerifyAndClearExpectations(&driver);
442}
diff --git a/tests/auto_shift/retro_shift/tap_hold_configurations/permissive_hold/config.h b/tests/auto_shift/retro_shift/tap_hold_configurations/permissive_hold/config.h
new file mode 100644
index 0000000000..5194027c9f
--- /dev/null
+++ b/tests/auto_shift/retro_shift/tap_hold_configurations/permissive_hold/config.h
@@ -0,0 +1,26 @@
1/* Copyright 2022 Isaac Elenbaas
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#pragma once
18
19#include "test_common.h"
20
21#define PERMISSIVE_HOLD
22
23#define RETRO_SHIFT 2 * TAPPING_TERM
24// releases between AUTO_SHIFT_TIMEOUT and TAPPING_TERM are not tested
25#define AUTO_SHIFT_TIMEOUT TAPPING_TERM
26#define AUTO_SHIFT_MODIFIERS
diff --git a/tests/auto_shift/retro_shift/tap_hold_configurations/permissive_hold/test.mk b/tests/auto_shift/retro_shift/tap_hold_configurations/permissive_hold/test.mk
new file mode 100644
index 0000000000..b687332005
--- /dev/null
+++ b/tests/auto_shift/retro_shift/tap_hold_configurations/permissive_hold/test.mk
@@ -0,0 +1,20 @@
1# Copyright 2022 Isaac Elenbaas
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# Keep this file, even if it is empty, as a marker that this folder contains tests
18# --------------------------------------------------------------------------------
19
20AUTO_SHIFT_ENABLE = yes
diff --git a/tests/auto_shift/retro_shift/tap_hold_configurations/permissive_hold/test_retro_shift.cpp b/tests/auto_shift/retro_shift/tap_hold_configurations/permissive_hold/test_retro_shift.cpp
new file mode 100644
index 0000000000..a6c2cab167
--- /dev/null
+++ b/tests/auto_shift/retro_shift/tap_hold_configurations/permissive_hold/test_retro_shift.cpp
@@ -0,0 +1,419 @@
1/* Copyright 2022 Isaac Elenbaas
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 "keyboard_report_util.hpp"
18#include "keycode.h"
19#include "test_common.hpp"
20#include "action_tapping.h"
21#include "test_fixture.hpp"
22#include "test_keymap_key.hpp"
23
24bool get_auto_shifted_key(uint16_t keycode, keyrecord_t *record) {
25 return true;
26}
27
28using testing::_;
29using testing::AnyNumber;
30using testing::AnyOf;
31using testing::InSequence;
32
33class RetroShiftPermissiveHold : public TestFixture {};
34
35TEST_F(RetroShiftPermissiveHold, tap_regular_key_while_mod_tap_key_is_held_under_tapping_term) {
36 TestDriver driver;
37 InSequence s;
38 auto mod_tap_hold_key = KeymapKey(0, 0, 0, CTL_T(KC_P));
39 auto regular_key = KeymapKey(0, 1, 0, KC_A);
40
41 set_keymap({mod_tap_hold_key, regular_key});
42
43 /* Press mod-tap-hold key. */
44 EXPECT_NO_REPORT(driver);
45 mod_tap_hold_key.press();
46 run_one_scan_loop();
47 testing::Mock::VerifyAndClearExpectations(&driver);
48
49 /* Press regular key. */
50 EXPECT_NO_REPORT(driver);
51 regular_key.press();
52 run_one_scan_loop();
53 testing::Mock::VerifyAndClearExpectations(&driver);
54
55 /* Release regular key. */
56 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LCTL))).Times(AnyNumber());
57 EXPECT_REPORT(driver, (KC_LCTL, KC_A));
58 EXPECT_REPORT(driver, (KC_LCTL));
59 regular_key.release();
60 run_one_scan_loop();
61 testing::Mock::VerifyAndClearExpectations(&driver);
62
63 /* Release mod-tap-hold key. */
64 EXPECT_EMPTY_REPORT(driver);
65 mod_tap_hold_key.release();
66 run_one_scan_loop();
67 testing::Mock::VerifyAndClearExpectations(&driver);
68}
69
70TEST_F(RetroShiftPermissiveHold, tap_mod_tap_key_while_mod_tap_key_is_held_under_tapping_term) {
71 TestDriver driver;
72 InSequence s;
73 auto mod_tap_hold_key = KeymapKey(0, 0, 0, CTL_T(KC_P));
74 auto mod_tap_regular_key = KeymapKey(0, 1, 0, ALT_T(KC_A));
75
76 set_keymap({mod_tap_hold_key, mod_tap_regular_key});
77
78 /* Press mod-tap-hold key. */
79 EXPECT_NO_REPORT(driver);
80 mod_tap_hold_key.press();
81 run_one_scan_loop();
82 testing::Mock::VerifyAndClearExpectations(&driver);
83
84 /* Press mod-tap-regular key. */
85 EXPECT_NO_REPORT(driver);
86 mod_tap_regular_key.press();
87 run_one_scan_loop();
88 testing::Mock::VerifyAndClearExpectations(&driver);
89
90 /* Release mod-tap-regular key. */
91 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LCTL))).Times(AnyNumber());
92 EXPECT_REPORT(driver, (KC_LCTL, KC_A));
93 EXPECT_REPORT(driver, (KC_LCTL));
94 mod_tap_regular_key.release();
95 run_one_scan_loop();
96 testing::Mock::VerifyAndClearExpectations(&driver);
97
98 /* Release mod-tap-hold key. */
99 EXPECT_EMPTY_REPORT(driver);
100 mod_tap_hold_key.release();
101 run_one_scan_loop();
102 testing::Mock::VerifyAndClearExpectations(&driver);
103}
104
105TEST_F(RetroShiftPermissiveHold, tap_regular_key_while_mod_tap_key_is_held_over_tapping_term) {
106 TestDriver driver;
107 InSequence s;
108 auto mod_tap_hold_key = KeymapKey(0, 0, 0, CTL_T(KC_P));
109 auto regular_key = KeymapKey(0, 1, 0, KC_A);
110
111 set_keymap({mod_tap_hold_key, regular_key});
112
113 /* Press mod-tap-hold key. */
114 EXPECT_NO_REPORT(driver);
115 mod_tap_hold_key.press();
116 run_one_scan_loop();
117 testing::Mock::VerifyAndClearExpectations(&driver);
118
119 /* Press regular key. */
120 EXPECT_NO_REPORT(driver);
121 regular_key.press();
122 run_one_scan_loop();
123 testing::Mock::VerifyAndClearExpectations(&driver);
124
125 /* Release regular key. */
126 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LCTL))).Times(AnyNumber());
127 EXPECT_REPORT(driver, (KC_LCTL, KC_A));
128 EXPECT_REPORT(driver, (KC_LCTL));
129 regular_key.release();
130 run_one_scan_loop();
131 idle_for(TAPPING_TERM);
132 testing::Mock::VerifyAndClearExpectations(&driver);
133
134 /* Release mod-tap-hold key. */
135 EXPECT_EMPTY_REPORT(driver);
136 mod_tap_hold_key.release();
137 run_one_scan_loop();
138 testing::Mock::VerifyAndClearExpectations(&driver);
139}
140
141TEST_F(RetroShiftPermissiveHold, tap_mod_tap_key_while_mod_tap_key_is_held_over_tapping_term) {
142 TestDriver driver;
143 InSequence s;
144 auto mod_tap_hold_key = KeymapKey(0, 0, 0, CTL_T(KC_P));
145 auto mod_tap_regular_key = KeymapKey(0, 1, 0, ALT_T(KC_A));
146
147 set_keymap({mod_tap_hold_key, mod_tap_regular_key});
148
149 /* Press mod-tap-hold key. */
150 EXPECT_NO_REPORT(driver);
151 mod_tap_hold_key.press();
152 run_one_scan_loop();
153 testing::Mock::VerifyAndClearExpectations(&driver);
154
155 /* Press mod-tap-regular key. */
156 EXPECT_NO_REPORT(driver);
157 mod_tap_regular_key.press();
158 run_one_scan_loop();
159 testing::Mock::VerifyAndClearExpectations(&driver);
160
161 /* Release mod-tap-regular key. */
162 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LCTL))).Times(AnyNumber());
163 EXPECT_REPORT(driver, (KC_LCTL, KC_A));
164 EXPECT_REPORT(driver, (KC_LCTL));
165 mod_tap_regular_key.release();
166 run_one_scan_loop();
167 idle_for(TAPPING_TERM);
168 testing::Mock::VerifyAndClearExpectations(&driver);
169
170 /* Release mod-tap-hold key. */
171 EXPECT_EMPTY_REPORT(driver);
172 mod_tap_hold_key.release();
173 run_one_scan_loop();
174 testing::Mock::VerifyAndClearExpectations(&driver);
175}
176
177TEST_F(RetroShiftPermissiveHold, hold_regular_key_while_mod_tap_key_is_held_over_tapping_term) {
178 TestDriver driver;
179 InSequence s;
180 auto mod_tap_hold_key = KeymapKey(0, 0, 0, CTL_T(KC_P));
181 auto regular_key = KeymapKey(0, 1, 0, KC_A);
182
183 set_keymap({mod_tap_hold_key, regular_key});
184
185 /* Press mod-tap-hold key. */
186 EXPECT_NO_REPORT(driver);
187 mod_tap_hold_key.press();
188 run_one_scan_loop();
189 testing::Mock::VerifyAndClearExpectations(&driver);
190
191 /* Press regular key. */
192 EXPECT_NO_REPORT(driver);
193 regular_key.press();
194 run_one_scan_loop();
195 idle_for(AUTO_SHIFT_TIMEOUT);
196 testing::Mock::VerifyAndClearExpectations(&driver);
197
198 /* Release regular key. */
199 // clang-format off
200 EXPECT_CALL(driver, send_keyboard_mock(AnyOf(
201 KeyboardReport(KC_LCTL, KC_LSFT),
202 KeyboardReport(KC_LSFT),
203 KeyboardReport(KC_LCTL))))
204 .Times(AnyNumber());
205 // clang-format on
206 EXPECT_REPORT(driver, (KC_LCTL, KC_LSFT, KC_A));
207 // clang-format off
208 EXPECT_CALL(driver, send_keyboard_mock(AnyOf(
209 KeyboardReport(KC_LCTL, KC_LSFT),
210 KeyboardReport(KC_LSFT))))
211 .Times(AnyNumber());
212 // clang-format on
213 EXPECT_REPORT(driver, (KC_LCTL));
214 regular_key.release();
215 run_one_scan_loop();
216 testing::Mock::VerifyAndClearExpectations(&driver);
217
218 /* Release mod-tap-hold key. */
219 EXPECT_EMPTY_REPORT(driver);
220 mod_tap_hold_key.release();
221 run_one_scan_loop();
222 testing::Mock::VerifyAndClearExpectations(&driver);
223}
224
225TEST_F(RetroShiftPermissiveHold, hold_mod_tap_key_while_mod_tap_key_is_held_over_tapping_term) {
226 TestDriver driver;
227 InSequence s;
228 auto mod_tap_hold_key = KeymapKey(0, 0, 0, CTL_T(KC_P));
229 auto mod_tap_regular_key = KeymapKey(0, 1, 0, ALT_T(KC_A));
230
231 set_keymap({mod_tap_hold_key, mod_tap_regular_key});
232
233 /* Press mod-tap-hold key. */
234 EXPECT_NO_REPORT(driver);
235 mod_tap_hold_key.press();
236 run_one_scan_loop();
237 testing::Mock::VerifyAndClearExpectations(&driver);
238
239 /* Press mod-tap-regular key. */
240 EXPECT_NO_REPORT(driver);
241 mod_tap_regular_key.press();
242 run_one_scan_loop();
243 idle_for(AUTO_SHIFT_TIMEOUT);
244 testing::Mock::VerifyAndClearExpectations(&driver);
245
246 /* Release mod-tap-regular key. */
247 // clang-format off
248 EXPECT_CALL(driver, send_keyboard_mock(AnyOf(
249 KeyboardReport(KC_LCTL, KC_LSFT),
250 KeyboardReport(KC_LSFT),
251 KeyboardReport(KC_LCTL))))
252 .Times(AnyNumber());
253 // clang-format on
254 EXPECT_REPORT(driver, (KC_LCTL, KC_LSFT, KC_A));
255 // clang-format off
256 EXPECT_CALL(driver, send_keyboard_mock(AnyOf(
257 KeyboardReport(KC_LCTL, KC_LSFT),
258 KeyboardReport(KC_LSFT))))
259 .Times(AnyNumber());
260 // clang-format on
261 EXPECT_REPORT(driver, (KC_LCTL));
262 mod_tap_regular_key.release();
263 run_one_scan_loop();
264 idle_for(TAPPING_TERM);
265 testing::Mock::VerifyAndClearExpectations(&driver);
266
267 /* Release mod-tap-hold key. */
268 EXPECT_EMPTY_REPORT(driver);
269 mod_tap_hold_key.release();
270 run_one_scan_loop();
271 testing::Mock::VerifyAndClearExpectations(&driver);
272}
273
274TEST_F(RetroShiftPermissiveHold, roll_tap_regular_key_while_mod_tap_key_is_held_under_tapping_term) {
275 TestDriver driver;
276 InSequence s;
277 auto mod_tap_hold_key = KeymapKey(0, 0, 0, CTL_T(KC_P));
278 auto regular_key = KeymapKey(0, 1, 0, KC_A);
279
280 set_keymap({mod_tap_hold_key, regular_key});
281
282 /* Press mod-tap-hold key. */
283 EXPECT_NO_REPORT(driver);
284 mod_tap_hold_key.press();
285 run_one_scan_loop();
286 testing::Mock::VerifyAndClearExpectations(&driver);
287
288 /* Press regular key. */
289 EXPECT_NO_REPORT(driver);
290 regular_key.press();
291 run_one_scan_loop();
292 testing::Mock::VerifyAndClearExpectations(&driver);
293
294 /* Release mod-tap-hold key. */
295 EXPECT_REPORT(driver, (KC_P));
296 EXPECT_EMPTY_REPORT(driver);
297 mod_tap_hold_key.release();
298 run_one_scan_loop();
299 testing::Mock::VerifyAndClearExpectations(&driver);
300
301 /* Release regular key. */
302 EXPECT_REPORT(driver, (KC_A));
303 EXPECT_EMPTY_REPORT(driver);
304 regular_key.release();
305 run_one_scan_loop();
306 testing::Mock::VerifyAndClearExpectations(&driver);
307}
308
309TEST_F(RetroShiftPermissiveHold, roll_tap_mod_tap_key_while_mod_tap_key_is_held_under_tapping_term) {
310 TestDriver driver;
311 InSequence s;
312 auto mod_tap_hold_key = KeymapKey(0, 0, 0, CTL_T(KC_P));
313 auto mod_tap_regular_key = KeymapKey(0, 1, 0, ALT_T(KC_A));
314
315 set_keymap({mod_tap_hold_key, mod_tap_regular_key});
316
317 /* Press mod-tap-hold key. */
318 EXPECT_NO_REPORT(driver);
319 mod_tap_hold_key.press();
320 run_one_scan_loop();
321 testing::Mock::VerifyAndClearExpectations(&driver);
322
323 /* Press mod-tap-regular key. */
324 EXPECT_NO_REPORT(driver);
325 mod_tap_regular_key.press();
326 run_one_scan_loop();
327 testing::Mock::VerifyAndClearExpectations(&driver);
328
329 /* Release mod-tap-hold key. */
330 EXPECT_REPORT(driver, (KC_P));
331 EXPECT_EMPTY_REPORT(driver);
332 mod_tap_hold_key.release();
333 run_one_scan_loop();
334 testing::Mock::VerifyAndClearExpectations(&driver);
335
336 /* Release mod-tap-regular key. */
337 EXPECT_REPORT(driver, (KC_A));
338 EXPECT_EMPTY_REPORT(driver);
339 mod_tap_regular_key.release();
340 run_one_scan_loop();
341 testing::Mock::VerifyAndClearExpectations(&driver);
342}
343
344TEST_F(RetroShiftPermissiveHold, roll_hold_regular_key_while_mod_tap_key_is_held_under_tapping_term) {
345 TestDriver driver;
346 InSequence s;
347 auto mod_tap_hold_key = KeymapKey(0, 0, 0, CTL_T(KC_P));
348 auto regular_key = KeymapKey(0, 1, 0, KC_A);
349
350 set_keymap({mod_tap_hold_key, regular_key});
351
352 /* Press mod-tap-hold key. */
353 EXPECT_NO_REPORT(driver);
354 mod_tap_hold_key.press();
355 run_one_scan_loop();
356 testing::Mock::VerifyAndClearExpectations(&driver);
357
358 /* Press regular key. */
359 EXPECT_NO_REPORT(driver);
360 regular_key.press();
361 run_one_scan_loop();
362 testing::Mock::VerifyAndClearExpectations(&driver);
363
364 /* Release mod-tap-hold key. */
365 EXPECT_REPORT(driver, (KC_P));
366 EXPECT_EMPTY_REPORT(driver);
367 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT))).Times(AnyNumber());
368 EXPECT_REPORT(driver, (KC_LSFT, KC_A));
369 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT))).Times(AnyNumber());
370 EXPECT_EMPTY_REPORT(driver);
371 mod_tap_hold_key.release();
372 run_one_scan_loop();
373 idle_for(AUTO_SHIFT_TIMEOUT);
374 testing::Mock::VerifyAndClearExpectations(&driver);
375
376 /* Release regular key. */
377 EXPECT_NO_REPORT(driver);
378 regular_key.release();
379 run_one_scan_loop();
380 testing::Mock::VerifyAndClearExpectations(&driver);
381}
382
383TEST_F(RetroShiftPermissiveHold, roll_hold_mod_tap_key_while_mod_tap_key_is_held_under_tapping_term) {
384 TestDriver driver;
385 InSequence s;
386 auto mod_tap_hold_key = KeymapKey(0, 0, 0, CTL_T(KC_P));
387 auto mod_tap_regular_key = KeymapKey(0, 1, 0, ALT_T(KC_A));
388
389 set_keymap({mod_tap_hold_key, mod_tap_regular_key});
390
391 /* Press mod-tap-hold key. */
392 EXPECT_NO_REPORT(driver);
393 mod_tap_hold_key.press();
394 run_one_scan_loop();
395 testing::Mock::VerifyAndClearExpectations(&driver);
396
397 /* Press mod-tap-regular key. */
398 EXPECT_NO_REPORT(driver);
399 mod_tap_regular_key.press();
400 run_one_scan_loop();
401 testing::Mock::VerifyAndClearExpectations(&driver);
402
403 /* Release mod-tap-hold key. */
404 EXPECT_REPORT(driver, (KC_P));
405 EXPECT_EMPTY_REPORT(driver);
406 mod_tap_hold_key.release();
407 run_one_scan_loop();
408 testing::Mock::VerifyAndClearExpectations(&driver);
409
410 /* Release mod-tap-regular key. */
411 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT))).Times(AnyNumber());
412 EXPECT_REPORT(driver, (KC_LSFT, KC_A));
413 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT))).Times(AnyNumber());
414 EXPECT_EMPTY_REPORT(driver);
415 idle_for(AUTO_SHIFT_TIMEOUT);
416 mod_tap_regular_key.release();
417 run_one_scan_loop();
418 testing::Mock::VerifyAndClearExpectations(&driver);
419}
diff --git a/tests/auto_shift/retro_shift/tap_hold_configurations/permissive_hold_hold_on_other_key_press/config.h b/tests/auto_shift/retro_shift/tap_hold_configurations/permissive_hold_hold_on_other_key_press/config.h
new file mode 100644
index 0000000000..a9535d8db0
--- /dev/null
+++ b/tests/auto_shift/retro_shift/tap_hold_configurations/permissive_hold_hold_on_other_key_press/config.h
@@ -0,0 +1,27 @@
1/* Copyright 2022 Isaac Elenbaas
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#pragma once
18
19#include "test_common.h"
20
21#define HOLD_ON_OTHER_KEY_PRESS
22#define PERMISSIVE_HOLD
23
24#define RETRO_SHIFT 2 * TAPPING_TERM
25// releases between AUTO_SHIFT_TIMEOUT and TAPPING_TERM are not tested
26#define AUTO_SHIFT_TIMEOUT TAPPING_TERM
27#define AUTO_SHIFT_MODIFIERS
diff --git a/tests/auto_shift/retro_shift/tap_hold_configurations/permissive_hold_hold_on_other_key_press/test.mk b/tests/auto_shift/retro_shift/tap_hold_configurations/permissive_hold_hold_on_other_key_press/test.mk
new file mode 100644
index 0000000000..b687332005
--- /dev/null
+++ b/tests/auto_shift/retro_shift/tap_hold_configurations/permissive_hold_hold_on_other_key_press/test.mk
@@ -0,0 +1,20 @@
1# Copyright 2022 Isaac Elenbaas
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# Keep this file, even if it is empty, as a marker that this folder contains tests
18# --------------------------------------------------------------------------------
19
20AUTO_SHIFT_ENABLE = yes
diff --git a/tests/auto_shift/retro_shift/tap_hold_configurations/permissive_hold_hold_on_other_key_press/test_retro_shift.cpp b/tests/auto_shift/retro_shift/tap_hold_configurations/permissive_hold_hold_on_other_key_press/test_retro_shift.cpp
new file mode 100644
index 0000000000..25c80b2cba
--- /dev/null
+++ b/tests/auto_shift/retro_shift/tap_hold_configurations/permissive_hold_hold_on_other_key_press/test_retro_shift.cpp
@@ -0,0 +1,442 @@
1/* Copyright 2022 Isaac Elenbaas
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 "keyboard_report_util.hpp"
18#include "keycode.h"
19#include "test_common.hpp"
20#include "action_tapping.h"
21#include "test_fixture.hpp"
22#include "test_keymap_key.hpp"
23
24bool get_auto_shifted_key(uint16_t keycode, keyrecord_t *record) {
25 return true;
26}
27
28using testing::_;
29using testing::AnyNumber;
30using testing::AnyOf;
31using testing::InSequence;
32
33class RetroShiftPermissiveHoldHoldOnOtherKeyPress : public TestFixture {};
34
35TEST_F(RetroShiftPermissiveHoldHoldOnOtherKeyPress, tap_regular_key_while_mod_tap_key_is_held_under_tapping_term) {
36 TestDriver driver;
37 InSequence s;
38 auto mod_tap_hold_key = KeymapKey(0, 0, 0, CTL_T(KC_P));
39 auto regular_key = KeymapKey(0, 1, 0, KC_A);
40
41 set_keymap({mod_tap_hold_key, regular_key});
42
43 /* Press mod-tap-hold key. */
44 EXPECT_NO_REPORT(driver);
45 mod_tap_hold_key.press();
46 run_one_scan_loop();
47 testing::Mock::VerifyAndClearExpectations(&driver);
48
49 /* Press regular key. */
50 EXPECT_NO_REPORT(driver);
51 regular_key.press();
52 run_one_scan_loop();
53 testing::Mock::VerifyAndClearExpectations(&driver);
54
55 /* Release regular key. */
56 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LCTL))).Times(AnyNumber());
57 EXPECT_REPORT(driver, (KC_LCTL, KC_A));
58 EXPECT_REPORT(driver, (KC_LCTL));
59 regular_key.release();
60 run_one_scan_loop();
61 testing::Mock::VerifyAndClearExpectations(&driver);
62
63 /* Release mod-tap-hold key. */
64 EXPECT_EMPTY_REPORT(driver);
65 mod_tap_hold_key.release();
66 run_one_scan_loop();
67 testing::Mock::VerifyAndClearExpectations(&driver);
68}
69
70TEST_F(RetroShiftPermissiveHoldHoldOnOtherKeyPress, tap_mod_tap_key_while_mod_tap_key_is_held_under_tapping_term) {
71 TestDriver driver;
72 InSequence s;
73 auto mod_tap_hold_key = KeymapKey(0, 0, 0, CTL_T(KC_P));
74 auto mod_tap_regular_key = KeymapKey(0, 1, 0, ALT_T(KC_A));
75
76 set_keymap({mod_tap_hold_key, mod_tap_regular_key});
77
78 /* Press mod-tap-hold key. */
79 EXPECT_NO_REPORT(driver);
80 mod_tap_hold_key.press();
81 run_one_scan_loop();
82 testing::Mock::VerifyAndClearExpectations(&driver);
83
84 /* Press mod-tap-regular key. */
85 EXPECT_NO_REPORT(driver);
86 mod_tap_regular_key.press();
87 run_one_scan_loop();
88 testing::Mock::VerifyAndClearExpectations(&driver);
89
90 /* Release mod-tap-regular key. */
91 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LCTL))).Times(AnyNumber());
92 EXPECT_REPORT(driver, (KC_LCTL, KC_A));
93 EXPECT_REPORT(driver, (KC_LCTL));
94 mod_tap_regular_key.release();
95 run_one_scan_loop();
96 testing::Mock::VerifyAndClearExpectations(&driver);
97
98 /* Release mod-tap-hold key. */
99 EXPECT_EMPTY_REPORT(driver);
100 mod_tap_hold_key.release();
101 run_one_scan_loop();
102 testing::Mock::VerifyAndClearExpectations(&driver);
103}
104
105TEST_F(RetroShiftPermissiveHoldHoldOnOtherKeyPress, tap_regular_key_while_mod_tap_key_is_held_over_tapping_term) {
106 TestDriver driver;
107 InSequence s;
108 auto mod_tap_hold_key = KeymapKey(0, 0, 0, CTL_T(KC_P));
109 auto regular_key = KeymapKey(0, 1, 0, KC_A);
110
111 set_keymap({mod_tap_hold_key, regular_key});
112
113 /* Press mod-tap-hold key. */
114 EXPECT_NO_REPORT(driver);
115 mod_tap_hold_key.press();
116 run_one_scan_loop();
117 testing::Mock::VerifyAndClearExpectations(&driver);
118
119 /* Press regular key. */
120 EXPECT_NO_REPORT(driver);
121 regular_key.press();
122 run_one_scan_loop();
123 testing::Mock::VerifyAndClearExpectations(&driver);
124
125 /* Release regular key. */
126 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LCTL))).Times(AnyNumber());
127 EXPECT_REPORT(driver, (KC_LCTL, KC_A));
128 EXPECT_REPORT(driver, (KC_LCTL));
129 regular_key.release();
130 run_one_scan_loop();
131 idle_for(TAPPING_TERM);
132 testing::Mock::VerifyAndClearExpectations(&driver);
133
134 /* Release mod-tap-hold key. */
135 EXPECT_EMPTY_REPORT(driver);
136 mod_tap_hold_key.release();
137 run_one_scan_loop();
138 testing::Mock::VerifyAndClearExpectations(&driver);
139}
140
141TEST_F(RetroShiftPermissiveHoldHoldOnOtherKeyPress, tap_mod_tap_key_while_mod_tap_key_is_held_over_tapping_term) {
142 TestDriver driver;
143 InSequence s;
144 auto mod_tap_hold_key = KeymapKey(0, 0, 0, CTL_T(KC_P));
145 auto mod_tap_regular_key = KeymapKey(0, 1, 0, ALT_T(KC_A));
146
147 set_keymap({mod_tap_hold_key, mod_tap_regular_key});
148
149 /* Press mod-tap-hold key. */
150 EXPECT_NO_REPORT(driver);
151 mod_tap_hold_key.press();
152 run_one_scan_loop();
153 testing::Mock::VerifyAndClearExpectations(&driver);
154
155 /* Press mod-tap-regular key. */
156 EXPECT_NO_REPORT(driver);
157 mod_tap_regular_key.press();
158 run_one_scan_loop();
159 testing::Mock::VerifyAndClearExpectations(&driver);
160
161 /* Release mod-tap-regular key. */
162 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LCTL))).Times(AnyNumber());
163 EXPECT_REPORT(driver, (KC_LCTL, KC_A));
164 EXPECT_REPORT(driver, (KC_LCTL));
165 mod_tap_regular_key.release();
166 run_one_scan_loop();
167 idle_for(TAPPING_TERM);
168 testing::Mock::VerifyAndClearExpectations(&driver);
169
170 /* Release mod-tap-hold key. */
171 EXPECT_EMPTY_REPORT(driver);
172 mod_tap_hold_key.release();
173 run_one_scan_loop();
174 testing::Mock::VerifyAndClearExpectations(&driver);
175}
176
177TEST_F(RetroShiftPermissiveHoldHoldOnOtherKeyPress, hold_regular_key_while_mod_tap_key_is_held_over_tapping_term) {
178 TestDriver driver;
179 InSequence s;
180 auto mod_tap_hold_key = KeymapKey(0, 0, 0, CTL_T(KC_P));
181 auto regular_key = KeymapKey(0, 1, 0, KC_A);
182
183 set_keymap({mod_tap_hold_key, regular_key});
184
185 /* Press mod-tap-hold key. */
186 EXPECT_NO_REPORT(driver);
187 mod_tap_hold_key.press();
188 run_one_scan_loop();
189 testing::Mock::VerifyAndClearExpectations(&driver);
190
191 /* Press regular key. */
192 EXPECT_NO_REPORT(driver);
193 regular_key.press();
194 run_one_scan_loop();
195 idle_for(AUTO_SHIFT_TIMEOUT);
196 testing::Mock::VerifyAndClearExpectations(&driver);
197
198 /* Release regular key. */
199 // clang-format off
200 EXPECT_CALL(driver, send_keyboard_mock(AnyOf(
201 KeyboardReport(KC_LCTL, KC_LSFT),
202 KeyboardReport(KC_LSFT),
203 KeyboardReport(KC_LCTL))))
204 .Times(AnyNumber());
205 // clang-format on
206 EXPECT_REPORT(driver, (KC_LCTL, KC_LSFT, KC_A));
207 // clang-format off
208 EXPECT_CALL(driver, send_keyboard_mock(AnyOf(
209 KeyboardReport(KC_LCTL, KC_LSFT),
210 KeyboardReport(KC_LSFT))))
211 .Times(AnyNumber());
212 // clang-format on
213 EXPECT_REPORT(driver, (KC_LCTL));
214 regular_key.release();
215 run_one_scan_loop();
216 testing::Mock::VerifyAndClearExpectations(&driver);
217
218 /* Release mod-tap-hold key. */
219 EXPECT_EMPTY_REPORT(driver);
220 mod_tap_hold_key.release();
221 run_one_scan_loop();
222 testing::Mock::VerifyAndClearExpectations(&driver);
223}
224
225TEST_F(RetroShiftPermissiveHoldHoldOnOtherKeyPress, hold_mod_tap_key_while_mod_tap_key_is_held_over_tapping_term) {
226 TestDriver driver;
227 InSequence s;
228 auto mod_tap_hold_key = KeymapKey(0, 0, 0, CTL_T(KC_P));
229 auto mod_tap_regular_key = KeymapKey(0, 1, 0, ALT_T(KC_A));
230
231 set_keymap({mod_tap_hold_key, mod_tap_regular_key});
232
233 /* Press mod-tap-hold key. */
234 EXPECT_NO_REPORT(driver);
235 mod_tap_hold_key.press();
236 run_one_scan_loop();
237 testing::Mock::VerifyAndClearExpectations(&driver);
238
239 /* Press mod-tap-regular key. */
240 EXPECT_NO_REPORT(driver);
241 mod_tap_regular_key.press();
242 run_one_scan_loop();
243 idle_for(AUTO_SHIFT_TIMEOUT);
244 testing::Mock::VerifyAndClearExpectations(&driver);
245
246 /* Release mod-tap-regular key. */
247 // clang-format off
248 EXPECT_CALL(driver, send_keyboard_mock(AnyOf(
249 KeyboardReport(KC_LCTL, KC_LSFT),
250 KeyboardReport(KC_LSFT),
251 KeyboardReport(KC_LCTL))))
252 .Times(AnyNumber());
253 // clang-format on
254 EXPECT_REPORT(driver, (KC_LCTL, KC_LSFT, KC_A));
255 // clang-format off
256 EXPECT_CALL(driver, send_keyboard_mock(AnyOf(
257 KeyboardReport(KC_LCTL, KC_LSFT),
258 KeyboardReport(KC_LSFT))))
259 .Times(AnyNumber());
260 // clang-format on
261 EXPECT_REPORT(driver, (KC_LCTL));
262 mod_tap_regular_key.release();
263 run_one_scan_loop();
264 idle_for(TAPPING_TERM);
265 testing::Mock::VerifyAndClearExpectations(&driver);
266
267 /* Release mod-tap-hold key. */
268 EXPECT_EMPTY_REPORT(driver);
269 mod_tap_hold_key.release();
270 run_one_scan_loop();
271 testing::Mock::VerifyAndClearExpectations(&driver);
272}
273
274TEST_F(RetroShiftPermissiveHoldHoldOnOtherKeyPress, roll_tap_regular_key_while_mod_tap_key_is_held_under_tapping_term) {
275 TestDriver driver;
276 InSequence s;
277 auto mod_tap_hold_key = KeymapKey(0, 0, 0, CTL_T(KC_P));
278 auto regular_key = KeymapKey(0, 1, 0, KC_A);
279
280 set_keymap({mod_tap_hold_key, regular_key});
281
282 /* Press mod-tap-hold key. */
283 EXPECT_NO_REPORT(driver);
284 mod_tap_hold_key.press();
285 run_one_scan_loop();
286 testing::Mock::VerifyAndClearExpectations(&driver);
287
288 /* Press regular key. */
289 EXPECT_NO_REPORT(driver);
290 regular_key.press();
291 run_one_scan_loop();
292 testing::Mock::VerifyAndClearExpectations(&driver);
293
294 /* Release mod-tap-hold key. */
295 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LCTL))).Times(AnyNumber());
296 mod_tap_hold_key.release();
297 run_one_scan_loop();
298 testing::Mock::VerifyAndClearExpectations(&driver);
299
300 /* Release regular key. */
301 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LCTL))).Times(AnyNumber());
302 EXPECT_REPORT(driver, (KC_LCTL, KC_A));
303 EXPECT_REPORT(driver, (KC_LCTL));
304 EXPECT_EMPTY_REPORT(driver);
305 regular_key.release();
306 run_one_scan_loop();
307 testing::Mock::VerifyAndClearExpectations(&driver);
308}
309
310TEST_F(RetroShiftPermissiveHoldHoldOnOtherKeyPress, roll_tap_mod_tap_key_while_mod_tap_key_is_held_under_tapping_term) {
311 TestDriver driver;
312 InSequence s;
313 auto mod_tap_hold_key = KeymapKey(0, 0, 0, CTL_T(KC_P));
314 auto mod_tap_regular_key = KeymapKey(0, 1, 0, ALT_T(KC_A));
315
316 set_keymap({mod_tap_hold_key, mod_tap_regular_key});
317
318 /* Press mod-tap-hold key. */
319 EXPECT_NO_REPORT(driver);
320 mod_tap_hold_key.press();
321 run_one_scan_loop();
322 testing::Mock::VerifyAndClearExpectations(&driver);
323
324 /* Press mod-tap-regular key. */
325 EXPECT_NO_REPORT(driver);
326 mod_tap_regular_key.press();
327 run_one_scan_loop();
328 testing::Mock::VerifyAndClearExpectations(&driver);
329
330 /* Release mod-tap-hold key. */
331 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LCTL))).Times(AnyNumber());
332 mod_tap_hold_key.release();
333 run_one_scan_loop();
334 testing::Mock::VerifyAndClearExpectations(&driver);
335
336 /* Release mod-tap-regular key. */
337 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LCTL))).Times(AnyNumber());
338 EXPECT_REPORT(driver, (KC_LCTL, KC_A));
339 EXPECT_REPORT(driver, (KC_LCTL));
340 EXPECT_EMPTY_REPORT(driver);
341 mod_tap_regular_key.release();
342 run_one_scan_loop();
343 testing::Mock::VerifyAndClearExpectations(&driver);
344}
345
346TEST_F(RetroShiftPermissiveHoldHoldOnOtherKeyPress, roll_hold_regular_key_while_mod_tap_key_is_held_under_tapping_term) {
347 TestDriver driver;
348 InSequence s;
349 auto mod_tap_hold_key = KeymapKey(0, 0, 0, CTL_T(KC_P));
350 auto regular_key = KeymapKey(0, 1, 0, KC_A);
351
352 set_keymap({mod_tap_hold_key, regular_key});
353
354 /* Press mod-tap-hold key. */
355 EXPECT_NO_REPORT(driver);
356 mod_tap_hold_key.press();
357 run_one_scan_loop();
358 testing::Mock::VerifyAndClearExpectations(&driver);
359
360 /* Press regular key. */
361 EXPECT_NO_REPORT(driver);
362 regular_key.press();
363 run_one_scan_loop();
364 testing::Mock::VerifyAndClearExpectations(&driver);
365
366 /* Release mod-tap-hold key. */
367 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LCTL))).Times(AnyNumber());
368 mod_tap_hold_key.release();
369 run_one_scan_loop();
370 testing::Mock::VerifyAndClearExpectations(&driver);
371
372 /* Release regular key. */
373 // clang-format off
374 EXPECT_CALL(driver, send_keyboard_mock(AnyOf(
375 KeyboardReport(KC_LCTL, KC_LSFT),
376 KeyboardReport(KC_LSFT),
377 KeyboardReport(KC_LCTL))))
378 .Times(AnyNumber());
379 // clang-format on
380 EXPECT_REPORT(driver, (KC_LCTL, KC_LSFT, KC_A));
381 // clang-format off
382 EXPECT_CALL(driver, send_keyboard_mock(AnyOf(
383 KeyboardReport(KC_LCTL, KC_LSFT),
384 KeyboardReport(KC_LSFT),
385 KeyboardReport(KC_LCTL))))
386 .Times(AnyNumber());
387 // clang-format on
388 EXPECT_EMPTY_REPORT(driver);
389 idle_for(AUTO_SHIFT_TIMEOUT);
390 regular_key.release();
391 run_one_scan_loop();
392 testing::Mock::VerifyAndClearExpectations(&driver);
393}
394
395TEST_F(RetroShiftPermissiveHoldHoldOnOtherKeyPress, roll_hold_mod_tap_key_while_mod_tap_key_is_held_under_tapping_term) {
396 TestDriver driver;
397 InSequence s;
398 auto mod_tap_hold_key = KeymapKey(0, 0, 0, CTL_T(KC_P));
399 auto mod_tap_regular_key = KeymapKey(0, 1, 0, ALT_T(KC_A));
400
401 set_keymap({mod_tap_hold_key, mod_tap_regular_key});
402
403 /* Press mod-tap-hold key. */
404 EXPECT_NO_REPORT(driver);
405 mod_tap_hold_key.press();
406 run_one_scan_loop();
407 testing::Mock::VerifyAndClearExpectations(&driver);
408
409 /* Press mod-tap-regular key. */
410 EXPECT_NO_REPORT(driver);
411 mod_tap_regular_key.press();
412 run_one_scan_loop();
413 testing::Mock::VerifyAndClearExpectations(&driver);
414
415 /* Release mod-tap-hold key. */
416 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LCTL))).Times(AnyNumber());
417 mod_tap_hold_key.release();
418 run_one_scan_loop();
419 testing::Mock::VerifyAndClearExpectations(&driver);
420
421 /* Release mod-tap-regular key. */
422 // clang-format off
423 EXPECT_CALL(driver, send_keyboard_mock(AnyOf(
424 KeyboardReport(KC_LCTL, KC_LSFT),
425 KeyboardReport(KC_LSFT),
426 KeyboardReport(KC_LCTL))))
427 .Times(AnyNumber());
428 // clang-format on
429 EXPECT_REPORT(driver, (KC_LCTL, KC_LSFT, KC_A));
430 // clang-format off
431 EXPECT_CALL(driver, send_keyboard_mock(AnyOf(
432 KeyboardReport(KC_LCTL, KC_LSFT),
433 KeyboardReport(KC_LSFT),
434 KeyboardReport(KC_LCTL))))
435 .Times(AnyNumber());
436 // clang-format on
437 EXPECT_EMPTY_REPORT(driver);
438 idle_for(AUTO_SHIFT_TIMEOUT);
439 mod_tap_regular_key.release();
440 run_one_scan_loop();
441 testing::Mock::VerifyAndClearExpectations(&driver);
442}
diff --git a/tests/auto_shift/test.mk b/tests/auto_shift/test.mk
index 4259c606e4..a4c6b380ed 100644
--- a/tests/auto_shift/test.mk
+++ b/tests/auto_shift/test.mk
@@ -17,4 +17,4 @@
17# Keep this file, even if it is empty, as a marker that this folder contains tests 17# Keep this file, even if it is empty, as a marker that this folder contains tests
18# -------------------------------------------------------------------------------- 18# --------------------------------------------------------------------------------
19 19
20AUTO_SHIFT_ENABLE = yes \ No newline at end of file 20AUTO_SHIFT_ENABLE = yes