forked from qt-creator/qt-creator
AutoTest: Tweak run after successful build
Make it possible to distinguish between all and selected test cases also for the automatic run after build feature. Change-Id: I91715a7ae4f09cea2e31844940a6b21ae9e62157 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -29,7 +29,6 @@
|
||||
#include "testprojectsettings.h"
|
||||
|
||||
#include <QBoxLayout>
|
||||
#include <QCheckBox>
|
||||
#include <QComboBox>
|
||||
#include <QLabel>
|
||||
#include <QTreeWidget>
|
||||
@@ -61,12 +60,19 @@ ProjectTestSettingsWidget::ProjectTestSettingsWidget(ProjectExplorer::Project *p
|
||||
m_activeFrameworks->setRootIsDecorated(false);
|
||||
groupBoxLayout->addWidget(new QLabel(tr("Active frameworks:")));
|
||||
groupBoxLayout->addWidget(m_activeFrameworks);
|
||||
m_runAfterBuild = new QCheckBox(tr("Automatically run after build"));
|
||||
m_runAfterBuild->setChecked(m_projectSettings->runAfterBuild());
|
||||
groupBoxLayout->addWidget(m_runAfterBuild);
|
||||
auto horizontalLayout = new QHBoxLayout;
|
||||
horizontalLayout->addWidget(new QLabel(tr("Automatically run tests after build")));
|
||||
m_runAfterBuild = new QComboBox;
|
||||
m_runAfterBuild->addItem(tr("None"));
|
||||
m_runAfterBuild->addItem(tr("All"));
|
||||
m_runAfterBuild->addItem(tr("Selected"));
|
||||
m_runAfterBuild->setCurrentIndex(int(m_projectSettings->runAfterBuild()));
|
||||
horizontalLayout->addWidget(m_runAfterBuild);
|
||||
horizontalLayout->addItem(createSpacer(QSizePolicy::Expanding, QSizePolicy::Minimum));
|
||||
groupBoxLayout->addLayout(horizontalLayout);
|
||||
generalWidget->setLayout(groupBoxLayout);
|
||||
|
||||
auto horizontalLayout = new QHBoxLayout;
|
||||
horizontalLayout = new QHBoxLayout;
|
||||
horizontalLayout->addWidget(m_useGlobalSettings);
|
||||
horizontalLayout->addItem(createSpacer(QSizePolicy::Expanding, QSizePolicy::Minimum));
|
||||
verticalLayout->addLayout(horizontalLayout);
|
||||
@@ -90,8 +96,10 @@ ProjectTestSettingsWidget::ProjectTestSettingsWidget(ProjectExplorer::Project *p
|
||||
});
|
||||
connect(m_activeFrameworks, &QTreeWidget::itemChanged,
|
||||
this, &ProjectTestSettingsWidget::onActiveFrameworkChanged);
|
||||
connect(m_runAfterBuild, &QCheckBox::toggled,
|
||||
m_projectSettings, &TestProjectSettings::setRunAfterBuild);
|
||||
connect(m_runAfterBuild, QOverload<int>::of(&QComboBox::currentIndexChanged),
|
||||
this, [this](int index) {
|
||||
m_projectSettings->setRunAfterBuild(RunAfterBuildMode(index));
|
||||
});
|
||||
m_syncFrameworksTimer.setSingleShot(true);
|
||||
connect(&m_syncFrameworksTimer, &QTimer::timeout,
|
||||
TestTreeModel::instance(), &TestTreeModel::synchronizeTestFrameworks);
|
||||
|
@@ -29,7 +29,6 @@
|
||||
#include <QWidget>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QCheckBox;
|
||||
class QComboBox;
|
||||
class QTreeWidget;
|
||||
class QTreeWidgetItem;
|
||||
@@ -55,7 +54,7 @@ private:
|
||||
TestProjectSettings *m_projectSettings;
|
||||
QComboBox *m_useGlobalSettings = nullptr;
|
||||
QTreeWidget *m_activeFrameworks = nullptr;
|
||||
QCheckBox *m_runAfterBuild = nullptr;
|
||||
QComboBox *m_runAfterBuild = nullptr;
|
||||
QTimer m_syncFrameworksTimer;
|
||||
};
|
||||
|
||||
|
@@ -88,7 +88,8 @@ void TestProjectSettings::load()
|
||||
}
|
||||
|
||||
const QVariant runAfterBuild = m_project->namedSettings(SK_RUN_AFTER_BUILD);
|
||||
m_runAfterBuild = runAfterBuild.isValid() ? runAfterBuild.toBool() : false;
|
||||
m_runAfterBuild = runAfterBuild.isValid() ? RunAfterBuildMode(runAfterBuild.toInt())
|
||||
: RunAfterBuildMode::None;
|
||||
}
|
||||
|
||||
void TestProjectSettings::save()
|
||||
@@ -99,7 +100,7 @@ void TestProjectSettings::save()
|
||||
for (auto it = m_activeTestFrameworks.cbegin(); it != end; ++it)
|
||||
activeFrameworks.insert(it.key().toString(), it.value());
|
||||
m_project->setNamedSettings(SK_ACTIVE_FRAMEWORKS, activeFrameworks);
|
||||
m_project->setNamedSettings(SK_RUN_AFTER_BUILD, m_runAfterBuild);
|
||||
m_project->setNamedSettings(SK_RUN_AFTER_BUILD, int(m_runAfterBuild));
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -25,6 +25,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "testsettings.h"
|
||||
|
||||
#include <projectexplorer/project.h>
|
||||
|
||||
namespace Autotest {
|
||||
@@ -39,8 +41,8 @@ public:
|
||||
|
||||
void setUseGlobalSettings(bool useGlobal);
|
||||
bool useGlobalSettings() const { return m_useGlobalSettings; }
|
||||
void setRunAfterBuild(bool enabled) {m_runAfterBuild = enabled; }
|
||||
bool runAfterBuild() const { return m_runAfterBuild; }
|
||||
void setRunAfterBuild(RunAfterBuildMode mode) {m_runAfterBuild = mode; }
|
||||
RunAfterBuildMode runAfterBuild() const { return m_runAfterBuild; }
|
||||
void setActiveFrameworks(const QMap<Core::Id, bool> enabledFrameworks)
|
||||
{ m_activeTestFrameworks = enabledFrameworks; }
|
||||
QMap<Core::Id, bool> activeFrameworks() const { return m_activeTestFrameworks; }
|
||||
@@ -51,7 +53,7 @@ private:
|
||||
|
||||
ProjectExplorer::Project *m_project;
|
||||
bool m_useGlobalSettings = true;
|
||||
bool m_runAfterBuild = false;
|
||||
RunAfterBuildMode m_runAfterBuild = RunAfterBuildMode::None;
|
||||
QMap<Core::Id, bool> m_activeTestFrameworks;
|
||||
};
|
||||
|
||||
|
@@ -674,11 +674,11 @@ void TestRunner::buildFinished(bool success)
|
||||
}
|
||||
}
|
||||
|
||||
static bool runAfterBuild()
|
||||
static RunAfterBuildMode runAfterBuild()
|
||||
{
|
||||
Project *project = SessionManager::startupProject();
|
||||
if (!project)
|
||||
return false;
|
||||
return RunAfterBuildMode::None;
|
||||
|
||||
if (!project->namedSettings(Constants::SK_USE_GLOBAL).isValid())
|
||||
return AutotestPlugin::settings()->runAfterBuild;
|
||||
@@ -696,14 +696,16 @@ void TestRunner::onBuildQueueFinished(bool success)
|
||||
if (!success || m_runMode != TestRunMode::None)
|
||||
return;
|
||||
|
||||
if (!runAfterBuild())
|
||||
RunAfterBuildMode mode = runAfterBuild();
|
||||
if (mode == RunAfterBuildMode::None)
|
||||
return;
|
||||
|
||||
auto testTreeModel = TestTreeModel::instance();
|
||||
if (!testTreeModel->hasTests())
|
||||
return;
|
||||
|
||||
setSelectedTests(testTreeModel->getAllTestCases());
|
||||
setSelectedTests(mode == RunAfterBuildMode::All ? testTreeModel->getAllTestCases()
|
||||
: testTreeModel->getSelectedTests());
|
||||
prepareToRunTests(TestRunMode::RunAfterBuild);
|
||||
}
|
||||
|
||||
|
@@ -67,7 +67,7 @@ void TestSettings::toSettings(QSettings *s) const
|
||||
s->setValue(popupOnStartKey, popupOnStart);
|
||||
s->setValue(popupOnFinishKey, popupOnFinish);
|
||||
s->setValue(popupOnFailKey, popupOnFail);
|
||||
s->setValue(runAfterBuildKey, runAfterBuild);
|
||||
s->setValue(runAfterBuildKey, int(runAfterBuild));
|
||||
// store frameworks and their current active and grouping state
|
||||
for (const Core::Id &id : frameworks.keys()) {
|
||||
s->setValue(QLatin1String(id.name()), frameworks.value(id));
|
||||
@@ -89,7 +89,8 @@ void TestSettings::fromSettings(QSettings *s)
|
||||
popupOnStart = s->value(popupOnStartKey, true).toBool();
|
||||
popupOnFinish = s->value(popupOnFinishKey, true).toBool();
|
||||
popupOnFail = s->value(popupOnFailKey, false).toBool();
|
||||
runAfterBuild = s->value(runAfterBuildKey, false).toBool();
|
||||
runAfterBuild = RunAfterBuildMode(s->value(runAfterBuildKey,
|
||||
int(RunAfterBuildMode::None)).toInt());
|
||||
// try to get settings for registered frameworks
|
||||
TestFrameworkManager *frameworkManager = TestFrameworkManager::instance();
|
||||
const QList<Core::Id> ®istered = frameworkManager->registeredFrameworkIds();
|
||||
|
@@ -36,6 +36,13 @@ QT_END_NAMESPACE
|
||||
namespace Autotest {
|
||||
namespace Internal {
|
||||
|
||||
enum class RunAfterBuildMode
|
||||
{
|
||||
None,
|
||||
All,
|
||||
Selected
|
||||
};
|
||||
|
||||
struct TestSettings
|
||||
{
|
||||
TestSettings();
|
||||
@@ -52,7 +59,7 @@ struct TestSettings
|
||||
bool popupOnStart = true;
|
||||
bool popupOnFinish = true;
|
||||
bool popupOnFail = false;
|
||||
bool runAfterBuild = false;
|
||||
RunAfterBuildMode runAfterBuild = RunAfterBuildMode::None;
|
||||
QHash<Core::Id, bool> frameworks;
|
||||
QHash<Core::Id, bool> frameworksGrouping;
|
||||
};
|
||||
|
@@ -69,7 +69,7 @@ void TestSettingsWidget::setSettings(const TestSettings &settings)
|
||||
m_ui.openResultsOnStartCB->setChecked(settings.popupOnStart);
|
||||
m_ui.openResultsOnFinishCB->setChecked(settings.popupOnFinish);
|
||||
m_ui.openResultsOnFailCB->setChecked(settings.popupOnFail);
|
||||
m_ui.runAfterBuildCB->setChecked(settings.runAfterBuild);
|
||||
m_ui.runAfterBuildCB->setCurrentIndex(int(settings.runAfterBuild));
|
||||
populateFrameworksListWidget(settings.frameworks);
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ TestSettings TestSettingsWidget::settings() const
|
||||
result.popupOnStart = m_ui.openResultsOnStartCB->isChecked();
|
||||
result.popupOnFinish = m_ui.openResultsOnFinishCB->isChecked();
|
||||
result.popupOnFail = m_ui.openResultsOnFailCB->isChecked();
|
||||
result.runAfterBuild = m_ui.runAfterBuildCB->isChecked();
|
||||
result.runAfterBuild = RunAfterBuildMode(m_ui.runAfterBuildCB->currentIndex());
|
||||
frameworkSettings(result);
|
||||
return result;
|
||||
}
|
||||
|
@@ -145,14 +145,50 @@ Warning: this is an experimental feature and might lead to failing to execute th
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="runAfterBuildCB">
|
||||
<property name="toolTip">
|
||||
<string>Runs all tests automatically if a build succeeded.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Automatically run after build</string>
|
||||
</property>
|
||||
</widget>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_8">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Automatically run</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="runAfterBuildCB">
|
||||
<property name="toolTip">
|
||||
<string>Runs chosen tests automatically if a build succeeded.</string>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>None</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>All</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Selected</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2" stretch="0,0,0">
|
||||
|
Reference in New Issue
Block a user