diff options
| author | Shawn Rutledge <shawn.rutledge@qt.io> | 2024-06-26 20:20:27 -0700 |
|---|---|---|
| committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2024-06-29 09:28:55 -0700 |
| commit | 3616b446224e1bd49e97a2fe41350efccd5b9be5 (patch) | |
| tree | aa86e3f441f701b6e99dd1689fd6ba7ac214d562 /src/quicktestutils/quick/viewtestutils.cpp | |
| parent | 428f64a12ed7e71cffd0d394d1560bb4e7e701c4 (diff) | |
QQuickTest::initView: don't do things on Wayland that aren't allowed
Neither exact window positioning nor QCursor::setPos() are allowed.
Attempting to do it results in warnings, which tests treat as failures.
Pick-to: 6.8
Change-Id: I1cd23147e52e833b151df5367b2753b4b453fa2d
Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
Diffstat (limited to 'src/quicktestutils/quick/viewtestutils.cpp')
| -rw-r--r-- | src/quicktestutils/quick/viewtestutils.cpp | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/src/quicktestutils/quick/viewtestutils.cpp b/src/quicktestutils/quick/viewtestutils.cpp index 40a67a305e..629849992a 100644 --- a/src/quicktestutils/quick/viewtestutils.cpp +++ b/src/quicktestutils/quick/viewtestutils.cpp @@ -469,6 +469,7 @@ namespace QQuickTest { */ bool initView(QQuickView &view, const QUrl &url, bool moveMouseOut, QByteArray *errorMessage) { + const bool platformIsWayland = !QGuiApplication::platformName().compare(QLatin1String("wayland"), Qt::CaseInsensitive); view.setSource(url); while (view.status() == QQuickView::Loading) QTest::qWait(10); @@ -479,20 +480,22 @@ namespace QQuickTest { } return false; } - const QRect screenGeometry = view.screen()->availableGeometry(); - const QSize size = view.size(); if (view.width() == 0) view.setWidth(100); if (view.height() == 0) view.setHeight(100); - const QPoint offset = QPoint(size.width() / 2, size.height() / 2); - view.setFramePosition(screenGeometry.center() - offset); - #if QT_CONFIG(cursor) // Get the cursor out of the way. - if (moveMouseOut) - QCursor::setPos(view.geometry().topRight() + QPoint(100, 100)); - #else - Q_UNUSED(moveMouseOut); - #endif + if (!platformIsWayland) { + const QSize size = view.size(); + const QRect screenGeometry = view.screen()->availableGeometry(); + const QPoint offset = QPoint(size.width() / 2, size.height() / 2); + view.setFramePosition(screenGeometry.center() - offset); +#if QT_CONFIG(cursor) // Get the cursor out of the way. But it's not possible on Wayland. + if (moveMouseOut) + QCursor::setPos(view.geometry().topRight() + QPoint(100, 100)); +#else + Q_UNUSED(moveMouseOut); +#endif + } return true; } |
