|
|
|
|
@@ -18,13 +18,14 @@
|
|
|
|
|
#include "input/IEventNotifier.h"
|
|
|
|
|
#include "input/DistributingEvent.h"
|
|
|
|
|
#include "input/Detector.h"
|
|
|
|
|
#include "utilities/LoggerFactory.h"
|
|
|
|
|
#include "utilities/InputGPIOInterface.h"
|
|
|
|
|
#include "utility/LoggerFactory.h"
|
|
|
|
|
#include "utility/InputGPIOInterface.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
using namespace fakeit;
|
|
|
|
|
using namespace FlippR_Driver;
|
|
|
|
|
using namespace Input;
|
|
|
|
|
using namespace utility;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SCENARIO("Creating a Detector object", "")
|
|
|
|
|
@@ -42,11 +43,11 @@ SCENARIO("Creating a Detector object", "")
|
|
|
|
|
Fake(Dtor(event_notifier_mock));
|
|
|
|
|
When(Method(event_notifier_mock, distribute_event)).AlwaysReturn();
|
|
|
|
|
|
|
|
|
|
std::map<char, std::shared_ptr<DistributingEvent>> events;
|
|
|
|
|
std::vector<std::shared_ptr<DistributingEvent>> events;
|
|
|
|
|
|
|
|
|
|
WHEN("Detector is created")
|
|
|
|
|
{
|
|
|
|
|
Detector detector(std::unique_ptr<IInputGPIOInterface>(&gpio_interface_mock.get()), events, std::shared_ptr<IEventNotifier>(&event_notifier_mock.get()));
|
|
|
|
|
Detector detector(std::unique_ptr<IInputGPIOInterface>(&gpio_interface_mock.get()), events);
|
|
|
|
|
THEN("a thread should be created")
|
|
|
|
|
{
|
|
|
|
|
REQUIRE(typeid(detector.detect_thread).hash_code() == typeid(std::thread).hash_code());
|
|
|
|
|
@@ -75,16 +76,16 @@ SCENARIO("There are events at the input", "")
|
|
|
|
|
DistributingEvent event2(2, '2', "event 2", std::chrono::milliseconds(0), event_notifier);
|
|
|
|
|
DistributingEvent event3(3, '3', "event 3", std::chrono::milliseconds(0), event_notifier);
|
|
|
|
|
|
|
|
|
|
std::map<char, std::shared_ptr<DistributingEvent>> events;
|
|
|
|
|
std::vector<std::shared_ptr<DistributingEvent>> events;
|
|
|
|
|
|
|
|
|
|
auto event2ptr = std::make_shared<DistributingEvent>(event2);
|
|
|
|
|
events.insert(std::make_pair(1, std::make_shared<DistributingEvent>(event1)));
|
|
|
|
|
events.insert(std::make_pair(2, event2ptr));
|
|
|
|
|
events.insert(std::make_pair(3, std::make_shared<DistributingEvent>(event3)));
|
|
|
|
|
events.push_back(std::make_shared<DistributingEvent>(event1));
|
|
|
|
|
events.push_back(event2ptr);
|
|
|
|
|
events.push_back(std::make_shared<DistributingEvent>(event3));
|
|
|
|
|
|
|
|
|
|
WHEN("an event can be found at gpio interface")
|
|
|
|
|
{
|
|
|
|
|
Detector detector(std::unique_ptr<IInputGPIOInterface>(&gpio_interface_mock.get()), events, std::shared_ptr<IEventNotifier>(&event_notifier_mock.get()));
|
|
|
|
|
Detector detector(std::unique_ptr<IInputGPIOInterface>(&gpio_interface_mock.get()), events);
|
|
|
|
|
std::this_thread::sleep_for(std::chrono::milliseconds(50));
|
|
|
|
|
THEN("the event should be distributed")
|
|
|
|
|
{
|
|
|
|
|
@@ -116,15 +117,15 @@ SCENARIO("There are events at the input but no suitable event in map", "")
|
|
|
|
|
DistributingEvent event2(2, '2', "event 2", std::chrono::milliseconds(0), event_notifier);
|
|
|
|
|
DistributingEvent event3(3, '3', "event 3", std::chrono::milliseconds(0), event_notifier);
|
|
|
|
|
|
|
|
|
|
std::map<char, std::shared_ptr<DistributingEvent>> events;
|
|
|
|
|
std::vector<std::shared_ptr<DistributingEvent>> events;
|
|
|
|
|
|
|
|
|
|
events.insert(std::make_pair(1, std::make_shared<DistributingEvent>(event1)));
|
|
|
|
|
events.insert(std::make_pair(2, std::make_shared<DistributingEvent>(event2)));
|
|
|
|
|
events.insert(std::make_pair(3, std::make_shared<DistributingEvent>(event3)));
|
|
|
|
|
events.push_back(std::make_shared<DistributingEvent>(event1));
|
|
|
|
|
events.push_back(std::make_shared<DistributingEvent>(event2));
|
|
|
|
|
events.push_back(std::make_shared<DistributingEvent>(event3));
|
|
|
|
|
|
|
|
|
|
WHEN("an event can be found at gpio interface")
|
|
|
|
|
{
|
|
|
|
|
Detector detector(std::unique_ptr<IInputGPIOInterface>(&gpio_interface_mock.get()), events, std::shared_ptr<IEventNotifier>(&event_notifier_mock.get()));
|
|
|
|
|
Detector detector(std::unique_ptr<IInputGPIOInterface>(&gpio_interface_mock.get()), events);
|
|
|
|
|
std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
|
|
|
|
THEN("the event should be distributed")
|
|
|
|
|
{
|
|
|
|
|
|