test_fixture.cpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #include "test_fixture.h"
  2. #include "gmock/gmock.h"
  3. #include "test_driver.h"
  4. #include "test_matrix.h"
  5. #include "keyboard.h"
  6. using testing::_;
  7. using testing::AnyNumber;
  8. using testing::Return;
  9. using testing::Between;
  10. void TestFixture::SetUpTestCase() {
  11. TestDriver driver;
  12. EXPECT_CALL(driver, send_keyboard_mock(_));
  13. keyboard_init();
  14. }
  15. void TestFixture::TearDownTestCase() {
  16. }
  17. TestFixture::TestFixture() {
  18. }
  19. TestFixture::~TestFixture() {
  20. TestDriver driver;
  21. clear_all_keys();
  22. // Run for a while to make sure all keys are completely released
  23. // Should probably wait until tapping term etc, has timed out
  24. EXPECT_CALL(driver, send_keyboard_mock(_)).Times(AnyNumber());
  25. EXPECT_CALL(driver, keyboard_leds_mock()).WillRepeatedly(Return(0));
  26. for (int i=0; i<100; i++) {
  27. keyboard_task();
  28. }
  29. testing::Mock::VerifyAndClearExpectations(&driver);
  30. // Verify that the matrix really is cleared
  31. EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).Times(Between(0, 1));
  32. EXPECT_CALL(driver, keyboard_leds_mock()).WillRepeatedly(Return(0));
  33. }