Merge lp:~osomon/webbrowser-app/topsites-previews into lp:webbrowser-app

Proposed by Olivier Tilloy
Status: Merged
Approved by: Olivier Tilloy
Approved revision: no longer in the source branch.
Merged at revision: 1351
Proposed branch: lp:~osomon/webbrowser-app/topsites-previews
Merge into: lp:webbrowser-app
Diff against target: 127 lines (+44/-9)
3 files modified
src/app/webbrowser/BrowserTab.qml (+24/-1)
src/app/webbrowser/UrlPreviewDelegate.qml (+15/-5)
tests/autopilot/webbrowser_app/tests/test_site_previews.py (+5/-3)
To merge this branch: bzr merge lp:~osomon/webbrowser-app/topsites-previews
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Needs Fixing
Ubuntu Phablet Team Pending
Review via email: mp+285697@code.launchpad.net

Commit message

Take a capture of the current page shortly after it has finished loading to give rendering an opportunity to complete.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
1347. By Olivier Tilloy

Add a placeholder asset for missing previews.

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

Update an existing autopilot test.

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/webbrowser/BrowserTab.qml'
2--- src/app/webbrowser/BrowserTab.qml 2015-12-10 17:10:37 +0000
3+++ src/app/webbrowser/BrowserTab.qml 2016-02-16 16:31:38 +0000
4@@ -1,5 +1,5 @@
5 /*
6- * Copyright 2014-2015 Canonical Ltd.
7+ * Copyright 2014-2016 Canonical Ltd.
8 *
9 * This file is part of webbrowser-app.
10 *
11@@ -168,6 +168,29 @@
12 }
13 }
14
15+ // Take a capture of the current page shortly after it has finished
16+ // loading to give rendering an opportunity to complete. There is
17+ // unfortunately no signal to notify us when rendering has completed.
18+ Timer {
19+ id: delayedCapture
20+ interval: 500
21+ onTriggered: {
22+ if (webview && current && visible && !internal.hiding) {
23+ webview.grabToImage(function(result) {
24+ PreviewManager.saveToDisk(result, url)
25+ })
26+ }
27+ }
28+ }
29+ Connections {
30+ target: webview
31+ onLoadingStateChanged: {
32+ if (!webview.loading && !webview.incognito) {
33+ delayedCapture.restart()
34+ }
35+ }
36+ }
37+
38 onAboutToShow: {
39 if (!current) {
40 opacity = 0
41
42=== modified file 'src/app/webbrowser/UrlPreviewDelegate.qml'
43--- src/app/webbrowser/UrlPreviewDelegate.qml 2015-10-16 07:55:02 +0000
44+++ src/app/webbrowser/UrlPreviewDelegate.qml 2016-02-16 16:31:38 +0000
45@@ -1,5 +1,5 @@
46 /*
47- * Copyright 2015 Canonical Ltd.
48+ * Copyright 2015-2016 Canonical Ltd.
49 *
50 * This file is part of webbrowser-app.
51 *
52@@ -79,10 +79,14 @@
53 anchors.left: parent.left
54 width: units.gu(26)
55 height: units.gu(16)
56+ backgroundColor: "#f7f7f7"
57+
58+ property url previewUrl: Qt.resolvedUrl(PreviewManager.previewPathFromUrl(preview.url))
59+ readonly property bool hasPreview: FileOperations.exists(previewUrl)
60
61 source: Image {
62 id: previewImage
63- source: FileOperations.exists(previewShape.previewUrl) ? previewShape.previewUrl : ""
64+ source: previewShape.hasPreview ? previewShape.previewUrl : ""
65 sourceSize.width: previewShape.width
66 cache: false
67 }
68@@ -90,12 +94,10 @@
69 sourceHorizontalAlignment: UbuntuShape.AlignLeft
70 sourceVerticalAlignment: UbuntuShape.AlignTop
71
72- property url previewUrl: Qt.resolvedUrl(PreviewManager.previewPathFromUrl(preview.url))
73-
74 Connections {
75 target: PreviewManager
76 onPreviewSaved: {
77- if (pageUrl !== preview.url) return
78+ if (pageUrl != preview.url) return
79 previewImage.source = ""
80 previewImage.source = previewShape.previewUrl
81 }
82@@ -105,6 +107,14 @@
83 preview.setCurrent()
84 PopupUtils.open(contextMenuComponent, previewShape)
85 }
86+
87+ Image {
88+ anchors.centerIn: parent
89+ width: units.gu(2.5)
90+ height: units.gu(2.5)
91+ source: previewShape.hasPreview ? "" : "assets/stock_website.png"
92+ fillMode: Image.PreserveAspectFit
93+ }
94 }
95 }
96
97
98=== added file 'src/app/webbrowser/assets/stock_website.png'
99Binary files src/app/webbrowser/assets/stock_website.png 1970-01-01 00:00:00 +0000 and src/app/webbrowser/assets/stock_website.png 2016-02-16 16:31:38 +0000 differ
100=== modified file 'tests/autopilot/webbrowser_app/tests/test_site_previews.py'
101--- tests/autopilot/webbrowser_app/tests/test_site_previews.py 2015-11-19 11:48:10 +0000
102+++ tests/autopilot/webbrowser_app/tests/test_site_previews.py 2016-02-16 16:31:38 +0000
103@@ -1,6 +1,6 @@
104 # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
105 #
106-# Copyright 2015 Canonical
107+# Copyright 2015-2016 Canonical
108 #
109 # This program is free software: you can redistribute it and/or modify it
110 # under the terms of the GNU General Public License version 3, as published
111@@ -91,12 +91,14 @@
112 self.populate_captures_dir(history + [other_url, not_hash, not_image])
113
114 self.launch_app()
115- time.sleep(0.5) # wait for file system to settle
116+ time.sleep(1) # wait for file system to settle
117
118 # verify that non-image files and top 10 sites are left alone,
119 # everything else is cleaned up
120 topsites = history[0:10]
121- self.assertThat(self.captures_dir, DirContains(topsites + [not_image]))
122+ current_tab = self.capture_file(self.url)
123+ self.assertThat(self.captures_dir,
124+ DirContains(topsites + [not_image, current_tab]))
125
126
127 class TestSitePreviews(TestSitePreviewsBase):

Subscribers

People subscribed via source and target branches

to status/vote changes: