atrooney-online-2/test/test_apng.cpp
2021-01-28 11:05:42 -06:00

40 lines
1.1 KiB
C++

#include <catch2/catch.hpp>
#include <QPluginLoader>
#include <QImageReader>
#include <QCoreApplication>
#include <QApplication>
#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 };
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());
}