summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorMorten Johan Sørvig <morten.sorvig@qt.io>2022-01-05 23:10:33 +0100
committerMorten Johan Sørvig <morten.sorvig@qt.io>2022-01-12 03:17:47 +0100
commiteef865cdc594c20b6f468d206475ddab48e2819a (patch)
tree3153bc5c9763c54965f6c30a7273ae6e210d7789 /tests/auto
parent38a66aa53a26eca4aef1e82f5c059efb82f977a8 (diff)
Make QCursor::setPos() use the correct screen
setPos() takes a screen argument, however this argument indicates which cursor should be moved only and is not usable as an argument to toNativePixels() since the position may be on a sibling screen. Add call to QScreen::virtualSiblingAt to get the target screen. Task-number: QTBUG-99009 Pick-to: 6.3 6.2 5.15 Change-Id: I8714ebc93a283c58bc67911315f787c484fb0dd8 Reviewed-by: Liang Qi <liang.qi@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/gui/kernel/qhighdpi/tst_qhighdpi.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/auto/gui/kernel/qhighdpi/tst_qhighdpi.cpp b/tests/auto/gui/kernel/qhighdpi/tst_qhighdpi.cpp
index b732954230..cd721f249b 100644
--- a/tests/auto/gui/kernel/qhighdpi/tst_qhighdpi.cpp
+++ b/tests/auto/gui/kernel/qhighdpi/tst_qhighdpi.cpp
@@ -76,6 +76,8 @@ private slots:
void mouseEvents();
void mouseVelocity();
void mouseVelocity_data();
+ void setCursor();
+ void setCursor_data();
};
/// Offscreen platform plugin test setup
@@ -805,5 +807,22 @@ void tst_QHighDpi::mouseVelocity()
}
}
+void tst_QHighDpi::setCursor_data()
+{
+ standardScreenDpiTestData();
+}
+
+void tst_QHighDpi::setCursor()
+{
+ QFETCH(QList<qreal>, dpiValues);
+ std::unique_ptr<QGuiApplication> app(createStandardOffscreenApp(dpiValues));
+
+ for (QScreen *screen : app->screens()) {
+ QPoint center = screen->geometry().center();
+ QCursor::setPos(center.x(), center.y());
+ QCOMPARE(QCursor::pos(), center);
+ }
+}
+
#include "tst_qhighdpi.moc"
QTEST_APPLESS_MAIN(tst_QHighDpi);