[PATCH weston v1 12/17] tests: make client_roundtrip universal

Marek Chalupa mchqwerty at gmail.com
Fri Dec 5 05:36:45 PST 2014


Make client_roundtrip a function instead of macro and
make it work with both - normal clients and toytoolkit clients.

Signed-off-by: Marek Chalupa <mchqwerty at gmail.com>
---
 tests/weston-test-client-helper.c | 17 +++++++++++++++++
 tests/weston-test-client-helper.h |  5 ++---
 2 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/tests/weston-test-client-helper.c b/tests/weston-test-client-helper.c
index 23b2048..ae104a8 100644
--- a/tests/weston-test-client-helper.c
+++ b/tests/weston-test-client-helper.c
@@ -82,6 +82,23 @@ frame_callback_wait_nofail(struct client *client, int *done)
 }
 
 void
+client_roundtrip(struct client *client)
+{
+	struct wl_callback *cb;
+	int done = 0;
+
+	if (client->toytoolkit) {
+		cb = wl_display_sync(client->wl_display);
+		/* use frame_listener, it does exactly what we need */
+		wl_callback_add_listener(cb, &frame_listener, &done);
+
+		while(!done)
+			assert(display_dispatch(client->toytoolkit->display, -1) > 0);
+	} else
+		assert(wl_display_roundtrip(client->wl_display) >= 0);
+}
+
+void
 move_client(struct client *client, int x, int y)
 {
 	struct surface *surface = client->surface;
diff --git a/tests/weston-test-client-helper.h b/tests/weston-test-client-helper.h
index 3998c6d..bdd8cd9 100644
--- a/tests/weston-test-client-helper.h
+++ b/tests/weston-test-client-helper.h
@@ -132,9 +132,8 @@ surface_contains(struct surface *surface, int x, int y);
 void
 move_client(struct client *client, int x, int y);
 
-#define client_roundtrip(c) do { \
-	assert(wl_display_roundtrip((c)->wl_display) >= 0); \
-} while (0)
+void
+client_roundtrip(struct client *client);
 
 struct wl_callback *
 frame_callback_set(struct wl_surface *surface, int *done);
-- 
2.1.0



More information about the wayland-devel mailing list