[PATCH weston 11/13] Update the unit tests to use views
Jason Ekstrand
jason at jlekstrand.net
Sun Oct 13 05:38:21 CEST 2013
Signed-off-by: Jason Ekstrand <jason at jlekstrand.net>
---
tests/surface-global-test.c | 23 +++++++++++++----------
tests/surface-test.c | 15 +++++++++------
tests/weston-test.c | 38 +++++++++++++++++++++++++-------------
3 files changed, 47 insertions(+), 29 deletions(-)
diff --git a/tests/surface-global-test.c b/tests/surface-global-test.c
index 04b64d6..788e694 100644
--- a/tests/surface-global-test.c
+++ b/tests/surface-global-test.c
@@ -29,39 +29,42 @@ surface_to_from_global(void *data)
{
struct weston_compositor *compositor = data;
struct weston_surface *surface;
+ struct weston_view *view;
float x, y;
wl_fixed_t fx, fy;
int32_t ix, iy;
surface = weston_surface_create(compositor);
assert(surface);
- weston_surface_configure(surface, 5, 10, 50, 50);
- weston_surface_update_transform(surface);
+ view = weston_view_create(surface);
+ assert(view);
+ weston_view_configure(view, 5, 10, 50, 50);
+ weston_view_update_transform(view);
- weston_surface_to_global_float(surface, 33, 22, &x, &y);
+ weston_view_to_global_float(view, 33, 22, &x, &y);
assert(x == 38 && y == 32);
- weston_surface_to_global_float(surface, -8, -2, &x, &y);
+ weston_view_to_global_float(view, -8, -2, &x, &y);
assert(x == -3 && y == 8);
- weston_surface_to_global_fixed(surface, wl_fixed_from_int(12),
+ weston_view_to_global_fixed(view, wl_fixed_from_int(12),
wl_fixed_from_int(5), &fx, &fy);
assert(fx == wl_fixed_from_int(17) && fy == wl_fixed_from_int(15));
- weston_surface_from_global_float(surface, 38, 32, &x, &y);
+ weston_view_from_global_float(view, 38, 32, &x, &y);
assert(x == 33 && y == 22);
- weston_surface_from_global_float(surface, 42, 5, &x, &y);
+ weston_view_from_global_float(view, 42, 5, &x, &y);
assert(x == 37 && y == -5);
- weston_surface_from_global_fixed(surface, wl_fixed_from_int(21),
+ weston_view_from_global_fixed(view, wl_fixed_from_int(21),
wl_fixed_from_int(100), &fx, &fy);
assert(fx == wl_fixed_from_int(16) && fy == wl_fixed_from_int(90));
- weston_surface_from_global(surface, 0, 0, &ix, &iy);
+ weston_view_from_global(view, 0, 0, &ix, &iy);
assert(ix == -5 && iy == -10);
- weston_surface_from_global(surface, 5, 10, &ix, &iy);
+ weston_view_from_global(view, 5, 10, &ix, &iy);
assert(ix == 0 && iy == 0);
wl_display_terminate(compositor->wl_display);
diff --git a/tests/surface-test.c b/tests/surface-test.c
index e8af2ed..4a8b2b2 100644
--- a/tests/surface-test.c
+++ b/tests/surface-test.c
@@ -31,20 +31,23 @@ surface_transform(void *data)
{
struct weston_compositor *compositor = data;
struct weston_surface *surface;
+ struct weston_view *view;
float x, y;
surface = weston_surface_create(compositor);
assert(surface);
- weston_surface_configure(surface, 100, 100, 200, 200);
- weston_surface_update_transform(surface);
- weston_surface_to_global_float(surface, 20, 20, &x, &y);
+ view = weston_view_create(surface);
+ assert(view);
+ weston_view_configure(view, 100, 100, 200, 200);
+ weston_view_update_transform(view);
+ weston_view_to_global_float(view, 20, 20, &x, &y);
fprintf(stderr, "20,20 maps to %f, %f\n", x, y);
assert(x == 120 && y == 120);
- weston_surface_set_position(surface, 150, 300);
- weston_surface_update_transform(surface);
- weston_surface_to_global_float(surface, 50, 40, &x, &y);
+ weston_view_set_position(view, 150, 300);
+ weston_view_update_transform(view);
+ weston_view_to_global_float(view, 50, 40, &x, &y);
assert(x == 200 && y == 340);
wl_display_terminate(compositor->wl_display);
diff --git a/tests/weston-test.c b/tests/weston-test.c
index bc5b6e9..6050b22 100644
--- a/tests/weston-test.c
+++ b/tests/weston-test.c
@@ -36,6 +36,7 @@ struct weston_test {
struct weston_test_surface {
struct weston_surface *surface;
+ struct weston_view *view;
int32_t x, y;
struct weston_test *test;
};
@@ -79,15 +80,16 @@ test_surface_configure(struct weston_surface *surface, int32_t sx, int32_t sy, i
struct weston_test_surface *test_surface = surface->configure_private;
struct weston_test *test = test_surface->test;
- if (wl_list_empty(&surface->layer_link))
- wl_list_insert(&test->layer.surface_list,
- &surface->layer_link);
+ if (wl_list_empty(&test_surface->view->layer_link))
+ wl_list_insert(&test->layer.view_list,
+ &test_surface->view->layer_link);
- weston_surface_configure(surface, test_surface->x, test_surface->y,
- width, height);
+ weston_view_configure(test_surface->view,
+ test_surface->x, test_surface->y,
+ width, height);
- if (!weston_surface_is_mapped(surface))
- weston_surface_update_transform(surface);
+ if (!weston_view_is_mapped(test_surface->view))
+ weston_view_update_transform(test_surface->view);
}
static void
@@ -99,13 +101,23 @@ move_surface(struct wl_client *client, struct wl_resource *resource,
wl_resource_get_user_data(surface_resource);
struct weston_test_surface *test_surface;
- surface->configure = test_surface_configure;
- if (surface->configure_private == NULL)
- surface->configure_private = malloc(sizeof *test_surface);
test_surface = surface->configure_private;
- if (test_surface == NULL) {
- wl_resource_post_no_memory(resource);
- return;
+ if (!test_surface) {
+ test_surface = malloc(sizeof *test_surface);
+ if (!test_surface) {
+ wl_resource_post_no_memory(resource);
+ return;
+ }
+
+ test_surface->view = weston_view_create(surface);
+ if (!test_surface->view) {
+ wl_resource_post_no_memory(resource);
+ free(test_surface);
+ return;
+ }
+
+ surface->configure_private = test_surface;
+ surface->configure = test_surface_configure;
}
test_surface->surface = surface;
--
1.8.3.1
More information about the wayland-devel
mailing list