[PATCH weston 5/8] tests: Add checks for pointer motion and button event timestamps
Alexandros Frantzis
alexandros.frantzis at collabora.com
Mon Dec 4 13:34:05 UTC 2017
Enhance the existing pointer motion and button event tests to
additionally verify the event timestamps. This requires updating the
weston-test protocol to support passing motion and button event
timestamps.
Signed-off-by: Alexandros Frantzis <alexandros.frantzis at collabora.com>
---
protocol/weston-test.xml | 6 ++++++
tests/internal-screenshot-test.c | 2 +-
tests/pointer-test.c | 45 ++++++++++++++++++++++++++++++---------
tests/subsurface-shot-test.c | 2 +-
tests/weston-test-client-helper.c | 2 ++
tests/weston-test-client-helper.h | 2 ++
tests/weston-test.c | 6 ++++--
7 files changed, 51 insertions(+), 14 deletions(-)
diff --git a/protocol/weston-test.xml b/protocol/weston-test.xml
index 74a15214..ae3349ed 100644
--- a/protocol/weston-test.xml
+++ b/protocol/weston-test.xml
@@ -40,10 +40,16 @@
<arg name="y" type="int"/>
</request>
<request name="move_pointer">
+ <arg name="tv_sec_hi" type="uint"/>
+ <arg name="tv_sec_lo" type="uint"/>
+ <arg name="tv_nsec" type="uint"/>
<arg name="x" type="int"/>
<arg name="y" type="int"/>
</request>
<request name="send_button">
+ <arg name="tv_sec_hi" type="uint"/>
+ <arg name="tv_sec_lo" type="uint"/>
+ <arg name="tv_nsec" type="uint"/>
<arg name="button" type="int"/>
<arg name="state" type="uint"/>
</request>
diff --git a/tests/internal-screenshot-test.c b/tests/internal-screenshot-test.c
index 3bf9b31b..2a7424b8 100644
--- a/tests/internal-screenshot-test.c
+++ b/tests/internal-screenshot-test.c
@@ -97,7 +97,7 @@ TEST(internal_screenshot)
*/
/* Move the pointer away from the screenshot area. */
- weston_test_move_pointer(client->test->weston_test, 0, 0);
+ weston_test_move_pointer(client->test->weston_test, 0, 1, 0, 0, 0);
buf = create_shm_buffer_a8r8g8b8(client, 100, 100);
draw_stuff(buf->image);
diff --git a/tests/pointer-test.c b/tests/pointer-test.c
index e0e700e0..c241fa1d 100644
--- a/tests/pointer-test.c
+++ b/tests/pointer-test.c
@@ -28,8 +28,36 @@
#include <linux/input.h>
+#include "shared/timespec-util.h"
#include "weston-test-client-helper.h"
+static const struct timespec t0 = { .tv_sec = 0, .tv_nsec = 100000000 };
+static const struct timespec t1 = { .tv_sec = 1, .tv_nsec = 1000001 };
+static const struct timespec t2 = { .tv_sec = 2, .tv_nsec = 2000001 };
+
+static void
+send_motion(struct client *client, const struct timespec *time, int x, int y)
+{
+ uint32_t tv_sec_hi, tv_sec_lo, tv_nsec;
+
+ timespec_to_proto(time, &tv_sec_hi, &tv_sec_lo, &tv_nsec);
+ weston_test_move_pointer(client->test->weston_test, tv_sec_hi, tv_sec_lo,
+ tv_nsec, x, y);
+ client_roundtrip(client);
+}
+
+static void
+send_button(struct client *client, const struct timespec *time,
+ uint32_t button, uint32_t state)
+{
+ 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_button(client->test->weston_test, tv_sec_hi, tv_sec_lo,
+ tv_nsec, button, state);
+ client_roundtrip(client);
+}
+
static void
check_pointer(struct client *client, int x, int y)
{
@@ -64,8 +92,7 @@ check_pointer(struct client *client, int x, int y)
static void
check_pointer_move(struct client *client, int x, int y)
{
- weston_test_move_pointer(client->test->weston_test, x, y);
- client_roundtrip(client);
+ send_motion(client, &t0, x, y);
check_pointer(client, x, y);
}
@@ -303,10 +330,10 @@ TEST(pointer_motion_events)
100, 100);
struct pointer *pointer = client->input->pointer;
- weston_test_move_pointer(client->test->weston_test, 150, 150);
- client_roundtrip(client);
+ send_motion(client, &t1, 150, 150);
assert(pointer->x == 50);
assert(pointer->y == 50);
+ assert(pointer->motion_time == timespec_to_msec(&t1));
}
TEST(pointer_button_events)
@@ -318,15 +345,13 @@ TEST(pointer_button_events)
assert(pointer->button == 0);
assert(pointer->state == 0);
- weston_test_send_button(client->test->weston_test, BTN_LEFT,
- WL_POINTER_BUTTON_STATE_PRESSED);
- client_roundtrip(client);
+ send_button(client, &t1, BTN_LEFT, WL_POINTER_BUTTON_STATE_PRESSED);
assert(pointer->button == BTN_LEFT);
assert(pointer->state == WL_POINTER_BUTTON_STATE_PRESSED);
+ assert(pointer->button_time == timespec_to_msec(&t1));
- weston_test_send_button(client->test->weston_test, BTN_LEFT,
- WL_POINTER_BUTTON_STATE_RELEASED);
- client_roundtrip(client);
+ send_button(client, &t2, BTN_LEFT, WL_POINTER_BUTTON_STATE_RELEASED);
assert(pointer->button == BTN_LEFT);
assert(pointer->state == WL_POINTER_BUTTON_STATE_RELEASED);
+ assert(pointer->button_time == timespec_to_msec(&t2));
}
diff --git a/tests/subsurface-shot-test.c b/tests/subsurface-shot-test.c
index 10415ec7..e8bab676 100644
--- a/tests/subsurface-shot-test.c
+++ b/tests/subsurface-shot-test.c
@@ -200,7 +200,7 @@ TEST(subsurface_z_order)
subco = get_subcompositor(client);
/* move the pointer clearly away from our screenshooting area */
- weston_test_move_pointer(client->test->weston_test, 2, 30);
+ weston_test_move_pointer(client->test->weston_test, 0, 1, 0, 2, 30);
/* make the parent surface red */
surf[0] = client->surface->wl_surface;
diff --git a/tests/weston-test-client-helper.c b/tests/weston-test-client-helper.c
index fd6d5c84..108fecfb 100644
--- a/tests/weston-test-client-helper.c
+++ b/tests/weston-test-client-helper.c
@@ -154,6 +154,7 @@ pointer_handle_motion(void *data, struct wl_pointer *wl_pointer,
pointer->x = wl_fixed_to_int(x);
pointer->y = wl_fixed_to_int(y);
+ pointer->motion_time = time;
fprintf(stderr, "test-client: got pointer motion %d %d\n",
pointer->x, pointer->y);
@@ -168,6 +169,7 @@ pointer_handle_button(void *data, struct wl_pointer *wl_pointer,
pointer->button = button;
pointer->state = state;
+ pointer->button_time = time;
fprintf(stderr, "test-client: got pointer button %u %u\n",
button, state);
diff --git a/tests/weston-test-client-helper.h b/tests/weston-test-client-helper.h
index a288af7e..08817242 100644
--- a/tests/weston-test-client-helper.h
+++ b/tests/weston-test-client-helper.h
@@ -90,6 +90,8 @@ struct pointer {
int y;
uint32_t button;
uint32_t state;
+ uint32_t motion_time;
+ uint32_t button_time;
};
struct keyboard {
diff --git a/tests/weston-test.c b/tests/weston-test.c
index 6e7beeb7..1799de92 100644
--- a/tests/weston-test.c
+++ b/tests/weston-test.c
@@ -146,6 +146,7 @@ move_surface(struct wl_client *client, struct wl_resource *resource,
static void
move_pointer(struct wl_client *client, struct wl_resource *resource,
+ uint32_t tv_sec_hi, uint32_t tv_sec_lo, uint32_t tv_nsec,
int32_t x, int32_t y)
{
struct weston_test *test = wl_resource_get_user_data(resource);
@@ -160,7 +161,7 @@ move_pointer(struct wl_client *client, struct wl_resource *resource,
.dy = wl_fixed_to_double(wl_fixed_from_int(y) - pointer->y),
};
- timespec_from_msec(&time, 100);
+ timespec_from_proto(&time, tv_sec_hi, tv_sec_lo, tv_nsec);
notify_motion(seat, &time, &event);
@@ -169,6 +170,7 @@ move_pointer(struct wl_client *client, struct wl_resource *resource,
static void
send_button(struct wl_client *client, struct wl_resource *resource,
+ uint32_t tv_sec_hi, uint32_t tv_sec_lo, uint32_t tv_nsec,
int32_t button, uint32_t state)
{
struct timespec time;
@@ -176,7 +178,7 @@ send_button(struct wl_client *client, struct wl_resource *resource,
struct weston_test *test = wl_resource_get_user_data(resource);
struct weston_seat *seat = get_seat(test);
- timespec_from_msec(&time, 100);
+ timespec_from_proto(&time, tv_sec_hi, tv_sec_lo, tv_nsec);
notify_button(seat, &time, button, state);
}
--
2.14.1
More information about the wayland-devel
mailing list