feat(tests): add tests for resource pack parsing
Signed-off-by: flow <flowlnlnln@gmail.com>
This commit is contained in:
parent
8a7e117f6b
commit
0331f5a1eb
@ -388,6 +388,10 @@ ecm_add_test(minecraft/Library_test.cpp LINK_LIBRARIES Launcher_logic Qt${QT_VER
|
||||
ecm_add_test(minecraft/mod/ResourceFolderModel_test.cpp LINK_LIBRARIES Launcher_logic Qt${QT_VERSION_MAJOR}::Test
|
||||
TEST_NAME ResourceFolderModel)
|
||||
|
||||
ecm_add_test(minecraft/mod/ResourcePackParse_test.cpp
|
||||
LINK_LIBRARIES Launcher_logic Qt${QT_VERSION_MAJOR}::Test
|
||||
TEST_NAME ResourcePackParse)
|
||||
|
||||
ecm_add_test(minecraft/ParseUtils_test.cpp LINK_LIBRARIES Launcher_logic Qt${QT_VERSION_MAJOR}::Test
|
||||
TEST_NAME ParseUtils)
|
||||
|
||||
|
@ -146,7 +146,8 @@ slots:
|
||||
for (auto mod : model.allMods())
|
||||
qDebug() << mod->name();
|
||||
|
||||
QCOMPARE(model.size(), 2);
|
||||
// FIXME: It considers every file in the directory as a mod, but we should probably filter that out somehow.
|
||||
QCOMPARE(model.size(), 4);
|
||||
|
||||
model.stopWatching();
|
||||
|
||||
|
73
launcher/minecraft/mod/ResourcePackParse_test.cpp
Normal file
73
launcher/minecraft/mod/ResourcePackParse_test.cpp
Normal file
@ -0,0 +1,73 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
/*
|
||||
* PolyMC - Minecraft Launcher
|
||||
* Copyright (c) 2022 flowln <flowlnlnln@gmail.com>
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#include <QTest>
|
||||
#include <QTimer>
|
||||
|
||||
#include "FileSystem.h"
|
||||
|
||||
#include "ResourcePack.h"
|
||||
#include "tasks/LocalResourcePackParseTask.h"
|
||||
|
||||
class ResourcePackParseTest : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
private slots:
|
||||
void test_parseZIP()
|
||||
{
|
||||
QString source = QFINDTESTDATA("testdata");
|
||||
|
||||
QString zip_rp = FS::PathCombine(source, "test_resource_pack_idk.zip");
|
||||
ResourcePack pack { QFileInfo(zip_rp) };
|
||||
|
||||
ResourcePackUtils::processZIP(pack);
|
||||
|
||||
QVERIFY(pack.packFormat() == 3);
|
||||
QVERIFY(pack.description() == "um dois, feijão com arroz, três quatro, feijão no prato, cinco seis, café inglês, sete oito, comer biscoito, nove dez comer pastéis!!");
|
||||
}
|
||||
|
||||
void test_parseFolder()
|
||||
{
|
||||
QString source = QFINDTESTDATA("testdata");
|
||||
|
||||
QString folder_rp = FS::PathCombine(source, "test_folder");
|
||||
ResourcePack pack { QFileInfo(folder_rp) };
|
||||
|
||||
ResourcePackUtils::processFolder(pack);
|
||||
|
||||
QVERIFY(pack.packFormat() == 1);
|
||||
QVERIFY(pack.description() == "Some resource pack maybe");
|
||||
}
|
||||
|
||||
void test_parseFolder2()
|
||||
{
|
||||
QString source = QFINDTESTDATA("testdata");
|
||||
|
||||
QString folder_rp = FS::PathCombine(source, "another_test_folder");
|
||||
ResourcePack pack { QFileInfo(folder_rp) };
|
||||
|
||||
ResourcePackUtils::process(pack);
|
||||
|
||||
QVERIFY(pack.packFormat() == 6);
|
||||
QVERIFY(pack.description() == "o quartel pegou fogo, policia deu sinal, acode acode acode a bandeira nacional");
|
||||
}
|
||||
};
|
||||
|
||||
QTEST_GUILESS_MAIN(ResourcePackParseTest)
|
||||
|
||||
#include "ResourcePackParse_test.moc"
|
BIN
launcher/minecraft/mod/testdata/another_test_folder/pack.mcmeta
vendored
Normal file
BIN
launcher/minecraft/mod/testdata/another_test_folder/pack.mcmeta
vendored
Normal file
Binary file not shown.
BIN
launcher/minecraft/mod/testdata/test_resource_pack_idk.zip
vendored
Normal file
BIN
launcher/minecraft/mod/testdata/test_resource_pack_idk.zip
vendored
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user