mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2026-04-10 08:21:15 -04:00
tests: add test for receiving an error on destroyed object
test if receiving an error on already destroyed object won't do any harm Signed-off-by: Marek Chalupa <mchqwerty@gmail.com> Reviewed-by: Jonas Ådahl <jadahl@gmail.com> Reviewed-by: Bryce Harrington <bryce@osg.samsung.com> Tested-by: Bryce Harrington <bryce@osg.samsung.com> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
This commit is contained in:
parent
25fcb88a26
commit
564623653a
1 changed files with 50 additions and 0 deletions
|
|
@ -876,3 +876,53 @@ TEST(versions)
|
||||||
|
|
||||||
display_destroy(d);
|
display_destroy(d);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
check_error_on_destroyed_object(void *data)
|
||||||
|
{
|
||||||
|
struct client *c;
|
||||||
|
struct wl_seat *seat;
|
||||||
|
uint32_t id;
|
||||||
|
const struct wl_interface *intf;
|
||||||
|
|
||||||
|
c = client_connect();
|
||||||
|
seat = client_get_seat(c);
|
||||||
|
|
||||||
|
/* destroy the seat proxy. The display won't know
|
||||||
|
* about it yet, so it will post the error as usual */
|
||||||
|
wl_proxy_destroy((struct wl_proxy *) seat);
|
||||||
|
|
||||||
|
/* let display post the error. The error will
|
||||||
|
* be caught in stop_display while dispatching */
|
||||||
|
assert(stop_display(c, 1) == -1);
|
||||||
|
|
||||||
|
/* check the returned error. Since the object was destroyed,
|
||||||
|
* we don't know the interface and id */
|
||||||
|
assert(wl_display_get_error(c->wl_display) == EPROTO);
|
||||||
|
assert(wl_display_get_protocol_error(c->wl_display, &intf, &id) == 23);
|
||||||
|
assert(intf == NULL);
|
||||||
|
assert(id == 0);
|
||||||
|
|
||||||
|
client_disconnect_nocheck(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(error_on_destroyed_object)
|
||||||
|
{
|
||||||
|
struct client_info *cl;
|
||||||
|
struct display *d = display_create();
|
||||||
|
|
||||||
|
wl_global_create(d->wl_display, &wl_seat_interface,
|
||||||
|
1, d, bind_seat);
|
||||||
|
|
||||||
|
cl = client_create_noarg(d, check_error_on_destroyed_object);
|
||||||
|
display_run(d);
|
||||||
|
|
||||||
|
/* did client bind to the seat? */
|
||||||
|
assert(cl->data);
|
||||||
|
|
||||||
|
/* post error on the destroyed object */
|
||||||
|
wl_resource_post_error((struct wl_resource *) cl->data,
|
||||||
|
23, "Dummy error");
|
||||||
|
display_resume(d);
|
||||||
|
display_destroy(d);
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue