Merge lp:~dandrader/unity/lp940612 into lp:unity
- lp940612
- Merge into trunk
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Tim Penhey | ||||
Approved revision: | no longer in the source branch. | ||||
Merged at revision: | 2240 | ||||
Proposed branch: | lp:~dandrader/unity/lp940612 | ||||
Merge into: | lp:unity | ||||
Diff against target: |
1178 lines (+831/-69) 19 files modified
plugins/unityshell/src/GeisAdapter.cpp (+10/-10) plugins/unityshell/src/GeisAdapter.h (+10/-10) plugins/unityshell/src/GestureEngine.cpp (+22/-40) plugins/unityshell/src/GestureEngine.h (+1/-2) tests/CMakeLists.txt (+14/-7) tests/test-gesture-engine/CMakeLists.txt (+40/-0) tests/test-gesture-engine/GeisAdapterMock.cpp (+30/-0) tests/test-gesture-engine/GeisAdapterMock.h (+148/-0) tests/test-gesture-engine/PluginAdapterMock.cpp (+33/-0) tests/test-gesture-engine/PluginAdapterMock.h (+37/-0) tests/test-gesture-engine/X11_mock.cpp (+40/-0) tests/test-gesture-engine/X11_mock.h (+37/-0) tests/test-gesture-engine/compiz_mock/core/core.h (+29/-0) tests/test-gesture-engine/compiz_mock/core/screen.h (+68/-0) tests/test-gesture-engine/compiz_mock/core/window.h (+66/-0) tests/test-gesture-engine/sed_script (+14/-0) tests/test-gesture-engine/test_gesture_engine.cpp (+165/-0) tests/test-gesture-engine/ubus-server-mock.cpp (+32/-0) tests/test-gesture-engine/ubus-server-mock.h (+35/-0) |
||||
To merge this branch: | bzr merge lp:~dandrader/unity/lp940612 | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Tim Penhey (community) | Approve | ||
Review via email: mp+99956@code.launchpad.net |
This proposal supersedes a proposal from 2012-03-28.
Commit message
Fix the three-finger move for unity.
Description of the change
Fixes bug #940612.
Updated according to comments from previous proposal.
Tim Penhey (thumper) wrote : Posted in a previous version of this proposal | # |
Daniel d'Andrada (dandrader) wrote : | # |
Updated. The loop sure looks better now.
Tim Penhey (thumper) wrote : | # |
You don't need this check in the method any more, because it is caught by rbegin() == rend().
171 + if (client_
172 + return nullptr;
Once you push, you don't need to resubmit. Launchpad will just update the diff.
Do we have any tests for this?
Is there any way to "fake" utouch events?
Daniel d'Andrada (dandrader) wrote : | # |
> You don't need this check in the method any more, because it is caught by
> rbegin() == rend().
>
> 171 + if (client_
> 172 + return nullptr;
True. Line removed.
> Once you push, you don't need to resubmit. Launchpad will just update the
> diff.
Alright. I've pushed the updated version. Let's see.
> Do we have any tests for this?
No.
> Is there any way to "fake" utouch events?
Only if you do some mocking in a unity test.
But you can record and then replay multitouch events straight out of a /dev/input/eventX file using utouch-evemu-tools (for the recording) and libutouch-evemu1 in your test. But it would be a functional or integration test since several layers would be involved (events coming out of /dev/input/eventX into xserver and then sent as XInput2 events to compiz)
Tim Penhey (thumper) wrote : | # |
Unless autopilot tests are trivial to add for this, I'd suggest we have a manual test for now.
There is a template in the manual-tests directory.
Code looks fine now.
Daniel d'Andrada (dandrader) wrote : | # |
> Unless autopilot tests are trivial to add for this, I'd suggest we have a
> manual test for now.
> [...]
It now has unit tests.
Tim Penhey (thumper) : | # |
Preview Diff
1 | === modified file 'plugins/unityshell/src/GeisAdapter.cpp' | |||
2 | --- plugins/unityshell/src/GeisAdapter.cpp 2011-12-22 17:52:55 +0000 | |||
3 | +++ plugins/unityshell/src/GeisAdapter.cpp 2012-04-04 14:40:28 +0000 | |||
4 | @@ -237,9 +237,9 @@ | |||
5 | 237 | else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_TIMESTAMP)) | 237 | else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_TIMESTAMP)) |
6 | 238 | result->timestamp = attr.integer_val; | 238 | result->timestamp = attr.integer_val; |
7 | 239 | else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_FOCUS_X)) | 239 | else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_FOCUS_X)) |
9 | 240 | result->focus_x = attr.integer_val; | 240 | result->focus_x = attr.float_val; |
10 | 241 | else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_FOCUS_Y)) | 241 | else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_FOCUS_Y)) |
12 | 242 | result->focus_y = attr.integer_val; | 242 | result->focus_y = attr.float_val; |
13 | 243 | else if (g_str_equal (attr.name, GEIS_GESTURE_ATTRIBUTE_TOUCHES)) | 243 | else if (g_str_equal (attr.name, GEIS_GESTURE_ATTRIBUTE_TOUCHES)) |
14 | 244 | result->touches = attr.integer_val; | 244 | result->touches = attr.integer_val; |
15 | 245 | else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_GESTURE_NAME)) | 245 | else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_GESTURE_NAME)) |
16 | @@ -289,9 +289,9 @@ | |||
17 | 289 | else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_TIMESTAMP)) | 289 | else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_TIMESTAMP)) |
18 | 290 | result->timestamp = attr.integer_val; | 290 | result->timestamp = attr.integer_val; |
19 | 291 | else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_FOCUS_X)) | 291 | else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_FOCUS_X)) |
21 | 292 | result->focus_x = attr.integer_val; | 292 | result->focus_x = attr.float_val; |
22 | 293 | else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_FOCUS_Y)) | 293 | else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_FOCUS_Y)) |
24 | 294 | result->focus_y = attr.integer_val; | 294 | result->focus_y = attr.float_val; |
25 | 295 | else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_TOUCHES)) | 295 | else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_TOUCHES)) |
26 | 296 | result->touches = attr.integer_val; | 296 | result->touches = attr.integer_val; |
27 | 297 | else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_BOUNDINGBOX_X1)) | 297 | else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_BOUNDINGBOX_X1)) |
28 | @@ -322,9 +322,9 @@ | |||
29 | 322 | else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_TIMESTAMP)) | 322 | else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_TIMESTAMP)) |
30 | 323 | result->timestamp = attr.integer_val; | 323 | result->timestamp = attr.integer_val; |
31 | 324 | else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_FOCUS_X)) | 324 | else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_FOCUS_X)) |
33 | 325 | result->focus_x = attr.integer_val; | 325 | result->focus_x = attr.float_val; |
34 | 326 | else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_FOCUS_Y)) | 326 | else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_FOCUS_Y)) |
36 | 327 | result->focus_y = attr.integer_val; | 327 | result->focus_y = attr.float_val; |
37 | 328 | else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_TOUCHES)) | 328 | else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_TOUCHES)) |
38 | 329 | result->touches = attr.integer_val; | 329 | result->touches = attr.integer_val; |
39 | 330 | else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_POSITION_X)) | 330 | else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_POSITION_X)) |
40 | @@ -367,9 +367,9 @@ | |||
41 | 367 | else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_TIMESTAMP)) | 367 | else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_TIMESTAMP)) |
42 | 368 | result->timestamp = attr.integer_val; | 368 | result->timestamp = attr.integer_val; |
43 | 369 | else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_FOCUS_X)) | 369 | else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_FOCUS_X)) |
45 | 370 | result->focus_x = attr.integer_val; | 370 | result->focus_x = attr.float_val; |
46 | 371 | else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_FOCUS_Y)) | 371 | else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_FOCUS_Y)) |
48 | 372 | result->focus_y = attr.integer_val; | 372 | result->focus_y = attr.float_val; |
49 | 373 | else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_TOUCHES)) | 373 | else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_TOUCHES)) |
50 | 374 | result->touches = attr.integer_val; | 374 | result->touches = attr.integer_val; |
51 | 375 | else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_RADIUS)) | 375 | else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_RADIUS)) |
52 | @@ -406,9 +406,9 @@ | |||
53 | 406 | else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_TIMESTAMP)) | 406 | else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_TIMESTAMP)) |
54 | 407 | result->timestamp = attr.integer_val; | 407 | result->timestamp = attr.integer_val; |
55 | 408 | else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_FOCUS_X)) | 408 | else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_FOCUS_X)) |
57 | 409 | result->focus_x = attr.integer_val; | 409 | result->focus_x = attr.float_val; |
58 | 410 | else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_FOCUS_Y)) | 410 | else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_FOCUS_Y)) |
60 | 411 | result->focus_y = attr.integer_val; | 411 | result->focus_y = attr.float_val; |
61 | 412 | else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_TOUCHES)) | 412 | else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_TOUCHES)) |
62 | 413 | result->touches = attr.integer_val; | 413 | result->touches = attr.integer_val; |
63 | 414 | else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_ANGLE)) | 414 | else if (g_str_equal(attr.name, GEIS_GESTURE_ATTRIBUTE_ANGLE)) |
64 | 415 | 415 | ||
65 | === modified file 'plugins/unityshell/src/GeisAdapter.h' | |||
66 | --- plugins/unityshell/src/GeisAdapter.h 2011-08-29 23:36:21 +0000 | |||
67 | +++ plugins/unityshell/src/GeisAdapter.h 2012-04-04 14:40:28 +0000 | |||
68 | @@ -41,8 +41,8 @@ | |||
69 | 41 | Window window; | 41 | Window window; |
70 | 42 | int touches; | 42 | int touches; |
71 | 43 | int timestamp; | 43 | int timestamp; |
74 | 44 | int focus_x; | 44 | float focus_x; |
75 | 45 | int focus_y; | 45 | float focus_y; |
76 | 46 | int tap_length_ms; | 46 | int tap_length_ms; |
77 | 47 | float position_x; | 47 | float position_x; |
78 | 48 | float position_y; | 48 | float position_y; |
79 | @@ -59,8 +59,8 @@ | |||
80 | 59 | Window window; | 59 | Window window; |
81 | 60 | int touches; | 60 | int touches; |
82 | 61 | int timestamp; | 61 | int timestamp; |
85 | 62 | int focus_x; | 62 | float focus_x; |
86 | 63 | int focus_y; | 63 | float focus_y; |
87 | 64 | float delta_x; | 64 | float delta_x; |
88 | 65 | float delta_y; | 65 | float delta_y; |
89 | 66 | float velocity_x; | 66 | float velocity_x; |
90 | @@ -80,8 +80,8 @@ | |||
91 | 80 | Window window; | 80 | Window window; |
92 | 81 | int touches; | 81 | int touches; |
93 | 82 | int timestamp; | 82 | int timestamp; |
96 | 83 | int focus_x; | 83 | float focus_x; |
97 | 84 | int focus_y; | 84 | float focus_y; |
98 | 85 | float angle; | 85 | float angle; |
99 | 86 | float angle_delta; | 86 | float angle_delta; |
100 | 87 | float angle_velocity; | 87 | float angle_velocity; |
101 | @@ -98,8 +98,8 @@ | |||
102 | 98 | Window window; | 98 | Window window; |
103 | 99 | int touches; | 99 | int touches; |
104 | 100 | int timestamp; | 100 | int timestamp; |
107 | 101 | int focus_x; | 101 | float focus_x; |
108 | 102 | int focus_y; | 102 | float focus_y; |
109 | 103 | float radius; | 103 | float radius; |
110 | 104 | float radius_delta; | 104 | float radius_delta; |
111 | 105 | float radius_velocity; | 105 | float radius_velocity; |
112 | @@ -116,8 +116,8 @@ | |||
113 | 116 | Window window; | 116 | Window window; |
114 | 117 | int touches; | 117 | int touches; |
115 | 118 | int timestamp; | 118 | int timestamp; |
118 | 119 | int focus_x; | 119 | float focus_x; |
119 | 120 | int focus_y; | 120 | float focus_y; |
120 | 121 | float bound_x1; | 121 | float bound_x1; |
121 | 122 | float bound_y1; | 122 | float bound_y1; |
122 | 123 | float bound_x2; | 123 | float bound_x2; |
123 | 124 | 124 | ||
124 | === modified file 'plugins/unityshell/src/GestureEngine.cpp' | |||
125 | --- plugins/unityshell/src/GestureEngine.cpp 2012-03-14 06:24:18 +0000 | |||
126 | +++ plugins/unityshell/src/GestureEngine.cpp 2012-04-04 14:40:28 +0000 | |||
127 | @@ -75,44 +75,26 @@ | |||
128 | 75 | } | 75 | } |
129 | 76 | } | 76 | } |
130 | 77 | 77 | ||
133 | 78 | CompWindow* | 78 | CompWindow* GestureEngine::FindCompWindowAtPos(float fpos_x, float fpos_y) |
132 | 79 | GestureEngine::FindCompWindow(Window window) | ||
134 | 80 | { | 79 | { |
170 | 81 | CompWindow* result = _screen->findTopLevelWindow(window); | 80 | const CompWindowVector& client_list_stacking = _screen->clientList(true); |
171 | 82 | 81 | ||
172 | 83 | while (!result) | 82 | int pos_x = fpos_x; |
173 | 84 | { | 83 | int pos_y = fpos_y; |
174 | 85 | Window parent, root; | 84 | |
175 | 86 | Window* children = NULL; | 85 | for (auto iter = client_list_stacking.rbegin(), |
176 | 87 | unsigned int nchildren; | 86 | end = client_list_stacking.rend(); |
177 | 88 | Status status; | 87 | iter != end; ++iter) |
178 | 89 | 88 | { | |
179 | 90 | status = XQueryTree(_screen->dpy(), window, &root, &parent, &children, &nchildren); | 89 | CompWindow* window = *iter; |
180 | 91 | if (status == 0) | 90 | |
181 | 92 | break; | 91 | if (pos_x >= window->x() && pos_x <= (window->width() + window->x()) |
182 | 93 | 92 | && | |
183 | 94 | if (children) | 93 | pos_y >= window->y() && pos_y <= (window->height() + window->y())) |
184 | 95 | XFree(children); | 94 | return window; |
185 | 96 | 95 | } | |
186 | 97 | // parent will be zero when the window passed to this method is already the | 96 | |
187 | 98 | // root one. | 97 | return nullptr; |
153 | 99 | if (parent == root || parent == 0) | ||
154 | 100 | break; | ||
155 | 101 | |||
156 | 102 | window = parent; | ||
157 | 103 | result = _screen->findTopLevelWindow(window); | ||
158 | 104 | } | ||
159 | 105 | |||
160 | 106 | if (result) | ||
161 | 107 | { | ||
162 | 108 | if (!(result->type() & (CompWindowTypeUtilMask | | ||
163 | 109 | CompWindowTypeNormalMask | | ||
164 | 110 | CompWindowTypeDialogMask | | ||
165 | 111 | CompWindowTypeModalDialogMask))) | ||
166 | 112 | result = 0; | ||
167 | 113 | } | ||
168 | 114 | |||
169 | 115 | return result; | ||
188 | 116 | } | 98 | } |
189 | 117 | 99 | ||
190 | 118 | void | 100 | void |
191 | @@ -120,7 +102,7 @@ | |||
192 | 120 | { | 102 | { |
193 | 121 | if (data->touches == 3) | 103 | if (data->touches == 3) |
194 | 122 | { | 104 | { |
196 | 123 | _drag_window = FindCompWindow(data->window); | 105 | _drag_window = FindCompWindowAtPos(data->focus_x, data->focus_y); |
197 | 124 | 106 | ||
198 | 125 | 107 | ||
199 | 126 | if (!_drag_window) | 108 | if (!_drag_window) |
200 | @@ -222,7 +204,7 @@ | |||
201 | 222 | { | 204 | { |
202 | 223 | if (data->touches == 3 && data->window != 0) | 205 | if (data->touches == 3 && data->window != 0) |
203 | 224 | { | 206 | { |
205 | 225 | CompWindow* result = FindCompWindow(data->window); | 207 | CompWindow* result = FindCompWindowAtPos(data->focus_x, data->focus_y); |
206 | 226 | 208 | ||
207 | 227 | if (result) | 209 | if (result) |
208 | 228 | { | 210 | { |
209 | @@ -256,7 +238,7 @@ | |||
210 | 256 | { | 238 | { |
211 | 257 | if (data->touches == 3) | 239 | if (data->touches == 3) |
212 | 258 | { | 240 | { |
214 | 259 | _pinch_window = FindCompWindow(data->window); | 241 | _pinch_window = FindCompWindowAtPos(data->focus_x, data->focus_y); |
215 | 260 | 242 | ||
216 | 261 | if (!_pinch_window) | 243 | if (!_pinch_window) |
217 | 262 | return; | 244 | return; |
218 | 263 | 245 | ||
219 | === modified file 'plugins/unityshell/src/GestureEngine.h' | |||
220 | --- plugins/unityshell/src/GestureEngine.h 2011-09-28 14:31:35 +0000 | |||
221 | +++ plugins/unityshell/src/GestureEngine.h 2012-04-04 14:40:28 +0000 | |||
222 | @@ -23,7 +23,6 @@ | |||
223 | 23 | #include <core/core.h> | 23 | #include <core/core.h> |
224 | 24 | 24 | ||
225 | 25 | #include <sigc++/sigc++.h> | 25 | #include <sigc++/sigc++.h> |
226 | 26 | #include <Nux/Nux.h> | ||
227 | 27 | #include "GeisAdapter.h" | 26 | #include "GeisAdapter.h" |
228 | 28 | 27 | ||
229 | 29 | class GestureEngine : public sigc::trackable | 28 | class GestureEngine : public sigc::trackable |
230 | @@ -52,7 +51,7 @@ | |||
231 | 52 | 51 | ||
232 | 53 | void EndDrag(); | 52 | void EndDrag(); |
233 | 54 | private: | 53 | private: |
235 | 55 | CompWindow* FindCompWindow(Window window); | 54 | CompWindow* FindCompWindowAtPos(float pos_x, float pos_y); |
236 | 56 | 55 | ||
237 | 57 | CompScreen* _screen; | 56 | CompScreen* _screen; |
238 | 58 | CompWindow* _drag_window; | 57 | CompWindow* _drag_window; |
239 | 59 | 58 | ||
240 | === modified file 'tests/CMakeLists.txt' | |||
241 | --- tests/CMakeLists.txt 2012-03-31 10:47:22 +0000 | |||
242 | +++ tests/CMakeLists.txt 2012-04-04 14:40:28 +0000 | |||
243 | @@ -34,7 +34,6 @@ | |||
244 | 34 | add_definitions (${CFLAGS}) | 34 | add_definitions (${CFLAGS}) |
245 | 35 | 35 | ||
246 | 36 | set (LIBS ${TEST_UNIT_DEPS_LIBRARIES} "-lunity-core-${UNITY_API_VERSION} -lm") | 36 | set (LIBS ${TEST_UNIT_DEPS_LIBRARIES} "-lunity-core-${UNITY_API_VERSION} -lm") |
247 | 37 | link_libraries (${LIBS}) | ||
248 | 38 | 37 | ||
249 | 39 | set (LIB_PATHS ${TEST_UNIT_DEPS_LIBRARY_DIRS}) | 38 | set (LIB_PATHS ${TEST_UNIT_DEPS_LIBRARY_DIRS}) |
250 | 40 | link_directories (${CMAKE_BINARY_DIR}/UnityCore ${LIB_PATHS}) | 39 | link_directories (${CMAKE_BINARY_DIR}/UnityCore ${LIB_PATHS}) |
251 | @@ -72,6 +71,7 @@ | |||
252 | 72 | ${CMAKE_CURRENT_BINARY_DIR}/panel-marshal.c | 71 | ${CMAKE_CURRENT_BINARY_DIR}/panel-marshal.c |
253 | 73 | ${UNITY_SRC}/ubus-server.cpp | 72 | ${UNITY_SRC}/ubus-server.cpp |
254 | 74 | ) | 73 | ) |
255 | 74 | target_link_libraries (test-unit ${LIBS}) | ||
256 | 75 | add_dependencies (test-unit unity-core-${UNITY_API_VERSION}) | 75 | add_dependencies (test-unit unity-core-${UNITY_API_VERSION}) |
257 | 76 | add_subdirectory (test-input-remover) | 76 | add_subdirectory (test-input-remover) |
258 | 77 | add_subdirectory (test-minimize-window-handler) | 77 | add_subdirectory (test-minimize-window-handler) |
259 | @@ -110,6 +110,7 @@ | |||
260 | 110 | test_service_main.c | 110 | test_service_main.c |
261 | 111 | test_service_model.c | 111 | test_service_model.c |
262 | 112 | test_service_model.h) | 112 | test_service_model.h) |
263 | 113 | target_link_libraries(test-gtest-service ${LIBS}) | ||
264 | 113 | add_dependencies (test-gtest-service unity-core-${UNITY_API_VERSION} gtest) | 114 | add_dependencies (test-gtest-service unity-core-${UNITY_API_VERSION} gtest) |
265 | 114 | 115 | ||
266 | 115 | 116 | ||
267 | @@ -166,7 +167,7 @@ | |||
268 | 166 | ${CMAKE_SOURCE_DIR}/plugins/unity-mt-grab-handles/src/unity-mt-grab-handle-layout.cpp | 167 | ${CMAKE_SOURCE_DIR}/plugins/unity-mt-grab-handles/src/unity-mt-grab-handle-layout.cpp |
269 | 167 | ${CMAKE_SOURCE_DIR}/plugins/unity-mt-grab-handles/src/unity-mt-texture.cpp | 168 | ${CMAKE_SOURCE_DIR}/plugins/unity-mt-grab-handles/src/unity-mt-texture.cpp |
270 | 168 | ) | 169 | ) |
272 | 169 | target_link_libraries(test-gtest-xless gtest ${GMOCK_LIB} ${GMOCK_MAIN_LIB}) | 170 | target_link_libraries(test-gtest-xless gtest ${GMOCK_LIB} ${GMOCK_MAIN_LIB} ${LIBS}) |
273 | 170 | add_test(UnityGTestXless test-gtest-xless) | 171 | add_test(UnityGTestXless test-gtest-xless) |
274 | 171 | add_dependencies(test-gtest-xless unity-core-${UNITY_API_VERSION} gtest) | 172 | add_dependencies(test-gtest-xless unity-core-${UNITY_API_VERSION} gtest) |
275 | 172 | 173 | ||
276 | @@ -184,7 +185,7 @@ | |||
277 | 184 | test_ratings_filter.cpp | 185 | test_ratings_filter.cpp |
278 | 185 | test_results.cpp | 186 | test_results.cpp |
279 | 186 | ) | 187 | ) |
281 | 187 | target_link_libraries(test-gtest-dbus gtest) | 188 | target_link_libraries(test-gtest-dbus gtest ${LIBS}) |
282 | 188 | add_test(UnityGTestDBus test-gtest-dbus) | 189 | add_test(UnityGTestDBus test-gtest-dbus) |
283 | 189 | add_dependencies(test-gtest-dbus unity-core-${UNITY_API_VERSION} test-gtest-service gtest) | 190 | add_dependencies(test-gtest-dbus unity-core-${UNITY_API_VERSION} test-gtest-service gtest) |
284 | 190 | 191 | ||
285 | @@ -246,7 +247,7 @@ | |||
286 | 246 | ${UNITY_SRC}/UScreen.cpp | 247 | ${UNITY_SRC}/UScreen.cpp |
287 | 247 | ${UNITY_SRC}/WindowManager.cpp | 248 | ${UNITY_SRC}/WindowManager.cpp |
288 | 248 | ) | 249 | ) |
290 | 249 | target_link_libraries(test-gtest gtest) | 250 | target_link_libraries(test-gtest gtest ${LIBS}) |
291 | 250 | add_test(UnityGTest test-gtest) | 251 | add_test(UnityGTest test-gtest) |
292 | 251 | add_dependencies(test-gtest unity-core-${UNITY_API_VERSION} gtest) | 252 | add_dependencies(test-gtest unity-core-${UNITY_API_VERSION} gtest) |
293 | 252 | 253 | ||
294 | @@ -254,6 +255,8 @@ | |||
295 | 254 | GMOCK_LIB AND | 255 | GMOCK_LIB AND |
296 | 255 | GMOCK_MAIN_LIB) | 256 | GMOCK_MAIN_LIB) |
297 | 256 | 257 | ||
298 | 258 | add_subdirectory (test-gesture-engine) | ||
299 | 259 | |||
300 | 257 | # | 260 | # |
301 | 258 | # check target | 261 | # check target |
302 | 259 | # | 262 | # |
303 | @@ -263,21 +266,25 @@ | |||
304 | 263 | set (GTEST_TEST_COMMAND ./test-gtest) | 266 | set (GTEST_TEST_COMMAND ./test-gtest) |
305 | 264 | set (GTEST_TEST_COMMAND_XLESS ./test-gtest-xless) | 267 | set (GTEST_TEST_COMMAND_XLESS ./test-gtest-xless) |
306 | 265 | set (GTEST_TEST_COMMAND_DBUS dbus-test-runner --task ./test-gtest-service --task ./test-gtest-dbus) | 268 | set (GTEST_TEST_COMMAND_DBUS dbus-test-runner --task ./test-gtest-service --task ./test-gtest-dbus) |
307 | 269 | set (GTEST_TEST_COMMAND_GESTURE_ENGINE ./test-gesture-engine/test-gesture-engine) | ||
308 | 266 | 270 | ||
309 | 267 | set (TEST_COMMAND | 271 | set (TEST_COMMAND |
310 | 268 | gtester --verbose -k --g-fatal-warnings -o=${TEST_RESULT_XML} ./test-unit | 272 | gtester --verbose -k --g-fatal-warnings -o=${TEST_RESULT_XML} ./test-unit |
311 | 269 | && ${GTEST_TEST_COMMAND} | 273 | && ${GTEST_TEST_COMMAND} |
312 | 270 | && ${GTEST_TEST_COMMAND_XLESS} | 274 | && ${GTEST_TEST_COMMAND_XLESS} |
314 | 271 | && ${GTEST_TEST_COMMAND_DBUS}) | 275 | && ${GTEST_TEST_COMMAND_GESTURE_ENGINE} |
315 | 276 | && ${GTEST_TEST_COMMAND_DBUS} | ||
316 | 277 | ) | ||
317 | 272 | 278 | ||
318 | 273 | set (TEST_COMMAND_HEADLESS | 279 | set (TEST_COMMAND_HEADLESS |
319 | 274 | ${GTEST_TEST_COMMAND_XLESS} | 280 | ${GTEST_TEST_COMMAND_XLESS} |
320 | 281 | && ${GTEST_TEST_COMMAND_GESTURE_ENGINE} | ||
321 | 275 | #&& ${GTEST_TEST_COMMAND_DBUS} | 282 | #&& ${GTEST_TEST_COMMAND_DBUS} |
322 | 276 | && echo "Warning, DBus test cases are disabled!!") | 283 | && echo "Warning, DBus test cases are disabled!!") |
323 | 277 | 284 | ||
324 | 278 | if (GTEST_SRC_DIR) | 285 | if (GTEST_SRC_DIR) |
327 | 279 | add_custom_target (check COMMAND ${TEST_COMMAND} DEPENDS test-unit test-gtest test-gtest-xless test-gtest-dbus) | 286 | add_custom_target (check COMMAND ${TEST_COMMAND} DEPENDS test-unit test-gtest test-gtest-xless test-gtest-dbus test-gesture-engine) |
328 | 280 | add_custom_target (check-headless COMMAND ${TEST_COMMAND_HEADLESS} DEPENDS test-gtest-xless test-gtest-dbus) | 287 | add_custom_target (check-headless COMMAND ${TEST_COMMAND_HEADLESS} DEPENDS test-gtest-xless test-gtest-dbus test-gesture-engine) |
329 | 281 | add_custom_target (check-report COMMAND ${TEST_UNIT_COMMAND} && gtester-report ${TEST_RESULT_XML} > ${TEST_RESULT_HTML}) | 288 | add_custom_target (check-report COMMAND ${TEST_UNIT_COMMAND} && gtester-report ${TEST_RESULT_XML} > ${TEST_RESULT_HTML}) |
330 | 282 | add_custom_target (gcheck COMMAND ${DBUS_TEST_COMMAND} DEPENDS test-gtest test-gtest-xless) | 289 | add_custom_target (gcheck COMMAND ${DBUS_TEST_COMMAND} DEPENDS test-gtest test-gtest-xless) |
331 | 283 | else (GTEST_SRC_DIR) | 290 | else (GTEST_SRC_DIR) |
332 | 284 | 291 | ||
333 | === added directory 'tests/test-gesture-engine' | |||
334 | === added file 'tests/test-gesture-engine/CMakeLists.txt' | |||
335 | --- tests/test-gesture-engine/CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
336 | +++ tests/test-gesture-engine/CMakeLists.txt 2012-04-04 14:40:28 +0000 | |||
337 | @@ -0,0 +1,40 @@ | |||
338 | 1 | if (GTEST_SRC_DIR) | ||
339 | 2 | set(UNITY_SRC ${CMAKE_SOURCE_DIR}/plugins/unityshell/src) | ||
340 | 3 | |||
341 | 4 | add_custom_command(OUTPUT GestureEngine.cpp GestureEngine.h UBusMessages.h | ||
342 | 5 | COMMAND cp ${UNITY_SRC}/GestureEngine.cpp ${UNITY_SRC}/GestureEngine.h ${UNITY_SRC}/UBusMessages.h ${CMAKE_CURRENT_BINARY_DIR} | ||
343 | 6 | COMMAND sed -f ${CMAKE_CURRENT_SOURCE_DIR}/sed_script ${UNITY_SRC}/GestureEngine.cpp > ${CMAKE_CURRENT_BINARY_DIR}/GestureEngine.cpp | ||
344 | 7 | COMMAND sed -f ${CMAKE_CURRENT_SOURCE_DIR}/sed_script ${UNITY_SRC}/GestureEngine.h > ${CMAKE_CURRENT_BINARY_DIR}/GestureEngine.h | ||
345 | 8 | DEPENDS ${UNITY_SRC}/GestureEngine.cpp ${UNITY_SRC}/GestureEngine.h ${UNITY_SRC}/UBusMessages.h | ||
346 | 9 | COMMENT "Copying GestureEngine source.") | ||
347 | 10 | |||
348 | 11 | # Clean-up includes and definitions made in ../CmakeLists.txt | ||
349 | 12 | remove_definitions(${CFLAGS}) | ||
350 | 13 | set_directory_properties(PROPERTY INCLUDE_DIRECTORIES "") | ||
351 | 14 | # And make our own | ||
352 | 15 | pkg_check_modules (TEST_GESTURE_ENGINE_DEPS REQUIRED QUIET "${UNITY_PLUGIN_DEPS}") | ||
353 | 16 | set(TEST_GESTURE_ENGINE_CFLAGS | ||
354 | 17 | "-g" | ||
355 | 18 | "-I${CMAKE_CURRENT_SOURCE_DIR}" | ||
356 | 19 | "-I${CMAKE_CURRENT_BINARY_DIR}" | ||
357 | 20 | ${TEST_GESTURE_ENGINE_DEPS_CFLAGS} | ||
358 | 21 | ) | ||
359 | 22 | add_definitions(${TEST_GESTURE_ENGINE_CFLAGS}) | ||
360 | 23 | |||
361 | 24 | pkg_check_modules (COMPIZ REQUIRED QUIET compiz) | ||
362 | 25 | link_directories (${COMPIZ_LIBDIR}) | ||
363 | 26 | |||
364 | 27 | add_executable(test-gesture-engine | ||
365 | 28 | test_gesture_engine.cpp | ||
366 | 29 | X11_mock.cpp | ||
367 | 30 | GestureEngine.cpp | ||
368 | 31 | PluginAdapterMock.cpp | ||
369 | 32 | GeisAdapterMock.cpp | ||
370 | 33 | ubus-server-mock.cpp | ||
371 | 34 | ) | ||
372 | 35 | target_link_libraries(test-gesture-engine gtest ${TEST_GESTURE_ENGINE_DEPS_LIBRARIES} -lcompiz_core) | ||
373 | 36 | add_test(UnityGTestGestureEngine test-gesture-engine) | ||
374 | 37 | add_dependencies(test-gesture-engine gtest) | ||
375 | 38 | |||
376 | 39 | add_custom_target (check-gesture-engine COMMAND ./test-gesture-engine DEPENDS test-gesture-engine) | ||
377 | 40 | endif (GTEST_SRC_DIR) | ||
378 | 0 | 41 | ||
379 | === added file 'tests/test-gesture-engine/GeisAdapterMock.cpp' | |||
380 | --- tests/test-gesture-engine/GeisAdapterMock.cpp 1970-01-01 00:00:00 +0000 | |||
381 | +++ tests/test-gesture-engine/GeisAdapterMock.cpp 2012-04-04 14:40:28 +0000 | |||
382 | @@ -0,0 +1,30 @@ | |||
383 | 1 | /* | ||
384 | 2 | * Copyright 2012 Canonical Ltd. | ||
385 | 3 | * | ||
386 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
387 | 5 | * under the terms of the GNU General Public License version 3, as published | ||
388 | 6 | * by the Free Software Foundation. | ||
389 | 7 | * | ||
390 | 8 | * This program is distributed in the hope that it will be useful, but | ||
391 | 9 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
392 | 10 | * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR | ||
393 | 11 | * PURPOSE. See the GNU General Public License for more details. | ||
394 | 12 | * | ||
395 | 13 | * You should have received a copy of the GNU General Public License | ||
396 | 14 | * version 3 along with this program. If not, see | ||
397 | 15 | * <http://www.gnu.org/licenses/> | ||
398 | 16 | * | ||
399 | 17 | * Authored by: Daniel d'Andrada <daniel.dandrada@canonical.com> | ||
400 | 18 | * | ||
401 | 19 | */ | ||
402 | 20 | |||
403 | 21 | #include "GeisAdapterMock.h" | ||
404 | 22 | |||
405 | 23 | GeisAdapterMock *GeisAdapterMock::_default = 0; | ||
406 | 24 | |||
407 | 25 | GeisAdapterMock* GeisAdapterMock::Default() { | ||
408 | 26 | if (!_default) { | ||
409 | 27 | _default = new GeisAdapterMock; | ||
410 | 28 | } | ||
411 | 29 | return _default; | ||
412 | 30 | } | ||
413 | 0 | 31 | ||
414 | === added file 'tests/test-gesture-engine/GeisAdapterMock.h' | |||
415 | --- tests/test-gesture-engine/GeisAdapterMock.h 1970-01-01 00:00:00 +0000 | |||
416 | +++ tests/test-gesture-engine/GeisAdapterMock.h 2012-04-04 14:40:28 +0000 | |||
417 | @@ -0,0 +1,148 @@ | |||
418 | 1 | /* | ||
419 | 2 | * Copyright 2012 Canonical Ltd. | ||
420 | 3 | * | ||
421 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
422 | 5 | * under the terms of the GNU General Public License version 3, as published | ||
423 | 6 | * by the Free Software Foundation. | ||
424 | 7 | * | ||
425 | 8 | * This program is distributed in the hope that it will be useful, but | ||
426 | 9 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
427 | 10 | * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR | ||
428 | 11 | * PURPOSE. See the GNU General Public License for more details. | ||
429 | 12 | * | ||
430 | 13 | * You should have received a copy of the GNU General Public License | ||
431 | 14 | * version 3 along with this program. If not, see | ||
432 | 15 | * <http://www.gnu.org/licenses/> | ||
433 | 16 | * | ||
434 | 17 | * Authored by: Daniel d'Andrada <daniel.dandrada@canonical.com> | ||
435 | 18 | * | ||
436 | 19 | */ | ||
437 | 20 | |||
438 | 21 | #ifndef GEISADAPTER_MOCK_H | ||
439 | 22 | #define GEISADAPTER_MOCK_H | ||
440 | 23 | |||
441 | 24 | #include <sigc++/sigc++.h> | ||
442 | 25 | #include <X11/Xlib.h> | ||
443 | 26 | |||
444 | 27 | class GeisAdapterMock : public sigc::trackable | ||
445 | 28 | { | ||
446 | 29 | public: | ||
447 | 30 | static GeisAdapterMock* Default(); | ||
448 | 31 | |||
449 | 32 | ~GeisAdapterMock() {} | ||
450 | 33 | |||
451 | 34 | typedef struct _GeisTapData | ||
452 | 35 | { | ||
453 | 36 | int id; | ||
454 | 37 | int device_id; | ||
455 | 38 | Window window; | ||
456 | 39 | int touches; | ||
457 | 40 | int timestamp; | ||
458 | 41 | float focus_x; | ||
459 | 42 | float focus_y; | ||
460 | 43 | int tap_length_ms; | ||
461 | 44 | float position_x; | ||
462 | 45 | float position_y; | ||
463 | 46 | float bound_x1; | ||
464 | 47 | float bound_y1; | ||
465 | 48 | float bound_x2; | ||
466 | 49 | float bound_y2; | ||
467 | 50 | } GeisTapData; | ||
468 | 51 | |||
469 | 52 | typedef struct _GeisDragData | ||
470 | 53 | { | ||
471 | 54 | int id; | ||
472 | 55 | int device_id; | ||
473 | 56 | Window window; | ||
474 | 57 | int touches; | ||
475 | 58 | int timestamp; | ||
476 | 59 | float focus_x; | ||
477 | 60 | float focus_y; | ||
478 | 61 | float delta_x; | ||
479 | 62 | float delta_y; | ||
480 | 63 | float velocity_x; | ||
481 | 64 | float velocity_y; | ||
482 | 65 | float position_x; | ||
483 | 66 | float position_y; | ||
484 | 67 | float bound_x1; | ||
485 | 68 | float bound_y1; | ||
486 | 69 | float bound_x2; | ||
487 | 70 | float bound_y2; | ||
488 | 71 | } GeisDragData; | ||
489 | 72 | |||
490 | 73 | typedef struct _GeisRotateData | ||
491 | 74 | { | ||
492 | 75 | int id; | ||
493 | 76 | int device_id; | ||
494 | 77 | Window window; | ||
495 | 78 | int touches; | ||
496 | 79 | int timestamp; | ||
497 | 80 | float focus_x; | ||
498 | 81 | float focus_y; | ||
499 | 82 | float angle; | ||
500 | 83 | float angle_delta; | ||
501 | 84 | float angle_velocity; | ||
502 | 85 | float bound_x1; | ||
503 | 86 | float bound_y1; | ||
504 | 87 | float bound_x2; | ||
505 | 88 | float bound_y2; | ||
506 | 89 | } GeisRotateData; | ||
507 | 90 | |||
508 | 91 | typedef struct _GeisPinchData | ||
509 | 92 | { | ||
510 | 93 | int id; | ||
511 | 94 | int device_id; | ||
512 | 95 | Window window; | ||
513 | 96 | int touches; | ||
514 | 97 | int timestamp; | ||
515 | 98 | float focus_x; | ||
516 | 99 | float focus_y; | ||
517 | 100 | float radius; | ||
518 | 101 | float radius_delta; | ||
519 | 102 | float radius_velocity; | ||
520 | 103 | float bound_x1; | ||
521 | 104 | float bound_y1; | ||
522 | 105 | float bound_x2; | ||
523 | 106 | float bound_y2; | ||
524 | 107 | } GeisPinchData; | ||
525 | 108 | |||
526 | 109 | typedef struct _GeisTouchData | ||
527 | 110 | { | ||
528 | 111 | int id; | ||
529 | 112 | int device_id; | ||
530 | 113 | Window window; | ||
531 | 114 | int touches; | ||
532 | 115 | int timestamp; | ||
533 | 116 | float focus_x; | ||
534 | 117 | float focus_y; | ||
535 | 118 | float bound_x1; | ||
536 | 119 | float bound_y1; | ||
537 | 120 | float bound_x2; | ||
538 | 121 | float bound_y2; | ||
539 | 122 | } GeisTouchData; | ||
540 | 123 | |||
541 | 124 | sigc::signal<void, GeisTapData*> tap; | ||
542 | 125 | |||
543 | 126 | sigc::signal<void, GeisDragData*> drag_start; | ||
544 | 127 | sigc::signal<void, GeisDragData*> drag_update; | ||
545 | 128 | sigc::signal<void, GeisDragData*> drag_finish; | ||
546 | 129 | |||
547 | 130 | sigc::signal<void, GeisRotateData*> rotate_start; | ||
548 | 131 | sigc::signal<void, GeisRotateData*> rotate_update; | ||
549 | 132 | sigc::signal<void, GeisRotateData*> rotate_finish; | ||
550 | 133 | |||
551 | 134 | sigc::signal<void, GeisPinchData*> pinch_start; | ||
552 | 135 | sigc::signal<void, GeisPinchData*> pinch_update; | ||
553 | 136 | sigc::signal<void, GeisPinchData*> pinch_finish; | ||
554 | 137 | |||
555 | 138 | sigc::signal<void, GeisTouchData*> touch_start; | ||
556 | 139 | sigc::signal<void, GeisTouchData*> touch_update; | ||
557 | 140 | sigc::signal<void, GeisTouchData*> touch_finish; | ||
558 | 141 | |||
559 | 142 | private: | ||
560 | 143 | GeisAdapterMock() {} | ||
561 | 144 | |||
562 | 145 | static GeisAdapterMock* _default; | ||
563 | 146 | |||
564 | 147 | }; | ||
565 | 148 | #endif | ||
566 | 0 | 149 | ||
567 | === added file 'tests/test-gesture-engine/PluginAdapterMock.cpp' | |||
568 | --- tests/test-gesture-engine/PluginAdapterMock.cpp 1970-01-01 00:00:00 +0000 | |||
569 | +++ tests/test-gesture-engine/PluginAdapterMock.cpp 2012-04-04 14:40:28 +0000 | |||
570 | @@ -0,0 +1,33 @@ | |||
571 | 1 | /* | ||
572 | 2 | * Copyright 2012 Canonical Ltd. | ||
573 | 3 | * | ||
574 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
575 | 5 | * under the terms of the GNU General Public License version 3, as published | ||
576 | 6 | * by the Free Software Foundation. | ||
577 | 7 | * | ||
578 | 8 | * This program is distributed in the hope that it will be useful, but | ||
579 | 9 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
580 | 10 | * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR | ||
581 | 11 | * PURPOSE. See the GNU General Public License for more details. | ||
582 | 12 | * | ||
583 | 13 | * You should have received a copy of the GNU General Public License | ||
584 | 14 | * version 3 along with this program. If not, see | ||
585 | 15 | * <http://www.gnu.org/licenses/> | ||
586 | 16 | * | ||
587 | 17 | * Authored by: Daniel d'Andrada <daniel.dandrada@canonical.com> | ||
588 | 18 | * | ||
589 | 19 | */ | ||
590 | 20 | |||
591 | 21 | #include "PluginAdapterMock.h" | ||
592 | 22 | |||
593 | 23 | PluginAdapterMock *PluginAdapterMock::_default = 0; | ||
594 | 24 | |||
595 | 25 | PluginAdapterMock *PluginAdapterMock::Default() { | ||
596 | 26 | if (!_default) { | ||
597 | 27 | _default = new PluginAdapterMock; | ||
598 | 28 | } | ||
599 | 29 | return _default; | ||
600 | 30 | } | ||
601 | 31 | |||
602 | 32 | void PluginAdapterMock::ShowGrabHandles(CompWindowMock* window, bool use_timer) { | ||
603 | 33 | } | ||
604 | 0 | 34 | ||
605 | === added file 'tests/test-gesture-engine/PluginAdapterMock.h' | |||
606 | --- tests/test-gesture-engine/PluginAdapterMock.h 1970-01-01 00:00:00 +0000 | |||
607 | +++ tests/test-gesture-engine/PluginAdapterMock.h 2012-04-04 14:40:28 +0000 | |||
608 | @@ -0,0 +1,37 @@ | |||
609 | 1 | /* | ||
610 | 2 | * Copyright 2012 Canonical Ltd. | ||
611 | 3 | * | ||
612 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
613 | 5 | * under the terms of the GNU General Public License version 3, as published | ||
614 | 6 | * by the Free Software Foundation. | ||
615 | 7 | * | ||
616 | 8 | * This program is distributed in the hope that it will be useful, but | ||
617 | 9 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
618 | 10 | * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR | ||
619 | 11 | * PURPOSE. See the GNU General Public License for more details. | ||
620 | 12 | * | ||
621 | 13 | * You should have received a copy of the GNU General Public License | ||
622 | 14 | * version 3 along with this program. If not, see | ||
623 | 15 | * <http://www.gnu.org/licenses/> | ||
624 | 16 | * | ||
625 | 17 | * Authored by: Daniel d'Andrada <daniel.dandrada@canonical.com> | ||
626 | 18 | * | ||
627 | 19 | */ | ||
628 | 20 | |||
629 | 21 | #ifndef PLUGINADAPTER_MOCK_H | ||
630 | 22 | #define PLUGINADAPTER_MOCK_H | ||
631 | 23 | |||
632 | 24 | #include <compiz_mock/core/core.h> | ||
633 | 25 | |||
634 | 26 | class PluginAdapterMock { | ||
635 | 27 | public: | ||
636 | 28 | static PluginAdapterMock *Default(); | ||
637 | 29 | |||
638 | 30 | void ShowGrabHandles(CompWindowMock* window, bool use_timer); | ||
639 | 31 | |||
640 | 32 | private: | ||
641 | 33 | PluginAdapterMock() {} | ||
642 | 34 | static PluginAdapterMock* _default; | ||
643 | 35 | }; | ||
644 | 36 | |||
645 | 37 | #endif | ||
646 | 0 | 38 | ||
647 | === added file 'tests/test-gesture-engine/X11_mock.cpp' | |||
648 | --- tests/test-gesture-engine/X11_mock.cpp 1970-01-01 00:00:00 +0000 | |||
649 | +++ tests/test-gesture-engine/X11_mock.cpp 2012-04-04 14:40:28 +0000 | |||
650 | @@ -0,0 +1,40 @@ | |||
651 | 1 | /* | ||
652 | 2 | * Copyright 2012 Canonical Ltd. | ||
653 | 3 | * | ||
654 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
655 | 5 | * under the terms of the GNU General Public License version 3, as published | ||
656 | 6 | * by the Free Software Foundation. | ||
657 | 7 | * | ||
658 | 8 | * This program is distributed in the hope that it will be useful, but | ||
659 | 9 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
660 | 10 | * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR | ||
661 | 11 | * PURPOSE. See the GNU General Public License for more details. | ||
662 | 12 | * | ||
663 | 13 | * You should have received a copy of the GNU General Public License | ||
664 | 14 | * version 3 along with this program. If not, see | ||
665 | 15 | * <http://www.gnu.org/licenses/> | ||
666 | 16 | * | ||
667 | 17 | * Authored by: Daniel d'Andrada <daniel.dandrada@canonical.com> | ||
668 | 18 | * | ||
669 | 19 | */ | ||
670 | 20 | |||
671 | 21 | #include <X11/Xlib.h> | ||
672 | 22 | |||
673 | 23 | Cursor XCreateFontCursorMock(Display * /*display*/, unsigned int /*shape*/) { | ||
674 | 24 | return 1; | ||
675 | 25 | } | ||
676 | 26 | |||
677 | 27 | int XFreeCursorMock(Display * /*display*/, Cursor /*cursor*/) { | ||
678 | 28 | return 1; | ||
679 | 29 | } | ||
680 | 30 | |||
681 | 31 | int XSyncMock(Display *display, Bool discard) { | ||
682 | 32 | return 1; | ||
683 | 33 | } | ||
684 | 34 | |||
685 | 35 | int XWarpPointerMock(Display *display, Window src_w, Window dest_w, | ||
686 | 36 | int src_x, int src_y, | ||
687 | 37 | unsigned int src_width, unsigned int src_height, | ||
688 | 38 | int dest_x, int dest_y) { | ||
689 | 39 | return 1; | ||
690 | 40 | } | ||
691 | 0 | 41 | ||
692 | === added file 'tests/test-gesture-engine/X11_mock.h' | |||
693 | --- tests/test-gesture-engine/X11_mock.h 1970-01-01 00:00:00 +0000 | |||
694 | +++ tests/test-gesture-engine/X11_mock.h 2012-04-04 14:40:28 +0000 | |||
695 | @@ -0,0 +1,37 @@ | |||
696 | 1 | /* | ||
697 | 2 | * Copyright 2012 Canonical Ltd. | ||
698 | 3 | * | ||
699 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
700 | 5 | * under the terms of the GNU General Public License version 3, as published | ||
701 | 6 | * by the Free Software Foundation. | ||
702 | 7 | * | ||
703 | 8 | * This program is distributed in the hope that it will be useful, but | ||
704 | 9 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
705 | 10 | * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR | ||
706 | 11 | * PURPOSE. See the GNU General Public License for more details. | ||
707 | 12 | * | ||
708 | 13 | * You should have received a copy of the GNU General Public License | ||
709 | 14 | * version 3 along with this program. If not, see | ||
710 | 15 | * <http://www.gnu.org/licenses/> | ||
711 | 16 | * | ||
712 | 17 | * Authored by: Daniel d'Andrada <daniel.dandrada@canonical.com> | ||
713 | 18 | * | ||
714 | 19 | */ | ||
715 | 20 | |||
716 | 21 | #ifndef X11_MOCK_H | ||
717 | 22 | #define X11_MOCK_H | ||
718 | 23 | |||
719 | 24 | #include <X11/Xlib.h> | ||
720 | 25 | |||
721 | 26 | Cursor XCreateFontCursorMock(Display *display, unsigned int shape); | ||
722 | 27 | |||
723 | 28 | int XFreeCursorMock(Display *display, Cursor cursor); | ||
724 | 29 | |||
725 | 30 | int XSyncMock(Display *display, Bool discard); | ||
726 | 31 | |||
727 | 32 | int XWarpPointerMock(Display *display, Window src_w, Window dest_w, | ||
728 | 33 | int src_x, int src_y, | ||
729 | 34 | unsigned int src_width, unsigned int src_height, | ||
730 | 35 | int dest_x, int dest_y); | ||
731 | 36 | |||
732 | 37 | #endif // X11_MOCK_H | ||
733 | 0 | 38 | ||
734 | === added directory 'tests/test-gesture-engine/compiz_mock' | |||
735 | === added directory 'tests/test-gesture-engine/compiz_mock/core' | |||
736 | === added file 'tests/test-gesture-engine/compiz_mock/core/core.h' | |||
737 | --- tests/test-gesture-engine/compiz_mock/core/core.h 1970-01-01 00:00:00 +0000 | |||
738 | +++ tests/test-gesture-engine/compiz_mock/core/core.h 2012-04-04 14:40:28 +0000 | |||
739 | @@ -0,0 +1,29 @@ | |||
740 | 1 | /* | ||
741 | 2 | * Copyright 2012 Canonical Ltd. | ||
742 | 3 | * | ||
743 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
744 | 5 | * under the terms of the GNU General Public License version 3, as published | ||
745 | 6 | * by the Free Software Foundation. | ||
746 | 7 | * | ||
747 | 8 | * This program is distributed in the hope that it will be useful, but | ||
748 | 9 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
749 | 10 | * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR | ||
750 | 11 | * PURPOSE. See the GNU General Public License for more details. | ||
751 | 12 | * | ||
752 | 13 | * You should have received a copy of the GNU General Public License | ||
753 | 14 | * version 3 along with this program. If not, see | ||
754 | 15 | * <http://www.gnu.org/licenses/> | ||
755 | 16 | * | ||
756 | 17 | * Authored by: Daniel d'Andrada <daniel.dandrada@canonical.com> | ||
757 | 18 | * | ||
758 | 19 | */ | ||
759 | 20 | |||
760 | 21 | #ifndef COMPIZ_CORE_MOCK_H | ||
761 | 22 | #define COMPIZ_CORE_MOCK_H | ||
762 | 23 | |||
763 | 24 | #include <X11_mock.h> | ||
764 | 25 | |||
765 | 26 | #include <compiz_mock/core/window.h> | ||
766 | 27 | #include <compiz_mock/core/screen.h> | ||
767 | 28 | |||
768 | 29 | #endif | ||
769 | 0 | 30 | ||
770 | === added file 'tests/test-gesture-engine/compiz_mock/core/screen.h' | |||
771 | --- tests/test-gesture-engine/compiz_mock/core/screen.h 1970-01-01 00:00:00 +0000 | |||
772 | +++ tests/test-gesture-engine/compiz_mock/core/screen.h 2012-04-04 14:40:28 +0000 | |||
773 | @@ -0,0 +1,68 @@ | |||
774 | 1 | /* | ||
775 | 2 | * Copyright 2012 Canonical Ltd. | ||
776 | 3 | * | ||
777 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
778 | 5 | * under the terms of the GNU General Public License version 3, as published | ||
779 | 6 | * by the Free Software Foundation. | ||
780 | 7 | * | ||
781 | 8 | * This program is distributed in the hope that it will be useful, but | ||
782 | 9 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
783 | 10 | * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR | ||
784 | 11 | * PURPOSE. See the GNU General Public License for more details. | ||
785 | 12 | * | ||
786 | 13 | * You should have received a copy of the GNU General Public License | ||
787 | 14 | * version 3 along with this program. If not, see | ||
788 | 15 | * <http://www.gnu.org/licenses/> | ||
789 | 16 | * | ||
790 | 17 | * Authored by: Daniel d'Andrada <daniel.dandrada@canonical.com> | ||
791 | 18 | * | ||
792 | 19 | */ | ||
793 | 20 | |||
794 | 21 | #ifndef COMPIZ_SCREEN_MOCK_H | ||
795 | 22 | #define COMPIZ_SCREEN_MOCK_H | ||
796 | 23 | |||
797 | 24 | #include <X11/Xlib.h> | ||
798 | 25 | #include <vector> | ||
799 | 26 | |||
800 | 27 | // The real CompScreen | ||
801 | 28 | #include <core/screen.h> | ||
802 | 29 | |||
803 | 30 | typedef std::vector<CompWindowMock*> CompWindowMockVector; | ||
804 | 31 | |||
805 | 32 | class CompScreenMock { | ||
806 | 33 | public: | ||
807 | 34 | typedef int GrabHandle; | ||
808 | 35 | |||
809 | 36 | int width() const {return _width;} | ||
810 | 37 | int height() const {return _height;} | ||
811 | 38 | |||
812 | 39 | Display *dpy() {return _dpy;} | ||
813 | 40 | |||
814 | 41 | const CompWindowMockVector & clientList(bool stackingOrder = true) { | ||
815 | 42 | if (stackingOrder) | ||
816 | 43 | return _client_list_stacking; | ||
817 | 44 | else | ||
818 | 45 | return _client_list; | ||
819 | 46 | } | ||
820 | 47 | |||
821 | 48 | Window root() {return _root;} | ||
822 | 49 | |||
823 | 50 | GrabHandle pushGrab(Cursor cursor, const char *name) {return 0;} | ||
824 | 51 | void removeGrab(GrabHandle handle, CompPoint *restorePointer) {} | ||
825 | 52 | |||
826 | 53 | Cursor invisibleCursor() {return 1;} | ||
827 | 54 | |||
828 | 55 | int _width; | ||
829 | 56 | int _height; | ||
830 | 57 | Display *_dpy; | ||
831 | 58 | CompWindowMockVector _client_list; | ||
832 | 59 | CompWindowMockVector _client_list_stacking; | ||
833 | 60 | Window _root; | ||
834 | 61 | }; | ||
835 | 62 | |||
836 | 63 | extern CompScreenMock *screen_mock; | ||
837 | 64 | extern int pointerX_mock; | ||
838 | 65 | extern int pointerY_mock; | ||
839 | 66 | |||
840 | 67 | #endif | ||
841 | 68 | |||
842 | 0 | 69 | ||
843 | === added file 'tests/test-gesture-engine/compiz_mock/core/window.h' | |||
844 | --- tests/test-gesture-engine/compiz_mock/core/window.h 1970-01-01 00:00:00 +0000 | |||
845 | +++ tests/test-gesture-engine/compiz_mock/core/window.h 2012-04-04 14:40:28 +0000 | |||
846 | @@ -0,0 +1,66 @@ | |||
847 | 1 | /* | ||
848 | 2 | * Copyright 2012 Canonical Ltd. | ||
849 | 3 | * | ||
850 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
851 | 5 | * under the terms of the GNU General Public License version 3, as published | ||
852 | 6 | * by the Free Software Foundation. | ||
853 | 7 | * | ||
854 | 8 | * This program is distributed in the hope that it will be useful, but | ||
855 | 9 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
856 | 10 | * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR | ||
857 | 11 | * PURPOSE. See the GNU General Public License for more details. | ||
858 | 12 | * | ||
859 | 13 | * You should have received a copy of the GNU General Public License | ||
860 | 14 | * version 3 along with this program. If not, see | ||
861 | 15 | * <http://www.gnu.org/licenses/> | ||
862 | 16 | * | ||
863 | 17 | * Authored by: Daniel d'Andrada <daniel.dandrada@canonical.com> | ||
864 | 18 | * | ||
865 | 19 | */ | ||
866 | 20 | |||
867 | 21 | #ifndef COMPIZ_WINDOW_MOCK_H | ||
868 | 22 | #define COMPIZ_WINDOW_MOCK_H | ||
869 | 23 | |||
870 | 24 | /* The real CompWindow */ | ||
871 | 25 | #include <core/window.h> | ||
872 | 26 | |||
873 | 27 | class CompWindowMock { | ||
874 | 28 | public: | ||
875 | 29 | CompWindowMock() : _moved(false) {} | ||
876 | 30 | |||
877 | 31 | int x() const {return _geometry.x();} | ||
878 | 32 | int y() const {return _geometry.y();} | ||
879 | 33 | int width() const {return _geometry.width() + (_geometry.border()*2);} | ||
880 | 34 | int height() const {return _geometry.height() + (_geometry.border()*2);} | ||
881 | 35 | |||
882 | 36 | void move(int dx, int dy, bool immediate = true) { | ||
883 | 37 | _moved = true; | ||
884 | 38 | _movement_x = dx; | ||
885 | 39 | _movement_y = dy; | ||
886 | 40 | } | ||
887 | 41 | |||
888 | 42 | unsigned int actions () {return _actions;} | ||
889 | 43 | |||
890 | 44 | void maximize(int state) {} | ||
891 | 45 | |||
892 | 46 | /* OBS: I wonder why it returns a reference */ | ||
893 | 47 | unsigned int &state() {return _state;} | ||
894 | 48 | |||
895 | 49 | void grabNotify(int x, int y, unsigned int state, unsigned int mask) {} | ||
896 | 50 | void ungrabNotify() {} | ||
897 | 51 | |||
898 | 52 | void syncPosition() {} | ||
899 | 53 | |||
900 | 54 | compiz::window::Geometry &serverGeometry() {return _serverGeometry;} | ||
901 | 55 | |||
902 | 56 | unsigned int _actions; | ||
903 | 57 | unsigned int _state; | ||
904 | 58 | compiz::window::Geometry _serverGeometry; | ||
905 | 59 | compiz::window::Geometry _geometry; | ||
906 | 60 | |||
907 | 61 | bool _moved; | ||
908 | 62 | int _movement_x; | ||
909 | 63 | int _movement_y; | ||
910 | 64 | }; | ||
911 | 65 | |||
912 | 66 | #endif | ||
913 | 0 | 67 | ||
914 | === added file 'tests/test-gesture-engine/sed_script' | |||
915 | --- tests/test-gesture-engine/sed_script 1970-01-01 00:00:00 +0000 | |||
916 | +++ tests/test-gesture-engine/sed_script 2012-04-04 14:40:28 +0000 | |||
917 | @@ -0,0 +1,14 @@ | |||
918 | 1 | s|<core/core.h>|<compiz_mock/core/core.h>| | ||
919 | 2 | s|\<CompScreen\>|CompScreenMock|g | ||
920 | 3 | s|\<CompWindow\>|CompWindowMock|g | ||
921 | 4 | s|\<CompWindowVector\>|CompWindowMockVector|g | ||
922 | 5 | s|\<screen\>|screen_mock|g | ||
923 | 6 | s|\<pointerX\>|pointerX_mock|g | ||
924 | 7 | s|\<pointerY\>|pointerY_mock|g | ||
925 | 8 | s|\<XSync\>|XSyncMock|g | ||
926 | 9 | s|\<XWarpPointer\>|XWarpPointerMock|g | ||
927 | 10 | s|\<XFreeCursor\>|XFreeCursorMock|g | ||
928 | 11 | s|\<XCreateFontCursor\>|XCreateFontCursorMock|g | ||
929 | 12 | s|\<GeisAdapter\>|GeisAdapterMock|g | ||
930 | 13 | s|\<PluginAdapter\>|PluginAdapterMock|g | ||
931 | 14 | s|\<ubus-server.h\>|ubus-server-mock.h|g | ||
932 | 0 | 15 | ||
933 | === added file 'tests/test-gesture-engine/test_gesture_engine.cpp' | |||
934 | --- tests/test-gesture-engine/test_gesture_engine.cpp 1970-01-01 00:00:00 +0000 | |||
935 | +++ tests/test-gesture-engine/test_gesture_engine.cpp 2012-04-04 14:40:28 +0000 | |||
936 | @@ -0,0 +1,165 @@ | |||
937 | 1 | /* | ||
938 | 2 | * Copyright 2012 Canonical Ltd. | ||
939 | 3 | * | ||
940 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
941 | 5 | * under the terms of the GNU General Public License version 3, as published | ||
942 | 6 | * by the Free Software Foundation. | ||
943 | 7 | * | ||
944 | 8 | * This program is distributed in the hope that it will be useful, but | ||
945 | 9 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
946 | 10 | * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR | ||
947 | 11 | * PURPOSE. See the GNU General Public License for more details. | ||
948 | 12 | * | ||
949 | 13 | * You should have received a copy of the GNU General Public License | ||
950 | 14 | * version 3 along with this program. If not, see | ||
951 | 15 | * <http://www.gnu.org/licenses/> | ||
952 | 16 | * | ||
953 | 17 | * Authored by: Daniel d'Andrada <daniel.dandrada@canonical.com> | ||
954 | 18 | * | ||
955 | 19 | */ | ||
956 | 20 | |||
957 | 21 | #include <gtest/gtest.h> | ||
958 | 22 | #include <compiz_mock/core/core.h> | ||
959 | 23 | #include "GestureEngine.h" | ||
960 | 24 | |||
961 | 25 | CompScreenMock concrete_screen_mock; | ||
962 | 26 | CompScreenMock *screen_mock = &concrete_screen_mock; | ||
963 | 27 | int pointerX_mock = 0; | ||
964 | 28 | int pointerY_mock = 0; | ||
965 | 29 | |||
966 | 30 | class GestureEngineTest : public ::testing::Test { | ||
967 | 31 | protected: | ||
968 | 32 | virtual void SetUp() { | ||
969 | 33 | screen_mock->_width = 1280; | ||
970 | 34 | screen_mock->_height = 1024; | ||
971 | 35 | |||
972 | 36 | GenerateWindows(); | ||
973 | 37 | } | ||
974 | 38 | |||
975 | 39 | private: | ||
976 | 40 | void GenerateWindows() { | ||
977 | 41 | /* remove windows from previous test */ | ||
978 | 42 | for (auto window : screen_mock->_client_list_stacking) { | ||
979 | 43 | delete window; | ||
980 | 44 | } | ||
981 | 45 | screen_mock->_client_list_stacking.clear(); | ||
982 | 46 | |||
983 | 47 | /* and generate new ones */ | ||
984 | 48 | CompWindowMock *window; | ||
985 | 49 | |||
986 | 50 | /* the root window */ | ||
987 | 51 | window = new CompWindowMock; | ||
988 | 52 | /* x, y, width, height, border */ | ||
989 | 53 | window->_geometry.set(0, 0, screen_mock->width(), screen_mock->height(), 0); | ||
990 | 54 | window->_serverGeometry = window->_geometry; | ||
991 | 55 | window->_actions = 0; | ||
992 | 56 | window->_state = 0; | ||
993 | 57 | screen_mock->_client_list_stacking.push_back(window); | ||
994 | 58 | |||
995 | 59 | /* middle window */ | ||
996 | 60 | window = new CompWindowMock; | ||
997 | 61 | window->_geometry.set(10, 10, 400, 400, 0); | ||
998 | 62 | window->_serverGeometry = window->_geometry; | ||
999 | 63 | window->_actions = CompWindowActionMoveMask; | ||
1000 | 64 | window->_state = 0; | ||
1001 | 65 | screen_mock->_client_list_stacking.push_back(window); | ||
1002 | 66 | |||
1003 | 67 | /* top-level window */ | ||
1004 | 68 | window = new CompWindowMock; | ||
1005 | 69 | window->_geometry.set(500, 500, 410, 410, 0); | ||
1006 | 70 | window->_serverGeometry = window->_geometry; | ||
1007 | 71 | window->_actions = CompWindowActionMoveMask; | ||
1008 | 72 | window->_state = 0; | ||
1009 | 73 | screen_mock->_client_list_stacking.push_back(window); | ||
1010 | 74 | |||
1011 | 75 | screen_mock->_client_list = screen_mock->_client_list_stacking; | ||
1012 | 76 | std::reverse(screen_mock->_client_list.begin(), | ||
1013 | 77 | screen_mock->_client_list.end()); | ||
1014 | 78 | } | ||
1015 | 79 | }; | ||
1016 | 80 | |||
1017 | 81 | TEST_F(GestureEngineTest, ThreeFingersDragMovesWindow) | ||
1018 | 82 | { | ||
1019 | 83 | GestureEngine gestureEngine(screen_mock); | ||
1020 | 84 | CompWindowMock *middle_window = screen_mock->_client_list_stacking[1]; | ||
1021 | 85 | |||
1022 | 86 | GeisAdapterMock::GeisTouchData touch_data; | ||
1023 | 87 | touch_data.id = 1; | ||
1024 | 88 | touch_data.touches = 3; | ||
1025 | 89 | touch_data.window = 123; | ||
1026 | 90 | touch_data.focus_x = 100; /* hits the middle window */ | ||
1027 | 91 | touch_data.focus_y = 100; | ||
1028 | 92 | gestureEngine.OnTouchStart(&touch_data); | ||
1029 | 93 | |||
1030 | 94 | GeisAdapterMock::GeisDragData drag_data; | ||
1031 | 95 | drag_data.id = 1; | ||
1032 | 96 | drag_data.touches = 3; | ||
1033 | 97 | drag_data.window = 123; | ||
1034 | 98 | drag_data.focus_x = 100; /* hits the middle window */ | ||
1035 | 99 | drag_data.focus_y = 100; | ||
1036 | 100 | gestureEngine.OnDragStart(&drag_data); | ||
1037 | 101 | |||
1038 | 102 | ASSERT_FALSE(middle_window->_moved); | ||
1039 | 103 | |||
1040 | 104 | touch_data.focus_x += 10; | ||
1041 | 105 | touch_data.focus_y += 20; | ||
1042 | 106 | gestureEngine.OnTouchUpdate(&touch_data); | ||
1043 | 107 | |||
1044 | 108 | drag_data.delta_x = 10; | ||
1045 | 109 | drag_data.delta_y = 20; | ||
1046 | 110 | drag_data.focus_x += drag_data.delta_x; | ||
1047 | 111 | drag_data.focus_y += drag_data.delta_x; | ||
1048 | 112 | gestureEngine.OnDragUpdate(&drag_data); | ||
1049 | 113 | |||
1050 | 114 | ASSERT_TRUE(middle_window->_moved); | ||
1051 | 115 | ASSERT_EQ(drag_data.delta_x, middle_window->_movement_x); | ||
1052 | 116 | ASSERT_EQ(drag_data.delta_y, middle_window->_movement_y); | ||
1053 | 117 | } | ||
1054 | 118 | |||
1055 | 119 | TEST_F(GestureEngineTest, ThreeFingersDragDoesntMoveStaticWindow) | ||
1056 | 120 | { | ||
1057 | 121 | GestureEngine gestureEngine(screen_mock); | ||
1058 | 122 | CompWindowMock *middle_window = screen_mock->_client_list_stacking[1]; | ||
1059 | 123 | |||
1060 | 124 | /* can't be moved */ | ||
1061 | 125 | middle_window->_actions = 0; | ||
1062 | 126 | |||
1063 | 127 | GeisAdapterMock::GeisTouchData touch_data; | ||
1064 | 128 | touch_data.id = 1; | ||
1065 | 129 | touch_data.touches = 3; | ||
1066 | 130 | touch_data.window = 123; | ||
1067 | 131 | touch_data.focus_x = 100; /* hits the middle window */ | ||
1068 | 132 | touch_data.focus_y = 100; | ||
1069 | 133 | gestureEngine.OnTouchStart(&touch_data); | ||
1070 | 134 | |||
1071 | 135 | GeisAdapterMock::GeisDragData drag_data; | ||
1072 | 136 | drag_data.id = 1; | ||
1073 | 137 | drag_data.touches = 3; | ||
1074 | 138 | drag_data.window = 123; | ||
1075 | 139 | drag_data.focus_x = 100; /* hits the middle window */ | ||
1076 | 140 | drag_data.focus_y = 100; | ||
1077 | 141 | gestureEngine.OnDragStart(&drag_data); | ||
1078 | 142 | |||
1079 | 143 | ASSERT_FALSE(middle_window->_moved); | ||
1080 | 144 | |||
1081 | 145 | touch_data.focus_x += 10; | ||
1082 | 146 | touch_data.focus_y += 20; | ||
1083 | 147 | gestureEngine.OnTouchUpdate(&touch_data); | ||
1084 | 148 | |||
1085 | 149 | drag_data.delta_x = 10; | ||
1086 | 150 | drag_data.delta_y = 20; | ||
1087 | 151 | drag_data.focus_x += drag_data.delta_x; | ||
1088 | 152 | drag_data.focus_y += drag_data.delta_x; | ||
1089 | 153 | gestureEngine.OnDragUpdate(&drag_data); | ||
1090 | 154 | |||
1091 | 155 | ASSERT_FALSE(middle_window->_moved); | ||
1092 | 156 | } | ||
1093 | 157 | |||
1094 | 158 | int main(int argc, char** argv) | ||
1095 | 159 | { | ||
1096 | 160 | ::testing::InitGoogleTest(&argc, argv); | ||
1097 | 161 | |||
1098 | 162 | int ret = RUN_ALL_TESTS(); | ||
1099 | 163 | |||
1100 | 164 | return ret; | ||
1101 | 165 | } | ||
1102 | 0 | 166 | ||
1103 | === added file 'tests/test-gesture-engine/ubus-server-mock.cpp' | |||
1104 | --- tests/test-gesture-engine/ubus-server-mock.cpp 1970-01-01 00:00:00 +0000 | |||
1105 | +++ tests/test-gesture-engine/ubus-server-mock.cpp 2012-04-04 14:40:28 +0000 | |||
1106 | @@ -0,0 +1,32 @@ | |||
1107 | 1 | /* | ||
1108 | 2 | * Copyright 2012 Canonical Ltd. | ||
1109 | 3 | * | ||
1110 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
1111 | 5 | * under the terms of the GNU General Public License version 3, as published | ||
1112 | 6 | * by the Free Software Foundation. | ||
1113 | 7 | * | ||
1114 | 8 | * This program is distributed in the hope that it will be useful, but | ||
1115 | 9 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
1116 | 10 | * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR | ||
1117 | 11 | * PURPOSE. See the GNU General Public License for more details. | ||
1118 | 12 | * | ||
1119 | 13 | * You should have received a copy of the GNU General Public License | ||
1120 | 14 | * version 3 along with this program. If not, see | ||
1121 | 15 | * <http://www.gnu.org/licenses/> | ||
1122 | 16 | * | ||
1123 | 17 | * Authored by: Daniel d'Andrada <daniel.dandrada@canonical.com> | ||
1124 | 18 | * | ||
1125 | 19 | */ | ||
1126 | 20 | |||
1127 | 21 | #include <ubus-server-mock.h> | ||
1128 | 22 | |||
1129 | 23 | UBusServer default_server; | ||
1130 | 24 | |||
1131 | 25 | UBusServer* ubus_server_get_default() { | ||
1132 | 26 | return &default_server; | ||
1133 | 27 | } | ||
1134 | 28 | |||
1135 | 29 | void ubus_server_send_message(UBusServer* server, | ||
1136 | 30 | const gchar* message, | ||
1137 | 31 | GVariant* data) { | ||
1138 | 32 | } | ||
1139 | 0 | 33 | ||
1140 | === added file 'tests/test-gesture-engine/ubus-server-mock.h' | |||
1141 | --- tests/test-gesture-engine/ubus-server-mock.h 1970-01-01 00:00:00 +0000 | |||
1142 | +++ tests/test-gesture-engine/ubus-server-mock.h 2012-04-04 14:40:28 +0000 | |||
1143 | @@ -0,0 +1,35 @@ | |||
1144 | 1 | /* | ||
1145 | 2 | * Copyright 2012 Canonical Ltd. | ||
1146 | 3 | * | ||
1147 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
1148 | 5 | * under the terms of the GNU General Public License version 3, as published | ||
1149 | 6 | * by the Free Software Foundation. | ||
1150 | 7 | * | ||
1151 | 8 | * This program is distributed in the hope that it will be useful, but | ||
1152 | 9 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
1153 | 10 | * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR | ||
1154 | 11 | * PURPOSE. See the GNU General Public License for more details. | ||
1155 | 12 | * | ||
1156 | 13 | * You should have received a copy of the GNU General Public License | ||
1157 | 14 | * version 3 along with this program. If not, see | ||
1158 | 15 | * <http://www.gnu.org/licenses/> | ||
1159 | 16 | * | ||
1160 | 17 | * Authored by: Daniel d'Andrada <daniel.dandrada@canonical.com> | ||
1161 | 18 | * | ||
1162 | 19 | */ | ||
1163 | 20 | |||
1164 | 21 | #ifndef UBUS_SERVER_MOCK_H | ||
1165 | 22 | #define UBUS_SERVER_MOCK_H | ||
1166 | 23 | |||
1167 | 24 | #include <glib-object.h> | ||
1168 | 25 | #include <glib.h> | ||
1169 | 26 | |||
1170 | 27 | class UBusServer { | ||
1171 | 28 | }; | ||
1172 | 29 | |||
1173 | 30 | UBusServer* ubus_server_get_default(); | ||
1174 | 31 | |||
1175 | 32 | void ubus_server_send_message(UBusServer* server, | ||
1176 | 33 | const gchar* message, | ||
1177 | 34 | GVariant* data); | ||
1178 | 35 | #endif // UBUS_SERVER_MOCK_H |
Please keep the variable type and variable name separate: list_stacking list_stacking list_stacking
const CompWindowVector &client_
should be
CompWindowVector const& client_
(or
const CompWindowVector& client_
- but my preference is for the first)
> if (client_ list_stacking. size() == 0)
can just be:
if (client_ list_stacking. empty() )
> int pos_x = (int) fpos_x;
Please don't use C style casts. It isn't needed here (mostly
certain about that).
The do/while loop misses the first element of the vector if there
is more than one element.
A traditional for loop is more idiomatic and understandable.
Also, can remove the window and result temporaries from outside the loop.
And... if using the iterators, you don't need the empty check first
as the initial check makes sure of that too.
for (auto iter = client_ list_stacking. rbegin( ), list_stacking. rend();
end = client_
iter != end; ++iter)
{
CompWindow* window = *iter;
if (pos_x >= window->x() && pos_x <= (window->width() + window->x())
&&
pos_y >= window->y() && pos_y <= (window->height() + window->y()))
return window;
}
return nullptr;