diff options
author | Friedemann Kleint <Friedemann.Kleint@digia.com> | 2013-08-23 13:35:00 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-08-26 10:21:56 +0200 |
commit | 6ba7d88df623df5bce85bfdae853fc49006e76f2 (patch) | |
tree | 64de42db0f026a55b684ea787999a2e8c95762d6 /tests/auto/quick/shared/viewtestutil.cpp | |
parent | cf3537e99c75d3bb92b9d4ed6f4d437e316dcf01 (diff) |
Stabilize tests using utilities from QQuickViewTestUtil.
Change QQuickViewTestUtil::createView() to center the window on
the screen to avoid taskbar areas. Add routine to move the mouse
away and use that in tests using QQuickViewTestUtil::flick()
and other mouse interaction since the mouse cursor can interfere
with it. Affected tests: qquickgridview, qquickpathview,
qquickflickable, qquicklistview, qquickrepeater and qquickpositioners.
Task-number: QTBUG-33017
Change-Id: I540c0efb54a231dcb44c8fd5ad9573a2d4d4b9df
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@digia.com>
Diffstat (limited to 'tests/auto/quick/shared/viewtestutil.cpp')
-rw-r--r-- | tests/auto/quick/shared/viewtestutil.cpp | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/tests/auto/quick/shared/viewtestutil.cpp b/tests/auto/quick/shared/viewtestutil.cpp index 29b82072c9..0e3964d52d 100644 --- a/tests/auto/quick/shared/viewtestutil.cpp +++ b/tests/auto/quick/shared/viewtestutil.cpp @@ -42,17 +42,41 @@ #include "viewtestutil.h" #include <QtQuick/QQuickView> +#include <QtQuick/QQuickView> +#include <QtGui/QScreen> #include <QtTest/QTest> QQuickView *QQuickViewTestUtil::createView() { QQuickView *window = new QQuickView(0); - window->setGeometry(0,0,240,320); - + const QSize size(240, 320); + window->resize(size); + QQuickViewTestUtil::centerOnScreen(window, size); return window; } +void QQuickViewTestUtil::centerOnScreen(QQuickView *window, const QSize &size) +{ + const QRect screenGeometry = window->screen()->availableGeometry(); + const QPoint offset = QPoint(size.width() / 2, size.height() / 2); + window->setFramePosition(screenGeometry.center() - offset); +} + +void QQuickViewTestUtil::centerOnScreen(QQuickView *window) +{ + QQuickViewTestUtil::centerOnScreen(window, window->size()); +} + +void QQuickViewTestUtil::moveMouseAway(QQuickView *window) +{ +#ifndef QT_NO_CURSOR // Get the cursor out of the way. + QCursor::setPos(window->geometry().topRight() + QPoint(100, 100)); +#else + Q_UNUSED(window) +#endif +} + void QQuickViewTestUtil::flick(QQuickView *window, const QPoint &from, const QPoint &to, int duration) { const int pointCount = 5; |