AutoTest: Fix handling of unnamed QuickTests

..now that the parser understands multiple TestCase items
inside a single qml file.
As long a test function is located inside a different TestCase
it is considered as a different one, so treat test functions
even of unnamed test cases correct.

Change-Id: I5cbfe1f63f896317523d51bbf67ea59169481a71
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Christian Stenger
2019-07-30 15:14:40 +02:00
parent abe3dde5d6
commit 8cd7a11926
6 changed files with 37 additions and 10 deletions

View File

@@ -329,7 +329,8 @@ TestTreeItem *QuickTestTreeItem::find(const TestParseResult *result)
case GroupNode:
return findChildByNameAndFile(result->name, result->fileName);
case TestCase:
return name().isEmpty() ? findChildByNameAndFile(result->name, result->fileName)
return name().isEmpty() ? findChildByNameFileAndLine(result->name, result->fileName,
result->line)
: findChildByName(result->name);
default:
return nullptr;
@@ -351,7 +352,8 @@ TestTreeItem *QuickTestTreeItem::findChild(const TestTreeItem *other)
case TestCase:
if (otherType != TestFunction && otherType != TestDataFunction && otherType != TestSpecialFunction)
return nullptr;
return name().isEmpty() ? findChildByNameAndFile(other->name(), other->filePath())
return name().isEmpty() ? findChildByNameFileAndLine(other->name(), other->filePath(),
other->line())
: findChildByName(other->name());
default:
return nullptr;
@@ -368,8 +370,7 @@ bool QuickTestTreeItem::modify(const TestParseResult *result)
case TestFunction:
case TestDataFunction:
case TestSpecialFunction:
return name().isEmpty() ? modifyLineAndColumn(result)
: modifyTestFunctionContent(result);
return modifyTestFunctionContent(result);
default:
return false;
}
@@ -454,6 +455,14 @@ TestTreeItem *QuickTestTreeItem::findChildByFileNameAndType(const QString &fileP
});
}
TestTreeItem *QuickTestTreeItem::findChildByNameFileAndLine(const QString &name,
const QString &filePath, unsigned line)
{
return findFirstLevelChild([name, filePath, line](const TestTreeItem *other) {
return other->filePath() == filePath && other->line() == line && other->name() == name;
});
}
TestTreeItem *QuickTestTreeItem::unnamedQuickTests() const
{
if (type() != Root)