aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2022-10-18 23:15:53 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-10-19 18:32:13 +0000
commit33a08af6682cc1f122d3b6a8909d09f79fa361d3 (patch)
tree2112cf7205897cafa7fdab659e30178a1fcad014
parentf75ba7953f963a12749ab5e6a46d25e1afd2424c (diff)
Attempt to stabilize tst_HoverHandler::deviceCursor (part 2)
CI logs tell us that QTRY_COMPARE(mouseHandler->isHovered(), true) has been failing sometimes. It's not supposed to fail, because we are sending a mouse move event that should result in HoverHandler detecting hovering (as opposed to using QCursor::setPos(), which is known for being a more thorough test on window systems that support it, but also not working on some systems). On the hypothesis that this has something to do with timing, avoid checking isHovered() until after we have verified that the mouse-handling HoverHandler has received an event with a timestamp at least 100 ms after the one that went to the last tablet-handling HoverHandler, and only in that case continue with checking hover states and the cursor. And anyway, if it keeps failing, we might at least get the qCDebug line in the logs to be able to check the timestamps. Amends 79893e1773be9d04208243cb88c1daf793d830a4 Task-number: QTBUG-107763 Change-Id: Id7c657bfadf7b49ba3440e28d13121c041d38816 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit d475b74d66cd2199e4c9ddf067c15569370b1afa) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--tests/auto/quick/pointerhandlers/qquickhoverhandler/tst_qquickhoverhandler.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/tests/auto/quick/pointerhandlers/qquickhoverhandler/tst_qquickhoverhandler.cpp b/tests/auto/quick/pointerhandlers/qquickhoverhandler/tst_qquickhoverhandler.cpp
index 9d9faffb2e..b17395a99d 100644
--- a/tests/auto/quick/pointerhandlers/qquickhoverhandler/tst_qquickhoverhandler.cpp
+++ b/tests/auto/quick/pointerhandlers/qquickhoverhandler/tst_qquickhoverhandler.cpp
@@ -546,13 +546,18 @@ void tst_HoverHandler::deviceCursor()
// move the mouse: the mouse-specific HoverHandler gets to set the cursor only if
// more than kCursorOverrideTimeout ms have elapsed (100ms)
QTest::mouseMove(&window, point, 100);
- QTRY_COMPARE(mouseHandler->isHovered(), true);
+ QTRY_IMPL(mouseHandler->isHovered() == true, 500);
const bool afterTimeout =
QQuickPointerHandlerPrivate::get(airbrushEraserHandler)->lastEventTime + 100 <
QQuickPointerHandlerPrivate::get(mouseHandler)->lastEventTime;
qCDebug(lcPointerTests) << "airbrush handler reacted last time:" << QQuickPointerHandlerPrivate::get(airbrushEraserHandler)->lastEventTime
<< "and the mouse handler reacted at time:" << QQuickPointerHandlerPrivate::get(mouseHandler)->lastEventTime
<< "so > 100 ms have elapsed?" << afterTimeout;
+ if (afterTimeout)
+ QCOMPARE(mouseHandler->isHovered(), true);
+ else
+ QSKIP("Failed to delay mouse move 100ms after the previous tablet event");
+
#if QT_CONFIG(cursor)
QCOMPARE(window.cursor().shape(), afterTimeout ? Qt::IBeamCursor : Qt::OpenHandCursor);
#endif