mirror of
https://gitlab.freedesktop.org/libinput/libei.git
synced 2026-05-04 03:48:02 +02:00
test: aded a test for key events
This commit is contained in:
parent
81d6fb335d
commit
cc28d90a82
1 changed files with 34 additions and 0 deletions
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue