[PATCH 10/10] test/integration: add tests for evdev/synaptics default behaviour

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


Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 .../SynPS2_Synaptics_TouchPad/device.prop          |   33 ++++++++
 test/integration/xorg-conf-input-tests.cpp         |   82 ++++++++++++++++++--
 2 files changed, 107 insertions(+), 8 deletions(-)
 create mode 100644 test/integration/recordings/SynPS2_Synaptics_TouchPad/device.prop

diff --git a/test/integration/recordings/SynPS2_Synaptics_TouchPad/device.prop b/test/integration/recordings/SynPS2_Synaptics_TouchPad/device.prop
new file mode 100644
index 0000000..3f4982b
--- /dev/null
+++ b/test/integration/recordings/SynPS2_Synaptics_TouchPad/device.prop
@@ -0,0 +1,33 @@
+N: SynPS/2 Synaptics TouchPad
+I: 0011 0002 0007 01b1
+P: 05 00 00 00 00 00 00 00
+B: 00 0b 00 00 00 00 00 00 00
+B: 01 00 00 00 00 00 00 00 00
+B: 01 00 00 00 00 00 00 00 00
+B: 01 00 00 00 00 00 00 00 00
+B: 01 00 00 00 00 00 00 00 00
+B: 01 00 00 01 00 00 00 00 00
+B: 01 20 e5 00 00 00 00 00 00
+B: 01 00 00 00 00 00 00 00 00
+B: 01 00 00 00 00 00 00 00 00
+B: 01 00 00 00 00 00 00 00 00
+B: 01 00 00 00 00 00 00 00 00
+B: 01 00 00 00 00 00 00 00 00
+B: 01 00 00 00 00 00 00 00 00
+B: 02 00 00 00 00 00 00 00 00
+B: 03 03 00 00 11 00 80 60 06
+B: 04 00 00 00 00 00 00 00 00
+B: 05 00 00 00 00 00 00 00 00
+B: 11 00 00 00 00 00 00 00 00
+B: 12 00 00 00 00 00 00 00 00
+B: 15 00 00 00 00 00 00 00 00
+B: 15 00 00 00 00 00 00 00 00
+A: 00 1472 5472 8 0
+A: 01 1408 4448 8 0
+A: 18 0 255 0 0
+A: 1c 0 15 0 0
+A: 2f 0 1 0 0
+A: 35 1472 5472 8 0
+A: 36 1408 4448 8 0
+A: 39 0 65535 0 0
+A: 3a 0 255 0 0
diff --git a/test/integration/xorg-conf-input-tests.cpp b/test/integration/xorg-conf-input-tests.cpp
index 76512ca..401a981 100644
--- a/test/integration/xorg-conf-input-tests.cpp
+++ b/test/integration/xorg-conf-input-tests.cpp
@@ -113,7 +113,8 @@ TEST_F(XOrgConfigInputTest, DefaultDevices)
 
 class XOrgConfigInputDriverTest : public XOrgConfigInputTest,
                                   public ::testing::WithParamInterface<const char*> {
-    void AddDriverSection(const char *param) {
+public:
+    void AddDriverSection(const char *param, const char *options = "") {
         std::ofstream conffile(config_file.c_str(), std::ios_base::app);
         conffile.exceptions(std::ofstream::failbit | std::ofstream::badbit);
 
@@ -123,6 +124,7 @@ class XOrgConfigInputDriverTest : public XOrgConfigInputTest,
 "            Section \"InputDevice\""
 "                Identifier \"--device--\""
 "                Driver \"" << driver << "\""
+                 << options <<
 "            EndSection";
         server.SetOption("-config", config_file);
     }
@@ -166,13 +168,6 @@ TEST_P(XOrgConfigInputDriverTest, DriverDevice)
     XIFreeDeviceInfo(info);
 }
 
-int main(int argc, char **argv) {
-
-    testing::InitGoogleTest(&argc, argv);
-
-    return RUN_ALL_TESTS();
-}
-
 /* mouse, keyboard, void, evdev, synaptics and vmmouse have special status,
    they are picked as core devices if AAD is off and any section is found
    in the xorg.conf.
@@ -180,3 +175,74 @@ int main(int argc, char **argv) {
  */
 INSTANTIATE_TEST_CASE_P(, XOrgConfigInputDriverTest,
         ::testing::Values("mouse", "keyboard", "void"));
+
+
+#ifdef __linux__ /* we need evemu for these */
+class XOrgConfigInputDriverTestDevice : public XOrgConfigInputDriverTest {
+    private:
+        std::auto_ptr<xorg::testing::evemu::Device> device;
+
+    virtual void SetUp()
+    {
+        const char *param = GetParam();
+
+        try {
+            device = std::auto_ptr<xorg::testing::evemu::Device>(
+                new xorg::testing::evemu::Device(TEST_ROOT_DIR "recordings/SynPS2_Synaptics_TouchPad/device.prop")
+                );
+        } catch (std::runtime_error &error) {
+            std::cerr << "Failed to create evemu device, skipping test.\n";
+            return;
+        }
+
+        std::stringstream s;
+        s << "Option \"Device\" \"" << device->GetDeviceNode() << "\"";
+        std::string device_option = s.str();
+
+        WriteConfig(param);
+        AddDriverSection(param, device_option.c_str());
+        StartServer();
+    }
+};
+
+/**
+ * AutoAddDevices is off, InputDevice sections are present but unreferenced,
+ * with those drivers that are elevated to core device status if found.
+ */
+TEST_P(XOrgConfigInputDriverTestDevice, DriverDevice)
+{
+    const char *param;
+    int ndevices;
+    XIDeviceInfo *info;
+
+    param = GetParam();
+    info = XIQueryDevice(Display(), XIAllDevices, &ndevices);
+    /* VCP, VCK, 2 test devices, forced mouse/keyboard */
+    ASSERT_EQ(ndevices, 6) << "Drivers required for this test: "
+                               "keyboard, " << param;
+
+    bool found = false;
+    while(ndevices--) {
+        if (strcmp(info[ndevices].name, "--device--") == 0) {
+            ASSERT_EQ(found, false) << "Duplicate device" << std::endl;
+            found = true;
+        }
+    }
+
+    ASSERT_EQ(found, true);
+
+    XIFreeDeviceInfo(info);
+}
+
+
+INSTANTIATE_TEST_CASE_P(, XOrgConfigInputDriverTestDevice,
+                        ::testing::Values("evdev", "synaptics"));
+#endif /* __linux__ */
+
+int main(int argc, char **argv) {
+
+    testing::InitGoogleTest(&argc, argv);
+
+    return RUN_ALL_TESTS();
+}
+
-- 
1.7.10.4



More information about the xorg-devel mailing list