From 96d6df5da9cddedf4931bf8e17f96e242467c661 Mon Sep 17 00:00:00 2001 From: marha Date: Wed, 27 Apr 2011 06:58:32 +0000 Subject: xserver libX11 libxtrans mesa pixman xkeyboard-config git update 27 Apr 2011 --- xorg-server/test/xi2/Makefile.am | 10 +- xorg-server/test/xi2/protocol-common.c | 355 ++++++++++----------- xorg-server/test/xi2/protocol-common.h | 11 +- xorg-server/test/xi2/protocol-eventconvert.c | 172 +++++----- xorg-server/test/xi2/protocol-xigetclientpointer.c | 31 +- .../test/xi2/protocol-xigetselectedevents.c | 28 +- .../test/xi2/protocol-xipassivegrabdevice.c | 234 ++++++++++++++ xorg-server/test/xi2/protocol-xiquerydevice.c | 98 +++--- xorg-server/test/xi2/protocol-xiquerypointer.c | 38 +-- xorg-server/test/xi2/protocol-xiqueryversion.c | 28 +- xorg-server/test/xi2/protocol-xiselectevents.c | 24 +- xorg-server/test/xi2/protocol-xisetclientpointer.c | 32 +- xorg-server/test/xi2/protocol-xiwarppointer.c | 24 +- 13 files changed, 642 insertions(+), 443 deletions(-) create mode 100644 xorg-server/test/xi2/protocol-xipassivegrabdevice.c (limited to 'xorg-server/test/xi2') diff --git a/xorg-server/test/xi2/Makefile.am b/xorg-server/test/xi2/Makefile.am index 1b9bfe08e..b15d8ba02 100644 --- a/xorg-server/test/xi2/Makefile.am +++ b/xorg-server/test/xi2/Makefile.am @@ -1,5 +1,4 @@ if ENABLE_UNIT_TESTS -if HAVE_GLIB if HAVE_LD_WRAP noinst_PROGRAMS = \ protocol-xiqueryversion \ @@ -8,15 +7,16 @@ noinst_PROGRAMS = \ protocol-xigetselectedevents \ protocol-xisetclientpointer \ protocol-xigetclientpointer \ + protocol-xipassivegrabdevice \ protocol-xiquerypointer \ protocol-xiwarppointer \ protocol-eventconvert TESTS=$(noinst_PROGRAMS) -AM_CFLAGS = $(DIX_CFLAGS) $(GLIB_CFLAGS) @XORG_CFLAGS@ +AM_CFLAGS = $(DIX_CFLAGS) @XORG_CFLAGS@ INCLUDES = @XORG_INCS@ -TEST_LDADD=../libxservertest.la $(XORG_SYS_LIBS) $(XSERVER_SYS_LIBS) $(GLIB_LIBS) +TEST_LDADD=../libxservertest.la $(XORG_SYS_LIBS) $(XSERVER_SYS_LIBS) COMMON_SOURCES=protocol-common.h protocol-common.c if SPECIAL_DTRACE_OBJECTS @@ -30,6 +30,7 @@ protocol_xigetselectedevents_LDADD=$(TEST_LDADD) protocol_xisetclientpointer_LDADD=$(TEST_LDADD) protocol_xigetclientpointer_LDADD=$(TEST_LDADD) protocol_xiquerypointer_LDADD=$(TEST_LDADD) +protocol_xipassivegrabdevice_LDADD=$(TEST_LDADD) protocol_xiwarppointer_LDADD=$(TEST_LDADD) protocol_eventconvert_LDADD=$(TEST_LDADD) @@ -39,6 +40,7 @@ protocol_xiselectevents_LDFLAGS=$(AM_LDFLAGS) -Wl,-wrap,dixLookupWindow -Wl,-wra protocol_xigetselectedevents_LDFLAGS=$(AM_LDFLAGS) -Wl,-wrap,WriteToClient -Wl,-wrap,dixLookupWindow -Wl,-wrap,AddResource protocol_xisetclientpointer_LDFLAGS=$(AM_LDFLAGS) -Wl,-wrap,dixLookupClient protocol_xigetclientpointer_LDFLAGS=$(AM_LDFLAGS) -Wl,-wrap,WriteToClient -Wl,-wrap,dixLookupClient +protocol_xipassivegrabdevice_LDFLAGS=$(AM_LDFLAGS) -Wl,-wrap,GrabButton -Wl,-wrap,dixLookupWindow -Wl,-wrap,WriteToClient protocol_xiquerypointer_LDFLAGS=$(AM_LDFLAGS) -Wl,-wrap,WriteToClient -Wl,-wrap,dixLookupWindow protocol_xiwarppointer_LDFLAGS=$(AM_LDFLAGS) -Wl,-wrap,WriteToClient -Wl,-wrap,dixLookupWindow @@ -49,7 +51,7 @@ protocol_xigetselectedevents_SOURCES=$(COMMON_SOURCES) protocol-xigetselectedeve protocol_xisetclientpointer_SOURCES=$(COMMON_SOURCES) protocol-xisetclientpointer.c protocol_xigetclientpointer_SOURCES=$(COMMON_SOURCES) protocol-xigetclientpointer.c protocol_xiquerypointer_SOURCES=$(COMMON_SOURCES) protocol-xiquerypointer.c +protocol_xipassivegrabdevice_SOURCES=$(COMMON_SOURCES) protocol-xipassivegrabdevice.c protocol_xiwarppointer_SOURCES=$(COMMON_SOURCES) protocol-xiwarppointer.c endif endif -endif diff --git a/xorg-server/test/xi2/protocol-common.c b/xorg-server/test/xi2/protocol-common.c index 86a7201b8..6ffc69721 100644 --- a/xorg-server/test/xi2/protocol-common.c +++ b/xorg-server/test/xi2/protocol-common.c @@ -1,178 +1,177 @@ -/** - * Copyright © 2009 Red Hat, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#ifdef HAVE_DIX_CONFIG_H -#include -#endif - -#include -#include "extinit.h" /* for XInputExtensionInit */ -#include "exglobals.h" -#include "xkbsrv.h" /* for XkbInitPrivates */ -#include - -#include "protocol-common.h" - -struct devices devices; -ScreenRec screen; -WindowRec root; -WindowRec window; - -void *userdata; - -extern int CorePointerProc(DeviceIntPtr pDev, int what); -extern int CoreKeyboardProc(DeviceIntPtr pDev, int what); - -static void fake_init_sprite(DeviceIntPtr dev) -{ - SpritePtr sprite; - sprite = dev->spriteInfo->sprite; - - sprite->spriteTraceSize = 10; - sprite->spriteTrace = calloc(sprite->spriteTraceSize, sizeof(WindowPtr)); - sprite->spriteTraceGood = 1; - sprite->spriteTrace[0] = &root; - sprite->hot.x = SPRITE_X; - sprite->hot.y = SPRITE_Y; - sprite->hotPhys.x = sprite->hot.x; - sprite->hotPhys.y = sprite->hot.y; - sprite->win = &window; - sprite->hotPhys.pScreen = &screen; - sprite->physLimits.x1 = 0; - sprite->physLimits.y1 = 0; - sprite->physLimits.x2 = screen.width; - sprite->physLimits.y2 = screen.height; -} - -/** - * Create and init 2 master devices (VCP + VCK) and two slave devices, one - * default mouse, one default keyboard. - */ -struct devices init_devices(void) -{ - ClientRec client; - struct devices devices; - - client = init_client(0, NULL); - - AllocDevicePair(&client, "Virtual core", &devices.vcp, &devices.vck, - CorePointerProc, CoreKeyboardProc, TRUE); - inputInfo.pointer = devices.vcp; - inputInfo.keyboard = devices.vck; - ActivateDevice(devices.vcp, FALSE); - ActivateDevice(devices.vck, FALSE); - EnableDevice(devices.vcp, FALSE); - EnableDevice(devices.vck, FALSE); - - AllocDevicePair(&client, "", &devices.mouse, &devices.kbd, - CorePointerProc, CoreKeyboardProc, FALSE); - ActivateDevice(devices.mouse, FALSE); - ActivateDevice(devices.kbd, FALSE); - EnableDevice(devices.mouse, FALSE); - EnableDevice(devices.kbd, FALSE); - - devices.num_devices = 4; - devices.num_master_devices = 2; - - fake_init_sprite(devices.mouse); - fake_init_sprite(devices.vcp); - - return devices; -} - - -/* Create minimal client, with the given buffer and len as request buffer */ -ClientRec init_client(int len, void *data) -{ - ClientRec client = { 0 }; - - /* we store the privates now and reassign it after the memset. this way - * we can share them across multiple test runs and don't have to worry - * about freeing them after each test run. */ - - client.index = CLIENT_INDEX; - client.clientAsMask = CLIENT_MASK; - client.sequence = CLIENT_SEQUENCE; - client.req_len = len; - - client.requestBuffer = data; - dixAllocatePrivates(&client.devPrivates, PRIVATE_CLIENT); - return client; -} - -void init_window(WindowPtr window, WindowPtr parent, int id) -{ - memset(window, 0, sizeof(window)); - - window->drawable.id = id; - if (parent) - { - window->drawable.x = 30; - window->drawable.y = 50; - window->drawable.width = 100; - window->drawable.height = 200; - } - window->parent = parent; - window->optional = calloc(1, sizeof(WindowOptRec)); - g_assert(window->optional); -} - -extern DevPrivateKeyRec miPointerScreenKeyRec; -extern DevPrivateKeyRec miPointerPrivKeyRec; - -/* Needed for the screen setup, otherwise we crash during sprite initialization */ -static Bool device_cursor_init(DeviceIntPtr dev, ScreenPtr screen) { return TRUE; } -static Bool set_cursor_pos(DeviceIntPtr dev, ScreenPtr screen, int x, int y, Bool event) { return TRUE; } -void init_simple(void) -{ - screenInfo.numScreens = 1; - screenInfo.screens[0] = &screen; - - screen.myNum = 0; - screen.id = 100; - screen.width = 640; - screen.height = 480; - screen.DeviceCursorInitialize = device_cursor_init; - screen.SetCursorPosition = set_cursor_pos; - - dixResetPrivates(); - InitAtoms(); - XkbInitPrivates(); - dixRegisterPrivateKey(&XIClientPrivateKeyRec, PRIVATE_CLIENT, sizeof(XIClientRec)); - dixRegisterPrivateKey(&miPointerScreenKeyRec, PRIVATE_SCREEN, 0); - dixRegisterPrivateKey(&miPointerPrivKeyRec, PRIVATE_DEVICE, 0); - XInputExtensionInit(); - - init_window(&root, NULL, ROOT_WINDOW_ID); - init_window(&window, &root, CLIENT_WINDOW_ID); - - devices = init_devices(); -} - -void __wrap_WriteToClient(ClientPtr client, int len, void *data) -{ - g_assert(reply_handler != NULL); - - (*reply_handler)(client, len, data, userdata); -} - +/** + * Copyright © 2009 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#ifdef HAVE_DIX_CONFIG_H +#include +#endif + +#include +#include "extinit.h" /* for XInputExtensionInit */ +#include "exglobals.h" +#include "xkbsrv.h" /* for XkbInitPrivates */ + +#include "protocol-common.h" + +struct devices devices; +ScreenRec screen; +WindowRec root; +WindowRec window; + +void *userdata; + +extern int CorePointerProc(DeviceIntPtr pDev, int what); +extern int CoreKeyboardProc(DeviceIntPtr pDev, int what); + +static void fake_init_sprite(DeviceIntPtr dev) +{ + SpritePtr sprite; + sprite = dev->spriteInfo->sprite; + + sprite->spriteTraceSize = 10; + sprite->spriteTrace = calloc(sprite->spriteTraceSize, sizeof(WindowPtr)); + sprite->spriteTraceGood = 1; + sprite->spriteTrace[0] = &root; + sprite->hot.x = SPRITE_X; + sprite->hot.y = SPRITE_Y; + sprite->hotPhys.x = sprite->hot.x; + sprite->hotPhys.y = sprite->hot.y; + sprite->win = &window; + sprite->hotPhys.pScreen = &screen; + sprite->physLimits.x1 = 0; + sprite->physLimits.y1 = 0; + sprite->physLimits.x2 = screen.width; + sprite->physLimits.y2 = screen.height; +} + +/** + * Create and init 2 master devices (VCP + VCK) and two slave devices, one + * default mouse, one default keyboard. + */ +struct devices init_devices(void) +{ + ClientRec client; + struct devices devices; + + client = init_client(0, NULL); + + AllocDevicePair(&client, "Virtual core", &devices.vcp, &devices.vck, + CorePointerProc, CoreKeyboardProc, TRUE); + inputInfo.pointer = devices.vcp; + inputInfo.keyboard = devices.vck; + ActivateDevice(devices.vcp, FALSE); + ActivateDevice(devices.vck, FALSE); + EnableDevice(devices.vcp, FALSE); + EnableDevice(devices.vck, FALSE); + + AllocDevicePair(&client, "", &devices.mouse, &devices.kbd, + CorePointerProc, CoreKeyboardProc, FALSE); + ActivateDevice(devices.mouse, FALSE); + ActivateDevice(devices.kbd, FALSE); + EnableDevice(devices.mouse, FALSE); + EnableDevice(devices.kbd, FALSE); + + devices.num_devices = 4; + devices.num_master_devices = 2; + + fake_init_sprite(devices.mouse); + fake_init_sprite(devices.vcp); + + return devices; +} + + +/* Create minimal client, with the given buffer and len as request buffer */ +ClientRec init_client(int len, void *data) +{ + ClientRec client = { 0 }; + + /* we store the privates now and reassign it after the memset. this way + * we can share them across multiple test runs and don't have to worry + * about freeing them after each test run. */ + + client.index = CLIENT_INDEX; + client.clientAsMask = CLIENT_MASK; + client.sequence = CLIENT_SEQUENCE; + client.req_len = len; + + client.requestBuffer = data; + dixAllocatePrivates(&client.devPrivates, PRIVATE_CLIENT); + return client; +} + +void init_window(WindowPtr window, WindowPtr parent, int id) +{ + memset(window, 0, sizeof(window)); + + window->drawable.id = id; + if (parent) + { + window->drawable.x = 30; + window->drawable.y = 50; + window->drawable.width = 100; + window->drawable.height = 200; + } + window->parent = parent; + window->optional = calloc(1, sizeof(WindowOptRec)); + assert(window->optional); +} + +extern DevPrivateKeyRec miPointerScreenKeyRec; +extern DevPrivateKeyRec miPointerPrivKeyRec; + +/* Needed for the screen setup, otherwise we crash during sprite initialization */ +static Bool device_cursor_init(DeviceIntPtr dev, ScreenPtr screen) { return TRUE; } +static Bool set_cursor_pos(DeviceIntPtr dev, ScreenPtr screen, int x, int y, Bool event) { return TRUE; } +void init_simple(void) +{ + screenInfo.numScreens = 1; + screenInfo.screens[0] = &screen; + + screen.myNum = 0; + screen.id = 100; + screen.width = 640; + screen.height = 480; + screen.DeviceCursorInitialize = device_cursor_init; + screen.SetCursorPosition = set_cursor_pos; + + dixResetPrivates(); + InitAtoms(); + XkbInitPrivates(); + dixRegisterPrivateKey(&XIClientPrivateKeyRec, PRIVATE_CLIENT, sizeof(XIClientRec)); + dixRegisterPrivateKey(&miPointerScreenKeyRec, PRIVATE_SCREEN, 0); + dixRegisterPrivateKey(&miPointerPrivKeyRec, PRIVATE_DEVICE, 0); + XInputExtensionInit(); + + init_window(&root, NULL, ROOT_WINDOW_ID); + init_window(&window, &root, CLIENT_WINDOW_ID); + + devices = init_devices(); +} + +void __wrap_WriteToClient(ClientPtr client, int len, void *data) +{ + assert(reply_handler != NULL); + + (*reply_handler)(client, len, data, userdata); +} + diff --git a/xorg-server/test/xi2/protocol-common.h b/xorg-server/test/xi2/protocol-common.h index afa08780c..18c61e62a 100644 --- a/xorg-server/test/xi2/protocol-common.h +++ b/xorg-server/test/xi2/protocol-common.h @@ -29,6 +29,7 @@ #include "windowstr.h" #include "scrnintstr.h" #include "exevents.h" +#include #ifndef PROTOCOL_COMMON_H #define PROTOCOL_COMMON_H @@ -38,11 +39,11 @@ extern int BadDevice; /* Check default values in a reply */ #define reply_check_defaults(rep, len, type) \ { \ - g_assert((len) >= sz_x##type##Reply); \ - g_assert((rep)->repType == X_Reply); \ - g_assert((rep)->RepType == X_##type); \ - g_assert((rep)->sequenceNumber == CLIENT_SEQUENCE); \ - g_assert((rep)->length >= (sz_x##type##Reply - 32)/4); \ + assert((len) >= sz_x##type##Reply); \ + assert((rep)->repType == X_Reply); \ + assert((rep)->RepType == X_##type); \ + assert((rep)->sequenceNumber == CLIENT_SEQUENCE); \ + assert((rep)->length >= (sz_x##type##Reply - 32)/4); \ } /* initialise default values for request */ diff --git a/xorg-server/test/xi2/protocol-eventconvert.c b/xorg-server/test/xi2/protocol-eventconvert.c index 0478c33fe..edba974bf 100644 --- a/xorg-server/test/xi2/protocol-eventconvert.c +++ b/xorg-server/test/xi2/protocol-eventconvert.c @@ -25,7 +25,6 @@ #endif #include -#include #include "inputstr.h" #include "eventstr.h" @@ -33,7 +32,6 @@ #include "exevents.h" #include - static void test_values_XIRawEvent(RawDeviceEvent *in, xXIRawEvent *out, BOOL swap) { @@ -58,21 +56,21 @@ static void test_values_XIRawEvent(RawDeviceEvent *in, xXIRawEvent *out, } - g_assert(out->type == GenericEvent); - g_assert(out->extension == 0); /* IReqCode defaults to 0 */ - g_assert(out->evtype == GetXI2Type((InternalEvent*)in)); - g_assert(out->time == in->time); - g_assert(out->detail == in->detail.button); - g_assert(out->deviceid == in->deviceid); - g_assert(out->valuators_len >= bytes_to_int32(bits_to_bytes(sizeof(in->valuators.mask)))); - g_assert(out->flags == 0); /* FIXME: we don't set the flags yet */ + assert(out->type == GenericEvent); + assert(out->extension == 0); /* IReqCode defaults to 0 */ + assert(out->evtype == GetXI2Type((InternalEvent*)in)); + assert(out->time == in->time); + assert(out->detail == in->detail.button); + assert(out->deviceid == in->deviceid); + assert(out->valuators_len >= bytes_to_int32(bits_to_bytes(sizeof(in->valuators.mask)))); + assert(out->flags == 0); /* FIXME: we don't set the flags yet */ ptr = (unsigned char*)&out[1]; bits_set = 0; for (i = 0; out->valuators_len && i < sizeof(in->valuators.mask) * 8; i++) { - g_assert (XIMaskIsSet(in->valuators.mask, i) == XIMaskIsSet(ptr, i)); + assert (XIMaskIsSet(in->valuators.mask, i) == XIMaskIsSet(ptr, i)); if (XIMaskIsSet(in->valuators.mask, i)) bits_set++; } @@ -81,13 +79,13 @@ static void test_values_XIRawEvent(RawDeviceEvent *in, xXIRawEvent *out, * set. Each bit set represents 2 8-byte values, hence the * 'bits_set * 4' */ len = out->valuators_len + bits_set * 4; - g_assert(out->length == len); + assert(out->length == len); nvals = 0; for (i = 0; out->valuators_len && i < MAX_VALUATORS; i++) { - g_assert (XIMaskIsSet(in->valuators.mask, i) == XIMaskIsSet(ptr, i)); + assert (XIMaskIsSet(in->valuators.mask, i) == XIMaskIsSet(ptr, i)); if (XIMaskIsSet(in->valuators.mask, i)) { FP3232 vi, vo; @@ -106,8 +104,8 @@ static void test_values_XIRawEvent(RawDeviceEvent *in, xXIRawEvent *out, swapl(&vo.frac, n); } - g_assert(vi.integral == vo.integral); - g_assert(vi.frac == vo.frac); + assert(vi.integral == vo.integral); + assert(vi.frac == vo.frac); raw_value = value + bits_set; @@ -123,8 +121,8 @@ static void test_values_XIRawEvent(RawDeviceEvent *in, xXIRawEvent *out, swapl(&vo.frac, n); } - g_assert(vi.integral == vo.integral); - g_assert(vi.frac == vo.frac); + assert(vi.integral == vo.integral); + assert(vi.frac == vo.frac); nvals++; } @@ -137,7 +135,7 @@ static void test_XIRawEvent(RawDeviceEvent *in) int rc; rc = EventToXI2((InternalEvent*)in, (xEvent**)&out); - g_assert(rc == Success); + assert(rc == Success); test_values_XIRawEvent(in, out, FALSE); @@ -158,24 +156,24 @@ static void test_convert_XIFocusEvent(void) in.header = ET_Internal; in.type = ET_Enter; rc = EventToXI2((InternalEvent*)&in, &out); - g_assert(rc == Success); - g_assert(out == NULL); + assert(rc == Success); + assert(out == NULL); in.header = ET_Internal; in.type = ET_FocusIn; rc = EventToXI2((InternalEvent*)&in, &out); - g_assert(rc == Success); - g_assert(out == NULL); + assert(rc == Success); + assert(out == NULL); in.header = ET_Internal; in.type = ET_FocusOut; rc = EventToXI2((InternalEvent*)&in, &out); - g_assert(rc == BadImplementation); + assert(rc == BadImplementation); in.header = ET_Internal; in.type = ET_Leave; rc = EventToXI2((InternalEvent*)&in, &out); - g_assert(rc == BadImplementation); + assert(rc == BadImplementation); } @@ -186,7 +184,7 @@ static void test_convert_XIRawEvent(void) memset(&in, 0, sizeof(in)); - g_test_message("Testing all event types"); + printf("Testing all event types\n"); in.header = ET_Internal; in.type = ET_RawMotion; test_XIRawEvent(&in); @@ -207,7 +205,7 @@ static void test_convert_XIRawEvent(void) in.type = ET_RawButtonRelease; test_XIRawEvent(&in); - g_test_message("Testing details and other fields"); + printf("Testing details and other fields\n"); in.detail.button = 1L; test_XIRawEvent(&in); in.detail.button = 1L << 8; @@ -239,7 +237,7 @@ static void test_convert_XIRawEvent(void) in.deviceid = ~0 & 0xFF; test_XIRawEvent(&in); - g_test_message("Testing valuator masks"); + printf("Testing valuator masks\n"); for (i = 0; i < sizeof(in.valuators.mask) * 8; i++) { XISetMask(in.valuators.mask, i); @@ -301,14 +299,14 @@ static void test_values_XIDeviceEvent(DeviceEvent *in, xXIDeviceEvent *out, swapl(&out->flags, n); } - g_assert(out->extension == 0); /* IReqCode defaults to 0 */ - g_assert(out->evtype == GetXI2Type((InternalEvent*)in)); - g_assert(out->time == in->time); - g_assert(out->detail == in->detail.button); - g_assert(out->length >= 12); + assert(out->extension == 0); /* IReqCode defaults to 0 */ + assert(out->evtype == GetXI2Type((InternalEvent*)in)); + assert(out->time == in->time); + assert(out->detail == in->detail.button); + assert(out->length >= 12); - g_assert(out->deviceid == in->deviceid); - g_assert(out->sourceid == in->sourceid); + assert(out->deviceid == in->deviceid); + assert(out->sourceid == in->sourceid); switch (in->type) { case ET_KeyPress: @@ -318,41 +316,41 @@ static void test_values_XIDeviceEvent(DeviceEvent *in, xXIDeviceEvent *out, flagmask = 0; break; } - g_assert((out->flags & ~flagmask) == 0); + assert((out->flags & ~flagmask) == 0); - g_assert(out->root == in->root); - g_assert(out->event == None); /* set in FixUpEventFromWindow */ - g_assert(out->child == None); /* set in FixUpEventFromWindow */ + assert(out->root == in->root); + assert(out->event == None); /* set in FixUpEventFromWindow */ + assert(out->child == None); /* set in FixUpEventFromWindow */ - g_assert(out->mods.base_mods == in->mods.base); - g_assert(out->mods.latched_mods == in->mods.latched); - g_assert(out->mods.locked_mods == in->mods.locked); - g_assert(out->mods.effective_mods == in->mods.effective); + assert(out->mods.base_mods == in->mods.base); + assert(out->mods.latched_mods == in->mods.latched); + assert(out->mods.locked_mods == in->mods.locked); + assert(out->mods.effective_mods == in->mods.effective); - g_assert(out->group.base_group == in->group.base); - g_assert(out->group.latched_group == in->group.latched); - g_assert(out->group.locked_group == in->group.locked); - g_assert(out->group.effective_group == in->group.effective); + assert(out->group.base_group == in->group.base); + assert(out->group.latched_group == in->group.latched); + assert(out->group.locked_group == in->group.locked); + assert(out->group.effective_group == in->group.effective); - g_assert(out->event_x == 0); /* set in FixUpEventFromWindow */ - g_assert(out->event_y == 0); /* set in FixUpEventFromWindow */ + assert(out->event_x == 0); /* set in FixUpEventFromWindow */ + assert(out->event_y == 0); /* set in FixUpEventFromWindow */ - g_assert(out->root_x == FP1616(in->root_x, in->root_x_frac)); - g_assert(out->root_y == FP1616(in->root_y, in->root_y_frac)); + assert(out->root_x == FP1616(in->root_x, in->root_x_frac)); + assert(out->root_y == FP1616(in->root_y, in->root_y_frac)); buttons = 0; for (i = 0; i < bits_to_bytes(sizeof(in->buttons)); i++) { if (XIMaskIsSet(in->buttons, i)) { - g_assert(out->buttons_len >= bytes_to_int32(bits_to_bytes(i))); + assert(out->buttons_len >= bytes_to_int32(bits_to_bytes(i))); buttons++; } } ptr = (unsigned char*)&out[1]; for (i = 0; i < sizeof(in->buttons) * 8; i++) - g_assert(XIMaskIsSet(in->buttons, i) == XIMaskIsSet(ptr, i)); + assert(XIMaskIsSet(in->buttons, i) == XIMaskIsSet(ptr, i)); valuators = 0; @@ -360,7 +358,7 @@ static void test_values_XIDeviceEvent(DeviceEvent *in, xXIDeviceEvent *out, if (XIMaskIsSet(in->valuators.mask, i)) valuators++; - g_assert(out->valuators_len >= bytes_to_int32(bits_to_bytes(valuators))); + assert(out->valuators_len >= bytes_to_int32(bits_to_bytes(valuators))); ptr += out->buttons_len * 4; values = (FP3232*)(ptr + out->valuators_len * 4); @@ -368,11 +366,11 @@ static void test_values_XIDeviceEvent(DeviceEvent *in, xXIDeviceEvent *out, i < (out->valuators_len * 4) * 8; i++) { if (i > sizeof(in->valuators.mask) * 8) - g_assert(!XIMaskIsSet(ptr, i)); + assert(!XIMaskIsSet(ptr, i)); else if (i > out->valuators_len * 4 * 8) - g_assert(!XIMaskIsSet(in->valuators.mask, i)); + assert(!XIMaskIsSet(in->valuators.mask, i)); else { - g_assert(XIMaskIsSet(in->valuators.mask, i) == + assert(XIMaskIsSet(in->valuators.mask, i) == XIMaskIsSet(ptr, i)); if (XIMaskIsSet(ptr, i)) @@ -392,8 +390,8 @@ static void test_values_XIDeviceEvent(DeviceEvent *in, xXIDeviceEvent *out, } - g_assert(vi.integral == vo.integral); - g_assert(vi.frac == vo.frac); + assert(vi.integral == vo.integral); + assert(vi.frac == vo.frac); values++; } } @@ -406,7 +404,7 @@ static void test_XIDeviceEvent(DeviceEvent *in) int rc; rc = EventToXI2((InternalEvent*)in, (xEvent**)&out); - g_assert(rc == Success); + assert(rc == Success); test_values_XIDeviceEvent(in, out, FALSE); @@ -425,7 +423,7 @@ static void test_convert_XIDeviceEvent(void) memset(&in, 0, sizeof(in)); - g_test_message("Testing simple field values"); + printf("Testing simple field values\n"); in.header = ET_Internal; in.type = ET_Motion; in.length = sizeof(DeviceEvent); @@ -449,7 +447,7 @@ static void test_convert_XIDeviceEvent(void) test_XIDeviceEvent(&in); - g_test_message("Testing field ranges"); + printf("Testing field ranges\n"); /* 32 bit */ in.detail.button = 1L; test_XIDeviceEvent(&in); @@ -597,7 +595,7 @@ static void test_convert_XIDeviceEvent(void) in.mods.effective = ~0 & 0xFF; test_XIDeviceEvent(&in); - g_test_message("Testing button masks"); + printf("Testing button masks\n"); for (i = 0; i < sizeof(in.buttons) * 8; i++) { XISetMask(in.buttons, i); @@ -611,7 +609,7 @@ static void test_convert_XIDeviceEvent(void) test_XIDeviceEvent(&in); } - g_test_message("Testing valuator masks"); + printf("Testing valuator masks\n"); for (i = 0; i < sizeof(in.valuators.mask) * 8; i++) { XISetMask(in.valuators.mask, i); @@ -656,12 +654,12 @@ static void test_values_XIDeviceChangedEvent(DeviceChangedEvent *in, swaps(&out->num_classes, n); } - g_assert(out->type == GenericEvent); - g_assert(out->extension == 0); /* IReqCode defaults to 0 */ - g_assert(out->evtype == GetXI2Type((InternalEvent*)in)); - g_assert(out->time == in->time); - g_assert(out->deviceid == in->deviceid); - g_assert(out->sourceid == in->sourceid); + assert(out->type == GenericEvent); + assert(out->extension == 0); /* IReqCode defaults to 0 */ + assert(out->evtype == GetXI2Type((InternalEvent*)in)); + assert(out->time == in->time); + assert(out->deviceid == in->deviceid); + assert(out->sourceid == in->sourceid); ptr = (unsigned char*)&out[1]; for (i = 0; i < out->num_classes; i++) @@ -689,11 +687,11 @@ static void test_values_XIDeviceChangedEvent(DeviceChangedEvent *in, swaps(&b->num_buttons, n); } - g_assert(b->length == + assert(b->length == bytes_to_int32(sizeof(xXIButtonInfo)) + bytes_to_int32(bits_to_bytes(b->num_buttons)) + b->num_buttons); - g_assert(b->num_buttons == in->buttons.num_buttons); + assert(b->num_buttons == in->buttons.num_buttons); names = (Atom*)((char*)&b[1] + pad_to_int32(bits_to_bytes(b->num_buttons))); @@ -704,7 +702,7 @@ static void test_values_XIDeviceChangedEvent(DeviceChangedEvent *in, char n; swapl(&names[j], n); } - g_assert(names[j] == in->buttons.names[j]); + assert(names[j] == in->buttons.names[j]); } } break; @@ -719,10 +717,10 @@ static void test_values_XIDeviceChangedEvent(DeviceChangedEvent *in, swaps(&k->num_keycodes, n); } - g_assert(k->length == + assert(k->length == bytes_to_int32(sizeof(xXIKeyInfo)) + k->num_keycodes); - g_assert(k->num_keycodes == in->keys.max_keycode - + assert(k->num_keycodes == in->keys.max_keycode - in->keys.min_keycode + 1); kc = (uint32_t*)&k[1]; @@ -733,21 +731,22 @@ static void test_values_XIDeviceChangedEvent(DeviceChangedEvent *in, char n; swapl(&kc[j], n); } - g_assert(kc[j] >= in->keys.min_keycode); - g_assert(kc[j] <= in->keys.max_keycode); + assert(kc[j] >= in->keys.min_keycode); + assert(kc[j] <= in->keys.max_keycode); } } break; case XIValuatorClass: { xXIValuatorInfo *v = (xXIValuatorInfo*)any; - g_assert(v->length == + assert(v->length == bytes_to_int32(sizeof(xXIValuatorInfo))); } break; default: - g_error("Invalid class type.\n"); + printf("Invalid class type.\n\n"); + assert(1); break; } @@ -762,7 +761,7 @@ static void test_XIDeviceChangedEvent(DeviceChangedEvent *in) int rc; rc = EventToXI2((InternalEvent*)in, (xEvent**)&out); - g_assert(rc == Success); + assert(rc == Success); test_values_XIDeviceChangedEvent(in, out, FALSE); @@ -779,7 +778,7 @@ static void test_convert_XIDeviceChangedEvent(void) DeviceChangedEvent in; int i; - g_test_message("Testing simple field values"); + printf("Testing simple field values\n"); memset(&in, 0, sizeof(in)); in.header = ET_Internal; in.type = ET_DeviceChanged; @@ -905,13 +904,10 @@ static void test_convert_XIDeviceChangedEvent(void) int main(int argc, char** argv) { - g_test_init(&argc, &argv,NULL); - g_test_bug_base("https://bugzilla.freedesktop.org/show_bug.cgi?id="); - - g_test_add_func("/xi2/eventconvert/XIRawEvent", test_convert_XIRawEvent); - g_test_add_func("/xi2/eventconvert/XIFocusEvent", test_convert_XIFocusEvent); - g_test_add_func("/xi2/eventconvert/XIDeviceEvent", test_convert_XIDeviceEvent); - g_test_add_func("/xi2/eventconvert/XIDeviceChangedEvent", test_convert_XIDeviceChangedEvent); + test_convert_XIRawEvent(); + test_convert_XIFocusEvent(); + test_convert_XIDeviceEvent(); + test_convert_XIDeviceChangedEvent(); - return g_test_run(); + return 0; } diff --git a/xorg-server/test/xi2/protocol-xigetclientpointer.c b/xorg-server/test/xi2/protocol-xigetclientpointer.c index 6b4d04957..5e45e7b32 100644 --- a/xorg-server/test/xi2/protocol-xigetclientpointer.c +++ b/xorg-server/test/xi2/protocol-xigetclientpointer.c @@ -39,7 +39,6 @@ #include "exevents.h" #include "protocol-common.h" -#include struct { int cp_is_set; @@ -79,9 +78,9 @@ static void reply_XIGetClientPointer(ClientPtr client, int len, char *data, void reply_check_defaults(rep, len, XIGetClientPointer); - g_assert(rep->set == test_data.cp_is_set); + assert(rep->set == test_data.cp_is_set); if (rep->set) - g_assert(rep->deviceid == test_data.dev->id); + assert(rep->deviceid == test_data.dev->id); } static void request_XIGetClientPointer(ClientPtr client, xXIGetClientPointerReq* req, int error) @@ -92,19 +91,19 @@ static void request_XIGetClientPointer(ClientPtr client, xXIGetClientPointerReq* test_data.win = req->win; rc = ProcXIGetClientPointer(&client_request); - g_assert(rc == error); + assert(rc == error); if (rc == BadWindow) - g_assert(client_request.errorValue == req->win); + assert(client_request.errorValue == req->win); client_request.swapped = TRUE; swapl(&req->win, n); swaps(&req->length, n); rc = SProcXIGetClientPointer(&client_request); - g_assert(rc == error); + assert(rc == error); if (rc == BadWindow) - g_assert(client_request.errorValue == req->win); + assert(client_request.errorValue == req->win); } @@ -121,21 +120,21 @@ static void test_XIGetClientPointer(void) client_request = init_client(request.length, &request); - g_test_message("Testing invalid window"); + printf("Testing invalid window\n"); request.win = INVALID_WINDOW_ID; request_XIGetClientPointer(&client_request, &request, BadWindow); test_data.cp_is_set = FALSE; - g_test_message("Testing window None, unset ClientPointer."); + printf("Testing window None, unset ClientPointer.\n"); request.win = None; request_XIGetClientPointer(&client_request, &request, Success); - g_test_message("Testing valid window, unset ClientPointer."); + printf("Testing valid window, unset ClientPointer.\n"); request.win = CLIENT_WINDOW_ID; request_XIGetClientPointer(&client_request, &request, Success); - g_test_message("Testing valid window, set ClientPointer."); + printf("Testing valid window, set ClientPointer.\n"); client_window.clientPtr = devices.vcp; test_data.dev = devices.vcp; test_data.cp_is_set = TRUE; @@ -144,7 +143,7 @@ static void test_XIGetClientPointer(void) client_window.clientPtr = NULL; - g_test_message("Testing window None, set ClientPointer."); + printf("Testing window None, set ClientPointer.\n"); client_request.clientPtr = devices.vcp; test_data.dev = devices.vcp; test_data.cp_is_set = TRUE; @@ -154,14 +153,10 @@ static void test_XIGetClientPointer(void) int main(int argc, char** argv) { - g_test_init(&argc, &argv,NULL); - g_test_bug_base("https://bugzilla.freedesktop.org/show_bug.cgi?id="); - init_simple(); client_window = init_client(0, NULL); + test_XIGetClientPointer(); - g_test_add_func("/xi2/protocol/XIGetClientPointer", test_XIGetClientPointer); - - return g_test_run(); + return 0; } diff --git a/xorg-server/test/xi2/protocol-xigetselectedevents.c b/xorg-server/test/xi2/protocol-xigetselectedevents.c index 97aae159f..55de77356 100644 --- a/xorg-server/test/xi2/protocol-xigetselectedevents.c +++ b/xorg-server/test/xi2/protocol-xigetselectedevents.c @@ -48,7 +48,6 @@ #include "exevents.h" #include "protocol-common.h" -#include static void reply_XIGetSelectedEvents(ClientPtr client, int len, char *data, void *userdata); static void reply_XIGetSelectedEvents_data(ClientPtr client, int len, char *data, void *userdata); @@ -100,7 +99,7 @@ static void reply_XIGetSelectedEvents(ClientPtr client, int len, char *data, voi reply_check_defaults(rep, len, XIGetSelectedEvents); - g_assert(rep->num_masks == test_data.num_masks_expected); + assert(rep->num_masks == test_data.num_masks_expected); reply_handler = reply_XIGetSelectedEvents_data; } @@ -121,11 +120,11 @@ static void reply_XIGetSelectedEvents_data(ClientPtr client, int len, char *data swaps(&mask->mask_len, n); } - g_assert(mask->deviceid < 6); - g_assert(mask->mask_len <= (((XI2LASTEVENT + 8)/8) + 3)/4) ; + assert(mask->deviceid < 6); + assert(mask->mask_len <= (((XI2LASTEVENT + 8)/8) + 3)/4) ; bitmask = (unsigned char*)&mask[1]; - g_assert(memcmp(bitmask, + assert(memcmp(bitmask, test_data.mask[mask->deviceid], mask->mask_len * 4) == 0); @@ -145,14 +144,14 @@ static void request_XIGetSelectedEvents(xXIGetSelectedEventsReq* req, int error) reply_handler = reply_XIGetSelectedEvents; rc = ProcXIGetSelectedEvents(&client); - g_assert(rc == error); + assert(rc == error); reply_handler = reply_XIGetSelectedEvents; client.swapped = TRUE; swapl(&req->win, n); swaps(&req->length, n); rc = SProcXIGetSelectedEvents(&client); - g_assert(rc == error); + assert(rc == error); } static void test_XIGetSelectedEvents(void) @@ -165,11 +164,11 @@ static void test_XIGetSelectedEvents(void) request_init(&request, XIGetSelectedEvents); - g_test_message("Testing for BadWindow on invalid window."); + printf("Testing for BadWindow on invalid window.\n"); request.win = None; request_XIGetSelectedEvents(&request, BadWindow); - g_test_message("Testing for zero-length (unset) masks."); + printf("Testing for zero-length (unset) masks.\n"); /* No masks set yet */ test_data.num_masks_expected = 0; request.win = ROOT_WINDOW_ID; @@ -181,7 +180,7 @@ static void test_XIGetSelectedEvents(void) memset(test_data.mask, 0, sizeof(test_data.mask)); - g_test_message("Testing for valid masks"); + printf("Testing for valid masks\n"); memset(&dev, 0, sizeof(dev)); /* dev->id is enough for XISetEventMask */ request.win = ROOT_WINDOW_ID; @@ -210,7 +209,7 @@ static void test_XIGetSelectedEvents(void) } } - g_test_message("Testing removing all masks"); + printf("Testing removing all masks\n"); /* Unset all masks one-by-one */ for (j = MAXDEVICES - 1; j >= 0; j--) { @@ -229,13 +228,10 @@ static void test_XIGetSelectedEvents(void) int main(int argc, char** argv) { - g_test_init(&argc, &argv,NULL); - g_test_bug_base("https://bugzilla.freedesktop.org/show_bug.cgi?id="); - init_simple(); - g_test_add_func("/xi2/protocol/XIGetSelectedEvents", test_XIGetSelectedEvents); + test_XIGetSelectedEvents(); - return g_test_run(); + return 0; } diff --git a/xorg-server/test/xi2/protocol-xipassivegrabdevice.c b/xorg-server/test/xi2/protocol-xipassivegrabdevice.c new file mode 100644 index 000000000..a61c1549c --- /dev/null +++ b/xorg-server/test/xi2/protocol-xipassivegrabdevice.c @@ -0,0 +1,234 @@ +/** + * Copyright © 2011 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#ifdef HAVE_DIX_CONFIG_H +#include +#endif + +/* + * Protocol testing for XIPassiveGrab request. + */ +#include +#include +#include +#include +#include "inputstr.h" +#include "windowstr.h" +#include "scrnintstr.h" +#include "xipassivegrab.h" +#include "exevents.h" + +#include "protocol-common.h" + +static ClientRec client_request; +#define N_MODS 7 +static uint32_t modifiers[N_MODS] = {1, 2, 3, 4, 5, 6, 7}; + +struct test_data { + int num_modifiers; +} testdata; + +int __wrap_GrabButton(ClientPtr client, DeviceIntPtr dev, DeviceIntPtr modifier_device, + int button, GrabParameters *param, GrabType grabtype, + GrabMask *mask); +static void reply_XIPassiveGrabDevice_data(ClientPtr client, int len, char *data, void *userdata); + +int __wrap_dixLookupWindow(WindowPtr *win, XID id, ClientPtr client, Mask access) +{ + if (id == root.drawable.id) + { + *win = &root; + return Success; + } else if (id == window.drawable.id) + { + *win = &window; + return Success; + } + + return __real_dixLookupWindow(win, id, client, access); +} + +int __wrap_GrabButton(ClientPtr client, DeviceIntPtr dev, DeviceIntPtr modifier_device, + int button, GrabParameters *param, GrabType grabtype, + GrabMask *mask) +{ + /* Fail every odd modifier */ + if (param->modifiers % 2) + return BadAccess; + + return Success; +} + +static void reply_XIPassiveGrabDevice(ClientPtr client, int len, char *data, void *userdata) +{ + xXIPassiveGrabDeviceReply *rep = (xXIPassiveGrabDeviceReply*)data; + + if (client->swapped) + { + char n; + swaps(&rep->sequenceNumber, n); + swapl(&rep->length, n); + swaps(&rep->num_modifiers, n); + + testdata.num_modifiers = rep->num_modifiers; + } + + reply_check_defaults(rep, len, XIPassiveGrabDevice); + + /* ProcXIPassiveGrabDevice sends the data in two batches, let the second + * handler handle the modifier data */ + if (rep->num_modifiers > 0) + reply_handler = reply_XIPassiveGrabDevice_data; +} + +static void reply_XIPassiveGrabDevice_data(ClientPtr client, int len, char *data, void *userdata) +{ + int i; + int n; + + xXIGrabModifierInfo *mods = (xXIGrabModifierInfo*)data; + + for (i = 0; i < testdata.num_modifiers; i++, mods++) + { + if (client->swapped) + swapl(&mods->modifiers, n); + + /* 1 - 7 is the range we use for the global modifiers array + * above */ + assert(mods->modifiers > 0); + assert(mods->modifiers <= 7); + assert(mods->modifiers % 2 == 1); /* because we fail odd ones */ + assert(mods->status != Success); + assert(mods->pad0 == 0); + assert(mods->pad1 == 0); + } + + reply_handler = reply_XIPassiveGrabDevice; +} + +static void request_XIPassiveGrabDevice(ClientPtr client, xXIPassiveGrabDeviceReq* req, int error, int errval) +{ + char n; + int rc; + int modifiers; + + rc = ProcXIPassiveGrabDevice(&client_request); + assert(rc == error); + + if (rc != Success) + assert(client_request.errorValue == errval); + + client_request.swapped = TRUE; + swaps(&req->length, n); + swapl(&req->time, n); + swapl(&req->grab_window, n); + swapl(&req->cursor, n); + swapl(&req->detail, n); + swaps(&req->deviceid, n); + modifiers = req->num_modifiers; + swaps(&req->num_modifiers, n); + swaps(&req->mask_len, n); + + while(modifiers--) + { + CARD32 *mod = ((CARD32*)(req + 1)) + modifiers; + swapl(mod, n); + } + + rc = SProcXIPassiveGrabDevice(&client_request); + assert(rc == error); + + if (rc != Success) + assert(client_request.errorValue == errval); +} + +static unsigned char *data[4096]; /* the request buffer */ +static void test_XIPassiveGrabDevice(void) +{ + int i; + xXIPassiveGrabDeviceReq *request = (xXIPassiveGrabDeviceReq*)data; + unsigned char *mask; + + request_init(request, XIPassiveGrabDevice); + + request->grab_window = CLIENT_WINDOW_ID; + + reply_handler = reply_XIPassiveGrabDevice; + client_request = init_client(request->length, request); + + printf("Testing invalid device\n"); + request->deviceid = 12; + request_XIPassiveGrabDevice(&client_request, request, BadDevice, request->deviceid); + + request->deviceid = XIAllMasterDevices; + + printf("Testing invalid grab types\n"); + for (i = XIGrabtypeFocusIn + 1; i < 0xFF; i++) + { + request->grab_type = i; + request_XIPassiveGrabDevice(&client_request, request, BadValue, request->grab_type); + } + + printf("Testing invalid grab type + detail combinations\n"); + request->grab_type = XIGrabtypeEnter; + request->detail = 1; + request_XIPassiveGrabDevice(&client_request, request, BadValue, request->detail); + + request->grab_type = XIGrabtypeFocusIn; + request_XIPassiveGrabDevice(&client_request, request, BadValue, request->detail); + + request->detail = 0; + + printf("Testing invalid masks\n"); + mask = (unsigned char*)&request[1]; + + request->mask_len = bytes_to_int32(XI2LASTEVENT + 1); + request->length += request->mask_len; + SetBit(mask, XI2LASTEVENT + 1); + request_XIPassiveGrabDevice(&client_request, request, BadValue, XI2LASTEVENT + 1); + + ClearBit(mask, XI2LASTEVENT + 1); + + /* tested all special cases now, test a few valid cases */ + + /* no modifiers */ + request->deviceid = XIAllDevices; + request->grab_type = XIGrabtypeButton; + request->detail = XIAnyButton; + request_XIPassiveGrabDevice(&client_request, request, Success, 0); + + /* some modifiers */ + request->num_modifiers = N_MODS; + request->length += N_MODS; + memcpy((uint32_t*)(request + 1) + request->mask_len, modifiers, sizeof(modifiers)); + request_XIPassiveGrabDevice(&client_request, request, Success, 0); +} + +int main(int argc, char** argv) +{ + init_simple(); + + test_XIPassiveGrabDevice(); + + return 0; +} diff --git a/xorg-server/test/xi2/protocol-xiquerydevice.c b/xorg-server/test/xi2/protocol-xiquerydevice.c index 508fc4dfb..cb1cc8130 100644 --- a/xorg-server/test/xi2/protocol-xiquerydevice.c +++ b/xorg-server/test/xi2/protocol-xiquerydevice.c @@ -38,7 +38,6 @@ #include "xiquerydevice.h" #include "protocol-common.h" -#include /* * Protocol testing for XIQueryDevice request and reply. * @@ -74,11 +73,11 @@ static void reply_XIQueryDevice(ClientPtr client, int len, char* data, void *use reply_check_defaults(rep, len, XIQueryDevice); if (querydata->which_device == XIAllDevices) - g_assert(rep->num_devices == devices.num_devices); + assert(rep->num_devices == devices.num_devices); else if (querydata->which_device == XIAllMasterDevices) - g_assert(rep->num_devices == devices.num_master_devices); + assert(rep->num_devices == devices.num_master_devices); else - g_assert(rep->num_devices == 1); + assert(rep->num_devices == 1); querydata->num_devices_in_reply = rep->num_devices; reply_handler = reply_XIQueryDevice_data; @@ -107,46 +106,46 @@ static void reply_XIQueryDevice_data(ClientPtr client, int len, char *data, void } if (querydata->which_device > XIAllMasterDevices) - g_assert(info->deviceid == querydata->which_device); + assert(info->deviceid == querydata->which_device); - g_assert(info->deviceid >= 2); /* 0 and 1 is reserved */ + assert(info->deviceid >= 2); /* 0 and 1 is reserved */ switch(info->deviceid) { case 2: /* VCP */ dev = devices.vcp; - g_assert(info->use == XIMasterPointer); - g_assert(info->attachment == devices.vck->id); - g_assert(info->num_classes == 3); /* 2 axes + button */ + assert(info->use == XIMasterPointer); + assert(info->attachment == devices.vck->id); + assert(info->num_classes == 3); /* 2 axes + button */ break; case 3: /* VCK */ dev = devices.vck; - g_assert(info->use == XIMasterKeyboard); - g_assert(info->attachment == devices.vcp->id); - g_assert(info->num_classes == 1); + assert(info->use == XIMasterKeyboard); + assert(info->attachment == devices.vcp->id); + assert(info->num_classes == 1); break; case 4: /* mouse */ dev = devices.mouse; - g_assert(info->use == XISlavePointer); - g_assert(info->attachment == devices.vcp->id); - g_assert(info->num_classes == 3); /* 2 axes + button */ + assert(info->use == XISlavePointer); + assert(info->attachment == devices.vcp->id); + assert(info->num_classes == 3); /* 2 axes + button */ break; case 5: /* keyboard */ dev = devices.kbd; - g_assert(info->use == XISlaveKeyboard); - g_assert(info->attachment == devices.vck->id); - g_assert(info->num_classes == 1); + assert(info->use == XISlaveKeyboard); + assert(info->attachment == devices.vck->id); + assert(info->num_classes == 1); break; default: /* We shouldn't get here */ - g_assert(0); + assert(0); break; } - g_assert(info->enabled == dev->enabled); - g_assert(info->name_len == strlen(dev->name)); - g_assert(strncmp((char*)&info[1], dev->name, info->name_len) == 0); + assert(info->enabled == dev->enabled); + assert(info->name_len == strlen(dev->name)); + assert(strncmp((char*)&info[1], dev->name, info->name_len) == 0); any = (xXIAnyInfo*)((char*)&info[1] + ((info->name_len + 3)/4) * 4); for (j = 0; j < info->num_classes; j++) @@ -171,9 +170,9 @@ static void reply_XIQueryDevice_data(ClientPtr client, int len, char *data, void if (client->swapped) swaps(&ki->num_keycodes, n); - g_assert(any->type == XIKeyClass); - g_assert(ki->num_keycodes == (xkb->max_key_code - xkb->min_key_code + 1)); - g_assert(any->length == (2 + ki->num_keycodes)); + assert(any->type == XIKeyClass); + assert(ki->num_keycodes == (xkb->max_key_code - xkb->min_key_code + 1)); + assert(any->length == (2 + ki->num_keycodes)); kc = (uint32_t*)&ki[1]; for (k = 0; k < ki->num_keycodes; k++, kc++) @@ -181,15 +180,15 @@ static void reply_XIQueryDevice_data(ClientPtr client, int len, char *data, void if (client->swapped) swapl(kc, n); - g_assert(*kc >= xkb->min_key_code); - g_assert(*kc <= xkb->max_key_code); + assert(*kc >= xkb->min_key_code); + assert(*kc <= xkb->max_key_code); } break; } case 2: /* VCP and mouse have the same properties */ case 4: { - g_assert(any->type == XIButtonClass || + assert(any->type == XIButtonClass || any->type == XIValuatorClass); if (any->type == XIButtonClass) @@ -200,10 +199,10 @@ static void reply_XIQueryDevice_data(ClientPtr client, int len, char *data, void if (client->swapped) swaps(&bi->num_buttons, n); - g_assert(bi->num_buttons == devices.vcp->button->numButtons); + assert(bi->num_buttons == devices.vcp->button->numButtons); len = 2 + bi->num_buttons + bytes_to_int32(bits_to_bytes(bi->num_buttons)); - g_assert(bi->length == len); + assert(bi->length == len); } else if (any->type == XIValuatorClass) { xXIValuatorInfo *vi = (xXIValuatorInfo*)any; @@ -219,17 +218,17 @@ static void reply_XIQueryDevice_data(ClientPtr client, int len, char *data, void swapl(&vi->resolution, n); } - g_assert(vi->length == 11); - g_assert(vi->number == 0 || + assert(vi->length == 11); + assert(vi->number == 0 || vi->number == 1); - g_assert(vi->mode == XIModeRelative); + assert(vi->mode == XIModeRelative); /* device was set up as relative, so standard * values here. */ - g_assert(vi->min.integral == -1); - g_assert(vi->min.frac == 0); - g_assert(vi->max.integral == -1); - g_assert(vi->max.frac == 0); - g_assert(vi->resolution == 0); + assert(vi->min.integral == -1); + assert(vi->min.frac == 0); + assert(vi->max.integral == -1); + assert(vi->max.frac == 0); + assert(vi->resolution == 0); } } break; @@ -257,10 +256,10 @@ static void request_XIQueryDevice(struct test_data *querydata, request.deviceid = deviceid; rc = ProcXIQueryDevice(&client); - g_assert(rc == error); + assert(rc == error); if (rc != Success) - g_assert(client.errorValue == deviceid); + assert(client.errorValue == deviceid); reply_handler = reply_XIQueryDevice; @@ -268,10 +267,10 @@ static void request_XIQueryDevice(struct test_data *querydata, swaps(&request.length, n); swaps(&request.deviceid, n); rc = SProcXIQueryDevice(&client); - g_assert(rc == error); + assert(rc == error); if (rc != Success) - g_assert(client.errorValue == deviceid); + assert(client.errorValue == deviceid); } static void test_XIQueryDevice(void) @@ -284,16 +283,16 @@ static void test_XIQueryDevice(void) userdata = &data; request_init(&request, XIQueryDevice); - g_test_message("Testing XIAllDevices."); + printf("Testing XIAllDevices.\n"); request_XIQueryDevice(&data, XIAllDevices, Success); - g_test_message("Testing XIAllMasterDevices."); + printf("Testing XIAllMasterDevices.\n"); request_XIQueryDevice(&data, XIAllMasterDevices, Success); - g_test_message("Testing existing device ids."); + printf("Testing existing device ids.\n"); for (i = 2; i < 6; i++) request_XIQueryDevice(&data, i, Success); - g_test_message("Testing non-existing device ids."); + printf("Testing non-existing device ids.\n"); for (i = 6; i <= 0xFFFF; i++) request_XIQueryDevice(&data, i, BadDevice); @@ -304,13 +303,10 @@ static void test_XIQueryDevice(void) int main(int argc, char** argv) { - g_test_init(&argc, &argv,NULL); - g_test_bug_base("https://bugzilla.freedesktop.org/show_bug.cgi?id="); - init_simple(); - g_test_add_func("/dix/xi2protocol/XIQueryDevice", test_XIQueryDevice); + test_XIQueryDevice(); - return g_test_run(); + return 0; } diff --git a/xorg-server/test/xi2/protocol-xiquerypointer.c b/xorg-server/test/xi2/protocol-xiquerypointer.c index a42d59515..0985ec70d 100644 --- a/xorg-server/test/xi2/protocol-xiquerypointer.c +++ b/xorg-server/test/xi2/protocol-xiquerypointer.c @@ -39,7 +39,6 @@ #include "exevents.h" #include "protocol-common.h" -#include static ClientRec client_request; static void reply_XIQueryPointer_data(ClientPtr client, int len, @@ -96,18 +95,18 @@ static void reply_XIQueryPointer(ClientPtr client, int len, char *data, reply_check_defaults(rep, len, XIQueryPointer); - g_assert(rep->root == root.drawable.id); - g_assert(rep->same_screen == xTrue); + assert(rep->root == root.drawable.id); + assert(rep->same_screen == xTrue); sprite = test_data.dev->spriteInfo->sprite; - g_assert((rep->root_x >> 16) == sprite->hot.x); - g_assert((rep->root_y >> 16) == sprite->hot.y); + assert((rep->root_x >> 16) == sprite->hot.x); + assert((rep->root_y >> 16) == sprite->hot.y); if (test_data.win == &root) { - g_assert(rep->root_x == rep->win_x); - g_assert(rep->root_y == rep->win_y); - g_assert(rep->child == window.drawable.id); + assert(rep->root_x == rep->win_x); + assert(rep->root_y == rep->win_y); + assert(rep->child == window.drawable.id); } else { int x, y; @@ -115,13 +114,13 @@ static void reply_XIQueryPointer(ClientPtr client, int len, char *data, x = sprite->hot.x - window.drawable.x; y = sprite->hot.y - window.drawable.y; - g_assert((rep->win_x >> 16) == x); - g_assert((rep->win_y >> 16) == y); - g_assert(rep->child == None); + assert((rep->win_x >> 16) == x); + assert((rep->win_y >> 16) == y); + assert(rep->child == None); } - g_assert(rep->same_screen == xTrue); + assert(rep->same_screen == xTrue); reply_handler = reply_XIQueryPointer_data; } @@ -137,19 +136,19 @@ static void request_XIQueryPointer(ClientPtr client, xXIQueryPointerReq* req, in int rc; rc = ProcXIQueryPointer(&client_request); - g_assert(rc == error); + assert(rc == error); if (rc == BadDevice) - g_assert(client_request.errorValue == req->deviceid); + assert(client_request.errorValue == req->deviceid); client_request.swapped = TRUE; swaps(&req->deviceid, n); swaps(&req->length, n); rc = SProcXIQueryPointer(&client_request); - g_assert(rc == error); + assert(rc == error); if (rc == BadDevice) - g_assert(client_request.errorValue == req->deviceid); + assert(client_request.errorValue == req->deviceid); } static void test_XIQueryPointer(void) @@ -209,12 +208,9 @@ static void test_XIQueryPointer(void) int main(int argc, char** argv) { - g_test_init(&argc, &argv,NULL); - g_test_bug_base("https://bugzilla.freedesktop.org/show_bug.cgi?id="); - init_simple(); - g_test_add_func("/xi2/protocol/XIQueryPointer", test_XIQueryPointer); + test_XIQueryPointer(); - return g_test_run(); + return 0; } diff --git a/xorg-server/test/xi2/protocol-xiqueryversion.c b/xorg-server/test/xi2/protocol-xiqueryversion.c index 46e62acbd..3bb356e7f 100644 --- a/xorg-server/test/xi2/protocol-xiqueryversion.c +++ b/xorg-server/test/xi2/protocol-xiqueryversion.c @@ -46,7 +46,6 @@ #include "xiqueryversion.h" #include "protocol-common.h" -#include extern XExtensionVersion XIVersion; @@ -74,14 +73,14 @@ static void reply_XIQueryVersion(ClientPtr client, int len, char* data, void *us reply_check_defaults(rep, len, XIQueryVersion); - g_assert(rep->length == 0); + assert(rep->length == 0); sver = versions->major_server * 1000 + versions->minor_server; cver = versions->major_client * 1000 + versions->minor_client; ver = rep->major_version * 1000 + rep->minor_version; - g_assert(ver >= 2000); - g_assert((sver > cver) ? ver == cver : ver == sver); + assert(ver >= 2000); + assert((sver > cver) ? ver == cver : ver == sver); } /** @@ -115,7 +114,7 @@ static void request_XIQueryVersion(int smaj, int smin, int cmaj, int cmin, int e request.major_version = versions.major_client; request.minor_version = versions.minor_client; rc = ProcXIQueryVersion(&client); - g_assert(rc == error); + assert(rc == error); client.swapped = TRUE; @@ -124,7 +123,7 @@ static void request_XIQueryVersion(int smaj, int smin, int cmaj, int cmin, int e swaps(&request.minor_version, n); rc = SProcXIQueryVersion(&client); - g_assert(rc == error); + assert(rc == error); } /* Client version less than 2.0 must return BadValue, all other combinations @@ -133,23 +132,23 @@ static void test_XIQueryVersion(void) { reply_handler = reply_XIQueryVersion; - g_test_message("Server version 2.0 - client versions [1..3].0"); + printf("Server version 2.0 - client versions [1..3].0\n"); /* some simple tests to catch common errors quickly */ request_XIQueryVersion(2, 0, 1, 0, BadValue); request_XIQueryVersion(2, 0, 2, 0, Success); request_XIQueryVersion(2, 0, 3, 0, Success); - g_test_message("Server version 3.0 - client versions [1..3].0"); + printf("Server version 3.0 - client versions [1..3].0\n"); request_XIQueryVersion(3, 0, 1, 0, BadValue); request_XIQueryVersion(3, 0, 2, 0, Success); request_XIQueryVersion(3, 0, 3, 0, Success); - g_test_message("Server version 2.0 - client versions [1..3].[1..3]"); + printf("Server version 2.0 - client versions [1..3].[1..3]\n"); request_XIQueryVersion(2, 0, 1, 1, BadValue); request_XIQueryVersion(2, 0, 2, 2, Success); request_XIQueryVersion(2, 0, 3, 3, Success); - g_test_message("Server version 2.2 - client versions [1..3].0"); + printf("Server version 2.2 - client versions [1..3].0\n"); request_XIQueryVersion(2, 2, 1, 0, BadValue); request_XIQueryVersion(2, 2, 2, 0, Success); request_XIQueryVersion(2, 2, 3, 0, Success); @@ -158,7 +157,7 @@ static void test_XIQueryVersion(void) /* this one takes a while */ unsigned int cmin, cmaj, smin, smaj; - g_test_message("Testing all combinations."); + printf("Testing all combinations.\n"); for (smaj = 2; smaj <= 0xFFFF; smaj++) for (smin = 0; smin <= 0xFFFF; smin++) for (cmin = 0; cmin <= 0xFFFF; cmin++) @@ -175,12 +174,9 @@ static void test_XIQueryVersion(void) int main(int argc, char** argv) { - g_test_init(&argc, &argv,NULL); - g_test_bug_base("https://bugzilla.freedesktop.org/show_bug.cgi?id="); - init_simple(); - g_test_add_func("/xi2/protocol/XIQueryVersion", test_XIQueryVersion); + test_XIQueryVersion(); - return g_test_run(); + return 0; } diff --git a/xorg-server/test/xi2/protocol-xiselectevents.c b/xorg-server/test/xi2/protocol-xiselectevents.c index f951a14fe..fa422e2cb 100644 --- a/xorg-server/test/xi2/protocol-xiselectevents.c +++ b/xorg-server/test/xi2/protocol-xiselectevents.c @@ -58,7 +58,6 @@ #include "xiselectev.h" #include "protocol-common.h" -#include static unsigned char *data[4096 * 20]; /* the request data buffer */ @@ -107,7 +106,7 @@ static void request_XISelectEvent(xXISelectEventsReq *req, int error) client = init_client(req->length, req); rc = ProcXISelectEvents(&client); - g_assert(rc == error); + assert(rc == error); client.swapped = TRUE; @@ -124,7 +123,7 @@ static void request_XISelectEvent(xXISelectEventsReq *req, int error) swaps(&req->length, n); swaps(&req->num_masks, n); rc = SProcXISelectEvents(&client); - g_assert(rc == error); + assert(rc == error); } static void request_XISelectEvents_masks(xXISelectEventsReq *req) @@ -250,7 +249,7 @@ static void test_XISelectEvents(void) request_init(req, XISelectEvents); - g_test_message("Testing for BadValue on zero-length masks"); + printf("Testing for BadValue on zero-length masks\n"); /* zero masks are BadValue, regardless of the window */ req->num_masks = 0; @@ -263,7 +262,7 @@ static void test_XISelectEvents(void) req->win = CLIENT_WINDOW_ID; request_XISelectEvent(req, BadValue); - g_test_message("Testing for BadWindow."); + printf("Testing for BadWindow.\n"); /* None window is BadWindow, regardless of the masks. * We don't actually need to set the masks here, BadWindow must occur * before checking the masks. @@ -283,7 +282,7 @@ static void test_XISelectEvents(void) req->num_masks = 0xFFFC; request_XISelectEvent(req, BadWindow); - g_test_message("Triggering num_masks/length overflow"); + printf("Triggering num_masks/length overflow\n"); req->win = ROOT_WINDOW_ID; /* Integer overflow - req->length can't hold that much */ req->num_masks = 0xFFFF; @@ -292,14 +291,14 @@ static void test_XISelectEvents(void) req->win = ROOT_WINDOW_ID; req->num_masks = 1; - g_test_message("Triggering bogus mask length error"); + printf("Triggering bogus mask length error\n"); mask = (xXIEventMask*)&req[1]; mask->deviceid = 0; mask->mask_len = 0xFFFF; request_XISelectEvent(req, BadLength); /* testing various device ids */ - g_test_message("Testing existing device ids."); + printf("Testing existing device ids.\n"); for (i = 0; i < 6; i++) { mask = (xXIEventMask*)&req[1]; @@ -310,7 +309,7 @@ static void test_XISelectEvents(void) request_XISelectEvent(req, Success); } - g_test_message("Testing non-existing device ids."); + printf("Testing non-existing device ids.\n"); for (i = 6; i <= 0xFFFF; i++) { req->win = ROOT_WINDOW_ID; @@ -326,13 +325,10 @@ static void test_XISelectEvents(void) int main(int argc, char** argv) { - g_test_init(&argc, &argv,NULL); - g_test_bug_base("https://bugzilla.freedesktop.org/show_bug.cgi?id="); - init_simple(); - g_test_add_func("/xi2/protocol/XISelectEvents", test_XISelectEvents); + test_XISelectEvents(); - return g_test_run(); + return 0; } diff --git a/xorg-server/test/xi2/protocol-xisetclientpointer.c b/xorg-server/test/xi2/protocol-xisetclientpointer.c index 2e638eea7..c266b6560 100644 --- a/xorg-server/test/xi2/protocol-xisetclientpointer.c +++ b/xorg-server/test/xi2/protocol-xisetclientpointer.c @@ -46,7 +46,6 @@ #include "exevents.h" #include "protocol-common.h" -#include static ClientRec client_window; static ClientRec client_request; @@ -72,20 +71,20 @@ static void request_XISetClientPointer(xXISetClientPointerReq* req, int error) client_request = init_client(req->length, req); rc = ProcXISetClientPointer(&client_request); - g_assert(rc == error); + assert(rc == error); if (rc == BadDevice) - g_assert(client_request.errorValue == req->deviceid); + assert(client_request.errorValue == req->deviceid); client_request.swapped = TRUE; swapl(&req->win, n); swaps(&req->length, n); swaps(&req->deviceid, n); rc = SProcXISetClientPointer(&client_request); - g_assert(rc == error); + assert(rc == error); if (rc == BadDevice) - g_assert(client_request.errorValue == req->deviceid); + assert(client_request.errorValue == req->deviceid); } @@ -98,36 +97,36 @@ static void test_XISetClientPointer(void) request.win = CLIENT_WINDOW_ID; - g_test_message("Testing BadDevice error for XIAllDevices and XIMasterDevices."); + printf("Testing BadDevice error for XIAllDevices and XIMasterDevices.\n"); request.deviceid = XIAllDevices; request_XISetClientPointer(&request, BadDevice); request.deviceid = XIAllMasterDevices; request_XISetClientPointer(&request, BadDevice); - g_test_message("Testing Success for VCP and VCK."); + printf("Testing Success for VCP and VCK.\n"); request.deviceid = devices.vcp->id; /* 2 */ request_XISetClientPointer(&request, Success); - g_assert(client_window.clientPtr->id == 2); + assert(client_window.clientPtr->id == 2); request.deviceid = devices.vck->id; /* 3 */ request_XISetClientPointer(&request, Success); - g_assert(client_window.clientPtr->id == 2); + assert(client_window.clientPtr->id == 2); - g_test_message("Testing BadDevice error for all other devices."); + printf("Testing BadDevice error for all other devices.\n"); for (i = 4; i <= 0xFFFF; i++) { request.deviceid = i; request_XISetClientPointer(&request, BadDevice); } - g_test_message("Testing window None"); + printf("Testing window None\n"); request.win = None; request.deviceid = devices.vcp->id; /* 2 */ request_XISetClientPointer(&request, Success); - g_assert(client_request.clientPtr->id == 2); + assert(client_request.clientPtr->id == 2); - g_test_message("Testing invalid window"); + printf("Testing invalid window\n"); request.win = INVALID_WINDOW_ID; request.deviceid = devices.vcp->id; request_XISetClientPointer(&request, BadWindow); @@ -137,13 +136,10 @@ static void test_XISetClientPointer(void) int main(int argc, char** argv) { - g_test_init(&argc, &argv,NULL); - g_test_bug_base("https://bugzilla.freedesktop.org/show_bug.cgi?id="); - init_simple(); client_window = init_client(0, NULL); - g_test_add_func("/xi2/protocol/XISetClientPointer", test_XISetClientPointer); + test_XISetClientPointer(); - return g_test_run(); + return 0; } diff --git a/xorg-server/test/xi2/protocol-xiwarppointer.c b/xorg-server/test/xi2/protocol-xiwarppointer.c index 75b7617a0..0c8db453d 100644 --- a/xorg-server/test/xi2/protocol-xiwarppointer.c +++ b/xorg-server/test/xi2/protocol-xiwarppointer.c @@ -39,7 +39,6 @@ #include "exevents.h" #include "protocol-common.h" -#include static int expected_x = SPRITE_X; static int expected_y = SPRITE_Y; @@ -70,8 +69,8 @@ int __wrap_dixLookupWindow(WindowPtr *win, XID id, ClientPtr client, Mask access static Bool ScreenSetCursorPosition(DeviceIntPtr dev, ScreenPtr screen, int x, int y, Bool generateEvent) { - g_assert(x == expected_x); - g_assert(y == expected_y); + assert(x == expected_x); + assert(y == expected_y); return TRUE; } @@ -83,12 +82,12 @@ static void request_XIWarpPointer(ClientPtr client, xXIWarpPointerReq* req, int rc; rc = ProcXIWarpPointer(client); - g_assert(rc == error); + assert(rc == error); if (rc == BadDevice) - g_assert(client->errorValue == req->deviceid); + assert(client->errorValue == req->deviceid); else if (rc == BadWindow) - g_assert(client->errorValue == req->dst_win || + assert(client->errorValue == req->dst_win || client->errorValue == req->src_win); @@ -105,12 +104,12 @@ static void request_XIWarpPointer(ClientPtr client, xXIWarpPointerReq* req, swaps(&req->deviceid, n); rc = SProcXIWarpPointer(client); - g_assert(rc == error); + assert(rc == error); if (rc == BadDevice) - g_assert(client->errorValue == req->deviceid); + assert(client->errorValue == req->deviceid); else if (rc == BadWindow) - g_assert(client->errorValue == req->dst_win || + assert(client->errorValue == req->dst_win || client->errorValue == req->src_win); client->swapped = FALSE; @@ -204,13 +203,10 @@ static void test_XIWarpPointer(void) int main(int argc, char** argv) { - g_test_init(&argc, &argv,NULL); - g_test_bug_base("https://bugzilla.freedesktop.org/show_bug.cgi?id="); - init_simple(); screen.SetCursorPosition = ScreenSetCursorPosition; - g_test_add_func("/xi2/protocol/XIWarpPointer", test_XIWarpPointer); + test_XIWarpPointer(); - return g_test_run(); + return 0; } -- cgit v1.2.3