Merge lp:~chris.gagnon/autopilot/click_object into lp:autopilot

Proposed by Chris Gagnon
Status: Merged
Approved by: Thomi Richards
Approved revision: 208
Merged at revision: 215
Proposed branch: lp:~chris.gagnon/autopilot/click_object
Merge into: lp:autopilot
Diff against target: 70 lines (+40/-2)
2 files modified
autopilot/input/__init__.py (+39/-0)
autopilot/tests/functional/test_input_stack.py (+1/-2)
To merge this branch: bzr merge lp:~chris.gagnon/autopilot/click_object
Reviewer Review Type Date Requested Status
Thomi Richards (community) Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+163622@code.launchpad.net

Commit message

add click_object to mouse

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)
207. By Chris Gagnon

add click object

208. By Chris Gagnon

move click_object to base class

Revision history for this message
Thomi Richards (thomir-deactivatedaccount) wrote :

LGTM

review: Approve

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-05-21 03:22:47 +0000
+++ autopilot/input/__init__.py 2013-05-21 21:33:25 +0000
@@ -238,6 +238,24 @@
238 """Click mouse at current location."""238 """Click mouse at current location."""
239 raise NotImplementedError("You cannot use this class directly.")239 raise NotImplementedError("You cannot use this class directly.")
240240
241 def click_object(self, object_proxy, button=1, press_duration=0.10):
242 """Click the center point of a given object.
243
244 It does this by looking for several attributes, in order. The first
245 attribute found will be used. The attributes used are (in order):
246
247 * globalRect (x,y,w,h)
248 * center_x, center_y
249 * x, y, w, h
250
251 :raises: **ValueError** if none of these attributes are found, or if an
252 attribute is of an incorrect type.
253
254 """
255 self.move_to_object(object_proxy)
256 self.click(button, press_duration)
257
258
241 def move(self, x, y, animate=True, rate=10, time_between_events=0.01):259 def move(self, x, y, animate=True, rate=10, time_between_events=0.01):
242 """Moves mouse to location (x, y).260 """Moves mouse to location (x, y).
243261
@@ -473,6 +491,27 @@
473 self._x = x491 self._x = x
474 self._y = y492 self._y = y
475493
494 def click_object(self, object_proxy, button=1, press_duration=0.10):
495 """
496 Attempts to move the pointer to 'object_proxy's centre point.
497 and click a button
498
499 It does this by looking for several attributes, in order. The first
500 attribute found will be used. The attributes used are (in order):
501
502 * globalRect (x,y,w,h)
503 * center_x, center_y
504 * x, y, w, h
505
506 If the wrapped device is a mouse, the button specification is used. If
507 it is a touch device, passing anything other than 1 will raise a ValueError
508 exception.
509
510 """
511
512 self.move_to_object(object_proxy)
513 self.click(button, press_duration)
514
476 def move_to_object(self, object_proxy):515 def move_to_object(self, object_proxy):
477 """Attempts to move the pointer to 'object_proxy's centre point.516 """Attempts to move the pointer to 'object_proxy's centre point.
478517
479518
=== modified file 'autopilot/tests/functional/test_input_stack.py'
--- autopilot/tests/functional/test_input_stack.py 2013-05-21 04:38:09 +0000
+++ autopilot/tests/functional/test_input_stack.py 2013-05-21 21:33:25 +0000
@@ -88,8 +88,7 @@
88 text_edit = app_proxy.select_single('QTextEdit')88 text_edit = app_proxy.select_single('QTextEdit')
8989
90 # make sure the text edit has keyboard focus:90 # make sure the text edit has keyboard focus:
91 self.mouse.move_to_object(text_edit)91 self.mouse.click_object(text_edit)
92 self.mouse.click()
9392
94 # create keyboard and type the text.93 # create keyboard and type the text.
95 keyboard = Keyboard.create(self.backend)94 keyboard = Keyboard.create(self.backend)

Subscribers

People subscribed via source and target branches