2022-09-04 13:45:09 +01:00
|
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
/*
|
2023-08-04 18:41:47 +01:00
|
|
|
* Prism Launcher - Minecraft Launcher
|
2022-09-04 13:45:09 +01:00
|
|
|
* Copyright (c) 2022 flowln <flowlnlnln@gmail.com>
|
2022-09-08 08:43:55 +01:00
|
|
|
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
|
2022-09-04 13:45:09 +01:00
|
|
|
*
|
|
|
|
* 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"
|
|
|
|
|
2022-09-04 14:05:11 +01:00
|
|
|
#include "minecraft/mod/TexturePack.h"
|
|
|
|
#include "minecraft/mod/tasks/LocalTexturePackParseTask.h"
|
2022-09-04 13:45:09 +01:00
|
|
|
|
|
|
|
class TexturePackParseTest : public QObject {
|
|
|
|
Q_OBJECT
|
|
|
|
|
2023-08-02 17:35:35 +01:00
|
|
|
private slots:
|
2022-09-04 13:45:09 +01:00
|
|
|
void test_parseZIP()
|
|
|
|
{
|
2022-09-04 14:05:11 +01:00
|
|
|
QString source = QFINDTESTDATA("testdata/TexturePackParse");
|
2022-09-04 13:45:09 +01:00
|
|
|
|
|
|
|
QString zip_rp = FS::PathCombine(source, "test_texture_pack_idk.zip");
|
2023-08-02 17:35:35 +01:00
|
|
|
TexturePack pack{ QFileInfo(zip_rp) };
|
2022-09-04 13:45:09 +01:00
|
|
|
|
2022-12-25 01:08:08 +00:00
|
|
|
bool valid = TexturePackUtils::processZIP(pack);
|
2022-09-04 13:45:09 +01:00
|
|
|
|
|
|
|
QVERIFY(pack.description() == "joe biden, wake up");
|
2022-12-25 01:08:08 +00:00
|
|
|
QVERIFY(valid == true);
|
2022-09-04 13:45:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void test_parseFolder()
|
|
|
|
{
|
2022-09-04 14:05:11 +01:00
|
|
|
QString source = QFINDTESTDATA("testdata/TexturePackParse");
|
2022-09-04 13:45:09 +01:00
|
|
|
|
|
|
|
QString folder_rp = FS::PathCombine(source, "test_texturefolder");
|
2023-08-02 17:35:35 +01:00
|
|
|
TexturePack pack{ QFileInfo(folder_rp) };
|
2022-09-04 13:45:09 +01:00
|
|
|
|
2022-12-25 01:08:08 +00:00
|
|
|
bool valid = TexturePackUtils::processFolder(pack, TexturePackUtils::ProcessingLevel::BasicInfoOnly);
|
2022-09-04 13:45:09 +01:00
|
|
|
|
|
|
|
QVERIFY(pack.description() == "Some texture pack surely");
|
2022-12-25 01:08:08 +00:00
|
|
|
QVERIFY(valid == true);
|
2022-09-04 13:45:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void test_parseFolder2()
|
|
|
|
{
|
2022-09-04 14:05:11 +01:00
|
|
|
QString source = QFINDTESTDATA("testdata/TexturePackParse");
|
2022-09-04 13:45:09 +01:00
|
|
|
|
|
|
|
QString folder_rp = FS::PathCombine(source, "another_test_texturefolder");
|
2023-08-02 17:35:35 +01:00
|
|
|
TexturePack pack{ QFileInfo(folder_rp) };
|
2022-09-04 13:45:09 +01:00
|
|
|
|
2022-12-25 01:08:08 +00:00
|
|
|
bool valid = TexturePackUtils::process(pack, TexturePackUtils::ProcessingLevel::BasicInfoOnly);
|
2022-09-04 13:45:09 +01:00
|
|
|
|
|
|
|
QVERIFY(pack.description() == "quieres\nfor real");
|
2022-12-25 01:08:08 +00:00
|
|
|
QVERIFY(valid == true);
|
2022-09-04 13:45:09 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
QTEST_GUILESS_MAIN(TexturePackParseTest)
|
|
|
|
|
|
|
|
#include "TexturePackParse_test.moc"
|