File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ #include " ../test_dummies.hpp"
12#include < Arduino-wrapper.h>
3+ #include < board_pins.hpp>
24#include < input_device_interface/Keypad.hpp>
5+ #include < iostream>
36#include < unity.h>
47
58using namespace fakeit ;
69
10+ static void dummyCallback (const KeyId id)
11+ {
12+ std::cout << " dummy callback has been called with key " << id << std::endl;
13+ }
14+
715void setUp (void )
816{
17+ isr_collection.clear ();
918}
1019
1120void tearDown (void )
@@ -18,6 +27,22 @@ void test_default_inactive()
1827 TEST_ASSERT_FALSE (keypad.isKeyPressed (KeyId::TASK1));
1928}
2029
30+ void test_switch_on_off ()
31+ {
32+ Keypad keypad;
33+ keypad.setCallback (dummyCallback);
34+
35+ // set & test "active"
36+ When (Method (ArduinoFake (), digitalRead).Using (board::button::pin::task1)).Return (LOW); // set task 1 button to low
37+ changeButtonState (board::button::pin::task1); // stop task
38+ TEST_ASSERT_TRUE (keypad.isKeyPressed (KeyId::TASK1));
39+
40+ // set & test "inactive"
41+ When (Method (ArduinoFake (), digitalRead).Using (board::button::pin::task1)).Return (HIGH); // set task 1 button to high
42+ changeButtonState (board::button::pin::task1); // stop task
43+ TEST_ASSERT_FALSE (keypad.isKeyPressed (KeyId::TASK1));
44+ }
45+
2146int main ()
2247{
2348 // irrelevant test doubles
@@ -26,6 +51,7 @@ int main()
2651 UNITY_BEGIN ();
2752
2853 RUN_TEST (test_default_inactive);
54+ RUN_TEST (test_switch_on_off);
2955
3056 return UNITY_END ();
3157}
You can’t perform that action at this time.
0 commit comments