diff options
author | Pekka Paalanen <ppaalanen@gmail.com> | 2012-12-12 14:26:41 +0200 |
---|---|---|
committer | Kristian Høgsberg <krh@bitplanet.net> | 2012-12-12 10:39:01 -0500 |
commit | f2aa64f18a44ad6343a3da42288a604fad8579f4 (patch) | |
tree | bf4c52a2279bb0c607c627bc923d504b299cddf5 /tests | |
parent | 07921d791aa3b72d74f1a935e8ac6cae73825b22 (diff) |
tests: check wl_display_roundtrip() for errors
Add a macro that wraps wl_display_roundtrip() and check for errors. It
is a macro, so that the assert would show the relevant file and line
number.
This will also catch protocol errors, that would go unnoticed otherwise.
All roundtrips in tests are replaced with the check.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/button-test.c | 6 | ||||
-rw-r--r-- | tests/event-test.c | 2 | ||||
-rw-r--r-- | tests/keyboard-test.c | 2 | ||||
-rw-r--r-- | tests/text-test.c | 10 | ||||
-rw-r--r-- | tests/weston-test-client-helper.h | 3 |
5 files changed, 13 insertions, 10 deletions
diff --git a/tests/button-test.c b/tests/button-test.c index ac75ee08..dc02fd44 100644 --- a/tests/button-test.c +++ b/tests/button-test.c @@ -37,19 +37,19 @@ TEST(simple_button_test) assert(pointer->state == 0); wl_test_move_pointer(client->test->wl_test, 150, 150); - wl_display_roundtrip(client->wl_display); + client_roundtrip(client); assert(pointer->x == 50); assert(pointer->y == 50); wl_test_send_button(client->test->wl_test, BTN_LEFT, WL_POINTER_BUTTON_STATE_PRESSED); - wl_display_roundtrip(client->wl_display); + client_roundtrip(client); assert(pointer->button == BTN_LEFT); assert(pointer->state == WL_POINTER_BUTTON_STATE_PRESSED); wl_test_send_button(client->test->wl_test, BTN_LEFT, WL_POINTER_BUTTON_STATE_RELEASED); - wl_display_roundtrip(client->wl_display); + client_roundtrip(client); assert(pointer->button == BTN_LEFT); assert(pointer->state == WL_POINTER_BUTTON_STATE_RELEASED); } diff --git a/tests/event-test.c b/tests/event-test.c index ba22f3f9..254517dd 100644 --- a/tests/event-test.c +++ b/tests/event-test.c @@ -57,7 +57,7 @@ static void check_pointer_move(struct client *client, int x, int y) { wl_test_move_pointer(client->test->wl_test, x, y); - wl_display_roundtrip(client->wl_display); + client_roundtrip(client); check_pointer(client, x, y); } diff --git a/tests/keyboard-test.c b/tests/keyboard-test.c index 3d5d6e3c..542bf4eb 100644 --- a/tests/keyboard-test.c +++ b/tests/keyboard-test.c @@ -60,6 +60,6 @@ TEST(simple_keyboard_test) break; } - wl_display_roundtrip(client->wl_display); + client_roundtrip(client); } } diff --git a/tests/text-test.c b/tests/text-test.c index 9492bd21..8994d105 100644 --- a/tests/text-test.c +++ b/tests/text-test.c @@ -161,28 +161,28 @@ TEST(text_test) /* Make sure our test surface has keyboard focus. */ wl_test_activate_surface(client->test->wl_test, client->surface->wl_surface); - wl_display_roundtrip(client->wl_display); + client_roundtrip(client); assert(client->input->keyboard->focus == client->surface); /* Activate test model and make sure we get enter event. */ text_model_activate(text_model, client->input->wl_seat, client->surface->wl_surface); - wl_display_roundtrip(client->wl_display); + client_roundtrip(client); assert(state.activated == 1 && state.deactivated == 0); /* Deactivate test model and make sure we get leave event. */ text_model_deactivate(text_model, client->input->wl_seat); - wl_display_roundtrip(client->wl_display); + client_roundtrip(client); assert(state.activated == 1 && state.deactivated == 1); /* Activate test model again. */ text_model_activate(text_model, client->input->wl_seat, client->surface->wl_surface); - wl_display_roundtrip(client->wl_display); + client_roundtrip(client); assert(state.activated == 2 && state.deactivated == 1); /* Take keyboard focus away and verify we get leave event. */ wl_test_activate_surface(client->test->wl_test, NULL); - wl_display_roundtrip(client->wl_display); + client_roundtrip(client); assert(state.activated == 2 && state.deactivated == 2); } diff --git a/tests/weston-test-client-helper.h b/tests/weston-test-client-helper.h index e84d3b27..27042b25 100644 --- a/tests/weston-test-client-helper.h +++ b/tests/weston-test-client-helper.h @@ -107,5 +107,8 @@ surface_contains(struct surface *surface, int x, int y); void move_client(struct client *client, int x, int y); +#define client_roundtrip(c) do { \ + assert(wl_display_roundtrip((c)->wl_display) >= 0); \ +} while (0) #endif |