summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2012-11-28 13:01:14 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2012-11-28 13:01:14 +1000
commit39e9ebb667c243c7a87aaa28a53c4e9e67574e61 (patch)
treeb3cd5b10e883173bbd0f5d5d16386e1e4e53dff7
parentcad65cb3a9be068923a430a2934886b0e3d1fb81 (diff)
common/helpers: add simple method for creating a window
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r--tests/common/helpers.cpp27
-rw-r--r--tests/common/helpers.h7
2 files changed, 34 insertions, 0 deletions
diff --git a/tests/common/helpers.cpp b/tests/common/helpers.cpp
index 9cffda7..d6f1d95 100644
--- a/tests/common/helpers.cpp
+++ b/tests/common/helpers.cpp
@@ -205,3 +205,30 @@ void WarpPointer(Display *dpy, int x, int y)
0, 0, 0, 0, x, y);
XSync(dpy, False);
}
+
+Window CreateWindow(Display *dpy, Window parent,
+ int x, int y,
+ int width, int height)
+{
+ Window win;
+
+ if (width == -1)
+ width = DisplayWidth(dpy, DefaultScreen(dpy));
+ if (height == -1)
+ DisplayHeight(dpy, DefaultScreen(dpy));
+ if (parent == None)
+ parent = DefaultRootWindow(dpy);
+
+ win = XCreateSimpleWindow(dpy, parent, x, y, width, height, 0, 0, 0);
+ XSelectInput(dpy, win, StructureNotifyMask);
+ XMapWindow(dpy, win);
+ if (xorg::testing::XServer::WaitForEventOfType(dpy, MapNotify, -1, -1)) {
+ XEvent ev;
+ XNextEvent(dpy, &ev);
+ } else {
+ ADD_FAILURE() << "Failed waiting for Exposure";
+ }
+ XSelectInput(dpy, win, 0);
+ XSync(dpy, False);
+ return win;
+}
diff --git a/tests/common/helpers.h b/tests/common/helpers.h
index 4529870..7ad714b 100644
--- a/tests/common/helpers.h
+++ b/tests/common/helpers.h
@@ -126,5 +126,12 @@ Bool QueryPointerPosition(Display *dpy, double *root_x, double *root_y);
*/
void WarpPointer(Display *dpy, int x, int y);
+/**
+ * Create and map a window below the given parent. Default is a full-screen window.
+ */
+Window CreateWindow(Display *dpy, Window parent = None,
+ int x = 0, int y = 0,
+ int width = -1, int height = -1);
+
#endif