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
---
Makefile.am | 7 +++-
protocol/weston-test.xml | 9 +
tests/touch-test.c| 71 +++
tests/weston-test-client-helper.c | 3 ++
tests/weston-test-client-helper.h | 3 ++
tests/weston-test.c | 16 +
6 files changed, 108 insertions(+), 1 deletion(-)
create mode 100644 tests/touch-test.c
diff --git a/Makefile.am b/Makefile.am
index 47b110df..c7141734 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1231,7 +1231,8 @@ weston_tests =\
roles.weston\
subsurface.weston \
subsurface-shot.weston \
- devices.weston
+ devices.weston \
+ touch.weston
ivi_tests =
@@ -1426,6 +1427,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
diff --git a/protocol/weston-test.xml b/protocol/weston-test.xml
index 37fa221f..00b7185d 100644
--- a/protocol/weston-test.xml
+++ b/protocol/weston-test.xml
@@ -96,6 +96,15 @@
provided buffer.
+
+
+
+
+
+
+
+
+
diff --git a/tests/touch-test.c b/tests/touch-test.c
new file mode 100644
index ..374df116
--- /dev/null
+++ b/tests/touch-test.c
@@ -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
+
+#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 = 101 };
+static const struct timespec t2 = { .tv_sec = 2, .tv_nsec = 201 };
+static const struct timespec t3 = { .tv_sec = 3, .tv_nsec = 301 };
+
+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, _sec_hi, _sec_lo, _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, , WL_TOUCH_DOWN);
+ assert(touch->down_time == timespec_to_msec());
+
+ send_touch(client, , WL_TOUCH_MOTION);
+ assert(touch->motion_time == timespec_to_msec());
+
+ send_touch(client, , WL_TOUCH_UP);
+ assert(touch->up_time == timespec_to_msec());
+}
diff --git a/tests/weston-test-client-helper.c
b/tests/weston-test-client-helper.c
index ef58d77a..7266e028 100644
--- a/tests/weston-test-client-helper.c
+++ b/tests/weston-test-client-helper.c
@@ -334,6 +334,7 @@ touch_handle_down(void *data, struct wl_touch *wl_touch,
touch->down_x = wl_fixed_to_int(x_w);
touch->down_y = wl_fixed_to_int(y_w);
touch->id = id;
+ touch->down_time = time;