refactor: Logger is now a proper singleton
This commit is contained in:
committed by
Chris Rizzitello
parent
8256a3ba43
commit
ec9f7efcff
@ -25,6 +25,10 @@ public:
|
||||
|
||||
Q_SIGNALS:
|
||||
void newLine(const QString &line);
|
||||
|
||||
private:
|
||||
explicit Logger() = default;
|
||||
~Logger() = default;
|
||||
};
|
||||
|
||||
} // namespace deskflow::gui
|
||||
|
||||
@ -30,13 +30,11 @@ void LoggerTests::initTestCase()
|
||||
|
||||
void LoggerTests::newLine()
|
||||
{
|
||||
Logger logger;
|
||||
|
||||
QSignalSpy spy(&logger, &Logger::newLine);
|
||||
QSignalSpy spy(Logger::instance(), &Logger::newLine);
|
||||
QVERIFY(spy.isValid());
|
||||
|
||||
Settings::setValue(Settings::Log::GuiDebug, true);
|
||||
logger.handleMessage(QtDebugMsg, "stub", "test");
|
||||
Logger::instance()->handleMessage(QtDebugMsg, "stub", "test");
|
||||
|
||||
QCOMPARE(spy.count(), 1);
|
||||
QVERIFY(qvariant_cast<QString>(spy.takeFirst().at(0)).contains("test"));
|
||||
@ -45,14 +43,13 @@ void LoggerTests::newLine()
|
||||
|
||||
void LoggerTests::noNewLine()
|
||||
{
|
||||
Logger logger;
|
||||
bool newLineEmitted = false;
|
||||
|
||||
QSignalSpy spy(&logger, &Logger::newLine);
|
||||
QSignalSpy spy(Logger::instance(), &Logger::newLine);
|
||||
QVERIFY(spy.isValid());
|
||||
|
||||
Settings::setValue(Settings::Log::GuiDebug, false);
|
||||
logger.handleMessage(QtDebugMsg, "stub", "test");
|
||||
Logger::instance()->handleMessage(QtDebugMsg, "stub", "test");
|
||||
QCOMPARE(spy.count(), 0);
|
||||
QVERIFY(!newLineEmitted);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user