summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@trolltech.com>2009-09-30 08:38:09 (GMT)
committerOlivier Goffart <ogoffart@trolltech.com>2009-09-30 09:21:49 (GMT)
commit85b4c2a9e4c62a836819baf0669b91a3f30c9a4e (patch)
treeb59449fe977d056c66391fba09b2d9e83305576c /tests/auto
parentbc714d469487856c85a42ecb0ceb540420f3e7cc (diff)
downloadQt-85b4c2a9e4c62a836819baf0669b91a3f30c9a4e.zip
Qt-85b4c2a9e4c62a836819baf0669b91a3f30c9a4e.tar.gz
Qt-85b4c2a9e4c62a836819baf0669b91a3f30c9a4e.tar.bz2
Stabilize and speedup QGraphicsItem and QGraphicsView and QGraphicsProxyWidget test
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp371
-rw-r--r--tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp208
-rw-r--r--tests/auto/qgraphicsview/tst_qgraphicsview.cpp64
3 files changed, 309 insertions, 334 deletions
diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
index d08e74b..ef9fe9e 100644
--- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
+++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
@@ -1372,19 +1372,20 @@ void tst_QGraphicsItem::selected_textItem()
QGraphicsView view(&scene);
view.show();
- QTest::qWait(1000);
+ QTest::qWaitForWindowShown(&view);
+ QTest::qWait(20);
- QVERIFY(!text->isSelected());
+ QTRY_VERIFY(!text->isSelected());
QTest::mouseClick(view.viewport(), Qt::LeftButton, 0,
view.mapFromScene(text->mapToScene(0, 0)));
- QVERIFY(text->isSelected());
+ QTRY_VERIFY(text->isSelected());
text->setSelected(false);
text->setTextInteractionFlags(Qt::TextEditorInteraction);
QTest::mouseClick(view.viewport(), Qt::LeftButton, 0,
view.mapFromScene(text->mapToScene(0, 0)));
- QVERIFY(text->isSelected());
+ QTRY_VERIFY(text->isSelected());
}
void tst_QGraphicsItem::selected_multi()
@@ -1416,91 +1417,91 @@ void tst_QGraphicsItem::selected_multi()
// Click on item1
QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(item1->scenePos()));
- QTest::qWait(200);
+ 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(200);
+ 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(200);
+ 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(200);
+ 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(200);
+ 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(200);
+ 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(200);
+ 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(200);
+ 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(200);
+ 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(200);
+ 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(200);
+ 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(200);
+ 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(200);
+ 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(200);
+ 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(200);
+ QTest::qWait(20);
QVERIFY(!item1->isSelected());
QVERIFY(!item2->isSelected());
@@ -1508,14 +1509,14 @@ 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(200);
+ 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(200);
+ QTest::qWait(20);
QVERIFY(item1->isSelected());
QVERIFY(!item2->isSelected());
@@ -1524,7 +1525,7 @@ void tst_QGraphicsItem::selected_multi()
// Ctrl-press on item1
QTest::mousePress(view.viewport(), Qt::LeftButton, Qt::ControlModifier, view.mapFromScene(item1->scenePos()));
- QTest::qWait(200);
+ QTest::qWait(20);
QVERIFY(!item1->isSelected());
QVERIFY(!item2->isSelected());
@@ -1532,14 +1533,14 @@ 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(200);
+ 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(200);
+ QTest::qWait(20);
QVERIFY(item1->isSelected());
QVERIFY(!item2->isSelected());
}
@@ -2927,7 +2928,7 @@ void tst_QGraphicsItem::hoverEventsGenerateRepaints()
#ifdef Q_WS_X11
qt_x11_wait_for_window_manager(&view);
#endif
- QTest::qWait(250);
+ QTest::qWait(20);
EventTester *tester = new EventTester;
scene.addItem(tester);
@@ -3059,7 +3060,8 @@ void tst_QGraphicsItem::childrenBoundingRect()
QGraphicsView view(&scene);
view.show();
- QTest::qWait(5000);
+ QTest::qWaitForWindowShown(&view);
+ QTest::qWait(30);
QCOMPARE(parent->childrenBoundingRect(), QRectF(-500, -100, 600, 800));
}
@@ -3164,7 +3166,8 @@ void tst_QGraphicsItem::group()
QGraphicsView view(&scene);
view.show();
- QTest::qWait(250);
+ QTest::qWaitForWindowShown(&view);
+ QApplication::processEvents();
QGraphicsItemGroup *group = new QGraphicsItemGroup;
group->setSelected(true);
@@ -3180,7 +3183,7 @@ void tst_QGraphicsItem::group()
QCOMPARE(scene.items().size(), 4);
QCOMPARE(scene.items(group->sceneBoundingRect()).size(), 3);
- QTest::qWait(250);
+ QTest::qWait(25);
QRectF parent2SceneBoundingRect = parent2->sceneBoundingRect();
group->addToGroup(parent2);
@@ -3192,7 +3195,7 @@ void tst_QGraphicsItem::group()
QCOMPARE(scene.items().size(), 4);
QCOMPARE(scene.items(group->sceneBoundingRect()).size(), 4);
- QTest::qWait(250);
+ QTest::qWait(25);
QList<QGraphicsItem *> newItems;
for (int i = 0; i < 100; ++i) {
@@ -3372,8 +3375,8 @@ void tst_QGraphicsItem::handlesChildEvents()
QGraphicsView view(&scene);
view.show();
-
- QTest::qWait(1000);
+ QTest::qWaitForWindowShown(&view);
+ QTest::qWait(20);
// Pull out the items, closest item first
QList<QGraphicsItem *> items = scene.items(scene.itemsBoundingRect());
@@ -3496,14 +3499,14 @@ void tst_QGraphicsItem::handlesChildEvents2()
QGraphicsView view(&scene);
view.show();
-
- QTestEventLoop::instance().enterLoop(1);
+ QTest::qWaitForWindowShown(&view);
+ QApplication::processEvents();
QMouseEvent event(QEvent::MouseButtonPress, view.mapFromScene(5, 5),
view.viewport()->mapToGlobal(view.mapFromScene(5, 5)), Qt::LeftButton, 0, 0);
QApplication::sendEvent(view.viewport(), &event);
- QCOMPARE(root->counter, 1);
+ QTRY_COMPARE(root->counter, 1);
}
void tst_QGraphicsItem::handlesChildEvents3()
@@ -3585,8 +3588,8 @@ void tst_QGraphicsItem::filtersChildEvents()
QGraphicsView view(&scene);
view.show();
-
- QTest::qWait(1000);
+ QTest::qWaitForWindowShown(&view);
+ QTest::qWait(20);
QGraphicsSceneMouseEvent pressEvent(QEvent::GraphicsSceneMousePress);
QGraphicsSceneMouseEvent releaseEvent(QEvent::GraphicsSceneMouseRelease);
@@ -3601,7 +3604,7 @@ void tst_QGraphicsItem::filtersChildEvents()
QApplication::sendEvent(&scene, &pressEvent);
QApplication::sendEvent(&scene, &releaseEvent);
- QCOMPARE(child->counter, 1); // mouse release is not filtered
+ QTRY_COMPARE(child->counter, 1); // mouse release is not filtered
QCOMPARE(filter->counter, 1); // mouse press is filtered
QCOMPARE(root->counter, 0);
@@ -3656,17 +3659,18 @@ void tst_QGraphicsItem::filtersChildEvents2()
QGraphicsView view(&scene);
view.show();
- QTestEventLoop::instance().enterLoop(1);
+ QTest::qWaitForWindowShown(&view);
+ QApplication::processEvents();
QMouseEvent event(QEvent::MouseButtonPress, view.mapFromScene(5, 5),
view.viewport()->mapToGlobal(view.mapFromScene(5, 5)), Qt::LeftButton, 0, 0);
QApplication::sendEvent(view.viewport(), &event);
+ QTRY_COMPARE(root->counter, 1);
QCOMPARE(child->counter, 0);
QCOMPARE(child2->counter, 0);
QCOMPARE(child3->counter, 0);
QCOMPARE(child4->counter, 0);
- QCOMPARE(root->counter, 1);
}
class CustomItem : public QGraphicsItem
@@ -3703,21 +3707,22 @@ void tst_QGraphicsItem::ensureVisible()
QGraphicsView view(&scene);
view.setFixedSize(300, 300);
view.show();
+ QTest::qWaitForWindowShown(&view);
for (int i = 0; i < 25; ++i) {
view.scale(qreal(1.06), qreal(1.06));
- QTest::qWait(25);
+ QApplication::processEvents();
}
item->ensureVisible(-100, -100, 25, 25);
- QTest::qWait(250);
+ QTest::qWait(25);
for (int x = -100; x < 100; x += 25) {
for (int y = -100; y < 100; y += 25) {
int xmargin = rand() % 75;
int ymargin = rand() % 75;
item->ensureVisible(x, y, 25, 25, xmargin, ymargin);
- QTest::qWait(25);
+ QApplication::processEvents();
QPolygonF viewScenePoly;
viewScenePoly << view.mapToScene(view.rect().topLeft())
@@ -3744,7 +3749,7 @@ void tst_QGraphicsItem::ensureVisible()
}
item->ensureVisible(100, 100, 25, 25);
- QTest::qWait(250);
+ QTest::qWait(25);
}
void tst_QGraphicsItem::cursor()
@@ -3785,7 +3790,7 @@ void tst_QGraphicsItem::cursor()
view.show();
QTest::mouseMove(&view, view.rect().center());
- QTest::qWait(250);
+ QTest::qWait(25);
QCursor cursor = view.viewport()->cursor();
@@ -3794,7 +3799,7 @@ void tst_QGraphicsItem::cursor()
QApplication::sendEvent(view.viewport(), &event);
}
- QTest::qWait(250);
+ QTest::qWait(25);
QCOMPARE(view.viewport()->cursor().shape(), cursor.shape());
@@ -3819,7 +3824,7 @@ void tst_QGraphicsItem::cursor()
QApplication::sendEvent(view.viewport(), &event);
}
- QTest::qWait(250);
+ QTest::qWait(25);
QCOMPARE(view.viewport()->cursor().shape(), item2->cursor().shape());
@@ -3829,7 +3834,7 @@ void tst_QGraphicsItem::cursor()
QApplication::sendEvent(view.viewport(), &event);
}
- QTest::qWait(250);
+ QTest::qWait(25);
QCOMPARE(view.viewport()->cursor().shape(), cursor.shape());
#endif
@@ -4488,10 +4493,9 @@ void tst_QGraphicsItem::sceneEventFilter()
QGraphicsView view(&scene);
view.show();
-#ifdef Q_WS_X11
- qt_x11_wait_for_window_manager(&view);
-#endif
- QTest::qWait(250);
+ QApplication::setActiveWindow(&view);
+ QTest::qWaitForWindowShown(&view);
+ QTest::qWait(25);
QGraphicsTextItem *text1 = scene.addText(QLatin1String("Text1"));
QGraphicsTextItem *text2 = scene.addText(QLatin1String("Text2"));
@@ -4503,10 +4507,10 @@ void tst_QGraphicsItem::sceneEventFilter()
EventFilterTesterItem *tester = new EventFilterTesterItem;
scene.addItem(tester);
- QVERIFY(!text1->hasFocus());
+ QTRY_VERIFY(!text1->hasFocus());
text1->installSceneEventFilter(tester);
text1->setFocus();
- QVERIFY(text1->hasFocus());
+ QTRY_VERIFY(text1->hasFocus());
QCOMPARE(tester->filteredEvents.size(), 1);
QCOMPARE(tester->filteredEvents.at(0), QEvent::FocusIn);
@@ -4554,13 +4558,14 @@ void tst_QGraphicsItem::sceneEventFilter()
QGraphicsTextItem *ti3 = anotherScene->addText("This is a test #3");
gv.setScene(anotherScene);
gv.show();
- QTest::qWait(250);
+ QTest::qWaitForWindowShown(&gv);
+ QTest::qWait(25);
ti->installSceneEventFilter(ti2);
ti3->installSceneEventFilter(ti);
delete ti2;
//we souldn't crash
QTest::mouseMove(gv.viewport(), gv.mapFromScene(ti->scenePos()));
- QTest::qWait(250);
+ QTest::qWait(30);
delete ti;
}
@@ -4608,10 +4613,8 @@ void tst_QGraphicsItem::paint()
QGraphicsView view(&scene);
view.show();
-#ifdef Q_WS_X11
- qt_x11_wait_for_window_manager(&view);
-#endif
- QTest::qWait(250);
+ QTest::qWaitForWindowShown(&view);
+ QApplication::processEvents();
#ifdef Q_OS_WIN32
//we try to switch the desktop: if it fails, we skip the test
if (::SwitchDesktop( ::GetThreadDesktop( ::GetCurrentThreadId() ) ) == 0) {
@@ -4619,14 +4622,15 @@ void tst_QGraphicsItem::paint()
}
#endif
- QCOMPARE(paintTester.widget, view.viewport());
+ QTRY_COMPARE(paintTester.widget, view.viewport());
view.hide();
QGraphicsScene scene2;
QGraphicsView view2(&scene2);
view2.show();
- QTest::qWait(250);
+ QTest::qWaitForWindowShown(&view2);
+ QTest::qWait(25);
PaintTester tester2;
scene2.addItem(&tester2);
@@ -4638,22 +4642,19 @@ void tst_QGraphicsItem::paint()
//nominal case, update call paint
tester2.update();
qApp->processEvents();
- QTest::qWait(250);
- QVERIFY(tester2.painted == 2);
+ 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();
- QTest::qWait(250);
- QVERIFY(tester2.painted == 2);
+ QTRY_VERIFY(tester2.painted == 2);
//We re-add the item, the number of paint should increase
scene2.addItem(&tester2);
tester2.update();
qApp->processEvents();
- QTest::qWait(250);
- QVERIFY(tester2.painted == 3);
+ QTRY_VERIFY(tester2.painted == 3);
}
class HarakiriItem : public QGraphicsRectItem
@@ -5414,6 +5415,8 @@ void tst_QGraphicsItem::untransformable()
view.setBackgroundBrush(QBrush(Qt::black, Qt::DiagCrossPattern));
#endif
+ QTest::qWaitForWindowShown(&view);
+
for (int i = 0; i < 10; ++i) {
QPoint center = view.viewport()->rect().center();
QCOMPARE(view.itemAt(center), item1);
@@ -5438,7 +5441,7 @@ void tst_QGraphicsItem::untransformable()
view.rotate(13);
view.shear(qreal(0.01), qreal(0.01));
view.translate(10, 10);
- QTest::qWait(250);
+ QTest::qWait(25);
}
}
@@ -5474,11 +5477,9 @@ void tst_QGraphicsItem::contextMenuEventPropagation()
QGraphicsView view(&scene);
view.setAlignment(Qt::AlignLeft | Qt::AlignTop);
view.show();
-#ifdef Q_WS_X11
- qt_x11_wait_for_window_manager(&view);
-#endif
view.resize(200, 200);
- QTest::qWait(250);
+ QTest::qWaitForWindowShown(&view);
+ QTest::qWait(20);
QContextMenuEvent event(QContextMenuEvent::Mouse, QPoint(10, 10),
view.viewport()->mapToGlobal(QPoint(10, 10)));
@@ -5579,15 +5580,16 @@ void tst_QGraphicsItem::task141694_textItemEnsureVisible()
QGraphicsView view(&scene);
view.setFixedSize(200, 200);
view.show();
+ QTest::qWaitForWindowShown(&view);
view.ensureVisible(-1000, -1000, 5, 5);
int hscroll = view.horizontalScrollBar()->value();
int vscroll = view.verticalScrollBar()->value();
- QTestEventLoop::instance().enterLoop(1);
+ QTest::qWait(10);
// This should not cause the view to scroll
- QCOMPARE(view.horizontalScrollBar()->value(), hscroll);
+ QTRY_COMPARE(view.horizontalScrollBar()->value(), hscroll);
QCOMPARE(view.verticalScrollBar()->value(), vscroll);
}
@@ -5752,16 +5754,17 @@ void tst_QGraphicsItem::ensureUpdateOnTextItem()
QGraphicsScene scene;
QGraphicsView view(&scene);
view.show();
- QTest::qWait(250);
+ QTest::qWaitForWindowShown(&view);
+ QTest::qWait(25);
TextItem *text1 = new TextItem(QLatin1String("123"));
scene.addItem(text1);
qApp->processEvents();
- QCOMPARE(text1->updates,1);
+ QTRY_COMPARE(text1->updates,1);
//same bouding rect but we have to update
text1->setText(QLatin1String("321"));
- QTest::qWait(250);
- QCOMPARE(text1->updates,2);
+ qApp->processEvents();
+ QTRY_COMPARE(text1->updates,2);
}
void tst_QGraphicsItem::task243707_addChildBeforeParent()
@@ -6049,10 +6052,8 @@ void tst_QGraphicsItem::opacity2()
MyGraphicsView view(&scene);
view.show();
-#ifdef Q_WS_X11
- qt_x11_wait_for_window_manager(&view);
-#endif
- QTest::qWait(250);
+ QTest::qWaitForWindowShown(&view);
+ QTRY_COMPARE(view.repaints, 1);
#define RESET_REPAINT_COUNTERS \
parent->repaints = 0; \
@@ -6063,8 +6064,8 @@ void tst_QGraphicsItem::opacity2()
RESET_REPAINT_COUNTERS
child->setOpacity(0.0);
- QTest::qWait(100);
- QCOMPARE(view.repaints, 1);
+ QTest::qWait(10);
+ QTRY_COMPARE(view.repaints, 1);
QCOMPARE(parent->repaints, 1);
QCOMPARE(child->repaints, 0);
QCOMPARE(grandChild->repaints, 0);
@@ -6072,8 +6073,8 @@ void tst_QGraphicsItem::opacity2()
RESET_REPAINT_COUNTERS
child->setOpacity(1.0);
- QTest::qWait(100);
- QCOMPARE(view.repaints, 1);
+ QTest::qWait(10);
+ QTRY_COMPARE(view.repaints, 1);
QCOMPARE(parent->repaints, 1);
QCOMPARE(child->repaints, 1);
QCOMPARE(grandChild->repaints, 1);
@@ -6081,8 +6082,8 @@ void tst_QGraphicsItem::opacity2()
RESET_REPAINT_COUNTERS
parent->setOpacity(0.0);
- QTest::qWait(100);
- QCOMPARE(view.repaints, 1);
+ QTest::qWait(10);
+ QTRY_COMPARE(view.repaints, 1);
QCOMPARE(parent->repaints, 0);
QCOMPARE(child->repaints, 0);
QCOMPARE(grandChild->repaints, 0);
@@ -6090,8 +6091,8 @@ void tst_QGraphicsItem::opacity2()
RESET_REPAINT_COUNTERS
parent->setOpacity(1.0);
- QTest::qWait(100);
- QCOMPARE(view.repaints, 1);
+ QTest::qWait(10);
+ QTRY_COMPARE(view.repaints, 1);
QCOMPARE(parent->repaints, 1);
QCOMPARE(child->repaints, 1);
QCOMPARE(grandChild->repaints, 1);
@@ -6100,8 +6101,8 @@ void tst_QGraphicsItem::opacity2()
RESET_REPAINT_COUNTERS
child->setOpacity(0.0);
- QTest::qWait(100);
- QCOMPARE(view.repaints, 1);
+ QTest::qWait(10);
+ QTRY_COMPARE(view.repaints, 1);
QCOMPARE(parent->repaints, 1);
QCOMPARE(child->repaints, 0);
QCOMPARE(grandChild->repaints, 1);
@@ -6109,8 +6110,8 @@ void tst_QGraphicsItem::opacity2()
RESET_REPAINT_COUNTERS
child->setOpacity(0.0); // Already 0.0; no change.
- QTest::qWait(100);
- QCOMPARE(view.repaints, 0);
+ QTest::qWait(10);
+ QTRY_COMPARE(view.repaints, 0);
QCOMPARE(parent->repaints, 0);
QCOMPARE(child->repaints, 0);
QCOMPARE(grandChild->repaints, 0);
@@ -6142,15 +6143,13 @@ void tst_QGraphicsItem::opacityZeroUpdates()
MyGraphicsView view(&scene);
view.show();
-#ifdef Q_WS_X11
- qt_x11_wait_for_window_manager(&view);
-#endif
- QTest::qWait(250);
+ QTest::qWaitForWindowShown(&view);
+ QTRY_VERIFY(view.repaints > 0);
view.reset();
parent->setOpacity(0.0);
- QTest::qWait(200);
+ QTest::qWait(20);
// transforming items bounding rect to view coordinates
const QRect childDeviceBoundingRect = child->deviceTransform(view.viewportTransform())
@@ -6161,7 +6160,7 @@ void tst_QGraphicsItem::opacityZeroUpdates()
QRegion expectedRegion = parentDeviceBoundingRect.adjusted(-2, -2, 2, 2);
expectedRegion += childDeviceBoundingRect.adjusted(-2, -2, 2, 2);
- QCOMPARE(view.paintedRegion, expectedRegion);
+ QTRY_COMPARE(view.paintedRegion, expectedRegion);
}
class StacksBehindParentHelper : public QGraphicsRectItem
@@ -6217,15 +6216,12 @@ void tst_QGraphicsItem::itemStacksBehindParent()
QGraphicsView view(&scene);
view.show();
-#ifdef Q_WS_X11
- qt_x11_wait_for_window_manager(&view);
-#endif
- QTest::qWait(250);
+ QTest::qWaitForWindowShown(&view);
+ QTest::qWait(100);
paintedItems.clear();
view.viewport()->update();
- QTest::qWait(100);
-
- QCOMPARE(scene.items(0, 0, 100, 100), (QList<QGraphicsItem *>()
+ QApplication::processEvents();
+ QTRY_COMPARE(scene.items(0, 0, 100, 100), (QList<QGraphicsItem *>()
<< grandChild111 << child11
<< grandChild121 << child12 << parent1
<< grandChild211 << child21
@@ -6239,9 +6235,9 @@ void tst_QGraphicsItem::itemStacksBehindParent()
child11->setFlag(QGraphicsItem::ItemStacksBehindParent);
scene.update();
paintedItems.clear();
- QTest::qWait(250);
+ QApplication::processEvents();
- QCOMPARE(scene.items(0, 0, 100, 100), (QList<QGraphicsItem *>()
+ QTRY_COMPARE(scene.items(0, 0, 100, 100), (QList<QGraphicsItem *>()
<< grandChild121 << child12 << parent1
<< grandChild111 << child11
<< grandChild211 << child21
@@ -6255,9 +6251,9 @@ void tst_QGraphicsItem::itemStacksBehindParent()
child12->setFlag(QGraphicsItem::ItemStacksBehindParent);
paintedItems.clear();
scene.update();
- QTest::qWait(250);
+ QApplication::processEvents();
- QCOMPARE(scene.items(0, 0, 100, 100), (QList<QGraphicsItem *>()
+ QTRY_COMPARE(scene.items(0, 0, 100, 100), (QList<QGraphicsItem *>()
<< parent1 << grandChild111 << child11
<< grandChild121 << child12
<< grandChild211 << child21
@@ -6503,31 +6499,29 @@ void tst_QGraphicsItem::tabChangesFocus()
QWidget widget;
widget.setLayout(layout);
widget.show();
-#ifdef Q_WS_X11
- qt_x11_wait_for_window_manager(&widget);
-#endif
- QTest::qWait(250);
- QVERIFY(scene.isActive());
+ QTest::qWaitForWindowShown(&widget);
+
+ QTRY_VERIFY(scene.isActive());
dial1->setFocus();
- QTest::qWait(125);
- QVERIFY(dial1->hasFocus());
+ QTest::qWait(15);
+ QTRY_VERIFY(dial1->hasFocus());
QTest::keyPress(QApplication::focusWidget(), Qt::Key_Tab);
- QTest::qWait(125);
- QVERIFY(view->hasFocus());
- QVERIFY(item->hasFocus());
+ QTest::qWait(15);
+ QTRY_VERIFY(view->hasFocus());
+ QTRY_VERIFY(item->hasFocus());
QTest::keyPress(QApplication::focusWidget(), Qt::Key_Tab);
- QTest::qWait(125);
+ QTest::qWait(15);
if (tabChangesFocus) {
- QVERIFY(!view->hasFocus());
- QVERIFY(!item->hasFocus());
- QVERIFY(dial2->hasFocus());
+ QTRY_VERIFY(!view->hasFocus());
+ QTRY_VERIFY(!item->hasFocus());
+ QTRY_VERIFY(dial2->hasFocus());
} else {
- QVERIFY(view->hasFocus());
- QVERIFY(item->hasFocus());
+ QTRY_VERIFY(view->hasFocus());
+ QTRY_VERIFY(item->hasFocus());
QCOMPARE(item->toPlainText(), QString("\tHello"));
}
}
@@ -6538,12 +6532,12 @@ void tst_QGraphicsItem::cacheMode()
QGraphicsView view(&scene);
view.resize(150, 150);
view.show();
-#ifdef Q_WS_X11
- qt_x11_wait_for_window_manager(&view);
-#endif
+ QApplication::setActiveWindow(&view);
+ QTest::qWaitForWindowShown(&view);
+
// Increase the probability of window activation
// not causing another repaint of test items.
- QTest::qWait(250);
+ QTest::qWait(50);
EventTester *tester = new EventTester;
EventTester *testerChild = new EventTester;
@@ -6553,24 +6547,24 @@ void tst_QGraphicsItem::cacheMode()
testerChild2->setFlag(QGraphicsItem::ItemIgnoresTransformations);
scene.addItem(tester);
- QTest::qWait(250);
+ QTest::qWait(10);
for (int i = 0; i < 2; ++i) {
// No visual change.
- QCOMPARE(tester->repaints, 1);
+ QTRY_COMPARE(tester->repaints, 1);
QCOMPARE(testerChild->repaints, 1);
QCOMPARE(testerChild2->repaints, 1);
tester->setCacheMode(QGraphicsItem::NoCache);
testerChild->setCacheMode(QGraphicsItem::NoCache);
testerChild2->setCacheMode(QGraphicsItem::NoCache);
- QTest::qWait(250);
- QCOMPARE(tester->repaints, 1);
+ QTest::qWait(25);
+ QTRY_COMPARE(tester->repaints, 1);
QCOMPARE(testerChild->repaints, 1);
QCOMPARE(testerChild2->repaints, 1);
tester->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
testerChild->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
testerChild2->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
- QTest::qWait(250);
+ QTest::qWait(25);
}
// The first move causes a repaint as the item is painted into its pixmap.
@@ -6578,8 +6572,8 @@ void tst_QGraphicsItem::cacheMode()
tester->setPos(10, 10);
testerChild->setPos(10, 10);
testerChild2->setPos(10, 10);
- QTest::qWait(250);
- QCOMPARE(tester->repaints, 2);
+ QTest::qWait(25);
+ QTRY_COMPARE(tester->repaints, 2);
QCOMPARE(testerChild->repaints, 2);
QCOMPARE(testerChild2->repaints, 2);
@@ -6594,15 +6588,15 @@ void tst_QGraphicsItem::cacheMode()
// Translating does not result in a repaint.
tester->translate(10, 10);
- QTest::qWait(250);
- QCOMPARE(tester->repaints, 2);
+ QTest::qWait(25);
+ QTRY_COMPARE(tester->repaints, 2);
QCOMPARE(testerChild->repaints, 2);
QCOMPARE(testerChild2->repaints, 2);
// Rotating results in a repaint.
tester->rotate(45);
- QTest::qWait(250);
- QCOMPARE(tester->repaints, 3);
+ QTest::qWait(25);
+ QTRY_COMPARE(tester->repaints, 3);
QCOMPARE(testerChild->repaints, 3);
QCOMPARE(testerChild2->repaints, 2);
@@ -6610,8 +6604,8 @@ void tst_QGraphicsItem::cacheMode()
tester->setCacheMode(QGraphicsItem::ItemCoordinateCache); // autosize
testerChild->setCacheMode(QGraphicsItem::ItemCoordinateCache); // autosize
testerChild2->setCacheMode(QGraphicsItem::ItemCoordinateCache); // autosize
- QTest::qWait(250);
- QCOMPARE(tester->repaints, 4);
+ QTest::qWait(25);
+ QTRY_COMPARE(tester->repaints, 4);
QCOMPARE(testerChild->repaints, 4);
QCOMPARE(testerChild2->repaints, 3);
@@ -6619,30 +6613,30 @@ void tst_QGraphicsItem::cacheMode()
tester->rotate(22);
testerChild->rotate(22);
testerChild2->rotate(22);
- QTest::qWait(250);
- QCOMPARE(tester->repaints, 4);
+ QTest::qWait(25);
+ QTRY_COMPARE(tester->repaints, 4);
QCOMPARE(testerChild->repaints, 4);
QCOMPARE(testerChild2->repaints, 3);
// Explicit update causes a repaint.
tester->update(0, 0, 5, 5);
- QTest::qWait(250);
- QCOMPARE(tester->repaints, 5);
+ QTest::qWait(25);
+ QTRY_COMPARE(tester->repaints, 5);
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(250);
- QCOMPARE(tester->repaints, 5);
+ QTest::qWait(25);
+ QTRY_COMPARE(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(250);
- QCOMPARE(tester->repaints, 6);
+ QTest::qWait(25);
+ QTRY_COMPARE(tester->repaints, 6);
QCOMPARE(testerChild->repaints, 4);
QCOMPARE(testerChild2->repaints, 3);
@@ -6650,22 +6644,22 @@ 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(250);
- QCOMPARE(tester->repaints, 7);
+ 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(250);
- QCOMPARE(tester->repaints, 7);
+ QTest::qWait(25);
+ QTRY_COMPARE(tester->repaints, 7);
QCOMPARE(testerChild->repaints, 6);
QCOMPARE(testerChild2->repaints, 4);
// Scaling the view does not cause a repaint.
view.scale(0.7, 0.7);
- QTest::qWait(250);
- QCOMPARE(tester->repaints, 7);
+ QTest::qWait(25);
+ QTRY_COMPARE(tester->repaints, 7);
QCOMPARE(testerChild->repaints, 6);
QCOMPARE(testerChild2->repaints, 4);
@@ -6673,54 +6667,54 @@ void tst_QGraphicsItem::cacheMode()
tester->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
testerChild->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
testerChild2->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
- QTest::qWait(250);
- QCOMPARE(tester->repaints, 8);
+ 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(250);
- QCOMPARE(tester->repaints, 9);
+ 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(250);
- QCOMPARE(tester->repaints, 10);
+ 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,
// because the parent is rotated with a perspective.
testerChild->setPos(1, 1);
- QTest::qWait(250);
- QCOMPARE(tester->repaints, 10);
+ QTest::qWait(25);
+ QTRY_COMPARE(tester->repaints, 10);
QCOMPARE(testerChild->repaints, 10);
QCOMPARE(testerChild2->repaints, 5);
// Make a huge item
tester->setGeometry(QRectF(-4000, -4000, 8000, 8000));
- QTest::qWait(250);
- QCOMPARE(tester->repaints, 11);
+ QTest::qWait(25);
+ QTRY_COMPARE(tester->repaints, 11);
QCOMPARE(testerChild->repaints, 10);
QCOMPARE(testerChild2->repaints, 5);
// Move the large item - will cause a repaint as the
// cache is clipped.
tester->setPos(5, 0);
- QTest::qWait(250);
- QCOMPARE(tester->repaints, 12);
+ QTest::qWait(25);
+ QTRY_COMPARE(tester->repaints, 12);
QCOMPARE(testerChild->repaints, 10);
QCOMPARE(testerChild2->repaints, 5);
// Hiding and showing should invalidate the cache
tester->hide();
- QTest::qWait(250);
+ QTest::qWait(25);
tester->show();
- QTest::qWait(250);
- QCOMPARE(tester->repaints, 13);
+ QTest::qWait(25);
+ QTRY_COMPARE(tester->repaints, 13);
QCOMPARE(testerChild->repaints, 11);
QCOMPARE(testerChild2->repaints, 6);
}
@@ -6739,30 +6733,30 @@ void tst_QGraphicsItem::updateCachedItemAfterMove()
view.show();
QTest::qWaitForWindowShown(&view);
- QTest::qWait(125);
+ QTest::qWait(12);
QTRY_VERIFY(tester->repaints > 0);
tester->repaints = 0;
// Move the item, should not cause repaints
tester->setPos(10, 0);
- QTest::qWait(125);
+ QTest::qWait(12);
QCOMPARE(tester->repaints, 0);
// Move then update, should cause one repaint
tester->setPos(20, 0);
tester->update();
- QTest::qWait(125);
+ QTest::qWait(12);
QCOMPARE(tester->repaints, 1);
// Hiding the item doesn't cause a repaint
tester->hide();
- QTest::qWait(125);
+ QTest::qWait(12);
QCOMPARE(tester->repaints, 1);
// Moving a hidden item doesn't cause a repaint
tester->setPos(30, 0);
tester->update();
- QTest::qWait(125);
+ QTest::qWait(12);
QCOMPARE(tester->repaints, 1);
}
@@ -7177,17 +7171,17 @@ void tst_QGraphicsItem::itemUsesExtendedStyleOption()
QGraphicsView view(&scene);
rect->startTrack = false;
view.show();
- QTest::qWait(500);
+ QTest::qWaitForWindowShown(&view);
rect->startTrack = true;
rect->update(10, 10, 10, 10);
- QTest::qWait(125);
+ QTest::qWait(12);
rect->startTrack = false;
rect->setFlag(QGraphicsItem::ItemUsesExtendedStyleOption, true);
QVERIFY((rect->flags() & QGraphicsItem::ItemUsesExtendedStyleOption));
- QTest::qWait(125);
+ QTest::qWait(12);
rect->startTrack = true;
rect->update(10, 10, 10, 10);
- QTest::qWait(125);
+ QTest::qWait(12);
}
void tst_QGraphicsItem::itemSendsGeometryChanges()
@@ -7379,10 +7373,8 @@ void tst_QGraphicsItem::itemHasNoContents()
QGraphicsView view(&scene);
view.show();
-#ifdef Q_WS_X11
- qt_x11_wait_for_window_manager(&view);
-#endif
- QTest::qWait(100);
+ QTest::qWaitForWindowShown(&view);
+ QTRY_VERIFY(!_paintedItems.isEmpty());
_paintedItems.clear();
@@ -7390,10 +7382,10 @@ void tst_QGraphicsItem::itemHasNoContents()
#ifdef Q_WS_MAC
// There's no difference between update() and repaint() on the Mac,
// so we have to process events here to make sure we get the event.
- QTest::qWait(100);
+ QTest::qWait(10);
#endif
- QCOMPARE(_paintedItems, QList<QGraphicsItem *>() << item2);
+ QTRY_COMPARE(_paintedItems, QList<QGraphicsItem *>() << item2);
}
void tst_QGraphicsItem::hitTestUntransformableItem()
@@ -8474,9 +8466,10 @@ void tst_QGraphicsItem::QTBUG_4233_updateCachedWithSceneRect()
QGraphicsView view(&scene);
view.show();
+ QTest::qWaitForWindowShown(&view);
QTRY_COMPARE(QApplication::activeWindow(), (QWidget *)&view);
- QCOMPARE(tester->repaints, 1);
+ QTRY_COMPARE(tester->repaints, 1);
scene.update(); // triggers "updateAll" optimization
qApp->processEvents();
diff --git a/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp b/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
index a289257..5c0073c 100644
--- a/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
+++ b/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
@@ -783,11 +783,9 @@ void tst_QGraphicsProxyWidget::focusNextPrevChild()
QGraphicsScene scene;
QGraphicsView view(&scene);
view.show();
-#ifdef Q_WS_X11
- qt_x11_wait_for_window_manager(&view);
-#endif
QApplication::setActiveWindow(&view);
- QTest::qWait(250);
+ QTest::qWaitForWindowShown(&view);
+ QApplication::processEvents();
QTRY_COMPARE(QApplication::activeWindow(), &view);
if (hasScene) {
scene.addItem(proxy);
@@ -832,13 +830,11 @@ void tst_QGraphicsProxyWidget::focusOutEvent()
SubQGraphicsProxyWidget *proxy = new SubQGraphicsProxyWidget;
scene.addItem(proxy);
view.show();
-#ifdef Q_WS_X11
- qt_x11_wait_for_window_manager(&view);
-#endif
QApplication::setActiveWindow(&view);
view.activateWindow();
view.setFocus();
- QTest::qWait(125);
+ QTest::qWaitForWindowShown(&view);
+ QApplication::processEvents();
QTRY_VERIFY(view.isVisible());
QTRY_COMPARE(QApplication::activeWindow(), &view);
@@ -856,11 +852,10 @@ void tst_QGraphicsProxyWidget::focusOutEvent()
if (!call) {
QWidget *other = new QLineEdit(&view);
other->show();
- QTest::qWait(125);
+ QApplication::processEvents();
QTRY_VERIFY(other->isVisible());
other->setFocus();
QTRY_VERIFY(other->hasFocus());
- QTest::qWait(125);
qApp->processEvents();
QTRY_COMPARE(proxy->hasFocus(), false);
QVERIFY(proxy->focusOut);
@@ -992,7 +987,7 @@ void tst_QGraphicsProxyWidget::hoverEnterLeaveEvent()
// in
QTest::mouseMove(&view, QPoint(50, 50));
- QTest::qWait(250);
+ QTest::qWait(25);
QTRY_COMPARE(widget->testAttribute(Qt::WA_UnderMouse), hasWidget ? true : false);
// ### this attribute isn't supported
QCOMPARE(widget->enterCount, hasWidget ? 1 : 0);
@@ -1002,7 +997,7 @@ void tst_QGraphicsProxyWidget::hoverEnterLeaveEvent()
// out
QTest::mouseMove(&view, QPoint(10, 10));
- QTest::qWait(250);
+ QTest::qWait(25);
// QTRY_COMPARE(widget->testAttribute(Qt::WA_UnderMouse), false);
// ### this attribute isn't supported
QCOMPARE(widget->leaveCount, hasWidget ? 1 : 0);
@@ -1067,14 +1062,14 @@ void tst_QGraphicsProxyWidget::hoverMoveEvent()
// in
QTest::mouseMove(&view, QPoint(50, 50));
- QTest::qWait(125);
+ QTest::qWait(12);
if (mouseDown)
QTest::mousePress(view.viewport(), Qt::LeftButton);
// move a little bit
QTest::mouseMove(&view, QPoint(60, 60));
- QTest::qWait(125);
+ QTest::qWait(12);
QTRY_COMPARE(widget->hoverEnter, (hasWidget && hoverEnabled) ? 1 : 0);
QCOMPARE(widget->moveCount, (hasWidget && mouseTracking) || (hasWidget && mouseDown) ? 1 : 0);
@@ -1098,11 +1093,9 @@ void tst_QGraphicsProxyWidget::keyPressEvent()
QGraphicsView view(&scene);
view.show();
view.viewport()->setFocus();
-#ifdef Q_WS_X11
- qt_x11_wait_for_window_manager(&view);
-#endif
QApplication::setActiveWindow(&view);
- QTest::qWait(250);
+ QTest::qWaitForWindowShown(&view);
+ QApplication::processEvents();
QTRY_COMPARE(QApplication::activeWindow(), &view);
SubQGraphicsProxyWidget *proxy = new SubQGraphicsProxyWidget;
@@ -1142,11 +1135,8 @@ void tst_QGraphicsProxyWidget::keyReleaseEvent()
QGraphicsScene scene;
QGraphicsView view(&scene);
view.show();
-#ifdef Q_WS_X11
- qt_x11_wait_for_window_manager(&view);
-#endif
QApplication::setActiveWindow(&view);
- QTest::qWait(250);
+ QTest::qWaitForWindowShown(&view);
QTRY_COMPARE(QApplication::activeWindow(), &view);
@@ -1190,7 +1180,7 @@ void tst_QGraphicsProxyWidget::mouseDoubleClickEvent()
view.show();
QApplication::setActiveWindow(&view);
- QTest::qWait(250);
+ QTest::qWaitForWindowShown(&view);
QTRY_COMPARE(QApplication::activeWindow(), &view);
SubQGraphicsProxyWidget *proxy = new SubQGraphicsProxyWidget;
@@ -1234,7 +1224,7 @@ void tst_QGraphicsProxyWidget::mousePressReleaseEvent()
QGraphicsScene scene;
QGraphicsView view(&scene);
view.show();
- QTest::qWait(125);
+ QTest::qWaitForWindowShown(&view);
SubQGraphicsProxyWidget *proxy = new SubQGraphicsProxyWidget;
proxy->setFlag(QGraphicsItem::ItemIsFocusable, true); // ### remove me!!!
@@ -1305,19 +1295,18 @@ void tst_QGraphicsProxyWidget::paintEvent()
w->show();
QTest::qWaitForWindowShown(w);
-
- QTest::qWait(100);
+ QApplication::processEvents();
proxy.setWidget(w);
scene.addItem(&proxy);
//make sure we flush all the paint events
- QTest::qWait(250);
+ QApplication::processEvents();
QTRY_VERIFY(proxy.paintCount > 1);
proxy.paintCount = 0;
w->update();
- QTest::qWait(100);
+ QApplication::processEvents();
QTRY_COMPARE(proxy.paintCount, 1); //the widget should have been painted now
}
@@ -1711,24 +1700,21 @@ void tst_QGraphicsProxyWidget::tabFocus_simpleWidget()
window.setLayout(layout);
window.show();
-#ifdef Q_WS_X11
- qt_x11_wait_for_window_manager(&window);
-#endif
QApplication::setActiveWindow(&window);
window.activateWindow();
- QTest::qWait(125);
+ QTest::qWaitForWindowShown(&window);
leftDial->setFocus();
- QTest::qWait(125);
+ QApplication::processEvents();
QTRY_VERIFY(leftDial->hasFocus());
EventSpy eventSpy(edit);
// Tab into line edit
QTest::keyPress(QApplication::focusWidget(), Qt::Key_Tab);
- QTest::qWait(125);
- QVERIFY(!leftDial->hasFocus());
- QVERIFY(view->hasFocus());
+ QApplication::processEvents();
+ QTRY_VERIFY(!leftDial->hasFocus());
+ QTRY_VERIFY(view->hasFocus());
QVERIFY(view->viewport()->hasFocus());
QVERIFY(scene.hasFocus());
QVERIFY(editProxy->hasFocus());
@@ -1738,22 +1724,22 @@ void tst_QGraphicsProxyWidget::tabFocus_simpleWidget()
// Tab into right dial
QTest::keyPress(QApplication::focusWidget(), Qt::Key_Tab);
- QTest::qWait(125);
- QVERIFY(!view->hasFocus());
+ QApplication::processEvents();
+ QTRY_VERIFY(!view->hasFocus());
QVERIFY(!view->viewport()->hasFocus());
QVERIFY(!scene.hasFocus());
QVERIFY(!editProxy->hasFocus());
QVERIFY(!edit->hasFocus());
- QVERIFY(rightDial->hasFocus());
+ QTRY_VERIFY(rightDial->hasFocus());
QCOMPARE(eventSpy.counts[QEvent::FocusIn], 1);
QCOMPARE(eventSpy.counts[QEvent::FocusOut], 1);
// Backtab into line edit
QTest::keyPress(QApplication::focusWidget(), Qt::Key_Backtab);
- QTest::qWait(125);
- QVERIFY(view->hasFocus());
+ QApplication::processEvents();
+ QTRY_VERIFY(view->hasFocus());
QVERIFY(view->viewport()->hasFocus());
- QVERIFY(scene.hasFocus());
+ QTRY_VERIFY(scene.hasFocus());
QVERIFY(editProxy->hasFocus());
QVERIFY(edit->hasFocus());
QVERIFY(!rightDial->hasFocus());
@@ -1762,13 +1748,13 @@ void tst_QGraphicsProxyWidget::tabFocus_simpleWidget()
// Backtab into left dial
QTest::keyPress(QApplication::focusWidget(), Qt::Key_Backtab);
- QTest::qWait(125);
- QVERIFY(!view->hasFocus());
+ QApplication::processEvents();
+ QTRY_VERIFY(!view->hasFocus());
QVERIFY(!view->viewport()->hasFocus());
QVERIFY(!scene.hasFocus());
QVERIFY(!editProxy->hasFocus());
QVERIFY(!edit->hasFocus());
- QVERIFY(leftDial->hasFocus());
+ QTRY_VERIFY(leftDial->hasFocus());
QCOMPARE(eventSpy.counts[QEvent::FocusIn], 2);
QCOMPARE(eventSpy.counts[QEvent::FocusOut], 2);
}
@@ -1796,14 +1782,12 @@ void tst_QGraphicsProxyWidget::tabFocus_simpleTwoWidgets()
window.setLayout(layout);
window.show();
-#ifdef Q_WS_X11
- qt_x11_wait_for_window_manager(&window);
-#endif
QApplication::setActiveWindow(&window);
window.activateWindow();
+ QTest::qWaitForWindowShown(&window);
leftDial->setFocus();
- QTest::qWait(125);
+ QApplication::processEvents();
QTRY_VERIFY(leftDial->hasFocus());
EventSpy eventSpy(edit);
@@ -1811,7 +1795,7 @@ void tst_QGraphicsProxyWidget::tabFocus_simpleTwoWidgets()
// Tab into line edit
QTest::keyPress(QApplication::focusWidget(), Qt::Key_Tab);
- QTest::qWait(125);
+ QApplication::processEvents();
QVERIFY(!leftDial->hasFocus());
QVERIFY(view->hasFocus());
QVERIFY(view->viewport()->hasFocus());
@@ -1823,7 +1807,7 @@ void tst_QGraphicsProxyWidget::tabFocus_simpleTwoWidgets()
// Tab into second line edit
QTest::keyPress(QApplication::focusWidget(), Qt::Key_Tab);
- QTest::qWait(125);
+ QApplication::processEvents();
QVERIFY(view->hasFocus());
QVERIFY(view->viewport()->hasFocus());
QVERIFY(scene.hasFocus());
@@ -1838,7 +1822,7 @@ void tst_QGraphicsProxyWidget::tabFocus_simpleTwoWidgets()
// Tab into right dial
QTest::keyPress(QApplication::focusWidget(), Qt::Key_Tab);
- QTest::qWait(125);
+ QApplication::processEvents();
QVERIFY(!view->hasFocus());
QVERIFY(!view->viewport()->hasFocus());
QVERIFY(!scene.hasFocus());
@@ -1854,7 +1838,7 @@ void tst_QGraphicsProxyWidget::tabFocus_simpleTwoWidgets()
// Backtab into line edit 2
QTest::keyPress(QApplication::focusWidget(), Qt::Key_Backtab);
- QTest::qWait(125);
+ QApplication::processEvents();
QVERIFY(view->hasFocus());
QVERIFY(view->viewport()->hasFocus());
QVERIFY(scene.hasFocus());
@@ -1870,7 +1854,7 @@ void tst_QGraphicsProxyWidget::tabFocus_simpleTwoWidgets()
// Backtab into line edit 1
QTest::keyPress(QApplication::focusWidget(), Qt::Key_Backtab);
- QTest::qWait(125);
+ QApplication::processEvents();
QVERIFY(view->hasFocus());
QVERIFY(view->viewport()->hasFocus());
QVERIFY(scene.hasFocus());
@@ -1886,7 +1870,7 @@ void tst_QGraphicsProxyWidget::tabFocus_simpleTwoWidgets()
// Backtab into left dial
QTest::keyPress(QApplication::focusWidget(), Qt::Key_Backtab);
- QTest::qWait(125);
+ QApplication::processEvents();
QVERIFY(!view->hasFocus());
QVERIFY(!view->viewport()->hasFocus());
QVERIFY(!scene.hasFocus());
@@ -1929,15 +1913,12 @@ void tst_QGraphicsProxyWidget::tabFocus_complexWidget()
window.setLayout(layout);
window.show();
-#ifdef Q_WS_X11
- qt_x11_wait_for_window_manager(&window);
-#endif
QApplication::setActiveWindow(&window);
window.activateWindow();
- QTest::qWait(125);
+ QTest::qWaitForWindowShown(&window);
leftDial->setFocus();
- QTest::qWait(125);
+ QApplication::processEvents();
QTRY_VERIFY(leftDial->hasFocus());
EventSpy eventSpy(edit1);
@@ -1946,7 +1927,7 @@ void tst_QGraphicsProxyWidget::tabFocus_complexWidget()
// Tab into group box
QTest::keyPress(QApplication::focusWidget(), Qt::Key_Tab);
- QTest::qWait(125);
+ QApplication::processEvents();
QVERIFY(!leftDial->hasFocus());
QVERIFY(view->hasFocus());
QVERIFY(view->viewport()->hasFocus());
@@ -1956,7 +1937,7 @@ void tst_QGraphicsProxyWidget::tabFocus_complexWidget()
// Tab into line edit
QTest::keyPress(QApplication::focusWidget(), Qt::Key_Tab);
- QTest::qWait(125);
+ QApplication::processEvents();
edit1->hasFocus();
QVERIFY(!box->hasFocus());
QCOMPARE(eventSpy.counts[QEvent::FocusIn], 1);
@@ -1964,7 +1945,7 @@ void tst_QGraphicsProxyWidget::tabFocus_complexWidget()
// Tab into line edit 2
QTest::keyPress(QApplication::focusWidget(), Qt::Key_Tab);
- QTest::qWait(125);
+ QApplication::processEvents();
edit2->hasFocus();
QVERIFY(!edit1->hasFocus());
QCOMPARE(eventSpy.counts[QEvent::FocusIn], 1);
@@ -1974,7 +1955,7 @@ void tst_QGraphicsProxyWidget::tabFocus_complexWidget()
// Tab into right dial
QTest::keyPress(QApplication::focusWidget(), Qt::Key_Tab);
- QTest::qWait(125);
+ QApplication::processEvents();
QVERIFY(!edit2->hasFocus());
rightDial->hasFocus();
QCOMPARE(eventSpy2.counts[QEvent::FocusIn], 1);
@@ -1982,7 +1963,7 @@ void tst_QGraphicsProxyWidget::tabFocus_complexWidget()
// Backtab into line edit 2
QTest::keyPress(QApplication::focusWidget(), Qt::Key_Backtab);
- QTest::qWait(125);
+ QApplication::processEvents();
QVERIFY(!rightDial->hasFocus());
edit2->hasFocus();
QCOMPARE(eventSpy2.counts[QEvent::FocusIn], 2);
@@ -1990,7 +1971,7 @@ void tst_QGraphicsProxyWidget::tabFocus_complexWidget()
// Backtab into line edit 1
QTest::keyPress(QApplication::focusWidget(), Qt::Key_Backtab);
- QTest::qWait(125);
+ QApplication::processEvents();
QVERIFY(!edit2->hasFocus());
edit1->hasFocus();
QCOMPARE(eventSpy2.counts[QEvent::FocusOut], 2);
@@ -1998,14 +1979,14 @@ void tst_QGraphicsProxyWidget::tabFocus_complexWidget()
// Backtab into line box
QTest::keyPress(QApplication::focusWidget(), Qt::Key_Backtab);
- QTest::qWait(125);
+ QApplication::processEvents();
QVERIFY(!edit1->hasFocus());
box->hasFocus();
QCOMPARE(eventSpy.counts[QEvent::FocusOut], 2);
// Backtab into left dial
QTest::keyPress(QApplication::focusWidget(), Qt::Key_Backtab);
- QTest::qWait(125);
+ QApplication::processEvents();
QVERIFY(!box->hasFocus());
leftDial->hasFocus();
}
@@ -2063,16 +2044,13 @@ void tst_QGraphicsProxyWidget::tabFocus_complexTwoWidgets()
window.setLayout(layout);
window.show();
-#ifdef Q_WS_X11
- qt_x11_wait_for_window_manager(&window);
-#endif
QApplication::setActiveWindow(&window);
window.activateWindow();
- QTest::qWait(125);
+ QTest::qWaitForWindowShown(&window);
QTRY_COMPARE(QApplication::activeWindow(), &window);
leftDial->setFocus();
- QTest::qWait(125);
+ QApplication::processEvents();
QTRY_VERIFY(leftDial->hasFocus());
EventSpy eventSpy(edit1);
@@ -2083,7 +2061,7 @@ void tst_QGraphicsProxyWidget::tabFocus_complexTwoWidgets()
// Tab into group box
QTest::keyPress(QApplication::focusWidget(), Qt::Key_Tab);
- QTest::qWait(125);
+ QApplication::processEvents();
QVERIFY(!leftDial->hasFocus());
QVERIFY(view->hasFocus());
QVERIFY(view->viewport()->hasFocus());
@@ -2093,7 +2071,7 @@ void tst_QGraphicsProxyWidget::tabFocus_complexTwoWidgets()
// Tab into line edit
QTest::keyPress(QApplication::focusWidget(), Qt::Key_Tab);
- QTest::qWait(125);
+ QApplication::processEvents();
edit1->hasFocus();
QVERIFY(!box->hasFocus());
QCOMPARE(eventSpy.counts[QEvent::FocusIn], 1);
@@ -2101,7 +2079,7 @@ void tst_QGraphicsProxyWidget::tabFocus_complexTwoWidgets()
// Tab into line edit 2
QTest::keyPress(QApplication::focusWidget(), Qt::Key_Tab);
- QTest::qWait(125);
+ QApplication::processEvents();
edit2->hasFocus();
QVERIFY(!edit1->hasFocus());
QCOMPARE(eventSpy.counts[QEvent::FocusIn], 1);
@@ -2109,13 +2087,13 @@ void tst_QGraphicsProxyWidget::tabFocus_complexTwoWidgets()
// Tab into right box
QTest::keyPress(QApplication::focusWidget(), Qt::Key_Tab);
- QTest::qWait(125);
+ QApplication::processEvents();
QVERIFY(!edit2->hasFocus());
box_2->hasFocus();
// Tab into right top line edit
QTest::keyPress(QApplication::focusWidget(), Qt::Key_Tab);
- QTest::qWait(125);
+ QApplication::processEvents();
QVERIFY(!box_2->hasFocus());
edit1_2->hasFocus();
QCOMPARE(eventSpy1_2.counts[QEvent::FocusIn], 1);
@@ -2123,7 +2101,7 @@ void tst_QGraphicsProxyWidget::tabFocus_complexTwoWidgets()
// Tab into right bottom line edit
QTest::keyPress(QApplication::focusWidget(), Qt::Key_Tab);
- QTest::qWait(125);
+ QApplication::processEvents();
QVERIFY(!edit1_2->hasFocus());
edit2_2->hasFocus();
QCOMPARE(eventSpy1_2.counts[QEvent::FocusIn], 1);
@@ -2133,50 +2111,50 @@ void tst_QGraphicsProxyWidget::tabFocus_complexTwoWidgets()
// Tab into right dial
QTest::keyPress(QApplication::focusWidget(), Qt::Key_Tab);
- QTest::qWait(125);
+ QApplication::processEvents();
QVERIFY(!edit2->hasFocus());
rightDial->hasFocus();
QCOMPARE(eventSpy2_2.counts[QEvent::FocusOut], 1);
// Backtab into line edit 2
QTest::keyPress(QApplication::focusWidget(), Qt::Key_Backtab);
- QTest::qWait(125);
+ QApplication::processEvents();
QVERIFY(!rightDial->hasFocus());
edit2_2->hasFocus();
// Backtab into line edit 1
QTest::keyPress(QApplication::focusWidget(), Qt::Key_Backtab);
- QTest::qWait(125);
+ QApplication::processEvents();
QVERIFY(!edit2_2->hasFocus());
edit1_2->hasFocus();
// Backtab into line box
QTest::keyPress(QApplication::focusWidget(), Qt::Key_Backtab);
- QTest::qWait(125);
+ QApplication::processEvents();
QVERIFY(!edit1_2->hasFocus());
box_2->hasFocus();
// Backtab into line edit 2
QTest::keyPress(QApplication::focusWidget(), Qt::Key_Backtab);
- QTest::qWait(125);
+ QApplication::processEvents();
QVERIFY(!rightDial->hasFocus());
edit2->hasFocus();
// Backtab into line edit 1
QTest::keyPress(QApplication::focusWidget(), Qt::Key_Backtab);
- QTest::qWait(125);
+ QApplication::processEvents();
QVERIFY(!edit2->hasFocus());
edit1->hasFocus();
// Backtab into line box
QTest::keyPress(QApplication::focusWidget(), Qt::Key_Backtab);
- QTest::qWait(125);
+ QApplication::processEvents();
QVERIFY(!edit1->hasFocus());
box->hasFocus();
// Backtab into left dial
QTest::keyPress(QApplication::focusWidget(), Qt::Key_Backtab);
- QTest::qWait(125);
+ QApplication::processEvents();
QVERIFY(!box->hasFocus());
leftDial->hasFocus();
}
@@ -2200,16 +2178,13 @@ void tst_QGraphicsProxyWidget::setFocus_simpleWidget()
window.setLayout(layout);
window.show();
-#ifdef Q_WS_X11
- qt_x11_wait_for_window_manager(&window);
-#endif
QApplication::setActiveWindow(&window);
window.activateWindow();
- QTest::qWait(125);
+ QTest::qWaitForWindowShown(&window);
QTRY_COMPARE(QApplication::activeWindow(), &window);
leftDial->setFocus();
- QTest::qWait(125);
+ QApplication::processEvents();
QTRY_VERIFY(leftDial->hasFocus());
EventSpy eventSpy(edit);
@@ -2273,16 +2248,13 @@ void tst_QGraphicsProxyWidget::setFocus_simpleTwoWidgets()
window.setLayout(layout);
window.show();
-#ifdef Q_WS_X11
- qt_x11_wait_for_window_manager(&window);
-#endif
QApplication::setActiveWindow(&window);
window.activateWindow();
- QTest::qWait(125);
+ QTest::qWaitForWindowShown(&window);
QTRY_COMPARE(QApplication::activeWindow(), &window);
leftDial->setFocus();
- QTest::qWait(125);
+ QApplication::processEvents();
QTRY_VERIFY(leftDial->hasFocus());
EventSpy eventSpy(edit);
@@ -2353,16 +2325,13 @@ void tst_QGraphicsProxyWidget::setFocus_complexTwoWidgets()
window.setLayout(layout);
window.show();
-#ifdef Q_WS_X11
- qt_x11_wait_for_window_manager(&window);
-#endif
QApplication::setActiveWindow(&window);
window.activateWindow();
- QTest::qWait(125);
+ QTest::qWaitForWindowShown(&window);
QTRY_COMPARE(QApplication::activeWindow(), &window);
leftDial->setFocus();
- QTest::qWait(125);
+ QApplication::processEvents();
QTRY_VERIFY(leftDial->hasFocus());
EventSpy eventSpy(edit1);
@@ -2377,7 +2346,7 @@ void tst_QGraphicsProxyWidget::setFocus_complexTwoWidgets()
QCOMPARE(eventSpy.counts[QEvent::FocusIn], 0);
edit1->setFocus();
- QTest::qWait(125);
+ QApplication::processEvents();
QVERIFY(scene.hasFocus());
QVERIFY(edit1->hasFocus());
QVERIFY(!box->hasFocus());
@@ -2385,7 +2354,7 @@ void tst_QGraphicsProxyWidget::setFocus_complexTwoWidgets()
QCOMPARE(eventSpyBox.counts[QEvent::FocusIn], 0);
edit2_2->setFocus();
- QTest::qWait(125);
+ QApplication::processEvents();
QVERIFY(!edit1->hasFocus());
QVERIFY(!box_2->hasFocus());
QVERIFY(edit2_2->hasFocus());
@@ -2396,7 +2365,7 @@ void tst_QGraphicsProxyWidget::setFocus_complexTwoWidgets()
QCOMPARE(eventSpyBox_2.counts[QEvent::FocusIn], 0);
box->setFocus();
- QTest::qWait(125);
+ QApplication::processEvents();
QVERIFY(!edit2_2->hasFocus());
QVERIFY(!edit1->hasFocus());
QVERIFY(box->hasFocus());
@@ -2410,7 +2379,7 @@ void tst_QGraphicsProxyWidget::setFocus_complexTwoWidgets()
QCOMPARE(eventSpyBox_2.counts[QEvent::FocusOut], 0);
edit2_2->setFocus();
- QTest::qWait(125);
+ QApplication::processEvents();
QVERIFY(edit2_2->hasFocus());
QVERIFY(!edit1->hasFocus());
QVERIFY(!box->hasFocus());
@@ -2447,12 +2416,14 @@ void tst_QGraphicsProxyWidget::popup_basic()
QCOMPARE(box->pos(), QPoint());
QCOMPARE(proxy->pos(), QPointF());
+ QTest::qWaitForWindowShown(&view);
QTest::qWait(125);
+ QApplication::processEvents();
QTest::mousePress(view.viewport(), Qt::LeftButton, 0,
view.mapFromScene(proxy->mapToScene(proxy->boundingRect().center())));
- QTest::qWait(125);
+ QTest::qWait(12);
QCOMPARE(box->pos(), QPoint());
@@ -2467,8 +2438,8 @@ void tst_QGraphicsProxyWidget::popup_basic()
QSKIP("Does not work due to SH_Combobox_Popup", SkipAll);
QCOMPARE(child->widget()->parent(), static_cast<QObject*>(box));
- QTest::qWait(125);
- QCOMPARE(proxy->pos(), QPointF(box->pos()));
+ QTest::qWait(12);
+ QTRY_COMPARE(proxy->pos(), QPointF(box->pos()));
QCOMPARE(child->x(), qreal(box->x()));
QCOMPARE(child->y(), qreal(box->rect().bottom()));
#ifndef Q_OS_WIN
@@ -2478,7 +2449,7 @@ void tst_QGraphicsProxyWidget::popup_basic()
QCOMPARE(child->widget()->y(), box->rect().bottom());
QCOMPARE(child->geometry().toRect(), child->widget()->geometry());
#endif
- QTest::qWait(125);
+ QTest::qWait(12);
}
void tst_QGraphicsProxyWidget::popup_subwidget()
@@ -2544,7 +2515,8 @@ void tst_QGraphicsProxyWidget::changingCursor_basic()
proxy->setWidget(widget);
proxy->show();
scene.addItem(proxy);
- QTest::qWait(125);
+ QTest::qWaitForWindowShown(&view);
+ QApplication::processEvents();
// in
QTest::mouseMove(view.viewport(), view.mapFromScene(proxy->mapToScene(proxy->boundingRect().center())));
@@ -2653,7 +2625,8 @@ void tst_QGraphicsProxyWidget::childPos()
for (int i = 0; i < 2; ++i) {
box->showPopup();
- QTest::qWait(50);
+ QApplication::processEvents();
+ QApplication::processEvents();
QWidget *menu = 0;
foreach (QObject *child, box->children()) {
@@ -2718,7 +2691,7 @@ void tst_QGraphicsProxyWidget::windowOpacity()
view.show();
QTest::qWaitForWindowShown(&view);
QApplication::sendPostedEvents();
- QTest::qWait(100);
+ QTest::qWait(50);
qRegisterMetaType<QList<QRectF> >("QList<QRectF>");
QSignalSpy signalSpy(&scene, SIGNAL(changed(const QList<QRectF> &)));
@@ -2727,7 +2700,7 @@ void tst_QGraphicsProxyWidget::windowOpacity()
QVERIFY(widget->isVisible());
widget->setWindowOpacity(0.5);
- QTest::qWait(100);
+ QApplication::processEvents();
// Make sure setWindowOpacity triggers an update on the scene,
// and not on the widget or the proxy itself. The entire proxy needs an update
@@ -2738,8 +2711,8 @@ void tst_QGraphicsProxyWidget::windowOpacity()
#ifdef Q_WS_X11
paints = !X11->use_xrender;
#endif
- QCOMPARE(eventSpy.counts[QEvent::UpdateRequest], 0);
- QCOMPARE(eventSpy.counts[QEvent::Paint], paints);
+ QTRY_COMPARE(eventSpy.counts[QEvent::UpdateRequest], 0);
+ QTRY_COMPARE(eventSpy.counts[QEvent::Paint], paints);
QCOMPARE(signalSpy.count(), 1);
const QList<QVariant> arguments = signalSpy.takeFirst();
@@ -2920,7 +2893,8 @@ void tst_QGraphicsProxyWidget::dontCrashWhenDie()
{
MainWidget *w = new MainWidget();
w->show();
- QTest::qWait(200);
+ QTest::qWaitForWindowShown(w);
+ QTest::qWait(100);
QTest::mouseMove(w->view->viewport(), w->view->mapFromScene(w->widget->mapToScene(w->widget->boundingRect().center())));
delete w->item;
}
diff --git a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp
index 95a038b..0c27079 100644
--- a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp
+++ b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp
@@ -363,7 +363,7 @@ void tst_QGraphicsView::alignment()
for (int k = 0; k < 3; ++k) {
view.resize(100 + k * 25, 100 + k * 25);
- QTest::qWait(25);
+ QApplication::processEvents();
}
}
}
@@ -455,7 +455,7 @@ void tst_QGraphicsView::setScene()
view.setScene(0);
- QTest::qWait(250);
+ QTest::qWait(25);
QVERIFY(!view.horizontalScrollBar()->isVisible());
QVERIFY(!view.verticalScrollBar()->isVisible());
@@ -530,7 +530,7 @@ void tst_QGraphicsView::sceneRect_growing()
size *= 2;
scene.setSceneRect(-size, -size, size * 2, size * 2);
- QTest::qWait(25);
+ QApplication::processEvents();
QCOMPARE(view.sceneRect(), scene.sceneRect());
QCOMPARE(view.mapToScene(0, 0), topLeft);
@@ -614,7 +614,8 @@ void tst_QGraphicsView::dragMode_scrollHand()
view.setFixedSize(100, 100);
view.show();
- QTest::qWait(25);
+ QTest::qWaitForWindowShown(&view);
+ QApplication::processEvents();
view.setInteractive(j ? false : true);
@@ -646,9 +647,9 @@ void tst_QGraphicsView::dragMode_scrollHand()
QApplication::sendEvent(view.viewport(), &event);
QVERIFY(event.isAccepted());
}
- QTest::qWait(250);
+ QApplication::processEvents();
- QVERIFY(item->isSelected());
+ QTRY_VERIFY(item->isSelected());
for (int k = 0; k < 4; ++k) {
#ifndef QT_NO_CURSOR
@@ -689,9 +690,9 @@ void tst_QGraphicsView::dragMode_scrollHand()
QApplication::sendEvent(view.viewport(), &event);
QVERIFY(event.isAccepted());
}
- QTest::qWait(250);
+ QApplication::processEvents();
- QVERIFY(item->isSelected());
+ QTRY_VERIFY(item->isSelected());
QCOMPARE(view.horizontalScrollBar()->value(), horizontalScrollBarValue - 10);
QCOMPARE(view.verticalScrollBar()->value(), verticalScrollBarValue - 10);
#ifndef QT_NO_CURSOR
@@ -749,6 +750,9 @@ void tst_QGraphicsView::dragMode_rubberBand()
view.setDragMode(QGraphicsView::RubberBandDrag);
+ QTest::qWaitForWindowShown(&view);
+ QApplication::processEvents();
+
for (int i = 0; i < 2; ++i) {
// RubberBandDrag
#ifndef QT_NO_CURSOR
@@ -769,7 +773,7 @@ void tst_QGraphicsView::dragMode_rubberBand()
QCOMPARE(view.viewport()->cursor().shape(), cursorShape);
#endif
- QTest::qWait(25);
+ QApplication::processEvents();
{
// Move
@@ -1073,7 +1077,7 @@ void tst_QGraphicsView::centerOnPoint()
QFAIL(qPrintable(error));
}
- QTest::qWait(1);
+ QApplication::processEvents();
}
}
@@ -2095,7 +2099,7 @@ void tst_QGraphicsView::transformationAnchor()
}
view.centerOn(0, 0);
view.horizontalScrollBar()->setValue(100);
- QTest::qWait(100);
+ QApplication::processEvents();
QPointF center = view.mapToScene(view.viewport()->rect().center());
@@ -2125,6 +2129,8 @@ void tst_QGraphicsView::resizeAnchor()
for (int i = 0; i < 2; ++i) {
view.resize(100, 100);
view.show();
+ QTest::qWaitForWindowShown(&view);
+ QApplication::processEvents();
if (i == 0) {
QCOMPARE(view.resizeAnchor(), QGraphicsView::NoAnchor);
@@ -2132,12 +2138,12 @@ void tst_QGraphicsView::resizeAnchor()
view.setResizeAnchor(QGraphicsView::AnchorViewCenter);
}
view.centerOn(0, 0);
- QTest::qWait(250);
+ QTest::qWait(25);
QPointF f = view.mapToScene(50, 50);
QPointF center = view.mapToScene(view.viewport()->rect().center());
- QTest::qWait(250);
+ QApplication::processEvents();
for (int size = 200; size <= 400; size += 25) {
view.resize(size, size);
@@ -2152,7 +2158,7 @@ void tst_QGraphicsView::resizeAnchor()
QVERIFY(qAbs(newCenter.x() - center.x()) < slack);
QVERIFY(qAbs(newCenter.y() - center.y()) < slack);
}
- QTest::qWait(20);
+ QApplication::processEvents();
}
}
}
@@ -2760,11 +2766,11 @@ void tst_QGraphicsView::task187791_setSceneCausesUpdate()
QCOMPARE(updateSpy.count(), 0);
view.setScene(0);
- QTest::qWait(125);
- QCOMPARE(updateSpy.count(), 1);
+ QApplication::processEvents();
+ QTRY_COMPARE(updateSpy.count(), 1);
view.setScene(&scene);
- QTest::qWait(125);
- QCOMPARE(updateSpy.count(), 2);
+ QApplication::processEvents();
+ QTRY_COMPARE(updateSpy.count(), 2);
}
class MouseMoveCounter : public QGraphicsView
@@ -2808,15 +2814,15 @@ void tst_QGraphicsView::task186827_deleteReplayedItem()
QApplication::sendEvent(view.viewport(), &event);
}
QCOMPARE(view.mouseMoves, 1);
- QTest::qWait(125);
- QCOMPARE(view.mouseMoves, 1);
- QTest::qWait(125);
+ QTest::qWait(25);
+ QTRY_COMPARE(view.mouseMoves, 1);
+ QTest::qWait(25);
{
QMouseEvent event(QEvent::MouseMove, view.mapFromScene(25, 25), Qt::NoButton, 0, 0);
QApplication::sendEvent(view.viewport(), &event);
}
QCOMPARE(view.mouseMoves, 2);
- QTest::qWait(125);
+ QTest::qWait(15);
}
void tst_QGraphicsView::task207546_focusCrash()
@@ -3412,11 +3418,11 @@ void tst_QGraphicsView::exposeRegion()
QRegion expectedExposeRegion = QRect(0, 0, 5, 5);
expectedExposeRegion += QRect(viewport->rect().bottomRight() - QPoint(5, 5), QSize(5, 5));
viewport->update(expectedExposeRegion);
- QTest::qWait(125);
+ QApplication::processEvents();
// Make sure it triggers correct repaint on the view.
- QCOMPARE(view.lastUpdateRegions.size(), 1);
- QCOMPARE(view.lastUpdateRegions.at(0), expectedExposeRegion);
+ QTRY_COMPARE(view.lastUpdateRegions.size(), 1);
+ QTRY_COMPARE(view.lastUpdateRegions.at(0), expectedExposeRegion);
// Make sure the item didn't get any repaints.
QCOMPARE(item->paints, 0);
@@ -3473,7 +3479,7 @@ void tst_QGraphicsView::update()
#if defined QT_BUILD_INTERNAL
const bool intersects = updateRect.intersects(viewportRect);
QGraphicsViewPrivate *viewPrivate = static_cast<QGraphicsViewPrivate *>(qt_widget_private(&view));
- QCOMPARE(viewPrivate->updateRect(updateRect), intersects);
+ QTRY_COMPARE(viewPrivate->updateRect(updateRect), intersects);
QCOMPARE(viewPrivate->updateRegion(updateRect), intersects);
view.lastUpdateRegions.clear();
@@ -3631,13 +3637,13 @@ void tst_QGraphicsView::task253415_reconnectUpdateSceneOnSceneChanged()
QObject::connect(&scene1, SIGNAL(changed(QList<QRectF>)), &dummyView, SLOT(updateScene(QList<QRectF>)));
view.setScene(&scene1);
- QTest::qWait(125);
+ QTest::qWait(12);
QGraphicsScene scene2;
QObject::connect(&scene2, SIGNAL(changed(QList<QRectF>)), &dummyView, SLOT(updateScene(QList<QRectF>)));
view.setScene(&scene2);
- QTest::qWait(125);
+ QTest::qWait(12);
bool wasConnected2 = QObject::disconnect(&scene2, SIGNAL(changed(QList<QRectF>)), &view, 0);
QVERIFY(wasConnected2);
@@ -3661,8 +3667,10 @@ void tst_QGraphicsView::task255529_transformationAnchorMouseAndViewportMargins()
};
VpGraphicsView view(&scene);
+ view.setWindowFlags(Qt::X11BypassWindowManagerHint);
view.show();
QTest::qWaitForWindowShown(&view);
+ QTest::qWait(50);
QPoint mouseViewPos(20, 20);
sendMouseMove(view.viewport(), mouseViewPos);