[PATCH 07/10] test/integration: test for default evdev behaviour

Peter Hutterer peter.hutterer at who-t.net
Mon Jul 2 23:59:24 PDT 2012


Default behaviour on linux is new devices are assigned the evdev driver and
show up with the same name as the uinput device. Test for that.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 test/integration/input_drivers.cpp |   65 ++++++++++++++++++++++++++++++++++++
 1 file changed, 65 insertions(+)

diff --git a/test/integration/input_drivers.cpp b/test/integration/input_drivers.cpp
index bd0777f..54a01a8 100644
--- a/test/integration/input_drivers.cpp
+++ b/test/integration/input_drivers.cpp
@@ -139,6 +139,71 @@ TEST_F(InputDriverTest, NewMaster)
     XIFreeDeviceInfo(info);
 }
 
+/* default setup on linux, we have hotplugging on and the device appears
+ * with its name */
+#ifdef __linux__
+TEST_F(InputDriverTest, Evdev)
+{
+    XIEventMask mask;
+    mask.deviceid = XIAllDevices;
+    mask.mask_len = XIMaskLen(XI_TouchEnd);
+    mask.mask = reinterpret_cast<unsigned char*>(calloc(mask.mask_len, 1));
+    XISetMask(mask.mask, XI_HierarchyChanged);
+
+    ASSERT_EQ(Success,
+              XISelectEvents(Display(), DefaultRootWindow(Display()), &mask,
+                             1));
+
+    free(mask.mask);
+
+    XFlush(Display());
+    std::auto_ptr<xorg::testing::evemu::Device> device;
+    try {
+      device = std::auto_ptr<xorg::testing::evemu::Device>(
+          new xorg::testing::evemu::Device(
+              TEST_ROOT_DIR "recordings/ntrig_dell_xt2/device.prop"));
+    } catch (std::runtime_error &error) {
+      std::cerr << "Failed to create evemu device, skipping test.\n";
+      return;
+    }
+
+    ASSERT_TRUE(xorg::testing::XServer::WaitForDevice(Display(),
+                              "N-Trig MultiTouch (Virtual Test Device)"));
+
+
+    Atom evdev_prop = XInternAtom(Display(),
+                                  "Evdev Middle Button Emulation", true);
+    ASSERT_NE(evdev_prop, None);
+
+    XIDeviceInfo *info;
+    int ndevices;
+    info = XIQueryDevice(Display(), XIAllDevices, &ndevices);
+    while(ndevices--) {
+        if (strcmp(info[ndevices].name,
+                   "N-Trig MultiTouch (Virtual Test Device)") == 0)
+            break;
+    }
+    ASSERT_GT(ndevices, 0);
+
+    Atom *props;
+    int nprops;
+
+    props = XIListProperties(Display(),
+                             info[ndevices].deviceid,
+                             &nprops);
+    ASSERT_GT(nprops, 0);
+
+    while(nprops--)
+        if (props[nprops] == evdev_prop)
+            break;
+    ASSERT_GT(nprops, 0);
+
+    XIFreeDeviceInfo(info);
+    XFree(props);
+
+}
+#endif
+
 int main(int argc, char **argv) {
 
     testing::InitGoogleTest(&argc, argv);
-- 
1.7.10.4



More information about the xorg-devel mailing list