QList<TestConfiguration *> QtTestTreeItem::getSelectedTestConfigurations() const { QList<TestConfiguration *> result; ProjectExplorer::Project *project = ProjectExplorer::SessionManager::startupProject(); if (!project || type() != Root) return result; QtTestConfiguration *testConfiguration = 0; for (int row = 0, count = childCount(); row < count; ++row) { const TestTreeItem *child = childItem(row); switch (child->checked()) { case Qt::Unchecked: continue; case Qt::Checked: testConfiguration = new QtTestConfiguration(); testConfiguration->setTestCaseCount(child->childCount()); testConfiguration->setProFile(child->proFile()); testConfiguration->setProject(project); testConfiguration->setDisplayName( TestUtils::getCMakeDisplayNameIfNecessary(child->filePath(), child->proFile())); result << testConfiguration; continue; case Qt::PartiallyChecked: default: int grandChildCount = child->childCount(); QStringList testCases; for (int grandChildRow = 0; grandChildRow < grandChildCount; ++grandChildRow) { const TestTreeItem *grandChild = child->childItem(grandChildRow); if (grandChild->checked() == Qt::Checked) { testCases << grandChild->name(); } else if (grandChild->checked() == Qt::PartiallyChecked) { const int dtCount = grandChild->childCount(); const QString funcName = grandChild->name(); for (int dtRow = 0; dtRow < dtCount; ++dtRow) { const TestTreeItem *dataTag = grandChild->childItem(dtRow); if (dataTag->checked() == Qt::Checked) testCases << funcName + ':' + dataTag->name(); } } } testConfiguration = new QtTestConfiguration(); testConfiguration->setTestCases(testCases); testConfiguration->setProFile(child->proFile()); testConfiguration->setProject(project); testConfiguration->setDisplayName( TestUtils::getCMakeDisplayNameIfNecessary(child->filePath(), child->proFile())); result << testConfiguration; } } return result; }
TestConfiguration *AutoTestTreeItem::testConfiguration() const { ProjectExplorer::Project *project = ProjectExplorer::SessionManager::startupProject(); QTC_ASSERT(project, return 0); QtTestConfiguration *config = 0; switch (type()) { case TestCase: config = new QtTestConfiguration; config->setTestCaseCount(childCount()); config->setProFile(proFile()); config->setProject(project); config->setDisplayName(TestUtils::getCMakeDisplayNameIfNecessary(filePath(), proFile())); break; case TestFunctionOrSet: { TestTreeItem *parent = parentItem(); config = new QtTestConfiguration(); config->setTestCases(QStringList(name())); config->setProFile(parent->proFile()); config->setProject(project); config->setDisplayName( TestUtils::getCMakeDisplayNameIfNecessary(filePath(), parent->proFile())); break; } case TestDataTag:{ const TestTreeItem *function = parentItem(); const TestTreeItem *parent = function ? function->parentItem() : 0; if (!parent) return 0; const QString functionWithTag = function->name() + QLatin1Char(':') + name(); config = new QtTestConfiguration(); config->setTestCases(QStringList(functionWithTag)); config->setProFile(parent->proFile()); config->setProject(project); config->setDisplayName(TestUtils::getCMakeDisplayNameIfNecessary(filePath(), parent->proFile())); break; } default: return 0; } return config; }