Details
-
Bug
-
Resolution: Done
-
P3: Somewhat important
-
5.6.1, 5.7.0
-
None
-
-
e09f5b17865a09dac41d0f30ef2ea238f38873eb
Description
Because of the movementEndingTimer thing that is internally used by QQuickFlickable, it emits movementEnded() even while the content is moving:
#include <QtTest> #include <QtQuick> class tst_Flickable : public QObject { Q_OBJECT private slots: void wheel(); }; static bool sendWheelEvent(QQuickItem *item, const QPoint &localPos, int degrees) { QQuickWindow *window = item->window(); QWheelEvent wheelEvent(localPos, item->window()->mapToGlobal(localPos), QPoint(0, 0), QPoint(0, 8 * degrees), 0, Qt::Vertical, Qt::NoButton, 0); QSpontaneKeyEvent::setSpontaneous(&wheelEvent); return qGuiApp->notify(window, &wheelEvent); } void tst_Flickable::wheel() { QQmlEngine engine; QQmlComponent component(&engine); component.setData("import QtQuick 2.6;" "import QtQuick.Window 2.2;" "Window {" " width: 400; height: 400;" " property alias listView: listView;" " ListView {" " id: listView;" " model: 100;" " anchors.fill: parent;" " delegate: Text {" " width: parent.width;" " text: index;" " }" " onContentYChanged: console.log('onContentYChanged', contentY, this);" " onMovementStarted: console.log('onMovementStarted', this);" " onMovementEnded: console.log('onMovementEnded', this);" " onMovingChanged: console.log('onMovingChanged', moving, this);" " }" "}", QUrl()); QQuickWindow *window = qobject_cast<QQuickWindow *>(component.create()); QVERIFY(window); window->show(); QVERIFY(QTest::qWaitForWindowExposed(window)); QQuickItem *listView = window->property("listView").value<QQuickItem*>(); QVERIFY(listView); QSignalSpy movingChanged(listView, SIGNAL(movingChanged())); QSignalSpy movementStartedSpy(listView, SIGNAL(movementStarted())); QSignalSpy movementEndedSpy(listView, SIGNAL(movementEnded())); QVERIFY(movingChanged.isValid() && movementStartedSpy.isValid() && movementEndedSpy.isValid()); // send a wheel event QVERIFY(sendWheelEvent(listView, QPoint(listView->width() / 2, listView->height() / 2), -15)); // check that the content starts moving QVERIFY(listView->property("moving").toBool()); QCOMPARE(movingChanged.count(), 1); QCOMPARE(movementStartedSpy.count(), 1); QCOMPARE(movementEndedSpy.count(), 0); // wait until the movement ends QTRY_VERIFY(!listView->property("moving").toBool()); QCOMPARE(movingChanged.count(), 2); QCOMPARE(movementStartedSpy.count(), 1); QCOMPARE(movementEndedSpy.count(), 1); // wait a bit and see if it still moves qreal before = listView->property("contentY").toReal(); QTest::qWait(500); qreal after = listView->property("contentY").toReal(); QCOMPARE(after, before); // fail } QTEST_MAIN(tst_Flickable) #include "tst_flickable.moc"
Attachments
Issue Links
- relates to
-
QTBUG-63026 [REG: 5.6-2->5.6.3]: Scrolling gesture inside QtQuick jumpy on macOS touchpad
- Closed
-
QTBUG-65160 add ScrollMomentum to ScrollPhase enum, and disambiguate "fingers lifted" from "scrolling movement ended" in cocoa plugin
- Closed
-
QTBUG-71449 Add support for simulating mouse wheel events in QTest
- Reported