diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/tools/rcc/data/sizes/size-2-0-35-1_python.expected | 68 | ||||
-rw-r--r-- | tests/auto/tools/rcc/tst_rcc.cpp | 41 |
2 files changed, 109 insertions, 0 deletions
diff --git a/tests/auto/tools/rcc/data/sizes/size-2-0-35-1_python.expected b/tests/auto/tools/rcc/data/sizes/size-2-0-35-1_python.expected new file mode 100644 index 0000000000..9dcd131af5 --- /dev/null +++ b/tests/auto/tools/rcc/data/sizes/size-2-0-35-1_python.expected @@ -0,0 +1,68 @@ +# Resource object code (Python 3) +# Created by: object code +# Created by: The Resource Compiler for Qt version 5.14.0 +# WARNING! All changes made in this file will be lost! + +from PySide2 import QtCore + +qt_resource_data = b"\ +\x00\x00\x00\x02\ +0\ +1\ +\x00\x00\x00#\ +0\ +123456789 012345\ +6789 0123456789 \ +12\ +\x00\x00\x00\x01\ +@\ +\ +\x00\x00\x00\x00\ +\ +" + +qt_resource_name = b"\ +\x00\x04\ +\x00\x06\xa8\xa1\ +\x00d\ +\x00a\x00t\x00a\ +\x00\x0a\ +\x04\x08\x0a\xb4\ +\x00d\ +\x00a\x00t\x00a\x00-\x002\x00.\x00t\x00x\x00t\ +\x00\x0b\ +\x00\xb5Ot\ +\x00d\ +\x00a\x00t\x00a\x00-\x003\x005\x00.\x00t\x00x\x00t\ +\x00\x0a\ +\x04\x11\x0a\xb4\ +\x00d\ +\x00a\x00t\x00a\x00-\x001\x00.\x00t\x00x\x00t\ +\x00\x0a\ +\x04\x0e\x0a\xb4\ +\x00d\ +\x00a\x00t\x00a\x00-\x000\x00.\x00t\x00x\x00t\ +" + +qt_resource_struct = b"\ +\x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x01\ +\x00\x00\x00\x00\x00\x00\x00\x00\ +\x00\x00\x00\x00\x00\x02\x00\x00\x00\x04\x00\x00\x00\x02\ +\x00\x00\x00\x00\x00\x00\x00\x00\ +\x00\x00\x00(\x00\x00\x00\x00\x00\x01\x00\x00\x00\x06\ +IGNORE: (time stamp) +\x00\x00\x00\x0e\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\ +IGNORE: (time stamp) +\x00\x00\x00^\x00\x00\x00\x00\x00\x01\x00\x00\x002\ +IGNORE: (time stamp) +\x00\x00\x00D\x00\x00\x00\x00\x00\x01\x00\x00\x00-\ +IGNORE: (time stamp) +" + +def qInitResources(): + QtCore.qRegisterResourceData(0x03, qt_resource_struct, qt_resource_name, qt_resource_data) + +def qCleanupResources(): + QtCore.qUnregisterResourceData(0x03, qt_resource_struct, qt_resource_name, qt_resource_data) + +qInitResources() diff --git a/tests/auto/tools/rcc/tst_rcc.cpp b/tests/auto/tools/rcc/tst_rcc.cpp index 2c63b0c770..24fd79cf19 100644 --- a/tests/auto/tools/rcc/tst_rcc.cpp +++ b/tests/auto/tools/rcc/tst_rcc.cpp @@ -89,6 +89,8 @@ private slots: void readback_data(); void readback(); + void python(); + void cleanupTestCase(); private: @@ -107,6 +109,12 @@ void tst_rcc::initTestCase() QVERIFY(!m_dataPath.isEmpty()); } + +static inline bool isPythonComment(const QString &line) +{ + return line.startsWith(QLatin1Char('#')); +} + static QString doCompare(const QStringList &actual, const QStringList &expected, const QString &timeStampPath) { @@ -116,10 +124,13 @@ static QString doCompare(const QStringList &actual, const QStringList &expected, } QByteArray ba; + const bool isPython = isPythonComment(expected.constFirst()); for (int i = 0, n = expected.size(); i != n; ++i) { QString expectedLine = expected.at(i); if (expectedLine.startsWith("IGNORE:")) continue; + if (isPython && isPythonComment(expectedLine) && isPythonComment(actual.at(i))) + continue; if (expectedLine.startsWith("TIMESTAMP:")) { const QString relativePath = expectedLine.mid(strlen("TIMESTAMP:")); const QFileInfo fi(timeStampPath + QLatin1Char('/') + relativePath); @@ -405,6 +416,36 @@ void tst_rcc::readback() QCOMPARE(resourceData, fileSystemData); } +void tst_rcc::python() +{ + const QString path = m_dataPath + QLatin1String("/sizes"); + const QString testFileRoot = path + QLatin1String("/size-2-0-35-1"); + const QString qrcFile = testFileRoot + QLatin1String(".qrc"); + const QString expectedFile = testFileRoot + QLatin1String("_python.expected"); + const QString actualFile = testFileRoot + QLatin1String(".rcc"); + + QProcess process; + process.setWorkingDirectory(path); + process.start(m_rcc, { "-g", "python", "-o", actualFile, qrcFile}); + QVERIFY2(process.waitForStarted(), msgProcessStartFailed(process).constData()); + if (!process.waitForFinished()) { + process.kill(); + QFAIL(msgProcessTimeout(process).constData()); + } + QVERIFY2(process.exitStatus() == QProcess::NormalExit, + msgProcessCrashed(process).constData()); + QVERIFY2(process.exitCode() == 0, + msgProcessFailed(process).constData()); + + const auto actualLines = readLinesFromFile(actualFile, QString::KeepEmptyParts); + QVERIFY(!actualLines.isEmpty()); + const auto expectedLines = readLinesFromFile(expectedFile, QString::KeepEmptyParts); + QVERIFY(!expectedLines.isEmpty()); + const QString diff = doCompare(actualLines, expectedLines, path); + if (!diff.isEmpty()) + QFAIL(qPrintable(diff)); +} + void tst_rcc::cleanupTestCase() { QDir dataDir(m_dataPath + QLatin1String("/binary")); |