Commit 87e5cf87 authored by Christian Stenger's avatar Christian Stenger Committed by Christian Stenger
Browse files

Enable 'Run *' buttons only if tests are available

parent d5913658
......@@ -56,6 +56,8 @@ TestResultsPane::TestResultsPane(QObject *parent) :
this, &TestResultsPane::onTestRunStarted);
connect(TestRunner::instance(), &TestRunner::testRunFinished,
this, &TestResultsPane::onTestRunFinished);
connect(TestTreeModel::instance(), &TestTreeModel::testTreeModelChanged,
this, &TestResultsPane::onTestTreeModelChanged);
}
void TestResultsPane::createToolButtons()
......@@ -278,5 +280,12 @@ void TestResultsPane::onTestRunFinished()
m_runSelected->setEnabled(true);
}
void TestResultsPane::onTestTreeModelChanged()
{
bool enable = TestTreeModel::instance()->hasTests();
m_runAll->setEnabled(enable);
m_runSelected->setEnabled(enable);
}
} // namespace Internal
} // namespace Autotest
......@@ -84,6 +84,7 @@ private:
void createToolButtons();
void onTestRunStarted();
void onTestRunFinished();
void onTestTreeModelChanged();
Utils::ListView *m_listView;
TestResultModel *m_model;
......
......@@ -331,6 +331,9 @@ void performTestRun(QFutureInterface<void> &future, const QList<TestConfiguratio
void TestRunner::runTests()
{
// clear old log and output pane
TestResultsPane::instance()->clearContents();
if (m_selectedTests.empty()) {
TestResultsPane::instance()->addTestResult(
TestResult(QString(), QString(), QString(), ResultType::MESSAGE_FATAL,
......@@ -339,7 +342,6 @@ void TestRunner::runTests()
}
ProjectExplorer::Project *project = m_selectedTests.at(0)->project();
if (!project) // add a warning or info to output? possible at all?
return;
......@@ -365,9 +367,6 @@ void TestRunner::runTests()
}
}
// clear old log and output pane
TestResultsPane::instance()->clearContents();
emit testRunStarted();
QFuture<void> future = QtConcurrent::run(&performTestRun , m_selectedTests);
Core::FutureProgress *progress = Core::ProgressManager::addTask(future, tr("Running Tests"),
......
......@@ -424,6 +424,7 @@ void TestTreeModel::modifyAutoTestSubtree(int row, TestTreeItem *newItem)
} // remove rest of the items
removeRows(newChildCount, childCount - newChildCount, toBeModifiedIndex);
}
emit testTreeModelChanged();
}
void TestTreeModel::removeAutoTestSubtreeByFilePath(const QString &file)
......@@ -438,6 +439,7 @@ void TestTreeModel::removeAutoTestSubtreeByFilePath(const QString &file)
break;
}
}
emit testTreeModelChanged();
}
void TestTreeModel::addAutoTest(TestTreeItem *newItem)
......@@ -445,6 +447,7 @@ void TestTreeModel::addAutoTest(TestTreeItem *newItem)
beginInsertRows(index(0, 0), m_autoTestRootItem->childCount(), m_autoTestRootItem->childCount());
m_autoTestRootItem->appendChild(newItem);
endInsertRows();
emit testTreeModelChanged();
}
void TestTreeModel::removeAllAutoTests()
......@@ -452,6 +455,7 @@ void TestTreeModel::removeAllAutoTests()
beginResetModel();
m_autoTestRootItem->removeChildren();
endResetModel();
emit testTreeModelChanged();
}
} // namespace Internal
......
......@@ -66,6 +66,7 @@ public:
void addAutoTest(TestTreeItem *newItem);
void removeAllAutoTests();
signals:
void testTreeModelChanged();
public slots:
......
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