summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2012-11-02 11:21:49 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2012-11-02 13:45:57 +1000
commitfa567e1e2c52e1a77952f91a6ba20b6d55240808 (patch)
treef3395550e50a22d7f24ed6e69a8efbd660dcd321
parent23c1bbef8d50aaa2c26f32b25d34a73b53e49d4a (diff)
common: add DeviceIDToString helper
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r--tests/common/helpers.cpp13
-rw-r--r--tests/common/helpers.h9
2 files changed, 22 insertions, 0 deletions
diff --git a/tests/common/helpers.cpp b/tests/common/helpers.cpp
index e7ef3b4..f48a134 100644
--- a/tests/common/helpers.cpp
+++ b/tests/common/helpers.cpp
@@ -3,6 +3,8 @@
#endif
#include "helpers.h"
+#include <sstream>
+
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#include <X11/extensions/XInput2.h>
@@ -167,3 +169,14 @@ XErrorEvent * ReleaseErrorTrap(Display *dpy) {
trap_state.is_trapping = False;
return error;
}
+
+std::string DeviceIDToString(int deviceid) {
+ switch (deviceid) {
+ case XIAllDevices:
+ return "XIAllDevices";
+ case XIAllMasterDevices:
+ return "XIAllMasterDevices";
+ default:
+ return static_cast<std::ostringstream*>(&(std::ostringstream() << deviceid) )->str();
+ }
+}
diff --git a/tests/common/helpers.h b/tests/common/helpers.h
index 7056f17..43f7c76 100644
--- a/tests/common/helpers.h
+++ b/tests/common/helpers.h
@@ -101,5 +101,14 @@ XErrorEvent * ReleaseErrorTrap(Display *dpy);
#define ASSERT_NO_ERROR(err) \
ASSERT_TRUE(err == NULL) << "Expected no error"
+
+/**
+ * Does not much for normal device IDs, but returns
+ * XIAllDevices/XIAllMasterDevices where applicable.
+ *
+ * @return string representing this deviceID.
+ */
+std::string DeviceIDToString(int deviceid);
+
#endif