Merge lp:~dandrader/frame/lp1025297 into lp:frame
- lp1025297
- Merge into trunk
Status: | Merged |
---|---|
Merged at revision: | 82 |
Proposed branch: | lp:~dandrader/frame/lp1025297 |
Merge into: | lp:frame |
Diff against target: |
1378 lines (+1014/-152) 19 files modified
.bzrignore (+4/-3) Makefile.am (+0/-2) configure.ac (+12/-4) m4/gtest.m4 (+51/-0) src/x11/window_x11.cpp (+21/-41) src/x11/window_x11.h (+0/-2) test/Makefile-xorg-gtest.am (+0/-63) test/Makefile.am (+5/-0) test/README (+11/-0) test/gtest/Makefile-xorg-gtest.am (+68/-0) test/gtest/Makefile.am (+11/-0) test/integration/Makefile.am (+20/-37) test/regular/Makefile.am (+57/-0) test/regular/accept-ended-touch.cpp (+72/-0) test/regular/frame-fixture.cpp (+161/-0) test/regular/frame-fixture.h (+31/-0) test/x11_mocks/Makefile.am (+14/-0) test/x11_mocks/x11_mocks.cpp (+435/-0) test/x11_mocks/x11_mocks.h (+41/-0) |
To merge this branch: | bzr merge lp:~dandrader/frame/lp1025297 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Chase Douglas (community) | Approve | ||
Review via email: mp+115357@code.launchpad.net |
Commit message
Description of the change
Fixes bug 1025297.
Patch is big because it's adding all the infrastructure needed for mocks-based tests.
- 86. By Daniel d'Andrada
-
Remove serial number from m4/gtest.m4
The serial number implies that it was copied in from some other distribution,
but it's not the case here. - 87. By Daniel d'Andrada
-
Use Makefile-
xorg-gtest. am from latest upstream xorg-gtest
Daniel d'Andrada (dandrader) wrote : | # |
> * The added gtest.m4 file shouldn't have a serial number since it's not
> distributed anywhere. The serial number implies that it was copied in from
> some other distribution.
>
> * The Makefile-
> it because of issues with the wrong files being included when compiling xorg-
> gtest itself. This has been fixed in the Makefile-
> upstream. It has not been fixed in Ubuntu yet, but you can download the change
> from here:
Done.
Chase Douglas (chasedouglas) wrote : | # |
Looks good!
Preview Diff
1 | === modified file '.bzrignore' | |||
2 | --- .bzrignore 2012-03-28 00:45:08 +0000 | |||
3 | +++ .bzrignore 2012-07-18 13:01:21 +0000 | |||
4 | @@ -26,9 +26,10 @@ | |||
5 | 26 | m4/lt~obsolete.m4 | 26 | m4/lt~obsolete.m4 |
6 | 27 | m4/pkg.m4 | 27 | m4/pkg.m4 |
7 | 28 | stamp-* | 28 | stamp-* |
11 | 29 | test/check-c-compile | 29 | test/regular/check-c-compile |
12 | 30 | test/check-cxx-compile | 30 | test/regular/check-cxx-compile |
13 | 31 | test/check-frame | 31 | test/regular/check-regular |
14 | 32 | test/integration/check-integration | ||
15 | 32 | tools/utouch-frame-test-mtdev | 33 | tools/utouch-frame-test-mtdev |
16 | 33 | tools/utouch-frame-test-mtdev.1 | 34 | tools/utouch-frame-test-mtdev.1 |
17 | 34 | tools/utouch-frame-test-xi2 | 35 | tools/utouch-frame-test-xi2 |
18 | 35 | 36 | ||
19 | === modified file 'Makefile.am' | |||
20 | --- Makefile.am 2012-03-31 02:31:54 +0000 | |||
21 | +++ Makefile.am 2012-07-18 13:01:21 +0000 | |||
22 | @@ -9,8 +9,6 @@ | |||
23 | 9 | pkgconfigdir = $(libdir)/pkgconfig | 9 | pkgconfigdir = $(libdir)/pkgconfig |
24 | 10 | pkgconfig_DATA = utouch-frame.pc | 10 | pkgconfig_DATA = utouch-frame.pc |
25 | 11 | 11 | ||
26 | 12 | INCLUDES = $(top_srcdir)/include/ | ||
27 | 13 | |||
28 | 14 | if HAVE_GCOV | 12 | if HAVE_GCOV |
29 | 15 | .PHONY: clean-gcda | 13 | .PHONY: clean-gcda |
30 | 16 | clean-gcda: | 14 | clean-gcda: |
31 | 17 | 15 | ||
32 | === modified file 'configure.ac' | |||
33 | --- configure.ac 2012-06-18 18:28:21 +0000 | |||
34 | +++ configure.ac 2012-07-18 13:01:21 +0000 | |||
35 | @@ -25,7 +25,8 @@ | |||
36 | 25 | AC_PROG_CXX | 25 | AC_PROG_CXX |
37 | 26 | AC_PROG_INSTALL | 26 | AC_PROG_INSTALL |
38 | 27 | 27 | ||
40 | 28 | PKG_CHECK_MODULES([EVEMU], [utouch-evemu >= 1.0.5]) | 28 | PKG_CHECK_MODULES([EVEMU], [utouch-evemu >= 1.0.5], [have_evemu=yes]) |
41 | 29 | AM_CONDITIONAL([HAVE_EVEMU], [test "x$have_evemu" = xyes]) | ||
42 | 29 | 30 | ||
43 | 30 | PKG_CHECK_MODULES(XINPUT, x11 xext xorg-server [xi >= 1.5.99.1] [inputproto >= 2.1.99.6]) | 31 | PKG_CHECK_MODULES(XINPUT, x11 xext xorg-server [xi >= 1.5.99.1] [inputproto >= 2.1.99.6]) |
44 | 31 | 32 | ||
45 | @@ -34,6 +35,11 @@ | |||
46 | 34 | AS_IF([test "x$ASCIIDOC" = "x"], | 35 | AS_IF([test "x$ASCIIDOC" = "x"], |
47 | 35 | [AC_MSG_WARN([asciidoc not installed, man pages will not be created])]) | 36 | [AC_MSG_WARN([asciidoc not installed, man pages will not be created])]) |
48 | 36 | 37 | ||
49 | 38 | |||
50 | 39 | # Check for Google C++ Testing Framework | ||
51 | 40 | CHECK_GTEST() | ||
52 | 41 | AM_CONDITIONAL([HAVE_GTEST], [test "x$have_gtest" = xyes]) | ||
53 | 42 | |||
54 | 37 | # Check for TDD tools | 43 | # Check for TDD tools |
55 | 38 | AC_ARG_ENABLE([integration-tests], | 44 | AC_ARG_ENABLE([integration-tests], |
56 | 39 | [AS_HELP_STRING([--enable-integration-tests], | 45 | [AS_HELP_STRING([--enable-integration-tests], |
57 | @@ -43,13 +49,11 @@ | |||
58 | 43 | 49 | ||
59 | 44 | AS_IF([test "x$enable_integration_tests" != xno], | 50 | AS_IF([test "x$enable_integration_tests" != xno], |
60 | 45 | [CHECK_XORG_GTEST( | 51 | [CHECK_XORG_GTEST( |
62 | 46 | [AC_MSG_NOTICE([xorg-gtest is available, tests will be built])], | 52 | [AC_MSG_NOTICE([xorg-gtest is available, integration tests will be built])], |
63 | 47 | [AC_MSG_WARN([xorg-gtest is not available, tests will not be built])])]) | 53 | [AC_MSG_WARN([xorg-gtest is not available, tests will not be built])])]) |
64 | 48 | 54 | ||
65 | 49 | AM_CONDITIONAL([ENABLE_INTEGRATION_TESTS], [test "x$have_xorg_gtest" = xyes]) | 55 | AM_CONDITIONAL([ENABLE_INTEGRATION_TESTS], [test "x$have_xorg_gtest" = xyes]) |
66 | 50 | 56 | ||
67 | 51 | AM_CONDITIONAL([HAVE_GTEST], [test "x$have_xorg_gtest" = xyes]) | ||
68 | 52 | |||
69 | 53 | AC_SUBST([GTEST_LDFLAGS]) | 57 | AC_SUBST([GTEST_LDFLAGS]) |
70 | 54 | AC_SUBST([GTEST_CXXFLAGS]) | 58 | AC_SUBST([GTEST_CXXFLAGS]) |
71 | 55 | 59 | ||
72 | @@ -66,6 +70,10 @@ | |||
73 | 66 | doc/Makefile | 70 | doc/Makefile |
74 | 67 | src/Makefile | 71 | src/Makefile |
75 | 68 | test/Makefile | 72 | test/Makefile |
76 | 73 | test/gtest/Makefile | ||
77 | 74 | test/integration/Makefile | ||
78 | 75 | test/regular/Makefile | ||
79 | 76 | test/x11_mocks/Makefile | ||
80 | 69 | tools/Makefile | 77 | tools/Makefile |
81 | 70 | utouch-frame.pc]) | 78 | utouch-frame.pc]) |
82 | 71 | 79 | ||
83 | 72 | 80 | ||
84 | === added file 'm4/gtest.m4' | |||
85 | --- m4/gtest.m4 1970-01-01 00:00:00 +0000 | |||
86 | +++ m4/gtest.m4 2012-07-18 13:01:21 +0000 | |||
87 | @@ -0,0 +1,51 @@ | |||
88 | 1 | # Copyright (C) 2012 Canonical, Ltd. | ||
89 | 2 | # | ||
90 | 3 | # Permission is hereby granted, free of charge, to any person obtaining a copy | ||
91 | 4 | # of this software and associated documentation files (the "Software"), to deal | ||
92 | 5 | # in the Software without restriction, including without limitation the rights | ||
93 | 6 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
94 | 7 | # copies of the Software, and to permit persons to whom the Software is | ||
95 | 8 | # furnished to do so, subject to the following conditions: | ||
96 | 9 | # | ||
97 | 10 | # The above copyright notice and this permission notice (including the next | ||
98 | 11 | # paragraph) shall be included in all copies or substantial portions of the | ||
99 | 12 | # Software. | ||
100 | 13 | # | ||
101 | 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
102 | 15 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
103 | 16 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
104 | 17 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
105 | 18 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
106 | 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
107 | 20 | # SOFTWARE. | ||
108 | 21 | |||
109 | 22 | # Checks whether the gtest source is available on the system. Allows for | ||
110 | 23 | # adjusting the include and source path. Sets have_gtest=yes if the source is | ||
111 | 24 | # present. Sets GTEST_CPPFLAGS and GTEST_SOURCE to the preprocessor flags and | ||
112 | 25 | # source location respectively. | ||
113 | 26 | AC_DEFUN([CHECK_GTEST], | ||
114 | 27 | [ | ||
115 | 28 | AC_ARG_WITH([gtest-include-path], | ||
116 | 29 | [AS_HELP_STRING([--with-gtest-include-path], | ||
117 | 30 | [location of the Google test headers])], | ||
118 | 31 | [GTEST_CPPFLAGS="-I$withval"]) | ||
119 | 32 | |||
120 | 33 | AC_ARG_WITH([gtest-source-path], | ||
121 | 34 | [AS_HELP_STRING([--with-gtest-source-path], | ||
122 | 35 | [location of the Google test sources, defaults to /usr/src/gtest])], | ||
123 | 36 | [GTEST_SOURCE="$withval"], | ||
124 | 37 | [GTEST_SOURCE="/usr/src/gtest"]) | ||
125 | 38 | |||
126 | 39 | GTEST_CPPFLAGS="$GTEST_CPPFLAGS -I$GTEST_SOURCE" | ||
127 | 40 | |||
128 | 41 | AC_CHECK_FILES([$GTEST_SOURCE/src/gtest-all.cc] | ||
129 | 42 | [$GTEST_SOURCE/src/gtest_main.cc], | ||
130 | 43 | [have_gtest=yes], | ||
131 | 44 | [have_gtest=no]) | ||
132 | 45 | |||
133 | 46 | AS_IF([test "x$have_gtest" = xyes], | ||
134 | 47 | [GTEST_LIBS=-lpthread | ||
135 | 48 | AC_SUBST(GTEST_CPPFLAGS) | ||
136 | 49 | AC_SUBST(GTEST_SOURCE) | ||
137 | 50 | AC_SUBST(GTEST_LIBS)]) | ||
138 | 51 | ]) # CHECK_GTEST | ||
139 | 0 | 52 | ||
140 | === modified file 'src/x11/window_x11.cpp' | |||
141 | --- src/x11/window_x11.cpp 2012-06-18 18:28:21 +0000 | |||
142 | +++ src/x11/window_x11.cpp 2012-07-18 13:01:21 +0000 | |||
143 | @@ -36,8 +36,6 @@ | |||
144 | 36 | : window_(window), | 36 | : window_(window), |
145 | 37 | display_(display), | 37 | display_(display), |
146 | 38 | device_(static_cast<UFDeviceX11*>(device.get())), | 38 | device_(static_cast<UFDeviceX11*>(device.get())), |
147 | 39 | touches_to_accept_(), | ||
148 | 40 | touches_to_reject_(), | ||
149 | 41 | unaccepted_unrejected_touches_() { | 39 | unaccepted_unrejected_touches_() { |
150 | 42 | } | 40 | } |
151 | 43 | 41 | ||
152 | @@ -167,55 +165,37 @@ | |||
153 | 167 | 165 | ||
154 | 168 | current_frame_ = *frame; | 166 | current_frame_ = *frame; |
155 | 169 | 167 | ||
167 | 170 | if (touches_to_accept_.count(event->touchid)) { | 168 | unaccepted_unrejected_touches_.insert(event->touchid); |
157 | 171 | XIAllowTouchEvents(display_, device_->master_id(), event->touchid, window_, | ||
158 | 172 | XIAcceptTouch); | ||
159 | 173 | touches_to_accept_.erase(event->touchid); | ||
160 | 174 | } else if (touches_to_reject_.count(event->touchid)) { | ||
161 | 175 | XIAllowTouchEvents(display_, device_->master_id(), event->touchid, window_, | ||
162 | 176 | XIRejectTouch); | ||
163 | 177 | touches_to_reject_.erase(event->touchid); | ||
164 | 178 | } else { | ||
165 | 179 | unaccepted_unrejected_touches_.insert(event->touchid); | ||
166 | 180 | } | ||
168 | 181 | 169 | ||
169 | 182 | return true; | 170 | return true; |
170 | 183 | } | 171 | } |
171 | 184 | 172 | ||
172 | 185 | UFStatus WindowX11::AcceptTouch(UFTouchId touch_id) { | 173 | UFStatus WindowX11::AcceptTouch(UFTouchId touch_id) { |
187 | 186 | if (current_frame_->IsTouchOwned(touch_id)) { | 174 | if (XIAllowTouchEvents(display_, device_->master_id(), touch_id, window_, |
188 | 187 | if (XIAllowTouchEvents(display_, device_->master_id(), touch_id, window_, | 175 | XIAcceptTouch)) |
189 | 188 | XIAcceptTouch)) | 176 | return UFStatusErrorGeneric; |
190 | 189 | return UFStatusErrorGeneric; | 177 | |
191 | 190 | 178 | /* Flush output buffer so touches are actually accepted ASAP. The server | |
192 | 191 | /* Flush output buffer so touches are actually accepted ASAP. The server | 179 | * can't perform pointer emulation while the currently emulated touch is |
193 | 192 | * can't perform pointer emulation while the currently emulated touch is | 180 | * still potentially active for pointer emulation. */ |
194 | 193 | * still potentially active for pointer emulation. */ | 181 | XFlush(display_); |
195 | 194 | XFlush(display_); | 182 | |
196 | 195 | 183 | unaccepted_unrejected_touches_.erase(touch_id); | |
183 | 196 | unaccepted_unrejected_touches_.erase(touch_id); | ||
184 | 197 | } else { | ||
185 | 198 | touches_to_accept_.insert(touch_id); | ||
186 | 199 | } | ||
197 | 200 | 184 | ||
198 | 201 | return UFStatusSuccess; | 185 | return UFStatusSuccess; |
199 | 202 | } | 186 | } |
200 | 203 | 187 | ||
201 | 204 | UFStatus WindowX11::RejectTouch(UFTouchId touch_id) { | 188 | UFStatus WindowX11::RejectTouch(UFTouchId touch_id) { |
216 | 205 | if (current_frame_->IsTouchOwned(touch_id)) { | 189 | if (XIAllowTouchEvents(display_, device_->master_id(), touch_id, window_, |
217 | 206 | if (XIAllowTouchEvents(display_, device_->master_id(), touch_id, window_, | 190 | XIRejectTouch)) |
218 | 207 | XIRejectTouch)) | 191 | return UFStatusErrorGeneric; |
219 | 208 | return UFStatusErrorGeneric; | 192 | |
220 | 209 | 193 | /* Flush output buffer so touches are actually rejected ASAP. The server | |
221 | 210 | /* Flush output buffer so touches are actually rejected ASAP. The server | 194 | * can't perform pointer emulation while the currently emulated touch is |
222 | 211 | * can't perform pointer emulation while the currently emulated touch is | 195 | * still potentially active for pointer emulation. */ |
223 | 212 | * still potentially active for pointer emulation. */ | 196 | XFlush(display_); |
224 | 213 | XFlush(display_); | 197 | |
225 | 214 | 198 | unaccepted_unrejected_touches_.erase(touch_id); | |
212 | 215 | unaccepted_unrejected_touches_.erase(touch_id); | ||
213 | 216 | } else { | ||
214 | 217 | touches_to_reject_.insert(touch_id); | ||
215 | 218 | } | ||
226 | 219 | 199 | ||
227 | 220 | return UFStatusSuccess; | 200 | return UFStatusSuccess; |
228 | 221 | } | 201 | } |
229 | 222 | 202 | ||
230 | === modified file 'src/x11/window_x11.h' | |||
231 | --- src/x11/window_x11.h 2012-06-18 18:28:21 +0000 | |||
232 | +++ src/x11/window_x11.h 2012-07-18 13:01:21 +0000 | |||
233 | @@ -57,8 +57,6 @@ | |||
234 | 57 | ::Window window_; | 57 | ::Window window_; |
235 | 58 | Display* display_; | 58 | Display* display_; |
236 | 59 | UFDeviceX11* device_; | 59 | UFDeviceX11* device_; |
237 | 60 | std::set<UFTouchId> touches_to_accept_; | ||
238 | 61 | std::set<UFTouchId> touches_to_reject_; | ||
239 | 62 | std::set<UFTouchId> unaccepted_unrejected_touches_; | 60 | std::set<UFTouchId> unaccepted_unrejected_touches_; |
240 | 63 | }; | 61 | }; |
241 | 64 | 62 | ||
242 | 65 | 63 | ||
243 | === removed file 'test/Makefile-xorg-gtest.am' | |||
244 | --- test/Makefile-xorg-gtest.am 2012-06-18 18:28:21 +0000 | |||
245 | +++ test/Makefile-xorg-gtest.am 1970-01-01 00:00:00 +0000 | |||
246 | @@ -1,63 +0,0 @@ | |||
247 | 1 | # Copyright (C) 2012 Canonical, Ltd. | ||
248 | 2 | # | ||
249 | 3 | # Permission is hereby granted, free of charge, to any person obtaining a copy | ||
250 | 4 | # of this software and associated documentation files (the "Software"), to deal | ||
251 | 5 | # in the Software without restriction, including without limitation the rights | ||
252 | 6 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
253 | 7 | # copies of the Software, and to permit persons to whom the Software is | ||
254 | 8 | # furnished to do so, subject to the following conditions: | ||
255 | 9 | # | ||
256 | 10 | # The above copyright notice and this permission notice (including the next | ||
257 | 11 | # paragraph) shall be included in all copies or substantial portions of the | ||
258 | 12 | # Software. | ||
259 | 13 | # | ||
260 | 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
261 | 15 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
262 | 16 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
263 | 17 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
264 | 18 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
265 | 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
266 | 20 | # SOFTWARE. | ||
267 | 21 | # | ||
268 | 22 | |||
269 | 23 | XORG_GTEST_BUILD_LIBS = \ | ||
270 | 24 | libgtest.a \ | ||
271 | 25 | libgtest_main.a \ | ||
272 | 26 | libxorg-gtest.a \ | ||
273 | 27 | libxorg-gtest_main.a | ||
274 | 28 | |||
275 | 29 | nodist_libgtest_a_SOURCES = $(GTEST_SOURCE)/src/gtest-all.cc | ||
276 | 30 | libgtest_a_CPPFLAGS = $(GTEST_CPPFLAGS) $(AM_CPPFLAGS) -w | ||
277 | 31 | libgtest_a_CXXFLAGS = $(GTEST_CXXFLAGS) $(AM_CXXFLAGS) | ||
278 | 32 | |||
279 | 33 | nodist_libgtest_main_a_SOURCES = $(GTEST_SOURCE)/src/gtest_main.cc | ||
280 | 34 | libgtest_main_a_CPPFLAGS = $(GTEST_CPPFLAGS) $(AM_CPPFLAGS) -w | ||
281 | 35 | libgtest_main_a_CXXFLAGS = $(GTEST_CXXFLAGS) $(AM_CXXFLAGS) | ||
282 | 36 | |||
283 | 37 | nodist_libxorg_gtest_a_SOURCES = $(XORG_GTEST_SOURCE)/src/xorg-gtest-all.cpp | ||
284 | 38 | libxorg_gtest_a_CPPFLAGS = \ | ||
285 | 39 | $(XORG_GTEST_CPPFLAGS) \ | ||
286 | 40 | $(GTEST_CPPFLAGS) \ | ||
287 | 41 | $(AM_CPPFLAGS) \ | ||
288 | 42 | -iquote$(XORG_GTEST_SOURCE) \ | ||
289 | 43 | -w | ||
290 | 44 | libxorg_gtest_a_CXXFLAGS = \ | ||
291 | 45 | $(XORG_GTEST_CXXFLAGS) \ | ||
292 | 46 | $(GTEST_CXXFLAGS) \ | ||
293 | 47 | $(AM_CPPFLAGS) | ||
294 | 48 | |||
295 | 49 | nodist_libxorg_gtest_main_a_SOURCES = \ | ||
296 | 50 | $(XORG_GTEST_SOURCE)/src/xorg-gtest_main.cpp | ||
297 | 51 | libxorg_gtest_main_a_CPPFLAGS = \ | ||
298 | 52 | $(XORG_GTEST_CPPFLAGS) \ | ||
299 | 53 | $(GTEST_CPPFLAGS) \ | ||
300 | 54 | $(AM_CPPFLAGS) \ | ||
301 | 55 | -iquote$(XORG_GTEST_SOURCE) \ | ||
302 | 56 | -w | ||
303 | 57 | libxorg_gtest_main_a_CXXFLAGS = \ | ||
304 | 58 | $(XORG_GTEST_CXXFLAGS) \ | ||
305 | 59 | $(GTEST_CXXFLAGS) \ | ||
306 | 60 | $(AM_CXXFLAGS) | ||
307 | 61 | |||
308 | 62 | XORG_GTEST_LIBS = libxorg-gtest.a libgtest.a -lpthread $(X11_LIBS) | ||
309 | 63 | XORG_GTEST_MAIN_LIBS = libxorg-gtest_main.a | ||
310 | 64 | 0 | ||
311 | === added file 'test/Makefile.am' | |||
312 | --- test/Makefile.am 1970-01-01 00:00:00 +0000 | |||
313 | +++ test/Makefile.am 2012-07-18 13:01:21 +0000 | |||
314 | @@ -0,0 +1,5 @@ | |||
315 | 1 | SUBDIRS = gtest x11_mocks regular | ||
316 | 2 | |||
317 | 3 | if ENABLE_INTEGRATION_TESTS | ||
318 | 4 | SUBDIRS += integration | ||
319 | 5 | endif | ||
320 | 0 | 6 | ||
321 | === added file 'test/README' | |||
322 | --- test/README 1970-01-01 00:00:00 +0000 | |||
323 | +++ test/README 2012-07-18 13:01:21 +0000 | |||
324 | @@ -0,0 +1,11 @@ | |||
325 | 1 | Directory structure | ||
326 | 2 | =================== | ||
327 | 3 | |||
328 | 4 | - integration | ||
329 | 5 | Here goes all integration tests. | ||
330 | 6 | Those tests take time to run and rely on or interact with other processes | ||
331 | 7 | beyond the test program itself. | ||
332 | 8 | |||
333 | 9 | - regular | ||
334 | 10 | Here goes tests that are fast to run and don't rely on the run-time | ||
335 | 11 | environment (such as other processes, files, etc). | ||
336 | 0 | 12 | ||
337 | === added directory 'test/gtest' | |||
338 | === added file 'test/gtest/Makefile-xorg-gtest.am' | |||
339 | --- test/gtest/Makefile-xorg-gtest.am 1970-01-01 00:00:00 +0000 | |||
340 | +++ test/gtest/Makefile-xorg-gtest.am 2012-07-18 13:01:21 +0000 | |||
341 | @@ -0,0 +1,68 @@ | |||
342 | 1 | # Copyright (C) 2012 Canonical, Ltd. | ||
343 | 2 | # | ||
344 | 3 | # Permission is hereby granted, free of charge, to any person obtaining a copy | ||
345 | 4 | # of this software and associated documentation files (the "Software"), to deal | ||
346 | 5 | # in the Software without restriction, including without limitation the rights | ||
347 | 6 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
348 | 7 | # copies of the Software, and to permit persons to whom the Software is | ||
349 | 8 | # furnished to do so, subject to the following conditions: | ||
350 | 9 | # | ||
351 | 10 | # The above copyright notice and this permission notice (including the next | ||
352 | 11 | # paragraph) shall be included in all copies or substantial portions of the | ||
353 | 12 | # Software. | ||
354 | 13 | # | ||
355 | 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
356 | 15 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
357 | 16 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
358 | 17 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
359 | 18 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
360 | 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
361 | 20 | # SOFTWARE. | ||
362 | 21 | # | ||
363 | 22 | |||
364 | 23 | XORG_GTEST_BUILD_LIBS = \ | ||
365 | 24 | libgtest.a \ | ||
366 | 25 | libgtest_main.a \ | ||
367 | 26 | libxorg-gtest.a \ | ||
368 | 27 | libxorg-gtest_main.a | ||
369 | 28 | |||
370 | 29 | # Here and below we compile without warnings (-w) because the projects using | ||
371 | 30 | # xorg-gtest will not want to see warnings or fail to build due to warnings in | ||
372 | 31 | # gtest or xorg-gtest. | ||
373 | 32 | nodist_libgtest_a_SOURCES = $(GTEST_SOURCE)/src/gtest-all.cc | ||
374 | 33 | libgtest_a_CPPFLAGS = --std=c++0x $(GTEST_CPPFLAGS) $(AM_CPPFLAGS) -w | ||
375 | 34 | libgtest_a_CXXFLAGS = $(GTEST_CXXFLAGS) $(AM_CXXFLAGS) | ||
376 | 35 | |||
377 | 36 | nodist_libgtest_main_a_SOURCES = $(GTEST_SOURCE)/src/gtest_main.cc | ||
378 | 37 | libgtest_main_a_CPPFLAGS = --std=c++0x $(GTEST_CPPFLAGS) $(AM_CPPFLAGS) -w | ||
379 | 38 | libgtest_main_a_CXXFLAGS = $(GTEST_CXXFLAGS) $(AM_CXXFLAGS) | ||
380 | 39 | |||
381 | 40 | nodist_libxorg_gtest_a_SOURCES = $(XORG_GTEST_SOURCE)/src/xorg-gtest-all.cpp | ||
382 | 41 | libxorg_gtest_a_CPPFLAGS = \ | ||
383 | 42 | --std=c++0x \ | ||
384 | 43 | $(XORG_GTEST_CPPFLAGS) \ | ||
385 | 44 | $(GTEST_CPPFLAGS) \ | ||
386 | 45 | $(AM_CPPFLAGS) \ | ||
387 | 46 | -iquote$(XORG_GTEST_SOURCE) \ | ||
388 | 47 | -w | ||
389 | 48 | libxorg_gtest_a_CXXFLAGS = \ | ||
390 | 49 | $(XORG_GTEST_CXXFLAGS) \ | ||
391 | 50 | $(GTEST_CXXFLAGS) \ | ||
392 | 51 | $(AM_CPPFLAGS) | ||
393 | 52 | |||
394 | 53 | nodist_libxorg_gtest_main_a_SOURCES = \ | ||
395 | 54 | $(XORG_GTEST_SOURCE)/src/xorg-gtest_main.cpp | ||
396 | 55 | libxorg_gtest_main_a_CPPFLAGS = \ | ||
397 | 56 | --std=c++0x \ | ||
398 | 57 | $(XORG_GTEST_CPPFLAGS) \ | ||
399 | 58 | $(GTEST_CPPFLAGS) \ | ||
400 | 59 | $(AM_CPPFLAGS) \ | ||
401 | 60 | -iquote$(XORG_GTEST_SOURCE) \ | ||
402 | 61 | -w | ||
403 | 62 | libxorg_gtest_main_a_CXXFLAGS = \ | ||
404 | 63 | $(XORG_GTEST_CXXFLAGS) \ | ||
405 | 64 | $(GTEST_CXXFLAGS) \ | ||
406 | 65 | $(AM_CXXFLAGS) | ||
407 | 66 | |||
408 | 67 | XORG_GTEST_LIBS = libxorg-gtest.a libgtest.a -lpthread $(X11_LIBS) | ||
409 | 68 | XORG_GTEST_MAIN_LIBS = libxorg-gtest_main.a | ||
410 | 0 | 69 | ||
411 | === added file 'test/gtest/Makefile.am' | |||
412 | --- test/gtest/Makefile.am 1970-01-01 00:00:00 +0000 | |||
413 | +++ test/gtest/Makefile.am 2012-07-18 13:01:21 +0000 | |||
414 | @@ -0,0 +1,11 @@ | |||
415 | 1 | include $(top_srcdir)/test/gtest/Makefile-xorg-gtest.am | ||
416 | 2 | |||
417 | 3 | check_LIBRARIES = | ||
418 | 4 | |||
419 | 5 | if HAVE_GTEST | ||
420 | 6 | check_LIBRARIES += libgtest.a libgtest_main.a | ||
421 | 7 | endif | ||
422 | 8 | |||
423 | 9 | if ENABLE_INTEGRATION_TESTS | ||
424 | 10 | check_LIBRARIES += libxorg-gtest.a libxorg-gtest_main.a | ||
425 | 11 | endif | ||
426 | 0 | 12 | ||
427 | === added directory 'test/integration' | |||
428 | === renamed file 'test/Makefile.am' => 'test/integration/Makefile.am' | |||
429 | --- test/Makefile.am 2012-06-18 18:28:21 +0000 | |||
430 | +++ test/integration/Makefile.am 2012-07-18 13:01:21 +0000 | |||
431 | @@ -1,18 +1,11 @@ | |||
440 | 1 | test_targets = check-c-compile check-cxx-compile | 1 | test_targets = check-integration |
433 | 2 | |||
434 | 3 | if ENABLE_INTEGRATION_TESTS | ||
435 | 4 | include $(top_srcdir)/test/Makefile-xorg-gtest.am | ||
436 | 5 | check_LIBRARIES = $(XORG_GTEST_BUILD_LIBS) | ||
437 | 6 | |||
438 | 7 | test_targets += check-frame | ||
439 | 8 | endif | ||
441 | 9 | 2 | ||
442 | 10 | TESTS = $(test_targets) | 3 | TESTS = $(test_targets) |
444 | 11 | check_PROGRAMS = $(test_targets) check-static-type-checking | 4 | check_PROGRAMS = $(test_targets) |
445 | 12 | 5 | ||
446 | 13 | x11dir = x11 | 6 | x11dir = x11 |
447 | 14 | 7 | ||
449 | 15 | check_frame_SOURCES = \ | 8 | check_integration_SOURCES = \ |
450 | 16 | events.cpp \ | 9 | events.cpp \ |
451 | 17 | events.h \ | 10 | events.h \ |
452 | 18 | x11/device.cpp \ | 11 | x11/device.cpp \ |
453 | @@ -22,53 +15,43 @@ | |||
454 | 22 | x11/ids.cpp \ | 15 | x11/ids.cpp \ |
455 | 23 | x11/recording.cpp | 16 | x11/recording.cpp |
456 | 24 | 17 | ||
458 | 25 | AM_CPPFLAGS = \ | 18 | check_integration_CPPFLAGS = \ |
459 | 19 | --std=c++0x \ | ||
460 | 20 | -I$(top_srcdir) \ | ||
461 | 26 | -I$(top_srcdir)/include \ | 21 | -I$(top_srcdir)/include \ |
462 | 22 | -I../include \ | ||
463 | 23 | -DTEST_ROOT_DIR=\"$(abs_top_srcdir)/test/integration/\"\ | ||
464 | 27 | $(WARNING_CPPFLAGS) \ | 24 | $(WARNING_CPPFLAGS) \ |
465 | 28 | $(GTEST_CPPFLAGS) \ | 25 | $(GTEST_CPPFLAGS) \ |
466 | 29 | $(XORG_GTEST_CPPFLAGS) | 26 | $(XORG_GTEST_CPPFLAGS) |
467 | 30 | 27 | ||
469 | 31 | AM_CFLAGS = $(C11_CFLAGS) $(COVERAGE_CFLAGS) | 28 | check_integration_CFLAGS = \ |
470 | 29 | $(C11_CFLAGS) \ | ||
471 | 30 | $(COVERAGE_CFLAGS) \ | ||
472 | 31 | $(XORG_GTEST_CFLAGS) | ||
473 | 32 | 32 | ||
475 | 33 | AM_CXXFLAGS = \ | 33 | check_integration_CXXFLAGS = \ |
476 | 34 | $(CXX11_CXXFLAGS) \ | 34 | $(CXX11_CXXFLAGS) \ |
477 | 35 | $(COVERAGE_CXXFLAGS) \ | ||
478 | 35 | $(GTEST_CXXFLAGS) \ | 36 | $(GTEST_CXXFLAGS) \ |
479 | 36 | $(COVERAGE_CXXFLAGS) \ | ||
480 | 37 | $(XORG_GTEST_CXXFLAGS) | 37 | $(XORG_GTEST_CXXFLAGS) |
481 | 38 | 38 | ||
493 | 39 | check_c_compile_SOURCES = check-c-compile.c | 39 | # check_integration_LDFLAGS = $(GTEST_LDFLAGS) |
483 | 40 | check_c_compile_LDADD = \ | ||
484 | 41 | $(top_builddir)/src/libutouch-frame.la \ | ||
485 | 42 | $(COVERAGE_LIBS) | ||
486 | 43 | |||
487 | 44 | check_cxx_compile_SOURCES = check-cxx-compile.cpp | ||
488 | 45 | check_cxx_compile_LDADD = \ | ||
489 | 46 | $(top_builddir)/src/libutouch-frame.la \ | ||
490 | 47 | $(COVERAGE_LIBS) | ||
491 | 48 | |||
492 | 49 | check_frame_LDFLAGS = $(GTEST_LDFLAGS) | ||
494 | 50 | 40 | ||
495 | 51 | # | 41 | # |
496 | 52 | # Link against the (non-distributed) static lib to pick up the | 42 | # Link against the (non-distributed) static lib to pick up the |
497 | 53 | # internal symbols. | 43 | # internal symbols. |
498 | 54 | # | 44 | # |
500 | 55 | check_frame_LDADD = \ | 45 | check_integration_LDADD = \ |
501 | 56 | $(top_builddir)/src/.libs/libutouch-frame.a \ | 46 | $(top_builddir)/src/.libs/libutouch-frame.a \ |
502 | 47 | $(top_builddir)/test/gtest/libgtest.a \ | ||
503 | 48 | $(top_builddir)/test/gtest/libxorg-gtest.a \ | ||
504 | 49 | $(top_builddir)/test/gtest/libxorg-gtest_main.a \ | ||
505 | 50 | $(GTEST_LIBS) \ | ||
506 | 57 | $(XORG_GTEST_LIBS) \ | 51 | $(XORG_GTEST_LIBS) \ |
507 | 58 | $(XORG_GTEST_MAIN_LIBS) \ | ||
508 | 59 | $(XINPUT_LIBS) \ | 52 | $(XINPUT_LIBS) \ |
509 | 60 | $(EVEMU_LIBS) \ | 53 | $(EVEMU_LIBS) \ |
510 | 61 | $(COVERAGE_LIBS) \ | 54 | $(COVERAGE_LIBS) \ |
511 | 62 | $(CXX_LIBS) | 55 | $(CXX_LIBS) |
512 | 63 | 56 | ||
513 | 64 | check-static-type-checking$(EXEEXT): | ||
514 | 65 | @echo "Checking whether static type checking works..." | ||
515 | 66 | $(AM_V_at)if $(CC) -I../include -L../.libs check-static-type-checking.c -o check_static_type_checking; then \ | ||
516 | 67 | echo "FAIL: Static type checking source compiled without error"; \ | ||
517 | 68 | exit -1; \ | ||
518 | 69 | else \ | ||
519 | 70 | echo "SUCCESS: Static type checking source failed to compile"; \ | ||
520 | 71 | exit 0; \ | ||
521 | 72 | fi | ||
522 | 73 | |||
523 | 74 | EXTRA_DIST = recordings | 57 | EXTRA_DIST = recordings |
524 | 75 | 58 | ||
525 | === renamed file 'test/events.cpp' => 'test/integration/events.cpp' | |||
526 | === renamed file 'test/events.h' => 'test/integration/events.h' | |||
527 | === renamed directory 'test/recordings' => 'test/integration/recordings' | |||
528 | === renamed directory 'test/x11' => 'test/integration/x11' | |||
529 | === added directory 'test/regular' | |||
530 | === added file 'test/regular/Makefile.am' | |||
531 | --- test/regular/Makefile.am 1970-01-01 00:00:00 +0000 | |||
532 | +++ test/regular/Makefile.am 2012-07-18 13:01:21 +0000 | |||
533 | @@ -0,0 +1,57 @@ | |||
534 | 1 | test_targets = check-c-compile check-cxx-compile | ||
535 | 2 | |||
536 | 3 | if HAVE_GTEST | ||
537 | 4 | test_targets += check-regular | ||
538 | 5 | endif | ||
539 | 6 | |||
540 | 7 | TESTS = $(test_targets) | ||
541 | 8 | check_PROGRAMS = $(test_targets) check-static-type-checking | ||
542 | 9 | |||
543 | 10 | check_c_compile_SOURCES = check-c-compile.c | ||
544 | 11 | check_c_compile_LDADD = \ | ||
545 | 12 | $(top_builddir)/src/libutouch-frame.la \ | ||
546 | 13 | $(COVERAGE_LIBS) | ||
547 | 14 | |||
548 | 15 | check_cxx_compile_SOURCES = check-cxx-compile.cpp | ||
549 | 16 | check_cxx_compile_LDADD = \ | ||
550 | 17 | $(top_builddir)/src/libutouch-frame.la \ | ||
551 | 18 | $(COVERAGE_LIBS) | ||
552 | 19 | |||
553 | 20 | check-static-type-checking$(EXEEXT): | ||
554 | 21 | @echo "Checking whether static type checking works..." | ||
555 | 22 | $(AM_V_at)if $(CC) -I../../include -L../../.libs check-static-type-checking.c -o check_static_type_checking; then \ | ||
556 | 23 | echo "FAIL: Static type checking source compiled without error"; \ | ||
557 | 24 | exit -1; \ | ||
558 | 25 | else \ | ||
559 | 26 | echo "SUCCESS: Static type checking source failed to compile"; \ | ||
560 | 27 | exit 0; \ | ||
561 | 28 | fi | ||
562 | 29 | |||
563 | 30 | ### check-regular | ||
564 | 31 | |||
565 | 32 | check_regular_SOURCES = \ | ||
566 | 33 | accept-ended-touch.cpp \ | ||
567 | 34 | frame-fixture.cpp | ||
568 | 35 | |||
569 | 36 | # | ||
570 | 37 | # Link against the (non-distributed) static lib to pick up the | ||
571 | 38 | # internal symbols. | ||
572 | 39 | # | ||
573 | 40 | check_regular_LDADD = \ | ||
574 | 41 | $(top_builddir)/src/.libs/libutouch-frame.a \ | ||
575 | 42 | $(top_builddir)/test/gtest/libgtest.a \ | ||
576 | 43 | $(top_builddir)/test/gtest/libgtest_main.a \ | ||
577 | 44 | $(top_builddir)/test/x11_mocks/libx11_mocks.a \ | ||
578 | 45 | $(COVERAGE_LIBS) \ | ||
579 | 46 | $(GTEST_LIBS) | ||
580 | 47 | |||
581 | 48 | check_regular_CPPFLAGS = \ | ||
582 | 49 | --std=c++0x \ | ||
583 | 50 | -I$(top_srcdir) \ | ||
584 | 51 | -I$(top_srcdir)/include \ | ||
585 | 52 | -I$(top_srcdir)/test/x11_mocks \ | ||
586 | 53 | $(WARNING_CPPFLAGS) \ | ||
587 | 54 | $(GTEST_CPPFLAGS) | ||
588 | 55 | |||
589 | 56 | check_regular_CFLAGS = \ | ||
590 | 57 | $(COVERAGE_CFLAGS) | ||
591 | 0 | 58 | ||
592 | === added file 'test/regular/accept-ended-touch.cpp' | |||
593 | --- test/regular/accept-ended-touch.cpp 1970-01-01 00:00:00 +0000 | |||
594 | +++ test/regular/accept-ended-touch.cpp 2012-07-18 13:01:21 +0000 | |||
595 | @@ -0,0 +1,72 @@ | |||
596 | 1 | #include "frame-fixture.h" | ||
597 | 2 | #include "x11_mocks.h" | ||
598 | 3 | |||
599 | 4 | class AcceptEndedTouch : public FrameFixture | ||
600 | 5 | { | ||
601 | 6 | }; | ||
602 | 7 | |||
603 | 8 | /* | ||
604 | 9 | Regression test for https://bugs.launchpad.net/bugs/1025297 | ||
605 | 10 | |||
606 | 11 | The bug is as follows: | ||
607 | 12 | |||
608 | 13 | frame lib fails to forward the accept/reject command to xserver for an owned | ||
609 | 14 | touch if it has already ended. | ||
610 | 15 | |||
611 | 16 | Steps to reproduce the issue: | ||
612 | 17 | 1 - touch 1 begins and gets ownership | ||
613 | 18 | 2 - touch 1 ends | ||
614 | 19 | 3 - touch 2 begins and gets ownership | ||
615 | 20 | 4 - frame client accepts touch 1 | ||
616 | 21 | |||
617 | 22 | Expected outcome: | ||
618 | 23 | frame lib accepts the touch on the XInput backend. | ||
619 | 24 | |||
620 | 25 | Outcome of the bug: | ||
621 | 26 | Nothing happens. frame lib never accepts that touch. | ||
622 | 27 | */ | ||
623 | 28 | TEST_F(AcceptEndedTouch, Test) | ||
624 | 29 | { | ||
625 | 30 | UFStatus status; | ||
626 | 31 | UFDevice device; | ||
627 | 32 | |||
628 | 33 | xmock_server_time = 1234; | ||
629 | 34 | |||
630 | 35 | CreateXMockTouchScreenDevice(); | ||
631 | 36 | |||
632 | 37 | Display *display = XOpenDisplay(NULL); | ||
633 | 38 | |||
634 | 39 | status = frame_x11_new(display, &frame_handle); | ||
635 | 40 | ASSERT_EQ(UFStatusSuccess, status); | ||
636 | 41 | |||
637 | 42 | FetchDeviceAddedEvent(&device); | ||
638 | 43 | AssertNoMoreEvents(); | ||
639 | 44 | |||
640 | 45 | SendTouchEvent(XI_TouchBegin, 1, 10.0f, 10.0f); | ||
641 | 46 | SendTouchOwnershipEvent(1); | ||
642 | 47 | |||
643 | 48 | xmock_server_time += 10; | ||
644 | 49 | |||
645 | 50 | SendTouchEvent(XI_TouchEnd, 1, 10.0f, 20.0f); | ||
646 | 51 | |||
647 | 52 | xmock_server_time += 3; | ||
648 | 53 | |||
649 | 54 | SendTouchEvent(XI_TouchBegin, 2, 10.0f, 21.0f); | ||
650 | 55 | SendTouchOwnershipEvent(2); | ||
651 | 56 | |||
652 | 57 | UFWindowId frame_window_id = frame_x11_create_window_id(DefaultRootWindow(display)); | ||
653 | 58 | status = frame_x11_accept_touch(device, frame_window_id, 1); | ||
654 | 59 | ASSERT_EQ(UFStatusSuccess, status); | ||
655 | 60 | |||
656 | 61 | ASSERT_EQ(XIAcceptTouch, | ||
657 | 62 | xmock_get_touch_acceptance(xmock_devices[0].attachment /* device id */, | ||
658 | 63 | 1 /* touch id */, | ||
659 | 64 | DefaultRootWindow(display))); | ||
660 | 65 | |||
661 | 66 | frame_x11_delete(frame_handle); | ||
662 | 67 | frame_handle = nullptr; | ||
663 | 68 | |||
664 | 69 | XCloseDisplay(display); | ||
665 | 70 | |||
666 | 71 | DestroyXMockDevices(); | ||
667 | 72 | } | ||
668 | 0 | 73 | ||
669 | === renamed file 'test/check-c-compile.c' => 'test/regular/check-c-compile.c' | |||
670 | === renamed file 'test/check-cxx-compile.cpp' => 'test/regular/check-cxx-compile.cpp' | |||
671 | === renamed file 'test/check-static-type-checking.c' => 'test/regular/check-static-type-checking.c' | |||
672 | === added file 'test/regular/frame-fixture.cpp' | |||
673 | --- test/regular/frame-fixture.cpp 1970-01-01 00:00:00 +0000 | |||
674 | +++ test/regular/frame-fixture.cpp 2012-07-18 13:01:21 +0000 | |||
675 | @@ -0,0 +1,161 @@ | |||
676 | 1 | #include "frame-fixture.h" | ||
677 | 2 | #include "x11_mocks.h" | ||
678 | 3 | |||
679 | 4 | FrameFixture::FrameFixture() | ||
680 | 5 | : frame_handle(nullptr), | ||
681 | 6 | _xevent_serial_number(1) | ||
682 | 7 | { | ||
683 | 8 | } | ||
684 | 9 | |||
685 | 10 | void FrameFixture::SetUp() | ||
686 | 11 | { | ||
687 | 12 | xmock_touch_acceptance.clear(); | ||
688 | 13 | } | ||
689 | 14 | |||
690 | 15 | void FrameFixture::TearDown() | ||
691 | 16 | { | ||
692 | 17 | ASSERT_EQ(nullptr, frame_handle); | ||
693 | 18 | } | ||
694 | 19 | |||
695 | 20 | void FrameFixture::CreateXMockTouchScreenDevice() | ||
696 | 21 | { | ||
697 | 22 | xmock_devices_count = 1; | ||
698 | 23 | xmock_devices = (XIDeviceInfo*) calloc(xmock_devices_count, | ||
699 | 24 | sizeof(XIDeviceInfo)); | ||
700 | 25 | |||
701 | 26 | XITouchClassInfo *touch_info = (XITouchClassInfo*) malloc(sizeof(XITouchClassInfo)); | ||
702 | 27 | touch_info->type = XITouchClass; | ||
703 | 28 | touch_info->sourceid = 0; | ||
704 | 29 | touch_info->mode = XIDirectTouch; | ||
705 | 30 | touch_info->num_touches = 5; | ||
706 | 31 | |||
707 | 32 | XIValuatorClassInfo *x_axis_info = (XIValuatorClassInfo*) malloc(sizeof(XIValuatorClassInfo)); | ||
708 | 33 | x_axis_info->type = XIValuatorClass; | ||
709 | 34 | x_axis_info->sourceid = 0; | ||
710 | 35 | x_axis_info->number = 0; /* identifies it as being the X axis */ | ||
711 | 36 | x_axis_info->min = -500.0; | ||
712 | 37 | x_axis_info->max = 500.0; | ||
713 | 38 | x_axis_info->resolution = 3000; /* counts/meter */ | ||
714 | 39 | |||
715 | 40 | XIValuatorClassInfo *y_axis_info = (XIValuatorClassInfo*) malloc(sizeof(XIValuatorClassInfo)); | ||
716 | 41 | y_axis_info->type = XIValuatorClass; | ||
717 | 42 | y_axis_info->sourceid = 0; | ||
718 | 43 | y_axis_info->number = 1; /* identifies it as being the Y axis */ | ||
719 | 44 | y_axis_info->min = -500.0; | ||
720 | 45 | y_axis_info->max = 500.0; | ||
721 | 46 | y_axis_info->resolution = 3000; | ||
722 | 47 | |||
723 | 48 | XIAnyClassInfo **classes = (XIAnyClassInfo**) malloc(sizeof(XIAnyClassInfo*)*3); | ||
724 | 49 | classes[0] = (XIAnyClassInfo*) touch_info; | ||
725 | 50 | classes[1] = (XIAnyClassInfo*) x_axis_info; | ||
726 | 51 | classes[2] = (XIAnyClassInfo*) y_axis_info; | ||
727 | 52 | |||
728 | 53 | xmock_devices[0].deviceid = 0; | ||
729 | 54 | xmock_devices[0].name = const_cast<char *>("Fake Touch Screen"); | ||
730 | 55 | xmock_devices[0].use = XISlavePointer; | ||
731 | 56 | xmock_devices[0].attachment = 1; | ||
732 | 57 | xmock_devices[0].enabled = True; | ||
733 | 58 | xmock_devices[0].num_classes = 3; | ||
734 | 59 | xmock_devices[0].classes = classes; | ||
735 | 60 | } | ||
736 | 61 | |||
737 | 62 | void FrameFixture::DestroyXMockDevices() | ||
738 | 63 | { | ||
739 | 64 | for (int i = 0; i < xmock_devices_count; ++i) | ||
740 | 65 | { | ||
741 | 66 | for (int j = 0; j < xmock_devices[i].num_classes; ++j) | ||
742 | 67 | free(xmock_devices[i].classes[j]); | ||
743 | 68 | free(xmock_devices[i].classes); | ||
744 | 69 | } | ||
745 | 70 | free(xmock_devices); | ||
746 | 71 | } | ||
747 | 72 | |||
748 | 73 | void FrameFixture::SendTouchEvent( | ||
749 | 74 | int event_type, int touch_id, float x, float y) | ||
750 | 75 | { | ||
751 | 76 | UFStatus status; | ||
752 | 77 | XGenericEventCookie xcookie; | ||
753 | 78 | XIDeviceEvent *device_event = 0; | ||
754 | 79 | |||
755 | 80 | device_event = (XIDeviceEvent*)calloc(1, sizeof(XIDeviceEvent)); | ||
756 | 81 | device_event->serial = _xevent_serial_number++; | ||
757 | 82 | device_event->display = xmock_display; | ||
758 | 83 | device_event->extension = xmock_xi2_opcode; | ||
759 | 84 | device_event->evtype = event_type; | ||
760 | 85 | device_event->time = xmock_server_time; | ||
761 | 86 | device_event->deviceid = 0; | ||
762 | 87 | device_event->sourceid = device_event->deviceid; | ||
763 | 88 | device_event->detail = touch_id; | ||
764 | 89 | device_event->root = DefaultRootWindow(xmock_display); | ||
765 | 90 | device_event->event = DefaultRootWindow(xmock_display); | ||
766 | 91 | device_event->child = 0; | ||
767 | 92 | device_event->root_x = x; | ||
768 | 93 | device_event->root_y = y; | ||
769 | 94 | device_event->event_x = device_event->root_x; | ||
770 | 95 | device_event->event_y = device_event->root_y; | ||
771 | 96 | device_event->valuators.mask_len = 2; | ||
772 | 97 | device_event->valuators.mask = (unsigned char*) malloc(2); | ||
773 | 98 | XISetMask(device_event->valuators.mask, 0); | ||
774 | 99 | XISetMask(device_event->valuators.mask, 1); | ||
775 | 100 | device_event->valuators.values = (double*) malloc(sizeof(double)*2); | ||
776 | 101 | device_event->valuators.values[0] = 0; /* just change the coordinate system */ | ||
777 | 102 | device_event->valuators.values[1] = 0; | ||
778 | 103 | xcookie.extension = xmock_xi2_opcode; | ||
779 | 104 | xcookie.evtype = event_type; | ||
780 | 105 | xcookie.data = device_event; | ||
781 | 106 | |||
782 | 107 | status = frame_x11_process_event(frame_handle, &xcookie); | ||
783 | 108 | ASSERT_EQ(UFStatusSuccess, status); | ||
784 | 109 | } | ||
785 | 110 | |||
786 | 111 | void FrameFixture::SendTouchOwnershipEvent(int touch_id) | ||
787 | 112 | { | ||
788 | 113 | UFStatus status; | ||
789 | 114 | XGenericEventCookie xcookie; | ||
790 | 115 | XITouchOwnershipEvent *ownership_event = 0; | ||
791 | 116 | |||
792 | 117 | ownership_event = (XITouchOwnershipEvent*)calloc(1, sizeof(XITouchOwnershipEvent)); | ||
793 | 118 | ownership_event->type = GenericEvent; | ||
794 | 119 | ownership_event->serial = _xevent_serial_number++; | ||
795 | 120 | ownership_event->display = xmock_display; | ||
796 | 121 | ownership_event->extension = xmock_xi2_opcode; | ||
797 | 122 | ownership_event->evtype = XI_TouchOwnership; | ||
798 | 123 | ownership_event->time = xmock_server_time; | ||
799 | 124 | ownership_event->deviceid = 0; | ||
800 | 125 | ownership_event->sourceid = ownership_event->deviceid; | ||
801 | 126 | ownership_event->touchid = touch_id; | ||
802 | 127 | ownership_event->root = DefaultRootWindow(xmock_display); | ||
803 | 128 | ownership_event->event = DefaultRootWindow(xmock_display); | ||
804 | 129 | ownership_event->child = 0; | ||
805 | 130 | xcookie.extension = xmock_xi2_opcode; | ||
806 | 131 | xcookie.evtype = XI_TouchOwnership; | ||
807 | 132 | xcookie.data = ownership_event; | ||
808 | 133 | |||
809 | 134 | status = frame_x11_process_event(frame_handle, &xcookie); | ||
810 | 135 | ASSERT_EQ(UFStatusSuccess, status); | ||
811 | 136 | } | ||
812 | 137 | |||
813 | 138 | void FrameFixture::FetchDeviceAddedEvent(UFDevice *device) | ||
814 | 139 | { | ||
815 | 140 | UFEvent event; | ||
816 | 141 | UFStatus status; | ||
817 | 142 | |||
818 | 143 | status = frame_get_event(frame_handle, &event); | ||
819 | 144 | ASSERT_EQ(UFStatusSuccess, status); | ||
820 | 145 | |||
821 | 146 | ASSERT_EQ(UFEventTypeDeviceAdded, frame_event_get_type(event)); | ||
822 | 147 | |||
823 | 148 | status = frame_event_get_property(event, UFEventPropertyDevice, device); | ||
824 | 149 | ASSERT_EQ(UFStatusSuccess, status); | ||
825 | 150 | |||
826 | 151 | frame_event_unref(event); | ||
827 | 152 | } | ||
828 | 153 | |||
829 | 154 | void FrameFixture::AssertNoMoreEvents() | ||
830 | 155 | { | ||
831 | 156 | UFEvent event; | ||
832 | 157 | UFStatus status; | ||
833 | 158 | |||
834 | 159 | status = frame_get_event(frame_handle, &event); | ||
835 | 160 | ASSERT_EQ(UFStatusErrorNoEvent, status); | ||
836 | 161 | } | ||
837 | 0 | 162 | ||
838 | === added file 'test/regular/frame-fixture.h' | |||
839 | --- test/regular/frame-fixture.h 1970-01-01 00:00:00 +0000 | |||
840 | +++ test/regular/frame-fixture.h 2012-07-18 13:01:21 +0000 | |||
841 | @@ -0,0 +1,31 @@ | |||
842 | 1 | #ifndef GTEST_FRAME_FIXTURE_H | ||
843 | 2 | #define GTEST_FRAME_FIXTURE_H | ||
844 | 3 | |||
845 | 4 | #include <gtest/gtest.h> | ||
846 | 5 | #include "utouch/frame.h" | ||
847 | 6 | #include "utouch/frame_x11.h" | ||
848 | 7 | |||
849 | 8 | class FrameFixture : public ::testing::Test | ||
850 | 9 | { | ||
851 | 10 | protected: | ||
852 | 11 | FrameFixture(); | ||
853 | 12 | |||
854 | 13 | virtual void SetUp(); | ||
855 | 14 | virtual void TearDown(); | ||
856 | 15 | |||
857 | 16 | void CreateXMockTouchScreenDevice(); | ||
858 | 17 | void DestroyXMockDevices(); | ||
859 | 18 | |||
860 | 19 | void SendTouchEvent(int event_type, int touch_id, float x, float y); | ||
861 | 20 | void SendTouchOwnershipEvent(int touch_id); | ||
862 | 21 | |||
863 | 22 | void FetchDeviceAddedEvent(UFDevice *device); | ||
864 | 23 | void AssertNoMoreEvents(); | ||
865 | 24 | |||
866 | 25 | UFHandle frame_handle; | ||
867 | 26 | private: | ||
868 | 27 | /* holds the serial number to be used on the next synthetic XEvent */ | ||
869 | 28 | int _xevent_serial_number; | ||
870 | 29 | }; | ||
871 | 30 | |||
872 | 31 | #endif | ||
873 | 0 | 32 | ||
874 | === added directory 'test/x11_mocks' | |||
875 | === added file 'test/x11_mocks/Makefile.am' | |||
876 | --- test/x11_mocks/Makefile.am 1970-01-01 00:00:00 +0000 | |||
877 | +++ test/x11_mocks/Makefile.am 2012-07-18 13:01:21 +0000 | |||
878 | @@ -0,0 +1,14 @@ | |||
879 | 1 | # | ||
880 | 2 | # @file testsuite/x11_mocks/Makefile.am | ||
881 | 3 | # @brief automake recipe for the X11 mockups | ||
882 | 4 | # | ||
883 | 5 | |||
884 | 6 | check_LIBRARIES = libx11_mocks.a | ||
885 | 7 | |||
886 | 8 | libx11_mocks_a_SOURCES = \ | ||
887 | 9 | x11_mocks.h x11_mocks.cpp | ||
888 | 10 | |||
889 | 11 | libx11_mocks_a_CPPFLAGS = \ | ||
890 | 12 | --std=c++0x \ | ||
891 | 13 | -Wno-unused-parameter | ||
892 | 14 | |||
893 | 0 | 15 | ||
894 | === added file 'test/x11_mocks/x11_mocks.cpp' | |||
895 | --- test/x11_mocks/x11_mocks.cpp 1970-01-01 00:00:00 +0000 | |||
896 | +++ test/x11_mocks/x11_mocks.cpp 2012-07-18 13:01:21 +0000 | |||
897 | @@ -0,0 +1,435 @@ | |||
898 | 1 | /* needed to break into 'Display' struct internals. */ | ||
899 | 2 | #define XLIB_ILLEGAL_ACCESS | ||
900 | 3 | #include <X11/Xlib.h> | ||
901 | 4 | |||
902 | 5 | #include "x11_mocks.h" | ||
903 | 6 | |||
904 | 7 | #include <sys/eventfd.h> | ||
905 | 8 | #include <stdio.h> | ||
906 | 9 | #include <stdlib.h> | ||
907 | 10 | #include <unistd.h> | ||
908 | 11 | |||
909 | 12 | int xmock_xi2_opcode = 42; | ||
910 | 13 | int xmock_xi2_event_base = 40000; | ||
911 | 14 | int xmock_xi2_error_base = 40000; | ||
912 | 15 | int xmock_xsync_event_base = 50000; | ||
913 | 16 | int xmock_xsync_error_base = 50000; | ||
914 | 17 | Display *xmock_display = NULL; | ||
915 | 18 | uint64_t xmock_server_time = 0; | ||
916 | 19 | |||
917 | 20 | XIDeviceInfo *xmock_devices = NULL; | ||
918 | 21 | int xmock_devices_count = 0; | ||
919 | 22 | |||
920 | 23 | std::map<int, std::map<unsigned int, std::map<Window, int> > > xmock_touch_acceptance; | ||
921 | 24 | |||
922 | 25 | /* id to be used for the next alarm that gets created */ | ||
923 | 26 | XSyncAlarm _xmock_next_alarm = 1; | ||
924 | 27 | |||
925 | 28 | struct EventQueueItem | ||
926 | 29 | { | ||
927 | 30 | XEvent event; | ||
928 | 31 | struct EventQueueItem *next; | ||
929 | 32 | } *xmock_event_queue = NULL; | ||
930 | 33 | |||
931 | 34 | #define XMOCK_PRINT_FUNCTION _xmock_print_function(__func__) | ||
932 | 35 | void _xmock_print_function(const char *function) | ||
933 | 36 | { | ||
934 | 37 | static int debug_enabled = -1; | ||
935 | 38 | if (debug_enabled == -1) | ||
936 | 39 | { | ||
937 | 40 | if (getenv("XMOCK_DEBUG")) | ||
938 | 41 | debug_enabled = 1; | ||
939 | 42 | else | ||
940 | 43 | debug_enabled = 0; | ||
941 | 44 | } | ||
942 | 45 | |||
943 | 46 | if (debug_enabled) | ||
944 | 47 | printf("XMOCK: %s mock called.\n", function); | ||
945 | 48 | } | ||
946 | 49 | |||
947 | 50 | void xmock_add_to_event_queue(const XEvent *event) | ||
948 | 51 | { | ||
949 | 52 | struct EventQueueItem *new_item = reinterpret_cast<struct EventQueueItem *>(malloc(sizeof(struct EventQueueItem))); | ||
950 | 53 | new_item->event = *event; | ||
951 | 54 | new_item->next = NULL; | ||
952 | 55 | |||
953 | 56 | if (!xmock_event_queue) | ||
954 | 57 | { | ||
955 | 58 | xmock_event_queue = new_item; | ||
956 | 59 | } | ||
957 | 60 | else | ||
958 | 61 | { | ||
959 | 62 | struct EventQueueItem *last_item = xmock_event_queue; | ||
960 | 63 | while (last_item->next) | ||
961 | 64 | { | ||
962 | 65 | last_item = last_item->next; | ||
963 | 66 | } | ||
964 | 67 | last_item->next = new_item; | ||
965 | 68 | } | ||
966 | 69 | |||
967 | 70 | static const uint64_t num = 1; | ||
968 | 71 | if (write(xmock_display->fd, &num, sizeof(num)) != sizeof(num)) | ||
969 | 72 | { | ||
970 | 73 | fprintf(stderr, "ERROR: failed to update eventfd instance,\n"); | ||
971 | 74 | exit(1); | ||
972 | 75 | } | ||
973 | 76 | } | ||
974 | 77 | |||
975 | 78 | int xmock_get_touch_acceptance(int device_id, unsigned int touch_id, Window window) | ||
976 | 79 | { | ||
977 | 80 | if (xmock_touch_acceptance.find(device_id) == xmock_touch_acceptance.end()) | ||
978 | 81 | return -1; | ||
979 | 82 | |||
980 | 83 | std::map<unsigned int, std::map<Window, int> > &touch_map = | ||
981 | 84 | xmock_touch_acceptance[device_id]; | ||
982 | 85 | |||
983 | 86 | if (touch_map.find(touch_id) == touch_map.end()) | ||
984 | 87 | return -1; | ||
985 | 88 | |||
986 | 89 | std::map<Window, int> &window_map = touch_map[touch_id]; | ||
987 | 90 | |||
988 | 91 | if (window_map.find(window) == window_map.end()) | ||
989 | 92 | return -1; | ||
990 | 93 | |||
991 | 94 | return window_map[window]; | ||
992 | 95 | } | ||
993 | 96 | |||
994 | 97 | Display *XOpenDisplay(_Xconst char *display_name) | ||
995 | 98 | { | ||
996 | 99 | XMOCK_PRINT_FUNCTION; | ||
997 | 100 | (void)display_name; | ||
998 | 101 | |||
999 | 102 | Display *display = (Display*)calloc(1, sizeof(Display)); | ||
1000 | 103 | display->fd = eventfd(0, EFD_NONBLOCK); | ||
1001 | 104 | display->default_screen = 0; | ||
1002 | 105 | display->nscreens = 1; | ||
1003 | 106 | display->screens = (Screen*)calloc(1, sizeof(Screen)); | ||
1004 | 107 | display->screens[0].root = 1; | ||
1005 | 108 | |||
1006 | 109 | xmock_display = display; | ||
1007 | 110 | |||
1008 | 111 | return display; | ||
1009 | 112 | } | ||
1010 | 113 | |||
1011 | 114 | int XCloseDisplay(Display *display) | ||
1012 | 115 | { | ||
1013 | 116 | XMOCK_PRINT_FUNCTION; | ||
1014 | 117 | |||
1015 | 118 | close(display->fd); | ||
1016 | 119 | free(display->screens); | ||
1017 | 120 | free(display); | ||
1018 | 121 | |||
1019 | 122 | xmock_display = NULL; | ||
1020 | 123 | |||
1021 | 124 | return 0; | ||
1022 | 125 | } | ||
1023 | 126 | |||
1024 | 127 | int XSync(Display *display, Bool discard) | ||
1025 | 128 | { | ||
1026 | 129 | (void)display; | ||
1027 | 130 | (void)discard; | ||
1028 | 131 | return 0; | ||
1029 | 132 | } | ||
1030 | 133 | |||
1031 | 134 | int XFlush(Display *display) | ||
1032 | 135 | { | ||
1033 | 136 | (void)display; | ||
1034 | 137 | return 0; | ||
1035 | 138 | } | ||
1036 | 139 | |||
1037 | 140 | Bool XQueryExtension(Display *display, const char *name, | ||
1038 | 141 | int *major_opcode_return, int *first_event_return, int *first_error_return) | ||
1039 | 142 | { | ||
1040 | 143 | XMOCK_PRINT_FUNCTION; | ||
1041 | 144 | (void)display; | ||
1042 | 145 | (void)name; /* assuming name == "XInputExtension" */ | ||
1043 | 146 | |||
1044 | 147 | *major_opcode_return = xmock_xi2_opcode; | ||
1045 | 148 | *first_event_return = xmock_xi2_event_base; | ||
1046 | 149 | *first_error_return = xmock_xi2_error_base; | ||
1047 | 150 | |||
1048 | 151 | return True; | ||
1049 | 152 | } | ||
1050 | 153 | |||
1051 | 154 | int XPending(Display *display) | ||
1052 | 155 | { | ||
1053 | 156 | XMOCK_PRINT_FUNCTION; | ||
1054 | 157 | (void)display; | ||
1055 | 158 | |||
1056 | 159 | int pending_events_count = 0; | ||
1057 | 160 | struct EventQueueItem *item = xmock_event_queue; | ||
1058 | 161 | while (item != NULL) | ||
1059 | 162 | { | ||
1060 | 163 | ++pending_events_count; | ||
1061 | 164 | item = item->next; | ||
1062 | 165 | } | ||
1063 | 166 | return pending_events_count; | ||
1064 | 167 | } | ||
1065 | 168 | |||
1066 | 169 | int XNextEvent(Display *display, XEvent *event_return) | ||
1067 | 170 | { | ||
1068 | 171 | XMOCK_PRINT_FUNCTION; | ||
1069 | 172 | (void)display; | ||
1070 | 173 | |||
1071 | 174 | |||
1072 | 175 | if (xmock_event_queue) | ||
1073 | 176 | { | ||
1074 | 177 | uint64_t num = 1; | ||
1075 | 178 | ssize_t bytes_read = read(xmock_display->fd, &num, sizeof(num)); | ||
1076 | 179 | (void)bytes_read; | ||
1077 | 180 | |||
1078 | 181 | *event_return = xmock_event_queue->event; | ||
1079 | 182 | |||
1080 | 183 | struct EventQueueItem *removed_item = xmock_event_queue; | ||
1081 | 184 | xmock_event_queue = xmock_event_queue->next; | ||
1082 | 185 | free(removed_item); | ||
1083 | 186 | } | ||
1084 | 187 | else | ||
1085 | 188 | { | ||
1086 | 189 | /* not going to block... */ | ||
1087 | 190 | } | ||
1088 | 191 | |||
1089 | 192 | return 0; | ||
1090 | 193 | } | ||
1091 | 194 | |||
1092 | 195 | Bool XGetEventData(Display *display, XGenericEventCookie *cookie) | ||
1093 | 196 | { | ||
1094 | 197 | XMOCK_PRINT_FUNCTION; | ||
1095 | 198 | (void)display; | ||
1096 | 199 | (void)cookie; | ||
1097 | 200 | return True; | ||
1098 | 201 | } | ||
1099 | 202 | |||
1100 | 203 | void XFreeEventData(Display *display, XGenericEventCookie *cookie) | ||
1101 | 204 | { | ||
1102 | 205 | XMOCK_PRINT_FUNCTION; | ||
1103 | 206 | (void)display; | ||
1104 | 207 | |||
1105 | 208 | if (cookie->data && cookie->extension == xmock_xi2_opcode) | ||
1106 | 209 | { | ||
1107 | 210 | if (cookie->evtype == XI_TouchBegin | ||
1108 | 211 | || cookie->evtype == XI_TouchUpdate | ||
1109 | 212 | || cookie->evtype == XI_TouchEnd) | ||
1110 | 213 | { | ||
1111 | 214 | XIDeviceEvent *device_event = (XIDeviceEvent*) cookie->data; | ||
1112 | 215 | free(device_event->valuators.mask); | ||
1113 | 216 | free(device_event->valuators.values); | ||
1114 | 217 | } | ||
1115 | 218 | free(cookie->data); | ||
1116 | 219 | } | ||
1117 | 220 | } | ||
1118 | 221 | |||
1119 | 222 | XIDeviceInfo* XIQueryDevice(Display * display, | ||
1120 | 223 | int deviceid, | ||
1121 | 224 | int * ndevices_return) | ||
1122 | 225 | { | ||
1123 | 226 | XMOCK_PRINT_FUNCTION; | ||
1124 | 227 | (void)display; | ||
1125 | 228 | (void)deviceid; /* assuming XIAllDevices */ | ||
1126 | 229 | |||
1127 | 230 | XIDeviceInfo *devices; | ||
1128 | 231 | |||
1129 | 232 | devices = reinterpret_cast<XIDeviceInfo*>(calloc(xmock_devices_count, sizeof(XIDeviceInfo))); | ||
1130 | 233 | |||
1131 | 234 | for (int i = 0; i < xmock_devices_count; ++i) { | ||
1132 | 235 | devices[i] = xmock_devices[i]; | ||
1133 | 236 | } | ||
1134 | 237 | |||
1135 | 238 | *ndevices_return = xmock_devices_count; | ||
1136 | 239 | |||
1137 | 240 | return devices; | ||
1138 | 241 | } | ||
1139 | 242 | |||
1140 | 243 | void XIFreeDeviceInfo(XIDeviceInfo *info) | ||
1141 | 244 | { | ||
1142 | 245 | XMOCK_PRINT_FUNCTION; | ||
1143 | 246 | free(info); | ||
1144 | 247 | } | ||
1145 | 248 | |||
1146 | 249 | Status XIQueryVersion(Display *display, | ||
1147 | 250 | int *major_version_inout, | ||
1148 | 251 | int *minor_version_inout) | ||
1149 | 252 | { | ||
1150 | 253 | XMOCK_PRINT_FUNCTION; | ||
1151 | 254 | (void)display; | ||
1152 | 255 | *major_version_inout = 2; | ||
1153 | 256 | *minor_version_inout = 2; | ||
1154 | 257 | return Success; | ||
1155 | 258 | } | ||
1156 | 259 | |||
1157 | 260 | Status XISelectEvents(Display *display, | ||
1158 | 261 | Window win, | ||
1159 | 262 | XIEventMask *masks, | ||
1160 | 263 | int num_masks) | ||
1161 | 264 | { | ||
1162 | 265 | XMOCK_PRINT_FUNCTION; | ||
1163 | 266 | (void)display; | ||
1164 | 267 | (void)win; | ||
1165 | 268 | (void)masks; | ||
1166 | 269 | (void)num_masks; | ||
1167 | 270 | return Success; | ||
1168 | 271 | } | ||
1169 | 272 | |||
1170 | 273 | int XIGrabTouchBegin( | ||
1171 | 274 | Display* display, | ||
1172 | 275 | int deviceid, | ||
1173 | 276 | Window grab_window, | ||
1174 | 277 | int owner_events, | ||
1175 | 278 | XIEventMask *mask, | ||
1176 | 279 | int num_modifiers, | ||
1177 | 280 | XIGrabModifiers *modifiers_inout) | ||
1178 | 281 | { | ||
1179 | 282 | XMOCK_PRINT_FUNCTION; | ||
1180 | 283 | (void)display; | ||
1181 | 284 | (void)deviceid; | ||
1182 | 285 | (void)grab_window; | ||
1183 | 286 | (void)owner_events; | ||
1184 | 287 | (void)mask; | ||
1185 | 288 | |||
1186 | 289 | for (int i = 0; i < num_modifiers; ++i) | ||
1187 | 290 | { | ||
1188 | 291 | modifiers_inout[i].status = XIGrabSuccess; | ||
1189 | 292 | } | ||
1190 | 293 | |||
1191 | 294 | return 0; | ||
1192 | 295 | } | ||
1193 | 296 | |||
1194 | 297 | Status XIUngrabTouchBegin( | ||
1195 | 298 | Display* display, | ||
1196 | 299 | int deviceid, | ||
1197 | 300 | Window grab_window, | ||
1198 | 301 | int num_modifiers, | ||
1199 | 302 | XIGrabModifiers *modifiers) | ||
1200 | 303 | { | ||
1201 | 304 | XMOCK_PRINT_FUNCTION; | ||
1202 | 305 | (void)display; | ||
1203 | 306 | (void)deviceid; | ||
1204 | 307 | (void)grab_window; | ||
1205 | 308 | (void)num_modifiers; | ||
1206 | 309 | (void)modifiers; | ||
1207 | 310 | return Success; | ||
1208 | 311 | } | ||
1209 | 312 | |||
1210 | 313 | Status XIAllowTouchEvents( | ||
1211 | 314 | Display* display, | ||
1212 | 315 | int deviceid, | ||
1213 | 316 | unsigned int touchid, | ||
1214 | 317 | Window grab_window, | ||
1215 | 318 | int event_mode) | ||
1216 | 319 | { | ||
1217 | 320 | XMOCK_PRINT_FUNCTION; | ||
1218 | 321 | (void)display; | ||
1219 | 322 | xmock_touch_acceptance[deviceid][touchid][grab_window] = event_mode; | ||
1220 | 323 | return Success; | ||
1221 | 324 | } | ||
1222 | 325 | |||
1223 | 326 | Status XSyncQueryExtension( | ||
1224 | 327 | Display* dpy, | ||
1225 | 328 | int* event_base_return, | ||
1226 | 329 | int* error_base_return) | ||
1227 | 330 | { | ||
1228 | 331 | XMOCK_PRINT_FUNCTION; | ||
1229 | 332 | (void)dpy; | ||
1230 | 333 | *event_base_return = xmock_xsync_event_base; | ||
1231 | 334 | *error_base_return = xmock_xsync_error_base; | ||
1232 | 335 | return True; | ||
1233 | 336 | } | ||
1234 | 337 | |||
1235 | 338 | Status XSyncInitialize( | ||
1236 | 339 | Display* dpy, | ||
1237 | 340 | int* major_version_return, | ||
1238 | 341 | int* minor_version_return) | ||
1239 | 342 | { | ||
1240 | 343 | XMOCK_PRINT_FUNCTION; | ||
1241 | 344 | (void)dpy; | ||
1242 | 345 | *major_version_return = 1; | ||
1243 | 346 | *minor_version_return = 0; | ||
1244 | 347 | return True; | ||
1245 | 348 | } | ||
1246 | 349 | |||
1247 | 350 | XSyncSystemCounter *XSyncListSystemCounters( | ||
1248 | 351 | Display* dpy, | ||
1249 | 352 | int* n_counters_return) | ||
1250 | 353 | { | ||
1251 | 354 | XMOCK_PRINT_FUNCTION; | ||
1252 | 355 | (void)dpy; | ||
1253 | 356 | *n_counters_return = 1; | ||
1254 | 357 | |||
1255 | 358 | XSyncSystemCounter *sys_counter = reinterpret_cast<XSyncSystemCounter*>(malloc(sizeof(XSyncSystemCounter))); | ||
1256 | 359 | sys_counter->name = const_cast<char*>("SERVERTIME"); // I know it's technically dangerous, but it's simple. | ||
1257 | 360 | sys_counter->counter = 1; | ||
1258 | 361 | sys_counter->resolution.hi = 1; | ||
1259 | 362 | sys_counter->resolution.lo = 0; | ||
1260 | 363 | return sys_counter; | ||
1261 | 364 | } | ||
1262 | 365 | |||
1263 | 366 | void XSyncFreeSystemCounterList(XSyncSystemCounter* list) | ||
1264 | 367 | { | ||
1265 | 368 | XMOCK_PRINT_FUNCTION; | ||
1266 | 369 | free(list); | ||
1267 | 370 | } | ||
1268 | 371 | |||
1269 | 372 | XSyncAlarm XSyncCreateAlarm( | ||
1270 | 373 | Display* dpy, | ||
1271 | 374 | unsigned long values_mask, | ||
1272 | 375 | XSyncAlarmAttributes* values) | ||
1273 | 376 | { | ||
1274 | 377 | XMOCK_PRINT_FUNCTION; | ||
1275 | 378 | (void)dpy; | ||
1276 | 379 | |||
1277 | 380 | XSyncAlarmNotifyEvent alarm_notify; | ||
1278 | 381 | alarm_notify.type = xmock_xsync_event_base + XSyncAlarmNotify; | ||
1279 | 382 | alarm_notify.alarm = _xmock_next_alarm; | ||
1280 | 383 | alarm_notify.counter_value = values->trigger.wait_value; | ||
1281 | 384 | xmock_add_to_event_queue((XEvent*)&alarm_notify); | ||
1282 | 385 | |||
1283 | 386 | XSyncValue time = values->trigger.wait_value; | ||
1284 | 387 | uint64_t timeout = (uint64_t)XSyncValueHigh32(time) << 32 | ||
1285 | 388 | | (uint64_t)XSyncValueLow32(time); | ||
1286 | 389 | xmock_server_time = timeout + 1; | ||
1287 | 390 | |||
1288 | 391 | return _xmock_next_alarm++; | ||
1289 | 392 | } | ||
1290 | 393 | |||
1291 | 394 | Status XSyncDestroyAlarm( | ||
1292 | 395 | Display* dpy, | ||
1293 | 396 | XSyncAlarm alarm) | ||
1294 | 397 | { | ||
1295 | 398 | XMOCK_PRINT_FUNCTION; | ||
1296 | 399 | (void)dpy; | ||
1297 | 400 | (void)alarm; | ||
1298 | 401 | return Success; | ||
1299 | 402 | } | ||
1300 | 403 | |||
1301 | 404 | void XSyncIntsToValue( | ||
1302 | 405 | XSyncValue* pv, | ||
1303 | 406 | unsigned int l, | ||
1304 | 407 | int h) | ||
1305 | 408 | { | ||
1306 | 409 | XMOCK_PRINT_FUNCTION; | ||
1307 | 410 | pv->hi = h; | ||
1308 | 411 | pv->lo = l; | ||
1309 | 412 | } | ||
1310 | 413 | |||
1311 | 414 | int XSyncValueHigh32(XSyncValue v) | ||
1312 | 415 | { | ||
1313 | 416 | XMOCK_PRINT_FUNCTION; | ||
1314 | 417 | return v.hi; | ||
1315 | 418 | } | ||
1316 | 419 | |||
1317 | 420 | unsigned int XSyncValueLow32(XSyncValue v) | ||
1318 | 421 | { | ||
1319 | 422 | XMOCK_PRINT_FUNCTION; | ||
1320 | 423 | return v.lo; | ||
1321 | 424 | } | ||
1322 | 425 | |||
1323 | 426 | Atom XInternAtom(Display* display, _Xconst char* atom_name, Bool only_if_exists) | ||
1324 | 427 | { | ||
1325 | 428 | XMOCK_PRINT_FUNCTION; | ||
1326 | 429 | /* This function doesn't end up getting called when frame is run from tests yet. | ||
1327 | 430 | It's here just to make the code compile. Add some minimal logic when needed. */ | ||
1328 | 431 | abort(); | ||
1329 | 432 | return 1; | ||
1330 | 433 | } | ||
1331 | 434 | |||
1332 | 435 | |||
1333 | 0 | 436 | ||
1334 | === added file 'test/x11_mocks/x11_mocks.h' | |||
1335 | --- test/x11_mocks/x11_mocks.h 1970-01-01 00:00:00 +0000 | |||
1336 | +++ test/x11_mocks/x11_mocks.h 2012-07-18 13:01:21 +0000 | |||
1337 | @@ -0,0 +1,41 @@ | |||
1338 | 1 | #ifndef X11_MOCKS_H | ||
1339 | 2 | #define X11_MOCKS_H | ||
1340 | 3 | |||
1341 | 4 | #include <X11/Xlib.h> | ||
1342 | 5 | #include <X11/extensions/XInput2.h> | ||
1343 | 6 | #include <X11/extensions/sync.h> | ||
1344 | 7 | #include <stdint.h> | ||
1345 | 8 | #include <map> | ||
1346 | 9 | |||
1347 | 10 | extern int xmock_xi2_opcode; | ||
1348 | 11 | extern int xmock_xi2_event_base; | ||
1349 | 12 | extern int xmock_xi2_error_base; | ||
1350 | 13 | extern int xmock_xsync_event_base; | ||
1351 | 14 | extern int xmock_xsync_error_base; | ||
1352 | 15 | extern Display *xmock_display; | ||
1353 | 16 | extern uint64_t xmock_server_time; | ||
1354 | 17 | |||
1355 | 18 | /* to be filled by user. A copy of it will be returned by each | ||
1356 | 19 | XIQueryDevice call */ | ||
1357 | 20 | extern XIDeviceInfo *xmock_devices; | ||
1358 | 21 | extern int xmock_devices_count; | ||
1359 | 22 | |||
1360 | 23 | /* Adds the given XEvent to the xmock event queue. | ||
1361 | 24 | The Diplay connection will signal that there are | ||
1362 | 25 | pending events */ | ||
1363 | 26 | extern void xmock_add_to_event_queue(const XEvent* event); | ||
1364 | 27 | |||
1365 | 28 | /* | ||
1366 | 29 | Each call to: | ||
1367 | 30 | XIAllowTouchEvents(display, device_id, touch_id, window_id, touch_acceptance) | ||
1368 | 31 | Causes: | ||
1369 | 32 | xmock_touch_acceptance[device_id][touch_id][window_id] = touch_acceptance; | ||
1370 | 33 | */ | ||
1371 | 34 | extern std::map<int, std::map<unsigned int, std::map<Window, int> > > xmock_touch_acceptance; | ||
1372 | 35 | |||
1373 | 36 | /* | ||
1374 | 37 | Returns -1 if XIAllowTouchEvents wasn't called with the given parameters. | ||
1375 | 38 | */ | ||
1376 | 39 | int xmock_get_touch_acceptance(int device_id, unsigned int touch_id, Window window); | ||
1377 | 40 | |||
1378 | 41 | #endif |
* The added gtest.m4 file shouldn't have a serial number since it's not distributed anywhere. The serial number implies that it was copied in from some other distribution.
* The Makefile- xorg-gtest. am removal should be reverted. I think you removed it because of issues with the wrong files being included when compiling xorg-gtest itself. This has been fixed in the Makefile- xorg-gtest. am shipped upstream. It has not been fixed in Ubuntu yet, but you can download the change from here:
http:// cgit.freedeskto p.org/xorg/ test/xorg- gtest/commit/ ?id=3fefcde53f8 b69b37baeec6126 5f2e0190713fe6
Everything else looks good!