summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorSteven Yao <yaodong1974@hotmail.com>2013-04-25 09:26:53 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-02-13 08:41:33 +0100
commit4522b350e53471c2ebc6d4692736ee4708445b66 (patch)
tree3dd204d86d012eda94045516a2fec25b366bf256 /tests
parentd8d421ce5b2c218f0075ef457139cd4f17505de7 (diff)
Added webp image format plugin
Also added auto test and config test. This plugin was disabled on winrt and android. [ChangeLog] Added webp image format plugin. Task-number: QTBUG-14205 Done-with: Liang Qi <liang.qi@digia.com> Change-Id: I9409e894d7fc1aef9dce4ffdff8bdf483d689774 Reviewed-by: Ivan Komissarov <ABBAPOH@gmail.com> Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/auto.pro3
-rw-r--r--tests/auto/webp/images/kollada.pngbin0 -> 13907 bytes
-rw-r--r--tests/auto/webp/images/kollada.webpbin0 -> 11628 bytes
-rw-r--r--tests/auto/webp/images/kollada_lossless.webpbin0 -> 20488 bytes
-rw-r--r--tests/auto/webp/images/lena.jpgbin0 -> 7326 bytes
-rw-r--r--tests/auto/webp/images/lena.webpbin0 -> 2790 bytes
-rw-r--r--tests/auto/webp/images/lena_lossless.webpbin0 -> 9062 bytes
-rw-r--r--tests/auto/webp/tst_qwebp.cpp119
-rw-r--r--tests/auto/webp/webp.pro8
-rw-r--r--tests/auto/webp/webp.qrc10
10 files changed, 139 insertions, 1 deletions
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro
index 73f1014..deda6cb 100644
--- a/tests/auto/auto.pro
+++ b/tests/auto/auto.pro
@@ -4,6 +4,7 @@ SUBDIRS = \
wbmp \
dds \
icns \
- jp2
+ jp2 \
+ webp
contains(QT_CONFIG, system-zlib): SUBDIRS += mng tiff
diff --git a/tests/auto/webp/images/kollada.png b/tests/auto/webp/images/kollada.png
new file mode 100644
index 0000000..2abd4bb
--- /dev/null
+++ b/tests/auto/webp/images/kollada.png
Binary files differ
diff --git a/tests/auto/webp/images/kollada.webp b/tests/auto/webp/images/kollada.webp
new file mode 100644
index 0000000..7bbfe98
--- /dev/null
+++ b/tests/auto/webp/images/kollada.webp
Binary files differ
diff --git a/tests/auto/webp/images/kollada_lossless.webp b/tests/auto/webp/images/kollada_lossless.webp
new file mode 100644
index 0000000..fc6a353
--- /dev/null
+++ b/tests/auto/webp/images/kollada_lossless.webp
Binary files differ
diff --git a/tests/auto/webp/images/lena.jpg b/tests/auto/webp/images/lena.jpg
new file mode 100644
index 0000000..7add3fc
--- /dev/null
+++ b/tests/auto/webp/images/lena.jpg
Binary files differ
diff --git a/tests/auto/webp/images/lena.webp b/tests/auto/webp/images/lena.webp
new file mode 100644
index 0000000..4e1d816
--- /dev/null
+++ b/tests/auto/webp/images/lena.webp
Binary files differ
diff --git a/tests/auto/webp/images/lena_lossless.webp b/tests/auto/webp/images/lena_lossless.webp
new file mode 100644
index 0000000..250f945
--- /dev/null
+++ b/tests/auto/webp/images/lena_lossless.webp
Binary files differ
diff --git a/tests/auto/webp/tst_qwebp.cpp b/tests/auto/webp/tst_qwebp.cpp
new file mode 100644
index 0000000..2f84037
--- /dev/null
+++ b/tests/auto/webp/tst_qwebp.cpp
@@ -0,0 +1,119 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtAddOn.ImageFormats module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/QtTest>
+#include <QtGui/QtGui>
+
+class tst_qwebp : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void readImage_data();
+ void readImage();
+ void writeImage_data();
+ void writeImage();
+};
+
+void tst_qwebp::readImage_data()
+{
+ QTest::addColumn<QString>("fileName");
+ QTest::addColumn<QSize>("size");
+
+ QTest::newRow("lena") << QString("lena") << QSize(103, 103);
+ QTest::newRow("lena_lossless") << QString("lena_lossless") << QSize(103, 103);
+ QTest::newRow("kollada") << QString("kollada") << QSize(436, 160);
+ QTest::newRow("kollada_lossless") << QString("kollada_lossless") << QSize(436, 160);
+}
+
+void tst_qwebp::readImage()
+{
+ QFETCH(QString, fileName);
+ QFETCH(QSize, size);
+
+ const QString path = QStringLiteral(":/images/") + fileName + QStringLiteral(".webp");
+ QImageReader reader(path);
+ QVERIFY(reader.canRead());
+ QImage image = reader.read();
+ QVERIFY2(!image.isNull(), qPrintable(reader.errorString()));
+ QCOMPARE(image.size(), size);
+}
+
+void tst_qwebp::writeImage_data()
+{
+ QTest::addColumn<QString>("fileName");
+ QTest::addColumn<QString>("postfix");
+ QTest::addColumn<int>("quality");
+ QTest::addColumn<QSize>("size");
+ QTest::addColumn<bool>("needcheck");
+
+ QTest::newRow("lena-90") << QString("lena") << QString(".jpg") << 90 << QSize(103, 103) << false;
+ QTest::newRow("lena-100") << QString("lena") << QString(".jpg") << 100 << QSize(103, 103) << false;
+ QTest::newRow("kollada-75") << QString("kollada") << QString(".png") << 75 << QSize(436, 160) << false;
+ QTest::newRow("kollada-100") << QString("kollada") << QString(".png") << 100 << QSize(436, 160) << true;
+}
+
+void tst_qwebp::writeImage()
+{
+ QFETCH(QString, fileName);
+ QFETCH(QString, postfix);
+ QFETCH(int, quality);
+ QFETCH(QSize, size);
+ QFETCH(bool, needcheck);
+
+ const QString path = QString("%1-%2.webp").arg(fileName).arg(quality);
+ const QString sourcePath = QStringLiteral(":/images/") + fileName + postfix;
+
+ QImage image(sourcePath);
+ QVERIFY(!image.isNull());
+ QVERIFY(image.size() == size);
+
+ QImageWriter writer(path, QByteArrayLiteral("webp"));
+ QVERIFY2(writer.canWrite(), qPrintable(writer.errorString()));
+ writer.setQuality(quality);
+ QVERIFY2(writer.write(image), qPrintable(writer.errorString()));
+
+ if (needcheck)
+ QVERIFY(image == QImage(path));
+}
+
+QTEST_MAIN(tst_qwebp)
+#include "tst_qwebp.moc"
diff --git a/tests/auto/webp/webp.pro b/tests/auto/webp/webp.pro
new file mode 100644
index 0000000..666ab51
--- /dev/null
+++ b/tests/auto/webp/webp.pro
@@ -0,0 +1,8 @@
+TARGET = tst_qwebp
+
+QT = core gui testlib
+CONFIG -= app_bundle
+CONFIG += testcase
+
+SOURCES += tst_qwebp.cpp
+RESOURCES += $$PWD/webp.qrc
diff --git a/tests/auto/webp/webp.qrc b/tests/auto/webp/webp.qrc
new file mode 100644
index 0000000..6cf0ea0
--- /dev/null
+++ b/tests/auto/webp/webp.qrc
@@ -0,0 +1,10 @@
+<RCC>
+ <qresource prefix="/">
+ <file>images/lena.jpg</file>
+ <file>images/lena.webp</file>
+ <file>images/lena_lossless.webp</file>
+ <file>images/kollada.png</file>
+ <file>images/kollada.webp</file>
+ <file>images/kollada_lossless.webp</file>
+ </qresource>
+</RCC>