summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2019-07-03 16:25:54 +0200
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2019-07-10 06:17:09 +0200
commitb426cff1e0363b350f98bc64691b9b279bc6c757 (patch)
tree4561264fc2b7f9c1e84ee1953f1abc0c0e3f02a1 /tests
parent59b29d03b2fff8a138382d45077c81fe0d4b8ea8 (diff)
Make tst_QGraphicsItem painting tests most robust
Counting absolute paint events is fragile, as there are no guarantees that a single call to QApp::processEvents only delivers a single paint event to a widget. As of QTBUG-76566, we see that the items occasionally receive three calls to paint, which can be simulated by activating other windows while the test is running and waiting for events to be processed. Instead, verify that we do receive any paint events as the first test, and then verify increments when we expect updates. This also reverts change 24b9424adcda1ab083fae4ae857007227ba5fee2. Change-Id: Ib51853e918f31acd3aea10d4109c95f34012a29f Fixes: QTBUG-76566 Reviewed-by: Dimitrios Apostolou <dimitrios.apostolou@qt.io> Reviewed-by: Andreas Aardal Hanssen <andreas@hanssen.name>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp25
1 files changed, 11 insertions, 14 deletions
diff --git a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp
index e071edc332..872e0b62c5 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp
@@ -5057,12 +5057,6 @@ public:
void tst_QGraphicsItem::paint()
{
-#if defined(Q_OS_MACOS)
- if (QSysInfo::productVersion() == QLatin1String("10.12")) {
- QSKIP("Test is very flaky on MacOS_10_12, see QTBUG-76566");
- }
-#endif
-
QGraphicsScene scene;
PaintTester paintTester;
@@ -5092,22 +5086,25 @@ void tst_QGraphicsItem::paint()
PaintTester tester2;
scene2.addItem(&tester2);
- //First show one paint
- QTRY_COMPARE(tester2.painted, 1);
+ //First show at least one paint
+ QCOMPARE(tester2.painted, 0);
+ QTRY_VERIFY(tester2.painted > 0);
+ int painted = tester2.painted;
//nominal case, update call paint
tester2.update();
- QTRY_COMPARE(tester2.painted, 2);
+ QTRY_COMPARE(tester2.painted, painted + 1);
+ painted = tester2.painted;
//we remove the item from the scene, number of updates is still the same
tester2.update();
scene2.removeItem(&tester2);
- QTRY_COMPARE(tester2.painted, 2);
+ QTRY_COMPARE(tester2.painted, painted);
//We re-add the item, the number of paint should increase
scene2.addItem(&tester2);
tester2.update();
- QTRY_COMPARE(tester2.painted, 3);
+ QTRY_COMPARE(tester2.painted, painted + 1);
}
class HarakiriItem : public QGraphicsRectItem
@@ -11377,7 +11374,7 @@ void tst_QGraphicsItem::QTBUG_7714_fullUpdateDiscardingOpacityUpdate2()
origView.reset();
childYellow->setOpacity(0.0);
- QTRY_COMPARE(origView.repaints, 1);
+ QTRY_VERIFY(origView.repaints > 0);
view.show();
qApp->setActiveWindow(&view);
@@ -11392,8 +11389,8 @@ void tst_QGraphicsItem::QTBUG_7714_fullUpdateDiscardingOpacityUpdate2()
QEXPECT_FAIL("", "Fails on WinRT. Figure out why - QTBUG-68297", Abort);
#endif
- QTRY_COMPARE(origView.repaints, 1);
- QTRY_COMPARE(view.repaints, 1);
+ QTRY_VERIFY(origView.repaints > 0);
+ QTRY_VERIFY(view.repaints > 0);
}
void tst_QGraphicsItem::QT_2649_focusScope()