on xenial help sign in
DirectionalDragArea: emit draggingChanged() on direct recognition
dc9964eDaniel d'Andrada
plugins/Ubuntu/Gestures/DirectionalDragArea.cpp+4
@@ -391,6 +391,10 @@ void DirectionalDragArea::setStatus(DirectionalDragArea::Status newStatus)
391 m_recognitionTimer->start();
391 m_recognitionTimer->start();
392 Q_EMIT draggingChanged(true);
392 Q_EMIT draggingChanged(true);
393 break;
393 break;
394+ case Recognized:
395+ if (oldStatus == WaitingForTouch)
396+ Q_EMIT draggingChanged(true);
397+ break;
394 case Rejected:
398 case Rejected:
395 Q_EMIT draggingChanged(false);
399 Q_EMIT draggingChanged(false);
396 break;
400 break;
tests/plugins/Ubuntu/Gestures/tst_DirectionalDragArea.cpp+32
@@ -67,6 +67,7 @@ private Q_SLOTS:
67 void maxSilenceTime();
67 void maxSilenceTime();
68 void sceneXAndX();
68 void sceneXAndX();
69 void sceneYAndY();
69 void sceneYAndY();
70+ void emitDraggingChangedOnDirectRecognition();
70
71
71private:
72private:
72 QQuickView *createView();
73 QQuickView *createView();
@@ -514,6 +515,37 @@ void tst_DirectionalDragArea::sceneYAndY()
514 QCOMPARE(edgeDragArea->touchSceneY(), touchScenePos.y());
515 QCOMPARE(edgeDragArea->touchSceneY(), touchScenePos.y());
515}
516}
516
517
518+/*
519+ Emit draggingChanged() when status change from WaitingForTouch directly to Recognized.
520+ This happens when the gesture recognition is effectively disabled (e.g. by setting a
521+ distanceThreshold of zero)
522+ */
523+void tst_DirectionalDragArea::emitDraggingChangedOnDirectRecognition()
524+{
525+ DirectionalDragArea *edgeDragArea =
526+ view->rootObject()->findChild<DirectionalDragArea*>("hpDragArea");
527+ QVERIFY(edgeDragArea != 0);
528+ edgeDragArea->setRecognitionTimer(fakeTimer);
529+ edgeDragArea->setTimeSource(fakeTimeSource);
530+
531+ QPointF touchPos = calculateInitialTouchPos(edgeDragArea, view);
532+
533+ QSignalSpy draggingSpy(edgeDragArea, SIGNAL(draggingChanged(bool)));
534+
535+ // That will make it completetly skip the recognition phase ("Undecided" status).
536+ edgeDragArea->setDistanceThreshold(0.0);
537+
538+ QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::WaitingForTouch);
539+ QCOMPARE(edgeDragArea->dragging(), false);
540+
541+ fakeTimeSource->m_msecsSinceReference = 0;
542+ QTest::touchEvent(view, device).press(0, touchPos.toPoint());
543+
544+ QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::Recognized);
545+ QCOMPARE(draggingSpy.count(), 1);
546+ QCOMPARE(edgeDragArea->dragging(), true);
547+}
548+
517QTEST_MAIN(tst_DirectionalDragArea)
549QTEST_MAIN(tst_DirectionalDragArea)
518
550
519#include "tst_DirectionalDragArea.moc"
551#include "tst_DirectionalDragArea.moc"