QQuickMouseEventEx me(event->type(), transform.map(event->windowPos()),
event->windowPos(), event->screenPos(),
event->button(), event->buttons(), event->modifiers());
- if (QQuickMouseEventEx::extended(event))
- me.setVelocity(QQuickMouseEventEx::extended(event)->velocity());
+ QQuickMouseEventEx *eventEx = QQuickMouseEventEx::extended(event);
+ if (eventEx) {
+ me.setVelocity(eventEx->velocity());
+ me.setCapabilities(eventEx->capabilities());
+ }
+ me.setTimestamp(event->timestamp());
me.accept();
q->sendEvent(mouseGrabberItem, &me);
event->setAccepted(me.isAccepted());
// Vertical with a quick press-move-release: should cause a flick in release.
QSignalSpy vFlickSpy(flickable, SIGNAL(flickingVerticallyChanged()));
-
- QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(50, 90));
- QTest::qWait(10);
- QTest::mouseMove(canvas, QPoint(50, 40));
- QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(50, 40));
+ // Use something that generates a huge velocity just to make it testable.
+ // In practice this feature matters on touchscreen devices where the
+ // underlying drivers will hopefully provide a pre-calculated velocity
+ // (based on more data than what the UI gets), thus making this use case
+ // working even with small movements.
+ QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(50, 10));
+ QTest::mouseMove(canvas, QPoint(50, 300), 10);
+ QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(50, 100), 10);
QCOMPARE(vFlickSpy.count(), 1);
// send press, five equally spaced moves, and release.
QTest::mousePress(canvas, Qt::LeftButton, 0, from);
- for (int i = 0; i < pointCount; ++i) {
- QMouseEvent mv(QEvent::MouseMove, from + (i+1)*diff/pointCount, Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
- QGuiApplication::sendEvent(canvas, &mv);
- QTest::qWait(duration/pointCount);
- QCoreApplication::processEvents();
- }
+ for (int i = 0; i < pointCount; ++i)
+ QTest::mouseMove(canvas, from + (i+1)*diff/pointCount, duration / pointCount);
QTest::mouseRelease(canvas, Qt::LeftButton, 0, to);
QTest::qWait(50);