test_tap_hold.cpp (1618B)
1 2 /* Copyright 2021 Stefan Kerkmann 3 * 4 * This program is free software: you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation, either version 2 of the License, or 7 * (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program. If not, see <http://www.gnu.org/licenses/>. 16 */ 17 18 #include "keyboard_report_util.hpp" 19 #include "keycode.h" 20 #include "test_common.hpp" 21 #include "action_tapping.h" 22 #include "test_fixture.hpp" 23 #include "test_keymap_key.hpp" 24 25 using testing::_; 26 using testing::InSequence; 27 28 class RetroTapping : public TestFixture {}; 29 30 TEST_F(RetroTapping, tap_and_hold_mod_tap_hold_key) { 31 TestDriver driver; 32 InSequence s; 33 auto mod_tap_hold_key = KeymapKey(0, 1, 0, SFT_T(KC_P)); 34 35 set_keymap({mod_tap_hold_key}); 36 37 /* Press mod-tap-hold key. */ 38 EXPECT_NO_REPORT(driver); 39 mod_tap_hold_key.press(); 40 idle_for(TAPPING_TERM); 41 VERIFY_AND_CLEAR(driver); 42 43 /* Release mod-tap-hold key. */ 44 /* TODO: Why is LSHIFT send at all? */ 45 EXPECT_REPORT(driver, (KC_LEFT_SHIFT)); 46 EXPECT_EMPTY_REPORT(driver); 47 EXPECT_REPORT(driver, (KC_P)); 48 EXPECT_EMPTY_REPORT(driver); 49 mod_tap_hold_key.release(); 50 run_one_scan_loop(); 51 VERIFY_AND_CLEAR(driver); 52 }