forked from qt-creator/qt-creator
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:
@@ -349,6 +349,12 @@ void AutotestPlugin::clearChoiceCache()
|
|||||||
s_instance->m_runconfigCache.clear();
|
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 *> AutotestPlugin::createTestObjects() const
|
||||||
{
|
{
|
||||||
QList<QObject *> tests;
|
QList<QObject *> tests;
|
||||||
|
@@ -71,6 +71,7 @@ public:
|
|||||||
static void cacheRunConfigChoice(const QString &buildTargetKey, const ChoicePair &choice);
|
static void cacheRunConfigChoice(const QString &buildTargetKey, const ChoicePair &choice);
|
||||||
static ChoicePair cachedChoiceFor(const QString &buildTargetKey);
|
static ChoicePair cachedChoiceFor(const QString &buildTargetKey);
|
||||||
static void clearChoiceCache();
|
static void clearChoiceCache();
|
||||||
|
static void popupResultsPane();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void initializeMenuEntries();
|
void initializeMenuEntries();
|
||||||
|
@@ -509,6 +509,13 @@ void TestResultsPane::onTestRunStarted()
|
|||||||
m_summaryWidget->setVisible(false);
|
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()
|
void TestResultsPane::onTestRunFinished()
|
||||||
{
|
{
|
||||||
m_testRunning = false;
|
m_testRunning = false;
|
||||||
@@ -520,8 +527,10 @@ void TestResultsPane::onTestRunFinished()
|
|||||||
m_model->removeCurrentTestMessage();
|
m_model->removeCurrentTestMessage();
|
||||||
disconnect(m_treeView->verticalScrollBar(), &QScrollBar::rangeChanged,
|
disconnect(m_treeView->verticalScrollBar(), &QScrollBar::rangeChanged,
|
||||||
this, &TestResultsPane::onScrollBarRangeChanged);
|
this, &TestResultsPane::onScrollBarRangeChanged);
|
||||||
if (!m_treeView->isVisible())
|
if (AutotestPlugin::settings()->popupOnFinish
|
||||||
|
&& (!AutotestPlugin::settings()->popupOnFail || hasFailedTests(m_model))) {
|
||||||
popup(Core::IOutputPane::NoModeSwitch);
|
popup(Core::IOutputPane::NoModeSwitch);
|
||||||
|
}
|
||||||
createMarks();
|
createMarks();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -464,6 +464,8 @@ void TestRunner::runTests()
|
|||||||
m_futureWatcher.setFuture(future);
|
m_futureWatcher.setFuture(future);
|
||||||
|
|
||||||
Core::ProgressManager::addTask(future, tr("Running Tests"), Autotest::Constants::TASK_INDEX);
|
Core::ProgressManager::addTask(future, tr("Running Tests"), Autotest::Constants::TASK_INDEX);
|
||||||
|
if (AutotestPlugin::settings()->popupOnStart)
|
||||||
|
AutotestPlugin::popupResultsPane();
|
||||||
scheduleNext();
|
scheduleNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -603,6 +605,8 @@ void TestRunner::debugTests()
|
|||||||
|
|
||||||
connect(runControl, &ProjectExplorer::RunControl::stopped, this, &TestRunner::onFinished);
|
connect(runControl, &ProjectExplorer::RunControl::stopped, this, &TestRunner::onFinished);
|
||||||
ProjectExplorer::ProjectExplorerPlugin::startRunControl(runControl);
|
ProjectExplorer::ProjectExplorerPlugin::startRunControl(runControl);
|
||||||
|
if (useOutputProcessor && AutotestPlugin::settings()->popupOnStart)
|
||||||
|
AutotestPlugin::popupResultsPane();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestRunner::runOrDebugTests()
|
void TestRunner::runOrDebugTests()
|
||||||
|
@@ -41,6 +41,9 @@ static const char limitResultOutputKey[] = "LimitResultOutput";
|
|||||||
static const char autoScrollKey[] = "AutoScrollResults";
|
static const char autoScrollKey[] = "AutoScrollResults";
|
||||||
static const char processArgsKey[] = "ProcessArgs";
|
static const char processArgsKey[] = "ProcessArgs";
|
||||||
static const char displayApplicationKey[] = "DisplayApp";
|
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";
|
static const char groupSuffix[] = ".group";
|
||||||
|
|
||||||
constexpr int defaultTimeout = 60000;
|
constexpr int defaultTimeout = 60000;
|
||||||
@@ -60,6 +63,9 @@ void TestSettings::toSettings(QSettings *s) const
|
|||||||
s->setValue(autoScrollKey, autoScroll);
|
s->setValue(autoScrollKey, autoScroll);
|
||||||
s->setValue(processArgsKey, processArgs);
|
s->setValue(processArgsKey, processArgs);
|
||||||
s->setValue(displayApplicationKey, displayApplication);
|
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
|
// store frameworks and their current active and grouping state
|
||||||
for (const Core::Id &id : frameworks.keys()) {
|
for (const Core::Id &id : frameworks.keys()) {
|
||||||
s->setValue(QLatin1String(id.name()), frameworks.value(id));
|
s->setValue(QLatin1String(id.name()), frameworks.value(id));
|
||||||
@@ -78,6 +84,9 @@ void TestSettings::fromSettings(QSettings *s)
|
|||||||
autoScroll = s->value(autoScrollKey, true).toBool();
|
autoScroll = s->value(autoScrollKey, true).toBool();
|
||||||
processArgs = s->value(processArgsKey, false).toBool();
|
processArgs = s->value(processArgsKey, false).toBool();
|
||||||
displayApplication = s->value(displayApplicationKey, 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
|
// try to get settings for registered frameworks
|
||||||
TestFrameworkManager *frameworkManager = TestFrameworkManager::instance();
|
TestFrameworkManager *frameworkManager = TestFrameworkManager::instance();
|
||||||
const QList<Core::Id> ®istered = frameworkManager->registeredFrameworkIds();
|
const QList<Core::Id> ®istered = frameworkManager->registeredFrameworkIds();
|
||||||
|
@@ -49,6 +49,9 @@ struct TestSettings
|
|||||||
bool autoScroll = true;
|
bool autoScroll = true;
|
||||||
bool processArgs = false;
|
bool processArgs = false;
|
||||||
bool displayApplication = false;
|
bool displayApplication = false;
|
||||||
|
bool popupOnStart = true;
|
||||||
|
bool popupOnFinish = true;
|
||||||
|
bool popupOnFail = false;
|
||||||
QHash<Core::Id, bool> frameworks;
|
QHash<Core::Id, bool> frameworks;
|
||||||
QHash<Core::Id, bool> frameworksGrouping;
|
QHash<Core::Id, bool> frameworksGrouping;
|
||||||
};
|
};
|
||||||
|
@@ -53,6 +53,8 @@ TestSettingsWidget::TestSettingsWidget(QWidget *parent)
|
|||||||
this, &TestSettingsWidget::onFrameworkItemChanged);
|
this, &TestSettingsWidget::onFrameworkItemChanged);
|
||||||
connect(m_ui.resetChoicesButton, &QPushButton::clicked,
|
connect(m_ui.resetChoicesButton, &QPushButton::clicked,
|
||||||
this, [] { AutotestPlugin::clearChoiceCache(); });
|
this, [] { AutotestPlugin::clearChoiceCache(); });
|
||||||
|
connect(m_ui.openResultsOnFinishCB, &QCheckBox::toggled,
|
||||||
|
m_ui.openResultsOnFailCB, &QCheckBox::setEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestSettingsWidget::setSettings(const TestSettings &settings)
|
void TestSettingsWidget::setSettings(const TestSettings &settings)
|
||||||
@@ -64,6 +66,9 @@ void TestSettingsWidget::setSettings(const TestSettings &settings)
|
|||||||
m_ui.autoScrollCB->setChecked(settings.autoScroll);
|
m_ui.autoScrollCB->setChecked(settings.autoScroll);
|
||||||
m_ui.processArgsCB->setChecked(settings.processArgs);
|
m_ui.processArgsCB->setChecked(settings.processArgs);
|
||||||
m_ui.displayAppCB->setChecked(settings.displayApplication);
|
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);
|
populateFrameworksListWidget(settings.frameworks);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,6 +82,9 @@ TestSettings TestSettingsWidget::settings() const
|
|||||||
result.autoScroll = m_ui.autoScrollCB->isChecked();
|
result.autoScroll = m_ui.autoScrollCB->isChecked();
|
||||||
result.processArgs = m_ui.processArgsCB->isChecked();
|
result.processArgs = m_ui.processArgsCB->isChecked();
|
||||||
result.displayApplication = m_ui.displayAppCB->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);
|
frameworkSettings(result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@@ -6,8 +6,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>585</width>
|
<width>586</width>
|
||||||
<height>357</height>
|
<height>429</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@@ -60,6 +60,59 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</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>
|
<item>
|
||||||
<widget class="QCheckBox" name="autoScrollCB">
|
<widget class="QCheckBox" name="autoScrollCB">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
|
Reference in New Issue
Block a user