aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quickwidgets
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2016-06-27 11:55:33 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2016-06-27 15:40:17 +0000
commit97212616d5a7fc68d9ee97015751326ec2908287 (patch)
treeada8f172265b097406489672cd29cda1029f4642 /tests/auto/quickwidgets
parentc9d4c8ed97694defea78184a80874764ebedfda1 (diff)
Lazy create QmlEngine on accessing rootContext
A common usecase appears to be to set variables in the rootContext before loading a url in a QQuickWidget. We there need to ensure there is a QmlEngine to set variables on when this is attempted. Change-Id: I07aff2104313eeb3fab902ea3c6043c3c82c50f7 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Diffstat (limited to 'tests/auto/quickwidgets')
-rw-r--r--tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp b/tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp
index 9b4d0dd7d1..ab2c41b6bf 100644
--- a/tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp
+++ b/tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp
@@ -305,9 +305,13 @@ void tst_qquickwidget::grabBeforeShow()
void tst_qquickwidget::nullEngine()
{
QQuickWidget widget;
- QVERIFY(widget.engine() == Q_NULLPTR);
+ // Default should have no errors, even with a null qml engine
QVERIFY(widget.errors().isEmpty());
QCOMPARE(widget.status(), QQuickWidget::Null);
+
+ // A QML engine should be created lazily.
+ QVERIFY(widget.rootContext());
+ QVERIFY(widget.engine());
}
QTEST_MAIN(tst_qquickwidget)