diff options
author | marha <marha@users.sourceforge.net> | 2011-12-23 10:01:52 +0100 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2011-12-23 10:01:52 +0100 |
commit | e22891346b85a7db40dec7260a100f90b451cbc8 (patch) | |
tree | a7dd2d6757253947bcc821abbf68fd24d3301e89 /xorg-server/test/xi2 | |
parent | abacebe06d9f3d2fe1b7d256bd86cddbfa592a85 (diff) | |
download | vcxsrv-e22891346b85a7db40dec7260a100f90b451cbc8.tar.gz vcxsrv-e22891346b85a7db40dec7260a100f90b451cbc8.tar.bz2 vcxsrv-e22891346b85a7db40dec7260a100f90b451cbc8.zip |
git mesa pixman xserver xkeyboard-config update 24 dec 2011
Diffstat (limited to 'xorg-server/test/xi2')
-rw-r--r-- | xorg-server/test/xi2/protocol-eventconvert.c | 104 | ||||
-rw-r--r-- | xorg-server/test/xi2/protocol-xipassivegrabdevice.c | 2 | ||||
-rw-r--r-- | xorg-server/test/xi2/protocol-xiselectevents.c | 38 |
3 files changed, 127 insertions, 17 deletions
diff --git a/xorg-server/test/xi2/protocol-eventconvert.c b/xorg-server/test/xi2/protocol-eventconvert.c index e2037f911..faa9f407a 100644 --- a/xorg-server/test/xi2/protocol-eventconvert.c +++ b/xorg-server/test/xi2/protocol-eventconvert.c @@ -193,7 +193,6 @@ static void test_convert_XIRawEvent(void) memset(&in, 0, sizeof(in)); - printf("Testing all event types\n"); in.header = ET_Internal; in.type = ET_RawMotion; test_XIRawEvent(&in); @@ -214,7 +213,6 @@ static void test_convert_XIRawEvent(void) in.type = ET_RawButtonRelease; test_XIRawEvent(&in); - printf("Testing details and other fields\n"); in.detail.button = 1L; test_XIRawEvent(&in); in.detail.button = 1L << 8; @@ -246,7 +244,6 @@ static void test_convert_XIRawEvent(void) in.deviceid = ~0 & 0xFF; test_XIRawEvent(&in); - printf("Testing valuator masks\n"); for (i = 0; i < MAX_VALUATORS; i++) { XISetMask(in.valuators.mask, i); @@ -432,7 +429,6 @@ static void test_convert_XIDeviceEvent(void) memset(&in, 0, sizeof(in)); - printf("Testing simple field values\n"); in.header = ET_Internal; in.type = ET_Motion; in.length = sizeof(DeviceEvent); @@ -456,7 +452,6 @@ static void test_convert_XIDeviceEvent(void) test_XIDeviceEvent(&in); - printf("Testing field ranges\n"); /* 32 bit */ in.detail.button = 1L; test_XIDeviceEvent(&in); @@ -604,7 +599,6 @@ static void test_convert_XIDeviceEvent(void) in.mods.effective = ~0 & 0xFF; test_XIDeviceEvent(&in); - printf("Testing button masks\n"); for (i = 0; i < sizeof(in.buttons) * 8; i++) { XISetMask(in.buttons, i); @@ -618,7 +612,6 @@ static void test_convert_XIDeviceEvent(void) test_XIDeviceEvent(&in); } - printf("Testing valuator masks\n"); for (i = 0; i < MAX_VALUATORS; i++) { XISetMask(in.valuators.mask, i); @@ -799,7 +792,6 @@ static void test_convert_XIDeviceChangedEvent(void) DeviceChangedEvent in; int i; - printf("Testing simple field values\n"); memset(&in, 0, sizeof(in)); in.header = ET_Internal; in.type = ET_DeviceChanged; @@ -923,12 +915,108 @@ static void test_convert_XIDeviceChangedEvent(void) } } +static void +test_values_XITouchOwnershipEvent(TouchOwnershipEvent *in, + xXITouchOwnershipEvent *out, + BOOL swap) +{ + if (swap) + { + swaps(&out->sequenceNumber); + swapl(&out->length); + swaps(&out->evtype); + swaps(&out->deviceid); + swaps(&out->sourceid); + swapl(&out->time); + swapl(&out->touchid); + swapl(&out->root); + swapl(&out->event); + swapl(&out->child); + swapl(&out->time); + } + + 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->touchid == in->touchid); + assert(out->flags == in->reason); +} + +static void +test_XITouchOwnershipEvent(TouchOwnershipEvent *in) +{ + xXITouchOwnershipEvent *out, *swapped; + int rc; + + rc = EventToXI2((InternalEvent*)in, (xEvent**)&out); + assert(rc == Success); + + test_values_XITouchOwnershipEvent(in, out, FALSE); + + swapped = calloc(1, sizeof(xEvent) + out->length * 4); + XI2EventSwap((xGenericEvent*)out, (xGenericEvent*)swapped); + test_values_XITouchOwnershipEvent(in, swapped, TRUE); + free(out); + free(swapped); +} + +static void +test_convert_XITouchOwnershipEvent(void) +{ + TouchOwnershipEvent in; + long i; + + memset(&in, 0, sizeof(in)); + in.header = ET_Internal; + in.type = ET_TouchOwnership; + in.length = sizeof(in); + in.time = 0; + in.deviceid = 1; + in.sourceid = 2; + in.touchid = 0; + in.reason = 0; + in.resource = 0; + in.flags = 0; + + test_XITouchOwnershipEvent(&in); + + in.flags = XIAcceptTouch; + test_XITouchOwnershipEvent(&in); + + in.flags = XIRejectTouch; + test_XITouchOwnershipEvent(&in); + + for (i = 1; i <= 0xFFFF; i <<= 1) + { + in.deviceid = i; + test_XITouchOwnershipEvent(&in); + } + + for (i = 1; i <= 0xFFFF; i <<= 1) + { + in.sourceid = i; + test_XITouchOwnershipEvent(&in); + } + + for (i = 1; ; i <<= 1) + { + in.touchid = i; + test_XITouchOwnershipEvent(&in); + if (i == (1 << 31)) + break; + } +} + int main(int argc, char** argv) { test_convert_XIRawEvent(); test_convert_XIFocusEvent(); test_convert_XIDeviceEvent(); test_convert_XIDeviceChangedEvent(); + test_convert_XITouchOwnershipEvent(); return 0; } diff --git a/xorg-server/test/xi2/protocol-xipassivegrabdevice.c b/xorg-server/test/xi2/protocol-xipassivegrabdevice.c index 89ffc3d29..b405556be 100644 --- a/xorg-server/test/xi2/protocol-xipassivegrabdevice.c +++ b/xorg-server/test/xi2/protocol-xipassivegrabdevice.c @@ -180,7 +180,7 @@ static void test_XIPassiveGrabDevice(void) request->deviceid = XIAllMasterDevices; printf("Testing invalid grab types\n"); - for (i = XIGrabtypeFocusIn + 1; i < 0xFF; i++) + for (i = XIGrabtypeTouchBegin + 1; i < 0xFF; i++) { request->grab_type = i; request_XIPassiveGrabDevice(&client_request, request, BadValue, request->grab_type); diff --git a/xorg-server/test/xi2/protocol-xiselectevents.c b/xorg-server/test/xi2/protocol-xiselectevents.c index 4eaf839fa..0390858b1 100644 --- a/xorg-server/test/xi2/protocol-xiselectevents.c +++ b/xorg-server/test/xi2/protocol-xiselectevents.c @@ -125,6 +125,28 @@ static void request_XISelectEvent(xXISelectEventsReq *req, int error) assert(rc == error); } +static void _set_bit(unsigned char *bits, int bit) +{ + SetBit(bits, bit); + if (bit >= XI_TouchBegin && bit <= XI_TouchOwnership) + { + SetBit(bits, XI_TouchBegin); + SetBit(bits, XI_TouchUpdate); + SetBit(bits, XI_TouchEnd); + } +} + +static void _clear_bit(unsigned char *bits, int bit) +{ + ClearBit(bits, bit); + if (bit >= XI_TouchBegin && bit <= XI_TouchOwnership) + { + ClearBit(bits, XI_TouchBegin); + ClearBit(bits, XI_TouchUpdate); + ClearBit(bits, XI_TouchEnd); + } +} + static void request_XISelectEvents_masks(xXISelectEventsReq *req) { int i, j; @@ -157,9 +179,9 @@ static void request_XISelectEvents_masks(xXISelectEventsReq *req) memset(bits, 0, mask->mask_len * 4); for (j = 0; j <= XI2LASTEVENT; j++) { - SetBit(bits, j); + _set_bit(bits, j); request_XISelectEvent(req, Success); - ClearBit(bits, j); + _clear_bit(bits, j); } /* Test 2: @@ -173,7 +195,7 @@ static void request_XISelectEvents_masks(xXISelectEventsReq *req) for (j = 0; j <= XI2LASTEVENT; j++) { - SetBit(bits, j); + _set_bit(bits, j); request_XISelectEvent(req, Success); } @@ -187,9 +209,9 @@ static void request_XISelectEvents_masks(xXISelectEventsReq *req) for (j = XI2LASTEVENT + 1; j < mask->mask_len * 4; j++) { - SetBit(bits, j); + _set_bit(bits, j); request_XISelectEvent(req, BadValue); - ClearBit(bits, j); + _clear_bit(bits, j); } /* Test 4: @@ -200,7 +222,7 @@ static void request_XISelectEvents_masks(xXISelectEventsReq *req) memset(bits, 0, mask->mask_len * 4); for (j = 0; j <= XI2LASTEVENT; j++) { - SetBit(bits, j); + _set_bit(bits, j); request_XISelectEvent(req, Success); } @@ -227,8 +249,8 @@ static void request_XISelectEvents_masks(xXISelectEventsReq *req) mask->mask_len = (nmasks + 3)/4; memset(bits, 0, mask->mask_len * 4); for (j = 0; j <= XI2LASTEVENT; j++) - SetBit(bits, j); - ClearBit(bits, XI_HierarchyChanged); + _set_bit(bits, j); + _clear_bit(bits, XI_HierarchyChanged); for (j = 1; j < 6; j++) { mask->deviceid = j; |