summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDerek Foreman <derek.foreman@collabora.com>2023-02-07 07:13:48 -0600
committerPekka Paalanen <pq@iki.fi>2023-02-09 12:12:40 +0000
commit3ef8bb9935b84bcf7d8f81aac6d0559122cecc9a (patch)
treef1f49339da2e37f44311c21056a711fd5aab4c61 /tests
parent4d0ce16669441812080ca7d941a646d8519cbdb8 (diff)
downloadweston-3ef8bb9935b84bcf7d8f81aac6d0559122cecc9a.tar.gz
tests: Don't send real coordinates with WL_TOUCH_UP events
Wayland protocol can't do this, but the way our test protocol handles touch through a single event can - ensure that we don't by accident. This will matter more shortly when we add assert()s to prevent having coordinates with WL_TOUCH_UP events internally later. Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/touch-test.c35
-rw-r--r--tests/weston-test.c14
2 files changed, 46 insertions, 3 deletions
diff --git a/tests/touch-test.c b/tests/touch-test.c
index 080e7e73..d6a4ac40 100644
--- a/tests/touch-test.c
+++ b/tests/touch-test.c
@@ -59,17 +59,50 @@ create_touch_test_client(void)
}
static void
+send_broken_touch(struct client *client, const struct timespec *time)
+{
+ 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, WL_TOUCH_UP);
+
+ expect_protocol_error(client, &weston_test_interface,
+ WESTON_TEST_ERROR_TOUCH_UP_WITH_COORDINATE);
+}
+
+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;
+ wl_fixed_t x = 0, y = 0;
timespec_to_proto(time, &tv_sec_hi, &tv_sec_lo, &tv_nsec);
+ if (touch_type != WL_TOUCH_UP) {
+ x = 1;
+ y = 1;
+ }
+
weston_test_send_touch(client->test->weston_test, tv_sec_hi, tv_sec_lo,
- tv_nsec, 1, 1, 1, touch_type);
+ tv_nsec, 1, x, y, touch_type);
client_roundtrip(client);
}
+TEST(broken_touch_event)
+{
+ struct client *client = create_touch_test_client();
+ struct input_timestamps *input_ts =
+ input_timestamps_create_for_touch(client);
+
+ send_broken_touch(client, &t1);
+
+ input_timestamps_destroy(input_ts);
+
+ client_destroy(client);
+}
+
TEST(touch_events)
{
struct client *client = create_touch_test_client();
diff --git a/tests/weston-test.c b/tests/weston-test.c
index 58f27a04..c15dbfee 100644
--- a/tests/weston-test.c
+++ b/tests/weston-test.c
@@ -426,8 +426,18 @@ send_touch(struct wl_client *client, struct wl_resource *resource,
timespec_from_proto(&time, tv_sec_hi, tv_sec_lo, tv_nsec);
- notify_touch(device, &time, touch_id, wl_fixed_to_double(x),
- wl_fixed_to_double(y), touch_type);
+ if (touch_type == WL_TOUCH_UP) {
+ if (x != 0 || y != 0) {
+ wl_resource_post_error(resource,
+ WESTON_TEST_ERROR_TOUCH_UP_WITH_COORDINATE,
+ "Test protocol sent valid "
+ "coordinates with WL_TOUCH_UP");
+
+ return;
+ }
+ }
+
+ notify_touch(device, &time, touch_id, x, y, touch_type);
}
static const struct weston_test_interface test_implementation = {