Merge lp:~osomon/webbrowser-app/autopilot-more-robust into lp:webbrowser-app

Proposed by Olivier Tilloy
Status: Merged
Approved by: Günter Schwann
Approved revision: 164
Merged at revision: 164
Proposed branch: lp:~osomon/webbrowser-app/autopilot-more-robust
Merge into: lp:webbrowser-app
Diff against target: 227 lines (+39/-29)
7 files modified
tests/autopilot/webbrowser_app/tests/__init__.py (+9/-2)
tests/autopilot/webbrowser_app/tests/test_addressbar_action_button.py (+5/-4)
tests/autopilot/webbrowser_app/tests/test_addressbar_selection.py (+4/-4)
tests/autopilot/webbrowser_app/tests/test_addressbar_states.py (+1/-1)
tests/autopilot/webbrowser_app/tests/test_history.py (+9/-9)
tests/autopilot/webbrowser_app/tests/test_progressbar.py (+7/-5)
tests/autopilot/webbrowser_app/tests/test_title.py (+4/-4)
To merge this branch: bzr merge lp:~osomon/webbrowser-app/autopilot-more-robust
Reviewer Review Type Date Requested Status
Günter Schwann (community) Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+167770@code.launchpad.net

Commit message

Make as many test cases as possible inherit from StartOpenRemotePageTestCaseBase.

This should make them overall more robust by avoiding race conditions with the chrome automatically hiding when the homepage has finished loading.

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

129 - self.assertThat(listview.count, Eventually(Equals(6)))
130 + self.assertThat(listview.count, Eventually(Equals(7)))
Why does this value change?

Revision history for this message
Olivier Tilloy (osomon) wrote :

> 129 - self.assertThat(listview.count, Eventually(Equals(6)))
> 130 + self.assertThat(listview.count, Eventually(Equals(7)))
> Why does this value change?

Because with the new parent class, the homepage has finished loading when the test case starts, so the homepage has been added to the navigation history, and its URL contains a "u", which is what is being typed in the address bar, so as a consequence there is one more match in the suggestions list.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Günter Schwann (schwann) :
review: Approve

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-06-05 15:59:45 +0000
3+++ tests/autopilot/webbrowser_app/tests/__init__.py 2013-06-06 14:31:31 +0000
4@@ -222,8 +222,15 @@
5
6 class StartOpenRemotePageTestCaseBase(BrowserTestCaseBaseWithHTTPServer):
7
8- """Helper test class that opens the browser at a remote URL instead of
9- defaulting to the homepage."""
10+ """
11+ Helper test class that opens the browser at a remote URL instead of
12+ defaulting to the homepage.
13+
14+ This class should be preferred to the base test case class, as it doesn’t
15+ rely on a connection to the outside world (to open the default homepage),
16+ and because it ensures the initial page is fully loaded before the tests
17+ are executed, thus making them more robust.
18+ """
19
20 def setUp(self):
21 self.base_url = "http://localhost:%d" % HTTP_SERVER_PORT
22
23=== modified file 'tests/autopilot/webbrowser_app/tests/test_addressbar_action_button.py'
24--- tests/autopilot/webbrowser_app/tests/test_addressbar_action_button.py 2013-05-24 16:55:59 +0000
25+++ tests/autopilot/webbrowser_app/tests/test_addressbar_action_button.py 2013-06-06 14:31:31 +0000
26@@ -11,12 +11,13 @@
27 from testtools.matchers import Equals
28 from autopilot.matchers import Eventually
29
30-from webbrowser_app.tests import BrowserTestCaseBase
31-
32-
33-class TestMainWindowAddressBarActionButton(BrowserTestCaseBase):
34+from webbrowser_app.tests import StartOpenRemotePageTestCaseBase
35+
36+
37+class TestMainWindowAddressBarActionButton(StartOpenRemotePageTestCaseBase):
38
39 def test_button_disabled_when_text_is_empty(self):
40+ self.assert_chrome_eventually_hidden()
41 self.reveal_chrome()
42 self.clear_address_bar()
43 action_button = self.main_window.get_address_bar_action_button()
44
45=== modified file 'tests/autopilot/webbrowser_app/tests/test_addressbar_selection.py'
46--- tests/autopilot/webbrowser_app/tests/test_addressbar_selection.py 2013-05-14 15:14:11 +0000
47+++ tests/autopilot/webbrowser_app/tests/test_addressbar_selection.py 2013-06-06 14:31:31 +0000
48@@ -21,7 +21,7 @@
49 """Test the address bar selection"""
50
51 def test_click_to_select(self):
52- self.ensure_chrome_is_hidden()
53+ self.assert_chrome_eventually_hidden()
54 self.reveal_chrome()
55 address_bar = self.main_window.get_address_bar()
56 self.pointing_device.move_to_object(address_bar)
57@@ -31,7 +31,7 @@
58 Eventually(Equals(text_field.text)))
59
60 def test_click_on_action_button(self):
61- self.ensure_chrome_is_hidden()
62+ self.assert_chrome_eventually_hidden()
63 self.reveal_chrome()
64 action_button = self.main_window.get_address_bar_action_button()
65 self.pointing_device.move_to_object(action_button)
66@@ -40,7 +40,7 @@
67 self.assertThat(text_field.selectedText, Eventually(Equals("")))
68
69 def test_second_click_deselect_text(self):
70- self.ensure_chrome_is_hidden()
71+ self.assert_chrome_eventually_hidden()
72 self.reveal_chrome()
73 address_bar = self.main_window.get_address_bar()
74 self.pointing_device.move_to_object(address_bar)
75@@ -53,7 +53,7 @@
76 self.assertThat(text_field.cursorPosition, Eventually(GreaterThan(0)))
77
78 def test_double_click_select_word(self):
79- self.ensure_chrome_is_hidden()
80+ self.assert_chrome_eventually_hidden()
81 self.reveal_chrome()
82 address_bar = self.main_window.get_address_bar()
83 self.pointing_device.move_to_object(address_bar)
84
85=== modified file 'tests/autopilot/webbrowser_app/tests/test_addressbar_states.py'
86--- tests/autopilot/webbrowser_app/tests/test_addressbar_states.py 2013-05-20 11:45:18 +0000
87+++ tests/autopilot/webbrowser_app/tests/test_addressbar_states.py 2013-06-06 14:31:31 +0000
88@@ -43,7 +43,7 @@
89
90 def test_state_editing(self):
91 address_bar = self.main_window.get_address_bar()
92- self.ensure_chrome_is_hidden()
93+ self.assert_chrome_eventually_hidden()
94 self.reveal_chrome()
95 self.pointing_device.move_to_object(address_bar)
96 self.pointing_device.click()
97
98=== modified file 'tests/autopilot/webbrowser_app/tests/test_history.py'
99--- tests/autopilot/webbrowser_app/tests/test_history.py 2013-06-06 07:24:00 +0000
100+++ tests/autopilot/webbrowser_app/tests/test_history.py 2013-06-06 14:31:31 +0000
101@@ -16,10 +16,10 @@
102 from testtools.matchers import Contains, Equals
103 from autopilot.matchers import Eventually
104
105-from webbrowser_app.tests import BrowserTestCaseBase
106-
107-
108-class PrepopulatedHistoryDatabaseTestCaseBase(BrowserTestCaseBase):
109+from webbrowser_app.tests import StartOpenRemotePageTestCaseBase
110+
111+
112+class PrepopulatedHistoryDatabaseTestCaseBase(StartOpenRemotePageTestCaseBase):
113
114 """Helper test class that pre-populates the history database."""
115
116@@ -64,7 +64,7 @@
117 suggestions = self.main_window.get_address_bar_suggestions()
118 listview = self.main_window.get_address_bar_suggestions_listview()
119 self.assertThat(suggestions.visible, Equals(False))
120- self.ensure_chrome_is_hidden()
121+ self.assert_chrome_eventually_hidden()
122 self.reveal_chrome()
123 self.assertThat(suggestions.visible, Equals(False))
124 self.focus_address_bar()
125@@ -74,7 +74,7 @@
126 self.assertThat(suggestions.visible, Eventually(Equals(False)))
127 self.type_in_address_bar("u")
128 self.assertThat(suggestions.visible, Eventually(Equals(True)))
129- self.assertThat(listview.count, Eventually(Equals(6)))
130+ self.assertThat(listview.count, Eventually(Equals(7)))
131 self.type_in_address_bar("b")
132 self.assertThat(listview.count, Eventually(Equals(5)))
133 self.type_in_address_bar("leh")
134@@ -85,7 +85,7 @@
135
136 def test_clear_address_bar_dismisses_suggestions(self):
137 suggestions = self.main_window.get_address_bar_suggestions()
138- self.ensure_chrome_is_hidden()
139+ self.assert_chrome_eventually_hidden()
140 self.reveal_chrome()
141 self.focus_address_bar()
142 self.assertThat(suggestions.visible, Eventually(Equals(True)))
143@@ -97,7 +97,7 @@
144
145 def test_addressbar_loosing_focus_dismisses_suggestions(self):
146 suggestions = self.main_window.get_address_bar_suggestions()
147- self.ensure_chrome_is_hidden()
148+ self.assert_chrome_eventually_hidden()
149 self.reveal_chrome()
150 self.focus_address_bar()
151 self.assertThat(suggestions.visible, Eventually(Equals(True)))
152@@ -112,7 +112,7 @@
153 def test_select_suggestion(self):
154 suggestions = self.main_window.get_address_bar_suggestions()
155 listview = self.main_window.get_address_bar_suggestions_listview()
156- self.ensure_chrome_is_hidden()
157+ self.assert_chrome_eventually_hidden()
158 self.reveal_chrome()
159 self.focus_address_bar()
160 self.assertThat(suggestions.visible, Eventually(Equals(True)))
161
162=== modified file 'tests/autopilot/webbrowser_app/tests/test_progressbar.py'
163--- tests/autopilot/webbrowser_app/tests/test_progressbar.py 2013-06-05 15:59:45 +0000
164+++ tests/autopilot/webbrowser_app/tests/test_progressbar.py 2013-06-06 14:31:31 +0000
165@@ -12,7 +12,9 @@
166 from autopilot.matchers import Eventually
167
168 from webbrowser_app.tests import \
169- BrowserTestCaseBaseWithHTTPServer, HTTP_SERVER_PORT
170+ BrowserTestCaseBaseWithHTTPServer, \
171+ StartOpenRemotePageTestCaseBase, \
172+ HTTP_SERVER_PORT
173
174
175 LOREMIPSUM = "<p>Lorem ipsum dolor sit amet.</p>"
176@@ -35,13 +37,13 @@
177 self.assert_chrome_eventually_hidden()
178
179
180-class TestProgressBar(BrowserTestCaseBaseWithHTTPServer):
181+class TestProgressBar(StartOpenRemotePageTestCaseBase):
182
183 """Tests that the progress bar (embedded inside the address bar) is
184 visible when a page is loading and hidden by default otherwise."""
185
186 def test_chrome_hides_when_loaded(self):
187- self.ensure_chrome_is_hidden()
188+ self.assert_chrome_eventually_hidden()
189 url = "http://localhost:%d/wait/3" % HTTP_SERVER_PORT
190 self.go_to_url(url)
191 self.assert_chrome_eventually_shown()
192@@ -67,7 +69,7 @@
193 def test_hide_chrome_while_loading(self):
194 # simulate user interaction to hide the chrome while loading,
195 # and ensure it doesn’t re-appear when loaded
196- self.ensure_chrome_is_hidden()
197+ self.assert_chrome_eventually_hidden()
198 url = "http://localhost:%d/wait/3" % HTTP_SERVER_PORT
199 self.go_to_url(url)
200 self.assert_chrome_eventually_shown()
201@@ -81,7 +83,7 @@
202 def test_stop_loading(self):
203 # ensure that the chrome is not automatically hidden
204 # when the user interrupts a page that was loading
205- self.ensure_chrome_is_hidden()
206+ self.assert_chrome_eventually_hidden()
207 url = "http://localhost:%d/wait/5" % HTTP_SERVER_PORT
208 self.go_to_url(url)
209 self.assert_page_eventually_loading()
210
211=== modified file 'tests/autopilot/webbrowser_app/tests/test_title.py'
212--- tests/autopilot/webbrowser_app/tests/test_title.py 2013-05-24 16:54:50 +0000
213+++ tests/autopilot/webbrowser_app/tests/test_title.py 2013-06-06 14:31:31 +0000
214@@ -11,10 +11,10 @@
215 from testtools.matchers import Equals
216 from autopilot.matchers import Eventually
217
218-from webbrowser_app.tests import BrowserTestCaseBase
219-
220-
221-class TestWindowTitle(BrowserTestCaseBase):
222+from webbrowser_app.tests import StartOpenRemotePageTestCaseBase
223+
224+
225+class TestWindowTitle(StartOpenRemotePageTestCaseBase):
226
227 """Tests that the window’s title reflects the page title."""
228

Subscribers

People subscribed via source and target branches

to status/vote changes: