Commit 1258c58a authored by Christian Stenger's avatar Christian Stenger Committed by Christian Stenger
Browse files

Disable context menu on test tree when executing test

parent a2a4fe56
......@@ -52,7 +52,8 @@ TestRunner *TestRunner::instance()
TestRunner::TestRunner(QObject *parent) :
QObject(parent),
m_building(false)
m_building(false),
m_executingTests(false)
{
}
......@@ -375,12 +376,13 @@ void TestRunner::runTests()
}
}
m_executingTests = true;
emit testRunStarted();
QFuture<void> future = QtConcurrent::run(&performTestRun , m_selectedTests);
Core::FutureProgress *progress = Core::ProgressManager::addTask(future, tr("Running Tests"),
Autotest::Constants::TASK_INDEX);
connect(progress, &Core::FutureProgress::finished,
TestRunner::instance(), &TestRunner::testRunFinished);
TestRunner::instance(), &TestRunner::onFinished);
}
void TestRunner::buildProject(ProjectExplorer::Project *project)
......@@ -405,6 +407,12 @@ void TestRunner::buildFinished(bool success)
m_buildSucceeded = success;
}
void TestRunner::onFinished()
{
m_executingTests = false;
emit testRunFinished();
}
void TestRunner::stopTestRun()
{
if (m_runner && m_runner->state() != QProcess::NotRunning && m_currentFuture)
......
......@@ -41,6 +41,7 @@ public:
~TestRunner();
void setSelectedTests(const QList<TestConfiguration *> &selected);
bool isTestRunning() const { return m_executingTests; }
signals:
void testRunStarted();
......@@ -53,6 +54,7 @@ public slots:
private slots:
void buildProject(ProjectExplorer::Project *project);
void buildFinished(bool success);
void onFinished();
private:
explicit TestRunner(QObject *parent = 0);
......@@ -60,6 +62,7 @@ private:
QList<TestConfiguration *> m_selectedTests;
bool m_building;
bool m_buildSucceeded;
bool m_executingTests;
};
......
......@@ -71,6 +71,7 @@ TestTreeViewWidget::TestTreeViewWidget(QWidget *parent) :
void TestTreeViewWidget::contextMenuEvent(QContextMenuEvent *event)
{
bool enabled = !TestRunner::instance()->isTestRunning();
bool hasTests = m_model->hasTests();
QMenu menu;
QAction *runAll = new QAction(tr("Run All Tests"), &menu);
......@@ -87,10 +88,11 @@ void TestTreeViewWidget::contextMenuEvent(QContextMenuEvent *event)
connect(rescan, &QAction::triggered,
TestTreeModel::instance()->parser(), &TestCodeParser::updateTestTree);
runAll->setEnabled(hasTests);
runSelected->setEnabled(hasTests);
selectAll->setEnabled(hasTests);
deselectAll->setEnabled(hasTests);
runAll->setEnabled(enabled && hasTests);
runSelected->setEnabled(enabled && hasTests);
selectAll->setEnabled(enabled && hasTests);
deselectAll->setEnabled(enabled && hasTests);
rescan->setEnabled(enabled);
menu.addAction(runAll);
menu.addAction(runSelected);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment