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.

50 lines
1.2 KiB

  1. #include "test_fixture.hpp"
  2. #include "gmock/gmock.h"
  3. #include "test_driver.hpp"
  4. #include "test_matrix.h"
  5. #include "keyboard.h"
  6. #include "action.h"
  7. #include "action_tapping.h"
  8. extern "C" {
  9. void set_time(uint32_t t);
  10. void advance_time(uint32_t ms);
  11. }
  12. using testing::_;
  13. using testing::AnyNumber;
  14. using testing::Return;
  15. using testing::Between;
  16. void TestFixture::SetUpTestCase() {
  17. TestDriver driver;
  18. EXPECT_CALL(driver, send_keyboard_mock(_));
  19. keyboard_init();
  20. }
  21. void TestFixture::TearDownTestCase() {
  22. }
  23. TestFixture::TestFixture() {
  24. }
  25. TestFixture::~TestFixture() {
  26. TestDriver driver;
  27. clear_all_keys();
  28. // Run for a while to make sure all keys are completely released
  29. EXPECT_CALL(driver, send_keyboard_mock(_)).Times(AnyNumber());
  30. idle_for(TAPPING_TERM + 10);
  31. testing::Mock::VerifyAndClearExpectations(&driver);
  32. // Verify that the matrix really is cleared
  33. EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).Times(Between(0, 1));
  34. }
  35. void TestFixture::run_one_scan_loop() {
  36. keyboard_task();
  37. advance_time(1);
  38. }
  39. void TestFixture::idle_for(unsigned time) {
  40. for (unsigned i=0; i<time; i++) {
  41. run_one_scan_loop();
  42. }
  43. }