From 2592effef5f171af3f01a2b5130d9747403140f6 Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Tue, 28 Dec 2010 13:42:06 +0000 Subject: [PATCH] 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 Reviewed-by: Peter Hutterer Reviewed-by: Chase Douglas --- test/input.c | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/test/input.c b/test/input.c index 1fe228c32..c389a403a 100644 --- a/test/input.c +++ b/test/input.c @@ -256,7 +256,7 @@ static void dix_event_to_core(int type) #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; xEvent core; @@ -265,25 +265,18 @@ static void dix_event_to_core_conversion(void) ev.header = 0xFF; ev.length = sizeof(DeviceEvent); - ev.type = 0; + ev.type = evtype; rc = EventToCore((InternalEvent*)&ev, &core); - g_assert(rc == BadImplementation); + g_assert(rc == expected_rc); +} - ev.type = 1; - rc = EventToCore((InternalEvent*)&ev, &core); - g_assert(rc == BadImplementation); - - ev.type = ET_ProximityOut + 1; - rc = EventToCore((InternalEvent*)&ev, &core); - g_assert(rc == BadImplementation); - - 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); +static void dix_event_to_core_conversion(void) +{ + dix_event_to_core_fail(0, BadImplementation); + dix_event_to_core_fail(1, BadImplementation); + dix_event_to_core_fail(ET_ProximityOut + 1, BadImplementation); + dix_event_to_core_fail(ET_ProximityIn, BadMatch); + dix_event_to_core_fail(ET_ProximityOut, BadMatch); dix_event_to_core(ET_KeyPress); dix_event_to_core(ET_KeyRelease);