diff options
author | Liang Qi <liang.qi@qt.io> | 2016-04-27 08:47:35 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2016-04-27 08:47:35 +0200 |
commit | da374438be8f34f746f359aa39ae6c59fd1c4854 (patch) | |
tree | 2f3e2a2b93b39dfb825339c98580f23e824fad0e /tests/auto/qml/qqmltypeloader | |
parent | 1be53f4e143d417d60cd1f9a292193dab59b5b20 (diff) | |
parent | 2e6f7f362e62c3285e7d395aca607502c8e8160e (diff) |
Merge remote-tracking branch 'origin/5.6' into 5.7
Conflicts:
src/quick/items/qquickimagebase.cpp
src/imports/layouts/plugin.cpp
Change-Id: I5f48474df4034a1347ec74795c85d369a55b6b21
Diffstat (limited to 'tests/auto/qml/qqmltypeloader')
-rw-r--r-- | tests/auto/qml/qqmltypeloader/SlowImport/plugin.h | 2 | ||||
-rw-r--r-- | tests/auto/qml/qqmltypeloader/data/trim_cache.qml | 8 | ||||
-rw-r--r-- | tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp | 30 |
3 files changed, 39 insertions, 1 deletions
diff --git a/tests/auto/qml/qqmltypeloader/SlowImport/plugin.h b/tests/auto/qml/qqmltypeloader/SlowImport/plugin.h index d3a3b81832..34b3920a38 100644 --- a/tests/auto/qml/qqmltypeloader/SlowImport/plugin.h +++ b/tests/auto/qml/qqmltypeloader/SlowImport/plugin.h @@ -35,7 +35,7 @@ class SlowPlugin : public QQmlExtensionPlugin { Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") + Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) public: void registerTypes(const char *uri); diff --git a/tests/auto/qml/qqmltypeloader/data/trim_cache.qml b/tests/auto/qml/qqmltypeloader/data/trim_cache.qml new file mode 100644 index 0000000000..74303977dd --- /dev/null +++ b/tests/auto/qml/qqmltypeloader/data/trim_cache.qml @@ -0,0 +1,8 @@ +import QtQuick 2.2 +Rectangle +{ + objectName: "dings" + width: 100 + height: 100 + color: "blue" +} diff --git a/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp b/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp index 24358897f7..ef1ea3a897 100644 --- a/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp +++ b/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp @@ -30,6 +30,9 @@ #include <QtQml/qqmlengine.h> #include <QtQuick/qquickview.h> #include <QtQuick/qquickitem.h> +#include <QtQml/private/qqmlengine_p.h> +#include <QtQml/private/qqmltypeloader_p.h> +#include <QtQml/private/qqmlcompiler_p.h> #include "../../shared/util.h" class tst_QQMLTypeLoader : public QQmlDataTest @@ -39,6 +42,7 @@ class tst_QQMLTypeLoader : public QQmlDataTest private slots: void testLoadComplete(); void loadComponentSynchronously(); + void trimCache(); }; void tst_QQMLTypeLoader::testLoadComplete() @@ -68,6 +72,32 @@ void tst_QQMLTypeLoader::loadComponentSynchronously() QVERIFY(o); } +void tst_QQMLTypeLoader::trimCache() +{ + QQmlEngine engine; + QQmlTypeLoader &loader = QQmlEnginePrivate::get(&engine)->typeLoader; + for (int i = 0; i < 256; ++i) { + QUrl url = testFileUrl("trim_cache.qml"); + url.setQuery(QString::number(i)); + + QQmlTypeData *data = loader.getType(url); + if (i % 5 == 0) // keep references to some of them so that they aren't trimmed + data->compiledData()->addref(); + + data->release(); + } + + for (int i = 0; i < 256; ++i) { + QUrl url = testFileUrl("trim_cache.qml"); + url.setQuery(QString::number(i)); + if (i % 5 == 0) + QVERIFY(loader.isTypeLoaded(url)); + else if (i < 128) + QVERIFY(!loader.isTypeLoaded(url)); + // The cache is free to keep the others. + } +} + QTEST_MAIN(tst_QQMLTypeLoader) #include "tst_qqmltypeloader.moc" |