Parent directory

test_auto_shift.cpp

2000 bytes
 1/* Copyright 2021 Stefan Kerkmann
 2 *
 3 * This program is free software: you can redistribute it and/or modify
 4 * it under the terms of the GNU General Public License as published by
 5 * the Free Software Foundation, either version 2 of the License, or
 6 * (at your option) any later version.
 7 *
 8 * This program is distributed in the hope that it will be useful,
 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include "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::InSequence;
26
27class AutoShift : public TestFixture {};
28
29TEST_F(AutoShift, key_release_before_timeout) {
30    TestDriver driver;
31    InSequence s;
32    auto       regular_key = KeymapKey(0, 2, 0, KC_A);
33
34    set_keymap({regular_key});
35
36    /* Press regular key */
37    EXPECT_NO_REPORT(driver);
38    regular_key.press();
39    run_one_scan_loop();
40    VERIFY_AND_CLEAR(driver);
41
42    /* Release regular key */
43    EXPECT_REPORT(driver, (KC_A));
44    EXPECT_EMPTY_REPORT(driver);
45    regular_key.release();
46    run_one_scan_loop();
47    VERIFY_AND_CLEAR(driver);
48}
49
50TEST_F(AutoShift, key_release_after_timeout) {
51    TestDriver driver;
52    InSequence s;
53    auto       regular_key = KeymapKey(0, 2, 0, KC_A);
54
55    set_keymap({regular_key});
56
57    /* Press regular key */
58    EXPECT_NO_REPORT(driver);
59    regular_key.press();
60    idle_for(AUTO_SHIFT_TIMEOUT);
61    VERIFY_AND_CLEAR(driver);
62
63    /* Release regular key */
64    EXPECT_REPORT(driver, (KC_LSFT, KC_A));
65    EXPECT_REPORT(driver, (KC_LSFT));
66    EXPECT_EMPTY_REPORT(driver);
67    regular_key.release();
68    run_one_scan_loop();
69    VERIFY_AND_CLEAR(driver);
70}