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:
parent
bc56729ffe
commit
9e90760ab0
@ -2,7 +2,7 @@ plugin_test_shell_desktop = shared_library(
|
||||
'weston-test-desktop-shell',
|
||||
'weston-test-desktop-shell.c',
|
||||
include_directories: common_inc,
|
||||
dependencies: [ dep_lib_desktop, dep_libweston_public ],
|
||||
dependencies: [ dep_lib_desktop, dep_libweston_public, dep_libexec_weston ],
|
||||
name_prefix: '',
|
||||
install: false
|
||||
)
|
||||
@ -29,6 +29,7 @@ lib_test_client = static_library(
|
||||
'weston-test-client-helper.c',
|
||||
'weston-test-fixture-compositor.c',
|
||||
weston_test_client_protocol_h,
|
||||
weston_screenshooter_protocol_c,
|
||||
weston_test_protocol_c,
|
||||
viewporter_client_protocol_h,
|
||||
viewporter_protocol_c,
|
||||
|
@ -540,17 +540,20 @@ test_handle_pointer_position(void *data, struct weston_test *weston_test,
|
||||
}
|
||||
|
||||
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");
|
||||
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 = {
|
||||
test_handle_pointer_position,
|
||||
test_handle_capture_screenshot_done,
|
||||
};
|
||||
|
||||
static void
|
||||
@ -792,6 +795,12 @@ handle_global(void *data, struct wl_registry *registry,
|
||||
&weston_test_interface, version);
|
||||
weston_test_add_listener(test->weston_test, &test_listener, 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;
|
||||
|
||||
assert(client->screenshooter);
|
||||
|
||||
buffer = create_shm_buffer_a8r8g8b8(client,
|
||||
client->output->width,
|
||||
client->output->height);
|
||||
|
||||
client->test->buffer_copy_done = false;
|
||||
weston_test_capture_screenshot(client->test->weston_test,
|
||||
client->buffer_copy_done = false;
|
||||
weston_screenshooter_take_shot(client->screenshooter,
|
||||
client->output->wl_output,
|
||||
buffer->proxy);
|
||||
while (client->test->buffer_copy_done == false)
|
||||
if (wl_display_dispatch(client->wl_display) < 0)
|
||||
break;
|
||||
while (client->buffer_copy_done == false)
|
||||
assert(wl_display_dispatch(client->wl_display) >= 0);
|
||||
|
||||
/* FIXME: Document somewhere the orientation the screenshot is taken
|
||||
* and how the clip coords are interpreted, in case of scaling/transform.
|
||||
|
@ -37,6 +37,7 @@
|
||||
#include <wayland-client-protocol.h>
|
||||
#include "weston-test-runner.h"
|
||||
#include "weston-test-client-protocol.h"
|
||||
#include "weston-screenshooter-client-protocol.h"
|
||||
#include "viewporter-client-protocol.h"
|
||||
|
||||
struct client {
|
||||
@ -58,6 +59,8 @@ struct client {
|
||||
int has_argb;
|
||||
struct wl_list global_list;
|
||||
struct wl_list output_list; /* struct output::link */
|
||||
struct weston_screenshooter *screenshooter;
|
||||
bool buffer_copy_done;
|
||||
};
|
||||
|
||||
struct global {
|
||||
@ -72,7 +75,6 @@ struct test {
|
||||
int pointer_x;
|
||||
int pointer_y;
|
||||
uint32_t n_egl_buffers;
|
||||
bool buffer_copy_done;
|
||||
};
|
||||
|
||||
struct input {
|
||||
|
@ -221,6 +221,8 @@ wet_shell_init(struct weston_compositor *ec,
|
||||
if (dts->desktop == NULL)
|
||||
goto out_view;
|
||||
|
||||
screenshooter_create(ec);
|
||||
|
||||
return 0;
|
||||
|
||||
out_view:
|
||||
|
@ -369,6 +369,9 @@ execute_compositor(const struct compositor_setup *setup,
|
||||
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);
|
||||
prog_args_take(&args, tmp);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user