Fix tst_QFile::useQFileInAFileHandler for systems using resources for test data

Resource files are extracted to m_dataDir in tst_QFile::initTestCase.
Instead of trying to access the file from the resource on systems that
use qrc for bundling the test data, we have to use the files that were
extracted at the beginning of the test.

Change-Id: I35453fbdeb27e317d1342ff1cb7bbea9cebea14d
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
This commit is contained in:
Oliver Wolff 2017-11-08 12:12:06 +01:00
parent e27bd98137
commit bbc68dc815

View File

@ -2190,12 +2190,20 @@ public:
if (fileName.startsWith(":!")) {
QDir dir;
QString realFile = QFINDTESTDATA(fileName.mid(2));
#ifndef BUILTIN_TESTDATA
const QString realFile = QFINDTESTDATA(fileName.mid(2));
#else
const QString realFile = m_dataDir->filePath(fileName.mid(2));
#endif
if (dir.exists(realFile))
return new QFSFileEngine(realFile);
}
return 0;
}
#ifdef BUILTIN_TESTDATA
QSharedPointer<QTemporaryDir> m_dataDir;
#endif
};
#endif
@ -2204,6 +2212,9 @@ void tst_QFile::useQFileInAFileHandler()
{
// This test should not dead-lock
MyRecursiveHandler handler;
#ifdef BUILTIN_TESTDATA
handler.m_dataDir = m_dataDir;
#endif
QFile file(":!tst_qfile.cpp");
QVERIFY(file.exists());
}