logo

qmk_firmware

custom branch of QMK firmware git clone https://anongit.hacktivis.me/git/qmk_firmware.git

test_layer_tap.cpp (1806B)


  1. /* Copyright 2017 Fred Sundvik
  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. #include "keyboard_report_util.hpp"
  17. #include "keycode.h"
  18. #include "test_common.hpp"
  19. #include "action_tapping.h"
  20. #include "test_keymap_key.hpp"
  21. using testing::_;
  22. using testing::InSequence;
  23. class Tapping : public TestFixture {};
  24. TEST_F(Tapping, TapP_Layer_Tap_KeyReportsKey) {
  25. TestDriver driver;
  26. InSequence s;
  27. auto key_shift_hold_p_tap = KeymapKey(0, 7, 0, LT(1, KC_P));
  28. set_keymap({key_shift_hold_p_tap});
  29. key_shift_hold_p_tap.press();
  30. EXPECT_REPORT(driver, (KC_P));
  31. run_one_scan_loop();
  32. key_shift_hold_p_tap.release();
  33. EXPECT_EMPTY_REPORT(driver);
  34. run_one_scan_loop();
  35. VERIFY_AND_CLEAR(driver);
  36. }
  37. TEST_F(Tapping, HoldP_Layer_Tap_KeyReportsKey) {
  38. TestDriver driver;
  39. InSequence s;
  40. auto mod_tap_hold_key = KeymapKey(0, 7, 0, LT(1, KC_P));
  41. set_keymap({mod_tap_hold_key});
  42. mod_tap_hold_key.press();
  43. EXPECT_REPORT(driver, (KC_P));
  44. idle_for(TAPPING_TERM);
  45. run_one_scan_loop();
  46. EXPECT_NO_REPORT(driver);
  47. mod_tap_hold_key.release();
  48. EXPECT_EMPTY_REPORT(driver);
  49. run_one_scan_loop();
  50. VERIFY_AND_CLEAR(driver);
  51. }