diff options
author | Lars Knoll <lars.knoll@nokia.com> | 2009-03-23 09:18:55 (GMT) |
---|---|---|
committer | Simon Hausmann <simon.hausmann@nokia.com> | 2009-03-23 09:18:55 (GMT) |
commit | e5fcad302d86d316390c6b0f62759a067313e8a9 (patch) | |
tree | c2afbf6f1066b6ce261f14341cf6d310e5595bc1 /tests/auto/rcc | |
download | Qt-e5fcad302d86d316390c6b0f62759a067313e8a9.zip Qt-e5fcad302d86d316390c6b0f62759a067313e8a9.tar.gz Qt-e5fcad302d86d316390c6b0f62759a067313e8a9.tar.bz2 |
Long live Qt 4.5!
Diffstat (limited to 'tests/auto/rcc')
-rw-r--r-- | tests/auto/rcc/.gitignore | 1 | ||||
-rw-r--r-- | tests/auto/rcc/data/images.bin.expected | bin | 0 -> 663 bytes | |||
-rw-r--r-- | tests/auto/rcc/data/images.expected | 126 | ||||
-rw-r--r-- | tests/auto/rcc/data/images.qrc | 7 | ||||
-rw-r--r-- | tests/auto/rcc/data/images/circle.png | bin | 0 -> 165 bytes | |||
-rw-r--r-- | tests/auto/rcc/data/images/square.png | bin | 0 -> 94 bytes | |||
-rw-r--r-- | tests/auto/rcc/data/images/subdir/triangle.png | bin | 0 -> 170 bytes | |||
-rw-r--r-- | tests/auto/rcc/rcc.pro | 6 | ||||
-rw-r--r-- | tests/auto/rcc/tst_rcc.cpp | 173 |
9 files changed, 313 insertions, 0 deletions
diff --git a/tests/auto/rcc/.gitignore b/tests/auto/rcc/.gitignore new file mode 100644 index 0000000..1da39db --- /dev/null +++ b/tests/auto/rcc/.gitignore @@ -0,0 +1 @@ +tst_rcc diff --git a/tests/auto/rcc/data/images.bin.expected b/tests/auto/rcc/data/images.bin.expected Binary files differnew file mode 100644 index 0000000..cb67a25 --- /dev/null +++ b/tests/auto/rcc/data/images.bin.expected diff --git a/tests/auto/rcc/data/images.expected b/tests/auto/rcc/data/images.expected new file mode 100644 index 0000000..24d75b6 --- /dev/null +++ b/tests/auto/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 bool qRegisterResourceData + (int, const unsigned char *, const unsigned char *, const unsigned char *); + +extern 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/rcc/data/images.qrc b/tests/auto/rcc/data/images.qrc new file mode 100644 index 0000000..773baef --- /dev/null +++ b/tests/auto/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/rcc/data/images/circle.png b/tests/auto/rcc/data/images/circle.png Binary files differnew file mode 100644 index 0000000..dc392cb --- /dev/null +++ b/tests/auto/rcc/data/images/circle.png diff --git a/tests/auto/rcc/data/images/square.png b/tests/auto/rcc/data/images/square.png Binary files differnew file mode 100644 index 0000000..c0fd2d5 --- /dev/null +++ b/tests/auto/rcc/data/images/square.png diff --git a/tests/auto/rcc/data/images/subdir/triangle.png b/tests/auto/rcc/data/images/subdir/triangle.png Binary files differnew file mode 100644 index 0000000..2ee15f8 --- /dev/null +++ b/tests/auto/rcc/data/images/subdir/triangle.png diff --git a/tests/auto/rcc/rcc.pro b/tests/auto/rcc/rcc.pro new file mode 100644 index 0000000..d6a2083 --- /dev/null +++ b/tests/auto/rcc/rcc.pro @@ -0,0 +1,6 @@ +CONFIG += qttest_p4 + +TARGET = tst_rcc + +SOURCES += tst_rcc.cpp + diff --git a/tests/auto/rcc/tst_rcc.cpp b/tests/auto/rcc/tst_rcc.cpp new file mode 100644 index 0000000..3297b2b --- /dev/null +++ b/tests/auto/rcc/tst_rcc.cpp @@ -0,0 +1,173 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, 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. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $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(); + +private: +}; + + +QString findExpectedFile(const QString &base) +{ + QString expectedrccfile = base; + + if (QT_VERSION >= 0x040500 && QFileInfo(expectedrccfile + QLatin1String(".450")).exists()) + expectedrccfile += QLatin1String(".450"); + else if (QT_VERSION >= 0x040400 && QFileInfo(expectedrccfile + QLatin1String(".440")).exists()) + expectedrccfile += QLatin1String(".440"); + else if (QT_VERSION >= 0x040300 && QFileInfo(expectedrccfile + QLatin1String(".430")).exists()) + expectedrccfile += QLatin1String(".430"); + else if (QT_VERSION >= 0x040200 && QFileInfo(expectedrccfile + QLatin1String(".420")).exists()) + expectedrccfile += QLatin1String(".420"); + else if (QT_VERSION >= 0x040100 && QFileInfo(expectedrccfile + QLatin1String(".410")).exists()) + expectedrccfile += QLatin1String(".410"); + else if (QT_VERSION >= 0x040000 && QFileInfo(expectedrccfile + QLatin1String(".400")).exists()) + expectedrccfile += QLatin1String(".400"); + + 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") << "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_MAIN(tst_rcc) + +#include "tst_rcc.moc" |