diff options
| author | Fred Sundvik <fsundvik@gmail.com> | 2017-06-16 23:50:44 +0300 |
|---|---|---|
| committer | Fred Sundvik <fsundvik@gmail.com> | 2017-06-18 21:22:22 +0300 |
| commit | 3bb0586acc6472380365d78ee81a332aca468239 (patch) | |
| tree | d8b4e194d9f39216e53e9aaa4b944679dfa567f3 /tests/basic | |
| parent | 617578399cf1a0fff70ceeb21d63a06524c801a3 (diff) | |
| download | qmk_firmware-3bb0586acc6472380365d78ee81a332aca468239.tar.gz qmk_firmware-3bb0586acc6472380365d78ee81a332aca468239.zip | |
Add a couple of basic tests and implement driver mock
Diffstat (limited to 'tests/basic')
| -rw-r--r-- | tests/basic/test.cpp (renamed from tests/basic/test.c) | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/basic/test.c b/tests/basic/test.cpp index 2afb4d6a9..ce9a0cd72 100644 --- a/tests/basic/test.c +++ b/tests/basic/test.cpp | |||
| @@ -14,7 +14,16 @@ | |||
| 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 "gtest/gtest.h" | ||
| 18 | #include "gmock/gmock.h" | ||
| 19 | |||
| 17 | #include "quantum.h" | 20 | #include "quantum.h" |
| 21 | #include "keyboard.h" | ||
| 22 | #include "test_driver.h" | ||
| 23 | #include "test_matrix.h" | ||
| 24 | |||
| 25 | using testing::_; | ||
| 26 | using testing::Return; | ||
| 18 | 27 | ||
| 19 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | 28 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { |
| 20 | [0] = { | 29 | [0] = { |
| @@ -22,3 +31,20 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | |||
| 22 | {KC_C, KC_D} | 31 | {KC_C, KC_D} |
| 23 | }, | 32 | }, |
| 24 | }; | 33 | }; |
| 34 | |||
| 35 | TEST(Basic, SendKeyboardIsNotCalledWhenNoKeyIsPressed) { | ||
| 36 | keyboard_init(); | ||
| 37 | TestDriver driver; | ||
| 38 | EXPECT_CALL(driver, keyboard_leds_mock()).WillRepeatedly(Return(0)); | ||
| 39 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | ||
| 40 | keyboard_task(); | ||
| 41 | } | ||
| 42 | |||
| 43 | TEST(Basic, SendKeyboardIsCalledWhenAKeyIsPressed) { | ||
| 44 | keyboard_init(); | ||
| 45 | TestDriver driver; | ||
| 46 | press_key(0, 0); | ||
| 47 | EXPECT_CALL(driver, keyboard_leds_mock()).WillRepeatedly(Return(0)); | ||
| 48 | EXPECT_CALL(driver, send_keyboard_mock(_)); | ||
| 49 | keyboard_task(); | ||
| 50 | } | ||
