on xenial help sign in
Fix UnityTestCase.removeTimeConstraintsFromDirectionalDragAreas()
commitc1df1027e5be7d3d80dc5b53d490b97017f87ac4 authorDaniel d'Andrada <daniel.dandrada@canonical.com> dateWed 15 Apr 2015, 13:44 (12 years ago) parent06e9bc3
3 files changed+18−3
plugins/Ubuntu/Gestures/DirectionalDragArea.cpp+6 plugins/Ubuntu/Gestures/DirectionalDragArea.h+10 tests/utils/modules/Unity/Test/UnityTestCase.qml+2−3
plugins/Ubuntu/Gestures/DirectionalDragArea.cpp+6
@@ -189,6 +189,12 @@ void DirectionalDragArea::setImmediateRecognition(bool enabled)
189189 }
190190}
191191
192+void DirectionalDragArea::removeTimeConstraints()
193+{
194+ d->setMaxTime(60 * 60 * 1000);
195+ d->compositionTime = 0;
196+}
197+
192198bool DirectionalDragArea::event(QEvent *event)
193199{
194200 if (event->type() == TouchOwnershipEvent::touchOwnershipEventType()) {
plugins/Ubuntu/Gestures/DirectionalDragArea.h+10
@@ -97,6 +97,16 @@ public:
9797
9898 bool event(QEvent *e) override;
9999
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+
100110Q_SIGNALS:
101111 void directionChanged(Direction::Type direction);
102112 void draggingChanged(bool value);
tests/utils/modules/Unity/Test/UnityTestCase.qml+2−3
@@ -403,9 +403,8 @@ TestCase {
403403 function removeTimeConstraintsFromDirectionalDragAreas(item) {
404404
405405 // use duck-typing to identify a DirectionalDragArea
406− if (item.maxTime != undefined && item.compositionTime != undefined) {
407− item.maxTime = 60 * 60 * 1000;
408− item.compositionTime = 0;
406+ if (item.removeTimeConstraints != undefined) {
407+ item.removeTimeConstraints();
409408 } else {
410409 for (var i in item.children) {
411410 removeTimeConstraintsFromDirectionalDragAreas(item.children[i]);