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>
This commit is contained in:
Derek Foreman 2023-02-07 07:13:48 -06:00 committed by Pekka Paalanen
parent 4d0ce16669
commit 3ef8bb9935
3 changed files with 54 additions and 5 deletions

View File

@ -34,6 +34,12 @@
These requests may allow clients to do very bad things.
</description>
<enum name="error">
<entry name="touch_up_with_coordinate" value="0"
summary="invalid coordinate"/>
</enum>
<request name="move_surface">
<arg name="surface" type="object" interface="wl_surface"/>
<arg name="x" type="int"/>

View File

@ -59,17 +59,50 @@ create_touch_test_client(void)
}
static void
send_touch(struct client *client, const struct timespec *time,
uint32_t touch_type)
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, touch_type);
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, 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();

View File

@ -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 = {