diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2018-07-31 13:47:24 +0200 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2018-07-31 13:35:15 +0000 |
commit | 6952f40a3ef47e5bc62286f75b26b2d79eaa9d74 (patch) | |
tree | de96f48b172fa4d1e0e48243729fd5fcb7c17268 /src/qmltest | |
parent | f48732c2ce3e34d4abc4cb0113a04feaf8d8e794 (diff) |
QuickTestEvent: keep pressed mouse buttons constant during move events
After qtbase b3e91b66b9175c1c3ff5f73f3ac231f74f9bf932 and predecessors,
as stated, "Qt platform plugins are now responsible for sending
explicit mouse button type and state information; qtestlib should take
full responsibility now as well." In QML tests we have not yet had
this memory of which buttons are pressed, until now. Change
caa45b4fe8b63f4be87b63b33595f65a0f44230e made Flickable sensitive to
buttons: it refuses to flick in response to mouse events in which no
button is being held. This broke tests in qtquickcontrols2 which
assume that in a QML test sequence like
mousePress(tumbler, tumbler.width / 2, tumbler.height / 2, Qt.LeftButton)
mouseMove(tumbler, tumbler.width / 2, y, 1)
mouseRelease(tumbler, tumbler.width / 2, tumbler.height / 4, Qt.LeftButton)
the mouse moves will include the pressed left button because it was
pressed and not released. So we have to fulfill the assumption to
avoid needing to change those tests. When the function
bool mouseMove(QObject *item, qreal x, qreal y, int delay, int buttons);
is called from QML, if that last parameter is omitted, it defaults to
zero, so we can't tell whether the test is explicitly passing
Qt.NoButton or just omitted it.
Task-number: QTBUG-69704
Change-Id: Ife0f7d0e9cb0d39788e8d9961d8872c9e913431e
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io>
Diffstat (limited to 'src/qmltest')
-rw-r--r-- | src/qmltest/quicktestevent.cpp | 6 | ||||
-rw-r--r-- | src/qmltest/quicktestevent_p.h | 2 |
2 files changed, 7 insertions, 1 deletions
diff --git a/src/qmltest/quicktestevent.cpp b/src/qmltest/quicktestevent.cpp index ee375a896c..480811d95c 100644 --- a/src/qmltest/quicktestevent.cpp +++ b/src/qmltest/quicktestevent.cpp @@ -144,6 +144,7 @@ namespace QtQuickTest int lastMouseTimestamp = 0; + // TODO should be Qt::MouseButtons buttons in case multiple buttons are pressed static void mouseEvent(MouseAction action, QWindow *window, QObject *item, Qt::MouseButton button, Qt::KeyboardModifiers stateKey, const QPointF &_pos, int delay=-1) @@ -252,6 +253,7 @@ bool QuickTestEvent::mousePress QWindow *view = eventWindow(item); if (!view) return false; + m_pressedButtons.setFlag(Qt::MouseButton(button), true); QtQuickTest::mouseEvent(QtQuickTest::MousePress, view, item, Qt::MouseButton(button), Qt::KeyboardModifiers(modifiers), @@ -281,6 +283,7 @@ bool QuickTestEvent::mouseRelease QWindow *view = eventWindow(item); if (!view) return false; + m_pressedButtons.setFlag(Qt::MouseButton(button), false); QtQuickTest::mouseEvent(QtQuickTest::MouseRelease, view, item, Qt::MouseButton(button), Qt::KeyboardModifiers(modifiers), @@ -336,8 +339,9 @@ bool QuickTestEvent::mouseMove QWindow *view = eventWindow(item); if (!view) return false; + const Qt::MouseButtons effectiveButtons = buttons ? Qt::MouseButtons(buttons) : m_pressedButtons; QtQuickTest::mouseEvent(QtQuickTest::MouseMove, view, item, - Qt::MouseButton(buttons), Qt::NoModifier, + Qt::MouseButton(int(effectiveButtons)), Qt::NoModifier, QPointF(x, y), delay); return true; } diff --git a/src/qmltest/quicktestevent_p.h b/src/qmltest/quicktestevent_p.h index f33f339cdd..5208c03a82 100644 --- a/src/qmltest/quicktestevent_p.h +++ b/src/qmltest/quicktestevent_p.h @@ -119,6 +119,8 @@ private: QWindow *activeWindow(); QTouchDevice *touchDevice(); + Qt::MouseButtons m_pressedButtons; + friend class QQuickTouchEventSequence; }; |