Merge lp:~canonical-platform-qa/autopilot/fix1266601-Pointer-pressed-move-2 into lp:autopilot

Proposed by Leo Arias on 2015-03-13
Status: Merged
Approved by: Christopher Lee on 2015-03-18
Approved revision: 555
Merged at revision: 546
Proposed branch: lp:~canonical-platform-qa/autopilot/fix1266601-Pointer-pressed-move-2
Merge into: lp:autopilot
Diff against target: 588 lines (+235/-105)
4 files modified
autopilot/input/__init__.py (+7/-22)
autopilot/input/_uinput.py (+69/-29)
autopilot/tests/functional/test_input_stack.py (+6/-4)
autopilot/tests/unit/test_input.py (+153/-50)
To merge this branch: bzr merge lp:~canonical-platform-qa/autopilot/fix1266601-Pointer-pressed-move-2
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve on 2015-03-18
Christopher Lee (community) 2015-03-13 Approve on 2015-03-18
Richard Huddie (community) Approve on 2015-03-17
Review via email: mp+252932@code.launchpad.net

Commit Message

Fixed the pressed finger move on touch.
Moved the last position handling to the touch backend.
Moved the animated move from drag to move.

To post a comment you must log in.
550. By Leo Arias on 2015-03-13

Updated copyright, added docs, change the property name to be the same as x11.

551. By Leo Arias on 2015-03-13

Updated the fake touch in functional tests.

552. By Leo Arias on 2015-03-13

Updated the other functional test.

Christopher Lee (veebers) wrote :

Functional tests are failing with an error re: X11 and protocol. Have pinged CI and will follow up.

Christopher Lee (veebers) wrote :

Looking good, a couple of queries needing clarification. Thanks :-)

review: Needs Information
553. By Leo Arias on 2015-03-16

Fixed copyright year.

Leo Arias (elopio) wrote :

Thanks for the review veebers. Replied and pushed.

554. By Leo Arias on 2015-03-16

Made animate default to True.

555. By Leo Arias on 2015-03-16

extracted the call scenario method.

Richard Huddie (rhuddie) wrote :

The changes look good to me. New and modified tests pass and flake8 is clean, so approving.

review: Approve
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:555
http://jenkins.qa.ubuntu.com/job/autopilot-ci/1028/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-vivid-amd64-ci/91
        deb: http://jenkins.qa.ubuntu.com/job/autopilot-vivid-amd64-ci/91/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-vivid-armhf-ci/91
        deb: http://jenkins.qa.ubuntu.com/job/autopilot-vivid-armhf-ci/91/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-vivid-i386-ci/91
        deb: http://jenkins.qa.ubuntu.com/job/autopilot-vivid-i386-ci/91/artifact/work/output/*zip*/output.zip
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-vivid-touch/1817
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-vivid-autopilot/131
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-runner-vivid-mako/1606
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-vivid-armhf/1815
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-vivid-armhf/1815/artifact/work/output/*zip*/output.zip
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/18928
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-vivid-autopilot/133
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-vivid-amd64/871
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-vivid-amd64/871/artifact/work/output/*zip*/output.zip

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/autopilot-ci/1028/rebuild

review: Approve (continuous-integration)
Christopher Lee (veebers) wrote :

LGTM.

review: Approve
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'autopilot/input/__init__.py'
2--- autopilot/input/__init__.py 2014-10-24 19:35:45 +0000
3+++ autopilot/input/__init__.py 2015-03-16 15:18:07 +0000
4@@ -1,7 +1,7 @@
5 # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
6 #
7 # Autopilot Functional Test Tool
8-# Copyright (C) 2012-2013 Canonical
9+# Copyright (C) 2012, 2013, 2014, 2015 Canonical
10 #
11 # This program is free software: you can redistribute it and/or modify
12 # it under the terms of the GNU General Public License as published by
13@@ -558,8 +558,6 @@
14 raise TypeError(
15 "`device` must be either a Touch or a Mouse instance.")
16 self._device = device
17- self._x = 0
18- self._y = 0
19
20 @property
21 def x(self):
22@@ -569,10 +567,7 @@
23 last known X coordinate, which may not be a sensible value.
24
25 """
26- if isinstance(self._device, Mouse):
27- return self._device.x
28- else:
29- return self._x
30+ return self._device.x
31
32 @property
33 def y(self):
34@@ -582,10 +577,7 @@
35 last known Y coordinate, which may not be a sensible value.
36
37 """
38- if isinstance(self._device, Mouse):
39- return self._device.y
40- else:
41- return self._y
42+ return self._device.y
43
44 def press(self, button=1):
45 """Press the pointer at it's current location.
46@@ -637,8 +629,8 @@
47 raise ValueError(
48 "Touch devices do not have button %d" % (button))
49 self._device.tap(
50- self._x,
51- self._y,
52+ self.x,
53+ self.y,
54 press_duration=press_duration,
55 time_between_events=time_between_events
56 )
57@@ -652,11 +644,7 @@
58 :meth:`click` will occur.
59
60 """
61- if isinstance(self._device, Mouse):
62- self._device.move(x, y)
63- else:
64- self._x = x
65- self._y = y
66+ self._device.move(x, y)
67
68 def click_object(
69 self,
70@@ -714,7 +702,7 @@
71 if isinstance(self._device, Mouse):
72 return self._device.position()
73 else:
74- return (self._x, self._y)
75+ return (self.x, self.y)
76
77 def drag(self, x1, y1, x2, y2, rate=10, time_between_events=0.01):
78 """Perform a press, move and release.
79@@ -740,6 +728,3 @@
80 """
81 self._device.drag(
82 x1, y1, x2, y2, rate=rate, time_between_events=time_between_events)
83- if isinstance(self._device, Touch):
84- self._x = x2
85- self._y = y2
86
87=== modified file 'autopilot/input/_uinput.py'
88--- autopilot/input/_uinput.py 2014-10-30 23:42:46 +0000
89+++ autopilot/input/_uinput.py 2015-03-16 15:18:07 +0000
90@@ -1,7 +1,7 @@
91 # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
92 #
93 # Autopilot Functional Test Tool
94-# Copyright (C) 2012, 2013, 2014 Canonical
95+# Copyright (C) 2012, 2013, 2014, 2015 Canonical
96 #
97 # This program is free software: you can redistribute it and/or modify
98 # it under the terms of the GNU General Public License as published by
99@@ -458,6 +458,18 @@
100 super(Touch, self).__init__()
101 self._device = device_class()
102 self.event_delayer = EventDelay()
103+ self._x = 0
104+ self._y = 0
105+
106+ @property
107+ def x(self):
108+ """Finger position X coordinate."""
109+ return self._x
110+
111+ @property
112+ def y(self):
113+ """Finger position Y coordinate."""
114+ return self._y
115
116 @property
117 def pressed(self):
118@@ -472,10 +484,15 @@
119 """
120 _logger.debug("Tapping at: %d,%d", x, y)
121 self.event_delayer.delay(time_between_events)
122- self._device.finger_down(x, y)
123+ self._finger_down(x, y)
124 sleep(press_duration)
125 self._device.finger_up()
126
127+ def _finger_down(self, x, y):
128+ self._device.finger_down(x, y)
129+ self._x = x
130+ self._y = y
131+
132 def tap_object(self, object_, press_duration=0.1, time_between_events=0.1):
133 """Click (or 'tap') a given object.
134
135@@ -504,7 +521,7 @@
136
137 """
138 _logger.debug("Pressing at: %d,%d", x, y)
139- self._device.finger_down(x, y)
140+ self._finger_down(x, y)
141
142 def release(self):
143 """Release a previously pressed finger.
144@@ -515,15 +532,58 @@
145 _logger.debug("Releasing")
146 self._device.finger_up()
147
148- def move(self, x, y):
149+ def move(self, x, y, animate=True, rate=10, time_between_events=0.01):
150 """Moves the pointing "finger" to pos(x,y).
151
152 NOTE: The finger has to be down for this to have any effect.
153
154+ :param x: The point on the x axis where the move will end at.
155+ :param y: The point on the y axis where the move will end at.
156+ :param animate: Indicates if the move should be immediate or it should
157+ be animated moving the finger slowly accross the screen as a real
158+ user would do. By default, when the finger is down the finger is
159+ animated. When the finger is up, the parameter is ignored and the
160+ move is always immediate.
161+ :type animate: boolean.
162+ :param rate: The number of pixels the finger will be moved per
163+ iteration. Default is 10 pixels. A higher rate will make the drag
164+ faster, and lower rate will make it slower.
165+ :param time_between_events: The number of seconds that the drag will
166+ wait between iterations.
167 :raises RuntimeError: if the finger is not pressed.
168
169 """
170- self._device.finger_move(x, y)
171+ if self.pressed:
172+ if animate:
173+ self._move_with_animation(x, y, rate, time_between_events)
174+ else:
175+ self._device.finger_move(x, y)
176+ self._x = x
177+ self._y = y
178+
179+ def _move_with_animation(self, x, y, rate, time_between_events):
180+ current_x, current_y = self.x, self.y
181+ while current_x != x or current_y != y:
182+ dx = abs(x - current_x)
183+ dy = abs(y - current_y)
184+
185+ intx = float(dx) / max(dx, dy)
186+ inty = float(dy) / max(dx, dy)
187+
188+ step_x = min(rate * intx, dx)
189+ step_y = min(rate * inty, dy)
190+
191+ if x < current_x:
192+ step_x *= -1
193+ if y < current_y:
194+ step_y *= -1
195+
196+ current_x += step_x
197+ current_y += step_y
198+
199+ self._device.finger_move(current_x, current_y)
200+
201+ sleep(time_between_events)
202
203 def drag(self, x1, y1, x2, y2, rate=10, time_between_events=0.01):
204 """Perform a drag gesture.
205@@ -548,30 +608,10 @@
206
207 """
208 _logger.debug("Dragging from %d,%d to %d,%d", x1, y1, x2, y2)
209- self._device.finger_down(x1, y1)
210-
211- current_x, current_y = x1, y1
212- while current_x != x2 or current_y != y2:
213- dx = abs(x2 - current_x)
214- dy = abs(y2 - current_y)
215-
216- intx = float(dx) / max(dx, dy)
217- inty = float(dy) / max(dx, dy)
218-
219- step_x = min(rate * intx, dx)
220- step_y = min(rate * inty, dy)
221-
222- if x2 < current_x:
223- step_x *= -1
224- if y2 < current_y:
225- step_y *= -1
226-
227- current_x += step_x
228- current_y += step_y
229- self._device.finger_move(current_x, current_y)
230-
231- sleep(time_between_events)
232-
233+ self._finger_down(x1, y1)
234+ self.move(
235+ x2, y2, animate=True, rate=rate,
236+ time_between_events=time_between_events)
237 self._device.finger_up()
238
239
240
241=== modified file 'autopilot/tests/functional/test_input_stack.py'
242--- autopilot/tests/functional/test_input_stack.py 2014-11-06 22:32:53 +0000
243+++ autopilot/tests/functional/test_input_stack.py 2015-03-16 15:18:07 +0000
244@@ -484,8 +484,8 @@
245 device = Pointer(Touch.create())
246 device.move(34, 56)
247
248- self.assertThat(device._x, Equals(34))
249- self.assertThat(device._y, Equals(56))
250+ self.assertThat(device.x, Equals(34))
251+ self.assertThat(device.y, Equals(56))
252
253 def test_touch_drag_updates_coordinates(self):
254 """The Pointer wrapper must update it's x and y properties when
255@@ -494,11 +494,13 @@
256 """
257 class FakeTouch(Touch):
258 def __init__(self):
259- pass
260+ self.x = 0
261+ self.y = 0
262
263 def drag(self, x1, y1, x2, y2, rate='dummy',
264 time_between_events='dummy'):
265- pass
266+ self.x = x2
267+ self.y = y2
268
269 p = Pointer(FakeTouch())
270 p.drag(0, 0, 100, 123)
271
272=== modified file 'autopilot/tests/unit/test_input.py'
273--- autopilot/tests/unit/test_input.py 2014-10-30 23:42:46 +0000
274+++ autopilot/tests/unit/test_input.py 2015-03-16 15:18:07 +0000
275@@ -1,7 +1,7 @@
276 # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
277 #
278 # Autopilot Functional Test Tool
279-# Copyright (C) 2013, 2014 Canonical
280+# Copyright (C) 2013, 2014, 2015 Canonical
281 #
282 # This program is free software: you can redistribute it and/or modify
283 # it under the terms of the GNU General Public License as published by
284@@ -661,19 +661,65 @@
285 self.assertFalse(touch.pressed)
286
287
288-class UInputTouchTestCase(TestCase):
289+class UInputTouchBaseTestCase(TestCase):
290+
291+ def setUp(self):
292+ super(UInputTouchBaseTestCase, self).setUp()
293+ # Mock the sleeps so we don't have to spend time actually sleeping.
294+ self.addCleanup(utilities.sleep.disable_mock)
295+ utilities.sleep.enable_mock()
296+
297+ def get_touch_with_mocked_backend(self):
298+ touch = _uinput.Touch(device_class=Mock)
299+ touch._device.mock_add_spec(_uinput._UInputTouchDevice)
300+ return touch
301+
302+
303+class UInputTouchFingerCoordinatesTestCase(
304+ testscenarios.TestWithScenarios, UInputTouchBaseTestCase):
305+
306+ TEST_X_DESTINATION = 10
307+ TEST_Y_DESTINATION = 10
308+
309+ scenarios = [
310+ ('tap', {
311+ 'method': 'tap',
312+ 'args': (TEST_X_DESTINATION, TEST_Y_DESTINATION)
313+ }),
314+ ('press', {
315+ 'method': 'press',
316+ 'args': (TEST_X_DESTINATION, TEST_Y_DESTINATION)
317+ }),
318+ ('move', {
319+ 'method': 'move',
320+ 'args': (TEST_X_DESTINATION, TEST_Y_DESTINATION)
321+ }),
322+ ('drag', {
323+ 'method': 'drag',
324+ 'args': (0, 0, TEST_X_DESTINATION, TEST_Y_DESTINATION)
325+ })
326+ ]
327+
328+ def call_scenario_method(self, object_, method, *args):
329+ getattr(object_, method)(*self.args)
330+
331+ def test_method_must_update_finger_coordinates(self):
332+ touch = self.get_touch_with_mocked_backend()
333+
334+ self.call_scenario_method(touch, self.method, *self.args)
335+
336+ self.assertEqual(touch.x, self.TEST_X_DESTINATION)
337+ self.assertEqual(touch.y, self.TEST_Y_DESTINATION)
338+
339+
340+class UInputTouchTestCase(UInputTouchBaseTestCase):
341 """Test UInput Touch helper for autopilot tests."""
342
343- def setUp(self):
344- super(UInputTouchTestCase, self).setUp()
345- # Mock the sleeps so we don't have to spend time actually sleeping.
346- self.addCleanup(utilities.sleep.disable_mock)
347- utilities.sleep.enable_mock()
348+ def test_initial_coordinates_must_be_zero(self):
349+ touch = self.get_touch_with_mocked_backend()
350
351- def get_touch_with_mocked_backend(self):
352- touch = _uinput.Touch(device_class=Mock)
353- touch._device.mock_add_spec(_uinput._UInputTouchDevice)
354- return touch
355+ self.assertEqual(touch.x, 0)
356+ self.assertEqual(touch.y, 0)
357
358 def test_tap_must_put_finger_down_then_sleep_and_then_put_finger_up(self):
359 expected_calls = [
360@@ -720,52 +766,47 @@
361 touch.move(10, 10)
362 self.assertEqual(expected_calls, touch._device.mock_calls)
363
364- def test_drag_must_call_finger_down_move_and_up(self):
365- expected_calls = [
366- call.finger_down(0, 0),
367- call.finger_move(10, 10),
368- call.finger_up()
369- ]
370-
371- touch = self.get_touch_with_mocked_backend()
372- touch.drag(0, 0, 10, 10)
373- self.assertEqual(expected_calls, touch._device.mock_calls)
374-
375- def test_drag_must_move_with_specified_rate(self):
376- expected_calls = [
377- call.finger_down(0, 0),
378+ def test_move_must_move_with_specified_rate(self):
379+ expected_calls = [
380 call.finger_move(5, 5),
381 call.finger_move(10, 10),
382 call.finger_move(15, 15),
383- call.finger_up()]
384+ ]
385
386 touch = self.get_touch_with_mocked_backend()
387- touch.drag(0, 0, 15, 15, rate=5)
388+ touch.move(15, 15, rate=5)
389
390 self.assertEqual(
391 expected_calls, touch._device.mock_calls)
392
393- def test_drag_without_rate_must_use_default(self):
394+ def test_move_without_rate_must_use_default(self):
395 expected_calls = [
396- call.finger_down(0, 0),
397 call.finger_move(10, 10),
398 call.finger_move(20, 20),
399- call.finger_up()]
400+ ]
401
402 touch = self.get_touch_with_mocked_backend()
403- touch.drag(0, 0, 20, 20)
404+ touch.move(20, 20)
405
406 self.assertEqual(
407 expected_calls, touch._device.mock_calls)
408
409- def test_drag_to_same_place_must_not_move(self):
410+ def test_move_to_same_place_must_not_move(self):
411+ expected_calls = []
412+
413+ touch = self.get_touch_with_mocked_backend()
414+ touch.move(0, 0)
415+ self.assertEqual(expected_calls, touch._device.mock_calls)
416+
417+ def test_drag_must_call_finger_down_move_and_up(self):
418 expected_calls = [
419 call.finger_down(0, 0),
420+ call.finger_move(10, 10),
421 call.finger_up()
422 ]
423
424 touch = self.get_touch_with_mocked_backend()
425- touch.drag(0, 0, 0, 0)
426+ touch.drag(0, 0, 10, 10)
427 self.assertEqual(expected_calls, touch._device.mock_calls)
428
429 def test_tap_without_press_duration_must_sleep_default_time(self):
430@@ -848,55 +889,56 @@
431 self.assertFalse(finger2.pressed)
432
433
434-class DragUInputTouchTestCase(testscenarios.TestWithScenarios, TestCase):
435+class MoveWithAnimationUInputTouchTestCase(
436+ testscenarios.TestWithScenarios, TestCase):
437
438 scenarios = [
439- ('drag to top', dict(
440+ ('move to top', dict(
441 start_x=50, start_y=50, stop_x=50, stop_y=30,
442 expected_moves=[call.finger_move(50, 40),
443 call.finger_move(50, 30)])),
444- ('drag to bottom', dict(
445+ ('move to bottom', dict(
446 start_x=50, start_y=50, stop_x=50, stop_y=70,
447 expected_moves=[call.finger_move(50, 60),
448 call.finger_move(50, 70)])),
449- ('drag to left', dict(
450+ ('move to left', dict(
451 start_x=50, start_y=50, stop_x=30, stop_y=50,
452 expected_moves=[call.finger_move(40, 50),
453 call.finger_move(30, 50)])),
454- ('drag to right', dict(
455+ ('move to right', dict(
456 start_x=50, start_y=50, stop_x=70, stop_y=50,
457 expected_moves=[call.finger_move(60, 50),
458 call.finger_move(70, 50)])),
459
460- ('drag to top-left', dict(
461+ ('move to top-left', dict(
462 start_x=50, start_y=50, stop_x=30, stop_y=30,
463 expected_moves=[call.finger_move(40, 40),
464 call.finger_move(30, 30)])),
465- ('drag to top-right', dict(
466+ ('move to top-right', dict(
467 start_x=50, start_y=50, stop_x=70, stop_y=30,
468 expected_moves=[call.finger_move(60, 40),
469 call.finger_move(70, 30)])),
470- ('drag to bottom-left', dict(
471+ ('move to bottom-left', dict(
472 start_x=50, start_y=50, stop_x=30, stop_y=70,
473 expected_moves=[call.finger_move(40, 60),
474 call.finger_move(30, 70)])),
475- ('drag to bottom-right', dict(
476+ ('move to bottom-right', dict(
477 start_x=50, start_y=50, stop_x=70, stop_y=70,
478 expected_moves=[call.finger_move(60, 60),
479 call.finger_move(70, 70)])),
480
481- ('drag less than rate', dict(
482+ ('move less than rate', dict(
483 start_x=50, start_y=50, stop_x=55, stop_y=55,
484 expected_moves=[call.finger_move(55, 55)])),
485
486- ('drag with last move less than rate', dict(
487+ ('move with last move less than rate', dict(
488 start_x=50, start_y=50, stop_x=65, stop_y=65,
489 expected_moves=[call.finger_move(60, 60),
490 call.finger_move(65, 65)])),
491 ]
492
493 def setUp(self):
494- super(DragUInputTouchTestCase, self).setUp()
495+ super(MoveWithAnimationUInputTouchTestCase, self).setUp()
496 # Mock the sleeps so we don't have to spend time actually sleeping.
497 self.addCleanup(utilities.sleep.disable_mock)
498 utilities.sleep.enable_mock()
499@@ -910,12 +952,12 @@
500 def test_drag_moves(self):
501 touch = self.get_touch_with_mocked_backend()
502
503- touch.drag(
504- self.start_x, self.start_y, self.stop_x, self.stop_y)
505+ touch.press(self.start_x, self.start_y)
506+ touch.move(self.stop_x, self.stop_y)
507
508- # We don't check the finger down and finger up. They are already
509- # tested.
510- expected_calls = [ANY] + self.expected_moves + [ANY]
511+ expected_calls = (
512+ [call.finger_down(self.start_x, self.start_y)] +
513+ self.expected_moves)
514 self.assertEqual(
515 expected_calls, touch._device.mock_calls)
516
517@@ -929,6 +971,30 @@
518 pointer = autopilot.input.Pointer(touch)
519 return pointer
520
521+ def test_initial_coordinates_must_be_zero(self):
522+ pointer = self.get_pointer_with_touch_backend_with_mock_device()
523+
524+ self.assertEqual(pointer.x, 0)
525+ self.assertEqual(pointer.y, 0)
526+
527+ def test_drag_must_call_move_with_animation(self):
528+ test_rate = 2
529+ test_time_between_events = 1
530+ test_destination_x = 20
531+ test_destination_y = 20
532+
533+ pointer = self.get_pointer_with_touch_backend_with_mock_device()
534+ with patch.object(pointer._device, 'move') as mock_move:
535+ pointer.drag(
536+ 0, 0,
537+ test_destination_x, test_destination_y,
538+ rate=test_rate, time_between_events=test_time_between_events)
539+
540+ mock_move.assert_called_once_with(
541+ test_destination_x, test_destination_y,
542+ animate=True,
543+ rate=test_rate, time_between_events=test_time_between_events)
544+
545 def test_drag_with_rate(self):
546 pointer = self.get_pointer_with_touch_backend_with_mock_device()
547 with patch.object(pointer._device, 'drag') as mock_drag:
548@@ -968,3 +1034,40 @@
549
550 mock_tap.assert_called_once_with(
551 0, 0, press_duration=10, time_between_events=0.1)
552+
553+ def test_not_pressed_move_must_not_move_pointing_figer(self):
554+ """Test for moving the finger when it is not pressed.
555+
556+ The move method on the pointer class must update the finger coordinates
557+ but it must not execute a move on the device.
558+
559+ """
560+ test_x_destination = 20
561+ test_y_destination = 20
562+ pointer = self.get_pointer_with_touch_backend_with_mock_device()
563+
564+ pointer.move(10, 10)
565+ pointer._device._device.pressed = False
566+
567+ with patch.object(pointer._device._device, 'finger_move') as mock_move:
568+ pointer.move(test_x_destination, test_y_destination)
569+
570+ self.assertFalse(mock_move.called)
571+ self.assertEqual(pointer.x, test_x_destination)
572+ self.assertEqual(pointer.y, test_y_destination)
573+
574+ def test_pressed_move_must_move_pointing_finger(self):
575+ test_x_destination = 20
576+ test_y_destination = 20
577+
578+ pointer = self.get_pointer_with_touch_backend_with_mock_device()
579+
580+ pointer.move(10, 10)
581+ pointer._device._device.pressed = True
582+
583+ with patch.object(pointer._device._device, 'finger_move') as mock_move:
584+ pointer.move(test_x_destination, test_y_destination)
585+
586+ mock_move.assert_called_once_with(20, 20)
587+ self.assertEqual(pointer.x, test_x_destination)
588+ self.assertEqual(pointer.y, test_y_destination)

Subscribers

People subscribed via source and target branches