aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/shared
diff options
context:
space:
mode:
authorJan Arve Sæther <jan-arve.saether@qt.io>2019-02-07 13:22:49 +0100
committerShawn Rutledge <shawn.rutledge@qt.io>2019-02-11 08:29:54 +0000
commita804f31ee2665501c1894cbae8302db181090bd5 (patch)
tree688a03606c47bb5f1d2df001e9119508c99615a9 /tests/auto/quick/shared
parentf2cc7c8580f2a25554cf37426096935c62a5b7af (diff)
Move initView() to tests/auto/quick/shared
According to our "Coin - Flaky Tests" dashboard on our grafana, initView() in tst_qquickmousearea seems to have very few flakiness issues in actually exposing a QQuickView. It is therefore a good idea to share this implementation so that it can be used by other tests too. Change-Id: Ie83cbf7d00fa02bdd4699757471fa180945851e3 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'tests/auto/quick/shared')
-rw-r--r--tests/auto/quick/shared/viewtestutil.cpp27
-rw-r--r--tests/auto/quick/shared/viewtestutil.h4
2 files changed, 31 insertions, 0 deletions
diff --git a/tests/auto/quick/shared/viewtestutil.cpp b/tests/auto/quick/shared/viewtestutil.cpp
index 3bfa23173e..12d54c4bbe 100644
--- a/tests/auto/quick/shared/viewtestutil.cpp
+++ b/tests/auto/quick/shared/viewtestutil.cpp
@@ -451,3 +451,30 @@ namespace QQuickTouchUtils {
}
}
+
+namespace QQuickTest {
+ // Initialize view, set Url, center in available geometry, move mouse away if desired
+ bool initView(QQuickView &v, const QUrl &url, bool moveMouseOut, QByteArray *errorMessage)
+ {
+ v.setBaseSize(QSize(240,320));
+ v.setSource(url);
+ while (v.status() == QQuickView::Loading)
+ QTest::qWait(10);
+ if (v.status() != QQuickView::Ready) {
+ foreach (const QQmlError &e, v.errors())
+ errorMessage->append(e.toString().toLocal8Bit() + '\n');
+ return false;
+ }
+ const QRect screenGeometry = v.screen()->availableGeometry();
+ const QSize size = v.size();
+ const QPoint offset = QPoint(size.width() / 2, size.height() / 2);
+ v.setFramePosition(screenGeometry.center() - offset);
+ #if QT_CONFIG(cursor) // Get the cursor out of the way.
+ if (moveMouseOut)
+ QCursor::setPos(v.geometry().topRight() + QPoint(100, 100));
+ #else
+ Q_UNUSED(moveMouseOut)
+ #endif
+ return true;
+ }
+}
diff --git a/tests/auto/quick/shared/viewtestutil.h b/tests/auto/quick/shared/viewtestutil.h
index 04e1771ef8..3b57a29777 100644
--- a/tests/auto/quick/shared/viewtestutil.h
+++ b/tests/auto/quick/shared/viewtestutil.h
@@ -185,6 +185,10 @@ namespace QQuickTouchUtils {
void flush(QQuickWindow *window);
}
+namespace QQuickTest {
+ bool initView(QQuickView &v, const QUrl &url, bool moveMouseOut, QByteArray *errorMessage);
+}
+
Q_DECLARE_METATYPE(QQuickViewTestUtil::QaimModel*)
Q_DECLARE_METATYPE(QQuickViewTestUtil::ListChange)
Q_DECLARE_METATYPE(QList<QQuickViewTestUtil::ListChange>)