forked from qt-creator/qt-creator
AutoTest: add ITestBase::type() for better readability
Change-Id: I67133f4940329483f2d8d25d1212f4e07f57d39d Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -42,8 +42,7 @@ class ItemDataCache
|
||||
public:
|
||||
void insert(ITestTreeItem *item, const T &value)
|
||||
{
|
||||
m_cache[item->cacheName()] = {
|
||||
0, value, item->testBase()->asTestTool() ? ITestBase::Tool : ITestBase::Framework };
|
||||
m_cache[item->cacheName()] = {0, value, item->testBase()->type()};
|
||||
}
|
||||
|
||||
/* \a type represents an OR'ed value of ITestBase::TestBaseType */
|
||||
|
||||
@@ -32,8 +32,9 @@
|
||||
|
||||
namespace Autotest {
|
||||
|
||||
ITestBase::ITestBase(bool activeByDefault)
|
||||
ITestBase::ITestBase(bool activeByDefault, const ITestBase::TestBaseType type)
|
||||
: m_active(activeByDefault)
|
||||
, m_type(type)
|
||||
{}
|
||||
|
||||
Utils::Id ITestBase::settingsId() const
|
||||
@@ -59,7 +60,7 @@ void ITestBase::resetRootNode()
|
||||
|
||||
|
||||
ITestFramework::ITestFramework(bool activeByDefault)
|
||||
: ITestBase(activeByDefault)
|
||||
: ITestBase(activeByDefault, ITestBase::Framework)
|
||||
{}
|
||||
|
||||
ITestFramework::~ITestFramework()
|
||||
@@ -82,6 +83,10 @@ ITestParser *ITestFramework::testParser()
|
||||
return m_testParser;
|
||||
}
|
||||
|
||||
ITestTool::ITestTool(bool activeByDefault)
|
||||
: ITestBase(activeByDefault, ITestBase::Tool)
|
||||
{}
|
||||
|
||||
ITestTreeItem *ITestTool::rootNode()
|
||||
{
|
||||
if (!m_rootNode)
|
||||
|
||||
@@ -48,11 +48,12 @@ public:
|
||||
Tool = 0x2
|
||||
};
|
||||
|
||||
explicit ITestBase(bool activeByDefault);
|
||||
explicit ITestBase(bool activeByDefault, const TestBaseType type);
|
||||
virtual ~ITestBase() = default;
|
||||
|
||||
virtual const char *name() const = 0;
|
||||
virtual unsigned priority() const = 0; // should this be modifyable?
|
||||
TestBaseType type() const { return m_type; }
|
||||
|
||||
virtual ITestSettings *testSettings() { return nullptr; }
|
||||
|
||||
@@ -73,6 +74,7 @@ protected:
|
||||
private:
|
||||
ITestTreeItem *m_rootNode = nullptr;
|
||||
bool m_active = false;
|
||||
TestBaseType m_type = None;
|
||||
|
||||
friend class ITestFramework;
|
||||
friend class ITestTool;
|
||||
@@ -107,7 +109,7 @@ using TestFrameworks = QList<ITestFramework *>;
|
||||
class ITestTool : public ITestBase
|
||||
{
|
||||
public:
|
||||
explicit ITestTool(bool activeByDefault) : ITestBase(activeByDefault) {}
|
||||
explicit ITestTool(bool activeByDefault);
|
||||
|
||||
ITestTreeItem *rootNode();
|
||||
|
||||
|
||||
@@ -154,7 +154,8 @@ void TestNavigationWidget::contextMenuEvent(QContextMenuEvent *event)
|
||||
onRunThisTestTriggered(TestRunMode::RunWithoutDeploy);
|
||||
});
|
||||
}
|
||||
auto ttitem = item->testBase()->asFramework() ? static_cast<TestTreeItem *>(item)
|
||||
auto ttitem = item->testBase()->type() == ITestBase::Framework
|
||||
? static_cast<TestTreeItem *>(item)
|
||||
: nullptr;
|
||||
if (ttitem && ttitem->canProvideDebugConfiguration()) {
|
||||
debugThisTest = new QAction(tr("Debug This Test"), &menu);
|
||||
|
||||
@@ -635,7 +635,7 @@ void TestResultsPane::onCustomContextMenuRequested(const QPoint &pos)
|
||||
action = new QAction(tr("Debug This Test"), &menu);
|
||||
bool debugEnabled = false;
|
||||
if (correlatingItem) {
|
||||
if (correlatingItem->testBase()->asFramework()) {
|
||||
if (correlatingItem->testBase()->type() == ITestBase::Framework) {
|
||||
auto testTreeItem = static_cast<const TestTreeItem *>(correlatingItem);
|
||||
debugEnabled = testTreeItem && testTreeItem->canProvideDebugConfiguration();
|
||||
}
|
||||
|
||||
@@ -177,7 +177,7 @@ static QString constructOmittedVariablesDetailsString(const Utils::EnvironmentIt
|
||||
bool TestRunner::currentConfigValid()
|
||||
{
|
||||
QString commandFilePath;
|
||||
if (m_currentConfig->testBase()->asFramework()) {
|
||||
if (m_currentConfig->testBase()->type() == ITestBase::Framework) {
|
||||
TestConfiguration *current = static_cast<TestConfiguration *>(m_currentConfig);
|
||||
commandFilePath = current->executableFilePath();
|
||||
} else {
|
||||
@@ -206,7 +206,7 @@ void TestRunner::setUpProcess()
|
||||
QTC_ASSERT(m_currentConfig, return);
|
||||
m_currentProcess = new QProcess;
|
||||
m_currentProcess->setReadChannel(QProcess::StandardOutput);
|
||||
if (m_currentConfig->testBase()->asFramework()) {
|
||||
if (m_currentConfig->testBase()->type() == ITestBase::Framework) {
|
||||
TestConfiguration *current = static_cast<TestConfiguration *>(m_currentConfig);
|
||||
m_currentProcess->setProgram(current->executableFilePath());
|
||||
} else {
|
||||
@@ -217,7 +217,7 @@ void TestRunner::setUpProcess()
|
||||
|
||||
void TestRunner::setUpProcessEnv()
|
||||
{
|
||||
if (m_currentConfig->testBase()->asFramework()) {
|
||||
if (m_currentConfig->testBase()->type() == ITestBase::Framework) {
|
||||
TestConfiguration *current = static_cast<TestConfiguration *>(m_currentConfig);
|
||||
|
||||
QStringList omitted;
|
||||
@@ -604,7 +604,7 @@ void TestRunner::debugTests()
|
||||
QTC_ASSERT(m_selectedTests.size() == 1, onFinished();return);
|
||||
|
||||
ITestConfiguration *itc = m_selectedTests.first();
|
||||
QTC_ASSERT(itc->testBase()->asFramework(), onFinished();return);
|
||||
QTC_ASSERT(itc->testBase()->type() == ITestBase::Framework, onFinished();return);
|
||||
|
||||
TestConfiguration *config = static_cast<TestConfiguration *>(itc);
|
||||
config->completeTestInformation(TestRunMode::Debug);
|
||||
|
||||
@@ -151,7 +151,7 @@ bool TestTreeModel::setData(const QModelIndex &index, const QVariant &value, int
|
||||
}
|
||||
return true;
|
||||
} else if (role == FailedRole) {
|
||||
if (item->testBase()->asFramework())
|
||||
if (item->testBase()->type() == ITestBase::Framework)
|
||||
m_failedStateCache.insert(static_cast<TestTreeItem *>(item), true);
|
||||
}
|
||||
}
|
||||
@@ -204,7 +204,7 @@ QList<ITestConfiguration *> TestTreeModel::getTestsForFile(const Utils::FilePath
|
||||
{
|
||||
QList<ITestConfiguration *> result;
|
||||
for (Utils::TreeItem *frameworkRoot : *rootItem()) {
|
||||
if (static_cast<ITestTreeItem *>(frameworkRoot)->testBase()->asFramework())
|
||||
if (static_cast<ITestTreeItem *>(frameworkRoot)->testBase()->type() == ITestBase::Framework)
|
||||
result.append(static_cast<TestTreeItem *>(frameworkRoot)->getTestConfigurationsForFile(fileName));
|
||||
}
|
||||
return result;
|
||||
@@ -276,7 +276,7 @@ QList<TestTreeItem *> TestTreeModel::testItemsByName(const QString &testName)
|
||||
QList<TestTreeItem *> result;
|
||||
for (Utils::TreeItem *frameworkRoot : *rootItem()) {
|
||||
ITestTreeItem *root = static_cast<ITestTreeItem *>(frameworkRoot);
|
||||
if (root->testBase()->asFramework())
|
||||
if (root->testBase()->type() == ITestBase::Framework)
|
||||
result << testItemsByName(static_cast<TestTreeItem *>(root), testName);
|
||||
}
|
||||
|
||||
@@ -319,7 +319,7 @@ void TestTreeModel::synchronizeTestFrameworks()
|
||||
newlyAdded.insert(framework);
|
||||
}
|
||||
for (ITestTreeItem *oldFrameworkRoot : oldFrameworkRoots) {
|
||||
if (oldFrameworkRoot->testBase()->asFramework())
|
||||
if (oldFrameworkRoot->testBase()->type() == ITestBase::Framework)
|
||||
oldFrameworkRoot->removeChildren();
|
||||
else // re-add the test tools - they are handled separately
|
||||
invisibleRoot->appendChild(oldFrameworkRoot);
|
||||
@@ -727,7 +727,7 @@ void TestTreeModel::removeAllTestToolItems()
|
||||
{
|
||||
for (Utils::TreeItem *it : *rootItem()) {
|
||||
ITestTreeItem * item = static_cast<ITestTreeItem *>(it);
|
||||
if (item->testBase()->asFramework())
|
||||
if (item->testBase()->type() == ITestBase::Framework)
|
||||
continue;
|
||||
item->removeChildren();
|
||||
if (item->checked() == Qt::PartiallyChecked)
|
||||
|
||||
Reference in New Issue
Block a user