summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAlexandros Frantzis <alexandros.frantzis@collabora.com>2017-12-18 12:16:55 +0200
committerPekka Paalanen <pekka.paalanen@collabora.co.uk>2017-12-18 13:18:00 +0200
commitb0341ae972531a6c3bcf43a7f8b66c44f8bc8e49 (patch)
treec9b0e9f1aad481c3c970690bcc0b98593496e528 /tests
parentc20b580b5288d6ee6aa6bed4de165e2c191d3a28 (diff)
tests: Add test for pointer axis events
Add test to verify the server correctly emits pointer axis events. This requires updating the weston-test protocol with a new request for pointer axis events. Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Diffstat (limited to 'tests')
-rw-r--r--tests/pointer-test.c28
-rw-r--r--tests/weston-test-client-helper.c17
-rw-r--r--tests/weston-test-client-helper.h4
-rw-r--r--tests/weston-test.c20
4 files changed, 66 insertions, 3 deletions
diff --git a/tests/pointer-test.c b/tests/pointer-test.c
index 61bf83b7..4c438a22 100644
--- a/tests/pointer-test.c
+++ b/tests/pointer-test.c
@@ -59,6 +59,18 @@ send_button(struct client *client, const struct timespec *time,
}
static void
+send_axis(struct client *client, const struct timespec *time, uint32_t axis,
+ double value)
+{
+ 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_axis(client->test->weston_test, tv_sec_hi, tv_sec_lo,
+ tv_nsec, axis, wl_fixed_from_double(value));
+ client_roundtrip(client);
+}
+
+static void
check_pointer(struct client *client, int x, int y)
{
int sx, sy;
@@ -355,3 +367,19 @@ TEST(pointer_button_events)
assert(pointer->state == WL_POINTER_BUTTON_STATE_RELEASED);
assert(pointer->button_time_msec == timespec_to_msec(&t2));
}
+
+TEST(pointer_axis_events)
+{
+ struct client *client = create_client_with_pointer_focus(100, 100,
+ 100, 100);
+ struct pointer *pointer = client->input->pointer;
+
+ send_axis(client, &t1, 1, 1.0);
+ assert(pointer->axis == 1);
+ assert(pointer->axis_value == 1.0);
+ assert(pointer->axis_time_msec == timespec_to_msec(&t1));
+
+ send_axis(client, &t2, 2, 0.0);
+ assert(pointer->axis == 2);
+ assert(pointer->axis_stop_time_msec == timespec_to_msec(&t2));
+}
diff --git a/tests/weston-test-client-helper.c b/tests/weston-test-client-helper.c
index c5a00320..6e0a5246 100644
--- a/tests/weston-test-client-helper.c
+++ b/tests/weston-test-client-helper.c
@@ -177,8 +177,14 @@ pointer_handle_button(void *data, struct wl_pointer *wl_pointer,
static void
pointer_handle_axis(void *data, struct wl_pointer *wl_pointer,
- uint32_t time, uint32_t axis, wl_fixed_t value)
+ uint32_t time_msec, uint32_t axis, wl_fixed_t value)
{
+ struct pointer *pointer = data;
+
+ pointer->axis = axis;
+ pointer->axis_value = wl_fixed_to_double(value);
+ pointer->axis_time_msec = time_msec;
+
fprintf(stderr, "test-client: got pointer axis %u %f\n",
axis, wl_fixed_to_double(value));
}
@@ -198,9 +204,14 @@ pointer_handle_axis_source(void *data, struct wl_pointer *wl_pointer,
static void
pointer_handle_axis_stop(void *data, struct wl_pointer *wl_pointer,
- uint32_t time, uint32_t axis)
+ uint32_t time_msec, uint32_t axis)
{
- fprintf(stderr, "test-client: got pointer axis stop\n");
+ struct pointer *pointer = data;
+
+ pointer->axis = axis;
+ pointer->axis_stop_time_msec = time_msec;
+
+ fprintf(stderr, "test-client: got pointer axis stop %u\n", axis);
}
static void
diff --git a/tests/weston-test-client-helper.h b/tests/weston-test-client-helper.h
index 86ecb640..09a5df4a 100644
--- a/tests/weston-test-client-helper.h
+++ b/tests/weston-test-client-helper.h
@@ -90,8 +90,12 @@ struct pointer {
int y;
uint32_t button;
uint32_t state;
+ uint32_t axis;
+ double axis_value;
uint32_t motion_time_msec;
uint32_t button_time_msec;
+ uint32_t axis_time_msec;
+ uint32_t axis_stop_time_msec;
};
struct keyboard {
diff --git a/tests/weston-test.c b/tests/weston-test.c
index 14030f4c..80b3d65b 100644
--- a/tests/weston-test.c
+++ b/tests/weston-test.c
@@ -184,6 +184,25 @@ send_button(struct wl_client *client, struct wl_resource *resource,
}
static void
+send_axis(struct wl_client *client, struct wl_resource *resource,
+ uint32_t tv_sec_hi, uint32_t tv_sec_lo, uint32_t tv_nsec,
+ uint32_t axis, wl_fixed_t value)
+{
+ struct weston_test *test = wl_resource_get_user_data(resource);
+ struct weston_seat *seat = get_seat(test);
+ struct timespec time;
+ struct weston_pointer_axis_event axis_event;
+
+ timespec_from_proto(&time, tv_sec_hi, tv_sec_lo, tv_nsec);
+ axis_event.axis = axis;
+ axis_event.value = wl_fixed_to_double(value);
+ axis_event.has_discrete = false;
+ axis_event.discrete = 0;
+
+ notify_axis(seat, &time, &axis_event);
+}
+
+static void
activate_surface(struct wl_client *client, struct wl_resource *resource,
struct wl_resource *surface_resource)
{
@@ -519,6 +538,7 @@ static const struct weston_test_interface test_implementation = {
move_surface,
move_pointer,
send_button,
+ send_axis,
activate_surface,
send_key,
device_release,