Merge lp:~canonical-platform-qa/webbrowser-app/autopilot-address_bar-textfield into lp:webbrowser-app

Proposed by Leo Arias
Status: Merged
Approved by: Olivier Tilloy
Approved revision: 847
Merged at revision: 858
Proposed branch: lp:~canonical-platform-qa/webbrowser-app/autopilot-address_bar-textfield
Merge into: lp:webbrowser-app
Diff against target: 725 lines (+163/-183)
15 files modified
src/app/webbrowser/AddressBar.qml (+1/-0)
tests/autopilot/webbrowser_app/emulators/browser.py (+93/-60)
tests/autopilot/webbrowser_app/tests/__init__.py (+5/-42)
tests/autopilot/webbrowser_app/tests/test_addressbar_bookmark.py (+4/-9)
tests/autopilot/webbrowser_app/tests/test_addressbar_states.py (+6/-6)
tests/autopilot/webbrowser_app/tests/test_backforward.py (+5/-5)
tests/autopilot/webbrowser_app/tests/test_content_pick.py (+1/-1)
tests/autopilot/webbrowser_app/tests/test_errorsheet.py (+8/-8)
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_history.py (+26/-22)
tests/autopilot/webbrowser_app/tests/test_selection.py (+1/-1)
tests/autopilot/webbrowser_app/tests/test_session_save_restore.py (+1/-5)
tests/autopilot/webbrowser_app/tests/test_tabs.py (+9/-21)
tests/autopilot/webbrowser_app/tests/test_title.py (+1/-1)
To merge this branch: bzr merge lp:~canonical-platform-qa/webbrowser-app/autopilot-address_bar-textfield
Reviewer Review Type Date Requested Status
Olivier Tilloy Approve
Allan LeSage (community) Approve
PS Jenkins bot continuous-integration Needs Fixing
Review via email: mp+244663@code.launchpad.net

Commit message

Refactor the address bar autopilot helpers so they can be used from external test cases.

Description of the change

This MP refactors the address bar autopilot helpers out of the test case class and into the custom proxy object.
This way, we can call the action helpers, like go_to_url, from tests that don't inherit from the web browser base test cases. In many cases we don't want to inherit from this class, so we can launch the browser from the dash, or test the integration of the browser with other apps.
Here we follow the page object pattern [1], so every component encapsulates the services it makes available to users.

[1] http://developer.ubuntu.com/apps/platform/guides/acceptance-testing-using-the-page-object-model/

To post a comment you must log in.
Revision history for this message
Leo Arias (elopio) wrote :

@osomon, I removed the waits for osk. That's something that IMO shouldn't be implicitly tested when interacting with the address bar. In the ideal scenario, all the interaction between textfields and the osk would be tested by the toolkit. I think that part is ok. And when running the tests from the phone, they would use the OSK. That part is not ready yet, but on the last sprint we asked Michael Sheldon to update the osk-autopilot, so we should be closer by now.
Please let me know if you added those waits for a reason that I'm missing in this MP.

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

Leo, the waits were initially added because the address bar used to be on the bottom edge, and focusing it would trigger the OSK to show, thus shifting the address bar upwards, and that would mess up the expected coordinates. For example, focusing the address bar then clicking the refresh button wouldn’t work if the test didn’t wait for the position of the address bar to settle.

The chrome is now on the top edge, so the waits are probably less useful, but it remains to be proven (by running all the tests on a device and verifying that they pass).

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 :

FAILED: Continuous integration, rev:847
http://jenkins.qa.ubuntu.com/job/webbrowser-app-ci/1355/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-vivid-touch/613
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-vivid/346/console
    FAILURE: http://jenkins.qa.ubuntu.com/job/webbrowser-app-vivid-amd64-ci/113/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/webbrowser-app-vivid-armhf-ci/113
        deb: http://jenkins.qa.ubuntu.com/job/webbrowser-app-vivid-armhf-ci/113/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/webbrowser-app-vivid-i386-ci/113
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-runner-vivid-mako/525
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-vivid-armhf/611
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-vivid-armhf/611/artifact/work/output/*zip*/output.zip
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/16661
    FAILURE: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-vivid/284/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-vivid-amd64/352
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-vivid-amd64/352/artifact/work/output/*zip*/output.zip

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/webbrowser-app-ci/1355/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Allan LeSage (allanlesage) wrote :

No objection to any of the POM style enhancements; I built and tested on local and found these tests working--agree with Olivier that we'll need to see a Jenkins approval before proceeding, though, if we want to land. Any other changes you're wishing to see Olivier?

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

> The chrome is now on the top edge, so the waits are probably less useful, but
> it remains to be proven (by running all the tests on a device and verifying
> that they pass).

FWIW, I ran the tests in the device and they all passed.

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

516 + self.address_bar.clear()
517 + self.address_bar.write('xaMPL')

IIUC, self.address_bar.clear() is redundant, as self.address_bar.write(…) will first clear the contents of the field before typing the text.

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

Same remark as above for the following snippets:

529 + self.address_bar.clear()
530 + self.address_bar.write('ubuntu')

577 + self.address_bar.clear()
578 + self.address_bar.write('(phil')

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

The rest of the changes look good.

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

> Same remark as above for the following snippets:
>
> 529 + self.address_bar.clear()
> 530 + self.address_bar.write('ubuntu')
>
>
> 577 + self.address_bar.clear()
> 578 + self.address_bar.write('(phil')

As you were testing there the behaviour of the suggestions, I thought it would be better to make it explicit when we are clearing the address bar. When we call clear and there is nothing in the textfield, it does nothing; so we would be just duplicating one if, and no finger or mouse actions.

If you prefer, I can remove the calls to clear and use the keyword clear=True. Let me know if that seems better to you.

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

Nah, that’s alright as it is. I was only pointing out that the code could have been made a tad more succinct, but I don’t have a strong opinion on it. Thanks!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/app/webbrowser/AddressBar.qml'
2--- src/app/webbrowser/AddressBar.qml 2014-11-11 15:28:50 +0000
3+++ src/app/webbrowser/AddressBar.qml 2014-12-13 01:23:19 +0000
4@@ -59,6 +59,7 @@
5
6 TextField {
7 id: textField
8+ objectName: "addressBarTextField"
9
10 anchors.fill: parent
11
12
13=== modified file 'tests/autopilot/webbrowser_app/emulators/browser.py'
14--- tests/autopilot/webbrowser_app/emulators/browser.py 2014-11-06 15:42:56 +0000
15+++ tests/autopilot/webbrowser_app/emulators/browser.py 2014-12-13 01:23:19 +0000
16@@ -14,24 +14,74 @@
17 # You should have received a copy of the GNU General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19
20+import logging
21+
22+import autopilot.logging
23 import ubuntuuitoolkit as uitk
24
25-
26-class AddressBar(uitk.UbuntuUIToolkitCustomProxyObjectBase):
27-
28- def get_clear_button(self):
29- return self.select_single("AbstractButton")
30-
31- def get_action_button(self):
32- return self.select_single("QQuickMouseArea", objectName="actionButton")
33-
34- def get_bookmark_toggle(self):
35- return self.select_single("QQuickItem", objectName="bookmarkToggle")
36+logger = logging.getLogger(__name__)
37+
38+
39+class Browser(uitk.UbuntuUIToolkitCustomProxyObjectBase):
40+
41+ def __init__(self, *args):
42+ super().__init__(*args)
43+ self.chrome = self._get_chrome()
44+ self.address_bar = self.chrome.address_bar
45+
46+ def go_to_url(self, url):
47+ self.address_bar.go_to_url(url)
48+
49+ def get_window(self):
50+ return self.get_parent()
51+
52+ def _get_chrome(self):
53+ return self.select_single(Chrome)
54+
55+ def get_current_webview(self):
56+ return self.select_single("WebViewImpl", current=True)
57+
58+ def get_webviews(self):
59+ return self.select_many("WebViewImpl")
60+
61+ def get_visible_webviews(self):
62+ return self.select_many("WebViewImpl", visible=True)
63+
64+ def get_error_sheet(self):
65+ return self.select_single("ErrorSheet")
66+
67+ def get_suggestions(self):
68+ return self.select_single(Suggestions)
69+
70+ def get_geolocation_dialog(self):
71+ return self.wait_select_single(GeolocationPermissionRequest)
72+
73+ def get_selection(self):
74+ return self.wait_select_single(Selection)
75+
76+ def get_selection_actions(self):
77+ return self.wait_select_single("ActionSelectionPopover",
78+ objectName="selectionActions")
79+
80+ def get_tabs_view(self):
81+ return self.wait_select_single(TabsView)
82+
83+ def get_new_tab_view(self):
84+ return self.wait_select_single("NewTabView", visible=True)
85+
86+ def get_content_picker_dialog(self):
87+ # only on devices
88+ return self.wait_select_single("PopupBase",
89+ objectName="contentPickerDialog")
90
91
92 class Chrome(uitk.UbuntuUIToolkitCustomProxyObjectBase):
93
94- def get_address_bar(self):
95+ def __init__(self, *args):
96+ super().__init__(*args)
97+ self.address_bar = self._get_address_bar()
98+
99+ def _get_address_bar(self):
100 return self.select_single(AddressBar)
101
102 def get_back_button(self):
103@@ -52,6 +102,37 @@
104 return drawer.select_single("AbstractButton", objectName=actionName)
105
106
107+class AddressBar(uitk.UbuntuUIToolkitCustomProxyObjectBase):
108+
109+ def __init__(self, *args):
110+ super().__init__(*args)
111+ self.text_field = self.select_single(
112+ uitk.TextField, objectName='addressBarTextField')
113+
114+ @autopilot.logging.log_action(logger.debug)
115+ def focus(self):
116+ self.pointing_device.click_object(self)
117+ self.activeFocus.wait_for(True)
118+
119+ def clear(self):
120+ self.text_field.clear()
121+
122+ @autopilot.logging.log_action(logger.info)
123+ def go_to_url(self, url):
124+ self.focus()
125+ self.write(url)
126+ self.text_field.keyboard.press_and_release('Enter')
127+
128+ def write(self, text, clear=True):
129+ self.text_field.write(text, clear)
130+
131+ def get_action_button(self):
132+ return self.select_single("QQuickMouseArea", objectName="actionButton")
133+
134+ def get_bookmark_toggle(self):
135+ return self.select_single("QQuickItem", objectName="bookmarkToggle")
136+
137+
138 class Suggestions(uitk.UbuntuUIToolkitCustomProxyObjectBase):
139
140 def get_list(self):
141@@ -100,51 +181,3 @@
142
143 def get_add_button(self):
144 return self.select_single("ToolbarAction", objectName="addTabButton")
145-
146-
147-class Browser(uitk.UbuntuUIToolkitCustomProxyObjectBase):
148-
149- def get_window(self):
150- return self.get_parent()
151-
152- def get_keyboard_rectangle(self):
153- return self.select_single("KeyboardRectangle")
154-
155- def get_chrome(self):
156- return self.select_single(Chrome)
157-
158- def get_current_webview(self):
159- return self.select_single("WebViewImpl", current=True)
160-
161- def get_webviews(self):
162- return self.select_many("WebViewImpl")
163-
164- def get_visible_webviews(self):
165- return self.select_many("WebViewImpl", visible=True)
166-
167- def get_error_sheet(self):
168- return self.select_single("ErrorSheet")
169-
170- def get_suggestions(self):
171- return self.select_single(Suggestions)
172-
173- def get_geolocation_dialog(self):
174- return self.wait_select_single(GeolocationPermissionRequest)
175-
176- def get_selection(self):
177- return self.wait_select_single(Selection)
178-
179- def get_selection_actions(self):
180- return self.wait_select_single("ActionSelectionPopover",
181- objectName="selectionActions")
182-
183- def get_tabs_view(self):
184- return self.wait_select_single(TabsView)
185-
186- def get_new_tab_view(self):
187- return self.wait_select_single("NewTabView", visible=True)
188-
189- def get_content_picker_dialog(self):
190- # only on devices
191- return self.wait_select_single("PopupBase",
192- objectName="contentPickerDialog")
193
194=== modified file 'tests/autopilot/webbrowser_app/tests/__init__.py'
195--- tests/autopilot/webbrowser_app/tests/__init__.py 2014-11-18 20:03:46 +0000
196+++ tests/autopilot/webbrowser_app/tests/__init__.py 2014-12-13 01:23:19 +0000
197@@ -20,7 +20,7 @@
198 import shutil
199 import urllib.request
200
201-from testtools.matchers import Contains, Equals
202+from testtools.matchers import Equals
203
204 from autopilot.matchers import Eventually
205 from autopilot.platform import model
206@@ -87,44 +87,6 @@
207 def main_window(self):
208 return self.app.select_single(Browser)
209
210- def assert_osk_eventually_shown(self):
211- if model() != 'Desktop':
212- keyboardRectangle = self.main_window.get_keyboard_rectangle()
213- self.assertThat(keyboardRectangle.state,
214- Eventually(Equals("shown")))
215-
216- def assert_osk_eventually_hidden(self):
217- if model() != 'Desktop':
218- keyboardRectangle = self.main_window.get_keyboard_rectangle()
219- self.assertThat(keyboardRectangle.state,
220- Eventually(Equals("hidden")))
221-
222- def focus_address_bar(self):
223- address_bar = self.main_window.get_chrome().get_address_bar()
224- self.pointing_device.click_object(address_bar)
225- self.assertThat(address_bar.activeFocus, Eventually(Equals(True)))
226- self.assert_osk_eventually_shown()
227-
228- def clear_address_bar(self):
229- self.focus_address_bar()
230- self.assert_osk_eventually_shown()
231- address_bar = self.main_window.get_chrome().get_address_bar()
232- clear_button = address_bar.get_clear_button()
233- self.pointing_device.click_object(clear_button)
234- self.assertThat(address_bar.text, Eventually(Equals("")))
235-
236- def type_in_address_bar(self, text):
237- address_bar = self.main_window.get_chrome().get_address_bar()
238- self.assertThat(address_bar.activeFocus, Eventually(Equals(True)))
239- self.keyboard.type(text)
240- self.assertThat(address_bar.text, Eventually(Contains(text)))
241-
242- def go_to_url(self, url):
243- self.clear_address_bar()
244- self.type_in_address_bar(url)
245- self.keyboard.press_and_release("Enter")
246- self.assert_osk_eventually_hidden()
247-
248 def assert_page_eventually_loading(self):
249 webview = self.main_window.get_current_webview()
250 self.assertThat(webview.loading, Eventually(Equals(True)))
251@@ -138,7 +100,7 @@
252 self.assertThat(webview.loading, Eventually(Equals(False)))
253
254 def open_tabs_view(self):
255- chrome = self.main_window.get_chrome()
256+ chrome = self.main_window.chrome
257 drawer_button = chrome.get_drawer_button()
258 self.pointing_device.click_object(drawer_button)
259 chrome.get_drawer()
260@@ -158,8 +120,9 @@
261 self.assert_number_webviews_eventually(new_count)
262 self.main_window.get_new_tab_view()
263 if model() == 'Desktop':
264- address_bar = self.main_window.get_chrome().get_address_bar()
265- self.assertThat(address_bar.activeFocus, Eventually(Equals(True)))
266+ self.assertThat(
267+ self.main_window.address_bar.activeFocus,
268+ Eventually(Equals(True)))
269
270 def assert_number_webviews_eventually(self, count):
271 self.assertThat(lambda: len(self.main_window.get_webviews()),
272
273=== modified file 'tests/autopilot/webbrowser_app/tests/test_addressbar_bookmark.py'
274--- tests/autopilot/webbrowser_app/tests/test_addressbar_bookmark.py 2014-11-18 20:03:46 +0000
275+++ tests/autopilot/webbrowser_app/tests/test_addressbar_bookmark.py 2014-12-13 01:23:19 +0000
276@@ -16,7 +16,6 @@
277
278 from testtools.matchers import Equals
279 from autopilot.matchers import Eventually
280-from autopilot.platform import model
281
282 from webbrowser_app.tests import StartOpenRemotePageTestCaseBase
283
284@@ -28,8 +27,8 @@
285 super(TestAddressBarBookmark, self).setUp()
286
287 def test_switching_tabs_updates_bookmark_toggle(self):
288- chrome = self.main_window.get_chrome()
289- address_bar = chrome.get_address_bar()
290+ chrome = self.main_window.chrome
291+ address_bar = self.main_window.address_bar
292 bookmark_toggle = address_bar.get_bookmark_toggle()
293 self.pointing_device.click_object(bookmark_toggle)
294 self.assertThat(chrome.bookmarked, Eventually(Equals(True)))
295@@ -37,10 +36,7 @@
296 self.open_tabs_view()
297 self.open_new_tab()
298 url = self.base_url + "/test2"
299- if model() != 'Desktop':
300- self.focus_address_bar()
301- self.type_in_address_bar(url)
302- self.keyboard.press_and_release("Enter")
303+ self.main_window.go_to_url(url)
304 self.assert_page_eventually_loaded(url)
305 self.assertThat(chrome.bookmarked, Eventually(Equals(False)))
306
307@@ -69,8 +65,7 @@
308 tabs_view.wait_until_destroyed()
309 webview = self.main_window.get_current_webview()
310 self.pointing_device.click_object(webview)
311- chrome = self.main_window.get_chrome()
312- address_bar = chrome.get_address_bar()
313+ address_bar = self.main_window.address_bar
314 bookmark_toggle = address_bar.get_bookmark_toggle()
315 self.assertThat(address_bar.activeFocus, Eventually(Equals(False)))
316 self.assertThat(bookmark_toggle.visible, Eventually(Equals(True)))
317
318=== modified file 'tests/autopilot/webbrowser_app/tests/test_addressbar_states.py'
319--- tests/autopilot/webbrowser_app/tests/test_addressbar_states.py 2014-11-18 20:03:46 +0000
320+++ tests/autopilot/webbrowser_app/tests/test_addressbar_states.py 2014-12-13 01:23:19 +0000
321@@ -23,33 +23,33 @@
322 class TestAddressBarStates(StartOpenRemotePageTestCaseBase):
323
324 def test_cancel_state_loading(self):
325- address_bar = self.main_window.get_chrome().get_address_bar()
326+ address_bar = self.main_window.address_bar
327 action_button = address_bar.get_action_button()
328 url = self.base_url + "/wait/5"
329- self.go_to_url(url)
330+ self.main_window.go_to_url(url)
331 self.assertThat(address_bar.state, Eventually(Equals("loading")))
332 self.pointing_device.click_object(action_button)
333 self.assertThat(address_bar.state, Eventually(Equals("")))
334
335 def test_state_editing(self):
336- address_bar = self.main_window.get_chrome().get_address_bar()
337+ address_bar = self.main_window.address_bar
338 self.pointing_device.click_object(address_bar)
339 self.assertThat(address_bar.state, Eventually(Equals("editing")))
340 self.keyboard.press_and_release("Enter")
341 self.assertThat(address_bar.state, Eventually(Equals("")))
342
343 def test_looses_focus_when_loading_starts(self):
344- address_bar = self.main_window.get_chrome().get_address_bar()
345+ address_bar = self.main_window.address_bar
346 self.pointing_device.click_object(address_bar)
347 self.assertThat(address_bar.activeFocus, Eventually(Equals(True)))
348 self.assertThat(address_bar.state, Eventually(Equals("editing")))
349 url = self.base_url + "/test2"
350- self.go_to_url(url)
351+ self.main_window.go_to_url(url)
352 self.assertThat(address_bar.state, Eventually(Equals("")))
353 self.assertThat(address_bar.activeFocus, Eventually(Equals(False)))
354
355 def test_looses_focus_when_reloading(self):
356- address_bar = self.main_window.get_chrome().get_address_bar()
357+ address_bar = self.main_window.address_bar
358 self.pointing_device.click_object(address_bar)
359 self.assertThat(address_bar.activeFocus, Eventually(Equals(True)))
360 self.assertThat(address_bar.state, Eventually(Equals("editing")))
361
362=== modified file 'tests/autopilot/webbrowser_app/tests/test_backforward.py'
363--- tests/autopilot/webbrowser_app/tests/test_backforward.py 2014-11-18 20:03:46 +0000
364+++ tests/autopilot/webbrowser_app/tests/test_backforward.py 2014-12-13 01:23:19 +0000
365@@ -25,23 +25,23 @@
366 """Tests the back and forward functionality."""
367
368 def test_homepage_no_history(self):
369- chrome = self.main_window.get_chrome()
370+ chrome = self.main_window.chrome
371 self.assertThat(chrome.get_back_button().enabled, Equals(False))
372 self.assertThat(chrome.get_forward_button().enabled, Equals(False))
373
374 def test_opening_new_page_enables_back_button(self):
375- back_button = self.main_window.get_chrome().get_back_button()
376+ back_button = self.main_window.chrome.get_back_button()
377 self.assertThat(back_button.enabled, Equals(False))
378 url = self.base_url + "/test2"
379- self.go_to_url(url)
380+ self.main_window.go_to_url(url)
381 self.assert_page_eventually_loaded(url)
382 self.assertThat(back_button.enabled, Eventually(Equals(True)))
383
384 def test_navigating_back_enables_forward_button(self):
385 url = self.base_url + "/test2"
386- self.go_to_url(url)
387+ self.main_window.go_to_url(url)
388 self.assert_page_eventually_loaded(url)
389- chrome = self.main_window.get_chrome()
390+ chrome = self.main_window.chrome
391 forward_button = chrome.get_forward_button()
392 self.assertThat(forward_button.enabled, Equals(False))
393 self.pointing_device.click_object(chrome.get_back_button())
394
395=== modified file 'tests/autopilot/webbrowser_app/tests/test_content_pick.py'
396--- tests/autopilot/webbrowser_app/tests/test_content_pick.py 2014-07-16 11:40:21 +0000
397+++ tests/autopilot/webbrowser_app/tests/test_content_pick.py 2014-12-13 01:23:19 +0000
398@@ -29,7 +29,7 @@
399 @unittest.skipIf(model() == "Desktop", "on devices only")
400 def test_picker_dialog_shows_up(self):
401 url = self.base_url + "/uploadform"
402- self.go_to_url(url)
403+ self.main_window.go_to_url(url)
404 self.assert_page_eventually_loaded(url)
405 webview = self.main_window.get_current_webview()
406 self.pointing_device.click_object(webview)
407
408=== modified file 'tests/autopilot/webbrowser_app/tests/test_errorsheet.py'
409--- tests/autopilot/webbrowser_app/tests/test_errorsheet.py 2014-12-03 18:00:28 +0000
410+++ tests/autopilot/webbrowser_app/tests/test_errorsheet.py 2014-12-13 01:23:19 +0000
411@@ -29,32 +29,32 @@
412 def test_invalid_url_triggers_error_message(self):
413 error = self.main_window.get_error_sheet()
414 self.assertThat(error.visible, Equals(False))
415- self.go_to_url(INVALID_URL)
416+ self.main_window.go_to_url(INVALID_URL)
417 self.assertThat(error.visible, Eventually(Equals(True)))
418
419 def test_navigating_away_discards_error_message(self):
420 error = self.main_window.get_error_sheet()
421- self.go_to_url(INVALID_URL)
422+ self.main_window.go_to_url(INVALID_URL)
423 self.assertThat(error.visible, Eventually(Equals(True)))
424- self.go_to_url(self.base_url + "/test2")
425+ self.main_window.go_to_url(self.base_url + "/test2")
426 self.assertThat(error.visible, Eventually(Equals(False)))
427
428 def test_navigating_back_discards_error_message(self):
429 error = self.main_window.get_error_sheet()
430- self.go_to_url(INVALID_URL)
431+ self.main_window.go_to_url(INVALID_URL)
432 self.assertThat(error.visible, Eventually(Equals(True)))
433- chrome = self.main_window.get_chrome()
434+ chrome = self.main_window.chrome
435 self.pointing_device.click_object(chrome.get_back_button())
436 self.assertThat(error.visible, Eventually(Equals(False)))
437
438 def test_navigating_forward_discards_error_message(self):
439 error = self.main_window.get_error_sheet()
440- self.go_to_url(INVALID_URL)
441+ self.main_window.go_to_url(INVALID_URL)
442 self.assert_page_eventually_loaded(INVALID_URL)
443 url = self.base_url + "/test2"
444- self.go_to_url(url)
445+ self.main_window.go_to_url(url)
446 self.assert_page_eventually_loaded(url)
447- chrome = self.main_window.get_chrome()
448+ chrome = self.main_window.chrome
449 self.pointing_device.click_object(chrome.get_back_button())
450 self.assertThat(error.visible, Eventually(Equals(True)))
451 self.pointing_device.click_object(chrome.get_forward_button())
452
453=== modified file 'tests/autopilot/webbrowser_app/tests/test_fullscreen.py'
454--- tests/autopilot/webbrowser_app/tests/test_fullscreen.py 2014-10-06 10:35:36 +0000
455+++ tests/autopilot/webbrowser_app/tests/test_fullscreen.py 2014-12-13 01:23:19 +0000
456@@ -40,7 +40,7 @@
457 def test_toggle_fullscreen(self):
458 self.assert_eventually_windowed()
459 url = self.base_url + "/fullscreen"
460- self.go_to_url(url)
461+ self.main_window.go_to_url(url)
462 self.assert_page_eventually_loaded(url)
463 self.assert_eventually_windowed()
464 webview = self.main_window.get_current_webview()
465
466=== modified file 'tests/autopilot/webbrowser_app/tests/test_geolocation.py'
467--- tests/autopilot/webbrowser_app/tests/test_geolocation.py 2014-07-16 09:06:10 +0000
468+++ tests/autopilot/webbrowser_app/tests/test_geolocation.py 2014-12-13 01:23:19 +0000
469@@ -22,7 +22,7 @@
470 def setUp(self):
471 super(TestGeolocation, self).setUp()
472 url = self.base_url + "/geolocation"
473- self.go_to_url(url)
474+ self.main_window.go_to_url(url)
475 self.assert_page_eventually_loaded(url)
476 self.dialog = self.main_window.get_geolocation_dialog()
477
478
479=== modified file 'tests/autopilot/webbrowser_app/tests/test_history.py'
480--- tests/autopilot/webbrowser_app/tests/test_history.py 2014-11-19 08:46:19 +0000
481+++ tests/autopilot/webbrowser_app/tests/test_history.py 2014-12-13 01:23:19 +0000
482@@ -72,6 +72,10 @@
483
484 """Test the address bar suggestions based on navigation history."""
485
486+ def setUp(self):
487+ super().setUp()
488+ self.address_bar = self.main_window.address_bar
489+
490 def assert_suggestions_eventually_shown(self):
491 suggestions = self.main_window.get_suggestions()
492 self.assertThat(suggestions.opacity, Eventually(Equals(1)))
493@@ -84,33 +88,33 @@
494 listview = self.main_window.get_suggestions().get_list()
495 self.assert_suggestions_eventually_hidden()
496 self.assert_suggestions_eventually_hidden()
497- self.focus_address_bar()
498+ self.address_bar.focus()
499 self.assert_suggestions_eventually_shown()
500 self.assertThat(listview.count, Eventually(Equals(1)))
501- self.clear_address_bar()
502+ self.address_bar.clear()
503 self.assert_suggestions_eventually_hidden()
504- self.type_in_address_bar("u")
505+ self.address_bar.write('u')
506 self.assert_suggestions_eventually_shown()
507 self.assertThat(listview.count, Eventually(Equals(6)))
508- self.type_in_address_bar("b")
509+ self.address_bar.write('b', clear=False)
510 self.assertThat(listview.count, Eventually(Equals(5)))
511- self.type_in_address_bar("leh")
512+ self.address_bar.write('leh', clear=False)
513 self.assertThat(listview.count, Eventually(Equals(0)))
514- self.clear_address_bar()
515- self.type_in_address_bar("xaMPL")
516+ self.address_bar.clear()
517+ self.address_bar.write('xaMPL')
518 self.assertThat(listview.count, Eventually(Equals(2)))
519
520 def test_clear_address_bar_dismisses_suggestions(self):
521- self.focus_address_bar()
522- self.assert_suggestions_eventually_shown()
523- self.clear_address_bar()
524- self.type_in_address_bar("ubuntu")
525- self.assert_suggestions_eventually_shown()
526- self.clear_address_bar()
527+ self.address_bar.focus()
528+ self.assert_suggestions_eventually_shown()
529+ self.address_bar.clear()
530+ self.address_bar.write('ubuntu')
531+ self.assert_suggestions_eventually_shown()
532+ self.address_bar.clear()
533 self.assert_suggestions_eventually_hidden()
534
535 def test_addressbar_loosing_focus_dismisses_suggestions(self):
536- self.focus_address_bar()
537+ self.address_bar.focus()
538 self.assert_suggestions_eventually_shown()
539 suggestions = self.main_window.get_suggestions()
540 cs = suggestions.globalRect
541@@ -123,23 +127,23 @@
542 self.assert_suggestions_eventually_hidden()
543
544 def test_suggestions_hidden_while_drawer_open(self):
545- self.focus_address_bar()
546+ self.address_bar.focus()
547 self.assert_suggestions_eventually_shown()
548- chrome = self.main_window.get_chrome()
549+ chrome = self.main_window.chrome
550 drawer_button = chrome.get_drawer_button()
551 self.pointing_device.click_object(drawer_button)
552 chrome.get_drawer()
553 self.assert_suggestions_eventually_hidden()
554- self.focus_address_bar()
555+ self.address_bar.focus()
556 self.assert_suggestions_eventually_shown()
557
558 def test_select_suggestion(self):
559 suggestions = self.main_window.get_suggestions()
560 listview = suggestions.get_list()
561- self.focus_address_bar()
562+ self.address_bar.focus()
563 self.assert_suggestions_eventually_shown()
564- self.clear_address_bar()
565- self.type_in_address_bar("ubuntu")
566+ self.address_bar.clear()
567+ self.address_bar.write('ubuntu')
568 self.assert_suggestions_eventually_shown()
569 self.assertThat(listview.count, Eventually(Equals(5)))
570 entries = suggestions.get_entries()
571@@ -156,8 +160,8 @@
572 self.assert_suggestions_eventually_hidden()
573
574 def test_special_characters(self):
575- self.clear_address_bar()
576- self.type_in_address_bar("(phil")
577+ self.address_bar.clear()
578+ self.address_bar.write('(phil')
579 self.assert_suggestions_eventually_shown()
580 suggestions = self.main_window.get_suggestions()
581 listview = suggestions.get_list()
582
583=== modified file 'tests/autopilot/webbrowser_app/tests/test_selection.py'
584--- tests/autopilot/webbrowser_app/tests/test_selection.py 2014-06-27 11:51:42 +0000
585+++ tests/autopilot/webbrowser_app/tests/test_selection.py 2014-12-13 01:23:19 +0000
586@@ -27,7 +27,7 @@
587 def setUp(self):
588 super(TestSelection, self).setUp()
589 url = self.base_url + "/selection"
590- self.go_to_url(url)
591+ self.main_window.go_to_url(url)
592 self.assert_page_eventually_loaded(url)
593 webview = self.main_window.get_current_webview()
594 self.pointing_device.move_to_object(webview)
595
596=== modified file 'tests/autopilot/webbrowser_app/tests/test_session_save_restore.py'
597--- tests/autopilot/webbrowser_app/tests/test_session_save_restore.py 2014-11-18 20:03:46 +0000
598+++ tests/autopilot/webbrowser_app/tests/test_session_save_restore.py 2014-12-13 01:23:19 +0000
599@@ -15,7 +15,6 @@
600 # along with this program. If not, see <http://www.gnu.org/licenses/>.
601
602 from autopilot.matchers import Eventually
603-from autopilot.platform import model
604 from testtools.matchers import Equals
605
606 from webbrowser_app.tests import StartOpenRemotePageTestCaseBase
607@@ -27,10 +26,7 @@
608 self.open_tabs_view()
609 self.open_new_tab()
610 new_tab_view = self.main_window.get_new_tab_view()
611- if model() != 'Desktop':
612- self.focus_address_bar()
613- self.type_in_address_bar(url)
614- self.keyboard.press_and_release("Enter")
615+ self.main_window.go_to_url(url)
616 new_tab_view.wait_until_destroyed()
617
618 def test_session_is_saved_and_restored(self):
619
620=== modified file 'tests/autopilot/webbrowser_app/tests/test_tabs.py'
621--- tests/autopilot/webbrowser_app/tests/test_tabs.py 2014-11-18 20:03:46 +0000
622+++ tests/autopilot/webbrowser_app/tests/test_tabs.py 2014-12-13 01:23:19 +0000
623@@ -48,10 +48,7 @@
624 self.open_new_tab()
625 new_tab_view = self.main_window.get_new_tab_view()
626 url = self.base_url + "/test2"
627- if model() != 'Desktop':
628- self.focus_address_bar()
629- self.type_in_address_bar(url)
630- self.keyboard.press_and_release("Enter")
631+ self.main_window.go_to_url(url)
632 new_tab_view.wait_until_destroyed()
633
634 def test_close_last_open_tab(self):
635@@ -63,7 +60,7 @@
636 self.assert_number_webviews_eventually(1)
637 self.main_window.get_new_tab_view()
638 if model() == 'Desktop':
639- address_bar = self.main_window.get_chrome().get_address_bar()
640+ address_bar = self.main_window.address_bar
641 self.assertThat(address_bar.activeFocus, Eventually(Equals(True)))
642 webview = self.main_window.get_current_webview()
643 self.assertThat(webview.url, Equals(""))
644@@ -72,10 +69,7 @@
645 self.open_new_tab()
646 new_tab_view = self.main_window.get_new_tab_view()
647 url = self.base_url + "/test2"
648- if model() != 'Desktop':
649- self.focus_address_bar()
650- self.type_in_address_bar(url)
651- self.keyboard.press_and_release("Enter")
652+ self.main_window.go_to_url(url)
653 new_tab_view.wait_until_destroyed()
654 self.assert_number_webviews_eventually(2)
655 self.open_tabs_view()
656@@ -98,10 +92,7 @@
657 self.check_current_tab("")
658 new_tab_view = self.main_window.get_new_tab_view()
659 url = self.base_url + "/test2"
660- if model() != 'Desktop':
661- self.focus_address_bar()
662- self.type_in_address_bar(url)
663- self.keyboard.press_and_release("Enter")
664+ self.main_window.go_to_url(url)
665 new_tab_view.wait_until_destroyed()
666 self.check_current_tab(url)
667
668@@ -121,10 +112,7 @@
669
670 def test_error_only_for_current_tab(self):
671 self.open_new_tab()
672- if model() != 'Desktop':
673- self.focus_address_bar()
674- self.type_in_address_bar("http://invalid")
675- self.keyboard.press_and_release("Enter")
676+ self.main_window.go_to_url('http://invalid')
677 error = self.main_window.get_error_sheet()
678 self.assertThat(error.visible, Eventually(Equals(True)))
679
680@@ -140,7 +128,7 @@
681
682 def test_open_target_blank_in_new_tab(self):
683 url = self.base_url + "/blanktargetlink"
684- self.go_to_url(url)
685+ self.main_window.go_to_url(url)
686 self.assert_page_eventually_loaded(url)
687 webview = self.main_window.get_current_webview()
688 self.pointing_device.click_object(webview)
689@@ -149,7 +137,7 @@
690
691 def test_open_iframe_target_blank_in_new_tab(self):
692 url = self.base_url + "/fulliframewithblanktargetlink"
693- self.go_to_url(url)
694+ self.main_window.go_to_url(url)
695 self.assert_page_eventually_loaded(url)
696 webview = self.main_window.get_current_webview()
697 self.pointing_device.click_object(webview)
698@@ -157,7 +145,7 @@
699 self.assert_number_webviews_eventually(2)
700
701 def test_selecting_tab_focuses_webview(self):
702- self.focus_address_bar()
703+ self.main_window.address_bar.focus()
704 self.open_tabs_view()
705 tabs_view = self.main_window.get_tabs_view()
706 previews = tabs_view.get_previews()
707@@ -165,5 +153,5 @@
708 tabs_view.wait_until_destroyed()
709 webview = self.main_window.get_current_webview()
710 self.assertThat(webview.activeFocus, Eventually(Equals(True)))
711- address_bar = self.main_window.get_chrome().get_address_bar()
712+ address_bar = self.main_window.address_bar
713 self.assertThat(address_bar.activeFocus, Eventually(Equals(False)))
714
715=== modified file 'tests/autopilot/webbrowser_app/tests/test_title.py'
716--- tests/autopilot/webbrowser_app/tests/test_title.py 2014-11-18 20:03:46 +0000
717+++ tests/autopilot/webbrowser_app/tests/test_title.py 2014-12-13 01:23:19 +0000
718@@ -25,6 +25,6 @@
719 """Tests that the window’s title reflects the page title."""
720
721 def test_window_title(self):
722- self.go_to_url(self.base_url + "/test2")
723+ self.main_window.go_to_url(self.base_url + "/test2")
724 self.assertThat(self.main_window.get_window().title,
725 Eventually(Contains("test page 2")))

Subscribers

People subscribed via source and target branches

to status/vote changes: