diff options
| -rw-r--r-- | test/CMakeLists.txt | 4 | ||||
| -rw-r--r-- | test/test_apng.cpp | 21 |
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()); +} |
