autotests: Stabilize testWaylandSeat

TestWaylandSeat::sync() ensures that events and requests can't be
reordered after it. That is, it guarantees that

- events sent from the compositor will be processed by the client
  before sync() finishes
- requests issued by the client will be processed by the compositor
  before sync() finishes

WaylandSyncPoint relies on the fact that wl_display_sync()'s callback
and other wayland events will be processed in the same event queue.

But, it's not the case right now. The wl_callback belongs to the default
event queue and KWayland::Client::Seat belongs to a different queue.

If the default event queue is dispatched first, the WaylandSyncPoint may
emit the done signal too early.

In order to fix sync(), this change ensures that WaylandSyncPoint's
wl_callback uses the correct event queue.
master
Vlad Zahorodnii 1 year ago
parent 2f1744b67b
commit 5fb5f1c92b

@ -53,7 +53,7 @@ class WaylandSyncPoint : public QObject
Q_OBJECT
public:
explicit WaylandSyncPoint(wl_display *display)
explicit WaylandSyncPoint(KWayland::Client::ConnectionThread *connection, KWayland::Client::EventQueue *eventQueue)
{
static const wl_callback_listener listener = {
.done = [](void *data, wl_callback *callback, uint32_t callback_data) {
@ -62,7 +62,8 @@ public:
},
};
m_callback = wl_display_sync(display);
m_callback = wl_display_sync(connection->display());
eventQueue->addProxy(m_callback);
wl_callback_add_listener(m_callback, &listener, this);
}
@ -283,7 +284,7 @@ void TestWaylandSeat::cleanup()
bool TestWaylandSeat::sync()
{
WaylandSyncPoint syncPoint(m_connection->display());
WaylandSyncPoint syncPoint(m_connection, m_queue);
QSignalSpy doneSpy(&syncPoint, &WaylandSyncPoint::done);
return doneSpy.wait();
}

Loading…
Cancel
Save