forked from qt-creator/qt-creator
AutoTest: Allow grouping of test cases
Grouping of test cases can now get enabled for each registered framework. For now grouping happens only folder based. Task-number: QTCREATORBUG-17979 Change-Id: Ic0e5c0ecc76998a1aedea8aa0845f6d9b53fb179 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -26,6 +26,7 @@
|
||||
#include "quicktesttreeitem.h"
|
||||
#include "quicktestconfiguration.h"
|
||||
#include "quicktestparser.h"
|
||||
#include "../testframeworkmanager.h"
|
||||
|
||||
#include <cpptools/cppmodelmanager.h>
|
||||
#include <projectexplorer/session.h>
|
||||
@@ -267,7 +268,22 @@ TestTreeItem *QuickTestTreeItem::find(const TestParseResult *result)
|
||||
|
||||
switch (type()) {
|
||||
case Root:
|
||||
return result->name.isEmpty() ? unnamedQuickTests() : findChildByFile(result->fileName);
|
||||
if (result->name.isEmpty())
|
||||
return unnamedQuickTests();
|
||||
if (TestFrameworkManager::instance()->groupingEnabled(result->frameworkId)) {
|
||||
const QString path = QFileInfo(result->fileName).absolutePath();
|
||||
for (int row = 0; row < childCount(); ++row) {
|
||||
TestTreeItem *group = childItem(row);
|
||||
if (group->filePath() != path)
|
||||
continue;
|
||||
if (auto groupChild = group->findChildByFile(result->fileName))
|
||||
return groupChild;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
return findChildByFile(result->fileName);
|
||||
case GroupNode:
|
||||
return findChildByFile(result->fileName);
|
||||
case TestCase:
|
||||
return name().isEmpty() ? findChildByNameAndFile(result->name, result->fileName)
|
||||
: findChildByName(result->name);
|
||||
@@ -303,6 +319,26 @@ bool QuickTestTreeItem::lessThan(const TestTreeItem *other, TestTreeItem::SortMo
|
||||
return TestTreeItem::lessThan(other, mode);
|
||||
}
|
||||
|
||||
bool QuickTestTreeItem::isGroupNodeFor(const TestTreeItem *other) const
|
||||
{
|
||||
QTC_ASSERT(other, return false);
|
||||
if (other->name().isEmpty()) // unnamed quick tests will not get grouped
|
||||
return false;
|
||||
return TestTreeItem::isGroupNodeFor(other);
|
||||
}
|
||||
|
||||
TestTreeItem *QuickTestTreeItem::createParentGroupNode() const
|
||||
{
|
||||
if (filePath().isEmpty() || name().isEmpty())
|
||||
return nullptr;
|
||||
if (type() == TestFunctionOrSet)
|
||||
return nullptr;
|
||||
|
||||
const QFileInfo fileInfo(filePath());
|
||||
const QFileInfo base(fileInfo.absolutePath());
|
||||
return new QuickTestTreeItem(base.baseName(), fileInfo.absolutePath(), TestTreeItem::GroupNode);
|
||||
}
|
||||
|
||||
QSet<QString> QuickTestTreeItem::internalTargets() const
|
||||
{
|
||||
QSet<QString> result;
|
||||
|
||||
Reference in New Issue
Block a user