chore: remove Singleton & replace getIApp with getApp (#5514)
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
#pragma once
|
||||
|
||||
#include "mocks/DisabledStreamerMode.hpp"
|
||||
#include "mocks/EmptyApplication.hpp"
|
||||
#include "singletons/Settings.hpp"
|
||||
|
||||
#include <QString>
|
||||
|
||||
namespace chatterino::mock {
|
||||
|
||||
/**
|
||||
* BaseApplication intends to be a mock application with a few more sane defaults, but with less configurability
|
||||
*/
|
||||
class BaseApplication : public EmptyApplication
|
||||
{
|
||||
public:
|
||||
BaseApplication()
|
||||
: settings(this->settingsDir.filePath("settings.json"))
|
||||
{
|
||||
}
|
||||
|
||||
explicit BaseApplication(const QString &settingsData)
|
||||
: EmptyApplication(settingsData)
|
||||
, settings(this->settingsDir.filePath("settings.json"))
|
||||
{
|
||||
}
|
||||
|
||||
IStreamerMode *getStreamerMode() override
|
||||
{
|
||||
return &this->streamerMode;
|
||||
}
|
||||
|
||||
Settings settings;
|
||||
DisabledStreamerMode streamerMode;
|
||||
};
|
||||
|
||||
} // namespace chatterino::mock
|
||||
@@ -17,7 +17,17 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~EmptyApplication() = default;
|
||||
explicit EmptyApplication(const QString &settingsData)
|
||||
: EmptyApplication()
|
||||
{
|
||||
QFile settingsFile(this->settingsDir.filePath("settings.json"));
|
||||
settingsFile.open(QIODevice::WriteOnly | QIODevice::Text);
|
||||
settingsFile.write(settingsData.toUtf8());
|
||||
settingsFile.flush();
|
||||
settingsFile.close();
|
||||
}
|
||||
|
||||
~EmptyApplication() override = default;
|
||||
|
||||
bool isTest() const override
|
||||
{
|
||||
@@ -249,7 +259,6 @@ public:
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
protected:
|
||||
QTemporaryDir settingsDir;
|
||||
Paths paths_;
|
||||
Args args_;
|
||||
|
||||
Reference in New Issue
Block a user