Merge lp:~zsombi/ubuntu-ui-toolkit/imageExtensionFix into lp:ubuntu-ui-toolkit/staging

Proposed by Zsombor Egri
Status: Merged
Approved by: Cris Dywan
Approved revision: 1785
Merged at revision: 1782
Proposed branch: lp:~zsombi/ubuntu-ui-toolkit/imageExtensionFix
Merge into: lp:ubuntu-ui-toolkit/staging
Diff against target: 47 lines (+20/-5)
2 files modified
src/Ubuntu/Components/plugin/ucqquickimageextension.cpp (+3/-2)
tests/unit_x11/tst_components/tst_imageprovider.qml (+17/-3)
To merge this branch: bzr merge lp:~zsombi/ubuntu-ui-toolkit/imageExtensionFix
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Cris Dywan Approve
Olivier Tilloy (community) Approve
Review via email: mp+280942@code.launchpad.net

Commit message

Use original Image.source in image extension when no scaling is needed in order to keep the formatting which would be otherwise removed from a resolved file URL.

To post a comment you must log in.
Revision history for this message
Cris Dywan (kalikiana) wrote :

Can you add a comment on this behavior next to the fixed line? I think the wording in your commits would be good to have fore future reference. Like "// Use original source instead of resolved to keep invalid characters like #"

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

I can confirm this fixes the issue originally reported.

I’m not sure about the unit test though:

    "Non-existing file" is misleading, the file does exist. The description should probably be "URL with fragment"

    [file: file + "#" + Date.now()] should probably be [file: "file://" + file + "#" + Date.now()] for correctness

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

And again: "#" in a URL is not an invalid character. If the URL happens to point to a local file, then the fragment will be ignored, but that doesn’t make it invalid.

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

> Can you add a comment on this behavior next to the fixed line? I think the
> wording in your commits would be good to have fore future reference. Like "//
> Use original source instead of resolved to keep invalid characters like #"

I've added a more precise comment there.

Revision history for this message
Zsombor Egri (zsombi) wrote :

> I can confirm this fixes the issue originally reported.
>
> I’m not sure about the unit test though:
>
> "Non-existing file" is misleading, the file does exist. The description
> should probably be "URL with fragment"
>
> [file: file + "#" + Date.now()] should probably be [file: "file://" + file
> + "#" + Date.now()] for correctness

Right, it is a valid url, tag fixed as well as proper protocol added. However "file://" protocol is not mandatory in case of files :) even if you add fragments to the url.

1785. By Zsombor Egri

review comments addressed

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

Looks good to me, thanks!

review: Approve
Revision history for this message
Cris Dywan (kalikiana) wrote :

Good to go.

review: Approve
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) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/Ubuntu/Components/plugin/ucqquickimageextension.cpp'
2--- src/Ubuntu/Components/plugin/ucqquickimageextension.cpp 2015-10-15 08:43:17 +0000
3+++ src/Ubuntu/Components/plugin/ucqquickimageextension.cpp 2015-12-18 12:33:45 +0000
4@@ -81,8 +81,9 @@
5 if (scaleFactor == "1") {
6 if (qFuzzyCompare(qGuiApp->devicePixelRatio(), (qreal)1.0)
7 || selectedFilePath.endsWith(".svg") || selectedFilePath.endsWith(".svgz")) {
8- // No scaling necessary. Just pass the file as is.
9- m_image->setSource(QUrl::fromLocalFile(selectedFilePath));
10+ // No scaling necessary. Just pass the original file as is
11+ // to keep the full url structure
12+ m_image->setSource(m_source);
13 } else {
14 // Need to scale the pixel-based image to suit the devicePixelRatio setting ourselves.
15 // If we let Qt do it, Qt will not choose the UITK-supported "@gu" scaled images.
16
17=== modified file 'tests/unit_x11/tst_components/tst_imageprovider.qml'
18--- tests/unit_x11/tst_components/tst_imageprovider.qml 2015-03-03 13:20:06 +0000
19+++ tests/unit_x11/tst_components/tst_imageprovider.qml 2015-12-18 12:33:45 +0000
20@@ -53,10 +53,24 @@
21 signalName: "visibleChanged"
22 }
23
24- function test_sourceChanged() {
25+ function cleanup() {
26+ sourceChangeSpy.clear();
27+ visibleChangedSpy.clear();
28+ }
29+
30+ // tests adjusted to reproduce bug #1401920
31+ function test_sourceChanged_bug1401920_data() {
32+ var file = "file:///usr/share/icons/ubuntu-mobile/actions/scalable/delete.svg";
33+ return [
34+ {rag: "Existing file", file: file},
35+ {rag: "Url with fragment", file: file + "#" + Date.now()},
36+ ];
37+ }
38+
39+ function test_sourceChanged_bug1401920(data) {
40 sourceChangeSpy.target = test;
41- test.source = "/usr/share/icons/ubuntu-mobile/actions/scalable/delete.svg";
42- sourceChangeSpy.wait();
43+ test.source = data.file;
44+ sourceChangeSpy.wait(400);
45 }
46
47 function test_sourceNOTIFYable() {

Subscribers

People subscribed via source and target branches