[PATCH 1/2] test/xi2: Add a test for XIGrabDevice
Rui Matos
tiagomatos at gmail.com
Fri Apr 12 19:22:53 PDT 2013
Currently fails but will get fixed in the next commit.
---
test/xi2/.gitignore | 1 +
test/xi2/Makefile.am | 4 ++
test/xi2/protocol-xigrabdevice.c | 123 +++++++++++++++++++++++++++++++++++++++
3 files changed, 128 insertions(+)
create mode 100644 test/xi2/protocol-xigrabdevice.c
diff --git a/test/xi2/.gitignore b/test/xi2/.gitignore
index 817aa7b..548c1fb 100644
--- a/test/xi2/.gitignore
+++ b/test/xi2/.gitignore
@@ -1,6 +1,7 @@
protocol-eventconvert
protocol-xigetclientpointer
protocol-xigetselectedevents
+protocol-xigrabdevice
protocol-xipassivegrabdevice
protocol-xiquerydevice
protocol-xiquerypointer
diff --git a/test/xi2/Makefile.am b/test/xi2/Makefile.am
index 9de7abf..ba4ba97 100644
--- a/test/xi2/Makefile.am
+++ b/test/xi2/Makefile.am
@@ -8,6 +8,7 @@ noinst_PROGRAMS = \
protocol-xisetclientpointer \
protocol-xigetclientpointer \
protocol-xipassivegrabdevice \
+ protocol-xigrabdevice \
protocol-xiquerypointer \
protocol-xiwarppointer \
protocol-eventconvert \
@@ -33,6 +34,7 @@ protocol_xisetclientpointer_LDADD=$(TEST_LDADD)
protocol_xigetclientpointer_LDADD=$(TEST_LDADD)
protocol_xiquerypointer_LDADD=$(TEST_LDADD)
protocol_xipassivegrabdevice_LDADD=$(TEST_LDADD)
+protocol_xigrabdevice_LDADD=$(TEST_LDADD)
protocol_xiwarppointer_LDADD=$(TEST_LDADD)
protocol_eventconvert_LDADD=$(TEST_LDADD)
xi2_LDADD=$(TEST_LDADD)
@@ -44,6 +46,7 @@ protocol_xigetselectedevents_LDFLAGS=$(AM_LDFLAGS) -Wl,-wrap,WriteToClient -Wl,-
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_xigrabdevice_LDFLAGS=$(AM_LDFLAGS) -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
xi2_LDFLAGS=$(AM_LDFLAGS)
@@ -56,6 +59,7 @@ protocol_xisetclientpointer_SOURCES=$(COMMON_SOURCES) protocol-xisetclientpointe
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_xigrabdevice_SOURCES=$(COMMON_SOURCES) protocol-xigrabdevice.c
protocol_xiwarppointer_SOURCES=$(COMMON_SOURCES) protocol-xiwarppointer.c
else
# Print that xi2-tests were skipped (exit code 77 for automake test harness)
diff --git a/test/xi2/protocol-xigrabdevice.c b/test/xi2/protocol-xigrabdevice.c
new file mode 100644
index 0000000..f3044be
--- /dev/null
+++ b/test/xi2/protocol-xigrabdevice.c
@@ -0,0 +1,123 @@
+/**
+ * Copyright © 2013 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 XIGrabDevice request.
+ */
+#include <stdint.h>
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include <X11/extensions/XI2proto.h>
+#include "inputstr.h"
+#include "xigrabdev.h"
+#include "mi.h"
+
+#include "protocol-common.h"
+
+static ClientRec client_request;
+
+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_XIGrabDevice(ClientPtr client, int len, char *data, void *closure)
+{
+ xXIGrabDeviceReply *rep = (xXIGrabDeviceReply *) data;
+
+ reply_check_defaults(rep, len, XIGrabDevice);
+}
+
+static void
+request_XIGrabDevice(ClientPtr client, xXIGrabDeviceReq * req,
+ int error, int errval)
+{
+ int rc;
+
+ rc = ProcXIGrabDevice(&client_request);
+ assert(rc == error);
+
+ if (rc != Success)
+ assert(client_request.errorValue == errval);
+
+}
+
+static unsigned char *data[4096]; /* the request buffer */
+static void
+test_XIGrabDevice(void)
+{
+ xXIGrabDeviceReq *request = (xXIGrabDeviceReq *) data;
+
+ request_init(request, XIGrabDevice);
+
+ request->grab_window = CLIENT_WINDOW_ID;
+
+ reply_handler = reply_XIGrabDevice;
+ client_request = init_client(request->length, request);
+
+ request->deviceid = devices.vcp->id;
+ request->grab_mode = XIGrabModeSync;
+ request->paired_device_mode = XIGrabModeAsync;
+ request_XIGrabDevice(&client_request, request, Success, 0);
+ assert(devices.vcp->deviceGrab.grab->keyboardMode == XIGrabModeAsync);
+ assert(devices.vcp->deviceGrab.grab->pointerMode == XIGrabModeSync);
+
+ request->deviceid = devices.vck->id;
+ request->grab_mode = XIGrabModeSync;
+ request->paired_device_mode = XIGrabModeAsync;
+ request_XIGrabDevice(&client_request, request, Success, 0);
+ assert(devices.vck->deviceGrab.grab->keyboardMode == XIGrabModeSync);
+ assert(devices.vck->deviceGrab.grab->pointerMode == XIGrabModeAsync);
+}
+
+int
+main(int argc, char **argv)
+{
+ InitEvents();
+ mieqInit();
+
+ init_simple();
+
+ /* Should go in protocol-common.c ? */
+ window.realized = 1;
+ screen.root = &root;
+
+ test_XIGrabDevice();
+
+ return 0;
+}
--
1.8.1.4
More information about the xorg-devel
mailing list