don't pollute the Autotest namespace with an enum

Change-Id: Ic6c3e3beaba15e83c8524394ccc6a1953e76d59a
Reviewed-by: Christian Stenger <christian.stenger@theqtcompany.com>
This commit is contained in:
Tim Jenssen
2015-01-08 13:46:28 +01:00
parent e0616dc889
commit 0c9531f384
7 changed files with 161 additions and 159 deletions

View File

@@ -21,13 +21,13 @@
namespace Autotest { namespace Autotest {
namespace Internal { namespace Internal {
FaultyTestResult::FaultyTestResult(ResultType result, const QString &description) FaultyTestResult::FaultyTestResult(Result::Type result, const QString &description)
: TestResult(QString(), QString(), QString(), result, description) : TestResult(QString(), QString(), QString(), result, description)
{ {
} }
TestResult::TestResult(const QString &className, const QString &testCase, const QString &dataTag, TestResult::TestResult(const QString &className, const QString &testCase, const QString &dataTag,
ResultType result, const QString &description) Result::Type result, const QString &description)
: m_class(className), : m_class(className),
m_case(testCase), m_case(testCase),
m_dataTag(dataTag), m_dataTag(dataTag),
@@ -37,125 +37,125 @@ TestResult::TestResult(const QString &className, const QString &testCase, const
{ {
} }
ResultType TestResult::resultFromString(const QString &resultString) Result::Type TestResult::resultFromString(const QString &resultString)
{ {
if (resultString == QLatin1String("pass")) if (resultString == QLatin1String("pass"))
return PASS; return Result::PASS;
if (resultString == QLatin1String("fail")) if (resultString == QLatin1String("fail"))
return FAIL; return Result::FAIL;
if (resultString == QLatin1String("xfail")) if (resultString == QLatin1String("xfail"))
return EXPECTED_FAIL; return Result::EXPECTED_FAIL;
if (resultString == QLatin1String("xpass")) if (resultString == QLatin1String("xpass"))
return UNEXPECTED_PASS; return Result::UNEXPECTED_PASS;
if (resultString == QLatin1String("skip")) if (resultString == QLatin1String("skip"))
return SKIP; return Result::SKIP;
if (resultString == QLatin1String("qdebug")) if (resultString == QLatin1String("qdebug"))
return MESSAGE_DEBUG; return Result::MESSAGE_DEBUG;
if (resultString == QLatin1String("warn") || resultString == QLatin1String("qwarn")) if (resultString == QLatin1String("warn") || resultString == QLatin1String("qwarn"))
return MESSAGE_WARN; return Result::MESSAGE_WARN;
if (resultString == QLatin1String("qfatal")) if (resultString == QLatin1String("qfatal"))
return MESSAGE_FATAL; return Result::MESSAGE_FATAL;
if (resultString == QLatin1String("bpass")) if (resultString == QLatin1String("bpass"))
return BLACKLISTED_PASS; return Result::BLACKLISTED_PASS;
if (resultString == QLatin1String("bfail")) if (resultString == QLatin1String("bfail"))
return BLACKLISTED_FAIL; return Result::BLACKLISTED_FAIL;
qDebug(" unexpected testresult..."); qDebug(" unexpected testresult...");
qDebug(resultString.toLatin1()); qDebug(resultString.toLatin1());
return UNKNOWN; return Result::UNKNOWN;
} }
ResultType TestResult::toResultType(int rt) Result::Type TestResult::toResultType(int rt)
{ {
switch(rt) { switch(rt) {
case PASS: case Result::PASS:
return PASS; return Result::PASS;
case FAIL: case Result::FAIL:
return FAIL; return Result::FAIL;
case EXPECTED_FAIL: case Result::EXPECTED_FAIL:
return EXPECTED_FAIL; return Result::EXPECTED_FAIL;
case UNEXPECTED_PASS: case Result::UNEXPECTED_PASS:
return UNEXPECTED_PASS; return Result::UNEXPECTED_PASS;
case SKIP: case Result::SKIP:
return SKIP; return Result::SKIP;
case BLACKLISTED_PASS: case Result::BLACKLISTED_PASS:
return BLACKLISTED_PASS; return Result::BLACKLISTED_PASS;
case BLACKLISTED_FAIL: case Result::BLACKLISTED_FAIL:
return BLACKLISTED_FAIL; return Result::BLACKLISTED_FAIL;
case BENCHMARK: case Result::BENCHMARK:
return BENCHMARK; return Result::BENCHMARK;
case MESSAGE_DEBUG: case Result::MESSAGE_DEBUG:
return MESSAGE_DEBUG; return Result::MESSAGE_DEBUG;
case MESSAGE_WARN: case Result::MESSAGE_WARN:
return MESSAGE_WARN; return Result::MESSAGE_WARN;
case MESSAGE_FATAL: case Result::MESSAGE_FATAL:
return MESSAGE_FATAL; return Result::MESSAGE_FATAL;
case MESSAGE_INTERNAL: case Result::MESSAGE_INTERNAL:
return MESSAGE_INTERNAL; return Result::MESSAGE_INTERNAL;
case MESSAGE_CURRENT_TEST: case Result::MESSAGE_CURRENT_TEST:
return MESSAGE_CURRENT_TEST; return Result::MESSAGE_CURRENT_TEST;
default: default:
return UNKNOWN; return Result::UNKNOWN;
} }
} }
QString TestResult::resultToString(const ResultType type) QString TestResult::resultToString(const Result::Type type)
{ {
switch(type) { switch(type) {
case PASS: case Result::PASS:
return QLatin1String("PASS"); return QLatin1String("PASS");
case FAIL: case Result::FAIL:
return QLatin1String("FAIL"); return QLatin1String("FAIL");
case EXPECTED_FAIL: case Result::EXPECTED_FAIL:
return QLatin1String("XFAIL"); return QLatin1String("XFAIL");
case UNEXPECTED_PASS: case Result::UNEXPECTED_PASS:
return QLatin1String("XPASS"); return QLatin1String("XPASS");
case SKIP: case Result::SKIP:
return QLatin1String("SKIP"); return QLatin1String("SKIP");
case BENCHMARK: case Result::BENCHMARK:
return QLatin1String("BENCH"); return QLatin1String("BENCH");
case MESSAGE_DEBUG: case Result::MESSAGE_DEBUG:
return QLatin1String("DEBUG"); return QLatin1String("DEBUG");
case MESSAGE_WARN: case Result::MESSAGE_WARN:
return QLatin1String("WARN"); return QLatin1String("WARN");
case MESSAGE_FATAL: case Result::MESSAGE_FATAL:
return QLatin1String("FATAL"); return QLatin1String("FATAL");
case MESSAGE_INTERNAL: case Result::MESSAGE_INTERNAL:
case MESSAGE_CURRENT_TEST: case Result::MESSAGE_CURRENT_TEST:
return QString(); return QString();
case BLACKLISTED_PASS: case Result::BLACKLISTED_PASS:
return QLatin1String("BPASS"); return QLatin1String("BPASS");
case BLACKLISTED_FAIL: case Result::BLACKLISTED_FAIL:
return QLatin1String("BFAIL"); return QLatin1String("BFAIL");
default: default:
return QLatin1String("UNKNOWN"); return QLatin1String("UNKNOWN");
} }
} }
QColor TestResult::colorForType(const ResultType type) QColor TestResult::colorForType(const Result::Type type)
{ {
switch(type) { switch(type) {
case PASS: case Result::PASS:
return QColor("#009900"); return QColor("#009900");
case FAIL: case Result::FAIL:
return QColor("#a00000"); return QColor("#a00000");
case EXPECTED_FAIL: case Result::EXPECTED_FAIL:
return QColor("#00ff00"); return QColor("#00ff00");
case UNEXPECTED_PASS: case Result::UNEXPECTED_PASS:
return QColor("#ff0000"); return QColor("#ff0000");
case SKIP: case Result::SKIP:
return QColor("#787878"); return QColor("#787878");
case BLACKLISTED_PASS: case Result::BLACKLISTED_PASS:
return QColor(0, 0, 0); return QColor(0, 0, 0);
case BLACKLISTED_FAIL: case Result::BLACKLISTED_FAIL:
return QColor(0, 0, 0); return QColor(0, 0, 0);
case MESSAGE_DEBUG: case Result::MESSAGE_DEBUG:
return QColor("#329696"); return QColor("#329696");
case MESSAGE_WARN: case Result::MESSAGE_WARN:
return QColor("#d0bb00"); return QColor("#d0bb00");
case MESSAGE_FATAL: case Result::MESSAGE_FATAL:
return QColor("#640000"); return QColor("#640000");
case MESSAGE_INTERNAL: case Result::MESSAGE_INTERNAL:
case MESSAGE_CURRENT_TEST: case Result::MESSAGE_CURRENT_TEST:
return QColor("transparent"); return QColor("transparent");
default: default:
return QColor("#000000"); return QColor("#000000");

View File

@@ -25,7 +25,8 @@
namespace Autotest { namespace Autotest {
namespace Internal { namespace Internal {
enum ResultType { namespace Result{
enum Type {
PASS, PASS,
FAIL, FAIL,
EXPECTED_FAIL, EXPECTED_FAIL,
@@ -41,6 +42,7 @@ enum ResultType {
MESSAGE_CURRENT_TEST, MESSAGE_CURRENT_TEST,
UNKNOWN // ??? UNKNOWN // ???
}; };
}
class TestResult class TestResult
{ {
@@ -48,12 +50,12 @@ public:
TestResult(const QString &className = QString(), const QString &testCase = QString(), TestResult(const QString &className = QString(), const QString &testCase = QString(),
const QString &dataTag = QString(), const QString &dataTag = QString(),
ResultType result = UNKNOWN, const QString &description = QString()); Result::Type result = Result::UNKNOWN, const QString &description = QString());
QString className() const { return m_class; } QString className() const { return m_class; }
QString testCase() const { return m_case; } QString testCase() const { return m_case; }
QString dataTag() const { return m_dataTag; } QString dataTag() const { return m_dataTag; }
ResultType result() const { return m_result; } Result::Type result() const { return m_result; }
QString description() const { return m_description; } QString description() const { return m_description; }
QString fileName() const { return m_file; } QString fileName() const { return m_file; }
int line() const { return m_line; } int line() const { return m_line; }
@@ -62,16 +64,16 @@ public:
void setFileName(const QString &fileName) { m_file = fileName; } void setFileName(const QString &fileName) { m_file = fileName; }
void setLine(int line) { m_line = line; } void setLine(int line) { m_line = line; }
static ResultType resultFromString(const QString &resultString); static Result::Type resultFromString(const QString &resultString);
static ResultType toResultType(int rt); static Result::Type toResultType(int rt);
static QString resultToString(const ResultType type); static QString resultToString(const Result::Type type);
static QColor colorForType(const ResultType type); static QColor colorForType(const Result::Type type);
private: private:
QString m_class; QString m_class;
QString m_case; QString m_case;
QString m_dataTag; QString m_dataTag;
ResultType m_result; Result::Type m_result;
QString m_description; QString m_description;
QString m_file; QString m_file;
int m_line; int m_line;
@@ -81,7 +83,7 @@ private:
class FaultyTestResult : public TestResult class FaultyTestResult : public TestResult
{ {
public: public:
FaultyTestResult(ResultType result, const QString &description); FaultyTestResult(Result::Type result, const QString &description);
}; };
bool operator==(const TestResult &t1, const TestResult &t2); bool operator==(const TestResult &t1, const TestResult &t2);
@@ -90,6 +92,6 @@ bool operator==(const TestResult &t1, const TestResult &t2);
} // namespace Autotest } // namespace Autotest
Q_DECLARE_METATYPE(Autotest::Internal::TestResult) Q_DECLARE_METATYPE(Autotest::Internal::TestResult)
Q_DECLARE_METATYPE(Autotest::Internal::ResultType) Q_DECLARE_METATYPE(Autotest::Internal::Result::Type)
#endif // TESTRESULT_H #endif // TESTRESULT_H

View File

@@ -68,7 +68,7 @@ void TestResultDelegate::paint(QPainter *painter, const QStyleOptionViewItem &op
TestResultModel *resultModel = static_cast<TestResultModel *>(resultFilterModel->sourceModel()); TestResultModel *resultModel = static_cast<TestResultModel *>(resultFilterModel->sourceModel());
LayoutPositions positions(opt, resultModel); LayoutPositions positions(opt, resultModel);
TestResult testResult = resultModel->testResult(resultFilterModel->mapToSource(index)); TestResult testResult = resultModel->testResult(resultFilterModel->mapToSource(index));
ResultType type = testResult.result(); Result::Type type = testResult.result();
QIcon icon = index.data(Qt::DecorationRole).value<QIcon>(); QIcon icon = index.data(Qt::DecorationRole).value<QIcon>();
if (!icon.isNull()) if (!icon.isNull())
@@ -88,12 +88,12 @@ void TestResultDelegate::paint(QPainter *painter, const QStyleOptionViewItem &op
const QString desc = testResult.description(); const QString desc = testResult.description();
QString output; QString output;
switch (type) { switch (type) {
case ResultType::PASS: case Result::PASS:
case ResultType::FAIL: case Result::FAIL:
case ResultType::EXPECTED_FAIL: case Result::EXPECTED_FAIL:
case ResultType::UNEXPECTED_PASS: case Result::UNEXPECTED_PASS:
case ResultType::BLACKLISTED_FAIL: case Result::BLACKLISTED_FAIL:
case ResultType::BLACKLISTED_PASS: case Result::BLACKLISTED_PASS:
output = testResult.className() + QLatin1String("::") + testResult.testCase(); output = testResult.className() + QLatin1String("::") + testResult.testCase();
if (!testResult.dataTag().isEmpty()) if (!testResult.dataTag().isEmpty())
output.append(QString::fromLatin1(" (%1)").arg(testResult.dataTag())); output.append(QString::fromLatin1(" (%1)").arg(testResult.dataTag()));
@@ -101,7 +101,7 @@ void TestResultDelegate::paint(QPainter *painter, const QStyleOptionViewItem &op
output.append(QLatin1Char('\n')).append(desc); output.append(QLatin1Char('\n')).append(desc);
} }
break; break;
case ResultType::BENCHMARK: case Result::BENCHMARK:
output = testResult.className() + QLatin1String("::") + testResult.testCase(); output = testResult.className() + QLatin1String("::") + testResult.testCase();
if (!testResult.dataTag().isEmpty()) if (!testResult.dataTag().isEmpty())
output.append(QString::fromLatin1(" (%1)").arg(testResult.dataTag())); output.append(QString::fromLatin1(" (%1)").arg(testResult.dataTag()));
@@ -202,12 +202,12 @@ QSize TestResultDelegate::sizeHint(const QStyleOptionViewItem &option, const QMo
QString desc = testResult.description(); QString desc = testResult.description();
QString output; QString output;
switch (testResult.result()) { switch (testResult.result()) {
case ResultType::PASS: case Result::PASS:
case ResultType::FAIL: case Result::FAIL:
case ResultType::EXPECTED_FAIL: case Result::EXPECTED_FAIL:
case ResultType::UNEXPECTED_PASS: case Result::UNEXPECTED_PASS:
case ResultType::BLACKLISTED_FAIL: case Result::BLACKLISTED_FAIL:
case ResultType::BLACKLISTED_PASS: case Result::BLACKLISTED_PASS:
output = testResult.className() + QLatin1String("::") + testResult.testCase(); output = testResult.className() + QLatin1String("::") + testResult.testCase();
if (!testResult.dataTag().isEmpty()) if (!testResult.dataTag().isEmpty())
output.append(QString::fromLatin1(" (%1)").arg(testResult.dataTag())); output.append(QString::fromLatin1(" (%1)").arg(testResult.dataTag()));
@@ -215,7 +215,7 @@ QSize TestResultDelegate::sizeHint(const QStyleOptionViewItem &option, const QMo
output.append(QLatin1Char('\n')).append(desc); output.append(QLatin1Char('\n')).append(desc);
} }
break; break;
case ResultType::BENCHMARK: case Result::BENCHMARK:
output = testResult.className() + QLatin1String("::") + testResult.testCase(); output = testResult.className() + QLatin1String("::") + testResult.testCase();
if (!testResult.dataTag().isEmpty()) if (!testResult.dataTag().isEmpty())
output.append(QString::fromLatin1(" (%1)").arg(testResult.dataTag())); output.append(QString::fromLatin1(" (%1)").arg(testResult.dataTag()));

View File

@@ -61,7 +61,7 @@ int TestResultModel::columnCount(const QModelIndex &parent) const
return parent.isValid() ? 0 : 1; return parent.isValid() ? 0 : 1;
} }
static QIcon testResultIcon(ResultType result) { static QIcon testResultIcon(Result::Type result) {
static QIcon icons[11] = { static QIcon icons[11] = {
QIcon(QLatin1String(":/images/pass.png")), QIcon(QLatin1String(":/images/pass.png")),
QIcon(QLatin1String(":/images/fail.png")), QIcon(QLatin1String(":/images/fail.png")),
@@ -76,7 +76,7 @@ static QIcon testResultIcon(ResultType result) {
QIcon(QLatin1String(":/images/fatal.png")), QIcon(QLatin1String(":/images/fatal.png")),
}; // provide an icon for unknown?? }; // provide an icon for unknown??
if (result < 0 || result >= MESSAGE_INTERNAL) if (result < 0 || result >= Result::MESSAGE_INTERNAL)
return QIcon(); return QIcon();
return icons[result]; return icons[result];
} }
@@ -88,14 +88,14 @@ QVariant TestResultModel::data(const QModelIndex &index, int role) const
if (role == Qt::DisplayRole) { if (role == Qt::DisplayRole) {
const TestResult &tr = m_testResults.at(index.row()); const TestResult &tr = m_testResults.at(index.row());
switch (tr.result()) { switch (tr.result()) {
case ResultType::PASS: case Result::PASS:
case ResultType::FAIL: case Result::FAIL:
case ResultType::EXPECTED_FAIL: case Result::EXPECTED_FAIL:
case ResultType::UNEXPECTED_PASS: case Result::UNEXPECTED_PASS:
case ResultType::SKIP: case Result::SKIP:
case ResultType::BLACKLISTED_PASS: case Result::BLACKLISTED_PASS:
case ResultType::BLACKLISTED_FAIL: case Result::BLACKLISTED_FAIL:
case ResultType::BENCHMARK: case Result::BENCHMARK:
return QString::fromLatin1("%1::%2 (%3) - %4").arg(tr.className(), tr.testCase(), return QString::fromLatin1("%1::%2 (%3) - %4").arg(tr.className(), tr.testCase(),
tr.dataTag(), tr.fileName()); tr.dataTag(), tr.fileName());
default: default:
@@ -112,8 +112,8 @@ QVariant TestResultModel::data(const QModelIndex &index, int role) const
void TestResultModel::addTestResult(const TestResult &testResult) void TestResultModel::addTestResult(const TestResult &testResult)
{ {
const bool isCurrentTestMssg = testResult.result() == ResultType::MESSAGE_CURRENT_TEST; const bool isCurrentTestMssg = testResult.result() == Result::MESSAGE_CURRENT_TEST;
const bool hasCurrentTestMssg = m_availableResultTypes.contains(ResultType::MESSAGE_CURRENT_TEST); const bool hasCurrentTestMssg = m_availableResultTypes.contains(Result::MESSAGE_CURRENT_TEST);
int position = m_testResults.size(); int position = m_testResults.size();
@@ -139,11 +139,11 @@ void TestResultModel::addTestResult(const TestResult &testResult)
void TestResultModel::removeCurrentTestMessage() void TestResultModel::removeCurrentTestMessage()
{ {
if (m_availableResultTypes.contains(ResultType::MESSAGE_CURRENT_TEST)) { if (m_availableResultTypes.contains(Result::MESSAGE_CURRENT_TEST)) {
beginRemoveRows(QModelIndex(), m_testResults.size() - 1, m_testResults.size() - 1); beginRemoveRows(QModelIndex(), m_testResults.size() - 1, m_testResults.size() - 1);
m_testResults.removeLast(); m_testResults.removeLast();
endRemoveRows(); endRemoveRows();
m_availableResultTypes.remove(ResultType::MESSAGE_CURRENT_TEST); m_availableResultTypes.remove(Result::MESSAGE_CURRENT_TEST);
} }
} }
@@ -201,7 +201,7 @@ int TestResultModel::maxWidthOfLineNumber(const QFont &font)
return m_widthOfLineNumber; return m_widthOfLineNumber;
} }
int TestResultModel::resultTypeCount(ResultType type) int TestResultModel::resultTypeCount(Result::Type type)
{ {
return m_testResultCount.value(type, 0); return m_testResultCount.value(type, 0);
} }
@@ -218,16 +218,16 @@ TestResultFilterModel::TestResultFilterModel(TestResultModel *sourceModel, QObje
void TestResultFilterModel::enableAllResultTypes() void TestResultFilterModel::enableAllResultTypes()
{ {
m_enabled << ResultType::PASS << ResultType::FAIL << ResultType::EXPECTED_FAIL m_enabled << Result::PASS << Result::FAIL << Result::EXPECTED_FAIL
<< ResultType::UNEXPECTED_PASS << ResultType::SKIP << ResultType::MESSAGE_DEBUG << Result::UNEXPECTED_PASS << Result::SKIP << Result::MESSAGE_DEBUG
<< ResultType::MESSAGE_WARN << ResultType::MESSAGE_INTERNAL << Result::MESSAGE_WARN << Result::MESSAGE_INTERNAL
<< ResultType::MESSAGE_FATAL << ResultType::UNKNOWN << ResultType::BLACKLISTED_PASS << Result::MESSAGE_FATAL << Result::UNKNOWN << Result::BLACKLISTED_PASS
<< ResultType::BLACKLISTED_FAIL << ResultType::BENCHMARK << Result::BLACKLISTED_FAIL << Result::BENCHMARK
<< ResultType::MESSAGE_CURRENT_TEST; << Result::MESSAGE_CURRENT_TEST;
invalidateFilter(); invalidateFilter();
} }
void TestResultFilterModel::toggleTestResultType(ResultType type) void TestResultFilterModel::toggleTestResultType(Result::Type type)
{ {
if (m_enabled.contains(type)) { if (m_enabled.contains(type)) {
m_enabled.remove(type); m_enabled.remove(type);

View File

@@ -51,8 +51,8 @@ public:
int maxWidthOfFileName(const QFont &font); int maxWidthOfFileName(const QFont &font);
int maxWidthOfLineNumber(const QFont &font); int maxWidthOfLineNumber(const QFont &font);
bool hasResultType(ResultType type) { return m_availableResultTypes.contains(type); } bool hasResultType(Result::Type type) { return m_availableResultTypes.contains(type); }
int resultTypeCount(ResultType type); int resultTypeCount(Result::Type type);
signals: signals:
@@ -60,12 +60,12 @@ public slots:
private: private:
QList<TestResult> m_testResults; QList<TestResult> m_testResults;
QMap<ResultType, int> m_testResultCount; QMap<Result::Type, int> m_testResultCount;
int m_widthOfLineNumber; int m_widthOfLineNumber;
int m_maxWidthOfFileName; int m_maxWidthOfFileName;
int m_lastMaxWidthIndex; int m_lastMaxWidthIndex;
QFont m_measurementFont; QFont m_measurementFont;
QSet<ResultType> m_availableResultTypes; QSet<Result::Type> m_availableResultTypes;
}; };
class TestResultFilterModel : public QSortFilterProxyModel class TestResultFilterModel : public QSortFilterProxyModel
@@ -75,7 +75,7 @@ public:
TestResultFilterModel(TestResultModel *sourceModel, QObject *parent = 0); TestResultFilterModel(TestResultModel *sourceModel, QObject *parent = 0);
void enableAllResultTypes(); void enableAllResultTypes();
void toggleTestResultType(ResultType type); void toggleTestResultType(Result::Type type);
void clearTestResults(); void clearTestResults();
bool hasResults(); bool hasResults();
TestResult testResult(const QModelIndex &index) const; TestResult testResult(const QModelIndex &index) const;
@@ -85,7 +85,7 @@ protected:
private: private:
TestResultModel *m_sourceModel; TestResultModel *m_sourceModel;
QSet<ResultType> m_enabled; QSet<Result::Type> m_enabled;
}; };
} // namespace Internal } // namespace Internal

View File

@@ -276,23 +276,23 @@ void TestResultsPane::initializeFilterMenu()
const bool omitIntern = AutotestPlugin::instance()->settings()->omitInternalMssg; const bool omitIntern = AutotestPlugin::instance()->settings()->omitInternalMssg;
// FilterModel has all messages enabled by default // FilterModel has all messages enabled by default
if (omitIntern) if (omitIntern)
m_filterModel->toggleTestResultType(ResultType::MESSAGE_INTERNAL); m_filterModel->toggleTestResultType(Result::MESSAGE_INTERNAL);
QMap<ResultType, QString> textAndType; QMap<Result::Type, QString> textAndType;
textAndType.insert(ResultType::PASS, tr("Pass")); textAndType.insert(Result::PASS, tr("Pass"));
textAndType.insert(ResultType::FAIL, tr("Fail")); textAndType.insert(Result::FAIL, tr("Fail"));
textAndType.insert(ResultType::EXPECTED_FAIL, tr("Expected Fail")); textAndType.insert(Result::EXPECTED_FAIL, tr("Expected Fail"));
textAndType.insert(ResultType::UNEXPECTED_PASS, tr("Unexpected Pass")); textAndType.insert(Result::UNEXPECTED_PASS, tr("Unexpected Pass"));
textAndType.insert(ResultType::SKIP, tr("Skip")); textAndType.insert(Result::SKIP, tr("Skip"));
textAndType.insert(ResultType::BENCHMARK, tr("Benchmarks")); textAndType.insert(Result::BENCHMARK, tr("Benchmarks"));
textAndType.insert(ResultType::MESSAGE_DEBUG, tr("Debug Messages")); textAndType.insert(Result::MESSAGE_DEBUG, tr("Debug Messages"));
textAndType.insert(ResultType::MESSAGE_WARN, tr("Warning Messages")); textAndType.insert(Result::MESSAGE_WARN, tr("Warning Messages"));
textAndType.insert(ResultType::MESSAGE_INTERNAL, tr("Internal Messages")); textAndType.insert(Result::MESSAGE_INTERNAL, tr("Internal Messages"));
foreach (ResultType result, textAndType.keys()) { foreach (Result::Type result, textAndType.keys()) {
QAction *action = new QAction(m_filterMenu); QAction *action = new QAction(m_filterMenu);
action->setText(textAndType.value(result)); action->setText(textAndType.value(result));
action->setCheckable(true); action->setCheckable(true);
action->setChecked(result != ResultType::MESSAGE_INTERNAL || !omitIntern); action->setChecked(result != Result::MESSAGE_INTERNAL || !omitIntern);
action->setData(result); action->setData(result);
m_filterMenu->addAction(action); m_filterMenu->addAction(action);
} }
@@ -307,22 +307,22 @@ void TestResultsPane::initializeFilterMenu()
void TestResultsPane::updateSummaryLabel() void TestResultsPane::updateSummaryLabel()
{ {
QString labelText = QString::fromLatin1("<p><b>Test Summary:</b>&nbsp;&nbsp; %1 %2, %3 %4") QString labelText = QString::fromLatin1("<p><b>Test Summary:</b>&nbsp;&nbsp; %1 %2, %3 %4")
.arg(QString::number(m_model->resultTypeCount(ResultType::PASS)), tr("passes"), .arg(QString::number(m_model->resultTypeCount(Result::PASS)), tr("passes"),
QString::number(m_model->resultTypeCount(ResultType::FAIL)), tr("fails")); QString::number(m_model->resultTypeCount(Result::FAIL)), tr("fails"));
int count = m_model->resultTypeCount(ResultType::UNEXPECTED_PASS); int count = m_model->resultTypeCount(Result::UNEXPECTED_PASS);
if (count) if (count)
labelText.append(QString::fromLatin1(", %1 %2") labelText.append(QString::fromLatin1(", %1 %2")
.arg(QString::number(count), tr("unexpected passes"))); .arg(QString::number(count), tr("unexpected passes")));
count = m_model->resultTypeCount(ResultType::EXPECTED_FAIL); count = m_model->resultTypeCount(Result::EXPECTED_FAIL);
if (count) if (count)
labelText.append(QString::fromLatin1(", %1 %2") labelText.append(QString::fromLatin1(", %1 %2")
.arg(QString::number(count), tr("expected fails"))); .arg(QString::number(count), tr("expected fails")));
count = m_model->resultTypeCount(ResultType::MESSAGE_FATAL); count = m_model->resultTypeCount(Result::MESSAGE_FATAL);
if (count) if (count)
labelText.append(QString::fromLatin1(", %1 %2") labelText.append(QString::fromLatin1(", %1 %2")
.arg(QString::number(count), tr("fatals"))); .arg(QString::number(count), tr("fatals")));
count = m_model->resultTypeCount(ResultType::BLACKLISTED_FAIL) count = m_model->resultTypeCount(Result::BLACKLISTED_FAIL)
+ m_model->resultTypeCount(ResultType::BLACKLISTED_PASS); + m_model->resultTypeCount(Result::BLACKLISTED_PASS);
if (count) if (count)
labelText.append(QString::fromLatin1(", %1 %2") labelText.append(QString::fromLatin1(", %1 %2")
.arg(QString::number(count), tr("blacklisted"))); .arg(QString::number(count), tr("blacklisted")));

View File

@@ -99,7 +99,7 @@ static bool xmlCData(const QString &code, const QString &start, QString &result)
} }
static bool xmlExtractTypeFileLine(const QString &code, const QString &tagStart, static bool xmlExtractTypeFileLine(const QString &code, const QString &tagStart,
ResultType &result, QString &file, int &line) Result::Type &result, QString &file, int &line)
{ {
if (code.startsWith(tagStart)) { if (code.startsWith(tagStart)) {
int start = code.indexOf(QLatin1String(" type=\"")) + 7; int start = code.indexOf(QLatin1String(" type=\"")) + 7;
@@ -206,7 +206,7 @@ void processOutput()
static QString className; static QString className;
static QString testCase; static QString testCase;
static QString dataTag; static QString dataTag;
static ResultType result = ResultType::UNKNOWN; static Result::Type result = Result::UNKNOWN;
static QString description; static QString description;
static QString file; static QString file;
static int lineNumber = 0; static int lineNumber = 0;
@@ -230,11 +230,11 @@ void processOutput()
description = QString(); description = QString();
duration = QString(); duration = QString();
file = QString(); file = QString();
result = ResultType::UNKNOWN; result = Result::UNKNOWN;
lineNumber = 0; lineNumber = 0;
readingDescription = false; readingDescription = false;
emitTestResultCreated( emitTestResultCreated(
TestResult(QString(), QString(), QString(), ResultType::MESSAGE_CURRENT_TEST, TestResult(QString(), QString(), QString(), Result::MESSAGE_CURRENT_TEST,
QObject::tr("Entering Test Function %1::%2") QObject::tr("Entering Test Function %1::%2")
.arg(className).arg(testCase))); .arg(className).arg(testCase)));
continue; continue;
@@ -263,7 +263,7 @@ void processOutput()
continue; continue;
} }
if (xmlExtractBenchmarkInformation(line, QLatin1String("<BenchmarkResult"), bmDescription)) { if (xmlExtractBenchmarkInformation(line, QLatin1String("<BenchmarkResult"), bmDescription)) {
TestResult testResult(className, testCase, dataTag, ResultType::BENCHMARK, bmDescription); TestResult testResult(className, testCase, dataTag, Result::BENCHMARK, bmDescription);
emitTestResultCreated(testResult); emitTestResultCreated(testResult);
continue; continue;
} }
@@ -276,12 +276,12 @@ void processOutput()
emitTestResultCreated(testResult); emitTestResultCreated(testResult);
description = QString(); description = QString();
} else if (line == QLatin1String("</TestFunction>") && !duration.isEmpty()) { } else if (line == QLatin1String("</TestFunction>") && !duration.isEmpty()) {
TestResult testResult(className, testCase, QString(), ResultType::MESSAGE_INTERNAL, TestResult testResult(className, testCase, QString(), Result::MESSAGE_INTERNAL,
QObject::tr("execution took %1ms").arg(duration)); QObject::tr("execution took %1ms").arg(duration));
emitTestResultCreated(testResult); emitTestResultCreated(testResult);
m_currentFuture->setProgressValue(m_currentFuture->progressValue() + 1); m_currentFuture->setProgressValue(m_currentFuture->progressValue() + 1);
} else if (line == QLatin1String("</TestCase>") && !duration.isEmpty()) { } else if (line == QLatin1String("</TestCase>") && !duration.isEmpty()) {
TestResult testResult(className, QString(), QString(), ResultType::MESSAGE_INTERNAL, TestResult testResult(className, QString(), QString(), Result::MESSAGE_INTERNAL,
QObject::tr("Test execution took %1ms").arg(duration)); QObject::tr("Test execution took %1ms").arg(duration));
emitTestResultCreated(testResult); emitTestResultCreated(testResult);
} else if (readingDescription) { } else if (readingDescription) {
@@ -294,10 +294,10 @@ void processOutput()
description.append(line); description.append(line);
} }
} else if (xmlStartsWith(line, QLatin1String("<QtVersion>"), qtVersion)) { } else if (xmlStartsWith(line, QLatin1String("<QtVersion>"), qtVersion)) {
emitTestResultCreated(FaultyTestResult(ResultType::MESSAGE_INTERNAL, emitTestResultCreated(FaultyTestResult(Result::MESSAGE_INTERNAL,
QObject::tr("Qt Version: %1").arg(qtVersion))); QObject::tr("Qt Version: %1").arg(qtVersion)));
} else if (xmlStartsWith(line, QLatin1String("<QTestVersion>"), qtestVersion)) { } else if (xmlStartsWith(line, QLatin1String("<QTestVersion>"), qtestVersion)) {
emitTestResultCreated(FaultyTestResult(ResultType::MESSAGE_INTERNAL, emitTestResultCreated(FaultyTestResult(Result::MESSAGE_INTERNAL,
QObject::tr("QTest Version: %1").arg(qtestVersion))); QObject::tr("QTest Version: %1").arg(qtestVersion)));
} else { } else {
// qDebug() << "Unhandled line:" << line; // TODO remove // qDebug() << "Unhandled line:" << line; // TODO remove
@@ -349,7 +349,7 @@ bool performExec(const QString &cmd, const QStringList &args, const QString &wor
} }
if (runCmd.isEmpty()) { if (runCmd.isEmpty()) {
emitTestResultCreated(FaultyTestResult(ResultType::MESSAGE_FATAL, emitTestResultCreated(FaultyTestResult(Result::MESSAGE_FATAL,
QObject::tr("*** Could not find command '%1' ***").arg(cmd))); QObject::tr("*** Could not find command '%1' ***").arg(cmd)));
return false; return false;
} }
@@ -371,7 +371,7 @@ bool performExec(const QString &cmd, const QStringList &args, const QString &wor
if (m_currentFuture->isCanceled()) { if (m_currentFuture->isCanceled()) {
m_runner->kill(); m_runner->kill();
m_runner->waitForFinished(); m_runner->waitForFinished();
emitTestResultCreated(FaultyTestResult(ResultType::MESSAGE_FATAL, emitTestResultCreated(FaultyTestResult(Result::MESSAGE_FATAL,
QObject::tr("*** Test Run canceled by user ***"))); QObject::tr("*** Test Run canceled by user ***")));
} }
qApp->processEvents(); qApp->processEvents();
@@ -383,7 +383,7 @@ bool performExec(const QString &cmd, const QStringList &args, const QString &wor
if (m_runner->state() != QProcess::NotRunning) { if (m_runner->state() != QProcess::NotRunning) {
m_runner->kill(); m_runner->kill();
m_runner->waitForFinished(); m_runner->waitForFinished();
emitTestResultCreated(FaultyTestResult(ResultType::MESSAGE_FATAL, emitTestResultCreated(FaultyTestResult(Result::MESSAGE_FATAL,
QObject::tr("*** Test Case canceled due to timeout ***\nMaybe raise the timeout?"))); QObject::tr("*** Test Case canceled due to timeout ***\nMaybe raise the timeout?")));
} }
return false; return false;
@@ -443,7 +443,7 @@ void TestRunner::runTests()
foreach (TestConfiguration *config, m_selectedTests) foreach (TestConfiguration *config, m_selectedTests)
if (!config->project()) { if (!config->project()) {
toBeRemoved.append(config); toBeRemoved.append(config);
TestResultsPane::instance()->addTestResult(FaultyTestResult(ResultType::MESSAGE_WARN, TestResultsPane::instance()->addTestResult(FaultyTestResult(Result::MESSAGE_WARN,
tr("*** Project is null for '%1' - removing from Test Run ***\n" tr("*** Project is null for '%1' - removing from Test Run ***\n"
"This might be the case for a faulty environment or similar." "This might be the case for a faulty environment or similar."
).arg(config->displayName()))); ).arg(config->displayName())));
@@ -454,14 +454,14 @@ void TestRunner::runTests()
} }
if (m_selectedTests.empty()) { if (m_selectedTests.empty()) {
TestResultsPane::instance()->addTestResult(FaultyTestResult(ResultType::MESSAGE_WARN, TestResultsPane::instance()->addTestResult(FaultyTestResult(Result::MESSAGE_WARN,
tr("*** No tests selected - canceling Test Run ***"))); tr("*** No tests selected - canceling Test Run ***")));
return; return;
} }
ProjectExplorer::Project *project = m_selectedTests.at(0)->project(); ProjectExplorer::Project *project = m_selectedTests.at(0)->project();
if (!project) { if (!project) {
TestResultsPane::instance()->addTestResult(FaultyTestResult(ResultType::MESSAGE_WARN, TestResultsPane::instance()->addTestResult(FaultyTestResult(Result::MESSAGE_WARN,
tr("*** Project is null - canceling Test Run ***\n" tr("*** Project is null - canceling Test Run ***\n"
"Actually only Desktop kits are supported - make sure the " "Actually only Desktop kits are supported - make sure the "
"current active kit is a Desktop kit."))); "current active kit is a Desktop kit.")));
@@ -472,7 +472,7 @@ void TestRunner::runTests()
ProjectExplorer::ProjectExplorerPlugin::projectExplorerSettings(); ProjectExplorer::ProjectExplorerPlugin::projectExplorerSettings();
if (pes.buildBeforeDeploy) { if (pes.buildBeforeDeploy) {
if (!project->hasActiveBuildSettings()) { if (!project->hasActiveBuildSettings()) {
TestResultsPane::instance()->addTestResult(FaultyTestResult(ResultType::MESSAGE_FATAL, TestResultsPane::instance()->addTestResult(FaultyTestResult(Result::MESSAGE_FATAL,
tr("*** Project is not configured - canceling Test Run ***"))); tr("*** Project is not configured - canceling Test Run ***")));
return; return;
} }
@@ -482,7 +482,7 @@ void TestRunner::runTests()
} }
if (!m_buildSucceeded) { if (!m_buildSucceeded) {
TestResultsPane::instance()->addTestResult(FaultyTestResult(ResultType::MESSAGE_FATAL, TestResultsPane::instance()->addTestResult(FaultyTestResult(Result::MESSAGE_FATAL,
tr("*** Build failed - canceling Test Run ***"))); tr("*** Build failed - canceling Test Run ***")));
return; return;
} }