diff options
author | flow <flowlnlnln@gmail.com> | 2022-08-30 14:55:37 -0300 |
---|---|---|
committer | flow <flowlnlnln@gmail.com> | 2022-09-03 13:37:22 -0300 |
commit | 0331f5a1eb3e9fa21e89fc7fd56fdd4e87f29e44 (patch) | |
tree | ea0a8ead9459871e0bf54e1514144403f6fd2a95 /launcher/minecraft | |
parent | 8a7e117f6b013972be8fc05480339e11b7325e3e (diff) | |
download | PrismLauncher-0331f5a1eb3e9fa21e89fc7fd56fdd4e87f29e44.tar.gz PrismLauncher-0331f5a1eb3e9fa21e89fc7fd56fdd4e87f29e44.tar.bz2 PrismLauncher-0331f5a1eb3e9fa21e89fc7fd56fdd4e87f29e44.zip |
feat(tests): add tests for resource pack parsing
Signed-off-by: flow <flowlnlnln@gmail.com>
Diffstat (limited to 'launcher/minecraft')
-rw-r--r-- | launcher/minecraft/mod/ResourceFolderModel_test.cpp | 3 | ||||
-rw-r--r-- | launcher/minecraft/mod/ResourcePackParse_test.cpp | 73 | ||||
-rw-r--r-- | launcher/minecraft/mod/testdata/another_test_folder/pack.mcmeta | 6 | ||||
-rw-r--r-- | launcher/minecraft/mod/testdata/test_resource_pack_idk.zip | bin | 0 -> 322 bytes |
4 files changed, 81 insertions, 1 deletions
diff --git a/launcher/minecraft/mod/ResourceFolderModel_test.cpp b/launcher/minecraft/mod/ResourceFolderModel_test.cpp index fe98552e..8fe93c2a 100644 --- a/launcher/minecraft/mod/ResourceFolderModel_test.cpp +++ b/launcher/minecraft/mod/ResourceFolderModel_test.cpp @@ -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(); diff --git a/launcher/minecraft/mod/ResourcePackParse_test.cpp b/launcher/minecraft/mod/ResourcePackParse_test.cpp new file mode 100644 index 00000000..a49582d6 --- /dev/null +++ b/launcher/minecraft/mod/ResourcePackParse_test.cpp @@ -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" diff --git a/launcher/minecraft/mod/testdata/another_test_folder/pack.mcmeta b/launcher/minecraft/mod/testdata/another_test_folder/pack.mcmeta new file mode 100644 index 00000000..d33a0e5d --- /dev/null +++ b/launcher/minecraft/mod/testdata/another_test_folder/pack.mcmeta @@ -0,0 +1,6 @@ +{
+ "pack": {
+ "pack_format": 6,
+ "description": "o quartel pegou fogo, policia deu sinal, acode acode acode a bandeira nacional"
+ }
+}
diff --git a/launcher/minecraft/mod/testdata/test_resource_pack_idk.zip b/launcher/minecraft/mod/testdata/test_resource_pack_idk.zip Binary files differnew file mode 100644 index 00000000..52b91cdc --- /dev/null +++ b/launcher/minecraft/mod/testdata/test_resource_pack_idk.zip |