QmlProfiler: Make the tool test more robust

Apparently there is a different message box that commonly pops up while
we are waiting for the attach dialog. Just close it and try again. Also,
stop the timer once we have seen the dialog. Otherwise we might fail on
extra message boxes that pop up afterwards.

Change-Id: I06ae16eb3ad89c9a022ac6fae781f8465425d96f
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
Ulf Hermann
2018-10-05 09:14:47 +02:00
parent e8f28dbef3
commit bc2260ab29

View File

@@ -71,8 +71,6 @@ void QmlProfilerToolTest::testAttachToWaitingApplication()
timer.setInterval(100); timer.setInterval(100);
bool modalSeen = false; bool modalSeen = false;
bool dialogAccepted = false;
connect(&timer, &QTimer::timeout, this, [&]() { connect(&timer, &QTimer::timeout, this, [&]() {
if (QWidget *activeModal = QApplication::activeModalWidget()) { if (QWidget *activeModal = QApplication::activeModalWidget()) {
modalSeen = true; modalSeen = true;
@@ -80,10 +78,10 @@ void QmlProfilerToolTest::testAttachToWaitingApplication()
if (dialog) { if (dialog) {
dialog->setPort(serverUrl.port()); dialog->setPort(serverUrl.port());
dialog->accept(); dialog->accept();
dialogAccepted = true; timer.stop();
} else { } else {
qWarning() << "Some other modal widget popped up:" << activeModal; qWarning() << "Some other modal widget popped up:" << activeModal;
QFAIL("Interference from unrelated code."); activeModal->close();
} }
} }
}); });
@@ -95,7 +93,7 @@ void QmlProfilerToolTest::testAttachToWaitingApplication()
QTRY_VERIFY(connection); QTRY_VERIFY(connection);
QTRY_VERIFY(runControl->isRunning()); QTRY_VERIFY(runControl->isRunning());
QTRY_VERIFY(modalSeen); QTRY_VERIFY(modalSeen);
QTRY_VERIFY(dialogAccepted); QTRY_VERIFY(!timer.isActive());
QTRY_VERIFY(profilerTool.clientManager()->isConnected()); QTRY_VERIFY(profilerTool.clientManager()->isConnected());
connection.reset(); connection.reset();