diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/basic/keymap.c | 26 | ||||
-rw-r--r-- | tests/basic/test_keypress.cpp | 6 | ||||
-rw-r--r-- | tests/basic/test_macro.cpp | 94 | ||||
-rw-r--r-- | tests/test_common/keyboard_report_util.cpp | 62 | ||||
-rw-r--r-- | tests/test_common/matrix.c | 32 | ||||
-rw-r--r-- | tests/test_common/test_driver.cpp | 35 | ||||
-rw-r--r-- | tests/test_common/test_fixture.cpp | 14 |
7 files changed, 98 insertions, 171 deletions
diff --git a/tests/basic/keymap.c b/tests/basic/keymap.c index 5dd9aaeb6..02b3cc961 100644 --- a/tests/basic/keymap.c +++ b/tests/basic/keymap.c | |||
@@ -21,22 +21,24 @@ | |||
21 | 21 | ||
22 | #define COMBO1 RSFT(LCTL(KC_O)) | 22 | #define COMBO1 RSFT(LCTL(KC_O)) |
23 | 23 | ||
24 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | 24 | const uint16_t PROGMEM |
25 | [0] = { | 25 | keymaps[][MATRIX_ROWS][MATRIX_COLS] = |
26 | // 0 1 2 3 4 5 6 7 8 9 | 26 | { |
27 | {KC_A, KC_B, KC_NO, KC_LSFT, KC_RSFT, KC_LCTL, COMBO1, SFT_T(KC_P), M(0), KC_NO}, | 27 | [0] = |
28 | {KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO}, | 28 | { |
29 | {KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO}, | 29 | // 0 1 2 3 4 5 6 7 8 9 |
30 | {KC_C, KC_D, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO}, | 30 | {KC_A, KC_B, KC_NO, KC_LSFT, KC_RSFT, KC_LCTL, COMBO1, SFT_T(KC_P), M(0), KC_NO}, |
31 | }, | 31 | {KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO}, |
32 | {KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO}, | ||
33 | {KC_C, KC_D, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO}, | ||
34 | }, | ||
32 | }; | 35 | }; |
33 | 36 | ||
34 | const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) { | 37 | const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) { |
35 | if (record->event.pressed) { | 38 | if (record->event.pressed) { |
36 | switch(id) { | 39 | switch (id) { |
37 | case 0: | 40 | case 0: |
38 | return MACRO(D(LSFT), T(H), U(LSFT), T(E), T(L), T(L), T(O), T(SPACE), W(100), | 41 | return MACRO(D(LSFT), T(H), U(LSFT), T(E), T(L), T(L), T(O), T(SPACE), W(100), D(LSFT), T(W), U(LSFT), I(10), T(O), T(R), T(L), T(D), D(LSFT), T(1), U(LSFT), END); |
39 | D(LSFT), T(W), U(LSFT), I(10), T(O), T(R), T(L), T(D), D(LSFT), T(1), U(LSFT), END); | ||
40 | } | 42 | } |
41 | } | 43 | } |
42 | return MACRO_NONE; | 44 | return MACRO_NONE; |
diff --git a/tests/basic/test_keypress.cpp b/tests/basic/test_keypress.cpp index 194b1745b..e5247911c 100644 --- a/tests/basic/test_keypress.cpp +++ b/tests/basic/test_keypress.cpp | |||
@@ -41,15 +41,15 @@ TEST_F(KeyPress, CorrectKeysAreReportedWhenTwoKeysArePressed) { | |||
41 | TestDriver driver; | 41 | TestDriver driver; |
42 | press_key(1, 0); | 42 | press_key(1, 0); |
43 | press_key(0, 3); | 43 | press_key(0, 3); |
44 | //Note that QMK only processes one key at a time | 44 | // Note that QMK only processes one key at a time |
45 | //See issue #1476 for more information | 45 | // See issue #1476 for more information |
46 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_B))); | 46 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_B))); |
47 | keyboard_task(); | 47 | keyboard_task(); |
48 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_B, KC_C))); | 48 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_B, KC_C))); |
49 | keyboard_task(); | 49 | keyboard_task(); |
50 | release_key(1, 0); | 50 | release_key(1, 0); |
51 | release_key(0, 3); | 51 | release_key(0, 3); |
52 | //Note that the first key released is the first one in the matrix order | 52 | // Note that the first key released is the first one in the matrix order |
53 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_C))); | 53 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_C))); |
54 | keyboard_task(); | 54 | keyboard_task(); |
55 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())); | 55 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())); |
diff --git a/tests/basic/test_macro.cpp b/tests/basic/test_macro.cpp index 80676d515..a1fa31708 100644 --- a/tests/basic/test_macro.cpp +++ b/tests/basic/test_macro.cpp | |||
@@ -22,78 +22,50 @@ using testing::InvokeWithoutArgs; | |||
22 | 22 | ||
23 | class Macro : public TestFixture {}; | 23 | class Macro : public TestFixture {}; |
24 | 24 | ||
25 | #define AT_TIME(t) WillOnce(InvokeWithoutArgs([current_time]() {EXPECT_EQ(timer_elapsed32(current_time), t);})) | 25 | #define AT_TIME(t) WillOnce(InvokeWithoutArgs([current_time]() { EXPECT_EQ(timer_elapsed32(current_time), t); })) |
26 | 26 | ||
27 | TEST_F(Macro, PlayASimpleMacro) { | 27 | TEST_F(Macro, PlayASimpleMacro) { |
28 | TestDriver driver; | 28 | TestDriver driver; |
29 | InSequence s; | 29 | InSequence s; |
30 | press_key(8, 0); | 30 | press_key(8, 0); |
31 | uint32_t current_time = timer_read32(); | 31 | uint32_t current_time = timer_read32(); |
32 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT))) | 32 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT))).AT_TIME(0); |
33 | .AT_TIME(0); | 33 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT, KC_H))).AT_TIME(0); |
34 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT, KC_H))) | 34 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT))).AT_TIME(0); |
35 | .AT_TIME(0); | 35 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).AT_TIME(0); |
36 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT))) | 36 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_E))).AT_TIME(0); |
37 | .AT_TIME(0); | ||
38 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())) | ||
39 | .AT_TIME(0); | ||
40 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_E))) | ||
41 | .AT_TIME(0); | ||
42 | // The macro system could actually skip these empty keyboard reports | 37 | // The macro system could actually skip these empty keyboard reports |
43 | // it should be enough to just send a report with the next key down | 38 | // it should be enough to just send a report with the next key down |
44 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())) | 39 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).AT_TIME(0); |
45 | .AT_TIME(0); | 40 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_L))).AT_TIME(0); |
46 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_L))) | 41 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).AT_TIME(0); |
47 | .AT_TIME(0); | 42 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_L))).AT_TIME(0); |
48 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())) | 43 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).AT_TIME(0); |
49 | .AT_TIME(0); | 44 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_O))).AT_TIME(0); |
50 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_L))) | 45 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).AT_TIME(0); |
51 | .AT_TIME(0); | 46 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_SPACE))).AT_TIME(0); |
52 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())) | 47 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).AT_TIME(0); |
53 | .AT_TIME(0); | 48 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT))).AT_TIME(100); |
54 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_O))) | 49 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT, KC_W))).AT_TIME(100); |
55 | .AT_TIME(0); | 50 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT))).AT_TIME(100); |
56 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())) | 51 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).AT_TIME(100); |
57 | .AT_TIME(0); | ||
58 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_SPACE))) | ||
59 | .AT_TIME(0); | ||
60 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())) | ||
61 | .AT_TIME(0); | ||
62 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT))) | ||
63 | .AT_TIME(100); | ||
64 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT, KC_W))) | ||
65 | .AT_TIME(100); | ||
66 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT))) | ||
67 | .AT_TIME(100); | ||
68 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())) | ||
69 | .AT_TIME(100); | ||
70 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_O))) | 52 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_O))) |
71 | // BUG: The timer should not really have advanced 10 ms here | 53 | // BUG: The timer should not really have advanced 10 ms here |
72 | // See issue #1477 | 54 | // See issue #1477 |
73 | .AT_TIME(110); | 55 | .AT_TIME(110); |
74 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())) | 56 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())) |
75 | // BUG: The timer should not advance on both keydown and key-up | 57 | // BUG: The timer should not advance on both keydown and key-up |
76 | // See issue #1477 | 58 | // See issue #1477 |
77 | .AT_TIME(120); | 59 | .AT_TIME(120); |
78 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_R))) | 60 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_R))).AT_TIME(130); |
79 | .AT_TIME(130); | 61 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).AT_TIME(140); |
80 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())) | 62 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_L))).AT_TIME(150); |
81 | .AT_TIME(140); | 63 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).AT_TIME(160); |
82 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_L))) | 64 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_D))).AT_TIME(170); |
83 | .AT_TIME(150); | 65 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).AT_TIME(180); |
84 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())) | 66 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT))).AT_TIME(190); |
85 | .AT_TIME(160); | 67 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT, KC_1))).AT_TIME(200); |
86 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_D))) | 68 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT))).AT_TIME(210); |
87 | .AT_TIME(170); | 69 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).AT_TIME(220); |
88 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())) | ||
89 | .AT_TIME(180); | ||
90 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT))) | ||
91 | .AT_TIME(190); | ||
92 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT, KC_1))) | ||
93 | .AT_TIME(200); | ||
94 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT))) | ||
95 | .AT_TIME(210); | ||
96 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())) | ||
97 | .AT_TIME(220); | ||
98 | run_one_scan_loop(); | 70 | run_one_scan_loop(); |
99 | } \ No newline at end of file | 71 | } \ No newline at end of file |
diff --git a/tests/test_common/keyboard_report_util.cpp b/tests/test_common/keyboard_report_util.cpp index bf728b9a2..245072c0e 100644 --- a/tests/test_common/keyboard_report_util.cpp +++ b/tests/test_common/keyboard_report_util.cpp | |||
@@ -14,30 +14,29 @@ | |||
14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
15 | */ | 15 | */ |
16 | 16 | ||
17 | #include "keyboard_report_util.hpp" | 17 | #include "keyboard_report_util.hpp" |
18 | #include <vector> | 18 | #include <vector> |
19 | #include <algorithm> | 19 | #include <algorithm> |
20 | using namespace testing; | 20 | using namespace testing; |
21 | 21 | ||
22 | namespace | 22 | namespace { |
23 | { | 23 | std::vector<uint8_t> get_keys(const report_keyboard_t& report) { |
24 | std::vector<uint8_t> get_keys(const report_keyboard_t& report) { | 24 | std::vector<uint8_t> result; |
25 | std::vector<uint8_t> result; | 25 | #if defined(NKRO_ENABLE) |
26 | #if defined(NKRO_ENABLE) | 26 | # error NKRO support not implemented yet |
27 | #error NKRO support not implemented yet | 27 | #elif defined(USB_6KRO_ENABLE) |
28 | #elif defined(USB_6KRO_ENABLE) | 28 | # error 6KRO support not implemented yet |
29 | #error 6KRO support not implemented yet | 29 | #else |
30 | #else | 30 | for (size_t i = 0; i < KEYBOARD_REPORT_KEYS; i++) { |
31 | for(size_t i=0; i<KEYBOARD_REPORT_KEYS; i++) { | 31 | if (report.keys[i]) { |
32 | if (report.keys[i]) { | 32 | result.emplace_back(report.keys[i]); |
33 | result.emplace_back(report.keys[i]); | ||
34 | } | ||
35 | } | 33 | } |
36 | #endif | 34 | } |
37 | std::sort(result.begin(), result.end()); | 35 | #endif |
38 | return result; | 36 | std::sort(result.begin(), result.end()); |
39 | } | 37 | return result; |
40 | } | 38 | } |
39 | } // namespace | ||
41 | 40 | ||
42 | bool operator==(const report_keyboard_t& lhs, const report_keyboard_t& rhs) { | 41 | bool operator==(const report_keyboard_t& lhs, const report_keyboard_t& rhs) { |
43 | auto lhskeys = get_keys(lhs); | 42 | auto lhskeys = get_keys(lhs); |
@@ -50,7 +49,7 @@ std::ostream& operator<<(std::ostream& stream, const report_keyboard_t& value) { | |||
50 | stream << "Mods: " << (uint32_t)value.mods << std::endl; | 49 | stream << "Mods: " << (uint32_t)value.mods << std::endl; |
51 | stream << "Keys: "; | 50 | stream << "Keys: "; |
52 | // TODO: This should probably print friendly names for the keys | 51 | // TODO: This should probably print friendly names for the keys |
53 | for (uint32_t k: get_keys(value)) { | 52 | for (uint32_t k : get_keys(value)) { |
54 | stream << k << " "; | 53 | stream << k << " "; |
55 | } | 54 | } |
56 | stream << std::endl; | 55 | stream << std::endl; |
@@ -59,24 +58,17 @@ std::ostream& operator<<(std::ostream& stream, const report_keyboard_t& value) { | |||
59 | 58 | ||
60 | KeyboardReportMatcher::KeyboardReportMatcher(const std::vector<uint8_t>& keys) { | 59 | KeyboardReportMatcher::KeyboardReportMatcher(const std::vector<uint8_t>& keys) { |
61 | memset(m_report.raw, 0, sizeof(m_report.raw)); | 60 | memset(m_report.raw, 0, sizeof(m_report.raw)); |
62 | for (auto k: keys) { | 61 | for (auto k : keys) { |
63 | if (IS_MOD(k)) { | 62 | if (IS_MOD(k)) { |
64 | m_report.mods |= MOD_BIT(k); | 63 | m_report.mods |= MOD_BIT(k); |
65 | } | 64 | } else { |
66 | else { | ||
67 | add_key_to_report(&m_report, k); | 65 | add_key_to_report(&m_report, k); |
68 | } | 66 | } |
69 | } | 67 | } |
70 | } | 68 | } |
71 | 69 | ||
72 | bool KeyboardReportMatcher::MatchAndExplain(report_keyboard_t& report, MatchResultListener* listener) const { | 70 | bool KeyboardReportMatcher::MatchAndExplain(report_keyboard_t& report, MatchResultListener* listener) const { return m_report == report; } |
73 | return m_report == report; | ||
74 | } | ||
75 | 71 | ||
76 | void KeyboardReportMatcher::DescribeTo(::std::ostream* os) const { | 72 | void KeyboardReportMatcher::DescribeTo(::std::ostream* os) const { *os << "is equal to " << m_report; } |
77 | *os << "is equal to " << m_report; | ||
78 | } | ||
79 | 73 | ||
80 | void KeyboardReportMatcher::DescribeNegationTo(::std::ostream* os) const { | 74 | void KeyboardReportMatcher::DescribeNegationTo(::std::ostream* os) const { *os << "is not equal to " << m_report; } \ No newline at end of file |
81 | *os << "is not equal to " << m_report; | ||
82 | } \ No newline at end of file | ||
diff --git a/tests/test_common/matrix.c b/tests/test_common/matrix.c index 4b501039b..9a92a801c 100644 --- a/tests/test_common/matrix.c +++ b/tests/test_common/matrix.c | |||
@@ -14,7 +14,6 @@ | |||
14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
15 | */ | 15 | */ |
16 | 16 | ||
17 | |||
18 | #include "matrix.h" | 17 | #include "matrix.h" |
19 | #include "test_matrix.h" | 18 | #include "test_matrix.h" |
20 | #include <string.h> | 19 | #include <string.h> |
@@ -31,33 +30,18 @@ uint8_t matrix_scan(void) { | |||
31 | return 1; | 30 | return 1; |
32 | } | 31 | } |
33 | 32 | ||
34 | matrix_row_t matrix_get_row(uint8_t row) { | 33 | matrix_row_t matrix_get_row(uint8_t row) { return matrix[row]; } |
35 | return matrix[row]; | ||
36 | } | ||
37 | |||
38 | void matrix_print(void) { | ||
39 | |||
40 | } | ||
41 | |||
42 | void matrix_init_kb(void) { | ||
43 | 34 | ||
44 | } | 35 | void matrix_print(void) {} |
45 | 36 | ||
46 | void matrix_scan_kb(void) { | 37 | void matrix_init_kb(void) {} |
47 | 38 | ||
48 | } | 39 | void matrix_scan_kb(void) {} |
49 | 40 | ||
50 | void press_key(uint8_t col, uint8_t row) { | 41 | void press_key(uint8_t col, uint8_t row) { matrix[row] |= 1 << col; } |
51 | matrix[row] |= 1 << col; | ||
52 | } | ||
53 | 42 | ||
54 | void release_key(uint8_t col, uint8_t row) { | 43 | void release_key(uint8_t col, uint8_t row) { matrix[row] &= ~(1 << col); } |
55 | matrix[row] &= ~(1 << col); | ||
56 | } | ||
57 | 44 | ||
58 | void clear_all_keys(void) { | 45 | void clear_all_keys(void) { memset(matrix, 0, sizeof(matrix)); } |
59 | memset(matrix, 0, sizeof(matrix)); | ||
60 | } | ||
61 | 46 | ||
62 | void led_set(uint8_t usb_led) { | 47 | void led_set(uint8_t usb_led) {} |
63 | } | ||
diff --git a/tests/test_common/test_driver.cpp b/tests/test_common/test_driver.cpp index 511309969..84e249d83 100644 --- a/tests/test_common/test_driver.cpp +++ b/tests/test_common/test_driver.cpp | |||
@@ -18,40 +18,19 @@ | |||
18 | 18 | ||
19 | TestDriver* TestDriver::m_this = nullptr; | 19 | TestDriver* TestDriver::m_this = nullptr; |
20 | 20 | ||
21 | TestDriver::TestDriver() | 21 | TestDriver::TestDriver() : m_driver{&TestDriver::keyboard_leds, &TestDriver::send_keyboard, &TestDriver::send_mouse, &TestDriver::send_system, &TestDriver::send_consumer} { |
22 | : m_driver{ | ||
23 | &TestDriver::keyboard_leds, | ||
24 | &TestDriver::send_keyboard, | ||
25 | &TestDriver::send_mouse, | ||
26 | &TestDriver::send_system, | ||
27 | &TestDriver::send_consumer | ||
28 | } | ||
29 | { | ||
30 | host_set_driver(&m_driver); | 22 | host_set_driver(&m_driver); |
31 | m_this = this; | 23 | m_this = this; |
32 | } | 24 | } |
33 | 25 | ||
34 | TestDriver::~TestDriver() { | 26 | TestDriver::~TestDriver() { m_this = nullptr; } |
35 | m_this = nullptr; | ||
36 | } | ||
37 | 27 | ||
38 | uint8_t TestDriver::keyboard_leds(void) { | 28 | uint8_t TestDriver::keyboard_leds(void) { return m_this->m_leds; } |
39 | return m_this->m_leds; | ||
40 | } | ||
41 | 29 | ||
42 | void TestDriver::send_keyboard(report_keyboard_t* report) { | 30 | void TestDriver::send_keyboard(report_keyboard_t* report) { m_this->send_keyboard_mock(*report); } |
43 | m_this->send_keyboard_mock(*report); | ||
44 | 31 | ||
45 | } | 32 | void TestDriver::send_mouse(report_mouse_t* report) { m_this->send_mouse_mock(*report); } |
46 | 33 | ||
47 | void TestDriver::send_mouse(report_mouse_t* report) { | 34 | void TestDriver::send_system(uint16_t data) { m_this->send_system_mock(data); } |
48 | m_this->send_mouse_mock(*report); | ||
49 | } | ||
50 | 35 | ||
51 | void TestDriver::send_system(uint16_t data) { | 36 | void TestDriver::send_consumer(uint16_t data) { m_this->send_consumer(data); } |
52 | m_this->send_system_mock(data); | ||
53 | } | ||
54 | |||
55 | void TestDriver::send_consumer(uint16_t data) { | ||
56 | m_this->send_consumer(data); | ||
57 | } | ||
diff --git a/tests/test_common/test_fixture.cpp b/tests/test_common/test_fixture.cpp index d86681eea..8caf1fca4 100644 --- a/tests/test_common/test_fixture.cpp +++ b/tests/test_common/test_fixture.cpp | |||
@@ -11,14 +11,14 @@ extern "C" { | |||
11 | } | 11 | } |
12 | 12 | ||
13 | extern "C" { | 13 | extern "C" { |
14 | void set_time(uint32_t t); | 14 | void set_time(uint32_t t); |
15 | void advance_time(uint32_t ms); | 15 | void advance_time(uint32_t ms); |
16 | } | 16 | } |
17 | 17 | ||
18 | using testing::_; | 18 | using testing::_; |
19 | using testing::AnyNumber; | 19 | using testing::AnyNumber; |
20 | using testing::Return; | ||
21 | using testing::Between; | 20 | using testing::Between; |
21 | using testing::Return; | ||
22 | 22 | ||
23 | void TestFixture::SetUpTestCase() { | 23 | void TestFixture::SetUpTestCase() { |
24 | TestDriver driver; | 24 | TestDriver driver; |
@@ -26,11 +26,9 @@ void TestFixture::SetUpTestCase() { | |||
26 | keyboard_init(); | 26 | keyboard_init(); |
27 | } | 27 | } |
28 | 28 | ||
29 | void TestFixture::TearDownTestCase() { | 29 | void TestFixture::TearDownTestCase() {} |
30 | } | ||
31 | 30 | ||
32 | TestFixture::TestFixture() { | 31 | TestFixture::TestFixture() {} |
33 | } | ||
34 | 32 | ||
35 | TestFixture::~TestFixture() { | 33 | TestFixture::~TestFixture() { |
36 | TestDriver driver; | 34 | TestDriver driver; |
@@ -50,7 +48,7 @@ void TestFixture::run_one_scan_loop() { | |||
50 | } | 48 | } |
51 | 49 | ||
52 | void TestFixture::idle_for(unsigned time) { | 50 | void TestFixture::idle_for(unsigned time) { |
53 | for (unsigned i=0; i<time; i++) { | 51 | for (unsigned i = 0; i < time; i++) { |
54 | run_one_scan_loop(); | 52 | run_one_scan_loop(); |
55 | } | 53 | } |
56 | } | 54 | } |