Merge lp:~canonical-platform-qa/webbrowser-app/autopilot-back-forward into lp:webbrowser-app

Proposed by Leo Arias
Status: Merged
Approved by: Olivier Tilloy
Approved revision: 852
Merged at revision: 859
Proposed branch: lp:~canonical-platform-qa/webbrowser-app/autopilot-back-forward
Merge into: lp:webbrowser-app
Prerequisite: lp:~canonical-platform-qa/webbrowser-app/autopilot-address_bar-textfield
Diff against target: 280 lines (+77/-55)
10 files modified
tests/autopilot/webbrowser_app/emulators/browser.py (+38/-5)
tests/autopilot/webbrowser_app/tests/__init__.py (+1/-13)
tests/autopilot/webbrowser_app/tests/test_addressbar_bookmark.py (+1/-1)
tests/autopilot/webbrowser_app/tests/test_backforward.py (+26/-23)
tests/autopilot/webbrowser_app/tests/test_content_pick.py (+1/-1)
tests/autopilot/webbrowser_app/tests/test_errorsheet.py (+5/-7)
tests/autopilot/webbrowser_app/tests/test_fullscreen.py (+1/-1)
tests/autopilot/webbrowser_app/tests/test_geolocation.py (+1/-1)
tests/autopilot/webbrowser_app/tests/test_selection.py (+1/-1)
tests/autopilot/webbrowser_app/tests/test_tabs.py (+2/-2)
To merge this branch: bzr merge lp:~canonical-platform-qa/webbrowser-app/autopilot-back-forward
Reviewer Review Type Date Requested Status
Olivier Tilloy Approve
PS Jenkins bot continuous-integration Needs Fixing
Allan LeSage (community) Approve
Richard Huddie (community) Approve
Review via email: mp+244665@code.launchpad.net

Commit message

Expose on the autopilot helpers the back and forward functionality.

Description of the change

We are automating part of the sanity test suite. In that suite, there is one test that clicks back and then forward on the browser.
In order for those tests to work, we need stable, tested and readable helpers from the browser custom proxy objects.
By calling the methods with a name that reflects clearly what is the user action, as suggested by the page object pattern, we enable this higher level testing of the browser in combination with other projects.

To post a comment you must log in.
Revision history for this message
Richard Huddie (rhuddie) wrote :

This looks good to me.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Allan LeSage (allanlesage) wrote :

Again nothing to add to the POM style adjustments, confirm that the changed tests pass locally--the Jenkins failure appears unrelated and should be pursued with CI as it'll block this landing. . . .

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

Since you removed the assert_page_eventually_loaded() method, while you’re at it can you also remove the assert_page_eventually_loading() method? I see that it’s not used anywhere any longer.

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

The changes you made to test_opening_new_page_enables_back_button() and test_navigating_back_enables_forward_button() are not semantically equivalent:

141 - self.assertThat(back_button.enabled, Eventually(Equals(True)))
143 + self.main_window.go_back()
144 + self.assert_home_page_eventually_loaded()

We don’t want to actually go back, we only want to verify that the back button is *eventually* enabled (which the go_back() method doesn’t do). And the is_back_button_enabled() method doesn’t contemplate a possible delay (that would translate into the use of an Eventually() matcher).

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

The rest of the changes look good to me.

850. By Leo Arias

Remove unused method.

Revision history for this message
Leo Arias (elopio) wrote :

> Since you removed the assert_page_eventually_loaded() method, while you’re at
> it can you also remove the assert_page_eventually_loading() method? I see that
> it’s not used anywhere any longer.

Done.

851. By Leo Arias

Renamed the back and forward tests. Added waits for the buttons to be enabled.

852. By Leo Arias

Fixed typo.

Revision history for this message
Leo Arias (elopio) wrote :

> The changes you made to test_opening_new_page_enables_back_button() and
> test_navigating_back_enables_forward_button() are not semantically equivalent:
>
> 141 - self.assertThat(back_button.enabled,
> Eventually(Equals(True)))
> 143 + self.main_window.go_back()
> 144 + self.assert_home_page_eventually_loaded()
>
> We don’t want to actually go back, we only want to verify that the back button
> is *eventually* enabled (which the go_back() method doesn’t do). And the
> is_back_button_enabled() method doesn’t contemplate a possible delay (that
> would translate into the use of an Eventually() matcher).

I renamed the tests and added waits in the go methods.
The tests pass here, and I've triggered a new jenkins run to confirm that.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Leo Arias (elopio) wrote :

The failures are on settle. All the tests are passing.

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

Looks good to me now, thanks!

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/emulators/browser.py'
--- tests/autopilot/webbrowser_app/emulators/browser.py 2014-12-18 15:53:25 +0000
+++ tests/autopilot/webbrowser_app/emulators/browser.py 2014-12-18 15:53:25 +0000
@@ -47,15 +47,28 @@
47 self.chrome = self._get_chrome()47 self.chrome = self._get_chrome()
48 self.address_bar = self.chrome.address_bar48 self.address_bar = self.chrome.address_bar
4949
50 def _get_chrome(self):
51 return self.select_single(Chrome)
52
50 def go_to_url(self, url):53 def go_to_url(self, url):
51 self.address_bar.go_to_url(url)54 self.address_bar.go_to_url(url)
5255
56 def wait_until_page_loaded(self, url):
57 webview = self.get_current_webview()
58 webview.url.wait_for(url)
59 # loadProgress == 100 ensures that a page has actually loaded
60 webview.loadProgress.wait_for(100, timeout=20)
61 webview.loading.wait_for(False)
62
63 def go_back(self):
64 self.chrome.go_back()
65
66 def go_forward(self):
67 self.chrome.go_forward()
68
53 def get_window(self):69 def get_window(self):
54 return self.get_parent()70 return self.get_parent()
5571
56 def _get_chrome(self):
57 return self.select_single(Chrome)
58
59 def get_current_webview(self):72 def get_current_webview(self):
60 return self.select_single("WebViewImpl", current=True)73 return self.select_single("WebViewImpl", current=True)
6174
@@ -102,12 +115,32 @@
102 def _get_address_bar(self):115 def _get_address_bar(self):
103 return self.select_single(AddressBar)116 return self.select_single(AddressBar)
104117
105 def get_back_button(self):118 @autopilot.logging.log_action(logger.info)
119 def go_back(self):
120 back_button = self._get_back_button()
121 back_button.enabled.wait_for(True)
122 self.pointing_device.click_object(back_button)
123
124 def _get_back_button(self):
106 return self.select_single("ChromeButton", objectName="backButton")125 return self.select_single("ChromeButton", objectName="backButton")
107126
108 def get_forward_button(self):127 def is_back_button_enabled(self):
128 back_button = self._get_back_button()
129 return back_button.enabled
130
131 @autopilot.logging.log_action(logger.info)
132 def go_forward(self):
133 forward_button = self._get_forward_button()
134 forward_button.enabled.wait_for(True)
135 self.pointing_device.click_object(forward_button)
136
137 def _get_forward_button(self):
109 return self.select_single("ChromeButton", objectName="forwardButton")138 return self.select_single("ChromeButton", objectName="forwardButton")
110139
140 def is_forward_button_enabled(self):
141 forward_button = self._get_forward_button()
142 return forward_button.enabled
143
111 def get_drawer_button(self):144 def get_drawer_button(self):
112 return self.select_single("ChromeButton", objectName="drawerButton")145 return self.select_single("ChromeButton", objectName="drawerButton")
113146
114147
=== modified file 'tests/autopilot/webbrowser_app/tests/__init__.py'
--- tests/autopilot/webbrowser_app/tests/__init__.py 2014-12-18 15:53:25 +0000
+++ tests/autopilot/webbrowser_app/tests/__init__.py 2014-12-18 15:53:25 +0000
@@ -87,18 +87,6 @@
87 def main_window(self):87 def main_window(self):
88 return self.app.main_window88 return self.app.main_window
8989
90 def assert_page_eventually_loading(self):
91 webview = self.main_window.get_current_webview()
92 self.assertThat(webview.loading, Eventually(Equals(True)))
93
94 def assert_page_eventually_loaded(self, url):
95 webview = self.main_window.get_current_webview()
96 self.assertThat(webview.url, Eventually(Equals(url)))
97 # loadProgress == 100 ensures that a page has actually loaded
98 self.assertThat(webview.loadProgress,
99 Eventually(Equals(100), timeout=20))
100 self.assertThat(webview.loading, Eventually(Equals(False)))
101
102 def open_tabs_view(self):90 def open_tabs_view(self):
103 chrome = self.main_window.chrome91 chrome = self.main_window.chrome
104 drawer_button = chrome.get_drawer_button()92 drawer_button = chrome.get_drawer_button()
@@ -157,4 +145,4 @@
157 self.assert_home_page_eventually_loaded()145 self.assert_home_page_eventually_loaded()
158146
159 def assert_home_page_eventually_loaded(self):147 def assert_home_page_eventually_loaded(self):
160 self.assert_page_eventually_loaded(self.url)148 self.main_window.wait_until_page_loaded(self.url)
161149
=== modified file 'tests/autopilot/webbrowser_app/tests/test_addressbar_bookmark.py'
--- tests/autopilot/webbrowser_app/tests/test_addressbar_bookmark.py 2014-12-18 15:53:25 +0000
+++ tests/autopilot/webbrowser_app/tests/test_addressbar_bookmark.py 2014-12-18 15:53:25 +0000
@@ -37,7 +37,7 @@
37 self.open_new_tab()37 self.open_new_tab()
38 url = self.base_url + "/test2"38 url = self.base_url + "/test2"
39 self.main_window.go_to_url(url)39 self.main_window.go_to_url(url)
40 self.assert_page_eventually_loaded(url)40 self.main_window.wait_until_page_loaded(url)
41 self.assertThat(chrome.bookmarked, Eventually(Equals(False)))41 self.assertThat(chrome.bookmarked, Eventually(Equals(False)))
4242
43 self.open_tabs_view()43 self.open_tabs_view()
4444
=== modified file 'tests/autopilot/webbrowser_app/tests/test_backforward.py'
--- tests/autopilot/webbrowser_app/tests/test_backforward.py 2014-12-18 15:53:25 +0000
+++ tests/autopilot/webbrowser_app/tests/test_backforward.py 2014-12-18 15:53:25 +0000
@@ -15,7 +15,6 @@
15# along with this program. If not, see <http://www.gnu.org/licenses/>.15# along with this program. If not, see <http://www.gnu.org/licenses/>.
1616
17from testtools.matchers import Equals17from testtools.matchers import Equals
18from autopilot.matchers import Eventually
1918
20from webbrowser_app.tests import StartOpenRemotePageTestCaseBase19from webbrowser_app.tests import StartOpenRemotePageTestCaseBase
2120
@@ -24,26 +23,30 @@
2423
25 """Tests the back and forward functionality."""24 """Tests the back and forward functionality."""
2625
26 def setUp(self):
27 super().setUp()
28 self.chrome = self.main_window.chrome
29
27 def test_homepage_no_history(self):30 def test_homepage_no_history(self):
28 chrome = self.main_window.chrome31 self.assertThat(self.chrome.is_back_button_enabled(), Equals(False))
29 self.assertThat(chrome.get_back_button().enabled, Equals(False))32 self.assertThat(self.chrome.is_forward_button_enabled(), Equals(False))
30 self.assertThat(chrome.get_forward_button().enabled, Equals(False))33
3134 def test_go_back_after_opening_a_new_page(self):
32 def test_opening_new_page_enables_back_button(self):35 """Test that the back button must open the previous page."""
33 back_button = self.main_window.chrome.get_back_button()36 self.assertThat(self.chrome.is_back_button_enabled(), Equals(False))
34 self.assertThat(back_button.enabled, Equals(False))37 url = self.base_url + "/test2"
35 url = self.base_url + "/test2"38 self.main_window.go_to_url(url)
36 self.main_window.go_to_url(url)39 self.main_window.wait_until_page_loaded(url)
37 self.assert_page_eventually_loaded(url)40 self.main_window.go_back()
38 self.assertThat(back_button.enabled, Eventually(Equals(True)))41 self.assert_home_page_eventually_loaded()
3942
40 def test_navigating_back_enables_forward_button(self):43 def test_go_forward_after_going_back(self):
41 url = self.base_url + "/test2"44 """Test that the forward button must open the previous page."""
42 self.main_window.go_to_url(url)45 url = self.base_url + "/test2"
43 self.assert_page_eventually_loaded(url)46 self.main_window.go_to_url(url)
44 chrome = self.main_window.chrome47 self.main_window.wait_until_page_loaded(url)
45 forward_button = chrome.get_forward_button()48 self.assertThat(self.chrome.is_forward_button_enabled(), Equals(False))
46 self.assertThat(forward_button.enabled, Equals(False))49 self.main_window.go_back()
47 self.pointing_device.click_object(chrome.get_back_button())50 self.assert_home_page_eventually_loaded()
48 self.assert_home_page_eventually_loaded()51 self.main_window.go_forward()
49 self.assertThat(forward_button.enabled, Eventually(Equals(True)))52 self.main_window.wait_until_page_loaded(url)
5053
=== modified file 'tests/autopilot/webbrowser_app/tests/test_content_pick.py'
--- tests/autopilot/webbrowser_app/tests/test_content_pick.py 2014-12-18 15:53:25 +0000
+++ tests/autopilot/webbrowser_app/tests/test_content_pick.py 2014-12-18 15:53:25 +0000
@@ -30,7 +30,7 @@
30 def test_picker_dialog_shows_up(self):30 def test_picker_dialog_shows_up(self):
31 url = self.base_url + "/uploadform"31 url = self.base_url + "/uploadform"
32 self.main_window.go_to_url(url)32 self.main_window.go_to_url(url)
33 self.assert_page_eventually_loaded(url)33 self.main_window.wait_until_page_loaded(url)
34 webview = self.main_window.get_current_webview()34 webview = self.main_window.get_current_webview()
35 self.pointing_device.click_object(webview)35 self.pointing_device.click_object(webview)
36 dialog = self.main_window.get_content_picker_dialog()36 dialog = self.main_window.get_content_picker_dialog()
3737
=== modified file 'tests/autopilot/webbrowser_app/tests/test_errorsheet.py'
--- tests/autopilot/webbrowser_app/tests/test_errorsheet.py 2014-12-18 15:53:25 +0000
+++ tests/autopilot/webbrowser_app/tests/test_errorsheet.py 2014-12-18 15:53:25 +0000
@@ -43,19 +43,17 @@
43 error = self.main_window.get_error_sheet()43 error = self.main_window.get_error_sheet()
44 self.main_window.go_to_url(INVALID_URL)44 self.main_window.go_to_url(INVALID_URL)
45 self.assertThat(error.visible, Eventually(Equals(True)))45 self.assertThat(error.visible, Eventually(Equals(True)))
46 chrome = self.main_window.chrome46 self.main_window.go_back()
47 self.pointing_device.click_object(chrome.get_back_button())
48 self.assertThat(error.visible, Eventually(Equals(False)))47 self.assertThat(error.visible, Eventually(Equals(False)))
4948
50 def test_navigating_forward_discards_error_message(self):49 def test_navigating_forward_discards_error_message(self):
51 error = self.main_window.get_error_sheet()50 error = self.main_window.get_error_sheet()
52 self.main_window.go_to_url(INVALID_URL)51 self.main_window.go_to_url(INVALID_URL)
53 self.assert_page_eventually_loaded(INVALID_URL)52 self.main_window.wait_until_page_loaded(INVALID_URL)
54 url = self.base_url + "/test2"53 url = self.base_url + "/test2"
55 self.main_window.go_to_url(url)54 self.main_window.go_to_url(url)
56 self.assert_page_eventually_loaded(url)55 self.main_window.wait_until_page_loaded(url)
57 chrome = self.main_window.chrome56 self.main_window.go_back()
58 self.pointing_device.click_object(chrome.get_back_button())
59 self.assertThat(error.visible, Eventually(Equals(True)))57 self.assertThat(error.visible, Eventually(Equals(True)))
60 self.pointing_device.click_object(chrome.get_forward_button())58 self.main_window.go_forward()
61 self.assertThat(error.visible, Eventually(Equals(False)))59 self.assertThat(error.visible, Eventually(Equals(False)))
6260
=== modified file 'tests/autopilot/webbrowser_app/tests/test_fullscreen.py'
--- tests/autopilot/webbrowser_app/tests/test_fullscreen.py 2014-12-18 15:53:25 +0000
+++ tests/autopilot/webbrowser_app/tests/test_fullscreen.py 2014-12-18 15:53:25 +0000
@@ -41,7 +41,7 @@
41 self.assert_eventually_windowed()41 self.assert_eventually_windowed()
42 url = self.base_url + "/fullscreen"42 url = self.base_url + "/fullscreen"
43 self.main_window.go_to_url(url)43 self.main_window.go_to_url(url)
44 self.assert_page_eventually_loaded(url)44 self.main_window.wait_until_page_loaded(url)
45 self.assert_eventually_windowed()45 self.assert_eventually_windowed()
46 webview = self.main_window.get_current_webview()46 webview = self.main_window.get_current_webview()
47 self.pointing_device.click_object(webview)47 self.pointing_device.click_object(webview)
4848
=== modified file 'tests/autopilot/webbrowser_app/tests/test_geolocation.py'
--- tests/autopilot/webbrowser_app/tests/test_geolocation.py 2014-12-18 15:53:25 +0000
+++ tests/autopilot/webbrowser_app/tests/test_geolocation.py 2014-12-18 15:53:25 +0000
@@ -23,7 +23,7 @@
23 super(TestGeolocation, self).setUp()23 super(TestGeolocation, self).setUp()
24 url = self.base_url + "/geolocation"24 url = self.base_url + "/geolocation"
25 self.main_window.go_to_url(url)25 self.main_window.go_to_url(url)
26 self.assert_page_eventually_loaded(url)26 self.main_window.wait_until_page_loaded(url)
27 self.dialog = self.main_window.get_geolocation_dialog()27 self.dialog = self.main_window.get_geolocation_dialog()
2828
29 def tearDown(self):29 def tearDown(self):
3030
=== modified file 'tests/autopilot/webbrowser_app/tests/test_selection.py'
--- tests/autopilot/webbrowser_app/tests/test_selection.py 2014-12-18 15:53:25 +0000
+++ tests/autopilot/webbrowser_app/tests/test_selection.py 2014-12-18 15:53:25 +0000
@@ -28,7 +28,7 @@
28 super(TestSelection, self).setUp()28 super(TestSelection, self).setUp()
29 url = self.base_url + "/selection"29 url = self.base_url + "/selection"
30 self.main_window.go_to_url(url)30 self.main_window.go_to_url(url)
31 self.assert_page_eventually_loaded(url)31 self.main_window.wait_until_page_loaded(url)
32 webview = self.main_window.get_current_webview()32 webview = self.main_window.get_current_webview()
33 self.pointing_device.move_to_object(webview)33 self.pointing_device.move_to_object(webview)
34 if model() == 'Desktop':34 if model() == 'Desktop':
3535
=== modified file 'tests/autopilot/webbrowser_app/tests/test_tabs.py'
--- tests/autopilot/webbrowser_app/tests/test_tabs.py 2014-12-18 15:53:25 +0000
+++ tests/autopilot/webbrowser_app/tests/test_tabs.py 2014-12-18 15:53:25 +0000
@@ -129,7 +129,7 @@
129 def test_open_target_blank_in_new_tab(self):129 def test_open_target_blank_in_new_tab(self):
130 url = self.base_url + "/blanktargetlink"130 url = self.base_url + "/blanktargetlink"
131 self.main_window.go_to_url(url)131 self.main_window.go_to_url(url)
132 self.assert_page_eventually_loaded(url)132 self.main_window.wait_until_page_loaded(url)
133 webview = self.main_window.get_current_webview()133 webview = self.main_window.get_current_webview()
134 self.pointing_device.click_object(webview)134 self.pointing_device.click_object(webview)
135 self.check_current_tab(self.base_url + "/test2")135 self.check_current_tab(self.base_url + "/test2")
@@ -138,7 +138,7 @@
138 def test_open_iframe_target_blank_in_new_tab(self):138 def test_open_iframe_target_blank_in_new_tab(self):
139 url = self.base_url + "/fulliframewithblanktargetlink"139 url = self.base_url + "/fulliframewithblanktargetlink"
140 self.main_window.go_to_url(url)140 self.main_window.go_to_url(url)
141 self.assert_page_eventually_loaded(url)141 self.main_window.wait_until_page_loaded(url)
142 webview = self.main_window.get_current_webview()142 webview = self.main_window.get_current_webview()
143 self.pointing_device.click_object(webview)143 self.pointing_device.click_object(webview)
144 self.check_current_tab(self.base_url + "/test2")144 self.check_current_tab(self.base_url + "/test2")

Subscribers

People subscribed via source and target branches

to status/vote changes: