Merge lp:~dandrader/unity/lp940612 into lp:unity

Proposed by Daniel d'Andrada
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
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.

To post a comment you must log in.
Revision history for this message
Tim Penhey (thumper) wrote : Posted in a previous version of this proposal

Please keep the variable type and variable name separate:
  const CompWindowVector &client_list_stacking
should be
  CompWindowVector const& client_list_stacking
(or
  const CompWindowVector& client_list_stacking
   - 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(),
          end = client_list_stacking.rend();
     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;

review: Needs Fixing
Revision history for this message
Daniel d'Andrada (dandrader) wrote :

Updated. The loop sure looks better now.

Revision history for this message
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_list_stacking.empty())
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?

review: Needs Fixing
Revision history for this message
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_list_stacking.empty())
> 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)

Revision history for this message
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.

review: Needs Fixing
Revision history for this message
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.

Revision history for this message
Tim Penhey (thumper) :
review: Approve

Preview Diff

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