on xenial help sign in
Reimplement removeTimeConstraintsFromDirectionalDragAreas
5335fb2Albert Astals Cid
tests/qmltests/Greeter/tst_Greeter.qml+1−1
@@ -166,7 +166,7 @@ Item {
166 tryCompare(loader, "itemDestroyed", true);
166 tryCompare(loader, "itemDestroyed", true);
167 loader.active = true;
167 loader.active = true;
168 tryCompare(loader, "status", Loader.Ready);
168 tryCompare(loader, "status", Loader.Ready);
169− removeTimeConstraintsFromDirectionalDragAreas(loader.item);
169+ removeTimeConstraintsFromSwipeAreas(loader.item);
170 }
170 }
171
171
172 function getIndexOf(name) {
172 function getIndexOf(name) {
tests/qmltests/Greeter/tst_NarrowView.qml+1−1
@@ -300,7 +300,7 @@ Item {
300 tryCompare(loader, "itemDestroyed", true);
300 tryCompare(loader, "itemDestroyed", true);
301 loader.active = true;
301 loader.active = true;
302 tryCompare(loader, "status", Loader.Ready);
302 tryCompare(loader, "status", Loader.Ready);
303− removeTimeConstraintsFromDirectionalDragAreas(loader.item);
303+ removeTimeConstraintsFromSwipeAreas(loader.item);
304 }
304 }
305
305
306 function swipeAwayCover(toTheRight) {
306 function swipeAwayCover(toTheRight) {
tests/qmltests/Greeter/tst_WideView.qml+1−1
@@ -330,7 +330,7 @@ Item {
330 tryCompare(loader, "itemDestroyed", true);
330 tryCompare(loader, "itemDestroyed", true);
331 loader.active = true;
331 loader.active = true;
332 tryCompare(loader, "status", Loader.Ready);
332 tryCompare(loader, "status", Loader.Ready);
333− removeTimeConstraintsFromDirectionalDragAreas(loader.item);
333+ removeTimeConstraintsFromSwipeAreas(loader.item);
334 }
334 }
335
335
336 function getIndexOf(name) {
336 function getIndexOf(name) {
tests/qmltests/Stages/tst_PhoneStage.qml−2
@@ -141,10 +141,8 @@ Item {
141 var inactiveApp = ApplicationManager.get(1);
141 var inactiveApp = ApplicationManager.get(1);
142 wait(1000);
142 wait(1000);
143
143
144− console.log("STARTING FLICK");
145 touchFlick(phoneStage, startX, startY, endX, endY,
144 touchFlick(phoneStage, startX, startY, endX, endY,
146 true /* beginTouch */, true /* endTouch */, units.gu(10), 50);
145 true /* beginTouch */, true /* endTouch */, units.gu(10), 50);
147− console.log("FLICK DONE");
148
146
149 tryCompare(ApplicationManager, "focusedApplicationId", inactiveApp.appId)
147 tryCompare(ApplicationManager, "focusedApplicationId", inactiveApp.appId)
150
148
tests/qmltests/Tutorial/tst_Tutorial.qml+1−1
@@ -140,7 +140,7 @@ Item {
140 shellLoader.active = true;
140 shellLoader.active = true;
141
141
142 tryCompare(shellLoader, "status", Loader.Ready);
142 tryCompare(shellLoader, "status", Loader.Ready);
143− removeTimeConstraintsFromDirectionalDragAreas(shellLoader.item);
143+ removeTimeConstraintsFromSwipeAreas(shellLoader.item);
144 }
144 }
145
145
146 function killApps() {
146 function killApps() {
tests/qmltests/tst_OrientedShell.qml+1−1
@@ -1318,7 +1318,7 @@ Rectangle {
1318 orientedShellLoader.active = true;
1318 orientedShellLoader.active = true;
1319
1319
1320 tryCompare(orientedShellLoader, "status", Loader.Ready);
1320 tryCompare(orientedShellLoader, "status", Loader.Ready);
1321− removeTimeConstraintsFromDirectionalDragAreas(orientedShellLoader.item);
1321+ removeTimeConstraintsFromSwipeAreas(orientedShellLoader.item);
1322
1322
1323 shell = findChild(orientedShell, "shell");
1323 shell = findChild(orientedShell, "shell");
1324
1324
tests/qmltests/tst_Shell.qml+3−3
@@ -324,7 +324,7 @@ Rectangle {
324 shellLoader.state = formFactor;
324 shellLoader.state = formFactor;
325 shellLoader.active = true;
325 shellLoader.active = true;
326 tryCompare(shellLoader, "status", Loader.Ready);
326 tryCompare(shellLoader, "status", Loader.Ready);
327− removeTimeConstraintsFromDirectionalDragAreas(shellLoader.item);
327+ removeTimeConstraintsFromSwipeAreas(shellLoader.item);
328 tryCompare(shell, "enabled", true); // enabled by greeter when ready
328 tryCompare(shell, "enabled", true); // enabled by greeter when ready
329
329
330 sessionSpy.target = findChild(shell, "greeter")
330 sessionSpy.target = findChild(shell, "greeter")
@@ -631,7 +631,7 @@ Rectangle {
631 // again before interacting with it otherwise any
631 // again before interacting with it otherwise any
632 // DirectionalDragAreas in there won't be easily fooled by
632 // DirectionalDragAreas in there won't be easily fooled by
633 // fake swipes.
633 // fake swipes.
634− removeTimeConstraintsFromDirectionalDragAreas(greeter);
634+ removeTimeConstraintsFromSwipeAreas(greeter);
635 swipeAwayGreeter();
635 swipeAwayGreeter();
636
636
637 compare(mainApp.requestedState, ApplicationInfoInterface.RequestedRunning);
637 compare(mainApp.requestedState, ApplicationInfoInterface.RequestedRunning);
@@ -951,7 +951,7 @@ Rectangle {
951 // again before interacting with it otherwise any
951 // again before interacting with it otherwise any
952 // DirectionalDragAreas in there won't be easily fooled by
952 // DirectionalDragAreas in there won't be easily fooled by
953 // fake swipes.
953 // fake swipes.
954− removeTimeConstraintsFromDirectionalDragAreas(greeter);
954+ removeTimeConstraintsFromSwipeAreas(greeter);
955 }
955 }
956
956
957 function revealLauncherByEdgePushWithMouse() {
957 function revealLauncherByEdgePushWithMouse() {
tests/qmltests/tst_ShellWithPin.qml+1−1
@@ -175,7 +175,7 @@ Item {
175 shellLoader.active = true
175 shellLoader.active = true
176
176
177 tryCompare(shellLoader, "status", Loader.Ready)
177 tryCompare(shellLoader, "status", Loader.Ready)
178− removeTimeConstraintsFromDirectionalDragAreas(shellLoader.item)
178+ removeTimeConstraintsFromSwipeAreas(shellLoader.item)
179 }
179 }
180
180
181 function killApps() {
181 function killApps() {
tests/utils/modules/Unity/Test/UnityTestCase.qml+9−9
@@ -438,26 +438,26 @@ TestCase {
438 while (rootItem.parent != undefined) {
438 while (rootItem.parent != undefined) {
439 rootItem = rootItem.parent;
439 rootItem = rootItem.parent;
440 }
440 }
441− removeTimeConstraintsFromDirectionalDragAreas(rootItem);
441+ removeTimeConstraintsFromSwipeAreas(rootItem);
442 }
442 }
443
443
444 /*
444 /*
445 In qmltests, sequences of touch events are sent all at once, unlike in "real life".
445 In qmltests, sequences of touch events are sent all at once, unlike in "real life".
446 Also qmltests might run really slowly, e.g. when run from inside virtual machines.
446 Also qmltests might run really slowly, e.g. when run from inside virtual machines.
447 Thus to remove a variable that qmltests cannot really control, namely time, this
447 Thus to remove a variable that qmltests cannot really control, namely time, this
448− function removes all constraints from DirectionalDragAreas that are sensible to
448+ function removes all constraints from SwipeAreas that are sensible to
449 elapsed time.
449 elapsed time.
450
450
451− This effectively makes DirectionalDragAreas easier to fool.
451+ This effectively makes SwipeAreas easier to fool.
452 */
452 */
453− function removeTimeConstraintsFromDirectionalDragAreas(item) {
453+ function removeTimeConstraintsFromSwipeAreas(item) {
454−
454+ if (UT.Util.isInstanceOf(item, "UCSwipeArea")) {
455− // use duck-typing to identify a DirectionalDragArea
455+ var privateSwipeArea = UT.Util.findQObjectChild(item, "UCSwipeAreaPrivate");
456− if (item.removeTimeConstraints != undefined) {
456+ privateSwipeArea.setMaxTime(60 * 60 * 1000);
457− item.removeTimeConstraints();
457+ privateSwipeArea.compositionTime = 0;
458 } else {
458 } else {
459 for (var i in item.children) {
459 for (var i in item.children) {
460− removeTimeConstraintsFromDirectionalDragAreas(item.children[i]);
460+ removeTimeConstraintsFromSwipeAreas(item.children[i]);
461 }
461 }
462 }
462 }
463 }
463 }
tests/utils/modules/Unity/Test/testutil.cpp+5
@@ -72,6 +72,11 @@ TouchEventSequenceWrapper *TestUtil::touchEvent(QQuickItem *item)
72 QTest::touchEvent(m_targetWindow, m_touchDevice, /* autoCommit */ false), item);
72 QTest::touchEvent(m_targetWindow, m_touchDevice, /* autoCommit */ false), item);
73}
73}
74
74
75+QObject *TestUtil::findQObjectChild(QObject *object, const QString &objectName)
76+{
77+ return object->findChild<QObject*>(objectName);
78+}
79+
75void TestUtil::ensureTargetWindow()
80void TestUtil::ensureTargetWindow()
76{
81{
77 if (!m_targetWindow && !QGuiApplication::topLevelWindows().isEmpty())
82 if (!m_targetWindow && !QGuiApplication::topLevelWindows().isEmpty())
tests/utils/modules/Unity/Test/testutil.h+1
@@ -34,6 +34,7 @@ public:
34
34
35 Q_INVOKABLE bool isInstanceOf(QObject*, QString);
35 Q_INVOKABLE bool isInstanceOf(QObject*, QString);
36 Q_INVOKABLE TouchEventSequenceWrapper *touchEvent(QQuickItem *item);
36 Q_INVOKABLE TouchEventSequenceWrapper *touchEvent(QQuickItem *item);
37+ Q_INVOKABLE QObject *findQObjectChild(QObject *object, const QString &objectName);
37
38
38private:
39private:
39 void ensureTargetWindow();
40 void ensureTargetWindow();