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
=== modified file 'autopilot/input/__init__.py'
--- autopilot/input/__init__.py 2013-09-04 03:44:07 +0000
+++ autopilot/input/__init__.py 2013-09-13 16:28:42 +0000
@@ -337,7 +337,7 @@
337 self.click(button, press_duration)337 self.click(button, press_duration)
338338
339 def move(self, x, y, animate=True, rate=10, time_between_events=0.01):339 def move(self, x, y, animate=True, rate=10, time_between_events=0.01):
340 """Moves mouse to location (x, y).340 """Moves mouse to location (x,y).
341341
342 Callers should avoid specifying the *rate* or *time_between_events*342 Callers should avoid specifying the *rate* or *time_between_events*
343 parameters unless they need a specific rate of movement.343 parameters unless they need a specific rate of movement.
@@ -426,7 +426,7 @@
426 raise NotImplementedError("You cannot use this class directly.")426 raise NotImplementedError("You cannot use this class directly.")
427427
428 def tap(self, x, y):428 def tap(self, x, y):
429 """Click (or 'tap') at given x and y coordinates."""429 """Click (or 'tap') at given x,y coordinates."""
430 raise NotImplementedError("You cannot use this class directly.")430 raise NotImplementedError("You cannot use this class directly.")
431431
432 def tap_object(self, object):432 def tap_object(self, object):
@@ -446,7 +446,20 @@
446 raise NotImplementedError("You cannot use this class directly.")446 raise NotImplementedError("You cannot use this class directly.")
447447
448 def press(self, x, y):448 def press(self, x, y):
449 """Press and hold."""449 """Press and hold at the given x,y coordinates."""
450 raise NotImplementedError("You cannot use this class directly.")
451
452 def move(self, x, y):
453 """Move the pointer coords to (x,y).
454
455 .. note:: The touch 'finger' must be pressed for a call to this
456 method to be successful. (see :py:meth:`press` for further details on
457 touch presses.)
458
459 :raises: **RuntimeError** if called and the touch 'finger' isn't
460 pressed.
461
462 """
450 raise NotImplementedError("You cannot use this class directly.")463 raise NotImplementedError("You cannot use this class directly.")
451464
452 def release(self):465 def release(self):
453466
=== modified file 'autopilot/input/_uinput.py'
--- autopilot/input/_uinput.py 2013-07-24 08:26:10 +0000
+++ autopilot/input/_uinput.py 2013-09-13 16:28:42 +0000
@@ -350,6 +350,16 @@
350 logger.debug("Releasing")350 logger.debug("Releasing")
351 self._finger_up()351 self._finger_up()
352352
353 def move(self, x, y):
354 """Moves the pointing "finger" to pos(x,y).
355
356 NOTE: The finger has to be down for this to have any effect.
357
358 """
359 if self._touch_finger is None:
360 raise RuntimeError("Attempting to move without finger being down.")
361 self._finger_move(x, y)
362
353 def drag(self, x1, y1, x2, y2):363 def drag(self, x1, y1, x2, y2):
354 """Perform a drag gesture from (x1,y1) to (x2,y2)"""364 """Perform a drag gesture from (x1,y1) to (x2,y2)"""
355 logger.debug("Dragging from %d,%d to %d,%d", x1, y1, x2, y2)365 logger.debug("Dragging from %d,%d to %d,%d", x1, y1, x2, y2)
356366
=== modified file 'autopilot/introspection/dbus.py'
--- autopilot/introspection/dbus.py 2013-08-09 01:29:23 +0000
+++ autopilot/introspection/dbus.py 2013-09-13 16:28:42 +0000
@@ -128,7 +128,7 @@
128 self.__state = {}128 self.__state = {}
129 self.__refresh_on_attribute = True129 self.__refresh_on_attribute = True
130 self._set_properties(state_dict)130 self._set_properties(state_dict)
131 self.path = path131 self._path = path
132132
133 def _set_properties(self, state_dict):133 def _set_properties(self, state_dict):
134 """Creates and set attributes of *self* based on contents of134 """Creates and set attributes of *self* based on contents of
@@ -509,10 +509,10 @@
509 def get_class_query_string(self):509 def get_class_query_string(self):
510 """Get the XPath query string required to refresh this class's510 """Get the XPath query string required to refresh this class's
511 state."""511 state."""
512 if not self.path.startswith('/'):512 if not self._path.startswith('/'):
513 return "//" + self.path + "[id=%d]" % self.id513 return "//" + self._path + "[id=%d]" % self.id
514 else:514 else:
515 return self.path + "[id=%d]" % self.id515 return self._path + "[id=%d]" % self.id
516516
517 @classmethod517 @classmethod
518 def make_introspection_object(cls, dbus_tuple):518 def make_introspection_object(cls, dbus_tuple):
519519
=== modified file 'autopilot/tests/functional/test_input_stack.py'
--- autopilot/tests/functional/test_input_stack.py 2013-09-04 03:44:07 +0000
+++ autopilot/tests/functional/test_input_stack.py 2013-09-13 16:28:42 +0000
@@ -29,6 +29,7 @@
2929
30from autopilot import platform30from autopilot import platform
31from autopilot.testcase import AutopilotTestCase, multiply_scenarios31from autopilot.testcase import AutopilotTestCase, multiply_scenarios
32from autopilot.gestures import pinch
32from autopilot.input import Keyboard, Mouse, Pointer, Touch33from autopilot.input import Keyboard, Mouse, Pointer, Touch
33from autopilot.input._common import get_center_point34from autopilot.input._common import get_center_point
34from autopilot.matchers import Eventually35from autopilot.matchers import Eventually
@@ -333,6 +334,56 @@
333 self.button_status.text, Eventually(Equals("Touch Release")))334 self.button_status.text, Eventually(Equals("Touch Release")))
334335
335336
337class TouchGesturesTests(AutopilotTestCase):
338 def _start_qml_script(self, script_contents):
339 """Launch a qml script."""
340 qml_path = mktemp(suffix='.qml')
341 open(qml_path, 'w').write(script_contents)
342 self.addCleanup(os.remove, qml_path)
343
344 return self.launch_test_application(
345 "qmlscene",
346 qml_path,
347 app_type='qt',
348 )
349
350 def test_pinch_gesture(self):
351 """Ensure that the pinch gesture pinches as expected."""
352
353 test_qml = dedent("""\
354 import QtQuick 2.0
355
356 Rectangle {
357 id: colorBox
358 width: 250
359 height: 250
360 color: "#00FF00"
361
362 PinchArea {
363 anchors.fill: parent
364 onPinchFinished: {
365 colorBox.color = "#0000FF"
366 }
367 }
368 }
369 """)
370
371 # Returned results include the alpha (RGBA)
372 start_green_bg = [0, 255, 0, 255]
373 end_blue_bg = [0, 0, 255, 255]
374
375 app = self._start_qml_script(test_qml)
376 pinch_widget = app.select_single("QQuickRectangle")
377 widget_bg_colour = lambda: pinch_widget.color
378
379 self.assertThat(widget_bg_colour, Eventually(Equals(start_green_bg)))
380
381 x, y = get_center_point(pinch_widget)
382 pinch((x, y), (10, 0), (100, 0))
383
384 self.assertThat(widget_bg_colour, Eventually(Equals(end_blue_bg)))
385
386
336class PointerWrapperTests(AutopilotTestCase):387class PointerWrapperTests(AutopilotTestCase):
337388
338 def test_can_move_touch_wrapper(self):389 def test_can_move_touch_wrapper(self):
339390
=== modified file 'autopilot/tests/unit/test_introspection_features.py'
--- autopilot/tests/unit/test_introspection_features.py 2013-08-08 20:33:14 +0000
+++ autopilot/tests/unit/test_introspection_features.py 2013-09-13 16:28:42 +0000
@@ -25,6 +25,7 @@
2525
26from autopilot.introspection.dbus import (26from autopilot.introspection.dbus import (
27 CustomEmulatorBase,27 CustomEmulatorBase,
28 DBusIntrospectionObject,
28 _is_valid_server_side_filter_param,29 _is_valid_server_side_filter_param,
29)30)
3031
@@ -80,3 +81,14 @@
80 _is_valid_server_side_filter_param(self.key, self.value),81 _is_valid_server_side_filter_param(self.key, self.value),
81 Equals(self.result)82 Equals(self.result)
82 )83 )
84
85
86class DBusIntrospectionObjectTests(TestCase):
87
88 def test_can_access_path_attribute(self):
89 fake_object = DBusIntrospectionObject(
90 dict(id=123, path='/some/path'),
91 '/'
92 )
93 with fake_object.no_automatic_refreshing():
94 self.assertThat(fake_object.path, Equals('/some/path'))

Subscribers

People subscribed via source and target branches