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 XIGetClientPointer request.
33 #include <X11/Xproto.h>
34 #include <X11/extensions/XI2proto.h>
36 #include "windowstr.h"
37 #include "scrnintstr.h"
38 #include "xigetclientpointer.h"
41 #include "protocol-common.h"
49 static ClientRec client_window
;
50 static ClientRec client_request
;
53 __wrap_dixLookupClient(ClientPtr
*pClient
, XID rid
, ClientPtr client
,
56 if (rid
== ROOT_WINDOW_ID
)
59 if (rid
== CLIENT_WINDOW_ID
) {
60 *pClient
= &client_window
;
64 return __real_dixLookupClient(pClient
, rid
, client
, access
);
68 reply_XIGetClientPointer(ClientPtr client
, int len
, char *data
, void *userdata
)
70 xXIGetClientPointerReply
*rep
= (xXIGetClientPointerReply
*) data
;
72 if (client
->swapped
) {
74 swaps(&rep
->sequenceNumber
);
75 swaps(&rep
->deviceid
);
78 reply_check_defaults(rep
, len
, XIGetClientPointer
);
80 assert(rep
->set
== test_data
.cp_is_set
);
82 assert(rep
->deviceid
== test_data
.dev
->id
);
86 request_XIGetClientPointer(ClientPtr client
, xXIGetClientPointerReq
* req
,
91 test_data
.win
= req
->win
;
93 rc
= ProcXIGetClientPointer(&client_request
);
97 assert(client_request
.errorValue
== req
->win
);
99 client_request
.swapped
= TRUE
;
102 rc
= SProcXIGetClientPointer(&client_request
);
106 assert(client_request
.errorValue
== req
->win
);
111 test_XIGetClientPointer(void)
113 xXIGetClientPointerReq request
;
115 request_init(&request
, XIGetClientPointer
);
117 request
.win
= CLIENT_WINDOW_ID
;
119 reply_handler
= reply_XIGetClientPointer
;
121 client_request
= init_client(request
.length
, &request
);
123 printf("Testing invalid window\n");
124 request
.win
= INVALID_WINDOW_ID
;
125 request_XIGetClientPointer(&client_request
, &request
, BadWindow
);
127 test_data
.cp_is_set
= FALSE
;
129 printf("Testing window None, unset ClientPointer.\n");
131 request_XIGetClientPointer(&client_request
, &request
, Success
);
133 printf("Testing valid window, unset ClientPointer.\n");
134 request
.win
= CLIENT_WINDOW_ID
;
135 request_XIGetClientPointer(&client_request
, &request
, Success
);
137 printf("Testing valid window, set ClientPointer.\n");
138 client_window
.clientPtr
= devices
.vcp
;
139 test_data
.dev
= devices
.vcp
;
140 test_data
.cp_is_set
= TRUE
;
141 request
.win
= CLIENT_WINDOW_ID
;
142 request_XIGetClientPointer(&client_request
, &request
, Success
);
144 client_window
.clientPtr
= NULL
;
146 printf("Testing window None, set ClientPointer.\n");
147 client_request
.clientPtr
= devices
.vcp
;
148 test_data
.dev
= devices
.vcp
;
149 test_data
.cp_is_set
= TRUE
;
151 request_XIGetClientPointer(&client_request
, &request
, Success
);
155 main(int argc
, char **argv
)
158 client_window
= init_client(0, NULL
);
160 test_XIGetClientPointer();