diff --git a/plugins/autotest/autotest.qrc b/plugins/autotest/autotest.qrc
index b4b47f100f6..fe59718a584 100644
--- a/plugins/autotest/autotest.qrc
+++ b/plugins/autotest/autotest.qrc
@@ -16,5 +16,6 @@
images/xpass.png
images/run.png
images/runselected.png
+ images/stop.png
diff --git a/plugins/autotest/images/stop.png b/plugins/autotest/images/stop.png
new file mode 100644
index 00000000000..1063d089985
Binary files /dev/null and b/plugins/autotest/images/stop.png differ
diff --git a/plugins/autotest/testconfiguration.cpp b/plugins/autotest/testconfiguration.cpp
index 22037989233..4841a86fbfe 100644
--- a/plugins/autotest/testconfiguration.cpp
+++ b/plugins/autotest/testconfiguration.cpp
@@ -24,12 +24,16 @@ namespace Autotest {
namespace Internal {
TestConfiguration::TestConfiguration(const QString &testClass, const QStringList &testCases,
- QObject *parent)
+ int testCaseCount, QObject *parent)
: QObject(parent),
m_testClass(testClass),
m_testCases(testCases),
+ m_testCaseCount(testCaseCount),
m_project(0)
{
+ if (testCases.size() != 0) {
+ m_testCaseCount = testCases.size();
+ }
}
TestConfiguration::~TestConfiguration()
diff --git a/plugins/autotest/testconfiguration.h b/plugins/autotest/testconfiguration.h
index fa9545157b4..aab9d31db67 100644
--- a/plugins/autotest/testconfiguration.h
+++ b/plugins/autotest/testconfiguration.h
@@ -37,7 +37,7 @@ class TestConfiguration : public QObject
Q_OBJECT
public:
explicit TestConfiguration(const QString &testClass, const QStringList &testCases,
- QObject *parent = 0);
+ int testCaseCount = 0, QObject *parent = 0);
~TestConfiguration();
void setTargetFile(const QString &targetFile);
@@ -49,6 +49,7 @@ public:
QString testClass() const { return m_testClass; }
QStringList testCases() const { return m_testCases; }
+ int testCaseCount() const { return m_testCaseCount; }
QString proFile() const { return m_proFile; }
QString targetFile() const { return m_targetFile; }
QString targetName() const { return m_targetName; }
@@ -64,6 +65,7 @@ public slots:
private:
QString m_testClass;
QStringList m_testCases;
+ int m_testCaseCount;
QString m_proFile;
QString m_targetFile;
QString m_targetName;
diff --git a/plugins/autotest/testresultspane.cpp b/plugins/autotest/testresultspane.cpp
index 244b775f93c..5deb34803e0 100644
--- a/plugins/autotest/testresultspane.cpp
+++ b/plugins/autotest/testresultspane.cpp
@@ -52,6 +52,10 @@ TestResultsPane::TestResultsPane(QObject *parent) :
connect(m_listView, &Utils::ListView::activated, this, &TestResultsPane::onItemActivated);
connect(m_listView->selectionModel(), &QItemSelectionModel::currentChanged,
trd, &TestResultDelegate::currentChanged);
+ connect(TestRunner::instance(), &TestRunner::testRunStarted,
+ this, &TestResultsPane::onTestRunStarted);
+ connect(TestRunner::instance(), &TestRunner::testRunFinished,
+ this, &TestResultsPane::onTestRunFinished);
}
void TestResultsPane::createToolButtons()
@@ -66,6 +70,12 @@ void TestResultsPane::createToolButtons()
m_runSelected->setToolTip(tr("Run Selected Tests"));
connect(m_runSelected, &QToolButton::clicked, this, &TestResultsPane::onRunSelectedTriggered);
+ m_stopTestRun = new QToolButton(m_listView);
+ m_stopTestRun->setIcon(QIcon(QLatin1String(":/images/stop.png")));
+ m_stopTestRun->setToolTip(tr("Stop Test Run"));
+ m_stopTestRun->setEnabled(false);
+ connect(m_stopTestRun, &QToolButton::clicked, TestRunner::instance(), &TestRunner::stopTestRun);
+
m_filterButton = new QToolButton(m_listView);
m_filterButton->setIcon(QIcon(QLatin1String(Core::Constants::ICON_FILTER)));
m_filterButton->setToolTip(tr("Filter Test Results"));
@@ -114,7 +124,7 @@ QWidget *TestResultsPane::outputWidget(QWidget *parent)
QList TestResultsPane::toolBarWidgets() const
{
- return QList() << m_runAll << m_runSelected << m_filterButton;
+ return QList() << m_runAll << m_runSelected << m_stopTestRun << m_filterButton;
}
QString TestResultsPane::displayName() const
@@ -254,5 +264,19 @@ void TestResultsPane::filterMenuTriggered(QAction *action)
navigateStateChanged();
}
+void TestResultsPane::onTestRunStarted()
+{
+ m_stopTestRun->setEnabled(true);
+ m_runAll->setEnabled(false);
+ m_runSelected->setEnabled(false);
+}
+
+void TestResultsPane::onTestRunFinished()
+{
+ m_stopTestRun->setEnabled(false);
+ m_runAll->setEnabled(true);
+ m_runSelected->setEnabled(true);
+}
+
} // namespace Internal
} // namespace Autotest
diff --git a/plugins/autotest/testresultspane.h b/plugins/autotest/testresultspane.h
index 86936223ac1..6f3df33e5c9 100644
--- a/plugins/autotest/testresultspane.h
+++ b/plugins/autotest/testresultspane.h
@@ -82,6 +82,8 @@ private slots:
private:
explicit TestResultsPane(QObject *parent = 0);
void createToolButtons();
+ void onTestRunStarted();
+ void onTestRunFinished();
Utils::ListView *m_listView;
TestResultModel *m_model;
@@ -89,6 +91,7 @@ private:
Core::IContext *m_context;
QToolButton *m_runAll;
QToolButton *m_runSelected;
+ QToolButton *m_stopTestRun;
QToolButton *m_filterButton;
QMenu *m_filterMenu;
};
diff --git a/plugins/autotest/testrunner.cpp b/plugins/autotest/testrunner.cpp
index fe73cd91e8b..ded6fab9f1e 100644
--- a/plugins/autotest/testrunner.cpp
+++ b/plugins/autotest/testrunner.cpp
@@ -104,10 +104,16 @@ void TestRunner::runTests()
}
}
+ int testCaseCount = 0;
+ foreach (const TestConfiguration *config, m_selectedTests)
+ testCaseCount += config->testCaseCount();
+
// clear old log and output pane
m_xmlLog.clear();
TestResultsPane::instance()->clearContents();
+ emit testRunStarted();
+
foreach (TestConfiguration *tc, m_selectedTests) {
QString cmd = tc->targetFile();
QString workDir = tc->workingDirectory();
@@ -121,11 +127,18 @@ void TestRunner::runTests()
exec(cmd, args, workDir, env);
}
qDebug("test run finished");
+ emit testRunFinished();
}
void TestRunner::stopTestRun()
{
-
+ if (m_runner.state() != QProcess::NotRunning) {
+ m_runner.kill();
+ m_runner.waitForFinished();
+ TestResultsPane::instance()->addTestResult(
+ TestResult(QString(), QString(), QString(), ResultType::MESSAGE_FATAL,
+ tr("*** Test Run canceled by user ***")));
+ }
}
/******************** XML line parser helper ********************/
diff --git a/plugins/autotest/testrunner.h b/plugins/autotest/testrunner.h
index 48f674716d2..6ed530d05cb 100644
--- a/plugins/autotest/testrunner.h
+++ b/plugins/autotest/testrunner.h
@@ -43,6 +43,8 @@ public:
void setSelectedTests(const QList &selected);
signals:
+ void testRunStarted();
+ void testRunFinished();
public slots:
void runTests();
diff --git a/plugins/autotest/testtreemodel.cpp b/plugins/autotest/testtreemodel.cpp
index a0aff69744b..39b42ba5b97 100644
--- a/plugins/autotest/testtreemodel.cpp
+++ b/plugins/autotest/testtreemodel.cpp
@@ -305,7 +305,8 @@ QList TestTreeModel::getAllTestCases() const
for (int row = 0; row < count; ++row) {
TestTreeItem *child = m_autoTestRootItem->child(row);
- TestConfiguration *tc = new TestConfiguration(child->name(), QStringList());
+ TestConfiguration *tc = new TestConfiguration(child->name(), QStringList(),
+ child->childCount());
addProjectInformation(tc, child->filePath());
result << tc;
}
@@ -325,7 +326,7 @@ QList TestTreeModel::getSelectedTests() const
case Qt::Unchecked:
continue;
case Qt::Checked:
- tc = new TestConfiguration(child->name(), QStringList());
+ tc = new TestConfiguration(child->name(), QStringList(), child->childCount());
addProjectInformation(tc, child->filePath());
result << tc;
continue;