aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorSkye Deving <76892045+skyedeving@users.noreply.github.com>2021-01-07 03:15:45 -0600
committerSkye Deving <76892045+skyedeving@users.noreply.github.com>2021-01-28 11:05:42 -0600
commita8fdea09b046a7c9c4fbb00d878fbb693abecdde (patch)
treec29d0afdf793dfdc31ef98bff2cada2fd51c4468 /test
parentbd5ed84c1678877e7500558f0e455bed4d653766 (diff)
Add test for detecting png animation
Diffstat (limited to 'test')
-rw-r--r--test/CMakeLists.txt4
-rw-r--r--test/test_apng.cpp21
2 files changed, 23 insertions, 2 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index aa26ae4c..e43b5517 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -1,8 +1,8 @@
-find_package(Qt5 COMPONENTS Core Gui REQUIRED)
+find_package(Qt5 COMPONENTS Core Gui Widgets REQUIRED)
find_package(Catch2 REQUIRED)
add_executable(test test_aopacket.cpp test_caseloading.cpp test_apng.cpp test_bass.cpp ../include/aopacket.h ../src/aopacket.cpp)
target_include_directories(test PRIVATE ../include)
target_link_directories(test PRIVATE ../lib)
-target_link_libraries(test PRIVATE Qt5::Core Qt5::Gui Catch2::Catch2 bass bassopus discord-rpc)
+target_link_libraries(test PRIVATE Qt5::Core Qt5::Gui Qt5::Widgets Catch2::Catch2 bass bassopus discord-rpc)
target_compile_definitions(Attorney_Online PRIVATE DISCORD)
diff --git a/test/test_apng.cpp b/test/test_apng.cpp
index 7d7062bc..cbeb68a7 100644
--- a/test/test_apng.cpp
+++ b/test/test_apng.cpp
@@ -3,6 +3,8 @@
#include <QPluginLoader>
#include <QImageReader>
#include <QCoreApplication>
+#include <QApplication>
+#include <QPixmap>
TEST_CASE("Support APNG Plugin", "[apng]") {
// Check paths for libs
@@ -16,3 +18,22 @@ TEST_CASE("Support APNG Plugin", "[apng]") {
INFO(QImageReader::supportedImageFormats().join(' ').toStdString());
REQUIRE(QImageReader::supportedImageFormats().contains("apng"));
}
+
+TEST_CASE("Detect png animation", "[apng]") {
+ // Required for QPixmap methods
+ int argc = 1;
+ char bin[] = "test";
+ char *argv[] = { bin };
+ QApplication app(argc, argv);
+
+ // Detect apng supports animation
+ QImageReader a("snackoo.png", "apng");
+ REQUIRE(a.supportsAnimation());
+ REQUIRE(!QPixmap::fromImage(a.read()).isNull());
+
+ // Detect png frame has no animation
+ QImageReader p("snackoo-frame.png", "apng");
+ REQUIRE(!p.supportsAnimation());
+ p.setFormat("png");
+ REQUIRE(!QPixmap::fromImage(p.read()).isNull());
+}