From: Kristian Høgsberg Date: Sun, 22 Apr 2012 18:17:02 +0000 (-0400) Subject: tests: Test invoking closures built with wl_closure_vmarshal() X-Git-Tag: 0.94.90~85 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e7dd32710f3fcff0bbbaf33807fb65b78a43e2fb;p=platform%2Fupstream%2Fwayland.git tests: Test invoking closures built with wl_closure_vmarshal() --- diff --git a/tests/connection-test.c b/tests/connection-test.c index 72c32e6..54ac423 100644 --- a/tests/connection-test.c +++ b/tests/connection-test.c @@ -424,3 +424,41 @@ TEST(connection_marshal_alot) release_marshal_data(&data); } + +static void +marshal_helper(const char *format, void *handler, ...) +{ + struct wl_closure closure; + static struct wl_object sender = { NULL, NULL, 1234 }, object; + static const int opcode = 4444; + struct wl_message message = { "test", format, NULL }; + va_list ap; + int ret, done; + + va_start(ap, handler); + ret = wl_closure_vmarshal(&closure, &sender, opcode, ap, &message); + va_end(ap); + + assert(ret == 0); + done = 0; + wl_closure_invoke(&closure, &object, handler, &done); + wl_closure_destroy(&closure); + assert(done); +} + +static void +suu_handler(void *data, struct wl_object *object, + const char *s, uint32_t u1, uint32_t u2) +{ + int *done = data; + + assert(strcmp(s, "foo") == 0); + assert(u1 = 500); + assert(u2 = 404040); + *done = 1; +} + +TEST(invoke_closure) +{ + marshal_helper("suu", suu_handler, "foo", 500, 404040); +}