[PATCH weston 3/3] tests: Make sure that events are handled before sending client states

Jonas Ådahl jadahl at gmail.com
Wed Nov 14 14:39:53 PST 2012


Before the client sends its state, make a roundtrip to the server to
make sure that all events queued by the server are handled.

Signed-off-by: Jonas Ådahl <jadahl at gmail.com>
---

Hi,

After this commit, the tests pass some of the times (on my machine), but
far from every time. It haven't figured out why this is yet, but it might
be related to connection buffers, as calling wl_display_flush_clients()
before sending commands (in test_client_send()) to the client seems to
make them pass every time.

I did not include that call in a commit as I suspect that it should work
even without flushing as a roundtrip should trigger a connection to be
flush; so something else might be fishy.

Jonas

 tests/test-client.c      |   10 ++++++++--
 tests/test-text-client.c |    2 ++
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/tests/test-client.c b/tests/test-client.c
index 8ef9584..170f544 100644
--- a/tests/test-client.c
+++ b/tests/test-client.c
@@ -334,8 +334,11 @@ send_keyboard_state(int fd, struct display *display)
 {
 	char buf[64];
 	int len;
-	int focus = display->input->keyboard_focus != NULL;
+	int focus;
 
+	wl_display_roundtrip(display->display);
+
+	focus = display->input->keyboard_focus != NULL;
 	if (focus) {
 		assert(display->input->keyboard_focus == display->surface);
 	}
@@ -368,16 +371,19 @@ send_state(int fd, struct display* display)
 {
 	char buf[64];
 	int len;
-	int visible = display->surface->output != NULL;
+	int visible;
 	wl_fixed_t x = wl_fixed_from_int(-1);
 	wl_fixed_t y = wl_fixed_from_int(-1);
 
+	wl_display_roundtrip(display->display);
+
 	if (display->input->pointer_focus != NULL) {
 		assert(display->input->pointer_focus == display->surface);
 		x = wl_fixed_from_double(display->input->x);
 		y = wl_fixed_from_double(display->input->y);
 	}
 
+	visible = display->surface->output != NULL;
 	if (visible) {
 		/* FIXME: this fails on multi-display setup */
 		/* assert(display->surface->output == display->output); */
diff --git a/tests/test-text-client.c b/tests/test-text-client.c
index c684674..8677a71 100644
--- a/tests/test-text-client.c
+++ b/tests/test-text-client.c
@@ -195,6 +195,8 @@ write_state(int fd, struct display *display)
 	char buf[64];
 	int len;
 
+	wl_display_roundtrip(display->display);
+
 	wl_display_flush(display->display);
 	len = snprintf(buf, sizeof buf, "activated %u deactivated %u\n",
 		       display->activated, display->deactivated);
-- 
1.7.10.4



More information about the wayland-devel mailing list