diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2020-07-03 10:47:13 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2020-07-07 18:51:33 +1000 |
commit | 52d639875366d7337a35c14759adc52112c011c0 (patch) | |
tree | cd517bb1f2b89349e9b8691aa30d6be679c61c5a | |
parent | d78d6629280878a64a506d72fbbaf9a4e8ece328 (diff) | |
download | libinput-52d639875366d7337a35c14759adc52112c011c0.tar.gz |
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 <peter.hutterer@who-t.net>
-rw-r--r-- | test/litest.c | 8 | ||||
-rw-r--r-- | test/litest.h | 1 | ||||
-rw-r--r-- | test/test-device.c | 40 | ||||
-rw-r--r-- | test/test-keyboard.c | 8 | ||||
-rw-r--r-- | test/test-log.c | 8 | ||||
-rw-r--r-- | test/test-misc.c | 5 | ||||
-rw-r--r-- | test/test-path.c | 4 | ||||
-rw-r--r-- | test/test-pointer.c | 12 | ||||
-rw-r--r-- | test/test-switch.c | 15 | ||||
-rw-r--r-- | test/test-tablet.c | 14 | ||||
-rw-r--r-- | test/test-totem.c | 8 | ||||
-rw-r--r-- | test/test-touch.c | 4 | ||||
-rw-r--r-- | test/test-touchpad.c | 6 |
13 files changed, 70 insertions, 63 deletions
diff --git a/test/litest.c b/test/litest.c index 5393bb07..9965b72f 100644 --- a/test/litest.c +++ b/test/litest.c @@ -1632,6 +1632,12 @@ litest_create_context(void) } void +litest_destroy_context(struct libinput *li) +{ + libinput_unref(li); +} + +void litest_disable_log_handler(struct libinput *libinput) { libinput_log_set_handler(libinput, NULL); @@ -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); diff --git a/test/litest.h b/test/litest.h index c32e58ac..0f8f188b 100644 --- a/test/litest.h +++ b/test/litest.h @@ -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); diff --git a/test/test-device.c b/test/test-device.c index d27ebbc3..44de8dc1 100644 --- a/test/test-device.c +++ b/test/test-device.c @@ -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); } } diff --git a/test/test-keyboard.c b/test/test-keyboard.c index f5b566dd..6da6f853 100644 --- a/test/test-keyboard.c +++ b/test/test-keyboard.c @@ -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 diff --git a/test/test-log.c b/test/test-log.c index a7787bc4..47b4debe 100644 --- a/test/test-log.c +++ b/test/test-log.c @@ -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; diff --git a/test/test-misc.c b/test/test-misc.c index 436e8ecb..8030e198 100644 --- a/test/test-misc.c +++ b/test/test-misc.c @@ -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 diff --git a/test/test-path.c b/test/test-path.c index 76498214..9c6f25cf 100644 --- a/test/test-path.c +++ b/test/test-path.c @@ -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 diff --git a/test/test-pointer.c b/test/test-pointer.c index aca68446..c89a15a4 100644 --- a/test/test-pointer.c +++ b/test/test-pointer.c @@ -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 diff --git a/test/test-switch.c b/test/test-switch.c index 339519eb..e0434100 100644 --- a/test/test-switch.c +++ b/test/test-switch.c @@ -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); } diff --git a/test/test-tablet.c b/test/test-tablet.c index 24dad831..a722deed 100644 --- a/test/test-tablet.c +++ b/test/test-tablet.c @@ -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 diff --git a/test/test-totem.c b/test/test-totem.c index bafa8d23..d10ad323 100644 --- a/test/test-totem.c +++ b/test/test-totem.c @@ -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 diff --git a/test/test-touch.c b/test/test-touch.c index 2b513cc2..72dca0d0 100644 --- a/test/test-touch.c +++ b/test/test-touch.c @@ -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 diff --git a/test/test-touchpad.c b/test/test-touchpad.c index 3a9008c7..89d6c8ab 100644 --- a/test/test-touchpad.c +++ b/test/test-touchpad.c @@ -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 |