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>
This commit is contained in:
parent
07921d791a
commit
f2aa64f18a
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -60,6 +60,6 @@ TEST(simple_keyboard_test)
|
|||
break;
|
||||
}
|
||||
|
||||
wl_display_roundtrip(client->wl_display);
|
||||
client_roundtrip(client);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue