forked from qt-creator/qt-creator
AutoTest: Introduce ITestTool
Preparation for separating handling of code based and build system based tests. Task-number: QTCREATORBUG-23332 Change-Id: I490af5f3157fd4a8cd07d976cdfd9e4503ade97b Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -37,13 +37,13 @@ ITestParser *BoostTestFramework::createTestParser()
|
||||
return new BoostTestParser(this);
|
||||
}
|
||||
|
||||
TestTreeItem *BoostTestFramework::createRootNode()
|
||||
ITestTreeItem *BoostTestFramework::createRootNode()
|
||||
{
|
||||
return new BoostTestTreeItem(
|
||||
this,
|
||||
QCoreApplication::translate("BoostTestFramework",
|
||||
BoostTest::Constants::FRAMEWORK_SETTINGS_CATEGORY),
|
||||
QString(), TestTreeItem::Root);
|
||||
QString(), ITestTreeItem::Root);
|
||||
}
|
||||
|
||||
const char *BoostTestFramework::name() const
|
||||
|
||||
@@ -43,7 +43,7 @@ private:
|
||||
unsigned priority() const override;
|
||||
ITestSettings *testSettings() override { return &m_settings; }
|
||||
ITestParser *createTestParser() override;
|
||||
TestTreeItem *createRootNode() override;
|
||||
ITestTreeItem *createRootNode() override;
|
||||
|
||||
BoostTestSettings m_settings;
|
||||
BoostTestSettingsPage m_settingsPage{&m_settings, settingsId()};
|
||||
|
||||
@@ -75,7 +75,7 @@ TestTreeItem *BoostTestTreeItem::find(const TestParseResult *result)
|
||||
|
||||
switch (type()) {
|
||||
case Root:
|
||||
if (static_cast<BoostTestFramework *>(result->base)->grouping()) {
|
||||
if (result->base->asFramework()->grouping()) {
|
||||
const QFileInfo fileInfo(bResult->fileName);
|
||||
const QFileInfo base(fileInfo.absolutePath());
|
||||
for (int row = 0; row < childCount(); ++row) {
|
||||
@@ -188,13 +188,12 @@ QList<ITestConfiguration *> BoostTestTreeItem::getAllTestConfigurations() const
|
||||
|
||||
// we only need the unique project files (and number of test cases for the progress indicator)
|
||||
QHash<QString, BoostTestCases> testsPerProjectfile;
|
||||
forAllChildren([&testsPerProjectfile](TreeItem *it){
|
||||
auto item = static_cast<BoostTestTreeItem *>(it);
|
||||
forAllChildItems([&testsPerProjectfile](TestTreeItem *item){
|
||||
if (item->type() != TestSuite)
|
||||
return;
|
||||
int funcChildren = 0;
|
||||
item->forAllChildren([&funcChildren](TreeItem *child){
|
||||
if (static_cast<BoostTestTreeItem *>(child)->type() == TestCase)
|
||||
item->forAllChildItems([&funcChildren](TestTreeItem *child){
|
||||
if (child->type() == TestCase)
|
||||
++funcChildren;
|
||||
});
|
||||
if (funcChildren) {
|
||||
|
||||
@@ -45,11 +45,11 @@ ITestParser *CatchFramework::createTestParser()
|
||||
return new CatchTestParser(this);
|
||||
}
|
||||
|
||||
TestTreeItem *CatchFramework::createRootNode()
|
||||
ITestTreeItem *CatchFramework::createRootNode()
|
||||
{
|
||||
return new CatchTreeItem(this,
|
||||
QCoreApplication::translate("CatchFramework", "Catch Test"),
|
||||
QString(), TestTreeItem::Root);
|
||||
QString(), ITestTreeItem::Root);
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
@@ -42,7 +42,7 @@ public:
|
||||
|
||||
protected:
|
||||
ITestParser *createTestParser() override;
|
||||
TestTreeItem *createRootNode() override;
|
||||
ITestTreeItem *createRootNode() override;
|
||||
|
||||
private:
|
||||
ITestSettings * testSettings() override { return &m_settings; }
|
||||
|
||||
@@ -86,7 +86,7 @@ TestTreeItem *CatchTreeItem::find(const TestParseResult *result)
|
||||
|
||||
switch (type()) {
|
||||
case Root:
|
||||
if (static_cast<CatchFramework *>(result->base)->grouping()) {
|
||||
if (result->base->asFramework()->grouping()) {
|
||||
const QString path = QFileInfo(result->fileName).absolutePath();
|
||||
for (int row = 0; row < childCount(); ++row) {
|
||||
TestTreeItem *group = childItem(row);
|
||||
@@ -229,8 +229,7 @@ static void collectFailedTestInfo(const CatchTreeItem *item,
|
||||
|
||||
item->forAllChildItems([&testCasesForProfile](TestTreeItem *it) {
|
||||
QTC_ASSERT(it, return);
|
||||
CatchTreeItem *parent = static_cast<CatchTreeItem *>(it->parentItem());
|
||||
QTC_ASSERT(parent, return);
|
||||
QTC_ASSERT(it->parentItem(), return);
|
||||
if (it->type() == TestTreeItem::TestCase && it->data(0, FailedRole).toBool()) {
|
||||
CatchTreeItem *current = static_cast<CatchTreeItem *>(it);
|
||||
testCasesForProfile[it->proFile()].names.append(current->testCasesString());
|
||||
|
||||
@@ -44,13 +44,13 @@ ITestParser *GTestFramework::createTestParser()
|
||||
return new GTestParser(this);
|
||||
}
|
||||
|
||||
TestTreeItem *GTestFramework::createRootNode()
|
||||
ITestTreeItem *GTestFramework::createRootNode()
|
||||
{
|
||||
return new GTestTreeItem(
|
||||
this,
|
||||
QCoreApplication::translate("GTestFramework",
|
||||
GTest::Constants::FRAMEWORK_SETTINGS_CATEGORY),
|
||||
QString(), TestTreeItem::Root);
|
||||
QString(), ITestTreeItem::Root);
|
||||
}
|
||||
|
||||
const char *GTestFramework::name() const
|
||||
|
||||
@@ -47,7 +47,7 @@ private:
|
||||
QString groupingToolTip() const override;
|
||||
ITestSettings *testSettings() override { return &m_settings; }
|
||||
ITestParser *createTestParser() override;
|
||||
TestTreeItem *createRootNode() override;
|
||||
ITestTreeItem *createRootNode() override;
|
||||
|
||||
GTestSettings m_settings;
|
||||
GTestSettingsPage m_settingsPage{&m_settings, settingsId()};
|
||||
|
||||
@@ -377,7 +377,7 @@ TestTreeItem *GTestTreeItem::find(const TestParseResult *result)
|
||||
states |= GTestTreeItem::Typed;
|
||||
switch (type()) {
|
||||
case Root:
|
||||
if (static_cast<GTestFramework *>(result->base)->grouping()) {
|
||||
if (result->base->asFramework()->grouping()) {
|
||||
if (GTestFramework::groupMode() == GTest::Constants::Directory) {
|
||||
const QFileInfo fileInfo(parseResult->fileName);
|
||||
const QFileInfo base(fileInfo.absolutePath());
|
||||
|
||||
@@ -36,14 +36,6 @@ ITestBase::ITestBase(bool activeByDefault)
|
||||
: m_active(activeByDefault)
|
||||
{}
|
||||
|
||||
TestTreeItem *ITestBase::rootNode()
|
||||
{
|
||||
if (!m_rootNode)
|
||||
m_rootNode = createRootNode();
|
||||
// These are stored in the TestTreeModel and destroyed on shutdown there.
|
||||
return m_rootNode;
|
||||
}
|
||||
|
||||
Utils::Id ITestBase::settingsId() const
|
||||
{
|
||||
return Utils::Id(Constants::SETTINGSPAGE_PREFIX)
|
||||
@@ -75,6 +67,14 @@ ITestFramework::~ITestFramework()
|
||||
delete m_testParser;
|
||||
}
|
||||
|
||||
TestTreeItem *ITestFramework::rootNode()
|
||||
{
|
||||
if (!m_rootNode)
|
||||
m_rootNode = createRootNode();
|
||||
// These are stored in the TestTreeModel and destroyed on shutdown there.
|
||||
return static_cast<TestTreeItem *>(m_rootNode);
|
||||
}
|
||||
|
||||
ITestParser *ITestFramework::testParser()
|
||||
{
|
||||
if (!m_testParser)
|
||||
@@ -82,4 +82,12 @@ ITestParser *ITestFramework::testParser()
|
||||
return m_testParser;
|
||||
}
|
||||
|
||||
ITestTreeItem *ITestTool::rootNode()
|
||||
{
|
||||
if (!m_rootNode)
|
||||
m_rootNode = createRootNode();
|
||||
// These are stored in the TestTreeModel and destroyed on shutdown there.
|
||||
return m_rootNode;
|
||||
}
|
||||
|
||||
} // namespace Autotest
|
||||
|
||||
@@ -27,10 +27,15 @@
|
||||
|
||||
#include <utils/id.h>
|
||||
|
||||
namespace ProjectExplorer { struct TestCaseInfo; }
|
||||
|
||||
namespace Autotest {
|
||||
|
||||
class ITestFramework;
|
||||
class ITestParser;
|
||||
class ITestSettings;
|
||||
class ITestTool;
|
||||
class ITestTreeItem;
|
||||
class TestTreeItem;
|
||||
|
||||
class ITestBase
|
||||
@@ -44,8 +49,6 @@ public:
|
||||
|
||||
virtual ITestSettings *testSettings() { return nullptr; }
|
||||
|
||||
TestTreeItem *rootNode();
|
||||
|
||||
Utils::Id settingsId() const;
|
||||
Utils::Id id() const;
|
||||
|
||||
@@ -54,12 +57,18 @@ public:
|
||||
|
||||
void resetRootNode();
|
||||
|
||||
virtual ITestFramework *asFramework() { return nullptr; }
|
||||
virtual ITestTool *asTestTool() { return nullptr; }
|
||||
|
||||
protected:
|
||||
virtual TestTreeItem *createRootNode() = 0;
|
||||
virtual ITestTreeItem *createRootNode() = 0;
|
||||
|
||||
private:
|
||||
TestTreeItem *m_rootNode = nullptr;
|
||||
ITestTreeItem *m_rootNode = nullptr;
|
||||
bool m_active = false;
|
||||
|
||||
friend class ITestFramework;
|
||||
friend class ITestTool;
|
||||
};
|
||||
|
||||
class ITestFramework : public ITestBase
|
||||
@@ -68,6 +77,7 @@ public:
|
||||
explicit ITestFramework(bool activeByDefault);
|
||||
~ITestFramework() override;
|
||||
|
||||
TestTreeItem *rootNode();
|
||||
ITestParser *testParser();
|
||||
|
||||
bool grouping() const { return m_grouping; }
|
||||
@@ -75,6 +85,8 @@ public:
|
||||
// framework specific tool tip to be displayed on the general settings page
|
||||
virtual QString groupingToolTip() const { return QString(); }
|
||||
|
||||
ITestFramework *asFramework() final { return this; }
|
||||
|
||||
protected:
|
||||
virtual ITestParser *createTestParser() = 0;
|
||||
|
||||
@@ -85,4 +97,23 @@ private:
|
||||
|
||||
using TestFrameworks = QList<ITestFramework *>;
|
||||
|
||||
class ITestTool : public ITestBase
|
||||
{
|
||||
public:
|
||||
explicit ITestTool(bool activeByDefault) : ITestBase(activeByDefault) {}
|
||||
|
||||
ITestTreeItem *rootNode();
|
||||
|
||||
virtual Utils::Id buildSystemId() const = 0;
|
||||
|
||||
virtual ITestTreeItem *createItemFromTestCaseInfo(const ProjectExplorer::TestCaseInfo &tci) = 0;
|
||||
|
||||
ITestTool *asTestTool() final { return this; }
|
||||
|
||||
private:
|
||||
unsigned priority() const final { return 255; }
|
||||
};
|
||||
|
||||
using TestTools = QList<ITestTool *>;
|
||||
|
||||
} // namespace Autotest
|
||||
|
||||
@@ -36,13 +36,13 @@ ITestParser *QtTestFramework::createTestParser()
|
||||
return new QtTestParser(this);
|
||||
}
|
||||
|
||||
TestTreeItem *QtTestFramework::createRootNode()
|
||||
ITestTreeItem *QtTestFramework::createRootNode()
|
||||
{
|
||||
return new QtTestTreeItem(
|
||||
this,
|
||||
QCoreApplication::translate("QtTestFramework",
|
||||
QtTest::Constants::FRAMEWORK_SETTINGS_CATEGORY),
|
||||
QString(), TestTreeItem::Root);
|
||||
QString(), ITestTreeItem::Root);
|
||||
}
|
||||
|
||||
const char *QtTestFramework::name() const
|
||||
|
||||
@@ -42,7 +42,7 @@ private:
|
||||
const char *name() const override;
|
||||
unsigned priority() const override;
|
||||
ITestParser *createTestParser() override;
|
||||
TestTreeItem *createRootNode() override;
|
||||
ITestTreeItem *createRootNode() override;
|
||||
ITestSettings *testSettings() override { return &m_settings; }
|
||||
|
||||
QtTestSettings m_settings;
|
||||
|
||||
@@ -310,7 +310,7 @@ TestTreeItem *QtTestTreeItem::find(const TestParseResult *result)
|
||||
|
||||
switch (type()) {
|
||||
case Root:
|
||||
if (static_cast<QtTestFramework *>(result->base)->grouping()) {
|
||||
if (result->base->asFramework()->grouping()) {
|
||||
const QString path = QFileInfo(result->fileName).absolutePath();
|
||||
for (int row = 0; row < childCount(); ++row) {
|
||||
TestTreeItem *group = childItem(row);
|
||||
|
||||
@@ -39,10 +39,10 @@ ITestParser *QuickTestFramework::createTestParser()
|
||||
return new QuickTestParser(this);
|
||||
}
|
||||
|
||||
TestTreeItem *QuickTestFramework::createRootNode()
|
||||
ITestTreeItem *QuickTestFramework::createRootNode()
|
||||
{
|
||||
return new QuickTestTreeItem(this, QCoreApplication::translate("QuickTestFramework", "Quick Test"),
|
||||
QString(), TestTreeItem::Root);
|
||||
QString(), ITestTreeItem::Root);
|
||||
}
|
||||
|
||||
const char *QuickTestFramework::name() const
|
||||
|
||||
@@ -48,7 +48,7 @@ public:
|
||||
|
||||
protected:
|
||||
ITestParser *createTestParser() override;
|
||||
TestTreeItem *createRootNode() override;
|
||||
ITestTreeItem *createRootNode() override;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
@@ -290,7 +290,7 @@ TestTreeItem *QuickTestTreeItem::find(const TestParseResult *result)
|
||||
case Root:
|
||||
if (result->name.isEmpty())
|
||||
return unnamedQuickTests();
|
||||
if (static_cast<QuickTestFramework *>(result->base)->grouping()) {
|
||||
if (result->base->asFramework()->grouping()) {
|
||||
const QString path = QFileInfo(result->fileName).absolutePath();
|
||||
TestTreeItem *group = findFirstLevelChildItem([path](TestTreeItem *group) {
|
||||
return group->filePath() == path;
|
||||
|
||||
@@ -120,7 +120,7 @@ void TestCodeParser::syncTestFrameworks(const QList<ITestFramework *> &framework
|
||||
qCDebug(LOG) << "Setting" << frameworks << "as current parsers";
|
||||
for (ITestFramework *framework : frameworks) {
|
||||
ITestParser *testParser = framework->testParser();
|
||||
QTC_ASSERT(testParser, continue);
|
||||
QTC_ASSERT(testParser, continue); // buildsystem based frameworks have no code parser
|
||||
m_testCodeParsers.append(testParser);
|
||||
}
|
||||
}
|
||||
@@ -341,18 +341,22 @@ void TestCodeParser::scanForTests(const QStringList &fileList, const QList<ITest
|
||||
return !fn.endsWith(".qml");
|
||||
});
|
||||
if (!parsers.isEmpty()) {
|
||||
for (ITestFramework *framework : parsers)
|
||||
for (ITestFramework *framework : parsers) {
|
||||
QTC_ASSERT(framework->testParser(), continue); // mark only frameworks with a parser
|
||||
framework->rootNode()->markForRemovalRecursively(true);
|
||||
}
|
||||
} else {
|
||||
emit requestRemoveAll();
|
||||
emit requestRemoveAllFrameworkItems();
|
||||
}
|
||||
} else if (!parsers.isEmpty()) {
|
||||
for (ITestFramework *framework : parsers) {
|
||||
for (const QString &filePath : list)
|
||||
for (const QString &filePath : qAsConst(list)) {
|
||||
QTC_ASSERT(framework->testParser(), continue);
|
||||
framework->rootNode()->markForRemovalRecursively(filePath);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (const QString &filePath : list)
|
||||
for (const QString &filePath : qAsConst(list))
|
||||
emit requestRemoval(filePath);
|
||||
}
|
||||
|
||||
@@ -484,7 +488,7 @@ void TestCodeParser::parsePostponedFiles()
|
||||
|
||||
void TestCodeParser::releaseParserInternals()
|
||||
{
|
||||
for (ITestParser *parser : m_testCodeParsers)
|
||||
for (ITestParser *parser : qAsConst(m_testCodeParsers))
|
||||
parser->release();
|
||||
}
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ signals:
|
||||
void parsingFinished();
|
||||
void parsingFailed();
|
||||
void requestRemoval(const QString &filePath);
|
||||
void requestRemoveAll();
|
||||
void requestRemoveAllFrameworkItems();
|
||||
|
||||
public:
|
||||
void emitUpdateTestTree(ITestParser *parser = nullptr);
|
||||
|
||||
@@ -136,7 +136,7 @@ void TestNavigationWidget::contextMenuEvent(QContextMenuEvent *event)
|
||||
const QModelIndex index = list.first();
|
||||
QRect rect(m_view->visualRect(index));
|
||||
if (rect.contains(event->pos())) {
|
||||
TestTreeItem *item = static_cast<TestTreeItem *>(
|
||||
ITestTreeItem *item = static_cast<ITestTreeItem *>(
|
||||
m_model->itemForIndex(m_sortFilterModel->mapToSource(index)));
|
||||
if (item->canProvideTestConfiguration()) {
|
||||
runThisTest = new QAction(tr("Run This Test"), &menu);
|
||||
@@ -152,7 +152,9 @@ void TestNavigationWidget::contextMenuEvent(QContextMenuEvent *event)
|
||||
onRunThisTestTriggered(TestRunMode::RunWithoutDeploy);
|
||||
});
|
||||
}
|
||||
if (item->canProvideDebugConfiguration()) {
|
||||
auto ttitem = item->testBase()->asFramework() ? static_cast<TestTreeItem *>(item)
|
||||
: nullptr;
|
||||
if (ttitem && ttitem->canProvideDebugConfiguration()) {
|
||||
debugThisTest = new QAction(tr("Debug This Test"), &menu);
|
||||
debugThisTest->setEnabled(enabled);
|
||||
connect(debugThisTest, &QAction::triggered,
|
||||
@@ -313,7 +315,7 @@ void TestNavigationWidget::onRunThisTestTriggered(TestRunMode runMode)
|
||||
if (!sourceIndex.isValid())
|
||||
return;
|
||||
|
||||
TestTreeItem *item = static_cast<TestTreeItem *>(sourceIndex.internalPointer());
|
||||
ITestTreeItem *item = static_cast<ITestTreeItem *>(sourceIndex.internalPointer());
|
||||
TestRunner::instance()->runTest(runMode, item);
|
||||
}
|
||||
|
||||
|
||||
@@ -27,9 +27,11 @@
|
||||
|
||||
#include "autotesticons.h"
|
||||
#include "autotestplugin.h"
|
||||
#include "itestframework.h"
|
||||
#include "testeditormark.h"
|
||||
#include "testresultdelegate.h"
|
||||
#include "testresultmodel.h"
|
||||
#include "testresultmodel.h"
|
||||
#include "testrunner.h"
|
||||
#include "testsettings.h"
|
||||
#include "testtreemodel.h"
|
||||
@@ -631,9 +633,14 @@ void TestResultsPane::onCustomContextMenuRequested(const QPoint &pos)
|
||||
menu.addAction(action);
|
||||
|
||||
action = new QAction(tr("Debug This Test"), &menu);
|
||||
// FIXME limit to Test Frameworks
|
||||
auto testTreeItem = static_cast<const TestTreeItem *>(correlatingItem);
|
||||
action->setEnabled(testTreeItem && testTreeItem->canProvideDebugConfiguration());
|
||||
bool debugEnabled = false;
|
||||
if (correlatingItem) {
|
||||
if (correlatingItem->testBase()->asFramework()) {
|
||||
auto testTreeItem = static_cast<const TestTreeItem *>(correlatingItem);
|
||||
debugEnabled = testTreeItem && testTreeItem->canProvideDebugConfiguration();
|
||||
}
|
||||
}
|
||||
action->setEnabled(debugEnabled);
|
||||
connect(action, &QAction::triggered, this, [this, clicked] {
|
||||
onRunThisTestTriggered(TestRunMode::Debug, clicked);
|
||||
});
|
||||
|
||||
@@ -62,8 +62,8 @@ TestTreeModel::TestTreeModel(TestCodeParser *parser) :
|
||||
this, &TestTreeModel::sweep, Qt::QueuedConnection);
|
||||
connect(m_parser, &TestCodeParser::parsingFailed,
|
||||
this, &TestTreeModel::sweep, Qt::QueuedConnection);
|
||||
connect(m_parser, &TestCodeParser::requestRemoveAll,
|
||||
this, &TestTreeModel::markAllForRemoval);
|
||||
connect(m_parser, &TestCodeParser::requestRemoveAllFrameworkItems,
|
||||
this, &TestTreeModel::markAllFrameworkItemsForRemoval);
|
||||
connect(m_parser, &TestCodeParser::requestRemoval,
|
||||
this, &TestTreeModel::markForRemoval);
|
||||
connect(this, &QAbstractItemModel::dataChanged,
|
||||
@@ -137,8 +137,9 @@ bool TestTreeModel::setData(const QModelIndex &index, const QVariant &value, int
|
||||
revalidateCheckState(parent); // handle parent too
|
||||
}
|
||||
return true;
|
||||
} else if (role == FailedRole) { // FIXME limit to Frameworks
|
||||
m_failedStateCache.insert(static_cast<TestTreeItem *>(item), true);
|
||||
} else if (role == FailedRole) {
|
||||
if (item->testBase()->asFramework())
|
||||
m_failedStateCache.insert(static_cast<TestTreeItem *>(item), true);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
@@ -181,7 +182,6 @@ QList<ITestConfiguration *> TestTreeModel::getSelectedTests() const
|
||||
QList<ITestConfiguration *> TestTreeModel::getFailedTests() const
|
||||
{
|
||||
QList<ITestConfiguration *> result;
|
||||
// FIXME limit to frameworks
|
||||
for (Utils::TreeItem *frameworkRoot : *rootItem())
|
||||
result.append(static_cast<ITestTreeItem *>(frameworkRoot)->getFailedTestConfigurations());
|
||||
return result;
|
||||
@@ -190,9 +190,10 @@ QList<ITestConfiguration *> TestTreeModel::getFailedTests() const
|
||||
QList<ITestConfiguration *> TestTreeModel::getTestsForFile(const Utils::FilePath &fileName) const
|
||||
{
|
||||
QList<ITestConfiguration *> result;
|
||||
// FIXME limit to frameworks
|
||||
for (Utils::TreeItem *frameworkRoot : *rootItem())
|
||||
result.append(static_cast<TestTreeItem *>(frameworkRoot)->getTestConfigurationsForFile(fileName));
|
||||
for (Utils::TreeItem *frameworkRoot : *rootItem()) {
|
||||
if (static_cast<ITestTreeItem *>(frameworkRoot)->testBase()->asFramework())
|
||||
result.append(static_cast<TestTreeItem *>(frameworkRoot)->getTestConfigurationsForFile(fileName));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -223,9 +224,11 @@ QList<TestTreeItem *> TestTreeModel::testItemsByName(TestTreeItem *root, const Q
|
||||
QList<TestTreeItem *> TestTreeModel::testItemsByName(const QString &testName)
|
||||
{
|
||||
QList<TestTreeItem *> result;
|
||||
// FIXME limit to frameworks
|
||||
for (Utils::TreeItem *frameworkRoot : *rootItem())
|
||||
result << testItemsByName(static_cast<TestTreeItem *>(frameworkRoot), testName);
|
||||
for (Utils::TreeItem *frameworkRoot : *rootItem()) {
|
||||
ITestTreeItem *root = static_cast<ITestTreeItem *>(frameworkRoot);
|
||||
if (root->testBase()->asFramework())
|
||||
result << testItemsByName(static_cast<TestTreeItem *>(root), testName);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -350,9 +353,12 @@ void TestTreeModel::removeFiles(const QStringList &files)
|
||||
sweep();
|
||||
}
|
||||
|
||||
void TestTreeModel::markAllForRemoval()
|
||||
void TestTreeModel::markAllFrameworkItemsForRemoval()
|
||||
{
|
||||
for (Utils::TreeItem *frameworkRoot : *rootItem()) {
|
||||
// skip buildsystem based frameworks
|
||||
if (static_cast<ITestTreeItem *>(frameworkRoot)->testBase()->asTestTool())
|
||||
continue;
|
||||
for (Utils::TreeItem *item : *frameworkRoot)
|
||||
static_cast<TestTreeItem *>(item)->markForRemovalRecursively(true);
|
||||
}
|
||||
@@ -364,9 +370,11 @@ void TestTreeModel::markForRemoval(const QString &filePath)
|
||||
return;
|
||||
|
||||
for (Utils::TreeItem *frameworkRoot : *rootItem()) {
|
||||
TestTreeItem *root = static_cast<TestTreeItem *>(frameworkRoot);
|
||||
ITestTreeItem *root = static_cast<ITestTreeItem *>(frameworkRoot);
|
||||
if (root->testBase()->asTestTool())
|
||||
continue;
|
||||
for (int childRow = root->childCount() - 1; childRow >= 0; --childRow) {
|
||||
TestTreeItem *child = root->childItem(childRow);
|
||||
TestTreeItem *child = static_cast<TestTreeItem *>(root->childAt(childRow));
|
||||
child->markForRemovalRecursively(filePath);
|
||||
}
|
||||
}
|
||||
@@ -375,9 +383,12 @@ void TestTreeModel::markForRemoval(const QString &filePath)
|
||||
void TestTreeModel::sweep()
|
||||
{
|
||||
for (Utils::TreeItem *frameworkRoot : *rootItem()) {
|
||||
TestTreeItem *root = static_cast<TestTreeItem *>(frameworkRoot);
|
||||
sweepChildren(root);
|
||||
revalidateCheckState(root);
|
||||
ITestTreeItem *root = static_cast<ITestTreeItem *>(frameworkRoot);
|
||||
if (root->testBase()->asTestTool())
|
||||
continue;
|
||||
TestTreeItem *ttRoot = static_cast<TestTreeItem *>(root);
|
||||
sweepChildren(ttRoot);
|
||||
revalidateCheckState(ttRoot);
|
||||
}
|
||||
// even if nothing has changed by the sweeping we might had parse which added or modified items
|
||||
emit testTreeModelChanged();
|
||||
@@ -532,7 +543,9 @@ void TestTreeModel::revalidateCheckState(ITestTreeItem *item)
|
||||
|
||||
void TestTreeModel::onParseResultReady(const TestParseResultPtr result)
|
||||
{
|
||||
TestTreeItem *rootNode = result->base->rootNode();
|
||||
ITestFramework *framework = result->base->asFramework();
|
||||
QTC_ASSERT(framework, return);
|
||||
TestTreeItem *rootNode = framework->rootNode();
|
||||
QTC_ASSERT(rootNode, return);
|
||||
handleParseResult(result.data(), rootNode);
|
||||
}
|
||||
@@ -554,7 +567,7 @@ void Autotest::TestTreeModel::onDataChanged(const QModelIndex &topLeft,
|
||||
|
||||
void TestTreeModel::handleParseResult(const TestParseResult *result, TestTreeItem *parentNode)
|
||||
{
|
||||
const bool groupingEnabled = static_cast<ITestFramework *>(result->base)->grouping();
|
||||
const bool groupingEnabled = result->base->asFramework()->grouping();
|
||||
// lookup existing items
|
||||
if (TestTreeItem *toBeModified = parentNode->find(result)) {
|
||||
// found existing item... Do not remove
|
||||
|
||||
@@ -84,7 +84,7 @@ public:
|
||||
QMap<QString, int> boostTestSuitesAndTests() const;
|
||||
#endif
|
||||
|
||||
void markAllForRemoval();
|
||||
void markAllFrameworkItemsForRemoval();
|
||||
void markForRemoval(const QString &filePath);
|
||||
void sweep();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user