aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/test/xi2
diff options
context:
space:
mode:
Diffstat (limited to 'xorg-server/test/xi2')
-rw-r--r--xorg-server/test/xi2/protocol-eventconvert.c218
-rw-r--r--xorg-server/test/xi2/protocol-xiquerydevice.c2
-rw-r--r--xorg-server/test/xi2/protocol-xiselectevents.c12
3 files changed, 224 insertions, 8 deletions
diff --git a/xorg-server/test/xi2/protocol-eventconvert.c b/xorg-server/test/xi2/protocol-eventconvert.c
index bb3177cc1..aea380ed5 100644
--- a/xorg-server/test/xi2/protocol-eventconvert.c
+++ b/xorg-server/test/xi2/protocol-eventconvert.c
@@ -694,7 +694,7 @@ test_values_XIDeviceChangedEvent(DeviceChangedEvent *in,
assert(k->num_keycodes == in->keys.max_keycode -
in->keys.min_keycode + 1);
- kc = (uint32_t *) & k[1];
+ kc = (uint32_t *) &k[1];
for (j = 0; j < k->num_keycodes; j++) {
if (swap) {
swapl(&kc[j]);
@@ -984,6 +984,221 @@ test_convert_XITouchOwnershipEvent(void)
}
}
+static void
+test_XIBarrierEvent(BarrierEvent *in)
+{
+ xXIBarrierEvent *out, *swapped;
+ int count;
+ int rc;
+ int eventlen;
+ FP3232 value;
+
+ rc = EventToXI((InternalEvent*)in, (xEvent**)&out, &count);
+ assert(rc == BadMatch);
+
+ rc = EventToCore((InternalEvent*)in, (xEvent**)&out, &count);
+ assert(rc == BadMatch);
+
+ rc = EventToXI2((InternalEvent*)in, (xEvent**)&out);
+
+ assert(out->type == GenericEvent);
+ assert(out->extension == 0); /* IReqCode defaults to 0 */
+ assert(out->evtype == GetXI2Type(in->type));
+ assert(out->time == in->time);
+ assert(out->deviceid == in->deviceid);
+ assert(out->sourceid == in->sourceid);
+ assert(out->barrier == in->barrierid);
+ assert(out->flags == in->flags);
+ assert(out->event == in->window);
+ assert(out->root == in->root);
+ assert(out->dtime == in->dt);
+ assert(out->eventid == in->event_id);
+ assert(out->root_x == double_to_fp1616(in->root_x));
+ assert(out->root_y == double_to_fp1616(in->root_y));
+
+ value = double_to_fp3232(in->dx);
+ assert(out->dx.integral == value.integral);
+ assert(out->dx.frac == value.frac);
+ value = double_to_fp3232(in->dy);
+ assert(out->dy.integral == value.integral);
+ assert(out->dy.frac == value.frac);
+
+ eventlen = sizeof(xEvent) + out->length * 4;
+ swapped = calloc(1, eventlen);
+ XI2EventSwap((xGenericEvent *) out, (xGenericEvent *) swapped);
+
+ swaps(&swapped->sequenceNumber);
+ swapl(&swapped->length);
+ swaps(&swapped->evtype);
+ swaps(&swapped->deviceid);
+ swapl(&swapped->time);
+ swapl(&swapped->eventid);
+ swapl(&swapped->root);
+ swapl(&swapped->event);
+ swapl(&swapped->barrier);
+ swapl(&swapped->dtime);
+ swaps(&swapped->sourceid);
+ swapl(&swapped->root_x);
+ swapl(&swapped->root_y);
+ swapl(&swapped->dx.integral);
+ swapl(&swapped->dx.frac);
+ swapl(&swapped->dy.integral);
+ swapl(&swapped->dy.frac);
+
+ assert(memcmp(swapped, out, eventlen) == 0);
+
+ free(swapped);
+ free(out);
+}
+
+static void
+test_convert_XIBarrierEvent(void)
+{
+ BarrierEvent in;
+
+ memset(&in, 0, sizeof(in));
+ in.header = ET_Internal;
+ in.type = ET_BarrierHit;
+ in.length = sizeof(in);
+ in.time = 0;
+ in.deviceid = 1;
+ in.sourceid = 2;
+
+ test_XIBarrierEvent(&in);
+
+ in.deviceid = 1;
+ while(in.deviceid & 0xFFFF) {
+ test_XIBarrierEvent(&in);
+ in.deviceid <<= 1;
+ }
+ in.deviceid = 0;
+
+ in.sourceid = 1;
+ while(in.sourceid & 0xFFFF) {
+ test_XIBarrierEvent(&in);
+ in.sourceid <<= 1;
+ }
+ in.sourceid = 0;
+
+ in.flags = 1;
+ while(in.flags) {
+ test_XIBarrierEvent(&in);
+ in.flags <<= 1;
+ }
+
+ in.barrierid = 1;
+ while(in.barrierid) {
+ test_XIBarrierEvent(&in);
+ in.barrierid <<= 1;
+ }
+
+ in.dt = 1;
+ while(in.dt) {
+ test_XIBarrierEvent(&in);
+ in.dt <<= 1;
+ }
+
+ in.event_id = 1;
+ while(in.event_id) {
+ test_XIBarrierEvent(&in);
+ in.event_id <<= 1;
+ }
+
+ in.window = 1;
+ while(in.window) {
+ test_XIBarrierEvent(&in);
+ in.window <<= 1;
+ }
+
+ in.root = 1;
+ while(in.root) {
+ test_XIBarrierEvent(&in);
+ in.root <<= 1;
+ }
+
+ /* pseudo-random 16 bit numbers */
+ in.root_x = 1;
+ test_XIBarrierEvent(&in);
+ in.root_x = 1.3;
+ test_XIBarrierEvent(&in);
+ in.root_x = 264.908;
+ test_XIBarrierEvent(&in);
+ in.root_x = 35638.292;
+ test_XIBarrierEvent(&in);
+
+ in.root_x = -1;
+ test_XIBarrierEvent(&in);
+ in.root_x = -1.3;
+ test_XIBarrierEvent(&in);
+ in.root_x = -264.908;
+ test_XIBarrierEvent(&in);
+ in.root_x = -35638.292;
+ test_XIBarrierEvent(&in);
+
+ in.root_y = 1;
+ test_XIBarrierEvent(&in);
+ in.root_y = 1.3;
+ test_XIBarrierEvent(&in);
+ in.root_y = 264.908;
+ test_XIBarrierEvent(&in);
+ in.root_y = 35638.292;
+ test_XIBarrierEvent(&in);
+
+ in.root_y = -1;
+ test_XIBarrierEvent(&in);
+ in.root_y = -1.3;
+ test_XIBarrierEvent(&in);
+ in.root_y = -264.908;
+ test_XIBarrierEvent(&in);
+ in.root_y = -35638.292;
+ test_XIBarrierEvent(&in);
+
+ /* equally pseudo-random 32 bit numbers */
+ in.dx = 1;
+ test_XIBarrierEvent(&in);
+ in.dx = 1.3;
+ test_XIBarrierEvent(&in);
+ in.dx = 264.908;
+ test_XIBarrierEvent(&in);
+ in.dx = 35638.292;
+ test_XIBarrierEvent(&in);
+ in.dx = 2947813871.2342;
+ test_XIBarrierEvent(&in);
+
+ in.dx = -1;
+ test_XIBarrierEvent(&in);
+ in.dx = -1.3;
+ test_XIBarrierEvent(&in);
+ in.dx = -264.908;
+ test_XIBarrierEvent(&in);
+ in.dx = -35638.292;
+ test_XIBarrierEvent(&in);
+ in.dx = -2947813871.2342;
+ test_XIBarrierEvent(&in);
+
+ in.dy = 1;
+ test_XIBarrierEvent(&in);
+ in.dy = 1.3;
+ test_XIBarrierEvent(&in);
+ in.dy = 264.908;
+ test_XIBarrierEvent(&in);
+ in.dy = 35638.292;
+ test_XIBarrierEvent(&in);
+ in.dy = 2947813871.2342;
+ test_XIBarrierEvent(&in);
+
+ in.dy = -1;
+ test_XIBarrierEvent(&in);
+ in.dy = -1.3;
+ test_XIBarrierEvent(&in);
+ in.dy = -264.908;
+ test_XIBarrierEvent(&in);
+ in.dy = -35638.292;
+ test_XIBarrierEvent(&in);
+ in.dy = -2947813871.2342;
+ test_XIBarrierEvent(&in);
+}
+
int
main(int argc, char **argv)
{
@@ -992,6 +1207,7 @@ main(int argc, char **argv)
test_convert_XIDeviceEvent();
test_convert_XIDeviceChangedEvent();
test_convert_XITouchOwnershipEvent();
+ test_convert_XIBarrierEvent();
return 0;
}
diff --git a/xorg-server/test/xi2/protocol-xiquerydevice.c b/xorg-server/test/xi2/protocol-xiquerydevice.c
index 9d13bbb6f..c066daa35 100644
--- a/xorg-server/test/xi2/protocol-xiquerydevice.c
+++ b/xorg-server/test/xi2/protocol-xiquerydevice.c
@@ -171,7 +171,7 @@ reply_XIQueryDevice_data(ClientPtr client, int len, char *data, void *closure)
(xkb->max_key_code - xkb->min_key_code + 1));
assert(any->length == (2 + ki->num_keycodes));
- kc = (uint32_t *) & ki[1];
+ kc = (uint32_t *) &ki[1];
for (k = 0; k < ki->num_keycodes; k++, kc++) {
if (client->swapped)
swapl(kc);
diff --git a/xorg-server/test/xi2/protocol-xiselectevents.c b/xorg-server/test/xi2/protocol-xiselectevents.c
index 8f6b947d4..183746f98 100644
--- a/xorg-server/test/xi2/protocol-xiselectevents.c
+++ b/xorg-server/test/xi2/protocol-xiselectevents.c
@@ -98,7 +98,7 @@ request_XISelectEvent(xXISelectEventsReq * req, int error)
xXIEventMask *mask, *next;
req->length = (sz_xXISelectEventsReq / 4);
- mask = (xXIEventMask *) & req[1];
+ mask = (xXIEventMask *) &req[1];
for (i = 0; i < req->num_masks; i++) {
req->length += sizeof(xXIEventMask) / 4 + mask->mask_len;
mask = (xXIEventMask *) ((char *) &mask[1] + mask->mask_len * 4);
@@ -111,7 +111,7 @@ request_XISelectEvent(xXISelectEventsReq * req, int error)
client.swapped = TRUE;
- mask = (xXIEventMask *) & req[1];
+ mask = (xXIEventMask *) &req[1];
for (i = 0; i < req->num_masks; i++) {
next = (xXIEventMask *) ((char *) &mask[1] + mask->mask_len * 4);
swaps(&mask->deviceid);
@@ -156,7 +156,7 @@ request_XISelectEvents_masks(xXISelectEventsReq * req)
int nmasks = (XI2LASTEVENT + 7) / 8;
unsigned char *bits;
- mask = (xXIEventMask *) & req[1];
+ mask = (xXIEventMask *) &req[1];
req->win = ROOT_WINDOW_ID;
/* if a clients submits more than 100 masks, consider it insane and untested */
@@ -312,7 +312,7 @@ test_XISelectEvents(void)
req->num_masks = 1;
printf("Triggering bogus mask length error\n");
- mask = (xXIEventMask *) & req[1];
+ mask = (xXIEventMask *) &req[1];
mask->deviceid = 0;
mask->mask_len = 0xFFFF;
request_XISelectEvent(req, BadLength);
@@ -320,7 +320,7 @@ test_XISelectEvents(void)
/* testing various device ids */
printf("Testing existing device ids.\n");
for (i = 0; i < 6; i++) {
- mask = (xXIEventMask *) & req[1];
+ mask = (xXIEventMask *) &req[1];
mask->deviceid = i;
mask->mask_len = 1;
req->win = ROOT_WINDOW_ID;
@@ -332,7 +332,7 @@ test_XISelectEvents(void)
for (i = 6; i <= 0xFFFF; i++) {
req->win = ROOT_WINDOW_ID;
req->num_masks = 1;
- mask = (xXIEventMask *) & req[1];
+ mask = (xXIEventMask *) &req[1];
mask->deviceid = i;
mask->mask_len = 1;
request_XISelectEvent(req, BadDevice);