refactor: move away from UnitTest.cmake
This commit is contained in:
@ -1,5 +1,4 @@
|
||||
#include <QTest>
|
||||
#include "TestUtil.h"
|
||||
|
||||
#include "minecraft/GradleSpecifier.h"
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
#include <QTest>
|
||||
#include "TestUtil.h"
|
||||
|
||||
#include "minecraft/MojangVersionFormat.h"
|
||||
#include "minecraft/OneSixVersionFormat.h"
|
||||
@ -11,15 +10,14 @@ class LibraryTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
private:
|
||||
LibraryPtr readMojangJson(const char *file)
|
||||
LibraryPtr readMojangJson(const QString path)
|
||||
{
|
||||
auto path = QFINDTESTDATA(file);
|
||||
QFile jsonFile(path);
|
||||
jsonFile.open(QIODevice::ReadOnly);
|
||||
auto data = jsonFile.readAll();
|
||||
jsonFile.close();
|
||||
ProblemContainer problems;
|
||||
return MojangVersionFormat::libraryFromJson(problems, QJsonDocument::fromJson(data).object(), file);
|
||||
return MojangVersionFormat::libraryFromJson(problems, QJsonDocument::fromJson(data).object(), path);
|
||||
}
|
||||
// get absolute path to expected storage, assuming default cache prefix
|
||||
QStringList getStorage(QString relative)
|
||||
@ -32,7 +30,7 @@ slots:
|
||||
{
|
||||
cache.reset(new HttpMetaCache());
|
||||
cache->addBase("libraries", QDir("libraries").absolutePath());
|
||||
dataDir = QDir("data").absolutePath();
|
||||
dataDir = QDir(QFINDTESTDATA("testdata")).absolutePath();
|
||||
}
|
||||
void test_legacy()
|
||||
{
|
||||
@ -74,14 +72,14 @@ slots:
|
||||
QCOMPARE(test.isNative(), false);
|
||||
QStringList failedFiles;
|
||||
test.setHint("local");
|
||||
auto downloads = test.getDownloads(currentSystem, cache.get(), failedFiles, QString("data"));
|
||||
auto downloads = test.getDownloads(currentSystem, cache.get(), failedFiles, QFINDTESTDATA("testdata"));
|
||||
QCOMPARE(downloads.size(), 0);
|
||||
qDebug() << failedFiles;
|
||||
QCOMPARE(failedFiles.size(), 0);
|
||||
|
||||
QStringList jar, native, native32, native64;
|
||||
test.getApplicableFiles(currentSystem, jar, native, native32, native64, QString("data"));
|
||||
QCOMPARE(jar, {QFileInfo("data/codecwav-20101023.jar").absoluteFilePath()});
|
||||
test.getApplicableFiles(currentSystem, jar, native, native32, native64, QFINDTESTDATA("testdata"));
|
||||
QCOMPARE(jar, {QFileInfo(QFINDTESTDATA("testdata/codecwav-20101023.jar")).absoluteFilePath()});
|
||||
QCOMPARE(native, {});
|
||||
QCOMPARE(native32, {});
|
||||
QCOMPARE(native64, {});
|
||||
@ -167,20 +165,20 @@ slots:
|
||||
test.setRepositoryURL("file://foo/bar");
|
||||
{
|
||||
QStringList jar, native, native32, native64;
|
||||
test.getApplicableFiles(Os_Linux, jar, native, native32, native64, QString("data"));
|
||||
test.getApplicableFiles(Os_Linux, jar, native, native32, native64, QFINDTESTDATA("testdata"));
|
||||
QCOMPARE(jar, {});
|
||||
QCOMPARE(native, {});
|
||||
QCOMPARE(native32, {QFileInfo("data/testname-testversion-linux-32.jar").absoluteFilePath()});
|
||||
QCOMPARE(native64, {QFileInfo("data/testname-testversion-linux-64.jar").absoluteFilePath()});
|
||||
QCOMPARE(native32, {QFileInfo(QFINDTESTDATA("testdata/testname-testversion-linux-32.jar")).absoluteFilePath()});
|
||||
QCOMPARE(native64, {QFileInfo(QFINDTESTDATA("testdata") + "/testname-testversion-linux-64.jar").absoluteFilePath()});
|
||||
QStringList failedFiles;
|
||||
auto dls = test.getDownloads(Os_Linux, cache.get(), failedFiles, QString("data"));
|
||||
auto dls = test.getDownloads(Os_Linux, cache.get(), failedFiles, QFINDTESTDATA("testdata"));
|
||||
QCOMPARE(dls.size(), 0);
|
||||
QCOMPARE(failedFiles, {"data/testname-testversion-linux-64.jar"});
|
||||
QCOMPARE(failedFiles, {QFileInfo(QFINDTESTDATA("testdata") + "/testname-testversion-linux-64.jar").absoluteFilePath()});
|
||||
}
|
||||
}
|
||||
void test_onenine()
|
||||
{
|
||||
auto test = readMojangJson("data/lib-simple.json");
|
||||
auto test = readMojangJson(QFINDTESTDATA("testdata/lib-simple.json"));
|
||||
{
|
||||
QStringList jar, native, native32, native64;
|
||||
test->getApplicableFiles(Os_OSX, jar, native, native32, native64, QString());
|
||||
@ -199,41 +197,41 @@ slots:
|
||||
test->setHint("local");
|
||||
{
|
||||
QStringList jar, native, native32, native64;
|
||||
test->getApplicableFiles(Os_OSX, jar, native, native32, native64, QString("data"));
|
||||
QCOMPARE(jar, {QFileInfo("data/codecwav-20101023.jar").absoluteFilePath()});
|
||||
test->getApplicableFiles(Os_OSX, jar, native, native32, native64, QFINDTESTDATA("testdata"));
|
||||
QCOMPARE(jar, {QFileInfo(QFINDTESTDATA("testdata/codecwav-20101023.jar")).absoluteFilePath()});
|
||||
QCOMPARE(native, {});
|
||||
QCOMPARE(native32, {});
|
||||
QCOMPARE(native64, {});
|
||||
}
|
||||
{
|
||||
QStringList failedFiles;
|
||||
auto dls = test->getDownloads(Os_Linux, cache.get(), failedFiles, QString("data"));
|
||||
auto dls = test->getDownloads(Os_Linux, cache.get(), failedFiles, QFINDTESTDATA("testdata"));
|
||||
QCOMPARE(dls.size(), 0);
|
||||
QCOMPARE(failedFiles, {});
|
||||
}
|
||||
}
|
||||
void test_onenine_local_override()
|
||||
{
|
||||
auto test = readMojangJson("data/lib-simple.json");
|
||||
auto test = readMojangJson(QFINDTESTDATA("testdata/lib-simple.json"));
|
||||
test->setHint("local");
|
||||
{
|
||||
QStringList jar, native, native32, native64;
|
||||
test->getApplicableFiles(Os_OSX, jar, native, native32, native64, QString("data"));
|
||||
QCOMPARE(jar, {QFileInfo("data/codecwav-20101023.jar").absoluteFilePath()});
|
||||
test->getApplicableFiles(Os_OSX, jar, native, native32, native64, QFINDTESTDATA("testdata"));
|
||||
QCOMPARE(jar, {QFileInfo(QFINDTESTDATA("testdata/codecwav-20101023.jar")).absoluteFilePath()});
|
||||
QCOMPARE(native, {});
|
||||
QCOMPARE(native32, {});
|
||||
QCOMPARE(native64, {});
|
||||
}
|
||||
{
|
||||
QStringList failedFiles;
|
||||
auto dls = test->getDownloads(Os_Linux, cache.get(), failedFiles, QString("data"));
|
||||
auto dls = test->getDownloads(Os_Linux, cache.get(), failedFiles, QFINDTESTDATA("testdata"));
|
||||
QCOMPARE(dls.size(), 0);
|
||||
QCOMPARE(failedFiles, {});
|
||||
}
|
||||
}
|
||||
void test_onenine_native()
|
||||
{
|
||||
auto test = readMojangJson("data/lib-native.json");
|
||||
auto test = readMojangJson(QFINDTESTDATA("testdata/lib-native.json"));
|
||||
QStringList jar, native, native32, native64;
|
||||
test->getApplicableFiles(Os_OSX, jar, native, native32, native64, QString());
|
||||
QCOMPARE(jar, QStringList());
|
||||
@ -248,7 +246,7 @@ slots:
|
||||
}
|
||||
void test_onenine_native_arch()
|
||||
{
|
||||
auto test = readMojangJson("data/lib-native-arch.json");
|
||||
auto test = readMojangJson(QFINDTESTDATA("testdata/lib-native-arch.json"));
|
||||
QStringList jar, native, native32, native64;
|
||||
test->getApplicableFiles(Os_Windows, jar, native, native32, native64, QString());
|
||||
QCOMPARE(jar, {});
|
||||
|
@ -1,6 +1,5 @@
|
||||
#include <QTest>
|
||||
#include <QDebug>
|
||||
#include "TestUtil.h"
|
||||
|
||||
#include "minecraft/MojangVersionFormat.h"
|
||||
|
||||
@ -8,9 +7,8 @@ class MojangVersionFormatTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
static QJsonDocument readJson(const char *file)
|
||||
static QJsonDocument readJson(const QString path)
|
||||
{
|
||||
auto path = QFINDTESTDATA(file);
|
||||
QFile jsonFile(path);
|
||||
jsonFile.open(QIODevice::ReadOnly);
|
||||
auto data = jsonFile.readAll();
|
||||
@ -31,7 +29,7 @@ private
|
||||
slots:
|
||||
void test_Through_Simple()
|
||||
{
|
||||
QJsonDocument doc = readJson("data/1.9-simple.json");
|
||||
QJsonDocument doc = readJson(QFINDTESTDATA("testdata/1.9-simple.json"));
|
||||
auto vfile = MojangVersionFormat::versionFileFromJson(doc, "1.9-simple.json");
|
||||
auto doc2 = MojangVersionFormat::versionFileToJson(vfile);
|
||||
writeJson("1.9-simple-passthorugh.json", doc2);
|
||||
@ -41,7 +39,7 @@ slots:
|
||||
|
||||
void test_Through()
|
||||
{
|
||||
QJsonDocument doc = readJson("data/1.9.json");
|
||||
QJsonDocument doc = readJson(QFINDTESTDATA("testdata/1.9.json"));
|
||||
auto vfile = MojangVersionFormat::versionFileFromJson(doc, "1.9.json");
|
||||
auto doc2 = MojangVersionFormat::versionFileToJson(vfile);
|
||||
writeJson("1.9-passthorugh.json", doc2);
|
||||
|
@ -1,5 +1,4 @@
|
||||
#include <QTest>
|
||||
#include "TestUtil.h"
|
||||
|
||||
#include "minecraft/ParseUtils.h"
|
||||
|
||||
@ -42,4 +41,3 @@ slots:
|
||||
QTEST_GUILESS_MAIN(ParseUtilsTest)
|
||||
|
||||
#include "ParseUtils_test.moc"
|
||||
|
||||
|
@ -35,7 +35,6 @@
|
||||
|
||||
#include <QTest>
|
||||
#include <QTemporaryDir>
|
||||
#include "TestUtil.h"
|
||||
|
||||
#include "FileSystem.h"
|
||||
#include "minecraft/mod/ModFolderModel.h"
|
||||
@ -50,7 +49,7 @@ slots:
|
||||
void test_1178()
|
||||
{
|
||||
// source
|
||||
QString source = QFINDTESTDATA("data/test_folder");
|
||||
QString source = QFINDTESTDATA("testdata/test_folder");
|
||||
|
||||
// sanity check
|
||||
QVERIFY(!source.endsWith('/'));
|
||||
|
1
launcher/minecraft/mod/testdata/test_folder/assets/minecraft/textures/blah.txt
vendored
Normal file
1
launcher/minecraft/mod/testdata/test_folder/assets/minecraft/textures/blah.txt
vendored
Normal file
@ -0,0 +1 @@
|
||||
|
6
launcher/minecraft/mod/testdata/test_folder/pack.mcmeta
vendored
Normal file
6
launcher/minecraft/mod/testdata/test_folder/pack.mcmeta
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"pack": {
|
||||
"pack_format": 1,
|
||||
"description": "Some resource pack maybe"
|
||||
}
|
||||
}
|
1
launcher/minecraft/mod/testdata/test_folder/pack.nfo
vendored
Normal file
1
launcher/minecraft/mod/testdata/test_folder/pack.nfo
vendored
Normal file
@ -0,0 +1 @@
|
||||
|
Reference in New Issue
Block a user