[PATCH xserver 02/17] Test: Input: Add helper function for failing EventToCore

Daniel Stone daniel at fooishbar.org
Tue Dec 28 09:57:53 PST 2010


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 at fooishbar.org>
---
 test/input.c |   29 +++++++++++------------------
 1 files changed, 11 insertions(+), 18 deletions(-)

diff --git a/test/input.c b/test/input.c
index 1fe228c..c389a40 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);
-- 
1.7.2.3



More information about the xorg-devel mailing list