tests: add test_seat_release() for symmetry
Add test_seat_release() as the counterpart of test_seat_init() instead of open-coding it. This helps adding more code to test_seat_release() later. Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
+14
-6
@@ -80,6 +80,9 @@ test_client_sigchld(struct weston_process *process, int status)
|
|||||||
static int
|
static int
|
||||||
test_seat_init(struct weston_test *test)
|
test_seat_init(struct weston_test *test)
|
||||||
{
|
{
|
||||||
|
assert(!test->is_seat_initialized &&
|
||||||
|
"Trying to add already added test seat");
|
||||||
|
|
||||||
/* create our own seat */
|
/* create our own seat */
|
||||||
weston_seat_init(&test->seat, test->compositor, "test-seat");
|
weston_seat_init(&test->seat, test->compositor, "test-seat");
|
||||||
test->is_seat_initialized = true;
|
test->is_seat_initialized = true;
|
||||||
@@ -93,6 +96,16 @@ test_seat_init(struct weston_test *test)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_seat_release(struct weston_test *test)
|
||||||
|
{
|
||||||
|
assert(test->is_seat_initialized &&
|
||||||
|
"Trying to release already released test seat");
|
||||||
|
test->is_seat_initialized = false;
|
||||||
|
weston_seat_release(&test->seat);
|
||||||
|
memset(&test->seat, 0, sizeof test->seat);
|
||||||
|
}
|
||||||
|
|
||||||
static struct weston_seat *
|
static struct weston_seat *
|
||||||
get_seat(struct weston_test *test)
|
get_seat(struct weston_test *test)
|
||||||
{
|
{
|
||||||
@@ -270,10 +283,7 @@ device_release(struct wl_client *client,
|
|||||||
} else if (strcmp(device, "touch") == 0) {
|
} else if (strcmp(device, "touch") == 0) {
|
||||||
weston_seat_release_touch(seat);
|
weston_seat_release_touch(seat);
|
||||||
} else if (strcmp(device, "seat") == 0) {
|
} else if (strcmp(device, "seat") == 0) {
|
||||||
assert(test->is_seat_initialized &&
|
test_seat_release(test);
|
||||||
"Trying to release already released test seat");
|
|
||||||
weston_seat_release(seat);
|
|
||||||
test->is_seat_initialized = false;
|
|
||||||
} else {
|
} else {
|
||||||
assert(0 && "Unsupported device");
|
assert(0 && "Unsupported device");
|
||||||
}
|
}
|
||||||
@@ -293,8 +303,6 @@ device_add(struct wl_client *client,
|
|||||||
} else if (strcmp(device, "touch") == 0) {
|
} else if (strcmp(device, "touch") == 0) {
|
||||||
weston_seat_init_touch(seat);
|
weston_seat_init_touch(seat);
|
||||||
} else if (strcmp(device, "seat") == 0) {
|
} else if (strcmp(device, "seat") == 0) {
|
||||||
assert(!test->is_seat_initialized &&
|
|
||||||
"Trying to add already added test seat");
|
|
||||||
test_seat_init(test);
|
test_seat_init(test);
|
||||||
} else {
|
} else {
|
||||||
assert(0 && "Unsupported device");
|
assert(0 && "Unsupported device");
|
||||||
|
|||||||
Reference in New Issue
Block a user