diff options
| author | Fred Sundvik <fsundvik@gmail.com> | 2017-06-19 00:19:09 +0300 |
|---|---|---|
| committer | Fred Sundvik <fsundvik@gmail.com> | 2017-06-19 00:19:09 +0300 |
| commit | 43d8fa5bf1248ce5c1ce5f9cb0d238d794b4475d (patch) | |
| tree | cc98ca3ae09ef1b639de0f7b81636b8162301ca0 /tests | |
| parent | 36f820be7e80bc8f1f5489373708356cf142c269 (diff) | |
| download | qmk_firmware-43d8fa5bf1248ce5c1ce5f9cb0d238d794b4475d.tar.gz qmk_firmware-43d8fa5bf1248ce5c1ce5f9cb0d238d794b4475d.zip | |
More natural interface for setting keyboard leds
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/basic/test.cpp | 3 | ||||
| -rw-r--r-- | tests/test_common/test_driver.cpp | 3 | ||||
| -rw-r--r-- | tests/test_common/test_driver.h | 4 | ||||
| -rw-r--r-- | tests/test_common/test_fixture.cpp | 2 |
4 files changed, 4 insertions, 8 deletions
diff --git a/tests/basic/test.cpp b/tests/basic/test.cpp index 26a09585c..1bd5c2762 100644 --- a/tests/basic/test.cpp +++ b/tests/basic/test.cpp | |||
| @@ -37,7 +37,6 @@ class KeyPress : public TestFixture {}; | |||
| 37 | 37 | ||
| 38 | TEST_F(KeyPress, SendKeyboardIsNotCalledWhenNoKeyIsPressed) { | 38 | TEST_F(KeyPress, SendKeyboardIsNotCalledWhenNoKeyIsPressed) { |
| 39 | TestDriver driver; | 39 | TestDriver driver; |
| 40 | EXPECT_CALL(driver, keyboard_leds_mock()).WillRepeatedly(Return(0)); | ||
| 41 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | 40 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); |
| 42 | keyboard_task(); | 41 | keyboard_task(); |
| 43 | } | 42 | } |
| @@ -45,7 +44,6 @@ TEST_F(KeyPress, SendKeyboardIsNotCalledWhenNoKeyIsPressed) { | |||
| 45 | TEST_F(KeyPress, CorrectKeyIsReportedWhenPressed) { | 44 | TEST_F(KeyPress, CorrectKeyIsReportedWhenPressed) { |
| 46 | TestDriver driver; | 45 | TestDriver driver; |
| 47 | press_key(0, 0); | 46 | press_key(0, 0); |
| 48 | EXPECT_CALL(driver, keyboard_leds_mock()).WillRepeatedly(Return(0)); | ||
| 49 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_A))); | 47 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_A))); |
| 50 | keyboard_task(); | 48 | keyboard_task(); |
| 51 | } | 49 | } |
| @@ -54,7 +52,6 @@ TEST_F(KeyPress, CorrectKeysAreReportedWhenTwoKeysArePressed) { | |||
| 54 | TestDriver driver; | 52 | TestDriver driver; |
| 55 | press_key(1, 0); | 53 | press_key(1, 0); |
| 56 | press_key(0, 1); | 54 | press_key(0, 1); |
| 57 | EXPECT_CALL(driver, keyboard_leds_mock()).WillRepeatedly(Return(0)); | ||
| 58 | //Note that QMK only processes one key at a time | 55 | //Note that QMK only processes one key at a time |
| 59 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_B))); | 56 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_B))); |
| 60 | keyboard_task(); | 57 | keyboard_task(); |
diff --git a/tests/test_common/test_driver.cpp b/tests/test_common/test_driver.cpp index 9e618aa97..feb80563a 100644 --- a/tests/test_common/test_driver.cpp +++ b/tests/test_common/test_driver.cpp | |||
| @@ -27,7 +27,6 @@ TestDriver::TestDriver() | |||
| 27 | &TestDriver::send_consumer | 27 | &TestDriver::send_consumer |
| 28 | } | 28 | } |
| 29 | { | 29 | { |
| 30 | |||
| 31 | host_set_driver(&m_driver); | 30 | host_set_driver(&m_driver); |
| 32 | m_this = this; | 31 | m_this = this; |
| 33 | } | 32 | } |
| @@ -37,7 +36,7 @@ TestDriver::~TestDriver() { | |||
| 37 | } | 36 | } |
| 38 | 37 | ||
| 39 | uint8_t TestDriver::keyboard_leds(void) { | 38 | uint8_t TestDriver::keyboard_leds(void) { |
| 40 | return m_this->keyboard_leds_mock(); | 39 | return m_this->m_leds; |
| 41 | } | 40 | } |
| 42 | 41 | ||
| 43 | void TestDriver::send_keyboard(report_keyboard_t* report) { | 42 | void TestDriver::send_keyboard(report_keyboard_t* report) { |
diff --git a/tests/test_common/test_driver.h b/tests/test_common/test_driver.h index b1b95fbcc..0123fd539 100644 --- a/tests/test_common/test_driver.h +++ b/tests/test_common/test_driver.h | |||
| @@ -27,7 +27,8 @@ class TestDriver { | |||
| 27 | public: | 27 | public: |
| 28 | TestDriver(); | 28 | TestDriver(); |
| 29 | ~TestDriver(); | 29 | ~TestDriver(); |
| 30 | MOCK_METHOD0(keyboard_leds_mock, uint8_t ()); | 30 | void set_leds(uint8_t leds) { m_leds = leds; } |
| 31 | |||
| 31 | MOCK_METHOD1(send_keyboard_mock, void (report_keyboard_t&)); | 32 | MOCK_METHOD1(send_keyboard_mock, void (report_keyboard_t&)); |
| 32 | MOCK_METHOD1(send_mouse_mock, void (report_mouse_t&)); | 33 | MOCK_METHOD1(send_mouse_mock, void (report_mouse_t&)); |
| 33 | MOCK_METHOD1(send_system_mock, void (uint16_t)); | 34 | MOCK_METHOD1(send_system_mock, void (uint16_t)); |
| @@ -39,6 +40,7 @@ private: | |||
| 39 | static void send_system(uint16_t data); | 40 | static void send_system(uint16_t data); |
| 40 | static void send_consumer(uint16_t data); | 41 | static void send_consumer(uint16_t data); |
| 41 | host_driver_t m_driver; | 42 | host_driver_t m_driver; |
| 43 | uint8_t m_leds = 0; | ||
| 42 | static TestDriver* m_this; | 44 | static TestDriver* m_this; |
| 43 | }; | 45 | }; |
| 44 | 46 | ||
diff --git a/tests/test_common/test_fixture.cpp b/tests/test_common/test_fixture.cpp index aff518d21..eef9b854b 100644 --- a/tests/test_common/test_fixture.cpp +++ b/tests/test_common/test_fixture.cpp | |||
| @@ -27,12 +27,10 @@ TestFixture::~TestFixture() { | |||
| 27 | // Run for a while to make sure all keys are completely released | 27 | // Run for a while to make sure all keys are completely released |
| 28 | // Should probably wait until tapping term etc, has timed out | 28 | // Should probably wait until tapping term etc, has timed out |
| 29 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(AnyNumber()); | 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++) { | 30 | for (int i=0; i<100; i++) { |
| 32 | keyboard_task(); | 31 | keyboard_task(); |
| 33 | } | 32 | } |
| 34 | testing::Mock::VerifyAndClearExpectations(&driver); | 33 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 35 | // Verify that the matrix really is cleared | 34 | // Verify that the matrix really is cleared |
| 36 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).Times(Between(0, 1)); | 35 | 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 | 36 | } \ No newline at end of file |
