Move TestType enum into constants...

...to avoid defining the enum in several places although almost
having the same meaning.
Additionally rename the values to ensure not to run in a name
clash at some point.

Change-Id: I0f23041b785c87efd3e7feebef855042595473f6
Reviewed-by: Niels Weber <niels.weber@theqtcompany.com>
This commit is contained in:
Christian Stenger
2016-01-12 13:52:21 +01:00
committed by Niels Weber
parent 97011c6951
commit 54d753574e
8 changed files with 28 additions and 25 deletions

View File

@@ -36,8 +36,18 @@ const char TASK_PARSE[] = "AutoTest.Task.Parse";
const char UNNAMED_QUICKTESTS[] = QT_TR_NOOP("<unnamed>");
const char AUTOTEST_SETTINGS_CATEGORY[] = "ZY.Tests";
} // namespace Autotest
} // namespace Constants
namespace Internal {
enum TestType
{
TestTypeQt,
TestTypeGTest
};
} // namespace Internal
} // namespace Autotest
#endif // AUTOTESTCONSTANTS_H

View File

@@ -43,7 +43,7 @@ TestConfiguration::TestConfiguration(const QString &testClass, const QStringList
m_unnamedOnly(false),
m_project(0),
m_guessedConfiguration(false),
m_type(Qt)
m_type(TestTypeQt)
{
if (testCases.size() != 0)
m_testCaseCount = testCases.size();

View File

@@ -20,6 +20,8 @@
#ifndef TESTCONFIGURATION_H
#define TESTCONFIGURATION_H
#include "autotestconstants.h"
#include <utils/environment.h>
#include <QObject>
@@ -37,11 +39,6 @@ class TestConfiguration : public QObject
{
Q_OBJECT
public:
enum TestType {
Qt,
GTest
};
explicit TestConfiguration(const QString &testClass, const QStringList &testCases,
int testCaseCount = 0, QObject *parent = 0);
~TestConfiguration();

View File

@@ -37,7 +37,7 @@ TestResult::TestResult(const QString &className)
: m_class(className)
, m_result(Result::Invalid)
, m_line(0)
, m_type(Qt)
, m_type(TestTypeQt)
{
}
@@ -155,7 +155,7 @@ QTestResult::QTestResult(const QString &className)
GTestResult::GTestResult(const QString &className)
: TestResult(className)
{
setTestType(GTest);
setTestType(TestTypeGTest);
}
} // namespace Internal

View File

@@ -20,6 +20,8 @@
#ifndef TESTRESULT_H
#define TESTRESULT_H
#include "autotestconstants.h"
#include <QString>
#include <QColor>
#include <QMetaType>
@@ -58,12 +60,6 @@ enum Type {
class TestResult
{
public:
enum TestType
{
Qt,
GTest
};
TestResult();
TestResult(const QString &className);

View File

@@ -48,9 +48,9 @@ QString TestResultDelegate::outputString(const TestResult &testResult, bool sele
case Result::UnexpectedPass:
case Result::BlacklistedFail:
case Result::BlacklistedPass:
if (testResult.type() == TestResult::Qt)
if (testResult.type() == TestTypeQt)
output = testResult.className() + QLatin1String("::") + testResult.testCase();
else // TestResult::GTest
else // TestTypeGTest
output = testResult.testCase();
if (!testResult.dataTag().isEmpty())
output.append(QString::fromLatin1(" (%1)").arg(testResult.dataTag()));

View File

@@ -142,8 +142,8 @@ void performTestRun(QFutureInterface<void> &futureInterface,
if (connection)
QObject::disconnect(connection);
TestConfiguration::TestType testType = testConfiguration->testType();
if (testType == TestConfiguration::Qt) {
TestType testType = testConfiguration->testType();
if (testType == TestTypeQt) {
connection = QObject::connect(&testProcess, &QProcess::readyRead, &outputReader,
&TestOutputReader::processOutput);
} else {
@@ -166,14 +166,14 @@ void performTestRun(QFutureInterface<void> &futureInterface,
continue;
}
if (testType == TestConfiguration::Qt) {
if (testType == TestTypeQt) {
QStringList argumentList(QLatin1String("-xml"));
if (!metricsOption.isEmpty())
argumentList << metricsOption;
if (testConfiguration->testCases().count())
argumentList << testConfiguration->testCases();
testProcess.setArguments(argumentList);
} else { // TestConfiguration::GTest
} else { // TestTypeGTest
const QStringList &testSets = testConfiguration->testCases();
if (testSets.size()) {
QStringList argumentList;

View File

@@ -256,7 +256,7 @@ QList<TestConfiguration *> TestTreeModel::getAllTestCases() const
foundMains.value(proFile));
tc->setProFile(proFile);
tc->setProject(project);
tc->setTestType(TestConfiguration::GTest);
tc->setTestType(TestTypeGTest);
result << tc;
}
@@ -398,7 +398,7 @@ QList<TestConfiguration *> TestTreeModel::getSelectedTests() const
foreach (const QString &proFile, proFilesWithEnabledTestSets.keys()) {
TestConfiguration *tc = new TestConfiguration(QString(),
proFilesWithEnabledTestSets.value(proFile));
tc->setTestType(TestConfiguration::GTest);
tc->setTestType(TestTypeGTest);
tc->setProFile(proFile);
tc->setProject(project);
result << tc;
@@ -468,7 +468,7 @@ TestConfiguration *TestTreeModel::getTestConfiguration(const TestTreeItem *item)
config->setTestCaseCount(childCount);
config->setProFile(item->childItem(0)->mainFile());
config->setProject(project);
config->setTestType(TestConfiguration::GTest);
config->setTestType(TestTypeGTest);
}
break;
}
@@ -478,7 +478,7 @@ TestConfiguration *TestTreeModel::getTestConfiguration(const TestTreeItem *item)
QStringList(parent->name() + QLatin1Char('.') + item->name()));
config->setProFile(item->mainFile());
config->setProject(project);
config->setTestType(TestConfiguration::GTest);
config->setTestType(TestTypeGTest);
break;
}
// not supported items