Merge lp:~osomon/webbrowser-app/settings-page-ap-tests into lp:webbrowser-app

Proposed by Olivier Tilloy on 2015-03-31
Status: Merged
Approved by: Olivier Tilloy on 2015-04-07
Approved revision: 973
Merged at revision: 957
Proposed branch: lp:~osomon/webbrowser-app/settings-page-ap-tests
Merge into: lp:webbrowser-app
Prerequisite: lp:~rpadovani/webbrowser-app/settings-page
Diff against target: 317 lines (+183/-2)
6 files modified
README (+2/-2)
src/app/webbrowser/SettingsPage.qml (+20/-0)
src/app/webbrowser/SettingsPageHeader.qml (+2/-0)
tests/autopilot/webbrowser_app/emulators/browser.py (+36/-0)
tests/autopilot/webbrowser_app/tests/__init__.py (+9/-0)
tests/autopilot/webbrowser_app/tests/test_settings.py (+114/-0)
To merge this branch: bzr merge lp:~osomon/webbrowser-app/settings-page-ap-tests
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Needs Fixing on 2015-04-07
Ubuntu Phablet Team 2015-03-31 Pending
Review via email: mp+254788@code.launchpad.net

Commit Message

Autopilot tests for the settings UI.

To post a comment you must log in.
969. By Olivier Tilloy on 2015-03-31

Add a test to clear browsing history.

970. By Olivier Tilloy on 2015-03-31

Add a test to reset browser settings.

971. By Olivier Tilloy on 2015-04-01

Updated README.

972. By Olivier Tilloy on 2015-04-07

Merge the latest changes from Riccardo’s branch.

973. By Olivier Tilloy on 2015-04-07

Make test_reset_browser_settings() more complete, by also verifying the state of checkbox options.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'README'
2--- README 2015-04-07 13:09:37 +0000
3+++ README 2015-04-07 13:09:38 +0000
4@@ -71,8 +71,8 @@
5
6 = Settings =
7
8-webbrowser-app supports a limited set of custom settings, currently not exposed
9-in the UI. The settings are persisted on disk in the following INI-like file:
10+webbrowser-app supports a limited set of custom settings, persisted on disk in
11+the following INI-like file:
12
13 $HOME/.config/webbrowser-app/webbrowser-app.conf
14
15
16=== modified file 'src/app/webbrowser/SettingsPage.qml'
17--- src/app/webbrowser/SettingsPage.qml 2015-04-07 13:09:37 +0000
18+++ src/app/webbrowser/SettingsPage.qml 2015-04-07 13:09:38 +0000
19@@ -87,6 +87,8 @@
20 }
21
22 ListItem.Subtitled {
23+ objectName: "homepage"
24+
25 text: i18n.tr("Homepage")
26 subText: settingsObject.homepage
27
28@@ -94,6 +96,8 @@
29 }
30
31 ListItem.Standard {
32+ objectName: "restoreSession"
33+
34 text: i18n.tr("Restore previous session at startup")
35 highlightWhenPressed: false
36
37@@ -109,6 +113,8 @@
38 }
39
40 ListItem.Standard {
41+ objectName: "backgroundTabs"
42+
43 text: i18n.tr("Allow opening new tabs in background")
44 highlightWhenPressed: false
45
46@@ -127,13 +133,18 @@
47 }
48
49 ListItem.Standard {
50+ objectName: "privacy"
51+
52 text: i18n.tr("Privacy")
53
54 onClicked: privacyComponent.createObject(subpageContainer);
55 }
56
57 ListItem.Standard {
58+ objectName: "reset"
59+
60 text: i18n.tr("Reset browser settings")
61+
62 onClicked: settingsObject.restoreDefaults();
63 }
64 }
65@@ -198,6 +209,8 @@
66
67 Item {
68 id: privacyItem
69+ objectName: "privacySettings"
70+
71 anchors.fill: parent
72
73 Rectangle {
74@@ -228,6 +241,7 @@
75 width: parent.width
76
77 ListItem.Standard {
78+ objectName: "privacy.clearHistory"
79 text: i18n.tr("Clear Browsing History")
80 onClicked: historyModel.clearAll();
81 enabled: historyModel.count > 0
82@@ -240,8 +254,11 @@
83
84 Component {
85 id: homepageDialog
86+
87 Dialog {
88 id: dialogue
89+ objectName: "homepageDialog"
90+
91 title: i18n.tr("Homepage")
92
93 Component.onCompleted: {
94@@ -251,17 +268,20 @@
95
96 TextField {
97 id: homepageTextField
98+ objectName: "homepageDialog.text"
99 text: settingsObject.homepage
100 inputMethodHints: Qt.ImhNoAutoUppercase | Qt.ImhNoPredictiveText | Qt.ImhUrlCharactersOnly
101 }
102
103 Button {
104+ objectName: "homepageDialog.cancelButton"
105 anchors { left: parent.left; right: parent.right }
106 text: i18n.tr("Cancel")
107 onClicked: PopupUtils.close(dialogue);
108 }
109
110 Button {
111+ objectName: "homepageDialog.saveButton"
112 anchors { left: parent.left; right: parent.right }
113 text: i18n.tr("Save")
114 color: "#3fb24f"
115
116=== modified file 'src/app/webbrowser/SettingsPageHeader.qml'
117--- src/app/webbrowser/SettingsPageHeader.qml 2015-04-07 13:09:37 +0000
118+++ src/app/webbrowser/SettingsPageHeader.qml 2015-04-07 13:09:38 +0000
119@@ -51,6 +51,8 @@
120
121 AbstractButton {
122 id: backButton
123+ objectName: "backButton"
124+
125 width: height
126
127 onTriggered: root.back()
128
129=== modified file 'tests/autopilot/webbrowser_app/emulators/browser.py'
130--- tests/autopilot/webbrowser_app/emulators/browser.py 2015-03-20 16:14:17 +0000
131+++ tests/autopilot/webbrowser_app/emulators/browser.py 2015-04-07 13:09:38 +0000
132@@ -101,6 +101,9 @@
133 def get_new_tab_view(self):
134 return self.wait_select_single("NewTabView", visible=True)
135
136+ def get_settings_page(self):
137+ return self.wait_select_single(SettingsPage, visible=True)
138+
139 def get_content_picker_dialog(self):
140 # only on devices
141 return self.wait_select_single("PopupBase",
142@@ -257,3 +260,36 @@
143 self.isFullyShown.wait_for(True)
144 action = self.select_single("ToolbarAction", objectName=name)
145 self.pointing_device.click_object(action)
146+
147+
148+class SettingsPage(uitk.UbuntuUIToolkitCustomProxyObjectBase):
149+
150+ def get_header(self):
151+ return self.select_single(SettingsPageHeader)
152+
153+ def get_homepage_entry(self):
154+ return self.select_single("Subtitled", objectName="homepage")
155+
156+ def get_restore_session_entry(self):
157+ return self.select_single("Standard", objectName="restoreSession")
158+
159+ def get_background_tabs_entry(self):
160+ return self.select_single("Standard", objectName="backgroundTabs")
161+
162+ def get_privacy_entry(self):
163+ return self.select_single("Standard", objectName="privacy")
164+
165+ def get_privacy_page(self):
166+ return self.wait_select_single("QQuickItem",
167+ objectName="privacySettings")
168+
169+ def get_reset_settings_entry(self):
170+ return self.select_single("Standard", objectName="reset")
171+
172+
173+class SettingsPageHeader(uitk.UbuntuUIToolkitCustomProxyObjectBase):
174+
175+ @autopilot.logging.log_action(logger.info)
176+ def click_back_button(self):
177+ button = self.select_single("AbstractButton", objectName="backButton")
178+ self.pointing_device.click_object(button)
179
180=== modified file 'tests/autopilot/webbrowser_app/tests/__init__.py'
181--- tests/autopilot/webbrowser_app/tests/__init__.py 2015-03-23 07:49:19 +0000
182+++ tests/autopilot/webbrowser_app/tests/__init__.py 2015-04-07 13:09:38 +0000
183@@ -123,6 +123,15 @@
184 self.main_window.address_bar.activeFocus,
185 Eventually(Equals(True)))
186
187+ def open_settings(self):
188+ chrome = self.main_window.chrome
189+ drawer_button = chrome.get_drawer_button()
190+ self.pointing_device.click_object(drawer_button)
191+ chrome.get_drawer()
192+ settings_action = chrome.get_drawer_action("settings")
193+ self.pointing_device.click_object(settings_action)
194+ return self.main_window.get_settings_page()
195+
196 def assert_number_webviews_eventually(self, count):
197 self.assertThat(lambda: len(self.main_window.get_webviews()),
198 Eventually(Equals(count)))
199
200=== added file 'tests/autopilot/webbrowser_app/tests/test_settings.py'
201--- tests/autopilot/webbrowser_app/tests/test_settings.py 1970-01-01 00:00:00 +0000
202+++ tests/autopilot/webbrowser_app/tests/test_settings.py 2015-04-07 13:09:38 +0000
203@@ -0,0 +1,114 @@
204+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
205+#
206+# Copyright 2015 Canonical
207+#
208+# This program is free software: you can redistribute it and/or modify it
209+# under the terms of the GNU General Public License version 3, as published
210+# by the Free Software Foundation.
211+#
212+# This program is distributed in the hope that it will be useful,
213+# but WITHOUT ANY WARRANTY; without even the implied warranty of
214+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
215+# GNU General Public License for more details.
216+#
217+# You should have received a copy of the GNU General Public License
218+# along with this program. If not, see <http://www.gnu.org/licenses/>.
219+
220+from datetime import datetime
221+
222+from webbrowser_app.tests import StartOpenRemotePageTestCaseBase
223+
224+from testtools.matchers import Equals, NotEquals
225+from autopilot.matchers import Eventually
226+from autopilot.platform import model
227+
228+import ubuntuuitoolkit as uitk
229+
230+from webbrowser_app.emulators import browser
231+
232+
233+class TestSettings(StartOpenRemotePageTestCaseBase):
234+
235+ def get_homepage_dialog(self):
236+ return self.main_window.wait_select_single("Dialog",
237+ objectName="homepageDialog")
238+
239+ def test_open_close_settings_page(self):
240+ settings = self.open_settings()
241+ settings.get_header().click_back_button()
242+ settings.wait_until_destroyed()
243+
244+ def test_change_homepage(self):
245+ settings = self.open_settings()
246+ homepage = settings.get_homepage_entry()
247+ old = homepage.subText
248+ self.assertThat(old, NotEquals(""))
249+
250+ # First test cancelling the edition
251+ self.pointing_device.click_object(homepage)
252+ dialog = self.get_homepage_dialog()
253+ textField = dialog.select_single(uitk.TextField,
254+ objectName="homepageDialog.text")
255+ self.assertThat(textField.text, Eventually(Equals(old)))
256+ cancel_button = dialog.select_single(
257+ "Button",
258+ objectName="homepageDialog.cancelButton")
259+ self.pointing_device.click_object(cancel_button)
260+ dialog.wait_until_destroyed()
261+ self.assertThat(homepage.subText, Equals(old))
262+
263+ # Then test actually changing the homepage
264+ self.pointing_device.click_object(homepage)
265+ dialog = self.get_homepage_dialog()
266+ textField = dialog.select_single(uitk.TextField,
267+ objectName="homepageDialog.text")
268+ self.assertThat(textField.text, Eventually(Equals(old)))
269+ self.pointing_device.click_object(textField)
270+ textField.activeFocus.wait_for(True)
271+ new = "http://example.org/{}".format(int(datetime.now().timestamp()))
272+ textField.write(new, True)
273+ save_button = dialog.select_single(
274+ "Button",
275+ objectName="homepageDialog.saveButton")
276+ self.pointing_device.click_object(save_button)
277+ dialog.wait_until_destroyed()
278+ self.assertThat(homepage.subText, Eventually(Equals(new)))
279+
280+ def test_open_close_privacy_settings(self):
281+ settings = self.open_settings()
282+ privacy = settings.get_privacy_entry()
283+ self.pointing_device.click_object(privacy)
284+ privacy_page = settings.get_privacy_page()
285+ privacy_header = privacy_page.select_single(browser.SettingsPageHeader)
286+ privacy_header.click_back_button()
287+ privacy_page.wait_until_destroyed()
288+
289+ def test_clear_browsing_history(self):
290+ settings = self.open_settings()
291+ privacy = settings.get_privacy_entry()
292+ self.pointing_device.click_object(privacy)
293+ privacy_page = settings.get_privacy_page()
294+ clear_history = privacy_page.select_single(
295+ "Standard",
296+ objectName="privacy.clearHistory")
297+ self.assertThat(clear_history.enabled, Equals(True))
298+ self.pointing_device.click_object(clear_history)
299+ self.assertThat(clear_history.enabled, Eventually(Equals(False)))
300+
301+ def test_reset_browser_settings(self):
302+ settings = self.open_settings()
303+ reset = settings.get_reset_settings_entry()
304+ self.pointing_device.click_object(reset)
305+
306+ homepage = settings.get_homepage_entry()
307+ self.assertThat(homepage.subText,
308+ Eventually(Equals("http://start.ubuntu.com")))
309+
310+ restore_session = settings.get_restore_session_entry()
311+ checkbox = restore_session.select_single(uitk.CheckBox)
312+ self.assertThat(checkbox.checked, Eventually(Equals(True)))
313+
314+ background_tabs = settings.get_background_tabs_entry()
315+ checkbox = background_tabs.select_single(uitk.CheckBox)
316+ self.assertThat(checkbox.checked,
317+ Eventually(Equals(model() == 'Desktop')))

Subscribers

People subscribed via source and target branches

to status/vote changes: