tests: destroy client in pointer-test

Fixes all the leaks reported by ASan in this test.

The manual pointer release in
pointer_timestamps_stop_after_client_releases_wl_pointer is slightly
awkward as we need to open-code a part of input_destroy() to avoid
double-freeing pointer->wl_pointer.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
dev
Pekka Paalanen 3 years ago committed by Pekka Paalanen
parent ef8d652023
commit 689e8b3c0a
  1. 30
      tests/pointer-test.c

@ -156,6 +156,8 @@ TEST(test_pointer_top_left)
x -= 1; y -= 1; x -= 1; y -= 1;
assert(!surface_contains(client->surface, x, y)); assert(!surface_contains(client->surface, x, y));
check_pointer_move(client, x, y); check_pointer_move(client, x, y);
client_destroy(client);
} }
TEST(test_pointer_bottom_left) TEST(test_pointer_bottom_left)
@ -181,6 +183,8 @@ TEST(test_pointer_bottom_left)
x -= 1; y += 1; x -= 1; y += 1;
assert(!surface_contains(client->surface, x, y)); assert(!surface_contains(client->surface, x, y));
check_pointer_move(client, x, y); check_pointer_move(client, x, y);
client_destroy(client);
} }
TEST(test_pointer_top_right) TEST(test_pointer_top_right)
@ -206,6 +210,8 @@ TEST(test_pointer_top_right)
x += 1; y -= 1; x += 1; y -= 1;
assert(!surface_contains(client->surface, x, y)); assert(!surface_contains(client->surface, x, y));
check_pointer_move(client, x, y); check_pointer_move(client, x, y);
client_destroy(client);
} }
TEST(test_pointer_bottom_right) TEST(test_pointer_bottom_right)
@ -231,6 +237,8 @@ TEST(test_pointer_bottom_right)
x += 1; y += 1; x += 1; y += 1;
assert(!surface_contains(client->surface, x, y)); assert(!surface_contains(client->surface, x, y));
check_pointer_move(client, x, y); check_pointer_move(client, x, y);
client_destroy(client);
} }
TEST(test_pointer_top_center) TEST(test_pointer_top_center)
@ -256,6 +264,8 @@ TEST(test_pointer_top_center)
y -= 1; y -= 1;
assert(!surface_contains(client->surface, x, y)); assert(!surface_contains(client->surface, x, y));
check_pointer_move(client, x, y); check_pointer_move(client, x, y);
client_destroy(client);
} }
TEST(test_pointer_bottom_center) TEST(test_pointer_bottom_center)
@ -281,6 +291,8 @@ TEST(test_pointer_bottom_center)
y += 1; y += 1;
assert(!surface_contains(client->surface, x, y)); assert(!surface_contains(client->surface, x, y));
check_pointer_move(client, x, y); check_pointer_move(client, x, y);
client_destroy(client);
} }
TEST(test_pointer_left_center) TEST(test_pointer_left_center)
@ -306,6 +318,8 @@ TEST(test_pointer_left_center)
x -= 1; x -= 1;
assert(!surface_contains(client->surface, x, y)); assert(!surface_contains(client->surface, x, y));
check_pointer_move(client, x, y); check_pointer_move(client, x, y);
client_destroy(client);
} }
TEST(test_pointer_right_center) TEST(test_pointer_right_center)
@ -331,6 +345,8 @@ TEST(test_pointer_right_center)
x += 1; x += 1;
assert(!surface_contains(client->surface, x, y)); assert(!surface_contains(client->surface, x, y));
check_pointer_move(client, x, y); check_pointer_move(client, x, y);
client_destroy(client);
} }
TEST(test_pointer_surface_move) TEST(test_pointer_surface_move)
@ -348,6 +364,8 @@ TEST(test_pointer_surface_move)
move_client(client, 0, 0); move_client(client, 0, 0);
assert(surface_contains(client->surface, 50, 50)); assert(surface_contains(client->surface, 50, 50));
check_pointer(client, 50, 50); check_pointer(client, 50, 50);
client_destroy(client);
} }
TEST(pointer_motion_events) TEST(pointer_motion_events)
@ -365,6 +383,8 @@ TEST(pointer_motion_events)
assert(timespec_eq(&pointer->motion_time_timespec, &t1)); assert(timespec_eq(&pointer->motion_time_timespec, &t1));
input_timestamps_destroy(input_ts); input_timestamps_destroy(input_ts);
client_destroy(client);
} }
TEST(pointer_button_events) TEST(pointer_button_events)
@ -391,6 +411,8 @@ TEST(pointer_button_events)
assert(timespec_eq(&pointer->button_time_timespec, &t2)); assert(timespec_eq(&pointer->button_time_timespec, &t2));
input_timestamps_destroy(input_ts); input_timestamps_destroy(input_ts);
client_destroy(client);
} }
TEST(pointer_axis_events) TEST(pointer_axis_events)
@ -413,6 +435,8 @@ TEST(pointer_axis_events)
assert(timespec_eq(&pointer->axis_stop_time_timespec, &t2)); assert(timespec_eq(&pointer->axis_stop_time_timespec, &t2));
input_timestamps_destroy(input_ts); input_timestamps_destroy(input_ts);
client_destroy(client);
} }
TEST(pointer_timestamps_stop_after_input_timestamps_object_is_destroyed) TEST(pointer_timestamps_stop_after_input_timestamps_object_is_destroyed)
@ -436,6 +460,8 @@ TEST(pointer_timestamps_stop_after_input_timestamps_object_is_destroyed)
assert(pointer->state == WL_POINTER_BUTTON_STATE_RELEASED); assert(pointer->state == WL_POINTER_BUTTON_STATE_RELEASED);
assert(pointer->button_time_msec == timespec_to_msec(&t2)); assert(pointer->button_time_msec == timespec_to_msec(&t2));
assert(timespec_is_zero(&pointer->button_time_timespec)); assert(timespec_is_zero(&pointer->button_time_timespec));
client_destroy(client);
} }
TEST(pointer_timestamps_stop_after_client_releases_wl_pointer) TEST(pointer_timestamps_stop_after_client_releases_wl_pointer)
@ -464,4 +490,8 @@ TEST(pointer_timestamps_stop_after_client_releases_wl_pointer)
assert(timespec_eq(&pointer->input_timestamp, &t_other)); assert(timespec_eq(&pointer->input_timestamp, &t_other));
input_timestamps_destroy(input_ts); input_timestamps_destroy(input_ts);
free(client->input->pointer);
client->input->pointer = NULL;
client_destroy(client);
} }

Loading…
Cancel
Save