summaryrefslogtreecommitdiff
path: root/tests/weston-test-client-helper.h
diff options
context:
space:
mode:
Diffstat (limited to 'tests/weston-test-client-helper.h')
-rw-r--r--tests/weston-test-client-helper.h119
1 files changed, 75 insertions, 44 deletions
diff --git a/tests/weston-test-client-helper.h b/tests/weston-test-client-helper.h
index 5762258f..52e8a560 100644
--- a/tests/weston-test-client-helper.h
+++ b/tests/weston-test-client-helper.h
@@ -1,23 +1,26 @@
/*
* Copyright © 2012 Intel Corporation
*
- * Permission to use, copy, modify, distribute, and sell this software and
- * its documentation for any purpose is hereby granted without fee, provided
- * that the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of the copyright holders not be used in
- * advertising or publicity pertaining to distribution of the software
- * without specific, written prior permission. The copyright holders make
- * no representations about the suitability of this software for any
- * purpose. It is provided "as is" without express or implied warranty.
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
*
- * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
- * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
- * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
- * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
- * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
- * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
*/
#ifndef _WESTON_TEST_CLIENT_HELPER_H_
@@ -27,7 +30,11 @@
#include <assert.h>
#include <stdbool.h>
+#include <stdint.h>
+#include <time.h>
+#include <pixman.h>
+#include <wayland-client-protocol.h>
#include "weston-test-runner.h"
#include "weston-test-client-protocol.h"
@@ -68,6 +75,8 @@ struct test {
};
struct input {
+ struct client *client;
+ uint32_t global_name;
struct wl_seat *wl_seat;
struct pointer *pointer;
struct keyboard *keyboard;
@@ -84,6 +93,17 @@ struct pointer {
int y;
uint32_t button;
uint32_t state;
+ uint32_t axis;
+ double axis_value;
+ uint32_t motion_time_msec;
+ uint32_t button_time_msec;
+ uint32_t axis_time_msec;
+ uint32_t axis_stop_time_msec;
+ struct timespec input_timestamp;
+ struct timespec motion_time_timespec;
+ struct timespec button_time_timespec;
+ struct timespec axis_time_timespec;
+ struct timespec axis_stop_time_timespec;
};
struct keyboard {
@@ -99,6 +119,9 @@ struct keyboard {
int rate;
int delay;
} repeat_info;
+ uint32_t key_time_msec;
+ struct timespec input_timestamp;
+ struct timespec key_time_timespec;
};
struct touch {
@@ -111,6 +134,13 @@ struct touch {
int up_id; /* id of last wl_touch.up event */
int frame_no;
int cancel_no;
+ uint32_t down_time_msec;
+ uint32_t up_time_msec;
+ uint32_t motion_time_msec;
+ struct timespec input_timestamp;
+ struct timespec down_time_timespec;
+ struct timespec up_time_timespec;
+ struct timespec motion_time_timespec;
};
struct output {
@@ -123,15 +153,20 @@ struct output {
int initialized;
};
+struct buffer {
+ struct wl_buffer *proxy;
+ size_t len;
+ pixman_image_t *image;
+};
+
struct surface {
struct wl_surface *wl_surface;
- struct wl_buffer *wl_buffer;
struct output *output;
int x;
int y;
int width;
int height;
- void *data;
+ struct buffer *buffer;
};
struct rectangle {
@@ -141,29 +176,20 @@ struct rectangle {
int height;
};
-void *
-fail_on_null(void *p);
-
-static inline void *
-xzalloc(size_t s)
-{
- return fail_on_null(calloc(1, s));
-}
-
-static inline void *
-xmalloc(size_t s)
-{
- return fail_on_null(malloc(s));
-}
-
struct client *
create_client(void);
+struct surface *
+create_test_surface(struct client *client);
+
struct client *
create_client_and_test_surface(int x, int y, int width, int height);
-struct wl_buffer *
-create_shm_buffer(struct client *client, int width, int height, void **pixels);
+struct buffer *
+create_shm_buffer_a8r8g8b8(struct client *client, int width, int height);
+
+void
+buffer_destroy(struct buffer *buf);
int
surface_contains(struct surface *surface, int x, int y);
@@ -183,9 +209,6 @@ frame_callback_wait_nofail(struct client *client, int *done);
#define frame_callback_wait(c, d) assert(frame_callback_wait_nofail((c), (d)))
-int
-get_n_egl_buffers(struct client *client);
-
void
skip(const char *fmt, ...);
@@ -193,19 +216,27 @@ void
expect_protocol_error(struct client *client,
const struct wl_interface *intf, uint32_t code);
-char*
+char *
screenshot_output_filename(const char *basename, uint32_t seq);
-char*
+char *
screenshot_reference_filename(const char *basename, uint32_t seq);
bool
-check_surfaces_geometry(const struct surface *a, const struct surface *b);
+check_images_match(pixman_image_t *img_a, pixman_image_t *img_b,
+ const struct rectangle *clip);
-bool
-check_surfaces_equal(const struct surface *a, const struct surface *b);
+pixman_image_t *
+visualize_image_difference(pixman_image_t *img_a, pixman_image_t *img_b,
+ const struct rectangle *clip_rect);
bool
-check_surfaces_match_in_clip(const struct surface *a, const struct surface *b, const struct rectangle *clip);
+write_image_as_png(pixman_image_t *image, const char *fname);
+
+pixman_image_t *
+load_image_from_png(const char *fname);
+
+struct buffer *
+capture_screenshot_of_output(struct client *client);
#endif