diff options
| author | oldmud0 <oldmud0@users.noreply.github.com> | 2021-01-29 12:17:54 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-01-29 12:17:54 -0600 |
| commit | 097220f11afa9cb0a045ac21fdedad6e0df69f57 (patch) | |
| tree | cd9ea0054cf3ec4e584ff650bce7e0a3967ce9e8 /test/test_apng.cpp | |
| parent | 5cafb011f5b3cc2aef780f767e0bf054d18efc0f (diff) | |
| parent | 9242c3dd0d6429ae79679c1f7a2846c228f6d3e8 (diff) | |
Merge pull request #368 from skyedeving/add-tests
Add a CMakeLists, tests, and pipeline to automatically test with Github actions
Diffstat (limited to 'test/test_apng.cpp')
| -rw-r--r-- | test/test_apng.cpp | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/test/test_apng.cpp b/test/test_apng.cpp new file mode 100644 index 0000000..20c7e92 --- /dev/null +++ b/test/test_apng.cpp @@ -0,0 +1,61 @@ +#include <catch2/catch.hpp> + +#include <QPluginLoader> +#include <QImageReader> +#include <QCoreApplication> +#include <QGuiApplication> +#include <QPixmap> + +TEST_CASE("Support APNG Plugin", "[apng]") { + // Check paths for libs + QCoreApplication::addLibraryPath("."); + QCoreApplication::addLibraryPath("lib"); + + // Either it's loaded from system or we load local + QPluginLoader apngPlugin("qapng"); + apngPlugin.load(); + + 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 }; + QGuiApplication app(argc, argv); + + // Instantiate reader + QImageReader reader; + + SECTION("Decide format from content fails on apng") { + reader.setFileName("snackoo.png"); + reader.setDecideFormatFromContent(true); + REQUIRE(!reader.supportsAnimation()); + REQUIRE(!QPixmap::fromImage(reader.read()).isNull()); + } + + SECTION("Auto detect fails on apng") { + reader.setFileName("snackoo.png"); + reader.setAutoDetectImageFormat(true); + REQUIRE(!reader.supportsAnimation()); + REQUIRE(!QPixmap::fromImage(reader.read()).isNull()); + } + + SECTION("Detect apng supports animation") { + reader.setFileName("snackoo.png"); + reader.setFormat("apng"); + REQUIRE(reader.supportsAnimation()); + REQUIRE(!QPixmap::fromImage(reader.read()).isNull()); + } + + SECTION("Detect png frame has no animation") { + reader.setFileName("missle.png"); + reader.setFormat("apng"); + REQUIRE(!reader.supportsAnimation()); + reader.setFormat("png"); + REQUIRE(!reader.supportsAnimation()); + REQUIRE(!QPixmap::fromImage(reader.read()).isNull()); + } +} |
