summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndre de la Rocha <andre.rocha@qt.io>2019-02-08 22:33:15 +0100
committerAndre de la Rocha <andre.rocha@qt.io>2019-02-12 22:17:40 +0000
commit80bcfa776f9243641484181a18090b34147e8e30 (patch)
tree84d04982ff0e285c68ef888e261d9be2b2e7f1cd
parent77389ad8ff9fd3dc56f5a398fab11a993e7a621c (diff)
Fix QSpinBox tests failing after change in the Windows QPA
Some QSpinBox tests start failing after reverting to using legacy mouse messages to handle mouse input in the Windows QPA. It seems to be caused by a test that runs before it and moves the mouse cursor. Then when the QSpinBox tests run, they create widgets that appear below the mouse cursor, causing some mouse events to be generating and messing with the events synthesized by the test itself. With the pointer messages being used for mouse input, the legacy mouse messages that are generated under this condition were being ignored. But by reverting to the old implementation, the legacy messages are handled again, causing the test to fail. This change moves the mouse pointer to a safe position during the test initialization, so it does not depend on the state left by previous tests. This change needs to be integrated together or before the change in the windows QPA. Change-Id: I91f7e9376dc495ee61250e0a7d908c1c2b685bc8 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
-rw-r--r--tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp b/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp
index 37bb28dec9..1d106f94f3 100644
--- a/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp
+++ b/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp
@@ -53,6 +53,8 @@
#include <QStyleOptionSpinBox>
#include <QStyle>
#include <QProxyStyle>
+#include <QScreen>
+
class SpinBox : public QSpinBox
{
@@ -343,6 +345,14 @@ tst_QSpinBox::tst_QSpinBox()
void tst_QSpinBox::init()
{
QLocale::setDefault(QLocale(QLocale::C));
+
+#if QT_CONFIG(cursor)
+ // Ensure mouse cursor was not left by previous tests where widgets
+ // will appear, as it could cause events and interfere with the tests.
+ const QScreen *screen = QGuiApplication::primaryScreen();
+ const QRect availableGeometry = screen->availableGeometry();
+ QCursor::setPos(availableGeometry.topLeft());
+#endif
}
void tst_QSpinBox::setValue_data()