tests: port to new QMutableEventPoint static API

This code didn't actually use QMutableEventPoint::from(), so didn't
run into the UB that from() depended on, but it's in the way of making
QMutableEventPoint a befriendable namespace instead of a public
subclass of QEventPoint.

Replaced the QMutableEventPoint ctor that takes a timestamp, and
therefore isn't compatible with the ctors on QEventPoint, with a
static function that returns QEventPoint instead.

Port QList initialization to braced-initialization as a drive-by.

Task-number: QTBUG-99615
Pick-to: 6.3
Change-Id: If5a1dbea21cc31cdefdb640716793421c8ec0af4
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
This commit is contained in:
Marc Mutz 2022-01-10 08:30:37 +01:00
parent 7d63efc16f
commit cfca4188f9
4 changed files with 131 additions and 120 deletions

View File

@ -133,6 +133,15 @@ public:
d->pos = position;
}
static QEventPoint withTimeStamp(ulong timestamp, int pointId, QEventPoint::State state,
QPointF position, QPointF scenePosition, QPointF globalPosition)
{
QEventPoint p(pointId, state, scenePosition, globalPosition);
p.d->timestamp = timestamp;
p.d->pos = position;
return p;
}
static void update(const QEventPoint &from, QEventPoint &to);
void detach() { detach(*this); }

View File

@ -404,11 +404,11 @@ void tst_QTouchEvent::touchDisabledByDefault()
QVERIFY(!item.acceptTouchEvents());
// compose an event to the scene that is over the item
QMutableEventPoint touchPoint(0);
touchPoint.setState(QEventPoint::State::Pressed);
touchPoint.setPosition(view.mapFromScene(item.mapToScene(item.boundingRect().center())));
touchPoint.setGlobalPosition(view.mapToGlobal(touchPoint.position().toPoint()));
touchPoint.setScenePosition(view.mapToScene(touchPoint.position().toPoint()));
QEventPoint touchPoint(0);
QMutableEventPoint::setState(touchPoint, QEventPoint::State::Pressed);
QMutableEventPoint::setPosition(touchPoint, view.mapFromScene(item.mapToScene(item.boundingRect().center())));
QMutableEventPoint::setGlobalPosition(touchPoint, view.mapToGlobal(touchPoint.position().toPoint()));
QMutableEventPoint::setScenePosition(touchPoint, view.mapToScene(touchPoint.position().toPoint()));
QTouchEvent touchEvent(QEvent::TouchBegin,
touchScreenDevice,
@ -464,10 +464,10 @@ void tst_QTouchEvent::touchEventAcceptedByDefault()
// compose an event to the scene that is over the item
QPointF pos = view.mapFromScene(item.mapToScene(item.boundingRect().center()));
QMutableEventPoint touchPoint(0, QEventPoint::State::Pressed,
view.mapToScene(pos.toPoint()),
view.mapToGlobal(pos.toPoint()));
touchPoint.setPosition(pos);
QEventPoint touchPoint(0, QEventPoint::State::Pressed,
view.mapToScene(pos.toPoint()),
view.mapToGlobal(pos.toPoint()));
QMutableEventPoint::setPosition(touchPoint, pos);
QTouchEvent touchEvent(QEvent::TouchBegin,
touchScreenDevice,
Qt::NoModifier,
@ -576,10 +576,10 @@ void tst_QTouchEvent::touchBeginPropagatesWhenIgnored()
// compose an event to the scene that is over the grandchild
QPointF pos = view.mapFromScene(grandchild.mapToScene(grandchild.boundingRect().center()));
QMutableEventPoint touchPoint(0, QEventPoint::State::Pressed,
view.mapToScene(pos.toPoint()),
view.mapToGlobal(pos.toPoint()));
touchPoint.setPosition(pos);
QEventPoint touchPoint(0, QEventPoint::State::Pressed,
view.mapToScene(pos.toPoint()),
view.mapToGlobal(pos.toPoint()));
QMutableEventPoint::setPosition(touchPoint, pos);
QTouchEvent touchEvent(QEvent::TouchBegin,
touchScreenDevice,
Qt::NoModifier,
@ -659,10 +659,10 @@ void tst_QTouchEvent::touchUpdateAndEndNeverPropagate()
// compose an event to the scene that is over the child
QPointF pos = view.mapFromScene(grandchild.mapToScene(grandchild.boundingRect().center()));
QMutableEventPoint touchPoint(0, QEventPoint::State::Pressed,
view.mapToScene(pos.toPoint()),
view.mapToGlobal(pos.toPoint()));
touchPoint.setPosition(pos);
QEventPoint touchPoint(0, QEventPoint::State::Pressed,
view.mapToScene(pos.toPoint()),
view.mapToGlobal(pos.toPoint()));
QMutableEventPoint::setPosition(touchPoint, pos);
QTouchEvent touchBeginEvent(QEvent::TouchBegin,
touchScreenDevice,
Qt::NoModifier,
@ -674,10 +674,10 @@ void tst_QTouchEvent::touchUpdateAndEndNeverPropagate()
QVERIFY(!root.seenTouchBegin);
// send the touch update to the child, but ignore it, it doesn't propagate
touchPoint = QMutableEventPoint(0, QEventPoint::State::Updated,
view.mapToScene(pos.toPoint()),
view.mapToGlobal(pos.toPoint()));
touchPoint.setPosition(pos);
touchPoint = QEventPoint(0, QEventPoint::State::Updated,
view.mapToScene(pos.toPoint()),
view.mapToGlobal(pos.toPoint()));
QMutableEventPoint::setPosition(touchPoint, pos);
QTouchEvent touchUpdateEvent(QEvent::TouchUpdate,
touchScreenDevice,
Qt::NoModifier,
@ -689,10 +689,10 @@ void tst_QTouchEvent::touchUpdateAndEndNeverPropagate()
QVERIFY(!root.seenTouchUpdate);
// send the touch end, same thing should happen as with touch update
touchPoint = QMutableEventPoint(0, QEventPoint::State::Released,
view.mapToScene(pos.toPoint()),
view.mapToGlobal(pos.toPoint()));
touchPoint.setPosition(pos);
touchPoint = QEventPoint(0, QEventPoint::State::Released,
view.mapToScene(pos.toPoint()),
view.mapToGlobal(pos.toPoint()));
QMutableEventPoint::setPosition(touchPoint, pos);
QTouchEvent touchEndEvent(QEvent::TouchEnd,
touchScreenDevice,
Qt::NoModifier,
@ -1027,7 +1027,7 @@ void tst_QTouchEvent::touchOnMultipleTouchscreens()
// this should be translated to a TouchBegin
QList<QWindowSystemInterface::TouchPoint> nativeTouchPoints =
QWindowSystemInterfacePrivate::toNativeTouchPoints(QList<QEventPoint>() <<
QMutableEventPoint(1234, 1, QEventPoint::State::Pressed, screenPos, screenPos, screenPos), window);
QMutableEventPoint::withTimeStamp(1234, 1, QEventPoint::State::Pressed, screenPos, screenPos, screenPos), window);
QWindowSystemInterface::handleTouchEvent(window, timestamp, touchScreenDevice, nativeTouchPoints);
QCoreApplication::processEvents();
QVERIFY(touchWidget.seenTouchBegin);
@ -1044,7 +1044,7 @@ void tst_QTouchEvent::touchOnMultipleTouchscreens()
touchWidget.seenTouchBegin = false;
nativeTouchPoints =
QWindowSystemInterfacePrivate::toNativeTouchPoints(QList<QEventPoint>() <<
QMutableEventPoint(1234, 10, QEventPoint::State::Pressed, screenPos, screenPos, screenPos), window);
QMutableEventPoint::withTimeStamp(1234, 10, QEventPoint::State::Pressed, screenPos, screenPos, screenPos), window);
QWindowSystemInterface::handleTouchEvent(window, ++timestamp, secondaryTouchScreenDevice, nativeTouchPoints);
QCoreApplication::processEvents();
QVERIFY(!touchWidget.seenTouchEnd);
@ -1059,7 +1059,7 @@ void tst_QTouchEvent::touchOnMultipleTouchscreens()
touchWidget.seenTouchBegin = false;
nativeTouchPoints =
QWindowSystemInterfacePrivate::toNativeTouchPoints(QList<QEventPoint>() <<
QMutableEventPoint(1234, 11, QEventPoint::State::Pressed, screenPos, screenPos, screenPos), window);
QMutableEventPoint::withTimeStamp(1234, 11, QEventPoint::State::Pressed, screenPos, screenPos, screenPos), window);
QWindowSystemInterface::handleTouchEvent(window, ++timestamp, secondaryTouchScreenDevice, nativeTouchPoints);
QCoreApplication::processEvents();
QVERIFY(!touchWidget.seenTouchEnd);
@ -1073,7 +1073,7 @@ void tst_QTouchEvent::touchOnMultipleTouchscreens()
// moving the first point should translate to TouchUpdate
nativeTouchPoints =
QWindowSystemInterfacePrivate::toNativeTouchPoints(QList<QEventPoint>() <<
QMutableEventPoint(1234, 1, QEventPoint::State::Updated, screenPos + delta, screenPos + delta, screenPos + delta), window);
QMutableEventPoint::withTimeStamp(1234, 1, QEventPoint::State::Updated, screenPos + delta, screenPos + delta, screenPos + delta), window);
QWindowSystemInterface::handleTouchEvent(window, ++timestamp, touchScreenDevice, nativeTouchPoints);
QCoreApplication::processEvents();
QVERIFY(touchWidget.seenTouchBegin);
@ -1088,7 +1088,7 @@ void tst_QTouchEvent::touchOnMultipleTouchscreens()
// releasing the first point translates to TouchEnd
nativeTouchPoints =
QWindowSystemInterfacePrivate::toNativeTouchPoints(QList<QEventPoint>() <<
QMutableEventPoint(1234, 1, QEventPoint::State::Released, screenPos + delta + delta, screenPos + delta + delta, screenPos + delta + delta), window);
QMutableEventPoint::withTimeStamp(1234, 1, QEventPoint::State::Released, screenPos + delta + delta, screenPos + delta + delta, screenPos + delta + delta), window);
QWindowSystemInterface::handleTouchEvent(window, ++timestamp, touchScreenDevice, nativeTouchPoints);
QCoreApplication::processEvents();
QVERIFY(touchWidget.seenTouchBegin);
@ -1112,8 +1112,8 @@ void tst_QTouchEvent::touchOnMultipleTouchscreens()
touchWidget.touchEndPoints.clear();
nativeTouchPoints =
QWindowSystemInterfacePrivate::toNativeTouchPoints(QList<QEventPoint>() <<
QMutableEventPoint(1234, 10, QEventPoint::State::Released, screenPos, screenPos, screenPos) <<
QMutableEventPoint(1234, 11, QEventPoint::State::Stationary, screenPos, screenPos, screenPos), window);
QMutableEventPoint::withTimeStamp(1234, 10, QEventPoint::State::Released, screenPos, screenPos, screenPos) <<
QMutableEventPoint::withTimeStamp(1234, 11, QEventPoint::State::Stationary, screenPos, screenPos, screenPos), window);
QWindowSystemInterface::handleTouchEvent(window, ++timestamp, secondaryTouchScreenDevice, nativeTouchPoints);
QCoreApplication::processEvents();
QVERIFY(touchWidget.seenTouchBegin);
@ -1127,7 +1127,7 @@ void tst_QTouchEvent::touchOnMultipleTouchscreens()
touchWidget.seenTouchEnd = false;
nativeTouchPoints =
QWindowSystemInterfacePrivate::toNativeTouchPoints(QList<QEventPoint>() <<
QMutableEventPoint(1234, 11, QEventPoint::State::Released, screenPos + delta + delta,
QMutableEventPoint::withTimeStamp(1234, 11, QEventPoint::State::Released, screenPos + delta + delta,
screenPos + delta + delta, screenPos + delta + delta), window);
QWindowSystemInterface::handleTouchEvent(window, ++timestamp, secondaryTouchScreenDevice, nativeTouchPoints);
QCoreApplication::processEvents();
@ -1178,18 +1178,19 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchPad()
const QPointF centerScreenPos = touchWidget.mapToGlobal(centerPos.toPoint());
ulong timestamp = 0;
QList<QMutableEventPoint> rawTouchPoints;
rawTouchPoints.append(QMutableEventPoint(0));
rawTouchPoints.append(QMutableEventPoint(1));
QList<QEventPoint> rawTouchPoints = {
QEventPoint(0),
QEventPoint(1),
};
// generate TouchBegin on leftWidget only
{
QMutableEventPoint &tp0 = rawTouchPoints[0];
tp0.setState(QEventPoint::State::Pressed);
tp0.setGlobalPosition(leftScreenPos);
QMutableEventPoint & tp1 = rawTouchPoints[1];
tp1.setState(QEventPoint::State::Pressed);
tp1.setGlobalPosition(rightScreenPos);
QEventPoint &tp0 = rawTouchPoints[0];
QMutableEventPoint::setState(tp0, QEventPoint::State::Pressed);
QMutableEventPoint::setGlobalPosition(tp0, leftScreenPos);
QEventPoint &tp1 = rawTouchPoints[1];
QMutableEventPoint::setState(tp1, QEventPoint::State::Pressed);
QMutableEventPoint::setGlobalPosition(tp1, rightScreenPos);
}
QWindow *window = touchWidget.windowHandle();
QList<QWindowSystemInterface::TouchPoint> nativeTouchPoints =
@ -1250,10 +1251,10 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchPad()
}
// generate TouchUpdate on leftWidget
rawTouchPoints[0].setState(QEventPoint::State::Updated);
rawTouchPoints[0].setGlobalPosition(centerScreenPos);
rawTouchPoints[1].setState(QEventPoint::State::Updated);
rawTouchPoints[1].setGlobalPosition(centerScreenPos);
QMutableEventPoint::setState(rawTouchPoints[0], QEventPoint::State::Updated);
QMutableEventPoint::setGlobalPosition(rawTouchPoints[0], centerScreenPos);
QMutableEventPoint::setState(rawTouchPoints[1], QEventPoint::State::Updated);
QMutableEventPoint::setGlobalPosition(rawTouchPoints[1], centerScreenPos);
nativeTouchPoints =
QWindowSystemInterfacePrivate::toNativeTouchPoints(rawTouchPoints, window);
QWindowSystemInterface::handleTouchEvent(window, ++timestamp, touchPadDevice, nativeTouchPoints);
@ -1314,8 +1315,8 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchPad()
// generate TouchEnd on leftWidget
// both touchpoints are still at centerScreenPos
rawTouchPoints[0].setState(QEventPoint::State::Released);
rawTouchPoints[1].setState(QEventPoint::State::Released);
QMutableEventPoint::setState(rawTouchPoints[0], QEventPoint::State::Released);
QMutableEventPoint::setState(rawTouchPoints[1], QEventPoint::State::Released);
nativeTouchPoints =
QWindowSystemInterfacePrivate::toNativeTouchPoints(rawTouchPoints, window);
QWindowSystemInterface::handleTouchEvent(window, ++timestamp, touchPadDevice, nativeTouchPoints);
@ -1392,17 +1393,17 @@ void tst_QTouchEvent::basicRawEventTranslationOfIds()
screenPos << touchWidget.mapToGlobal(pos[i].toPoint());
}
QPointF delta(10, 10);
QList<QMutableEventPoint> rawTouchPoints;
QList<QEventPoint> rawTouchPoints;
// Press both points, this should be translated to a TouchBegin
for (int i = 0; i < 2; ++i) {
QMutableEventPoint rawTouchPoint(i);
rawTouchPoint.setState(QEventPoint::State::Pressed);
rawTouchPoint.setGlobalPosition(screenPos[i]);
QEventPoint rawTouchPoint(i);
QMutableEventPoint::setState(rawTouchPoint, QEventPoint::State::Pressed);
QMutableEventPoint::setGlobalPosition(rawTouchPoint, screenPos[i]);
rawTouchPoints << rawTouchPoint;
}
QMutableEventPoint &p0 = rawTouchPoints[0];
QMutableEventPoint &p1 = rawTouchPoints[1];
QEventPoint &p0 = rawTouchPoints[0];
QEventPoint &p1 = rawTouchPoints[1];
ulong timestamp = 1234;
QWindow *window = touchWidget.windowHandle();
@ -1424,8 +1425,8 @@ void tst_QTouchEvent::basicRawEventTranslationOfIds()
// moving the point should translate to TouchUpdate
for (int i = 0; i < rawTouchPoints.count(); ++i) {
auto &p = rawTouchPoints[i];
p.setState(QEventPoint::State::Updated);
p.setGlobalPosition(p.globalPosition() + delta);
QMutableEventPoint::setState(p, QEventPoint::State::Updated);
QMutableEventPoint::setGlobalPosition(p, p.globalPosition() + delta);
}
nativeTouchPoints =
QWindowSystemInterfacePrivate::toNativeTouchPoints(rawTouchPoints, window);
@ -1439,8 +1440,8 @@ void tst_QTouchEvent::basicRawEventTranslationOfIds()
QCOMPARE(touchWidget.touchUpdatePoints.at(1).id(), 1);
// release last point
p0.setState(QEventPoint::State::Stationary);
p1.setState(QEventPoint::State::Released);
QMutableEventPoint::setState(p0, QEventPoint::State::Stationary);
QMutableEventPoint::setState(p1, QEventPoint::State::Released);
nativeTouchPoints =
QWindowSystemInterfacePrivate::toNativeTouchPoints(rawTouchPoints, window);
@ -1454,8 +1455,8 @@ void tst_QTouchEvent::basicRawEventTranslationOfIds()
QCOMPARE(touchWidget.touchUpdatePoints[1].id(), 1);
// Press last point again, id should increase
p1.setState(QEventPoint::State::Pressed);
p1.setId(42); // new id
QMutableEventPoint::setState(p1, QEventPoint::State::Pressed);
QMutableEventPoint::setId(p1, 42); // new id
nativeTouchPoints =
QWindowSystemInterfacePrivate::toNativeTouchPoints(rawTouchPoints, window);
QWindowSystemInterface::handleTouchEvent(window, ++timestamp, touchScreenDevice, nativeTouchPoints);
@ -1468,8 +1469,8 @@ void tst_QTouchEvent::basicRawEventTranslationOfIds()
QCOMPARE(touchWidget.touchUpdatePoints[1].id(), 42);
// release everything
p0.setState(QEventPoint::State::Released);
p1.setState(QEventPoint::State::Released);
QMutableEventPoint::setState(p0, QEventPoint::State::Released);
QMutableEventPoint::setState(p1, QEventPoint::State::Released);
nativeTouchPoints =
QWindowSystemInterfacePrivate::toNativeTouchPoints(rawTouchPoints, window);
QWindowSystemInterface::handleTouchEvent(window, ++timestamp, touchScreenDevice, nativeTouchPoints);
@ -1562,23 +1563,23 @@ void tst_QTouchEvent::deleteInEventHandler()
view.resize(200, 200);
view.fitInView(scene.sceneRect());
QMutableEventPoint touchPoint(0);
touchPoint.setState(QEventPoint::State::Pressed);
touchPoint.setPosition(view.mapFromScene(child1->mapToScene(child1->boundingRect().center())));
touchPoint.setGlobalPosition(view.mapToGlobal(touchPoint.position().toPoint()));
touchPoint.setScenePosition(view.mapToScene(touchPoint.position().toPoint()));
QEventPoint touchPoint(0);
QMutableEventPoint::setState(touchPoint, QEventPoint::State::Pressed);
QMutableEventPoint::setPosition(touchPoint, view.mapFromScene(child1->mapToScene(child1->boundingRect().center())));
QMutableEventPoint::setGlobalPosition(touchPoint, view.mapToGlobal(touchPoint.position().toPoint()));
QMutableEventPoint::setScenePosition(touchPoint, view.mapToScene(touchPoint.position().toPoint()));
QTouchEvent touchBeginEvent(QEvent::TouchBegin,
touchScreenDevice,
Qt::NoModifier,
{touchPoint});
touchPoint.detach();
touchPoint.setState(QEventPoint::State::Updated);
QMutableEventPoint::detach(touchPoint);
QMutableEventPoint::setState(touchPoint, QEventPoint::State::Updated);
QTouchEvent touchUpdateEvent(QEvent::TouchUpdate,
touchScreenDevice,
Qt::NoModifier,
{touchPoint});
touchPoint.detach();
touchPoint.setState(QEventPoint::State::Released);
QMutableEventPoint::detach(touchPoint);
QMutableEventPoint::setState(touchPoint, QEventPoint::State::Released);
QTouchEvent touchEndEvent(QEvent::TouchEnd,
touchScreenDevice,
Qt::NoModifier,
@ -1658,16 +1659,17 @@ void tst_QTouchEvent::deleteInRawEventTranslation()
QPointF rightScreenPos = rightWidget->mapToGlobal(rightPos.toPoint());
ulong timestamp = 0;
QList<QMutableEventPoint> rawTouchPoints;
rawTouchPoints.append(QMutableEventPoint(0));
rawTouchPoints.append(QMutableEventPoint(1));
rawTouchPoints.append(QMutableEventPoint(2));
rawTouchPoints[0].setState(QEventPoint::State::Pressed);
rawTouchPoints[0].setGlobalPosition(leftScreenPos);
rawTouchPoints[1].setState(QEventPoint::State::Pressed);
rawTouchPoints[1].setGlobalPosition(centerScreenPos);
rawTouchPoints[2].setState(QEventPoint::State::Pressed);
rawTouchPoints[2].setGlobalPosition(rightScreenPos);
QList<QEventPoint> rawTouchPoints = {
QEventPoint(0),
QEventPoint(1),
QEventPoint(2),
};
QMutableEventPoint::setState(rawTouchPoints[0], QEventPoint::State::Pressed);
QMutableEventPoint::setGlobalPosition(rawTouchPoints[0], leftScreenPos);
QMutableEventPoint::setState(rawTouchPoints[1], QEventPoint::State::Pressed);
QMutableEventPoint::setGlobalPosition(rawTouchPoints[1], centerScreenPos);
QMutableEventPoint::setState(rawTouchPoints[2], QEventPoint::State::Pressed);
QMutableEventPoint::setGlobalPosition(rawTouchPoints[2], rightScreenPos);
// generate begin events on all widgets, the left widget should die
QWindow *window = touchWidget.windowHandle();
@ -1680,18 +1682,18 @@ void tst_QTouchEvent::deleteInRawEventTranslation()
QVERIFY(!rightWidget.isNull());
// generate update events on all widget, the center widget should die
rawTouchPoints[0].setState(QEventPoint::State::Updated);
rawTouchPoints[1].setState(QEventPoint::State::Updated);
rawTouchPoints[2].setState(QEventPoint::State::Updated);
QMutableEventPoint::setState(rawTouchPoints[0], QEventPoint::State::Updated);
QMutableEventPoint::setState(rawTouchPoints[1], QEventPoint::State::Updated);
QMutableEventPoint::setState(rawTouchPoints[2], QEventPoint::State::Updated);
nativeTouchPoints =
QWindowSystemInterfacePrivate::toNativeTouchPoints(rawTouchPoints, window);
QWindowSystemInterface::handleTouchEvent(window, ++timestamp, touchScreenDevice, nativeTouchPoints);
QCoreApplication::processEvents();
// generate end events on all widget, the right widget should die
rawTouchPoints[0].setState(QEventPoint::State::Released);
rawTouchPoints[1].setState(QEventPoint::State::Released);
rawTouchPoints[2].setState(QEventPoint::State::Released);
QMutableEventPoint::setState(rawTouchPoints[0], QEventPoint::State::Released);
QMutableEventPoint::setState(rawTouchPoints[1], QEventPoint::State::Released);
QMutableEventPoint::setState(rawTouchPoints[2], QEventPoint::State::Released);
nativeTouchPoints =
QWindowSystemInterfacePrivate::toNativeTouchPoints(rawTouchPoints, window);
QWindowSystemInterface::handleTouchEvent(window, ++timestamp, touchScreenDevice, nativeTouchPoints);

View File

@ -11019,13 +11019,13 @@ static QList<QEventPoint>
QEventPoint::State state = QEventPoint::State::Pressed)
{
const QPointF screenPos = view.viewport()->mapToGlobal(view.mapFromScene(scenePos));
QMutableEventPoint tp(0, state, scenePos, screenPos);
tp.setState(state);
tp.setScenePosition(scenePos);
tp.setGlobalPosition(screenPos);
tp.setGlobalPressPosition(screenPos);
tp.setGlobalLastPosition(screenPos);
tp.setEllipseDiameters(ellipseDiameters);
QEventPoint tp(0, state, scenePos, screenPos);
QMutableEventPoint::setState(tp, state);
QMutableEventPoint::setScenePosition(tp, scenePos);
QMutableEventPoint::setGlobalPosition(tp, screenPos);
QMutableEventPoint::setGlobalPressPosition(tp, screenPos);
QMutableEventPoint::setGlobalLastPosition(tp, screenPos);
QMutableEventPoint::setEllipseDiameters(tp, ellipseDiameters);
return QList<QEventPoint>() << tp;
}

View File

@ -148,11 +148,11 @@ void tst_QScroller::kineticScroll(tst_QScrollerWidget *sw, QPointF from, QPoint
QScrollerProperties sp1 = QScroller::scroller(sw)->scrollerProperties();
// send the touch begin event
QMutableEventPoint touchPoint(0);
touchPoint.setState(QEventPoint::State::Pressed);
touchPoint.setPosition(touchStart);
touchPoint.setScenePosition(touchStart);
touchPoint.setGlobalPosition(touchStart);
QEventPoint touchPoint(0);
QMutableEventPoint::setState(touchPoint, QEventPoint::State::Pressed);
QMutableEventPoint::setPosition(touchPoint, touchStart);
QMutableEventPoint::setScenePosition(touchPoint, touchStart);
QMutableEventPoint::setGlobalPosition(touchPoint, touchStart);
QTouchEvent touchEvent1(QEvent::TouchBegin,
m_touchScreen,
@ -165,10 +165,10 @@ void tst_QScroller::kineticScroll(tst_QScrollerWidget *sw, QPointF from, QPoint
// send the touch update far enough to trigger a scroll
QTest::qWait(200); // we need to wait a little or else the speed would be infinite. now we have around 500 pixel per second.
touchPoint.setPosition(touchUpdate);
touchPoint.setScenePosition(touchUpdate);
touchPoint.setGlobalPosition(touchUpdate);
touchPoint.setState(QEventPoint::State::Updated);
QMutableEventPoint::setPosition(touchPoint, touchUpdate);
QMutableEventPoint::setScenePosition(touchPoint, touchUpdate);
QMutableEventPoint::setGlobalPosition(touchPoint, touchUpdate);
QMutableEventPoint::setState(touchPoint, QEventPoint::State::Updated);
QTouchEvent touchEvent2(QEvent::TouchUpdate,
m_touchScreen,
Qt::NoModifier,
@ -189,10 +189,10 @@ void tst_QScroller::kineticScroll(tst_QScrollerWidget *sw, QPointF from, QPoint
QVERIFY(qAbs(sw->currentPos.y() - calculatedPos.y()) < 1.0);
// send the touch end
touchPoint.setPosition(touchEnd);
touchPoint.setScenePosition(touchEnd);
touchPoint.setGlobalPosition(touchEnd);
touchPoint.setState(QEventPoint::State::Released);
QMutableEventPoint::setPosition(touchPoint, touchEnd);
QMutableEventPoint::setScenePosition(touchPoint, touchEnd);
QMutableEventPoint::setGlobalPosition(touchPoint, touchEnd);
QMutableEventPoint::setState(touchPoint, QEventPoint::State::Released);
QTouchEvent touchEvent5(QEvent::TouchEnd,
m_touchScreen,
Qt::NoModifier,
@ -216,11 +216,11 @@ void tst_QScroller::kineticScrollNoTest(tst_QScrollerWidget *sw, QPointF from, Q
int fps = 60;
// send the touch begin event
QMutableEventPoint touchPoint(0);
touchPoint.setState(QEventPoint::State::Pressed);
touchPoint.setPosition(touchStart);
touchPoint.setScenePosition(touchStart);
touchPoint.setGlobalPosition(touchStart);
QEventPoint touchPoint(0);
QMutableEventPoint::setState(touchPoint, QEventPoint::State::Pressed);
QMutableEventPoint::setPosition(touchPoint, touchStart);
QMutableEventPoint::setScenePosition(touchPoint, touchStart);
QMutableEventPoint::setGlobalPosition(touchPoint, touchStart);
QTouchEvent touchEvent1(QEvent::TouchBegin,
m_touchScreen,
Qt::NoModifier,
@ -229,10 +229,10 @@ void tst_QScroller::kineticScrollNoTest(tst_QScrollerWidget *sw, QPointF from, Q
// send the touch update far enough to trigger a scroll
QTest::qWait(200); // we need to wait a little or else the speed would be infinite. now we have around 500 pixel per second.
touchPoint.setState(QEventPoint::State::Updated);
touchPoint.setPosition(touchUpdate);
touchPoint.setScenePosition(touchUpdate);
touchPoint.setGlobalPosition(touchUpdate);
QMutableEventPoint::setState(touchPoint, QEventPoint::State::Updated);
QMutableEventPoint::setPosition(touchPoint, touchUpdate);
QMutableEventPoint::setScenePosition(touchPoint, touchUpdate);
QMutableEventPoint::setGlobalPosition(touchPoint, touchUpdate);
QTouchEvent touchEvent2(QEvent::TouchUpdate,
m_touchScreen,
Qt::NoModifier,
@ -242,10 +242,10 @@ void tst_QScroller::kineticScrollNoTest(tst_QScrollerWidget *sw, QPointF from, Q
QTest::qWait(1000 / fps * 2); // wait until the first scroll move
// send the touch end
touchPoint.setState(QEventPoint::State::Released);
touchPoint.setPosition(touchEnd);
touchPoint.setScenePosition(touchEnd);
touchPoint.setGlobalPosition(touchEnd);
QMutableEventPoint::setState(touchPoint, QEventPoint::State::Released);
QMutableEventPoint::setPosition(touchPoint, touchEnd);
QMutableEventPoint::setScenePosition(touchPoint, touchEnd);
QMutableEventPoint::setGlobalPosition(touchPoint, touchEnd);
QTouchEvent touchEvent5(QEvent::TouchEnd,
m_touchScreen,
Qt::NoModifier,