tst_qwindow: verify isBeginEvent(), isUpdateEvent() and isEndEvent()
It also demonstrated that the tests were out of sync with reality: since a97759a336c597327cb82eebc9f45c793aec32c9 QMouseEvent::button() and QWindowSystemInterfacePrivate::MouseEvent::button should be the button that changes state of course; but when a button is pressed, we are reacting to it after the fact, so QMouseEvent::buttons() and QWindowSystemInterfacePrivate::MouseEvent::buttons should include the new button that was just pressed. Likewise when a button was released, we send the event with buttons _omitting_ the button that was just released. Amends147a8bc4c8
and6d6ed64d6c
Change-Id: I670289019fcfa7de685ca38799804772dc0f1c8f Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
parent
871d19a5b9
commit
8f74f7d25b
@ -964,6 +964,10 @@ public:
|
|||||||
if (ignoreMouse) {
|
if (ignoreMouse) {
|
||||||
event->ignore();
|
event->ignore();
|
||||||
} else {
|
} else {
|
||||||
|
QCOMPARE(event->isBeginEvent(), true);
|
||||||
|
QCOMPARE(event->isUpdateEvent(), false);
|
||||||
|
QCOMPARE(event->isEndEvent(), false);
|
||||||
|
QCOMPARE(event->points().first().state(), QEventPoint::State::Pressed);
|
||||||
++mousePressedCount;
|
++mousePressedCount;
|
||||||
mouseSequenceSignature += 'p';
|
mouseSequenceSignature += 'p';
|
||||||
mousePressButton = event->button();
|
mousePressButton = event->button();
|
||||||
@ -979,6 +983,10 @@ public:
|
|||||||
if (ignoreMouse) {
|
if (ignoreMouse) {
|
||||||
event->ignore();
|
event->ignore();
|
||||||
} else {
|
} else {
|
||||||
|
QCOMPARE(event->isBeginEvent(), false);
|
||||||
|
QCOMPARE(event->isUpdateEvent(), false);
|
||||||
|
QCOMPARE(event->isEndEvent(), true);
|
||||||
|
QCOMPARE(event->points().first().state(), QEventPoint::State::Released);
|
||||||
++mouseReleasedCount;
|
++mouseReleasedCount;
|
||||||
mouseSequenceSignature += 'r';
|
mouseSequenceSignature += 'r';
|
||||||
mouseReleaseButton = event->button();
|
mouseReleaseButton = event->button();
|
||||||
@ -991,6 +999,10 @@ public:
|
|||||||
if (ignoreMouse) {
|
if (ignoreMouse) {
|
||||||
event->ignore();
|
event->ignore();
|
||||||
} else {
|
} else {
|
||||||
|
QCOMPARE(event->isBeginEvent(), false);
|
||||||
|
QCOMPARE(event->isUpdateEvent(), true);
|
||||||
|
QCOMPARE(event->isEndEvent(), false);
|
||||||
|
QCOMPARE(event->points().first().state(), QEventPoint::State::Updated);
|
||||||
++mouseMovedCount;
|
++mouseMovedCount;
|
||||||
mouseMoveButton = event->button();
|
mouseMoveButton = event->button();
|
||||||
mouseMoveScreenPos = event->globalPosition();
|
mouseMoveScreenPos = event->globalPosition();
|
||||||
@ -1002,6 +1014,10 @@ public:
|
|||||||
if (ignoreMouse) {
|
if (ignoreMouse) {
|
||||||
event->ignore();
|
event->ignore();
|
||||||
} else {
|
} else {
|
||||||
|
QCOMPARE(event->isBeginEvent(), false);
|
||||||
|
QCOMPARE(event->isUpdateEvent(), true);
|
||||||
|
QCOMPARE(event->isEndEvent(), false);
|
||||||
|
QCOMPARE(event->points().first().state(), QEventPoint::State::Stationary);
|
||||||
++mouseDoubleClickedCount;
|
++mouseDoubleClickedCount;
|
||||||
mouseSequenceSignature += 'd';
|
mouseSequenceSignature += 'd';
|
||||||
}
|
}
|
||||||
@ -1082,18 +1098,18 @@ public:
|
|||||||
static void simulateMouseClick(QWindow *target, const QPointF &local, const QPointF &global)
|
static void simulateMouseClick(QWindow *target, const QPointF &local, const QPointF &global)
|
||||||
{
|
{
|
||||||
QWindowSystemInterface::handleMouseEvent(target, local, global,
|
QWindowSystemInterface::handleMouseEvent(target, local, global,
|
||||||
{}, Qt::LeftButton, QEvent::MouseButtonPress);
|
Qt::LeftButton, Qt::LeftButton, QEvent::MouseButtonPress);
|
||||||
QWindowSystemInterface::handleMouseEvent(target, local, global,
|
QWindowSystemInterface::handleMouseEvent(target, local, global,
|
||||||
Qt::LeftButton, Qt::LeftButton, QEvent::MouseButtonRelease);
|
{}, Qt::LeftButton, QEvent::MouseButtonRelease);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void simulateMouseClick(QWindow *target, ulong &timeStamp,
|
static void simulateMouseClick(QWindow *target, ulong &timeStamp,
|
||||||
const QPointF &local, const QPointF &global)
|
const QPointF &local, const QPointF &global)
|
||||||
{
|
{
|
||||||
QWindowSystemInterface::handleMouseEvent(target, timeStamp++, local, global,
|
QWindowSystemInterface::handleMouseEvent(target, timeStamp++, local, global,
|
||||||
{}, Qt::LeftButton, QEvent::MouseButtonPress);
|
Qt::LeftButton, Qt::LeftButton, QEvent::MouseButtonPress);
|
||||||
QWindowSystemInterface::handleMouseEvent(target, timeStamp++, local, global,
|
QWindowSystemInterface::handleMouseEvent(target, timeStamp++, local, global,
|
||||||
Qt::LeftButton, Qt::LeftButton, QEvent::MouseButtonRelease);
|
{}, Qt::LeftButton, QEvent::MouseButtonRelease);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QWindow::testInputEvents()
|
void tst_QWindow::testInputEvents()
|
||||||
@ -1722,12 +1738,12 @@ void tst_QWindow::inputReentrancy()
|
|||||||
|
|
||||||
// Queue three events.
|
// Queue three events.
|
||||||
QPointF local(12, 34);
|
QPointF local(12, 34);
|
||||||
QWindowSystemInterface::handleMouseEvent(&window, local, local, {},
|
QWindowSystemInterface::handleMouseEvent(&window, local, local, Qt::LeftButton,
|
||||||
Qt::LeftButton, QEvent::MouseButtonPress);
|
Qt::LeftButton, QEvent::MouseButtonPress);
|
||||||
local += QPointF(2, 2);
|
local += QPointF(2, 2);
|
||||||
QWindowSystemInterface::handleMouseEvent(&window, local, local,
|
QWindowSystemInterface::handleMouseEvent(&window, local, local,
|
||||||
Qt::LeftButton, Qt::LeftButton, QEvent::MouseMove);
|
Qt::LeftButton, {}, QEvent::MouseMove);
|
||||||
QWindowSystemInterface::handleMouseEvent(&window, local, local, Qt::LeftButton,
|
QWindowSystemInterface::handleMouseEvent(&window, local, local, {},
|
||||||
Qt::LeftButton, QEvent::MouseButtonRelease);
|
Qt::LeftButton, QEvent::MouseButtonRelease);
|
||||||
// Process them. However, the event handler for the press will also call
|
// Process them. However, the event handler for the press will also call
|
||||||
// processEvents() so the move and release will be delivered before returning
|
// processEvents() so the move and release will be delivered before returning
|
||||||
@ -1736,7 +1752,8 @@ void tst_QWindow::inputReentrancy()
|
|||||||
QCOMPARE(window.mousePressButton, int(Qt::LeftButton));
|
QCOMPARE(window.mousePressButton, int(Qt::LeftButton));
|
||||||
QCOMPARE(window.mouseReleaseButton, int(Qt::LeftButton));
|
QCOMPARE(window.mouseReleaseButton, int(Qt::LeftButton));
|
||||||
QCOMPARE(window.mousePressedCount, 1);
|
QCOMPARE(window.mousePressedCount, 1);
|
||||||
QCOMPARE(window.mouseMovedCount, 1);
|
// The mouse press may have generated a synthetic move in QGuiApplicationPrivate::processMouseEvent()
|
||||||
|
QVERIFY(window.mouseMovedCount == 1 || window.mouseMovedCount == 2);
|
||||||
QCOMPARE(window.mouseReleasedCount, 1);
|
QCOMPARE(window.mouseReleasedCount, 1);
|
||||||
|
|
||||||
// Now the same for touch.
|
// Now the same for touch.
|
||||||
|
Loading…
Reference in New Issue
Block a user