[PATCH weston v1 04/17] tests: use wl_* objects instead of test structs
Marek Chalupa
mchqwerty at gmail.com
Fri Dec 5 05:36:37 PST 2014
When storing client state i. e. focus, we use our structs.
For example when we got pointer focus, we store into pointer->focus
the type 'struct surface'. We did it via user data in wl_* object,
but toytoolkit has its own data in the objects and storing and reading
them as our structures results in reading "garbage".
Solution: store wl_* objects instead - we don't need anything more.
Signed-off-by: Marek Chalupa <mchqwerty at gmail.com>
---
tests/event-test.c | 5 +++--
tests/keyboard-test.c | 6 +++---
tests/text-test.c | 2 +-
tests/weston-test-client-helper.c | 12 ++++++------
tests/weston-test-client-helper.h | 6 +++---
5 files changed, 16 insertions(+), 15 deletions(-)
diff --git a/tests/event-test.c b/tests/event-test.c
index b60ad85..beb452a 100644
--- a/tests/event-test.c
+++ b/tests/event-test.c
@@ -37,7 +37,8 @@ check_pointer(struct client *client, int x, int y)
/* Does global pointer map onto the surface? */
if (surface_contains(client->surface, x, y)) {
/* check that the surface has the pointer focus */
- assert(client->input->pointer->focus == client->surface);
+ assert(client->input->pointer->focus
+ == client->surface->wl_surface);
/*
* check that the local surface pointer maps
@@ -299,7 +300,7 @@ check_client_move(struct client *client, int x, int y)
move_client(client, x, y);
if (output_contains_client(client)) {
- assert(client->surface->output == client->output);
+ assert(client->surface->output == client->output->wl_output);
} else {
assert(client->surface->output == NULL);
}
diff --git a/tests/keyboard-test.c b/tests/keyboard-test.c
index a6d4ffa..c23214b 100644
--- a/tests/keyboard-test.c
+++ b/tests/keyboard-test.c
@@ -27,7 +27,7 @@
TEST(simple_keyboard_test)
{
struct client *client;
- struct surface *expect_focus = NULL;
+ struct wl_surface *expect_focus = NULL;
struct keyboard *keyboard;
uint32_t expect_key = 0;
uint32_t expect_state = 0;
@@ -52,10 +52,10 @@ TEST(simple_keyboard_test)
NULL);
} else if (expect_key < 10) {
expect_key++;
- expect_focus = client->surface;
+ expect_focus = client->surface->wl_surface;
expect_state = WL_KEYBOARD_KEY_STATE_PRESSED;
wl_test_activate_surface(client->test->wl_test,
- expect_focus->wl_surface);
+ expect_focus);
wl_test_send_key(client->test->wl_test, expect_key,
expect_state);
} else {
diff --git a/tests/text-test.c b/tests/text-test.c
index 0d20add..7f0baef 100644
--- a/tests/text-test.c
+++ b/tests/text-test.c
@@ -190,7 +190,7 @@ TEST(text_test)
wl_test_activate_surface(client->test->wl_test,
client->surface->wl_surface);
client_roundtrip(client);
- assert(client->input->keyboard->focus == client->surface);
+ assert(client->input->keyboard->focus == client->surface->wl_surface);
/* Activate test model and make sure we get enter event. */
wl_text_input_activate(text_input, client->input->wl_seat,
diff --git a/tests/weston-test-client-helper.c b/tests/weston-test-client-helper.c
index 45c2957..8293dbc 100644
--- a/tests/weston-test-client-helper.c
+++ b/tests/weston-test-client-helper.c
@@ -123,7 +123,7 @@ pointer_handle_enter(void *data, struct wl_pointer *wl_pointer,
{
struct pointer *pointer = data;
- pointer->focus = wl_surface_get_user_data(wl_surface);
+ pointer->focus = wl_surface;
pointer->x = wl_fixed_to_int(x);
pointer->y = wl_fixed_to_int(y);
@@ -140,7 +140,7 @@ pointer_handle_leave(void *data, struct wl_pointer *wl_pointer,
pointer->focus = NULL;
fprintf(stderr, "test-client: got pointer leave, surface %p\n",
- wl_surface_get_user_data(wl_surface));
+ wl_surface);
}
static void
@@ -202,7 +202,7 @@ keyboard_handle_enter(void *data, struct wl_keyboard *wl_keyboard,
{
struct keyboard *keyboard = data;
- keyboard->focus = wl_surface_get_user_data(wl_surface);
+ keyboard->focus = wl_surface;
fprintf(stderr, "test-client: got keyboard enter, surface %p\n",
keyboard->focus);
@@ -217,7 +217,7 @@ keyboard_handle_leave(void *data, struct wl_keyboard *wl_keyboard,
keyboard->focus = NULL;
fprintf(stderr, "test-client: got keyboard leave, surface %p\n",
- wl_surface_get_user_data(wl_surface));
+ wl_surface);
}
static void
@@ -264,7 +264,7 @@ surface_enter(void *data,
{
struct surface *surface = data;
- surface->output = wl_output_get_user_data(output);
+ surface->output = output;
fprintf(stderr, "test-client: got surface enter output %p\n",
surface->output);
@@ -279,7 +279,7 @@ surface_leave(void *data,
surface->output = NULL;
fprintf(stderr, "test-client: got surface leave output %p\n",
- wl_output_get_user_data(output));
+ output);
}
static const struct wl_surface_listener surface_listener = {
diff --git a/tests/weston-test-client-helper.h b/tests/weston-test-client-helper.h
index 446d158..a4f5505 100644
--- a/tests/weston-test-client-helper.h
+++ b/tests/weston-test-client-helper.h
@@ -74,7 +74,7 @@ struct input {
struct pointer {
struct wl_pointer *wl_pointer;
- struct surface *focus;
+ struct wl_surface *focus;
int x;
int y;
uint32_t button;
@@ -83,7 +83,7 @@ struct pointer {
struct keyboard {
struct wl_keyboard *wl_keyboard;
- struct surface *focus;
+ struct wl_surface *focus;
uint32_t key;
uint32_t state;
uint32_t mods_depressed;
@@ -103,7 +103,7 @@ struct output {
struct surface {
struct wl_surface *wl_surface;
struct wl_buffer *wl_buffer;
- struct output *output;
+ struct wl_output *output;
int x;
int y;
int width;
--
2.1.0
More information about the wayland-devel
mailing list