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"
42 struct wl_display *wl_display;
43 struct wl_registry *wl_registry;
44 struct wl_compositor *wl_compositor;
45 struct wl_shm *wl_shm;
47 /* the seat that is actually used for input events */
49 /* server can have more wl_seats. We need keep them all until we
50 * find the one that we need. After that, the others
51 * will be destroyed, so this list will have the length of 1.
52 * If some day in the future we will need the other seats,
53 * we can just keep them here. */
54 struct wl_list inputs;
55 struct output *output;
56 struct surface *surface;
58 struct wl_list global_list;
70 struct weston_test *weston_test;
73 uint32_t n_egl_buffers;
78 struct client *client;
80 struct wl_seat *wl_seat;
81 struct pointer *pointer;
82 struct keyboard *keyboard;
85 enum wl_seat_capability caps;
90 struct wl_pointer *wl_pointer;
91 struct surface *focus;
98 uint32_t motion_time_msec;
99 uint32_t button_time_msec;
100 uint32_t axis_time_msec;
101 uint32_t axis_stop_time_msec;
102 struct timespec input_timestamp;
103 struct timespec motion_time_timespec;
104 struct timespec button_time_timespec;
105 struct timespec axis_time_timespec;
106 struct timespec axis_stop_time_timespec;
110 struct wl_keyboard *wl_keyboard;
111 struct surface *focus;
114 uint32_t mods_depressed;
115 uint32_t mods_latched;
116 uint32_t mods_locked;
122 uint32_t key_time_msec;
123 struct timespec input_timestamp;
124 struct timespec key_time_timespec;
128 struct wl_touch *wl_touch;
134 int up_id; /* id of last wl_touch.up event */
137 uint32_t down_time_msec;
138 uint32_t up_time_msec;
139 uint32_t motion_time_msec;
140 struct timespec input_timestamp;
141 struct timespec down_time_timespec;
142 struct timespec up_time_timespec;
143 struct timespec motion_time_timespec;
147 struct wl_output *wl_output;
157 struct wl_buffer *proxy;
159 pixman_image_t *image;
163 struct wl_surface *wl_surface;
164 struct output *output;
169 struct buffer *buffer;
183 create_test_surface(struct client *client);
186 create_client_and_test_surface(int x, int y, int width, int height);
189 create_shm_buffer_a8r8g8b8(struct client *client, int width, int height);
192 buffer_destroy(struct buffer *buf);
195 surface_contains(struct surface *surface, int x, int y);
198 move_client(struct client *client, int x, int y);
200 #define client_roundtrip(c) do { \
201 assert(wl_display_roundtrip((c)->wl_display) >= 0); \
205 frame_callback_set(struct wl_surface *surface, int *done);
208 frame_callback_wait_nofail(struct client *client, int *done);
210 #define frame_callback_wait(c, d) assert(frame_callback_wait_nofail((c), (d)))
213 skip(const char *fmt, ...);
216 expect_protocol_error(struct client *client,
217 const struct wl_interface *intf, uint32_t code);
220 screenshot_output_filename(const char *basename, uint32_t seq);
223 screenshot_reference_filename(const char *basename, uint32_t seq);
226 check_images_match(pixman_image_t *img_a, pixman_image_t *img_b,
227 const struct rectangle *clip);
230 visualize_image_difference(pixman_image_t *img_a, pixman_image_t *img_b,
231 const struct rectangle *clip_rect);
234 write_image_as_png(pixman_image_t *image, const char *fname);
237 load_image_from_png(const char *fname);
240 capture_screenshot_of_output(struct client *client);