Merge lp:autopilot into lp:autopilot/1.5

Proposed by Christopher Lee
Status: Merged
Approved by: Christopher Lee
Approved revision: 576
Merged at revision: 527
Proposed branch: lp:autopilot
Merge into: lp:autopilot/1.5
Diff against target: 216 lines (+27/-77)
7 files modified
autopilot/input/_X11.py (+5/-49)
autopilot/input/__init__.py (+13/-21)
autopilot/input/_common.py (+5/-1)
autopilot/input/_uinput.py (+1/-1)
autopilot/introspection/_search.py (+1/-1)
autopilot/tests/functional/test_input_stack.py (+1/-2)
autopilot/tests/unit/test_input.py (+1/-2)
To merge this branch: bzr merge lp:autopilot
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Autopilot Hackers Pending
Review via email: mp+287534@code.launchpad.net

Commit message

Bugfix for lp:1308330 Simplify X11 mouse move_to_point.

Description of the change

Bugfix for lp:1308330. Also allows us to sync between vivid & xenial.

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
Max Brustkern (nuclearbob) wrote :

So this doesn't build in trusty. I'm not sure if that needs to be addressed before Chris returns, so if anyone reports problems, please let me know.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'autopilot/input/_X11.py'
2--- autopilot/input/_X11.py 2014-10-30 23:42:46 +0000
3+++ autopilot/input/_X11.py 2016-02-29 21:05:52 +0000
4@@ -26,6 +26,7 @@
5
6 import logging
7
8+from autopilot.input import get_center_point
9 from autopilot.display import is_point_on_any_screen, move_mouse_to_screen
10 from autopilot.utilities import (
11 EventDelay,
12@@ -395,57 +396,12 @@
13 def move_to_object(self, object_proxy):
14 """Attempts to move the mouse to 'object_proxy's centre point.
15
16- It does this by looking for several attributes, in order. The first
17- attribute found will be used. The attributes used are (in order):
18-
19- * globalRect (x,y,w,h)
20- * center_x, center_y
21- * x, y, w, h
22-
23- :raises: **ValueError** if none of these attributes are found, or if an
24- attribute is of an incorrect type.
25+ See :py:meth:`~autopilot.input.get_center_point` for details on how
26+ the center point is calculated.
27
28 """
29- try:
30- x, y, w, h = object_proxy.globalRect
31- _logger.debug("Moving to object's globalRect coordinates.")
32- self.move(x+w/2, y+h/2)
33- return
34- except AttributeError:
35- pass
36- except (TypeError, ValueError):
37- raise ValueError(
38- "Object '%r' has globalRect attribute, but it is not of the "
39- "correct type" % object_proxy)
40-
41- try:
42- x, y = object_proxy.center_x, object_proxy.center_y
43- _logger.debug("Moving to object's center_x, center_y coordinates.")
44- self.move(x, y)
45- return
46- except AttributeError:
47- pass
48- except (TypeError, ValueError):
49- raise ValueError(
50- "Object '%r' has center_x, center_y attributes, but they are "
51- "not of the correct type" % object_proxy)
52-
53- try:
54- x, y, w, h = (
55- object_proxy.x, object_proxy.y, object_proxy.w, object_proxy.h)
56- _logger.debug(
57- "Moving to object's center point calculated from x,y,w,h "
58- "attributes.")
59- self.move(x+w/2, y+h/2)
60- return
61- except AttributeError:
62- raise ValueError(
63- "Object '%r' does not have any recognised position "
64- "attributes" % object_proxy)
65- except (TypeError, ValueError):
66- raise ValueError(
67- "Object '%r' has x,y attribute, but they are not of the "
68- "correct type" % object_proxy)
69+ x, y = get_center_point(object_proxy)
70+ self.move(x, y)
71
72 def position(self):
73 """
74
75=== modified file 'autopilot/input/__init__.py'
76--- autopilot/input/__init__.py 2015-08-19 00:25:00 +0000
77+++ autopilot/input/__init__.py 2016-02-29 21:05:52 +0000
78@@ -57,14 +57,17 @@
79
80 from collections import OrderedDict
81 from contextlib import contextmanager
82+from autopilot.input._common import get_center_point
83 from autopilot.utilities import _pick_backend, CleanupRegistered
84-from autopilot.input._common import get_center_point
85
86 import logging
87
88 _logger = logging.getLogger(__name__)
89
90
91+__all__ = ['get_center_point']
92+
93+
94 class Keyboard(CleanupRegistered):
95
96 """A simple keyboard device class.
97@@ -653,23 +656,19 @@
98 press_duration=0.10,
99 time_between_events=0.1):
100 """
101- Attempts to move the pointer to 'object_proxy's centre point.
102- and click a button
103-
104- It does this by looking for several attributes, in order. The first
105- attribute found will be used. The attributes used are (in order):
106-
107- * globalRect (x,y,w,h)
108- * center_x, center_y
109- * x, y, w, h
110+ Attempts to move the pointer to 'object_proxy's centre point
111+ and click a button.
112+
113+ See :py:meth:`~autopilot.input.get_center_point` for details on how
114+ the center point is calculated.
115
116 If the wrapped device is a mouse, the button specification is used. If
117 it is a touch device, passing anything other than 1 will raise a
118 ValueError exception.
119
120 :param time_between_events: takes floating point to represent the
121- delay time between subsequent clicks/taps. Default value 0.1
122- represents tenth of a second.
123+ delay time between subsequent clicks/taps. Default value 0.1
124+ represents tenth of a second.
125
126 """
127
128@@ -679,15 +678,8 @@
129 def move_to_object(self, object_proxy):
130 """Attempts to move the pointer to 'object_proxy's centre point.
131
132- It does this by looking for several attributes, in order. The first
133- attribute found will be used. The attributes used are (in order):
134-
135- * globalRect (x,y,w,h)
136- * center_x, center_y
137- * x, y, w, h
138-
139- :raises: **ValueError** if none of these attributes are found, or if an
140- attribute is of an incorrect type.
141+ See :py:meth:`~autopilot.input.get_center_point` for details on how
142+ the center point is calculated.
143
144 """
145 x, y = get_center_point(object_proxy)
146
147=== modified file 'autopilot/input/_common.py'
148--- autopilot/input/_common.py 2014-03-25 14:42:25 +0000
149+++ autopilot/input/_common.py 2016-02-29 21:05:52 +0000
150@@ -29,7 +29,11 @@
151 """Get the center point of an object.
152
153 It searches for several different ways of determining exactly where the
154- center is.
155+ center is. The attributes used are (in order):
156+
157+ * globalRect (x,y,w,h)
158+ * center_x, center_y
159+ * x, y, w, h
160
161 :raises ValueError: if `object_proxy` has the globalRect attribute but it
162 is not of the correct type.
163
164=== modified file 'autopilot/input/_uinput.py'
165--- autopilot/input/_uinput.py 2015-07-07 22:12:40 +0000
166+++ autopilot/input/_uinput.py 2016-02-29 21:05:52 +0000
167@@ -25,7 +25,7 @@
168
169 from autopilot.input import Keyboard as KeyboardBase
170 from autopilot.input import Touch as TouchBase
171-from autopilot.input._common import get_center_point
172+from autopilot.input import get_center_point
173 from autopilot.utilities import deprecated, EventDelay, sleep
174
175
176
177=== modified file 'autopilot/introspection/_search.py'
178--- autopilot/introspection/_search.py 2015-06-16 02:39:23 +0000
179+++ autopilot/introspection/_search.py 2016-02-29 21:05:52 +0000
180@@ -692,7 +692,7 @@
181 def __call__(self, pid):
182 if self._cached_result is None:
183 self._cached_result = [
184- p.pid for p in psutil.Process(pid).get_children(recursive=True)
185+ p.pid for p in psutil.Process(pid).children(recursive=True)
186 ]
187 return self._cached_result
188
189
190=== modified file 'autopilot/tests/functional/test_input_stack.py'
191--- autopilot/tests/functional/test_input_stack.py 2015-08-19 00:25:00 +0000
192+++ autopilot/tests/functional/test_input_stack.py 2016-02-29 21:05:52 +0000
193@@ -43,8 +43,7 @@
194 )
195 from autopilot.display import Display
196 from autopilot.gestures import pinch
197-from autopilot.input import Keyboard, Mouse, Pointer, Touch
198-from autopilot.input._common import get_center_point
199+from autopilot.input import Keyboard, Mouse, Pointer, Touch, get_center_point
200 from autopilot.matchers import Eventually
201 from autopilot.testcase import AutopilotTestCase, multiply_scenarios
202 from autopilot.tests.functional import QmlScriptRunnerMixin
203
204=== modified file 'autopilot/tests/unit/test_input.py'
205--- autopilot/tests/unit/test_input.py 2015-07-07 22:50:24 +0000
206+++ autopilot/tests/unit/test_input.py 2016-02-29 21:05:52 +0000
207@@ -30,8 +30,7 @@
208 tests,
209 utilities
210 )
211-from autopilot.input import _uinput
212-from autopilot.input._common import get_center_point
213+from autopilot.input import _uinput, get_center_point
214
215
216 class Empty(object):

Subscribers

People subscribed via source and target branches