aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorTrial97 <alexandru.tripon97@gmail.com>2023-09-28 22:50:12 +0300
committerTrial97 <alexandru.tripon97@gmail.com>2023-09-28 22:50:12 +0300
commit9acbf98f940204cd141203a6eccbc9a7351e5a78 (patch)
tree6ac8fe4b0e51ee58c67e02783fe97b00de707167 /tests
parent254444470f020b086648ac496ebfffb7d3e9ce05 (diff)
parent59e565ef96b85be9a25fa5d4f1723ee87fd5e75e (diff)
downloadPrismLauncher-9acbf98f940204cd141203a6eccbc9a7351e5a78.tar.gz
PrismLauncher-9acbf98f940204cd141203a6eccbc9a7351e5a78.tar.bz2
PrismLauncher-9acbf98f940204cd141203a6eccbc9a7351e5a78.zip
Merge branch 'develop' of https://github.com/PrismLauncher/PrismLauncher into feat/acknowledge_release_type
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/CMakeLists.txt3
-rw-r--r--tests/CatPack_test.cpp40
-rw-r--r--tests/DummyResourceAPI.h2
-rw-r--r--tests/FileSystem_test.cpp13
-rw-r--r--tests/GZip_test.cpp2
-rw-r--r--tests/ResourceModel_test.cpp10
-rw-r--r--tests/Task_test.cpp4
-rw-r--r--tests/testdata/CatPacks/index.json50
8 files changed, 107 insertions, 17 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index a26a49fe..59e0e314 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -56,3 +56,6 @@ ecm_add_test(Index_test.cpp LINK_LIBRARIES Launcher_logic Qt${QT_VERSION_MAJOR}:
ecm_add_test(Version_test.cpp LINK_LIBRARIES Launcher_logic Qt${QT_VERSION_MAJOR}::Test
TEST_NAME Version)
+
+ecm_add_test(CatPack_test.cpp LINK_LIBRARIES Launcher_logic Qt${QT_VERSION_MAJOR}::Test
+ TEST_NAME CatPack)
diff --git a/tests/CatPack_test.cpp b/tests/CatPack_test.cpp
new file mode 100644
index 00000000..330d1a81
--- /dev/null
+++ b/tests/CatPack_test.cpp
@@ -0,0 +1,40 @@
+#include <QTest>
+
+#include <QDate>
+#include <QFileInfo>
+#include <QList>
+#include <QTemporaryFile>
+#include "FileSystem.h"
+#include "ui/themes/CatPack.h"
+
+class CatPackTest : public QObject {
+ Q_OBJECT
+ private slots:
+ void test_catPack()
+ {
+ auto dataDir = QDir(QFINDTESTDATA("testdata/CatPacks")).absolutePath();
+ auto fileName = FS::PathCombine(dataDir, "index.json");
+ auto fileinfo = QFileInfo(fileName);
+ try {
+ auto cat = JsonCatPack(fileinfo);
+ QCOMPARE(cat.path(QDate(2023, 4, 12)), FS::PathCombine(fileinfo.path(), "oneDay.png"));
+ QCOMPARE(cat.path(QDate(2023, 4, 11)), FS::PathCombine(fileinfo.path(), "maxwell.png"));
+ QCOMPARE(cat.path(QDate(2023, 4, 13)), FS::PathCombine(fileinfo.path(), "maxwell.png"));
+ QCOMPARE(cat.path(QDate(2023, 12, 21)), FS::PathCombine(fileinfo.path(), "christmas.png"));
+ QCOMPARE(cat.path(QDate(2023, 12, 28)), FS::PathCombine(fileinfo.path(), "christmas.png"));
+ QCOMPARE(cat.path(QDate(2023, 12, 29)), FS::PathCombine(fileinfo.path(), "newyear.png"));
+ QCOMPARE(cat.path(QDate(2023, 12, 30)), FS::PathCombine(fileinfo.path(), "newyear2.png"));
+ QCOMPARE(cat.path(QDate(2023, 12, 31)), FS::PathCombine(fileinfo.path(), "newyear2.png"));
+ QCOMPARE(cat.path(QDate(2024, 1, 1)), FS::PathCombine(fileinfo.path(), "newyear2.png"));
+ QCOMPARE(cat.path(QDate(2024, 1, 2)), FS::PathCombine(fileinfo.path(), "newyear.png"));
+ QCOMPARE(cat.path(QDate(2024, 1, 3)), FS::PathCombine(fileinfo.path(), "newyear.png"));
+ QCOMPARE(cat.path(QDate(2024, 1, 4)), FS::PathCombine(fileinfo.path(), "maxwell.png"));
+ } catch (const Exception& e) {
+ QFAIL(e.cause().toLatin1());
+ }
+ }
+};
+
+QTEST_GUILESS_MAIN(CatPackTest)
+
+#include "CatPack_test.moc"
diff --git a/tests/DummyResourceAPI.h b/tests/DummyResourceAPI.h
index 0cc90958..35de9515 100644
--- a/tests/DummyResourceAPI.h
+++ b/tests/DummyResourceAPI.h
@@ -32,7 +32,7 @@ class DummyResourceAPI : public ResourceAPI {
}
DummyResourceAPI() : ResourceAPI() {}
- [[nodiscard]] auto getSortingMethods() const -> QList<SortingMethod> override { return {}; };
+ [[nodiscard]] auto getSortingMethods() const -> QList<SortingMethod> override { return {}; }
[[nodiscard]] Task::Ptr searchProjects(SearchArgs&&, SearchCallbacks&& callbacks) const override
{
diff --git a/tests/FileSystem_test.cpp b/tests/FileSystem_test.cpp
index 3adcd343..1d3cee85 100644
--- a/tests/FileSystem_test.cpp
+++ b/tests/FileSystem_test.cpp
@@ -81,10 +81,10 @@ class LinkTask : public Task {
} else {
emitSucceeded();
}
- };
+ }
FS::create_link* m_lnk;
- bool m_useHard = false;
+ [[maybe_unused]] bool m_useHard = false;
bool m_linkRecursive = true;
};
@@ -353,15 +353,12 @@ class FileSystemTest : public QObject {
}
}
- void test_getDesktop()
- {
- QCOMPARE(FS::getDesktopDir(), QStandardPaths::writableLocation(QStandardPaths::DesktopLocation));
- }
+ void test_getDesktop() { QCOMPARE(FS::getDesktopDir(), QStandardPaths::writableLocation(QStandardPaths::DesktopLocation)); }
void test_link()
{
QString folder = QFINDTESTDATA("testdata/FileSystem/test_folder");
- auto f = [&folder, this]() {
+ auto f = [&folder]() {
QTemporaryDir tempDir;
tempDir.setAutoRemove(true);
qDebug() << "From:" << folder << "To:" << tempDir.path();
@@ -630,7 +627,7 @@ class FileSystemTest : public QObject {
void test_link_with_max_depth()
{
QString folder = QFINDTESTDATA("testdata/FileSystem/test_folder");
- auto f = [&folder, this]() {
+ auto f = [&folder]() {
QTemporaryDir tempDir;
tempDir.setAutoRemove(true);
qDebug() << "From:" << folder << "To:" << tempDir.path();
diff --git a/tests/GZip_test.cpp b/tests/GZip_test.cpp
index 4c1259c2..c11ba271 100644
--- a/tests/GZip_test.cpp
+++ b/tests/GZip_test.cpp
@@ -26,7 +26,7 @@ class GZipTest : public QObject {
// initialize random buffer
for (int i = 0; i < size; i++) {
- random.append((char)idis(eng));
+ random.append(static_cast<char>(idis(eng)));
}
// initialize fibonacci
diff --git a/tests/ResourceModel_test.cpp b/tests/ResourceModel_test.cpp
index 9626c64e..b589758a 100644
--- a/tests/ResourceModel_test.cpp
+++ b/tests/ResourceModel_test.cpp
@@ -40,17 +40,17 @@ class DummyResourceModel : public ResourceModel {
DummyResourceModel() : ResourceModel(new DummyResourceAPI) {}
~DummyResourceModel() {}
- [[nodiscard]] auto metaEntryBase() const -> QString override { return ""; };
+ [[nodiscard]] auto metaEntryBase() const -> QString override { return ""; }
- ResourceAPI::SearchArgs createSearchArguments() override { return {}; };
- ResourceAPI::VersionSearchArgs createVersionsArguments(QModelIndex&) override { return {}; };
- ResourceAPI::ProjectInfoArgs createInfoArguments(QModelIndex&) override { return {}; };
+ ResourceAPI::SearchArgs createSearchArguments() override { return {}; }
+ ResourceAPI::VersionSearchArgs createVersionsArguments(QModelIndex&) override { return {}; }
+ ResourceAPI::ProjectInfoArgs createInfoArguments(QModelIndex&) override { return {}; }
QJsonArray documentToArray(QJsonDocument& doc) const override { return doc.object().value("hits").toArray(); }
void loadIndexedPack(ModPlatform::IndexedPack& pack, QJsonObject& obj) override
{
- pack.authors.append({ Json::requireString(obj, "author") });
+ pack.authors.append({ Json::requireString(obj, "author"), "" });
pack.description = Json::requireString(obj, "description");
pack.addonId = Json::requireString(obj, "project_id");
}
diff --git a/tests/Task_test.cpp b/tests/Task_test.cpp
index 95d927c6..abc9be90 100644
--- a/tests/Task_test.cpp
+++ b/tests/Task_test.cpp
@@ -19,7 +19,7 @@ class BasicTask : public Task {
BasicTask(bool show_debug_log = true) : Task(nullptr, show_debug_log) {}
private:
- void executeTask() override { emitSucceeded(); };
+ void executeTask() override { emitSucceeded(); }
};
/* Does nothing. Only used for testing. */
@@ -31,7 +31,7 @@ class BasicTask_MultiStep : public Task {
private:
auto isMultiStep() const -> bool override { return true; }
- void executeTask() override{};
+ void executeTask() override {}
};
class BigConcurrentTask : public ConcurrentTask {
diff --git a/tests/testdata/CatPacks/index.json b/tests/testdata/CatPacks/index.json
new file mode 100644
index 00000000..b5401d23
--- /dev/null
+++ b/tests/testdata/CatPacks/index.json
@@ -0,0 +1,50 @@
+{
+ "name": "My Cute Cat",
+ "default": "maxwell.png",
+ "variants": [
+ {
+ "startTime": {
+ "day": 12,
+ "month": 4
+ },
+ "endTime": {
+ "day": 12,
+ "month": 4
+ },
+ "path": "oneDay.png"
+ },
+ {
+ "startTime": {
+ "day": 20,
+ "month": 12
+ },
+ "endTime": {
+ "day": 28,
+ "month": 12
+ },
+ "path": "christmas.png"
+ },
+ {
+ "startTime": {
+ "day": 30,
+ "month": 12
+ },
+ "endTime": {
+ "day": 1,
+ "month": 1
+ },
+ "path": "newyear2.png"
+ },
+ {
+ "startTime": {
+ "day": 28,
+ "month": 12
+ },
+ "endTime": {
+ "day": 3,
+ "month": 1
+ },
+ "path": "newyear.png"
+ }
+ ]
+}