2022-10-08 19:09:53 +01:00
|
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
/*
|
|
|
|
* PolyMC - Minecraft Launcher
|
|
|
|
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, version 3.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following copyright and
|
|
|
|
* permission notice:
|
|
|
|
*
|
|
|
|
* Copyright 2013-2021 MultiMC Contributors
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2016-03-26 15:56:57 +00:00
|
|
|
#include <QTest>
|
|
|
|
|
2022-09-11 21:25:18 +01:00
|
|
|
#include <minecraft/MojangVersionFormat.h>
|
|
|
|
#include <minecraft/OneSixVersionFormat.h>
|
|
|
|
#include <minecraft/Library.h>
|
|
|
|
#include <net/HttpMetaCache.h>
|
|
|
|
#include <FileSystem.h>
|
2022-08-06 23:06:32 +01:00
|
|
|
#include <RuntimeContext.h>
|
2016-03-26 15:56:57 +00:00
|
|
|
|
|
|
|
class LibraryTest : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
private:
|
2022-06-12 00:46:30 +01:00
|
|
|
LibraryPtr readMojangJson(const QString path)
|
2016-03-26 15:56:57 +00:00
|
|
|
{
|
|
|
|
QFile jsonFile(path);
|
|
|
|
jsonFile.open(QIODevice::ReadOnly);
|
|
|
|
auto data = jsonFile.readAll();
|
|
|
|
jsonFile.close();
|
2021-04-01 02:50:28 +01:00
|
|
|
ProblemContainer problems;
|
2022-06-12 00:46:30 +01:00
|
|
|
return MojangVersionFormat::libraryFromJson(problems, QJsonDocument::fromJson(data).object(), path);
|
2016-03-26 15:56:57 +00:00
|
|
|
}
|
|
|
|
// get absolute path to expected storage, assuming default cache prefix
|
|
|
|
QStringList getStorage(QString relative)
|
|
|
|
{
|
|
|
|
return {FS::PathCombine(cache->getBasePath("libraries"), relative)};
|
|
|
|
}
|
2022-08-06 23:06:32 +01:00
|
|
|
|
|
|
|
RuntimeContext dummyContext(QString system = "linux", QString arch = "64", QString realArch = "amd64") {
|
|
|
|
RuntimeContext r;
|
|
|
|
r.javaArchitecture = arch;
|
|
|
|
r.javaRealArchitecture = realArch;
|
|
|
|
r.system = system;
|
|
|
|
return r;
|
|
|
|
}
|
2016-03-26 15:56:57 +00:00
|
|
|
private
|
|
|
|
slots:
|
|
|
|
void initTestCase()
|
|
|
|
{
|
|
|
|
cache.reset(new HttpMetaCache());
|
|
|
|
cache->addBase("libraries", QDir("libraries").absolutePath());
|
2022-09-11 21:25:18 +01:00
|
|
|
dataDir = QDir(QFINDTESTDATA("testdata/Library")).absolutePath();
|
2016-03-26 15:56:57 +00:00
|
|
|
}
|
|
|
|
void test_legacy()
|
|
|
|
{
|
2022-08-06 23:06:32 +01:00
|
|
|
RuntimeContext r = dummyContext();
|
2016-03-26 15:56:57 +00:00
|
|
|
Library test("test.package:testname:testversion");
|
|
|
|
QCOMPARE(test.artifactPrefix(), QString("test.package:testname"));
|
|
|
|
QCOMPARE(test.isNative(), false);
|
|
|
|
|
|
|
|
QStringList jar, native, native32, native64;
|
2022-08-06 23:06:32 +01:00
|
|
|
test.getApplicableFiles(r, jar, native, native32, native64, QString());
|
2016-03-26 15:56:57 +00:00
|
|
|
QCOMPARE(jar, getStorage("test/package/testname/testversion/testname-testversion.jar"));
|
|
|
|
QCOMPARE(native, {});
|
|
|
|
QCOMPARE(native32, {});
|
|
|
|
QCOMPARE(native64, {});
|
|
|
|
}
|
|
|
|
void test_legacy_url()
|
|
|
|
{
|
2022-08-06 23:06:32 +01:00
|
|
|
RuntimeContext r = dummyContext();
|
2016-03-26 15:56:57 +00:00
|
|
|
QStringList failedFiles;
|
|
|
|
Library test("test.package:testname:testversion");
|
|
|
|
test.setRepositoryURL("file://foo/bar");
|
2022-08-06 23:06:32 +01:00
|
|
|
auto downloads = test.getDownloads(r, cache.get(), failedFiles, QString());
|
2016-03-26 15:56:57 +00:00
|
|
|
QCOMPARE(downloads.size(), 1);
|
|
|
|
QCOMPARE(failedFiles, {});
|
2021-11-21 22:21:12 +00:00
|
|
|
NetAction::Ptr dl = downloads[0];
|
2016-03-26 15:56:57 +00:00
|
|
|
QCOMPARE(dl->m_url, QUrl("file://foo/bar/test/package/testname/testversion/testname-testversion.jar"));
|
|
|
|
}
|
|
|
|
void test_legacy_url_local_broken()
|
|
|
|
{
|
2022-08-06 23:06:32 +01:00
|
|
|
RuntimeContext r = dummyContext();
|
2016-03-26 15:56:57 +00:00
|
|
|
Library test("test.package:testname:testversion");
|
|
|
|
QCOMPARE(test.isNative(), false);
|
|
|
|
QStringList failedFiles;
|
|
|
|
test.setHint("local");
|
2022-08-06 23:06:32 +01:00
|
|
|
auto downloads = test.getDownloads(r, cache.get(), failedFiles, QString());
|
2016-03-26 15:56:57 +00:00
|
|
|
QCOMPARE(downloads.size(), 0);
|
2018-11-26 02:22:20 +00:00
|
|
|
QCOMPARE(failedFiles, {"testname-testversion.jar"});
|
2016-03-26 15:56:57 +00:00
|
|
|
}
|
2016-10-01 23:26:10 +01:00
|
|
|
void test_legacy_url_local_override()
|
|
|
|
{
|
2022-08-06 23:06:32 +01:00
|
|
|
RuntimeContext r = dummyContext();
|
2016-10-01 23:26:10 +01:00
|
|
|
Library test("com.paulscode:codecwav:20101023");
|
|
|
|
QCOMPARE(test.isNative(), false);
|
|
|
|
QStringList failedFiles;
|
|
|
|
test.setHint("local");
|
2022-08-06 23:06:32 +01:00
|
|
|
auto downloads = test.getDownloads(r, cache.get(), failedFiles, QFINDTESTDATA("testdata/Library"));
|
2016-10-01 23:26:10 +01:00
|
|
|
QCOMPARE(downloads.size(), 0);
|
2017-10-28 21:21:49 +01:00
|
|
|
qDebug() << failedFiles;
|
2016-10-01 23:26:10 +01:00
|
|
|
QCOMPARE(failedFiles.size(), 0);
|
|
|
|
|
|
|
|
QStringList jar, native, native32, native64;
|
2022-08-06 23:06:32 +01:00
|
|
|
test.getApplicableFiles(r, jar, native, native32, native64, QFINDTESTDATA("testdata/Library"));
|
2022-09-11 21:25:18 +01:00
|
|
|
QCOMPARE(jar, {QFileInfo(QFINDTESTDATA("testdata/Library/codecwav-20101023.jar")).absoluteFilePath()});
|
2016-10-01 23:26:10 +01:00
|
|
|
QCOMPARE(native, {});
|
|
|
|
QCOMPARE(native32, {});
|
|
|
|
QCOMPARE(native64, {});
|
|
|
|
}
|
2016-03-26 15:56:57 +00:00
|
|
|
void test_legacy_native()
|
|
|
|
{
|
2022-08-06 23:06:32 +01:00
|
|
|
RuntimeContext r = dummyContext();
|
2016-03-26 15:56:57 +00:00
|
|
|
Library test("test.package:testname:testversion");
|
2022-07-11 08:01:07 +01:00
|
|
|
test.m_nativeClassifiers["linux"] = "linux";
|
2016-03-26 15:56:57 +00:00
|
|
|
QCOMPARE(test.isNative(), true);
|
|
|
|
test.setRepositoryURL("file://foo/bar");
|
|
|
|
{
|
|
|
|
QStringList jar, native, native32, native64;
|
2022-08-06 23:06:32 +01:00
|
|
|
test.getApplicableFiles(r, jar, native, native32, native64, QString());
|
2016-03-26 15:56:57 +00:00
|
|
|
QCOMPARE(jar, {});
|
|
|
|
QCOMPARE(native, getStorage("test/package/testname/testversion/testname-testversion-linux.jar"));
|
|
|
|
QCOMPARE(native32, {});
|
|
|
|
QCOMPARE(native64, {});
|
|
|
|
QStringList failedFiles;
|
2022-08-06 23:06:32 +01:00
|
|
|
auto dls = test.getDownloads(r, cache.get(), failedFiles, QString());
|
2016-03-26 15:56:57 +00:00
|
|
|
QCOMPARE(dls.size(), 1);
|
|
|
|
QCOMPARE(failedFiles, {});
|
|
|
|
auto dl = dls[0];
|
|
|
|
QCOMPARE(dl->m_url, QUrl("file://foo/bar/test/package/testname/testversion/testname-testversion-linux.jar"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void test_legacy_native_arch()
|
|
|
|
{
|
2022-08-06 23:06:32 +01:00
|
|
|
RuntimeContext r = dummyContext();
|
2016-03-26 15:56:57 +00:00
|
|
|
Library test("test.package:testname:testversion");
|
2022-07-11 08:01:07 +01:00
|
|
|
test.m_nativeClassifiers["linux"]="linux-${arch}";
|
|
|
|
test.m_nativeClassifiers["osx"]="osx-${arch}";
|
|
|
|
test.m_nativeClassifiers["windows"]="windows-${arch}";
|
2016-03-26 15:56:57 +00:00
|
|
|
QCOMPARE(test.isNative(), true);
|
|
|
|
test.setRepositoryURL("file://foo/bar");
|
|
|
|
{
|
|
|
|
QStringList jar, native, native32, native64;
|
2022-08-06 23:06:32 +01:00
|
|
|
test.getApplicableFiles(r, jar, native, native32, native64, QString());
|
2016-03-26 15:56:57 +00:00
|
|
|
QCOMPARE(jar, {});
|
|
|
|
QCOMPARE(native, {});
|
|
|
|
QCOMPARE(native32, getStorage("test/package/testname/testversion/testname-testversion-linux-32.jar"));
|
|
|
|
QCOMPARE(native64, getStorage("test/package/testname/testversion/testname-testversion-linux-64.jar"));
|
|
|
|
QStringList failedFiles;
|
2022-08-06 23:06:32 +01:00
|
|
|
auto dls = test.getDownloads(r, cache.get(), failedFiles, QString());
|
2016-03-26 15:56:57 +00:00
|
|
|
QCOMPARE(dls.size(), 2);
|
|
|
|
QCOMPARE(failedFiles, {});
|
|
|
|
QCOMPARE(dls[0]->m_url, QUrl("file://foo/bar/test/package/testname/testversion/testname-testversion-linux-32.jar"));
|
|
|
|
QCOMPARE(dls[1]->m_url, QUrl("file://foo/bar/test/package/testname/testversion/testname-testversion-linux-64.jar"));
|
|
|
|
}
|
2022-08-06 23:06:32 +01:00
|
|
|
r.system = "windows";
|
2016-03-26 15:56:57 +00:00
|
|
|
{
|
|
|
|
QStringList jar, native, native32, native64;
|
2022-08-06 23:06:32 +01:00
|
|
|
test.getApplicableFiles(r, jar, native, native32, native64, QString());
|
2016-03-26 15:56:57 +00:00
|
|
|
QCOMPARE(jar, {});
|
|
|
|
QCOMPARE(native, {});
|
|
|
|
QCOMPARE(native32, getStorage("test/package/testname/testversion/testname-testversion-windows-32.jar"));
|
|
|
|
QCOMPARE(native64, getStorage("test/package/testname/testversion/testname-testversion-windows-64.jar"));
|
|
|
|
QStringList failedFiles;
|
2022-08-06 23:06:32 +01:00
|
|
|
auto dls = test.getDownloads(r, cache.get(), failedFiles, QString());
|
2016-03-26 15:56:57 +00:00
|
|
|
QCOMPARE(dls.size(), 2);
|
|
|
|
QCOMPARE(failedFiles, {});
|
|
|
|
QCOMPARE(dls[0]->m_url, QUrl("file://foo/bar/test/package/testname/testversion/testname-testversion-windows-32.jar"));
|
|
|
|
QCOMPARE(dls[1]->m_url, QUrl("file://foo/bar/test/package/testname/testversion/testname-testversion-windows-64.jar"));
|
|
|
|
}
|
2022-08-06 23:06:32 +01:00
|
|
|
r.system = "osx";
|
2016-03-26 15:56:57 +00:00
|
|
|
{
|
|
|
|
QStringList jar, native, native32, native64;
|
2022-08-06 23:06:32 +01:00
|
|
|
test.getApplicableFiles(r, jar, native, native32, native64, QString());
|
2016-03-26 15:56:57 +00:00
|
|
|
QCOMPARE(jar, {});
|
|
|
|
QCOMPARE(native, {});
|
|
|
|
QCOMPARE(native32, getStorage("test/package/testname/testversion/testname-testversion-osx-32.jar"));
|
|
|
|
QCOMPARE(native64, getStorage("test/package/testname/testversion/testname-testversion-osx-64.jar"));
|
|
|
|
QStringList failedFiles;
|
2022-08-06 23:06:32 +01:00
|
|
|
auto dls = test.getDownloads(r, cache.get(), failedFiles, QString());
|
2016-03-26 15:56:57 +00:00
|
|
|
QCOMPARE(dls.size(), 2);
|
|
|
|
QCOMPARE(failedFiles, {});
|
|
|
|
QCOMPARE(dls[0]->m_url, QUrl("file://foo/bar/test/package/testname/testversion/testname-testversion-osx-32.jar"));
|
|
|
|
QCOMPARE(dls[1]->m_url, QUrl("file://foo/bar/test/package/testname/testversion/testname-testversion-osx-64.jar"));
|
|
|
|
}
|
|
|
|
}
|
2016-10-01 23:26:10 +01:00
|
|
|
void test_legacy_native_arch_local_override()
|
|
|
|
{
|
2022-08-06 23:06:32 +01:00
|
|
|
RuntimeContext r = dummyContext();
|
2016-10-01 23:26:10 +01:00
|
|
|
Library test("test.package:testname:testversion");
|
2022-07-11 08:01:07 +01:00
|
|
|
test.m_nativeClassifiers["linux"]="linux-${arch}";
|
2016-10-01 23:26:10 +01:00
|
|
|
test.setHint("local");
|
|
|
|
QCOMPARE(test.isNative(), true);
|
|
|
|
test.setRepositoryURL("file://foo/bar");
|
|
|
|
{
|
|
|
|
QStringList jar, native, native32, native64;
|
2022-08-06 23:06:32 +01:00
|
|
|
test.getApplicableFiles(r, jar, native, native32, native64, QFINDTESTDATA("testdata/Library"));
|
2016-10-01 23:26:10 +01:00
|
|
|
QCOMPARE(jar, {});
|
|
|
|
QCOMPARE(native, {});
|
2022-09-11 21:25:18 +01:00
|
|
|
QCOMPARE(native32, {QFileInfo(QFINDTESTDATA("testdata/Library/testname-testversion-linux-32.jar")).absoluteFilePath()});
|
|
|
|
QCOMPARE(native64, {QFileInfo(QFINDTESTDATA("testdata/Library") + "/testname-testversion-linux-64.jar").absoluteFilePath()});
|
2016-10-01 23:26:10 +01:00
|
|
|
QStringList failedFiles;
|
2022-08-06 23:06:32 +01:00
|
|
|
auto dls = test.getDownloads(r, cache.get(), failedFiles, QFINDTESTDATA("testdata/Library"));
|
2016-10-01 23:26:10 +01:00
|
|
|
QCOMPARE(dls.size(), 0);
|
2022-09-11 21:25:18 +01:00
|
|
|
QCOMPARE(failedFiles, {QFileInfo(QFINDTESTDATA("testdata/Library") + "/testname-testversion-linux-64.jar").absoluteFilePath()});
|
2016-10-01 23:26:10 +01:00
|
|
|
}
|
|
|
|
}
|
2016-03-26 15:56:57 +00:00
|
|
|
void test_onenine()
|
|
|
|
{
|
2022-08-06 23:06:32 +01:00
|
|
|
RuntimeContext r = dummyContext("osx");
|
2022-09-11 21:25:18 +01:00
|
|
|
auto test = readMojangJson(QFINDTESTDATA("testdata/Library/lib-simple.json"));
|
2016-10-01 23:26:10 +01:00
|
|
|
{
|
|
|
|
QStringList jar, native, native32, native64;
|
2022-08-06 23:06:32 +01:00
|
|
|
test->getApplicableFiles(r, jar, native, native32, native64, QString());
|
2016-10-01 23:26:10 +01:00
|
|
|
QCOMPARE(jar, getStorage("com/paulscode/codecwav/20101023/codecwav-20101023.jar"));
|
|
|
|
QCOMPARE(native, {});
|
|
|
|
QCOMPARE(native32, {});
|
|
|
|
QCOMPARE(native64, {});
|
|
|
|
}
|
2022-08-06 23:06:32 +01:00
|
|
|
r.system = "linux";
|
2016-10-01 23:26:10 +01:00
|
|
|
{
|
|
|
|
QStringList failedFiles;
|
2022-08-06 23:06:32 +01:00
|
|
|
auto dls = test->getDownloads(r, cache.get(), failedFiles, QString());
|
2016-10-01 23:26:10 +01:00
|
|
|
QCOMPARE(dls.size(), 1);
|
|
|
|
QCOMPARE(failedFiles, {});
|
|
|
|
QCOMPARE(dls[0]->m_url, QUrl("https://libraries.minecraft.net/com/paulscode/codecwav/20101023/codecwav-20101023.jar"));
|
|
|
|
}
|
2022-08-06 23:06:32 +01:00
|
|
|
r.system = "osx";
|
2016-10-01 23:26:10 +01:00
|
|
|
test->setHint("local");
|
|
|
|
{
|
|
|
|
QStringList jar, native, native32, native64;
|
2022-08-06 23:06:32 +01:00
|
|
|
test->getApplicableFiles(r, jar, native, native32, native64, QFINDTESTDATA("testdata/Library"));
|
2022-09-11 21:25:18 +01:00
|
|
|
QCOMPARE(jar, {QFileInfo(QFINDTESTDATA("testdata/Library/codecwav-20101023.jar")).absoluteFilePath()});
|
2016-10-01 23:26:10 +01:00
|
|
|
QCOMPARE(native, {});
|
|
|
|
QCOMPARE(native32, {});
|
|
|
|
QCOMPARE(native64, {});
|
|
|
|
}
|
2022-08-06 23:06:32 +01:00
|
|
|
r.system = "linux";
|
2016-10-01 23:26:10 +01:00
|
|
|
{
|
|
|
|
QStringList failedFiles;
|
2022-08-06 23:06:32 +01:00
|
|
|
auto dls = test->getDownloads(r, cache.get(), failedFiles, QFINDTESTDATA("testdata/Library"));
|
2016-10-01 23:26:10 +01:00
|
|
|
QCOMPARE(dls.size(), 0);
|
|
|
|
QCOMPARE(failedFiles, {});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void test_onenine_local_override()
|
|
|
|
{
|
2022-08-06 23:06:32 +01:00
|
|
|
RuntimeContext r = dummyContext("osx");
|
2022-09-11 21:25:18 +01:00
|
|
|
auto test = readMojangJson(QFINDTESTDATA("testdata/Library/lib-simple.json"));
|
2016-10-01 23:26:10 +01:00
|
|
|
test->setHint("local");
|
|
|
|
{
|
|
|
|
QStringList jar, native, native32, native64;
|
2022-08-06 23:06:32 +01:00
|
|
|
test->getApplicableFiles(r, jar, native, native32, native64, QFINDTESTDATA("testdata/Library"));
|
2022-09-11 21:25:18 +01:00
|
|
|
QCOMPARE(jar, {QFileInfo(QFINDTESTDATA("testdata/Library/codecwav-20101023.jar")).absoluteFilePath()});
|
2016-10-01 23:26:10 +01:00
|
|
|
QCOMPARE(native, {});
|
|
|
|
QCOMPARE(native32, {});
|
|
|
|
QCOMPARE(native64, {});
|
|
|
|
}
|
2022-08-06 23:06:32 +01:00
|
|
|
r.system = "linux";
|
2016-10-01 23:26:10 +01:00
|
|
|
{
|
|
|
|
QStringList failedFiles;
|
2022-08-06 23:06:32 +01:00
|
|
|
auto dls = test->getDownloads(r, cache.get(), failedFiles, QFINDTESTDATA("testdata/Library"));
|
2016-10-01 23:26:10 +01:00
|
|
|
QCOMPARE(dls.size(), 0);
|
|
|
|
QCOMPARE(failedFiles, {});
|
|
|
|
}
|
2016-03-26 15:56:57 +00:00
|
|
|
}
|
|
|
|
void test_onenine_native()
|
|
|
|
{
|
2022-08-06 23:06:32 +01:00
|
|
|
RuntimeContext r = dummyContext("osx");
|
2022-09-11 21:25:18 +01:00
|
|
|
auto test = readMojangJson(QFINDTESTDATA("testdata/Library/lib-native.json"));
|
2016-03-26 15:56:57 +00:00
|
|
|
QStringList jar, native, native32, native64;
|
2022-08-06 23:06:32 +01:00
|
|
|
test->getApplicableFiles(r, jar, native, native32, native64, QString());
|
2017-04-06 22:31:23 +01:00
|
|
|
QCOMPARE(jar, QStringList());
|
2016-03-26 15:56:57 +00:00
|
|
|
QCOMPARE(native, getStorage("org/lwjgl/lwjgl/lwjgl-platform/2.9.4-nightly-20150209/lwjgl-platform-2.9.4-nightly-20150209-natives-osx.jar"));
|
|
|
|
QCOMPARE(native32, {});
|
|
|
|
QCOMPARE(native64, {});
|
|
|
|
QStringList failedFiles;
|
2022-08-06 23:06:32 +01:00
|
|
|
auto dls = test->getDownloads(r, cache.get(), failedFiles, QString());
|
2017-10-28 21:21:49 +01:00
|
|
|
QCOMPARE(dls.size(), 1);
|
2016-03-26 15:56:57 +00:00
|
|
|
QCOMPARE(failedFiles, {});
|
2017-10-28 21:21:49 +01:00
|
|
|
QCOMPARE(dls[0]->m_url, QUrl("https://libraries.minecraft.net/org/lwjgl/lwjgl/lwjgl-platform/2.9.4-nightly-20150209/lwjgl-platform-2.9.4-nightly-20150209-natives-osx.jar"));
|
2016-03-26 15:56:57 +00:00
|
|
|
}
|
|
|
|
void test_onenine_native_arch()
|
|
|
|
{
|
2022-08-06 23:06:32 +01:00
|
|
|
RuntimeContext r = dummyContext("windows");
|
2022-09-11 21:25:18 +01:00
|
|
|
auto test = readMojangJson(QFINDTESTDATA("testdata/Library/lib-native-arch.json"));
|
2016-03-26 15:56:57 +00:00
|
|
|
QStringList jar, native, native32, native64;
|
2022-08-06 23:06:32 +01:00
|
|
|
test->getApplicableFiles(r, jar, native, native32, native64, QString());
|
2016-03-26 15:56:57 +00:00
|
|
|
QCOMPARE(jar, {});
|
|
|
|
QCOMPARE(native, {});
|
|
|
|
QCOMPARE(native32, getStorage("tv/twitch/twitch-platform/5.16/twitch-platform-5.16-natives-windows-32.jar"));
|
|
|
|
QCOMPARE(native64, getStorage("tv/twitch/twitch-platform/5.16/twitch-platform-5.16-natives-windows-64.jar"));
|
|
|
|
QStringList failedFiles;
|
2022-08-06 23:06:32 +01:00
|
|
|
auto dls = test->getDownloads(r, cache.get(), failedFiles, QString());
|
2016-03-26 15:56:57 +00:00
|
|
|
QCOMPARE(dls.size(), 2);
|
|
|
|
QCOMPARE(failedFiles, {});
|
|
|
|
QCOMPARE(dls[0]->m_url, QUrl("https://libraries.minecraft.net/tv/twitch/twitch-platform/5.16/twitch-platform-5.16-natives-windows-32.jar"));
|
|
|
|
QCOMPARE(dls[1]->m_url, QUrl("https://libraries.minecraft.net/tv/twitch/twitch-platform/5.16/twitch-platform-5.16-natives-windows-64.jar"));
|
|
|
|
}
|
|
|
|
private:
|
|
|
|
std::unique_ptr<HttpMetaCache> cache;
|
2016-10-01 23:26:10 +01:00
|
|
|
QString dataDir;
|
2016-03-26 15:56:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
QTEST_GUILESS_MAIN(LibraryTest)
|
|
|
|
|
2016-04-14 00:23:54 +01:00
|
|
|
#include "Library_test.moc"
|