summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAlex <prevedtest@gmail.com>2013-12-16 22:32:39 +0400
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-12-17 11:22:27 +0100
commita9d13d79298ec7f7c7f69fb38f97b0f48ca45323 (patch)
tree5c53708f1d425df8ebef26f5fec5e24227c9f880 /tests
parent2c7b8941ae4e70787f56fc277b582c8c698716d3 (diff)
Add ICNS (Apple Icon Image) plugin.
Change-Id: I98f79d781e5986ee5602438e02d761c7f5a77217 Reviewed-by: Ivan Komissarov <ABBAPOH@me.com> Reviewed-by: Jake Petroules <jake.petroules@petroules.com> Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com> Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/auto.pro4
-rw-r--r--tests/auto/icns/icns.pro8
-rw-r--r--tests/auto/icns/tst_qicns.cpp129
-rw-r--r--tests/shared/images/icns.qrc15
-rw-r--r--tests/shared/images/icns/test-32bit.icnsbin0 -> 38865 bytes
-rw-r--r--tests/shared/images/icns/test-jp2.icnsbin0 -> 239220 bytes
-rw-r--r--tests/shared/images/icns/test-legacy.icnsbin0 -> 6712 bytes
-rw-r--r--tests/shared/images/icns/test-png.icnsbin0 -> 38792 bytes
-rw-r--r--tests/shared/images/icns/test-write-1024.pngbin0 -> 48514 bytes
-rw-r--r--tests/shared/images/icns/test-write-128.pngbin0 -> 6338 bytes
-rw-r--r--tests/shared/images/icns/test-write-16.pngbin0 -> 671 bytes
-rw-r--r--tests/shared/images/icns/test-write-256.pngbin0 -> 13260 bytes
-rw-r--r--tests/shared/images/icns/test-write-32.pngbin0 -> 1479 bytes
-rw-r--r--tests/shared/images/icns/test-write-512.pngbin0 -> 22098 bytes
-rw-r--r--tests/shared/images/icns/test-write-64.pngbin0 -> 3071 bytes
15 files changed, 155 insertions, 1 deletions
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro
index 6ac74e2..109f216 100644
--- a/tests/auto/auto.pro
+++ b/tests/auto/auto.pro
@@ -2,5 +2,7 @@ TEMPLATE = subdirs
SUBDIRS = \
tga \
wbmp \
- dds
+ dds \
+ icns
+
contains(QT_CONFIG, system-zlib): SUBDIRS += mng tiff
diff --git a/tests/auto/icns/icns.pro b/tests/auto/icns/icns.pro
new file mode 100644
index 0000000..ef891b7
--- /dev/null
+++ b/tests/auto/icns/icns.pro
@@ -0,0 +1,8 @@
+TARGET = tst_qicns
+
+QT = core gui testlib
+CONFIG -= app_bundle
+CONFIG += testcase
+
+SOURCES += tst_qicns.cpp
+RESOURCES += $$PWD/../../shared/images/icns.qrc
diff --git a/tests/auto/icns/tst_qicns.cpp b/tests/auto/icns/tst_qicns.cpp
new file mode 100644
index 0000000..261590e
--- /dev/null
+++ b/tests/auto/icns/tst_qicns.cpp
@@ -0,0 +1,129 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Alex Char.
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the ICNS autotests in the Qt ImageFormats module.
+**
+** $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_qicns: public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void readIcons_data();
+ void readIcons();
+ void writeIcons_data();
+ void writeIcons();
+};
+
+void tst_qicns::readIcons_data()
+{
+ QTest::addColumn<QString>("fileName");
+ QTest::addColumn<QSize>("size");
+ QTest::addColumn<int>("imageCount");
+ QTest::addColumn<QByteArray>("format");
+
+ QTest::newRow("1") << QStringLiteral("test-png") << QSize(128, 128) << 7 << QByteArrayLiteral("png");
+ QTest::newRow("2") << QStringLiteral("test-jp2") << QSize(128, 128) << 7 << QByteArrayLiteral("jp2");
+ QTest::newRow("3") << QStringLiteral("test-32bit") << QSize(128, 128) << 4 << QByteArray();
+ QTest::newRow("4") << QStringLiteral("test-legacy") << QSize(48, 48) << 12 << QByteArray();
+}
+
+void tst_qicns::readIcons()
+{
+ QFETCH(QString, fileName);
+ QFETCH(QSize, size);
+ QFETCH(int, imageCount);
+ QFETCH(QByteArray, format);
+
+ if (!format.isEmpty() && !QImageReader::supportedImageFormats().contains(format))
+ QSKIP("This test requires another image format plugin");
+ const QString path = QStringLiteral(":/icns/") + fileName + QStringLiteral(".icns");
+ QImageReader reader(path);
+ QVERIFY(reader.canRead());
+ QCOMPARE(reader.imageCount(), imageCount);
+
+ for (int i = 0; i < reader.imageCount(); ++i) {
+ QVERIFY2(reader.jumpToImage(i), qPrintable(reader.errorString()));
+ QImage image = reader.read();
+ if (i == 0)
+ QCOMPARE(image.size(), size);
+ QVERIFY2(!image.isNull(), qPrintable(reader.errorString()));
+ }
+}
+
+void tst_qicns::writeIcons_data()
+{
+ QTest::addColumn<QString>("fileName");
+ QTest::addColumn<QSize>("size");
+
+ QTest::newRow("1") << QStringLiteral("test-write-16") << QSize(16, 16);
+ QTest::newRow("2") << QStringLiteral("test-write-32") << QSize(32, 32);
+ QTest::newRow("3") << QStringLiteral("test-write-64") << QSize(64, 64);
+ QTest::newRow("4") << QStringLiteral("test-write-128") << QSize(128, 128);
+ QTest::newRow("5") << QStringLiteral("test-write-512") << QSize(512, 512);
+ QTest::newRow("6") << QStringLiteral("test-write-1024") << QSize(1024, 1024);
+}
+
+void tst_qicns::writeIcons()
+{
+ QTemporaryDir temp(QDir::tempPath() + QStringLiteral("/tst_qincs"));
+ QVERIFY2(temp.isValid(), "Unable to create temp dir.");
+
+ QFETCH(QString, fileName);
+ QFETCH(QSize, size);
+
+ const QString distPath = QStringLiteral("%1/%2.icns").arg(temp.path()).arg(fileName);
+ const QString sourcePath = QStringLiteral(":/icns/%1.png").arg(fileName);
+
+ QImage image(sourcePath);
+ QVERIFY(!image.isNull());
+ QVERIFY(image.size() == size);
+
+ QImageWriter writer(distPath, QByteArrayLiteral("icns"));
+ QVERIFY2(writer.canWrite(), qPrintable(writer.errorString()));
+ QVERIFY2(writer.write(image), qPrintable(writer.errorString()));
+
+ QVERIFY(image == QImage(distPath));
+}
+
+QTEST_MAIN(tst_qicns)
+#include "tst_qicns.moc"
diff --git a/tests/shared/images/icns.qrc b/tests/shared/images/icns.qrc
new file mode 100644
index 0000000..072b78c
--- /dev/null
+++ b/tests/shared/images/icns.qrc
@@ -0,0 +1,15 @@
+<RCC>
+ <qresource prefix="/">
+ <file>icns/test-png.icns</file>
+ <file>icns/test-jp2.icns</file>
+ <file>icns/test-32bit.icns</file>
+ <file>icns/test-legacy.icns</file>
+ <file>icns/test-write-16.png</file>
+ <file>icns/test-write-32.png</file>
+ <file>icns/test-write-64.png</file>
+ <file>icns/test-write-128.png</file>
+ <file>icns/test-write-256.png</file>
+ <file>icns/test-write-512.png</file>
+ <file>icns/test-write-1024.png</file>
+ </qresource>
+</RCC>
diff --git a/tests/shared/images/icns/test-32bit.icns b/tests/shared/images/icns/test-32bit.icns
new file mode 100644
index 0000000..be3921e
--- /dev/null
+++ b/tests/shared/images/icns/test-32bit.icns
Binary files differ
diff --git a/tests/shared/images/icns/test-jp2.icns b/tests/shared/images/icns/test-jp2.icns
new file mode 100644
index 0000000..57125bd
--- /dev/null
+++ b/tests/shared/images/icns/test-jp2.icns
Binary files differ
diff --git a/tests/shared/images/icns/test-legacy.icns b/tests/shared/images/icns/test-legacy.icns
new file mode 100644
index 0000000..fc66fac
--- /dev/null
+++ b/tests/shared/images/icns/test-legacy.icns
Binary files differ
diff --git a/tests/shared/images/icns/test-png.icns b/tests/shared/images/icns/test-png.icns
new file mode 100644
index 0000000..600bc67
--- /dev/null
+++ b/tests/shared/images/icns/test-png.icns
Binary files differ
diff --git a/tests/shared/images/icns/test-write-1024.png b/tests/shared/images/icns/test-write-1024.png
new file mode 100644
index 0000000..d62d14f
--- /dev/null
+++ b/tests/shared/images/icns/test-write-1024.png
Binary files differ
diff --git a/tests/shared/images/icns/test-write-128.png b/tests/shared/images/icns/test-write-128.png
new file mode 100644
index 0000000..1570976
--- /dev/null
+++ b/tests/shared/images/icns/test-write-128.png
Binary files differ
diff --git a/tests/shared/images/icns/test-write-16.png b/tests/shared/images/icns/test-write-16.png
new file mode 100644
index 0000000..a3b27e2
--- /dev/null
+++ b/tests/shared/images/icns/test-write-16.png
Binary files differ
diff --git a/tests/shared/images/icns/test-write-256.png b/tests/shared/images/icns/test-write-256.png
new file mode 100644
index 0000000..7a22292
--- /dev/null
+++ b/tests/shared/images/icns/test-write-256.png
Binary files differ
diff --git a/tests/shared/images/icns/test-write-32.png b/tests/shared/images/icns/test-write-32.png
new file mode 100644
index 0000000..ecede6f
--- /dev/null
+++ b/tests/shared/images/icns/test-write-32.png
Binary files differ
diff --git a/tests/shared/images/icns/test-write-512.png b/tests/shared/images/icns/test-write-512.png
new file mode 100644
index 0000000..12ce0d2
--- /dev/null
+++ b/tests/shared/images/icns/test-write-512.png
Binary files differ
diff --git a/tests/shared/images/icns/test-write-64.png b/tests/shared/images/icns/test-write-64.png
new file mode 100644
index 0000000..d11ccc1
--- /dev/null
+++ b/tests/shared/images/icns/test-write-64.png
Binary files differ