NOISSUE Split MultiMC app object into MultiMC and Env

This commit is contained in:
Petr Mrázek
2015-01-31 16:59:03 +01:00
parent e508728246
commit 6f3aa65bd6
44 changed files with 343 additions and 325 deletions

View File

@ -1,10 +1,6 @@
#include <QTest>
#include <QSignalSpy>
#include "logic/settings/SettingsObject.h"
#include "logic/settings/Setting.h"
#include "BuildConfig.h"
#include "TestUtil.h"
#include "logic/updater/UpdateChecker.h"
@ -24,19 +20,6 @@ QDebug operator<<(QDebug dbg, const UpdateChecker::ChannelListEntry &c)
return dbg.maybeSpace();
}
class ResetSetting
{
public:
ResetSetting(std::shared_ptr<Setting> setting) : setting(setting), oldValue(setting->get()) {}
~ResetSetting()
{
setting->set(oldValue);
}
std::shared_ptr<Setting> setting;
QVariant oldValue;
};
class UpdateCheckerTest : public QObject
{
Q_OBJECT
@ -99,7 +82,6 @@ slots:
}
void tst_ChannelListParsing()
{
ResetSetting resetUpdateChannel(MMC->settings()->getSetting("UpdateChannel"));
QFETCH(QString, channel);
QFETCH(QString, channelUrl);
@ -107,15 +89,11 @@ slots:
QFETCH(bool, valid);
QFETCH(QList<UpdateChecker::ChannelListEntry>, result);
MMC->settings()->set("UpdateChannel", channel);
UpdateChecker checker;
UpdateChecker checker(channelUrl, 0);
QSignalSpy channelListLoadedSpy(&checker, SIGNAL(channelListLoaded()));
QVERIFY(channelListLoadedSpy.isValid());
checker.setChannelListUrl(channelUrl);
checker.updateChanList(false);
if (valid)
@ -147,18 +125,12 @@ slots:
}
void tst_UpdateChecking()
{
ResetSetting resetUpdateChannel(MMC->settings()->getSetting("UpdateChannel"));
QFETCH(QString, channel);
QFETCH(QString, channelUrl);
QFETCH(int, currentBuild);
QFETCH(QList<QVariant>, result);
MMC->settings()->set("UpdateChannel", channel);
BuildConfig.VERSION_BUILD = currentBuild;
UpdateChecker checker;
checker.setChannelListUrl(channelUrl);
UpdateChecker checker(channelUrl, currentBuild);
QSignalSpy updateAvailableSpy(&checker, SIGNAL(updateAvailable(QString,QString,int)));
QVERIFY(updateAvailableSpy.isValid());
@ -170,7 +142,7 @@ slots:
checker.m_channels[0].url = QUrl::fromLocalFile(QDir::current().absoluteFilePath("tests/data/")).toString();
checker.checkForUpdate(false);
checker.checkForUpdate(channel, false);
QVERIFY(updateAvailableSpy.wait());
QList<QVariant> res = result;