aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/test/xi2/protocol-eventconvert.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2011-12-23 10:01:52 +0100
committermarha <marha@users.sourceforge.net>2011-12-23 10:01:52 +0100
commite22891346b85a7db40dec7260a100f90b451cbc8 (patch)
treea7dd2d6757253947bcc821abbf68fd24d3301e89 /xorg-server/test/xi2/protocol-eventconvert.c
parentabacebe06d9f3d2fe1b7d256bd86cddbfa592a85 (diff)
downloadvcxsrv-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/protocol-eventconvert.c')
-rw-r--r--xorg-server/test/xi2/protocol-eventconvert.c104
1 files changed, 96 insertions, 8 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;
}