mirror of
https://gitlab.freedesktop.org/wayland/weston.git
synced 2026-05-30 14:08:21 +02:00
tests/color-management-protocol: add soft-fail image description
We need to be able to test cases where a client tries to use a not-ready image description. Turns out passing an fd for a directory fails just the right way without triggering protocol errors. Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
This commit is contained in:
parent
1ffa089f7f
commit
5776cbb063
3 changed files with 64 additions and 4 deletions
|
|
@ -333,6 +333,26 @@ TEST(create_icc_image_description_no_info)
|
|||
return RESULT_OK;
|
||||
}
|
||||
|
||||
TEST(create_image_description_soft_fail)
|
||||
{
|
||||
struct client *client;
|
||||
struct color_manager_client *cm;
|
||||
struct image_description *image_descr;
|
||||
enum image_description_status status;
|
||||
|
||||
client = create_client_and_test_surface(100, 100, 100, 100);
|
||||
cm = color_manager_get(client);
|
||||
|
||||
image_descr = image_description_create_soft_fail(cm);
|
||||
status = image_description_wait(client, image_descr);
|
||||
test_assert_enum(status, CM_IMAGE_DESC_FAILED);
|
||||
|
||||
image_description_destroy(image_descr);
|
||||
client_destroy(client);
|
||||
|
||||
return RESULT_OK;
|
||||
}
|
||||
|
||||
TEST(get_surface_twice_bad)
|
||||
{
|
||||
struct client *client;
|
||||
|
|
|
|||
|
|
@ -290,15 +290,49 @@ image_description_create_for_icc(struct color_manager_client *cm,
|
|||
return image_description_from_proxy(proxy);
|
||||
}
|
||||
|
||||
void
|
||||
image_description_wait_until_ready(struct client *client,
|
||||
struct image_description *image_descr)
|
||||
/** Create an image description that gets rejected gracefully
|
||||
*
|
||||
* Passing a file descriptor referring to any directory as an ICC profile
|
||||
* will cause Weston to fail the image description without triggering a
|
||||
* protocol error.
|
||||
*/
|
||||
struct image_description *
|
||||
image_description_create_soft_fail(struct color_manager_client *cm)
|
||||
{
|
||||
struct wp_image_description_creator_icc_v1 *creator;
|
||||
struct wp_image_description_v1 *proxy;
|
||||
int fd;
|
||||
|
||||
fd = open("/", O_RDONLY);
|
||||
test_assert_int_ge(fd, 0);
|
||||
|
||||
creator = wp_color_manager_v1_create_icc_creator(cm->manager_proxy);
|
||||
wp_image_description_creator_icc_v1_set_icc_file(creator, fd, 0, 1);
|
||||
close(fd);
|
||||
proxy = wp_image_description_creator_icc_v1_create(creator);
|
||||
|
||||
return image_description_from_proxy(proxy);
|
||||
}
|
||||
|
||||
enum image_description_status
|
||||
image_description_wait(struct client *client, struct image_description *image_descr)
|
||||
{
|
||||
while (image_descr->status == CM_IMAGE_DESC_NOT_CREATED)
|
||||
if (!test_assert_int_ge(wl_display_dispatch(client->wl_display), 0))
|
||||
break;
|
||||
|
||||
test_assert_enum(image_descr->status, CM_IMAGE_DESC_READY);
|
||||
return image_descr->status;
|
||||
}
|
||||
|
||||
void
|
||||
image_description_wait_until_ready(struct client *client,
|
||||
struct image_description *image_descr)
|
||||
{
|
||||
enum image_description_status status;
|
||||
|
||||
status = image_description_wait(client, image_descr);
|
||||
|
||||
test_assert_enum(status, CM_IMAGE_DESC_READY);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -93,6 +93,12 @@ struct image_description *
|
|||
image_description_create_for_preferred(struct color_manager_client *cm,
|
||||
struct surface *surface);
|
||||
|
||||
struct image_description *
|
||||
image_description_create_soft_fail(struct color_manager_client *cm);
|
||||
|
||||
enum image_description_status
|
||||
image_description_wait(struct client *client, struct image_description *image_descr);
|
||||
|
||||
void
|
||||
image_description_wait_until_ready(struct client *client,
|
||||
struct image_description *image_descr);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue