Refactor the test for detecting apng from png
This commit is contained in:
parent
29354d919f
commit
760d586160
@ -26,28 +26,36 @@ TEST_CASE("Detect png animation", "[apng][noci]") {
|
|||||||
char *argv[] = { bin };
|
char *argv[] = { bin };
|
||||||
QGuiApplication app(argc, argv);
|
QGuiApplication app(argc, argv);
|
||||||
|
|
||||||
// Detect apng supports animation
|
// Instantiate reader
|
||||||
QImageReader a("snackoo.png", "apng");
|
QImageReader reader;
|
||||||
REQUIRE(a.supportsAnimation());
|
|
||||||
REQUIRE(!QPixmap::fromImage(a.read()).isNull());
|
|
||||||
|
|
||||||
// Detect png frame has no animation
|
SECTION("Decide format from content fails on apng") {
|
||||||
QImageReader p("snackoo-frame.png", "apng");
|
reader.setFileName("snackoo.png");
|
||||||
REQUIRE(!p.supportsAnimation());
|
reader.setDecideFormatFromContent(true);
|
||||||
p.setFormat("png");
|
REQUIRE(!reader.supportsAnimation());
|
||||||
REQUIRE(!QPixmap::fromImage(p.read()).isNull());
|
REQUIRE(!QPixmap::fromImage(reader.read()).isNull());
|
||||||
|
}
|
||||||
|
|
||||||
// Auto detect fails on apng
|
SECTION("Auto detect fails on apng") {
|
||||||
QImageReader d;
|
reader.setFileName("snackoo.png");
|
||||||
d.setAutoDetectImageFormat(true);
|
reader.setAutoDetectImageFormat(true);
|
||||||
d.setFileName("snackoo.png");
|
REQUIRE(!reader.supportsAnimation());
|
||||||
REQUIRE(!d.supportsAnimation());
|
REQUIRE(!QPixmap::fromImage(reader.read()).isNull());
|
||||||
REQUIRE(!QPixmap::fromImage(d.read()).isNull());
|
}
|
||||||
|
|
||||||
// Decide format fom content fails on apng
|
SECTION("Detect apng supports animation") {
|
||||||
QImageReader c;
|
reader.setFileName("snackoo.png");
|
||||||
c.setDecideFormatFromContent(true);
|
reader.setFormat("apng");
|
||||||
c.setFileName("snackoo.png");
|
REQUIRE(reader.supportsAnimation());
|
||||||
REQUIRE(!c.supportsAnimation());
|
REQUIRE(!QPixmap::fromImage(reader.read()).isNull());
|
||||||
REQUIRE(!QPixmap::fromImage(c.read()).isNull());
|
}
|
||||||
|
|
||||||
|
SECTION("Detect png frame has no animation") {
|
||||||
|
reader.setFileName("snackoo-frame.png");
|
||||||
|
reader.setFormat("apng");
|
||||||
|
REQUIRE(!reader.supportsAnimation());
|
||||||
|
reader.setFormat("png");
|
||||||
|
REQUIRE(!reader.supportsAnimation());
|
||||||
|
REQUIRE(!QPixmap::fromImage(reader.read()).isNull());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user