diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2017-12-07 16:31:43 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2018-03-29 20:50:00 +0000 |
commit | f3a461c4a2ca41669e1cccec0b528c0b1482b0ad (patch) | |
tree | 58a1351cb692bdb7168e5833554498fd1bb08a17 /tests | |
parent | 62da8e34800afb658a19037fa37715c869311fae (diff) |
Stabilize tst_QGraphicsProxyWidget::tooltip_basic()
Use QTRY_VERIFY instead of hard-coded wait for the tooltip to appear.
Also use QTRY_VERIFY to verify that no top level widgets are left over
to account for tooltips and effect windows.
Change-Id: Ia9835fdc480c6abb034f6fc4ad3d6b32751ee536
Reviewed-by: Sami Nurmenniemi <sami.nurmenniemi@qt.io>
Reviewed-by: Kari Oikarinen <kari.oikarinen@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp index 8287b9ebdd..4cd2fef2dc 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp @@ -281,7 +281,7 @@ void tst_QGraphicsProxyWidget::initTestCase() // This will be called after every test function. void tst_QGraphicsProxyWidget::cleanup() { - QVERIFY(QApplication::topLevelWidgets().isEmpty()); + QTRY_VERIFY(QApplication::topLevelWidgets().isEmpty()); } void tst_QGraphicsProxyWidget::qgraphicsproxywidget_data() @@ -2575,6 +2575,22 @@ void tst_QGraphicsProxyWidget::changingCursor_basic() } #endif +static bool findViewAndTipLabel(const QWidget *view) +{ + bool foundView = false; + bool foundTipLabel = false; + const QWidgetList &topLevels = QApplication::topLevelWidgets(); + for (const QWidget *widget : topLevels) { + if (widget == view) + foundView = true; + if (widget->inherits("QTipLabel")) + foundTipLabel = true; + if (foundView && foundTipLabel) + return true; + } + return false; +} + void tst_QGraphicsProxyWidget::tooltip_basic() { QString toolTip = "Qt rocks!"; @@ -2627,18 +2643,7 @@ void tst_QGraphicsProxyWidget::tooltip_basic() QHelpEvent helpEvent(QEvent::ToolTip, view.mapFromScene(proxy->boundingRect().center()), view.viewport()->mapToGlobal(view.mapFromScene(proxy->boundingRect().center()))); QApplication::sendEvent(view.viewport(), &helpEvent); - QTest::qWait(350); - - bool foundView = false; - bool foundTipLabel = false; - foreach (QWidget *widget, QApplication::topLevelWidgets()) { - if (widget == &view) - foundView = true; - if (widget->inherits("QTipLabel")) - foundTipLabel = true; - } - QVERIFY(foundView); - QVERIFY(foundTipLabel); + QTRY_VERIFY(findViewAndTipLabel(&view)); } } |