diff options
author | Morten Johan Sørvig <morten.sorvig@qt.io> | 2018-03-07 13:36:00 +0100 |
---|---|---|
committer | Morten Johan Sørvig <morten.sorvig@qt.io> | 2018-03-19 14:38:23 +0000 |
commit | dae8133ded616c9038407793232ae946fcf93e8c (patch) | |
tree | 391f886b41e3ec2a3aaae0d676c3229b63530fab | |
parent | b4650d9bcf29edffbf986bec5dc7afdd78318544 (diff) |
Stabilize tst_qgraphicsitem and tst_qgraphicsview
Add qWaitForWindowExposed() calls in addition to the
existing qWaitForWindowActive().
Depending on the platform, window activation events may
be synchronous, which means that a window can (and will)
become active before it becomes exposed.
This causes test failures for tests that count paint
event, and does not wait-for-exposed, when the expose/paint
event is delivered after waitForWindowActive() has returned.
We need to keep the waitForWindowActive() as well: the
test has several qWait() calls with he comment:
“Increase the probability of window activation not
causing another repaint of test items”.
These qWait() calls can possibly be removed in a future
commit.
Task-number: QTBUG-66536
Task-number: QTBUG-61967
Change-Id: Ie61bba058b583fdd1d80e600475aff3efccc32eb
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
-rw-r--r-- | tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp | 20 | ||||
-rw-r--r-- | tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp | 17 |
2 files changed, 37 insertions, 0 deletions
diff --git a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp index 4f4a11a79c..92225f60a2 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp @@ -986,6 +986,7 @@ void tst_QGraphicsItem::inputMethodHints() QGraphicsView view(&scene); QApplication::setActiveWindow(&view); view.show(); + QVERIFY(QTest::qWaitForWindowExposed(&view)); QVERIFY(QTest::qWaitForWindowActive(&view)); item->setFocus(); QTRY_VERIFY(item->hasFocus()); @@ -1036,6 +1037,7 @@ void tst_QGraphicsItem::toolTip() view.setFixedSize(200, 200); view.show(); QApplication::setActiveWindow(&view); + QVERIFY(QTest::qWaitForWindowExposed(&view)); QVERIFY(QTest::qWaitForWindowActive(&view)); { QHelpEvent helpEvent(QEvent::ToolTip, view.viewport()->rect().topLeft(), @@ -3251,6 +3253,7 @@ void tst_QGraphicsItem::hoverEventsGenerateRepaints() QGraphicsScene scene; QGraphicsView view(&scene); view.show(); + QVERIFY(QTest::qWaitForWindowExposed(&view)); QVERIFY(QTest::qWaitForWindowActive(&view)); EventTester *tester = new EventTester; @@ -4975,6 +4978,7 @@ void tst_QGraphicsItem::sceneEventFilter() QGraphicsView view(&scene); view.show(); QApplication::setActiveWindow(&view); + QVERIFY(QTest::qWaitForWindowExposed(&view)); QVERIFY(QTest::qWaitForWindowActive(&view)); QGraphicsTextItem *text1 = scene.addText(QLatin1String("Text1")); @@ -6850,6 +6854,7 @@ void tst_QGraphicsItem::opacity2() MyGraphicsView view(&scene); view.show(); + QVERIFY(QTest::qWaitForWindowExposed(&view)); QVERIFY(QTest::qWaitForWindowActive(&view)); QTRY_VERIFY(view.repaints >= 1); @@ -6927,6 +6932,7 @@ void tst_QGraphicsItem::opacityZeroUpdates() MyGraphicsView view(&scene); view.show(); + QVERIFY(QTest::qWaitForWindowExposed(&view)); QVERIFY(QTest::qWaitForWindowActive(&view)); QTRY_VERIFY(view.repaints > 0); @@ -7322,6 +7328,7 @@ void tst_QGraphicsItem::cacheMode() view.resize(150, 150); view.show(); QApplication::setActiveWindow(&view); + QVERIFY(QTest::qWaitForWindowExposed(&view)); QVERIFY(QTest::qWaitForWindowActive(&view)); // Increase the probability of window activation @@ -7516,6 +7523,7 @@ void tst_QGraphicsItem::cacheMode2() view.resize(150, 150); view.show(); QApplication::setActiveWindow(&view); + QVERIFY(QTest::qWaitForWindowExposed(&view)); QVERIFY(QTest::qWaitForWindowActive(&view)); // Increase the probability of window activation @@ -8180,6 +8188,7 @@ void tst_QGraphicsItem::moveLineItem() MyGraphicsView view(&scene); view.show(); + QVERIFY(QTest::qWaitForWindowExposed(&view)); QVERIFY(QTest::qWaitForWindowActive(&view)); view.reset(); @@ -8250,6 +8259,7 @@ void tst_QGraphicsItem::sorting() view.setFrameStyle(0); view.show(); qApp->setActiveWindow(&view); + QVERIFY(QTest::qWaitForWindowExposed(&view)); QVERIFY(QTest::qWaitForWindowActive(&view)); QTest::qWait(100); @@ -8286,6 +8296,7 @@ void tst_QGraphicsItem::itemHasNoContents() QGraphicsView view(&scene); view.show(); qApp->setActiveWindow(&view); + QVERIFY(QTest::qWaitForWindowExposed(&view)); QVERIFY(QTest::qWaitForWindowActive(&view)); QTRY_VERIFY(!_paintedItems.isEmpty()); @@ -9294,6 +9305,7 @@ void tst_QGraphicsItem::ensureDirtySceneTransform() QGraphicsView view(&scene); view.show(); QApplication::setActiveWindow(&view); + QVERIFY(QTest::qWaitForWindowExposed(&view)); QVERIFY(QTest::qWaitForWindowActive(&view)); QCOMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&view)); @@ -9680,6 +9692,7 @@ void tst_QGraphicsItem::QTBUG_4233_updateCachedWithSceneRect() QGraphicsView view(&scene); view.show(); QApplication::setActiveWindow(&view); + QVERIFY(QTest::qWaitForWindowExposed(&view)); QVERIFY(QTest::qWaitForWindowActive(&view)); QCOMPARE(QApplication::activeWindow(), (QWidget *)&view); @@ -10810,6 +10823,7 @@ void tst_QGraphicsItem::scroll() MyGraphicsView view(&scene); view.setFrameStyle(0); view.show(); + QVERIFY(QTest::qWaitForWindowExposed(&view)); QVERIFY(QTest::qWaitForWindowActive(&view)); QTRY_VERIFY(view.repaints > 0); @@ -11332,6 +11346,7 @@ void tst_QGraphicsItem::QTBUG_6738_missingUpdateWithSetParent() MyGraphicsView view(&scene); view.show(); qApp->setActiveWindow(&view); + QVERIFY(QTest::qWaitForWindowExposed(&view)); QVERIFY(QTest::qWaitForWindowActive(&view)); QTRY_VERIFY(view.repaints > 0); @@ -11380,6 +11395,7 @@ void tst_QGraphicsItem::QT_2653_fullUpdateDiscardingOpacityUpdate() parentGreen->setFlag(QGraphicsItem::ItemIgnoresTransformations); view.show(); + QVERIFY(QTest::qWaitForWindowExposed(&view)); QVERIFY(QTest::qWaitForWindowActive(&view)); view.reset(); @@ -11426,6 +11442,7 @@ void tst_QGraphicsItem::QTBUG_7714_fullUpdateDiscardingOpacityUpdate2() view.show(); qApp->setActiveWindow(&view); + QVERIFY(QTest::qWaitForWindowExposed(&view)); QVERIFY(QTest::qWaitForWindowActive(&view)); view.reset(); origView.reset(); @@ -11565,6 +11582,7 @@ void tst_QGraphicsItem::doNotMarkFullUpdateIfNotInScene() item2->setParentItem(item); scene.addItem(item); view.show(); + QVERIFY(QTest::qWaitForWindowExposed(view.windowHandle())); QVERIFY(QTest::qWaitForWindowActive(view.windowHandle())); view.activateWindow(); QTRY_VERIFY(view.isActiveWindow()); @@ -11596,6 +11614,7 @@ void tst_QGraphicsItem::itemDiesDuringDraggingOperation() scene.addItem(item); view.show(); QApplication::setActiveWindow(&view); + QVERIFY(QTest::qWaitForWindowExposed(&view)); QVERIFY(QTest::qWaitForWindowActive(&view)); QCOMPARE(QApplication::activeWindow(), (QWidget *)&view); QGraphicsSceneDragDropEvent dragEnter(QEvent::GraphicsSceneDragEnter); @@ -11623,6 +11642,7 @@ void tst_QGraphicsItem::QTBUG_12112_focusItem() view.show(); QApplication::setActiveWindow(&view); + QVERIFY(QTest::qWaitForWindowExposed(&view)); QVERIFY(QTest::qWaitForWindowActive(&view)); QCOMPARE(QApplication::activeWindow(), (QWidget *)&view); diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp index 3d5df7506d..c4b26bb350 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp @@ -431,6 +431,7 @@ void tst_QGraphicsView::interactive() QCOMPARE(item->events.size(), 0); view.show(); view.activateWindow(); + QVERIFY(QTest::qWaitForWindowExposed(&view)); QVERIFY(QTest::qWaitForWindowActive(&view)); QTRY_COMPARE(item->events.size(), 1); // activate @@ -1655,6 +1656,7 @@ void tst_QGraphicsView::itemsInRect_cosmeticAdjust() view.setFrameStyle(0); view.resize(300, 300); view.showNormal(); + QVERIFY(QTest::qWaitForWindowExposed(&view)); QVERIFY(QTest::qWaitForWindowActive(&view)); QTRY_VERIFY(rect->numPaints > 0); @@ -2149,6 +2151,7 @@ void tst_QGraphicsView::sendEvent() QGraphicsView view(&scene); view.show(); QApplication::setActiveWindow(&view); + QVERIFY(QTest::qWaitForWindowExposed(&view)); QVERIFY(QTest::qWaitForWindowActive(&view)); QCOMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&view)); @@ -2216,6 +2219,7 @@ void tst_QGraphicsView::wheelEvent() QGraphicsView view(&scene); view.show(); QApplication::setActiveWindow(&view); + QVERIFY(QTest::qWaitForWindowExposed(&view)); QVERIFY(QTest::qWaitForWindowActive(&view)); QCOMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&view)); @@ -2452,6 +2456,7 @@ void tst_QGraphicsView::viewportUpdateMode() // Show the view, and initialize our test. view.show(); qApp->setActiveWindow(&view); + QVERIFY(QTest::qWaitForWindowExposed(&view)); QVERIFY(QTest::qWaitForWindowActive(&view)); QTRY_VERIFY(!view.lastUpdateRegions.isEmpty()); view.lastUpdateRegions.clear(); @@ -2536,6 +2541,7 @@ void tst_QGraphicsView::viewportUpdateMode2() view.resize(200 + left + right, 200 + top + bottom); toplevel.show(); qApp->setActiveWindow(&toplevel); + QVERIFY(QTest::qWaitForWindowExposed(&toplevel)); QVERIFY(QTest::qWaitForWindowActive(&toplevel)); QTRY_VERIFY(view.painted); const QRect viewportRect = view.viewport()->rect(); @@ -3192,6 +3198,7 @@ void tst_QGraphicsView::task172231_untransformableItems() view.scale(2, 1); view.show(); QApplication::setActiveWindow(&view); + QVERIFY(QTest::qWaitForWindowExposed(&view)); QVERIFY(QTest::qWaitForWindowActive(&view)); QCOMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&view)); @@ -3994,6 +4001,7 @@ void tst_QGraphicsView::exposeRegion() view.setScene(&scene); view.show(); qApp->setActiveWindow(&view); + QVERIFY(QTest::qWaitForWindowExposed(&view)); QVERIFY(QTest::qWaitForWindowActive(&view)); QTRY_VERIFY(item->paints > 0); @@ -4148,6 +4156,7 @@ void tst_QGraphicsView::update2() view.resize(200, 200); view.show(); qApp->setActiveWindow(&view); + QVERIFY(QTest::qWaitForWindowExposed(&view)); QVERIFY(QTest::qWaitForWindowActive(&view)); QTRY_VERIFY(rect->numPaints > 0); @@ -4217,6 +4226,7 @@ void tst_QGraphicsView::update_ancestorClipsChildrenToShape() CustomView view(&scene); view.show(); qApp->setActiveWindow(&view); + QVERIFY(QTest::qWaitForWindowExposed(&view)); QVERIFY(QTest::qWaitForWindowActive(&view)); QTRY_VERIFY(view.painted); @@ -4270,6 +4280,7 @@ void tst_QGraphicsView::update_ancestorClipsChildrenToShape2() CustomView view(&scene); view.show(); qApp->setActiveWindow(&view); + QVERIFY(QTest::qWaitForWindowExposed(&view)); QVERIFY(QTest::qWaitForWindowActive(&view)); QTRY_VERIFY(view.painted); @@ -4332,6 +4343,7 @@ void tst_QGraphicsView::inputMethodSensitivity() QGraphicsView view(&scene); view.show(); QApplication::setActiveWindow(&view); + QVERIFY(QTest::qWaitForWindowExposed(&view)); QVERIFY(QTest::qWaitForWindowActive(&view)); QCOMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&view)); @@ -4426,6 +4438,7 @@ void tst_QGraphicsView::inputContextReset() view.show(); QApplication::setActiveWindow(&view); + QVERIFY(QTest::qWaitForWindowExposed(&view)); QVERIFY(QTest::qWaitForWindowActive(&view)); QCOMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&view)); @@ -4573,6 +4586,7 @@ void tst_QGraphicsView::task255529_transformationAnchorMouseAndViewportMargins() view.setWindowFlags(Qt::X11BypassWindowManagerHint); view.show(); qApp->setActiveWindow(&view); + QVERIFY(QTest::qWaitForWindowExposed(&view)); QVERIFY(QTest::qWaitForWindowActive(&view)); // This is highly unstable (observed to pass on Windows and some Linux configurations). #ifndef Q_OS_MAC @@ -4700,6 +4714,7 @@ void tst_QGraphicsView::QTBUG_4151_clipAndIgnore() view.resize(75, 75); view.show(); view.activateWindow(); + QVERIFY(QTest::qWaitForWindowExposed(&view)); QVERIFY(QTest::qWaitForWindowActive(&view)); QCOMPARE(QApplication::activeWindow(), (QWidget *)&view); @@ -4737,6 +4752,7 @@ void tst_QGraphicsView::QTBUG_5859_exposedRect() view.scale(4.15, 4.15); view.showNormal(); qApp->setActiveWindow(&view); + QVERIFY(QTest::qWaitForWindowExposed(&view)); QVERIFY(QTest::qWaitForWindowActive(&view)); view.viewport()->repaint(10,10,20,20); @@ -4861,6 +4877,7 @@ void tst_QGraphicsView::QTBUG_16063_microFocusRect() view.setFixedSize(40, 40); view.show(); + QVERIFY(QTest::qWaitForWindowExposed(&view)); QVERIFY(QTest::qWaitForWindowActive(&view)); scene.setFocusItem(item); |