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
=== modified file 'tests/autopilot/webbrowser_app/tests/__init__.py'
--- tests/autopilot/webbrowser_app/tests/__init__.py 2013-06-05 15:59:45 +0000
+++ tests/autopilot/webbrowser_app/tests/__init__.py 2013-06-06 14:31:31 +0000
@@ -222,8 +222,15 @@
222222
223class StartOpenRemotePageTestCaseBase(BrowserTestCaseBaseWithHTTPServer):223class StartOpenRemotePageTestCaseBase(BrowserTestCaseBaseWithHTTPServer):
224224
225 """Helper test class that opens the browser at a remote URL instead of225 """
226 defaulting to the homepage."""226 Helper test class that opens the browser at a remote URL instead of
227 defaulting to the homepage.
228
229 This class should be preferred to the base test case class, as it doesn’t
230 rely on a connection to the outside world (to open the default homepage),
231 and because it ensures the initial page is fully loaded before the tests
232 are executed, thus making them more robust.
233 """
227234
228 def setUp(self):235 def setUp(self):
229 self.base_url = "http://localhost:%d" % HTTP_SERVER_PORT236 self.base_url = "http://localhost:%d" % HTTP_SERVER_PORT
230237
=== modified file 'tests/autopilot/webbrowser_app/tests/test_addressbar_action_button.py'
--- tests/autopilot/webbrowser_app/tests/test_addressbar_action_button.py 2013-05-24 16:55:59 +0000
+++ tests/autopilot/webbrowser_app/tests/test_addressbar_action_button.py 2013-06-06 14:31:31 +0000
@@ -11,12 +11,13 @@
11from testtools.matchers import Equals11from testtools.matchers import Equals
12from autopilot.matchers import Eventually12from autopilot.matchers import Eventually
1313
14from webbrowser_app.tests import BrowserTestCaseBase14from webbrowser_app.tests import StartOpenRemotePageTestCaseBase
1515
1616
17class TestMainWindowAddressBarActionButton(BrowserTestCaseBase):17class TestMainWindowAddressBarActionButton(StartOpenRemotePageTestCaseBase):
1818
19 def test_button_disabled_when_text_is_empty(self):19 def test_button_disabled_when_text_is_empty(self):
20 self.assert_chrome_eventually_hidden()
20 self.reveal_chrome()21 self.reveal_chrome()
21 self.clear_address_bar()22 self.clear_address_bar()
22 action_button = self.main_window.get_address_bar_action_button()23 action_button = self.main_window.get_address_bar_action_button()
2324
=== modified file 'tests/autopilot/webbrowser_app/tests/test_addressbar_selection.py'
--- tests/autopilot/webbrowser_app/tests/test_addressbar_selection.py 2013-05-14 15:14:11 +0000
+++ tests/autopilot/webbrowser_app/tests/test_addressbar_selection.py 2013-06-06 14:31:31 +0000
@@ -21,7 +21,7 @@
21 """Test the address bar selection"""21 """Test the address bar selection"""
2222
23 def test_click_to_select(self):23 def test_click_to_select(self):
24 self.ensure_chrome_is_hidden()24 self.assert_chrome_eventually_hidden()
25 self.reveal_chrome()25 self.reveal_chrome()
26 address_bar = self.main_window.get_address_bar()26 address_bar = self.main_window.get_address_bar()
27 self.pointing_device.move_to_object(address_bar)27 self.pointing_device.move_to_object(address_bar)
@@ -31,7 +31,7 @@
31 Eventually(Equals(text_field.text)))31 Eventually(Equals(text_field.text)))
3232
33 def test_click_on_action_button(self):33 def test_click_on_action_button(self):
34 self.ensure_chrome_is_hidden()34 self.assert_chrome_eventually_hidden()
35 self.reveal_chrome()35 self.reveal_chrome()
36 action_button = self.main_window.get_address_bar_action_button()36 action_button = self.main_window.get_address_bar_action_button()
37 self.pointing_device.move_to_object(action_button)37 self.pointing_device.move_to_object(action_button)
@@ -40,7 +40,7 @@
40 self.assertThat(text_field.selectedText, Eventually(Equals("")))40 self.assertThat(text_field.selectedText, Eventually(Equals("")))
4141
42 def test_second_click_deselect_text(self):42 def test_second_click_deselect_text(self):
43 self.ensure_chrome_is_hidden()43 self.assert_chrome_eventually_hidden()
44 self.reveal_chrome()44 self.reveal_chrome()
45 address_bar = self.main_window.get_address_bar()45 address_bar = self.main_window.get_address_bar()
46 self.pointing_device.move_to_object(address_bar)46 self.pointing_device.move_to_object(address_bar)
@@ -53,7 +53,7 @@
53 self.assertThat(text_field.cursorPosition, Eventually(GreaterThan(0)))53 self.assertThat(text_field.cursorPosition, Eventually(GreaterThan(0)))
5454
55 def test_double_click_select_word(self):55 def test_double_click_select_word(self):
56 self.ensure_chrome_is_hidden()56 self.assert_chrome_eventually_hidden()
57 self.reveal_chrome()57 self.reveal_chrome()
58 address_bar = self.main_window.get_address_bar()58 address_bar = self.main_window.get_address_bar()
59 self.pointing_device.move_to_object(address_bar)59 self.pointing_device.move_to_object(address_bar)
6060
=== modified file 'tests/autopilot/webbrowser_app/tests/test_addressbar_states.py'
--- tests/autopilot/webbrowser_app/tests/test_addressbar_states.py 2013-05-20 11:45:18 +0000
+++ tests/autopilot/webbrowser_app/tests/test_addressbar_states.py 2013-06-06 14:31:31 +0000
@@ -43,7 +43,7 @@
4343
44 def test_state_editing(self):44 def test_state_editing(self):
45 address_bar = self.main_window.get_address_bar()45 address_bar = self.main_window.get_address_bar()
46 self.ensure_chrome_is_hidden()46 self.assert_chrome_eventually_hidden()
47 self.reveal_chrome()47 self.reveal_chrome()
48 self.pointing_device.move_to_object(address_bar)48 self.pointing_device.move_to_object(address_bar)
49 self.pointing_device.click()49 self.pointing_device.click()
5050
=== modified file 'tests/autopilot/webbrowser_app/tests/test_history.py'
--- tests/autopilot/webbrowser_app/tests/test_history.py 2013-06-06 07:24:00 +0000
+++ tests/autopilot/webbrowser_app/tests/test_history.py 2013-06-06 14:31:31 +0000
@@ -16,10 +16,10 @@
16from testtools.matchers import Contains, Equals16from testtools.matchers import Contains, Equals
17from autopilot.matchers import Eventually17from autopilot.matchers import Eventually
1818
19from webbrowser_app.tests import BrowserTestCaseBase19from webbrowser_app.tests import StartOpenRemotePageTestCaseBase
2020
2121
22class PrepopulatedHistoryDatabaseTestCaseBase(BrowserTestCaseBase):22class PrepopulatedHistoryDatabaseTestCaseBase(StartOpenRemotePageTestCaseBase):
2323
24 """Helper test class that pre-populates the history database."""24 """Helper test class that pre-populates the history database."""
2525
@@ -64,7 +64,7 @@
64 suggestions = self.main_window.get_address_bar_suggestions()64 suggestions = self.main_window.get_address_bar_suggestions()
65 listview = self.main_window.get_address_bar_suggestions_listview()65 listview = self.main_window.get_address_bar_suggestions_listview()
66 self.assertThat(suggestions.visible, Equals(False))66 self.assertThat(suggestions.visible, Equals(False))
67 self.ensure_chrome_is_hidden()67 self.assert_chrome_eventually_hidden()
68 self.reveal_chrome()68 self.reveal_chrome()
69 self.assertThat(suggestions.visible, Equals(False))69 self.assertThat(suggestions.visible, Equals(False))
70 self.focus_address_bar()70 self.focus_address_bar()
@@ -74,7 +74,7 @@
74 self.assertThat(suggestions.visible, Eventually(Equals(False)))74 self.assertThat(suggestions.visible, Eventually(Equals(False)))
75 self.type_in_address_bar("u")75 self.type_in_address_bar("u")
76 self.assertThat(suggestions.visible, Eventually(Equals(True)))76 self.assertThat(suggestions.visible, Eventually(Equals(True)))
77 self.assertThat(listview.count, Eventually(Equals(6)))77 self.assertThat(listview.count, Eventually(Equals(7)))
78 self.type_in_address_bar("b")78 self.type_in_address_bar("b")
79 self.assertThat(listview.count, Eventually(Equals(5)))79 self.assertThat(listview.count, Eventually(Equals(5)))
80 self.type_in_address_bar("leh")80 self.type_in_address_bar("leh")
@@ -85,7 +85,7 @@
8585
86 def test_clear_address_bar_dismisses_suggestions(self):86 def test_clear_address_bar_dismisses_suggestions(self):
87 suggestions = self.main_window.get_address_bar_suggestions()87 suggestions = self.main_window.get_address_bar_suggestions()
88 self.ensure_chrome_is_hidden()88 self.assert_chrome_eventually_hidden()
89 self.reveal_chrome()89 self.reveal_chrome()
90 self.focus_address_bar()90 self.focus_address_bar()
91 self.assertThat(suggestions.visible, Eventually(Equals(True)))91 self.assertThat(suggestions.visible, Eventually(Equals(True)))
@@ -97,7 +97,7 @@
9797
98 def test_addressbar_loosing_focus_dismisses_suggestions(self):98 def test_addressbar_loosing_focus_dismisses_suggestions(self):
99 suggestions = self.main_window.get_address_bar_suggestions()99 suggestions = self.main_window.get_address_bar_suggestions()
100 self.ensure_chrome_is_hidden()100 self.assert_chrome_eventually_hidden()
101 self.reveal_chrome()101 self.reveal_chrome()
102 self.focus_address_bar()102 self.focus_address_bar()
103 self.assertThat(suggestions.visible, Eventually(Equals(True)))103 self.assertThat(suggestions.visible, Eventually(Equals(True)))
@@ -112,7 +112,7 @@
112 def test_select_suggestion(self):112 def test_select_suggestion(self):
113 suggestions = self.main_window.get_address_bar_suggestions()113 suggestions = self.main_window.get_address_bar_suggestions()
114 listview = self.main_window.get_address_bar_suggestions_listview()114 listview = self.main_window.get_address_bar_suggestions_listview()
115 self.ensure_chrome_is_hidden()115 self.assert_chrome_eventually_hidden()
116 self.reveal_chrome()116 self.reveal_chrome()
117 self.focus_address_bar()117 self.focus_address_bar()
118 self.assertThat(suggestions.visible, Eventually(Equals(True)))118 self.assertThat(suggestions.visible, Eventually(Equals(True)))
119119
=== modified file 'tests/autopilot/webbrowser_app/tests/test_progressbar.py'
--- tests/autopilot/webbrowser_app/tests/test_progressbar.py 2013-06-05 15:59:45 +0000
+++ tests/autopilot/webbrowser_app/tests/test_progressbar.py 2013-06-06 14:31:31 +0000
@@ -12,7 +12,9 @@
12from autopilot.matchers import Eventually12from autopilot.matchers import Eventually
1313
14from webbrowser_app.tests import \14from webbrowser_app.tests import \
15 BrowserTestCaseBaseWithHTTPServer, HTTP_SERVER_PORT15 BrowserTestCaseBaseWithHTTPServer, \
16 StartOpenRemotePageTestCaseBase, \
17 HTTP_SERVER_PORT
1618
1719
18LOREMIPSUM = "<p>Lorem ipsum dolor sit amet.</p>"20LOREMIPSUM = "<p>Lorem ipsum dolor sit amet.</p>"
@@ -35,13 +37,13 @@
35 self.assert_chrome_eventually_hidden()37 self.assert_chrome_eventually_hidden()
3638
3739
38class TestProgressBar(BrowserTestCaseBaseWithHTTPServer):40class TestProgressBar(StartOpenRemotePageTestCaseBase):
3941
40 """Tests that the progress bar (embedded inside the address bar) is42 """Tests that the progress bar (embedded inside the address bar) is
41 visible when a page is loading and hidden by default otherwise."""43 visible when a page is loading and hidden by default otherwise."""
4244
43 def test_chrome_hides_when_loaded(self):45 def test_chrome_hides_when_loaded(self):
44 self.ensure_chrome_is_hidden()46 self.assert_chrome_eventually_hidden()
45 url = "http://localhost:%d/wait/3" % HTTP_SERVER_PORT47 url = "http://localhost:%d/wait/3" % HTTP_SERVER_PORT
46 self.go_to_url(url)48 self.go_to_url(url)
47 self.assert_chrome_eventually_shown()49 self.assert_chrome_eventually_shown()
@@ -67,7 +69,7 @@
67 def test_hide_chrome_while_loading(self):69 def test_hide_chrome_while_loading(self):
68 # simulate user interaction to hide the chrome while loading,70 # simulate user interaction to hide the chrome while loading,
69 # and ensure it doesn’t re-appear when loaded71 # and ensure it doesn’t re-appear when loaded
70 self.ensure_chrome_is_hidden()72 self.assert_chrome_eventually_hidden()
71 url = "http://localhost:%d/wait/3" % HTTP_SERVER_PORT73 url = "http://localhost:%d/wait/3" % HTTP_SERVER_PORT
72 self.go_to_url(url)74 self.go_to_url(url)
73 self.assert_chrome_eventually_shown()75 self.assert_chrome_eventually_shown()
@@ -81,7 +83,7 @@
81 def test_stop_loading(self):83 def test_stop_loading(self):
82 # ensure that the chrome is not automatically hidden84 # ensure that the chrome is not automatically hidden
83 # when the user interrupts a page that was loading85 # when the user interrupts a page that was loading
84 self.ensure_chrome_is_hidden()86 self.assert_chrome_eventually_hidden()
85 url = "http://localhost:%d/wait/5" % HTTP_SERVER_PORT87 url = "http://localhost:%d/wait/5" % HTTP_SERVER_PORT
86 self.go_to_url(url)88 self.go_to_url(url)
87 self.assert_page_eventually_loading()89 self.assert_page_eventually_loading()
8890
=== modified file 'tests/autopilot/webbrowser_app/tests/test_title.py'
--- tests/autopilot/webbrowser_app/tests/test_title.py 2013-05-24 16:54:50 +0000
+++ tests/autopilot/webbrowser_app/tests/test_title.py 2013-06-06 14:31:31 +0000
@@ -11,10 +11,10 @@
11from testtools.matchers import Equals11from testtools.matchers import Equals
12from autopilot.matchers import Eventually12from autopilot.matchers import Eventually
1313
14from webbrowser_app.tests import BrowserTestCaseBase14from webbrowser_app.tests import StartOpenRemotePageTestCaseBase
1515
1616
17class TestWindowTitle(BrowserTestCaseBase):17class TestWindowTitle(StartOpenRemotePageTestCaseBase):
1818
19 """Tests that the window’s title reflects the page title."""19 """Tests that the window’s title reflects the page title."""
2020

Subscribers

People subscribed via source and target branches

to status/vote changes: