tests: start to use Weston's default screenshooter in the test suite

Until now we had two different protocol extensions: one for the
test suite screenshooter and other for the screenshooter client.
As they are identical and this won't change, make the test suite
use the same protocol that the screenshooter client uses.

Besides the cleanup, this change will also allow us to use the
DRM writeback screenshooter in the test suite, as the test suite
implementation is hardcoded to use a renderer based screenshooter.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
This commit is contained in:
Leandro Ribeiro 2020-10-17 15:03:09 -03:00 committed by Pekka Paalanen
parent bc56729ffe
commit 9e90760ab0
5 changed files with 29 additions and 11 deletions

View File

@ -2,7 +2,7 @@ plugin_test_shell_desktop = shared_library(
'weston-test-desktop-shell', 'weston-test-desktop-shell',
'weston-test-desktop-shell.c', 'weston-test-desktop-shell.c',
include_directories: common_inc, include_directories: common_inc,
dependencies: [ dep_lib_desktop, dep_libweston_public ], dependencies: [ dep_lib_desktop, dep_libweston_public, dep_libexec_weston ],
name_prefix: '', name_prefix: '',
install: false install: false
) )
@ -29,6 +29,7 @@ lib_test_client = static_library(
'weston-test-client-helper.c', 'weston-test-client-helper.c',
'weston-test-fixture-compositor.c', 'weston-test-fixture-compositor.c',
weston_test_client_protocol_h, weston_test_client_protocol_h,
weston_screenshooter_protocol_c,
weston_test_protocol_c, weston_test_protocol_c,
viewporter_client_protocol_h, viewporter_client_protocol_h,
viewporter_protocol_c, viewporter_protocol_c,

View File

@ -540,17 +540,20 @@ test_handle_pointer_position(void *data, struct weston_test *weston_test,
} }
static void static void
test_handle_capture_screenshot_done(void *data, struct weston_test *weston_test) test_handle_capture_screenshot_done(void *data, struct weston_screenshooter *screenshooter)
{ {
struct test *test = data; struct client *client = data;
testlog("Screenshot has been captured\n"); testlog("Screenshot has been captured\n");
test->buffer_copy_done = true; client->buffer_copy_done = true;
} }
static const struct weston_screenshooter_listener screenshooter_listener = {
test_handle_capture_screenshot_done
};
static const struct weston_test_listener test_listener = { static const struct weston_test_listener test_listener = {
test_handle_pointer_position, test_handle_pointer_position,
test_handle_capture_screenshot_done,
}; };
static void static void
@ -792,6 +795,12 @@ handle_global(void *data, struct wl_registry *registry,
&weston_test_interface, version); &weston_test_interface, version);
weston_test_add_listener(test->weston_test, &test_listener, test); weston_test_add_listener(test->weston_test, &test_listener, test);
client->test = test; client->test = test;
} else if (strcmp(interface, "weston_screenshooter") == 0) {
client->screenshooter =
wl_registry_bind(registry, id,
&weston_screenshooter_interface, 1);
weston_screenshooter_add_listener(client->screenshooter,
&screenshooter_listener, client);
} }
} }
@ -1614,17 +1623,18 @@ capture_screenshot_of_output(struct client *client)
{ {
struct buffer *buffer; struct buffer *buffer;
assert(client->screenshooter);
buffer = create_shm_buffer_a8r8g8b8(client, buffer = create_shm_buffer_a8r8g8b8(client,
client->output->width, client->output->width,
client->output->height); client->output->height);
client->test->buffer_copy_done = false; client->buffer_copy_done = false;
weston_test_capture_screenshot(client->test->weston_test, weston_screenshooter_take_shot(client->screenshooter,
client->output->wl_output, client->output->wl_output,
buffer->proxy); buffer->proxy);
while (client->test->buffer_copy_done == false) while (client->buffer_copy_done == false)
if (wl_display_dispatch(client->wl_display) < 0) assert(wl_display_dispatch(client->wl_display) >= 0);
break;
/* FIXME: Document somewhere the orientation the screenshot is taken /* FIXME: Document somewhere the orientation the screenshot is taken
* and how the clip coords are interpreted, in case of scaling/transform. * and how the clip coords are interpreted, in case of scaling/transform.

View File

@ -37,6 +37,7 @@
#include <wayland-client-protocol.h> #include <wayland-client-protocol.h>
#include "weston-test-runner.h" #include "weston-test-runner.h"
#include "weston-test-client-protocol.h" #include "weston-test-client-protocol.h"
#include "weston-screenshooter-client-protocol.h"
#include "viewporter-client-protocol.h" #include "viewporter-client-protocol.h"
struct client { struct client {
@ -58,6 +59,8 @@ struct client {
int has_argb; int has_argb;
struct wl_list global_list; struct wl_list global_list;
struct wl_list output_list; /* struct output::link */ struct wl_list output_list; /* struct output::link */
struct weston_screenshooter *screenshooter;
bool buffer_copy_done;
}; };
struct global { struct global {
@ -72,7 +75,6 @@ struct test {
int pointer_x; int pointer_x;
int pointer_y; int pointer_y;
uint32_t n_egl_buffers; uint32_t n_egl_buffers;
bool buffer_copy_done;
}; };
struct input { struct input {

View File

@ -221,6 +221,8 @@ wet_shell_init(struct weston_compositor *ec,
if (dts->desktop == NULL) if (dts->desktop == NULL)
goto out_view; goto out_view;
screenshooter_create(ec);
return 0; return 0;
out_view: out_view:

View File

@ -369,6 +369,9 @@ execute_compositor(const struct compositor_setup *setup,
return RESULT_FAIL; return RESULT_FAIL;
} }
/* Test suite needs the debug protocol to be able to take screenshots */
prog_args_take(&args, strdup("--debug"));
asprintf(&tmp, "--socket=%s", setup->testset_name); asprintf(&tmp, "--socket=%s", setup->testset_name);
prog_args_take(&args, tmp); prog_args_take(&args, tmp);