Merge lp:~thomir-deactivatedaccount/autopilot/1.3-fix-path-attr-hiding into lp:autopilot

Proposed by Thomi Richards
Status: Superseded
Proposed branch: lp:~thomir-deactivatedaccount/autopilot/1.3-fix-path-attr-hiding
Merge into: lp:autopilot
Diff against target: 187 lines (+93/-7)
5 files modified
autopilot/input/__init__.py (+16/-3)
autopilot/input/_uinput.py (+10/-0)
autopilot/introspection/dbus.py (+4/-4)
autopilot/tests/functional/test_input_stack.py (+51/-0)
autopilot/tests/unit/test_introspection_features.py (+12/-0)
To merge this branch: bzr merge lp:~thomir-deactivatedaccount/autopilot/1.3-fix-path-attr-hiding
Reviewer Review Type Date Requested Status
Autopilot Hackers Pending
Review via email: mp+185542@code.launchpad.net

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

Commit message

Fix bug.

Description of the change

Fix bug where we were overwriting an attribute named 'path' in some proxy objects with a variable that should have been made private.

To post a comment you must log in.

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-09-04 03:44:07 +0000
3+++ autopilot/input/__init__.py 2013-09-13 16:28:42 +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-13 16:28:42 +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/introspection/dbus.py'
67--- autopilot/introspection/dbus.py 2013-08-09 01:29:23 +0000
68+++ autopilot/introspection/dbus.py 2013-09-13 16:28:42 +0000
69@@ -128,7 +128,7 @@
70 self.__state = {}
71 self.__refresh_on_attribute = True
72 self._set_properties(state_dict)
73- self.path = path
74+ self._path = path
75
76 def _set_properties(self, state_dict):
77 """Creates and set attributes of *self* based on contents of
78@@ -509,10 +509,10 @@
79 def get_class_query_string(self):
80 """Get the XPath query string required to refresh this class's
81 state."""
82- if not self.path.startswith('/'):
83- return "//" + self.path + "[id=%d]" % self.id
84+ if not self._path.startswith('/'):
85+ return "//" + self._path + "[id=%d]" % self.id
86 else:
87- return self.path + "[id=%d]" % self.id
88+ return self._path + "[id=%d]" % self.id
89
90 @classmethod
91 def make_introspection_object(cls, dbus_tuple):
92
93=== modified file 'autopilot/tests/functional/test_input_stack.py'
94--- autopilot/tests/functional/test_input_stack.py 2013-09-04 03:44:07 +0000
95+++ autopilot/tests/functional/test_input_stack.py 2013-09-13 16:28:42 +0000
96@@ -29,6 +29,7 @@
97
98 from autopilot import platform
99 from autopilot.testcase import AutopilotTestCase, multiply_scenarios
100+from autopilot.gestures import pinch
101 from autopilot.input import Keyboard, Mouse, Pointer, Touch
102 from autopilot.input._common import get_center_point
103 from autopilot.matchers import Eventually
104@@ -333,6 +334,56 @@
105 self.button_status.text, Eventually(Equals("Touch Release")))
106
107
108+class TouchGesturesTests(AutopilotTestCase):
109+ def _start_qml_script(self, script_contents):
110+ """Launch a qml script."""
111+ qml_path = mktemp(suffix='.qml')
112+ open(qml_path, 'w').write(script_contents)
113+ self.addCleanup(os.remove, qml_path)
114+
115+ return self.launch_test_application(
116+ "qmlscene",
117+ qml_path,
118+ app_type='qt',
119+ )
120+
121+ def test_pinch_gesture(self):
122+ """Ensure that the pinch gesture pinches as expected."""
123+
124+ test_qml = dedent("""\
125+ import QtQuick 2.0
126+
127+ Rectangle {
128+ id: colorBox
129+ width: 250
130+ height: 250
131+ color: "#00FF00"
132+
133+ PinchArea {
134+ anchors.fill: parent
135+ onPinchFinished: {
136+ colorBox.color = "#0000FF"
137+ }
138+ }
139+ }
140+ """)
141+
142+ # Returned results include the alpha (RGBA)
143+ start_green_bg = [0, 255, 0, 255]
144+ end_blue_bg = [0, 0, 255, 255]
145+
146+ app = self._start_qml_script(test_qml)
147+ pinch_widget = app.select_single("QQuickRectangle")
148+ widget_bg_colour = lambda: pinch_widget.color
149+
150+ self.assertThat(widget_bg_colour, Eventually(Equals(start_green_bg)))
151+
152+ x, y = get_center_point(pinch_widget)
153+ pinch((x, y), (10, 0), (100, 0))
154+
155+ self.assertThat(widget_bg_colour, Eventually(Equals(end_blue_bg)))
156+
157+
158 class PointerWrapperTests(AutopilotTestCase):
159
160 def test_can_move_touch_wrapper(self):
161
162=== modified file 'autopilot/tests/unit/test_introspection_features.py'
163--- autopilot/tests/unit/test_introspection_features.py 2013-08-08 20:33:14 +0000
164+++ autopilot/tests/unit/test_introspection_features.py 2013-09-13 16:28:42 +0000
165@@ -25,6 +25,7 @@
166
167 from autopilot.introspection.dbus import (
168 CustomEmulatorBase,
169+ DBusIntrospectionObject,
170 _is_valid_server_side_filter_param,
171 )
172
173@@ -80,3 +81,14 @@
174 _is_valid_server_side_filter_param(self.key, self.value),
175 Equals(self.result)
176 )
177+
178+
179+class DBusIntrospectionObjectTests(TestCase):
180+
181+ def test_can_access_path_attribute(self):
182+ fake_object = DBusIntrospectionObject(
183+ dict(id=123, path='/some/path'),
184+ '/'
185+ )
186+ with fake_object.no_automatic_refreshing():
187+ self.assertThat(fake_object.path, Equals('/some/path'))

Subscribers

People subscribed via source and target branches