diff options
Diffstat (limited to 'tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp')
-rw-r--r-- | tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp | 47 |
1 files changed, 16 insertions, 31 deletions
diff --git a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp index 7bd0393760..ae71b0412f 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp @@ -1282,33 +1282,16 @@ void tst_QGraphicsScene::removeItem() view.show(); QApplication::setActiveWindow(&view); QVERIFY(QTest::qWaitForWindowActive(&view)); - QTest::mouseMove(view.viewport(), QPoint(-1, -1)); - { - QMouseEvent moveEvent(QEvent::MouseMove, view.mapFromScene(hoverItem->scenePos() + QPointF(20, 20)), Qt::NoButton, 0, 0); - QApplication::sendEvent(view.viewport(), &moveEvent); - } - qApp->processEvents(); // update - qApp->processEvents(); // draw - QVERIFY(!hoverItem->isHovered); + QTest::mouseMove(view.viewport(), view.mapFromScene(hoverItem->scenePos() + QPointF(20, 20)), Qt::NoButton); + QTRY_VERIFY(!hoverItem->isHovered); - { - QTest::qWait(250); - QTest::mouseMove(view.viewport(), view.mapFromScene(hoverItem->scenePos()), Qt::NoButton); - QTest::qWait(10); - QMouseEvent moveEvent(QEvent::MouseMove, view.mapFromScene(hoverItem->scenePos()), Qt::NoButton, 0, 0); - QApplication::sendEvent(view.viewport(), &moveEvent); - } - qApp->processEvents(); // update - qApp->processEvents(); // draw - QVERIFY(hoverItem->isHovered); + QTest::mouseMove(view.viewport(), view.mapFromScene(hoverItem->scenePos()), Qt::NoButton); + QTRY_VERIFY(hoverItem->isHovered); scene.removeItem(hoverItem); hoverItem->setAcceptsHoverEvents(false); scene.addItem(hoverItem); - qApp->processEvents(); // <- delayed update is called - qApp->processEvents(); // <- scene schedules pending update - qApp->processEvents(); // <- pending update is sent to view - QVERIFY(!hoverItem->isHovered); + QTRY_VERIFY(!hoverItem->isHovered); } void tst_QGraphicsScene::focusItem() @@ -3509,6 +3492,8 @@ void tst_QGraphicsScene::task160653_selectionChanged() QSignalSpy spy(&scene, SIGNAL(selectionChanged())); QGraphicsView view(&scene); + view.show(); + QVERIFY(QTest::qWaitForWindowActive(&view)); QTest::mouseClick( view.viewport(), Qt::LeftButton, 0, view.mapFromScene(scene.items().first()->scenePos())); QCOMPARE(spy.count(), 1); @@ -4742,9 +4727,9 @@ void tst_QGraphicsScene::minimumRenderSize() QTRY_VERIFY(view.repaints > viewRepaints); viewRepaints = view.repaints; - QVERIFY(viewRepaints == bigParent->repaints); - QVERIFY(viewRepaints == smallChild->repaints); - QVERIFY(viewRepaints == smallerGrandChild->repaints); + QCOMPARE(viewRepaints, bigParent->repaints); + QCOMPARE(viewRepaints, smallChild->repaints); + QCOMPARE(viewRepaints, smallerGrandChild->repaints); // Setting a minimum render size should cause a repaint scene.setMinimumRenderSize(0.5); @@ -4753,9 +4738,9 @@ void tst_QGraphicsScene::minimumRenderSize() QTRY_VERIFY(view.repaints > viewRepaints); viewRepaints = view.repaints; - QVERIFY(viewRepaints == bigParent->repaints); - QVERIFY(viewRepaints == smallChild->repaints); - QVERIFY(viewRepaints == smallerGrandChild->repaints); + QCOMPARE(viewRepaints, bigParent->repaints); + QCOMPARE(viewRepaints, smallChild->repaints); + QCOMPARE(viewRepaints, smallerGrandChild->repaints); // Scaling should cause a repaint of big items only. view.scale(0.1, 0.1); @@ -4764,8 +4749,8 @@ void tst_QGraphicsScene::minimumRenderSize() QTRY_VERIFY(view.repaints > viewRepaints); viewRepaints = view.repaints; - QVERIFY(viewRepaints == bigParent->repaints); - QVERIFY(viewRepaints == smallChild->repaints); + QCOMPARE(viewRepaints, bigParent->repaints); + QCOMPARE(viewRepaints, smallChild->repaints); QVERIFY(smallChild->repaints > smallerGrandChild->repaints); // Scaling further should cause even fewer items to be repainted @@ -4775,7 +4760,7 @@ void tst_QGraphicsScene::minimumRenderSize() QTRY_VERIFY(view.repaints > viewRepaints); viewRepaints = view.repaints; - QVERIFY(viewRepaints == bigParent->repaints); + QCOMPARE(viewRepaints, bigParent->repaints); QVERIFY(bigParent->repaints > smallChild->repaints); QVERIFY(smallChild->repaints > smallerGrandChild->repaints); } |