test: aded a test for key events

This commit is contained in:
Peter Hutterer 2022-03-03 14:36:09 +10:00
parent 81d6fb335d
commit cc28d90a82

View file

@ -27,6 +27,7 @@
#include <errno.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <linux/input.h>
#include "util-io.h"
#include "util-munit.h"
#include "util-memfile.h"
@ -225,6 +226,39 @@ MUNIT_TEST(test_ei_device_add_remove)
return MUNIT_OK;
}
MUNIT_TEST(test_ei_device_keyboard_key)
{
_unref_(peck) *peck = peck_new();
peck_enable_eis_behavior(peck, PECK_EIS_BEHAVIOR_ACCEPT_ALL);
peck_enable_eis_behavior(peck, PECK_EIS_BEHAVIOR_ADD_KEYBOARD);
peck_enable_ei_behavior(peck, PECK_EI_BEHAVIOR_AUTODEVICES);
peck_dispatch_until_stable(peck);
with_client(peck) {
struct ei_device *device = peck_ei_get_default_keyboard(peck);
ei_device_keyboard_key(device, KEY_Q, true);
ei_device_frame(device);
ei_device_keyboard_key(device, KEY_Q, false);
ei_device_frame(device);
}
peck_dispatch_until_stable(peck);
with_server(peck) {
_unref_(eis_event) *press =
peck_eis_next_event(eis, EIS_EVENT_KEYBOARD_KEY);
munit_assert_int(eis_event_keyboard_get_key(press), ==, KEY_Q);
munit_assert_true(eis_event_keyboard_get_key_is_press(press));
_unref_(eis_event) *release =
peck_eis_next_event(eis, EIS_EVENT_KEYBOARD_KEY);
munit_assert_int(eis_event_keyboard_get_key(release), ==, KEY_Q);
munit_assert_false(eis_event_keyboard_get_key_is_press(release));
}
return MUNIT_OK;
}
MUNIT_TEST(test_ei_device_pointer_rel)
{