diff options
author | Michael Brasser <michael.brasser@live.com> | 2015-07-21 14:31:19 -0500 |
---|---|---|
committer | Michael Brasser <michael.brasser@live.com> | 2015-07-22 17:58:00 +0000 |
commit | a4498f155085ab47d3c7a81ab318d9be7bb7fad3 (patch) | |
tree | 5f7243c59353d4057678bc85eb620178036b1eb9 /tests/auto/quick/qquickflickable | |
parent | 5ba31c335d3e3e14aaa9ba1c7e236b0ba300ce0f (diff) |
Emit movement signals for flick().
Make flick() more like a real flick and ensure the movement signals
and properties are updated. This allows them to be handled from QML.
This also fixes issues with flick() and dynamic delegates. Flickable
has several checks of the form:
!d->pressed && !d->hData.moving && !d->vData.moving
That were processed incorrectly for flick(), as the moving variables
were not being updated.
[ChangeLog][QtQuick][Flickable] The movement related signals and
properties are now updated for flicks started via the flick function.
Change-Id: I7e96e2e12a4d0a0ee73ddd6f29d95f19c44667b0
Task-number: QTBUG-34507
Reviewed-by: Martin Jones <martin.jones@qinetic.com.au>
Diffstat (limited to 'tests/auto/quick/qquickflickable')
-rw-r--r-- | tests/auto/quick/qquickflickable/data/movementSignals.qml | 26 | ||||
-rw-r--r-- | tests/auto/quick/qquickflickable/tst_qquickflickable.cpp | 20 |
2 files changed, 46 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickflickable/data/movementSignals.qml b/tests/auto/quick/qquickflickable/data/movementSignals.qml new file mode 100644 index 0000000000..581e882139 --- /dev/null +++ b/tests/auto/quick/qquickflickable/data/movementSignals.qml @@ -0,0 +1,26 @@ +import QtQuick 2.0 + +Flickable { + width: 400; height: 400 + contentWidth: 400; contentHeight: 1200 + + property string signalString + + Rectangle { + width: 400; height: 400 + color: "red" + } + Rectangle { + y: 400; width: 400; height: 400 + color: "yellow" + } + Rectangle { + y: 800; width: 400; height: 400 + color: "green" + } + + onMovementStarted: signalString += "ms" + onMovementEnded: signalString += "me" + onFlickStarted: signalString += "fs" + onFlickEnded: signalString += "fe" +} diff --git a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp index 44da9a64e5..d6c1fd6eea 100644 --- a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp +++ b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp @@ -91,6 +91,7 @@ private slots: void stopAtBounds_data(); void nestedMouseAreaUsingTouch(); void pressDelayWithLoader(); + void movementFromProgrammaticFlick(); void cleanup(); private: @@ -1719,6 +1720,25 @@ void tst_qquickflickable::pressDelayWithLoader() QTest::mouseRelease(window.data(), Qt::LeftButton, 0, QPoint(150, 150)); } +// QTBUG-34507 +void tst_qquickflickable::movementFromProgrammaticFlick() +{ + QScopedPointer<QQuickView> window(new QQuickView); + window->setSource(testFileUrl("movementSignals.qml")); + QTRY_COMPARE(window->status(), QQuickView::Ready); + QQuickViewTestUtil::centerOnScreen(window.data()); + QQuickViewTestUtil::moveMouseAway(window.data()); + window->show(); + QVERIFY(QTest::qWaitForWindowActive(window.data())); + + QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(window->rootObject()); + QVERIFY(flickable != 0); + + // verify that the signals for movement and flicking are called in the right order + flickable->flick(0, -1000); + QTRY_COMPARE(flickable->property("signalString").toString(), QString("msfsfeme")); +} + QTEST_MAIN(tst_qquickflickable) #include "tst_qquickflickable.moc" |