Stabilize tst_QTouchEvent::multiPointRawEventTranslationOnTouchPad

The test is impacted by the position of the mouse cursor, and fails if
the mouse enters the test window when it gets shown. Try to move the
cursor away from the window.

As a drive-by, const'ify some of the local variables.

Revert 7b4b5115dd by removing the
blacklisting of the test on macOS in CI.

Pick-to: 6.3 6.2
Change-Id: Ia0c554fdf161fd4eb4aa3965e937c7db8ceeef8f
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
This commit is contained in:
Volker Hilsheimer 2022-01-14 13:17:46 +01:00
parent 98237fe16c
commit dd3c4cb9bf
2 changed files with 15 additions and 8 deletions

View File

@ -4,7 +4,5 @@ ubuntu-16.04
android
[multiPointRawEventTranslationOnTouchPad]
android
# QTBUG-99489
macos ci
[touchBeginWithGraphicsWidget]
android

View File

@ -26,6 +26,7 @@
**
****************************************************************************/
#include <QtGui/QCursor>
#include <QtGui/QScreen>
#include <QtWidgets/QGraphicsItem>
#include <QtWidgets/QGraphicsScene>
@ -1140,6 +1141,14 @@ void tst_QTouchEvent::touchOnMultipleTouchscreens()
void tst_QTouchEvent::multiPointRawEventTranslationOnTouchPad()
{
#ifdef Q_OS_MACOS
#if QT_CONFIG(cursor)
QCursor::setPos(0, 0); // move mouse out of the way
if (!QTest::qWaitFor([]{ return QCursor::pos() == QPoint(0, 0); }))
#endif
QSKIP("The macOS mouse cursor interferes with this test can cannot be moved away");
#endif
tst_QTouchEventWidget touchWidget;
touchWidget.setObjectName("touchWidget");
touchWidget.setWindowTitle(QTest::currentTestFunction());
@ -1160,12 +1169,12 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchPad()
touchWidget.show();
QVERIFY(QTest::qWaitForWindowExposed(&touchWidget));
QPointF leftPos = leftWidget.rect().center();
QPointF rightPos = rightWidget.rect().center();
QPointF centerPos = touchWidget.rect().center();
QPointF leftScreenPos = leftWidget.mapToGlobal(leftPos.toPoint());
QPointF rightScreenPos = rightWidget.mapToGlobal(rightPos.toPoint());
QPointF centerScreenPos = touchWidget.mapToGlobal(centerPos.toPoint());
const QPointF leftPos = leftWidget.rect().center();
const QPointF rightPos = rightWidget.rect().center();
const QPointF centerPos = touchWidget.rect().center();
const QPointF leftScreenPos = leftWidget.mapToGlobal(leftPos.toPoint());
const QPointF rightScreenPos = rightWidget.mapToGlobal(rightPos.toPoint());
const QPointF centerScreenPos = touchWidget.mapToGlobal(centerPos.toPoint());
ulong timestamp = 0;
QList<QMutableEventPoint> rawTouchPoints;