Merge lp:~uriboni/webbrowser-app/bookmark-folders-from-contextual-menu into lp:webbrowser-app

Proposed by Ugo Riboni
Status: Merged
Approved by: Olivier Tilloy
Approved revision: 1144
Merged at revision: 1164
Proposed branch: lp:~uriboni/webbrowser-app/bookmark-folders-from-contextual-menu
Merge into: lp:webbrowser-app
Diff against target: 492 lines (+147/-74)
10 files modified
src/app/UrlUtils.js (+10/-5)
src/app/webbrowser/AddressBar.qml (+2/-1)
src/app/webbrowser/Browser.qml (+23/-10)
src/app/webbrowser/Chrome.qml (+3/-0)
src/app/webbrowser/NavigationBar.qml (+2/-0)
tests/autopilot/webbrowser_app/emulators/browser.py (+36/-0)
tests/autopilot/webbrowser_app/tests/__init__.py (+2/-1)
tests/autopilot/webbrowser_app/tests/test_bookmark_options.py (+35/-5)
tests/autopilot/webbrowser_app/tests/test_contextmenu.py (+20/-52)
tests/unittests/qml/tst_UrlUtils.qml (+14/-0)
To merge this branch: bzr merge lp:~uriboni/webbrowser-app/bookmark-folders-from-contextual-menu
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Needs Fixing
Olivier Tilloy Approve
Review via email: mp+267934@code.launchpad.net

Commit message

Allow choosing the bookmark folder when bookmarking a link from the context menu. Disable the bookmark option when the link is already bookmarked. Ensure the bookmark star state in the chrome is always consistent with the bookmarked state of the current webview URL.

Description of the change

Allow choosing the bookmark folder when bookmarking a link from the context menu. Disable the bookmark option when the link is already bookmarked. Ensure the bookmark star state in the chrome is always consistent with the bookmarked state of the current webview URL.

To post a comment you must log in.
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
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Olivier Tilloy (osomon) wrote :

Please revert changes to po/webbrowser-app.pot.

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

The revert of po/webbrowser-app.pot was done from an old version of the trunk, so when merging into the latest trunk there are still changes to that file.

If a hyperlink doesn’t have a title, the title field will appear empty in the popover. In that case I think it would make sense to pre-fill the field with the URL. What do you think?

contextualMenuTarget should be made explicitly invisible, and its x, y, width and height property could be bound to contextualData.sourceArea’s values, instead of setting them imperatively in the action’s onTriggered handler.

Autopilot tests:

 self.pointing_device.click_object(webview, button=3) works only on desktop, right? The test needs to work on devices as well, by simulating a long press on the page. You can do something like that:

    webview = self.main_window.get_current_webview()
    self.pointing_device.move_to_object(webview)
    if model() == 'Desktop':
        self.pointing_device.click(button=3)
    else:
        self.pointing_device.press()
        time.sleep(1.5)
        self.pointing_device.release()

 actions.click_button_by_text("Bookmark link") isn’t portable. It fails on my desktop because the text is translated. A portable way is to add a name to the actions (e.g. BookmarkLink.qml would have [name: "bookmarklink"], all actions need to have a unique name), and in UbuntuWebView02.qml add a custom delegate for the ActionSelectionPopover whose objectName will be set to 'action.name' (plus optionally a prefix/suffix). Then you can select the menu item by objectName.

review: Needs Fixing
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
Ugo Riboni (uriboni) wrote :

All done except when otherwise noted below:

> If a hyperlink doesn’t have a title, the title field will appear empty in the
> popover. In that case I think it would make sense to pre-fill the field with
> the URL. What do you think?

Design said we should display the URL without the scheme (e.g. without http://), and do that in all cases when the popover for bookmark options appear, so I did just that.

> actions.click_button_by_text("Bookmark link") isn’t portable. It fails on my
> desktop because the text is translated. A portable way is to add a name to the
> actions (e.g. BookmarkLink.qml would have [name: "bookmarklink"], all actions
> need to have a unique name), and in UbuntuWebView02.qml add a custom delegate
> for the ActionSelectionPopover whose objectName will be set to 'action.name'
> (plus optionally a prefix/suffix). Then you can select the menu item by
> objectName.

Adding a custom delegate is a workaround, but the right fix is for the ActionSelectionPopover to do this by default (otherwise they would essentially be making mandatory to have your own delegate, if you want to write testable code).
I have been talking to the SDK people about this and they agree on this fix.

There is a bug to track all this https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1205144 and there is a patch attached to the bug that Christian created a few days ago.

It seems to me that using a custom delegate is adding an awful amount of code just for testing purposes, and we have been trying very hard to avoid this in the past. I would suggest that we fix the bug as if the code in the UITK fix has been committed, then disable the test with a link to the bug, then re-enabled it when it has been committed for real.

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
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Olivier Tilloy (osomon) wrote :

Looks good to me, thanks!

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

There are now a bunch of conflicts when merging this branch into the latest trunk, would you mind addressing them? Thanks!

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

test_bookmark_options_from_contextual_menu can now be updated and unskipped, since the context menu implementation has custom delegates (and the emulator has a get_context_menu() method, which returns an object that has a click_action() method).

The _invoke_contextual_menu_on_item() could be made an emulator method, since it duplicates code in test_contextmenu.py (have a look at the open_context_menu() method there, which takes into account the height of the chrome to determine where to invoke the context menu).

In UrlUtils.js, the naming of the 'authority' variable in the new removeScheme function is confusing, since it’s not actually extracting the authority, only removing the scheme. Call it 'remainder', or 'tail', or something more accurate please.

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
Olivier Tilloy (osomon) wrote :

+ id: tab

This doesn’t seem to be used anywhere, can the change be reverted?

The _invoke_contextual_menu_on_item helper method isn’t used anymore, it should be removed.

Other than that, LGTM.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Olivier Tilloy (osomon) :
review: Approve
Revision history for this message
Olivier Tilloy (osomon) wrote :

flake8 unit test is failing

review: Needs Fixing
1144. By Ugo Riboni

Fix flake8

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/app/UrlUtils.js'
2--- src/app/UrlUtils.js 2015-06-16 16:32:39 +0000
3+++ src/app/UrlUtils.js 2015-09-03 09:40:58 +0000
4@@ -18,12 +18,17 @@
5
6 'use strict';
7
8+function removeScheme(url) {
9+ var rest = url.toString()
10+ var indexOfScheme = rest.indexOf("://")
11+ if (indexOfScheme !== -1) {
12+ rest = rest.slice(indexOfScheme + 3)
13+ }
14+ return rest
15+}
16+
17 function extractAuthority(url) {
18- var authority = url.toString()
19- var indexOfScheme = authority.indexOf("://")
20- if (indexOfScheme !== -1) {
21- authority = authority.slice(indexOfScheme + 3)
22- }
23+ var authority = removeScheme(url)
24 var indexOfPath = authority.indexOf("/")
25 if (indexOfPath !== -1) {
26 authority = authority.slice(0, indexOfPath)
27
28=== modified file 'src/app/webbrowser/AddressBar.qml'
29--- src/app/webbrowser/AddressBar.qml 2015-08-18 08:49:24 +0000
30+++ src/app/webbrowser/AddressBar.qml 2015-09-03 09:40:58 +0000
31@@ -30,6 +30,7 @@
32 property bool incognito: false
33 property alias text: textField.text
34 property bool bookmarked: false
35+ signal toggleBookmark()
36 property url requestedUrl
37 property url actualUrl
38 signal validated()
39@@ -223,7 +224,7 @@
40 color: addressbar.bookmarked ? UbuntuColors.orange : UbuntuColors.darkGrey
41 }
42
43- onClicked: addressbar.bookmarked = !addressbar.bookmarked
44+ onClicked: addressbar.toggleBookmark()
45
46 Item {
47 id: bookmarkTogglePlaceHolderItem
48
49=== modified file 'src/app/webbrowser/Browser.qml'
50--- src/app/webbrowser/Browser.qml 2015-08-27 14:02:05 +0000
51+++ src/app/webbrowser/Browser.qml 2015-09-03 09:40:58 +0000
52@@ -316,12 +316,9 @@
53 return ((webview && browser.bookmarksModel) ? browser.bookmarksModel.contains(webview.url) : false)
54 }
55 bookmarked: isCurrentUrlBookmarked()
56- onBookmarkedChanged: {
57- if (bookmarked && !isCurrentUrlBookmarked()) {
58- internal.addBookmark(webview.url, webview.title, webview.icon)
59- } else if (!bookmarked && isCurrentUrlBookmarked()) {
60- browser.bookmarksModel.remove(webview.url)
61- }
62+ onToggleBookmark: {
63+ if (isCurrentUrlBookmarked()) browser.bookmarksModel.remove(webview.url)
64+ else internal.addBookmark(webview.url, webview.title, webview.icon)
65 }
66 onWebviewChanged: bookmarked = isCurrentUrlBookmarked()
67 Connections {
68@@ -903,6 +900,11 @@
69 current: tabsModel && tabsModel.currentTab === this
70 focus: current
71
72+ Item {
73+ id: contextualMenuTarget
74+ visible: false
75+ }
76+
77 webviewComponent: WebViewImpl {
78 id: webviewimpl
79
80@@ -942,8 +944,17 @@
81 Actions.BookmarkLink {
82 objectName: "bookmarkLinkContextualAction"
83 enabled: contextModel && contextModel.linkUrl.toString() &&
84- browser.bookmarksModel
85- onTriggered: bookmarksModel.add(contextModel.linkUrl, contextModel.linkText, "", "")
86+ browser.bookmarksModel && !bookmarksModel.contains(contextModel.linkUrl)
87+ onTriggered: {
88+ // position the menu target with a one-off assignement instead of a binding
89+ // since the contents of the contextModel have meaning only while the context
90+ // menu is active
91+ contextualMenuTarget.x = contextModel.position.x * devicePixelRatio
92+ contextualMenuTarget.y = contextModel.position.y * devicePixelRatio +
93+ locationBarController.height + locationBarController.offset
94+ internal.addBookmark(contextModel.linkUrl, contextModel.linkText,
95+ "", contextualMenuTarget)
96+ }
97 }
98 Actions.CopyLink {
99 objectName: "copyLinkContextualAction"
100@@ -1269,10 +1280,12 @@
101 }
102 }
103
104- function addBookmark(url, title, icon) {
105+ function addBookmark(url, title, icon, location) {
106+ if (title == "") title = UrlUtils.removeScheme(url)
107 bookmarksModel.add(url, title, icon, "")
108+ if (location === undefined) location = chrome.bookmarkTogglePlaceHolder
109 PopupUtils.open(bookmarkOptionsComponent,
110- chrome.bookmarkTogglePlaceHolder,
111+ location,
112 {"bookmarkUrl": url,
113 "bookmarkTitle": title})
114 }
115
116=== modified file 'src/app/webbrowser/Chrome.qml'
117--- src/app/webbrowser/Chrome.qml 2015-08-11 10:37:56 +0000
118+++ src/app/webbrowser/Chrome.qml 2015-09-03 09:40:58 +0000
119@@ -27,6 +27,7 @@
120 property alias searchUrl: navigationBar.searchUrl
121 property alias text: navigationBar.text
122 property alias bookmarked: navigationBar.bookmarked
123+ signal toggleBookmark()
124 property alias drawerActions: navigationBar.drawerActions
125 property alias drawerOpen: navigationBar.drawerOpen
126 property alias requestedUrl: navigationBar.requestedUrl
127@@ -90,6 +91,8 @@
128 right: parent.right
129 }
130 height: units.gu(6)
131+
132+ onToggleBookmark: chrome.toggleBookmark()
133 }
134 }
135 }
136
137=== modified file 'src/app/webbrowser/NavigationBar.qml'
138--- src/app/webbrowser/NavigationBar.qml 2015-08-11 10:37:56 +0000
139+++ src/app/webbrowser/NavigationBar.qml 2015-09-03 09:40:58 +0000
140@@ -27,6 +27,7 @@
141 property alias searchUrl: addressbar.searchUrl
142 readonly property string text: addressbar.text
143 property alias bookmarked: addressbar.bookmarked
144+ signal toggleBookmark()
145 property list<Action> drawerActions
146 readonly property bool drawerOpen: internal.openDrawer
147 property alias requestedUrl: addressbar.requestedUrl
148@@ -126,6 +127,7 @@
149 webview.reload()
150 }
151 onRequestStop: webview.stop()
152+ onToggleBookmark: root.toggleBookmark()
153
154 Connections {
155 target: webview
156
157=== modified file 'tests/autopilot/webbrowser_app/emulators/browser.py'
158--- tests/autopilot/webbrowser_app/emulators/browser.py 2015-08-25 13:56:58 +0000
159+++ tests/autopilot/webbrowser_app/emulators/browser.py 2015-09-03 09:40:58 +0000
160@@ -15,11 +15,13 @@
161 # along with this program. If not, see <http://www.gnu.org/licenses/>.
162
163 import logging
164+import time
165
166 import autopilot.logging
167 import ubuntuuitoolkit as uitk
168 from autopilot import exceptions
169 from autopilot import input
170+from autopilot.platform import model
171
172 logger = logging.getLogger(__name__)
173
174@@ -174,6 +176,35 @@
175 else:
176 return self.wait_select_single(ContextMenuMobile)
177
178+ def open_context_menu(self):
179+ webview = self.get_current_webview()
180+ chrome = self.chrome
181+ x = webview.globalRect.x + webview.globalRect.width // 2
182+ y = webview.globalRect.y + \
183+ (webview.globalRect.height + chrome.height) // 2
184+ self.pointing_device.move(x, y)
185+ if model() == 'Desktop':
186+ self.pointing_device.click(button=3)
187+ else:
188+ self.pointing_device.press()
189+ time.sleep(1.5)
190+ self.pointing_device.release()
191+ return self.get_context_menu()
192+
193+ def dismiss_context_menu(self, menu):
194+ if self.wide:
195+ # Dismiss by clicking outside of the menu
196+ webview_rect = self.get_current_webview().globalRect
197+ actions = menu.get_visible_actions()
198+ outside_x = (webview_rect.x + actions[0].globalRect.x) // 2
199+ outside_y = webview_rect.y + webview_rect.height // 2
200+ self.pointing_device.move(outside_x, outside_y)
201+ self.pointing_device.click()
202+ else:
203+ # Dismiss by clicking the cancel action
204+ menu.click_cancel_action()
205+ menu.wait_until_destroyed()
206+
207
208 class Chrome(uitk.UbuntuUIToolkitCustomProxyObjectBase):
209
210@@ -574,11 +605,16 @@
211 def get_visible_actions(self):
212 return self.select_many("Empty", visible=True)
213
214+ def get_action(self, objectName):
215+ name = objectName + "_item"
216+ return self.select_single("Empty", objectName=name)
217+
218 def click_action(self, objectName):
219 name = objectName + "_item"
220 action = self.select_single("Empty", visible=True,
221 enabled=True, objectName=name)
222 self.pointing_device.click_object(action)
223+ self.wait_until_destroyed()
224
225
226 class ContextMenuWide(ContextMenuBase):
227
228=== modified file 'tests/autopilot/webbrowser_app/tests/__init__.py'
229--- tests/autopilot/webbrowser_app/tests/__init__.py 2015-08-12 12:31:56 +0000
230+++ tests/autopilot/webbrowser_app/tests/__init__.py 2015-09-03 09:40:58 +0000
231@@ -233,7 +233,8 @@
232 self.useFixture(fixtures.EnvironmentVariable(
233 'UBUNTU_WEBVIEW_HOST_MAPPING_RULES',
234 "MAP test:80 localhost:{}".format(self.http_server.port)))
235- self.base_url = "http://test"
236+ self.base_domain = "test"
237+ self.base_url = "http://" + self.base_domain
238 self.url = self.base_url + path
239 self.ARGS = self.ARGS + [self.url]
240 super(StartOpenRemotePageTestCaseBase, self).setUp()
241
242=== modified file 'tests/autopilot/webbrowser_app/tests/test_bookmark_options.py'
243--- tests/autopilot/webbrowser_app/tests/test_bookmark_options.py 2015-08-15 00:30:14 +0000
244+++ tests/autopilot/webbrowser_app/tests/test_bookmark_options.py 2015-09-03 09:40:58 +0000
245@@ -17,7 +17,6 @@
246 import os.path
247 import sqlite3
248 import time
249-import testtools
250
251 from autopilot.matchers import Eventually
252 from testtools.matchers import Equals
253@@ -201,10 +200,8 @@
254 Eventually(Equals(4)))
255 self._assert_bookmark_count_in_folder(new_tab, "NewFolder", 1)
256
257- @testtools.skip("Temporarily skipped until popover going out of view with"
258- " OSK is fixed http://pad.lv/1466222")
259 def test_set_bookmark_title(self):
260- url = self.base_url + "/test2"
261+ url = self.base_url + "/blanktargetlink"
262 self.main_window.go_to_url(url)
263 self.main_window.wait_until_page_loaded(url)
264
265@@ -214,6 +211,8 @@
266 bookmark_options = self._get_bookmark_options()
267
268 title_text_field = bookmark_options.get_title_text_field()
269+ self.assertThat(title_text_field.text,
270+ Equals(self.base_domain + "/blanktargetlink"))
271 self.pointing_device.click_object(title_text_field)
272 title_text_field.activeFocus.wait_for(True)
273 title_text_field.write("NewTitle", True)
274@@ -227,7 +226,38 @@
275 self._assert_bookmark_count_in_folder(new_tab, "", 5)
276
277 index = 0
278- if self.main_view.wide:
279+ if self.main_window.wide:
280 index += 1
281 bookmark = new_tab.get_bookmarks("")[index]
282 self.assertThat(bookmark.title, Equals("NewTitle"))
283+
284+ def test_bookmark_options_from_contextual_menu(self):
285+ url = self.base_url + "/blanktargetlink"
286+ self.main_window.go_to_url(url)
287+ self.main_window.wait_until_page_loaded(url)
288+ webview = self.main_window.get_current_webview()
289+
290+ # invoke the context menu over the link, which covers the entire page
291+ menu = self.main_window.open_context_menu()
292+ menu.click_action("bookmarkLinkContextualAction")
293+
294+ bookmark_options = self.main_window.get_bookmark_options()
295+ bookmark_options.click_dismiss_button()
296+ bookmark_options.wait_until_destroyed()
297+
298+ # reopen the context menu and verify that the bookmark options is
299+ # disabled as we have already bookmarked this link
300+ menu = self.main_window.open_context_menu()
301+ bookmark_action = menu.get_action("bookmarkLinkContextualAction")
302+ self.assertThat(bookmark_action.visible, Equals(False))
303+
304+ # dismiss the dialog
305+ self.main_window.dismiss_context_menu(menu)
306+
307+ # click on the link and verify that the bookmark star is lit on the
308+ # target page
309+ self.pointing_device.click_object(webview)
310+ self.main_window.wait_until_page_loaded(self.base_url + "/test2")
311+
312+ chrome = self.main_window.chrome
313+ self.assertThat(chrome.bookmarked, Eventually(Equals(True)))
314
315=== modified file 'tests/autopilot/webbrowser_app/tests/test_contextmenu.py'
316--- tests/autopilot/webbrowser_app/tests/test_contextmenu.py 2015-08-21 17:02:09 +0000
317+++ tests/autopilot/webbrowser_app/tests/test_contextmenu.py 2015-09-03 09:40:58 +0000
318@@ -14,11 +14,10 @@
319 # You should have received a copy of the GNU General Public License
320 # along with this program. If not, see <http://www.gnu.org/licenses/>.
321
322-import time
323 from autopilot.platform import model
324 from autopilot.matchers import Eventually
325 import testtools
326-from testtools.matchers import Equals, GreaterThan, StartsWith
327+from testtools.matchers import Equals, StartsWith
328
329 from webbrowser_app.tests import StartOpenRemotePageTestCaseBase
330
331@@ -29,26 +28,7 @@
332
333 def setUp(self, path):
334 super(TestContextMenuBase, self).setUp(path)
335- self.menu = self.open_context_menu()
336-
337- def open_context_menu(self):
338- webview = self.main_window.get_current_webview()
339- chrome = self.main_window.chrome
340- x = webview.globalRect.x + webview.globalRect.width // 2
341- y = webview.globalRect.y + \
342- (webview.globalRect.height + chrome.height) // 2
343- self.pointing_device.move(x, y)
344- if model() == 'Desktop':
345- self.pointing_device.click(button=3)
346- else:
347- self.pointing_device.press()
348- time.sleep(1.5)
349- self.pointing_device.release()
350- return self.main_window.get_context_menu()
351-
352- def click_action(self, name):
353- self.menu.click_action(name)
354- self.menu.wait_until_destroyed()
355+ self.menu = self.main_window.open_context_menu()
356
357 def verify_link_opened_in_a_new_tab(self):
358 self.assert_number_webviews_eventually(2)
359@@ -76,38 +56,24 @@
360 self.assertThat(self.menu.get_title_label().text,
361 Equals(self.base_url + "/test1"))
362
363- def test_dismiss_menu(self):
364- if self.main_window.wide:
365- # Verify that clicking outside the menu dismisses it
366- webview_rect = self.main_window.get_current_webview().globalRect
367- actions = self.menu.get_visible_actions()
368- self.assertThat(actions[0].globalRect.x,
369- GreaterThan(webview_rect.x))
370- outside_x = (webview_rect.x + actions[0].globalRect.x) // 2
371- outside_y = webview_rect.y + webview_rect.height // 2
372- self.pointing_device.move(outside_x, outside_y)
373- self.pointing_device.click()
374- else:
375- # Verify that clicking the cancel action dismisses it
376- self.menu.click_cancel_action()
377- self.menu.wait_until_destroyed()
378-
379 def test_open_link_in_new_tab(self):
380- self.click_action("openLinkInNewTabContextualAction")
381+ self.menu.click_action("openLinkInNewTabContextualAction")
382 self.verify_link_opened_in_a_new_tab()
383
384 def test_bookmark_link(self):
385- self.click_action("bookmarkLinkContextualAction")
386+ self.menu.click_action("bookmarkLinkContextualAction")
387+ bookmark_options = self.main_window.get_bookmark_options()
388+ bookmark_options.click_dismiss_button()
389 self.verify_link_bookmarked()
390
391 def test_copy_link(self):
392 # There is no easy way to test the contents of the clipboard,
393 # but we can at least verify that the context menu was dismissed.
394- self.click_action("copyLinkContextualAction")
395+ self.menu.click_action("copyLinkContextualAction")
396
397 @testtools.skipIf(model() == "Desktop", "on devices only")
398 def test_share_link(self):
399- self.click_action("ShareLinkContextualAction")
400+ self.menu.click_action("ShareLinkContextualAction")
401 self.main_window.wait_select_single("ContentShareDialog")
402
403
404@@ -119,13 +85,13 @@
405 StartsWith(self.data_uri_prefix))
406
407 def test_open_image_in_new_tab(self):
408- self.click_action("OpenImageInNewTabContextualAction")
409+ self.menu.click_action("OpenImageInNewTabContextualAction")
410 self.verify_image_opened_in_a_new_tab()
411
412 def test_copy_image(self):
413 # There is no easy way to test the contents of the clipboard,
414 # but we can at least verify that the context menu was dismissed.
415- self.click_action("CopyImageContextualAction")
416+ self.menu.click_action("CopyImageContextualAction")
417
418
419 class TestContextMenuImageAndLink(TestContextMenuBase):
420@@ -136,31 +102,33 @@
421 StartsWith(self.data_uri_prefix))
422
423 def test_open_link_in_new_tab(self):
424- self.click_action("openLinkInNewTabContextualAction")
425+ self.menu.click_action("openLinkInNewTabContextualAction")
426 self.verify_link_opened_in_a_new_tab()
427
428 def test_bookmark_link(self):
429- self.click_action("bookmarkLinkContextualAction")
430+ self.menu.click_action("bookmarkLinkContextualAction")
431+ bookmark_options = self.main_window.get_bookmark_options()
432+ bookmark_options.click_dismiss_button()
433 self.verify_link_bookmarked()
434
435 def test_copy_link(self):
436 # There is no easy way to test the contents of the clipboard,
437 # but we can at least verify that the context menu was dismissed.
438- self.click_action("copyLinkContextualAction")
439+ self.menu.click_action("copyLinkContextualAction")
440
441 @testtools.skipIf(model() == "Desktop", "on devices only")
442 def test_share_link(self):
443- self.click_action("ShareLinkContextualAction")
444+ self.menu.click_action("ShareLinkContextualAction")
445 self.main_window.wait_select_single("ContentShareDialog")
446
447 def test_open_image_in_new_tab(self):
448- self.click_action("OpenImageInNewTabContextualAction")
449+ self.menu.click_action("OpenImageInNewTabContextualAction")
450 self.verify_image_opened_in_a_new_tab()
451
452 def test_copy_image(self):
453 # There is no easy way to test the contents of the clipboard,
454 # but we can at least verify that the context menu was dismissed.
455- self.click_action("CopyImageContextualAction")
456+ self.menu.click_action("CopyImageContextualAction")
457
458
459 class TestContextMenuTextArea(TestContextMenuBase):
460@@ -173,5 +141,5 @@
461 actions = ["SelectAll", "Cut", "Undo", "Redo",
462 "Paste", "SelectAll", "Copy", "Erase"]
463 for action in actions:
464- self.click_action("{}ContextualAction".format(action))
465- self.menu = self.open_context_menu()
466+ self.menu.click_action("{}ContextualAction".format(action))
467+ self.menu = self.main_window.open_context_menu()
468
469=== modified file 'tests/unittests/qml/tst_UrlUtils.qml'
470--- tests/unittests/qml/tst_UrlUtils.qml 2015-04-27 20:37:41 +0000
471+++ tests/unittests/qml/tst_UrlUtils.qml 2015-09-03 09:40:58 +0000
472@@ -55,6 +55,20 @@
473 compare(UrlUtils.extractHost(data.url), data.host)
474 }
475
476+ function test_removeScheme_data() {
477+ return [
478+ {url: "http://example.org/", removed: "example.org/"},
479+ {url: "file://user:pwd@example.org:2442/", removed: "user:pwd@example.org:2442/"},
480+ {url: "file:///home/foo/bar.txt", removed: "/home/foo/bar.txt"},
481+ {url: "ht+tp://www.example.org/", removed: "www.example.org/"},
482+ {url: "www.example.org", removed: "www.example.org"},
483+ ]
484+ }
485+
486+ function test_removeScheme(data) {
487+ compare(UrlUtils.removeScheme(data.url), data.removed)
488+ }
489+
490 function test_looksLikeAUrl_data() {
491 return [
492 {url: "", looksLike: false},

Subscribers

People subscribed via source and target branches

to status/vote changes: