Status: | Merged |
---|---|
Merged at revision: | 213 |
Proposed branch: | lp:~bregma/geis/lp-937021 |
Merge into: | lp:geis |
Diff against target: |
499 lines (+261/-56) 10 files modified
.bzrignore (+3/-3) configure.ac (+3/-1) libutouch-geis/backend/grail/geis_grail_backend.c (+15/-1) libutouch-geis/backend/grail/geis_grail_window_grab.c (+15/-4) libutouch-geis/backend/grail/geis_grail_window_grab.h (+4/-2) testsuite/geis2/Makefile.am (+3/-1) testsuite/geis2/gtest_attrs.cpp (+9/-44) testsuite/geis2/gtest_geis_fixture.cpp (+64/-0) testsuite/geis2/gtest_geis_fixture.h (+50/-0) testsuite/geis2/gtest_subscriptions.cpp (+95/-0) |
To merge this branch: | bzr merge lp:~bregma/geis/lp-937021 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Chase Douglas (community) | Approve | ||
Review via email: mp+94837@code.launchpad.net |
Commit message
Description of the change
Check he success of grabbing multi-touch input on a window and propagates the result up the stack.
Fixes lp:937021.
Fix can be verified by running the geistest tool without any command-line arguments so that it attempts to grab input from the root window. This will now fail, additional error messages are show if the environment variable GEIS_DEBUG is set to an integer value greater than or equal to 1.
Jussi Pakkanen (jpakkane) wrote : | # |
Chase Douglas (chasedouglas) wrote : | # |
This needs an automated test that runs at 'make check'.
- 210. By Stephen M. Webb
-
synched with trunk
- 211. By Stephen M. Webb
-
Refactored GEIS test fixture.
- 212. By Stephen M. Webb
-
Removed warnings from configure.
- 213. By Stephen M. Webb
-
Added test case for lp:937021
- 214. By Stephen M. Webb
-
Got lp:937021 test case passing (when evemu works).
- 215. By Stephen M. Webb
-
Eliminated transient evemy device creation failures.
Stephen M. Webb (bregma) wrote : | # |
OK, test cases seem to pass every time. Ready for full review.
Chase Douglas (chasedouglas) wrote : | # |
Looks good to me :). The GeisSubscriptio
- 216. By Stephen M. Webb
-
Removed unnecessary fixture SetUp() and TearDown() in gtest-based tests.
Preview Diff
1 | === modified file '.bzrignore' | |||
2 | --- .bzrignore 2012-02-21 20:31:39 +0000 | |||
3 | +++ .bzrignore 2012-03-07 18:15:24 +0000 | |||
4 | @@ -10,9 +10,9 @@ | |||
5 | 10 | *Makefile.in | 10 | *Makefile.in |
6 | 11 | aclocal.m4 | 11 | aclocal.m4 |
7 | 12 | autom4te.cache | 12 | autom4te.cache |
11 | 13 | check_geis1_api | 13 | check-*-compile |
12 | 14 | check_geis2_api | 14 | check_*_api |
13 | 15 | check_geis2_internals | 15 | check_*_internals |
14 | 16 | check_geis_util | 16 | check_geis_util |
15 | 17 | config.* | 17 | config.* |
16 | 18 | configure | 18 | configure |
17 | 19 | 19 | ||
18 | === modified file 'configure.ac' | |||
19 | --- configure.ac 2012-02-23 17:07:26 +0000 | |||
20 | +++ configure.ac 2012-03-07 18:15:24 +0000 | |||
21 | @@ -32,6 +32,7 @@ | |||
22 | 32 | 32 | ||
23 | 33 | # Checks for programs. | 33 | # Checks for programs. |
24 | 34 | AM_PROG_CC_C_O | 34 | AM_PROG_CC_C_O |
25 | 35 | AC_PROG_CXX | ||
26 | 35 | AM_PATH_PYTHON([2.7]) | 36 | AM_PATH_PYTHON([2.7]) |
27 | 36 | 37 | ||
28 | 37 | LT_PREREQ([2.2.6b]) | 38 | LT_PREREQ([2.2.6b]) |
29 | @@ -99,7 +100,7 @@ | |||
30 | 99 | [with_integration_tests=check]) | 100 | [with_integration_tests=check]) |
31 | 100 | AC_MSG_RESULT([$with_integration_tests]) | 101 | AC_MSG_RESULT([$with_integration_tests]) |
32 | 101 | AS_IF([test "x$with_integration_tests" != xno], | 102 | AS_IF([test "x$with_integration_tests" != xno], |
34 | 102 | [AC_PROG_CXX | 103 | [AC_LANG_PUSH(C++) |
35 | 103 | AC_CHECK_LIB([gtest], [main], [have_gtest=yes]) | 104 | AC_CHECK_LIB([gtest], [main], [have_gtest=yes]) |
36 | 104 | AS_IF([test "x$have_gtest" = xyes], | 105 | AS_IF([test "x$have_gtest" = xyes], |
37 | 105 | [PKG_CHECK_MODULES([XORG_GTEST], | 106 | [PKG_CHECK_MODULES([XORG_GTEST], |
38 | @@ -109,6 +110,7 @@ | |||
39 | 109 | unit testing disabled])]) | 110 | unit testing disabled])]) |
40 | 110 | PKG_CHECK_MODULES([EVEMU],[utouch-evemu >= 1.0.5]) | 111 | PKG_CHECK_MODULES([EVEMU],[utouch-evemu >= 1.0.5]) |
41 | 111 | ]) | 112 | ]) |
42 | 113 | AC_LANG_POP | ||
43 | 112 | XORG_GTEST_LIBS="$XORG_GTEST_LIBS -lgtest -lpthread"]) | 114 | XORG_GTEST_LIBS="$XORG_GTEST_LIBS -lgtest -lpthread"]) |
44 | 113 | AM_CONDITIONAL([HAVE_XORG_GTEST],[test "x$have_xorg_gtest" = xyes]) | 115 | AM_CONDITIONAL([HAVE_XORG_GTEST],[test "x$have_xorg_gtest" = xyes]) |
45 | 114 | 116 | ||
46 | 115 | 117 | ||
47 | === modified file 'libutouch-geis/backend/grail/geis_grail_backend.c' | |||
48 | --- libutouch-geis/backend/grail/geis_grail_backend.c 2012-02-24 17:12:40 +0000 | |||
49 | +++ libutouch-geis/backend/grail/geis_grail_backend.c 2012-03-07 18:15:24 +0000 | |||
50 | @@ -1437,7 +1437,13 @@ | |||
51 | 1437 | (void *)ugsub, | 1437 | (void *)ugsub, |
52 | 1438 | grail_use_atomic_gestures); | 1438 | grail_use_atomic_gestures); |
53 | 1439 | 1439 | ||
55 | 1440 | geis_grail_window_grab_store_grab(gbe->window_grabs, window_id); | 1440 | status = geis_grail_window_grab_store_grab(gbe->window_grabs, window_id); |
56 | 1441 | if (status != GEIS_STATUS_SUCCESS) | ||
57 | 1442 | { | ||
58 | 1443 | geis_error("failed to grab input on window 0x%08x", window_id); | ||
59 | 1444 | goto final_exit; | ||
60 | 1445 | } | ||
61 | 1446 | |||
62 | 1441 | ugstatus = grail_subscription_activate(gbe->grail, ugsub); | 1447 | ugstatus = grail_subscription_activate(gbe->grail, ugsub); |
63 | 1442 | if (ugstatus != UGStatusSuccess) | 1448 | if (ugstatus != UGStatusSuccess) |
64 | 1443 | { | 1449 | { |
65 | @@ -1486,6 +1492,10 @@ | |||
66 | 1486 | device, | 1492 | device, |
67 | 1487 | window_id, | 1493 | window_id, |
68 | 1488 | subscription); | 1494 | subscription); |
69 | 1495 | if (status != GEIS_STATUS_SUCCESS) | ||
70 | 1496 | { | ||
71 | 1497 | goto final_exit; | ||
72 | 1498 | } | ||
73 | 1489 | } | 1499 | } |
74 | 1490 | else | 1500 | else |
75 | 1491 | { | 1501 | { |
76 | @@ -1506,6 +1516,8 @@ | |||
77 | 1506 | subscription); | 1516 | subscription); |
78 | 1507 | } | 1517 | } |
79 | 1508 | } | 1518 | } |
80 | 1519 | |||
81 | 1520 | final_exit: | ||
82 | 1509 | return status; | 1521 | return status; |
83 | 1510 | } | 1522 | } |
84 | 1511 | 1523 | ||
85 | @@ -1558,6 +1570,8 @@ | |||
86 | 1558 | status = GEIS_STATUS_SUCCESS; | 1570 | status = GEIS_STATUS_SUCCESS; |
87 | 1559 | } | 1571 | } |
88 | 1560 | geis_device_bag_delete(selected_devices); | 1572 | geis_device_bag_delete(selected_devices); |
89 | 1573 | if (status != GEIS_STATUS_SUCCESS) | ||
90 | 1574 | break; | ||
91 | 1561 | } | 1575 | } |
92 | 1562 | 1576 | ||
93 | 1563 | return status; | 1577 | return status; |
94 | 1564 | 1578 | ||
95 | === modified file 'libutouch-geis/backend/grail/geis_grail_window_grab.c' | |||
96 | --- libutouch-geis/backend/grail/geis_grail_window_grab.c 2012-03-02 17:54:50 +0000 | |||
97 | +++ libutouch-geis/backend/grail/geis_grail_window_grab.c 2012-03-07 18:15:24 +0000 | |||
98 | @@ -20,7 +20,6 @@ | |||
99 | 20 | #include "geis_config.h" | 20 | #include "geis_config.h" |
100 | 21 | #include "geis_grail_window_grab.h" | 21 | #include "geis_grail_window_grab.h" |
101 | 22 | 22 | ||
102 | 23 | #include "geis/geis.h" | ||
103 | 24 | #include "geis_bag.h" | 23 | #include "geis_bag.h" |
104 | 25 | #include "geis_logging.h" | 24 | #include "geis_logging.h" |
105 | 26 | #include <X11/extensions/XInput2.h> | 25 | #include <X11/extensions/XInput2.h> |
106 | @@ -124,9 +123,10 @@ | |||
107 | 124 | /* | 123 | /* |
108 | 125 | * Grabs a window through a window grab store. | 124 | * Grabs a window through a window grab store. |
109 | 126 | */ | 125 | */ |
111 | 127 | void | 126 | GeisStatus |
112 | 128 | geis_grail_window_grab_store_grab(GeisGrailWindowGrabStore wgs, Window window_id) | 127 | geis_grail_window_grab_store_grab(GeisGrailWindowGrabStore wgs, Window window_id) |
113 | 129 | { | 128 | { |
114 | 129 | GeisStatus status = GEIS_STATUS_UNKNOWN_ERROR; | ||
115 | 130 | GeisGrailWindowGrab grab = _window_grab_store_find(wgs, window_id); | 130 | GeisGrailWindowGrab grab = _window_grab_store_find(wgs, window_id); |
116 | 131 | if (!grab) | 131 | if (!grab) |
117 | 132 | { | 132 | { |
118 | @@ -147,16 +147,27 @@ | |||
119 | 147 | int xstat = XIGrabTouchBegin(wgs->display, XIAllMasterDevices, | 147 | int xstat = XIGrabTouchBegin(wgs->display, XIAllMasterDevices, |
120 | 148 | window_id, | 148 | window_id, |
121 | 149 | 0, &mask, 1, &mods); | 149 | 0, &mask, 1, &mods); |
122 | 150 | free(mask.mask); | ||
123 | 150 | if (xstat) | 151 | if (xstat) |
124 | 151 | { | 152 | { |
125 | 152 | geis_error("error %d returned from XIGrabTouchBegin()", xstat); | 153 | geis_error("error %d returned from XIGrabTouchBegin()", xstat); |
128 | 153 | } | 154 | goto final_exit; |
129 | 154 | free(mask.mask); | 155 | } |
130 | 156 | else if (mods.status != XIGrabSuccess) | ||
131 | 157 | { | ||
132 | 158 | geis_error("status %d returned from XIGrabTouchBegin()", mods.status); | ||
133 | 159 | goto final_exit; | ||
134 | 160 | } | ||
135 | 161 | status = GEIS_STATUS_SUCCESS; | ||
136 | 155 | } | 162 | } |
137 | 156 | else | 163 | else |
138 | 157 | { | 164 | { |
139 | 158 | ++grab->grab_count; | 165 | ++grab->grab_count; |
140 | 166 | status = GEIS_STATUS_SUCCESS; | ||
141 | 159 | } | 167 | } |
142 | 168 | |||
143 | 169 | final_exit: | ||
144 | 170 | return status; | ||
145 | 160 | } | 171 | } |
146 | 161 | 172 | ||
147 | 162 | 173 | ||
148 | 163 | 174 | ||
149 | === modified file 'libutouch-geis/backend/grail/geis_grail_window_grab.h' | |||
150 | --- libutouch-geis/backend/grail/geis_grail_window_grab.h 2012-01-31 20:46:42 +0000 | |||
151 | +++ libutouch-geis/backend/grail/geis_grail_window_grab.h 2012-03-07 18:15:24 +0000 | |||
152 | @@ -20,6 +20,7 @@ | |||
153 | 20 | #ifndef GEIS_BACKEND_GRAIL_WINDOW_GRAB_H_ | 20 | #ifndef GEIS_BACKEND_GRAIL_WINDOW_GRAB_H_ |
154 | 21 | #define GEIS_BACKEND_GRAIL_WINDOW_GRAB_H_ | 21 | #define GEIS_BACKEND_GRAIL_WINDOW_GRAB_H_ |
155 | 22 | 22 | ||
156 | 23 | #include "geis/geis.h" | ||
157 | 23 | #include <X11/Xlib.h> | 24 | #include <X11/Xlib.h> |
158 | 24 | 25 | ||
159 | 25 | 26 | ||
160 | @@ -56,9 +57,10 @@ | |||
161 | 56 | * @param store A window grab store. | 57 | * @param store A window grab store. |
162 | 57 | * @param window The window to grab. | 58 | * @param window The window to grab. |
163 | 58 | * | 59 | * |
165 | 59 | * @returns a reference to the grab. | 60 | * @returns GEIS_STATUS_SUCCESS if the multi-touch for the window was grabbed |
166 | 61 | * successfully, GEIS_STATUS_UNKNOWN_ERROR otherwise. | ||
167 | 60 | */ | 62 | */ |
169 | 61 | void | 63 | GeisStatus |
170 | 62 | geis_grail_window_grab_store_grab(GeisGrailWindowGrabStore store, | 64 | geis_grail_window_grab_store_grab(GeisGrailWindowGrabStore store, |
171 | 63 | Window window); | 65 | Window window); |
172 | 64 | 66 | ||
173 | 65 | 67 | ||
174 | === modified file 'testsuite/geis2/Makefile.am' | |||
175 | --- testsuite/geis2/Makefile.am 2012-03-05 14:22:20 +0000 | |||
176 | +++ testsuite/geis2/Makefile.am 2012-03-07 18:15:24 +0000 | |||
177 | @@ -44,7 +44,9 @@ | |||
178 | 44 | 44 | ||
179 | 45 | gtest_geis2_api_SOURCES = \ | 45 | gtest_geis2_api_SOURCES = \ |
180 | 46 | gtest_attrs.cpp \ | 46 | gtest_attrs.cpp \ |
182 | 47 | gtest_evemu_device.h gtest_evemu_device.cpp | 47 | gtest_subscriptions.cpp \ |
183 | 48 | gtest_evemu_device.h gtest_evemu_device.cpp \ | ||
184 | 49 | gtest_geis_fixture.h gtest_geis_fixture.cpp | ||
185 | 48 | 50 | ||
186 | 49 | gtest_geis2_api_CPPFLAGS = \ | 51 | gtest_geis2_api_CPPFLAGS = \ |
187 | 50 | --std=c++0x \ | 52 | --std=c++0x \ |
188 | 51 | 53 | ||
189 | === modified file 'testsuite/geis2/gtest_attrs.cpp' | |||
190 | --- testsuite/geis2/gtest_attrs.cpp 2012-03-05 17:22:19 +0000 | |||
191 | +++ testsuite/geis2/gtest_attrs.cpp 2012-03-07 18:15:24 +0000 | |||
192 | @@ -7,13 +7,11 @@ | |||
193 | 7 | #include <functional> | 7 | #include <functional> |
194 | 8 | #include "geis/geis.h" | 8 | #include "geis/geis.h" |
195 | 9 | #include "gtest_evemu_device.h" | 9 | #include "gtest_evemu_device.h" |
196 | 10 | #include "gtest_geis_fixture.h" | ||
197 | 10 | #include <gtest/gtest.h> | 11 | #include <gtest/gtest.h> |
198 | 11 | #include <memory> | ||
199 | 12 | #include <mutex> | 12 | #include <mutex> |
200 | 13 | #include <sys/select.h> | 13 | #include <sys/select.h> |
201 | 14 | #include <sys/time.h> | 14 | #include <sys/time.h> |
202 | 15 | #include <X11/extensions/XInput2.h> | ||
203 | 16 | #include <xorg/gtest/test.h> | ||
204 | 17 | 15 | ||
205 | 18 | 16 | ||
206 | 19 | namespace | 17 | namespace |
207 | @@ -23,52 +21,19 @@ | |||
208 | 23 | static const std::string TEST_DEVICE_EVENTS_FILE("touchscreen_a_rotate90.events"); | 21 | static const std::string TEST_DEVICE_EVENTS_FILE("touchscreen_a_rotate90.events"); |
209 | 24 | 22 | ||
210 | 25 | /** | 23 | /** |
212 | 26 | * Fixture for testing expected attributes. | 24 | * Fixture for testing expected attributes. This has to be a separate class |
213 | 25 | * because of the way Java reflection is used in jUnit. | ||
214 | 27 | */ | 26 | */ |
215 | 28 | class GeisAttributeTests | 27 | class GeisAttributeTests |
217 | 29 | : public xorg::testing::Test | 28 | : public GTestGeisFixture |
218 | 30 | { | 29 | { |
219 | 31 | public: | 30 | public: |
256 | 32 | void | 31 | GeisAttributeTests() |
257 | 33 | SetUp() | 32 | : evemu_device_(TEST_DEVICE_PROP_FILE) |
258 | 34 | { | 33 | { } |
223 | 35 | // Chain up the static class heirarchy, as if the test framework was | ||
224 | 36 | // designed by a Java trainee with some exposure to glib but has never used | ||
225 | 37 | // C++. | ||
226 | 38 | ASSERT_NO_FATAL_FAILURE(xorg::testing::Test::SetUp()); | ||
227 | 39 | |||
228 | 40 | // Verify that whatever X server is in use supports the required XInput | ||
229 | 41 | // version. | ||
230 | 42 | int xi_major = 2; | ||
231 | 43 | int xi_minor = 2; | ||
232 | 44 | ASSERT_EQ(Success, XIQueryVersion(Display(), &xi_major, &xi_minor)); | ||
233 | 45 | ASSERT_GE(xi_major, 2); | ||
234 | 46 | ASSERT_GE(xi_minor, 2); | ||
235 | 47 | |||
236 | 48 | evemu_device_.reset(new Testsuite::EvemuDevice(TEST_DEVICE_PROP_FILE)); | ||
237 | 49 | |||
238 | 50 | geis_ = geis_new(GEIS_INIT_SYNCHRONOUS_START, GEIS_INIT_NO_ATOMIC_GESTURES, NULL); | ||
239 | 51 | } | ||
240 | 52 | |||
241 | 53 | void | ||
242 | 54 | TearDown() | ||
243 | 55 | { | ||
244 | 56 | geis_delete(geis_); | ||
245 | 57 | xorg::testing::Test::TearDown(); // NVI ftw. | ||
246 | 58 | evemu_device_.reset(); | ||
247 | 59 | } | ||
248 | 60 | |||
249 | 61 | int | ||
250 | 62 | geis_fd() | ||
251 | 63 | { | ||
252 | 64 | GeisInteger fd; | ||
253 | 65 | geis_get_configuration(geis_, GEIS_CONFIGURATION_FD, &fd); | ||
254 | 66 | return fd; | ||
255 | 67 | } | ||
259 | 68 | 34 | ||
260 | 69 | protected: | 35 | protected: |
263 | 70 | std::unique_ptr<Testsuite::EvemuDevice> evemu_device_; | 36 | Testsuite::EvemuDevice evemu_device_; |
262 | 71 | Geis geis_; | ||
264 | 72 | }; | 37 | }; |
265 | 73 | 38 | ||
266 | 74 | 39 | ||
267 | @@ -114,7 +79,7 @@ | |||
268 | 114 | { | 79 | { |
269 | 115 | if (geis_event_type(event) == GEIS_EVENT_INIT_COMPLETE) | 80 | if (geis_event_type(event) == GEIS_EVENT_INIT_COMPLETE) |
270 | 116 | { | 81 | { |
272 | 117 | evemu_device_->play(TEST_DEVICE_EVENTS_FILE); | 82 | evemu_device_.play(TEST_DEVICE_EVENTS_FILE); |
273 | 118 | } | 83 | } |
274 | 119 | else if (geis_event_type(event) == GEIS_EVENT_GESTURE_END) | 84 | else if (geis_event_type(event) == GEIS_EVENT_GESTURE_END) |
275 | 120 | { | 85 | { |
276 | 121 | 86 | ||
277 | === added file 'testsuite/geis2/gtest_geis_fixture.cpp' | |||
278 | --- testsuite/geis2/gtest_geis_fixture.cpp 1970-01-01 00:00:00 +0000 | |||
279 | +++ testsuite/geis2/gtest_geis_fixture.cpp 2012-03-07 18:15:24 +0000 | |||
280 | @@ -0,0 +1,64 @@ | |||
281 | 1 | /** | ||
282 | 2 | * @file gtest_geis_fixture.cpp | ||
283 | 3 | * @brief A GTest fixture for testing the full uTouch stack through GEIS. | ||
284 | 4 | */ | ||
285 | 5 | /* | ||
286 | 6 | * Copyright 2012 Canonical Ltd. | ||
287 | 7 | * | ||
288 | 8 | * This program is free software: you can redistribute it and/or modify it | ||
289 | 9 | * under the terms of the GNU General Public License version 3, as published | ||
290 | 10 | * by the Free Software Foundation. | ||
291 | 11 | * | ||
292 | 12 | * This program is distributed in the hope that it will be useful, but | ||
293 | 13 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
294 | 14 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
295 | 15 | * PURPOSE. See the GNU General Public License for more details. | ||
296 | 16 | * | ||
297 | 17 | * You should have received a copy of the GNU General Public License along | ||
298 | 18 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
299 | 19 | */ | ||
300 | 20 | #include "gtest_geis_fixture.h" | ||
301 | 21 | |||
302 | 22 | #include <unistd.h> | ||
303 | 23 | #include <X11/extensions/XInput2.h> | ||
304 | 24 | |||
305 | 25 | |||
306 | 26 | void GTestGeisFixture:: | ||
307 | 27 | SetUp() | ||
308 | 28 | { | ||
309 | 29 | // wait for things to settle | ||
310 | 30 | usleep(1000000); | ||
311 | 31 | |||
312 | 32 | // Chain up the static class heirarchy, as if the test framework was | ||
313 | 33 | // designed by a Java trainee with some exposure to glib but has never used | ||
314 | 34 | // C++. | ||
315 | 35 | ASSERT_NO_FATAL_FAILURE(xorg::testing::Test::SetUp()); | ||
316 | 36 | |||
317 | 37 | // Verify that whatever X server is in use supports the required XInput | ||
318 | 38 | // version. | ||
319 | 39 | int xi_major = 2; | ||
320 | 40 | int xi_minor = 2; | ||
321 | 41 | ASSERT_EQ(Success, XIQueryVersion(Display(), &xi_major, &xi_minor)); | ||
322 | 42 | ASSERT_GE(xi_major, 2); | ||
323 | 43 | ASSERT_GE(xi_minor, 2); | ||
324 | 44 | |||
325 | 45 | geis_ = geis_new(GEIS_INIT_SYNCHRONOUS_START, GEIS_INIT_NO_ATOMIC_GESTURES, NULL); | ||
326 | 46 | } | ||
327 | 47 | |||
328 | 48 | void GTestGeisFixture:: | ||
329 | 49 | TearDown() | ||
330 | 50 | { | ||
331 | 51 | geis_delete(geis_); | ||
332 | 52 | xorg::testing::Test::TearDown(); // NVI ftw. | ||
333 | 53 | usleep(1000000); | ||
334 | 54 | } | ||
335 | 55 | |||
336 | 56 | int GTestGeisFixture:: | ||
337 | 57 | geis_fd() | ||
338 | 58 | { | ||
339 | 59 | GeisInteger fd; | ||
340 | 60 | geis_get_configuration(geis_, GEIS_CONFIGURATION_FD, &fd); | ||
341 | 61 | return fd; | ||
342 | 62 | } | ||
343 | 63 | |||
344 | 64 | |||
345 | 0 | 65 | ||
346 | === added file 'testsuite/geis2/gtest_geis_fixture.h' | |||
347 | --- testsuite/geis2/gtest_geis_fixture.h 1970-01-01 00:00:00 +0000 | |||
348 | +++ testsuite/geis2/gtest_geis_fixture.h 2012-03-07 18:15:24 +0000 | |||
349 | @@ -0,0 +1,50 @@ | |||
350 | 1 | /** | ||
351 | 2 | * @file gtest_geis_fixture.h | ||
352 | 3 | * @brief A GTest fixture for testing the full uTouch stack through GEIS. | ||
353 | 4 | */ | ||
354 | 5 | /* | ||
355 | 6 | * Copyright 2012 Canonical Ltd. | ||
356 | 7 | * | ||
357 | 8 | * This program is free software: you can redistribute it and/or modify it | ||
358 | 9 | * under the terms of the GNU General Public License version 3, as published | ||
359 | 10 | * by the Free Software Foundation. | ||
360 | 11 | * | ||
361 | 12 | * This program is distributed in the hope that it will be useful, but | ||
362 | 13 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
363 | 14 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
364 | 15 | * PURPOSE. See the GNU General Public License for more details. | ||
365 | 16 | * | ||
366 | 17 | * You should have received a copy of the GNU General Public License along | ||
367 | 18 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
368 | 19 | */ | ||
369 | 20 | #ifndef GTEST_GEIS_FIXTURE_H_ | ||
370 | 21 | #define GTEST_GEIS_FIXTURE_H_ | ||
371 | 22 | |||
372 | 23 | #include "geis/geis.h" | ||
373 | 24 | #include <gtest/gtest.h> | ||
374 | 25 | #include <xorg/gtest/test.h> | ||
375 | 26 | |||
376 | 27 | |||
377 | 28 | /** | ||
378 | 29 | * Fixture for testing expected attributes. | ||
379 | 30 | */ | ||
380 | 31 | class GTestGeisFixture | ||
381 | 32 | : public xorg::testing::Test | ||
382 | 33 | { | ||
383 | 34 | public: | ||
384 | 35 | void | ||
385 | 36 | SetUp(); | ||
386 | 37 | |||
387 | 38 | void | ||
388 | 39 | TearDown(); | ||
389 | 40 | |||
390 | 41 | int | ||
391 | 42 | geis_fd(); | ||
392 | 43 | |||
393 | 44 | protected: | ||
394 | 45 | Geis geis_; | ||
395 | 46 | }; | ||
396 | 47 | |||
397 | 48 | |||
398 | 49 | #endif /* GTEST_GEIS_FIXTURE_H_ */ | ||
399 | 50 | |||
400 | 0 | 51 | ||
401 | === added file 'testsuite/geis2/gtest_subscriptions.cpp' | |||
402 | --- testsuite/geis2/gtest_subscriptions.cpp 1970-01-01 00:00:00 +0000 | |||
403 | +++ testsuite/geis2/gtest_subscriptions.cpp 2012-03-07 18:15:24 +0000 | |||
404 | @@ -0,0 +1,95 @@ | |||
405 | 1 | /** | ||
406 | 2 | * GTest-based test suite for GEIS subscription actions. | ||
407 | 3 | * | ||
408 | 4 | * Copyright 2012 Canonical Ltd. | ||
409 | 5 | */ | ||
410 | 6 | |||
411 | 7 | #include "gtest_evemu_device.h" | ||
412 | 8 | #include "gtest_geis_fixture.h" | ||
413 | 9 | |||
414 | 10 | |||
415 | 11 | static const std::string TEST_DEVICE_PROP_FILE("touchscreen_a.prop"); | ||
416 | 12 | |||
417 | 13 | |||
418 | 14 | /** | ||
419 | 15 | * Tests need to make sure at least one multi-touch device is available. | ||
420 | 16 | */ | ||
421 | 17 | class GeisSubscriptionTests | ||
422 | 18 | : public GTestGeisFixture | ||
423 | 19 | { | ||
424 | 20 | public: | ||
425 | 21 | GeisSubscriptionTests() | ||
426 | 22 | : evemu_device_(TEST_DEVICE_PROP_FILE) | ||
427 | 23 | { } | ||
428 | 24 | |||
429 | 25 | private: | ||
430 | 26 | Testsuite::EvemuDevice evemu_device_; | ||
431 | 27 | }; | ||
432 | 28 | |||
433 | 29 | |||
434 | 30 | /** | ||
435 | 31 | * Regression test for lp:937021: Geis subscription touch grabs need to check | ||
436 | 32 | * for failure. | ||
437 | 33 | * | ||
438 | 34 | * This test creates two subscriptions, both attached to the root window but | ||
439 | 35 | * each on a different X client. Since multiple subscriptions for the same | ||
440 | 36 | * window but a different client are expected to fail using the XI2.2-based | ||
441 | 37 | * grail back end, activating the second subscription is extected to resut in | ||
442 | 38 | * a failure. | ||
443 | 39 | * | ||
444 | 40 | * This behaviour is very dependent on the particular back end used and internal | ||
445 | 41 | * implementattion details of that back end. It is not a unit test or a | ||
446 | 42 | * reliable group or system test. | ||
447 | 43 | */ | ||
448 | 44 | TEST_F(GeisSubscriptionTests, duplicate_window_subscription) | ||
449 | 45 | { | ||
450 | 46 | Geis geis2 = geis_new(GEIS_INIT_SYNCHRONOUS_START, | ||
451 | 47 | GEIS_INIT_NO_ATOMIC_GESTURES, | ||
452 | 48 | NULL); | ||
453 | 49 | EXPECT_TRUE(geis2 != NULL) << "can not create second geis instance"; | ||
454 | 50 | |||
455 | 51 | GeisSubscription sub1 = geis_subscription_new(geis_, | ||
456 | 52 | "subscription 1", | ||
457 | 53 | GEIS_SUBSCRIPTION_NONE); | ||
458 | 54 | EXPECT_TRUE(sub1 != NULL) << "can not create first subscription"; | ||
459 | 55 | |||
460 | 56 | GeisSubscription sub2 = geis_subscription_new(geis2, | ||
461 | 57 | "subscription 2", | ||
462 | 58 | GEIS_SUBSCRIPTION_NONE); | ||
463 | 59 | EXPECT_TRUE(sub1 != NULL) << "can not create second subscription"; | ||
464 | 60 | |||
465 | 61 | GeisFilter filter1 = geis_filter_new(geis_, "root window 1"); | ||
466 | 62 | EXPECT_TRUE(filter1 != NULL) << "can not create filter 1"; | ||
467 | 63 | |||
468 | 64 | GeisStatus fs = geis_filter_add_term(filter1, | ||
469 | 65 | GEIS_FILTER_CLASS, | ||
470 | 66 | GEIS_CLASS_ATTRIBUTE_NAME, GEIS_FILTER_OP_EQ, GEIS_GESTURE_ROTATE, | ||
471 | 67 | GEIS_GESTURE_ATTRIBUTE_TOUCHES, GEIS_FILTER_OP_GT, 1, | ||
472 | 68 | NULL); | ||
473 | 69 | EXPECT_EQ(fs, GEIS_STATUS_SUCCESS) << "can not add class to filter 1"; | ||
474 | 70 | |||
475 | 71 | GeisFilter filter2 = geis_filter_new(geis_, "root window 2"); | ||
476 | 72 | EXPECT_TRUE(filter2 != NULL) << "can not create filter 2"; | ||
477 | 73 | |||
478 | 74 | fs = geis_filter_add_term(filter2, | ||
479 | 75 | GEIS_FILTER_CLASS, | ||
480 | 76 | GEIS_CLASS_ATTRIBUTE_NAME, GEIS_FILTER_OP_EQ, GEIS_GESTURE_ROTATE, | ||
481 | 77 | GEIS_GESTURE_ATTRIBUTE_TOUCHES, GEIS_FILTER_OP_GT, 1, | ||
482 | 78 | NULL); | ||
483 | 79 | EXPECT_EQ(fs, GEIS_STATUS_SUCCESS) << "can not add class to filter 2"; | ||
484 | 80 | |||
485 | 81 | fs = geis_subscription_add_filter(sub1, filter1); | ||
486 | 82 | EXPECT_EQ(fs, GEIS_STATUS_SUCCESS) << "can not subscribe filter 1"; | ||
487 | 83 | fs = geis_subscription_add_filter(sub2, filter2); | ||
488 | 84 | EXPECT_EQ(fs, GEIS_STATUS_SUCCESS) << "can not subscribe filter 2"; | ||
489 | 85 | |||
490 | 86 | EXPECT_EQ(GEIS_STATUS_SUCCESS, geis_subscription_activate(sub1)) | ||
491 | 87 | << "can not activate subscription 1"; | ||
492 | 88 | EXPECT_NE(GEIS_STATUS_SUCCESS, geis_subscription_activate(sub2)) | ||
493 | 89 | << "mistakenly activated subscription 2"; | ||
494 | 90 | |||
495 | 91 | geis_subscription_delete(sub2); | ||
496 | 92 | geis_subscription_delete(sub1); | ||
497 | 93 | geis_delete(geis2); | ||
498 | 94 | } | ||
499 | 95 |
Having final_exit and goto would make more sense if some resource were freed there. Personally I would replace them with an explicit "return GEIS_STATUS_ UNKNOWN_ ERROR;" . This is not a blocker for merging, though.