diff options
author | Simon Hausmann <simon.hausmann@qt.io> | 2016-11-22 15:53:07 +0100 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2016-11-23 13:06:27 +0000 |
commit | eb7ec4fb9492b51d8371d8689b9538d6d22d13fd (patch) | |
tree | f809e744c90e5dc53d6454b4927df43598da04d4 /tests/auto/qml/qmldiskcache | |
parent | d236661940b09194cc6a864ffbe687569922787e (diff) |
Fix handling of qrc:/// urls with disk caching
Use the right function for converting a qrc:/// url to a local path.
QUrl::toLocalFile() gives us an empty path, which prevents us from
getting a time stamp and comparing it against the stamp in the cache
file.
This fixes disk caching with samegame.
Change-Id: Id3eb270f1f7a7f25143d2f075a45f32bdb0384c5
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'tests/auto/qml/qmldiskcache')
-rw-r--r-- | tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp b/tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp index f8698f0afa..8af446173d 100644 --- a/tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp +++ b/tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp @@ -549,7 +549,6 @@ void tst_qmldiskcache::cacheResources() { CleanlyLoadingComponent component(&engine, QUrl("qrc:/test.qml")); - qDebug() << component.errorString(); QScopedPointer<QObject> obj(component.create()); QVERIFY(!obj.isNull()); QCOMPARE(obj->property("value").toInt(), 20); @@ -558,17 +557,37 @@ void tst_qmldiskcache::cacheResources() const QStringList entries = QDir(qmlCacheDirectory).entryList(QDir::NoDotAndDotDot | QDir::Files); QCOMPARE(entries.count(), 1); + QDateTime cacheFileTimeStamp; + { QFile cacheFile(qmlCacheDirectory + QLatin1Char('/') + entries.constFirst()); QVERIFY2(cacheFile.open(QIODevice::ReadOnly), qPrintable(cacheFile.errorString())); QV4::CompiledData::Unit unit; QVERIFY(cacheFile.read(reinterpret_cast<char *>(&unit), sizeof(unit)) == sizeof(unit)); + cacheFileTimeStamp = QFileInfo(cacheFile.fileName()).lastModified(); + QDateTime referenceTimeStamp = QFileInfo(":/test.qml").lastModified(); if (!referenceTimeStamp.isValid()) referenceTimeStamp = QFileInfo(QCoreApplication::applicationFilePath()).lastModified(); QCOMPARE(qint64(unit.sourceTimeStamp), referenceTimeStamp.toMSecsSinceEpoch()); } + + waitForFileSystem(); + + { + CleanlyLoadingComponent component(&engine, QUrl("qrc:///test.qml")); + QScopedPointer<QObject> obj(component.create()); + QVERIFY(!obj.isNull()); + QCOMPARE(obj->property("value").toInt(), 20); + } + + { + const QStringList entries = QDir(qmlCacheDirectory).entryList(QDir::NoDotAndDotDot | QDir::Files); + QCOMPARE(entries.count(), 1); + + QCOMPARE(QFileInfo(qmlCacheDirectory + QLatin1Char('/') + entries.constFirst()).lastModified().toMSecsSinceEpoch(), cacheFileTimeStamp.toMSecsSinceEpoch()); + } } void tst_qmldiskcache::stableOrderOfDependentCompositeTypes() |