Merge lp:~veebers/autopilot/fix_1205949_gestures into lp:autopilot

Proposed by Christopher Lee
Status: Superseded
Proposed branch: lp:~veebers/autopilot/fix_1205949_gestures
Merge into: lp:autopilot
Diff against target: 138 lines (+78/-3)
3 files modified
autopilot/input/__init__.py (+16/-3)
autopilot/input/_uinput.py (+10/-0)
autopilot/tests/functional/test_input_stack.py (+52/-0)
To merge this branch: bzr merge lp:~veebers/autopilot/fix_1205949_gestures
Reviewer Review Type Date Requested Status
Thomi Richards (community) Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+177985@code.launchpad.net

This proposal has been superseded by a proposal from 2013-09-09.

Commit message

Fix for pinch gesture with test.

Description of the change

Fix for pinch gesture with test.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Thomi Richards (thomir-deactivatedaccount) wrote :

Hi Chris,

You still need better documentation in the Touch interface. In particular, you need to mention which exception will be raised, and under which conditions. There's very little point adding docstrings to the implementation, since they never get seen by the user.

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Thomi Richards (thomir-deactivatedaccount) :
review: Approve

Unmerged revisions

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 2013-07-23 04:04:43 +0000
3+++ autopilot/input/__init__.py 2013-08-12 05:44:56 +0000
4@@ -273,7 +273,7 @@
5 self.click(button, press_duration)
6
7 def move(self, x, y, animate=True, rate=10, time_between_events=0.01):
8- """Moves mouse to location (x, y).
9+ """Moves mouse to location (x,y).
10
11 Callers should avoid specifying the *rate* or *time_between_events*
12 parameters unless they need a specific rate of movement.
13@@ -362,7 +362,7 @@
14 raise NotImplementedError("You cannot use this class directly.")
15
16 def tap(self, x, y):
17- """Click (or 'tap') at given x and y coordinates."""
18+ """Click (or 'tap') at given x,y coordinates."""
19 raise NotImplementedError("You cannot use this class directly.")
20
21 def tap_object(self, object):
22@@ -382,7 +382,20 @@
23 raise NotImplementedError("You cannot use this class directly.")
24
25 def press(self, x, y):
26- """Press and hold."""
27+ """Press and hold at the given x,y coordinates."""
28+ raise NotImplementedError("You cannot use this class directly.")
29+
30+ def move(self, x, y):
31+ """Move the pointer coords to (x,y).
32+
33+ .. note:: The touch 'finger' must be pressed for a call to this
34+ method to be successful. (see :py:meth:`press` for further details on
35+ touch presses.)
36+
37+ :raises: **RuntimeError** if called and the touch 'finger' isn't
38+ pressed.
39+
40+ """
41 raise NotImplementedError("You cannot use this class directly.")
42
43 def release(self):
44
45=== modified file 'autopilot/input/_uinput.py'
46--- autopilot/input/_uinput.py 2013-07-24 08:26:10 +0000
47+++ autopilot/input/_uinput.py 2013-08-12 05:44:56 +0000
48@@ -350,6 +350,16 @@
49 logger.debug("Releasing")
50 self._finger_up()
51
52+ def move(self, x, y):
53+ """Moves the pointing "finger" to pos(x,y).
54+
55+ NOTE: The finger has to be down for this to have any effect.
56+
57+ """
58+ if self._touch_finger is None:
59+ raise RuntimeError("Attempting to move without finger being down.")
60+ self._finger_move(x, y)
61+
62 def drag(self, x1, y1, x2, y2):
63 """Perform a drag gesture from (x1,y1) to (x2,y2)"""
64 logger.debug("Dragging from %d,%d to %d,%d", x1, y1, x2, y2)
65
66=== modified file 'autopilot/tests/functional/test_input_stack.py'
67--- autopilot/tests/functional/test_input_stack.py 2013-07-24 08:26:10 +0000
68+++ autopilot/tests/functional/test_input_stack.py 2013-08-12 05:44:56 +0000
69@@ -23,10 +23,12 @@
70 from tempfile import mktemp
71 from testtools import TestCase
72 from testtools.matchers import IsInstance, Equals, raises
73+from textwrap import dedent
74 from unittest import SkipTest
75 from mock import patch
76
77 from autopilot.testcase import AutopilotTestCase, multiply_scenarios
78+from autopilot.gestures import pinch
79 from autopilot.input import Keyboard, Mouse, Pointer, Touch
80 from autopilot.input._common import get_center_point
81 from autopilot.matchers import Eventually
82@@ -204,6 +206,56 @@
83 self.button_status.text, Eventually(Equals("Touch Release")))
84
85
86+class TouchGesturesTests(AutopilotTestCase):
87+ def _start_qml_script(self, script_contents):
88+ """Launch a qml script."""
89+ qml_path = mktemp(suffix='.qml')
90+ open(qml_path, 'w').write(script_contents)
91+ self.addCleanup(os.remove, qml_path)
92+
93+ return self.launch_test_application(
94+ "qmlscene",
95+ qml_path,
96+ app_type='qt',
97+ )
98+
99+ def test_pinch_gesture(self):
100+ """Ensure that the pinch gesture pinches as expected."""
101+
102+ test_qml = dedent("""\
103+ import QtQuick 2.0
104+
105+ Rectangle {
106+ id: colorBox
107+ width: 250
108+ height: 250
109+ color: "#00FF00"
110+
111+ PinchArea {
112+ anchors.fill: parent
113+ onPinchFinished: {
114+ colorBox.color = "#0000FF"
115+ }
116+ }
117+ }
118+ """)
119+
120+ # Returned results include the alpha (RGBA)
121+ start_green_bg = [0, 255, 0, 255]
122+ end_blue_bg = [0, 0, 255, 255]
123+
124+ app = self._start_qml_script(test_qml)
125+ pinch_widget = app.select_single("QQuickRectangle")
126+ widget_bg_colour = lambda: pinch_widget.color
127+
128+ self.assertThat(widget_bg_colour, Eventually(Equals(start_green_bg)))
129+
130+ x, y = get_center_point(pinch_widget)
131+ pinch((x, y), (10, 0), (100, 0))
132+
133+ self.assertThat(widget_bg_colour, Eventually(Equals(end_blue_bg)))
134+
135+
136 class PointerWrapperTests(AutopilotTestCase):
137
138 def test_can_move_touch_wrapper(self):

Subscribers

People subscribed via source and target branches