AutoTest: Make automatic popup of results pane configurable

Let the test results pane automatically popup before the
first test result is added to indicate running the tests
has started.
Beside this provide settings for enabling or disabling
the popup of the results pane on start or finish of a
test run and make it possible to limit the automatic
popup on finish to failed test runs.

Change-Id: Ib22735536effd9f2330b39a7d2830c97839eb21f
Reviewed-by: André Hartmann <aha_1980@gmx.de>
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Christian Stenger
2019-03-13 11:05:22 +01:00
parent 5944c7f0f6
commit 6dee2dc019
8 changed files with 96 additions and 3 deletions

View File

@@ -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<QObject *> AutotestPlugin::createTestObjects() const
{
QList<QObject *> tests;

View File

@@ -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();

View File

@@ -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();
}

View File

@@ -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()

View File

@@ -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<Core::Id> &registered = frameworkManager->registeredFrameworkIds();

View File

@@ -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<Core::Id, bool> frameworks;
QHash<Core::Id, bool> frameworksGrouping;
};

View File

@@ -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;
}

View File

@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>585</width>
<height>357</height>
<width>586</width>
<height>429</height>
</rect>
</property>
<property name="windowTitle">
@@ -60,6 +60,59 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="openResultsOnStartCB">
<property name="toolTip">
<string>Opens the test results pane automatically when tests are started.</string>
</property>
<property name="text">
<string>Open results pane when tests start</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="openResultsOnFinishCB">
<property name="toolTip">
<string>Opens the test result pane automatically when tests are finished.</string>
</property>
<property name="text">
<string>Open results pane when tests finish</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>10</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QCheckBox" name="openResultsOnFailCB">
<property name="toolTip">
<string>Opens the test result pane only if the test run contains failed, fatal or unexpectedly passed tests.</string>
</property>
<property name="text">
<string>Only for unsuccessful test runs</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="autoScrollCB">
<property name="toolTip">