tests: migrate surface, surface-global

These are normal plugin tests, moved to the new harness.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
This commit is contained in:
Pekka Paalanen 2019-11-13 14:20:45 +02:00 committed by Daniel Stone
parent 9615ad8b91
commit 99c536db91
3 changed files with 32 additions and 38 deletions

View file

@ -116,6 +116,8 @@ tests = [
{ 'name': 'roles', },
{ 'name': 'string', },
{ 'name': 'subsurface-shot', },
{ 'name': 'surface', },
{ 'name': 'surface-global', },
{
'name': 'vertex-clip',
'dep_objs': dep_vertex_clipping,
@ -203,8 +205,6 @@ if get_option('xwayland')
endif
tests_weston_plugin = [
['surface'],
['surface-global'],
['surface-screenshot', 'surface-screenshot-test.c', dep_libshared],
]

View file

@ -31,11 +31,23 @@
#include <libweston/libweston.h>
#include "libweston-internal.h"
#include "compositor/weston.h"
#include "weston-test-runner.h"
#include "weston-test-fixture-compositor.h"
static void
surface_to_from_global(void *data)
static enum test_result_code
fixture_setup(struct weston_test_harness *harness)
{
struct weston_compositor *compositor = data;
struct compositor_setup setup;
compositor_setup_defaults(&setup);
return weston_test_harness_execute_as_plugin(harness, &setup);
}
DECLARE_FIXTURE_SETUP(fixture_setup);
PLUGIN_TEST(surface_to_from_global)
{
/* struct weston_compositor *compositor; */
struct weston_surface *surface;
struct weston_view *view;
float x, y;
@ -76,19 +88,4 @@ surface_to_from_global(void *data)
weston_view_from_global(view, 5, 10, &ix, &iy);
assert(ix == 0 && iy == 0);
weston_compositor_exit(compositor);
}
WL_EXPORT int
wet_module_init(struct weston_compositor *compositor,
int *argc, char *argv[])
{
struct wl_event_loop *loop;
loop = wl_display_get_event_loop(compositor->wl_display);
wl_event_loop_add_idle(loop, surface_to_from_global, compositor);
return 0;
}

View file

@ -30,11 +30,23 @@
#include <libweston/libweston.h>
#include "compositor/weston.h"
#include "weston-test-runner.h"
#include "weston-test-fixture-compositor.h"
static void
surface_transform(void *data)
static enum test_result_code
fixture_setup(struct weston_test_harness *harness)
{
struct weston_compositor *compositor = data;
struct compositor_setup setup;
compositor_setup_defaults(&setup);
return weston_test_harness_execute_as_plugin(harness, &setup);
}
DECLARE_FIXTURE_SETUP(fixture_setup);
PLUGIN_TEST(surface_transform)
{
/* struct weston_compositor *compositor; */
struct weston_surface *surface;
struct weston_view *view;
float x, y;
@ -56,19 +68,4 @@ surface_transform(void *data)
weston_view_update_transform(view);
weston_view_to_global_float(view, 50, 40, &x, &y);
assert(x == 200 && y == 340);
weston_compositor_exit(compositor);
}
WL_EXPORT int
wet_module_init(struct weston_compositor *compositor,
int *argc, char *argv[])
{
struct wl_event_loop *loop;
loop = wl_display_get_event_loop(compositor->wl_display);
wl_event_loop_add_idle(loop, surface_transform, compositor);
return 0;
}