aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qmldiskcache
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@qt.io>2016-08-01 15:57:53 +0200
committerSimon Hausmann <simon.hausmann@qt.io>2016-08-04 14:32:11 +0000
commit01575a22ea2d2e54ef1748733929243ca024234b (patch)
tree0069207f40828894baee32346d44dd5e0d1b0bf9 /tests/auto/qml/qmldiskcache
parentd77e544a568dbfff698c4d37c669bc991383fe9b (diff)
Fix interaction of files selectors with disk caching
Make sure to save the .qmlc/.jsc files to the location determined by the file selectors. Change-Id: If535bb1e4f0d20ac692b3d8e6d563f77cd00446b Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'tests/auto/qml/qmldiskcache')
-rw-r--r--tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp52
1 files changed, 52 insertions, 0 deletions
diff --git a/tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp b/tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp
index a4e10205bd..ca47aae92e 100644
--- a/tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp
+++ b/tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp
@@ -36,6 +36,7 @@
#include <private/qv4engine_p.h>
#include <QQmlComponent>
#include <QQmlEngine>
+#include <QQmlFileSelector>
#include <QThread>
class tst_qmldiskcache: public QObject
@@ -49,6 +50,7 @@ private slots:
void registerImportForImplicitComponent();
void basicVersionChecks();
void recompileAfterChange();
+ void fileSelectors();
};
// A wrapper around QQmlComponent to ensure the temporary reference counts
@@ -433,6 +435,56 @@ void tst_qmldiskcache::recompileAfterChange()
}
}
+void tst_qmldiskcache::fileSelectors()
+{
+ QQmlEngine engine;
+
+ QTemporaryDir tempDir;
+ QVERIFY(tempDir.isValid());
+
+ const QString testFilePath = tempDir.path() + "/test.qml";
+ {
+ QFile f(testFilePath);
+ QVERIFY2(f.open(QIODevice::WriteOnly), qPrintable(f.errorString()));
+ f.write(QByteArrayLiteral("import QtQml 2.0\nQtObject { property int value: 42 }"));
+ }
+
+ const QString selector = QStringLiteral("testSelector");
+ const QString selectorPath = tempDir.path() + "/+" + selector;
+ const QString selectedTestFilePath = selectorPath + "/test.qml";
+ {
+ QVERIFY(QDir::root().mkpath(selectorPath));
+ QFile f(selectorPath + "/test.qml");
+ QVERIFY2(f.open(QIODevice::WriteOnly), qPrintable(f.errorString()));
+ f.write(QByteArrayLiteral("import QtQml 2.0\nQtObject { property int value: 100 }"));
+ }
+
+ {
+ QQmlComponent component(&engine, testFilePath);
+ QScopedPointer<QObject> obj(component.create());
+ QVERIFY(!obj.isNull());
+ QCOMPARE(obj->property("value").toInt(), 42);
+
+ QFile cacheFile(testFilePath + "c");
+ QVERIFY2(cacheFile.exists(), qPrintable(cacheFile.fileName()));
+ }
+
+ QQmlFileSelector qmlSelector(&engine);
+ qmlSelector.setExtraSelectors(QStringList() << selector);
+
+ engine.clearComponentCache();
+
+ {
+ QQmlComponent component(&engine, testFilePath);
+ QScopedPointer<QObject> obj(component.create());
+ QVERIFY(!obj.isNull());
+ QCOMPARE(obj->property("value").toInt(), 100);
+
+ QFile cacheFile(selectedTestFilePath + "c");
+ QVERIFY2(cacheFile.exists(), qPrintable(cacheFile.fileName()));
+ }
+}
+
QTEST_MAIN(tst_qmldiskcache)
#include "tst_qmldiskcache.moc"