rcc: Add some tests
- three more tests cases on expected .qrc generation - a new test comparing data read via resource with the same data directly read from the original file Change-Id: Ic34e68c9fc3fa110110161b57d4129ae44419020 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
parent
b73f1cc045
commit
d9e2bd5388
0
tests/auto/tools/rcc/data/sizes/data/data-0.txt
Normal file
0
tests/auto/tools/rcc/data/sizes/data/data-0.txt
Normal file
1
tests/auto/tools/rcc/data/sizes/data/data-1.txt
Normal file
1
tests/auto/tools/rcc/data/sizes/data/data-1.txt
Normal file
@ -0,0 +1 @@
|
||||
@
|
1
tests/auto/tools/rcc/data/sizes/data/data-2.txt
Normal file
1
tests/auto/tools/rcc/data/sizes/data/data-2.txt
Normal file
@ -0,0 +1 @@
|
||||
01
|
1
tests/auto/tools/rcc/data/sizes/data/data-35.txt
Normal file
1
tests/auto/tools/rcc/data/sizes/data/data-35.txt
Normal file
@ -0,0 +1 @@
|
||||
0123456789 0123456789 0123456789 12
|
88
tests/auto/tools/rcc/data/sizes/size-0.expected
Normal file
88
tests/auto/tools/rcc/data/sizes/size-0.expected
Normal file
@ -0,0 +1,88 @@
|
||||
/****************************************************************************
|
||||
** Resource object code
|
||||
**
|
||||
IGNORE: ** Created by: The Resource Compiler for Qt version 5.11.2
|
||||
**
|
||||
** WARNING! All changes made in this file will be lost!
|
||||
*****************************************************************************/
|
||||
|
||||
static const unsigned char qt_resource_data[] = {
|
||||
IGNORE: // /data/dev/qt-5/qtbase/tests/auto/tools/rcc/data/sizes/data/data-0.txt
|
||||
0x0,0x0,0x0,0x0,
|
||||
|
||||
|
||||
};
|
||||
|
||||
static const unsigned char qt_resource_name[] = {
|
||||
// data
|
||||
0x0,0x4,
|
||||
0x0,0x6,0xa8,0xa1,
|
||||
0x0,0x64,
|
||||
0x0,0x61,0x0,0x74,0x0,0x61,
|
||||
// data-0.txt
|
||||
0x0,0xa,
|
||||
0x4,0xe,0xa,0xb4,
|
||||
0x0,0x64,
|
||||
0x0,0x61,0x0,0x74,0x0,0x61,0x0,0x2d,0x0,0x30,0x0,0x2e,0x0,0x74,0x0,0x78,0x0,0x74,
|
||||
|
||||
};
|
||||
|
||||
static const unsigned char qt_resource_struct[] = {
|
||||
// :
|
||||
0x0,0x0,0x0,0x0,0x0,0x2,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x1,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
// :/data
|
||||
0x0,0x0,0x0,0x0,0x0,0x2,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x2,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
// :/data/data-0.txt
|
||||
0x0,0x0,0x0,0xe,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x0,
|
||||
TIMESTAMP:data/data-0.txt
|
||||
|
||||
};
|
||||
|
||||
#ifdef QT_NAMESPACE
|
||||
# define QT_RCC_PREPEND_NAMESPACE(name) ::QT_NAMESPACE::name
|
||||
# define QT_RCC_MANGLE_NAMESPACE0(x) x
|
||||
# define QT_RCC_MANGLE_NAMESPACE1(a, b) a##_##b
|
||||
# define QT_RCC_MANGLE_NAMESPACE2(a, b) QT_RCC_MANGLE_NAMESPACE1(a,b)
|
||||
# define QT_RCC_MANGLE_NAMESPACE(name) QT_RCC_MANGLE_NAMESPACE2( \
|
||||
QT_RCC_MANGLE_NAMESPACE0(name), QT_RCC_MANGLE_NAMESPACE0(QT_NAMESPACE))
|
||||
#else
|
||||
# define QT_RCC_PREPEND_NAMESPACE(name) name
|
||||
# define QT_RCC_MANGLE_NAMESPACE(name) name
|
||||
#endif
|
||||
|
||||
#ifdef QT_NAMESPACE
|
||||
namespace QT_NAMESPACE {
|
||||
#endif
|
||||
|
||||
bool qRegisterResourceData(int, const unsigned char *, const unsigned char *, const unsigned char *);
|
||||
|
||||
bool qUnregisterResourceData(int, const unsigned char *, const unsigned char *, const unsigned char *);
|
||||
|
||||
#ifdef QT_NAMESPACE
|
||||
}
|
||||
#endif
|
||||
|
||||
int QT_RCC_MANGLE_NAMESPACE(qInitResources)();
|
||||
int QT_RCC_MANGLE_NAMESPACE(qInitResources)()
|
||||
{
|
||||
QT_RCC_PREPEND_NAMESPACE(qRegisterResourceData)
|
||||
(0x2, qt_resource_struct, qt_resource_name, qt_resource_data);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int QT_RCC_MANGLE_NAMESPACE(qCleanupResources)();
|
||||
int QT_RCC_MANGLE_NAMESPACE(qCleanupResources)()
|
||||
{
|
||||
QT_RCC_PREPEND_NAMESPACE(qUnregisterResourceData)
|
||||
(0x2, qt_resource_struct, qt_resource_name, qt_resource_data);
|
||||
return 1;
|
||||
}
|
||||
|
||||
namespace {
|
||||
struct initializer {
|
||||
initializer() { QT_RCC_MANGLE_NAMESPACE(qInitResources)(); }
|
||||
~initializer() { QT_RCC_MANGLE_NAMESPACE(qCleanupResources)(); }
|
||||
} dummy;
|
||||
}
|
5
tests/auto/tools/rcc/data/sizes/size-0.qrc
Normal file
5
tests/auto/tools/rcc/data/sizes/size-0.qrc
Normal file
@ -0,0 +1,5 @@
|
||||
<!DOCTYPE RCC><RCC version="1.0">
|
||||
<qresource>
|
||||
<file>data/data-0.txt</file>
|
||||
</qresource>
|
||||
</RCC>
|
89
tests/auto/tools/rcc/data/sizes/size-1.expected
Normal file
89
tests/auto/tools/rcc/data/sizes/size-1.expected
Normal file
@ -0,0 +1,89 @@
|
||||
/****************************************************************************
|
||||
** Resource object code
|
||||
**
|
||||
IGNORE:** Created by: The Resource Compiler for Qt version 5.11.2
|
||||
**
|
||||
** WARNING! All changes made in this file will be lost!
|
||||
*****************************************************************************/
|
||||
|
||||
static const unsigned char qt_resource_data[] = {
|
||||
IGNORE: // /data/dev/qt-5/qtbase/tests/auto/tools/rcc/data/sizes/data/data-1.txt
|
||||
0x0,0x0,0x0,0x1,
|
||||
0x40,
|
||||
|
||||
|
||||
};
|
||||
|
||||
static const unsigned char qt_resource_name[] = {
|
||||
// data
|
||||
0x0,0x4,
|
||||
0x0,0x6,0xa8,0xa1,
|
||||
0x0,0x64,
|
||||
0x0,0x61,0x0,0x74,0x0,0x61,
|
||||
// data-1.txt
|
||||
0x0,0xa,
|
||||
0x4,0x11,0xa,0xb4,
|
||||
0x0,0x64,
|
||||
0x0,0x61,0x0,0x74,0x0,0x61,0x0,0x2d,0x0,0x31,0x0,0x2e,0x0,0x74,0x0,0x78,0x0,0x74,
|
||||
|
||||
};
|
||||
|
||||
static const unsigned char qt_resource_struct[] = {
|
||||
// :
|
||||
0x0,0x0,0x0,0x0,0x0,0x2,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x1,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
// :/data
|
||||
0x0,0x0,0x0,0x0,0x0,0x2,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x2,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
// :/data/data-1.txt
|
||||
0x0,0x0,0x0,0xe,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x0,
|
||||
TIMESTAMP:data/data-1.txt
|
||||
|
||||
};
|
||||
|
||||
#ifdef QT_NAMESPACE
|
||||
# define QT_RCC_PREPEND_NAMESPACE(name) ::QT_NAMESPACE::name
|
||||
# define QT_RCC_MANGLE_NAMESPACE0(x) x
|
||||
# define QT_RCC_MANGLE_NAMESPACE1(a, b) a##_##b
|
||||
# define QT_RCC_MANGLE_NAMESPACE2(a, b) QT_RCC_MANGLE_NAMESPACE1(a,b)
|
||||
# define QT_RCC_MANGLE_NAMESPACE(name) QT_RCC_MANGLE_NAMESPACE2( \
|
||||
QT_RCC_MANGLE_NAMESPACE0(name), QT_RCC_MANGLE_NAMESPACE0(QT_NAMESPACE))
|
||||
#else
|
||||
# define QT_RCC_PREPEND_NAMESPACE(name) name
|
||||
# define QT_RCC_MANGLE_NAMESPACE(name) name
|
||||
#endif
|
||||
|
||||
#ifdef QT_NAMESPACE
|
||||
namespace QT_NAMESPACE {
|
||||
#endif
|
||||
|
||||
bool qRegisterResourceData(int, const unsigned char *, const unsigned char *, const unsigned char *);
|
||||
|
||||
bool qUnregisterResourceData(int, const unsigned char *, const unsigned char *, const unsigned char *);
|
||||
|
||||
#ifdef QT_NAMESPACE
|
||||
}
|
||||
#endif
|
||||
|
||||
int QT_RCC_MANGLE_NAMESPACE(qInitResources)();
|
||||
int QT_RCC_MANGLE_NAMESPACE(qInitResources)()
|
||||
{
|
||||
QT_RCC_PREPEND_NAMESPACE(qRegisterResourceData)
|
||||
(0x2, qt_resource_struct, qt_resource_name, qt_resource_data);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int QT_RCC_MANGLE_NAMESPACE(qCleanupResources)();
|
||||
int QT_RCC_MANGLE_NAMESPACE(qCleanupResources)()
|
||||
{
|
||||
QT_RCC_PREPEND_NAMESPACE(qUnregisterResourceData)
|
||||
(0x2, qt_resource_struct, qt_resource_name, qt_resource_data);
|
||||
return 1;
|
||||
}
|
||||
|
||||
namespace {
|
||||
struct initializer {
|
||||
initializer() { QT_RCC_MANGLE_NAMESPACE(qInitResources)(); }
|
||||
~initializer() { QT_RCC_MANGLE_NAMESPACE(qCleanupResources)(); }
|
||||
} dummy;
|
||||
}
|
5
tests/auto/tools/rcc/data/sizes/size-1.qrc
Normal file
5
tests/auto/tools/rcc/data/sizes/size-1.qrc
Normal file
@ -0,0 +1,5 @@
|
||||
<!DOCTYPE RCC><RCC version="1.0">
|
||||
<qresource>
|
||||
<file>data/data-1.txt</file>
|
||||
</qresource>
|
||||
</RCC>
|
126
tests/auto/tools/rcc/data/sizes/size-2-0-35-1.expected
Normal file
126
tests/auto/tools/rcc/data/sizes/size-2-0-35-1.expected
Normal file
@ -0,0 +1,126 @@
|
||||
/****************************************************************************
|
||||
** Resource object code
|
||||
**
|
||||
IGNORE: ** Created by: The Resource Compiler for Qt version 5.11.2
|
||||
**
|
||||
** WARNING! All changes made in this file will be lost!
|
||||
*****************************************************************************/
|
||||
|
||||
static const unsigned char qt_resource_data[] = {
|
||||
IGNORE: // /data/dev/qt-5/qtbase/tests/auto/tools/rcc/data/sizes/data/data-2.txt
|
||||
0x0,0x0,0x0,0x2,
|
||||
0x30,
|
||||
0x31,
|
||||
IGNORE: // /data/dev/qt-5/qtbase/tests/auto/tools/rcc/data/sizes/data/data-35.txt
|
||||
0x0,0x0,0x0,0x23,
|
||||
0x30,
|
||||
0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x20,0x30,0x31,0x32,0x33,0x34,0x35,
|
||||
0x36,0x37,0x38,0x39,0x20,0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x20,
|
||||
0x31,0x32,
|
||||
IGNORE: // /data/dev/qt-5/qtbase/tests/auto/tools/rcc/data/sizes/data/data-1.txt
|
||||
0x0,0x0,0x0,0x1,
|
||||
0x40,
|
||||
|
||||
IGNORE: // /data/dev/qt-5/qtbase/tests/auto/tools/rcc/data/sizes/data/data-0.txt
|
||||
0x0,0x0,0x0,0x0,
|
||||
|
||||
|
||||
};
|
||||
|
||||
static const unsigned char qt_resource_name[] = {
|
||||
// data
|
||||
0x0,0x4,
|
||||
0x0,0x6,0xa8,0xa1,
|
||||
0x0,0x64,
|
||||
0x0,0x61,0x0,0x74,0x0,0x61,
|
||||
// data-2.txt
|
||||
0x0,0xa,
|
||||
0x4,0x8,0xa,0xb4,
|
||||
0x0,0x64,
|
||||
0x0,0x61,0x0,0x74,0x0,0x61,0x0,0x2d,0x0,0x32,0x0,0x2e,0x0,0x74,0x0,0x78,0x0,0x74,
|
||||
// data-35.txt
|
||||
0x0,0xb,
|
||||
0x0,0xb5,0x4f,0x74,
|
||||
0x0,0x64,
|
||||
0x0,0x61,0x0,0x74,0x0,0x61,0x0,0x2d,0x0,0x33,0x0,0x35,0x0,0x2e,0x0,0x74,0x0,0x78,0x0,0x74,
|
||||
// data-1.txt
|
||||
0x0,0xa,
|
||||
0x4,0x11,0xa,0xb4,
|
||||
0x0,0x64,
|
||||
0x0,0x61,0x0,0x74,0x0,0x61,0x0,0x2d,0x0,0x31,0x0,0x2e,0x0,0x74,0x0,0x78,0x0,0x74,
|
||||
// data-0.txt
|
||||
0x0,0xa,
|
||||
0x4,0xe,0xa,0xb4,
|
||||
0x0,0x64,
|
||||
0x0,0x61,0x0,0x74,0x0,0x61,0x0,0x2d,0x0,0x30,0x0,0x2e,0x0,0x74,0x0,0x78,0x0,0x74,
|
||||
|
||||
};
|
||||
|
||||
static const unsigned char qt_resource_struct[] = {
|
||||
// :
|
||||
0x0,0x0,0x0,0x0,0x0,0x2,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x1,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
// :/data
|
||||
0x0,0x0,0x0,0x0,0x0,0x2,0x0,0x0,0x0,0x4,0x0,0x0,0x0,0x2,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
// :/data/data-35.txt
|
||||
0x0,0x0,0x0,0x28,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x6,
|
||||
TIMESTAMP:data/data-35.txt
|
||||
// :/data/data-2.txt
|
||||
0x0,0x0,0x0,0xe,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x0,
|
||||
TIMESTAMP:data/data-2.txt
|
||||
// :/data/data-0.txt
|
||||
0x0,0x0,0x0,0x5e,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x32,
|
||||
TIMESTAMP:data/data-0.txt
|
||||
// :/data/data-1.txt
|
||||
0x0,0x0,0x0,0x44,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x2d,
|
||||
TIMESTAMP:data/data-1.txt
|
||||
|
||||
};
|
||||
|
||||
#ifdef QT_NAMESPACE
|
||||
# define QT_RCC_PREPEND_NAMESPACE(name) ::QT_NAMESPACE::name
|
||||
# define QT_RCC_MANGLE_NAMESPACE0(x) x
|
||||
# define QT_RCC_MANGLE_NAMESPACE1(a, b) a##_##b
|
||||
# define QT_RCC_MANGLE_NAMESPACE2(a, b) QT_RCC_MANGLE_NAMESPACE1(a,b)
|
||||
# define QT_RCC_MANGLE_NAMESPACE(name) QT_RCC_MANGLE_NAMESPACE2( \
|
||||
QT_RCC_MANGLE_NAMESPACE0(name), QT_RCC_MANGLE_NAMESPACE0(QT_NAMESPACE))
|
||||
#else
|
||||
# define QT_RCC_PREPEND_NAMESPACE(name) name
|
||||
# define QT_RCC_MANGLE_NAMESPACE(name) name
|
||||
#endif
|
||||
|
||||
#ifdef QT_NAMESPACE
|
||||
namespace QT_NAMESPACE {
|
||||
#endif
|
||||
|
||||
bool qRegisterResourceData(int, const unsigned char *, const unsigned char *, const unsigned char *);
|
||||
|
||||
bool qUnregisterResourceData(int, const unsigned char *, const unsigned char *, const unsigned char *);
|
||||
|
||||
#ifdef QT_NAMESPACE
|
||||
}
|
||||
#endif
|
||||
|
||||
int QT_RCC_MANGLE_NAMESPACE(qInitResources)();
|
||||
int QT_RCC_MANGLE_NAMESPACE(qInitResources)()
|
||||
{
|
||||
QT_RCC_PREPEND_NAMESPACE(qRegisterResourceData)
|
||||
(0x2, qt_resource_struct, qt_resource_name, qt_resource_data);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int QT_RCC_MANGLE_NAMESPACE(qCleanupResources)();
|
||||
int QT_RCC_MANGLE_NAMESPACE(qCleanupResources)()
|
||||
{
|
||||
QT_RCC_PREPEND_NAMESPACE(qUnregisterResourceData)
|
||||
(0x2, qt_resource_struct, qt_resource_name, qt_resource_data);
|
||||
return 1;
|
||||
}
|
||||
|
||||
namespace {
|
||||
struct initializer {
|
||||
initializer() { QT_RCC_MANGLE_NAMESPACE(qInitResources)(); }
|
||||
~initializer() { QT_RCC_MANGLE_NAMESPACE(qCleanupResources)(); }
|
||||
} dummy;
|
||||
}
|
8
tests/auto/tools/rcc/data/sizes/size-2-0-35-1.qrc
Normal file
8
tests/auto/tools/rcc/data/sizes/size-2-0-35-1.qrc
Normal file
@ -0,0 +1,8 @@
|
||||
<!DOCTYPE RCC><RCC version="1.0">
|
||||
<qresource>
|
||||
<file>data/data-2.txt</file>
|
||||
<file>data/data-0.txt</file>
|
||||
<file>data/data-35.txt</file>
|
||||
<file>data/data-1.txt</file>
|
||||
</qresource>
|
||||
</RCC>
|
@ -3,3 +3,10 @@ QT = core testlib
|
||||
TARGET = tst_rcc
|
||||
|
||||
SOURCES += tst_rcc.cpp
|
||||
|
||||
RESOURCES += \
|
||||
$$PWD/data/images/images.qrc \
|
||||
$$PWD/data/sizes/size-0.qrc \
|
||||
$$PWD/data/sizes/size-2-0-35-1.qrc \
|
||||
$$PWD/data/sizes/size-1.qrc
|
||||
|
||||
|
@ -55,9 +55,13 @@ private slots:
|
||||
|
||||
void rcc_data();
|
||||
void rcc();
|
||||
|
||||
void binary_data();
|
||||
void binary();
|
||||
|
||||
void readback_data();
|
||||
void readback();
|
||||
|
||||
void cleanupTestCase();
|
||||
|
||||
private:
|
||||
@ -126,6 +130,13 @@ void tst_rcc::rcc_data()
|
||||
if (dataPath.isEmpty())
|
||||
QFAIL("data path not found");
|
||||
QTest::newRow("images") << dataPath << "images.qrc" << "images.expected";
|
||||
|
||||
QString sizesPath = QFINDTESTDATA("data/sizes/");
|
||||
if (sizesPath.isEmpty())
|
||||
QFAIL("data path not found");
|
||||
QTest::newRow("size-0") << sizesPath << "size-0.qrc" << "size-0.expected";
|
||||
QTest::newRow("size-1") << sizesPath << "size-1.qrc" << "size-1.expected";
|
||||
QTest::newRow("size-2-0-35-1") << sizesPath << "size-2-0-35-1.qrc" << "size-2-0-35-1.expected";
|
||||
}
|
||||
|
||||
void tst_rcc::rcc()
|
||||
@ -353,6 +364,42 @@ void tst_rcc::binary()
|
||||
QLocale::setDefault(oldDefaultLocale);
|
||||
}
|
||||
|
||||
void tst_rcc::readback_data()
|
||||
{
|
||||
QTest::addColumn<QString>("resourceName");
|
||||
QTest::addColumn<QString>("fileSystemName");
|
||||
|
||||
QTest::newRow("data-0") << ":data/data-0.txt" << "sizes/data/data-0.txt";
|
||||
QTest::newRow("data-1") << ":data/data-1.txt" << "sizes/data/data-1.txt";
|
||||
QTest::newRow("data-2") << ":data/data-2.txt" << "sizes/data/data-2.txt";
|
||||
QTest::newRow("data-35") << ":data/data-35.txt" << "sizes/data/data-35.txt";
|
||||
QTest::newRow("circle") << ":images/circle.png" << "images/images/circle.png";
|
||||
QTest::newRow("square") << ":images/square.png" << "images/images/square.png";
|
||||
QTest::newRow("triangle") << ":images/subdir/triangle.png"
|
||||
<< "images/images/subdir/triangle.png";
|
||||
}
|
||||
|
||||
void tst_rcc::readback()
|
||||
{
|
||||
QFETCH(QString, resourceName);
|
||||
QFETCH(QString, fileSystemName);
|
||||
|
||||
QString dataPath = QFINDTESTDATA("data/");
|
||||
if (dataPath.isEmpty())
|
||||
QFAIL("data path not found");
|
||||
|
||||
QFile resourceFile(resourceName);
|
||||
QVERIFY(resourceFile.open(QIODevice::ReadOnly));
|
||||
QByteArray resourceData = resourceFile.readAll();
|
||||
resourceFile.close();
|
||||
|
||||
QFile fileSystemFile(dataPath + fileSystemName);
|
||||
QVERIFY(fileSystemFile.open(QIODevice::ReadOnly));
|
||||
QByteArray fileSystemData = fileSystemFile.readAll();
|
||||
fileSystemFile.close();
|
||||
|
||||
QCOMPARE(resourceData, fileSystemData);
|
||||
}
|
||||
|
||||
void tst_rcc::cleanupTestCase()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user