2 * Copyright © 2012 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining
5 * a copy of this software and associated documentation files (the
6 * "Software"), to deal in the Software without restriction, including
7 * without limitation the rights to use, copy, modify, merge, publish,
8 * distribute, sublicense, and/or sell copies of the Software, and to
9 * permit persons to whom the Software is furnished to do so, subject to
10 * the following conditions:
12 * The above copyright notice and this permission notice (including the
13 * next paragraph) shall be included in all copies or substantial
14 * portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
20 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
21 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 #ifndef _WESTON_TEST_CLIENT_HELPER_H_
27 #define _WESTON_TEST_CLIENT_HELPER_H_
37 #include <wayland-client-protocol.h>
38 #include "weston-test-runner.h"
39 #include "weston-test-client-protocol.h"
40 #include "viewporter-client-protocol.h"
43 struct wl_display *wl_display;
44 struct wl_registry *wl_registry;
45 struct wl_compositor *wl_compositor;
46 struct wl_shm *wl_shm;
48 /* the seat that is actually used for input events */
50 /* server can have more wl_seats. We need keep them all until we
51 * find the one that we need. After that, the others
52 * will be destroyed, so this list will have the length of 1.
53 * If some day in the future we will need the other seats,
54 * we can just keep them here. */
55 struct wl_list inputs;
56 struct output *output;
57 struct surface *surface;
59 struct wl_list global_list;
61 struct wl_list output_list; /* struct output::link */
72 struct weston_test *weston_test;
75 uint32_t n_egl_buffers;
80 struct client *client;
82 struct wl_seat *wl_seat;
83 struct pointer *pointer;
84 struct keyboard *keyboard;
87 enum wl_seat_capability caps;
92 struct wl_pointer *wl_pointer;
93 struct surface *focus;
100 uint32_t motion_time_msec;
101 uint32_t button_time_msec;
102 uint32_t axis_time_msec;
103 uint32_t axis_stop_time_msec;
104 struct timespec input_timestamp;
105 struct timespec motion_time_timespec;
106 struct timespec button_time_timespec;
107 struct timespec axis_time_timespec;
108 struct timespec axis_stop_time_timespec;
112 struct wl_keyboard *wl_keyboard;
113 struct surface *focus;
116 uint32_t mods_depressed;
117 uint32_t mods_latched;
118 uint32_t mods_locked;
124 uint32_t key_time_msec;
125 struct timespec input_timestamp;
126 struct timespec key_time_timespec;
130 struct wl_touch *wl_touch;
136 int up_id; /* id of last wl_touch.up event */
139 uint32_t down_time_msec;
140 uint32_t up_time_msec;
141 uint32_t motion_time_msec;
142 struct timespec input_timestamp;
143 struct timespec down_time_timespec;
144 struct timespec up_time_timespec;
145 struct timespec motion_time_timespec;
149 struct wl_output *wl_output;
150 struct wl_list link; /* struct client::output_list */
160 struct wl_buffer *proxy;
162 pixman_image_t *image;
166 struct wl_surface *wl_surface;
167 struct output *output; /* not owned */
172 struct buffer *buffer;
191 client_destroy(struct client *client);
194 create_test_surface(struct client *client);
197 surface_destroy(struct surface *surface);
200 create_client_and_test_surface(int x, int y, int width, int height);
203 create_shm_buffer_a8r8g8b8(struct client *client, int width, int height);
206 buffer_destroy(struct buffer *buf);
209 surface_contains(struct surface *surface, int x, int y);
212 move_client(struct client *client, int x, int y);
214 #define client_roundtrip(c) do { \
215 assert(wl_display_roundtrip((c)->wl_display) >= 0); \
219 frame_callback_set(struct wl_surface *surface, int *done);
222 frame_callback_wait_nofail(struct client *client, int *done);
224 #define frame_callback_wait(c, d) assert(frame_callback_wait_nofail((c), (d)))
227 skip(const char *fmt, ...);
230 expect_protocol_error(struct client *client,
231 const struct wl_interface *intf, uint32_t code);
234 screenshot_output_filename(const char *basename, uint32_t seq);
237 screenshot_reference_filename(const char *basename, uint32_t seq);
240 image_filename(const char *basename);
243 check_images_match(pixman_image_t *img_a, pixman_image_t *img_b,
244 const struct rectangle *clip,
245 const struct range *prec);
248 visualize_image_difference(pixman_image_t *img_a, pixman_image_t *img_b,
249 const struct rectangle *clip_rect,
250 const struct range *prec);
253 write_image_as_png(pixman_image_t *image, const char *fname);
256 load_image_from_png(const char *fname);
259 capture_screenshot_of_output(struct client *client);
262 verify_screen_content(struct client *client,
263 const char *ref_image,
265 const struct rectangle *clip,
269 client_buffer_from_image_file(struct client *client,
270 const char *basename,
274 bind_to_singleton_global(struct client *client,
275 const struct wl_interface *iface,
279 client_create_viewport(struct client *client);
282 fill_image_with_color(pixman_image_t *image, pixman_color_t *color);
285 color_rgb888(pixman_color_t *tmp, uint8_t r, uint8_t g, uint8_t b);