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

Proposed by Thomi Richards
Status: Merged
Approved by: Thomi Richards
Approved revision: 301
Merged at revision: 323
Proposed branch: lp:~veebers/autopilot/fix_1205949_gestures
Merge into: lp:autopilot/1.3
Diff against target: 133 lines (+77/-3)
3 files modified
autopilot/input/__init__.py (+16/-3)
autopilot/input/_uinput.py (+10/-0)
autopilot/tests/functional/test_input_stack.py (+51/-0)
To merge this branch: bzr merge lp:~veebers/autopilot/fix_1205949_gestures
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Thomi Richards (community) Approve
Review via email: mp+184675@code.launchpad.net

This proposal supersedes a proposal from 2013-08-01.

Commit message

commit message.

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 : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
Thomi Richards (thomir-deactivatedaccount) wrote : Posted in a previous version of this proposal

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 : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
Thomi Richards (thomir-deactivatedaccount) : Posted in a previous version of this proposal
review: Approve
Revision history for this message
Thomi Richards (thomir-deactivatedaccount) wrote :

Re-targetted at correct target branch, re-approving.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Autolanding.
No commit message was specified in the merge proposal. Hit 'Add commit message' on the merge proposal web page or follow the link below. You can approve the merge proposal yourself to rerun.
https://code.launchpad.net/~veebers/autopilot/fix_1205949_gestures/+merge/184675/+edit-commit-message

review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) :
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 2013-09-04 03:44:07 +0000
3+++ autopilot/input/__init__.py 2013-09-09 20:27:25 +0000
4@@ -337,7 +337,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@@ -426,7 +426,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@@ -446,7 +446,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-09-09 20:27:25 +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-09-04 03:44:07 +0000
68+++ autopilot/tests/functional/test_input_stack.py 2013-09-09 20:27:25 +0000
69@@ -29,6 +29,7 @@
70
71 from autopilot import platform
72 from autopilot.testcase import AutopilotTestCase, multiply_scenarios
73+from autopilot.gestures import pinch
74 from autopilot.input import Keyboard, Mouse, Pointer, Touch
75 from autopilot.input._common import get_center_point
76 from autopilot.matchers import Eventually
77@@ -333,6 +334,56 @@
78 self.button_status.text, Eventually(Equals("Touch Release")))
79
80
81+class TouchGesturesTests(AutopilotTestCase):
82+ def _start_qml_script(self, script_contents):
83+ """Launch a qml script."""
84+ qml_path = mktemp(suffix='.qml')
85+ open(qml_path, 'w').write(script_contents)
86+ self.addCleanup(os.remove, qml_path)
87+
88+ return self.launch_test_application(
89+ "qmlscene",
90+ qml_path,
91+ app_type='qt',
92+ )
93+
94+ def test_pinch_gesture(self):
95+ """Ensure that the pinch gesture pinches as expected."""
96+
97+ test_qml = dedent("""\
98+ import QtQuick 2.0
99+
100+ Rectangle {
101+ id: colorBox
102+ width: 250
103+ height: 250
104+ color: "#00FF00"
105+
106+ PinchArea {
107+ anchors.fill: parent
108+ onPinchFinished: {
109+ colorBox.color = "#0000FF"
110+ }
111+ }
112+ }
113+ """)
114+
115+ # Returned results include the alpha (RGBA)
116+ start_green_bg = [0, 255, 0, 255]
117+ end_blue_bg = [0, 0, 255, 255]
118+
119+ app = self._start_qml_script(test_qml)
120+ pinch_widget = app.select_single("QQuickRectangle")
121+ widget_bg_colour = lambda: pinch_widget.color
122+
123+ self.assertThat(widget_bg_colour, Eventually(Equals(start_green_bg)))
124+
125+ x, y = get_center_point(pinch_widget)
126+ pinch((x, y), (10, 0), (100, 0))
127+
128+ self.assertThat(widget_bg_colour, Eventually(Equals(end_blue_bg)))
129+
130+
131 class PointerWrapperTests(AutopilotTestCase):
132
133 def test_can_move_touch_wrapper(self):

Subscribers

People subscribed via source and target branches