From 7bb9fc5b62e6881da4d69859263bc6505b90da62 Mon Sep 17 00:00:00 2001 From: Marius Vlad Date: Fri, 2 May 2025 11:00:04 +0300 Subject: [PATCH] weston-test-client-helper: Move helpers into weston-test-client-helper As we can re-use this for other tests make them available. Signed-off-by: Marius Vlad --- tests/kiosk-shell-test.c | 50 ---------------------------- tests/weston-test-client-helper.c | 54 +++++++++++++++++++++++++++++++ tests/weston-test-client-helper.h | 9 ++++++ 3 files changed, 63 insertions(+), 50 deletions(-) diff --git a/tests/kiosk-shell-test.c b/tests/kiosk-shell-test.c index 4edd26b9c..aae7a079a 100644 --- a/tests/kiosk-shell-test.c +++ b/tests/kiosk-shell-test.c @@ -68,56 +68,6 @@ DECLARE_LIST_ITERATOR(pnode_from_z, struct weston_output, paint_node_z_order_lis DECLARE_LIST_ITERATOR(view_from_surface, struct weston_surface, views, struct weston_view, link); -static void assert_resource_is_proxy(struct wet_testsuite_data *suite_data, - struct wl_resource *r, void *p) -{ - test_assert_ptr_not_null(r); - test_assert_ptr_eq(wl_resource_get_client(r), suite_data->wl_client); - test_assert_u32_eq(wl_resource_get_id(r), - wl_proxy_get_id((struct wl_proxy *) p)); -} - -static void assert_surface_matches(struct wet_testsuite_data *suite_data, - struct weston_surface *s, struct surface *c) -{ - test_assert_ptr_not_null(s); - test_assert_ptr_not_null(c); - - assert_resource_is_proxy(suite_data, s->resource, c->wl_surface); - test_assert_s32_eq(s->width, c->width); - test_assert_s32_eq(s->height, c->height); - - test_assert_ptr_not_null(s->buffer_ref.buffer); - test_assert_ptr_not_null(c->buffer); - assert_resource_is_proxy(suite_data, s->buffer_ref.buffer->resource, - c->buffer->proxy); -} - -static void assert_output_matches(struct wet_testsuite_data *suite_data, - struct weston_output *s, struct output *c) -{ - struct weston_head *head; - bool found_client_resource = false; - - test_assert_ptr_not_null(s); - test_assert_ptr_not_null(c); - - wl_list_for_each(head, &s->head_list, output_link) { - struct wl_resource *res; - wl_resource_for_each(res, &head->resource_list) { - if (wl_resource_get_client(res) == suite_data->wl_client && - wl_resource_get_id(res) == - wl_proxy_get_id((struct wl_proxy *) c->wl_output)) { - found_client_resource = true; - break; - } - } - } - test_assert_true(found_client_resource); - - test_assert_s32_eq(s->width, c->width); - test_assert_s32_eq(s->height, c->height); -} static void assert_surface_is_background(struct wet_testsuite_data *suite_data, diff --git a/tests/weston-test-client-helper.c b/tests/weston-test-client-helper.c index c0f987e25..2d45cdb8c 100644 --- a/tests/weston-test-client-helper.c +++ b/tests/weston-test-client-helper.c @@ -2352,6 +2352,60 @@ get_resource_data_from_proxy(struct wet_testsuite_data *suite_data, return wl_resource_get_user_data(resource); } +void +assert_resource_is_proxy(struct wet_testsuite_data *suite_data, + struct wl_resource *r, void *p) +{ + test_assert_ptr_not_null(r); + test_assert_ptr_eq(wl_resource_get_client(r), suite_data->wl_client); + test_assert_u32_eq(wl_resource_get_id(r), + wl_proxy_get_id((struct wl_proxy *) p)); +} + +void +assert_surface_matches(struct wet_testsuite_data *suite_data, + struct weston_surface *s, struct surface *c) +{ + test_assert_ptr_not_null(s); + test_assert_ptr_not_null(c); + + assert_resource_is_proxy(suite_data, s->resource, c->wl_surface); + test_assert_s32_eq(s->width, c->width); + test_assert_s32_eq(s->height, c->height); + + test_assert_ptr_not_null(s->buffer_ref.buffer); + test_assert_ptr_not_null(c->buffer); + assert_resource_is_proxy(suite_data, s->buffer_ref.buffer->resource, + c->buffer->proxy); +} + +void +assert_output_matches(struct wet_testsuite_data *suite_data, + struct weston_output *s, struct output *c) +{ + struct weston_head *head; + bool found_client_resource = false; + + test_assert_ptr_not_null(s); + test_assert_ptr_not_null(c); + + wl_list_for_each(head, &s->head_list, output_link) { + struct wl_resource *res; + wl_resource_for_each(res, &head->resource_list) { + if (wl_resource_get_client(res) == suite_data->wl_client && + wl_resource_get_id(res) == + wl_proxy_get_id((struct wl_proxy *) c->wl_output)) { + found_client_resource = true; + break; + } + } + } + test_assert_true(found_client_resource); + + test_assert_s32_eq(s->width, c->width); + test_assert_s32_eq(s->height, c->height); +} + /** * Asks the server to wait for a specified breakpoint the next time it occurs, * inserted immediately into the wait list with no synchronization to the diff --git a/tests/weston-test-client-helper.h b/tests/weston-test-client-helper.h index bb7240c68..43abeff3c 100644 --- a/tests/weston-test-client-helper.h +++ b/tests/weston-test-client-helper.h @@ -383,5 +383,14 @@ client_release_breakpoint(struct client *client, void * get_resource_data_from_proxy(struct wet_testsuite_data *suite_data, struct wl_proxy *proxy); +void +assert_resource_is_proxy(struct wet_testsuite_data *suite_data, + struct wl_resource *r, void *p); +void +assert_output_matches(struct wet_testsuite_data *suite_data, + struct weston_output *s, struct output *c); +void +assert_surface_matches(struct wet_testsuite_data *suite_data, + struct weston_surface *s, struct surface *c); #endif