diff options
author | marha <marha@users.sourceforge.net> | 2011-03-04 15:38:04 +0000 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2011-03-04 15:38:04 +0000 |
commit | 3592ad31cfc72ffff3c9024eecea7d3b987c7954 (patch) | |
tree | 0e3b50cb6bcd0839b591d318a41d04b7cbd8e6e2 /xorg-server/test | |
parent | 79409465b0b8d5d38e6b94deb1943316f40c66eb (diff) | |
parent | 0a5888393c68f6f7db86206d1f277232db18240b (diff) | |
download | vcxsrv-3592ad31cfc72ffff3c9024eecea7d3b987c7954.tar.gz vcxsrv-3592ad31cfc72ffff3c9024eecea7d3b987c7954.tar.bz2 vcxsrv-3592ad31cfc72ffff3c9024eecea7d3b987c7954.zip |
svn merge ^/branches/released .
Diffstat (limited to 'xorg-server/test')
-rw-r--r-- | xorg-server/test/input.c | 68 | ||||
-rw-r--r-- | xorg-server/test/xi2/protocol-xiquerypointer.c | 440 | ||||
-rw-r--r-- | xorg-server/test/xi2/protocol-xiwarppointer.c | 432 |
3 files changed, 475 insertions, 465 deletions
diff --git a/xorg-server/test/input.c b/xorg-server/test/input.c index 3e6619181..9a1ac632e 100644 --- a/xorg-server/test/input.c +++ b/xorg-server/test/input.c @@ -149,29 +149,32 @@ static void dix_check_grab_values(void) static void dix_event_to_core(int type)
{
DeviceEvent ev;
- xEvent core;
+ xEvent *core;
int time;
int x, y;
int rc;
int state;
int detail;
+ int count;
const int ROOT_WINDOW_ID = 0x100;
/* EventToCore memsets the event to 0 */
#define test_event() \
g_assert(rc == Success); \
- g_assert(core.u.u.type == type); \
- g_assert(core.u.u.detail == detail); \
- g_assert(core.u.keyButtonPointer.time == time); \
- g_assert(core.u.keyButtonPointer.rootX == x); \
- g_assert(core.u.keyButtonPointer.rootY == y); \
- g_assert(core.u.keyButtonPointer.state == state); \
- g_assert(core.u.keyButtonPointer.eventX == 0); \
- g_assert(core.u.keyButtonPointer.eventY == 0); \
- g_assert(core.u.keyButtonPointer.root == ROOT_WINDOW_ID); \
- g_assert(core.u.keyButtonPointer.event == 0); \
- g_assert(core.u.keyButtonPointer.child == 0); \
- g_assert(core.u.keyButtonPointer.sameScreen == FALSE);
+ g_assert(core); \
+ g_assert(count == 1); \
+ g_assert(core->u.u.type == type); \
+ g_assert(core->u.u.detail == detail); \
+ g_assert(core->u.keyButtonPointer.time == time); \
+ g_assert(core->u.keyButtonPointer.rootX == x); \
+ g_assert(core->u.keyButtonPointer.rootY == y); \
+ g_assert(core->u.keyButtonPointer.state == state); \
+ g_assert(core->u.keyButtonPointer.eventX == 0); \
+ g_assert(core->u.keyButtonPointer.eventY == 0); \
+ g_assert(core->u.keyButtonPointer.root == ROOT_WINDOW_ID); \
+ g_assert(core->u.keyButtonPointer.event == 0); \
+ g_assert(core->u.keyButtonPointer.child == 0); \
+ g_assert(core->u.keyButtonPointer.sameScreen == FALSE);
x = 0;
y = 0;
@@ -192,30 +195,33 @@ static void dix_event_to_core(int type) ev.type = type;
ev.detail.key = 0;
- rc = EventToCore((InternalEvent*)&ev, &core);
+ rc = EventToCore((InternalEvent*)&ev, &core, &count);
test_event();
x = 1;
y = 2;
ev.root_x = x;
ev.root_y = y;
- rc = EventToCore((InternalEvent*)&ev, &core);
+ rc = EventToCore((InternalEvent*)&ev, &core, &count);
test_event();
x = 0x7FFF;
y = 0x7FFF;
ev.root_x = x;
ev.root_y = y;
- rc = EventToCore((InternalEvent*)&ev, &core);
+ rc = EventToCore((InternalEvent*)&ev, &core, &count);
test_event();
x = 0x8000; /* too high */
y = 0x8000; /* too high */
ev.root_x = x;
ev.root_y = y;
- rc = EventToCore((InternalEvent*)&ev, &core);
- g_assert(core.u.keyButtonPointer.rootX != x);
- g_assert(core.u.keyButtonPointer.rootY != y);
+ rc = EventToCore((InternalEvent*)&ev, &core, &count);
+ g_assert(rc == Success);
+ g_assert(core);
+ g_assert(count == 1);
+ g_assert(core->u.keyButtonPointer.rootX != x);
+ g_assert(core->u.keyButtonPointer.rootY != y);
x = 0x7FFF;
y = 0x7FFF;
@@ -223,36 +229,39 @@ static void dix_event_to_core(int type) ev.root_y = y;
time = 0;
ev.time = time;
- rc = EventToCore((InternalEvent*)&ev, &core);
+ rc = EventToCore((InternalEvent*)&ev, &core, &count);
test_event();
detail = 1;
ev.detail.key = detail;
- rc = EventToCore((InternalEvent*)&ev, &core);
+ rc = EventToCore((InternalEvent*)&ev, &core, &count);
test_event();
detail = 0xFF; /* highest value */
ev.detail.key = detail;
- rc = EventToCore((InternalEvent*)&ev, &core);
+ rc = EventToCore((InternalEvent*)&ev, &core, &count);
test_event();
detail = 0xFFF; /* too big */
ev.detail.key = detail;
- rc = EventToCore((InternalEvent*)&ev, &core);
+ rc = EventToCore((InternalEvent*)&ev, &core, &count);
g_assert(rc == BadMatch);
detail = 0xFF; /* too big */
ev.detail.key = detail;
state = 0xFFFF; /* highest value */
ev.corestate = state;
- rc = EventToCore((InternalEvent*)&ev, &core);
+ rc = EventToCore((InternalEvent*)&ev, &core, &count);
test_event();
state = 0x10000; /* too big */
ev.corestate = state;
- rc = EventToCore((InternalEvent*)&ev, &core);
- g_assert(core.u.keyButtonPointer.state != state);
- g_assert(core.u.keyButtonPointer.state == (state & 0xFFFF));
+ rc = EventToCore((InternalEvent*)&ev, &core, &count);
+ g_assert(rc == Success);
+ g_assert(core);
+ g_assert(count == 1);
+ g_assert(core->u.keyButtonPointer.state != state);
+ g_assert(core->u.keyButtonPointer.state == (state & 0xFFFF));
#undef test_event
}
@@ -260,14 +269,15 @@ static void dix_event_to_core(int type) static void dix_event_to_core_fail(int evtype, int expected_rc)
{
DeviceEvent ev;
- xEvent core;
+ xEvent *core;
int rc;
+ int count;
ev.header = 0xFF;
ev.length = sizeof(DeviceEvent);
ev.type = evtype;
- rc = EventToCore((InternalEvent*)&ev, &core);
+ rc = EventToCore((InternalEvent*)&ev, &core, &count);
g_assert(rc == expected_rc);
}
diff --git a/xorg-server/test/xi2/protocol-xiquerypointer.c b/xorg-server/test/xi2/protocol-xiquerypointer.c index 810c61575..95c8b4bc1 100644 --- a/xorg-server/test/xi2/protocol-xiquerypointer.c +++ b/xorg-server/test/xi2/protocol-xiquerypointer.c @@ -1,220 +1,220 @@ -/** - * 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 <dix-config.h> -#endif - -/* - * Protocol testing for XIQueryPointer request. - */ -#include <stdint.h> -#include <X11/X.h> -#include <X11/Xproto.h> -#include <X11/extensions/XI2proto.h> -#include "inputstr.h" -#include "windowstr.h" -#include "scrnintstr.h" -#include "xiquerypointer.h" -#include "exevents.h" - -#include "protocol-common.h" -#include <glib.h> - -static ClientRec client_request; -static void reply_XIQueryPointer_data(ClientPtr client, int len, - char *data, void *userdata); - -static struct { - DeviceIntPtr dev; - WindowPtr win; -} test_data; - - -/* dixLookupWindow requires a lot of setup not necessary for this test. - * Simple wrapper that returns either one of the fake root window or the - * fake client window. If the requested ID is neither of those wanted, - * return whatever the real dixLookupWindow does. - */ -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); -} - -static void reply_XIQueryPointer(ClientPtr client, int len, char *data, - void *userdata) -{ - xXIQueryPointerReply *rep = (xXIQueryPointerReply*)data; - SpritePtr sprite; - - if (!rep->repType) - return; - - if (client->swapped) - { - char n; - swapl(&rep->length, n); - swaps(&rep->sequenceNumber, n); - swapl(&rep->root, n); - swapl(&rep->child, n); - swapl(&rep->root_x, n); - swapl(&rep->root_y, n); - swapl(&rep->win_x, n); - swapl(&rep->win_y, n); - swaps(&rep->buttons_len, n); - } - - reply_check_defaults(rep, len, XIQueryPointer); - - g_assert(rep->root == root.drawable.id); - g_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); - - 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); - } else - { - int x, y; - - 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); - } - - - g_assert(rep->same_screen == xTrue); - - reply_handler = reply_XIQueryPointer_data; -} - -static void reply_XIQueryPointer_data(ClientPtr client, int len, char *data, void *userdata) -{ - reply_handler = reply_XIQueryPointer; -} - -static void request_XIQueryPointer(ClientPtr client, xXIQueryPointerReq* req, int error) -{ - char n; - int rc; - - rc = ProcXIQueryPointer(&client_request); - g_assert(rc == error); - - if (rc == BadDevice) - g_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); - - if (rc == BadDevice) - g_assert(client_request.errorValue == req->deviceid); -} - -static void test_XIQueryPointer(void) -{ - int i; - xXIQueryPointerReq request; - - memset(&request, 0, sizeof(request)); - - request_init(&request, XIQueryPointer); - - reply_handler = reply_XIQueryPointer; - - client_request = init_client(request.length, &request); - - request.deviceid = XIAllDevices; - request_XIQueryPointer(&client_request, &request, BadDevice); - - request.deviceid = XIAllMasterDevices; - request_XIQueryPointer(&client_request, &request, BadDevice); - - request.win = root.drawable.id; - test_data.win = &root; - - test_data.dev = devices.vcp; - request.deviceid = devices.vcp->id; - request_XIQueryPointer(&client_request, &request, Success); - request.deviceid = devices.vck->id; - request_XIQueryPointer(&client_request, &request, BadDevice); - request.deviceid = devices.mouse->id; - request_XIQueryPointer(&client_request, &request, BadDevice); - request.deviceid = devices.kbd->id; - request_XIQueryPointer(&client_request, &request, BadDevice); - - test_data.dev = devices.mouse; - devices.mouse->u.master = NULL; /* Float, kind-of */ - request.deviceid = devices.mouse->id; - request_XIQueryPointer(&client_request, &request, Success); - - for (i = devices.kbd->id + 1; i <= 0xFFFF; i++) - { - request.deviceid = i; - request_XIQueryPointer(&client_request, &request, BadDevice); - } - - request.win = window.drawable.id; - - test_data.dev = devices.vcp; - test_data.win = &window; - request.deviceid = devices.vcp->id; - request_XIQueryPointer(&client_request, &request, Success); - - test_data.dev = devices.mouse; - request.deviceid = devices.mouse->id; - request_XIQueryPointer(&client_request, &request, Success); -} - -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); - - return g_test_run(); -} +/**
+ * 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 <dix-config.h>
+#endif
+
+/*
+ * Protocol testing for XIQueryPointer request.
+ */
+#include <stdint.h>
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include <X11/extensions/XI2proto.h>
+#include "inputstr.h"
+#include "windowstr.h"
+#include "scrnintstr.h"
+#include "xiquerypointer.h"
+#include "exevents.h"
+
+#include "protocol-common.h"
+#include <glib.h>
+
+static ClientRec client_request;
+static void reply_XIQueryPointer_data(ClientPtr client, int len,
+ char *data, void *userdata);
+
+static struct {
+ DeviceIntPtr dev;
+ WindowPtr win;
+} test_data;
+
+
+/* dixLookupWindow requires a lot of setup not necessary for this test.
+ * Simple wrapper that returns either one of the fake root window or the
+ * fake client window. If the requested ID is neither of those wanted,
+ * return whatever the real dixLookupWindow does.
+ */
+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);
+}
+
+static void reply_XIQueryPointer(ClientPtr client, int len, char *data,
+ void *userdata)
+{
+ xXIQueryPointerReply *rep = (xXIQueryPointerReply*)data;
+ SpritePtr sprite;
+
+ if (!rep->repType)
+ return;
+
+ if (client->swapped)
+ {
+ char n;
+ swapl(&rep->length, n);
+ swaps(&rep->sequenceNumber, n);
+ swapl(&rep->root, n);
+ swapl(&rep->child, n);
+ swapl(&rep->root_x, n);
+ swapl(&rep->root_y, n);
+ swapl(&rep->win_x, n);
+ swapl(&rep->win_y, n);
+ swaps(&rep->buttons_len, n);
+ }
+
+ reply_check_defaults(rep, len, XIQueryPointer);
+
+ g_assert(rep->root == root.drawable.id);
+ g_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);
+
+ 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);
+ } else
+ {
+ int x, y;
+
+ 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);
+ }
+
+
+ g_assert(rep->same_screen == xTrue);
+
+ reply_handler = reply_XIQueryPointer_data;
+}
+
+static void reply_XIQueryPointer_data(ClientPtr client, int len, char *data, void *userdata)
+{
+ reply_handler = reply_XIQueryPointer;
+}
+
+static void request_XIQueryPointer(ClientPtr client, xXIQueryPointerReq* req, int error)
+{
+ char n;
+ int rc;
+
+ rc = ProcXIQueryPointer(&client_request);
+ g_assert(rc == error);
+
+ if (rc == BadDevice)
+ g_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);
+
+ if (rc == BadDevice)
+ g_assert(client_request.errorValue == req->deviceid);
+}
+
+static void test_XIQueryPointer(void)
+{
+ int i;
+ xXIQueryPointerReq request;
+
+ memset(&request, 0, sizeof(request));
+
+ request_init(&request, XIQueryPointer);
+
+ reply_handler = reply_XIQueryPointer;
+
+ client_request = init_client(request.length, &request);
+
+ request.deviceid = XIAllDevices;
+ request_XIQueryPointer(&client_request, &request, BadDevice);
+
+ request.deviceid = XIAllMasterDevices;
+ request_XIQueryPointer(&client_request, &request, BadDevice);
+
+ request.win = root.drawable.id;
+ test_data.win = &root;
+
+ test_data.dev = devices.vcp;
+ request.deviceid = devices.vcp->id;
+ request_XIQueryPointer(&client_request, &request, Success);
+ request.deviceid = devices.vck->id;
+ request_XIQueryPointer(&client_request, &request, BadDevice);
+ request.deviceid = devices.mouse->id;
+ request_XIQueryPointer(&client_request, &request, BadDevice);
+ request.deviceid = devices.kbd->id;
+ request_XIQueryPointer(&client_request, &request, BadDevice);
+
+ test_data.dev = devices.mouse;
+ devices.mouse->master = NULL; /* Float, kind-of */
+ request.deviceid = devices.mouse->id;
+ request_XIQueryPointer(&client_request, &request, Success);
+
+ for (i = devices.kbd->id + 1; i <= 0xFFFF; i++)
+ {
+ request.deviceid = i;
+ request_XIQueryPointer(&client_request, &request, BadDevice);
+ }
+
+ request.win = window.drawable.id;
+
+ test_data.dev = devices.vcp;
+ test_data.win = &window;
+ request.deviceid = devices.vcp->id;
+ request_XIQueryPointer(&client_request, &request, Success);
+
+ test_data.dev = devices.mouse;
+ request.deviceid = devices.mouse->id;
+ request_XIQueryPointer(&client_request, &request, Success);
+}
+
+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);
+
+ return g_test_run();
+}
diff --git a/xorg-server/test/xi2/protocol-xiwarppointer.c b/xorg-server/test/xi2/protocol-xiwarppointer.c index 4f8860ea0..98169b154 100644 --- a/xorg-server/test/xi2/protocol-xiwarppointer.c +++ b/xorg-server/test/xi2/protocol-xiwarppointer.c @@ -1,216 +1,216 @@ -/** - * 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 <dix-config.h> -#endif - -/* - * Protocol testing for XIWarpPointer request. - */ -#include <stdint.h> -#include <X11/X.h> -#include <X11/Xproto.h> -#include <X11/extensions/XI2proto.h> -#include "inputstr.h" -#include "windowstr.h" -#include "scrnintstr.h" -#include "xiwarppointer.h" -#include "exevents.h" - -#include "protocol-common.h" -#include <glib.h> - -static int expected_x = SPRITE_X; -static int expected_y = SPRITE_Y; - -/* dixLookupWindow requires a lot of setup not necessary for this test. - * Simple wrapper that returns either one of the fake root window or the - * fake client window. If the requested ID is neither of those wanted, - * return whatever the real dixLookupWindow does. - */ -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); -} - -/** - * This function overrides the one in the screen rec. - */ -static Bool ScreenSetCursorPosition(DeviceIntPtr dev, ScreenPtr screen, - int x, int y, Bool generateEvent) -{ - g_assert(x == expected_x); - g_assert(y == expected_y); - return TRUE; -} - - -static void request_XIWarpPointer(ClientPtr client, xXIWarpPointerReq* req, - int error) -{ - char n; - int rc; - - rc = ProcXIWarpPointer(client); - g_assert(rc == error); - - if (rc == BadDevice) - g_assert(client->errorValue == req->deviceid); - else if (rc == BadWindow) - g_assert(client->errorValue == req->dst_win || - client->errorValue == req->src_win); - - - client->swapped = TRUE; - - swapl(&req->src_win, n); - swapl(&req->dst_win, n); - swapl(&req->src_x, n); - swapl(&req->src_y, n); - swapl(&req->dst_x, n); - swapl(&req->dst_y, n); - swaps(&req->src_width, n); - swaps(&req->src_height, n); - swaps(&req->deviceid, n); - - rc = SProcXIWarpPointer(client); - g_assert(rc == error); - - if (rc == BadDevice) - g_assert(client->errorValue == req->deviceid); - else if (rc == BadWindow) - g_assert(client->errorValue == req->dst_win || - client->errorValue == req->src_win); - - client->swapped = FALSE; -} - -static void test_XIWarpPointer(void) -{ - int i; - ClientRec client_request; - xXIWarpPointerReq request; - - memset(&request, 0, sizeof(request)); - - request_init(&request, XIWarpPointer); - - client_request = init_client(request.length, &request); - - request.deviceid = XIAllDevices; - request_XIWarpPointer(&client_request, &request, BadDevice); - - request.deviceid = XIAllMasterDevices; - request_XIWarpPointer(&client_request, &request, BadDevice); - - request.src_win = root.drawable.id; - request.dst_win = root.drawable.id; - request.deviceid = devices.vcp->id; - request_XIWarpPointer(&client_request, &request, Success); - request.deviceid = devices.vck->id; - request_XIWarpPointer(&client_request, &request, BadDevice); - request.deviceid = devices.mouse->id; - request_XIWarpPointer(&client_request, &request, BadDevice); - request.deviceid = devices.kbd->id; - request_XIWarpPointer(&client_request, &request, BadDevice); - - devices.mouse->u.master = NULL; /* Float, kind-of */ - request.deviceid = devices.mouse->id; - request_XIWarpPointer(&client_request, &request, Success); - - for (i = devices.kbd->id + 1; i <= 0xFFFF; i++) - { - request.deviceid = i; - request_XIWarpPointer(&client_request, &request, BadDevice); - } - - request.src_win = window.drawable.id; - request.deviceid = devices.vcp->id; - request_XIWarpPointer(&client_request, &request, Success); - - request.deviceid = devices.mouse->id; - request_XIWarpPointer(&client_request, &request, Success); - - request.src_win = root.drawable.id; - request.dst_win = 0xFFFF; /* invalid window */ - request_XIWarpPointer(&client_request, &request, BadWindow); - - request.src_win = 0xFFFF; /* invalid window */ - request.dst_win = root.drawable.id; - request_XIWarpPointer(&client_request, &request, BadWindow); - - request.src_win = None; - request.dst_win = None; - - request.dst_y = 0; - expected_y = SPRITE_Y; - - request.dst_x = 1 << 16; - expected_x = SPRITE_X + 1; - request.deviceid = devices.vcp->id; - request_XIWarpPointer(&client_request, &request, Success); - - request.dst_x = -1 << 16; - expected_x = SPRITE_X - 1; - request.deviceid = devices.vcp->id; - request_XIWarpPointer(&client_request, &request, Success); - - request.dst_x = 0; - expected_x = SPRITE_X; - - request.dst_y = 1 << 16; - expected_y = SPRITE_Y + 1; - request.deviceid = devices.vcp->id; - request_XIWarpPointer(&client_request, &request, Success); - - request.dst_y = -1 << 16; - expected_y = SPRITE_Y - 1; - request.deviceid = devices.vcp->id; - request_XIWarpPointer(&client_request, &request, Success); - - /* FIXME: src_x/y checks */ -} - -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); - - return g_test_run(); -} +/**
+ * 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 <dix-config.h>
+#endif
+
+/*
+ * Protocol testing for XIWarpPointer request.
+ */
+#include <stdint.h>
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include <X11/extensions/XI2proto.h>
+#include "inputstr.h"
+#include "windowstr.h"
+#include "scrnintstr.h"
+#include "xiwarppointer.h"
+#include "exevents.h"
+
+#include "protocol-common.h"
+#include <glib.h>
+
+static int expected_x = SPRITE_X;
+static int expected_y = SPRITE_Y;
+
+/* dixLookupWindow requires a lot of setup not necessary for this test.
+ * Simple wrapper that returns either one of the fake root window or the
+ * fake client window. If the requested ID is neither of those wanted,
+ * return whatever the real dixLookupWindow does.
+ */
+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);
+}
+
+/**
+ * This function overrides the one in the screen rec.
+ */
+static Bool ScreenSetCursorPosition(DeviceIntPtr dev, ScreenPtr screen,
+ int x, int y, Bool generateEvent)
+{
+ g_assert(x == expected_x);
+ g_assert(y == expected_y);
+ return TRUE;
+}
+
+
+static void request_XIWarpPointer(ClientPtr client, xXIWarpPointerReq* req,
+ int error)
+{
+ char n;
+ int rc;
+
+ rc = ProcXIWarpPointer(client);
+ g_assert(rc == error);
+
+ if (rc == BadDevice)
+ g_assert(client->errorValue == req->deviceid);
+ else if (rc == BadWindow)
+ g_assert(client->errorValue == req->dst_win ||
+ client->errorValue == req->src_win);
+
+
+ client->swapped = TRUE;
+
+ swapl(&req->src_win, n);
+ swapl(&req->dst_win, n);
+ swapl(&req->src_x, n);
+ swapl(&req->src_y, n);
+ swapl(&req->dst_x, n);
+ swapl(&req->dst_y, n);
+ swaps(&req->src_width, n);
+ swaps(&req->src_height, n);
+ swaps(&req->deviceid, n);
+
+ rc = SProcXIWarpPointer(client);
+ g_assert(rc == error);
+
+ if (rc == BadDevice)
+ g_assert(client->errorValue == req->deviceid);
+ else if (rc == BadWindow)
+ g_assert(client->errorValue == req->dst_win ||
+ client->errorValue == req->src_win);
+
+ client->swapped = FALSE;
+}
+
+static void test_XIWarpPointer(void)
+{
+ int i;
+ ClientRec client_request;
+ xXIWarpPointerReq request;
+
+ memset(&request, 0, sizeof(request));
+
+ request_init(&request, XIWarpPointer);
+
+ client_request = init_client(request.length, &request);
+
+ request.deviceid = XIAllDevices;
+ request_XIWarpPointer(&client_request, &request, BadDevice);
+
+ request.deviceid = XIAllMasterDevices;
+ request_XIWarpPointer(&client_request, &request, BadDevice);
+
+ request.src_win = root.drawable.id;
+ request.dst_win = root.drawable.id;
+ request.deviceid = devices.vcp->id;
+ request_XIWarpPointer(&client_request, &request, Success);
+ request.deviceid = devices.vck->id;
+ request_XIWarpPointer(&client_request, &request, BadDevice);
+ request.deviceid = devices.mouse->id;
+ request_XIWarpPointer(&client_request, &request, BadDevice);
+ request.deviceid = devices.kbd->id;
+ request_XIWarpPointer(&client_request, &request, BadDevice);
+
+ devices.mouse->master = NULL; /* Float, kind-of */
+ request.deviceid = devices.mouse->id;
+ request_XIWarpPointer(&client_request, &request, Success);
+
+ for (i = devices.kbd->id + 1; i <= 0xFFFF; i++)
+ {
+ request.deviceid = i;
+ request_XIWarpPointer(&client_request, &request, BadDevice);
+ }
+
+ request.src_win = window.drawable.id;
+ request.deviceid = devices.vcp->id;
+ request_XIWarpPointer(&client_request, &request, Success);
+
+ request.deviceid = devices.mouse->id;
+ request_XIWarpPointer(&client_request, &request, Success);
+
+ request.src_win = root.drawable.id;
+ request.dst_win = 0xFFFF; /* invalid window */
+ request_XIWarpPointer(&client_request, &request, BadWindow);
+
+ request.src_win = 0xFFFF; /* invalid window */
+ request.dst_win = root.drawable.id;
+ request_XIWarpPointer(&client_request, &request, BadWindow);
+
+ request.src_win = None;
+ request.dst_win = None;
+
+ request.dst_y = 0;
+ expected_y = SPRITE_Y;
+
+ request.dst_x = 1 << 16;
+ expected_x = SPRITE_X + 1;
+ request.deviceid = devices.vcp->id;
+ request_XIWarpPointer(&client_request, &request, Success);
+
+ request.dst_x = -1 << 16;
+ expected_x = SPRITE_X - 1;
+ request.deviceid = devices.vcp->id;
+ request_XIWarpPointer(&client_request, &request, Success);
+
+ request.dst_x = 0;
+ expected_x = SPRITE_X;
+
+ request.dst_y = 1 << 16;
+ expected_y = SPRITE_Y + 1;
+ request.deviceid = devices.vcp->id;
+ request_XIWarpPointer(&client_request, &request, Success);
+
+ request.dst_y = -1 << 16;
+ expected_y = SPRITE_Y - 1;
+ request.deviceid = devices.vcp->id;
+ request_XIWarpPointer(&client_request, &request, Success);
+
+ /* FIXME: src_x/y checks */
+}
+
+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);
+
+ return g_test_run();
+}
|