logo

qmk_firmware

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

test_mod_tap.cpp (2941B)


  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, TapA_SHFT_T_KeyReportsKey) {
  25. TestDriver driver;
  26. InSequence s;
  27. auto key_shift_hold_p_tap = KeymapKey(0, 7, 0, SFT_T(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, HoldA_SHFT_T_KeyReportsShift) {
  38. TestDriver driver;
  39. InSequence s;
  40. auto mod_tap_hold_key = KeymapKey(0, 7, 0, SFT_T(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. }
  52. TEST_F(Tapping, ANewTapWithinTappingTermIsBuggy) {
  53. // See issue #1478 for more information
  54. TestDriver driver;
  55. InSequence s;
  56. auto key_shift_hold_p_tap = KeymapKey(0, 7, 0, SFT_T(KC_P));
  57. set_keymap({key_shift_hold_p_tap});
  58. // Tapping keys does nothing on press
  59. key_shift_hold_p_tap.press();
  60. EXPECT_REPORT(driver, (KC_P));
  61. run_one_scan_loop();
  62. key_shift_hold_p_tap.release();
  63. EXPECT_EMPTY_REPORT(driver);
  64. run_one_scan_loop();
  65. key_shift_hold_p_tap.press();
  66. EXPECT_REPORT(driver, (KC_P));
  67. run_one_scan_loop();
  68. key_shift_hold_p_tap.release();
  69. EXPECT_EMPTY_REPORT(driver);
  70. idle_for(TAPPING_TERM + 1);
  71. key_shift_hold_p_tap.press();
  72. EXPECT_REPORT(driver, (KC_P));
  73. run_one_scan_loop();
  74. key_shift_hold_p_tap.release();
  75. EXPECT_EMPTY_REPORT(driver);
  76. idle_for(TAPPING_TERM + 1);
  77. key_shift_hold_p_tap.press();
  78. // Shouldn't be called here really
  79. EXPECT_REPORT(driver, (KC_P));
  80. idle_for(TAPPING_TERM);
  81. EXPECT_EMPTY_REPORT(driver);
  82. key_shift_hold_p_tap.release();
  83. run_one_scan_loop();
  84. VERIFY_AND_CLEAR(driver);
  85. }