forked from qt-creator/qt-creator
Add stop button and minor preparation for progress bar
This commit is contained in:
committed by
Christian Stenger
parent
345b4de47a
commit
431d15bd0c
@@ -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>
|
||||
|
BIN
plugins/autotest/images/stop.png
Normal file
BIN
plugins/autotest/images/stop.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 314 B |
@@ -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()
|
||||
|
@@ -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;
|
||||
|
@@ -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
|
||||
|
@@ -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;
|
||||
};
|
||||
|
@@ -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 ********************/
|
||||
|
@@ -43,6 +43,8 @@ public:
|
||||
void setSelectedTests(const QList<TestConfiguration *> &selected);
|
||||
|
||||
signals:
|
||||
void testRunStarted();
|
||||
void testRunFinished();
|
||||
|
||||
public slots:
|
||||
void runTests();
|
||||
|
@@ -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;
|
||||
|
Reference in New Issue
Block a user