@@ -86,6 +86,7 @@ private Q_SLOTS:
86 void rotated();
86 void rotated();
87 void sceneDistance();
87 void sceneDistance();
88 void sceneDistance_data();
88 void sceneDistance_data();
89+ void disabledWhileDragging();
91 void passTime(qint64 timeSpan);
92 void passTime(qint64 timeSpan);
@@ -795,6 +796,51 @@ void tst_DirectionalDragArea::sceneDistance_data()
795 QTest::newRow("rotated by 90 degrees") << 90. << QPointF(0., 1.);
796 QTest::newRow("rotated by 90 degrees") << 90. << QPointF(0., 1.);
800+ Regression test for https://bugs.launchpad.net/unity8/+bug/1276122
803+ If setting "enabled: false" while the DirectionalDragArea's (DDA) dragging
804+ property is true, the DDA stays in that state and doesn't recover any more.
806+void tst_DirectionalDragArea::disabledWhileDragging()
808+ DirectionalDragArea *edgeDragArea =
809+ m_view->rootObject()->findChild<DirectionalDragArea*>("hpDragArea");
810+ Q_ASSERT(edgeDragArea != 0);
811+ edgeDragArea->setRecognitionTimer(fakeTimer);
812+ edgeDragArea->setTimeSource(fakeTimeSource);
814+ QPointF touchPoint = calculateInitialTouchPos(edgeDragArea);
816+ qreal desiredDragDistance = edgeDragArea->distanceThreshold()*2.0f;
817+ QPointF dragDirectionVector(1., 0.); // horizontal positive
819+ qreal movementStepDistance = edgeDragArea->distanceThreshold() * 0.1f;
820+ QPointF touchMovement = dragDirectionVector * movementStepDistance;
821+ int totalMovementSteps = qCeil(desiredDragDistance / movementStepDistance);
822+ int movementTimeStepMs = (edgeDragArea->compositionTime() * 1.5f) / totalMovementSteps;
824+ QTest::touchEvent(m_view, m_device).press(0, touchPoint.toPoint());
826+ for (int i = 0; i < totalMovementSteps; ++i) {
827+ touchPoint += touchMovement;
828+ passTime(movementTimeStepMs);
829+ QTest::touchEvent(m_view, m_device).move(0, touchPoint.toPoint());
832+ QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::Recognized);
833+ QCOMPARE(edgeDragArea->dragging(), true);
835+ // disable the dragArea while it's being dragged.
836+ edgeDragArea->setEnabled(false);
838+ QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::WaitingForTouch);
839+ QCOMPARE(edgeDragArea->dragging(), false);
841+ QTest::touchEvent(m_view, m_device).release(0, touchPoint.toPoint());
798QTEST_MAIN(tst_DirectionalDragArea)
844QTEST_MAIN(tst_DirectionalDragArea)
800#include "tst_DirectionalDragArea.moc"
846#include "tst_DirectionalDragArea.moc"