From f0ce8b847e2169ad4ae884dbb35b58e6dd0f1859 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Tue, 24 Jan 2017 15:29:07 +0100 Subject: tst_snippets: share a single QQuickView instance for all data rows This test contains a lot of data rows. Re-creating a QQuickView for every data row puts a lot of stress on the system. In the new Open Nebula -based CI, things start consistently exploding after a random amount of tst_snippets data rows. This change fixes that. Task-number: QTBUG-58196 Change-Id: I6549944a6d7b2bd384d09ee974bee6423ffe625c Reviewed-by: Mitch Curtis Reviewed-by: Qt CI Bot --- tests/auto/snippets/tst_snippets.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tests/auto/snippets/tst_snippets.cpp b/tests/auto/snippets/tst_snippets.cpp index e5e3ab9e..f870ec7d 100644 --- a/tests/auto/snippets/tst_snippets.cpp +++ b/tests/auto/snippets/tst_snippets.cpp @@ -53,6 +53,7 @@ private slots: void screenshots_data(); private: + QQuickView view; QMap snippetPaths; QMap screenshotSnippetPaths; }; @@ -97,7 +98,15 @@ static void loadAndShow(QQuickView *view, const QString &source) QSignalSpy warnings(view->engine(), SIGNAL(warnings(QList))); QVERIFY(warnings.isValid()); - view->setSource(QUrl::fromLocalFile(source)); + QUrl url = QUrl::fromLocalFile(source); + QQmlComponent *component = new QQmlComponent(view->engine(), view); + component->loadUrl(url); + + QObject *root = component->beginCreate(view->rootContext()); + QVERIFY(root); + view->setContent(url, component, root); + component->completeCreate(); + QCOMPARE(view->status(), QQuickView::Ready); QVERIFY(view->errors().isEmpty()); QVERIFY(view->rootObject()); @@ -113,7 +122,6 @@ void tst_Snippets::verify() { QFETCH(QString, input); - QQuickView view; loadAndShow(&view, input); QGuiApplication::processEvents(); } @@ -132,7 +140,6 @@ void tst_Snippets::screenshots() QFETCH(QString, input); QFETCH(QString, output); - QQuickView view; loadAndShow(&view, input); QSharedPointer result = view.contentItem()->grabToImage(); -- cgit v1.2.3