on xenial help sign in
Fix UnityTestCase.removeTimeConstraintsFromDirectionalDragAreas()
c1df102Daniel d'Andrada
plugins/Ubuntu/Gestures/DirectionalDragArea.cpp+6
@@ -189,6 +189,12 @@ void DirectionalDragArea::setImmediateRecognition(bool enabled)
189 }
189 }
190}
190}
191
191
192+void DirectionalDragArea::removeTimeConstraints()
193+{
194+ d->setMaxTime(60 * 60 * 1000);
195+ d->compositionTime = 0;
196+}
197+
192bool DirectionalDragArea::event(QEvent *event)
198bool DirectionalDragArea::event(QEvent *event)
193{
199{
194 if (event->type() == TouchOwnershipEvent::touchOwnershipEventType()) {
200 if (event->type() == TouchOwnershipEvent::touchOwnershipEventType()) {
plugins/Ubuntu/Gestures/DirectionalDragArea.h+10
@@ -97,6 +97,16 @@ public:
97
97
98 bool event(QEvent *e) override;
98 bool event(QEvent *e) override;
99
99
100+ /*
101+ In qmltests, sequences of touch events are sent all at once, unlike in "real life".
102+ Also qmltests might run really slowly, e.g. when run from inside virtual machines.
103+ Thus to remove a variable that qmltests cannot really control, namely time, this
104+ function removes all constraints that are sensible to elapsed time.
105+
106+ This effectively makes the DirectionalDragArea easier to fool.
107+ */
108+ Q_INVOKABLE void removeTimeConstraints();
109+
100Q_SIGNALS:
110Q_SIGNALS:
101 void directionChanged(Direction::Type direction);
111 void directionChanged(Direction::Type direction);
102 void draggingChanged(bool value);
112 void draggingChanged(bool value);
tests/utils/modules/Unity/Test/UnityTestCase.qml+2−3
@@ -403,9 +403,8 @@ TestCase {
403 function removeTimeConstraintsFromDirectionalDragAreas(item) {
403 function removeTimeConstraintsFromDirectionalDragAreas(item) {
404
404
405 // use duck-typing to identify a DirectionalDragArea
405 // use duck-typing to identify a DirectionalDragArea
406− if (item.maxTime != undefined && item.compositionTime != undefined) {
406+ if (item.removeTimeConstraints != undefined) {
407− item.maxTime = 60 * 60 * 1000;
407+ item.removeTimeConstraints();
408− item.compositionTime = 0;
409 } else {
408 } else {
410 for (var i in item.children) {
409 for (var i in item.children) {
411 removeTimeConstraintsFromDirectionalDragAreas(item.children[i]);
410 removeTimeConstraintsFromDirectionalDragAreas(item.children[i]);