From: Laszlo Agocs Date: Tue, 3 Apr 2012 09:24:52 +0000 (+0300) Subject: Properly copy all event parameters in deliverMouseEvent() X-Git-Tag: 071012131707~663 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=aa959012a82900ea90a13129af4a5c43b155b4e2;p=profile%2Fivi%2Fqtdeclarative.git Properly copy all event parameters in deliverMouseEvent() Timestamp and capabilities were missing. One of the very special flick test cases needs to be fixed, because setting the proper timestamp will now generate correct velocities. A potentially dangerous, legacy implementation of flick() has also been updated to match how QTestLib works in Qt 5. Change-Id: Ibc99f7212ba21d41a419eaadac2fdda730658dc6 Reviewed-by: Martin Jones --- diff --git a/src/quick/items/qquickcanvas.cpp b/src/quick/items/qquickcanvas.cpp index 29733e9..382c5e8 100644 --- a/src/quick/items/qquickcanvas.cpp +++ b/src/quick/items/qquickcanvas.cpp @@ -1092,8 +1092,12 @@ bool QQuickCanvasPrivate::deliverMouseEvent(QMouseEvent *event) 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()); diff --git a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp index 2ed42e7..f926dbe 100644 --- a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp +++ b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp @@ -443,11 +443,14 @@ void tst_qquickflickable::movingAndDragging() // 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); diff --git a/tests/auto/quick/shared/viewtestutil.cpp b/tests/auto/quick/shared/viewtestutil.cpp index d00a0e2..1c4319f 100644 --- a/tests/auto/quick/shared/viewtestutil.cpp +++ b/tests/auto/quick/shared/viewtestutil.cpp @@ -88,12 +88,8 @@ void QQuickViewTestUtil::flick(QQuickView *canvas, const QPoint &from, const QPo // 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);