aboutsummaryrefslogtreecommitdiff
path: root/tests/test_common/test_fixture.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_common/test_fixture.cpp')
-rw-r--r--tests/test_common/test_fixture.cpp23
1 files changed, 19 insertions, 4 deletions
diff --git a/tests/test_common/test_fixture.cpp b/tests/test_common/test_fixture.cpp
index eef9b854b..5ca5247db 100644
--- a/tests/test_common/test_fixture.cpp
+++ b/tests/test_common/test_fixture.cpp
@@ -3,6 +3,13 @@
3#include "test_driver.h" 3#include "test_driver.h"
4#include "test_matrix.h" 4#include "test_matrix.h"
5#include "keyboard.h" 5#include "keyboard.h"
6#include "action.h"
7#include "action_tapping.h"
8
9extern "C" {
10 void set_time(uint32_t t);
11 void advance_time(uint32_t ms);
12}
6 13
7using testing::_; 14using testing::_;
8using testing::AnyNumber; 15using testing::AnyNumber;
@@ -25,12 +32,20 @@ TestFixture::~TestFixture() {
25 TestDriver driver; 32 TestDriver driver;
26 clear_all_keys(); 33 clear_all_keys();
27 // Run for a while to make sure all keys are completely released 34 // 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()); 35 EXPECT_CALL(driver, send_keyboard_mock(_)).Times(AnyNumber());
30 for (int i=0; i<100; i++) { 36 idle_for(TAPPING_TERM + 10);
31 keyboard_task();
32 }
33 testing::Mock::VerifyAndClearExpectations(&driver); 37 testing::Mock::VerifyAndClearExpectations(&driver);
34 // Verify that the matrix really is cleared 38 // Verify that the matrix really is cleared
35 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).Times(Between(0, 1)); 39 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).Times(Between(0, 1));
40}
41
42void TestFixture::run_one_scan_loop() {
43 keyboard_task();
44 advance_time(1);
45}
46
47void TestFixture::idle_for(uint time) {
48 for (uint i=0; i<time; i++) {
49 run_one_scan_loop();
50 }
36} \ No newline at end of file 51} \ No newline at end of file