Merge lp:~smspillaz/compiz-core/compiz-core.geometry-tests into lp:compiz-core/0.9.5
- compiz-core.geometry-tests
- Merge into 0.9.5
Proposed by
Sam Spilsbury
Status: | Merged |
---|---|
Merged at revision: | 2923 |
Proposed branch: | lp:~smspillaz/compiz-core/compiz-core.geometry-tests |
Merge into: | lp:compiz-core/0.9.5 |
Prerequisite: | lp:~smspillaz/compiz-core/compiz-core.rect-tests |
Diff against target: |
525 lines (+442/-0) (has conflicts) 10 files modified
plugins/CMakeLists.txt (+1/-0) src/CMakeLists.txt (+5/-0) src/window/CMakeLists.txt (+1/-0) src/window/geometry/CMakeLists.txt (+69/-0) src/window/geometry/include/core/windowgeometry.h (+74/-0) src/window/geometry/src/windowgeometry.cpp (+120/-0) src/window/geometry/tests/CMakeLists.txt (+18/-0) src/window/geometry/tests/test-window-geometry.cpp (+26/-0) src/window/geometry/tests/test-window-geometry.h (+39/-0) src/window/geometry/tests/window-geometry/src/test-window-geometry.cpp (+89/-0) Text conflict in src/CMakeLists.txt |
To merge this branch: | bzr merge lp:~smspillaz/compiz-core/compiz-core.geometry-tests |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Alan Griffiths | Approve | ||
Review via email: mp+89385@code.launchpad.net |
Commit message
Description of the change
Added a compiz:
CompWindow:
To post a comment you must log in.
- 2922. By Sam Spilsbury
-
Merged compiz-
core.rect- tests into compiz- core.geometry- tests.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'plugins/CMakeLists.txt' |
2 | --- plugins/CMakeLists.txt 2012-01-20 09:51:31 +0000 |
3 | +++ plugins/CMakeLists.txt 2012-01-20 09:51:31 +0000 |
4 | @@ -16,6 +16,7 @@ |
5 | ${CMAKE_CURRENT_SOURCE_DIR}/../src/pluginclasshandler/include |
6 | ${CMAKE_CURRENT_SOURCE_DIR}/../src/point/include |
7 | ${CMAKE_CURRENT_SOURCE_DIR}/../src/rect/include |
8 | + ${CMAKE_CURRENT_SOURCE_DIR}/../src/window/geometry/include |
9 | ${CMAKE_CURRENT_SOURCE_DIR}/../logmessage/include |
10 | ) |
11 | |
12 | |
13 | === modified file 'src/CMakeLists.txt' |
14 | --- src/CMakeLists.txt 2012-01-20 09:51:31 +0000 |
15 | +++ src/CMakeLists.txt 2012-01-20 09:51:31 +0000 |
16 | @@ -7,6 +7,7 @@ |
17 | add_subdirectory( pluginclasshandler ) |
18 | add_subdirectory( point ) |
19 | add_subdirectory( rect ) |
20 | +add_subdirectory( window ) |
21 | add_subdirectory( wrapsystem/tests ) |
22 | |
23 | compiz_add_bcop_targets ( |
24 | @@ -48,6 +49,9 @@ |
25 | |
26 | ${CMAKE_CURRENT_SOURCE_DIR}/rect/include |
27 | ${CMAKE_CURRENT_SOURCE_DIR}/rect/src |
28 | + |
29 | + ${CMAKE_CURRENT_SOURCE_DIR}/window/geometry/include |
30 | + ${CMAKE_CURRENT_SOURCE_DIR}/window/geometry/src |
31 | ) |
32 | |
33 | add_definitions ( |
34 | @@ -144,6 +148,7 @@ |
35 | compiz_pluginclasshandler |
36 | compiz_point |
37 | compiz_rect |
38 | + compiz_window_geometry |
39 | # ${CORE_MOD_LIBRARIES} |
40 | >>>>>>> MERGE-SOURCE |
41 | ) |
42 | |
43 | === added directory 'src/window' |
44 | === added file 'src/window/CMakeLists.txt' |
45 | --- src/window/CMakeLists.txt 1970-01-01 00:00:00 +0000 |
46 | +++ src/window/CMakeLists.txt 2012-01-20 09:51:31 +0000 |
47 | @@ -0,0 +1,1 @@ |
48 | +add_subdirectory (geometry) |
49 | |
50 | === added directory 'src/window/geometry' |
51 | === added file 'src/window/geometry/CMakeLists.txt' |
52 | --- src/window/geometry/CMakeLists.txt 1970-01-01 00:00:00 +0000 |
53 | +++ src/window/geometry/CMakeLists.txt 2012-01-20 09:51:31 +0000 |
54 | @@ -0,0 +1,69 @@ |
55 | +pkg_check_modules ( |
56 | + GLIBMM |
57 | + REQUIRED |
58 | + glibmm-2.4 glib-2.0 |
59 | +) |
60 | + |
61 | +INCLUDE_DIRECTORIES ( |
62 | + ${CMAKE_CURRENT_SOURCE_DIR}/include |
63 | + ${CMAKE_CURRENT_SOURCE_DIR}/src |
64 | + |
65 | + ${compiz_SOURCE_DIR}/include |
66 | + ${compiz_SOURCE_DIR}/src/point/include |
67 | + ${compiz_SOURCE_DIR}/src/rect/include |
68 | + |
69 | + ${Boost_INCLUDE_DIRS} |
70 | + |
71 | + ${GLIBMM_INCLUDE_DIRS} |
72 | +) |
73 | + |
74 | +LINK_DIRECTORIES (${GLIBMM_LIBRARY_DIRS}) |
75 | + |
76 | +SET ( |
77 | + PUBLIC_HEADERS |
78 | + ${CMAKE_CURRENT_SOURCE_DIR}/include/core/windowgeometry.h |
79 | +) |
80 | + |
81 | +SET ( |
82 | + PRIVATE_HEADERS |
83 | +) |
84 | + |
85 | +SET( |
86 | + SRCS |
87 | + ${CMAKE_CURRENT_SOURCE_DIR}/src/windowgeometry.cpp |
88 | +) |
89 | + |
90 | +ADD_LIBRARY( |
91 | + compiz_window_geometry STATIC |
92 | + |
93 | + ${SRCS} |
94 | + |
95 | + ${PUBLIC_HEADERS} |
96 | + ${PRIVATE_HEADERS} |
97 | +) |
98 | + |
99 | +ADD_SUBDIRECTORY( ${CMAKE_CURRENT_SOURCE_DIR}/tests ) |
100 | + |
101 | +SET_TARGET_PROPERTIES( |
102 | + compiz_window_geometry PROPERTIES |
103 | + PUBLIC_HEADER "${PUBLIC_HEADERS}" |
104 | + COMPILE_FLAGS "-fPIC" |
105 | +) |
106 | + |
107 | +INSTALL( |
108 | + TARGETS compiz_window_geometry |
109 | + RUNTIME DESTINATION bin |
110 | + LIBRARY DESTINATION lib |
111 | + ARCHIVE DESTINATION lib |
112 | + PUBLIC_HEADER DESTINATION include/compiz/core |
113 | +) |
114 | + |
115 | + |
116 | + |
117 | +TARGET_LINK_LIBRARIES( |
118 | + compiz_window_geometry |
119 | + compiz_point |
120 | + compiz_rect |
121 | + |
122 | + ${GLIBMM_LIBRARIES} |
123 | +) |
124 | |
125 | === added directory 'src/window/geometry/include' |
126 | === added directory 'src/window/geometry/include/core' |
127 | === added file 'src/window/geometry/include/core/windowgeometry.h' |
128 | --- src/window/geometry/include/core/windowgeometry.h 1970-01-01 00:00:00 +0000 |
129 | +++ src/window/geometry/include/core/windowgeometry.h 2012-01-20 09:51:31 +0000 |
130 | @@ -0,0 +1,74 @@ |
131 | +/* |
132 | + * Copyright © 2011 Canonical Ltd. |
133 | + * Copyright © 2008 Dennis Kasprzyk |
134 | + * Copyright © 2007 Novell, Inc. |
135 | + * |
136 | + * Permission to use, copy, modify, distribute, and sell this software |
137 | + * and its documentation for any purpose is hereby granted without |
138 | + * fee, provided that the above copyright notice appear in all copies |
139 | + * and that both that copyright notice and this permission notice |
140 | + * appear in supporting documentation, and that the name of |
141 | + * Dennis Kasprzyk not be used in advertising or publicity pertaining to |
142 | + * distribution of the software without specific, written prior permission. |
143 | + * Dennis Kasprzyk makes no representations about the suitability of this |
144 | + * software for any purpose. It is provided "as is" without express or |
145 | + * implied warranty. |
146 | + * |
147 | + * DENNIS KASPRZYK DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, |
148 | + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN |
149 | + * NO EVENT SHALL DENNIS KASPRZYK BE LIABLE FOR ANY SPECIAL, INDIRECT OR |
150 | + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS |
151 | + * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, |
152 | + * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION |
153 | + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
154 | + * |
155 | + * Authors: Dennis Kasprzyk <onestone@compiz-fusion.org> |
156 | + * David Reveman <davidr@novell.com> |
157 | + */ |
158 | + |
159 | +#ifndef _COMPWINDOWGEOMETRY_H |
160 | +#define _COMPWINDOWGEOMETRY_H |
161 | + |
162 | +#include <core/rect.h> |
163 | + |
164 | +enum ChangeMask |
165 | +{ |
166 | + CHANGE_X = 1 << 0, |
167 | + CHANGE_Y = 1 << 1, |
168 | + CHANGE_WIDTH = 1 << 2, |
169 | + CHANGE_HEIGHT = 1 << 3, |
170 | + CHANGE_BORDER = 1 << 4 |
171 | +}; |
172 | + |
173 | +namespace compiz |
174 | +{ |
175 | +namespace window |
176 | +{ |
177 | + |
178 | +/** |
179 | + * A mutable object about the dimensions and location of a CompWindow. |
180 | + */ |
181 | +class Geometry : |
182 | + public CompRect |
183 | +{ |
184 | +public: |
185 | + Geometry (); |
186 | + Geometry (int x, int y, int width, int height, int border); |
187 | + |
188 | + int border () const; |
189 | + |
190 | + void set (int x, int y, int width, int height, int border); |
191 | + void setBorder (int border); |
192 | + |
193 | + unsigned int changeMask (const compiz::window::Geometry &g) const; |
194 | + compiz::window::Geometry change (const compiz::window::Geometry &g, unsigned int mask) const; |
195 | + void applyChange (const compiz::window::Geometry &g, unsigned int mask); |
196 | + |
197 | +private: |
198 | + int mBorder; |
199 | +}; |
200 | + |
201 | +} |
202 | +} |
203 | + |
204 | +#endif |
205 | |
206 | === added directory 'src/window/geometry/src' |
207 | === added file 'src/window/geometry/src/windowgeometry.cpp' |
208 | --- src/window/geometry/src/windowgeometry.cpp 1970-01-01 00:00:00 +0000 |
209 | +++ src/window/geometry/src/windowgeometry.cpp 2012-01-20 09:51:31 +0000 |
210 | @@ -0,0 +1,120 @@ |
211 | +/* |
212 | + * Copyright © 2008 Dennis Kasprzyk |
213 | + * |
214 | + * Permission to use, copy, modify, distribute, and sell this software |
215 | + * and its documentation for any purpose is hereby granted without |
216 | + * fee, provided that the above copyright notice appear in all copies |
217 | + * and that both that copyright notice and this permission notice |
218 | + * appear in supporting documentation, and that the name of |
219 | + * Dennis Kasprzyk not be used in advertising or publicity pertaining to |
220 | + * distribution of the software without specific, written prior permission. |
221 | + * Dennis Kasprzyk makes no representations about the suitability of this |
222 | + * software for any purpose. It is provided "as is" without express or |
223 | + * implied warranty. |
224 | + * |
225 | + * DENNIS KASPRZYK DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, |
226 | + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN |
227 | + * NO EVENT SHALL DENNIS KASPRZYK BE LIABLE FOR ANY SPECIAL, INDIRECT OR |
228 | + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS |
229 | + * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, |
230 | + * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION |
231 | + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
232 | + * |
233 | + * Authors: Dennis Kasprzyk <onestone@compiz-fusion.org> |
234 | + */ |
235 | + |
236 | +#include <core/windowgeometry.h> |
237 | + |
238 | + |
239 | +compiz::window::Geometry::Geometry () : |
240 | + mBorder (0) |
241 | +{ |
242 | +} |
243 | + |
244 | +compiz::window::Geometry::Geometry (int x, |
245 | + int y, |
246 | + int width, |
247 | + int height, |
248 | + int border) : |
249 | + CompRect (x, y, width, height), |
250 | + mBorder (border) |
251 | +{ |
252 | +} |
253 | + |
254 | +int |
255 | +compiz::window::Geometry::border () const |
256 | +{ |
257 | + return mBorder; |
258 | +} |
259 | + |
260 | +void |
261 | +compiz::window::Geometry::setBorder (int border) |
262 | +{ |
263 | + mBorder = border; |
264 | +} |
265 | + |
266 | +void |
267 | +compiz::window::Geometry::set (int x, |
268 | + int y, |
269 | + int width, |
270 | + int height, |
271 | + int border) |
272 | +{ |
273 | + setX (x); |
274 | + setY (y); |
275 | + setWidth (width); |
276 | + setHeight (height); |
277 | + mBorder = border; |
278 | +} |
279 | + |
280 | +unsigned int |
281 | +compiz::window::Geometry::changeMask (const compiz::window::Geometry &g) const |
282 | +{ |
283 | + unsigned int mask = 0; |
284 | + |
285 | + if (g.x () != x ()) |
286 | + mask |= CHANGE_X; |
287 | + |
288 | + if (g.y () != y ()) |
289 | + mask |= CHANGE_Y; |
290 | + |
291 | + if (g.width () != width ()) |
292 | + mask |= CHANGE_WIDTH; |
293 | + |
294 | + if (g.height () != height ()) |
295 | + mask |= CHANGE_HEIGHT; |
296 | + |
297 | + if (g.border () != border ()) |
298 | + mask |= CHANGE_BORDER; |
299 | + |
300 | + return mask; |
301 | +} |
302 | + |
303 | +compiz::window::Geometry |
304 | +compiz::window::Geometry::change (const compiz::window::Geometry &g, unsigned int mask) const |
305 | +{ |
306 | + compiz::window::Geometry rg = *this; |
307 | + |
308 | + rg.applyChange (g, mask); |
309 | + |
310 | + return rg; |
311 | +} |
312 | + |
313 | +void |
314 | +compiz::window::Geometry::applyChange (const compiz::window::Geometry &g, unsigned int mask) |
315 | +{ |
316 | + if (mask & CHANGE_X) |
317 | + setX (g.x ()); |
318 | + |
319 | + if (mask & CHANGE_Y) |
320 | + setY (g.y ()); |
321 | + |
322 | + if (mask & CHANGE_WIDTH) |
323 | + setWidth (g.width ()); |
324 | + |
325 | + if (mask & CHANGE_HEIGHT) |
326 | + setHeight (g.height ()); |
327 | + |
328 | + if (mask & CHANGE_BORDER) |
329 | + setBorder (g.border ()); |
330 | +} |
331 | |
332 | === added directory 'src/window/geometry/tests' |
333 | === added file 'src/window/geometry/tests/CMakeLists.txt' |
334 | --- src/window/geometry/tests/CMakeLists.txt 1970-01-01 00:00:00 +0000 |
335 | +++ src/window/geometry/tests/CMakeLists.txt 2012-01-20 09:51:31 +0000 |
336 | @@ -0,0 +1,18 @@ |
337 | +include_directories(${CMAKE_CURRENT_SOURCE_DIR}) |
338 | + |
339 | +add_library (compiz_window_geometry_test |
340 | + ${CMAKE_CURRENT_SOURCE_DIR}/test-window-geometry.cpp) |
341 | + |
342 | +add_executable (compiz_test_window_geometry |
343 | + ${CMAKE_CURRENT_SOURCE_DIR}/window-geometry/src/test-window-geometry.cpp) |
344 | + |
345 | +target_link_libraries (compiz_test_window_geometry |
346 | + compiz_window_geometry_test |
347 | + compiz_window_geometry |
348 | + ${GTEST_BOTH_LIBRARIES} |
349 | + ${GMOCK_LIBRARY} |
350 | + ${GMOCK_MAIN_LIBRARY} |
351 | + ${CMAKE_THREAD_LIBS_INIT} # Link in pthread. |
352 | + ) |
353 | + |
354 | +add_test (compiz_window_geometry compiz_test_window_geometry) |
355 | |
356 | === added file 'src/window/geometry/tests/test-window-geometry.cpp' |
357 | --- src/window/geometry/tests/test-window-geometry.cpp 1970-01-01 00:00:00 +0000 |
358 | +++ src/window/geometry/tests/test-window-geometry.cpp 2012-01-20 09:51:31 +0000 |
359 | @@ -0,0 +1,26 @@ |
360 | +/* |
361 | + * Copyright © 2011 Canonical Ltd. |
362 | + * |
363 | + * Permission to use, copy, modify, distribute, and sell this software |
364 | + * and its documentation for any purpose is hereby granted without |
365 | + * fee, provided that the above copyright notice appear in all copies |
366 | + * and that both that copyright notice and this permission notice |
367 | + * appear in supporting documentation, and that the name of |
368 | + * Canonical Ltd. not be used in advertising or publicity pertaining to |
369 | + * distribution of the software without specific, written prior permission. |
370 | + * Canonical Ltd. makes no representations about the suitability of this |
371 | + * software for any purpose. It is provided "as is" without express or |
372 | + * implied warranty. |
373 | + * |
374 | + * CANONICAL, LTD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, |
375 | + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN |
376 | + * NO EVENT SHALL CANONICAL, LTD. BE LIABLE FOR ANY SPECIAL, INDIRECT OR |
377 | + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS |
378 | + * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, |
379 | + * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION |
380 | + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
381 | + * |
382 | + * Authored by: Sam Spilsbury <sam.spilsbury@canonical.com> |
383 | + */ |
384 | + |
385 | +#include "test-window-geometry.h" |
386 | |
387 | === added file 'src/window/geometry/tests/test-window-geometry.h' |
388 | --- src/window/geometry/tests/test-window-geometry.h 1970-01-01 00:00:00 +0000 |
389 | +++ src/window/geometry/tests/test-window-geometry.h 2012-01-20 09:51:31 +0000 |
390 | @@ -0,0 +1,39 @@ |
391 | +/* |
392 | + * Copyright © 2011 Canonical Ltd. |
393 | + * |
394 | + * Permission to use, copy, modify, distribute, and sell this software |
395 | + * and its documentation for any purpose is hereby granted without |
396 | + * fee, provided that the above copyright notice appear in all copies |
397 | + * and that both that copyright notice and this permission notice |
398 | + * appear in supporting documentation, and that the name of |
399 | + * Canonical Ltd. not be used in advertising or publicity pertaining to |
400 | + * distribution of the software without specific, written prior permission. |
401 | + * Canonical Ltd. makes no representations about the suitability of this |
402 | + * software for any purpose. It is provided "as is" without express or |
403 | + * implied warranty. |
404 | + * |
405 | + * CANONICAL, LTD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, |
406 | + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN |
407 | + * NO EVENT SHALL CANONICAL, LTD. BE LIABLE FOR ANY SPECIAL, INDIRECT OR |
408 | + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS |
409 | + * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, |
410 | + * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION |
411 | + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
412 | + * |
413 | + * Authored by: Sam Spilsbury <sam.spilsbury@canonical.com> |
414 | + */ |
415 | + |
416 | +#ifndef _COMPIZ_TEST_WINDOW_GEOMETRY_H |
417 | +#define _COMPIZ_TEST_WINDOW_GEOMETRY_H |
418 | + |
419 | +#include <gtest/gtest.h> |
420 | +#include <core/windowgeometry.h> |
421 | +#include <core/rect.h> |
422 | +#include <iostream> |
423 | +#include <boost/bind.hpp> |
424 | + |
425 | +class CompWindowGeometryTest : public ::testing::Test |
426 | +{ |
427 | +}; |
428 | + |
429 | +#endif |
430 | |
431 | === added directory 'src/window/geometry/tests/window-geometry' |
432 | === added directory 'src/window/geometry/tests/window-geometry/src' |
433 | === added file 'src/window/geometry/tests/window-geometry/src/test-window-geometry.cpp' |
434 | --- src/window/geometry/tests/window-geometry/src/test-window-geometry.cpp 1970-01-01 00:00:00 +0000 |
435 | +++ src/window/geometry/tests/window-geometry/src/test-window-geometry.cpp 2012-01-20 09:51:31 +0000 |
436 | @@ -0,0 +1,89 @@ |
437 | +/* |
438 | + * Copyright © 2011 Canonical Ltd. |
439 | + * |
440 | + * Permission to use, copy, modify, distribute, and sell this software |
441 | + * and its documentation for any purpose is hereby granted without |
442 | + * fee, provided that the above copyright notice appear in all copies |
443 | + * and that both that copyright notice and this permission notice |
444 | + * appear in supporting documentation, and that the name of |
445 | + * Canonical Ltd. not be used in advertising or publicity pertaining to |
446 | + * distribution of the software without specific, written prior permission. |
447 | + * Canonical Ltd. makes no representations about the suitability of this |
448 | + * software for any purpose. It is provided "as is" without express or |
449 | + * implied warranty. |
450 | + * |
451 | + * CANONICAL, LTD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, |
452 | + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN |
453 | + * NO EVENT SHALL CANONICAL, LTD. BE LIABLE FOR ANY SPECIAL, INDIRECT OR |
454 | + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS |
455 | + * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, |
456 | + * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION |
457 | + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
458 | + * |
459 | + * Authored by: Sam Spilsbury <sam.spilsbury@canonical.com> |
460 | + */ |
461 | + |
462 | +#include "test-window-geometry.h" |
463 | + |
464 | +class CompWindowGeometryTestGeometry : |
465 | + public CompWindowGeometryTest |
466 | +{ |
467 | + public: |
468 | + |
469 | + CompWindowGeometryTestGeometry (); |
470 | + ~CompWindowGeometryTestGeometry (); |
471 | + |
472 | + protected: |
473 | + |
474 | + compiz::window::Geometry g; |
475 | +}; |
476 | + |
477 | +CompWindowGeometryTestGeometry::CompWindowGeometryTestGeometry () : |
478 | + g (50, 100, 200, 300, 5) |
479 | +{ |
480 | +} |
481 | + |
482 | +CompWindowGeometryTestGeometry::~CompWindowGeometryTestGeometry () |
483 | +{ |
484 | +} |
485 | + |
486 | +TEST_F (CompWindowGeometryTestGeometry, TestGeometry) |
487 | +{ |
488 | + |
489 | + /* apply x only */ |
490 | + compiz::window::Geometry rg = compiz::window::Geometry (); |
491 | + rg.applyChange (g, CHANGE_X); |
492 | + |
493 | + EXPECT_EQ (rg, compiz::window::Geometry (50, 0, 0, 0, 0)); |
494 | + |
495 | + /* apply y only */ |
496 | + rg = compiz::window::Geometry (); |
497 | + rg.applyChange (g, CHANGE_Y); |
498 | + |
499 | + EXPECT_EQ (rg, compiz::window::Geometry (0, 100, 0, 0, 0)); |
500 | + |
501 | + /* apply width only */ |
502 | + rg = compiz::window::Geometry (); |
503 | + rg.applyChange (g, CHANGE_WIDTH); |
504 | + |
505 | + EXPECT_EQ (rg, compiz::window::Geometry (0, 0, 200, 0, 0)); |
506 | + |
507 | + /* apply height only */ |
508 | + rg = compiz::window::Geometry (); |
509 | + rg.applyChange (g, CHANGE_HEIGHT); |
510 | + |
511 | + EXPECT_EQ (rg, compiz::window::Geometry (0, 0, 0, 300, 0)); |
512 | + |
513 | + /* apply width | height */ |
514 | + rg = compiz::window::Geometry (); |
515 | + rg.applyChange (g, CHANGE_WIDTH | CHANGE_HEIGHT); |
516 | + |
517 | + EXPECT_EQ (rg, compiz::window::Geometry (0, 0, 200, 300, 0)); |
518 | + |
519 | + /* change mask for x | y | width | height */ |
520 | + rg = compiz::window::Geometry (49, 99, 199, 299, 5); |
521 | + unsigned int mask = rg.changeMask (g); |
522 | + |
523 | + EXPECT_EQ (rg, compiz::window::Geometry (49, 99, 199, 299, 5)); |
524 | + EXPECT_EQ (mask, CHANGE_X | CHANGE_Y | CHANGE_WIDTH | CHANGE_HEIGHT); |
525 | +} |
There seems to be a lot of scaffolding to introduce a single test.
You can drop test-window- geometry. h and /tests/ test-window- geometry. cpp - all you need is:
TEST(TestSuite, test_name)
// test body