@@ -24,6 +24,7 @@
25#include <AxisVelocityCalculator.h>
25#include <AxisVelocityCalculator.h>
26#include <Timer>
26#include <Timer>
27+#include "Direction.h"
28using namespace UbuntuGestures;
29using namespace UbuntuGestures;
@@ -49,11 +50,11 @@ private Q_SLOTS:
49 void hintingAnimation_dontRestartAfterFinishedAndStillPressed();
50 void hintingAnimation_dontRestartAfterFinishedAndStillPressed();
52− void flickAndHold(DirectionalDragArea *dragHandle, qreal distance);
53+ void flickAndHold(QQuickItem *dragHandle, qreal distance);
53 void drag(QPointF &touchPoint, const QPointF& direction, qreal distance,
54 void drag(QPointF &touchPoint, const QPointF& direction, qreal distance,
54 int numSteps, qint64 timeMs = 500);
55 int numSteps, qint64 timeMs = 500);
55− DirectionalDragArea *fetchAndSetupDragHandle(const char *objectName);
56+ QQuickItem *fetchAndSetupDragHandle(const char *objectName);
56− qreal fetchDragThreshold(DirectionalDragArea *dragHandle);
57+ qreal fetchDragThreshold(QQuickItem *dragHandle);
57 void tryCompare(std::function<qreal ()> actualFunc, qreal expectedValue);
58 void tryCompare(std::function<qreal ()> actualFunc, qreal expectedValue);
59 QQuickView *createView();
60 QQuickView *createView();
@@ -128,11 +129,11 @@ void tst_DragHandle::tryCompare(std::function<qreal ()> actualFunc,
130namespace {
131namespace {
131−QPointF calculateDirectionVector(DirectionalDragArea *edgeDragArea)
132+QPointF calculateDirectionVector(QQuickItem *edgeDragArea)
133 QPointF localOrigin(0., 0.);
134 QPointF localOrigin(0., 0.);
134 QPointF localDirection;
135 QPointF localDirection;
135− switch (edgeDragArea->direction()) {
136+ switch (edgeDragArea->property("direction").toInt()) {
136 case Direction::Upwards:
137 case Direction::Upwards:
137 localDirection.rx() = 0.;
138 localDirection.rx() = 0.;
138 localDirection.ry() = -1.;
139 localDirection.ry() = -1.;
@@ -156,7 +157,7 @@ QPointF calculateDirectionVector(DirectionalDragArea *edgeDragArea)
159−void tst_DragHandle::flickAndHold(DirectionalDragArea *dragHandle,
160+void tst_DragHandle::flickAndHold(QQuickItem *dragHandle,
160 qreal distance)
161 qreal distance)
162 QPointF initialTouchPos = dragHandle->mapToScene(
163 QPointF initialTouchPos = dragHandle->mapToScene(
@@ -194,13 +195,14 @@ void tst_DragHandle::drag(QPointF &touchPoint, const QPointF& direction, qreal d
197−DirectionalDragArea *tst_DragHandle::fetchAndSetupDragHandle(const char *objectName)
198+QQuickItem *tst_DragHandle::fetchAndSetupDragHandle(const char *objectName)
199− DirectionalDragArea *dragHandle =
200+ QQuickItem *dragHandle =
200− m_view->rootObject()->findChild<DirectionalDragArea*>(objectName);
201+ m_view->rootObject()->findChild<QQuickItem*>(objectName);
201 Q_ASSERT(dragHandle != 0);
202 Q_ASSERT(dragHandle != 0);
203+ QObject *swipeAreaPrivate = dragHandle->findChild<QObject*>("UCSwipeAreaPrivate");
202− dragHandle->d->setRecognitionTimer(m_fakeTimer);
204+ QMetaObject::invokeMethod(swipeAreaPrivate, "setRecognitionTimer", Q_ARG(UbuntuGestures::AbstractTimer*, m_fakeTimer));
203− dragHandle->d->setTimeSource(m_fakeTimeSource);
205+ QMetaObject::invokeMethod(swipeAreaPrivate, "setTimeSource", Q_ARG(UbuntuGestures::SharedTimeSource, m_fakeTimeSource));
205 AxisVelocityCalculator *edgeDragEvaluator =
207 AxisVelocityCalculator *edgeDragEvaluator =
206 dragHandle->findChild<AxisVelocityCalculator*>("edgeDragEvaluator");
208 dragHandle->findChild<AxisVelocityCalculator*>("edgeDragEvaluator");
@@ -210,7 +212,7 @@ DirectionalDragArea *tst_DragHandle::fetchAndSetupDragHandle(const char *objectN
210 return dragHandle;
212 return dragHandle;
213−qreal tst_DragHandle::fetchDragThreshold(DirectionalDragArea *dragHandle)
215+qreal tst_DragHandle::fetchDragThreshold(QQuickItem *dragHandle)
215 AxisVelocityCalculator *edgeDragEvaluator =
217 AxisVelocityCalculator *edgeDragEvaluator =
216 dragHandle->findChild<AxisVelocityCalculator*>("edgeDragEvaluator");
218 dragHandle->findChild<AxisVelocityCalculator*>("edgeDragEvaluator");
@@ -231,7 +233,7 @@ void tst_DragHandle::dragThreshold_horizontal()
231 QQuickItem *baseItem = m_view->rootObject()->findChild<QQuickItem*>("baseItem");
233 QQuickItem *baseItem = m_view->rootObject()->findChild<QQuickItem*>("baseItem");
232 baseItem->setRotation(rotation);
234 baseItem->setRotation(rotation);
234− DirectionalDragArea *dragHandle = fetchAndSetupDragHandle("rightwardsDragHandle");
236+ QQuickItem *dragHandle = fetchAndSetupDragHandle("rightwardsDragHandle");
235 QQuickItem *parentItem = dragHandle->parentItem();
237 QQuickItem *parentItem = dragHandle->parentItem();
237 qreal dragThreshold = fetchDragThreshold(dragHandle);
239 qreal dragThreshold = fetchDragThreshold(dragHandle);
@@ -284,7 +286,7 @@ void tst_DragHandle::dragThreshold_vertical()
284 QQuickItem *baseItem = m_view->rootObject()->findChild<QQuickItem*>("baseItem");
286 QQuickItem *baseItem = m_view->rootObject()->findChild<QQuickItem*>("baseItem");
285 baseItem->setRotation(rotation);
287 baseItem->setRotation(rotation);
287− DirectionalDragArea *dragHandle = fetchAndSetupDragHandle("downwardsDragHandle");
289+ QQuickItem *dragHandle = fetchAndSetupDragHandle("downwardsDragHandle");
289 qreal dragThreshold = fetchDragThreshold(dragHandle);
291 qreal dragThreshold = fetchDragThreshold(dragHandle);
@@ -336,7 +338,7 @@ void tst_DragHandle::dragThreshold_vertical_data()
337void tst_DragHandle::stretch_horizontal()
339void tst_DragHandle::stretch_horizontal()
339− DirectionalDragArea *dragHandle = fetchAndSetupDragHandle("rightwardsDragHandle");
341+ QQuickItem *dragHandle = fetchAndSetupDragHandle("rightwardsDragHandle");
340 qreal totalDragDistance = dragHandle->property("maxTotalDragDistance").toReal();
342 qreal totalDragDistance = dragHandle->property("maxTotalDragDistance").toReal();
341 QQuickItem *parentItem = dragHandle->parentItem();
343 QQuickItem *parentItem = dragHandle->parentItem();
@@ -366,7 +368,7 @@ void tst_DragHandle::stretch_horizontal()
367void tst_DragHandle::stretch_vertical()
369void tst_DragHandle::stretch_vertical()
369− DirectionalDragArea *dragHandle = fetchAndSetupDragHandle("downwardsDragHandle");
371+ QQuickItem *dragHandle = fetchAndSetupDragHandle("downwardsDragHandle");
370 qreal totalDragDistance = dragHandle->property("maxTotalDragDistance").toReal();
372 qreal totalDragDistance = dragHandle->property("maxTotalDragDistance").toReal();
371 QQuickItem *parentItem = dragHandle->parentItem();
373 QQuickItem *parentItem = dragHandle->parentItem();
@@ -402,7 +404,7 @@ void tst_DragHandle::stretch_vertical()
403void tst_DragHandle::hintingAnimation()
405void tst_DragHandle::hintingAnimation()
405− DirectionalDragArea *dragHandle = fetchAndSetupDragHandle("downwardsDragHandle");
407+ QQuickItem *dragHandle = fetchAndSetupDragHandle("downwardsDragHandle");
406 QQuickItem *parentItem = dragHandle->parentItem();
408 QQuickItem *parentItem = dragHandle->parentItem();
407 qreal hintDisplacement = 100.0;
409 qreal hintDisplacement = 100.0;
@@ -443,7 +445,7 @@ void tst_DragHandle::hintingAnimation()
444void tst_DragHandle::hintingAnimation_dontRestartAfterFinishedAndStillPressed()
446void tst_DragHandle::hintingAnimation_dontRestartAfterFinishedAndStillPressed()
446− DirectionalDragArea *dragHandle = fetchAndSetupDragHandle("downwardsDragHandle");
448+ QQuickItem *dragHandle = fetchAndSetupDragHandle("downwardsDragHandle");
447 QQuickItem *parentItem = dragHandle->parentItem();
449 QQuickItem *parentItem = dragHandle->parentItem();
448 qreal hintDisplacement = 100.0;
450 qreal hintDisplacement = 100.0;