tests: Add test for touch event timestamps

Add test to verify that the server correctly sets the timestamps of
touch events. This requires updating the weston-test protocol with a new
request for touch events.

Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
dev
Alexandros Frantzis 7 years ago committed by Pekka Paalanen
parent dae224c6dc
commit c20b580b52
  1. 7
      Makefile.am
  2. 9
      protocol/weston-test.xml
  3. 71
      tests/touch-test.c
  4. 13
      tests/weston-test-client-helper.c
  5. 3
      tests/weston-test-client-helper.h
  6. 16
      tests/weston-test.c

@ -1233,7 +1233,8 @@ weston_tests = \
roles.weston \
subsurface.weston \
subsurface-shot.weston \
devices.weston
devices.weston \
touch.weston
ivi_tests =
@ -1428,6 +1429,10 @@ nodist_viewporter_weston_SOURCES = \
viewporter_weston_CFLAGS = $(AM_CFLAGS) $(TEST_CLIENT_CFLAGS)
viewporter_weston_LDADD = libtest-client.la
touch_weston_SOURCES = tests/touch-test.c
touch_weston_CFLAGS = $(AM_CFLAGS) $(TEST_CLIENT_CFLAGS)
touch_weston_LDADD = libtest-client.la
if ENABLE_XWAYLAND_TEST
weston_tests += xwayland-test.weston
xwayland_test_weston_SOURCES = tests/xwayland-test.c

@ -89,6 +89,15 @@
provided buffer.
</description>
</event>
<request name="send_touch">
<arg name="tv_sec_hi" type="uint"/>
<arg name="tv_sec_lo" type="uint"/>
<arg name="tv_nsec" type="uint"/>
<arg name="touch_id" type="int"/>
<arg name="x" type="fixed"/>
<arg name="y" type="fixed"/>
<arg name="touch_type" type="uint"/>
</request>
</interface>
<interface name="weston_test_runner" version="1">

@ -0,0 +1,71 @@
/*
* Copyright © 2017 Collabora, Ltd.
*
* 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 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.
*/
#include "config.h"
#include <time.h>
#include "shared/timespec-util.h"
#include "weston-test-client-helper.h"
#include "wayland-server-protocol.h"
static const struct timespec t1 = { .tv_sec = 1, .tv_nsec = 1000001 };
static const struct timespec t2 = { .tv_sec = 2, .tv_nsec = 2000001 };
static const struct timespec t3 = { .tv_sec = 3, .tv_nsec = 3000001 };
static struct client *
create_touch_test_client(void)
{
struct client *cl = create_client_and_test_surface(0, 0, 100, 100);
assert(cl);
return cl;
}
static void
send_touch(struct client *client, const struct timespec *time,
uint32_t touch_type)
{
uint32_t tv_sec_hi, tv_sec_lo, tv_nsec;
timespec_to_proto(time, &tv_sec_hi, &tv_sec_lo, &tv_nsec);
weston_test_send_touch(client->test->weston_test, tv_sec_hi, tv_sec_lo,
tv_nsec, 1, 1, 1, touch_type);
client_roundtrip(client);
}
TEST(touch_events)
{
struct client *client = create_touch_test_client();
struct touch *touch = client->input->touch;
send_touch(client, &t1, WL_TOUCH_DOWN);
assert(touch->down_time_msec == timespec_to_msec(&t1));
send_touch(client, &t2, WL_TOUCH_MOTION);
assert(touch->motion_time_msec == timespec_to_msec(&t2));
send_touch(client, &t3, WL_TOUCH_UP);
assert(touch->up_time_msec == timespec_to_msec(&t3));
}

@ -315,14 +315,16 @@ static const struct wl_keyboard_listener keyboard_listener = {
static void
touch_handle_down(void *data, struct wl_touch *wl_touch,
uint32_t serial, uint32_t time, struct wl_surface *surface,
int32_t id, wl_fixed_t x_w, wl_fixed_t y_w)
uint32_t serial, uint32_t time_msec,
struct wl_surface *surface, int32_t id,
wl_fixed_t x_w, wl_fixed_t y_w)
{
struct touch *touch = data;
touch->down_x = wl_fixed_to_int(x_w);
touch->down_y = wl_fixed_to_int(y_w);
touch->id = id;
touch->down_time_msec = time_msec;
fprintf(stderr, "test-client: got touch down %d %d, surf: %p, id: %d\n",
touch->down_x, touch->down_y, surface, id);
@ -330,21 +332,24 @@ touch_handle_down(void *data, struct wl_touch *wl_touch,
static void
touch_handle_up(void *data, struct wl_touch *wl_touch,
uint32_t serial, uint32_t time, int32_t id)
uint32_t serial, uint32_t time_msec, int32_t id)
{
struct touch *touch = data;
touch->up_id = id;
touch->up_time_msec = time_msec;
fprintf(stderr, "test-client: got touch up, id: %d\n", id);
}
static void
touch_handle_motion(void *data, struct wl_touch *wl_touch,
uint32_t time, int32_t id, wl_fixed_t x_w, wl_fixed_t y_w)
uint32_t time_msec, int32_t id,
wl_fixed_t x_w, wl_fixed_t y_w)
{
struct touch *touch = data;
touch->x = wl_fixed_to_int(x_w);
touch->y = wl_fixed_to_int(y_w);
touch->motion_time_msec = time_msec;
fprintf(stderr, "test-client: got touch motion, %d %d, id: %d\n",
touch->x, touch->y, id);

@ -120,6 +120,9 @@ 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 output {

@ -500,6 +500,21 @@ capture_screenshot(struct wl_client *client,
capture_screenshot_done, resource);
}
static void
send_touch(struct wl_client *client, struct wl_resource *resource,
uint32_t tv_sec_hi, uint32_t tv_sec_lo, uint32_t tv_nsec,
int32_t touch_id, wl_fixed_t x, wl_fixed_t y, uint32_t touch_type)
{
struct weston_test *test = wl_resource_get_user_data(resource);
struct weston_seat *seat = get_seat(test);
struct timespec time;
timespec_from_proto(&time, tv_sec_hi, tv_sec_lo, tv_nsec);
notify_touch(seat, &time, touch_id, wl_fixed_to_double(x),
wl_fixed_to_double(y), touch_type);
}
static const struct weston_test_interface test_implementation = {
move_surface,
move_pointer,
@ -509,6 +524,7 @@ static const struct weston_test_interface test_implementation = {
device_release,
device_add,
capture_screenshot,
send_touch,
};
static void

Loading…
Cancel
Save