QList<TestConfiguration *> QuickTestTreeItem::getSelectedTestConfigurations() const { QList<TestConfiguration *> result; ProjectExplorer::Project *project = ProjectExplorer::SessionManager::startupProject(); if (!project || type() != Root) return result; QuickTestConfiguration *tc = 0; QHash<QString, QuickTestConfiguration *> foundProFiles; // unnamed Quick Tests must be handled first if (TestTreeItem *unnamed = unnamedQuickTests()) { for (int childRow = 0, ccount = unnamed->childCount(); childRow < ccount; ++ childRow) { const TestTreeItem *grandChild = unnamed->childItem(childRow); const QString &proFile = grandChild->proFile(); if (foundProFiles.contains(proFile)) { QTC_ASSERT(tc, qWarning() << "Illegal state (unnamed Quick Test listed as named)"; return QList<TestConfiguration *>()); foundProFiles[proFile]->setTestCaseCount(tc->testCaseCount() + 1); } else { tc = new QuickTestConfiguration; tc->setTestCaseCount(1); tc->setUnnamedOnly(true); tc->setProFile(proFile); tc->setProject(project); foundProFiles.insert(proFile, tc); } }
QList<TestConfiguration *> TestTreeModel::getSelectedTests() const { QList<TestConfiguration *> result; ProjectExplorer::Project *project = ProjectExplorer::SessionManager::startupProject(); if (!project) return result; TestConfiguration *testConfiguration = 0; for (int row = 0, count = m_autoTestRootItem->childCount(); row < count; ++row) { const TestTreeItem *child = m_autoTestRootItem->childItem(row); switch (child->checked()) { case Qt::Unchecked: continue; case Qt::Checked: testConfiguration = new TestConfiguration(child->name(), QStringList(), child->childCount()); testConfiguration->setMainFilePath(child->filePath()); testConfiguration->setProject(project); result << testConfiguration; continue; case Qt::PartiallyChecked: default: const QString childName = child->name(); 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(); } testConfiguration = new TestConfiguration(childName, testCases); testConfiguration->setMainFilePath(child->filePath()); testConfiguration->setProject(project); result << testConfiguration; } } // Quick Tests must be handled differently - need the calling cpp file to use this in // addProjectInformation() - additionally this must be unique to not execute the same executable // on and on and on... // TODO: do this later on for Auto Tests as well to support strange setups? or redo the model QMap<QString, TestConfiguration *> foundMains; if (TestTreeItem *unnamed = unnamedQuickTests()) { for (int childRow = 0, ccount = unnamed->childCount(); childRow < ccount; ++ childRow) { const TestTreeItem *grandChild = unnamed->childItem(childRow); const QString mainFile = grandChild->mainFile(); if (foundMains.contains(mainFile)) { QTC_ASSERT(testConfiguration, qWarning() << "Illegal state (unnamed Quick Test listed as named)"; return QList<TestConfiguration *>()); foundMains[mainFile]->setTestCaseCount(testConfiguration->testCaseCount() + 1); } else { testConfiguration = new TestConfiguration(QString(), QStringList()); testConfiguration->setTestCaseCount(1); testConfiguration->setUnnamedOnly(true); testConfiguration->setMainFilePath(mainFile); testConfiguration->setProject(project); foundMains.insert(mainFile, testConfiguration); } }