diff --git a/plugins/autotest/testresultspane.cpp b/plugins/autotest/testresultspane.cpp index 5deb34803e0..bb641d264a4 100644 --- a/plugins/autotest/testresultspane.cpp +++ b/plugins/autotest/testresultspane.cpp @@ -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 diff --git a/plugins/autotest/testresultspane.h b/plugins/autotest/testresultspane.h index 6f3df33e5c9..af8222e512e 100644 --- a/plugins/autotest/testresultspane.h +++ b/plugins/autotest/testresultspane.h @@ -84,6 +84,7 @@ private: void createToolButtons(); void onTestRunStarted(); void onTestRunFinished(); + void onTestTreeModelChanged(); Utils::ListView *m_listView; TestResultModel *m_model; diff --git a/plugins/autotest/testrunner.cpp b/plugins/autotest/testrunner.cpp index eae9d4c58a7..4591f94081f 100644 --- a/plugins/autotest/testrunner.cpp +++ b/plugins/autotest/testrunner.cpp @@ -331,6 +331,9 @@ void performTestRun(QFutureInterface &future, const QListclearContents(); + 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 future = QtConcurrent::run(&performTestRun , m_selectedTests); Core::FutureProgress *progress = Core::ProgressManager::addTask(future, tr("Running Tests"), diff --git a/plugins/autotest/testtreemodel.cpp b/plugins/autotest/testtreemodel.cpp index 39b42ba5b97..214afb110a4 100644 --- a/plugins/autotest/testtreemodel.cpp +++ b/plugins/autotest/testtreemodel.cpp @@ -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 diff --git a/plugins/autotest/testtreemodel.h b/plugins/autotest/testtreemodel.h index 9e70016b342..0a07ef0e3a1 100644 --- a/plugins/autotest/testtreemodel.h +++ b/plugins/autotest/testtreemodel.h @@ -66,6 +66,7 @@ public: void addAutoTest(TestTreeItem *newItem); void removeAllAutoTests(); signals: + void testTreeModelChanged(); public slots: