summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Stenger <christian.stenger@digia.com>2014-11-03 08:30:22 +0100
committerChristian Stenger <christian.stenger@theqtcompany.com>2014-12-04 13:52:15 +0100
commit431d15bd0caa70588c7118ef8c0b32850d08ab82 (patch)
tree5bb9b58aaff321bfacc0f3d752800f0f3535ca11
parent345b4de47a82916296e60643442e84cd737a2f8b (diff)
downloadqt-creator-431d15bd0caa70588c7118ef8c0b32850d08ab82.tar.gz
Add stop button and minor preparation for progress bar
-rw-r--r--plugins/autotest/autotest.qrc1
-rw-r--r--plugins/autotest/images/stop.pngbin0 -> 314 bytes
-rw-r--r--plugins/autotest/testconfiguration.cpp6
-rw-r--r--plugins/autotest/testconfiguration.h4
-rw-r--r--plugins/autotest/testresultspane.cpp26
-rw-r--r--plugins/autotest/testresultspane.h3
-rw-r--r--plugins/autotest/testrunner.cpp15
-rw-r--r--plugins/autotest/testrunner.h2
-rw-r--r--plugins/autotest/testtreemodel.cpp5
9 files changed, 56 insertions, 6 deletions
diff --git a/plugins/autotest/autotest.qrc b/plugins/autotest/autotest.qrc
index b4b47f100f..fe59718a58 100644
--- a/plugins/autotest/autotest.qrc
+++ b/plugins/autotest/autotest.qrc
@@ -16,5 +16,6 @@
<file>images/xpass.png</file>
<file>images/run.png</file>
<file>images/runselected.png</file>
+ <file>images/stop.png</file>
</qresource>
</RCC>
diff --git a/plugins/autotest/images/stop.png b/plugins/autotest/images/stop.png
new file mode 100644
index 0000000000..1063d08998
--- /dev/null
+++ b/plugins/autotest/images/stop.png
Binary files differ
diff --git a/plugins/autotest/testconfiguration.cpp b/plugins/autotest/testconfiguration.cpp
index 2203798923..4841a86fbf 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 fa9545157b..aab9d31db6 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 244b775f93..5deb34803e 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<QWidget *> TestResultsPane::toolBarWidgets() const
{
- return QList<QWidget *>() << m_runAll << m_runSelected << m_filterButton;
+ return QList<QWidget *>() << 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 86936223ac..6f3df33e5c 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 fe73cd91e8..ded6fab9f1 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 48f674716d..6ed530d05c 100644
--- a/plugins/autotest/testrunner.h
+++ b/plugins/autotest/testrunner.h
@@ -43,6 +43,8 @@ public:
void setSelectedTests(const QList<TestConfiguration *> &selected);
signals:
+ void testRunStarted();
+ void testRunFinished();
public slots:
void runTests();
diff --git a/plugins/autotest/testtreemodel.cpp b/plugins/autotest/testtreemodel.cpp
index a0aff69744..39b42ba5b9 100644
--- a/plugins/autotest/testtreemodel.cpp
+++ b/plugins/autotest/testtreemodel.cpp
@@ -305,7 +305,8 @@ QList<TestConfiguration *> 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<TestConfiguration *> 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;