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>
This commit is contained in:
parent
d9fb502b20
commit
59b29d03b2
@ -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
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user