The callback returns always with the same serial,
which is not right (it's serial, not constant...).
This test highlights the bug.

Signed-off-by: Marek Chalupa <[email protected]>
---
 tests/display-test.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 55 insertions(+)

diff --git a/tests/display-test.c b/tests/display-test.c
index a1e45b1..eb4ba1c 100644
--- a/tests/display-test.c
+++ b/tests/display-test.c
@@ -593,3 +593,58 @@ TEST(threading_read_after_error_tst)
 
        display_destroy(d);
 }
+
+static void
+sync_callback(void *data, struct wl_callback *wl_callback, uint32_t serial)
+{
+       int *got = data;
+       static uint32_t last_serial = 0;
+
+       /* if this is the first callback, just copy the value of serial */
+       if (*got == 0)
+               last_serial = serial;
+       else
+               ++last_serial;
+
+       /* since we only call display_sync, nothing else can increase the
+        * serial, so the serails must be sequential */
+       assert(serial == last_serial
+              && "Serial is not sequential");
+
+       ++(*got);
+}
+
+static const struct wl_callback_listener sync_listener = {
+       sync_callback
+};
+
+#define CB_NUM 1000
+static void
+callback_serial_tst_main(void)
+{
+       int i, got = 0;
+       struct wl_callback *cb;
+       struct client *client = client_connect();
+
+       for (i = 0; i < CB_NUM; ++i) {
+               cb = wl_display_sync(client->wl_display);
+               wl_callback_add_listener(cb, &sync_listener, &got);
+       }
+
+       wl_display_flush(client->wl_display);
+       wl_display_roundtrip(client->wl_display);
+
+       assert(got == CB_NUM && "Lost some callback");
+
+       client_disconnect(client);
+}
+
+TEST(callback_serial_tst)
+{
+       struct display *d = display_create();
+
+       client_create(d, callback_serial_tst_main);
+       display_run(d);
+
+       display_destroy(d);
+}
-- 
1.9.3

_______________________________________________
wayland-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/wayland-devel

Reply via email to