on xenial help sign in
Fix PreviewZoomableImage unit test.
4fa93a0Ying-Chun Liu
qml/Components/ZoomableImage.qml+1
@@ -38,6 +38,7 @@ Item {
38 clip: true
38 clip: true
39 contentHeight: imageContainer.height
39 contentHeight: imageContainer.height
40 contentWidth: imageContainer.width
40 contentWidth: imageContainer.width
41+
41 onHeightChanged: image.resetScale()
42 onHeightChanged: image.resetScale()
42 onWidthChanged: image.resetScale()
43 onWidthChanged: image.resetScale()
43 anchors.fill: parent
44 anchors.fill: parent
tests/qmltests/Components/tst_ZoomableImage.qml+9−9
@@ -21,8 +21,8 @@ import Unity.Test 0.1 as UT
21
21
22Rectangle {
22Rectangle {
23 id: root
23 id: root
24− width: units.gu(40)
24+ width: units.gu(20)
25− height: units.gu(80)
25+ height: units.gu(40)
26 color: "lightgrey"
26 color: "lightgrey"
27
27
28 property var widgetData0: {
28 property var widgetData0: {
@@ -76,6 +76,12 @@ Rectangle {
76 compare (signalSpy.count, 1);
76 compare (signalSpy.count, 1);
77 }
77 }
78
78
79+ function get_filename(a) {
80+ var wordsA = a.split("/");
81+ var filenameA = wordsA[wordsA.length-1];
82+ return filenameA;
83+ }
84+
79 function test_zoomable_data() {
85 function test_zoomable_data() {
80 return [ { source:widgetData2["source"],
86 return [ { source:widgetData2["source"],
81 zoomable:false,
87 zoomable:false,
@@ -90,12 +96,6 @@ Rectangle {
90 ]
96 ]
91 }
97 }
92
98
93− function get_filename(a) {
94− var wordsA = a.split("/");
95− var filenameA = wordsA[wordsA.length-1];
96− return filenameA;
97− }
98−
99 function test_zoomable(data) {
99 function test_zoomable(data) {
100 var image = findChild(zoomableImage, "image");
100 var image = findChild(zoomableImage, "image");
101 var lazyImage = findChild(zoomableImage, "lazyImage");
101 var lazyImage = findChild(zoomableImage, "lazyImage");
@@ -135,9 +135,9 @@ Rectangle {
135
135
136 for (var i = 0.0; i < 1.0; i += 0.02) {
136 for (var i = 0.0; i < 1.0; i += 0.02) {
137 event1.move(0, x1Start + (x1End - x1Start) * i, y1Start + (y1End - y1Start) * i);
137 event1.move(0, x1Start + (x1End - x1Start) * i, y1Start + (y1End - y1Start) * i);
138+ event1.commit();
138 event1.move(1, x2Start + (x2End - x2Start) * i, y2Start + (y2End - y2Start) * i);
139 event1.move(1, x2Start + (x2End - x2Start) * i, y2Start + (y2End - y2Start) * i);
139 event1.commit();
140 event1.commit();
140− wait(30);
141 }
141 }
142
142
143 event1.release(0, x1End, y1End);
143 event1.release(0, x1End, y1End);
tests/qmltests/Dash/Previews/tst_PreviewZoomableImage.qml+3−8
@@ -34,14 +34,9 @@ Rectangle {
34 "zoomable": false
34 "zoomable": false
35 }
35 }
36
36
37− property var widgetData2: {
38− "source": "../graphics/phone/screenshots/gallery@12.png",
39− "zoomable": true
40− }
41−
42 PreviewZoomableImage {
37 PreviewZoomableImage {
43 id: zoomableImage
38 id: zoomableImage
44− width: parent.width
39+ anchors.fill: parent
45 }
40 }
46
41
47 UT.UnityTestCase {
42 UT.UnityTestCase {
@@ -53,11 +48,11 @@ Rectangle {
53
48
54 zoomableImage.widgetData = widgetData0;
49 zoomableImage.widgetData = widgetData0;
55 waitForRendering(zoomableImage);
50 waitForRendering(zoomableImage);
56− tryCompare(image, "state", "default");
51+ tryCompare(image, "imageState", "default");
57
52
58 zoomableImage.widgetData = widgetData1;
53 zoomableImage.widgetData = widgetData1;
59 waitForRendering(zoomableImage);
54 waitForRendering(zoomableImage);
60− tryCompare(image, "state", "ready");
55+ tryCompare(image, "imageState", "ready");
61 }
56 }
62 }
57 }
63}
58}