[PATCH v2 wayland] tests: Test proxy versions

Derek Foreman derekf at osg.samsung.com
Thu Jan 14 14:17:40 PST 2016


Add a test that confirms that proxy versions are always 0 for display
and correct otherwise.

Signed-off-by: Derek Foreman <derekf at osg.samsung.com>
---
Changes from v1:
Make the global once at a high version, bind it with different versions

create a wl_pointer from the wl_seat to test version inheritance

also test the generated wl_seat/pointer_get_version instead of just
 wl_proxy_get_version

 tests/display-test.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)

diff --git a/tests/display-test.c b/tests/display-test.c
index 161a402..7b9c10a 100644
--- a/tests/display-test.c
+++ b/tests/display-test.c
@@ -100,12 +100,18 @@ TEST(tc_leaks_tests)
 	display_destroy(d);
 }
 
+static uint32_t expected_version;
+
 static void
 registry_handle_globals(void *data, struct wl_registry *registry,
 			uint32_t id, const char *intf, uint32_t ver)
 {
 	struct wl_seat **seat = data;
 
+	/* This is only for the proxy version test */
+	if (expected_version)
+		ver = expected_version;
+
 	if (strcmp(intf, "wl_seat") == 0) {
 		*seat = wl_registry_bind(registry, id,
 					 &wl_seat_interface, ver);
@@ -609,3 +615,46 @@ TEST(threading_read_after_error_tst)
 
 	display_destroy(d);
 }
+
+static void
+seat_version_main(void)
+{
+	struct client *c = client_connect();
+	struct wl_seat *seat = client_get_seat(c);
+	struct wl_pointer *pointer;
+	uint32_t ev = expected_version;
+
+	/* display proxy should always be version 0 */
+	assert(wl_proxy_get_version((struct wl_proxy *) c->wl_display) == 0);
+
+	assert(wl_proxy_get_version((struct wl_proxy *) seat) == ev);
+	assert(wl_seat_get_version(seat) == ev);
+
+	pointer = wl_seat_get_pointer(seat);
+	assert(wl_pointer_get_version(pointer) == ev);
+	assert(wl_proxy_get_version((struct wl_proxy *) pointer) == ev);
+	wl_proxy_destroy((struct wl_proxy *) pointer);
+
+	wl_proxy_destroy((struct wl_proxy *) seat);
+	client_disconnect_nocheck(c);
+}
+
+TEST(versions)
+{
+	struct display *d = display_create();
+	struct wl_global *global;
+	int i;
+
+	global = wl_global_create(d->wl_display, &wl_seat_interface,
+				  5, d, bind_seat);
+	for (i = 1; i <= 5; i++) {
+		expected_version = i;
+
+		client_create(d, seat_version_main);
+		display_run(d);
+
+	}
+	wl_global_destroy(global);
+
+	display_destroy(d);
+}
-- 
2.7.0.rc3



More information about the wayland-devel mailing list