From 77803fce273e0c87cf826ce122f06994ef4658e8 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Tue, 9 Feb 2021 16:49:05 +0100 Subject: Add initialProperties argument to QQuickApplicationHelper This allows setting required properties on loaded QML components. Change-Id: I9737cf85fac027077df234a02f81f5499e0cb6b5 Reviewed-by: Fabian Kosmale --- tests/auto/shared/visualtestutil.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/auto/shared/visualtestutil.h b/tests/auto/shared/visualtestutil.h index 1e530c70..122dd415 100644 --- a/tests/auto/shared/visualtestutil.h +++ b/tests/auto/shared/visualtestutil.h @@ -131,7 +131,8 @@ namespace QQuickVisualTestUtil { public: QQuickApplicationHelper(QQmlDataTest *testCase, const QString &testFilePath, - const QStringList &qmlImportPaths = QStringList()) + const QStringList &qmlImportPaths = {}, + const QVariantMap &initialProperties = {}) { for (const auto &path : qmlImportPaths) engine.addImportPath(path); @@ -139,7 +140,7 @@ namespace QQuickVisualTestUtil QQmlComponent component(&engine); component.loadUrl(testCase->testFileUrl(testFilePath)); - QObject *rootObject = component.create(); + QObject *rootObject = component.createWithInitialProperties(initialProperties); cleanup.reset(rootObject); if (!rootObject) { errorMessage = QString::fromUtf8("Failed to create window: %1").arg(component.errorString()).toUtf8(); -- cgit v1.2.3