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 <paul.tvete@qt.io>
This commit is contained in:
Johan Klokkhammer Helsing 2018-02-21 10:29:24 +01:00 committed by Johan Helsing
parent 6eac43515d
commit e3d236cfa7

View File

@ -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()