diff --git a/src/plugins/autotest/boost/boosttestframework.cpp b/src/plugins/autotest/boost/boosttestframework.cpp index a1448e33ccd..6f8ac0192fb 100644 --- a/src/plugins/autotest/boost/boosttestframework.cpp +++ b/src/plugins/autotest/boost/boosttestframework.cpp @@ -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 diff --git a/src/plugins/autotest/boost/boosttestframework.h b/src/plugins/autotest/boost/boosttestframework.h index 4c94858ab82..f91e06e6f84 100644 --- a/src/plugins/autotest/boost/boosttestframework.h +++ b/src/plugins/autotest/boost/boosttestframework.h @@ -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()}; diff --git a/src/plugins/autotest/boost/boosttesttreeitem.cpp b/src/plugins/autotest/boost/boosttesttreeitem.cpp index f2c44f07f4c..083386d5bd5 100644 --- a/src/plugins/autotest/boost/boosttesttreeitem.cpp +++ b/src/plugins/autotest/boost/boosttesttreeitem.cpp @@ -75,7 +75,7 @@ TestTreeItem *BoostTestTreeItem::find(const TestParseResult *result) switch (type()) { case Root: - if (static_cast(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 BoostTestTreeItem::getAllTestConfigurations() const // we only need the unique project files (and number of test cases for the progress indicator) QHash testsPerProjectfile; - forAllChildren([&testsPerProjectfile](TreeItem *it){ - auto item = static_cast(it); + forAllChildItems([&testsPerProjectfile](TestTreeItem *item){ if (item->type() != TestSuite) return; int funcChildren = 0; - item->forAllChildren([&funcChildren](TreeItem *child){ - if (static_cast(child)->type() == TestCase) + item->forAllChildItems([&funcChildren](TestTreeItem *child){ + if (child->type() == TestCase) ++funcChildren; }); if (funcChildren) { diff --git a/src/plugins/autotest/catch/catchframework.cpp b/src/plugins/autotest/catch/catchframework.cpp index 9ccff39cbe4..3a8b71c4c24 100644 --- a/src/plugins/autotest/catch/catchframework.cpp +++ b/src/plugins/autotest/catch/catchframework.cpp @@ -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 diff --git a/src/plugins/autotest/catch/catchframework.h b/src/plugins/autotest/catch/catchframework.h index a253d460a0b..0b143472ea3 100644 --- a/src/plugins/autotest/catch/catchframework.h +++ b/src/plugins/autotest/catch/catchframework.h @@ -42,7 +42,7 @@ public: protected: ITestParser *createTestParser() override; - TestTreeItem *createRootNode() override; + ITestTreeItem *createRootNode() override; private: ITestSettings * testSettings() override { return &m_settings; } diff --git a/src/plugins/autotest/catch/catchtreeitem.cpp b/src/plugins/autotest/catch/catchtreeitem.cpp index b12f75b88da..7567dc270c1 100644 --- a/src/plugins/autotest/catch/catchtreeitem.cpp +++ b/src/plugins/autotest/catch/catchtreeitem.cpp @@ -86,7 +86,7 @@ TestTreeItem *CatchTreeItem::find(const TestParseResult *result) switch (type()) { case Root: - if (static_cast(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(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(it); testCasesForProfile[it->proFile()].names.append(current->testCasesString()); diff --git a/src/plugins/autotest/gtest/gtestframework.cpp b/src/plugins/autotest/gtest/gtestframework.cpp index c97f209b6c7..9480ee5732b 100644 --- a/src/plugins/autotest/gtest/gtestframework.cpp +++ b/src/plugins/autotest/gtest/gtestframework.cpp @@ -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 diff --git a/src/plugins/autotest/gtest/gtestframework.h b/src/plugins/autotest/gtest/gtestframework.h index bbc30590b2c..1bdfd682411 100644 --- a/src/plugins/autotest/gtest/gtestframework.h +++ b/src/plugins/autotest/gtest/gtestframework.h @@ -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()}; diff --git a/src/plugins/autotest/gtest/gtesttreeitem.cpp b/src/plugins/autotest/gtest/gtesttreeitem.cpp index c372fe03f9e..efbd26913d3 100644 --- a/src/plugins/autotest/gtest/gtesttreeitem.cpp +++ b/src/plugins/autotest/gtest/gtesttreeitem.cpp @@ -377,7 +377,7 @@ TestTreeItem *GTestTreeItem::find(const TestParseResult *result) states |= GTestTreeItem::Typed; switch (type()) { case Root: - if (static_cast(result->base)->grouping()) { + if (result->base->asFramework()->grouping()) { if (GTestFramework::groupMode() == GTest::Constants::Directory) { const QFileInfo fileInfo(parseResult->fileName); const QFileInfo base(fileInfo.absolutePath()); diff --git a/src/plugins/autotest/itestframework.cpp b/src/plugins/autotest/itestframework.cpp index 3b8db6b4a94..adae992de90 100644 --- a/src/plugins/autotest/itestframework.cpp +++ b/src/plugins/autotest/itestframework.cpp @@ -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(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 diff --git a/src/plugins/autotest/itestframework.h b/src/plugins/autotest/itestframework.h index 1d1f66edd62..e0e8d0920c6 100644 --- a/src/plugins/autotest/itestframework.h +++ b/src/plugins/autotest/itestframework.h @@ -27,10 +27,15 @@ #include +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; +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; + } // namespace Autotest diff --git a/src/plugins/autotest/qtest/qttestframework.cpp b/src/plugins/autotest/qtest/qttestframework.cpp index c606c53f32e..fcf2445ebd8 100644 --- a/src/plugins/autotest/qtest/qttestframework.cpp +++ b/src/plugins/autotest/qtest/qttestframework.cpp @@ -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 diff --git a/src/plugins/autotest/qtest/qttestframework.h b/src/plugins/autotest/qtest/qttestframework.h index 2aee278a6a6..1f66deb09ae 100644 --- a/src/plugins/autotest/qtest/qttestframework.h +++ b/src/plugins/autotest/qtest/qttestframework.h @@ -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; diff --git a/src/plugins/autotest/qtest/qttesttreeitem.cpp b/src/plugins/autotest/qtest/qttesttreeitem.cpp index 9e5513733c1..5684601e6aa 100644 --- a/src/plugins/autotest/qtest/qttesttreeitem.cpp +++ b/src/plugins/autotest/qtest/qttesttreeitem.cpp @@ -310,7 +310,7 @@ TestTreeItem *QtTestTreeItem::find(const TestParseResult *result) switch (type()) { case Root: - if (static_cast(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); diff --git a/src/plugins/autotest/quick/quicktestframework.cpp b/src/plugins/autotest/quick/quicktestframework.cpp index 416fbc25d70..39763bc07a1 100644 --- a/src/plugins/autotest/quick/quicktestframework.cpp +++ b/src/plugins/autotest/quick/quicktestframework.cpp @@ -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 diff --git a/src/plugins/autotest/quick/quicktestframework.h b/src/plugins/autotest/quick/quicktestframework.h index 1fe50e0d7ca..316a5a9f380 100644 --- a/src/plugins/autotest/quick/quicktestframework.h +++ b/src/plugins/autotest/quick/quicktestframework.h @@ -48,7 +48,7 @@ public: protected: ITestParser *createTestParser() override; - TestTreeItem *createRootNode() override; + ITestTreeItem *createRootNode() override; }; } // namespace Internal diff --git a/src/plugins/autotest/quick/quicktesttreeitem.cpp b/src/plugins/autotest/quick/quicktesttreeitem.cpp index 9f2944f0ac7..ff1a0b6db6a 100644 --- a/src/plugins/autotest/quick/quicktesttreeitem.cpp +++ b/src/plugins/autotest/quick/quicktesttreeitem.cpp @@ -290,7 +290,7 @@ TestTreeItem *QuickTestTreeItem::find(const TestParseResult *result) case Root: if (result->name.isEmpty()) return unnamedQuickTests(); - if (static_cast(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; diff --git a/src/plugins/autotest/testcodeparser.cpp b/src/plugins/autotest/testcodeparser.cpp index 1382d807d3e..ab971a4e791 100644 --- a/src/plugins/autotest/testcodeparser.cpp +++ b/src/plugins/autotest/testcodeparser.cpp @@ -120,7 +120,7 @@ void TestCodeParser::syncTestFrameworks(const QList &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 QListtestParser(), 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(); } diff --git a/src/plugins/autotest/testcodeparser.h b/src/plugins/autotest/testcodeparser.h index 60a621ef3bf..9cef0fc2bda 100644 --- a/src/plugins/autotest/testcodeparser.h +++ b/src/plugins/autotest/testcodeparser.h @@ -77,7 +77,7 @@ signals: void parsingFinished(); void parsingFailed(); void requestRemoval(const QString &filePath); - void requestRemoveAll(); + void requestRemoveAllFrameworkItems(); public: void emitUpdateTestTree(ITestParser *parser = nullptr); diff --git a/src/plugins/autotest/testnavigationwidget.cpp b/src/plugins/autotest/testnavigationwidget.cpp index 32f06d69b8a..e6bb3363726 100644 --- a/src/plugins/autotest/testnavigationwidget.cpp +++ b/src/plugins/autotest/testnavigationwidget.cpp @@ -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( + ITestTreeItem *item = static_cast( 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(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(sourceIndex.internalPointer()); + ITestTreeItem *item = static_cast(sourceIndex.internalPointer()); TestRunner::instance()->runTest(runMode, item); } diff --git a/src/plugins/autotest/testresultspane.cpp b/src/plugins/autotest/testresultspane.cpp index cf8a1afa193..b4f24f437a5 100644 --- a/src/plugins/autotest/testresultspane.cpp +++ b/src/plugins/autotest/testresultspane.cpp @@ -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(correlatingItem); - action->setEnabled(testTreeItem && testTreeItem->canProvideDebugConfiguration()); + bool debugEnabled = false; + if (correlatingItem) { + if (correlatingItem->testBase()->asFramework()) { + auto testTreeItem = static_cast(correlatingItem); + debugEnabled = testTreeItem && testTreeItem->canProvideDebugConfiguration(); + } + } + action->setEnabled(debugEnabled); connect(action, &QAction::triggered, this, [this, clicked] { onRunThisTestTriggered(TestRunMode::Debug, clicked); }); diff --git a/src/plugins/autotest/testtreemodel.cpp b/src/plugins/autotest/testtreemodel.cpp index 10938f74cba..7051ee24f44 100644 --- a/src/plugins/autotest/testtreemodel.cpp +++ b/src/plugins/autotest/testtreemodel.cpp @@ -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(item), true); + } else if (role == FailedRole) { + if (item->testBase()->asFramework()) + m_failedStateCache.insert(static_cast(item), true); } } return false; @@ -181,7 +182,6 @@ QList TestTreeModel::getSelectedTests() const QList TestTreeModel::getFailedTests() const { QList result; - // FIXME limit to frameworks for (Utils::TreeItem *frameworkRoot : *rootItem()) result.append(static_cast(frameworkRoot)->getFailedTestConfigurations()); return result; @@ -190,9 +190,10 @@ QList TestTreeModel::getFailedTests() const QList TestTreeModel::getTestsForFile(const Utils::FilePath &fileName) const { QList result; - // FIXME limit to frameworks - for (Utils::TreeItem *frameworkRoot : *rootItem()) - result.append(static_cast(frameworkRoot)->getTestConfigurationsForFile(fileName)); + for (Utils::TreeItem *frameworkRoot : *rootItem()) { + if (static_cast(frameworkRoot)->testBase()->asFramework()) + result.append(static_cast(frameworkRoot)->getTestConfigurationsForFile(fileName)); + } return result; } @@ -223,9 +224,11 @@ QList TestTreeModel::testItemsByName(TestTreeItem *root, const Q QList TestTreeModel::testItemsByName(const QString &testName) { QList result; - // FIXME limit to frameworks - for (Utils::TreeItem *frameworkRoot : *rootItem()) - result << testItemsByName(static_cast(frameworkRoot), testName); + for (Utils::TreeItem *frameworkRoot : *rootItem()) { + ITestTreeItem *root = static_cast(frameworkRoot); + if (root->testBase()->asFramework()) + result << testItemsByName(static_cast(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(frameworkRoot)->testBase()->asTestTool()) + continue; for (Utils::TreeItem *item : *frameworkRoot) static_cast(item)->markForRemovalRecursively(true); } @@ -364,9 +370,11 @@ void TestTreeModel::markForRemoval(const QString &filePath) return; for (Utils::TreeItem *frameworkRoot : *rootItem()) { - TestTreeItem *root = static_cast(frameworkRoot); + ITestTreeItem *root = static_cast(frameworkRoot); + if (root->testBase()->asTestTool()) + continue; for (int childRow = root->childCount() - 1; childRow >= 0; --childRow) { - TestTreeItem *child = root->childItem(childRow); + TestTreeItem *child = static_cast(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(frameworkRoot); - sweepChildren(root); - revalidateCheckState(root); + ITestTreeItem *root = static_cast(frameworkRoot); + if (root->testBase()->asTestTool()) + continue; + TestTreeItem *ttRoot = static_cast(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(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 diff --git a/src/plugins/autotest/testtreemodel.h b/src/plugins/autotest/testtreemodel.h index 412dde98511..389d0c555b9 100644 --- a/src/plugins/autotest/testtreemodel.h +++ b/src/plugins/autotest/testtreemodel.h @@ -84,7 +84,7 @@ public: QMap boostTestSuitesAndTests() const; #endif - void markAllForRemoval(); + void markAllFrameworkItemsForRemoval(); void markForRemoval(const QString &filePath); void sweep();