logo

qmk_firmware

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

test_tapping.cpp (2869B)


  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_LSFT));
  31. run_one_scan_loop();
  32. key_shift_hold_p_tap.release();
  33. EXPECT_EMPTY_REPORT(driver);
  34. run_one_scan_loop();
  35. }
  36. TEST_F(Tapping, HoldA_SHFT_T_KeyReportsShift) {
  37. TestDriver driver;
  38. InSequence s;
  39. auto mod_tap_hold_key = KeymapKey(0, 7, 0, SFT_T(KC_P));
  40. set_keymap({mod_tap_hold_key});
  41. mod_tap_hold_key.press();
  42. EXPECT_REPORT(driver, (KC_LSFT));
  43. idle_for(TAPPING_TERM);
  44. run_one_scan_loop();
  45. EXPECT_NO_REPORT(driver);
  46. mod_tap_hold_key.release();
  47. EXPECT_EMPTY_REPORT(driver);
  48. run_one_scan_loop();
  49. }
  50. TEST_F(Tapping, ANewTapWithinTappingTermIsBuggy) {
  51. // See issue #1478 for more information
  52. TestDriver driver;
  53. InSequence s;
  54. auto key_shift_hold_p_tap = KeymapKey(0, 7, 0, SFT_T(KC_P));
  55. set_keymap({key_shift_hold_p_tap});
  56. // Tapping keys does nothing on press
  57. key_shift_hold_p_tap.press();
  58. EXPECT_REPORT(driver, (KC_LSFT));
  59. run_one_scan_loop();
  60. key_shift_hold_p_tap.release();
  61. EXPECT_EMPTY_REPORT(driver);
  62. run_one_scan_loop();
  63. key_shift_hold_p_tap.press();
  64. EXPECT_REPORT(driver, (KC_LSFT));
  65. run_one_scan_loop();
  66. key_shift_hold_p_tap.release();
  67. EXPECT_EMPTY_REPORT(driver);
  68. idle_for(TAPPING_TERM + 1);
  69. key_shift_hold_p_tap.press();
  70. EXPECT_REPORT(driver, (KC_LSFT));
  71. run_one_scan_loop();
  72. key_shift_hold_p_tap.release();
  73. EXPECT_EMPTY_REPORT(driver);
  74. idle_for(TAPPING_TERM + 1);
  75. key_shift_hold_p_tap.press();
  76. // Shouldn't be called here really
  77. EXPECT_REPORT(driver, (KC_LSFT));
  78. idle_for(TAPPING_TERM);
  79. EXPECT_EMPTY_REPORT(driver);
  80. key_shift_hold_p_tap.release();
  81. run_one_scan_loop();
  82. }