diff options
Diffstat (limited to 'tests/auto/quick/shared/viewtestutil.cpp')
-rw-r--r-- | tests/auto/quick/shared/viewtestutil.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/auto/quick/shared/viewtestutil.cpp b/tests/auto/quick/shared/viewtestutil.cpp index 3bfa23173e..5631ffe047 100644 --- a/tests/auto/quick/shared/viewtestutil.cpp +++ b/tests/auto/quick/shared/viewtestutil.cpp @@ -38,6 +38,7 @@ #include <private/qquickwindow_p.h> #include <private/qquickitemview_p_p.h> +QT_BEGIN_NAMESPACE QQuickView *QQuickViewTestUtil::createView() { @@ -451,3 +452,32 @@ 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; + } +} + +QT_END_NAMESPACE |