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
1=== modified file 'autopilot/input/__init__.py'
2--- autopilot/input/__init__.py 2013-05-21 03:22:47 +0000
3+++ autopilot/input/__init__.py 2013-05-21 21:33:25 +0000
4@@ -238,6 +238,24 @@
5 """Click mouse at current location."""
6 raise NotImplementedError("You cannot use this class directly.")
7
8+ def click_object(self, object_proxy, button=1, press_duration=0.10):
9+ """Click the center point of a given object.
10+
11+ It does this by looking for several attributes, in order. The first
12+ attribute found will be used. The attributes used are (in order):
13+
14+ * globalRect (x,y,w,h)
15+ * center_x, center_y
16+ * x, y, w, h
17+
18+ :raises: **ValueError** if none of these attributes are found, or if an
19+ attribute is of an incorrect type.
20+
21+ """
22+ self.move_to_object(object_proxy)
23+ self.click(button, press_duration)
24+
25+
26 def move(self, x, y, animate=True, rate=10, time_between_events=0.01):
27 """Moves mouse to location (x, y).
28
29@@ -473,6 +491,27 @@
30 self._x = x
31 self._y = y
32
33+ def click_object(self, object_proxy, button=1, press_duration=0.10):
34+ """
35+ Attempts to move the pointer to 'object_proxy's centre point.
36+ and click a button
37+
38+ It does this by looking for several attributes, in order. The first
39+ attribute found will be used. The attributes used are (in order):
40+
41+ * globalRect (x,y,w,h)
42+ * center_x, center_y
43+ * x, y, w, h
44+
45+ If the wrapped device is a mouse, the button specification is used. If
46+ it is a touch device, passing anything other than 1 will raise a ValueError
47+ exception.
48+
49+ """
50+
51+ self.move_to_object(object_proxy)
52+ self.click(button, press_duration)
53+
54 def move_to_object(self, object_proxy):
55 """Attempts to move the pointer to 'object_proxy's centre point.
56
57
58=== modified file 'autopilot/tests/functional/test_input_stack.py'
59--- autopilot/tests/functional/test_input_stack.py 2013-05-21 04:38:09 +0000
60+++ autopilot/tests/functional/test_input_stack.py 2013-05-21 21:33:25 +0000
61@@ -88,8 +88,7 @@
62 text_edit = app_proxy.select_single('QTextEdit')
63
64 # make sure the text edit has keyboard focus:
65- self.mouse.move_to_object(text_edit)
66- self.mouse.click()
67+ self.mouse.click_object(text_edit)
68
69 # create keyboard and type the text.
70 keyboard = Keyboard.create(self.backend)

Subscribers

People subscribed via source and target branches