diff --git a/src/plugins/autotest/autotestplugin.cpp b/src/plugins/autotest/autotestplugin.cpp index 9a513bd2d48..2c367828443 100644 --- a/src/plugins/autotest/autotestplugin.cpp +++ b/src/plugins/autotest/autotestplugin.cpp @@ -349,6 +349,12 @@ void AutotestPlugin::clearChoiceCache() s_instance->m_runconfigCache.clear(); } +void AutotestPlugin::popupResultsPane() +{ + if (s_instance) + s_instance->m_resultsPane->popup(Core::IOutputPane::NoModeSwitch); +} + QList AutotestPlugin::createTestObjects() const { QList tests; diff --git a/src/plugins/autotest/autotestplugin.h b/src/plugins/autotest/autotestplugin.h index dcbdb5ddde1..fe628c9dad6 100644 --- a/src/plugins/autotest/autotestplugin.h +++ b/src/plugins/autotest/autotestplugin.h @@ -71,6 +71,7 @@ public: static void cacheRunConfigChoice(const QString &buildTargetKey, const ChoicePair &choice); static ChoicePair cachedChoiceFor(const QString &buildTargetKey); static void clearChoiceCache(); + static void popupResultsPane(); private: void initializeMenuEntries(); diff --git a/src/plugins/autotest/testresultspane.cpp b/src/plugins/autotest/testresultspane.cpp index c036ad431a3..1f10eac7d46 100644 --- a/src/plugins/autotest/testresultspane.cpp +++ b/src/plugins/autotest/testresultspane.cpp @@ -509,6 +509,13 @@ void TestResultsPane::onTestRunStarted() m_summaryWidget->setVisible(false); } +static bool hasFailedTests(const TestResultModel *model) +{ + return (model->resultTypeCount(Result::Fail) > 0 + || model->resultTypeCount(Result::MessageFatal) > 0 + || model->resultTypeCount(Result::UnexpectedPass) > 0); +} + void TestResultsPane::onTestRunFinished() { m_testRunning = false; @@ -520,8 +527,10 @@ void TestResultsPane::onTestRunFinished() m_model->removeCurrentTestMessage(); disconnect(m_treeView->verticalScrollBar(), &QScrollBar::rangeChanged, this, &TestResultsPane::onScrollBarRangeChanged); - if (!m_treeView->isVisible()) + if (AutotestPlugin::settings()->popupOnFinish + && (!AutotestPlugin::settings()->popupOnFail || hasFailedTests(m_model))) { popup(Core::IOutputPane::NoModeSwitch); + } createMarks(); } diff --git a/src/plugins/autotest/testrunner.cpp b/src/plugins/autotest/testrunner.cpp index 876c7bfb2ee..45f7c2c52a4 100644 --- a/src/plugins/autotest/testrunner.cpp +++ b/src/plugins/autotest/testrunner.cpp @@ -464,6 +464,8 @@ void TestRunner::runTests() m_futureWatcher.setFuture(future); Core::ProgressManager::addTask(future, tr("Running Tests"), Autotest::Constants::TASK_INDEX); + if (AutotestPlugin::settings()->popupOnStart) + AutotestPlugin::popupResultsPane(); scheduleNext(); } @@ -603,6 +605,8 @@ void TestRunner::debugTests() connect(runControl, &ProjectExplorer::RunControl::stopped, this, &TestRunner::onFinished); ProjectExplorer::ProjectExplorerPlugin::startRunControl(runControl); + if (useOutputProcessor && AutotestPlugin::settings()->popupOnStart) + AutotestPlugin::popupResultsPane(); } void TestRunner::runOrDebugTests() diff --git a/src/plugins/autotest/testsettings.cpp b/src/plugins/autotest/testsettings.cpp index 49e028d41da..ddb4f49e81b 100644 --- a/src/plugins/autotest/testsettings.cpp +++ b/src/plugins/autotest/testsettings.cpp @@ -41,6 +41,9 @@ static const char limitResultOutputKey[] = "LimitResultOutput"; static const char autoScrollKey[] = "AutoScrollResults"; static const char processArgsKey[] = "ProcessArgs"; static const char displayApplicationKey[] = "DisplayApp"; +static const char popupOnStartKey[] = "PopupOnStart"; +static const char popupOnFinishKey[] = "PopupOnFinish"; +static const char popupOnFailKey[] = "PopupOnFail"; static const char groupSuffix[] = ".group"; constexpr int defaultTimeout = 60000; @@ -60,6 +63,9 @@ void TestSettings::toSettings(QSettings *s) const s->setValue(autoScrollKey, autoScroll); s->setValue(processArgsKey, processArgs); s->setValue(displayApplicationKey, displayApplication); + s->setValue(popupOnStartKey, popupOnStart); + s->setValue(popupOnFinishKey, popupOnFinish); + s->setValue(popupOnFailKey, popupOnFail); // store frameworks and their current active and grouping state for (const Core::Id &id : frameworks.keys()) { s->setValue(QLatin1String(id.name()), frameworks.value(id)); @@ -78,6 +84,9 @@ void TestSettings::fromSettings(QSettings *s) autoScroll = s->value(autoScrollKey, true).toBool(); processArgs = s->value(processArgsKey, false).toBool(); displayApplication = s->value(displayApplicationKey, false).toBool(); + popupOnStart = s->value(popupOnStartKey, true).toBool(); + popupOnFinish = s->value(popupOnFinishKey, true).toBool(); + popupOnFail = s->value(popupOnFailKey, false).toBool(); // try to get settings for registered frameworks TestFrameworkManager *frameworkManager = TestFrameworkManager::instance(); const QList ®istered = frameworkManager->registeredFrameworkIds(); diff --git a/src/plugins/autotest/testsettings.h b/src/plugins/autotest/testsettings.h index 3f41a8c1398..92c4ef99337 100644 --- a/src/plugins/autotest/testsettings.h +++ b/src/plugins/autotest/testsettings.h @@ -49,6 +49,9 @@ struct TestSettings bool autoScroll = true; bool processArgs = false; bool displayApplication = false; + bool popupOnStart = true; + bool popupOnFinish = true; + bool popupOnFail = false; QHash frameworks; QHash frameworksGrouping; }; diff --git a/src/plugins/autotest/testsettingspage.cpp b/src/plugins/autotest/testsettingspage.cpp index 709c9685c09..169bab7320c 100644 --- a/src/plugins/autotest/testsettingspage.cpp +++ b/src/plugins/autotest/testsettingspage.cpp @@ -53,6 +53,8 @@ TestSettingsWidget::TestSettingsWidget(QWidget *parent) this, &TestSettingsWidget::onFrameworkItemChanged); connect(m_ui.resetChoicesButton, &QPushButton::clicked, this, [] { AutotestPlugin::clearChoiceCache(); }); + connect(m_ui.openResultsOnFinishCB, &QCheckBox::toggled, + m_ui.openResultsOnFailCB, &QCheckBox::setEnabled); } void TestSettingsWidget::setSettings(const TestSettings &settings) @@ -64,6 +66,9 @@ void TestSettingsWidget::setSettings(const TestSettings &settings) m_ui.autoScrollCB->setChecked(settings.autoScroll); m_ui.processArgsCB->setChecked(settings.processArgs); m_ui.displayAppCB->setChecked(settings.displayApplication); + m_ui.openResultsOnStartCB->setChecked(settings.popupOnStart); + m_ui.openResultsOnFinishCB->setChecked(settings.popupOnFinish); + m_ui.openResultsOnFailCB->setChecked(settings.popupOnFail); populateFrameworksListWidget(settings.frameworks); } @@ -77,6 +82,9 @@ TestSettings TestSettingsWidget::settings() const result.autoScroll = m_ui.autoScrollCB->isChecked(); result.processArgs = m_ui.processArgsCB->isChecked(); result.displayApplication = m_ui.displayAppCB->isChecked(); + result.popupOnStart = m_ui.openResultsOnStartCB->isChecked(); + result.popupOnFinish = m_ui.openResultsOnFinishCB->isChecked(); + result.popupOnFail = m_ui.openResultsOnFailCB->isChecked(); frameworkSettings(result); return result; } diff --git a/src/plugins/autotest/testsettingspage.ui b/src/plugins/autotest/testsettingspage.ui index 53c85920373..cb65055bc36 100644 --- a/src/plugins/autotest/testsettingspage.ui +++ b/src/plugins/autotest/testsettingspage.ui @@ -6,8 +6,8 @@ 0 0 - 585 - 357 + 586 + 429 @@ -60,6 +60,59 @@ + + + + Opens the test results pane automatically when tests are started. + + + Open results pane when tests start + + + + + + + Opens the test result pane automatically when tests are finished. + + + Open results pane when tests finish + + + true + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 10 + + + + + + + + Opens the test result pane only if the test run contains failed, fatal or unexpectedly passed tests. + + + Only for unsuccessful test runs + + + + +