Commit 5a3a879a authored by Christian Stenger's avatar Christian Stenger

AutoTest: Unify naming scheme for gtest related classes and files

Change-Id: Ib0739889cbc6416da3f28f1e39b197317ec8a4e6
Reviewed-by: default avatarDavid Schulz <david.schulz@theqtcompany.com>
parent af81016e
......@@ -23,9 +23,9 @@ SOURCES += \
testsettingspage.cpp \
testnavigationwidget.cpp \
testoutputreader.cpp \
gtest/googletestconfiguration.cpp \
gtest/googletestparser.cpp \
gtest/googletesttreeitem.cpp \
gtest/gtestconfiguration.cpp \
gtest/gtestparser.cpp \
gtest/gtesttreeitem.cpp \
gtest/gtestresult.cpp \
gtest/gtestoutputreader.cpp \
gtest/gtestvisitors.cpp \
......@@ -63,9 +63,9 @@ HEADERS += \
testoutputreader.h \
autotesticons.h \
itestparser.h \
gtest/googletestconfiguration.h \
gtest/googletestparser.h \
gtest/googletesttreeitem.h \
gtest/gtestconfiguration.h \
gtest/gtestparser.h \
gtest/gtesttreeitem.h \
gtest/gtestoutputreader.h \
gtest/gtestresult.h \
gtest/gtest_utils.h \
......
......@@ -23,20 +23,20 @@
**
****************************************************************************/
#include "googletestconfiguration.h"
#include "gtestconfiguration.h"
#include "gtestoutputreader.h"
#include "../testsettings.h"
namespace Autotest {
namespace Internal {
TestOutputReader *GoogleTestConfiguration::outputReader(const QFutureInterface<TestResultPtr> &fi,
QProcess *app) const
TestOutputReader *GTestConfiguration::outputReader(const QFutureInterface<TestResultPtr> &fi,
QProcess *app) const
{
return new GTestOutputReader(fi, app, buildDirectory());
}
QStringList GoogleTestConfiguration::argumentsForTestRunner(const TestSettings &settings) const
QStringList GTestConfiguration::argumentsForTestRunner(const TestSettings &settings) const
{
QStringList arguments;
const QStringList &testSets = testCases();
......
......@@ -30,10 +30,10 @@
namespace Autotest {
namespace Internal {
class GoogleTestConfiguration : public TestConfiguration
class GTestConfiguration : public TestConfiguration
{
public:
explicit GoogleTestConfiguration() {}
explicit GTestConfiguration() {}
TestOutputReader *outputReader(const QFutureInterface<TestResultPtr> &fi,
QProcess *app) const override;
QStringList argumentsForTestRunner(const TestSettings &settings) const override;
......
......@@ -23,8 +23,8 @@
**
****************************************************************************/
#include "googletestparser.h"
#include "googletesttreeitem.h"
#include "gtestparser.h"
#include "gtesttreeitem.h"
#include "gtestvisitors.h"
#include "gtest_utils.h"
#include "../autotest_utils.h"
......@@ -32,10 +32,10 @@
namespace Autotest {
namespace Internal {
TestTreeItem *GoogleTestParseResult::createTestTreeItem() const
TestTreeItem *GTestParseResult::createTestTreeItem() const
{
if (itemType == TestTreeItem::TestCase || itemType == TestTreeItem::TestFunctionOrSet)
return GoogleTestTreeItem::createTestItem(this);
return GTestTreeItem::createTestItem(this);
return 0;
}
......@@ -91,7 +91,7 @@ static bool handleGTest(QFutureInterface<TestParseResultPtr> futureInterface,
proFile = ppList.first()->projectFile;
foreach (const GTestCaseSpec &testSpec, result.keys()) {
GoogleTestParseResult *parseResult = new GoogleTestParseResult;
GTestParseResult *parseResult = new GTestParseResult;
parseResult->itemType = TestTreeItem::TestCase;
parseResult->fileName = filePath;
parseResult->name = testSpec.testCaseName;
......@@ -101,12 +101,12 @@ static bool handleGTest(QFutureInterface<TestParseResultPtr> futureInterface,
parseResult->proFile = proFile;
foreach (const GTestCodeLocationAndType &location, result.value(testSpec)) {
GoogleTestParseResult *testSet = new GoogleTestParseResult;
GTestParseResult *testSet = new GTestParseResult;
testSet->name = location.m_name;
testSet->fileName = filePath;
testSet->line = location.m_line;
testSet->column = location.m_column;
testSet->disabled = location.m_state & GoogleTestTreeItem::Disabled;
testSet->disabled = location.m_state & GTestTreeItem::Disabled;
testSet->itemType = location.m_type;
testSet->proFile = proFile;
......@@ -118,8 +118,8 @@ static bool handleGTest(QFutureInterface<TestParseResultPtr> futureInterface,
return !result.keys().isEmpty();
}
bool GoogleTestParser::processDocument(QFutureInterface<TestParseResultPtr> futureInterface,
const QString &fileName)
bool GTestParser::processDocument(QFutureInterface<TestParseResultPtr> futureInterface,
const QString &fileName)
{
if (!m_cppSnapshot.contains(fileName) || !selectedForBuilding(fileName))
return false;
......
......@@ -30,17 +30,17 @@
namespace Autotest {
namespace Internal {
class GoogleTestParseResult : public TestParseResult
class GTestParseResult : public TestParseResult
{
public:
explicit GoogleTestParseResult() : TestParseResult(TestTreeModel::GoogleTest) {}
explicit GTestParseResult() : TestParseResult(TestTreeModel::GoogleTest) {}
TestTreeItem *createTestTreeItem() const override;
bool parameterized = false;
bool typed = false;
bool disabled = false;
};
class GoogleTestParser : public CppParser
class GTestParser : public CppParser
{
public:
bool processDocument(QFutureInterface<TestParseResultPtr> futureInterface,
......
......@@ -23,9 +23,9 @@
**
****************************************************************************/
#include "googletesttreeitem.h"
#include "googletestconfiguration.h"
#include "googletestparser.h"
#include "gtesttreeitem.h"
#include "gtestconfiguration.h"
#include "gtestparser.h"
#include "../autotest_utils.h"
#include <projectexplorer/session.h>
......@@ -34,22 +34,22 @@
namespace Autotest {
namespace Internal {
static QString gtestFilter(GoogleTestTreeItem::TestStates states)
static QString gtestFilter(GTestTreeItem::TestStates states)
{
if ((states & GoogleTestTreeItem::Parameterized) && (states & GoogleTestTreeItem::Typed))
if ((states & GTestTreeItem::Parameterized) && (states & GTestTreeItem::Typed))
return QLatin1String("*/%1/*.%2");
if (states & GoogleTestTreeItem::Parameterized)
if (states & GTestTreeItem::Parameterized)
return QLatin1String("*/%1.%2/*");
if (states & GoogleTestTreeItem::Typed)
if (states & GTestTreeItem::Typed)
return QLatin1String("%1/*.%2");
return QLatin1String("%1.%2");
}
GoogleTestTreeItem *GoogleTestTreeItem::createTestItem(const TestParseResult *result)
GTestTreeItem *GTestTreeItem::createTestItem(const TestParseResult *result)
{
const GoogleTestParseResult *parseResult = static_cast<const GoogleTestParseResult *>(result);
GoogleTestTreeItem *item = new GoogleTestTreeItem(parseResult->name, parseResult->fileName,
parseResult->itemType);
const GTestParseResult *parseResult = static_cast<const GTestParseResult *>(result);
GTestTreeItem *item = new GTestTreeItem(parseResult->name, parseResult->fileName,
parseResult->itemType);
item->setProFile(parseResult->proFile);
item->setLine(parseResult->line);
item->setColumn(parseResult->column);
......@@ -65,7 +65,7 @@ GoogleTestTreeItem *GoogleTestTreeItem::createTestItem(const TestParseResult *re
return item;
}
QVariant GoogleTestTreeItem::data(int column, int role) const
QVariant GTestTreeItem::data(int column, int role) const
{
switch (role) {
case Qt::DisplayRole: {
......@@ -93,17 +93,17 @@ QVariant GoogleTestTreeItem::data(int column, int role) const
return TestTreeItem::data(column, role);
}
TestConfiguration *GoogleTestTreeItem::testConfiguration() const
TestConfiguration *GTestTreeItem::testConfiguration() const
{
ProjectExplorer::Project *project = ProjectExplorer::SessionManager::startupProject();
QTC_ASSERT(project, return 0);
GoogleTestConfiguration *config = 0;
GTestConfiguration *config = 0;
switch (type()) {
case TestCase: {
const QString &testSpecifier = gtestFilter(state()).arg(name()).arg(QLatin1Char('*'));
if (int count = childCount()) {
config = new GoogleTestConfiguration;
config = new GTestConfiguration;
config->setTestCases(QStringList(testSpecifier));
config->setTestCaseCount(count);
config->setProFile(proFile());
......@@ -115,11 +115,11 @@ TestConfiguration *GoogleTestTreeItem::testConfiguration() const
break;
}
case TestFunctionOrSet: {
GoogleTestTreeItem *parent = static_cast<GoogleTestTreeItem *>(parentItem());
GTestTreeItem *parent = static_cast<GTestTreeItem *>(parentItem());
if (!parent)
return 0;
const QString &testSpecifier = gtestFilter(parent->state()).arg(parent->name()).arg(name());
config = new GoogleTestConfiguration;
config = new GTestConfiguration;
config->setTestCases(QStringList(testSpecifier));
config->setProFile(proFile());
config->setProject(project);
......@@ -161,7 +161,7 @@ uint qHash(const ProFileWithDisplayName &lhs)
return ::qHash(lhs.proFile) ^ ::qHash(lhs.displayName);
}
QList<TestConfiguration *> GoogleTestTreeItem::getAllTestConfigurations() const
QList<TestConfiguration *> GTestTreeItem::getAllTestConfigurations() const
{
QList<TestConfiguration *> result;
......@@ -171,7 +171,7 @@ QList<TestConfiguration *> GoogleTestTreeItem::getAllTestConfigurations() const
QHash<ProFileWithDisplayName, int> proFilesWithTestSets;
for (int row = 0, count = childCount(); row < count; ++row) {
const GoogleTestTreeItem *child = static_cast<const GoogleTestTreeItem *>(childItem(row));
const GTestTreeItem *child = static_cast<const GTestTreeItem *>(childItem(row));
const int grandChildCount = child->childCount();
for (int grandChildRow = 0; grandChildRow < grandChildCount; ++grandChildRow) {
......@@ -190,7 +190,7 @@ QList<TestConfiguration *> GoogleTestTreeItem::getAllTestConfigurations() const
QHash<ProFileWithDisplayName, int>::ConstIterator end = proFilesWithTestSets.end();
for ( ; it != end; ++it) {
const ProFileWithDisplayName &key = it.key();
GoogleTestConfiguration *tc = new GoogleTestConfiguration;
GTestConfiguration *tc = new GTestConfiguration;
tc->setTestCaseCount(it.value());
tc->setProFile(key.proFile);
tc->setDisplayName(key.displayName);
......@@ -201,7 +201,7 @@ QList<TestConfiguration *> GoogleTestTreeItem::getAllTestConfigurations() const
return result;
}
QList<TestConfiguration *> GoogleTestTreeItem::getSelectedTestConfigurations() const
QList<TestConfiguration *> GTestTreeItem::getSelectedTestConfigurations() const
{
QList<TestConfiguration *> result;
ProjectExplorer::Project *project = ProjectExplorer::SessionManager::startupProject();
......@@ -210,7 +210,7 @@ QList<TestConfiguration *> GoogleTestTreeItem::getSelectedTestConfigurations() c
QHash<ProFileWithDisplayName, QStringList> proFilesWithCheckedTestSets;
for (int row = 0, count = childCount(); row < count; ++row) {
const GoogleTestTreeItem *child = static_cast<const GoogleTestTreeItem *>(childItem(row));
const GTestTreeItem *child = static_cast<const GTestTreeItem *>(childItem(row));
if (child->checked() == Qt::Unchecked)
continue;
......@@ -232,7 +232,7 @@ QList<TestConfiguration *> GoogleTestTreeItem::getSelectedTestConfigurations() c
QHash<ProFileWithDisplayName, QStringList>::ConstIterator end = proFilesWithCheckedTestSets.end();
for ( ; it != end; ++it) {
const ProFileWithDisplayName &key = it.key();
GoogleTestConfiguration *tc = new GoogleTestConfiguration;
GTestConfiguration *tc = new GTestConfiguration;
tc->setTestCases(it.value());
tc->setProFile(key.proFile);
tc->setDisplayName(key.displayName);
......@@ -243,17 +243,17 @@ QList<TestConfiguration *> GoogleTestTreeItem::getSelectedTestConfigurations() c
return result;
}
TestTreeItem *GoogleTestTreeItem::find(const TestParseResult *result)
TestTreeItem *GTestTreeItem::find(const TestParseResult *result)
{
QTC_ASSERT(result, return 0);
const GoogleTestParseResult *parseResult = static_cast<const GoogleTestParseResult *>(result);
GoogleTestTreeItem::TestStates states = parseResult->disabled ? GoogleTestTreeItem::Disabled
: GoogleTestTreeItem::Enabled;
const GTestParseResult *parseResult = static_cast<const GTestParseResult *>(result);
GTestTreeItem::TestStates states = parseResult->disabled ? GTestTreeItem::Disabled
: GTestTreeItem::Enabled;
if (parseResult->parameterized)
states |= GoogleTestTreeItem::Parameterized;
states |= GTestTreeItem::Parameterized;
if (parseResult->typed)
states |= GoogleTestTreeItem::Typed;
states |= GTestTreeItem::Typed;
switch (type()) {
case Root:
return findChildByNameStateAndFile(parseResult->name, states, parseResult->proFile);
......@@ -264,23 +264,23 @@ TestTreeItem *GoogleTestTreeItem::find(const TestParseResult *result)
}
}
bool GoogleTestTreeItem::modify(const TestParseResult *result)
bool GTestTreeItem::modify(const TestParseResult *result)
{
QTC_ASSERT(result, return false);
switch (type()) {
case TestFunctionOrSet:
return modifyTestSetContent(static_cast<const GoogleTestParseResult *>(result));
return modifyTestSetContent(static_cast<const GTestParseResult *>(result));
default:
return false;
}
}
bool GoogleTestTreeItem::modifyTestSetContent(const GoogleTestParseResult *result)
bool GTestTreeItem::modifyTestSetContent(const GTestParseResult *result)
{
bool hasBeenModified = modifyLineAndColumn(result->line, result->column);
GoogleTestTreeItem::TestStates states = result->disabled ? GoogleTestTreeItem::Disabled
: GoogleTestTreeItem::Enabled;
GTestTreeItem::TestStates states = result->disabled ? GTestTreeItem::Disabled
: GTestTreeItem::Enabled;
if (m_state != states) {
m_state = states;
hasBeenModified = true;
......@@ -288,22 +288,22 @@ bool GoogleTestTreeItem::modifyTestSetContent(const GoogleTestParseResult *resul
return hasBeenModified;
}
TestTreeItem *GoogleTestTreeItem::findChildByNameStateAndFile(const QString &name,
GoogleTestTreeItem::TestStates state,
const QString &proFile) const
TestTreeItem *GTestTreeItem::findChildByNameStateAndFile(const QString &name,
GTestTreeItem::TestStates state,
const QString &proFile) const
{
return findChildBy([name, state, proFile](const TestTreeItem *other) -> bool {
const GoogleTestTreeItem *gtestItem = static_cast<const GoogleTestTreeItem *>(other);
const GTestTreeItem *gtestItem = static_cast<const GTestTreeItem *>(other);
return other->proFile() == proFile
&& other->name() == name
&& gtestItem->state() == state;
});
}
QString GoogleTestTreeItem::nameSuffix() const
QString GTestTreeItem::nameSuffix() const
{
static QString markups[] = { QCoreApplication::translate("GoogleTestTreeItem", "parameterized"),
QCoreApplication::translate("GoogleTestTreeItem", "typed") };
static QString markups[] = { QCoreApplication::translate("GTestTreeItem", "parameterized"),
QCoreApplication::translate("GTestTreeItem", "typed") };
QString suffix;
if (m_state & Parameterized)
suffix = QLatin1String(" [") + markups[0];
......
......@@ -30,9 +30,9 @@
namespace Autotest {
namespace Internal {
class GoogleTestParseResult;
class GTestParseResult;
class GoogleTestTreeItem : public TestTreeItem
class GTestTreeItem : public TestTreeItem
{
public:
enum TestState
......@@ -46,10 +46,10 @@ public:
Q_FLAGS(TestState)
Q_DECLARE_FLAGS(TestStates, TestState)
GoogleTestTreeItem(const QString &name = QString(), const QString &filePath = QString(),
Type type = Root) : TestTreeItem(name, filePath, type), m_state(Enabled) {}
GTestTreeItem(const QString &name = QString(), const QString &filePath = QString(),
Type type = Root) : TestTreeItem(name, filePath, type), m_state(Enabled) {}
static GoogleTestTreeItem *createTestItem(const TestParseResult *result);
static GTestTreeItem *createTestItem(const TestParseResult *result);
QVariant data(int column, int role) const override;
bool canProvideTestConfiguration() const override { return type() != Root; }
......@@ -62,20 +62,20 @@ public:
void setStates(TestStates states) { m_state = states; }
void setState(TestState state) { m_state |= state; }
TestStates state() const { return m_state; }
bool modifyTestSetContent(const GoogleTestParseResult *result);
bool modifyTestSetContent(const GTestParseResult *result);
TestTreeItem *findChildByNameStateAndFile(const QString &name,
GoogleTestTreeItem::TestStates state,
GTestTreeItem::TestStates state,
const QString &proFile) const;
QString nameSuffix() const;
private:
GoogleTestTreeItem::TestStates m_state;
GTestTreeItem::TestStates m_state;
};
class GTestCodeLocationAndType : public TestCodeLocationAndType
{
public:
GoogleTestTreeItem::TestStates m_state;
GTestTreeItem::TestStates m_state;
};
typedef QVector<GTestCodeLocationAndType> GTestCodeLocationList;
......
......@@ -70,8 +70,8 @@ bool GTestVisitor::visit(CPlusPlus::FunctionDefinitionAST *ast)
locationAndType.m_line = line;
locationAndType.m_column = column - 1;
locationAndType.m_type = TestTreeItem::TestFunctionOrSet;
locationAndType.m_state = disabled ? GoogleTestTreeItem::Disabled
: GoogleTestTreeItem::Enabled;
locationAndType.m_state = disabled ? GTestTreeItem::Disabled
: GTestTreeItem::Enabled;
GTestCaseSpec spec;
spec.testCaseName = testCaseName;
spec.parameterized = GTestUtils::isGTestParameterized(prettyName);
......
......@@ -25,7 +25,7 @@
#pragma once
#include "googletesttreeitem.h"
#include "gtesttreeitem.h"
#include <cplusplus/ASTVisitor.h>
#include <cplusplus/CppDocument.h>
......
......@@ -30,7 +30,7 @@
// FIXME
#include "qtest/qttestparser.h"
#include "quick/quicktestparser.h"
#include "gtest/googletestparser.h"
#include "gtest/gtestparser.h"
// end of FIXME
#include <coreplugin/editormanager/editormanager.h>
......@@ -84,7 +84,7 @@ TestCodeParser::TestCodeParser(TestTreeModel *parent)
m_testCodeParsers.append(new QtTestParser);
m_testCodeParsers.append(new QuickTestParser);
m_testCodeParsers.append(new GoogleTestParser);
m_testCodeParsers.append(new GTestParser);
}
TestCodeParser::~TestCodeParser()
......
......@@ -33,7 +33,7 @@
// FIXME
#include "qtest/qttesttreeitem.h"
#include "quick/quicktesttreeitem.h"
#include "gtest/googletesttreeitem.h"
#include "gtest/gtesttreeitem.h"
// end of FIXME
#include <cpptools/cppmodelmanager.h>
......@@ -50,7 +50,7 @@ TestTreeModel::TestTreeModel(QObject *parent) :
TreeModel(parent),
m_qtTestRootItem(new QtTestTreeItem(tr("Qt Tests"), QString(), TestTreeItem::Root)),
m_quickTestRootItem(new QuickTestTreeItem(tr("Qt Quick Tests"), QString(), TestTreeItem::Root)),
m_googleTestRootItem(new GoogleTestTreeItem(tr("Google Tests"), QString(), TestTreeItem::Root)),
m_googleTestRootItem(new GTestTreeItem(tr("Google Tests"), QString(), TestTreeItem::Root)),
m_parser(new TestCodeParser(this)),
m_connectionsInitialized(false)
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment