From e3d236cfa7bc0f2d78e175ec85e39febde835b83 Mon Sep 17 00:00:00 2001 From: Johan Klokkhammer Helsing Date: Wed, 21 Feb 2018 10:29:24 +0100 Subject: [PATCH] Fix flakiness in tst_WaylandClient::events The test was flaky because we have a workaround for a bug in Weston where Weston fails to send the last wl_touch.frame event (QTBUG-36602). We've worked around it by letting our client handle the wl_touch.up event before the frame event if it's the last up event. This caused a race condition in our tests, though (which include the frame event). Because Q_TRY_COMPARE(window.touchEventCount, 1) would pass and the window was sometimes destroyed before the frame event had been sent by the compositor thread. Work around it by moving the touch testing before the pointer testing, so the surface is still alive when the compositor tries to send the frame event. That way the test will not be flaky, and will continue to work when we eventually remove the workaround in QWaylandInputDevice. Task-number: QTBUG-66537 Change-Id: I5673445682810e75343c6df2d1b2a4f1c1b21bcb Reviewed-by: Paul Olav Tvete --- tests/auto/wayland/client/tst_client.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/tests/auto/wayland/client/tst_client.cpp b/tests/auto/wayland/client/tst_client.cpp index 0e086c7a6ab..981b8f129ec 100644 --- a/tests/auto/wayland/client/tst_client.cpp +++ b/tests/auto/wayland/client/tst_client.cpp @@ -314,6 +314,17 @@ void tst_WaylandClient::events() QTRY_COMPARE(window.keyReleaseEventCount, 1); QCOMPARE(window.keyCode, keyCode); + const int touchId = 0; + compositor->sendTouchDown(surface, window.frameOffset() + QPoint(10, 10), touchId); + // Note: wl_touch.frame should not be the last event in a test until QTBUG-66563 is fixed. + // See also: QTBUG-66537 + compositor->sendTouchFrame(surface); + QTRY_COMPARE(window.touchEventCount, 1); + + compositor->sendTouchUp(surface, touchId); + compositor->sendTouchFrame(surface); + QTRY_COMPARE(window.touchEventCount, 2); + QPoint mousePressPos(16, 16); QCOMPARE(window.mousePressEventCount, 0); compositor->sendMousePress(surface, window.frameOffset() + mousePressPos); @@ -323,15 +334,6 @@ void tst_WaylandClient::events() QCOMPARE(window.mouseReleaseEventCount, 0); compositor->sendMouseRelease(surface); QTRY_COMPARE(window.mouseReleaseEventCount, 1); - - const int touchId = 0; - compositor->sendTouchDown(surface, window.frameOffset() + QPoint(10, 10), touchId); - compositor->sendTouchFrame(surface); - QTRY_COMPARE(window.touchEventCount, 1); - - compositor->sendTouchUp(surface, touchId); - compositor->sendTouchFrame(surface); - QTRY_COMPARE(window.touchEventCount, 2); } void tst_WaylandClient::backingStore()