diff options
| author | Simon Ser <contact@emersion.fr> | 2022-05-12 19:30:38 +0200 |
|---|---|---|
| committer | Simon Ser <contact@emersion.fr> | 2022-06-15 07:53:19 +0000 |
| commit | 2fb4cdebbedb2c0468ce331cadafd0dfc83fb08f (patch) | |
| tree | 75ed7b8d31c549787878f890e71a2cccf5ef8a7f /tests/display-test.c | |
| parent | server: check visibility before sending global/global_remove (diff) | |
| download | wayland-2fb4cdebbedb2c0468ce331cadafd0dfc83fb08f.tar wayland-2fb4cdebbedb2c0468ce331cadafd0dfc83fb08f.tar.gz wayland-2fb4cdebbedb2c0468ce331cadafd0dfc83fb08f.tar.bz2 wayland-2fb4cdebbedb2c0468ce331cadafd0dfc83fb08f.tar.lz wayland-2fb4cdebbedb2c0468ce331cadafd0dfc83fb08f.tar.xz wayland-2fb4cdebbedb2c0468ce331cadafd0dfc83fb08f.tar.zst wayland-2fb4cdebbedb2c0468ce331cadafd0dfc83fb08f.zip | |
tests: add a test for dynamic filtered globals
Ensure dynamically created and destroyed globals which are filtered
don't trigger any global/global_remove event.
Signed-off-by: Simon Ser <contact@emersion.fr>
Diffstat (limited to 'tests/display-test.c')
| -rw-r--r-- | tests/display-test.c | 61 |
1 files changed, 60 insertions, 1 deletions
diff --git a/tests/display-test.c b/tests/display-test.c index a6f410d..bcb3267 100644 --- a/tests/display-test.c +++ b/tests/display-test.c @@ -1006,9 +1006,16 @@ registry_handle_filtered(void *data, struct wl_registry *registry, } } +static void +registry_handle_remove_filtered(void *data, struct wl_registry *registry, + uint32_t id) +{ + assert(false); +} + static const struct wl_registry_listener registry_listener_filtered = { registry_handle_filtered, - NULL + registry_handle_remove_filtered, }; static void @@ -1045,6 +1052,58 @@ TEST(filtered_global_is_hidden) } static void +get_dynamic_globals(void *data) +{ + struct client *c = client_connect(); + struct wl_registry *registry; + + registry = wl_display_get_registry(c->wl_display); + wl_registry_add_listener(registry, ®istry_listener_filtered, data); + wl_display_roundtrip(c->wl_display); + + /* Wait for the server to create a new global */ + assert(stop_display(c, 1) >= 0); + + /* Check that we don't see it */ + wl_display_roundtrip(c->wl_display); + + /* Wait for the server to remove that global */ + assert(stop_display(c, 1) >= 0); + + /* Check that we don't get a global_remove event */ + wl_display_roundtrip(c->wl_display); + + wl_registry_destroy(registry); + client_disconnect_nocheck(c); +} + +TEST(filtered_dynamic_global_is_hidden) +{ + struct display *d; + struct wl_global *g; + + d = display_create(); + wl_display_set_global_filter(d->wl_display, global_filter, NULL); + + /* Create a client and let it enumerate the globals */ + client_create_noarg(d, get_dynamic_globals); + display_run(d); + + /* Dynamically create a new global */ + g = wl_global_create(d->wl_display, &wl_data_offer_interface, + 1, d, bind_data_offer); + + display_resume(d); + + /* Dynamically remove the global */ + wl_global_destroy(g); + + display_resume(d); + + display_destroy(d); +} + +static void check_bind_error(struct client *c) { uint32_t errorcode, id; |
