Skip to content

Commit 65fc226

Browse files
committed
Simplify test by using a fake for Presenter.
The functionality of the Presenter has not been tested anyways.
1 parent 1541f4c commit 65fc226

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

Diff for: test/hmi/test_hmi/test_hmi.cpp

+6-13
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,21 @@
1212
#include <thread>
1313
#include <unity.h>
1414
#include <user_interaction/IKeypad.hpp>
15-
#include <user_interaction/Menu.hpp>
16-
#include <user_interaction/Presenter.hpp>
15+
#include <user_interaction/IPresenter.hpp>
1716
#include <user_interaction/ProcessHmiInputs.hpp>
18-
#include <user_interaction/guiEngine_factory_interface.hpp>
1917
#include <user_interaction/keypad_factory_interface.hpp>
20-
#include <user_interaction/statusindicators_factory_interface.hpp>
2118

2219
using namespace std::chrono_literals;
2320
using namespace fakeit;
2421

2522
// mocks
2623

27-
namespace board
24+
IPresenter &getFakePresenter()
2825
{
29-
IDisplay &getGuiEngine()
30-
{
31-
Mock<IDisplay> fakeDisplay;
32-
return fakeDisplay.get();
26+
static Mock<IPresenter> fakePresenter;
27+
When(Method(fakePresenter, setTaskStatusIndicator)).AlwaysReturn();
28+
return fakePresenter.get();
3329
}
34-
} // namespace board
3530

3631
namespace serial_port
3732
{
@@ -55,9 +50,7 @@ void test_Controller()
5550
Fake(Method(ArduinoFake(), tone));
5651

5752
// get collaborator objects
58-
Menu singleMenu(board::getGuiEngine(), board::getKeypad());
59-
Presenter presenter(singleMenu, board::getStatusIndicators());
60-
ProcessHmiInputs processor(presenter, board::getKeypad());
53+
ProcessHmiInputs processor(getFakePresenter(), board::getKeypad());
6154
auto &task1 = std::begin(device::tasks)->second; // we are going to test for task 1
6255

6356
When(Method(ArduinoFake(), digitalRead).Using(board::button::pin::task1)).Return(LOW); // set task 1 button to low

0 commit comments

Comments
 (0)