forked from qt-creator/qt-creator
AutoTest: Fix parsing of multiple test cases in single qml file
Quick tests allow definition of more than one TestCase inside a qml file and even nesting is possible, so support this correctly. Fixes: QTCREATORBUG-22761 Change-Id: I65fcc7cd6063d976d798c3e900d3299a12e2d73f Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -323,11 +323,11 @@ TestTreeItem *QuickTestTreeItem::find(const TestParseResult *result)
|
||||
TestTreeItem *group = findFirstLevelChild([path](TestTreeItem *group) {
|
||||
return group->filePath() == path;
|
||||
});
|
||||
return group ? group->findChildByFile(result->fileName) : nullptr;
|
||||
return group ? group->findChildByNameAndFile(result->name, result->fileName) : nullptr;
|
||||
}
|
||||
return findChildByFile(result->fileName);
|
||||
return findChildByNameAndFile(result->name, result->fileName);
|
||||
case GroupNode:
|
||||
return findChildByFile(result->fileName);
|
||||
return findChildByNameAndFile(result->name, result->fileName);
|
||||
case TestCase:
|
||||
return name().isEmpty() ? findChildByNameAndFile(result->name, result->fileName)
|
||||
: findChildByName(result->name);
|
||||
@@ -345,9 +345,9 @@ TestTreeItem *QuickTestTreeItem::findChild(const TestTreeItem *other)
|
||||
case Root:
|
||||
if (otherType == TestCase && other->name().isEmpty())
|
||||
return unnamedQuickTests();
|
||||
return findChildByFileAndType(other->filePath(), otherType);
|
||||
return findChildByFileNameAndType(other->filePath(), other->name(), otherType);
|
||||
case GroupNode:
|
||||
return findChildByFileAndType(other->filePath(), otherType);
|
||||
return findChildByFileNameAndType(other->filePath(), other->name(), otherType);
|
||||
case TestCase:
|
||||
if (otherType != TestFunction && otherType != TestDataFunction && otherType != TestSpecialFunction)
|
||||
return nullptr;
|
||||
@@ -444,6 +444,16 @@ void QuickTestTreeItem::markForRemovalRecursively(const QString &filePath)
|
||||
}
|
||||
}
|
||||
|
||||
TestTreeItem *QuickTestTreeItem::findChildByFileNameAndType(const QString &filePath,
|
||||
const QString &name,
|
||||
TestTreeItem::Type tType)
|
||||
|
||||
{
|
||||
return findFirstLevelChild([filePath, name, tType](const TestTreeItem *other) {
|
||||
return other->type() == tType && other->name() == name && other->filePath() == filePath;
|
||||
});
|
||||
}
|
||||
|
||||
TestTreeItem *QuickTestTreeItem::unnamedQuickTests() const
|
||||
{
|
||||
if (type() != Root)
|
||||
|
||||
Reference in New Issue
Block a user