Merge lp:~compiz-team/compiz/compiz.fix_1120009 into lp:compiz/0.9.9

Proposed by Sam Spilsbury
Status: Superseded
Proposed branch: lp:~compiz-team/compiz/compiz.fix_1120009
Merge into: lp:compiz/0.9.9
Diff against target: 447 lines (+318/-24)
7 files modified
debian/control (+1/-0)
src/window.cpp (+19/-18)
tests/system/xorg-gtest/CMakeLists.txt (+2/-2)
tests/system/xorg-gtest/include/compiz-xorg-gtest.h (+27/-0)
tests/system/xorg-gtest/src/compiz-xorg-gtest.cpp (+77/-4)
tests/system/xorg-gtest/tests/CMakeLists.txt (+8/-0)
tests/system/xorg-gtest/tests/compiz_xorg_gtest_test_shape_handling.cpp (+184/-0)
To merge this branch: bzr merge lp:~compiz-team/compiz/compiz.fix_1120009
Reviewer Review Type Date Requested Status
Compiz Maintainers Pending
Review via email: mp+147538@code.launchpad.net

This proposal supersedes a proposal from 2013-02-10.

This proposal has been superseded by a proposal from 2013-02-10.

Commit message

Enable xorg-gtest tests by default and build in CI

(LP: #1120009)

Description of the change

Enable xorg-gtest tests by default and build in CI

(LP: #1120009)

To post a comment you must log in.

Unmerged revisions

3557. By Sam Spilsbury

Enable xorg-gtest tests by default and build in CI

(LP: #1120009)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/control'
2--- debian/control 2012-11-05 21:35:41 +0000
3+++ debian/control 2013-02-10 04:57:28 +0000
4@@ -54,6 +54,7 @@
5 python-pyrex,
6 gnome-control-center-dev,
7 gsettings-desktop-schemas-dev,
8+ libxorg-gtest-dev,
9 Standards-Version: 3.9.3
10 # If you aren't a member of ~compiz-team but need to upload packaging changes,
11 # just go ahead. ~compiz-team will notice and sync up the code again.
12
13=== modified file 'src/window.cpp'
14--- src/window.cpp 2013-02-09 05:37:15 +0000
15+++ src/window.cpp 2013-02-10 04:57:28 +0000
16@@ -905,33 +905,34 @@
17
18 priv->region = priv->inputRegion = emptyRegion;
19
20- bool useXShape = screen->XShape ();
21- if (useXShape)
22- {
23- int order;
24-
25- /* We should update the server here */
26- XSync (screen->dpy (), false);
27-
28- boundingShapeRects = XShapeGetRectangles (screen->dpy (), priv->id,
29- ShapeBounding, &nBounding, &order);
30- inputShapeRects = XShapeGetRectangles (screen->dpy (), priv->id,
31- ShapeInput, &nInput, &order);
32- }
33-
34 r.x = -geom.border ();
35 r.y = -geom.border ();
36 r.width = geom.widthIncBorders ();
37 r.height = geom.heightIncBorders ();
38
39- if (nBounding < 1)
40+ if (screen->XShape ())
41+ {
42+ int order;
43+
44+ /* We should update the server here */
45+ XSync (screen->dpy (), false);
46+
47+ boundingShapeRects = XShapeGetRectangles (screen->dpy (),
48+ priv->id,
49+ ShapeBounding,
50+ &nBounding,
51+ &order);
52+ inputShapeRects = XShapeGetRectangles (screen->dpy (),
53+ priv->id,
54+ ShapeInput,
55+ &nInput,
56+ &order);
57+ }
58+ else
59 {
60 boundingShapeRects = &r;
61 nBounding = 1;
62- }
63
64- if (!useXShape)
65- {
66 inputShapeRects = &r;
67 nInput = 1;
68 }
69
70=== modified file 'tests/system/xorg-gtest/CMakeLists.txt'
71--- tests/system/xorg-gtest/CMakeLists.txt 2012-11-28 14:33:20 +0000
72+++ tests/system/xorg-gtest/CMakeLists.txt 2013-02-10 04:57:28 +0000
73@@ -2,7 +2,7 @@
74
75 pkg_check_modules (XORG_SERVER xorg-gtest xorg-server x11)
76
77-option (BUILD_XORG_GTEST "Build Xorg GTest integration tests" OFF)
78+option (BUILD_XORG_GTEST "Build Xorg GTest integration tests" ON)
79
80 if (XORG_SERVER_FOUND AND BUILD_XORG_GTEST)
81
82@@ -27,7 +27,7 @@
83
84 else (XORG_SERVER_FOUND AND BUILD_XORG_GTEST)
85
86- message (WARNING "Could not found xorg-gtest, not building system tests")
87+ message (WARNING "Not building xorg-gtest tests")
88 set (BUILD_XORG_GTEST OFF)
89
90 endif (XORG_SERVER_FOUND AND BUILD_XORG_GTEST)
91
92=== modified file 'tests/system/xorg-gtest/include/compiz-xorg-gtest.h'
93--- tests/system/xorg-gtest/include/compiz-xorg-gtest.h 2012-12-05 16:01:37 +0000
94+++ tests/system/xorg-gtest/include/compiz-xorg-gtest.h 2013-02-10 04:57:28 +0000
95@@ -75,6 +75,33 @@
96 std::auto_ptr <PrivateConfigureNotifyXEventMatcher> priv;
97 };
98
99+ class PrivateShapeNotifyXEventMatcher;
100+ class ShapeNotifyXEventMatcher :
101+ public compiz::testing::XEventMatcher
102+ {
103+ public:
104+
105+ ShapeNotifyXEventMatcher (int kind,
106+ int x,
107+ int y,
108+ unsigned int width,
109+ unsigned int height,
110+ Bool shaped);
111+
112+ virtual bool MatchAndExplain (const XEvent &event,
113+ MatchResultListener *listener) const;
114+ virtual void DescribeTo (std::ostream *os) const;
115+
116+ private:
117+
118+ std::auto_ptr <PrivateShapeNotifyXEventMatcher> priv;
119+ };
120+
121+ const int WINDOW_X = 0;
122+ const int WINDOW_Y = 0;
123+ const unsigned int WINDOW_WIDTH = 640;
124+ const unsigned int WINDOW_HEIGHT = 480;
125+
126 Window CreateNormalWindow (Display *dpy);
127
128 std::list <Window> NET_CLIENT_LIST_STACKING (Display *);
129
130=== modified file 'tests/system/xorg-gtest/src/compiz-xorg-gtest.cpp'
131--- tests/system/xorg-gtest/src/compiz-xorg-gtest.cpp 2012-12-05 16:01:37 +0000
132+++ tests/system/xorg-gtest/src/compiz-xorg-gtest.cpp 2013-02-10 04:57:28 +0000
133@@ -30,6 +30,7 @@
134 #include <compiz-xorg-gtest.h>
135 #include <X11/Xlib.h>
136 #include <X11/Xatom.h>
137+#include <X11/extensions/shape.h>
138
139 #include "compiz-xorg-gtest-config.h"
140
141@@ -39,10 +40,10 @@
142 namespace ct = compiz::testing;
143 namespace
144 {
145-const int WINDOW_X = 0;
146-const int WINDOW_Y = 0;
147-const unsigned int WINDOW_WIDTH = 640;
148-const unsigned int WINDOW_HEIGHT = 480;
149+const int WINDOW_X = ct::WINDOW_X;
150+const int WINDOW_Y = ct::WINDOW_Y;
151+const unsigned int WINDOW_WIDTH = ct::WINDOW_HEIGHT;
152+const unsigned int WINDOW_HEIGHT = ct::WINDOW_HEIGHT;
153 const unsigned int WINDOW_BORDER = 0;
154 const unsigned int WINDOW_DEPTH = CopyFromParent;
155 const unsigned int WINDOW_CLASS = InputOutput;
156@@ -325,6 +326,78 @@
157 " above: " << std::hex << priv->mAbove << std::dec;
158 }
159
160+class ct::PrivateShapeNotifyXEventMatcher
161+{
162+ public:
163+
164+ PrivateShapeNotifyXEventMatcher (int kind,
165+ int x,
166+ int y,
167+ unsigned int width,
168+ unsigned int height,
169+ Bool shaped) :
170+ mKind (kind),
171+ mX (x),
172+ mY (y),
173+ mWidth (width),
174+ mHeight (height),
175+ mShaped (shaped)
176+ {
177+ }
178+
179+ int mKind;
180+ int mX;
181+ int mY;
182+ unsigned int mWidth;
183+ unsigned int mHeight;
184+ Bool mShaped;
185+};
186+
187+bool
188+ct::ShapeNotifyXEventMatcher::MatchAndExplain (const XEvent &event,
189+ MatchResultListener *listener) const
190+{
191+ const XShapeEvent *sev = reinterpret_cast <const XShapeEvent *> (&event);
192+
193+ return sev->kind == priv->mKind &&
194+ sev->x == priv->mX &&
195+ sev->y == priv->mY &&
196+ sev->width == priv->mWidth &&
197+ sev->height == priv->mHeight &&
198+ sev->shaped == priv->mShaped;
199+}
200+
201+void
202+ct::ShapeNotifyXEventMatcher::DescribeTo (std::ostream *os) const
203+{
204+ std::string kindStr (priv->mKind == ShapeBounding ?
205+ " ShapeBounding " :
206+ " ShapeInput ");
207+
208+ *os << " Matches ShapeNotify with parameters : " << std::endl <<
209+ " kind : " << kindStr <<
210+ " x : " << priv->mX <<
211+ " y : " << priv->mY <<
212+ " width: " << priv->mWidth <<
213+ " height: " << priv->mHeight <<
214+ " shaped: " << priv->mShaped;
215+}
216+
217+ct::ShapeNotifyXEventMatcher::ShapeNotifyXEventMatcher (int kind,
218+ int x,
219+ int y,
220+ unsigned int width,
221+ unsigned int height,
222+ Bool shaped) :
223+ priv (new ct::PrivateShapeNotifyXEventMatcher (kind,
224+ x,
225+ y,
226+ width,
227+ height,
228+ shaped))
229+{
230+}
231+
232 class ct::PrivateCompizProcess
233 {
234 public:
235
236=== modified file 'tests/system/xorg-gtest/tests/CMakeLists.txt'
237--- tests/system/xorg-gtest/tests/CMakeLists.txt 2013-01-11 07:57:32 +0000
238+++ tests/system/xorg-gtest/tests/CMakeLists.txt 2013-02-10 04:57:28 +0000
239@@ -21,6 +21,9 @@
240 add_executable (compiz_xorg_gtest_test_ewmh
241 ${CMAKE_CURRENT_SOURCE_DIR}/compiz_xorg_gtest_ewmh.cpp)
242
243+ add_executable (compiz_xorg_gtest_test_shape_handling
244+ ${CMAKE_CURRENT_SOURCE_DIR}/compiz_xorg_gtest_test_shape_handling.cpp)
245+
246 set (COMPIZ_XORG_GTEST_LIBRARIES
247 compiz_xorg_gtest_system_test
248 xorg_gtest_all
249@@ -46,4 +49,9 @@
250
251 compiz_discover_tests (compiz_xorg_gtest_test_ewmh)
252
253+ target_link_libraries (compiz_xorg_gtest_test_shape_handling
254+ ${COMPIZ_XORG_GTEST_LIBRARIES})
255+
256+ compiz_discover_tests (compiz_xorg_gtest_test_shape_handling)
257+
258 endif (BUILD_XORG_GTEST AND X11_XI_FOUND)
259
260=== added file 'tests/system/xorg-gtest/tests/compiz_xorg_gtest_test_shape_handling.cpp'
261--- tests/system/xorg-gtest/tests/compiz_xorg_gtest_test_shape_handling.cpp 1970-01-01 00:00:00 +0000
262+++ tests/system/xorg-gtest/tests/compiz_xorg_gtest_test_shape_handling.cpp 2013-02-10 04:57:28 +0000
263@@ -0,0 +1,184 @@
264+/*
265+ * Compiz XOrg GTest, window stacking
266+ *
267+ * Copyright (C) 2012 Canonical Ltd.
268+ *
269+ * This library is free software; you can redistribute it and/or
270+ * modify it under the terms of the GNU Lesser General Public
271+ * License as published by the Free Software Foundation; either
272+ * version 2.1 of the License, or (at your option) any later version.
273+
274+ * This library is distributed in the hope that it will be useful,
275+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
276+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
277+ * Lesser General Public License for more details.
278+
279+ * You should have received a copy of the GNU Lesser General Public
280+ * License along with this library; if not, write to the Free Software
281+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
282+ *
283+ * Authored By:
284+ * Sam Spilsbury <sam.spilsbury@canonical.com>
285+ */
286+#include <list>
287+#include <string>
288+#include <stdexcept>
289+#include <gtest/gtest.h>
290+#include <gmock/gmock.h>
291+#include <xorg/gtest/xorg-gtest.h>
292+#include <compiz-xorg-gtest.h>
293+
294+#include <X11/X.h>
295+#include <X11/Xlib.h>
296+#include <X11/Xatom.h>
297+#include <X11/extensions/shape.h>
298+
299+using ::testing::MatchResultListener;
300+using ::testing::MakeMatcher;
301+using ::testing::Matcher;
302+using ::testing::IsNull;
303+using ::testing::NotNull;
304+
305+namespace ct = compiz::testing;
306+
307+namespace
308+{
309+ bool Advance (Display *dpy,
310+ bool waitResult)
311+ {
312+ return ct::AdvanceToNextEventOnSuccess (dpy, waitResult);
313+ }
314+
315+ Window FindTopLevelParent (Display *dpy,
316+ Window child)
317+ {
318+ Window lastParent = child;
319+ Window parent = lastParent, root = None;
320+ Window *children;
321+ unsigned int nchildren;
322+
323+ /* Keep doing XQueryTree until we find a non-root parent */
324+ while (parent != root)
325+ {
326+ lastParent = parent;
327+ XQueryTree (dpy, lastParent, &root, &parent,
328+ &children, &nchildren);
329+
330+ XFree (children);
331+ }
332+
333+ return lastParent;
334+ }
335+}
336+
337+class CompizXorgSystemShapeHandling :
338+ public ct::AutostartCompizXorgSystemTest
339+{
340+ public:
341+
342+ virtual void SetUp ()
343+ {
344+ ct::AutostartCompizXorgSystemTest::SetUp ();
345+
346+ ::Display *dpy = Display ();
347+ XSelectInput (dpy, DefaultRootWindow (dpy),
348+ SubstructureNotifyMask | PropertyChangeMask);
349+ XShapeQueryExtension (dpy, &shapeBase, &shapeError);
350+
351+ shapeEvent = shapeBase + ShapeNotify;
352+
353+ w = ct::CreateNormalWindow (dpy);
354+ XMapRaised (dpy, w);
355+
356+ ASSERT_TRUE (Advance (dpy, ct::WaitForEventOfTypeOnWindow (dpy, w, ReparentNotify, -1, -1)));
357+ ASSERT_TRUE (Advance (dpy, ct::WaitForEventOfTypeOnWindow (dpy, w, MapNotify, -1, -1)));
358+
359+ /* Now that we've received the ReparentNotify, find the toplevel parent */
360+ parent = FindTopLevelParent (dpy, w);
361+
362+ /* Select for ShapeNotify on the parent window */
363+ XShapeSelectInput (dpy, parent, ShapeNotifyMask);
364+ }
365+
366+ int shapeBase;
367+ int shapeError;
368+ int shapeEvent;
369+ Window w;
370+ Window parent;
371+};
372+
373+TEST_F (CompizXorgSystemShapeHandling, TestParentInputShapeSet)
374+{
375+ ::Display *dpy = Display ();
376+
377+ /* Change the input shape on the child window to None */
378+ XShapeCombineRectangles (dpy, w, ShapeInput, 0, 0, NULL, 0, ShapeSet, 0);
379+
380+ ct::ShapeNotifyXEventMatcher matcher (ShapeInput, 0, 0, 0, 0, True);
381+
382+ ASSERT_TRUE (Advance (dpy,
383+ ct::WaitForEventOfTypeOnWindowMatching (dpy,
384+ parent,
385+ shapeEvent,
386+ -1,
387+ 0,
388+ matcher)));
389+
390+ /* Query Input Shape - should be no rectangles */
391+ int n, ordering;
392+ ASSERT_THAT (XShapeGetRectangles (dpy, parent, ShapeInput, &n, &ordering),
393+ IsNull ());
394+ EXPECT_EQ (0, n);
395+
396+ /* Query Bounding Shape - should be one rectangle */
397+ XRectangle *rects =
398+ XShapeGetRectangles (dpy, parent, ShapeBounding, &n, &ordering);
399+ ASSERT_THAT (rects, NotNull ());
400+ ASSERT_EQ (1, n);
401+ EXPECT_EQ (ct::WINDOW_X, rects->x);
402+ EXPECT_EQ (ct::WINDOW_Y, rects->y);
403+ EXPECT_EQ (ct::WINDOW_WIDTH, rects->width);
404+ EXPECT_EQ (ct::WINDOW_HEIGHT, rects->height);
405+}
406+
407+TEST_F (CompizXorgSystemShapeHandling, TestParentBoundingShapeSet)
408+{
409+ ::Display *dpy = Display ();
410+
411+ /* Change the input shape on the child window to None */
412+ XShapeCombineRectangles (dpy,
413+ w,
414+ ShapeBounding,
415+ 0,
416+ 0,
417+ NULL,
418+ 0,
419+ ShapeSet,
420+ 0);
421+
422+ ct::ShapeNotifyXEventMatcher matcher (ShapeBounding, 0, 0, 0, 0, True);
423+
424+ ASSERT_TRUE (Advance (dpy,
425+ ct::WaitForEventOfTypeOnWindowMatching (dpy,
426+ parent,
427+ shapeEvent,
428+ -1,
429+ 0,
430+ matcher)));
431+
432+ /* Query Bounding Shape - should be no rectangles */
433+ int n, ordering;
434+ ASSERT_THAT (XShapeGetRectangles (dpy, parent, ShapeBounding, &n, &ordering),
435+ IsNull ());
436+ EXPECT_EQ (0, n);
437+
438+ /* Query Input Shape - should be one rectangle */
439+ XRectangle *rects =
440+ XShapeGetRectangles (dpy, parent, ShapeInput, &n, &ordering);
441+ ASSERT_THAT (rects, NotNull ());
442+ ASSERT_EQ (1, n);
443+ EXPECT_EQ (ct::WINDOW_X, rects->x);
444+ EXPECT_EQ (ct::WINDOW_Y, rects->y);
445+ EXPECT_EQ (ct::WINDOW_WIDTH, rects->width);
446+ EXPECT_EQ (ct::WINDOW_HEIGHT, rects->height);
447+}

Subscribers

People subscribed via source and target branches