on xenial help sign in
Fix regression making pan not possible in Zoomable Image

Also fix the test to actually test panning so that it may be harder to make such mistake in the future

commit55c003953d6d4f7a51e032cf82507b29aca61baa authorAlbert Astals Cid <albert.astals@canonical.com> dateWed 18 Mar 2015, 15:34 (12 years ago) parent35f26de
3 files changed+26−20
qml/Components/ZoomableImage.qml+14−14 tests/qmltests/Components/tst_ZoomableImage.qml+7 tests/utils/modules/Unity/Test/UnityTestCase.qml+5−6
qml/Components/ZoomableImage.qml+14−14
@@ -107,6 +107,20 @@ Item {
107107 }
108108 }
109109
110+ PinchArea {
111+ id: pinchArea
112+ objectName: "pinchArea"
113+ property real minScale: 1.0
114+ anchors.fill: parent
115+ enabled: zoomable ? zoomable : false
116+
117+ pinch.target: image
118+ pinch.minimumScale: minScale
119+ pinch.maximumScale: 10
120+
121+ onPinchFinished: flickable.returnToBounds()
122+ }
123+
110124 MouseArea {
111125 id: mouseArea
112126 objectName: "mouseArea"
@@ -139,18 +153,4 @@ Item {
139153 }
140154 }
141155 }
142−
143− PinchArea {
144− id: pinchArea
145− objectName: "pinchArea"
146− property real minScale: 1.0
147− anchors.fill: flickable
148− enabled: zoomable ? zoomable : false
149−
150− pinch.target: image
151− pinch.minimumScale: minScale
152− pinch.maximumScale: 10
153−
154− onPinchFinished: flickable.returnToBounds()
155− }
156156}
tests/qmltests/Components/tst_ZoomableImage.qml+7
@@ -182,6 +182,13 @@ Rectangle {
182182 compare(flickable.contentWidth, Math.max(imageRenderer.width * image.scale, flickable.width));
183183 compare(flickable.contentHeight, Math.max(imageRenderer.height * image.scale, flickable.height));
184184
185+ // try pan it a bit
186+ var contentX = flickable.contentX;
187+ var contentY = flickable.contentY;
188+ touchFlick(zoomableImage, units.gu(1), units.gu(1), units.gu(10), units.gu(10));
189+ tryCompare(flickable, "moving", false)
190+ tryCompareFunction(function() { return flickable.contentX != contentX && flickable.contentY != contentY; }, zoomableImage.zoomable)
191+
185192 wait(3000); // have to delay between two consequent pinch event.
186193 // pinch zoom-out
187194 touchPinch(zoomableImage, x1End, y1End, x1Start, y1Start, x2End, y2End, x2Start, y2Start);
tests/utils/modules/Unity/Test/UnityTestCase.qml+5−6
@@ -291,15 +291,14 @@ TestCase {
291291 // first finger
292292 event1.press(0, x1Start, y1Start);
293293 event1.commit();
294− // second finger
295− event1.stationary(0);
296− event1.press(1, x2Start, y2Start);
297− event1.commit();
298−
299294 // pinch
300295 for (var i = 0.0; i < 1.0; i += 0.02) {
301296 event1.move(0, x1Start + (x1End - x1Start) * i, y1Start + (y1End - y1Start) * i);
302− event1.move(1, x2Start + (x2End - x2Start) * i, y2Start + (y2End - y2Start) * i);
297+ if (i == 0) {
298+ event1.press(1, x2Start, y2Start);
299+ } else {
300+ event1.move(1, x2Start + (x2End - x2Start) * i, y2Start + (y2End - y2Start) * i);
301+ }
303302 event1.commit();
304303 }
305304