diff options
-rw-r--r-- | tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp | 486 |
1 files changed, 314 insertions, 172 deletions
diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index f81a520..7fdd9c9 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -962,11 +962,12 @@ void tst_QGraphicsItem::toolTip() QGraphicsView view(&scene); view.setFixedSize(200, 200); view.show(); + QTest::qWait(250); { QHelpEvent helpEvent(QEvent::ToolTip, view.viewport()->rect().topLeft(), view.viewport()->mapToGlobal(view.viewport()->rect().topLeft())); QApplication::sendEvent(view.viewport(), &helpEvent); - QTRY_COMPARE(QApplication::topLevelWidgets().size(), 1); + QTest::qWait(250); bool foundView = false; bool foundTipLabel = false; @@ -976,15 +977,15 @@ void tst_QGraphicsItem::toolTip() if (widget->inherits("QTipLabel")) foundTipLabel = true; } - QTRY_VERIFY(foundView); - QTRY_VERIFY(!foundTipLabel); + QVERIFY(foundView); + QVERIFY(!foundTipLabel); } { QHelpEvent helpEvent(QEvent::ToolTip, view.viewport()->rect().center(), view.viewport()->mapToGlobal(view.viewport()->rect().center())); QApplication::sendEvent(view.viewport(), &helpEvent); - QTRY_COMPARE(QApplication::topLevelWidgets().size(), 2); + QTest::qWait(250); bool foundView = false; bool foundTipLabel = false; @@ -994,15 +995,15 @@ void tst_QGraphicsItem::toolTip() if (widget->inherits("QTipLabel")) foundTipLabel = true; } - QTRY_VERIFY(foundView); - QTRY_VERIFY(foundTipLabel); + QVERIFY(foundView); + QVERIFY(foundTipLabel); } { QHelpEvent helpEvent(QEvent::ToolTip, view.viewport()->rect().topLeft(), view.viewport()->mapToGlobal(view.viewport()->rect().topLeft())); QApplication::sendEvent(view.viewport(), &helpEvent); - QTRY_COMPARE(QApplication::topLevelWidgets().size(), 1); + QTest::qWait(1000); bool foundView = false; bool foundTipLabel = false; @@ -1012,8 +1013,8 @@ void tst_QGraphicsItem::toolTip() if (widget->inherits("QTipLabel") && widget->isVisible()) foundTipLabel = true; } - QTRY_VERIFY(foundView); - QTRY_VERIFY(!foundTipLabel); + QVERIFY(foundView); + QVERIFY(!foundTipLabel); } } @@ -1507,6 +1508,7 @@ void tst_QGraphicsItem::selected_textItem() QGraphicsView view(&scene); view.show(); QTest::qWaitForWindowShown(&view); + QTest::qWait(20); QTRY_VERIFY(!text->isSelected()); QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, @@ -1546,115 +1548,136 @@ void tst_QGraphicsItem::selected_multi() QVERIFY(!item2->isSelected()); // Start clicking + QTest::qWait(200); // Click on item1 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(item1->scenePos())); - QTRY_VERIFY(item1->isSelected()); - QTRY_VERIFY(!item2->isSelected()); + QTest::qWait(20); + QVERIFY(item1->isSelected()); + QVERIFY(!item2->isSelected()); // Click on item2 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(item2->scenePos())); - QTRY_VERIFY(item2->isSelected()); - QTRY_VERIFY(!item1->isSelected()); + QTest::qWait(20); + QVERIFY(item2->isSelected()); + QVERIFY(!item1->isSelected()); // Ctrl-click on item1 QTest::mouseClick(view.viewport(), Qt::LeftButton, Qt::ControlModifier, view.mapFromScene(item1->scenePos())); - QTRY_VERIFY(item2->isSelected()); - QTRY_VERIFY(item1->isSelected()); + QTest::qWait(20); + QVERIFY(item2->isSelected()); + QVERIFY(item1->isSelected()); // Ctrl-click on item1 again QTest::mouseClick(view.viewport(), Qt::LeftButton, Qt::ControlModifier, view.mapFromScene(item1->scenePos())); - QTRY_VERIFY(item2->isSelected()); - QTRY_VERIFY(!item1->isSelected()); + QTest::qWait(20); + QVERIFY(item2->isSelected()); + QVERIFY(!item1->isSelected()); // Ctrl-click on item2 QTest::mouseClick(view.viewport(), Qt::LeftButton, Qt::ControlModifier, view.mapFromScene(item2->scenePos())); - QTRY_VERIFY(!item2->isSelected()); - QTRY_VERIFY(!item1->isSelected()); + QTest::qWait(20); + QVERIFY(!item2->isSelected()); + QVERIFY(!item1->isSelected()); // Click on item1 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(item1->scenePos())); - QTRY_VERIFY(item1->isSelected()); - QTRY_VERIFY(!item2->isSelected()); + QTest::qWait(20); + QVERIFY(item1->isSelected()); + QVERIFY(!item2->isSelected()); // Click on scene QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(0, 0)); - QTRY_VERIFY(!item1->isSelected()); - QTRY_VERIFY(!item2->isSelected()); + QTest::qWait(20); + QVERIFY(!item1->isSelected()); + QVERIFY(!item2->isSelected()); // Click on item1 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(item1->scenePos())); - QTRY_VERIFY(item1->isSelected()); - QTRY_VERIFY(!item2->isSelected()); + QTest::qWait(20); + QVERIFY(item1->isSelected()); + QVERIFY(!item2->isSelected()); // Ctrl-click on scene QTest::mouseClick(view.viewport(), Qt::LeftButton, Qt::ControlModifier, view.mapFromScene(0, 0)); - QTRY_VERIFY(!item1->isSelected()); - QTRY_VERIFY(!item2->isSelected()); + QTest::qWait(20); + QVERIFY(!item1->isSelected()); + QVERIFY(!item2->isSelected()); // Click on item1 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(item1->scenePos())); - QTRY_VERIFY(item1->isSelected()); - QTRY_VERIFY(!item2->isSelected()); + QTest::qWait(20); + QVERIFY(item1->isSelected()); + QVERIFY(!item2->isSelected()); // Press on item2 QTest::mousePress(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(item2->scenePos())); - QTRY_VERIFY(!item1->isSelected()); - QTRY_VERIFY(item2->isSelected()); + QTest::qWait(20); + QVERIFY(!item1->isSelected()); + QVERIFY(item2->isSelected()); // Release on item2 QTest::mouseRelease(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(item2->scenePos())); - QTRY_VERIFY(!item1->isSelected()); - QTRY_VERIFY(item2->isSelected()); + QTest::qWait(20); + QVERIFY(!item1->isSelected()); + QVERIFY(item2->isSelected()); // Click on item1 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(item1->scenePos())); - QTRY_VERIFY(item1->isSelected()); - QTRY_VERIFY(!item2->isSelected()); + QTest::qWait(20); + QVERIFY(item1->isSelected()); + QVERIFY(!item2->isSelected()); // Ctrl-click on item1 QTest::mouseClick(view.viewport(), Qt::LeftButton, Qt::ControlModifier, view.mapFromScene(item1->scenePos())); - QTRY_VERIFY(!item1->isSelected()); - QTRY_VERIFY(!item2->isSelected()); + QTest::qWait(20); + QVERIFY(!item1->isSelected()); + QVERIFY(!item2->isSelected()); // Ctrl-press on item1 QTest::mousePress(view.viewport(), Qt::LeftButton, Qt::ControlModifier, view.mapFromScene(item1->scenePos())); - QTRY_VERIFY(!item1->isSelected()); - QTRY_VERIFY(!item2->isSelected()); + QTest::qWait(20); + QVERIFY(!item1->isSelected()); + QVERIFY(!item2->isSelected()); { // Ctrl-move on item1 QMouseEvent event(QEvent::MouseMove, view.mapFromScene(item1->scenePos()) + QPoint(1, 0), Qt::LeftButton, Qt::LeftButton, Qt::ControlModifier); QApplication::sendEvent(view.viewport(), &event); - QTRY_VERIFY(!item1->isSelected()); - QTRY_VERIFY(!item2->isSelected()); + QTest::qWait(20); + QVERIFY(!item1->isSelected()); + QVERIFY(!item2->isSelected()); } // Release on item1 QTest::mouseRelease(view.viewport(), Qt::LeftButton, Qt::ControlModifier, view.mapFromScene(item1->scenePos())); - QTRY_VERIFY(item1->isSelected()); - QTRY_VERIFY(!item2->isSelected()); + QTest::qWait(20); + QVERIFY(item1->isSelected()); + QVERIFY(!item2->isSelected()); item1->setFlag(QGraphicsItem::ItemIsMovable); item1->setSelected(false); // Ctrl-press on item1 QTest::mousePress(view.viewport(), Qt::LeftButton, Qt::ControlModifier, view.mapFromScene(item1->scenePos())); - QTRY_VERIFY(!item1->isSelected()); - QTRY_VERIFY(!item2->isSelected()); + QTest::qWait(20); + QVERIFY(!item1->isSelected()); + QVERIFY(!item2->isSelected()); { // Ctrl-move on item1 QMouseEvent event(QEvent::MouseMove, view.mapFromScene(item1->scenePos()) + QPoint(1, 0), Qt::LeftButton, Qt::LeftButton, Qt::ControlModifier); QApplication::sendEvent(view.viewport(), &event); - QTRY_VERIFY(item1->isSelected()); - QTRY_VERIFY(!item2->isSelected()); + QTest::qWait(20); + QVERIFY(item1->isSelected()); + QVERIFY(!item2->isSelected()); } // Release on item1 QTest::mouseRelease(view.viewport(), Qt::LeftButton, Qt::ControlModifier, view.mapFromScene(item1->scenePos())); - QTRY_VERIFY(item1->isSelected()); - QTRY_VERIFY(!item2->isSelected()); + QTest::qWait(20); + QVERIFY(item1->isSelected()); + QVERIFY(!item2->isSelected()); } void tst_QGraphicsItem::acceptedMouseButtons() @@ -3038,6 +3061,7 @@ void tst_QGraphicsItem::hoverEventsGenerateRepaints() QGraphicsView view(&scene); view.show(); QTest::qWaitForWindowShown(&view); + QTest::qWait(150); EventTester *tester = new EventTester; scene.addItem(tester); @@ -3053,9 +3077,11 @@ void tst_QGraphicsItem::hoverEventsGenerateRepaints() // Check that we get a repaint int npaints = tester->repaints; - QTRY_COMPARE(tester->events.size(), 2); // enter + move - QTRY_COMPARE(tester->repaints, npaints + 1); - QTRY_COMPARE(tester->events.last(), QEvent::GraphicsSceneHoverMove); + qApp->processEvents(); + qApp->processEvents(); + QCOMPARE(tester->events.size(), 2); // enter + move + QCOMPARE(tester->repaints, npaints + 1); + QCOMPARE(tester->events.last(), QEvent::GraphicsSceneHoverMove); // Send a hover move event QGraphicsSceneHoverEvent hoverMoveEvent(QEvent::GraphicsSceneHoverMove); @@ -3064,9 +3090,12 @@ void tst_QGraphicsItem::hoverEventsGenerateRepaints() QApplication::sendEvent(&scene, &hoverMoveEvent); // Check that we don't get a repaint - QTRY_COMPARE(tester->events.size(), 3); - QTRY_COMPARE(tester->repaints, npaints + 1); - QTRY_COMPARE(tester->events.last(), QEvent::GraphicsSceneHoverMove); + qApp->processEvents(); + qApp->processEvents(); + + QCOMPARE(tester->events.size(), 3); + QCOMPARE(tester->repaints, npaints + 1); + QCOMPARE(tester->events.last(), QEvent::GraphicsSceneHoverMove); // Send a hover leave event QGraphicsSceneHoverEvent hoverLeaveEvent(QEvent::GraphicsSceneHoverLeave); @@ -3075,9 +3104,12 @@ void tst_QGraphicsItem::hoverEventsGenerateRepaints() QApplication::sendEvent(&scene, &hoverLeaveEvent); // Check that we get a repaint - QTRY_COMPARE(tester->events.size(), 4); - QTRY_COMPARE(tester->repaints, npaints + 2); - QTRY_COMPARE(tester->events.last(), QEvent::GraphicsSceneHoverLeave); + qApp->processEvents(); + qApp->processEvents(); + + QCOMPARE(tester->events.size(), 4); + QCOMPARE(tester->repaints, npaints + 2); + QCOMPARE(tester->events.last(), QEvent::GraphicsSceneHoverLeave); } void tst_QGraphicsItem::boundingRects_data() @@ -3161,8 +3193,9 @@ void tst_QGraphicsItem::childrenBoundingRect() view.show(); QTest::qWaitForWindowShown(&view); + QTest::qWait(30); - QTRY_COMPARE(parent->childrenBoundingRect(), QRectF(-500, -100, 600, 800)); + QCOMPARE(parent->childrenBoundingRect(), QRectF(-500, -100, 600, 800)); } void tst_QGraphicsItem::childrenBoundingRectTransformed() @@ -3308,6 +3341,8 @@ void tst_QGraphicsItem::group() QCOMPARE(scene.items().size(), 4); QCOMPARE(scene.items(group->sceneBoundingRect()).size(), 3); + QTest::qWait(25); + QRectF parent2SceneBoundingRect = parent2->sceneBoundingRect(); group->addToGroup(parent2); QCOMPARE(parent2->group(), group); @@ -3318,6 +3353,8 @@ void tst_QGraphicsItem::group() QCOMPARE(scene.items().size(), 4); QCOMPARE(scene.items(group->sceneBoundingRect()).size(), 4); + QTest::qWait(25); + QList<QGraphicsItem *> newItems; for (int i = 0; i < 100; ++i) { QGraphicsItem *item = scene.addRect(QRectF(-25, -25, 50, 50), QPen(Qt::black, 0), @@ -3334,7 +3371,9 @@ void tst_QGraphicsItem::group() int n = 0; foreach (QGraphicsItem *item, newItems) { group->addToGroup(item); - QTRY_COMPARE(item->group(), group); + QCOMPARE(item->group(), group); + if ((n++ % 100) == 0) + QTest::qWait(10); } } @@ -3524,6 +3563,7 @@ void tst_QGraphicsItem::handlesChildEvents() QGraphicsView view(&scene); view.show(); QTest::qWaitForWindowShown(&view); + QTest::qWait(20); // Pull out the items, closest item first QList<QGraphicsItem *> items = scene.items(scene.itemsBoundingRect()); @@ -3736,6 +3776,7 @@ void tst_QGraphicsItem::filtersChildEvents() QGraphicsView view(&scene); view.show(); QTest::qWaitForWindowShown(&view); + QTest::qWait(20); QGraphicsSceneMouseEvent pressEvent(QEvent::GraphicsSceneMousePress); QGraphicsSceneMouseEvent releaseEvent(QEvent::GraphicsSceneMouseRelease); @@ -3861,6 +3902,7 @@ void tst_QGraphicsItem::ensureVisible() } item->ensureVisible(-100, -100, 25, 25); + QTest::qWait(25); for (int x = -100; x < 100; x += 25) { for (int y = -100; y < 100; y += 25) { @@ -3894,6 +3936,7 @@ void tst_QGraphicsItem::ensureVisible() } item->ensureVisible(100, 100, 25, 25); + QTest::qWait(25); } void tst_QGraphicsItem::cursor() @@ -3934,6 +3977,8 @@ void tst_QGraphicsItem::cursor() view.show(); QTest::mouseMove(&view, view.rect().center()); + QTest::qWait(25); + QCursor cursor = view.viewport()->cursor(); { @@ -3941,7 +3986,9 @@ void tst_QGraphicsItem::cursor() QApplication::sendEvent(view.viewport(), &event); } - QTRY_COMPARE(view.viewport()->cursor().shape(), cursor.shape()); + QTest::qWait(25); + + QCOMPARE(view.viewport()->cursor().shape(), cursor.shape()); { QTest::mouseMove(view.viewport(), view.mapFromScene(item1->sceneBoundingRect().center())); @@ -3956,7 +4003,7 @@ void tst_QGraphicsItem::cursor() return; #endif - QTRY_COMPARE(view.viewport()->cursor().shape(), item1->cursor().shape()); + QCOMPARE(view.viewport()->cursor().shape(), item1->cursor().shape()); { QTest::mouseMove(view.viewport(), view.mapFromScene(item2->sceneBoundingRect().center())); @@ -3964,7 +4011,9 @@ void tst_QGraphicsItem::cursor() QApplication::sendEvent(view.viewport(), &event); } - QTRY_COMPARE(view.viewport()->cursor().shape(), item2->cursor().shape()); + QTest::qWait(25); + + QCOMPARE(view.viewport()->cursor().shape(), item2->cursor().shape()); { QTest::mouseMove(view.viewport(), view.rect().center()); @@ -3972,7 +4021,9 @@ void tst_QGraphicsItem::cursor() QApplication::sendEvent(view.viewport(), &event); } - QTRY_COMPARE(view.viewport()->cursor().shape(), cursor.shape()); + QTest::qWait(25); + + QCOMPARE(view.viewport()->cursor().shape(), cursor.shape()); #endif } /* @@ -4636,6 +4687,7 @@ void tst_QGraphicsItem::sceneEventFilter() view.show(); QApplication::setActiveWindow(&view); QTest::qWaitForWindowShown(&view); + QTest::qWait(25); QGraphicsTextItem *text1 = scene.addText(QLatin1String("Text1")); QGraphicsTextItem *text2 = scene.addText(QLatin1String("Text2")); @@ -4699,6 +4751,7 @@ void tst_QGraphicsItem::sceneEventFilter() gv.setScene(anotherScene); gv.show(); QTest::qWaitForWindowShown(&gv); + QTest::qWait(25); ti->installSceneEventFilter(ti2); ti3->installSceneEventFilter(ti); delete ti2; @@ -4769,25 +4822,30 @@ void tst_QGraphicsItem::paint() QGraphicsView view2(&scene2); view2.show(); QTest::qWaitForWindowShown(&view2); + QTest::qWait(25); PaintTester tester2; scene2.addItem(&tester2); + qApp->processEvents(); //First show one paint QTRY_COMPARE(tester2.painted, 1); //nominal case, update call paint tester2.update(); + qApp->processEvents(); QTRY_VERIFY(tester2.painted == 2); //we remove the item from the scene, number of updates is still the same tester2.update(); scene2.removeItem(&tester2); + qApp->processEvents(); QTRY_VERIFY(tester2.painted == 2); //We re-add the item, the number of paint should increase scene2.addItem(&tester2); tester2.update(); + qApp->processEvents(); QTRY_VERIFY(tester2.painted == 3); } @@ -5181,6 +5239,7 @@ void tst_QGraphicsItem::itemClipsChildrenToShape2() #else QGraphicsView view(&scene); view.show(); + QTest::qWait(5000); #endif } @@ -5590,29 +5649,29 @@ void tst_QGraphicsItem::untransformable() for (int i = 0; i < 10; ++i) { QPoint center = view.viewport()->rect().center(); - QTRY_COMPARE(view.itemAt(center), item1); - QTRY_COMPARE(view.itemAt(center - QPoint(40, 0)), item1); - QTRY_COMPARE(view.itemAt(center - QPoint(-40, 0)), item1); - QTRY_COMPARE(view.itemAt(center - QPoint(0, 40)), item1); - QTRY_COMPARE(view.itemAt(center - QPoint(0, -40)), item1); + QCOMPARE(view.itemAt(center), item1); + QCOMPARE(view.itemAt(center - QPoint(40, 0)), item1); + QCOMPARE(view.itemAt(center - QPoint(-40, 0)), item1); + QCOMPARE(view.itemAt(center - QPoint(0, 40)), item1); + QCOMPARE(view.itemAt(center - QPoint(0, -40)), item1); center += QPoint(70, 70); - QTRY_COMPARE(view.itemAt(center - QPoint(40, 0)), item2); - QTRY_COMPARE(view.itemAt(center - QPoint(-40, 0)), item2); - QTRY_COMPARE(view.itemAt(center - QPoint(0, 40)), item2); - QTRY_COMPARE(view.itemAt(center - QPoint(0, -40)), item2); + QCOMPARE(view.itemAt(center - QPoint(40, 0)), item2); + QCOMPARE(view.itemAt(center - QPoint(-40, 0)), item2); + QCOMPARE(view.itemAt(center - QPoint(0, 40)), item2); + QCOMPARE(view.itemAt(center - QPoint(0, -40)), item2); center += QPoint(0, 100); - QTRY_COMPARE(view.itemAt(center - QPoint(40, 0)), item3); - QTRY_COMPARE(view.itemAt(center - QPoint(-40, 0)), item3); - QTRY_COMPARE(view.itemAt(center - QPoint(0, 40)), item3); - QTRY_COMPARE(view.itemAt(center - QPoint(0, -40)), item3); + QCOMPARE(view.itemAt(center - QPoint(40, 0)), item3); + QCOMPARE(view.itemAt(center - QPoint(-40, 0)), item3); + QCOMPARE(view.itemAt(center - QPoint(0, 40)), item3); + QCOMPARE(view.itemAt(center - QPoint(0, -40)), item3); view.scale(0.5, 0.5); view.rotate(13); view.shear(qreal(0.01), qreal(0.01)); view.translate(10, 10); - qApp->processEvents(); + QTest::qWait(25); } } @@ -5650,6 +5709,7 @@ void tst_QGraphicsItem::contextMenuEventPropagation() view.show(); view.resize(200, 200); QTest::qWaitForWindowShown(&view); + QTest::qWait(20); QContextMenuEvent event(QContextMenuEvent::Mouse, QPoint(10, 10), view.viewport()->mapToGlobal(QPoint(10, 10))); @@ -5756,6 +5816,8 @@ void tst_QGraphicsItem::task141694_textItemEnsureVisible() int hscroll = view.horizontalScrollBar()->value(); int vscroll = view.verticalScrollBar()->value(); + QTest::qWait(10); + // This should not cause the view to scroll QTRY_COMPARE(view.horizontalScrollBar()->value(), hscroll); QCOMPARE(view.verticalScrollBar()->value(), vscroll); @@ -5923,6 +5985,7 @@ void tst_QGraphicsItem::ensureUpdateOnTextItem() QGraphicsView view(&scene); view.show(); QTest::qWaitForWindowShown(&view); + QTest::qWait(25); TextItem *text1 = new TextItem(QLatin1String("123")); scene.addItem(text1); qApp->processEvents(); @@ -6224,6 +6287,7 @@ void tst_QGraphicsItem::opacity2() RESET_REPAINT_COUNTERS child->setOpacity(0.0); + QTest::qWait(10); QTRY_COMPARE(view.repaints, 1); QCOMPARE(parent->repaints, 1); QCOMPARE(child->repaints, 0); @@ -6232,6 +6296,7 @@ void tst_QGraphicsItem::opacity2() RESET_REPAINT_COUNTERS child->setOpacity(1.0); + QTest::qWait(10); QTRY_COMPARE(view.repaints, 1); QCOMPARE(parent->repaints, 1); QCOMPARE(child->repaints, 1); @@ -6240,6 +6305,7 @@ void tst_QGraphicsItem::opacity2() RESET_REPAINT_COUNTERS parent->setOpacity(0.0); + QTest::qWait(10); QTRY_COMPARE(view.repaints, 1); QCOMPARE(parent->repaints, 0); QCOMPARE(child->repaints, 0); @@ -6248,6 +6314,7 @@ void tst_QGraphicsItem::opacity2() RESET_REPAINT_COUNTERS parent->setOpacity(1.0); + QTest::qWait(10); QTRY_COMPARE(view.repaints, 1); QCOMPARE(parent->repaints, 1); QCOMPARE(child->repaints, 1); @@ -6257,6 +6324,7 @@ void tst_QGraphicsItem::opacity2() RESET_REPAINT_COUNTERS child->setOpacity(0.0); + QTest::qWait(10); QTRY_COMPARE(view.repaints, 1); QCOMPARE(parent->repaints, 1); QCOMPARE(child->repaints, 0); @@ -6265,6 +6333,7 @@ void tst_QGraphicsItem::opacity2() RESET_REPAINT_COUNTERS child->setOpacity(0.0); // Already 0.0; no change. + QTest::qWait(10); QTRY_COMPARE(view.repaints, 0); QCOMPARE(parent->repaints, 0); QCOMPARE(child->repaints, 0); @@ -6289,6 +6358,8 @@ void tst_QGraphicsItem::opacityZeroUpdates() view.reset(); parent->setOpacity(0.0); + QTest::qWait(20); + // transforming items bounding rect to view coordinates const QRect childDeviceBoundingRect = child->deviceTransform(view.viewportTransform()) .mapRect(child->boundingRect()).toRect(); @@ -6356,6 +6427,7 @@ void tst_QGraphicsItem::itemStacksBehindParent() view.show(); QTest::qWaitForWindowShown(&view); QTRY_VERIFY(!paintedItems.isEmpty()); + QTest::qWait(100); paintedItems.clear(); view.viewport()->update(); QApplication::processEvents(); @@ -6452,6 +6524,7 @@ void tst_QGraphicsItem::nestedClipping() view.setOptimizationFlag(QGraphicsView::IndirectPainting); view.show(); QTest::qWaitForWindowShown(&view); + QTest::qWait(25); QList<QGraphicsItem *> expected; expected << root << l1 << l2 << l3; @@ -6639,13 +6712,16 @@ void tst_QGraphicsItem::tabChangesFocus() QTRY_VERIFY(scene.isActive()); dial1->setFocus(); + QTest::qWait(15); QTRY_VERIFY(dial1->hasFocus()); QTest::keyPress(QApplication::focusWidget(), Qt::Key_Tab); + QTest::qWait(15); QTRY_VERIFY(view->hasFocus()); QTRY_VERIFY(item->hasFocus()); QTest::keyPress(QApplication::focusWidget(), Qt::Key_Tab); + QTest::qWait(15); if (tabChangesFocus) { QTRY_VERIFY(!view->hasFocus()); @@ -6679,21 +6755,24 @@ void tst_QGraphicsItem::cacheMode() testerChild2->setFlag(QGraphicsItem::ItemIgnoresTransformations); scene.addItem(tester); + QTest::qWait(10); for (int i = 0; i < 2; ++i) { // No visual change. QTRY_COMPARE(tester->repaints, 1); - QTRY_COMPARE(testerChild->repaints, 1); - QTRY_COMPARE(testerChild2->repaints, 1); + QCOMPARE(testerChild->repaints, 1); + QCOMPARE(testerChild2->repaints, 1); tester->setCacheMode(QGraphicsItem::NoCache); testerChild->setCacheMode(QGraphicsItem::NoCache); testerChild2->setCacheMode(QGraphicsItem::NoCache); + QTest::qWait(25); QTRY_COMPARE(tester->repaints, 1); - QTRY_COMPARE(testerChild->repaints, 1); - QTRY_COMPARE(testerChild2->repaints, 1); + QCOMPARE(testerChild->repaints, 1); + QCOMPARE(testerChild2->repaints, 1); tester->setCacheMode(QGraphicsItem::DeviceCoordinateCache); testerChild->setCacheMode(QGraphicsItem::DeviceCoordinateCache); testerChild2->setCacheMode(QGraphicsItem::DeviceCoordinateCache); + QTest::qWait(25); } // The first move causes a repaint as the item is painted into its pixmap. @@ -6701,42 +6780,48 @@ void tst_QGraphicsItem::cacheMode() tester->setPos(10, 10); testerChild->setPos(10, 10); testerChild2->setPos(10, 10); + QTest::qWait(25); QTRY_COMPARE(tester->repaints, 2); - QTRY_COMPARE(testerChild->repaints, 2); - QTRY_COMPARE(testerChild2->repaints, 2); + QCOMPARE(testerChild->repaints, 2); + QCOMPARE(testerChild2->repaints, 2); // Consecutive moves should not repaint. tester->setPos(20, 20); testerChild->setPos(20, 20); testerChild2->setPos(20, 20); - QTRY_COMPARE(tester->repaints, 2); - QTRY_COMPARE(testerChild->repaints, 2); - QTRY_COMPARE(testerChild2->repaints, 2); + QTest::qWait(250); + QCOMPARE(tester->repaints, 2); + QCOMPARE(testerChild->repaints, 2); + QCOMPARE(testerChild2->repaints, 2); // Translating does not result in a repaint. tester->translate(10, 10); + QTest::qWait(25); QTRY_COMPARE(tester->repaints, 2); - QTRY_COMPARE(testerChild->repaints, 2); - QTRY_COMPARE(testerChild2->repaints, 2); + QCOMPARE(testerChild->repaints, 2); + QCOMPARE(testerChild2->repaints, 2); // Rotating results in a repaint. tester->rotate(45); + QTest::qWait(25); QTRY_COMPARE(tester->repaints, 3); - QTRY_COMPARE(testerChild->repaints, 3); - QTRY_COMPARE(testerChild2->repaints, 2); + QCOMPARE(testerChild->repaints, 3); + QCOMPARE(testerChild2->repaints, 2); // Change to ItemCoordinateCache (triggers repaint). tester->setCacheMode(QGraphicsItem::ItemCoordinateCache); // autosize testerChild->setCacheMode(QGraphicsItem::ItemCoordinateCache); // autosize testerChild2->setCacheMode(QGraphicsItem::ItemCoordinateCache); // autosize + QTest::qWait(25); QTRY_COMPARE(tester->repaints, 4); - QTRY_COMPARE(testerChild->repaints, 4); - QTRY_COMPARE(testerChild2->repaints, 3); + QCOMPARE(testerChild->repaints, 4); + QCOMPARE(testerChild2->repaints, 3); // Rotating items with ItemCoordinateCache doesn't cause a repaint. tester->rotate(22); testerChild->rotate(22); testerChild2->rotate(22); + QTest::qWait(25); QTRY_COMPARE(tester->repaints, 4); QTRY_COMPARE(testerChild->repaints, 4); QTRY_COMPARE(testerChild2->repaints, 3); @@ -6746,66 +6831,76 @@ void tst_QGraphicsItem::cacheMode() // Explicit update causes a repaint. tester->update(0, 0, 5, 5); + QTest::qWait(25); QTRY_COMPARE(tester->repaints, 5); - QTRY_COMPARE(testerChild->repaints, 4); - QTRY_COMPARE(testerChild2->repaints, 3); + QCOMPARE(testerChild->repaints, 4); + QCOMPARE(testerChild2->repaints, 3); // Updating outside the item's bounds does not cause a repaint. tester->update(10, 10, 5, 5); + QTest::qWait(25); QTRY_COMPARE(tester->repaints, 5); - QTRY_COMPARE(testerChild->repaints, 4); - QTRY_COMPARE(testerChild2->repaints, 3); + QCOMPARE(testerChild->repaints, 4); + QCOMPARE(testerChild2->repaints, 3); // Resizing an item should cause a repaint of that item. (because of // autosize). tester->setGeometry(QRectF(-15, -15, 30, 30)); + QTest::qWait(25); QTRY_COMPARE(tester->repaints, 6); - QTRY_COMPARE(testerChild->repaints, 4); - QTRY_COMPARE(testerChild2->repaints, 3); + QCOMPARE(testerChild->repaints, 4); + QCOMPARE(testerChild2->repaints, 3); // Set fixed size. tester->setCacheMode(QGraphicsItem::ItemCoordinateCache, QSize(30, 30)); testerChild->setCacheMode(QGraphicsItem::ItemCoordinateCache, QSize(30, 30)); testerChild2->setCacheMode(QGraphicsItem::ItemCoordinateCache, QSize(30, 30)); + QTest::qWait(20); QTRY_COMPARE(tester->repaints, 7); - QTRY_COMPARE(testerChild->repaints, 5); - QTRY_COMPARE(testerChild2->repaints, 4); + QCOMPARE(testerChild->repaints, 5); + QCOMPARE(testerChild2->repaints, 4); // Resizing the item should cause a repaint. testerChild->setGeometry(QRectF(-15, -15, 30, 30)); + QTest::qWait(25); QTRY_COMPARE(tester->repaints, 7); - QTRY_COMPARE(testerChild->repaints, 6); - QTRY_COMPARE(testerChild2->repaints, 4); + QCOMPARE(testerChild->repaints, 6); + QCOMPARE(testerChild2->repaints, 4); // Scaling the view does not cause a repaint. view.scale(0.7, 0.7); + QTest::qWait(25); QTRY_COMPARE(tester->repaints, 7); - QTRY_COMPARE(testerChild->repaints, 6); - QTRY_COMPARE(testerChild2->repaints, 4); + QCOMPARE(testerChild->repaints, 6); + QCOMPARE(testerChild2->repaints, 4); // Switch to device coordinate cache. tester->setCacheMode(QGraphicsItem::DeviceCoordinateCache); testerChild->setCacheMode(QGraphicsItem::DeviceCoordinateCache); testerChild2->setCacheMode(QGraphicsItem::DeviceCoordinateCache); + QTest::qWait(25); QTRY_COMPARE(tester->repaints, 8); - QTRY_COMPARE(testerChild->repaints, 7); - QTRY_COMPARE(testerChild2->repaints, 5); + QCOMPARE(testerChild->repaints, 7); + QCOMPARE(testerChild2->repaints, 5); // Scaling the view back should cause repaints for two of the items. view.setTransform(QTransform()); + QTest::qWait(25); QTRY_COMPARE(tester->repaints, 9); - QTRY_COMPARE(testerChild->repaints, 8); - QTRY_COMPARE(testerChild2->repaints, 5); + QCOMPARE(testerChild->repaints, 8); + QCOMPARE(testerChild2->repaints, 5); // Rotating the base item (perspective) should repaint two items. tester->setTransform(QTransform().rotate(10, Qt::XAxis)); + QTest::qWait(25); QTRY_COMPARE(tester->repaints, 10); - QTRY_COMPARE(testerChild->repaints, 9); - QTRY_COMPARE(testerChild2->repaints, 5); + QCOMPARE(testerChild->repaints, 9); + QCOMPARE(testerChild2->repaints, 5); // Moving the middle item should case a repaint even if it's a move, // because the parent is rotated with a perspective. testerChild->setPos(1, 1); + QTest::qWait(25); QTRY_COMPARE(tester->repaints, 10); QTRY_COMPARE(testerChild->repaints, 10); QTRY_COMPARE(testerChild2->repaints, 5); @@ -6826,6 +6921,7 @@ void tst_QGraphicsItem::cacheMode() // Hiding and showing should invalidate the cache tester->hide(); + QTest::qWait(25); tester->show(); QTRY_COMPARE(tester->repaints, 14); QTRY_COMPARE(testerChild->repaints, 12); @@ -6918,26 +7014,31 @@ void tst_QGraphicsItem::updateCachedItemAfterMove() view.show(); QTest::qWaitForWindowShown(&view); + QTest::qWait(12); QTRY_VERIFY(tester->repaints > 0); tester->repaints = 0; // Move the item, should not cause repaints tester->setPos(10, 0); - QTRY_COMPARE(tester->repaints, 0); + QTest::qWait(12); + QCOMPARE(tester->repaints, 0); // Move then update, should cause one repaint tester->setPos(20, 0); tester->update(); - QTRY_COMPARE(tester->repaints, 1); + QTest::qWait(12); + QCOMPARE(tester->repaints, 1); // Hiding the item doesn't cause a repaint tester->hide(); - QTRY_COMPARE(tester->repaints, 1); + QTest::qWait(12); + QCOMPARE(tester->repaints, 1); // Moving a hidden item doesn't cause a repaint tester->setPos(30, 0); tester->update(); - QTRY_COMPARE(tester->repaints, 1); + QTest::qWait(12); + QCOMPARE(tester->repaints, 1); } class Track : public QGraphicsRectItem @@ -7058,6 +7159,7 @@ void tst_QGraphicsItem::update() #ifdef Q_WS_X11 qt_x11_wait_for_window_manager(&view); #endif + QTest::qWait(100); EventTester *item = new EventTester; scene.addItem(item); @@ -7066,20 +7168,23 @@ void tst_QGraphicsItem::update() item->update(); // Item marked as dirty scene.update(); // Entire scene marked as dirty - QTRY_COMPARE(item->repaints, 1); + qApp->processEvents(); + QCOMPARE(item->repaints, 1); // Make sure the dirty state from the previous update is reset so that // the item don't think it is already dirty and discards this update. item->update(); - QTRY_COMPARE(item->repaints, 2); + qApp->processEvents(); + QCOMPARE(item->repaints, 2); // Make sure a partial update doesn't cause a full update to be discarded. view.reset(); item->repaints = 0; item->update(QRectF(0, 0, 5, 5)); item->update(); - QTRY_COMPARE(item->repaints, 1); - QTRY_COMPARE(view.repaints, 1); + qApp->processEvents(); + QCOMPARE(item->repaints, 1); + QCOMPARE(view.repaints, 1); QRect itemDeviceBoundingRect = item->deviceTransform(view.viewportTransform()) .mapRect(item->boundingRect()).toRect(); QRegion expectedRegion = itemDeviceBoundingRect.adjusted(-2, -2, 2, 2); @@ -7090,55 +7195,65 @@ void tst_QGraphicsItem::update() view.reset(); item->repaints = 0; item->update(-15, -15, 5, 5); // Item's brect: (-10, -10, 20, 20) - QTRY_COMPARE(item->repaints, 0); - QTRY_COMPARE(view.repaints, 0); + qApp->processEvents(); + QCOMPARE(item->repaints, 0); + QCOMPARE(view.repaints, 0); // Make sure the area occupied by an item is repainted when hiding it. view.reset(); item->repaints = 0; item->update(); // Full update; all sub-sequent update requests are discarded. item->hide(); // visible set to 0. ignoreVisible must be set to 1; the item won't be processed otherwise. - QTRY_COMPARE(item->repaints, 0); - QTRY_COMPARE(view.repaints, 1); + qApp->processEvents(); + QCOMPARE(item->repaints, 0); + QCOMPARE(view.repaints, 1); // The entire item's bounding rect (adjusted for antialiasing) should have been painted. - QTRY_COMPARE(view.paintedRegion, expectedRegion); + QCOMPARE(view.paintedRegion, expectedRegion); // Make sure item is repainted when shown (after being hidden). view.reset(); item->repaints = 0; item->show(); - QTRY_COMPARE(item->repaints, 1); - QTRY_COMPARE(view.repaints, 1); + qApp->processEvents(); + QCOMPARE(item->repaints, 1); + QCOMPARE(view.repaints, 1); // The entire item's bounding rect (adjusted for antialiasing) should have been painted. - QTRY_COMPARE(view.paintedRegion, expectedRegion); + QCOMPARE(view.paintedRegion, expectedRegion); item->repaints = 0; item->hide(); + qApp->processEvents(); view.reset(); const QPointF originalPos = item->pos(); item->setPos(5000, 5000); - QTRY_COMPARE(item->repaints, 0); - QTRY_COMPARE(view.repaints, 0); + qApp->processEvents(); + QCOMPARE(item->repaints, 0); + QCOMPARE(view.repaints, 0); + qApp->processEvents(); item->setPos(originalPos); - QTRY_COMPARE(item->repaints, 0); - QTRY_COMPARE(view.repaints, 0); + qApp->processEvents(); + QCOMPARE(item->repaints, 0); + QCOMPARE(view.repaints, 0); item->show(); - QTRY_COMPARE(item->repaints, 1); - QTRY_COMPARE(view.repaints, 1); + qApp->processEvents(); + QCOMPARE(item->repaints, 1); + QCOMPARE(view.repaints, 1); // The entire item's bounding rect (adjusted for antialiasing) should have been painted. QCOMPARE(view.paintedRegion, expectedRegion); QGraphicsViewPrivate *viewPrivate = static_cast<QGraphicsViewPrivate *>(qt_widget_private(&view)); item->setPos(originalPos + QPoint(50, 50)); viewPrivate->updateAll(); - QVERIFY(viewPrivate->fullUpdatePending); // test to ensure object will be updated - QTRY_VERIFY(!(viewPrivate->fullUpdatePending)); // test to ensure object has been updated + QVERIFY(viewPrivate->fullUpdatePending); + QTest::qWait(50); item->repaints = 0; view.reset(); item->setPos(originalPos); - QTRY_COMPARE(item->repaints, 1); - QTRY_COMPARE(view.repaints, 1); + QTest::qWait(50); + qApp->processEvents(); + QCOMPARE(item->repaints, 1); + QCOMPARE(view.repaints, 1); COMPARE_REGIONS(view.paintedRegion, expectedRegion + expectedRegion.translated(50, 50)); // Make sure moving a parent item triggers an update on the children @@ -7155,16 +7270,18 @@ void tst_QGraphicsItem::update() view.reset(); item->repaints = 0; parent->translate(-400, 0); - QTRY_COMPARE(item->repaints, 0); - QTRY_COMPARE(view.repaints, 1); - QTRY_COMPARE(view.paintedRegion, expectedRegion); + qApp->processEvents(); + QCOMPARE(item->repaints, 0); + QCOMPARE(view.repaints, 1); + QCOMPARE(view.paintedRegion, expectedRegion); view.reset(); item->repaints = 0; parent->translate(400, 0); - QTRY_COMPARE(item->repaints, 1); - QTRY_COMPARE(view.repaints, 1); - QTRY_COMPARE(view.paintedRegion, expectedRegion); - QTRY_COMPARE(view.paintedRegion, expectedRegion); + qApp->processEvents(); + QCOMPARE(item->repaints, 1); + QCOMPARE(view.repaints, 1); + QCOMPARE(view.paintedRegion, expectedRegion); + QCOMPARE(view.paintedRegion, expectedRegion); } void tst_QGraphicsItem::setTransformProperties_data() @@ -7321,13 +7438,17 @@ void tst_QGraphicsItem::itemUsesExtendedStyleOption() rect->startTrack = false; view.show(); QTest::qWaitForWindowShown(&view); + QTest::qWait(60); rect->startTrack = true; rect->update(10, 10, 10, 10); + QTest::qWait(60); rect->startTrack = false; rect->setFlag(QGraphicsItem::ItemUsesExtendedStyleOption, true); - QTRY_VERIFY((rect->flags() & QGraphicsItem::ItemUsesExtendedStyleOption)); + QVERIFY((rect->flags() & QGraphicsItem::ItemUsesExtendedStyleOption)); + QTest::qWait(60); rect->startTrack = true; rect->update(10, 10, 10, 10); + QTest::qWait(60); } void tst_QGraphicsItem::itemSendsGeometryChanges() @@ -7379,6 +7500,7 @@ void tst_QGraphicsItem::moveItem() #ifdef Q_WS_X11 qt_x11_wait_for_window_manager(&view); #endif + QTest::qWait(100); EventTester *parent = new EventTester; EventTester *child = new EventTester(parent); @@ -7401,8 +7523,9 @@ void tst_QGraphicsItem::moveItem() .adjusted(-2, -2, 2, 2); // Adjusted for antialiasing. parent->setPos(20, 20); - QTRY_COMPARE(parent->repaints, 1); - QTRY_COMPARE(view.repaints, 1); + qApp->processEvents(); + QCOMPARE(parent->repaints, 1); + QCOMPARE(view.repaints, 1); QRegion expectedParentRegion = parentDeviceBoundingRect; // old position parentDeviceBoundingRect.translate(20, 20); expectedParentRegion += parentDeviceBoundingRect; // new position @@ -7411,29 +7534,32 @@ void tst_QGraphicsItem::moveItem() RESET_COUNTERS child->setPos(20, 20); - QTRY_COMPARE(parent->repaints, 1); - QTRY_COMPARE(child->repaints, 1); - QTRY_COMPARE(view.repaints, 1); + qApp->processEvents(); + QCOMPARE(parent->repaints, 1); + QCOMPARE(child->repaints, 1); + QCOMPARE(view.repaints, 1); const QRegion expectedChildRegion = expectedParentRegion.translated(20, 20); COMPARE_REGIONS(view.paintedRegion, expectedChildRegion); RESET_COUNTERS grandChild->setPos(20, 20); - QTRY_COMPARE(parent->repaints, 1); - QTRY_COMPARE(child->repaints, 1); - QTRY_COMPARE(grandChild->repaints, 1); - QTRY_COMPARE(view.repaints, 1); + qApp->processEvents(); + QCOMPARE(parent->repaints, 1); + QCOMPARE(child->repaints, 1); + QCOMPARE(grandChild->repaints, 1); + QCOMPARE(view.repaints, 1); const QRegion expectedGrandChildRegion = expectedParentRegion.translated(40, 40); COMPARE_REGIONS(view.paintedRegion, expectedGrandChildRegion); RESET_COUNTERS parent->translate(20, 20); - QTRY_COMPARE(parent->repaints, 1); - QTRY_COMPARE(child->repaints, 1); - QTRY_COMPARE(grandChild->repaints, 1); - QTRY_COMPARE(view.repaints, 1); + qApp->processEvents(); + QCOMPARE(parent->repaints, 1); + QCOMPARE(child->repaints, 1); + QCOMPARE(grandChild->repaints, 1); + QCOMPARE(view.repaints, 1); expectedParentRegion.translate(20, 20); expectedParentRegion += expectedChildRegion.translated(20, 20); expectedParentRegion += expectedGrandChildRegion.translated(20, 20); @@ -7453,6 +7579,7 @@ void tst_QGraphicsItem::moveLineItem() #ifdef Q_WS_X11 qt_x11_wait_for_window_manager(&view); #endif + QTest::qWait(200); view.reset(); const QRect itemDeviceBoundingRect = item->deviceTransform(view.viewportTransform()) @@ -7461,13 +7588,15 @@ void tst_QGraphicsItem::moveLineItem() // Make sure the calculated region is correct. item->update(); + QTest::qWait(10); QTRY_COMPARE(view.paintedRegion, expectedRegion); view.reset(); // Old position: (50, 50) item->setPos(50, 100); expectedRegion += expectedRegion.translated(0, 50); - QTRY_COMPARE(view.paintedRegion, expectedRegion); + QTest::qWait(10); + QCOMPARE(view.paintedRegion, expectedRegion); } void tst_QGraphicsItem::sorting_data() @@ -7510,6 +7639,7 @@ void tst_QGraphicsItem::sorting() #ifdef Q_WS_X11 qt_x11_wait_for_window_manager(&view); #endif + QTest::qWait(100); _paintedItems.clear(); @@ -7568,6 +7698,7 @@ void tst_QGraphicsItem::hitTestUntransformableItem() #ifdef Q_WS_X11 qt_x11_wait_for_window_manager(&view); #endif + QTest::qWait(100); // Confuse the BSP with dummy items. QGraphicsRectItem *dummy = new QGraphicsRectItem(0, 0, 20, 20); @@ -7593,16 +7724,18 @@ void tst_QGraphicsItem::hitTestUntransformableItem() item3->setPos(80, 80); scene.addItem(item1); + QTest::qWait(100); QList<QGraphicsItem *> items = scene.items(QPointF(80, 80)); - QTRY_COMPARE(items.size(), 1); - QTRY_COMPARE(items.at(0), static_cast<QGraphicsItem*>(item3)); + QCOMPARE(items.size(), 1); + QCOMPARE(items.at(0), static_cast<QGraphicsItem*>(item3)); scene.setItemIndexMethod(QGraphicsScene::NoIndex); + QTest::qWait(100); items = scene.items(QPointF(80, 80)); - QTRY_COMPARE(items.size(), 1); - QTRY_COMPARE(items.at(0), static_cast<QGraphicsItem*>(item3)); + QCOMPARE(items.size(), 1); + QCOMPARE(items.at(0), static_cast<QGraphicsItem*>(item3)); } void tst_QGraphicsItem::hitTestGraphicsEffectItem() @@ -7615,6 +7748,7 @@ void tst_QGraphicsItem::hitTestGraphicsEffectItem() #ifdef Q_WS_X11 qt_x11_wait_for_window_manager(&view); #endif + QTest::qWait(100); // Confuse the BSP with dummy items. QGraphicsRectItem *dummy = new QGraphicsRectItem(0, 0, 20, 20); @@ -7647,6 +7781,7 @@ void tst_QGraphicsItem::hitTestGraphicsEffectItem() item3->brush = Qt::blue; scene.addItem(item1); + QTest::qWait(100); item1->repaints = 0; item2->repaints = 0; @@ -7656,26 +7791,28 @@ void tst_QGraphicsItem::hitTestGraphicsEffectItem() QGraphicsDropShadowEffect *shadow = new QGraphicsDropShadowEffect; shadow->setOffset(-20, -20); item1->setGraphicsEffect(shadow); + QTest::qWait(50); // Make sure all visible items are repainted. - QTRY_COMPARE(item1->repaints, 0); - QTRY_COMPARE(item2->repaints, 1); - QTRY_COMPARE(item3->repaints, 1); + QCOMPARE(item1->repaints, 0); + QCOMPARE(item2->repaints, 1); + QCOMPARE(item3->repaints, 1); // Make sure an item doesn't respond to a click on its shadow. QList<QGraphicsItem *> items = scene.items(QPointF(75, 75)); - QTRY_VERIFY(items.isEmpty()); + QVERIFY(items.isEmpty()); items = scene.items(QPointF(80, 80)); - QTRY_COMPARE(items.size(), 1); - QTRY_COMPARE(items.at(0), static_cast<QGraphicsItem *>(item3)); + QCOMPARE(items.size(), 1); + QCOMPARE(items.at(0), static_cast<QGraphicsItem *>(item3)); scene.setItemIndexMethod(QGraphicsScene::NoIndex); + QTest::qWait(100); items = scene.items(QPointF(75, 75)); - QTRY_VERIFY(items.isEmpty()); + QVERIFY(items.isEmpty()); items = scene.items(QPointF(80, 80)); - QTRY_COMPARE(items.size(), 1); - QTRY_COMPARE(items.at(0), static_cast<QGraphicsItem *>(item3)); + QCOMPARE(items.size(), 1); + QCOMPARE(items.at(0), static_cast<QGraphicsItem *>(item3)); } void tst_QGraphicsItem::focusProxy() @@ -8334,6 +8471,7 @@ void tst_QGraphicsItem::moveWhileDeleting() #ifdef Q_WS_X11 qt_x11_wait_for_window_manager(&view); #endif + QTest::qWait(125); delete rect; @@ -8342,6 +8480,8 @@ void tst_QGraphicsItem::moveWhileDeleting() silly = new MoveWhileDying(rect); child = new QGraphicsRectItem(silly); + QTest::qWait(125); + delete rect; rect = new MoveWhileDying; @@ -8349,6 +8489,8 @@ void tst_QGraphicsItem::moveWhileDeleting() child = new QGraphicsRectItem(rect); silly = new MoveWhileDying(child); + QTest::qWait(125); + delete rect; } |