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

@ -91,7 +91,7 @@ slots:
void test_writeInstallScript()
{
DownloadUpdateTask task(
DownloadUpdateTask task(QCoreApplication::applicationDirPath(),
QUrl::fromLocalFile(QDir::current().absoluteFilePath("tests/data/")).toString(), 0);
DownloadUpdateTask::UpdateOperationList ops;
@ -105,7 +105,7 @@ slots:
QCOMPARE(TestsInternal::readFileUtf8(script).replace(QRegExp("[\r\n]+"), "\n"),
MULTIMC_GET_TEST_FILE_UTF8(testFile).replace(QRegExp("[\r\n]+"), "\n"));
}
// DISABLED: fails.
/*
void test_parseVersionInfo_data()
@ -166,7 +166,7 @@ slots:
QTest::addColumn<DownloadUpdateTask::VersionFileList>("newVersion");
QTest::addColumn<DownloadUpdateTask::UpdateOperationList>("expectedOperations");
DownloadUpdateTask *downloader = new DownloadUpdateTask(QString(), -1);
DownloadUpdateTask *downloader = new DownloadUpdateTask(QCoreApplication::applicationDirPath(), QString(), -1);
// update fileOne, keep fileTwo, remove fileThree
QTest::newRow("test 1")

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;