From 1bc3103ef2d2a3e43f6e3e07479678aadb8a738a Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Thu, 4 Oct 2018 11:17:20 +0200 Subject: [PATCH] QmlProfiler: Add more fine grained checks to tool test The test frequently fails for unknown reasons. Check if we actually see the attach dialog, or if some other dialog interfers. Change-Id: Id279b8aa0a822dbdb565fe4105bfcb28ad704e3c Reviewed-by: Christian Kandeler --- .../tests/qmlprofilertool_test.cpp | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/plugins/qmlprofiler/tests/qmlprofilertool_test.cpp b/src/plugins/qmlprofiler/tests/qmlprofilertool_test.cpp index 6a766b6aa86..ea27c3cb505 100644 --- a/src/plugins/qmlprofiler/tests/qmlprofilertool_test.cpp +++ b/src/plugins/qmlprofiler/tests/qmlprofilertool_test.cpp @@ -69,11 +69,22 @@ void QmlProfilerToolTest::testAttachToWaitingApplication() QTimer timer; timer.setInterval(100); + + bool modalSeen = false; + bool dialogAccepted = false; + connect(&timer, &QTimer::timeout, this, [&]() { - if (auto activeModal - = qobject_cast(QApplication::activeModalWidget())) { - activeModal->setPort(serverUrl.port()); - activeModal->accept(); + if (QWidget *activeModal = QApplication::activeModalWidget()) { + modalSeen = true; + auto dialog = qobject_cast(activeModal); + if (dialog) { + dialog->setPort(serverUrl.port()); + dialog->accept(); + dialogAccepted = true; + } else { + qWarning() << "Some other modal widget popped up:" << activeModal; + QFAIL("Interference from unrelated code."); + } } }); @@ -83,6 +94,8 @@ void QmlProfilerToolTest::testAttachToWaitingApplication() QTRY_VERIFY(connection); QTRY_VERIFY(runControl->isRunning()); + QTRY_VERIFY(modalSeen); + QTRY_VERIFY(dialogAccepted); QTRY_VERIFY(profilerTool.clientManager()->isConnected()); connection.reset();