diff options
Diffstat (limited to 'tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp')
-rw-r--r-- | tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp b/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp index 9ad53aaa8b..266a4e97d6 100644 --- a/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp +++ b/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp @@ -58,9 +58,11 @@ private slots: void qmlSingletonWithinModule(); void multiSingletonModule(); void implicitComponentModule(); + void customDiskCachePath(); void qrcRootPathUrl(); void implicitImport(); void compositeSingletonCycle(); + void declarativeCppType(); }; void tst_QQMLTypeLoader::testLoadComplete() @@ -94,6 +96,8 @@ void tst_QQMLTypeLoader::trimCache() { QQmlEngine engine; QQmlTypeLoader &loader = QQmlEnginePrivate::get(&engine)->typeLoader; + QVector<QQmlTypeData *> releaseLater; + QVector<QV4::ExecutableCompilationUnit *> releaseCompilationUnitLater; for (int i = 0; i < 256; ++i) { QUrl url = testFileUrl("trim_cache.qml"); url.setQuery(QString::number(i)); @@ -106,8 +110,10 @@ void tst_QQMLTypeLoader::trimCache() // QQmlTypeData or its compiledData() should prevent the trimming. if (i % 10 == 0) { // keep ref on data, don't add ref on data->compiledData() + releaseLater.append(data); } else if (i % 5 == 0) { data->compilationUnit()->addref(); + releaseCompilationUnitLater.append(data->compilationUnit()); data->release(); } else { data->release(); @@ -123,6 +129,12 @@ void tst_QQMLTypeLoader::trimCache() QVERIFY(!loader.isTypeLoaded(url)); // The cache is free to keep the others. } + + for (auto *data : qAsConst(releaseCompilationUnitLater)) + data->release(); + + for (auto *data : qAsConst(releaseLater)) + data->release(); } void tst_QQMLTypeLoader::trimCache2() @@ -508,6 +520,35 @@ void tst_QQMLTypeLoader::implicitComponentModule() checkCleanCacheLoad(QLatin1String("implicitComponentModule")); } +void tst_QQMLTypeLoader::customDiskCachePath() +{ +#if QT_CONFIG(process) + const char *skipKey = "QT_TST_QQMLTYPELOADER_SKIP_MISMATCH"; + if (qEnvironmentVariableIsSet(skipKey)) { + QQmlEngine engine; + QQmlComponent component(&engine, testFileUrl("Base.qml")); + QCOMPARE(component.status(), QQmlComponent::Ready); + QScopedPointer<QObject> obj(component.create()); + QVERIFY(!obj.isNull()); + return; + } + + QTemporaryDir dir; + QProcess child; + child.setProgram(QCoreApplication::applicationFilePath()); + child.setArguments(QStringList(QLatin1String("customDiskCachePath"))); + QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); + env.insert(QLatin1String(skipKey), QLatin1String("1")); + env.insert(QLatin1String("QML_DISK_CACHE_PATH"), dir.path()); + child.setProcessEnvironment(env); + child.start(); + QVERIFY(child.waitForFinished()); + QCOMPARE(child.exitCode(), 0); + QDir cacheDir(dir.path()); + QVERIFY(!cacheDir.isEmpty()); +#endif +} + void tst_QQMLTypeLoader::qrcRootPathUrl() { QQmlEngine engine; @@ -542,6 +583,15 @@ void tst_QQMLTypeLoader::compositeSingletonCycle() QCOMPARE(qvariant_cast<QColor>(object->property("color")), QColorConstants::Black); } +void tst_QQMLTypeLoader::declarativeCppType() +{ + QQmlEngine engine; + QQmlComponent component(&engine, testFileUrl("declarativeCppType.qml")); + QCOMPARE(component.status(), QQmlComponent::Ready); + QScopedPointer<QObject> obj(component.create()); + QVERIFY(!obj.isNull()); +} + QTEST_MAIN(tst_QQMLTypeLoader) #include "tst_qqmltypeloader.moc" |