aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp')
-rw-r--r--tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp b/tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp
index 5838193a6b..cb4bee0d3a 100644
--- a/tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp
+++ b/tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp
@@ -70,6 +70,7 @@ private slots:
void contextLeak();
void outerContextObject();
+ void contextObjectHierarchy();
private:
QQmlEngine engine;
@@ -873,6 +874,24 @@ void tst_qqmlcontext::outerContextObject()
QTRY_VERIFY(iterations >= 100);
}
+void tst_qqmlcontext::contextObjectHierarchy()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.loadUrl(testFileUrl("contextObjectHierarchy.qml"));
+ QVERIFY(component.isReady());
+ QScopedPointer<QObject> root(component.create());
+ QVERIFY(!root.isNull());
+
+ for (const QObject *child : root->children())
+ QVERIFY(QQmlData::get(child)->outerContext != nullptr);
+
+ connect(root.data(), &QObject::destroyed, [&root]() {
+ for (const QObject *child : root->children())
+ QCOMPARE(QQmlData::get(child)->outerContext, nullptr);
+ });
+}
+
QTEST_MAIN(tst_qqmlcontext)
#include "tst_qqmlcontext.moc"