diff options
| author | Fred Sundvik <fsundvik@gmail.com> | 2017-06-18 23:49:38 +0300 |
|---|---|---|
| committer | Fred Sundvik <fsundvik@gmail.com> | 2017-06-18 23:49:38 +0300 |
| commit | 36f820be7e80bc8f1f5489373708356cf142c269 (patch) | |
| tree | cf3561b80650e536a2c41f0e3bb4bc70635b6435 /tests/test_common/test_fixture.cpp | |
| parent | e85b1857968d4c0378b9778650c30b9d2bca3ea9 (diff) | |
| download | qmk_firmware-36f820be7e80bc8f1f5489373708356cf142c269.tar.gz qmk_firmware-36f820be7e80bc8f1f5489373708356cf142c269.zip | |
Add a test fixture
It only initializes QMK once, and clears the matrix after each test.
Diffstat (limited to 'tests/test_common/test_fixture.cpp')
| -rw-r--r-- | tests/test_common/test_fixture.cpp | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/test_common/test_fixture.cpp b/tests/test_common/test_fixture.cpp new file mode 100644 index 000000000..aff518d21 --- /dev/null +++ b/tests/test_common/test_fixture.cpp | |||
| @@ -0,0 +1,38 @@ | |||
| 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 | |||
| 7 | using testing::_; | ||
| 8 | using testing::AnyNumber; | ||
| 9 | using testing::Return; | ||
| 10 | using testing::Between; | ||
| 11 | |||
| 12 | void TestFixture::SetUpTestCase() { | ||
| 13 | TestDriver driver; | ||
| 14 | EXPECT_CALL(driver, send_keyboard_mock(_)); | ||
| 15 | keyboard_init(); | ||
| 16 | } | ||
| 17 | |||
| 18 | void TestFixture::TearDownTestCase() { | ||
| 19 | } | ||
| 20 | |||
| 21 | TestFixture::TestFixture() { | ||
| 22 | } | ||
| 23 | |||
| 24 | TestFixture::~TestFixture() { | ||
| 25 | TestDriver driver; | ||
| 26 | clear_all_keys(); | ||
| 27 | // Run for a while to make sure all keys are completely released | ||
| 28 | // Should probably wait until tapping term etc, has timed out | ||
| 29 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(AnyNumber()); | ||
| 30 | EXPECT_CALL(driver, keyboard_leds_mock()).WillRepeatedly(Return(0)); | ||
| 31 | for (int i=0; i<100; i++) { | ||
| 32 | keyboard_task(); | ||
| 33 | } | ||
| 34 | testing::Mock::VerifyAndClearExpectations(&driver); | ||
| 35 | // Verify that the matrix really is cleared | ||
| 36 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).Times(Between(0, 1)); | ||
| 37 | EXPECT_CALL(driver, keyboard_leds_mock()).WillRepeatedly(Return(0)); | ||
| 38 | } \ No newline at end of file | ||
