summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2019-07-09 15:18:46 +0200
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2019-07-10 06:16:52 +0200
commit59b29d03b2fff8a138382d45077c81fe0d4b8ea8 (patch)
treeb7e9f13c31645e792c13109a048fd2e59fc71a64
parentd9fb502b20129ef975cc6e20df306dcd84c64142 (diff)
Further stabilization of QGraphicsItem::cursor test
The QTest::mouseMove calls are not reliable, and seem to produce flakiness, at least on WinRT. Removing them, and only depending on handling of the synchronously delivered QMouseEVent for simulated mouse moves. Also, initialize the expected cursor shape from an empty scene; this avoids that showing the view with the cursor accidentially on an item results in the wrong default shape. Remove hard coded coordinates, just test what we know. Fixes: QTBUG-73545 Change-Id: I6f81d6b16bb613ec77aaa776d6a80aac739aeb58 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp25
1 files changed, 9 insertions, 16 deletions
diff --git a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp
index 3260e09943..e071edc332 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp
@@ -4153,6 +4153,8 @@ void tst_QGraphicsItem::cursor()
QGraphicsView view(&scene);
view.showFullScreen();
QVERIFY(QTest::qWaitForWindowExposed(&view));
+ const Qt::CursorShape viewportShape = view.viewport()->cursor().shape();
+
QGraphicsRectItem *item1 = scene.addRect(QRectF(-100, 0, 50, 50));
QGraphicsRectItem *item2 = scene.addRect(QRectF(50, 0, 50, 50));
@@ -4184,50 +4186,41 @@ void tst_QGraphicsItem::cursor()
QPoint item1Center = view.mapFromScene(item1->sceneBoundingRect().center());
QPoint item2Center = view.mapFromScene(item2->sceneBoundingRect().center());
- QTest::mouseMove(&view, viewCenter);
-
- const Qt::CursorShape viewportShape = view.viewport()->cursor().shape();
-
{
- QTest::mouseMove(view.viewport(), QPoint(100, 50));
- QMouseEvent event(QEvent::MouseMove, QPoint(100, 50), view.viewport()->mapToGlobal(QPoint(100, 50)), Qt::NoButton, 0, 0);
+ QMouseEvent event(QEvent::MouseMove, viewCenter, view.viewport()->mapToGlobal(viewCenter), Qt::NoButton, 0, 0);
QApplication::sendEvent(view.viewport(), &event);
}
- QTRY_COMPARE(view.viewport()->cursor().shape(), viewportShape);
+ QCOMPARE(view.viewport()->cursor().shape(), viewportShape);
{
- QTest::mouseMove(view.viewport(), item1Center);
QMouseEvent event(QEvent::MouseMove, item1Center, view.viewport()->mapToGlobal(item1Center), Qt::NoButton, 0, 0);
QApplication::sendEvent(view.viewport(), &event);
}
- QTRY_COMPARE(view.viewport()->cursor().shape(), item1->cursor().shape());
+ QCOMPARE(view.viewport()->cursor().shape(), item1->cursor().shape());
{
- QTest::mouseMove(view.viewport(), item2Center);
QMouseEvent event(QEvent::MouseMove, item2Center, view.viewport()->mapToGlobal(item2Center), Qt::NoButton, 0, 0);
QApplication::sendEvent(view.viewport(), &event);
}
- QTRY_COMPARE(view.viewport()->cursor().shape(), item2->cursor().shape());
+ QCOMPARE(view.viewport()->cursor().shape(), item2->cursor().shape());
{
- QTest::mouseMove(view.viewport(), viewCenter);
- QMouseEvent event(QEvent::MouseMove, QPoint(100, 25), view.viewport()->mapToGlobal(QPoint(100, 50)), Qt::NoButton, 0, 0);
+ QMouseEvent event(QEvent::MouseMove, viewCenter, view.viewport()->mapToGlobal(viewCenter), Qt::NoButton, 0, 0);
QApplication::sendEvent(view.viewport(), &event);
}
- QTRY_COMPARE(view.viewport()->cursor().shape(), viewportShape);
+ QCOMPARE(view.viewport()->cursor().shape(), viewportShape);
item1->setEnabled(false);
{
- QTest::mouseMove(view.viewport(), item1Center);
QMouseEvent event(QEvent::MouseMove, item1Center, view.viewport()->mapToGlobal(item1Center), Qt::NoButton, 0, 0);
QApplication::sendEvent(view.viewport(), &event);
}
- QTRY_COMPARE(view.viewport()->cursor().shape(), viewportShape);
+ QCOMPARE(view.viewport()->cursor().shape(), viewportShape);
}
#endif
/*