Test: Input: Add helper function for failing EventToCore
We have quite a few tests which involve checking that EventToCore fails for specific events, so refactor them into a separate function. Signed-off-by: Daniel Stone <daniel@fooishbar.org> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
This commit is contained in:
parent
e1aed88be9
commit
2592effef5
29
test/input.c
29
test/input.c
|
@ -256,7 +256,7 @@ static void dix_event_to_core(int type)
|
||||||
#undef test_event
|
#undef test_event
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dix_event_to_core_conversion(void)
|
static void dix_event_to_core_fail(int evtype, int expected_rc)
|
||||||
{
|
{
|
||||||
DeviceEvent ev;
|
DeviceEvent ev;
|
||||||
xEvent core;
|
xEvent core;
|
||||||
|
@ -265,25 +265,18 @@ static void dix_event_to_core_conversion(void)
|
||||||
ev.header = 0xFF;
|
ev.header = 0xFF;
|
||||||
ev.length = sizeof(DeviceEvent);
|
ev.length = sizeof(DeviceEvent);
|
||||||
|
|
||||||
ev.type = 0;
|
ev.type = evtype;
|
||||||
rc = EventToCore((InternalEvent*)&ev, &core);
|
rc = EventToCore((InternalEvent*)&ev, &core);
|
||||||
g_assert(rc == BadImplementation);
|
g_assert(rc == expected_rc);
|
||||||
|
}
|
||||||
|
|
||||||
ev.type = 1;
|
static void dix_event_to_core_conversion(void)
|
||||||
rc = EventToCore((InternalEvent*)&ev, &core);
|
{
|
||||||
g_assert(rc == BadImplementation);
|
dix_event_to_core_fail(0, BadImplementation);
|
||||||
|
dix_event_to_core_fail(1, BadImplementation);
|
||||||
ev.type = ET_ProximityOut + 1;
|
dix_event_to_core_fail(ET_ProximityOut + 1, BadImplementation);
|
||||||
rc = EventToCore((InternalEvent*)&ev, &core);
|
dix_event_to_core_fail(ET_ProximityIn, BadMatch);
|
||||||
g_assert(rc == BadImplementation);
|
dix_event_to_core_fail(ET_ProximityOut, BadMatch);
|
||||||
|
|
||||||
ev.type = ET_ProximityIn;
|
|
||||||
rc = EventToCore((InternalEvent*)&ev, &core);
|
|
||||||
g_assert(rc == BadMatch);
|
|
||||||
|
|
||||||
ev.type = ET_ProximityOut;
|
|
||||||
rc = EventToCore((InternalEvent*)&ev, &core);
|
|
||||||
g_assert(rc == BadMatch);
|
|
||||||
|
|
||||||
dix_event_to_core(ET_KeyPress);
|
dix_event_to_core(ET_KeyPress);
|
||||||
dix_event_to_core(ET_KeyRelease);
|
dix_event_to_core(ET_KeyRelease);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user