todo make tests working
This commit is contained in:
@@ -15,7 +15,7 @@ void FlippR_Driver::Input::DistributingEvent::distribute()
|
|||||||
std::chrono::milliseconds elapsed_time = std::chrono::duration_cast<std::chrono::milliseconds>(now - last_activation);
|
std::chrono::milliseconds elapsed_time = std::chrono::duration_cast<std::chrono::milliseconds>(now - last_activation);
|
||||||
if(elapsed_time > deactivation_time)
|
if(elapsed_time > deactivation_time)
|
||||||
{
|
{
|
||||||
event_notifier->distribute_event(std::shared_ptr<Event>(this)); // todo why new shared ptr?
|
event_notifier->distribute_event(*this); // todo why new shared ptr?
|
||||||
this->last_activation = now;
|
this->last_activation = now;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,9 +49,9 @@ void EventNotifier::unregister_event_handler(IEventHandler* handler)
|
|||||||
this->event_handlers.erase(handler);
|
this->event_handlers.erase(handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventNotifier::distribute_event(std::shared_ptr<Event> event)
|
void EventNotifier::distribute_event(Event &event)
|
||||||
{
|
{
|
||||||
this->event_queue->push(*event);
|
this->event_queue->push(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventNotifier::notify()
|
void EventNotifier::notify()
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ public:
|
|||||||
void register_event_handler(IEventHandler* handler);
|
void register_event_handler(IEventHandler* handler);
|
||||||
void unregister_event_handler(IEventHandler* handler);
|
void unregister_event_handler(IEventHandler* handler);
|
||||||
|
|
||||||
void distribute_event(std::shared_ptr<Event> event);
|
void distribute_event(Event &event);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void notify();
|
void notify();
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ public:
|
|||||||
virtual void register_event_handler(IEventHandler* handler) = 0;
|
virtual void register_event_handler(IEventHandler* handler) = 0;
|
||||||
virtual void unregister_event_handler(IEventHandler* handler) = 0;
|
virtual void unregister_event_handler(IEventHandler* handler) = 0;
|
||||||
|
|
||||||
virtual void distribute_event(std::shared_ptr<Event> event) = 0;
|
virtual void distribute_event(Event &event) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -98,7 +98,6 @@ SCENARIO("An event should be distributed", "[distribute]")
|
|||||||
GIVEN("An event")
|
GIVEN("An event")
|
||||||
{
|
{
|
||||||
Event event(0, 0, "test");
|
Event event(0, 0, "test");
|
||||||
auto event_ptr = std::make_shared<Event>(event);
|
|
||||||
|
|
||||||
Mock<IBlockingQueue<Event>> queue_mock;
|
Mock<IBlockingQueue<Event>> queue_mock;
|
||||||
Fake(Method(queue_mock, push));
|
Fake(Method(queue_mock, push));
|
||||||
@@ -109,7 +108,7 @@ SCENARIO("An event should be distributed", "[distribute]")
|
|||||||
|
|
||||||
WHEN("The event comes in")
|
WHEN("The event comes in")
|
||||||
{
|
{
|
||||||
notifier.distribute_event(event_ptr);
|
notifier.distribute_event(event);
|
||||||
THEN("The event gets queued")
|
THEN("The event gets queued")
|
||||||
{
|
{
|
||||||
notifier.is_running = false;
|
notifier.is_running = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user