Skip to content
This repository has been archived by the owner on May 3, 2019. It is now read-only.

Commit

Permalink
#161 refactoring: plug in new code
Browse files Browse the repository at this point in the history
  • Loading branch information
ColinDuquesnoy committed Dec 8, 2017
1 parent efdd995 commit b5f47c8
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 16 deletions.
1 change: 1 addition & 0 deletions lib/MellowPlayer/Presentation/Qml/ContextProperties.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include "IContextProperties.hpp"
#include <QList>

namespace MellowPlayer::Presentation
{
Expand Down
6 changes: 4 additions & 2 deletions tests/Lib/TestsRunner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,16 @@ int TestsRunner::runTests(int argc, char* argv[])

DeprecatedApplicationViewModel webApplication(argc, argv, "MellowPlayer.Tests");

unique_ptr<ILoggerFactory> loggerFactory = make_unique<SpdLoggerFactory>();
SpdLoggerFactory loggerFactory;
LoggerConfig loggerConfig;
loggerConfig.createFileLogger = false;

try {
LoggingManager::instance();
assert(false);
} catch (const logic_error&) {
}
catch (const logic_error&) {

}
LoggingManager& loggingManager = LoggingManager::initialize(loggerFactory, loggerConfig);
loggingManager.setDefaultLogLevel(LogLevel::Off);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ SCENARIO("ApplicationDecoratorTests")
GIVEN("An application mock")
{
FakeApplication decorated;
ApplicationDecorator decorator(decorated);
ApplicationDecorator decorator(&decorated);

WHEN("decorated started signal is emitted")
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ SCENARIO("SingleInstance tests")
{
FakeApplication primaryDecorated;
FakeQtApplication primaryQtApplication;
SingleInstance primaryInstance(primaryDecorated,
SingleInstance primaryInstance(&primaryDecorated,
primaryQtApplication,
playerMock.get(),
commandLineArguments,
Expand All @@ -35,7 +35,7 @@ SCENARIO("SingleInstance tests")

FakeApplication secondaryDecorated;
FakeQtApplication secondaryQtApplication;
SingleInstance secondaryInstance(secondaryDecorated,
SingleInstance secondaryInstance(&secondaryDecorated,
secondaryQtApplication,
playerMock.get(),
commandLineArguments,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ SCENARIO("WithCommandLineArgumentsTests")
FakeApplication decorated;
FakeCommandLineArguments commandLineArguments;

WithCommandLineArguments commandLineArgumentsApp(decorated, commandLineArguments);
WithCommandLineArguments commandLineArgumentsApp(&decorated, commandLineArguments);

WHEN("initialize is called")
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ SCENARIO("WithLoggingTests")
{
FakeApplication decorated;
FakeCommandLineArguments commandLineArguments;
unique_ptr<ILoggerFactory> loggerFactory = make_unique<FakeLoggerFactory>();

WithLogging appWithLogging(decorated, loggerFactory, commandLineArguments);
WithLogging appWithLogging(&decorated, commandLineArguments);

WHEN("initialize is called")
{
Expand Down
14 changes: 7 additions & 7 deletions tests/UnitTests/Presentation/Qml/ContextPropertiesTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,23 @@ using namespace MellowPlayer::Presentation::Tests;

SCENARIO("ContextPropertiesTests")
{
GIVEN("A context properties instance with a fake qml application engine")
GIVEN("A context properties instance with a fake qml application engine and one property")
{
FakeQmlApplicationEngine qmlApplicationEngine;
ContextProperties contextProperties(qmlApplicationEngine);
FakeContextProperty contextProperty;
contextProperties.add(contextProperty);

WHEN("adding a context property")
WHEN("I call registerAll")
{
FakeContextProperty contextProperty;
contextProperties.registerAll();

contextProperties.add(contextProperty);

THEN("property name exists")
THEN("property name exists in qmlApplicationEngine")
{
REQUIRE(qmlApplicationEngine.hasContextProperty(contextProperty.name()));
}

THEN("the correct property has been added")
THEN("the correct property object has been added to qmlApplicationEngine")
{
REQUIRE(qmlApplicationEngine.contextProperty(contextProperty.name()) == &contextProperty);
}
Expand Down
5 changes: 5 additions & 0 deletions tests/UnitTests/Presentation/Qml/FakeContextProperties.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ namespace MellowPlayer::Presentation::Tests
return _items.contains(&contextProperty);
}

void registerAll() override
{

}

private:
QList<IContextProperty*> _items;
};
Expand Down

0 comments on commit b5f47c8

Please sign in to comment.