test: fix the device add test

Check that we're actually adding the device and getting the message back

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
Peter Hutterer 2020-08-11 10:51:30 +10:00
parent 55246512f0
commit ce51392241

View file

@ -142,17 +142,37 @@ static MunitResult
test_ei_device_add(const MunitParameter params[], void *user_data)
{
_cleanup_peck_ struct peck *peck = peck_new();
struct ei *ei = peck_get_ei(peck);
peck_enable_eis_behavior(peck, PECK_EIS_BEHAVIOR_ACCEPT_ALL);
with_server(peck) {
peck_enable_eis_behavior(peck, PECK_EIS_BEHAVIOR_ACCEPT_ALL);
peck_dispatch_eis(peck);
}
with_client(peck) {
peck_drain_ei(ei);
}
_cleanup_ei_device_ struct ei_device *device = NULL;
with_client(peck) {
device = ei_device_new(ei);
ei_device_configure_name(device, __func__);
ei_device_configure_capability(device, EI_DEVICE_CAP_POINTER);
ei_device_add(device);
}
peck_dispatch_eis(peck);
peck_dispatch_ei(peck);
peck_drain_ei(ei);
with_client(peck) {
_cleanup_ei_event_ struct ei_event *event = ei_get_event(ei);
munit_assert_ptr_not_null(event);
munit_assert_int(ei_event_get_type(event), ==, EI_EVENT_DEVICE_ADDED);
_cleanup_ei_device_ struct ei_device *device = ei_device_new(ei);
ei_device_configure_name(device, __func__);
ei_device_configure_capability(device, EI_DEVICE_CAP_POINTER);
ei_device_add(device);
struct ei_device *added = ei_event_get_device(event);
munit_assert_ptr_equal(device, added);
munit_assert(ei_device_has_capability(added, EI_DEVICE_CAP_POINTER));
}
return MUNIT_OK;
}