diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index aa26ae4..e43b551 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 7d7062b..cbeb68a 100644 --- a/test/test_apng.cpp +++ b/test/test_apng.cpp @@ -3,6 +3,8 @@ #include #include #include +#include +#include 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()); +}