forked from qt-creator/qt-creator
AutoTest: Adapt Type enum
Follow the official terms used by the test frameworks. In detail this means Google test now uses TestSuite and TestCase and the value for a normal function has been simplified to TestFunction. Beside the visual change there is no change in functionality. Change-Id: Idf541d07fa3469e04a699d46f4625ff9075d5b6f Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -36,7 +36,7 @@ namespace Internal {
|
||||
|
||||
TestTreeItem *GTestParseResult::createTestTreeItem() const
|
||||
{
|
||||
if (itemType != TestTreeItem::TestCase && itemType != TestTreeItem::TestFunctionOrSet)
|
||||
if (itemType != TestTreeItem::TestSuite && itemType != TestTreeItem::TestCase)
|
||||
return nullptr;
|
||||
GTestTreeItem *item = new GTestTreeItem(name, fileName, itemType);
|
||||
item->setProFile(proFile);
|
||||
@@ -110,7 +110,7 @@ static bool handleGTest(QFutureInterface<TestParseResultPtr> futureInterface,
|
||||
|
||||
for (const GTestCaseSpec &testSpec : result.keys()) {
|
||||
GTestParseResult *parseResult = new GTestParseResult(id);
|
||||
parseResult->itemType = TestTreeItem::TestCase;
|
||||
parseResult->itemType = TestTreeItem::TestSuite;
|
||||
parseResult->fileName = filePath;
|
||||
parseResult->name = testSpec.testCaseName;
|
||||
parseResult->parameterized = testSpec.parameterized;
|
||||
|
@@ -118,7 +118,7 @@ bool GTestResult::matches(const TestTreeItem *treeItem) const
|
||||
|
||||
bool GTestResult::matchesTestFunctionOrSet(const TestTreeItem *treeItem) const
|
||||
{
|
||||
if (treeItem->type() != TestTreeItem::TestFunctionOrSet)
|
||||
if (treeItem->type() != TestTreeItem::TestCase)
|
||||
return false;
|
||||
|
||||
const QString testItemTestSet = treeItem->parentItem()->name() + '.' + treeItem->name();
|
||||
@@ -127,7 +127,7 @@ bool GTestResult::matchesTestFunctionOrSet(const TestTreeItem *treeItem) const
|
||||
|
||||
bool GTestResult::matchesTestCase(const TestTreeItem *treeItem) const
|
||||
{
|
||||
if (treeItem->type() != TestTreeItem::TestCase)
|
||||
if (treeItem->type() != TestTreeItem::TestSuite)
|
||||
return false;
|
||||
|
||||
return treeItem->name() == normalizeTestName(name());
|
||||
|
@@ -130,8 +130,8 @@ QVariant GTestTreeItem::data(int column, int role) const
|
||||
switch (type()) {
|
||||
case Root:
|
||||
case GroupNode:
|
||||
case TestSuite:
|
||||
case TestCase:
|
||||
case TestFunctionOrSet:
|
||||
return checked();
|
||||
default:
|
||||
return QVariant();
|
||||
@@ -153,7 +153,7 @@ TestConfiguration *GTestTreeItem::testConfiguration() const
|
||||
|
||||
GTestConfiguration *config = nullptr;
|
||||
switch (type()) {
|
||||
case TestCase: {
|
||||
case TestSuite: {
|
||||
const QString &testSpecifier = gtestFilter(state()).arg(name()).arg('*');
|
||||
if (int count = childCount()) {
|
||||
config = new GTestConfiguration;
|
||||
@@ -164,7 +164,7 @@ TestConfiguration *GTestTreeItem::testConfiguration() const
|
||||
}
|
||||
break;
|
||||
}
|
||||
case TestFunctionOrSet: {
|
||||
case TestCase: {
|
||||
GTestTreeItem *parent = static_cast<GTestTreeItem *>(parentItem());
|
||||
if (!parent)
|
||||
return nullptr;
|
||||
@@ -212,7 +212,7 @@ static void collectTestInfo(const GTestTreeItem *item,
|
||||
}
|
||||
const int childCount = item->childCount();
|
||||
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();
|
||||
testCasesForProFile[projectFile].filters.append(
|
||||
@@ -221,7 +221,7 @@ static void collectTestInfo(const GTestTreeItem *item,
|
||||
testCasesForProFile[projectFile].internalTargets.unite(item->internalTargets());
|
||||
} else if (item->checked() == Qt::PartiallyChecked) {
|
||||
item->forFirstLevelChildren([&testCasesForProFile, item](TestTreeItem *child){
|
||||
QTC_ASSERT(child->type() == TestTreeItem::TestFunctionOrSet, return);
|
||||
QTC_ASSERT(child->type() == TestTreeItem::TestCase, return);
|
||||
if (child->checked() == Qt::Checked) {
|
||||
testCasesForProFile[child->proFile()].filters.append(
|
||||
gtestFilter(item->state()).arg(item->name()).arg(child->name()));
|
||||
@@ -281,10 +281,10 @@ QList<TestConfiguration *> GTestTreeItem::getTestConfigurationsForFile(const Uti
|
||||
QHash<QString, TestCases> testCases;
|
||||
const QString &file = fileName.toString();
|
||||
forAllChildren([&testCases, &file](TestTreeItem *node) {
|
||||
if (node->type() == Type::TestFunctionOrSet && node->filePath() == file) {
|
||||
if (node->type() == Type::TestCase && node->filePath() == file) {
|
||||
QTC_ASSERT(node->parentItem(), return);
|
||||
const GTestTreeItem *testCase = static_cast<GTestTreeItem *>(node->parentItem());
|
||||
QTC_ASSERT(testCase->type() == Type::TestCase, return);
|
||||
QTC_ASSERT(testCase->type() == Type::TestSuite, return);
|
||||
TestCases &cases = testCases[testCase->proFile()];
|
||||
cases.filters.append(
|
||||
gtestFilter(testCase->state()).arg(testCase->name(), node->name()));
|
||||
@@ -351,7 +351,7 @@ TestTreeItem *GTestTreeItem::find(const TestParseResult *result)
|
||||
return findChildByNameStateAndFile(parseResult->name, states, parseResult->proFile);
|
||||
case GroupNode:
|
||||
return findChildByNameStateAndFile(parseResult->name, states, parseResult->proFile);
|
||||
case TestCase:
|
||||
case TestSuite:
|
||||
return findChildByNameAndFile(result->name, result->fileName);
|
||||
default:
|
||||
return nullptr;
|
||||
@@ -367,7 +367,7 @@ TestTreeItem *GTestTreeItem::findChild(const TestTreeItem *other)
|
||||
TestTreeItem *result = nullptr;
|
||||
if (otherType == GroupNode) {
|
||||
result = findChildByNameAndFile(other->name(), other->filePath());
|
||||
} else if (otherType == TestCase) {
|
||||
} else if (otherType == TestSuite) {
|
||||
auto gtOther = static_cast<const GTestTreeItem *>(other);
|
||||
result = findChildByNameStateAndFile(gtOther->name(), gtOther->state(),
|
||||
gtOther->proFile());
|
||||
@@ -376,12 +376,12 @@ TestTreeItem *GTestTreeItem::findChild(const TestTreeItem *other)
|
||||
}
|
||||
case GroupNode: {
|
||||
auto gtOther = static_cast<const GTestTreeItem *>(other);
|
||||
return otherType == TestCase
|
||||
return otherType == TestSuite
|
||||
? findChildByNameStateAndFile(gtOther->name(), gtOther->state(), gtOther->proFile())
|
||||
: nullptr;
|
||||
}
|
||||
case TestCase:
|
||||
return otherType == TestFunctionOrSet
|
||||
case TestSuite:
|
||||
return otherType == TestCase
|
||||
? findChildByNameAndFile(other->name(), other->filePath())
|
||||
: nullptr;
|
||||
default:
|
||||
@@ -394,7 +394,7 @@ bool GTestTreeItem::modify(const TestParseResult *result)
|
||||
QTC_ASSERT(result, return false);
|
||||
|
||||
switch (type()) {
|
||||
case TestFunctionOrSet:
|
||||
case TestCase:
|
||||
return modifyTestSetContent(static_cast<const GTestParseResult *>(result));
|
||||
default:
|
||||
return false;
|
||||
@@ -489,11 +489,11 @@ bool GTestTreeItem::isGroupNodeFor(const TestTreeItem *other) const
|
||||
return QFileInfo(other->filePath()).absolutePath() == filePath();
|
||||
} else { // GTestFilter
|
||||
QString fullName;
|
||||
if (other->type() == TestCase) {
|
||||
if (other->type() == TestSuite) {
|
||||
fullName = other->name();
|
||||
if (other->childCount())
|
||||
fullName += '.' + other->childAt(0)->name();
|
||||
} else if (other->type() == TestFunctionOrSet) {
|
||||
} else if (other->type() == TestCase) {
|
||||
QTC_ASSERT(other->parentItem(), return false);
|
||||
fullName = other->parentItem()->name() + '.' + other->name();
|
||||
} else if (other->type() == GroupNode) { // can happen on a rebuild if only filter changes
|
||||
@@ -511,12 +511,12 @@ bool GTestTreeItem::isGroupNodeFor(const TestTreeItem *other) const
|
||||
|
||||
bool GTestTreeItem::isGroupable() const
|
||||
{
|
||||
return type() == TestCase;
|
||||
return type() == TestSuite;
|
||||
}
|
||||
|
||||
TestTreeItem *GTestTreeItem::applyFilters()
|
||||
{
|
||||
if (type() != TestCase)
|
||||
if (type() != TestSuite)
|
||||
return nullptr;
|
||||
|
||||
if (GTestFramework::groupMode() != GTest::Constants::GTestFilter)
|
||||
@@ -542,7 +542,7 @@ TestTreeItem *GTestTreeItem::applyFilters()
|
||||
|
||||
bool GTestTreeItem::shouldBeAddedAfterFiltering() const
|
||||
{
|
||||
return type() == TestTreeItem::TestFunctionOrSet || childCount();
|
||||
return type() == TestTreeItem::TestCase || childCount();
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -78,7 +78,7 @@ bool GTestVisitor::visit(CPlusPlus::FunctionDefinitionAST *ast)
|
||||
locationAndType.m_name = testName;
|
||||
locationAndType.m_line = line;
|
||||
locationAndType.m_column = column - 1;
|
||||
locationAndType.m_type = TestTreeItem::TestFunctionOrSet;
|
||||
locationAndType.m_type = TestTreeItem::TestCase;
|
||||
locationAndType.m_state = disabled ? GTestTreeItem::Disabled
|
||||
: GTestTreeItem::Enabled;
|
||||
GTestCaseSpec spec;
|
||||
|
@@ -159,7 +159,7 @@ bool QtTestResult::matches(const TestTreeItem *item) const
|
||||
if (item->proFile() != m_projectFile)
|
||||
return false;
|
||||
return matchesTestCase(item);
|
||||
case TestTreeItem::TestFunctionOrSet:
|
||||
case TestTreeItem::TestFunction:
|
||||
case TestTreeItem::TestSpecialFunction:
|
||||
if (!isTestFunction())
|
||||
return false;
|
||||
|
@@ -82,7 +82,7 @@ Qt::ItemFlags QtTestTreeItem::flags(int column) const
|
||||
switch (type()) {
|
||||
case TestDataTag:
|
||||
return defaultFlags | Qt::ItemIsUserCheckable;
|
||||
case TestFunctionOrSet:
|
||||
case TestFunction:
|
||||
return defaultFlags | Qt::ItemIsAutoTristate | Qt::ItemIsUserCheckable;
|
||||
default:
|
||||
return TestTreeItem::flags(column);
|
||||
@@ -93,7 +93,7 @@ bool QtTestTreeItem::canProvideTestConfiguration() const
|
||||
{
|
||||
switch (type()) {
|
||||
case TestCase:
|
||||
case TestFunctionOrSet:
|
||||
case TestFunction:
|
||||
case TestDataTag:
|
||||
return true;
|
||||
default:
|
||||
@@ -119,7 +119,7 @@ TestConfiguration *QtTestTreeItem::testConfiguration() const
|
||||
config->setProjectFile(proFile());
|
||||
config->setProject(project);
|
||||
break;
|
||||
case TestFunctionOrSet: {
|
||||
case TestFunction: {
|
||||
TestTreeItem *parent = parentItem();
|
||||
config = new QtTestConfiguration();
|
||||
config->setTestCases(QStringList(name()));
|
||||
@@ -245,7 +245,7 @@ QList<TestConfiguration *> QtTestTreeItem::getTestConfigurationsForFile(const Ut
|
||||
QHash<TestTreeItem *, QStringList> testFunctions;
|
||||
const QString &file = fileName.toString();
|
||||
forAllChildren([&testFunctions, &file](TestTreeItem *node) {
|
||||
if (node->type() == Type::TestFunctionOrSet && node->filePath() == file) {
|
||||
if (node->type() == Type::TestFunction && node->filePath() == file) {
|
||||
QTC_ASSERT(node->parentItem(), return);
|
||||
TestTreeItem *testCase = node->parentItem();
|
||||
QTC_ASSERT(testCase->type() == Type::TestCase, return);
|
||||
@@ -287,7 +287,7 @@ TestTreeItem *QtTestTreeItem::find(const TestParseResult *result)
|
||||
const QtTestParseResult *qtResult = static_cast<const QtTestParseResult *>(result);
|
||||
return findChildByNameAndInheritance(qtResult->displayName, qtResult->inherited());
|
||||
}
|
||||
case TestFunctionOrSet:
|
||||
case TestFunction:
|
||||
case TestDataFunction:
|
||||
case TestSpecialFunction:
|
||||
return findChildByName(result->name);
|
||||
@@ -306,12 +306,12 @@ TestTreeItem *QtTestTreeItem::findChild(const TestTreeItem *other)
|
||||
case GroupNode:
|
||||
return otherType == TestCase ? findChildByFile(other->filePath()) : nullptr;
|
||||
case TestCase: {
|
||||
if (otherType != TestFunctionOrSet && otherType != TestDataFunction && otherType != TestSpecialFunction)
|
||||
if (otherType != TestFunction && otherType != TestDataFunction && otherType != TestSpecialFunction)
|
||||
return nullptr;
|
||||
auto qtOther = static_cast<const QtTestTreeItem *>(other);
|
||||
return findChildByNameAndInheritance(other->filePath(), qtOther->inherited());
|
||||
}
|
||||
case TestFunctionOrSet:
|
||||
case TestFunction:
|
||||
case TestDataFunction:
|
||||
case TestSpecialFunction:
|
||||
return otherType == TestDataTag ? findChildByName(other->name()) : nullptr;
|
||||
@@ -327,7 +327,7 @@ bool QtTestTreeItem::modify(const TestParseResult *result)
|
||||
switch (type()) {
|
||||
case TestCase:
|
||||
return modifyTestCaseOrSuiteContent(result);
|
||||
case TestFunctionOrSet:
|
||||
case TestFunction:
|
||||
case TestDataFunction:
|
||||
case TestSpecialFunction:
|
||||
return modifyTestFunctionContent(result);
|
||||
|
@@ -82,7 +82,7 @@ bool TestVisitor::visit(CPlusPlus::Class *symbol)
|
||||
else if (name.endsWith("_data"))
|
||||
locationAndType.m_type = TestTreeItem::TestDataFunction;
|
||||
else
|
||||
locationAndType.m_type = TestTreeItem::TestFunctionOrSet;
|
||||
locationAndType.m_type = TestTreeItem::TestFunction;
|
||||
locationAndType.m_inherited = m_inherited;
|
||||
m_privSlots.insert(className + "::" + name, locationAndType);
|
||||
}
|
||||
|
@@ -65,7 +65,7 @@ QVariant QuickTestTreeItem::data(int column, int role) const
|
||||
return QVariant();
|
||||
case TestCase:
|
||||
return name().isEmpty() ? QVariant() : checked();
|
||||
case TestFunctionOrSet:
|
||||
case TestFunction:
|
||||
return (parentItem() && !parentItem()->name().isEmpty()) ? checked() : QVariant();
|
||||
default:
|
||||
return checked();
|
||||
@@ -78,7 +78,7 @@ QVariant QuickTestTreeItem::data(int column, int role) const
|
||||
return true;
|
||||
case TestCase:
|
||||
return name().isEmpty();
|
||||
case TestFunctionOrSet:
|
||||
case TestFunction:
|
||||
return parentItem() ? parentItem()->name().isEmpty() : false;
|
||||
default:
|
||||
return false;
|
||||
@@ -97,7 +97,7 @@ Qt::ItemFlags QuickTestTreeItem::flags(int column) const
|
||||
if (name().isEmpty())
|
||||
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
|
||||
break;
|
||||
case TestFunctionOrSet:
|
||||
case TestFunction:
|
||||
if (parentItem()->name().isEmpty())
|
||||
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
|
||||
break;
|
||||
@@ -111,7 +111,7 @@ bool QuickTestTreeItem::canProvideTestConfiguration() const
|
||||
switch (type()) {
|
||||
case TestCase:
|
||||
return !name().isEmpty();
|
||||
case TestFunctionOrSet:
|
||||
case TestFunction:
|
||||
return !parentItem()->name().isEmpty();
|
||||
default:
|
||||
return false;
|
||||
@@ -134,7 +134,7 @@ TestConfiguration *QuickTestTreeItem::testConfiguration() const
|
||||
const QString testName = name();
|
||||
QStringList testFunctions;
|
||||
forFirstLevelChildren([&testFunctions, &testName](TestTreeItem *child) {
|
||||
if (child->type() == TestTreeItem::TestFunctionOrSet)
|
||||
if (child->type() == TestTreeItem::TestFunction)
|
||||
testFunctions << testName + "::" + child->name();
|
||||
});
|
||||
config = new QuickTestConfiguration;
|
||||
@@ -143,7 +143,7 @@ TestConfiguration *QuickTestTreeItem::testConfiguration() const
|
||||
config->setProject(project);
|
||||
break;
|
||||
}
|
||||
case TestFunctionOrSet: {
|
||||
case TestFunction: {
|
||||
TestTreeItem *parent = parentItem();
|
||||
QStringList testFunction(parent->name() + "::" + name());
|
||||
config = new QuickTestConfiguration;
|
||||
@@ -177,7 +177,7 @@ static void testConfigurationFromCheckState(const TestTreeItem *item,
|
||||
const QString testName = item->name();
|
||||
QStringList testFunctions;
|
||||
item->forFirstLevelChildren([&testFunctions, &testName](TestTreeItem *child) {
|
||||
if (child->checked() == Qt::Checked && child->type() == TestTreeItem::TestFunctionOrSet)
|
||||
if (child->checked() == Qt::Checked && child->type() == TestTreeItem::TestFunction)
|
||||
testFunctions << testName + "::" + child->name();
|
||||
});
|
||||
if (foundProFiles.contains(item->proFile())) {
|
||||
@@ -290,7 +290,7 @@ QList<TestConfiguration *> QuickTestTreeItem::getTestConfigurationsForFile(const
|
||||
QHash<TestTreeItem *, QStringList> testFunctions;
|
||||
const QString &file = fileName.toString();
|
||||
forAllChildren([&testFunctions, &file](TestTreeItem *node) {
|
||||
if (node->type() == Type::TestFunctionOrSet && node->filePath() == file) {
|
||||
if (node->type() == Type::TestFunction && node->filePath() == file) {
|
||||
QTC_ASSERT(node->parentItem(), return);
|
||||
TestTreeItem *testCase = node->parentItem();
|
||||
QTC_ASSERT(testCase->type() == Type::TestCase, return);
|
||||
@@ -349,7 +349,7 @@ TestTreeItem *QuickTestTreeItem::findChild(const TestTreeItem *other)
|
||||
case GroupNode:
|
||||
return findChildByFileAndType(other->filePath(), otherType);
|
||||
case TestCase:
|
||||
if (otherType != TestFunctionOrSet && otherType != TestDataFunction && otherType != TestSpecialFunction)
|
||||
if (otherType != TestFunction && otherType != TestDataFunction && otherType != TestSpecialFunction)
|
||||
return nullptr;
|
||||
return name().isEmpty() ? findChildByNameAndFile(other->name(), other->filePath())
|
||||
: findChildByName(other->name());
|
||||
@@ -365,7 +365,7 @@ bool QuickTestTreeItem::modify(const TestParseResult *result)
|
||||
switch (type()) {
|
||||
case TestCase:
|
||||
return result->name.isEmpty() ? false : modifyTestCaseOrSuiteContent(result);
|
||||
case TestFunctionOrSet:
|
||||
case TestFunction:
|
||||
case TestDataFunction:
|
||||
case TestSpecialFunction:
|
||||
return name().isEmpty() ? modifyLineAndColumn(result)
|
||||
|
@@ -146,7 +146,7 @@ bool TestQmlVisitor::visit(QmlJS::AST::FunctionDeclaration *ast)
|
||||
else if (name.endsWith("_data"))
|
||||
locationAndType.m_type = TestTreeItem::TestDataFunction;
|
||||
else
|
||||
locationAndType.m_type = TestTreeItem::TestFunctionOrSet;
|
||||
locationAndType.m_type = TestTreeItem::TestFunction;
|
||||
|
||||
m_testFunctions.insert(name.toString(), locationAndType);
|
||||
}
|
||||
|
@@ -49,7 +49,7 @@ TestTreeItem::TestTreeItem(const QString &name, const QString &filePath, Type ty
|
||||
case GroupNode:
|
||||
case TestSuite:
|
||||
case TestCase:
|
||||
case TestFunctionOrSet:
|
||||
case TestFunction:
|
||||
m_checked = Qt::Checked;
|
||||
break;
|
||||
default:
|
||||
@@ -125,7 +125,7 @@ Qt::ItemFlags TestTreeItem::flags(int /*column*/) const
|
||||
case TestSuite:
|
||||
case TestCase:
|
||||
return defaultFlags | Qt::ItemIsAutoTristate | Qt::ItemIsUserCheckable;
|
||||
case TestFunctionOrSet:
|
||||
case TestFunction:
|
||||
return defaultFlags | Qt::ItemIsUserCheckable;
|
||||
default:
|
||||
return defaultFlags;
|
||||
@@ -175,7 +175,7 @@ Qt::CheckState TestTreeItem::checked() const
|
||||
case GroupNode:
|
||||
case TestSuite:
|
||||
case TestCase:
|
||||
case TestFunctionOrSet:
|
||||
case TestFunction:
|
||||
case TestDataTag:
|
||||
return m_checked;
|
||||
default:
|
||||
|
@@ -61,7 +61,7 @@ public:
|
||||
GroupNode,
|
||||
TestSuite,
|
||||
TestCase,
|
||||
TestFunctionOrSet,
|
||||
TestFunction,
|
||||
TestDataTag,
|
||||
TestDataFunction,
|
||||
TestSpecialFunction
|
||||
|
@@ -178,7 +178,7 @@ QList<TestTreeItem *> TestTreeModel::testItemsByName(TestTreeItem *root, const Q
|
||||
}
|
||||
TestTreeItem *testCase = node->findFirstLevelChild([&testName](TestTreeItem *it) {
|
||||
QTC_ASSERT(it, return false);
|
||||
return it->type() == TestTreeItem::TestFunctionOrSet && it->name() == testName;
|
||||
return it->type() == TestTreeItem::TestFunction && it->name() == testName;
|
||||
}); // collect only actual tests, not special functions like init, cleanup etc.
|
||||
if (testCase)
|
||||
result << testCase;
|
||||
|
Reference in New Issue
Block a user