Merge lp:~michael-sheldon/webbrowser-app/simplify-address-bar into lp:webbrowser-app

Proposed by Michael Sheldon
Status: Merged
Approved by: Bill Filler
Approved revision: 605
Merged at revision: 710
Proposed branch: lp:~michael-sheldon/webbrowser-app/simplify-address-bar
Merge into: lp:webbrowser-app
Diff against target: 166 lines (+71/-18)
5 files modified
src/app/webbrowser/AddressBar.qml (+36/-16)
src/app/webbrowser/Chrome.qml (+1/-0)
tests/autopilot/webbrowser_app/tests/__init__.py (+1/-0)
tests/autopilot/webbrowser_app/tests/test_addressbar_states.py (+12/-2)
tests/unittests/qml/tst_AddressBar.qml (+21/-0)
To merge this branch: bzr merge lp:~michael-sheldon/webbrowser-app/simplify-address-bar
Reviewer Review Type Date Requested Status
Bill Filler (community) Approve
PS Jenkins bot continuous-integration Needs Fixing
Olivier Tilloy Needs Fixing
Review via email: mp+232384@code.launchpad.net

Commit message

Simplify the address displayed in the address bar when not being edited

Description of the change

Simplify the address displayed in the address bar when not being edited

To post a comment you must log in.
Revision history for this message
Michael Sheldon (michael-sheldon) wrote :

Are there any related MPs required for this MP to build/function as expected? Please list.

 * No

Is your branch in sync with latest trunk (e.g. bzr pull lp:trunk -> no changes)

 * Yes

Did you perform an exploratory manual test run of your code change and any related functionality on device or emulator?

 * Yes

Did you successfully run all tests found in your component's Test Plan (https://wiki.ubuntu.com/Process/Merges/TestPlan/webbrowser-app) on device or emulator?

 * Yes

If you changed the UI, was the change specified/approved by design?

 * Yes

If you changed UI labels, did you update the pot file?

 * No change

If you changed the packaging (debian), did you add a core-dev as a reviewer to this MP?

 * No change

598. By Michael Sheldon

Remove accidentally added merge file

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:598
http://jenkins.qa.ubuntu.com/job/webbrowser-app-ci/1065/
Executed test runs:
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-utopic-touch/4110
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-utopic/3139/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/webbrowser-app-utopic-amd64-ci/264
    SUCCESS: http://jenkins.qa.ubuntu.com/job/webbrowser-app-utopic-armhf-ci/264
        deb: http://jenkins.qa.ubuntu.com/job/webbrowser-app-utopic-armhf-ci/264/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/webbrowser-app-utopic-i386-ci/264
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-runner-mako/3943
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-armhf/5362
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-armhf/5362/artifact/work/output/*zip*/output.zip
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/12200
    FAILURE: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-utopic/2566/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-amd64/3426
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-amd64/3426/artifact/work/output/*zip*/output.zip

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

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

132 + {text: "ubuntu.com", url: "http://user:<email address hidden>"},
133 + {text: "ubuntu.com", url: "http://user:<email address hidden>"},

this test row is duplicated

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

In simplifyUrl(…):

 - there are several calls to url.toString(), you might want to define a var that contains its value

 - if(hasProtocol) : missing whitespace before the opening parenthesis

 - domain.replace("www.", "") : this should happen only if "www." is at the beginning of the domain (e.g. "http://www.com" should not return "com" as a domain, you could add a test case for that)

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

Could you please add an autopilot test to verify that focusing / unfocusing / focusing again the address bar updates its contents as expected?

599. By Michael Sheldon

Reduce number of toString calls when simplifying URL and ensure 'www.' only get replaced at the beginning of a URL

600. By Michael Sheldon

Remove duplicate test case

601. By Michael Sheldon

Add test for URLs containing 'www.' in the middle of the domain

602. By Michael Sheldon

Add check for urls of the form http://www.com when simplifying domains

603. By Michael Sheldon

Add autopilot test for url simplification when focusing, defocusing and refocusing the addressbar

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Bill Filler (bfiller) wrote :

Seems to work well except in one case and I don't know what the intended design is.
If you load a page, you'll see the simplified url. Then if you click in the field you'll see the expanded url which is correct. But then clicking outside of the url field I would expect the url to show it's simplified form again, but it does not. It shows long form until you reload the page again.

review: Needs Fixing
Revision history for this message
Bill Filler (bfiller) wrote :

I can't always reproduce the problem, but is was happening for a while. Other thing I noticed when in that state is that selecting the field would not cause the Refresh button to be displayed so there was no way to refresh the page.

604. By Michael Sheldon

Merge from trunk

605. By Michael Sheldon

Allow address bar to return to simplified URL whilst still loading

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:605
http://jenkins.qa.ubuntu.com/job/webbrowser-app-ci/1079/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-utopic-touch/4594
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-utopic/3401/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/webbrowser-app-utopic-amd64-ci/278
    SUCCESS: http://jenkins.qa.ubuntu.com/job/webbrowser-app-utopic-armhf-ci/278
        deb: http://jenkins.qa.ubuntu.com/job/webbrowser-app-utopic-armhf-ci/278/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/webbrowser-app-utopic-i386-ci/278
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-runner-mako/4377
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-armhf/5846
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-armhf/5846/artifact/work/output/*zip*/output.zip
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/12864
    FAILURE: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-utopic/2805/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-amd64/3703
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-amd64/3703/artifact/work/output/*zip*/output.zip

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

review: Needs Fixing (continuous-integration)
Revision history for this message
Bill Filler (bfiller) wrote :

Did you perform an exploratory manual test run of the code change and any related functionality on device or emulator?
yes

Did you successfully run all tests found in your component's Test Plan (https://wiki.ubuntu.com/Process/Merges/TestPlan/<package-name>) on device or emulator?
yes

Did CI run pass? If not, please explain why.
yes

Have you checked that submitter has accurately filled out the submitter checklist and has taken no shortcut?
yes

review: Approve

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-08-13 22:04:39 +0000
3+++ src/app/webbrowser/AddressBar.qml 2014-09-08 10:11:06 +0000
4@@ -34,6 +34,7 @@
5 signal requestStop()
6 signal pressAndHold()
7 property string searchUrl
8+ signal textFieldFocused()
9
10 height: textField.height
11
12@@ -161,24 +162,13 @@
13
14 onAccepted: if (addressbar.state != "") parent.validate()
15
16- function ensureSchemeVisibleWhenUnfocused() {
17- // Ensure the beginning of the URL is always visible when unfocused.
18- // In the future, we’ll have a smarter address bar that hides the
19- // scheme to save some extra space and display more of the
20- // meaningful part of the URL (domain name and path).
21- if (!activeFocus) {
22- cursorPosition = 0
23- }
24- }
25 onActiveFocusChanged: {
26- if (!activeFocus) {
27- if (!addressbar.loading && addressbar.actualUrl.toString()) {
28- text = addressbar.actualUrl
29- }
30+ if (activeFocus) {
31+ addressbar.textFieldFocused();
32+ } else if (addressbar.actualUrl.toString()) {
33+ text = addressbar.simplifyUrl(addressbar.actualUrl)
34 }
35- ensureSchemeVisibleWhenUnfocused()
36 }
37- onTextChanged: ensureSchemeVisibleWhenUnfocused()
38
39 // Make sure that all the text is selected at the first click
40 MouseArea {
41@@ -249,5 +239,35 @@
42 validated()
43 }
44
45- onActualUrlChanged: text = actualUrl
46+ function simplifyUrl(url) {
47+ var urlString = url.toString();
48+ var hasProtocol = urlString.indexOf("://") != -1
49+ var domain;
50+ if (hasProtocol) {
51+ if (urlString.split("://")[0] == "file") {
52+ // Don't process file:// urls
53+ return url;
54+ }
55+ domain = urlString.split('/')[2];
56+ } else {
57+ domain = urlString.split('/')[0];
58+ }
59+ if (typeof domain !== 'undefined' && domain.length > 0) {
60+ // Remove user component if present
61+ var userRemoved = domain.split('@')[1];
62+ if (typeof userRemoved !== 'undefined') {
63+ domain = userRemoved;
64+ }
65+ // Remove port number if present
66+ domain = domain.split(':')[0];
67+ if (domain.lastIndexOf('.') != 3) { // http://www.com shouldn't be trimmed
68+ domain = domain.replace(/^www\./, "");
69+ }
70+ return domain;
71+ } else {
72+ return url;
73+ }
74+ }
75+
76+ onActualUrlChanged: text = simplifyUrl(actualUrl)
77 }
78
79=== modified file 'src/app/webbrowser/Chrome.qml'
80--- src/app/webbrowser/Chrome.qml 2014-08-18 09:44:55 +0000
81+++ src/app/webbrowser/Chrome.qml 2014-09-08 10:11:06 +0000
82@@ -107,6 +107,7 @@
83 onValidated: chrome.webview.url = requestedUrl
84 onRequestReload: chrome.webview.reload()
85 onRequestStop: chrome.webview.stop()
86+ onTextFieldFocused: text = chrome.webview.url
87
88 Connections {
89 target: chrome.webview
90
91=== modified file 'tests/autopilot/webbrowser_app/tests/__init__.py'
92--- tests/autopilot/webbrowser_app/tests/__init__.py 2014-08-20 10:42:40 +0000
93+++ tests/autopilot/webbrowser_app/tests/__init__.py 2014-09-08 10:11:06 +0000
94@@ -186,6 +186,7 @@
95 self.server = http_server.HTTPServerInAThread()
96 self.addCleanup(self.server.cleanup)
97 self.base_url = "http://localhost:{}".format(self.server.port)
98+ self.domain = "localhost"
99 self.ping_server()
100 self.url = self.base_url + "/loremipsum"
101 self.ARGS = self.ARGS + [self.url]
102
103=== modified file 'tests/autopilot/webbrowser_app/tests/test_addressbar_states.py'
104--- tests/autopilot/webbrowser_app/tests/test_addressbar_states.py 2014-08-13 22:04:39 +0000
105+++ tests/autopilot/webbrowser_app/tests/test_addressbar_states.py 2014-09-08 10:11:06 +0000
106@@ -51,12 +51,12 @@
107
108 def test_url_reset_when_unfocused(self):
109 address_bar = self.main_window.get_chrome().get_address_bar()
110- self.assertThat(address_bar.text, Eventually(Equals(self.url)))
111+ self.assertThat(address_bar.text, Eventually(Equals(self.domain)))
112 self.clear_address_bar()
113 self.assertThat(address_bar.text, Eventually(Equals("")))
114 webview = self.main_window.get_current_webview()
115 self.pointing_device.click_object(webview)
116- self.assertThat(address_bar.text, Eventually(Equals(self.url)))
117+ self.assertThat(address_bar.text, Eventually(Equals(self.domain)))
118
119 def test_looses_focus_when_loading_starts(self):
120 address_bar = self.main_window.get_chrome().get_address_bar()
121@@ -77,3 +77,13 @@
122 self.pointing_device.click_object(action_button)
123 self.assertThat(address_bar.state, Eventually(Equals("")))
124 self.assertThat(address_bar.activeFocus, Eventually(Equals(False)))
125+
126+ def test_url_simplification(self):
127+ address_bar = self.main_window.get_chrome().get_address_bar()
128+ self.pointing_device.click_object(address_bar)
129+ self.assertThat(address_bar.text, Eventually(Equals(self.url)))
130+ webview = self.main_window.get_current_webview()
131+ self.pointing_device.click_object(webview)
132+ self.assertThat(address_bar.text, Eventually(Equals(self.domain)))
133+ self.pointing_device.click_object(address_bar)
134+ self.assertThat(address_bar.text, Eventually(Equals(self.url)))
135
136=== modified file 'tests/unittests/qml/tst_AddressBar.qml'
137--- tests/unittests/qml/tst_AddressBar.qml 2014-06-30 11:01:27 +0000
138+++ tests/unittests/qml/tst_AddressBar.qml 2014-09-08 10:11:06 +0000
139@@ -113,6 +113,27 @@
140 compare(addressBar.requestedUrl, data.requestedUrl)
141 }
142
143+ function test_simplify_data() {
144+ return [
145+ {text: "ubuntu.com", url: "http://www.ubuntu.com"},
146+ {text: "ubuntu.com", url: "http://www.ubuntu.com/"},
147+ {text: "ubuntu.com", url: "http://www.ubuntu.com:80"},
148+ {text: "ubuntuwww.com", url: "http://www.ubuntuwww.com"},
149+ {text: "www.com", url: "http://www.com"},
150+ {text: "ubuntu.com", url: "http://user@www.ubuntu.com"},
151+ {text: "ubuntu.com", url: "http://user:password@www.ubuntu.com"},
152+ {text: "ubuntu.com", url: "http://user:password@www.ubuntu.com:80"},
153+ {text: "file:///home/phablet/", url: "file:///home/phablet/"},
154+ {text: "en.wikipedia.org", url: "http://en.wikipedia.org/wiki/Ubuntu"},
155+ {text: "en.wikipedia.org", url: "en.wikipedia.org"},
156+ {text: "en.wikipedia.org", url: "en.wikipedia.org/wiki/Foo"}
157+ ]
158+ }
159+
160+ function test_simplify(data) {
161+ compare(addressBar.simplifyUrl(data.url), data.text);
162+ }
163+
164 AddressBar {
165 id: addressBar
166 searchUrl: "http://www.ubuntu.com/search?q={searchTerms}"

Subscribers

People subscribed via source and target branches

to status/vote changes: