atrooney-online-2/test/test_apng.cpp
TrickyLeifa c9f52b7223 Ported to CMake, ...
* Ported the project to CMake
  * Android and Mac support dropped for the time
being.
  * Tests, BASS and Discord-RPC are now options
* Restructured and reformated the project.
  * Merged `include` and `src`
  * Renamed `resource` to `data`
  * Renamed various files
  * External libraries headers are no longer included in `src`
  * Replaced header guards with #pragma once
  * Multiple refactors (keywords, headers)
  * Added Qt6 compatibility
* Removed various unused functions and headers
* Reworked AOPacket
  * When content is passed to AOPacket, it should be ensured that the content is already decoded.
  * Encoding/decoding are now static methods.
* Fixed various memory leaks
* Removed animation code for AOImage
  * AOImage is always using static images
* Simplified ChatLogPiece
2024-05-15 00:04:16 +02:00

68 lines
1.7 KiB
C++

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