summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorKari Oikarinen <kari.oikarinen@qt.io>2018-04-10 15:43:07 +0300
committerKari Oikarinen <kari.oikarinen@qt.io>2018-05-14 06:05:19 +0000
commit627de835b1b87280741eb96ae77ea42b1f6ef5dc (patch)
treed55cef198789ceedf6cd5c6c6307380774ea8c75 /tests
parent69e0393399e4aba077f29b36611670dbe5813e27 (diff)
tests/auto/widgets/graphicsview: Avoid unconditional qWait()s
Task-number: QTBUG-63992 Change-Id: Ibbcf5bf968fcf1b1c3a043c805bdcc23a4005f00 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp2
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp2
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp202
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp5
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp6
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp41
6 files changed, 70 insertions, 188 deletions
diff --git a/tests/auto/widgets/graphicsview/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp b/tests/auto/widgets/graphicsview/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp
index 9124ff0070..65480bf665 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp
@@ -3066,8 +3066,6 @@ void tst_QGraphicsAnchorLayout1::testComplexCases()
widget->resize(size);
QCOMPARE(widget->size(), size);
-// QTest::qWait(500); // layouting is asynchronous..
-
// Validate
for (int i = 0; i < result.count(); ++i) {
const BasicLayoutTestResult item = result[i];
diff --git a/tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp b/tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp
index 6924b78397..34646a9074 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp
@@ -1826,7 +1826,7 @@ void tst_QGraphicsGridLayout::removeLayout()
QGraphicsView view(&scene);
view.show();
- QTest::qWait(20);
+ QVERIFY(QTest::qWaitForWindowActive(&view));
QRectF r1 = textEdit->geometry();
QRectF r2 = pushButton->geometry();
diff --git a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp
index 4f4a11a79c..6c1abaedb3 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp
@@ -1689,7 +1689,6 @@ void tst_QGraphicsItem::selected_textItem()
QGraphicsView view(&scene);
view.show();
QVERIFY(QTest::qWaitForWindowExposed(&view));
- QTest::qWait(20);
QTRY_VERIFY(!text->isSelected());
QTest::mouseClick(view.viewport(), Qt::LeftButton, 0,
@@ -1723,107 +1722,88 @@ void tst_QGraphicsItem::selected_multi()
QGraphicsView view(&scene);
view.show();
view.fitInView(scene.sceneRect());
- qApp->processEvents();
+ QVERIFY(QTest::qWaitForWindowActive(&view));
QVERIFY(!item1->isSelected());
QVERIFY(!item2->isSelected());
- // Start clicking
- QTest::qWait(200);
-
// Click on item1
QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(item1->scenePos()));
- QTest::qWait(20);
QVERIFY(item1->isSelected());
QVERIFY(!item2->isSelected());
// Click on item2
QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(item2->scenePos()));
- 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()));
- 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()));
- 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()));
- QTest::qWait(20);
QVERIFY(!item2->isSelected());
QVERIFY(!item1->isSelected());
// Click on item1
QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(item1->scenePos()));
- QTest::qWait(20);
QVERIFY(item1->isSelected());
QVERIFY(!item2->isSelected());
// Click on scene
QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(0, 0));
- QTest::qWait(20);
QVERIFY(!item1->isSelected());
QVERIFY(!item2->isSelected());
// Click on item1
QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(item1->scenePos()));
- 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));
- QTest::qWait(20);
QVERIFY(item1->isSelected());
QVERIFY(!item2->isSelected());
// Click on scene
QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(0, 0));
- QTest::qWait(20);
QVERIFY(!item1->isSelected());
QVERIFY(!item2->isSelected());
// Click on item1
QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(item1->scenePos()));
- QTest::qWait(20);
QVERIFY(item1->isSelected());
QVERIFY(!item2->isSelected());
// Press on item2
QTest::mousePress(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(item2->scenePos()));
- QTest::qWait(20);
QVERIFY(!item1->isSelected());
QVERIFY(item2->isSelected());
// Release on item2
QTest::mouseRelease(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(item2->scenePos()));
- QTest::qWait(20);
QVERIFY(!item1->isSelected());
QVERIFY(item2->isSelected());
// Click on item1
QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(item1->scenePos()));
- 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()));
- 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()));
- QTest::qWait(20);
QVERIFY(!item1->isSelected());
QVERIFY(!item2->isSelected());
@@ -1831,14 +1811,12 @@ void tst_QGraphicsItem::selected_multi()
// 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);
- QTest::qWait(20);
QVERIFY(!item1->isSelected());
QVERIFY(!item2->isSelected());
}
// Release on item1
QTest::mouseRelease(view.viewport(), Qt::LeftButton, Qt::ControlModifier, view.mapFromScene(item1->scenePos()));
- QTest::qWait(20);
QVERIFY(item1->isSelected());
QVERIFY(!item2->isSelected());
@@ -1847,7 +1825,6 @@ void tst_QGraphicsItem::selected_multi()
// Ctrl-press on item1
QTest::mousePress(view.viewport(), Qt::LeftButton, Qt::ControlModifier, view.mapFromScene(item1->scenePos()));
- QTest::qWait(20);
QVERIFY(!item1->isSelected());
QVERIFY(!item2->isSelected());
@@ -1855,14 +1832,12 @@ void tst_QGraphicsItem::selected_multi()
// 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);
- QTest::qWait(20);
QVERIFY(item1->isSelected());
QVERIFY(!item2->isSelected());
}
// Release on item1
QTest::mouseRelease(view.viewport(), Qt::LeftButton, Qt::ControlModifier, view.mapFromScene(item1->scenePos()));
- QTest::qWait(20);
QVERIFY(item1->isSelected());
QVERIFY(!item2->isSelected());
}
@@ -3383,9 +3358,8 @@ void tst_QGraphicsItem::childrenBoundingRect()
view.show();
QVERIFY(QTest::qWaitForWindowExposed(&view));
- QTest::qWait(30);
- QCOMPARE(parent->childrenBoundingRect(), QRectF(-500, -100, 600, 800));
+ QTRY_COMPARE(parent->childrenBoundingRect(), QRectF(-500, -100, 600, 800));
}
void tst_QGraphicsItem::childrenBoundingRectTransformed()
@@ -3576,7 +3550,6 @@ 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);
@@ -3588,8 +3561,6 @@ 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),
@@ -3603,12 +3574,9 @@ void tst_QGraphicsItem::group()
view.fitInView(scene.itemsBoundingRect());
- int n = 0;
foreach (QGraphicsItem *item, newItems) {
group->addToGroup(item);
QCOMPARE(item->group(), group);
- if ((n++ % 100) == 0)
- QTest::qWait(10);
}
}
@@ -3798,7 +3766,6 @@ void tst_QGraphicsItem::handlesChildEvents()
QGraphicsView view(&scene);
view.show();
QVERIFY(QTest::qWaitForWindowExposed(&view));
- QTest::qWait(20);
// Pull out the items, closest item first
QList<QGraphicsItem *> items = scene.items(scene.itemsBoundingRect());
@@ -4011,7 +3978,6 @@ void tst_QGraphicsItem::filtersChildEvents()
QGraphicsView view(&scene);
view.show();
QVERIFY(QTest::qWaitForWindowExposed(&view));
- QTest::qWait(20);
QGraphicsSceneMouseEvent pressEvent(QEvent::GraphicsSceneMousePress);
QGraphicsSceneMouseEvent releaseEvent(QEvent::GraphicsSceneMouseRelease);
@@ -4137,7 +4103,6 @@ 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) {
@@ -4217,8 +4182,6 @@ void tst_QGraphicsItem::cursor()
QTest::mouseMove(&view, view.rect().center());
- QTest::qWait(25);
-
const Qt::CursorShape viewportShape = view.viewport()->cursor().shape();
{
@@ -5039,7 +5002,6 @@ void tst_QGraphicsItem::sceneEventFilter()
gv.setScene(anotherScene);
gv.show();
QVERIFY(QTest::qWaitForWindowExposed(&gv));
- QTest::qWait(25);
ti->installSceneEventFilter(ti2);
ti3->installSceneEventFilter(ti);
delete ti2;
@@ -5112,30 +5074,25 @@ void tst_QGraphicsItem::paint()
QGraphicsView view2(&scene2);
view2.show();
QVERIFY(QTest::qWaitForWindowExposed(&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_COMPARE(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_COMPARE(tester2.painted, 2);
//We re-add the item, the number of paint should increase
scene2.addItem(&tester2);
tester2.update();
- qApp->processEvents();
QTRY_COMPARE(tester2.painted, 3);
}
@@ -6259,7 +6216,6 @@ void tst_QGraphicsItem::untransformable()
view.rotate(13);
view.shear(qreal(0.01), qreal(0.01));
view.translate(10, 10);
- QTest::qWait(25);
}
}
@@ -6298,7 +6254,6 @@ void tst_QGraphicsItem::contextMenuEventPropagation()
view.show();
view.resize(200, 200);
QVERIFY(QTest::qWaitForWindowExposed(&view));
- QTest::qWait(20);
QContextMenuEvent event(QContextMenuEvent::Mouse, QPoint(10, 10),
view.viewport()->mapToGlobal(QPoint(10, 10)));
@@ -6576,15 +6531,12 @@ void tst_QGraphicsItem::ensureUpdateOnTextItem()
QGraphicsView view(&scene);
view.show();
QVERIFY(QTest::qWaitForWindowExposed(&view));
- QTest::qWait(25);
TextItem *text1 = new TextItem(QLatin1String("123"));
scene.addItem(text1);
- qApp->processEvents();
QTRY_COMPARE(text1->updates,1);
//same bouding rect but we have to update
text1->setText(QLatin1String("321"));
- qApp->processEvents();
QTRY_COMPARE(text1->updates,2);
}
@@ -6862,7 +6814,6 @@ 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);
@@ -6871,7 +6822,6 @@ 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);
@@ -6880,7 +6830,6 @@ 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);
@@ -6889,7 +6838,6 @@ 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);
@@ -6899,7 +6847,6 @@ 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);
@@ -6909,7 +6856,7 @@ void tst_QGraphicsItem::opacity2()
child->setOpacity(0.0); // Already 0.0; no change.
QTest::qWait(10);
- QTRY_COMPARE(view.repaints, 0);
+ QCOMPARE(view.repaints, 0);
QCOMPARE(parent->repaints, 0);
QCOMPARE(child->repaints, 0);
QCOMPARE(grandChild->repaints, 0);
@@ -6933,7 +6880,7 @@ void tst_QGraphicsItem::opacityZeroUpdates()
view.reset();
parent->setOpacity(0.0);
- QTest::qWait(20);
+ QTRY_COMPARE(view.repaints, 1);
// transforming items bounding rect to view coordinates
const QRect childDeviceBoundingRect = child->deviceTransform(view.viewportTransform())
@@ -7002,7 +6949,6 @@ void tst_QGraphicsItem::itemStacksBehindParent()
view.show();
QVERIFY(QTest::qWaitForWindowExposed(&view));
QTRY_VERIFY(!paintedItems.isEmpty());
- QTest::qWait(100);
paintedItems.clear();
view.viewport()->update();
QApplication::processEvents();
@@ -7021,34 +6967,32 @@ void tst_QGraphicsItem::itemStacksBehindParent()
child11->setFlag(QGraphicsItem::ItemStacksBehindParent);
scene.update();
paintedItems.clear();
- QApplication::processEvents();
QTRY_COMPARE(scene.items(rect), (QList<QGraphicsItem *>()
<< grandChild121 << child12 << parent1
<< grandChild111 << child11
<< grandChild211 << child21
<< grandChild221 << child22 << parent2));
- QCOMPARE(paintedItems, QList<QGraphicsItem *>()
- << parent2 << child22 << grandChild221
- << child21 << grandChild211
- << child11 << grandChild111
- << parent1 << child12 << grandChild121);
+ QTRY_COMPARE(paintedItems, QList<QGraphicsItem *>()
+ << parent2 << child22 << grandChild221
+ << child21 << grandChild211
+ << child11 << grandChild111
+ << parent1 << child12 << grandChild121);
child12->setFlag(QGraphicsItem::ItemStacksBehindParent);
paintedItems.clear();
scene.update();
- QApplication::processEvents();
QTRY_COMPARE(scene.items(rect), (QList<QGraphicsItem *>()
<< parent1 << grandChild111 << child11
<< grandChild121 << child12
<< grandChild211 << child21
<< grandChild221 << child22 << parent2));
- QCOMPARE(paintedItems, QList<QGraphicsItem *>()
- << parent2 << child22 << grandChild221
- << child21 << grandChild211
- << child12 << grandChild121
- << child11 << grandChild111 << parent1);
+ QTRY_COMPARE(paintedItems, QList<QGraphicsItem *>()
+ << parent2 << child22 << grandChild221
+ << child21 << grandChild211
+ << child12 << grandChild121
+ << child11 << grandChild111 << parent1);
}
class ClippingAndTransformsScene : public QGraphicsScene
@@ -7100,7 +7044,6 @@ void tst_QGraphicsItem::nestedClipping()
view.setOptimizationFlag(QGraphicsView::IndirectPainting);
view.show();
QVERIFY(QTest::qWaitForWindowExposed(&view));
- QTest::qWait(25);
QList<QGraphicsItem *> expected;
expected << root << l1 << l2 << l3;
@@ -7293,16 +7236,13 @@ 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());
@@ -7324,10 +7264,6 @@ void tst_QGraphicsItem::cacheMode()
QApplication::setActiveWindow(&view);
QVERIFY(QTest::qWaitForWindowActive(&view));
- // Increase the probability of window activation
- // not causing another repaint of test items.
- QTest::qWait(50);
-
EventTester *tester = new EventTester;
EventTester *testerChild = new EventTester;
testerChild->setParentItem(tester);
@@ -7336,7 +7272,6 @@ void tst_QGraphicsItem::cacheMode()
testerChild2->setFlag(QGraphicsItem::ItemIgnoresTransformations);
scene.addItem(tester);
- QTest::qWait(10);
for (int i = 0; i < 2; ++i) {
// No visual change.
@@ -7361,7 +7296,6 @@ void tst_QGraphicsItem::cacheMode()
tester->setPos(10, 10);
testerChild->setPos(10, 10);
testerChild2->setPos(10, 10);
- QTest::qWait(25);
QTRY_COMPARE(tester->repaints, 2);
QCOMPARE(testerChild->repaints, 2);
QCOMPARE(testerChild2->repaints, 2);
@@ -7378,13 +7312,12 @@ void tst_QGraphicsItem::cacheMode()
// Translating does not result in a repaint.
tester->setTransform(QTransform::fromTranslate(10, 10), true);
QTest::qWait(25);
- QTRY_COMPARE(tester->repaints, 2);
+ QCOMPARE(tester->repaints, 2);
QCOMPARE(testerChild->repaints, 2);
QCOMPARE(testerChild2->repaints, 2);
// Rotating results in a repaint.
tester->setTransform(QTransform().rotate(45), true);
- QTest::qWait(25);
QTRY_COMPARE(tester->repaints, 3);
QCOMPARE(testerChild->repaints, 3);
QCOMPARE(testerChild2->repaints, 2);
@@ -7393,7 +7326,6 @@ void tst_QGraphicsItem::cacheMode()
tester->setCacheMode(QGraphicsItem::ItemCoordinateCache); // autosize
testerChild->setCacheMode(QGraphicsItem::ItemCoordinateCache); // autosize
testerChild2->setCacheMode(QGraphicsItem::ItemCoordinateCache); // autosize
- QTest::qWait(25);
QTRY_COMPARE(tester->repaints, 4);
QCOMPARE(testerChild->repaints, 4);
QCOMPARE(testerChild2->repaints, 3);
@@ -7403,16 +7335,15 @@ void tst_QGraphicsItem::cacheMode()
testerChild->setTransform(QTransform().rotate(22), true);
testerChild2->setTransform(QTransform().rotate(22), true);
QTest::qWait(25);
- QTRY_COMPARE(tester->repaints, 4);
- QTRY_COMPARE(testerChild->repaints, 4);
- QTRY_COMPARE(testerChild2->repaints, 3);
+ QCOMPARE(tester->repaints, 4);
+ QCOMPARE(testerChild->repaints, 4);
+ QCOMPARE(testerChild2->repaints, 3);
tester->resetTransform();
testerChild->resetTransform();
testerChild2->resetTransform();
// Explicit update causes a repaint.
tester->update(0, 0, 5, 5);
- QTest::qWait(25);
QTRY_COMPARE(tester->repaints, 5);
QCOMPARE(testerChild->repaints, 4);
QCOMPARE(testerChild2->repaints, 3);
@@ -7420,14 +7351,13 @@ void tst_QGraphicsItem::cacheMode()
// 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);
+ QCOMPARE(tester->repaints, 5);
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);
QCOMPARE(testerChild->repaints, 4);
QCOMPARE(testerChild2->repaints, 3);
@@ -7436,22 +7366,20 @@ void tst_QGraphicsItem::cacheMode()
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);
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);
- QCOMPARE(testerChild->repaints, 6);
+ QTRY_COMPARE(testerChild->repaints, 6);
+ QCOMPARE(tester->repaints, 7);
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);
+ QCOMPARE(tester->repaints, 7);
QCOMPARE(testerChild->repaints, 6);
QCOMPARE(testerChild2->repaints, 4);
@@ -7459,46 +7387,42 @@ void tst_QGraphicsItem::cacheMode()
tester->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
testerChild->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
testerChild2->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
- QTest::qWait(25);
QTRY_COMPARE(tester->repaints, 8);
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);
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);
QCOMPARE(testerChild->repaints, 9);
QCOMPARE(testerChild2->repaints, 5);
- // Moving the middle item should case a repaint even if it's a move,
+ // Moving the middle item should cause 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, 11);
QTRY_COMPARE(testerChild->repaints, 10);
- QTRY_COMPARE(testerChild2->repaints, 5);
+ QCOMPARE(testerChild2->repaints, 5);
tester->resetTransform();
// Make a huge item
tester->setGeometry(QRectF(-4000, -4000, 8000, 8000));
QTRY_COMPARE(tester->repaints, 12);
QTRY_COMPARE(testerChild->repaints, 11);
- QTRY_COMPARE(testerChild2->repaints, 5);
+ QCOMPARE(testerChild2->repaints, 5);
// Move the large item - will cause a repaint as the
// cache is clipped.
tester->setPos(5, 0);
QTRY_COMPARE(tester->repaints, 13);
QTRY_COMPARE(testerChild->repaints, 11);
- QTRY_COMPARE(testerChild2->repaints, 5);
+ QCOMPARE(testerChild2->repaints, 5);
// Hiding and showing should invalidate the cache
tester->hide();
@@ -7518,66 +7442,56 @@ void tst_QGraphicsItem::cacheMode2()
QApplication::setActiveWindow(&view);
QVERIFY(QTest::qWaitForWindowActive(&view));
- // Increase the probability of window activation
- // not causing another repaint of test items.
- QTest::qWait(50);
-
EventTester *tester = new EventTester;
scene.addItem(tester);
- QTest::qWait(10);
QTRY_COMPARE(tester->repaints, 1);
// Switching from NoCache to NoCache (no repaint)
tester->setCacheMode(QGraphicsItem::NoCache);
QTest::qWait(50);
- QTRY_COMPARE(tester->repaints, 1);
+ QCOMPARE(tester->repaints, 1);
// Switching from NoCache to DeviceCoordinateCache (no repaint)
tester->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
QTest::qWait(50);
- QTRY_COMPARE(tester->repaints, 1);
+ QCOMPARE(tester->repaints, 1);
// Switching from DeviceCoordinateCache to DeviceCoordinateCache (no repaint)
tester->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
QTest::qWait(50);
- QTRY_COMPARE(tester->repaints, 1);
+ QCOMPARE(tester->repaints, 1);
// Switching from DeviceCoordinateCache to NoCache (no repaint)
tester->setCacheMode(QGraphicsItem::NoCache);
QTest::qWait(50);
- QTRY_COMPARE(tester->repaints, 1);
+ QCOMPARE(tester->repaints, 1);
// Switching from NoCache to ItemCoordinateCache (repaint)
tester->setCacheMode(QGraphicsItem::ItemCoordinateCache);
- QTest::qWait(50);
QTRY_COMPARE(tester->repaints, 2);
// Switching from ItemCoordinateCache to ItemCoordinateCache (no repaint)
tester->setCacheMode(QGraphicsItem::ItemCoordinateCache);
QTest::qWait(50);
- QTRY_COMPARE(tester->repaints, 2);
+ QCOMPARE(tester->repaints, 2);
// Switching from ItemCoordinateCache to ItemCoordinateCache with different size (repaint)
tester->setCacheMode(QGraphicsItem::ItemCoordinateCache, QSize(100, 100));
- QTest::qWait(50);
QTRY_COMPARE(tester->repaints, 3);
// Switching from ItemCoordinateCache to NoCache (repaint)
tester->setCacheMode(QGraphicsItem::NoCache);
- QTest::qWait(50);
QTRY_COMPARE(tester->repaints, 4);
// Switching from DeviceCoordinateCache to ItemCoordinateCache (repaint)
tester->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
QTest::qWait(50);
- QTRY_COMPARE(tester->repaints, 4);
+ QCOMPARE(tester->repaints, 4);
tester->setCacheMode(QGraphicsItem::ItemCoordinateCache);
- QTest::qWait(50);
QTRY_COMPARE(tester->repaints, 5);
// Switching from ItemCoordinateCache to DeviceCoordinateCache (repaint)
tester->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
- QTest::qWait(50);
QTRY_COMPARE(tester->repaints, 6);
}
@@ -7595,7 +7509,6 @@ void tst_QGraphicsItem::updateCachedItemAfterMove()
view.show();
QVERIFY(QTest::qWaitForWindowExposed(&view));
- QTest::qWait(12);
QTRY_VERIFY(tester->repaints > 0);
tester->repaints = 0;
@@ -7607,8 +7520,7 @@ void tst_QGraphicsItem::updateCachedItemAfterMove()
// Move then update, should cause one repaint
tester->setPos(20, 0);
tester->update();
- QTest::qWait(12);
- QCOMPARE(tester->repaints, 1);
+ QTRY_COMPARE(tester->repaints, 1);
// Hiding the item doesn't cause a repaint
tester->hide();
@@ -7745,28 +7657,25 @@ void tst_QGraphicsItem::update()
EventTester *item = new EventTester;
scene.addItem(item);
- QTest::qWait(100); // Make sure all pending updates are processed.
+ QTRY_VERIFY(item->repaints > 0); // Wait for painting
item->repaints = 0;
item->update(); // Item marked as dirty
scene.update(); // Entire scene marked as dirty
- qApp->processEvents();
- QCOMPARE(item->repaints, 1);
+ QTRY_COMPARE(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();
- qApp->processEvents();
- QCOMPARE(item->repaints, 2);
+ QTRY_COMPARE(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();
- qApp->processEvents();
- QCOMPARE(item->repaints, 1);
- QCOMPARE(view.repaints, 1);
+ QTRY_COMPARE(item->repaints, 1);
+ QTRY_COMPARE(view.repaints, 1);
QRect itemDeviceBoundingRect = item->deviceTransform(view.viewportTransform())
.mapRect(item->boundingRect()).toAlignedRect();
QRegion expectedRegion = itemDeviceBoundingRect.adjusted(-2, -2, 2, 2);
@@ -7828,13 +7737,11 @@ void tst_QGraphicsItem::update()
item->setPos(originalPos + QPoint(50, 50));
viewPrivate->updateAll();
QVERIFY(viewPrivate->fullUpdatePending);
- QTest::qWait(50);
+ QTRY_VERIFY(view.repaints > 1 && item->repaints > 1);
item->repaints = 0;
view.reset();
item->setPos(originalPos);
- QTest::qWait(50);
- qApp->processEvents();
- QCOMPARE(item->repaints, 1);
+ QTRY_COMPARE(item->repaints, 1);
QCOMPARE(view.repaints, 1);
COMPARE_REGIONS(view.paintedRegion, expectedRegion + expectedRegion.translated(50, 50));
@@ -7845,7 +7752,6 @@ void tst_QGraphicsItem::update()
item->setParentItem(parent);
item->setPos(400, 0);
scene.addItem(parent);
- QTest::qWait(50);
itemDeviceBoundingRect = item->deviceTransform(view.viewportTransform())
.mapRect(item->boundingRect()).toAlignedRect();
expectedRegion = itemDeviceBoundingRect.adjusted(-2, -2, 2, 2);
@@ -7987,6 +7893,7 @@ public:
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0)
{
+ ++repaints;
if (startTrack) {
//Doesn't use the extended style option so the exposed rect is the boundingRect
if (!(flags() & QGraphicsItem::ItemUsesExtendedStyleOption)) {
@@ -8001,6 +7908,7 @@ public:
QGraphicsRectItem::paint(painter, option, widget);
}
bool startTrack;
+ int repaints = 0;
};
void tst_QGraphicsItem::itemUsesExtendedStyleOption()
@@ -8023,17 +7931,21 @@ void tst_QGraphicsItem::itemUsesExtendedStyleOption()
rect->startTrack = false;
topLevel.show();
QVERIFY(QTest::qWaitForWindowExposed(&topLevel));
- QTest::qWait(60);
+ QTRY_VERIFY(rect->repaints > 0);
+ rect->repaints = 0;
rect->startTrack = true;
rect->update(10, 10, 10, 10);
- QTest::qWait(60);
+ QTRY_COMPARE(rect->repaints, 1);
+ rect->repaints = 0;
rect->startTrack = false;
rect->setFlag(QGraphicsItem::ItemUsesExtendedStyleOption, true);
QVERIFY((rect->flags() & QGraphicsItem::ItemUsesExtendedStyleOption));
- QTest::qWait(60);
+ QTRY_COMPARE(rect->repaints, 1);
+ rect->repaints = 0;
rect->startTrack = true;
rect->update(10, 10, 10, 10);
QTest::qWait(60);
+ // MyStyleOptionTester does not receive a paint event. Why not?
}
void tst_QGraphicsItem::itemSendsGeometryChanges()
@@ -8116,8 +8028,9 @@ void tst_QGraphicsItem::moveItem()
grandChild->repaints = 0; \
view.reset();
+ RESET_COUNTERS
scene.addItem(parent);
- QTest::qWait(100);
+ QTRY_COMPARE(view.repaints, 1);
RESET_COUNTERS
@@ -8195,15 +8108,13 @@ 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);
- QTest::qWait(10);
- QCOMPARE(view.paintedRegion, expectedRegion);
+ QTRY_COMPARE(view.paintedRegion, expectedRegion);
}
void tst_QGraphicsItem::sorting_data()
@@ -8251,7 +8162,7 @@ void tst_QGraphicsItem::sorting()
view.show();
qApp->setActiveWindow(&view);
QVERIFY(QTest::qWaitForWindowActive(&view));
- QTest::qWait(100);
+ QTRY_VERIFY(_paintedItems.count() > 0);
_paintedItems.clear();
@@ -8334,7 +8245,6 @@ void tst_QGraphicsItem::hitTestUntransformableItem()
item3->setPos(80, 80);
scene.addItem(item1);
- QTest::qWait(100);
QList<QGraphicsItem *> items = scene.items(QPointF(80, 80));
QCOMPARE(items.size(), 1);
@@ -8391,7 +8301,8 @@ void tst_QGraphicsItem::hitTestGraphicsEffectItem()
item3->brush = Qt::blue;
scene.addItem(item1);
- QTest::qWait(100);
+ QTRY_COMPARE(item2->repaints, 1);
+ QCOMPARE(item3->repaints, 1);
item1->repaints = 0;
item2->repaints = 0;
@@ -8401,10 +8312,9 @@ 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.
- QCOMPARE(item1->repaints, 1);
+ QTRY_COMPARE(item1->repaints, 1);
QCOMPARE(item2->repaints, 1);
QCOMPARE(item3->repaints, 1);
diff --git a/tests/auto/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp b/tests/auto/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp
index 97f3eb4a60..f9b6fe3ebd 100644
--- a/tests/auto/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp
@@ -612,7 +612,6 @@ void tst_QGraphicsLinearLayout::insertStretch()
}
}
- //QTest::qWait(1000);
delete widget;
}
@@ -639,7 +638,6 @@ void tst_QGraphicsLinearLayout::invalidate()
layout.setContentsMargins(0, 0, 0, 0);
view.show();
widget->show();
- //QTest::qWait(1000);
QVERIFY(QTest::qWaitForWindowExposed(&view));
qApp->processEvents();
layout.layoutRequest = 0;
@@ -1218,7 +1216,6 @@ void tst_QGraphicsLinearLayout::testStretch()
//view->setSceneRect(-50, -50, 800, 800);
//view->show();
//QVERIFY(QTest::qWaitForWindowExposed(view));
- //QTest::qWait(5000);
QCOMPARE(form->geometry().size(), QSizeF(600,600));
QCOMPARE(w1->geometry(), QRectF(0, 0, 100, 100));
QCOMPARE(w2->geometry(), QRectF(400, 0, 200, 200));
@@ -1521,7 +1518,7 @@ void tst_QGraphicsLinearLayout::removeLayout()
QGraphicsView view(&scene);
view.show();
- QTest::qWait(20);
+ QVERIFY(QTest::qWaitForWindowActive(&view));
QRectF r1 = textEdit->geometry();
QRectF r2 = pushButton->geometry();
diff --git a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp
index 3b340d06ab..0071c39f49 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp
@@ -3108,7 +3108,6 @@ void tst_QGraphicsScene::tabFocus_sceneWithFocusableItems()
// Check that everyone loses focus when the widget is hidden.
widget.hide();
- QTest::qWait(15);
QTRY_VERIFY(!view->hasFocus());
QVERIFY(!view->viewport()->hasFocus());
QVERIFY(!scene.hasFocus());
@@ -4056,7 +4055,6 @@ void tst_QGraphicsScene::isActive()
QVERIFY(!scene2.hasFocus());
toplevel1.hide();
- QTest::qWait(50);
QTRY_VERIFY(!scene1.isActive());
QTRY_VERIFY(!scene2.isActive());
QVERIFY(!scene1.hasFocus());
@@ -4381,7 +4379,6 @@ void tst_QGraphicsScene::taskQT657_paintIntoCacheWithTransparentParts()
QVERIFY(QTest::qWaitForWindowExposed(view));
view->repaints = 0;
proxy->update(10, 10, 10, 10);
- QTest::qWait(50);
QTRY_VERIFY(view->repaints > 0);
QPixmap pix;
@@ -4427,7 +4424,6 @@ void tst_QGraphicsScene::taskQTBUG_7863_paintIntoCacheWithTransparentParts()
QVERIFY(QTest::qWaitForWindowExposed(view));
view->repaints = 0;
rectItem->update(10, 10, 10, 10);
- QTest::qWait(50);
QTRY_VERIFY(view->repaints > 0);
QPixmap pix;
@@ -4469,7 +4465,6 @@ void tst_QGraphicsScene::taskQTBUG_7863_paintIntoCacheWithTransparentParts()
QVERIFY(QTest::qWaitForWindowExposed(view));
view->repaints = 0;
rectItem->update(10, 10, 10, 10);
- QTest::qWait(50);
QTRY_VERIFY(view->repaints > 0);
QPixmap pix;
@@ -4510,7 +4505,6 @@ void tst_QGraphicsScene::taskQTBUG_7863_paintIntoCacheWithTransparentParts()
QVERIFY(QTest::qWaitForWindowExposed(view));
view->repaints = 0;
rectItem->update(10, 10, 10, 10);
- QTest::qWait(50);
QTRY_VERIFY(view->repaints > 0);
QPixmap pix;
diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp
index 10129eb10c..f52bbce53a 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp
@@ -507,10 +507,8 @@ void tst_QGraphicsView::setScene()
view.setScene(0);
- QTest::qWait(25);
-
- QVERIFY(!view.horizontalScrollBar()->isVisible());
- QVERIFY(!view.verticalScrollBar()->isVisible());
+ QTRY_VERIFY(!view.horizontalScrollBar()->isVisible());
+ QTRY_VERIFY(!view.verticalScrollBar()->isVisible());
QVERIFY(!view.horizontalScrollBar()->isHidden());
QVERIFY(!view.verticalScrollBar()->isHidden());
@@ -572,13 +570,12 @@ void tst_QGraphicsView::sceneRect_growing()
QGraphicsView view(&scene, &toplevel);
view.setFixedSize(200, 200);
toplevel.show();
+ QVERIFY(QTest::qWaitForWindowActive(&toplevel));
int size = 200;
scene.setSceneRect(-size, -size, size * 2, size * 2);
QCOMPARE(view.sceneRect(), scene.sceneRect());
- QTest::qWait(25);
-
QPointF topLeft = view.mapToScene(0, 0);
for (int i = 0; i < 5; ++i) {
@@ -641,14 +638,14 @@ void tst_QGraphicsView::viewport()
QVERIFY(view.viewport() != 0);
view.show();
- QTest::qWait(25);
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
QPointer<QWidget> widget = new QWidget;
view.setViewport(widget);
QCOMPARE(view.viewport(), (QWidget *)widget);
view.show();
- QTest::qWait(25);
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
view.setViewport(0);
QVERIFY(widget.isNull());
@@ -656,7 +653,7 @@ void tst_QGraphicsView::viewport()
QVERIFY(view.viewport() != widget);
view.show();
- QTest::qWait(25);
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
}
#ifndef QT_NO_OPENGL
@@ -888,8 +885,6 @@ void tst_QGraphicsView::dragMode_rubberBand()
// We don't use QRubberBand as of 4.3; the band is drawn internally.
QVERIFY(!view.findChild<QRubberBand *>());
- QTest::qWait(25);
-
{
// Move
QMouseEvent event(QEvent::MouseMove,
@@ -902,8 +897,6 @@ void tst_QGraphicsView::dragMode_rubberBand()
QCOMPARE(view.horizontalScrollBar()->value(), horizontalScrollBarValue);
QCOMPARE(view.verticalScrollBar()->value(), verticalScrollBarValue);
- QTest::qWait(25);
-
{
// Release
QMouseEvent event(QEvent::MouseButtonRelease,
@@ -919,8 +912,6 @@ void tst_QGraphicsView::dragMode_rubberBand()
QCOMPARE(view.viewport()->cursor().shape(), cursorShape);
#endif
- QTest::qWait(25);
-
if (view.scene())
QCOMPARE(scene.selectedItems().size(), 1);
@@ -1074,7 +1065,7 @@ void tst_QGraphicsView::backgroundBrush()
QCOMPARE(scene.backgroundBrush(), QBrush(Qt::blue));
view.show();
- QTest::qWait(25);
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
scene.setBackgroundBrush(QBrush());
QCOMPARE(scene.backgroundBrush(), QBrush());
@@ -1096,7 +1087,7 @@ void tst_QGraphicsView::foregroundBrush()
QCOMPARE(scene.foregroundBrush(), QBrush(Qt::blue));
view.show();
- QTest::qWait(25);
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
scene.setForegroundBrush(QBrush());
QCOMPARE(scene.foregroundBrush(), QBrush());
@@ -2052,7 +2043,7 @@ void tst_QGraphicsView::mapFromSceneRect()
view.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
view.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
topLevel.show();
- QTest::qWait(25);
+ QVERIFY(QTest::qWaitForWindowActive(&view));
QPolygon polygon;
polygon << QPoint(98, 98);
@@ -2459,7 +2450,6 @@ void tst_QGraphicsView::viewportUpdateMode()
// Issue two scene updates.
scene.update(QRectF(0, 0, 10, 10));
scene.update(QRectF(20, 0, 10, 10));
- QTest::qWait(50);
// The view gets two updates for the update scene updates.
QTRY_VERIFY(!view.lastUpdateRegions.isEmpty());
@@ -2565,8 +2555,7 @@ void tst_QGraphicsView::viewportUpdateMode2()
view.lastUpdateRegions.clear();
viewPrivate->processPendingUpdates();
- QTest::qWait(50);
- QCOMPARE(view.lastUpdateRegions.size(), 1);
+ QTRY_COMPARE(view.lastUpdateRegions.size(), 1);
// Note that we adjust by 2 for antialiasing.
QCOMPARE(view.lastUpdateRegions.at(0), QRegion(boundingRect.adjusted(-2, -2, 2, 2) & viewportRect));
#endif
@@ -2763,8 +2752,7 @@ void tst_QGraphicsView::optimizationFlags_dontSavePainterState2()
// Make sure the view is repainted; otherwise the tests below will fail.
view.viewport()->repaint();
- QTest::qWait(200);
- QVERIFY(view.painted);
+ QTRY_VERIFY(view.painted);
// Make sure the painter's world transform is preserved after drawItems.
QTransform expectedTransform = view.viewportTransform();
@@ -3676,7 +3664,6 @@ void tst_QGraphicsView::centerOnDirtyItem()
toplevel.show();
QVERIFY(QTest::qWaitForWindowExposed(&toplevel));
- QTest::qWait(50);
QImage before(view.viewport()->size(), QImage::Format_ARGB32);
view.viewport()->render(&before);
@@ -3684,8 +3671,6 @@ void tst_QGraphicsView::centerOnDirtyItem()
item->setPos(20, 0);
view.centerOn(item);
- QTest::qWait(50);
-
QImage after(view.viewport()->size(), QImage::Format_ARGB32);
view.viewport()->render(&after);
@@ -4279,8 +4264,6 @@ void tst_QGraphicsView::update_ancestorClipsChildrenToShape2()
QCOMPARE(view.lastUpdateRegions.at(0), QRegion(expected.toAlignedRect()));
#endif
- QTest::qWait(50);
-
view.lastUpdateRegions.clear();
view.painted = false;
@@ -4478,7 +4461,7 @@ void tst_QGraphicsView::indirectPainting()
view.setOptimizationFlag(QGraphicsView::IndirectPainting);
view.show();
QVERIFY(QTest::qWaitForWindowExposed(&view));
- QTest::qWait(100);
+ QTRY_VERIFY(scene.drawCount > 0);
scene.drawCount = 0;
item->setPos(20, 20);