@@ -62,9 +62,13 @@ private Q_SLOTS:
62 void stretch_horizontal();
62 void stretch_horizontal();
63 void stretch_vertical();
63 void stretch_vertical();
64 void hintingAnimation();
64 void hintingAnimation();
65+ void hintingAnimation_dontRestartAfterFinishedAndStillPressed();
67 void flickAndHold(DirectionalDragArea *dragHandle, qreal distance);
69 void flickAndHold(DirectionalDragArea *dragHandle, qreal distance);
70+ void drag(QPointF &touchPoint, const QPointF& direction, qreal distance,
71+ int numSteps, qint64 timeMs = 500);
68 DirectionalDragArea *fetchAndSetupDragHandle(const char *objectName);
72 DirectionalDragArea *fetchAndSetupDragHandle(const char *objectName);
69 qreal fetchDragThreshold(DirectionalDragArea *dragHandle);
73 qreal fetchDragThreshold(DirectionalDragArea *dragHandle);
70 void tryCompare(std::function<qreal ()> actualFunc, qreal expectedValue);
74 void tryCompare(std::function<qreal ()> actualFunc, qreal expectedValue);
@@ -161,25 +165,29 @@ void tst_DragHandle::flickAndHold(DirectionalDragArea *dragHandle,
161 QPointF initialTouchPos = dragHandle->mapToScene(
165 QPointF initialTouchPos = dragHandle->mapToScene(
162 QPointF(dragHandle->width() / 2.0, dragHandle->height() / 2.0));
166 QPointF(dragHandle->width() / 2.0, dragHandle->height() / 2.0));
163 QPointF touchPoint = initialTouchPos;
167 QPointF touchPoint = initialTouchPos;
165− qint64 flickTimeMs = 500;
166− qint64 timeStep = flickTimeMs / numSteps;
169+ QTest::touchEvent(m_view, m_device).press(0, touchPoint.toPoint());
168 QPointF dragDirectionVector = calculateDirectionVector(dragHandle);
172 QPointF dragDirectionVector = calculateDirectionVector(dragHandle);
169− QPointF touchMovement = dragDirectionVector * (distance / (qreal)numSteps);
173+ drag(touchPoint, dragDirectionVector, distance, numSteps);
175+ // Wait for quite a bit before finally releasing to make a very low flick/release
177+ m_fakeTimeSource->m_msecsSinceReference += 5000;
171− QTest::touchEvent(m_view, m_device).press(0, touchPoint.toPoint());
178+ QTest::touchEvent(m_view, m_device).release(0, touchPoint.toPoint());
181+void tst_DragHandle::drag(QPointF &touchPoint, const QPointF& direction, qreal distance,
182+ int numSteps, qint64 timeMs)
184+ qint64 timeStep = timeMs / numSteps;
185+ QPointF touchMovement = direction * (distance / (qreal)numSteps);
173 for (int i = 0; i < numSteps; ++i) {
186 for (int i = 0; i < numSteps; ++i) {
174 touchPoint += touchMovement;
187 touchPoint += touchMovement;
175 m_fakeTimeSource->m_msecsSinceReference += timeStep;
188 m_fakeTimeSource->m_msecsSinceReference += timeStep;
176 QTest::touchEvent(m_view, m_device).move(0, touchPoint.toPoint());
189 QTest::touchEvent(m_view, m_device).move(0, touchPoint.toPoint());
179− // Wait for quite a bit before finally releasing to make a very low flick/release
181− m_fakeTimeSource->m_msecsSinceReference += 5000;
182− QTest::touchEvent(m_view, m_device).release(0, touchPoint.toPoint());
185DirectionalDragArea *tst_DragHandle::fetchAndSetupDragHandle(const char *objectName)
193DirectionalDragArea *tst_DragHandle::fetchAndSetupDragHandle(const char *objectName)
@@ -389,6 +397,53 @@ void tst_DragHandle::hintingAnimation()
389 QCOMPARE(parentItem->property("shown").toBool(), false);
397 QCOMPARE(parentItem->property("shown").toBool(), false);
401+ Regression test for LP#1269022: https://bugs.launchpad.net/unity8/+bug/1269022
404+ 2) wait for hint portion to appear
405+ 3) slowly drag handle, only a few pixels
411+ Handle will momentarily move back to zero position, then back down to the
412+ hint displacement location.
414+void tst_DragHandle::hintingAnimation_dontRestartAfterFinishedAndStillPressed()
416+ DirectionalDragArea *dragHandle = fetchAndSetupDragHandle("downwardsDragHandle");
417+ QQuickItem *parentItem = dragHandle->parentItem();
418+ qreal hintDisplacement = 100.0;
420+ // enable hinting animations
421+ m_view->rootObject()->setProperty("hintDisplacement", QVariant(hintDisplacement));
422+ m_view->rootObject()->setProperty("stretch", QVariant(true));
424+ QCOMPARE(parentItem->height(), 0.0);
426+ QPointF initialTouchPos = dragHandle->mapToScene(
427+ QPointF(dragHandle->width() / 2.0, dragHandle->height() / 2.0));
428+ QPointF touchPoint = initialTouchPos;
430+ // Pressing causes the Showable to be stretched by hintDisplacement pixels
431+ const int touchId = 0;
432+ QTest::touchEvent(m_view, m_device).press(touchId, touchPoint.toPoint());
433+ tryCompare([&](){ return parentItem->height(); }, hintDisplacement);
436+ QSignalSpy parentHeightChangedSpy(parentItem, SIGNAL(heightChanged()));
438+ drag(touchPoint, QPointF(0.0, -1.0) /*dragDirectionVector*/, 15 /*distance*/, 3 /*numSteps*/);
440+ // Give some time for animations to run, if any
443+ // parentItem height shouldn't have changed at all
444+ QVERIFY(parentHeightChangedSpy.isEmpty());
392QTEST_MAIN(tst_DragHandle)
447QTEST_MAIN(tst_DragHandle)
394#include "tst_DragHandle.moc"
449#include "tst_DragHandle.moc"