logo

qmk_firmware

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

test_action_layer.cpp (2304B)


  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. #include "keyboard_report_util.hpp"
  17. #include "test_common.hpp"
  18. using testing::_;
  19. using testing::InSequence;
  20. class ActionLayer : public TestFixture {};
  21. TEST_F(ActionLayer, LayerTapToggleWithToggleWithKeypress) {
  22. TestDriver driver;
  23. KeymapKey layer_key = KeymapKey{0, 0, 0, TT(1)};
  24. /* These keys must have the same position in the matrix, only the layer is different. */
  25. KeymapKey regular_key = KeymapKey{0, 1, 0, KC_A};
  26. set_keymap({layer_key, regular_key, KeymapKey{1, 1, 0, KC_B}});
  27. /* Tap TT five times . */
  28. /* TODO: Tapping Force Hold breaks TT */
  29. EXPECT_NO_REPORT(driver);
  30. layer_key.press();
  31. run_one_scan_loop();
  32. layer_key.release();
  33. run_one_scan_loop();
  34. expect_layer_state(0);
  35. idle_for(QUICK_TAP_TERM + 10);
  36. layer_key.press();
  37. run_one_scan_loop();
  38. layer_key.release();
  39. run_one_scan_loop();
  40. expect_layer_state(0);
  41. layer_key.press();
  42. run_one_scan_loop();
  43. layer_key.release();
  44. run_one_scan_loop();
  45. expect_layer_state(0);
  46. layer_key.press();
  47. run_one_scan_loop();
  48. layer_key.release();
  49. run_one_scan_loop();
  50. expect_layer_state(0);
  51. layer_key.press();
  52. run_one_scan_loop();
  53. layer_key.release();
  54. run_one_scan_loop();
  55. expect_layer_state(0);
  56. VERIFY_AND_CLEAR(driver);
  57. EXPECT_REPORT(driver, (KC_A)).Times(1);
  58. regular_key.press();
  59. run_one_scan_loop();
  60. expect_layer_state(0);
  61. VERIFY_AND_CLEAR(driver);
  62. EXPECT_EMPTY_REPORT(driver).Times(1);
  63. regular_key.release();
  64. run_one_scan_loop();
  65. expect_layer_state(0);
  66. VERIFY_AND_CLEAR(driver);
  67. }