Merge lp:~aacid/unity8/qmluitests54 into lp:unity8

Proposed by Albert Astals Cid
Status: Merged
Approved by: Andrea Cimitan
Approved revision: 1622
Merged at revision: 1629
Proposed branch: lp:~aacid/unity8/qmluitests54
Merge into: lp:unity8
Diff against target: 315 lines (+61/-31)
11 files modified
qml/Components/ZoomableImage.qml (+14/-14)
tests/plugins/Ubuntu/Gestures/tst_DirectionalDragArea.cpp (+9/-0)
tests/plugins/Ubuntu/Gestures/tst_TouchGate.cpp (+7/-0)
tests/qmltests/Dash/Previews/tst_PreviewRatingInput.qml (+1/-1)
tests/qmltests/tst_ShellWithPin.qml (+1/-0)
tests/utils/modules/Unity/Test/CMakeLists.txt (+1/-0)
tests/utils/modules/Unity/Test/TouchEventSequenceWrapper.cpp (+10/-1)
tests/utils/modules/Unity/Test/TouchEventSequenceWrapper.h (+4/-1)
tests/utils/modules/Unity/Test/UnityTestCase.qml (+11/-11)
tests/utils/modules/Unity/Test/testutil.cpp (+2/-2)
tests/utils/modules/Unity/Test/testutil.h (+1/-1)
To merge this branch: bzr merge lp:~aacid/unity8/qmluitests54
Reviewer Review Type Date Requested Status
Andrea Cimitan (community) Approve
PS Jenkins bot (community) continuous-integration Needs Fixing
Daniel d'Andrada (community) tests code Approve
Review via email: mp+250021@code.launchpad.net

Commit message

Make qmluittests pass with Qt 5.4

Changes:
 * Make PinchArea not be a child of Flickable, otherwise when zooming out the Flickable was stealing the events from the PinchArea
 * Flush touch events in some tests. Since https://qt.gitorious.org/qt/qtdeclarative/commit/6dc8f47bb05a8acb3cbcc697e0dc05356a01d4cf touch events are aggregated and only sent once per frame, that breaks tests that are expecting things to happen immediately, hence the flush
 * Change a verify() to check for !== invalid instead of letting verify() do the cast to boolean by itself
 * Make sure the pin lock buttons are enabled before tapping into them

Description of the change

 * Are there any related MPs required for this MP to build/function as expected?
No

 * Did you perform an exploratory manual test run of your code change and any related functionality?
tests now pass, behaviour is the same

 * Did you make sure that your branch does not contain spurious tags?
Yes

 * If you changed the packaging (debian), did you subscribe the ubuntu-unity team to this MP?
N/A

 * If you changed the UI, has there been a design review?
N/A

To post a comment you must log in.
lp:~aacid/unity8/qmluitests54 updated
1619. By Albert Astals Cid

Wait for the button to be enabled before tapping on it

1620. By Albert Astals Cid

Make sure there's a window

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) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Daniel d'Andrada (dandrader) :
lp:~aacid/unity8/qmluitests54 updated
1621. By Albert Astals Cid

More ifdefs

Revision history for this message
Daniel d'Andrada (dandrader) wrote :

The changes made to test code look ok. It's unfortunate we have to resort to private APIs.

review: Approve (tests code)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
lp:~aacid/unity8/qmluitests54 updated
1622. By Albert Astals Cid

fix indent

Revision history for this message
Andrea Cimitan (cimi) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'qml/Components/ZoomableImage.qml'
2--- qml/Components/ZoomableImage.qml 2014-10-29 13:52:58 +0000
3+++ qml/Components/ZoomableImage.qml 2015-02-20 12:01:41 +0000
4@@ -107,20 +107,6 @@
5 }
6 }
7
8- PinchArea {
9- id: pinchArea
10- objectName: "pinchArea"
11- property real minScale: 1.0
12- anchors.fill: parent
13- enabled: zoomable ? zoomable : false
14-
15- pinch.target: image
16- pinch.minimumScale: minScale
17- pinch.maximumScale: 10
18-
19- onPinchFinished: flickable.returnToBounds()
20- }
21-
22 MouseArea {
23 id: mouseArea
24 objectName: "mouseArea"
25@@ -153,4 +139,18 @@
26 }
27 }
28 }
29+
30+ PinchArea {
31+ id: pinchArea
32+ objectName: "pinchArea"
33+ property real minScale: 1.0
34+ anchors.fill: flickable
35+ enabled: zoomable ? zoomable : false
36+
37+ pinch.target: image
38+ pinch.minimumScale: minScale
39+ pinch.maximumScale: 10
40+
41+ onPinchFinished: flickable.returnToBounds()
42+ }
43 }
44
45=== modified file 'tests/plugins/Ubuntu/Gestures/tst_DirectionalDragArea.cpp'
46--- tests/plugins/Ubuntu/Gestures/tst_DirectionalDragArea.cpp 2014-10-17 11:01:53 +0000
47+++ tests/plugins/Ubuntu/Gestures/tst_DirectionalDragArea.cpp 2015-02-20 12:01:41 +0000
48@@ -20,6 +20,9 @@
49 #include <QtQml/QQmlEngine>
50 #include <QPointer>
51 #include <private/qquickmousearea_p.h>
52+#if (QT_VERSION >= QT_VERSION_CHECK(5, 4, 0))
53+ #include <private/qquickwindow_p.h>
54+#endif
55
56
57 #include <DirectionalDragArea.h>
58@@ -814,10 +817,16 @@
59
60 QTest::touchEvent(m_view, m_device).press(0, touchPoint.toPoint());
61
62+#if (QT_VERSION >= QT_VERSION_CHECK(5, 4, 0))
63+ QQuickWindowPrivate *wp = QQuickWindowPrivate::get(m_view);
64+#endif
65 for (int i = 0; i < totalMovementSteps; ++i) {
66 touchPoint += touchMovement;
67 passTime(movementTimeStepMs);
68 QTest::touchEvent(m_view, m_device).move(0, touchPoint.toPoint());
69+#if (QT_VERSION >= QT_VERSION_CHECK(5, 4, 0))
70+ wp->flushDelayedTouchEvent();
71+#endif
72 }
73
74 qreal actualDragDistance = ((qreal)totalMovementSteps) * movementStepDistance;
75
76=== modified file 'tests/plugins/Ubuntu/Gestures/tst_TouchGate.cpp'
77--- tests/plugins/Ubuntu/Gestures/tst_TouchGate.cpp 2014-10-01 13:20:32 +0000
78+++ tests/plugins/Ubuntu/Gestures/tst_TouchGate.cpp 2015-02-20 12:01:41 +0000
79@@ -19,6 +19,9 @@
80 #include <QQmlEngine>
81 #include <QQuickView>
82 #include <QSharedPointer>
83+#if (QT_VERSION >= QT_VERSION_CHECK(5, 4, 0))
84+ #include <private/qquickwindow_p.h>
85+#endif
86
87 // C++ std lib
88 #include <functional>
89@@ -192,6 +195,10 @@
90
91 if (!ownershipAfterTouchEnd) {
92 touchRegistry->removeCandidateOwnerForTouch(0, candidateItem);
93+#if (QT_VERSION >= QT_VERSION_CHECK(5, 4, 0))
94+ QQuickWindowPrivate *wp = QQuickWindowPrivate::get(testItem->window());
95+ wp->flushDelayedTouchEvent();
96+#endif
97 // TouchGate should now open its flood gates and let testItem get all
98 // events from touch 0 produced so far
99 QCOMPARE(testItem->touchEventsReceived.count(), 2);
100
101=== modified file 'tests/qmltests/Dash/Previews/tst_PreviewRatingInput.qml'
102--- tests/qmltests/Dash/Previews/tst_PreviewRatingInput.qml 2015-01-09 09:15:45 +0000
103+++ tests/qmltests/Dash/Previews/tst_PreviewRatingInput.qml 2015-02-20 12:01:41 +0000
104@@ -196,7 +196,7 @@
105 compare(args[1], "rated");
106 compare(args[2]["rating"], data.triggeredData["rating"]);
107 compare(args[2]["review"], data.triggeredData["review"]);
108- verify(args[2]["author"]); // Just verifying it exists now
109+ verify(args[2]["author"] !== undefined); // Just verifying it exists now
110 }
111 }
112 }
113
114=== modified file 'tests/qmltests/tst_ShellWithPin.qml'
115--- tests/qmltests/tst_ShellWithPin.qml 2015-02-06 21:12:17 +0000
116+++ tests/qmltests/tst_ShellWithPin.qml 2015-02-20 12:01:41 +0000
117@@ -217,6 +217,7 @@
118 for (var i = 0; i < pin.length; ++i) {
119 var character = pin.charAt(i)
120 var button = findChild(shell, "pinPadButton" + character)
121+ tryCompare(button, "enabled", true);
122 tap(button)
123 }
124 }
125
126=== modified file 'tests/utils/modules/Unity/Test/CMakeLists.txt'
127--- tests/utils/modules/Unity/Test/CMakeLists.txt 2014-10-01 13:20:32 +0000
128+++ tests/utils/modules/Unity/Test/CMakeLists.txt 2015-02-20 12:01:41 +0000
129@@ -4,6 +4,7 @@
130
131 include_directories(
132 ${Qt5Gui_PRIVATE_INCLUDE_DIRS}
133+ ${Qt5Quick_PRIVATE_INCLUDE_DIRS}
134 ${CMAKE_SOURCE_DIR}/libs/UbuntuGestures
135 )
136
137
138=== modified file 'tests/utils/modules/Unity/Test/TouchEventSequenceWrapper.cpp'
139--- tests/utils/modules/Unity/Test/TouchEventSequenceWrapper.cpp 2013-06-05 22:03:08 +0000
140+++ tests/utils/modules/Unity/Test/TouchEventSequenceWrapper.cpp 2015-02-20 12:01:41 +0000
141@@ -15,15 +15,24 @@
142 */
143
144 #include "TouchEventSequenceWrapper.h"
145-TouchEventSequenceWrapper::TouchEventSequenceWrapper(QTest::QTouchEventSequence eventSequence)
146+#include <private/qquickwindow_p.h>
147+
148+TouchEventSequenceWrapper::TouchEventSequenceWrapper(QTest::QTouchEventSequence eventSequence, QQuickItem *item)
149 : QObject(0)
150 , m_eventSequence(eventSequence)
151+ , m_item(item)
152 {
153 }
154
155 void TouchEventSequenceWrapper::commit(bool processEvents)
156 {
157 m_eventSequence.commit(processEvents);
158+#if (QT_VERSION >= QT_VERSION_CHECK(5, 4, 0))
159+ if (m_item->window()) {
160+ QQuickWindowPrivate *wp = QQuickWindowPrivate::get(m_item->window());
161+ wp->flushDelayedTouchEvent();
162+ }
163+#endif
164 }
165
166 void TouchEventSequenceWrapper::move(int touchId, int x, int y)
167
168=== modified file 'tests/utils/modules/Unity/Test/TouchEventSequenceWrapper.h'
169--- tests/utils/modules/Unity/Test/TouchEventSequenceWrapper.h 2013-08-23 11:56:44 +0000
170+++ tests/utils/modules/Unity/Test/TouchEventSequenceWrapper.h 2015-02-20 12:01:41 +0000
171@@ -21,11 +21,13 @@
172 #include <QtTest/QTest>
173 #include <QtQml/qqml.h>
174
175+class QQuickItem;
176+
177 class TouchEventSequenceWrapper : public QObject
178 {
179 Q_OBJECT
180 public:
181- TouchEventSequenceWrapper(QTest::QTouchEventSequence eventSequence);
182+ TouchEventSequenceWrapper(QTest::QTouchEventSequence eventSequence, QQuickItem *item);
183
184 Q_INVOKABLE void commit(bool processEvents = true);
185 Q_INVOKABLE void move(int touchId, int x, int y);
186@@ -35,6 +37,7 @@
187
188 private:
189 QTest::QTouchEventSequence m_eventSequence;
190+ QQuickItem *m_item;
191 };
192
193 QML_DECLARE_TYPE(TouchEventSequenceWrapper)
194
195=== modified file 'tests/utils/modules/Unity/Test/UnityTestCase.qml'
196--- tests/utils/modules/Unity/Test/UnityTestCase.qml 2015-01-13 20:57:41 +0000
197+++ tests/utils/modules/Unity/Test/UnityTestCase.qml 2015-02-20 12:01:41 +0000
198@@ -221,8 +221,8 @@
199 }
200 }
201
202- function touchEvent() {
203- return UT.Util.touchEvent()
204+ function touchEvent(item) {
205+ return UT.Util.touchEvent(item)
206 }
207
208 // speed is in pixels/second
209@@ -255,7 +255,7 @@
210 if (beginTouch) {
211 fakeDateTime.currentTimeMs += timeStep
212
213- var event = touchEvent()
214+ var event = touchEvent(item)
215 event.press(0 /* touchId */, rootFrom.x, rootFrom.y)
216 event.commit()
217 }
218@@ -265,19 +265,19 @@
219 // Avoid any rounding errors by making the last move be at precisely
220 // the point specified
221 wait(iterations / speed)
222- var event = touchEvent()
223+ var event = touchEvent(item)
224 event.move(0 /* touchId */, rootTo.x, rootTo.y)
225 event.commit()
226 } else {
227 wait(iterations / speed)
228- var event = touchEvent()
229+ var event = touchEvent(item)
230 event.move(0 /* touchId */, rootFrom.x + (i + 1) * diffX, rootFrom.y + (i + 1) * diffY)
231 event.commit()
232 }
233 }
234 if (endTouch) {
235 fakeDateTime.currentTimeMs += timeStep
236- var event = touchEvent()
237+ var event = touchEvent(item)
238 event.release(0 /* touchId */, rootTo.x, rootTo.y)
239 event.commit()
240 }
241@@ -287,7 +287,7 @@
242 // Make sure the item is rendered
243 waitForRendering(item);
244
245- var event1 = touchEvent();
246+ var event1 = touchEvent(item);
247 // first finger
248 event1.press(0, x1Start, y1Start);
249 event1.commit();
250@@ -320,7 +320,7 @@
251 var root = fetchRootItem(item)
252 var rootPoint = item.mapToItem(root, x, y)
253
254- var event = touchEvent()
255+ var event = touchEvent(item)
256 event.press(0 /* touchId */, rootPoint.x, rootPoint.y)
257 event.commit()
258 }
259@@ -329,7 +329,7 @@
260 var root = fetchRootItem(item)
261 var rootPoint = item.mapToItem(root, x, y)
262
263- var event = touchEvent()
264+ var event = touchEvent(item)
265 event.release(0 /* touchId */, rootPoint.x, rootPoint.y)
266 event.commit()
267 }
268@@ -347,11 +347,11 @@
269 var root = fetchRootItem(item)
270 var rootPoint = item.mapToItem(root, x, y)
271
272- var event = touchEvent()
273+ var event = touchEvent(item)
274 event.press(0 /* touchId */, rootPoint.x, rootPoint.y)
275 event.commit()
276
277- event = touchEvent()
278+ event = touchEvent(item)
279 event.release(0 /* touchId */, rootPoint.x, rootPoint.y)
280 event.commit()
281 }
282
283=== modified file 'tests/utils/modules/Unity/Test/testutil.cpp'
284--- tests/utils/modules/Unity/Test/testutil.cpp 2014-10-17 14:22:40 +0000
285+++ tests/utils/modules/Unity/Test/testutil.cpp 2015-02-20 12:01:41 +0000
286@@ -55,14 +55,14 @@
287 return result;
288 }
289
290-TouchEventSequenceWrapper *TestUtil::touchEvent()
291+TouchEventSequenceWrapper *TestUtil::touchEvent(QQuickItem *item)
292 {
293 ensureTargetWindow();
294 ensureTouchDevice();
295 ensureTouchRegistryInstalled();
296
297 return new TouchEventSequenceWrapper(
298- QTest::touchEvent(m_targetWindow, m_touchDevice, /* autoCommit */ false));
299+ QTest::touchEvent(m_targetWindow, m_touchDevice, /* autoCommit */ false), item);
300 }
301
302 void TestUtil::ensureTargetWindow()
303
304=== modified file 'tests/utils/modules/Unity/Test/testutil.h'
305--- tests/utils/modules/Unity/Test/testutil.h 2014-10-17 14:22:40 +0000
306+++ tests/utils/modules/Unity/Test/testutil.h 2015-02-20 12:01:41 +0000
307@@ -33,7 +33,7 @@
308 ~TestUtil();
309
310 Q_INVOKABLE bool isInstanceOf(QObject*, QString);
311- Q_INVOKABLE TouchEventSequenceWrapper *touchEvent();
312+ Q_INVOKABLE TouchEventSequenceWrapper *touchEvent(QQuickItem *item);
313 Q_INVOKABLE void ensureTouchRegistryInstalled();
314
315 private:

Subscribers

People subscribed via source and target branches