summaryrefslogtreecommitdiffstats
path: root/tests/auto/tools/rcc
diff options
context:
space:
mode:
authorJo Asplin <jo.asplin@nokia.com>2011-09-12 09:21:12 +0200
committerJo Asplin <jo.asplin@nokia.com>2011-09-12 10:08:29 +0200
commit4c43b60323e88befb08504c1ec67305cc8f57e70 (patch)
treef63216a07d69701e791839d7a9938337792eaf73 /tests/auto/tools/rcc
parent3ade4d260f3afe160bd593e27e18f1dffdbee398 (diff)
Moved autotests in category 'tools' into new directory structure
Task-number: QTBUG-21355 Change-Id: I315d4b1f55d42391524c0e8625952dee1b96fca3 Reviewed-on: http://codereview.qt-project.org/4449 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
Diffstat (limited to 'tests/auto/tools/rcc')
-rw-r--r--tests/auto/tools/rcc/.gitignore1
-rw-r--r--tests/auto/tools/rcc/data/images.bin.expectedbin0 -> 663 bytes
-rw-r--r--tests/auto/tools/rcc/data/images.expected126
-rw-r--r--tests/auto/tools/rcc/data/images.qrc7
-rw-r--r--tests/auto/tools/rcc/data/images/circle.pngbin0 -> 165 bytes
-rw-r--r--tests/auto/tools/rcc/data/images/square.pngbin0 -> 94 bytes
-rw-r--r--tests/auto/tools/rcc/data/images/subdir/triangle.pngbin0 -> 170 bytes
-rw-r--r--tests/auto/tools/rcc/rcc.pro12
-rw-r--r--tests/auto/tools/rcc/tst_rcc.cpp162
9 files changed, 308 insertions, 0 deletions
diff --git a/tests/auto/tools/rcc/.gitignore b/tests/auto/tools/rcc/.gitignore
new file mode 100644
index 0000000000..1da39dbd88
--- /dev/null
+++ b/tests/auto/tools/rcc/.gitignore
@@ -0,0 +1 @@
+tst_rcc
diff --git a/tests/auto/tools/rcc/data/images.bin.expected b/tests/auto/tools/rcc/data/images.bin.expected
new file mode 100644
index 0000000000..cb67a25477
--- /dev/null
+++ b/tests/auto/tools/rcc/data/images.bin.expected
Binary files differ
diff --git a/tests/auto/tools/rcc/data/images.expected b/tests/auto/tools/rcc/data/images.expected
new file mode 100644
index 0000000000..71be819310
--- /dev/null
+++ b/tests/auto/tools/rcc/data/images.expected
@@ -0,0 +1,126 @@
+/****************************************************************************
+** Resource object code
+**
+IGNORE: ** Created: Tue Jul 15 11:17:15 2008
+IGNORE: ** by: The Resource Compiler for Qt version 4.4.2
+**
+** WARNING! All changes made in this file will be lost!
+*****************************************************************************/
+
+#include <QtCore/qglobal.h>
+
+static const unsigned char qt_resource_data[] = {
+IGNORE: // /data5/dev/qt/tests/auto/rcc/data/images/square.png
+ 0x0,0x0,0x0,0x5e,
+ 0x89,
+ 0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,
+ 0x0,0x0,0x20,0x0,0x0,0x0,0x20,0x1,0x3,0x0,0x0,0x0,0x49,0xb4,0xe8,0xb7,
+ 0x0,0x0,0x0,0x6,0x50,0x4c,0x54,0x45,0x0,0x0,0x0,0x58,0xa8,0xff,0x8c,0x14,
+ 0x1f,0xab,0x0,0x0,0x0,0x13,0x49,0x44,0x41,0x54,0x8,0xd7,0x63,0x60,0x0,0x81,
+ 0xfa,0xff,0xff,0xff,0xd,0x3e,0x2,0x4,0x0,0x8d,0x4d,0x68,0x6b,0xcf,0xb8,0x8e,
+ 0x86,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82,
+IGNORE: // /data5/dev/qt/tests/auto/rcc/data/images/circle.png
+ 0x0,0x0,0x0,0xa5,
+ 0x89,
+ 0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,
+ 0x0,0x0,0x20,0x0,0x0,0x0,0x20,0x8,0x6,0x0,0x0,0x0,0x73,0x7a,0x7a,0xf4,
+ 0x0,0x0,0x0,0x6c,0x49,0x44,0x41,0x54,0x58,0xc3,0xed,0xd7,0x5b,0xe,0x0,0x10,
+ 0xc,0x44,0x51,0xcb,0xb4,0x44,0xbb,0x64,0x3,0x1e,0xd5,0x18,0x1d,0x31,0x12,0xdf,
+ 0xf7,0x7c,0xd1,0xa6,0xf4,0xe8,0xa9,0x93,0x8b,0x8f,0xe6,0x52,0x87,0x17,0x81,0x59,
+ 0x46,0xd,0x18,0x7f,0xdc,0x13,0x1e,0x40,0x62,0xe2,0x5e,0xc4,0xd1,0xf8,0x2e,0x2,
+ 0x12,0xb7,0x22,0xa0,0x71,0xb,0x22,0x14,0x70,0x25,0x3e,0x43,0xfc,0xd,0xb8,0x1a,
+ 0xef,0x21,0x4,0x10,0x40,0x0,0x3d,0x44,0x14,0x0,0x7d,0xc7,0x14,0x13,0x11,0xc5,
+ 0x4c,0x48,0x31,0x15,0x53,0xec,0x5,0x14,0x9b,0x11,0xc5,0x6e,0x8,0xdd,0x8e,0x1b,
+ 0x14,0x54,0x19,0xf3,0xa1,0x23,0xdb,0xd5,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,
+ 0xae,0x42,0x60,0x82,
+IGNORE: // /data5/dev/qt/tests/auto/rcc/data/images/subdir/triangle.png
+ 0x0,0x0,0x0,0xaa,
+ 0x89,
+ 0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,
+ 0x0,0x0,0x20,0x0,0x0,0x0,0x20,0x8,0x6,0x0,0x0,0x0,0x73,0x7a,0x7a,0xf4,
+ 0x0,0x0,0x0,0x71,0x49,0x44,0x41,0x54,0x58,0xc3,0xed,0xce,0x4b,0xa,0x80,0x30,
+ 0x10,0x4,0xd1,0x1c,0xd3,0x23,0x7a,0xcb,0x11,0x82,0xb8,0x50,0x62,0x92,0xf9,0xd5,
+ 0x66,0x1a,0x7a,0x5d,0xaf,0xb5,0x5a,0xcd,0x36,0xb9,0xcf,0xc4,0x8f,0x53,0xfa,0x9,
+ 0xc4,0x13,0xa7,0x10,0x28,0xe0,0x13,0xcf,0x44,0xc,0xe3,0x59,0x8,0x14,0x30,0x8d,
+ 0x47,0x23,0x50,0xc0,0x72,0x3c,0x2,0xb1,0x1d,0xf7,0x46,0xa0,0x0,0x75,0xdc,0x3,
+ 0x61,0x8e,0x5b,0x11,0x28,0xc0,0x2d,0xae,0x45,0xa0,0x0,0xf7,0xf8,0xe,0x22,0x2c,
+ 0xbe,0x8a,0x40,0x1,0xe1,0xf1,0x3f,0x44,0x5a,0x7c,0x84,0x40,0x1,0xe9,0xf1,0x37,
+ 0x42,0xe0,0xd7,0xd8,0x5d,0xf,0x6f,0x97,0x11,0x88,0x38,0xa9,0x1e,0x0,0x0,0x0,
+ 0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82,
+
+};
+
+static const unsigned char qt_resource_name[] = {
+ // images
+ 0x0,0x6,
+ 0x7,0x3,0x7d,0xc3,
+ 0x0,0x69,
+ 0x0,0x6d,0x0,0x61,0x0,0x67,0x0,0x65,0x0,0x73,
+ // square.png
+ 0x0,0xa,
+ 0x8,0x8b,0x6,0x27,
+ 0x0,0x73,
+ 0x0,0x71,0x0,0x75,0x0,0x61,0x0,0x72,0x0,0x65,0x0,0x2e,0x0,0x70,0x0,0x6e,0x0,0x67,
+ // circle.png
+ 0x0,0xa,
+ 0xa,0x2d,0x16,0x47,
+ 0x0,0x63,
+ 0x0,0x69,0x0,0x72,0x0,0x63,0x0,0x6c,0x0,0x65,0x0,0x2e,0x0,0x70,0x0,0x6e,0x0,0x67,
+ // subdir
+ 0x0,0x6,
+ 0x7,0xab,0x8b,0x2,
+ 0x0,0x73,
+ 0x0,0x75,0x0,0x62,0x0,0x64,0x0,0x69,0x0,0x72,
+ // triangle.png
+ 0x0,0xc,
+ 0x5,0x59,0xa7,0xc7,
+ 0x0,0x74,
+ 0x0,0x72,0x0,0x69,0x0,0x61,0x0,0x6e,0x0,0x67,0x0,0x6c,0x0,0x65,0x0,0x2e,0x0,0x70,0x0,0x6e,0x0,0x67,
+
+};
+
+static const unsigned char qt_resource_struct[] = {
+ // :
+ 0x0,0x0,0x0,0x0,0x0,0x2,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x1,
+ // :/images
+ 0x0,0x0,0x0,0x0,0x0,0x2,0x0,0x0,0x0,0x3,0x0,0x0,0x0,0x2,
+ // :/images/subdir
+ 0x0,0x0,0x0,0x46,0x0,0x2,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x5,
+ // :/images/square.png
+ 0x0,0x0,0x0,0x12,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x0,
+ // :/images/circle.png
+ 0x0,0x0,0x0,0x2c,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x62,
+ // :/images/subdir/triangle.png
+ 0x0,0x0,0x0,0x58,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0x1,0xb,
+
+};
+
+QT_BEGIN_NAMESPACE
+
+extern Q_CORE_EXPORT bool qRegisterResourceData
+ (int, const unsigned char *, const unsigned char *, const unsigned char *);
+
+extern Q_CORE_EXPORT bool qUnregisterResourceData
+ (int, const unsigned char *, const unsigned char *, const unsigned char *);
+
+QT_END_NAMESPACE
+
+
+int QT_MANGLE_NAMESPACE(qInitResources)()
+{
+ QT_PREPEND_NAMESPACE(qRegisterResourceData)
+ (0x01, qt_resource_struct, qt_resource_name, qt_resource_data);
+ return 1;
+}
+
+Q_CONSTRUCTOR_FUNCTION(QT_MANGLE_NAMESPACE(qInitResources))
+
+int QT_MANGLE_NAMESPACE(qCleanupResources)()
+{
+ QT_PREPEND_NAMESPACE(qUnregisterResourceData)
+ (0x01, qt_resource_struct, qt_resource_name, qt_resource_data);
+ return 1;
+}
+
+Q_DESTRUCTOR_FUNCTION(QT_MANGLE_NAMESPACE(qCleanupResources))
+
diff --git a/tests/auto/tools/rcc/data/images.qrc b/tests/auto/tools/rcc/data/images.qrc
new file mode 100644
index 0000000000..773baef3e5
--- /dev/null
+++ b/tests/auto/tools/rcc/data/images.qrc
@@ -0,0 +1,7 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+ <file>images/circle.png</file>
+ <file>images/square.png</file>
+ <file>images/subdir/triangle.png</file>
+</qresource>
+</RCC>
diff --git a/tests/auto/tools/rcc/data/images/circle.png b/tests/auto/tools/rcc/data/images/circle.png
new file mode 100644
index 0000000000..dc392cb3f7
--- /dev/null
+++ b/tests/auto/tools/rcc/data/images/circle.png
Binary files differ
diff --git a/tests/auto/tools/rcc/data/images/square.png b/tests/auto/tools/rcc/data/images/square.png
new file mode 100644
index 0000000000..c0fd2d540a
--- /dev/null
+++ b/tests/auto/tools/rcc/data/images/square.png
Binary files differ
diff --git a/tests/auto/tools/rcc/data/images/subdir/triangle.png b/tests/auto/tools/rcc/data/images/subdir/triangle.png
new file mode 100644
index 0000000000..2ee15f8f1f
--- /dev/null
+++ b/tests/auto/tools/rcc/data/images/subdir/triangle.png
Binary files differ
diff --git a/tests/auto/tools/rcc/rcc.pro b/tests/auto/tools/rcc/rcc.pro
new file mode 100644
index 0000000000..1759b48a0e
--- /dev/null
+++ b/tests/auto/tools/rcc/rcc.pro
@@ -0,0 +1,12 @@
+CONFIG += qttest_p4
+
+TARGET = tst_rcc
+
+SOURCES += tst_rcc.cpp
+
+wince* {
+ DEFINES += SRCDIR=\\\"\\\"
+} else {
+ DEFINES += SRCDIR=\\\"$$PWD/\\\"
+}
+
diff --git a/tests/auto/tools/rcc/tst_rcc.cpp b/tests/auto/tools/rcc/tst_rcc.cpp
new file mode 100644
index 0000000000..90baf36b35
--- /dev/null
+++ b/tests/auto/tools/rcc/tst_rcc.cpp
@@ -0,0 +1,162 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtCore/QCoreApplication>
+#include <QtCore/QByteArray>
+#include <QtCore/QDebug>
+#include <QtCore/QDir>
+#include <QtCore/QFile>
+#include <QtCore/QProcess>
+#include <QtCore/QTimer>
+
+#include <QtTest/QtTest>
+
+
+class tst_rcc : public QObject
+{
+ Q_OBJECT
+public:
+ tst_rcc() {}
+
+private slots:
+ void rcc_data();
+ void rcc();
+};
+
+
+QString findExpectedFile(const QString &base)
+{
+ QString expectedrccfile = base;
+
+ // Must be updated with each minor release.
+ if (QFileInfo(expectedrccfile + QLatin1String(".450")).exists())
+ expectedrccfile += QLatin1String(".450");
+
+ return expectedrccfile;
+}
+
+static QString doCompare(const QStringList &actual, const QStringList &expected)
+{
+ if (actual.size() != expected.size()) {
+ return QString("Length count different: actual: %1, expected: %2")
+ .arg(actual.size()).arg(expected.size());
+ }
+
+ QByteArray ba;
+ for (int i = 0, n = expected.size(); i != n; ++i) {
+ if (expected.at(i).startsWith("IGNORE:"))
+ continue;
+ if (expected.at(i) != actual.at(i)) {
+ qDebug() << "LINES" << i << "DIFFER";
+ ba.append(
+ "\n<<<<<< actual\n" + actual.at(i) + "\n======\n" + expected.at(i)
+ + "\n>>>>>> expected\n"
+ );
+ }
+ }
+ return ba;
+}
+
+
+void tst_rcc::rcc_data()
+{
+ QTest::addColumn<QString>("directory");
+ QTest::addColumn<QString>("qrcfile");
+ QTest::addColumn<QString>("expected");
+
+ QTest::newRow("images") << SRCDIR "data" << "images.qrc" << "images.expected";
+}
+
+void tst_rcc::rcc()
+{
+ QFETCH(QString, directory);
+ QFETCH(QString, qrcfile);
+ QFETCH(QString, expected);
+
+ if (!QDir::setCurrent(directory)) {
+ QString message = QString::fromLatin1("Unable to cd from '%1' to '%2'").arg(QDir::currentPath(), directory);
+ QFAIL(qPrintable(message));
+ }
+
+ // If the file expectedoutput.txt exists, compare the
+ // console output with the content of that file
+ const QString expected2 = findExpectedFile(expected);
+ QFile expectedFile(expected2);
+ if (!expectedFile.exists()) {
+ qDebug() << "NO EXPECTATIONS? " << expected2;
+ return;
+ }
+
+ // Launch
+ const QString command = QLatin1String("rcc");
+ QProcess process;
+ process.start(command, QStringList(qrcfile));
+ if (!process.waitForFinished()) {
+ const QString path = QString::fromLocal8Bit(qgetenv("PATH"));
+ QString message = QString::fromLatin1("'%1' could not be found when run from '%2'. Path: '%3' ").
+ arg(command, QDir::currentPath(), path);
+ QFAIL(qPrintable(message));
+ }
+ const QChar cr = QLatin1Char('\r');
+ const QString err = QString::fromLocal8Bit(process.readAllStandardError()).remove(cr);
+ const QString out = QString::fromAscii(process.readAllStandardOutput()).remove(cr);
+
+ if (!err.isEmpty()) {
+ qDebug() << "UNEXPECTED STDERR CONTENTS: " << err;
+ QFAIL("UNEXPECTED STDERR CONTENTS");
+ }
+
+ const QChar nl = QLatin1Char('\n');
+ const QStringList actualLines = out.split(nl);
+
+ QVERIFY(expectedFile.open(QIODevice::ReadOnly|QIODevice::Text));
+ const QStringList expectedLines = QString::fromAscii(expectedFile.readAll()).split(nl);
+
+ const QString diff = doCompare(actualLines, expectedLines);
+ if (diff.size())
+ QFAIL(qPrintable(diff));
+}
+
+
+
+QTEST_APPLESS_MAIN(tst_rcc)
+
+#include "tst_rcc.moc"