diff options
Diffstat (limited to 'tests/auto/shared')
-rw-r--r-- | tests/auto/shared/visualtestutil.cpp | 12 | ||||
-rw-r--r-- | tests/auto/shared/visualtestutil.h | 2 |
2 files changed, 13 insertions, 1 deletions
diff --git a/tests/auto/shared/visualtestutil.cpp b/tests/auto/shared/visualtestutil.cpp index 47cfd74f..c5e69812 100644 --- a/tests/auto/shared/visualtestutil.cpp +++ b/tests/auto/shared/visualtestutil.cpp @@ -74,7 +74,10 @@ void QQuickVisualTestUtil::dumpTree(QQuickItem *parent, int depth) void QQuickVisualTestUtil::moveMouseAway(QQuickWindow *window) { #if QT_CONFIG(cursor) // Get the cursor out of the way. - QCursor::setPos(window->geometry().topRight() + QPoint(100, 100)); + // Using "bottomRight() + QPoint(100, 100)" was causing issues on Ubuntu, + // where the window was positioned at the bottom right corner of the window + // (even after centering the window on the screen), so we use another position. + QCursor::setPos(window->geometry().bottomLeft() + QPoint(0, 10)); #endif // make sure hover events from QQuickWindowPrivate::flushFrameSynchronousEvents() @@ -82,3 +85,10 @@ void QQuickVisualTestUtil::moveMouseAway(QQuickWindow *window) QEvent leave(QEvent::Leave); QCoreApplication::sendEvent(window, &leave); } + +void QQuickVisualTestUtil::centerOnScreen(QQuickWindow *window) +{ + const QRect screenGeometry = window->screen()->availableGeometry(); + const QPoint offset = QPoint(window->width() / 2, window->height() / 2); + window->setFramePosition(screenGeometry.center() - offset); +} diff --git a/tests/auto/shared/visualtestutil.h b/tests/auto/shared/visualtestutil.h index bcf45660..a6b52fef 100644 --- a/tests/auto/shared/visualtestutil.h +++ b/tests/auto/shared/visualtestutil.h @@ -54,6 +54,8 @@ namespace QQuickVisualTestUtil bool delegateVisible(QQuickItem *item); + void centerOnScreen(QQuickWindow *window); + void moveMouseAway(QQuickWindow *window); /* |