tests: Add the ability the specify the output name

In preparation of having multiple outputs available we should be able to
specify by its name. We just use the default one if none was set-up at all.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
This commit is contained in:
Marius Vlad 2022-11-30 17:54:16 +02:00 committed by Daniel Stone
parent 59ac0a38da
commit 1e16a5eb2d
14 changed files with 43 additions and 23 deletions

View File

@ -346,7 +346,7 @@ TEST(alpha_blend)
/* attach, damage, commit background window */
move_client(client, 0, 0);
shot = capture_screenshot_of_output(client);
shot = capture_screenshot_of_output(client, NULL);
assert(shot);
match = verify_image(shot->image, "alpha_blend", seq_no, NULL, seq_no);
assert(check_blend_pattern(bg, fg, shot, space));

View File

@ -143,7 +143,7 @@ TEST_P(buffer_transform, my_buffer_args)
bargs->transform);
move_client(client, 19, 19);
match = verify_screen_content(client, refname, 0, NULL, 0);
match = verify_screen_content(client, refname, 0, NULL, 0, NULL);
assert(match);
client_destroy(client);

View File

@ -618,7 +618,7 @@ TEST(opaque_pixel_conversion)
wl_surface_damage(surface, 0, 0, width, height);
wl_surface_commit(surface);
shot = capture_screenshot_of_output(client);
shot = capture_screenshot_of_output(client, NULL);
assert(shot);
match = verify_image(shot->image, "shaper_matrix", arg->ref_image_index,
@ -834,7 +834,7 @@ TEST(output_icc_alpha_blend)
/* attach, damage, commit background window */
move_client(client, 0, 0);
shot = capture_screenshot_of_output(client);
shot = capture_screenshot_of_output(client, NULL);
assert(shot);
match = verify_image(shot->image, "output_icc_alpha_blend", arg->ref_image_index,
NULL, seq_no);

View File

@ -90,7 +90,7 @@ TEST(drm_screenshot_no_damage) {
*/
for (i = 0; i < 5; i++) {
ret = verify_screen_content(client, "drm_screenshot_no_damage",
0, NULL, i);
0, NULL, i, NULL);
assert(ret);
}

View File

@ -118,7 +118,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);
screenshot = capture_screenshot_of_output(client, NULL);
assert(screenshot);
/* Load good reference image */

View File

@ -221,7 +221,7 @@ 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))
if (!verify_screen_content(client, refname, i, NULL, i, NULL))
match = false;
}

View File

@ -143,7 +143,7 @@ TEST_P(output_transform, my_buffer_args)
bargs->transform);
move_client(client, 19, 19);
match = verify_screen_content(client, refname, 0, NULL, 0);
match = verify_screen_content(client, refname, 0, NULL, 0, NULL);
assert(match);
client_destroy(client);

View File

@ -149,7 +149,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, 0, NULL);
assert(match);
/* Move the cursor just outside the main surface. */
@ -158,7 +158,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, 1, NULL);
assert(match);
/* And back in the main surface again. */
@ -167,7 +167,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, 2, NULL);
assert(match);
surface_destroy(back_cursor_surface);

View File

@ -102,7 +102,7 @@ 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);
match = verify_screen_content(client, "single-pixel-buffer", 0, NULL, 0, NULL);
assert(match);
wl_buffer_destroy(buffer);

View File

@ -103,7 +103,7 @@ check_screen(struct client *client,
bool match;
match = verify_screen_content(client, ref_image, ref_seq_no, clip,
seq_no);
seq_no, NULL);
return match ? 0 : -1;
}

View File

@ -92,7 +92,7 @@ TEST(viewport_upscale_solid)
move_client(client, 19, 19);
match = verify_screen_content(client, "viewport_upscale_solid", 0,
NULL, 0);
NULL, 0, NULL);
assert(match);
wp_viewport_destroy(viewport);

View File

@ -1721,8 +1721,8 @@ client_capture_output(struct client *client,
/**
* Take screenshot of a single output
*
* Requests a screenshot from the server of the output that the
* client appears on. This implies that the compositor goes through an output
* Requests a screenshot from the server of the output specified
* in output_name. This implies that the compositor goes through an output
* repaint to provide the screenshot before this function returns. This
* function is therefore both a server roundtrip and a wait for a repaint.
*
@ -1732,16 +1732,34 @@ client_capture_output(struct client *client,
* orientation rather than scale=1 or orientation=normal. The pixel format
* 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
* @returns A new buffer object, that should be freed with buffer_destroy().
*/
struct buffer *
capture_screenshot_of_output(struct client *client)
capture_screenshot_of_output(struct client *client, const char *output_name)
{
struct image_header ih;
struct buffer *shm;
struct buffer *buf;
struct output *output = NULL;
shm = client_capture_output(client, client->output,
if (output_name) {
struct output *output_iter;
wl_list_for_each(output_iter, &client->output_list, link) {
if (!strcmp(output_name, output_iter->name)) {
output = output_iter;
break;
}
}
assert(output);
} else {
output = client->output;
}
shm = client_capture_output(client, output,
WESTON_CAPTURE_V1_SOURCE_FRAMEBUFFER);
ih = image_header_from(shm->image);
@ -1866,6 +1884,8 @@ verify_image(pixman_image_t *shot,
* \param ref_seq_no See verify_image().
* \param clip See verify_image().
* \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.
* \return True if the screen contents matches the reference image,
* false otherwise.
*/
@ -1874,12 +1894,12 @@ verify_screen_content(struct client *client,
const char *ref_image,
int ref_seq_no,
const struct rectangle *clip,
int seq_no)
int seq_no, const char *output_name)
{
struct buffer *shot;
bool match;
shot = capture_screenshot_of_output(client);
shot = capture_screenshot_of_output(client, output_name);
assert(shot);
match = verify_image(shot->image, ref_image, ref_seq_no, clip, seq_no);
buffer_destroy(shot);

View File

@ -274,7 +274,7 @@ pixman_image_t *
load_image_from_png(const char *fname);
struct buffer *
capture_screenshot_of_output(struct client *client);
capture_screenshot_of_output(struct client *client, const char *output_name);
struct buffer *
client_capture_output(struct client *client,
@ -296,7 +296,7 @@ verify_screen_content(struct client *client,
const char *ref_image,
int ref_seq_no,
const struct rectangle *clip,
int seq_no);
int seq_no, const char *output_name);
struct buffer *
client_buffer_from_image_file(struct client *client,

View File

@ -464,7 +464,7 @@ TEST_P(yuv_buffer_shm, yuv_cases)
buf = my_case->create_buffer(client, my_case->drm_format, img);
show_window_with_yuv(client, buf);
match = verify_screen_content(client, "yuv-buffer", 0, NULL, 0);
match = verify_screen_content(client, "yuv-buffer", 0, NULL, 0, NULL);
assert(match);
yuv_buffer_destroy(buf);