Merge lp:~osomon/webbrowser-app/type_in_addressbar-helper into lp:webbrowser-app

Proposed by Olivier Tilloy
Status: Merged
Approved by: Olivier Tilloy
Approved revision: 143
Merged at revision: 142
Proposed branch: lp:~osomon/webbrowser-app/type_in_addressbar-helper
Merge into: lp:webbrowser-app
Diff against target: 147 lines (+22/-26)
4 files modified
tests/autopilot/webbrowser_app/tests/__init__.py (+10/-4)
tests/autopilot/webbrowser_app/tests/test_addressbar_action_button.py (+2/-2)
tests/autopilot/webbrowser_app/tests/test_history.py (+8/-7)
tests/autopilot/webbrowser_app/tests/test_title.py (+2/-13)
To merge this branch: bzr merge lp:~osomon/webbrowser-app/type_in_addressbar-helper
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Günter Schwann (community) Approve
Review via email: mp+165670@code.launchpad.net

Commit message

Define a type_in_address_bar helper method that asserts that the text has actually been input in the address bar before continuing.

This should make autopilot tests more reliable on slow machines.

To post a comment you must log in.
Revision history for this message
Günter Schwann (schwann) wrote :

looks good

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/autopilot/webbrowser_app/tests/__init__.py'
2--- tests/autopilot/webbrowser_app/tests/__init__.py 2013-05-20 18:15:26 +0000
3+++ tests/autopilot/webbrowser_app/tests/__init__.py 2013-05-24 16:58:30 +0000
4@@ -12,7 +12,7 @@
5 import shutil
6 import tempfile
7
8-from testtools.matchers import Equals
9+from testtools.matchers import Contains, Equals
10
11 from autopilot.input import Mouse, Touch, Pointer
12 from autopilot.matchers import Eventually
13@@ -143,6 +143,7 @@
14 address_bar = self.main_window.get_address_bar()
15 self.pointing_device.move_to_object(address_bar)
16 self.pointing_device.click()
17+ self.assertThat(address_bar.activeFocus, Eventually(Equals(True)))
18
19 def clear_address_bar(self):
20 self.focus_address_bar()
21@@ -159,13 +160,18 @@
22 self.assertThat(lambda: chrome.globalRect[1],
23 Eventually(Equals(expected_y)))
24
25+ def type_in_address_bar(self, text):
26+ address_bar = self.main_window.get_address_bar()
27+ self.assertThat(address_bar.activeFocus, Eventually(Equals(True)))
28+ self.keyboard.type(text, delay=TYPING_DELAY)
29+ text_field = self.main_window.get_address_bar_text_field()
30+ self.assertThat(text_field.text, Eventually(Contains(text)))
31+
32 def go_to_url(self, url):
33 self.ensure_chrome_is_hidden()
34 self.reveal_chrome()
35 self.clear_address_bar()
36- self.keyboard.type(url, delay=TYPING_DELAY)
37- text_field = self.main_window.get_address_bar_text_field()
38- self.assertThat(text_field.text, Eventually(Equals(url)))
39+ self.type_in_address_bar(url)
40 self.keyboard.press_and_release("Enter")
41
42 def assert_page_eventually_loading(self):
43
44=== modified file 'tests/autopilot/webbrowser_app/tests/test_addressbar_action_button.py'
45--- tests/autopilot/webbrowser_app/tests/test_addressbar_action_button.py 2013-05-16 07:53:16 +0000
46+++ tests/autopilot/webbrowser_app/tests/test_addressbar_action_button.py 2013-05-24 16:58:30 +0000
47@@ -11,7 +11,7 @@
48 from testtools.matchers import Equals
49 from autopilot.matchers import Eventually
50
51-from webbrowser_app.tests import BrowserTestCaseBase, TYPING_DELAY
52+from webbrowser_app.tests import BrowserTestCaseBase
53
54
55 class TestMainWindowAddressBarActionButton(BrowserTestCaseBase):
56@@ -21,5 +21,5 @@
57 self.clear_address_bar()
58 action_button = self.main_window.get_address_bar_action_button()
59 self.assertThat(action_button.enabled, Eventually(Equals(False)))
60- self.keyboard.type("ubuntu", delay=TYPING_DELAY)
61+ self.type_in_address_bar("ubuntu")
62 self.assertThat(action_button.enabled, Eventually(Equals(True)))
63
64=== modified file 'tests/autopilot/webbrowser_app/tests/test_history.py'
65--- tests/autopilot/webbrowser_app/tests/test_history.py 2013-05-20 11:45:18 +0000
66+++ tests/autopilot/webbrowser_app/tests/test_history.py 2013-05-24 16:58:30 +0000
67@@ -16,7 +16,7 @@
68 from testtools.matchers import Equals
69 from autopilot.matchers import Eventually
70
71-from webbrowser_app.tests import BrowserTestCaseBase, TYPING_DELAY
72+from webbrowser_app.tests import BrowserTestCaseBase
73
74
75 class PrepopulatedHistoryDatabaseTestCaseBase(BrowserTestCaseBase):
76@@ -72,15 +72,15 @@
77 self.assertThat(listview.count, Eventually(Equals(1)))
78 self.clear_address_bar()
79 self.assertThat(suggestions.visible, Eventually(Equals(False)))
80- self.keyboard.type("u", delay=TYPING_DELAY)
81+ self.type_in_address_bar("u")
82 self.assertThat(suggestions.visible, Eventually(Equals(True)))
83 self.assertThat(listview.count, Eventually(Equals(6)))
84- self.keyboard.type("b", delay=TYPING_DELAY)
85+ self.type_in_address_bar("b")
86 self.assertThat(listview.count, Eventually(Equals(5)))
87- self.keyboard.type("leh", delay=TYPING_DELAY)
88+ self.type_in_address_bar("leh")
89 self.assertThat(listview.count, Eventually(Equals(0)))
90 self.clear_address_bar()
91- self.keyboard.type("xaMPL", delay=TYPING_DELAY)
92+ self.type_in_address_bar("xaMPL")
93 self.assertThat(listview.count, Eventually(Equals(2)))
94
95 def test_clear_address_bar_dismisses_suggestions(self):
96@@ -90,7 +90,7 @@
97 self.focus_address_bar()
98 self.assertThat(suggestions.visible, Eventually(Equals(True)))
99 self.clear_address_bar()
100- self.keyboard.type("ubuntu", delay=TYPING_DELAY)
101+ self.type_in_address_bar("ubuntu")
102 self.assertThat(suggestions.visible, Eventually(Equals(True)))
103 self.clear_address_bar()
104 self.assertThat(suggestions.visible, Eventually(Equals(False)))
105@@ -117,7 +117,8 @@
106 self.focus_address_bar()
107 self.assertThat(suggestions.visible, Eventually(Equals(True)))
108 self.clear_address_bar()
109- self.keyboard.type("ubuntu", delay=TYPING_DELAY)
110+ self.type_in_address_bar("ubuntu")
111+ self.assertThat(suggestions.visible, Eventually(Equals(True)))
112 self.assertThat(listview.count, Eventually(Equals(5)))
113 entries = \
114 self.main_window.get_address_bar_suggestions_listview_entries()
115
116=== modified file 'tests/autopilot/webbrowser_app/tests/test_title.py'
117--- tests/autopilot/webbrowser_app/tests/test_title.py 2013-05-20 11:45:18 +0000
118+++ tests/autopilot/webbrowser_app/tests/test_title.py 2013-05-24 16:58:30 +0000
119@@ -11,7 +11,7 @@
120 from testtools.matchers import Equals
121 from autopilot.matchers import Eventually
122
123-from webbrowser_app.tests import BrowserTestCaseBase, TYPING_DELAY
124+from webbrowser_app.tests import BrowserTestCaseBase
125
126
127 class TestWindowTitle(BrowserTestCaseBase):
128@@ -22,18 +22,7 @@
129 title = "Alice in Wonderland"
130 body = "<p>Lorem ipsum dolor sit amet.</p>"
131 url = self.make_html_page(title, body)
132- self.ensure_chrome_is_hidden()
133- self.reveal_chrome()
134- address_bar = self.main_window.get_address_bar()
135- self.pointing_device.move_to_object(address_bar)
136- self.pointing_device.click()
137- clear_button = self.main_window.get_address_bar_clear_button()
138- self.pointing_device.move_to_object(clear_button)
139- self.pointing_device.click()
140- self.pointing_device.move_to_object(address_bar)
141- self.pointing_device.click()
142- self.keyboard.type(url, delay=TYPING_DELAY)
143- self.keyboard.press_and_release("Enter")
144+ self.go_to_url(url)
145 window = self.main_window.get_qml_view()
146 title = "Alice in Wonderland - Ubuntu Web Browser"
147 self.assertThat(window.title, Eventually(Equals(title)))

Subscribers

People subscribed via source and target branches

to status/vote changes: