summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2020-09-30 22:37:09 +0200
committerShawn Rutledge <shawn.rutledge@qt.io>2020-09-30 23:17:57 +0200
commit8f74f7d25b62979d2d8a458cdeb282184b64d8d9 (patch)
treeab303c383b8b2aabf1890c53804d5fc643282437 /tests
parent871d19a5b96fa5a5be4ac50e3121e0704ff08374 (diff)
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. Amends 147a8bc4c86dd7c818acd2614ee67cd7098cfa5e and 6d6ed64d6ca27c1b5fec305e6ed9b923b5bb1037 Change-Id: I670289019fcfa7de685ca38799804772dc0f1c8f Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/gui/kernel/qwindow/tst_qwindow.cpp33
1 files changed, 25 insertions, 8 deletions
diff --git a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
index c93783fd9c..655ba3ac33 100644
--- a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
+++ b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
@@ -964,6 +964,10 @@ public:
if (ignoreMouse) {
event->ignore();
} else {
+ QCOMPARE(event->isBeginEvent(), true);
+ QCOMPARE(event->isUpdateEvent(), false);
+ QCOMPARE(event->isEndEvent(), false);
+ QCOMPARE(event->points().first().state(), QEventPoint::State::Pressed);
++mousePressedCount;
mouseSequenceSignature += 'p';
mousePressButton = event->button();
@@ -979,6 +983,10 @@ public:
if (ignoreMouse) {
event->ignore();
} else {
+ QCOMPARE(event->isBeginEvent(), false);
+ QCOMPARE(event->isUpdateEvent(), false);
+ QCOMPARE(event->isEndEvent(), true);
+ QCOMPARE(event->points().first().state(), QEventPoint::State::Released);
++mouseReleasedCount;
mouseSequenceSignature += 'r';
mouseReleaseButton = event->button();
@@ -991,6 +999,10 @@ public:
if (ignoreMouse) {
event->ignore();
} else {
+ QCOMPARE(event->isBeginEvent(), false);
+ QCOMPARE(event->isUpdateEvent(), true);
+ QCOMPARE(event->isEndEvent(), false);
+ QCOMPARE(event->points().first().state(), QEventPoint::State::Updated);
++mouseMovedCount;
mouseMoveButton = event->button();
mouseMoveScreenPos = event->globalPosition();
@@ -1002,6 +1014,10 @@ public:
if (ignoreMouse) {
event->ignore();
} else {
+ QCOMPARE(event->isBeginEvent(), false);
+ QCOMPARE(event->isUpdateEvent(), true);
+ QCOMPARE(event->isEndEvent(), false);
+ QCOMPARE(event->points().first().state(), QEventPoint::State::Stationary);
++mouseDoubleClickedCount;
mouseSequenceSignature += 'd';
}
@@ -1082,18 +1098,18 @@ public:
static void simulateMouseClick(QWindow *target, const QPointF &local, const QPointF &global)
{
QWindowSystemInterface::handleMouseEvent(target, local, global,
- {}, Qt::LeftButton, QEvent::MouseButtonPress);
+ Qt::LeftButton, Qt::LeftButton, QEvent::MouseButtonPress);
QWindowSystemInterface::handleMouseEvent(target, local, global,
- Qt::LeftButton, Qt::LeftButton, QEvent::MouseButtonRelease);
+ {}, Qt::LeftButton, QEvent::MouseButtonRelease);
}
static void simulateMouseClick(QWindow *target, ulong &timeStamp,
const QPointF &local, const QPointF &global)
{
QWindowSystemInterface::handleMouseEvent(target, timeStamp++, local, global,
- {}, Qt::LeftButton, QEvent::MouseButtonPress);
+ Qt::LeftButton, Qt::LeftButton, QEvent::MouseButtonPress);
QWindowSystemInterface::handleMouseEvent(target, timeStamp++, local, global,
- Qt::LeftButton, Qt::LeftButton, QEvent::MouseButtonRelease);
+ {}, Qt::LeftButton, QEvent::MouseButtonRelease);
}
void tst_QWindow::testInputEvents()
@@ -1722,12 +1738,12 @@ void tst_QWindow::inputReentrancy()
// Queue three events.
QPointF local(12, 34);
- QWindowSystemInterface::handleMouseEvent(&window, local, local, {},
+ QWindowSystemInterface::handleMouseEvent(&window, local, local, Qt::LeftButton,
Qt::LeftButton, QEvent::MouseButtonPress);
local += QPointF(2, 2);
QWindowSystemInterface::handleMouseEvent(&window, local, local,
- Qt::LeftButton, Qt::LeftButton, QEvent::MouseMove);
- QWindowSystemInterface::handleMouseEvent(&window, local, local, Qt::LeftButton,
+ Qt::LeftButton, {}, QEvent::MouseMove);
+ QWindowSystemInterface::handleMouseEvent(&window, local, local, {},
Qt::LeftButton, QEvent::MouseButtonRelease);
// Process them. However, the event handler for the press will also call
// 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.mouseReleaseButton, int(Qt::LeftButton));
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);
// Now the same for touch.