Commit 52d63987 authored by Peter Hutterer's avatar Peter Hutterer

test: use litest_destroy_context() for test-suite contexts

Symmetrical to litest_create_context(), this allows us to store special data
in that context that we have access to during the tests.
Signed-off-by: Peter Hutterer's avatarPeter Hutterer <peter.hutterer@who-t.net>
parent d78d6629
......@@ -1631,6 +1631,12 @@ litest_create_context(void)
return libinput;
}
void
litest_destroy_context(struct libinput *li)
{
libinput_unref(li);
}
void
litest_disable_log_handler(struct libinput *libinput)
{
......@@ -1834,7 +1840,7 @@ litest_delete_device(struct litest_device *d)
}
if (d->owns_context) {
libinput_dispatch(d->libinput);
libinput_unref(d->libinput);
litest_destroy_context(d->libinput);
}
close(libevdev_get_fd(d->evdev));
libevdev_free(d->evdev);
......
......@@ -420,6 +420,7 @@ struct range {
};
struct libinput *litest_create_context(void);
void litest_destroy_context(struct libinput *li);
void litest_disable_log_handler(struct libinput *libinput);
void litest_restore_log_handler(struct libinput *libinput);
void litest_set_log_handler_bug(struct libinput *libinput);
......
......@@ -454,7 +454,7 @@ START_TEST(device_reenable_syspath_changed)
litest_delete_device(litest_device);
libinput_device_unref(device1);
libinput_unref(li);
litest_destroy_context(li);
}
END_TEST
......@@ -488,7 +488,7 @@ START_TEST(device_reenable_device_removed)
litest_assert_empty_queue(li);
libinput_device_unref(device);
libinput_unref(li);
litest_destroy_context(li);
}
END_TEST
......@@ -843,7 +843,7 @@ START_TEST(device_group_ref)
ck_assert_notnull(libinput_device_group_unref(group));
ck_assert(libinput_device_group_unref(group) == NULL);
libinput_unref(li);
litest_destroy_context(li);
}
END_TEST
......@@ -871,7 +871,7 @@ START_TEST(device_group_leak)
libinput_path_remove_device(device);
libevdev_uinput_destroy(uinput);
libinput_unref(li);
litest_destroy_context(li);
/* the device group leaks, check valgrind */
}
......@@ -894,7 +894,7 @@ START_TEST(abs_device_no_absx)
libevdev_uinput_get_devnode(uinput));
litest_restore_log_handler(li);
ck_assert(device == NULL);
libinput_unref(li);
litest_destroy_context(li);
libevdev_uinput_destroy(uinput);
}
......@@ -917,7 +917,7 @@ START_TEST(abs_device_no_absy)
libevdev_uinput_get_devnode(uinput));
litest_restore_log_handler(li);
ck_assert(device == NULL);
libinput_unref(li);
litest_destroy_context(li);
libevdev_uinput_destroy(uinput);
}
......@@ -943,7 +943,7 @@ START_TEST(abs_mt_device_no_absy)
libevdev_uinput_get_devnode(uinput));
litest_restore_log_handler(li);
ck_assert(device == NULL);
libinput_unref(li);
litest_destroy_context(li);
libevdev_uinput_destroy(uinput);
}
......@@ -969,7 +969,7 @@ START_TEST(abs_mt_device_no_absx)
libevdev_uinput_get_devnode(uinput));
litest_restore_log_handler(li);
ck_assert(device == NULL);
libinput_unref(li);
litest_destroy_context(li);
libevdev_uinput_destroy(uinput);
}
......@@ -1010,7 +1010,7 @@ START_TEST(abs_device_no_range)
assert_device_ignored(li, absinfo);
litest_restore_log_handler(li);
libinput_unref(li);
litest_destroy_context(li);
}
END_TEST
......@@ -1038,7 +1038,7 @@ START_TEST(abs_mt_device_no_range)
assert_device_ignored(li, absinfo);
litest_restore_log_handler(li);
libinput_unref(li);
litest_destroy_context(li);
}
END_TEST
......@@ -1062,7 +1062,7 @@ START_TEST(abs_device_missing_res)
assert_device_ignored(li, absinfo);
litest_restore_log_handler(li);
libinput_unref(li);
litest_destroy_context(li);
}
END_TEST
......@@ -1089,7 +1089,7 @@ START_TEST(abs_mt_device_missing_res)
assert_device_ignored(li, absinfo);
litest_restore_log_handler(li);
libinput_unref(li);
litest_destroy_context(li);
}
END_TEST
......@@ -1123,7 +1123,7 @@ START_TEST(ignore_joystick)
litest_assert_ptr_null(device);
libevdev_uinput_destroy(uinput);
litest_restore_log_handler(li);
libinput_unref(li);
litest_destroy_context(li);
}
END_TEST
......@@ -1161,7 +1161,7 @@ START_TEST(device_accelerometer)
litest_assert_ptr_null(device);
libevdev_uinput_destroy(uinput);
litest_restore_log_handler(li);
libinput_unref(li);
litest_destroy_context(li);
}
END_TEST
......@@ -1209,7 +1209,7 @@ START_TEST(device_nonpointer_rel)
}
litest_restore_log_handler(li);
libinput_unref(li);
litest_destroy_context(li);
libevdev_uinput_destroy(uinput);
}
END_TEST
......@@ -1249,7 +1249,7 @@ START_TEST(device_touchpad_rel)
libinput_dispatch(li);
}
libinput_unref(li);
litest_destroy_context(li);
libevdev_uinput_destroy(uinput);
}
END_TEST
......@@ -1290,7 +1290,7 @@ START_TEST(device_touch_rel)
}
litest_restore_log_handler(li);
libinput_unref(li);
litest_destroy_context(li);
libevdev_uinput_destroy(uinput);
}
END_TEST
......@@ -1326,7 +1326,7 @@ START_TEST(device_abs_rel)
libinput_dispatch(li);
}
libinput_unref(li);
litest_destroy_context(li);
libevdev_uinput_destroy(uinput);
}
END_TEST
......@@ -1472,7 +1472,7 @@ START_TEST(device_capability_nocaps_ignored)
libevdev_uinput_get_devnode(uinput));
litest_assert_ptr_null(device);
libinput_unref(li);
litest_destroy_context(li);
libevdev_uinput_destroy(uinput);
}
END_TEST
......@@ -1601,7 +1601,7 @@ START_TEST(device_button_down_remove)
libinput_event_destroy(event);
}
libinput_unref(li);
litest_destroy_context(li);
ck_assert_int_eq(have_down, have_up);
}
}
......
......@@ -96,7 +96,7 @@ START_TEST(keyboard_seat_key_count)
for (i = 0; i < num_devices; ++i)
litest_delete_device(devices[i]);
libinput_unref(libinput);
litest_destroy_context(libinput);
}
END_TEST
......@@ -157,8 +157,8 @@ START_TEST(keyboard_ignore_no_pressed_release)
litest_assert_empty_queue(libinput);
litest_delete_device(dev);
libinput_unref(libinput);
libinput_unref(unused_libinput);
litest_destroy_context(libinput);
litest_destroy_context(unused_libinput);
}
END_TEST
......@@ -258,7 +258,7 @@ START_TEST(keyboard_key_auto_release)
ck_assert_int_eq(keys[i].released, 1);
}
libinput_unref(libinput);
litest_destroy_context(libinput);
}
END_TEST
......
......@@ -57,7 +57,7 @@ START_TEST(log_default_priority)
ck_assert_int_eq(pri, LIBINPUT_LOG_PRIORITY_ERROR);
libinput_unref(li);
litest_destroy_context(li);
}
END_TEST
......@@ -78,7 +78,7 @@ START_TEST(log_handler_invoked)
ck_assert_int_gt(log_handler_called, 0);
libinput_unref(li);
litest_destroy_context(li);
log_handler_context = NULL;
log_handler_called = 0;
......@@ -99,7 +99,7 @@ START_TEST(log_handler_NULL)
ck_assert_int_eq(log_handler_called, 0);
libinput_unref(li);
litest_destroy_context(li);
log_handler_called = 0;
}
......@@ -127,7 +127,7 @@ START_TEST(log_priority)
libinput_path_add_device(li, "/dev/input/event0");
ck_assert_int_gt(log_handler_called, 1);
libinput_unref(li);
litest_destroy_context(li);
log_handler_context = NULL;
log_handler_called = 0;
......
......@@ -144,7 +144,7 @@ START_TEST(event_conversion_device_notify)
libinput_event_destroy(event);
}
libinput_unref(li);
litest_destroy_context(li);
libevdev_uinput_destroy(uinput);
ck_assert_int_gt(device_added, 0);
......@@ -793,7 +793,8 @@ START_TEST(timer_flush)
litest_delete_device(keyboard);
litest_delete_device(touchpad);
libinput_unref(li);
litest_destroy_context(li);
}
END_TEST
......
......@@ -469,7 +469,7 @@ START_TEST(path_add_invalid_path)
litest_assert_empty_queue(li);
libinput_unref(li);
litest_destroy_context(li);
}
END_TEST
......@@ -1007,7 +1007,7 @@ START_TEST(path_ignore_device)
device = libinput_path_add_device(li, path);
ck_assert(device == NULL);
libinput_unref(li);
litest_destroy_context(li);
litest_delete_device(dev);
}
END_TEST
......
......@@ -312,7 +312,7 @@ START_TEST(pointer_absolute_initial_state)
libinput_event_destroy(ev2);
}
libinput_unref(libinput2);
litest_destroy_context(libinput2);
}
END_TEST
......@@ -490,7 +490,7 @@ START_TEST(pointer_button_auto_release)
ck_assert_int_eq(buttons[i].released, 1);
}
libinput_unref(libinput);
litest_destroy_context(libinput);
}
END_TEST
......@@ -861,7 +861,7 @@ START_TEST(pointer_seat_button_count)
for (i = 0; i < num_devices; ++i)
litest_delete_device(devices[i]);
libinput_unref(libinput);
litest_destroy_context(libinput);
}
END_TEST
......@@ -1196,7 +1196,7 @@ START_TEST(pointer_scroll_button_device_remove_while_down)
litest_delete_device(dev);
libinput_dispatch(li);
libinput_unref(li);
litest_destroy_context(li);
}
END_TEST
......@@ -3094,7 +3094,7 @@ START_TEST(debounce_remove_device_button_up)
litest_timeout_debounce();
libinput_dispatch(li);
libinput_unref(li);
litest_destroy_context(li);
}
END_TEST
......@@ -3119,7 +3119,7 @@ START_TEST(debounce_remove_device_button_down)
litest_timeout_debounce();
libinput_dispatch(li);
libinput_unref(li);
litest_destroy_context(li);
}
END_TEST
......
......@@ -220,8 +220,7 @@ START_TEST(switch_down_on_init)
libinput_event_destroy(event);
litest_assert_empty_queue(li);
libinput_unref(li);
litest_destroy_context(li);
}
END_TEST
......@@ -254,7 +253,7 @@ START_TEST(switch_not_down_on_init)
litest_switch_action(dev, sw, LIBINPUT_SWITCH_STATE_OFF);
litest_assert_empty_queue(li);
libinput_unref(li);
litest_destroy_context(li);
}
END_TEST
......@@ -639,7 +638,7 @@ START_TEST(switch_suspend_with_keyboard)
litest_delete_device(sw);
libinput_dispatch(li);
libinput_unref(li);
litest_destroy_context(li);
}
END_TEST
......@@ -674,7 +673,7 @@ START_TEST(switch_suspend_with_touchpad)
litest_delete_device(touchpad);
litest_drain_events(li);
libinput_unref(li);
litest_destroy_context(li);
}
END_TEST
......@@ -723,7 +722,7 @@ START_TEST(lid_update_hw_on_key)
libinput_event_destroy(event);
litest_assert_empty_queue(li2);
libinput_unref(li2);
litest_destroy_context(li2);
litest_delete_device(keyboard);
}
END_TEST
......@@ -775,7 +774,7 @@ START_TEST(lid_update_hw_on_key_closed_on_init)
;
ck_assert(!libevdev_get_event_value(evdev, EV_SW, SW_LID));
libinput_unref(li);
litest_destroy_context(li);
litest_delete_device(keyboard);
}
END_TEST
......@@ -830,7 +829,7 @@ START_TEST(lid_update_hw_on_key_multiple_keyboards)
libinput_event_destroy(event);
litest_assert_empty_queue(li2);
libinput_unref(li2);
litest_destroy_context(li2);
litest_delete_device(keyboard1);
litest_delete_device(keyboard2);
}
......
......@@ -202,7 +202,7 @@ START_TEST(button_up_on_delete)
litest_assert_tablet_proximity_event(li,
LIBINPUT_TABLET_TOOL_PROXIMITY_STATE_OUT);
libevdev_free(evdev);
libinput_unref(li);
litest_destroy_context(li);
}
END_TEST
......@@ -923,7 +923,7 @@ START_TEST(tip_up_on_delete)
LIBINPUT_TABLET_TOOL_TIP_UP);
libinput_event_destroy(event);
libinput_unref(li);
litest_destroy_context(li);
}
END_TEST
......@@ -1698,7 +1698,7 @@ START_TEST(proximity_out_on_delete)
litest_assert_tablet_proximity_event(li,
LIBINPUT_TABLET_TOOL_PROXIMITY_STATE_OUT);
libinput_unref(li);
litest_destroy_context(li);
}
END_TEST
......@@ -2575,7 +2575,7 @@ START_TEST(tools_with_serials)
litest_delete_device(dev[0]);
litest_delete_device(dev[1]);
libinput_unref(li);
litest_destroy_context(li);
}
END_TEST
......@@ -2619,7 +2619,7 @@ START_TEST(tools_without_serials)
litest_delete_device(dev[0]);
litest_delete_device(dev[1]);
libinput_unref(li);
litest_destroy_context(li);
}
END_TEST
......@@ -2768,7 +2768,7 @@ START_TEST(tool_capabilities)
litest_delete_device(bamboo);
litest_delete_device(intuos);
libinput_unref(li);
litest_destroy_context(li);
}
END_TEST
......@@ -2914,7 +2914,7 @@ START_TEST(tool_in_prox_before_start)
litest_is_tablet_event(event, LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY);
libinput_event_destroy(event);
libinput_unref(li);
litest_destroy_context(li);
}
END_TEST
......
......@@ -193,7 +193,7 @@ START_TEST(totem_proximity_in_on_init)
litest_assert_empty_queue(li);
libinput_unref(li);
litest_destroy_context(li);
}
END_TEST
......@@ -231,7 +231,7 @@ START_TEST(totem_proximity_out_on_suspend)
libinput_event_destroy(event);
litest_assert_only_typed_events(li, LIBINPUT_EVENT_DEVICE_REMOVED);
libinput_unref(li);
litest_destroy_context(li);
}
END_TEST
......@@ -453,7 +453,7 @@ START_TEST(totem_button_down_on_init)
libinput_dispatch(li);
litest_assert_tablet_button_event(li, BTN_0, LIBINPUT_BUTTON_STATE_RELEASED);
libinput_unref(li);
litest_destroy_context(li);
}
END_TEST
......@@ -480,7 +480,7 @@ START_TEST(totem_button_up_on_delete)
litest_assert_tablet_proximity_event(li,
LIBINPUT_TABLET_TOOL_PROXIMITY_STATE_OUT);
libevdev_free(evdev);
libinput_unref(li);
litest_destroy_context(li);
}
END_TEST
......
......@@ -878,7 +878,7 @@ START_TEST(touch_initial_state)
libinput_event_destroy(ev1);
libinput_event_destroy(ev2);
libinput_unref(libinput2);
litest_destroy_context(libinput2);
}
END_TEST
......@@ -1003,7 +1003,7 @@ START_TEST(touch_release_on_unplug)
litest_assert_event_type(ev, LIBINPUT_EVENT_DEVICE_REMOVED);
libinput_event_destroy(ev);
libinput_unref(li);
litest_destroy_context(li);
}
END_TEST
......
......@@ -3546,7 +3546,7 @@ START_TEST(touchpad_initial_state)
libinput_event_destroy(ev2);
}
libinput_unref(libinput2);
litest_destroy_context(libinput2);
}
END_TEST
......@@ -3600,7 +3600,7 @@ START_TEST(touchpad_fingers_down_before_init)
litest_assert_empty_queue(li);
libinput_unref(li);
litest_destroy_context(li);
}
END_TEST
......@@ -5613,7 +5613,7 @@ START_TEST(touchpad_finger_always_down)
litest_assert_only_typed_events(li, LIBINPUT_EVENT_POINTER_MOTION);
libinput_unref(li);
litest_destroy_context(li);
}
END_TEST
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment