seperated logger & mocked destructors
This commit is contained in:
@@ -8,6 +8,8 @@
|
|||||||
|
|
||||||
#include "InputDriverFactory.h"
|
#include "InputDriverFactory.h"
|
||||||
|
|
||||||
|
#include "../utilities/LoggerFactory.hpp"
|
||||||
|
|
||||||
#include "EventNotifier.h"
|
#include "EventNotifier.h"
|
||||||
|
|
||||||
using namespace nlohmann;
|
using namespace nlohmann;
|
||||||
@@ -66,13 +68,5 @@ std::map<char, Event> InputDriverFactory::create_input_events(json matrix_config
|
|||||||
|
|
||||||
void InputDriverFactory::ConfigureLogger()
|
void InputDriverFactory::ConfigureLogger()
|
||||||
{
|
{
|
||||||
el::Loggers::getLogger(INPUT_LOGGER);
|
LoggerFactory::CreateInputLogger();
|
||||||
|
|
||||||
//TODO may configure?
|
|
||||||
el::Configurations conf;
|
|
||||||
conf.setToDefault();
|
|
||||||
conf.set(el::Level::Global, el::ConfigurationType::Filename, DRIVER_LOG_FILE);
|
|
||||||
conf.set(el::Level::Global, el::ConfigurationType::Format, "%datetime [%level] [%func] : %msg");
|
|
||||||
|
|
||||||
el::Loggers::reconfigureLogger(INPUT_LOGGER, conf);
|
|
||||||
}
|
}
|
||||||
|
|||||||
32
FlippR-Driver/src/utilities/LoggerFactory.hpp
Normal file
32
FlippR-Driver/src/utilities/LoggerFactory.hpp
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
/*
|
||||||
|
* LoggerFactory.hpp
|
||||||
|
*
|
||||||
|
* Created on: Jun 19, 2018
|
||||||
|
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert, Rafael Vinci, Dr. Franca Rupprecht
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SRC_UTILITIES_LOGGERFACTORY_HPP_
|
||||||
|
#define SRC_UTILITIES_LOGGERFACTORY_HPP_
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
class LoggerFactory
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static void CreateInputLogger()
|
||||||
|
{
|
||||||
|
el::Loggers::getLogger(INPUT_LOGGER);
|
||||||
|
|
||||||
|
//TODO may configure?
|
||||||
|
el::Configurations conf;
|
||||||
|
conf.setToDefault();
|
||||||
|
conf.set(el::Level::Global, el::ConfigurationType::Filename, DRIVER_LOG_FILE);
|
||||||
|
conf.set(el::Level::Global, el::ConfigurationType::Format, "%datetime [%level] [%func] : %msg");
|
||||||
|
|
||||||
|
el::Loggers::reconfigureLogger(INPUT_LOGGER, conf);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* SRC_UTILITIES_LOGGERFACTORY_HPP_ */
|
||||||
@@ -10,10 +10,9 @@
|
|||||||
|
|
||||||
#define private public
|
#define private public
|
||||||
|
|
||||||
#include "../../src/utilities/config.h"
|
#include "../../src/utilities/LoggerFactory.hpp"
|
||||||
#include "../../src/input/InputDriver.h"
|
#include "../../src/input/InputDriver.h"
|
||||||
|
|
||||||
#include "../../src/input/Event.h"
|
|
||||||
#include "../../src/input/IEventNotifier.h"
|
#include "../../src/input/IEventNotifier.h"
|
||||||
#include "../../src/input/IDetector.h"
|
#include "../../src/input/IDetector.h"
|
||||||
|
|
||||||
@@ -24,10 +23,15 @@ SCENARIO("An InputDriver gets created", "[construction}")
|
|||||||
{
|
{
|
||||||
GIVEN("An EventNotifier")
|
GIVEN("An EventNotifier")
|
||||||
{
|
{
|
||||||
|
LoggerFactory::CreateInputLogger();
|
||||||
|
|
||||||
Mock<Input::IDetector> detector_mock;
|
Mock<Input::IDetector> detector_mock;
|
||||||
|
When(Dtor(detector_mock)).AlwaysReturn();
|
||||||
|
|
||||||
Mock<Input::IEventNotifier> event_notifier_mock;
|
Mock<Input::IEventNotifier> event_notifier_mock;
|
||||||
|
When(Dtor(event_notifier_mock)).AlwaysReturn();
|
||||||
Mock<IEventHandler> event_handler_mock;
|
Mock<IEventHandler> event_handler_mock;
|
||||||
|
When(Dtor(event_handler_mock)).AlwaysReturn();
|
||||||
|
|
||||||
WHEN("The InputDriver gets created")
|
WHEN("The InputDriver gets created")
|
||||||
{
|
{
|
||||||
@@ -45,12 +49,19 @@ SCENARIO("An EventHandler [un]registers at the driver", "[un-register]")
|
|||||||
{
|
{
|
||||||
GIVEN("An InputDriver, EventHandler and an EventNotifier")
|
GIVEN("An InputDriver, EventHandler and an EventNotifier")
|
||||||
{
|
{
|
||||||
|
LoggerFactory::CreateInputLogger();
|
||||||
|
|
||||||
Mock<Input::IDetector> detector_mock;
|
Mock<Input::IDetector> detector_mock;
|
||||||
|
When(Dtor(detector_mock)).AlwaysReturn();
|
||||||
|
|
||||||
Mock<IEventHandler> event_handler_mock;
|
Mock<IEventHandler> event_handler_mock;
|
||||||
|
When(Method(event_handler_mock, handle)).AlwaysReturn();
|
||||||
|
When(Dtor(event_handler_mock)).AlwaysReturn();
|
||||||
|
|
||||||
Mock<Input::IEventNotifier> event_notifier_mock;
|
Mock<Input::IEventNotifier> event_notifier_mock;
|
||||||
When(Method(event_notifier_mock, register_event_handler));
|
When(Method(event_notifier_mock, register_event_handler)).AlwaysReturn();
|
||||||
When(Method(event_notifier_mock, unregister_event_handler));
|
When(Method(event_notifier_mock, unregister_event_handler)).AlwaysReturn();
|
||||||
|
When(Dtor(event_notifier_mock)).AlwaysReturn();
|
||||||
|
|
||||||
Input::InputDriver input_driver(&event_notifier_mock.get(), &detector_mock.get());
|
Input::InputDriver input_driver(&event_notifier_mock.get(), &detector_mock.get());
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user