summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDayang Shen <Archangel.SDY@gmail.com>2016-03-05 15:40:30 +0800
committerLiang Qi <liang.qi@theqtcompany.com>2016-03-10 14:38:14 +0000
commit1d4f24820c0fff474d524e006d715e13e409a4b8 (patch)
tree903ca840e78e32504699ddb24d535ed25d748796 /tests
parent35b4108a4e2090a856226ac15b796e118655fa8b (diff)
Add animation support to WebP plugin
We now use WebP Demux API to decode both single image format and muxed animation format. Change-Id: Ia2922892a3a626e9921c3910801d7c975d9fc6a2 Reviewed-by: aavit <eirik.aavitsland@theqtcompany.com> Reviewed-by: Liang Qi <liang.qi@theqtcompany.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/webp/images/kollada_animation.webpbin0 -> 24726 bytes
-rw-r--r--tests/auto/webp/tst_qwebp.cpp60
-rw-r--r--tests/auto/webp/webp.qrc1
3 files changed, 61 insertions, 0 deletions
diff --git a/tests/auto/webp/images/kollada_animation.webp b/tests/auto/webp/images/kollada_animation.webp
new file mode 100644
index 0000000..c38751a
--- /dev/null
+++ b/tests/auto/webp/images/kollada_animation.webp
Binary files differ
diff --git a/tests/auto/webp/tst_qwebp.cpp b/tests/auto/webp/tst_qwebp.cpp
index 4126076..d1d30db 100644
--- a/tests/auto/webp/tst_qwebp.cpp
+++ b/tests/auto/webp/tst_qwebp.cpp
@@ -37,6 +37,8 @@ private slots:
void initTestCase();
void readImage_data();
void readImage();
+ void readAnimation_data();
+ void readAnimation();
void writeImage_data();
void writeImage();
};
@@ -69,6 +71,64 @@ void tst_qwebp::readImage()
QCOMPARE(image.size(), size);
}
+void tst_qwebp::readAnimation_data()
+{
+ QTest::addColumn<QString>("fileName");
+ QTest::addColumn<QSize>("size");
+ QTest::addColumn<int>("imageCount");
+ QTest::addColumn<int>("loopCount");
+ QTest::addColumn<QColor>("bgColor");
+ QTest::addColumn<QList<QRect> >("imageRects");
+ QTest::addColumn<QList<int> >("imageDelays");
+
+ QTest::newRow("kollada")
+ << QString("kollada")
+ << QSize(436, 160)
+ << 1
+ << 0
+ << QColor()
+ << (QList<QRect>() << QRect(0, 0, 436, 160))
+ << (QList<int>() << 0);
+ QTest::newRow("kollada_animation")
+ << QString("kollada_animation")
+ << QSize(536, 260)
+ << 2
+ << 2
+ << QColor(128, 128, 128, 128)
+ << (QList<QRect>() << QRect(0, 0, 436, 160) << QRect(100, 100, 436, 160))
+ << (QList<int>() << 1000 << 1200);
+}
+
+void tst_qwebp::readAnimation()
+{
+ QFETCH(QString, fileName);
+ QFETCH(QSize, size);
+ QFETCH(int, imageCount);
+ QFETCH(int, loopCount);
+ QFETCH(QColor, bgColor);
+ QFETCH(QList<QRect>, imageRects);
+ QFETCH(QList<int>, imageDelays);
+
+ const QString path = QStringLiteral(":/images/") + fileName + QStringLiteral(".webp");
+ QImageReader reader(path);
+ QVERIFY(reader.canRead());
+ QCOMPARE(reader.size(), size);
+ QCOMPARE(reader.imageCount(), imageCount);
+ QCOMPARE(reader.loopCount(), loopCount);
+ QCOMPARE(reader.backgroundColor(), bgColor);
+
+ for (int i = 0; i < reader.imageCount(); ++i) {
+ QImage image = reader.read();
+ QVERIFY2(!image.isNull(), qPrintable(reader.errorString()));
+ QCOMPARE(image.size(), size);
+ QCOMPARE(reader.currentImageNumber(), i);
+ QCOMPARE(reader.currentImageRect(), imageRects[i]);
+ QCOMPARE(reader.nextImageDelay(), imageDelays[i]);
+ }
+
+ QVERIFY(reader.read().isNull());
+}
+
void tst_qwebp::writeImage_data()
{
QTest::addColumn<QString>("fileName");
diff --git a/tests/auto/webp/webp.qrc b/tests/auto/webp/webp.qrc
index ab0b1b2..6519e58 100644
--- a/tests/auto/webp/webp.qrc
+++ b/tests/auto/webp/webp.qrc
@@ -3,5 +3,6 @@
<file>images/kollada.png</file>
<file>images/kollada.webp</file>
<file>images/kollada_lossless.webp</file>
+ <file>images/kollada_animation.webp</file>
</qresource>
</RCC>