tst_QResourceEngine: store the actual byte contents that we expect
Instead of using a QString with only the prefix, let's do a full comparison to make sure there's no junk at the end of the file. Take the opportunity to remove the nonsense of a space at the end of most of these files (I didn't remove from all). Change-Id: I343f2beed55440a7ac0bfffd15632228c1bfe78f Reviewed-by: Lars Knoll <lars.knoll@qt.io>bb10
parent
7a4f41bad9
commit
6125fce799
|
|
@ -1 +1,2 @@
|
|||
testqrc/test.qrc -crlf
|
||||
*.txt -crlf
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
"This is a korean text file"
|
||||
"This is a korean text file"
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
qwerty
|
||||
qwerty
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
"This is the current dir"
|
||||
"This is the current dir"
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
"This is also the current dir"
|
||||
"This is also the current dir"
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
"This is the other dir"
|
||||
"This is the other dir"
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
"This is in the sub directory"
|
||||
"This is in the sub directory"
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
abc
|
||||
abc
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
def
|
||||
def
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
"This is in the test directory"
|
||||
"This is in the test directory"
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
"This is another file in this directory"
|
||||
"This is another file in this directory"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Copyright (C) 2018 Intel Corporation.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the test suite of the Qt Toolkit.
|
||||
|
|
@ -104,7 +105,7 @@ void tst_QResourceEngine::cleanupTestCase()
|
|||
void tst_QResourceEngine::checkStructure_data()
|
||||
{
|
||||
QTest::addColumn<QString>("pathName");
|
||||
QTest::addColumn<QString>("contents");
|
||||
QTest::addColumn<QByteArray>("contents");
|
||||
QTest::addColumn<QStringList>("containedFiles");
|
||||
QTest::addColumn<QStringList>("containedDirs");
|
||||
QTest::addColumn<QLocale>("locale");
|
||||
|
|
@ -134,7 +135,7 @@ void tst_QResourceEngine::checkStructure_data()
|
|||
|
||||
|
||||
QTest::newRow("root dir") << QString(":/")
|
||||
<< QString()
|
||||
<< QByteArray()
|
||||
<< (QStringList()
|
||||
#if defined(BUILTIN_TESTDATA)
|
||||
<< "parentdir.txt"
|
||||
|
|
@ -146,7 +147,7 @@ void tst_QResourceEngine::checkStructure_data()
|
|||
<< qlonglong(0);
|
||||
|
||||
QTest::newRow("secondary root") << QString(":/secondary_root/")
|
||||
<< QString()
|
||||
<< QByteArray()
|
||||
<< QStringList()
|
||||
<< (QStringList() << QLatin1String("runtime_resource"))
|
||||
<< QLocale::c()
|
||||
|
|
@ -158,56 +159,56 @@ void tst_QResourceEngine::checkStructure_data()
|
|||
const QString root = roots.at(i);
|
||||
|
||||
QTest::newRow(QString(root + "prefix dir").toLatin1().constData()) << QString(root + "test/abc/123/+++")
|
||||
<< QString()
|
||||
<< QByteArray()
|
||||
<< (QStringList() << QLatin1String("currentdir.txt") << QLatin1String("currentdir2.txt") << QLatin1String("parentdir.txt"))
|
||||
<< (QStringList() << QLatin1String("subdir"))
|
||||
<< QLocale::c()
|
||||
<< qlonglong(0);
|
||||
|
||||
QTest::newRow(QString(root + "parent to prefix").toLatin1().constData()) << QString(root + "test/abc/123")
|
||||
<< QString()
|
||||
<< QByteArray()
|
||||
<< QStringList()
|
||||
<< (QStringList() << QLatin1String("+++"))
|
||||
<< QLocale::c()
|
||||
<< qlonglong(0);
|
||||
|
||||
QTest::newRow(QString(root + "two parents prefix").toLatin1().constData()) << QString(root + "test/abc")
|
||||
<< QString()
|
||||
<< QByteArray()
|
||||
<< QStringList()
|
||||
<< QStringList(QLatin1String("123"))
|
||||
<< QLocale::c()
|
||||
<< qlonglong(0);
|
||||
|
||||
QTest::newRow(QString(root + "test dir ").toLatin1().constData()) << QString(root + "test")
|
||||
<< QString()
|
||||
<< QByteArray()
|
||||
<< (QStringList() << QLatin1String("testdir.txt"))
|
||||
<< (QStringList() << QLatin1String("abc") << QLatin1String("test"))
|
||||
<< QLocale::c()
|
||||
<< qlonglong(0);
|
||||
|
||||
QTest::newRow(QString(root + "prefix no slashes").toLatin1().constData()) << QString(root + "withoutslashes")
|
||||
<< QString()
|
||||
<< QByteArray()
|
||||
<< QStringList("blahblah.txt")
|
||||
<< QStringList()
|
||||
<< QLocale::c()
|
||||
<< qlonglong(0);
|
||||
|
||||
QTest::newRow(QString(root + "other dir").toLatin1().constData()) << QString(root + "otherdir")
|
||||
<< QString()
|
||||
<< QByteArray()
|
||||
<< QStringList(QLatin1String("otherdir.txt"))
|
||||
<< QStringList()
|
||||
<< QLocale::c()
|
||||
<< qlonglong(0);
|
||||
|
||||
QTest::newRow(QString(root + "alias dir").toLatin1().constData()) << QString(root + "aliasdir")
|
||||
<< QString()
|
||||
<< QByteArray()
|
||||
<< QStringList(QLatin1String("aliasdir.txt"))
|
||||
<< QStringList()
|
||||
<< QLocale::c()
|
||||
<< qlonglong(0);
|
||||
|
||||
QTest::newRow(QString(root + "second test dir").toLatin1().constData()) << QString(root + "test/test")
|
||||
<< QString()
|
||||
<< QByteArray()
|
||||
<< (QStringList() << QLatin1String("test1.txt") << QLatin1String("test2.txt"))
|
||||
<< QStringList()
|
||||
<< QLocale::c()
|
||||
|
|
@ -215,7 +216,7 @@ void tst_QResourceEngine::checkStructure_data()
|
|||
|
||||
info = QFileInfo(QFINDTESTDATA("testqrc/test/test/test1.txt"));
|
||||
QTest::newRow(QString(root + "test1 text").toLatin1().constData()) << QString(root + "test/test/test1.txt")
|
||||
<< QString("abc")
|
||||
<< QByteArray("abc\n")
|
||||
<< QStringList()
|
||||
<< QStringList()
|
||||
<< QLocale::c()
|
||||
|
|
@ -223,7 +224,7 @@ void tst_QResourceEngine::checkStructure_data()
|
|||
|
||||
info = QFileInfo(QFINDTESTDATA("testqrc/blahblah.txt"));
|
||||
QTest::newRow(QString(root + "text no slashes").toLatin1().constData()) << QString(root + "withoutslashes/blahblah.txt")
|
||||
<< QString("qwerty")
|
||||
<< QByteArray("qwerty\n")
|
||||
<< QStringList()
|
||||
<< QStringList()
|
||||
<< QLocale::c()
|
||||
|
|
@ -232,7 +233,7 @@ void tst_QResourceEngine::checkStructure_data()
|
|||
|
||||
info = QFileInfo(QFINDTESTDATA("testqrc/test/test/test2.txt"));
|
||||
QTest::newRow(QString(root + "test1 text").toLatin1().constData()) << QString(root + "test/test/test2.txt")
|
||||
<< QString("def")
|
||||
<< QByteArray("def\n")
|
||||
<< QStringList()
|
||||
<< QStringList()
|
||||
<< QLocale::c()
|
||||
|
|
@ -240,7 +241,7 @@ void tst_QResourceEngine::checkStructure_data()
|
|||
|
||||
info = QFileInfo(QFINDTESTDATA("testqrc/currentdir.txt"));
|
||||
QTest::newRow(QString(root + "currentdir text").toLatin1().constData()) << QString(root + "test/abc/123/+++/currentdir.txt")
|
||||
<< QString("\"This is the current dir\" ")
|
||||
<< QByteArray("\"This is the current dir\"\n")
|
||||
<< QStringList()
|
||||
<< QStringList()
|
||||
<< QLocale::c()
|
||||
|
|
@ -248,7 +249,7 @@ void tst_QResourceEngine::checkStructure_data()
|
|||
|
||||
info = QFileInfo(QFINDTESTDATA("testqrc/currentdir2.txt"));
|
||||
QTest::newRow(QString(root + "currentdir text2").toLatin1().constData()) << QString(root + "test/abc/123/+++/currentdir2.txt")
|
||||
<< QString("\"This is also the current dir\" ")
|
||||
<< QByteArray("\"This is also the current dir\"\n")
|
||||
<< QStringList()
|
||||
<< QStringList()
|
||||
<< QLocale::c()
|
||||
|
|
@ -256,7 +257,7 @@ void tst_QResourceEngine::checkStructure_data()
|
|||
|
||||
info = QFileInfo(QFINDTESTDATA("parentdir.txt"));
|
||||
QTest::newRow(QString(root + "parentdir text").toLatin1().constData()) << QString(root + "test/abc/123/+++/parentdir.txt")
|
||||
<< QString("abcdefgihklmnopqrstuvwxyz ")
|
||||
<< QByteArray("abcdefgihklmnopqrstuvwxyz \n")
|
||||
<< QStringList()
|
||||
<< QStringList()
|
||||
<< QLocale::c()
|
||||
|
|
@ -264,7 +265,7 @@ void tst_QResourceEngine::checkStructure_data()
|
|||
|
||||
info = QFileInfo(QFINDTESTDATA("testqrc/subdir/subdir.txt"));
|
||||
QTest::newRow(QString(root + "subdir text").toLatin1().constData()) << QString(root + "test/abc/123/+++/subdir/subdir.txt")
|
||||
<< QString("\"This is in the sub directory\" ")
|
||||
<< QByteArray("\"This is in the sub directory\"\n")
|
||||
<< QStringList()
|
||||
<< QStringList()
|
||||
<< QLocale::c()
|
||||
|
|
@ -272,7 +273,7 @@ void tst_QResourceEngine::checkStructure_data()
|
|||
|
||||
info = QFileInfo(QFINDTESTDATA("testqrc/test/testdir.txt"));
|
||||
QTest::newRow(QString(root + "testdir text").toLatin1().constData()) << QString(root + "test/testdir.txt")
|
||||
<< QString("\"This is in the test directory\" ")
|
||||
<< QByteArray("\"This is in the test directory\"\n")
|
||||
<< QStringList()
|
||||
<< QStringList()
|
||||
<< QLocale::c()
|
||||
|
|
@ -280,7 +281,7 @@ void tst_QResourceEngine::checkStructure_data()
|
|||
|
||||
info = QFileInfo(QFINDTESTDATA("testqrc/otherdir/otherdir.txt"));
|
||||
QTest::newRow(QString(root + "otherdir text").toLatin1().constData()) << QString(root + "otherdir/otherdir.txt")
|
||||
<< QString("\"This is the other dir\" ")
|
||||
<< QByteArray("\"This is the other dir\"\n")
|
||||
<< QStringList()
|
||||
<< QStringList()
|
||||
<< QLocale::c()
|
||||
|
|
@ -288,7 +289,7 @@ void tst_QResourceEngine::checkStructure_data()
|
|||
|
||||
info = QFileInfo(QFINDTESTDATA("testqrc/test/testdir2.txt"));
|
||||
QTest::newRow(QString(root + "alias text").toLatin1().constData()) << QString(root + "aliasdir/aliasdir.txt")
|
||||
<< QString("\"This is another file in this directory\" ")
|
||||
<< QByteArray("\"This is another file in this directory\"\n")
|
||||
<< QStringList()
|
||||
<< QStringList()
|
||||
<< QLocale::c()
|
||||
|
|
@ -296,7 +297,7 @@ void tst_QResourceEngine::checkStructure_data()
|
|||
|
||||
info = QFileInfo(QFINDTESTDATA("testqrc/aliasdir/aliasdir.txt"));
|
||||
QTest::newRow(QString(root + "korean text").toLatin1().constData()) << QString(root + "aliasdir/aliasdir.txt")
|
||||
<< QString("\"This is a korean text file\" ")
|
||||
<< QByteArray("\"This is a korean text file\"\n")
|
||||
<< QStringList()
|
||||
<< QStringList()
|
||||
<< QLocale("ko")
|
||||
|
|
@ -304,7 +305,7 @@ void tst_QResourceEngine::checkStructure_data()
|
|||
|
||||
info = QFileInfo(QFINDTESTDATA("testqrc/aliasdir/aliasdir.txt"));
|
||||
QTest::newRow(QString(root + "korean text 2").toLatin1().constData()) << QString(root + "aliasdir/aliasdir.txt")
|
||||
<< QString("\"This is a korean text file\" ")
|
||||
<< QByteArray("\"This is a korean text file\"\n")
|
||||
<< QStringList()
|
||||
<< QStringList()
|
||||
<< QLocale("ko_KR")
|
||||
|
|
@ -312,7 +313,7 @@ void tst_QResourceEngine::checkStructure_data()
|
|||
|
||||
info = QFileInfo(QFINDTESTDATA("testqrc/test/german.txt"));
|
||||
QTest::newRow(QString(root + "german text").toLatin1().constData()) << QString(root + "aliasdir/aliasdir.txt")
|
||||
<< QString("Deutsch")
|
||||
<< QByteArray("Deutsch\n")
|
||||
<< QStringList()
|
||||
<< QStringList()
|
||||
<< QLocale("de")
|
||||
|
|
@ -320,7 +321,7 @@ void tst_QResourceEngine::checkStructure_data()
|
|||
|
||||
info = QFileInfo(QFINDTESTDATA("testqrc/test/german.txt"));
|
||||
QTest::newRow(QString(root + "german text 2").toLatin1().constData()) << QString(root + "aliasdir/aliasdir.txt")
|
||||
<< QString("Deutsch")
|
||||
<< QByteArray("Deutsch\n")
|
||||
<< QStringList()
|
||||
<< QStringList()
|
||||
<< QLocale("de_DE")
|
||||
|
|
@ -330,7 +331,7 @@ void tst_QResourceEngine::checkStructure_data()
|
|||
file.open(QFile::ReadOnly);
|
||||
info = QFileInfo(QFINDTESTDATA("testqrc/aliasdir/compressme.txt"));
|
||||
QTest::newRow(QString(root + "compressed text").toLatin1().constData()) << QString(root + "aliasdir/aliasdir.txt")
|
||||
<< QString(file.readAll())
|
||||
<< file.readAll()
|
||||
<< QStringList()
|
||||
<< QStringList()
|
||||
<< QLocale("de_CH")
|
||||
|
|
@ -341,7 +342,7 @@ void tst_QResourceEngine::checkStructure_data()
|
|||
void tst_QResourceEngine::checkStructure()
|
||||
{
|
||||
QFETCH(QString, pathName);
|
||||
QFETCH(QString, contents);
|
||||
QFETCH(QByteArray, contents);
|
||||
QFETCH(QStringList, containedFiles);
|
||||
QFETCH(QStringList, containedDirs);
|
||||
QFETCH(QLocale, locale);
|
||||
|
|
@ -401,8 +402,8 @@ void tst_QResourceEngine::checkStructure()
|
|||
QFile file(pathName);
|
||||
QVERIFY(file.open(QFile::ReadOnly));
|
||||
|
||||
QByteArray ba = file.readAll();
|
||||
QVERIFY(QString(ba).startsWith(contents));
|
||||
// check contents
|
||||
QCOMPARE(file.readAll(), contents);
|
||||
}
|
||||
QLocale::setDefault(QLocale::system());
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue