diff --git a/tests/alpha-blending-test.c b/tests/alpha-blending-test.c index 1f1af32dc..d45c29672 100644 --- a/tests/alpha-blending-test.c +++ b/tests/alpha-blending-test.c @@ -353,7 +353,7 @@ TEST(alpha_blend) /* attach, damage, commit background window */ move_client(client, 0, 0); - shot = capture_screenshot_of_output(client, NULL); + shot = capture_screenshot_of_output(client, NULL, NO_DECORATIONS); test_assert_ptr_not_null(shot); match = verify_image(shot->image, "alpha_blend", seq_no, NULL, seq_no); test_assert_true(check_blend_pattern(bg, fg, shot, space)); diff --git a/tests/buffer-transforms-test.c b/tests/buffer-transforms-test.c index e20c0af33..1a776e884 100644 --- a/tests/buffer-transforms-test.c +++ b/tests/buffer-transforms-test.c @@ -151,7 +151,8 @@ TEST_P(buffer_transform, my_buffer_args) bargs->transform); move_client(client, 19, 19); - match = verify_screen_content(client, refname, 0, NULL, 0, NULL); + match = verify_screen_content(client, refname, 0, NULL, 0, NULL, + NO_DECORATIONS); test_assert_true(match); client_destroy(client); diff --git a/tests/client-buffer-test.c b/tests/client-buffer-test.c index 8efba1804..6ab7d8e3d 100644 --- a/tests/client-buffer-test.c +++ b/tests/client-buffer-test.c @@ -1667,7 +1667,7 @@ test_client_buffer(const struct client_buffer_case *cb_case, match = verify_screen_content(client, "client-buffer", cb_case->ref_seq_no, NULL, 0, - NULL); + NULL, NO_DECORATIONS); res = match ? RESULT_OK : RESULT_FAIL; client_buffer_util_destroy_buffer(buf); diff --git a/tests/color-effects-test.c b/tests/color-effects-test.c index 01009420a..3d4e679f1 100644 --- a/tests/color-effects-test.c +++ b/tests/color-effects-test.c @@ -149,7 +149,8 @@ TEST(color_effects) clip.y = 0; clip.width = buffer->buf->width; clip.height = buffer->buf->height; - verify_screen_content(client, arg->ref_image_prefix, seq_no, &clip, seq_no, NULL); + verify_screen_content(client, arg->ref_image_prefix, seq_no, &clip, + seq_no, NULL, NO_DECORATIONS); buffer_destroy(buffer); client_destroy(client); diff --git a/tests/color-icc-output-test.c b/tests/color-icc-output-test.c index f5debf6db..a5c857910 100644 --- a/tests/color-icc-output-test.c +++ b/tests/color-icc-output-test.c @@ -502,7 +502,7 @@ TEST(opaque_pixel_conversion) wl_surface_damage(surface, 0, 0, width, height); wl_surface_commit(surface); - shot = capture_screenshot_of_output(client, NULL); + shot = capture_screenshot_of_output(client, NULL, NO_DECORATIONS); test_assert_ptr_not_null(shot); match = verify_image(shot->image, "shaper_matrix", arg->ref_image_index, @@ -725,7 +725,7 @@ TEST(output_icc_alpha_blend) /* attach, damage, commit background window */ move_client(client, 0, 0); - shot = capture_screenshot_of_output(client, NULL); + shot = capture_screenshot_of_output(client, NULL, NO_DECORATIONS); test_assert_ptr_not_null(shot); match = verify_image(shot->image, "output_icc_alpha_blend", arg->ref_image_index, NULL, seq_no); @@ -760,23 +760,15 @@ TEST(output_icc_decorations) int seq_no = get_test_fixture_index(); const struct setup_args *arg = &my_setup_args[seq_no]; struct client *client; - struct buffer *shot; - pixman_image_t *img; bool match; client = create_client(); - shot = client_capture_output(client, client->output, - WESTON_CAPTURE_V1_SOURCE_FULL_FRAMEBUFFER, - CLIENT_BUFFER_TYPE_SHM); - img = image_convert_to_a8r8g8b8(shot->image); - - match = verify_image(img, "output-icc-decorations", - arg->ref_image_index, NULL, seq_no); + match = verify_screen_content(client, "output-icc-decorations", + arg->ref_image_index, NULL, seq_no, + client->output->name, INCLUDE_DECORATIONS); test_assert_true(match); - pixman_image_unref(img); - buffer_destroy(shot); client_destroy(client); return RESULT_OK; diff --git a/tests/drm-smoke-test.c b/tests/drm-smoke-test.c index e036a4252..bb5bed1e6 100644 --- a/tests/drm-smoke-test.c +++ b/tests/drm-smoke-test.c @@ -94,7 +94,7 @@ TEST(drm_screenshot_no_damage) { */ for (i = 0; i < 5; i++) { ret = verify_screen_content(client, "drm_screenshot_no_damage", - 0, NULL, i, NULL); + 0, NULL, i, NULL, NO_DECORATIONS); test_assert_true(ret); } diff --git a/tests/internal-screenshot-test.c b/tests/internal-screenshot-test.c index 17b12d5e5..6ac618797 100644 --- a/tests/internal-screenshot-test.c +++ b/tests/internal-screenshot-test.c @@ -120,7 +120,7 @@ TEST(internal_screenshot) /* Take a snapshot. Result will be in screenshot->wl_buffer. */ testlog("Taking a screenshot\n"); - screenshot = capture_screenshot_of_output(client, NULL); + screenshot = capture_screenshot_of_output(client, NULL, NO_DECORATIONS); test_assert_ptr_not_null(screenshot); /* Load good reference image */ diff --git a/tests/output-damage-test.c b/tests/output-damage-test.c index 320f5e91f..ed54f2966 100644 --- a/tests/output-damage-test.c +++ b/tests/output-damage-test.c @@ -224,8 +224,10 @@ TEST(output_damage) */ for (i = 1; i < COUNT_BUFS; i++) { commit_buffer_with_damage(client->surface, buf[i], damages[i]); - if (!verify_screen_content(client, refname, i, NULL, i, NULL)) + if (!verify_screen_content(client, refname, i, NULL, i, NULL, + NO_DECORATIONS)) { match = false; + } } test_assert_true(match); diff --git a/tests/output-decorations-test.c b/tests/output-decorations-test.c index a817d0d82..2298c7aee 100644 --- a/tests/output-decorations-test.c +++ b/tests/output-decorations-test.c @@ -82,22 +82,14 @@ DECLARE_FIXTURE_SETUP_WITH_ARG(fixture_setup, my_setup_args, meta); TEST(output_decorations) { struct client *client; - struct buffer *shot; - pixman_image_t *img; bool match; client = create_client(); - shot = client_capture_output(client, client->output, - WESTON_CAPTURE_V1_SOURCE_FULL_FRAMEBUFFER, - CLIENT_BUFFER_TYPE_SHM); - img = image_convert_to_a8r8g8b8(shot->image); - - match = verify_image(img, "output-decorations", 0, NULL, 0); + match = verify_screen_content(client, "output-decorations", 0, NULL, 0, + client->output->name, INCLUDE_DECORATIONS); test_assert_true(match); - pixman_image_unref(img); - buffer_destroy(shot); client_destroy(client); return RESULT_OK; diff --git a/tests/output-transforms-test.c b/tests/output-transforms-test.c index 05b9da45c..218978cd2 100644 --- a/tests/output-transforms-test.c +++ b/tests/output-transforms-test.c @@ -151,7 +151,8 @@ TEST_P(output_transform, my_buffer_args) bargs->transform); move_client(client, 19, 19); - match = verify_screen_content(client, refname, 0, NULL, 0, NULL); + match = verify_screen_content(client, refname, 0, NULL, 0, NULL, + NO_DECORATIONS); test_assert_true(match); client_destroy(client); diff --git a/tests/pointer-shot-test.c b/tests/pointer-shot-test.c index 23de08e57..166449be4 100644 --- a/tests/pointer-shot-test.c +++ b/tests/pointer-shot-test.c @@ -155,7 +155,7 @@ TEST(pointer_cursor_retains_committed_buffer_after_reenter) client->input->pointer->serial, main_cursor_surface->wl_surface, 0, 0); match = verify_screen_content(client, "pointer_cursor_reenter", 0, - NULL, 0, NULL); + NULL, 0, NULL, NO_DECORATIONS); test_assert_true(match); /* Move the cursor just outside the main surface. */ @@ -164,7 +164,7 @@ TEST(pointer_cursor_retains_committed_buffer_after_reenter) client->input->pointer->serial, back_cursor_surface->wl_surface, 0, 0); match = verify_screen_content(client, "pointer_cursor_reenter", 1, - NULL, 1, NULL); + NULL, 1, NULL, NO_DECORATIONS); test_assert_true(match); /* And back in the main surface again. */ @@ -173,7 +173,7 @@ TEST(pointer_cursor_retains_committed_buffer_after_reenter) client->input->pointer->serial, main_cursor_surface->wl_surface, 0, 0); match = verify_screen_content(client, "pointer_cursor_reenter", 2, - NULL, 2, NULL); + NULL, 2, NULL, NO_DECORATIONS); test_assert_true(match); surface_destroy(back_cursor_surface); diff --git a/tests/single-pixel-buffer-test.c b/tests/single-pixel-buffer-test.c index 740df373e..b4f1dd0d2 100644 --- a/tests/single-pixel-buffer-test.c +++ b/tests/single-pixel-buffer-test.c @@ -100,7 +100,8 @@ TEST(solid_buffer_argb_u32) wl_surface_commit(client->surface->wl_surface); frame_callback_wait(client, &done); - match = verify_screen_content(client, "single-pixel-buffer", 0, NULL, 0, NULL); + match = verify_screen_content(client, "single-pixel-buffer", 0, + NULL, 0, NULL, NO_DECORATIONS); test_assert_true(match); wl_buffer_destroy(buffer); diff --git a/tests/subsurface-shot-test.c b/tests/subsurface-shot-test.c index 80cdbb27b..905a98f0f 100644 --- a/tests/subsurface-shot-test.c +++ b/tests/subsurface-shot-test.c @@ -109,7 +109,7 @@ check_screen(struct client *client, bool match; match = verify_screen_content(client, ref_image, ref_seq_no, clip, - seq_no, NULL); + seq_no, NULL, NO_DECORATIONS); return match ? 0 : -1; } diff --git a/tests/viewporter-shot-test.c b/tests/viewporter-shot-test.c index caede8482..b25225f03 100644 --- a/tests/viewporter-shot-test.c +++ b/tests/viewporter-shot-test.c @@ -97,7 +97,7 @@ TEST(viewport_upscale_solid) move_client(client, 19, 19); match = verify_screen_content(client, "viewport_upscale_solid", 0, - NULL, 0, NULL); + NULL, 0, NULL, NO_DECORATIONS); test_assert_true(match); wp_viewport_destroy(viewport); diff --git a/tests/weston-test-client-helper.c b/tests/weston-test-client-helper.c index 6907e1219..d512b9f9f 100644 --- a/tests/weston-test-client-helper.c +++ b/tests/weston-test-client-helper.c @@ -2037,16 +2037,21 @@ client_capture_output(struct client *client, * is ensured to be PIXMAN_a8r8g8b8. * * @param client a client instance, as created by create_client() - * @param output_name the name of the output, as specified by wl_output.name + * @param output_name the name of the output, as specified by wl_output.name, + * or NULL to use the client-defined output + * @param include_decorations true if the screenshot should include output + * decorations, or false if it should include just the client content * @returns A new buffer object, that should be freed with buffer_destroy(). */ struct buffer * -capture_screenshot_of_output(struct client *client, const char *output_name) +capture_screenshot_of_output(struct client *client, const char *output_name, + enum screenshot_decoration_mode include_decorations) { struct image_header ih; struct buffer *shm; struct buffer *buf; struct output *output = NULL; + enum weston_capture_v1_source source; if (output_name) { struct output *output_iter; @@ -2063,8 +2068,12 @@ capture_screenshot_of_output(struct client *client, const char *output_name) output = client->output; } - shm = client_capture_output(client, output, - WESTON_CAPTURE_V1_SOURCE_FRAMEBUFFER, + if (include_decorations == INCLUDE_DECORATIONS) + source = WESTON_CAPTURE_V1_SOURCE_FULL_FRAMEBUFFER; + else + source = WESTON_CAPTURE_V1_SOURCE_FRAMEBUFFER; + + shm = client_capture_output(client, output, source, CLIENT_BUFFER_TYPE_SHM); ih = image_header_from(shm->image); @@ -2182,6 +2191,8 @@ verify_image(pixman_image_t *shot, * \param seq_no See verify_image(). * \param output_name the output name as specified by wl_output.name. If NULL, * this is the last wl_output advertised by wl_registry. + * \param include_decorations true if the screenshot should include output + * decorations, or false if it should include just the client content * \return True if the screen contents matches the reference image, * false otherwise. */ @@ -2190,12 +2201,14 @@ verify_screen_content(struct client *client, const char *ref_image, int ref_seq_no, const struct rectangle *clip, - int seq_no, const char *output_name) + int seq_no, const char *output_name, + enum screenshot_decoration_mode include_decorations) { struct buffer *shot; bool match; - shot = capture_screenshot_of_output(client, output_name); + shot = capture_screenshot_of_output(client, output_name, + include_decorations); test_assert_ptr_not_null(shot); match = verify_image(shot->image, ref_image, ref_seq_no, clip, seq_no); buffer_destroy(shot); diff --git a/tests/weston-test-client-helper.h b/tests/weston-test-client-helper.h index 9afeeb785..ad0713a40 100644 --- a/tests/weston-test-client-helper.h +++ b/tests/weston-test-client-helper.h @@ -207,6 +207,11 @@ struct range { int b; }; +enum screenshot_decoration_mode { + INCLUDE_DECORATIONS, + NO_DECORATIONS, +}; + struct client * create_client(void); @@ -318,7 +323,8 @@ pixman_image_t * load_image_from_png(const char *fname); struct buffer * -capture_screenshot_of_output(struct client *client, const char *output_name); +capture_screenshot_of_output(struct client *client, const char *output_name, + enum screenshot_decoration_mode include_decorations); struct buffer * client_capture_output(struct client *client, @@ -341,7 +347,8 @@ verify_screen_content(struct client *client, const char *ref_image, int ref_seq_no, const struct rectangle *clip, - int seq_no, const char *output_name); + int seq_no, const char *output_name, + enum screenshot_decoration_mode include_decorations); struct buffer * client_buffer_from_image_file(struct client *client,