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