diff options
author | Liang Qi <liang.qi@qt.io> | 2016-09-18 13:07:22 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2016-09-21 11:16:28 +0200 |
commit | 02b4770c3d867bf0b562db63015a7137479db10a (patch) | |
tree | 57157d0101a295fd394bf9acc91dd216fb361264 /tests/auto/qml/qqmltypeloader | |
parent | 858c62583ff776edb8c9e539f0331f5d658de2d1 (diff) | |
parent | 345226aa3ecee8642c3bf46e40c981d4a49d958e (diff) |
Merge remote-tracking branch 'origin/5.7' into 5.8
Conflicts:
src/qml/qml/qqmltypeloader.cpp
Change-Id: I07647700fc86764c95a5ef95c568e700a70fe45f
Diffstat (limited to 'tests/auto/qml/qqmltypeloader')
5 files changed, 54 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmltypeloader/data/MyComponent.qml b/tests/auto/qml/qqmltypeloader/data/MyComponent.qml new file mode 100644 index 0000000000..a642518199 --- /dev/null +++ b/tests/auto/qml/qqmltypeloader/data/MyComponent.qml @@ -0,0 +1,11 @@ +import QtQuick 2.0 + +Rectangle { + width: 100 + height: 62 + + MyComponent3 {} + + MyComponent2 {} +} + diff --git a/tests/auto/qml/qqmltypeloader/data/MyComponent2.qml b/tests/auto/qml/qqmltypeloader/data/MyComponent2.qml new file mode 100644 index 0000000000..02cf5cb5dd --- /dev/null +++ b/tests/auto/qml/qqmltypeloader/data/MyComponent2.qml @@ -0,0 +1,7 @@ +import QtQuick 2.0 + +Rectangle { + width: 100 + height: 62 +} + diff --git a/tests/auto/qml/qqmltypeloader/data/MyComponent3.qml b/tests/auto/qml/qqmltypeloader/data/MyComponent3.qml new file mode 100644 index 0000000000..ad5d569197 --- /dev/null +++ b/tests/auto/qml/qqmltypeloader/data/MyComponent3.qml @@ -0,0 +1,9 @@ +import QtQuick 2.0 + +Rectangle { + width: 100 + height: 62 + + MyComponent4 {} +} + diff --git a/tests/auto/qml/qqmltypeloader/data/trim_cache2.qml b/tests/auto/qml/qqmltypeloader/data/trim_cache2.qml new file mode 100644 index 0000000000..326a720a87 --- /dev/null +++ b/tests/auto/qml/qqmltypeloader/data/trim_cache2.qml @@ -0,0 +1,13 @@ +import QtQuick 2.0 + +Item { + width: 400 + height: 400 + + Component.onCompleted: { + var component = Qt.createComponent("MyComponent.qml") + if (component.status == Component.Error) + console.log(component.errorString()) + } +} + diff --git a/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp b/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp index 74f3929783..3d3a7ff725 100644 --- a/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp +++ b/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp @@ -42,6 +42,7 @@ private slots: void testLoadComplete(); void loadComponentSynchronously(); void trimCache(); + void trimCache2(); }; void tst_QQMLTypeLoader::testLoadComplete() @@ -106,6 +107,19 @@ void tst_QQMLTypeLoader::trimCache() } } +void tst_QQMLTypeLoader::trimCache2() +{ + QQuickView *window = new QQuickView(); + window->setSource(testFileUrl("trim_cache2.qml")); + QQmlTypeLoader &loader = QQmlEnginePrivate::get(window->engine())->typeLoader; + // in theory if gc has already run this could be false + // QCOMPARE(loader.isTypeLoaded(testFileUrl("MyComponent2.qml")), true); + window->engine()->collectGarbage(); + QTest::qWait(1); // force event loop + window->engine()->trimComponentCache(); + QCOMPARE(loader.isTypeLoaded(testFileUrl("MyComponent2.qml")), false); +} + QTEST_MAIN(tst_QQMLTypeLoader) #include "tst_qqmltypeloader.moc" |