You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
1.8 KiB

  1. // Copyright 2023 Google LLC
  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. #include "keyboard_report_util.hpp"
  16. #include "keycode.h"
  17. #include "test_common.hpp"
  18. #include "test_fixture.hpp"
  19. #include "test_keymap_key.hpp"
  20. using ::testing::AnyNumber;
  21. using ::testing::InSequence;
  22. namespace {
  23. class RepeatKey : public TestFixture {};
  24. // Tests repeating a combo, KC_X + KC_Y = KC_Q, by typing
  25. // "X, Repeat, Repeat, {X Y}, Repeat, Repeat". This produces "xxxqqq".
  26. TEST_F(RepeatKey, Combo) {
  27. TestDriver driver;
  28. KeymapKey key_x(0, 0, 0, KC_X);
  29. KeymapKey key_y(0, 1, 0, KC_Y);
  30. KeymapKey key_repeat(0, 2, 0, QK_REP);
  31. set_keymap({key_x, key_y, key_repeat});
  32. // Allow any number of empty reports.
  33. EXPECT_EMPTY_REPORT(driver).Times(AnyNumber());
  34. {
  35. InSequence seq;
  36. EXPECT_REPORT(driver, (KC_X));
  37. EXPECT_REPORT(driver, (KC_X));
  38. EXPECT_REPORT(driver, (KC_X));
  39. EXPECT_REPORT(driver, (KC_Q));
  40. EXPECT_REPORT(driver, (KC_Q));
  41. EXPECT_REPORT(driver, (KC_Q));
  42. }
  43. tap_keys(key_x, key_repeat, key_repeat);
  44. tap_combo({key_x, key_y});
  45. EXPECT_KEYCODE_EQ(get_last_keycode(), KC_Q);
  46. tap_keys(key_repeat, key_repeat);
  47. testing::Mock::VerifyAndClearExpectations(&driver);
  48. }
  49. } // namespace