summaryrefslogtreecommitdiff
path: root/tests/test_common
diff options
context:
space:
mode:
authorFred Sundvik <fsundvik@gmail.com>2017-06-19 00:19:09 +0300
committerFred Sundvik <fsundvik@gmail.com>2017-06-19 00:19:09 +0300
commit43d8fa5bf1248ce5c1ce5f9cb0d238d794b4475d (patch)
treecc98ca3ae09ef1b639de0f7b81636b8162301ca0 /tests/test_common
parent36f820be7e80bc8f1f5489373708356cf142c269 (diff)
More natural interface for setting keyboard leds
Diffstat (limited to 'tests/test_common')
-rw-r--r--tests/test_common/test_driver.cpp3
-rw-r--r--tests/test_common/test_driver.h4
-rw-r--r--tests/test_common/test_fixture.cpp2
3 files changed, 4 insertions, 5 deletions
diff --git a/tests/test_common/test_driver.cpp b/tests/test_common/test_driver.cpp
index 9e618aa978..feb80563a1 100644
--- a/tests/test_common/test_driver.cpp
+++ b/tests/test_common/test_driver.cpp
@@ -27,7 +27,6 @@ TestDriver::TestDriver()
&TestDriver::send_consumer
}
{
-
host_set_driver(&m_driver);
m_this = this;
}
@@ -37,7 +36,7 @@ TestDriver::~TestDriver() {
}
uint8_t TestDriver::keyboard_leds(void) {
- return m_this->keyboard_leds_mock();
+ return m_this->m_leds;
}
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 b1b95fbccb..0123fd539b 100644
--- a/tests/test_common/test_driver.h
+++ b/tests/test_common/test_driver.h
@@ -27,7 +27,8 @@ class TestDriver {
public:
TestDriver();
~TestDriver();
- MOCK_METHOD0(keyboard_leds_mock, uint8_t ());
+ void set_leds(uint8_t leds) { m_leds = leds; }
+
MOCK_METHOD1(send_keyboard_mock, void (report_keyboard_t&));
MOCK_METHOD1(send_mouse_mock, void (report_mouse_t&));
MOCK_METHOD1(send_system_mock, void (uint16_t));
@@ -39,6 +40,7 @@ private:
static void send_system(uint16_t data);
static void send_consumer(uint16_t data);
host_driver_t m_driver;
+ uint8_t m_leds = 0;
static TestDriver* m_this;
};
diff --git a/tests/test_common/test_fixture.cpp b/tests/test_common/test_fixture.cpp
index aff518d21e..eef9b854b7 100644
--- a/tests/test_common/test_fixture.cpp
+++ b/tests/test_common/test_fixture.cpp
@@ -27,12 +27,10 @@ TestFixture::~TestFixture() {
// Run for a while to make sure all keys are completely released
// Should probably wait until tapping term etc, has timed out
EXPECT_CALL(driver, send_keyboard_mock(_)).Times(AnyNumber());
- EXPECT_CALL(driver, keyboard_leds_mock()).WillRepeatedly(Return(0));
for (int i=0; i<100; i++) {
keyboard_task();
}
testing::Mock::VerifyAndClearExpectations(&driver);
// Verify that the matrix really is cleared
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).Times(Between(0, 1));
- EXPECT_CALL(driver, keyboard_leds_mock()).WillRepeatedly(Return(0));
} \ No newline at end of file