2 * Copyright © 2009 Red Hat, Inc.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
24 #ifdef HAVE_DIX_CONFIG_H
25 #include <dix-config.h>
29 * Protocol testing for XISetClientPointer request.
32 * BadDevice of all devices except master pointers.
33 * Success for a valid window.
34 * Success for window None.
35 * BadWindow for invalid windows.
39 #include <X11/Xproto.h>
40 #include <X11/extensions/XI2proto.h>
42 #include "windowstr.h"
43 #include "extinit.h" /* for XInputExtensionInit */
44 #include "scrnintstr.h"
45 #include "xisetclientpointer.h"
47 #include "exglobals.h"
49 #include "protocol-common.h"
51 static ClientRec client_window
;
52 static ClientRec client_request
;
55 __wrap_dixLookupClient(ClientPtr
*pClient
, XID rid
, ClientPtr client
,
58 if (rid
== ROOT_WINDOW_ID
)
61 if (rid
== CLIENT_WINDOW_ID
) {
62 *pClient
= &client_window
;
66 return __real_dixLookupClient(pClient
, rid
, client
, access
);
70 request_XISetClientPointer(xXISetClientPointerReq
* req
, int error
)
74 client_request
= init_client(req
->length
, req
);
76 rc
= ProcXISetClientPointer(&client_request
);
80 assert(client_request
.errorValue
== req
->deviceid
);
82 client_request
.swapped
= TRUE
;
85 swaps(&req
->deviceid
);
86 rc
= SProcXISetClientPointer(&client_request
);
90 assert(client_request
.errorValue
== req
->deviceid
);
95 test_XISetClientPointer(void)
98 xXISetClientPointerReq request
;
100 request_init(&request
, XISetClientPointer
);
102 request
.win
= CLIENT_WINDOW_ID
;
104 printf("Testing BadDevice error for XIAllDevices and XIMasterDevices.\n");
105 request
.deviceid
= XIAllDevices
;
106 request_XISetClientPointer(&request
, BadDevice
);
108 request
.deviceid
= XIAllMasterDevices
;
109 request_XISetClientPointer(&request
, BadDevice
);
111 printf("Testing Success for VCP and VCK.\n");
112 request
.deviceid
= devices
.vcp
->id
; /* 2 */
113 request_XISetClientPointer(&request
, Success
);
114 assert(client_window
.clientPtr
->id
== 2);
116 request
.deviceid
= devices
.vck
->id
; /* 3 */
117 request_XISetClientPointer(&request
, Success
);
118 assert(client_window
.clientPtr
->id
== 2);
120 printf("Testing BadDevice error for all other devices.\n");
121 for (i
= 4; i
<= 0xFFFF; i
++) {
122 request
.deviceid
= i
;
123 request_XISetClientPointer(&request
, BadDevice
);
126 printf("Testing window None\n");
128 request
.deviceid
= devices
.vcp
->id
; /* 2 */
129 request_XISetClientPointer(&request
, Success
);
130 assert(client_request
.clientPtr
->id
== 2);
132 printf("Testing invalid window\n");
133 request
.win
= INVALID_WINDOW_ID
;
134 request
.deviceid
= devices
.vcp
->id
;
135 request_XISetClientPointer(&request
, BadWindow
);
140 main(int argc
, char **argv
)
143 client_window
= init_client(0, NULL
);
145 test_XISetClientPointer();