diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2017-04-21 16:33:02 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2017-09-04 12:42:44 +1000 |
commit | aeca8739c7c2e852bc84998ab1f85162d74e9454 (patch) | |
tree | e01b40006ed206fe46ea207243c9dc916ff4c44e /test/test-switch.c | |
parent | a3c5f37b28322a22180545b63506522c885c9cac (diff) |
test: make the lid action helper function a generic switch action helper
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'test/test-switch.c')
-rw-r--r-- | test/test-switch.c | 84 |
1 files changed, 63 insertions, 21 deletions
diff --git a/test/test-switch.c b/test/test-switch.c index b5d3d586..4623e55b 100644 --- a/test/test-switch.c +++ b/test/test-switch.c @@ -38,7 +38,9 @@ START_TEST(lid_switch) litest_drain_events(li); /* lid closed */ - litest_lid_action(sw, LIBINPUT_SWITCH_STATE_ON); + litest_switch_action(sw, + LIBINPUT_SWITCH_LID, + LIBINPUT_SWITCH_STATE_ON); libinput_dispatch(li); event = libinput_get_event(li); @@ -48,7 +50,9 @@ START_TEST(lid_switch) libinput_event_destroy(event); /* lid opened */ - litest_lid_action(sw, LIBINPUT_SWITCH_STATE_OFF); + litest_switch_action(sw, + LIBINPUT_SWITCH_LID, + LIBINPUT_SWITCH_STATE_OFF); libinput_dispatch(li); event = libinput_get_event(li); @@ -69,7 +73,9 @@ START_TEST(lid_switch_double) litest_drain_events(li); - litest_lid_action(sw, LIBINPUT_SWITCH_STATE_ON); + litest_switch_action(sw, + LIBINPUT_SWITCH_LID, + LIBINPUT_SWITCH_STATE_ON); libinput_dispatch(li); event = libinput_get_event(li); @@ -80,7 +86,9 @@ START_TEST(lid_switch_double) /* This will be filtered by the kernel, so this test is a bit * useless */ - litest_lid_action(sw, LIBINPUT_SWITCH_STATE_ON); + litest_switch_action(sw, + LIBINPUT_SWITCH_LID, + LIBINPUT_SWITCH_STATE_ON); libinput_dispatch(li); litest_assert_empty_queue(li); @@ -113,7 +121,9 @@ START_TEST(lid_switch_down_on_init) if (!lid_switch_is_reliable(sw)) return; - litest_lid_action(sw, LIBINPUT_SWITCH_STATE_ON); + litest_switch_action(sw, + LIBINPUT_SWITCH_LID, + LIBINPUT_SWITCH_STATE_ON); /* need separate context to test */ li = litest_create_context(); @@ -134,7 +144,9 @@ START_TEST(lid_switch_down_on_init) libinput_event_destroy(event); } - litest_lid_action(sw, LIBINPUT_SWITCH_STATE_OFF); + litest_switch_action(sw, + LIBINPUT_SWITCH_LID, + LIBINPUT_SWITCH_STATE_OFF); libinput_dispatch(li); event = libinput_get_event(li); litest_is_switch_event(event, @@ -157,7 +169,9 @@ START_TEST(lid_switch_not_down_on_init) if (lid_switch_is_reliable(sw)) return; - litest_lid_action(sw, LIBINPUT_SWITCH_STATE_ON); + litest_switch_action(sw, + LIBINPUT_SWITCH_LID, + LIBINPUT_SWITCH_STATE_ON); /* need separate context to test */ li = litest_create_context(); @@ -171,7 +185,9 @@ START_TEST(lid_switch_not_down_on_init) libinput_event_destroy(event); } - litest_lid_action(sw, LIBINPUT_SWITCH_STATE_OFF); + litest_switch_action(sw, + LIBINPUT_SWITCH_LID, + LIBINPUT_SWITCH_STATE_OFF); litest_assert_empty_queue(li); libinput_unref(li); } @@ -196,7 +212,9 @@ START_TEST(lid_disable_touchpad) litest_drain_events(li); /* lid is down - no events */ - litest_lid_action(sw, LIBINPUT_SWITCH_STATE_ON); + litest_switch_action(sw, + LIBINPUT_SWITCH_LID, + LIBINPUT_SWITCH_STATE_ON); litest_assert_only_typed_events(li, LIBINPUT_EVENT_SWITCH_TOGGLE); litest_touch_down(touchpad, 0, 50, 50); @@ -205,7 +223,9 @@ START_TEST(lid_disable_touchpad) litest_assert_empty_queue(li); /* lid is up - motion events */ - litest_lid_action(sw, LIBINPUT_SWITCH_STATE_OFF); + litest_switch_action(sw, + LIBINPUT_SWITCH_LID, + LIBINPUT_SWITCH_STATE_OFF); litest_assert_only_typed_events(li, LIBINPUT_EVENT_SWITCH_TOGGLE); litest_touch_down(touchpad, 0, 50, 50); @@ -231,7 +251,9 @@ START_TEST(lid_disable_touchpad_during_touch) litest_touch_move_to(touchpad, 0, 50, 50, 70, 50, 5, 1); litest_assert_only_typed_events(li, LIBINPUT_EVENT_POINTER_MOTION); - litest_lid_action(sw, LIBINPUT_SWITCH_STATE_ON); + litest_switch_action(sw, + LIBINPUT_SWITCH_LID, + LIBINPUT_SWITCH_STATE_ON); litest_assert_only_typed_events(li, LIBINPUT_EVENT_SWITCH_TOGGLE); litest_touch_move_to(touchpad, 0, 70, 50, 50, 50, 5, 1); @@ -253,7 +275,9 @@ START_TEST(lid_disable_touchpad_edge_scroll) litest_drain_events(li); - litest_lid_action(sw, LIBINPUT_SWITCH_STATE_ON); + litest_switch_action(sw, + LIBINPUT_SWITCH_LID, + LIBINPUT_SWITCH_STATE_ON); litest_assert_only_typed_events(li, LIBINPUT_EVENT_SWITCH_TOGGLE); litest_touch_down(touchpad, 0, 99, 20); @@ -294,7 +318,9 @@ START_TEST(lid_disable_touchpad_edge_scroll_interrupt) libinput_dispatch(li); litest_assert_only_typed_events(li, LIBINPUT_EVENT_POINTER_AXIS); - litest_lid_action(sw, LIBINPUT_SWITCH_STATE_ON); + litest_switch_action(sw, + LIBINPUT_SWITCH_LID, + LIBINPUT_SWITCH_STATE_ON); libinput_dispatch(li); event = libinput_get_event(li); @@ -330,7 +356,9 @@ START_TEST(lid_disable_touchpad_already_open) litest_assert_only_typed_events(li, LIBINPUT_EVENT_POINTER_MOTION); /* open lid - motion events */ - litest_lid_action(sw, LIBINPUT_SWITCH_STATE_OFF); + litest_switch_action(sw, + LIBINPUT_SWITCH_LID, + LIBINPUT_SWITCH_STATE_OFF); litest_assert_empty_queue(li); litest_touch_down(touchpad, 0, 50, 50); @@ -351,7 +379,9 @@ START_TEST(lid_open_on_key) keyboard = litest_add_device(li, LITEST_KEYBOARD); - litest_lid_action(sw, LIBINPUT_SWITCH_STATE_ON); + litest_switch_action(sw, + LIBINPUT_SWITCH_LID, + LIBINPUT_SWITCH_STATE_ON); litest_drain_events(li); litest_event(keyboard, EV_KEY, KEY_A, 1); @@ -367,7 +397,9 @@ START_TEST(lid_open_on_key) litest_assert_only_typed_events(li, LIBINPUT_EVENT_KEYBOARD_KEY); - litest_lid_action(sw, LIBINPUT_SWITCH_STATE_OFF); + litest_switch_action(sw, + LIBINPUT_SWITCH_LID, + LIBINPUT_SWITCH_STATE_OFF); litest_assert_empty_queue(li); libinput_event_destroy(event); @@ -384,7 +416,9 @@ START_TEST(lid_open_on_key_touchpad_enabled) keyboard = litest_add_device(li, LITEST_KEYBOARD); touchpad = litest_add_device(li, LITEST_SYNAPTICS_I2C); - litest_lid_action(sw, LIBINPUT_SWITCH_STATE_ON); + litest_switch_action(sw, + LIBINPUT_SWITCH_LID, + LIBINPUT_SWITCH_STATE_ON); litest_drain_events(li); litest_event(keyboard, EV_KEY, KEY_A, 1); @@ -420,9 +454,13 @@ START_TEST(lid_suspend_with_keyboard) keyboard = litest_add_device(li, LITEST_KEYBOARD); libinput_dispatch(li); - litest_lid_action(sw, LIBINPUT_SWITCH_STATE_ON); + litest_switch_action(sw, + LIBINPUT_SWITCH_LID, + LIBINPUT_SWITCH_STATE_ON); litest_drain_events(li); - litest_lid_action(sw, LIBINPUT_SWITCH_STATE_OFF); + litest_switch_action(sw, + LIBINPUT_SWITCH_LID, + LIBINPUT_SWITCH_STATE_OFF); litest_drain_events(li); litest_delete_device(keyboard); @@ -476,7 +514,9 @@ START_TEST(lid_update_hw_on_key) libevdev_uinput_get_devnode(sw->uinput)); litest_drain_events(li2); - litest_lid_action(sw, LIBINPUT_SWITCH_STATE_ON); + litest_switch_action(sw, + LIBINPUT_SWITCH_LID, + LIBINPUT_SWITCH_STATE_ON); litest_drain_events(li); libinput_dispatch(li2); @@ -513,7 +553,9 @@ START_TEST(lid_update_hw_on_key_closed_on_init) struct libevdev *evdev = sw->evdev; struct input_event ev; - litest_lid_action(sw, LIBINPUT_SWITCH_STATE_ON); + litest_switch_action(sw, + LIBINPUT_SWITCH_LID, + LIBINPUT_SWITCH_STATE_ON); /* Make sure kernel state is right */ libevdev_next_event(evdev, LIBEVDEV_READ_FLAG_FORCE_SYNC, &ev); |