AutoTest: Pull catch tree nodes one level up

This patch makes test cases now match the TestCase node so that possible
additional sections can be functions instead of test data.
Mis-use the TestSuite for the file node that is used to additionally
group the items. The file node is kept - for now - as it seems rather
often that test case names get pretty long names.

Change-Id: I364fc40d1de6a22b6f170b3001f37393b64680aa
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Christian Stenger
2020-04-16 10:38:05 +02:00
parent df830ccf08
commit 4e0fa78752
3 changed files with 11 additions and 11 deletions

View File

@@ -48,7 +48,7 @@ CatchCodeParser::CatchCodeParser(const QByteArray &source, const LanguageFeature
static CatchTestCodeLocationAndType locationAndTypeFromToken(const Token &tkn)
{
CatchTestCodeLocationAndType locationAndType;
locationAndType.m_type = TestTreeItem::TestFunction;
locationAndType.m_type = TestTreeItem::TestCase;
locationAndType.m_line = tkn.lineno;
locationAndType.m_column = 0;
return locationAndType;

View File

@@ -114,7 +114,7 @@ static bool handleCatchDocument(QFutureInterface<TestParseResultPtr> futureInter
const CatchTestCodeLocationList foundTests = codeParser.findTests();
CatchParseResult *parseResult = new CatchParseResult(framework);
parseResult->itemType = TestTreeItem::TestCase;
parseResult->itemType = TestTreeItem::TestSuite;
parseResult->fileName = filePath;
parseResult->name = filePath;
parseResult->displayName = filePath;

View File

@@ -50,8 +50,8 @@ QVariant CatchTreeItem::data(int column, int role) const
switch (type()) {
case Root:
case GroupNode:
case TestSuite:
case TestCase:
case TestFunction:
return checked();
default:
return QVariant();
@@ -87,7 +87,7 @@ TestTreeItem *CatchTreeItem::find(const TestParseResult *result)
return findChildByFile(result->fileName);
case GroupNode:
return findChildByFile(result->fileName);
case TestCase:
case TestSuite:
return findChildByNameAndFile(result->name, result->fileName);
default:
return nullptr;
@@ -102,8 +102,8 @@ TestTreeItem *CatchTreeItem::findChild(const TestTreeItem *other)
case Root:
return findChildByFileAndType(other->filePath(), other->type());
case GroupNode:
return other->type() == TestCase ? findChildByFile(other->filePath()) : nullptr;
case TestCase:
return other->type() == TestSuite ? findChildByFile(other->filePath()) : nullptr;
case TestSuite:
return findChildByNameAndFile(other->name(), other->filePath());
default:
return nullptr;
@@ -115,8 +115,8 @@ bool CatchTreeItem::modify(const TestParseResult *result)
QTC_ASSERT(result, return false);
switch (type()) {
case TestSuite:
case TestCase:
case TestFunction:
return modifyTestFunctionContent(result);
default:
return false;
@@ -132,7 +132,7 @@ TestTreeItem *CatchTreeItem::createParentGroupNode() const
bool CatchTreeItem::canProvideTestConfiguration() const
{
return type() == TestFunction;
return type() == TestCase;
}
bool CatchTreeItem::canProvideDebugConfiguration() const
@@ -145,7 +145,7 @@ TestConfiguration *CatchTreeItem::testConfiguration() const
ProjectExplorer::Project *project = ProjectExplorer::SessionManager::startupProject();
QTC_ASSERT(project, return nullptr);
if (type() != TestFunction)
if (type() != TestCase)
return nullptr;
CatchConfiguration *config = nullptr;
@@ -186,7 +186,7 @@ static void collectTestInfo(const TestTreeItem *item,
}
QTC_ASSERT(childCount != 0, return);
QTC_ASSERT(item->type() == TestTreeItem::TestCase, return);
QTC_ASSERT(item->type() == TestTreeItem::TestSuite, return);
if (ignoreCheckState || item->checked() == Qt::Checked) {
const QString &projectFile = item->childAt(0)->proFile();
item->forAllChildren([&testCasesForProfile, &projectFile](TestTreeItem *it) {
@@ -196,7 +196,7 @@ static void collectTestInfo(const TestTreeItem *item,
testCasesForProfile[projectFile].internalTargets.unite(item->internalTargets());
} else if (item->checked() == Qt::PartiallyChecked) {
item->forFirstLevelChildren([&testCasesForProfile](TestTreeItem *child) {
QTC_ASSERT(child->type() == TestTreeItem::TestFunction, return);
QTC_ASSERT(child->type() == TestTreeItem::TestCase, return);
if (child->checked() == Qt::Checked) {
CatchTreeItem *current = static_cast<CatchTreeItem *>(child);
testCasesForProfile[child->proFile()].names.append(current->testCasesString());