on xenial help sign in
Reimplement removeTimeConstraintsFromDirectionalDragAreas

Needs small changes to the SDK i'll propose later

commit5335fb24c72c2b3dbcd5dd6f100c2aa3c6e64a27 authorAlbert Astals Cid <albert.astals@canonical.com> dateThu 10 Dec 2015, 13:21 (11 years ago) parent21dc999
11 files changed+24−20
tests/qmltests/Greeter/tst_Greeter.qml+1−1 tests/qmltests/Greeter/tst_NarrowView.qml+1−1 tests/qmltests/Greeter/tst_WideView.qml+1−1 tests/qmltests/Stages/tst_PhoneStage.qml−2 tests/qmltests/Tutorial/tst_Tutorial.qml+1−1 tests/qmltests/tst_OrientedShell.qml+1−1 tests/qmltests/tst_Shell.qml+3−3 tests/qmltests/tst_ShellWithPin.qml+1−1 tests/utils/modules/Unity/Test/UnityTestCase.qml+9−9 tests/utils/modules/Unity/Test/testutil.cpp+5 tests/utils/modules/Unity/Test/testutil.h+1
tests/qmltests/Greeter/tst_Greeter.qml+1−1
@@ -166,7 +166,7 @@ Item {
166166 tryCompare(loader, "itemDestroyed", true);
167167 loader.active = true;
168168 tryCompare(loader, "status", Loader.Ready);
169− removeTimeConstraintsFromDirectionalDragAreas(loader.item);
169+ removeTimeConstraintsFromSwipeAreas(loader.item);
170170 }
171171
172172 function getIndexOf(name) {
tests/qmltests/Greeter/tst_NarrowView.qml+1−1
@@ -300,7 +300,7 @@ Item {
300300 tryCompare(loader, "itemDestroyed", true);
301301 loader.active = true;
302302 tryCompare(loader, "status", Loader.Ready);
303− removeTimeConstraintsFromDirectionalDragAreas(loader.item);
303+ removeTimeConstraintsFromSwipeAreas(loader.item);
304304 }
305305
306306 function swipeAwayCover(toTheRight) {
tests/qmltests/Greeter/tst_WideView.qml+1−1
@@ -330,7 +330,7 @@ Item {
330330 tryCompare(loader, "itemDestroyed", true);
331331 loader.active = true;
332332 tryCompare(loader, "status", Loader.Ready);
333− removeTimeConstraintsFromDirectionalDragAreas(loader.item);
333+ removeTimeConstraintsFromSwipeAreas(loader.item);
334334 }
335335
336336 function getIndexOf(name) {
tests/qmltests/Stages/tst_PhoneStage.qml−2
@@ -141,10 +141,8 @@ Item {
141141 var inactiveApp = ApplicationManager.get(1);
142142 wait(1000);
143143
144− console.log("STARTING FLICK");
145144 touchFlick(phoneStage, startX, startY, endX, endY,
146145 true /* beginTouch */, true /* endTouch */, units.gu(10), 50);
147− console.log("FLICK DONE");
148146
149147 tryCompare(ApplicationManager, "focusedApplicationId", inactiveApp.appId)
150148
tests/qmltests/Tutorial/tst_Tutorial.qml+1−1
@@ -140,7 +140,7 @@ Item {
140140 shellLoader.active = true;
141141
142142 tryCompare(shellLoader, "status", Loader.Ready);
143− removeTimeConstraintsFromDirectionalDragAreas(shellLoader.item);
143+ removeTimeConstraintsFromSwipeAreas(shellLoader.item);
144144 }
145145
146146 function killApps() {
tests/qmltests/tst_OrientedShell.qml+1−1
@@ -1318,7 +1318,7 @@ Rectangle {
13181318 orientedShellLoader.active = true;
13191319
13201320 tryCompare(orientedShellLoader, "status", Loader.Ready);
1321− removeTimeConstraintsFromDirectionalDragAreas(orientedShellLoader.item);
1321+ removeTimeConstraintsFromSwipeAreas(orientedShellLoader.item);
13221322
13231323 shell = findChild(orientedShell, "shell");
13241324
tests/qmltests/tst_Shell.qml+3−3
@@ -324,7 +324,7 @@ Rectangle {
324324 shellLoader.state = formFactor;
325325 shellLoader.active = true;
326326 tryCompare(shellLoader, "status", Loader.Ready);
327− removeTimeConstraintsFromDirectionalDragAreas(shellLoader.item);
327+ removeTimeConstraintsFromSwipeAreas(shellLoader.item);
328328 tryCompare(shell, "enabled", true); // enabled by greeter when ready
329329
330330 sessionSpy.target = findChild(shell, "greeter")
@@ -631,7 +631,7 @@ Rectangle {
631631 // again before interacting with it otherwise any
632632 // DirectionalDragAreas in there won't be easily fooled by
633633 // fake swipes.
634− removeTimeConstraintsFromDirectionalDragAreas(greeter);
634+ removeTimeConstraintsFromSwipeAreas(greeter);
635635 swipeAwayGreeter();
636636
637637 compare(mainApp.requestedState, ApplicationInfoInterface.RequestedRunning);
@@ -951,7 +951,7 @@ Rectangle {
951951 // again before interacting with it otherwise any
952952 // DirectionalDragAreas in there won't be easily fooled by
953953 // fake swipes.
954− removeTimeConstraintsFromDirectionalDragAreas(greeter);
954+ removeTimeConstraintsFromSwipeAreas(greeter);
955955 }
956956
957957 function revealLauncherByEdgePushWithMouse() {
tests/qmltests/tst_ShellWithPin.qml+1−1
@@ -175,7 +175,7 @@ Item {
175175 shellLoader.active = true
176176
177177 tryCompare(shellLoader, "status", Loader.Ready)
178− removeTimeConstraintsFromDirectionalDragAreas(shellLoader.item)
178+ removeTimeConstraintsFromSwipeAreas(shellLoader.item)
179179 }
180180
181181 function killApps() {
tests/utils/modules/Unity/Test/UnityTestCase.qml+9−9
@@ -438,26 +438,26 @@ TestCase {
438438 while (rootItem.parent != undefined) {
439439 rootItem = rootItem.parent;
440440 }
441− removeTimeConstraintsFromDirectionalDragAreas(rootItem);
441+ removeTimeConstraintsFromSwipeAreas(rootItem);
442442 }
443443
444444 /*
445445 In qmltests, sequences of touch events are sent all at once, unlike in "real life".
446446 Also qmltests might run really slowly, e.g. when run from inside virtual machines.
447447 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
449449 elapsed time.
450450
451− This effectively makes DirectionalDragAreas easier to fool.
451+ This effectively makes SwipeAreas easier to fool.
452452 */
453− function removeTimeConstraintsFromDirectionalDragAreas(item) {
454−
455− // use duck-typing to identify a DirectionalDragArea
456− if (item.removeTimeConstraints != undefined) {
457− item.removeTimeConstraints();
453+ function removeTimeConstraintsFromSwipeAreas(item) {
454+ if (UT.Util.isInstanceOf(item, "UCSwipeArea")) {
455+ var privateSwipeArea = UT.Util.findQObjectChild(item, "UCSwipeAreaPrivate");
456+ privateSwipeArea.setMaxTime(60 * 60 * 1000);
457+ privateSwipeArea.compositionTime = 0;
458458 } else {
459459 for (var i in item.children) {
460− removeTimeConstraintsFromDirectionalDragAreas(item.children[i]);
460+ removeTimeConstraintsFromSwipeAreas(item.children[i]);
461461 }
462462 }
463463 }
tests/utils/modules/Unity/Test/testutil.cpp+5
@@ -72,6 +72,11 @@ TouchEventSequenceWrapper *TestUtil::touchEvent(QQuickItem *item)
7272 QTest::touchEvent(m_targetWindow, m_touchDevice, /* autoCommit */ false), item);
7373}
7474
75+QObject *TestUtil::findQObjectChild(QObject *object, const QString &objectName)
76+{
77+ return object->findChild<QObject*>(objectName);
78+}
79+
7580void TestUtil::ensureTargetWindow()
7681{
7782 if (!m_targetWindow && !QGuiApplication::topLevelWindows().isEmpty())
tests/utils/modules/Unity/Test/testutil.h+1
@@ -34,6 +34,7 @@ public:
3434
3535 Q_INVOKABLE bool isInstanceOf(QObject*, QString);
3636 Q_INVOKABLE TouchEventSequenceWrapper *touchEvent(QQuickItem *item);
37+ Q_INVOKABLE QObject *findQObjectChild(QObject *object, const QString &objectName);
3738
3839private:
3940 void ensureTargetWindow();