Add special message to results pane

This message just states which function actually is executed and will
always be on the bottom of the list of results.
When test run finishes this message will be completely removed.

Change-Id: Ie8fedfc74f67eba71a2bcf55f4dc1553754fca9a
Reviewed-by: Christian Stenger <christian.stenger@theqtcompany.com>
This commit is contained in:
Christian Stenger
2014-12-05 14:01:16 +01:00
parent e71a2c44fc
commit ac24550a22
6 changed files with 48 additions and 6 deletions

View File

@@ -86,6 +86,8 @@ ResultType TestResult::toResultType(int rt)
return MESSAGE_FATAL;
case MESSAGE_INTERNAL:
return MESSAGE_INTERNAL;
case MESSAGE_CURRENT_TEST:
return MESSAGE_CURRENT_TEST;
default:
return UNKNOWN;
}
@@ -113,6 +115,7 @@ QString TestResult::resultToString(const ResultType type)
case MESSAGE_FATAL:
return QLatin1String("FATAL");
case MESSAGE_INTERNAL:
case MESSAGE_CURRENT_TEST:
return QString();
case BLACKLISTED_PASS:
return QLatin1String("BPASS");
@@ -147,6 +150,7 @@ QColor TestResult::colorForType(const ResultType type)
case MESSAGE_FATAL:
return QColor("#640000");
case MESSAGE_INTERNAL:
case MESSAGE_CURRENT_TEST:
return QColor("transparent");
default:
return QColor("#000000");

View File

@@ -38,6 +38,7 @@ enum ResultType {
MESSAGE_WARN,
MESSAGE_FATAL,
MESSAGE_INTERNAL,
MESSAGE_CURRENT_TEST,
UNKNOWN // ???
};

View File

@@ -115,18 +115,48 @@ QVariant TestResultModel::data(const QModelIndex &index, int role) const
void TestResultModel::addTestResult(const TestResult &testResult)
{
const bool isCurrentTestMssg = testResult.result() == ResultType::MESSAGE_CURRENT_TEST;
const bool hasCurrentTestMssg = m_availableResultTypes.contains(ResultType::MESSAGE_CURRENT_TEST);
QReadLocker rLock(&m_rwLock);
beginInsertRows(QModelIndex(), m_testResults.size(), m_testResults.size());
int position = m_testResults.size();
rLock.unlock();
QWriteLocker wLock(&m_rwLock);
m_testResults.append(testResult);
if (hasCurrentTestMssg && isCurrentTestMssg) {
beginRemoveRows(QModelIndex(), position, position);
m_testResults.replace(position - 1, testResult);
endRemoveRows();
} else {
if (!isCurrentTestMssg && position) // decrement only if at least one other item
--position;
beginInsertRows(QModelIndex(), position, position);
m_testResults.insert(position, testResult);
endInsertRows();
}
wLock.unlock();
if (!isCurrentTestMssg) {
int count = m_testResultCount.value(testResult.result(), 0);
m_testResultCount.insert(testResult.result(), ++count);
endInsertRows();
}
m_availableResultTypes.insert(testResult.result());
}
void TestResultModel::removeCurrentTestMessage()
{
QReadLocker rLock(&m_rwLock);
if (m_availableResultTypes.contains(ResultType::MESSAGE_CURRENT_TEST)) {
rLock.unlock();
QWriteLocker wLock(&m_rwLock);
beginRemoveRows(QModelIndex(), m_testResults.size() - 1, m_testResults.size() - 1);
m_testResults.removeLast();
endRemoveRows();
m_availableResultTypes.remove(ResultType::MESSAGE_CURRENT_TEST);
}
}
void TestResultModel::clearTestResults()
{
QReadLocker rLock(&m_rwLock);
@@ -211,7 +241,8 @@ void TestResultFilterModel::enableAllResultTypes()
<< ResultType::UNEXPECTED_PASS << ResultType::SKIP << ResultType::MESSAGE_DEBUG
<< ResultType::MESSAGE_WARN << ResultType::MESSAGE_INTERNAL
<< ResultType::MESSAGE_FATAL << ResultType::UNKNOWN << ResultType::BLACKLISTED_PASS
<< ResultType::BLACKLISTED_FAIL << ResultType::BENCHMARK;
<< ResultType::BLACKLISTED_FAIL << ResultType::BENCHMARK
<< ResultType::MESSAGE_CURRENT_TEST;
invalidateFilter();
}

View File

@@ -43,6 +43,7 @@ public:
QVariant data(const QModelIndex &index, int role) const;
void addTestResult(const TestResult &testResult);
void removeCurrentTestMessage();
void clearTestResults();
bool hasResults() const { return m_testResults.size() > 0; }

View File

@@ -370,6 +370,7 @@ void TestResultsPane::onTestRunFinished()
m_runSelected->setEnabled(true);
updateSummaryLabel();
m_summaryWidget->setVisible(true);
m_model->removeCurrentTestMessage();
}
void TestResultsPane::onTestTreeModelChanged()

View File

@@ -228,6 +228,10 @@ void processOutput()
result = ResultType::UNKNOWN;
lineNumber = 0;
readingDescription = false;
TestResultsPane::instance()->addTestResult(
TestResult(className, testCase, QString(), ResultType::MESSAGE_CURRENT_TEST,
QObject::tr("Entering Test Function %1::%2")
.arg(className).arg(testCase)));
continue;
}
if (xmlStartsWith(line, QLatin1String("<Duration msecs=\""), duration)) {