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>
This commit is contained in:
Andre de la Rocha 2019-02-08 22:33:15 +01:00
parent 77389ad8ff
commit 80bcfa776f

View File

@ -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()