summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2017-01-24 15:29:07 +0100
committerJ-P Nurmi <jpnurmi@qt.io>2017-01-25 12:08:59 +0000
commitf0ce8b847e2169ad4ae884dbb35b58e6dd0f1859 (patch)
tree210abe93d5cac1ae7f4f7268023e3bc4696b1eda
parentdb286068f352291416d1fce9fe9953f376b74798 (diff)
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 <mitch.curtis@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
-rw-r--r--tests/auto/snippets/tst_snippets.cpp13
1 files 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<QString, QStringPair> snippetPaths;
QMap<QString, QStringPair> screenshotSnippetPaths;
};
@@ -97,7 +98,15 @@ static void loadAndShow(QQuickView *view, const QString &source)
QSignalSpy warnings(view->engine(), SIGNAL(warnings(QList<QQmlError>)));
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<QQuickItemGrabResult> result = view.contentItem()->grabToImage();