diff --git a/src/plugins/qmlprofiler/tests/localqmlprofilerrunner_test.cpp b/src/plugins/qmlprofiler/tests/localqmlprofilerrunner_test.cpp index 02518658f3c..830b7101e26 100644 --- a/src/plugins/qmlprofiler/tests/localqmlprofilerrunner_test.cpp +++ b/src/plugins/qmlprofiler/tests/localqmlprofilerrunner_test.cpp @@ -37,6 +37,17 @@ LocalQmlProfilerRunnerTest::LocalQmlProfilerRunnerTest(QObject *parent) : QObjec { } +bool checkErrors(const QStringList &errors, int number) +{ + if (errors.length() != number) { + qDebug() << "Found unexpected errors:" << errors; + return false; + } else { + return true; + } +} + + void LocalQmlProfilerRunnerTest::testRunner() { Debugger::AnalyzerConnection connection; @@ -53,7 +64,7 @@ void LocalQmlProfilerRunnerTest::testRunner() bool running = false; int runCount = 0; - int errors = 0; + QStringList errors; auto connectRunner = [&]() { connect(runner, &LocalQmlProfilerRunner::started, this, [&running, &runCount](){ @@ -68,10 +79,9 @@ void LocalQmlProfilerRunnerTest::testRunner() connect(runner, &LocalQmlProfilerRunner::appendMessage, this, [&errors](const QString &message, Utils::OutputFormat format) { - Q_UNUSED(message); if (format == Utils::ErrorMessageFormat && message != ProjectExplorer::ApplicationLauncher::msgWinCannotRetrieveDebuggingOutput()) - ++errors; + errors << message; }); }; @@ -81,7 +91,7 @@ void LocalQmlProfilerRunnerTest::testRunner() QTRY_COMPARE_WITH_TIMEOUT(runCount, 1, 10000); QTRY_VERIFY_WITH_TIMEOUT(!running, 10000); - QCOMPARE(errors, 1); + QVERIFY(checkErrors(errors, 1)); configuration.socket = connection.analyzerSocket = LocalQmlProfilerRunner::findFreeSocket(); configuration.debuggee.executable = qApp->applicationFilePath(); @@ -99,7 +109,7 @@ void LocalQmlProfilerRunnerTest::testRunner() QTRY_COMPARE_WITH_TIMEOUT(runCount, 2, 10000); QTRY_VERIFY_WITH_TIMEOUT(!running, 10000); - QCOMPARE(errors, 1); + QVERIFY(checkErrors(errors, 1)); delete rc; @@ -118,11 +128,11 @@ void LocalQmlProfilerRunnerTest::testRunner() QTRY_COMPARE_WITH_TIMEOUT(runCount, 3, 10000); QTest::qWait(1000); QVERIFY(running); // verify it doesn't spontaneously stop - QCOMPARE(errors, 1); + QVERIFY(checkErrors(errors, 1)); rc->stop(); QTRY_VERIFY_WITH_TIMEOUT(!running, 10000); - QCOMPARE(errors, 2); // "The program has unexpectedly finished." + QVERIFY(checkErrors(errors, 2)); // "The program has unexpectedly finished." delete rc; }