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