on xenial help sign in
Make tests pass with Qt 5.4
ce728e3Albert Astals Cid
qml/Components/ZoomableImage.qml+14−14
@@ -107,20 +107,6 @@ Item {
107 }
107 }
108 }
108 }
109
109
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−
124 MouseArea {
110 MouseArea {
125 id: mouseArea
111 id: mouseArea
126 objectName: "mouseArea"
112 objectName: "mouseArea"
@@ -153,4 +139,18 @@ Item {
153 }
139 }
154 }
140 }
155 }
141 }
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+ }
156}
156}
tests/plugins/Ubuntu/Gestures/tst_DirectionalDragArea.cpp+5
@@ -20,6 +20,7 @@
20#include <QtQml/QQmlEngine>
20#include <QtQml/QQmlEngine>
21#include <QPointer>
21#include <QPointer>
22#include <private/qquickmousearea_p.h>
22#include <private/qquickmousearea_p.h>
23+#include <private/qquickwindow_p.h>
23
24
24
25
25#include <DirectionalDragArea.h>
26#include <DirectionalDragArea.h>
@@ -814,10 +815,14 @@ void tst_DirectionalDragArea::sceneDistance()
814
815
815 QTest::touchEvent(m_view, m_device).press(0, touchPoint.toPoint());
816 QTest::touchEvent(m_view, m_device).press(0, touchPoint.toPoint());
816
817
818+ QQuickWindowPrivate *wp = QQuickWindowPrivate::get(m_view);
817 for (int i = 0; i < totalMovementSteps; ++i) {
819 for (int i = 0; i < totalMovementSteps; ++i) {
818 touchPoint += touchMovement;
820 touchPoint += touchMovement;
819 passTime(movementTimeStepMs);
821 passTime(movementTimeStepMs);
820 QTest::touchEvent(m_view, m_device).move(0, touchPoint.toPoint());
822 QTest::touchEvent(m_view, m_device).move(0, touchPoint.toPoint());
823+#if (QT_VERSION >= QT_VERSION_CHECK(5, 4, 0))
824+ wp->flushDelayedTouchEvent();
825+#endif
821 }
826 }
822
827
823 qreal actualDragDistance = ((qreal)totalMovementSteps) * movementStepDistance;
828 qreal actualDragDistance = ((qreal)totalMovementSteps) * movementStepDistance;
tests/plugins/Ubuntu/Gestures/tst_TouchGate.cpp+5
@@ -19,6 +19,7 @@
19#include <QQmlEngine>
19#include <QQmlEngine>
20#include <QQuickView>
20#include <QQuickView>
21#include <QSharedPointer>
21#include <QSharedPointer>
22+#include <private/qquickwindow_p.h>
22
23
23// C++ std lib
24// C++ std lib
24#include <functional>
25#include <functional>
@@ -192,6 +193,10 @@ void tst_TouchGate::holdsEventsUntilGainsOwnership()
192
193
193 if (!ownershipAfterTouchEnd) {
194 if (!ownershipAfterTouchEnd) {
194 touchRegistry->removeCandidateOwnerForTouch(0, candidateItem);
195 touchRegistry->removeCandidateOwnerForTouch(0, candidateItem);
196+#if (QT_VERSION >= QT_VERSION_CHECK(5, 4, 0))
197+ QQuickWindowPrivate *wp = QQuickWindowPrivate::get(testItem->window());
198+ wp->flushDelayedTouchEvent();
199+#endif
195 // TouchGate should now open its flood gates and let testItem get all
200 // TouchGate should now open its flood gates and let testItem get all
196 // events from touch 0 produced so far
201 // events from touch 0 produced so far
197 QCOMPARE(testItem->touchEventsReceived.count(), 2);
202 QCOMPARE(testItem->touchEventsReceived.count(), 2);
tests/qmltests/Dash/Previews/tst_PreviewRatingInput.qml+1−1
@@ -196,7 +196,7 @@ Rectangle {
196 compare(args[1], "rated");
196 compare(args[1], "rated");
197 compare(args[2]["rating"], data.triggeredData["rating"]);
197 compare(args[2]["rating"], data.triggeredData["rating"]);
198 compare(args[2]["review"], data.triggeredData["review"]);
198 compare(args[2]["review"], data.triggeredData["review"]);
199− verify(args[2]["author"]); // Just verifying it exists now
199+ verify(args[2]["author"] !== undefined); // Just verifying it exists now
200 }
200 }
201 }
201 }
202}
202}
tests/utils/modules/Unity/Test/CMakeLists.txt+1
@@ -4,6 +4,7 @@ add_definitions(-DQT_NO_KEYWORDS)
4
4
5include_directories(
5include_directories(
6 ${Qt5Gui_PRIVATE_INCLUDE_DIRS}
6 ${Qt5Gui_PRIVATE_INCLUDE_DIRS}
7+ ${Qt5Quick_PRIVATE_INCLUDE_DIRS}
7 ${CMAKE_SOURCE_DIR}/libs/UbuntuGestures
8 ${CMAKE_SOURCE_DIR}/libs/UbuntuGestures
8)
9)
9
10
tests/utils/modules/Unity/Test/TouchEventSequenceWrapper.cpp+8−1
@@ -15,15 +15,22 @@
15 */
15 */
16
16
17#include "TouchEventSequenceWrapper.h"
17#include "TouchEventSequenceWrapper.h"
18+#include <private/qquickwindow_p.h>
19+
18−TouchEventSequenceWrapper::TouchEventSequenceWrapper(QTest::QTouchEventSequence eventSequence)
20+TouchEventSequenceWrapper::TouchEventSequenceWrapper(QTest::QTouchEventSequence eventSequence, QQuickItem *item)
19 : QObject(0)
21 : QObject(0)
20 , m_eventSequence(eventSequence)
22 , m_eventSequence(eventSequence)
23+ , m_item(item)
21{
24{
22}
25}
23
26
24void TouchEventSequenceWrapper::commit(bool processEvents)
27void TouchEventSequenceWrapper::commit(bool processEvents)
25{
28{
26 m_eventSequence.commit(processEvents);
29 m_eventSequence.commit(processEvents);
30+#if (QT_VERSION >= QT_VERSION_CHECK(5, 4, 0))
31+ QQuickWindowPrivate *wp = QQuickWindowPrivate::get(m_item->window());
32+ wp->flushDelayedTouchEvent();
33+#endif
27}
34}
28
35
29void TouchEventSequenceWrapper::move(int touchId, int x, int y)
36void TouchEventSequenceWrapper::move(int touchId, int x, int y)
tests/utils/modules/Unity/Test/TouchEventSequenceWrapper.h+4−1
@@ -21,11 +21,13 @@
21#include <QtTest/QTest>
21#include <QtTest/QTest>
22#include <QtQml/qqml.h>
22#include <QtQml/qqml.h>
23
23
24+class QQuickItem;
25+
24class TouchEventSequenceWrapper : public QObject
26class TouchEventSequenceWrapper : public QObject
25{
27{
26 Q_OBJECT
28 Q_OBJECT
27public:
29public:
28− TouchEventSequenceWrapper(QTest::QTouchEventSequence eventSequence);
30+ TouchEventSequenceWrapper(QTest::QTouchEventSequence eventSequence, QQuickItem *item);
29
31
30 Q_INVOKABLE void commit(bool processEvents = true);
32 Q_INVOKABLE void commit(bool processEvents = true);
31 Q_INVOKABLE void move(int touchId, int x, int y);
33 Q_INVOKABLE void move(int touchId, int x, int y);
@@ -35,6 +37,7 @@ public:
35
37
36private:
38private:
37 QTest::QTouchEventSequence m_eventSequence;
39 QTest::QTouchEventSequence m_eventSequence;
40+ QQuickItem *m_item;
38};
41};
39
42
40QML_DECLARE_TYPE(TouchEventSequenceWrapper)
43QML_DECLARE_TYPE(TouchEventSequenceWrapper)
tests/utils/modules/Unity/Test/UnityTestCase.qml+11−11
@@ -221,8 +221,8 @@ TestCase {
221 }
221 }
222 }
222 }
223
223
224− function touchEvent() {
224+ function touchEvent(item) {
225− return UT.Util.touchEvent()
225+ return UT.Util.touchEvent(item)
226 }
226 }
227
227
228 // speed is in pixels/second
228 // speed is in pixels/second
@@ -255,7 +255,7 @@ TestCase {
255 if (beginTouch) {
255 if (beginTouch) {
256 fakeDateTime.currentTimeMs += timeStep
256 fakeDateTime.currentTimeMs += timeStep
257
257
258− var event = touchEvent()
258+ var event = touchEvent(item)
259 event.press(0 /* touchId */, rootFrom.x, rootFrom.y)
259 event.press(0 /* touchId */, rootFrom.x, rootFrom.y)
260 event.commit()
260 event.commit()
261 }
261 }
@@ -265,19 +265,19 @@ TestCase {
265 // Avoid any rounding errors by making the last move be at precisely
265 // Avoid any rounding errors by making the last move be at precisely
266 // the point specified
266 // the point specified
267 wait(iterations / speed)
267 wait(iterations / speed)
268− var event = touchEvent()
268+ var event = touchEvent(item)
269 event.move(0 /* touchId */, rootTo.x, rootTo.y)
269 event.move(0 /* touchId */, rootTo.x, rootTo.y)
270 event.commit()
270 event.commit()
271 } else {
271 } else {
272 wait(iterations / speed)
272 wait(iterations / speed)
273− var event = touchEvent()
273+ var event = touchEvent(item)
274 event.move(0 /* touchId */, rootFrom.x + (i + 1) * diffX, rootFrom.y + (i + 1) * diffY)
274 event.move(0 /* touchId */, rootFrom.x + (i + 1) * diffX, rootFrom.y + (i + 1) * diffY)
275 event.commit()
275 event.commit()
276 }
276 }
277 }
277 }
278 if (endTouch) {
278 if (endTouch) {
279 fakeDateTime.currentTimeMs += timeStep
279 fakeDateTime.currentTimeMs += timeStep
280− var event = touchEvent()
280+ var event = touchEvent(item)
281 event.release(0 /* touchId */, rootTo.x, rootTo.y)
281 event.release(0 /* touchId */, rootTo.x, rootTo.y)
282 event.commit()
282 event.commit()
283 }
283 }
@@ -287,7 +287,7 @@ TestCase {
287 // Make sure the item is rendered
287 // Make sure the item is rendered
288 waitForRendering(item);
288 waitForRendering(item);
289
289
290− var event1 = touchEvent();
290+ var event1 = touchEvent(item);
291 // first finger
291 // first finger
292 event1.press(0, x1Start, y1Start);
292 event1.press(0, x1Start, y1Start);
293 event1.commit();
293 event1.commit();
@@ -320,7 +320,7 @@ TestCase {
320 var root = fetchRootItem(item)
320 var root = fetchRootItem(item)
321 var rootPoint = item.mapToItem(root, x, y)
321 var rootPoint = item.mapToItem(root, x, y)
322
322
323− var event = touchEvent()
323+ var event = touchEvent(item)
324 event.press(0 /* touchId */, rootPoint.x, rootPoint.y)
324 event.press(0 /* touchId */, rootPoint.x, rootPoint.y)
325 event.commit()
325 event.commit()
326 }
326 }
@@ -329,7 +329,7 @@ TestCase {
329 var root = fetchRootItem(item)
329 var root = fetchRootItem(item)
330 var rootPoint = item.mapToItem(root, x, y)
330 var rootPoint = item.mapToItem(root, x, y)
331
331
332− var event = touchEvent()
332+ var event = touchEvent(item)
333 event.release(0 /* touchId */, rootPoint.x, rootPoint.y)
333 event.release(0 /* touchId */, rootPoint.x, rootPoint.y)
334 event.commit()
334 event.commit()
335 }
335 }
@@ -347,11 +347,11 @@ TestCase {
347 var root = fetchRootItem(item)
347 var root = fetchRootItem(item)
348 var rootPoint = item.mapToItem(root, x, y)
348 var rootPoint = item.mapToItem(root, x, y)
349
349
350− var event = touchEvent()
350+ var event = touchEvent(item)
351 event.press(0 /* touchId */, rootPoint.x, rootPoint.y)
351 event.press(0 /* touchId */, rootPoint.x, rootPoint.y)
352 event.commit()
352 event.commit()
353
353
354− event = touchEvent()
354+ event = touchEvent(item)
355 event.release(0 /* touchId */, rootPoint.x, rootPoint.y)
355 event.release(0 /* touchId */, rootPoint.x, rootPoint.y)
356 event.commit()
356 event.commit()
357 }
357 }
tests/utils/modules/Unity/Test/testutil.cpp+2−2
@@ -55,14 +55,14 @@ TestUtil::isInstanceOf(QObject *obj, QString name)
55 return result;
55 return result;
56}
56}
57
57
58−TouchEventSequenceWrapper *TestUtil::touchEvent()
58+TouchEventSequenceWrapper *TestUtil::touchEvent(QQuickItem *item)
59{
59{
60 ensureTargetWindow();
60 ensureTargetWindow();
61 ensureTouchDevice();
61 ensureTouchDevice();
62 ensureTouchRegistryInstalled();
62 ensureTouchRegistryInstalled();
63
63
64 return new TouchEventSequenceWrapper(
64 return new TouchEventSequenceWrapper(
65− QTest::touchEvent(m_targetWindow, m_touchDevice, /* autoCommit */ false));
65+ QTest::touchEvent(m_targetWindow, m_touchDevice, /* autoCommit */ false), item);
66}
66}
67
67
68void TestUtil::ensureTargetWindow()
68void TestUtil::ensureTargetWindow()
tests/utils/modules/Unity/Test/testutil.h+1−1
@@ -33,7 +33,7 @@ public:
33 ~TestUtil();
33 ~TestUtil();
34
34
35 Q_INVOKABLE bool isInstanceOf(QObject*, QString);
35 Q_INVOKABLE bool isInstanceOf(QObject*, QString);
36− Q_INVOKABLE TouchEventSequenceWrapper *touchEvent();
36+ Q_INVOKABLE TouchEventSequenceWrapper *touchEvent(QQuickItem *item);
37 Q_INVOKABLE void ensureTouchRegistryInstalled();
37 Q_INVOKABLE void ensureTouchRegistryInstalled();
38
38
39private:
39private: