diff options
author | Daniel Stone <daniel@fooishbar.org> | 2010-12-28 13:42:06 +0000 |
---|---|---|
committer | Daniel Stone <daniel@fooishbar.org> | 2011-01-06 17:10:21 +0000 |
commit | 2592effef5f171af3f01a2b5130d9747403140f6 (patch) | |
tree | 31b43c0e7c86565739a54439ac7cda7568aefec6 /test | |
parent | e1aed88be92c27d76bff1743f35f9915dea9264f (diff) |
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>
Diffstat (limited to 'test')
-rw-r--r-- | test/input.c | 29 |
1 files 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; - rc = EventToCore((InternalEvent*)&ev, &core); - g_assert(rc == BadImplementation); - - 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; + ev.type = evtype; rc = EventToCore((InternalEvent*)&ev, &core); - g_assert(rc == BadMatch); + g_assert(rc == expected_rc); +} - 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); |