Merge lp:~osomon/webbrowser-app/always-use-local-server-in-tests into lp:webbrowser-app

Proposed by Olivier Tilloy
Status: Merged
Approved by: Ugo Riboni
Approved revision: 405
Merged at revision: 416
Proposed branch: lp:~osomon/webbrowser-app/always-use-local-server-in-tests
Merge into: lp:webbrowser-app
Diff against target: 259 lines (+29/-72)
8 files modified
tests/autopilot/webbrowser_app/tests/__init__.py (+0/-44)
tests/autopilot/webbrowser_app/tests/http_server.py (+10/-0)
tests/autopilot/webbrowser_app/tests/test_activity.py (+1/-1)
tests/autopilot/webbrowser_app/tests/test_backforward.py (+4/-4)
tests/autopilot/webbrowser_app/tests/test_errorsheet.py (+4/-4)
tests/autopilot/webbrowser_app/tests/test_progressbar.py (+4/-10)
tests/autopilot/webbrowser_app/tests/test_title.py (+2/-5)
tests/autopilot/webbrowser_app/tests/test_toolbar.py (+4/-4)
To merge this branch: bzr merge lp:~osomon/webbrowser-app/always-use-local-server-in-tests
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Ubuntu Phablet Team Pending
Review via email: mp+194377@code.launchpad.net

Commit message

Use the local test server everywhere
instead of writing temporary html pages on disk.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:404
http://jenkins.qa.ubuntu.com/job/webbrowser-app-ci/529/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty/577
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty-touch/562/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/webbrowser-app-trusty-amd64-ci/31
    SUCCESS: http://jenkins.qa.ubuntu.com/job/webbrowser-app-trusty-armhf-ci/31
        deb: http://jenkins.qa.ubuntu.com/job/webbrowser-app-trusty-armhf-ci/31/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/webbrowser-app-trusty-i386-ci/31
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-trusty/530
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/577
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/577/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/562
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/562/artifact/work/output/*zip*/output.zip
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-maguro/3026/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-mako/3207
    SUCCESS: http://10.97.0.26:8080/job/touch-flash-device/1236
    SUCCESS: http://10.97.0.26:8080/job/touch-flash-device/1233

Click here to trigger a rebuild:
http://10.97.0.26:8080/job/webbrowser-app-ci/529/rebuild

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

PASSED: Continuous integration, rev:404
http://jenkins.qa.ubuntu.com/job/webbrowser-app-ci/531/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty/584
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty-touch/569
    SUCCESS: http://jenkins.qa.ubuntu.com/job/webbrowser-app-trusty-amd64-ci/33
    SUCCESS: http://jenkins.qa.ubuntu.com/job/webbrowser-app-trusty-armhf-ci/33
        deb: http://jenkins.qa.ubuntu.com/job/webbrowser-app-trusty-armhf-ci/33/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/webbrowser-app-trusty-i386-ci/33
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-trusty/536
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/584
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/584/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/569
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/569/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-maguro/3030
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-mako/3212
    SUCCESS: http://10.97.0.26:8080/job/touch-flash-device/1247
    SUCCESS: http://10.97.0.26:8080/job/touch-flash-device/1244

Click here to trigger a rebuild:
http://10.97.0.26:8080/job/webbrowser-app-ci/531/rebuild

review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
405. By Olivier Tilloy

Merge the latest changes from trunk, and resolve one conflict.

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-11-05 22:44:16 +0000
3+++ tests/autopilot/webbrowser_app/tests/__init__.py 2013-11-18 09:41:27 +0000
4@@ -10,7 +10,6 @@
5 import os
6 import os.path
7 import shutil
8-import tempfile
9
10 from testtools.matchers import Contains, Equals
11
12@@ -36,26 +35,16 @@
13 d_f = "--desktop_file_hint=/usr/share/applications/webbrowser-app.desktop"
14
15 ARGS = []
16- _temp_pages = []
17
18 def setUp(self):
19 self.pointing_device = toolkit_emulators.get_pointing_device()
20 super(BrowserTestCaseBase, self).setUp()
21- self.addCleanup(self.cleanup)
22 if os.path.exists(self.local_location):
23 self.launch_test_local()
24 else:
25 self.launch_test_installed()
26 self.main_window.visible.wait_for(True)
27
28- def cleanup(self):
29- for page in self._temp_pages:
30- try:
31- os.remove(page)
32- except:
33- pass
34- self._temp_pages = []
35-
36 def launch_test_local(self):
37 self.app = self.launch_test_application(
38 self.local_location,
39@@ -87,22 +76,6 @@
40 def main_window(self):
41 return self.app.select_single(Browser)
42
43- def make_raw_html_page(self, html):
44- fd, path = tempfile.mkstemp(suffix=".html", text=True)
45- os.write(fd, html)
46- os.close(fd)
47- self._temp_pages.append(path)
48- return "file://" + path
49-
50- def make_html_page(self, title, body):
51- """
52- Write a web page using title and body onto a temporary file,
53- and return the corresponding local "file://…" URL. The file
54- is automatically deleted after running the calling test method.
55- """
56- html = "<html><title>%s</title><body>%s</body></html>" % (title, body)
57- return self.make_raw_html_page(html)
58-
59 def assert_osk_eventually_shown(self):
60 if model() != 'Desktop':
61 keyboardRectangle = self.main_window.get_keyboard_rectangle()
62@@ -182,23 +155,6 @@
63 self.main_window.get_activity_view()
64
65
66-class StartOpenLocalPageTestCaseBase(BrowserTestCaseBase):
67-
68- """Helper test class that opens the browser at a local URL instead of
69- defaulting to the homepage."""
70-
71- def setUp(self):
72- title = "start page"
73- body = "<p>Lorem ipsum dolor sit amet.</p>"
74- self.url = self.make_html_page(title, body)
75- self.ARGS = [self.url]
76- super(StartOpenLocalPageTestCaseBase, self).setUp()
77- self.assert_home_page_eventually_loaded()
78-
79- def assert_home_page_eventually_loaded(self):
80- self.assert_page_eventually_loaded(self.url)
81-
82-
83 class StartOpenRemotePageTestCaseBase(BrowserTestCaseBase):
84
85 """
86
87=== modified file 'tests/autopilot/webbrowser_app/tests/http_server.py'
88--- tests/autopilot/webbrowser_app/tests/http_server.py 2013-09-30 05:54:59 +0000
89+++ tests/autopilot/webbrowser_app/tests/http_server.py 2013-11-18 09:41:27 +0000
90@@ -49,6 +49,16 @@
91 html = self.make_html(title, body)
92 time.sleep(delay)
93 self.send_html(html)
94+ elif self.path.startswith("/clickanywherethenwait/"):
95+ # craft a page that accepts clicks anywhere inside its window
96+ # and that redirects to a page that takes some time to load
97+ delay = int(self.path[23:])
98+ self.send_response(200)
99+ html = '<html><body style="margin: 0">'
100+ html += '<a href="/wait/%d">' % delay
101+ html += '<div style="height: 100%"></div></a>'
102+ html += '</body></html>'
103+ self.send_html(html)
104 elif self.path == "/blanktargetlink":
105 # craft a page that accepts clicks anywhere inside its window
106 # and that requests opening another page in a new tab
107
108=== modified file 'tests/autopilot/webbrowser_app/tests/test_activity.py'
109--- tests/autopilot/webbrowser_app/tests/test_activity.py 2013-10-04 09:44:02 +0000
110+++ tests/autopilot/webbrowser_app/tests/test_activity.py 2013-11-18 09:41:27 +0000
111@@ -20,7 +20,7 @@
112 self.assert_chrome_eventually_hidden()
113 self.main_window.open_toolbar()
114 self.clear_address_bar()
115- url = "http://localhost:%d/aleaiactaest" % self.server.port
116+ url = self.base_url + "/aleaiactaest"
117 self.type_in_address_bar(url)
118 self.keyboard.press_and_release("Enter")
119 self.assert_activity_view_eventually_hidden()
120
121=== modified file 'tests/autopilot/webbrowser_app/tests/test_backforward.py'
122--- tests/autopilot/webbrowser_app/tests/test_backforward.py 2013-08-29 16:28:44 +0000
123+++ tests/autopilot/webbrowser_app/tests/test_backforward.py 2013-11-18 09:41:27 +0000
124@@ -11,13 +11,13 @@
125 from testtools.matchers import Equals
126 from autopilot.matchers import Eventually
127
128-from webbrowser_app.tests import StartOpenLocalPageTestCaseBase
129+from webbrowser_app.tests import StartOpenRemotePageTestCaseBase
130
131
132 LOREMIPSUM = "<p>Lorem ipsum dolor sit amet.</p>"
133
134
135-class TestBackForward(StartOpenLocalPageTestCaseBase):
136+class TestBackForward(StartOpenRemotePageTestCaseBase):
137
138 """Tests the back and forward functionality."""
139
140@@ -34,13 +34,13 @@
141 def test_opening_new_page_enables_back_button(self):
142 back_button = self.main_window.get_back_button()
143 self.assertThat(back_button.enabled, Equals(False))
144- url = self.make_html_page("page 2", LOREMIPSUM)
145+ url = self.base_url + "/aleaiactaest"
146 self.go_to_url(url)
147 self.assert_page_eventually_loaded(url)
148 self.assertThat(back_button.enabled, Eventually(Equals(True)))
149
150 def test_navigating_back_enables_forward_button(self):
151- url = self.make_html_page("page 2", LOREMIPSUM)
152+ url = self.base_url + "/aleaiactaest"
153 self.go_to_url(url)
154 self.assert_page_eventually_loaded(url)
155 forward_button = self.main_window.get_forward_button()
156
157=== modified file 'tests/autopilot/webbrowser_app/tests/test_errorsheet.py'
158--- tests/autopilot/webbrowser_app/tests/test_errorsheet.py 2013-05-14 14:36:11 +0000
159+++ tests/autopilot/webbrowser_app/tests/test_errorsheet.py 2013-11-18 09:41:27 +0000
160@@ -11,10 +11,10 @@
161 from testtools.matchers import Equals
162 from autopilot.matchers import Eventually
163
164-from webbrowser_app.tests import StartOpenLocalPageTestCaseBase
165-
166-
167-class TestErrorSheet(StartOpenLocalPageTestCaseBase):
168+from webbrowser_app.tests import StartOpenRemotePageTestCaseBase
169+
170+
171+class TestErrorSheet(StartOpenRemotePageTestCaseBase):
172
173 """Tests the error message functionality."""
174
175
176=== modified file 'tests/autopilot/webbrowser_app/tests/test_progressbar.py'
177--- tests/autopilot/webbrowser_app/tests/test_progressbar.py 2013-09-27 11:02:31 +0000
178+++ tests/autopilot/webbrowser_app/tests/test_progressbar.py 2013-11-18 09:41:27 +0000
179@@ -52,20 +52,14 @@
180
181 def test_chrome_hides_when_loaded(self):
182 self.assert_chrome_eventually_hidden()
183- url = "http://localhost:%d/wait/3" % self.server.port
184+ url = self.base_url + "/wait/3"
185 self.go_to_url(url)
186 self.assert_chrome_eventually_shown()
187 self.assert_page_eventually_loaded(url)
188 self.assert_chrome_eventually_hidden()
189
190 def test_load_page_from_link_reveals_chrome(self):
191- # craft a page that accepts clicks anywhere inside its window
192- style = "'margin: 0; height: 100%'"
193- url = "http://localhost:%d/wait/3" % self.server.port
194- script = "'window.location = \"%s\"'" % url
195- html = "<html><body style=%s onclick=%s></body></html>" % \
196- (style, script)
197- url = self.make_raw_html_page(html)
198+ url = self.base_url + "/clickanywherethenwait/3"
199 self.go_to_url(url)
200 self.assert_page_eventually_loaded(url)
201 self.assert_chrome_eventually_hidden()
202@@ -77,7 +71,7 @@
203 # simulate user interaction to hide the chrome while loading,
204 # and ensure it doesn’t re-appear when loaded
205 self.assert_chrome_eventually_hidden()
206- url = "http://localhost:%d/wait/3" % self.server.port
207+ url = self.base_url + "/wait/3"
208 self.go_to_url(url)
209 self.assert_chrome_eventually_shown()
210 webview = self.main_window.get_current_webview()
211@@ -90,7 +84,7 @@
212 # ensure that the chrome is not automatically hidden
213 # when the user interrupts a page that was loading
214 self.assert_chrome_eventually_hidden()
215- url = "http://localhost:%d/wait/5" % self.server.port
216+ url = self.base_url + "/wait/5"
217 self.go_to_url(url)
218 self.assert_page_eventually_loading()
219 self.assert_chrome_eventually_shown()
220
221=== modified file 'tests/autopilot/webbrowser_app/tests/test_title.py'
222--- tests/autopilot/webbrowser_app/tests/test_title.py 2013-11-08 07:15:40 +0000
223+++ tests/autopilot/webbrowser_app/tests/test_title.py 2013-11-18 09:41:27 +0000
224@@ -19,10 +19,7 @@
225 """Tests that the window’s title reflects the page title."""
226
227 def test_window_title(self):
228- title = "Alice in Wonderland"
229- body = "<p>Lorem ipsum dolor sit amet.</p>"
230- url = self.make_html_page(title, body)
231- self.go_to_url(url)
232+ self.go_to_url(self.base_url + "/aleaiactaest")
233 #window = self.app.select_single("QQuickWindow")
234 # XXX: for some reason, autopilot finds two instances of QQuickWindow.
235 # One is the correct one, and the other one is not visible, its
236@@ -30,4 +27,4 @@
237 # object, and it has no children.
238 # See https://bugs.launchpad.net/bugs/1248620.
239 window = self.app.select_single("QQuickWindow", visible=True)
240- self.assertThat(window.title, Eventually(Contains(title)))
241+ self.assertThat(window.title, Eventually(Contains("Alea Iacta Est")))
242
243=== modified file 'tests/autopilot/webbrowser_app/tests/test_toolbar.py'
244--- tests/autopilot/webbrowser_app/tests/test_toolbar.py 2013-08-29 16:28:44 +0000
245+++ tests/autopilot/webbrowser_app/tests/test_toolbar.py 2013-11-18 09:41:27 +0000
246@@ -8,10 +8,10 @@
247
248 from __future__ import absolute_import
249
250-from webbrowser_app.tests import StartOpenLocalPageTestCaseBase
251-
252-
253-class TestToolbar(StartOpenLocalPageTestCaseBase):
254+from webbrowser_app.tests import StartOpenRemotePageTestCaseBase
255+
256+
257+class TestToolbar(StartOpenRemotePageTestCaseBase):
258
259 """Tests interaction with the toolbar."""
260

Subscribers

People subscribed via source and target branches

to status/vote changes: