summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeandro Ribeiro <leandro.ribeiro@collabora.com>2024-04-15 17:37:49 -0300
committerPekka Paalanen <pq@iki.fi>2024-04-26 12:11:17 +0000
commitf982e989542ac21e8a56bad25a6710e5f7375867 (patch)
tree9adf706a31ed194d9d05841e69335f7c41bce242
parentc10ca00e10847045803de92292baf2cf7e7f7e13 (diff)
tests: do not assume that the image description is immediately ready
This patch is for our CM&HDR protocol extension test. According to the protocol, the compositor may take the time it needs before sending 'ready' or 'failed' for a certain image description that the client creates through the CM&HDR protocol extension. In our CM&HDR tests, we are assuming that the image description would be ready immediately. Do not assume that. Instead, let's wait until the compositor sends one of the events ('failed' or 'ready'). Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
-rw-r--r--tests/color-management-test.c34
1 files changed, 24 insertions, 10 deletions
diff --git a/tests/color-management-test.c b/tests/color-management-test.c
index ec748667..9414d8f5 100644
--- a/tests/color-management-test.c
+++ b/tests/color-management-test.c
@@ -67,7 +67,11 @@ const struct lcms_pipeline pipeline_sRGB = {
struct image_description {
struct xx_image_description_v2 *xx_image_descr;
- bool ready;
+ enum image_description_status {
+ CM_IMAGE_DESC_NOT_CREATED = 0,
+ CM_IMAGE_DESC_READY,
+ CM_IMAGE_DESC_FAILED,
+ } status;
/* color_manager::image_descr_list */
struct wl_list link;
@@ -136,13 +140,17 @@ image_descr_ready(void *data, struct xx_image_description_v2 *xx_image_descripti
{
struct image_description *image_descr = data;
- image_descr->ready = true;
+ image_descr->status = CM_IMAGE_DESC_READY;
}
static void
image_descr_failed(void *data, struct xx_image_description_v2 *xx_image_description_v2,
uint32_t cause, const char *msg)
{
+ struct image_description *image_descr = data;
+
+ image_descr->status = CM_IMAGE_DESC_FAILED;
+
testlog("Failed to create image description:\n" \
" cause: %u, msg: %s\n", cause, msg);
}
@@ -699,6 +707,16 @@ image_descr_get_information(struct image_description *image_descr)
return image_descr_info;
}
+static void
+wait_until_image_description_ready(struct client *client,
+ struct image_description *image_descr)
+{
+ while (image_descr->status == CM_IMAGE_DESC_NOT_CREATED)
+ assert(wl_display_dispatch(client->wl_display) >= 0);
+
+ assert(image_descr->status == CM_IMAGE_DESC_READY);
+}
+
TEST(output_get_image_description)
{
struct client *client;
@@ -711,9 +729,7 @@ TEST(output_get_image_description)
/* Get image description from output */
image_descr = get_output_image_description(&cm);
- client_roundtrip(client);
-
- assert(image_descr->ready);
+ wait_until_image_description_ready(client, image_descr);
/* Get output image description information */
image_descr_info = image_descr_get_information(image_descr);
@@ -736,9 +752,7 @@ TEST(surface_get_preferred_image_description)
/* Get preferred image description from surface */
image_descr = get_surface_preferred_image_description(&cm);
- client_roundtrip(client);
-
- assert(image_descr->ready);
+ wait_until_image_description_ready(client, image_descr);
/* Get surface image description information */
image_descr_info = image_descr_get_information(image_descr);
@@ -937,7 +951,7 @@ TEST(create_icc_image_description_no_info)
/* Create image description based on ICC profile */
image_descr = create_icc_based_image_description(&cm, image_descr_creator_icc,
srgb_icc_profile_path);
- client_roundtrip(client);
+ wait_until_image_description_ready(client, image_descr);
/* Get image description information, and that should fail. Images
* descriptions that we create do not accept this request. */
@@ -966,7 +980,7 @@ TEST(set_surface_image_description)
/* Create image description based on ICC profile */
image_descr = create_icc_based_image_description(&cm, image_descr_creator_icc,
srgb_icc_profile_path);
- client_roundtrip(client);
+ wait_until_image_description_ready(client, image_descr);
/* Set surface image description */
xx_color_management_surface_v2_set_image_description(cm.surface,