rcc test: Avoid repetitive invocation of QFINDTESTDATA()
Store the test data path in a member variable. Task-number: PYSIDE-855 Change-Id: Ibb81e4024c870e67e209c79ec95264e747632bc6 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
parent
d8ac4b40b5
commit
d41a46bc39
@ -66,6 +66,7 @@ private slots:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_rcc;
|
QString m_rcc;
|
||||||
|
QString m_dataPath;
|
||||||
};
|
};
|
||||||
|
|
||||||
void tst_rcc::initTestCase()
|
void tst_rcc::initTestCase()
|
||||||
@ -74,6 +75,9 @@ void tst_rcc::initTestCase()
|
|||||||
// we must force a certain hash order when testing or tst_rcc will fail, see QTBUG-25078
|
// we must force a certain hash order when testing or tst_rcc will fail, see QTBUG-25078
|
||||||
QVERIFY(qputenv("QT_RCC_TEST", "1"));
|
QVERIFY(qputenv("QT_RCC_TEST", "1"));
|
||||||
m_rcc = QLibraryInfo::location(QLibraryInfo::BinariesPath) + QLatin1String("/rcc");
|
m_rcc = QLibraryInfo::location(QLibraryInfo::BinariesPath) + QLatin1String("/rcc");
|
||||||
|
|
||||||
|
m_dataPath = QFINDTESTDATA("data");
|
||||||
|
QVERIFY(!m_dataPath.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
QString findExpectedFile(const QString &base)
|
QString findExpectedFile(const QString &base)
|
||||||
@ -126,14 +130,10 @@ void tst_rcc::rcc_data()
|
|||||||
QTest::addColumn<QString>("qrcfile");
|
QTest::addColumn<QString>("qrcfile");
|
||||||
QTest::addColumn<QString>("expected");
|
QTest::addColumn<QString>("expected");
|
||||||
|
|
||||||
QString dataPath = QFINDTESTDATA("data/images/");
|
const QString imagesPath = m_dataPath + QLatin1String("/images/");
|
||||||
if (dataPath.isEmpty())
|
QTest::newRow("images") << imagesPath << "images.qrc" << "images.expected";
|
||||||
QFAIL("data path not found");
|
|
||||||
QTest::newRow("images") << dataPath << "images.qrc" << "images.expected";
|
|
||||||
|
|
||||||
QString sizesPath = QFINDTESTDATA("data/sizes/");
|
const QString sizesPath = m_dataPath + QLatin1String("/sizes/");
|
||||||
if (sizesPath.isEmpty())
|
|
||||||
QFAIL("data path not found");
|
|
||||||
QTest::newRow("size-0") << sizesPath << "size-0.qrc" << "size-0.expected";
|
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-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";
|
QTest::newRow("size-2-0-35-1") << sizesPath << "size-2-0-35-1.qrc" << "size-2-0-35-1.expected";
|
||||||
@ -268,9 +268,7 @@ void tst_rcc::binary_data()
|
|||||||
QTest::addColumn<QString>("baseDirectory");
|
QTest::addColumn<QString>("baseDirectory");
|
||||||
QTest::addColumn<QStringMap>("expectedFiles");
|
QTest::addColumn<QStringMap>("expectedFiles");
|
||||||
|
|
||||||
QString dataPath = QFINDTESTDATA("data/binary/");
|
QString dataPath = m_dataPath + QLatin1String("/binary/");
|
||||||
if (dataPath.isEmpty())
|
|
||||||
QFAIL("data path not found");
|
|
||||||
|
|
||||||
QDirIterator iter(dataPath, QStringList() << QLatin1String("*.qrc"));
|
QDirIterator iter(dataPath, QStringList() << QLatin1String("*.qrc"));
|
||||||
while (iter.hasNext())
|
while (iter.hasNext())
|
||||||
@ -386,16 +384,12 @@ void tst_rcc::readback()
|
|||||||
QFETCH(QString, resourceName);
|
QFETCH(QString, resourceName);
|
||||||
QFETCH(QString, fileSystemName);
|
QFETCH(QString, fileSystemName);
|
||||||
|
|
||||||
QString dataPath = QFINDTESTDATA("data/");
|
|
||||||
if (dataPath.isEmpty())
|
|
||||||
QFAIL("data path not found");
|
|
||||||
|
|
||||||
QFile resourceFile(resourceName);
|
QFile resourceFile(resourceName);
|
||||||
QVERIFY(resourceFile.open(QIODevice::ReadOnly));
|
QVERIFY(resourceFile.open(QIODevice::ReadOnly));
|
||||||
QByteArray resourceData = resourceFile.readAll();
|
QByteArray resourceData = resourceFile.readAll();
|
||||||
resourceFile.close();
|
resourceFile.close();
|
||||||
|
|
||||||
QFile fileSystemFile(dataPath + fileSystemName);
|
QFile fileSystemFile(m_dataPath + QLatin1Char('/') + fileSystemName);
|
||||||
QVERIFY(fileSystemFile.open(QIODevice::ReadOnly));
|
QVERIFY(fileSystemFile.open(QIODevice::ReadOnly));
|
||||||
QByteArray fileSystemData = fileSystemFile.readAll();
|
QByteArray fileSystemData = fileSystemFile.readAll();
|
||||||
fileSystemFile.close();
|
fileSystemFile.close();
|
||||||
@ -405,10 +399,7 @@ void tst_rcc::readback()
|
|||||||
|
|
||||||
void tst_rcc::cleanupTestCase()
|
void tst_rcc::cleanupTestCase()
|
||||||
{
|
{
|
||||||
QString dataPath = QFINDTESTDATA("data/binary/");
|
QDir dataDir(m_dataPath + QLatin1String("/binary"));
|
||||||
if (dataPath.isEmpty())
|
|
||||||
return;
|
|
||||||
QDir dataDir(dataPath);
|
|
||||||
QFileInfoList entries = dataDir.entryInfoList(QStringList() << QLatin1String("*.rcc"));
|
QFileInfoList entries = dataDir.entryInfoList(QStringList() << QLatin1String("*.rcc"));
|
||||||
foreach (const QFileInfo &entry, entries)
|
foreach (const QFileInfo &entry, entries)
|
||||||
QFile::remove(entry.absoluteFilePath());
|
QFile::remove(entry.absoluteFilePath());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user