Simplify qtestlib logging code, part 2
Rename the QTestLogger class to QXunitTestLogger. Change-Id: I7b93f9de4f4744e53997ccc001a745c36f375599 Reviewed-on: http://codereview.qt.nokia.com/3924 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
This commit is contained in:
parent
b17e9b3d94
commit
d88b335d08
@ -40,7 +40,7 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "qtestbasicstreamer.h"
|
#include "qtestbasicstreamer.h"
|
||||||
#include "qtestlogger_p.h"
|
#include "qxunittestlogger_p.h"
|
||||||
#include "qtestelement.h"
|
#include "qtestelement.h"
|
||||||
#include "qtestelementattribute.h"
|
#include "qtestelementattribute.h"
|
||||||
#include "qtestassert.h"
|
#include "qtestassert.h"
|
||||||
@ -54,7 +54,7 @@
|
|||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
QTestBasicStreamer::QTestBasicStreamer(QTestLogger *logger)
|
QTestBasicStreamer::QTestBasicStreamer(QXunitTestLogger *logger)
|
||||||
:testLogger(logger)
|
:testLogger(logger)
|
||||||
{
|
{
|
||||||
QTEST_ASSERT(testLogger);
|
QTEST_ASSERT(testLogger);
|
||||||
@ -156,7 +156,7 @@ void QTestBasicStreamer::outputString(const char *msg) const
|
|||||||
testLogger->outputString(msg);
|
testLogger->outputString(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
QTestLogger *QTestBasicStreamer::logger() const
|
QXunitTestLogger *QTestBasicStreamer::logger() const
|
||||||
{
|
{
|
||||||
return testLogger;
|
return testLogger;
|
||||||
}
|
}
|
||||||
|
@ -52,20 +52,20 @@ QT_MODULE(Test)
|
|||||||
|
|
||||||
class QTestElement;
|
class QTestElement;
|
||||||
class QTestElementAttribute;
|
class QTestElementAttribute;
|
||||||
class QTestLogger;
|
class QXunitTestLogger;
|
||||||
struct QTestCharBuffer;
|
struct QTestCharBuffer;
|
||||||
|
|
||||||
class QTestBasicStreamer
|
class QTestBasicStreamer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QTestBasicStreamer(QTestLogger *logger);
|
QTestBasicStreamer(QXunitTestLogger *logger);
|
||||||
virtual ~QTestBasicStreamer();
|
virtual ~QTestBasicStreamer();
|
||||||
|
|
||||||
virtual void output(QTestElement *element) const;
|
virtual void output(QTestElement *element) const;
|
||||||
|
|
||||||
void outputString(const char *msg) const;
|
void outputString(const char *msg) const;
|
||||||
|
|
||||||
QTestLogger *logger() const;
|
QXunitTestLogger *logger() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void formatStart(const QTestElement *element, QTestCharBuffer *formatted) const;
|
virtual void formatStart(const QTestElement *element, QTestCharBuffer *formatted) const;
|
||||||
@ -77,7 +77,7 @@ class QTestBasicStreamer
|
|||||||
virtual void outputElementAttributes(const QTestElement *element, QTestElementAttribute *attribute) const;
|
virtual void outputElementAttributes(const QTestElement *element, QTestElementAttribute *attribute) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QTestLogger *testLogger;
|
QXunitTestLogger *testLogger;
|
||||||
};
|
};
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
@ -45,7 +45,7 @@
|
|||||||
#include "QtTest/private/qtestresult_p.h"
|
#include "QtTest/private/qtestresult_p.h"
|
||||||
#include "QtTest/private/qabstracttestlogger_p.h"
|
#include "QtTest/private/qabstracttestlogger_p.h"
|
||||||
#include "QtTest/private/qplaintestlogger_p.h"
|
#include "QtTest/private/qplaintestlogger_p.h"
|
||||||
#include "QtTest/private/qtestlogger_p.h"
|
#include "QtTest/private/qxunittestlogger_p.h"
|
||||||
#include "QtTest/private/qxmltestlogger_p.h"
|
#include "QtTest/private/qxmltestlogger_p.h"
|
||||||
#include <QtCore/qatomic.h>
|
#include <QtCore/qatomic.h>
|
||||||
#include <QtCore/qbytearray.h>
|
#include <QtCore/qbytearray.h>
|
||||||
@ -178,7 +178,7 @@ namespace QTest {
|
|||||||
QTest::testLogger = new QXmlTestLogger(QXmlTestLogger::Light);
|
QTest::testLogger = new QXmlTestLogger(QXmlTestLogger::Light);
|
||||||
break;
|
break;
|
||||||
case QTestLog::XunitXML:
|
case QTestLog::XunitXML:
|
||||||
QTest::testLogger = new QTestLogger();
|
QTest::testLogger = new QXunitTestLogger();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@
|
|||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
QTestXunitStreamer::QTestXunitStreamer(QTestLogger *logger)
|
QTestXunitStreamer::QTestXunitStreamer(QXunitTestLogger *logger)
|
||||||
: QTestBasicStreamer(logger)
|
: QTestBasicStreamer(logger)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
@ -50,12 +50,12 @@ QT_BEGIN_NAMESPACE
|
|||||||
|
|
||||||
QT_MODULE(Test)
|
QT_MODULE(Test)
|
||||||
|
|
||||||
class QTestLogger;
|
class QXunitTestLogger;
|
||||||
|
|
||||||
class QTestXunitStreamer: public QTestBasicStreamer
|
class QTestXunitStreamer: public QTestBasicStreamer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QTestXunitStreamer(QTestLogger *logger);
|
QTestXunitStreamer(QXunitTestLogger *logger);
|
||||||
~QTestXunitStreamer();
|
~QTestXunitStreamer();
|
||||||
|
|
||||||
void formatStart(const QTestElement *element, QTestCharBuffer *formatted) const;
|
void formatStart(const QTestElement *element, QTestCharBuffer *formatted) const;
|
||||||
|
@ -39,7 +39,7 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "qtestlogger_p.h"
|
#include "qxunittestlogger_p.h"
|
||||||
#include "qtestelement.h"
|
#include "qtestelement.h"
|
||||||
#include "qtestxunitstreamer.h"
|
#include "qtestxunitstreamer.h"
|
||||||
|
|
||||||
@ -51,7 +51,7 @@
|
|||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
QTestLogger::QTestLogger()
|
QXunitTestLogger::QXunitTestLogger()
|
||||||
: listOfTestcases(0)
|
: listOfTestcases(0)
|
||||||
, currentLogElement(0)
|
, currentLogElement(0)
|
||||||
, errorLogElement(0)
|
, errorLogElement(0)
|
||||||
@ -62,13 +62,13 @@ QTestLogger::QTestLogger()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
QTestLogger::~QTestLogger()
|
QXunitTestLogger::~QXunitTestLogger()
|
||||||
{
|
{
|
||||||
delete currentLogElement;
|
delete currentLogElement;
|
||||||
delete logFormatter;
|
delete logFormatter;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QTestLogger::startLogging(const char *filename)
|
void QXunitTestLogger::startLogging(const char *filename)
|
||||||
{
|
{
|
||||||
QAbstractTestLogger::startLogging(filename);
|
QAbstractTestLogger::startLogging(filename);
|
||||||
|
|
||||||
@ -77,7 +77,7 @@ void QTestLogger::startLogging(const char *filename)
|
|||||||
errorLogElement = new QTestElement(QTest::LET_SystemError);
|
errorLogElement = new QTestElement(QTest::LET_SystemError);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QTestLogger::stopLogging()
|
void QXunitTestLogger::stopLogging()
|
||||||
{
|
{
|
||||||
QTestElement *iterator = listOfTestcases;
|
QTestElement *iterator = listOfTestcases;
|
||||||
|
|
||||||
@ -127,7 +127,7 @@ void QTestLogger::stopLogging()
|
|||||||
QAbstractTestLogger::stopLogging();
|
QAbstractTestLogger::stopLogging();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QTestLogger::enterTestFunction(const char *function)
|
void QXunitTestLogger::enterTestFunction(const char *function)
|
||||||
{
|
{
|
||||||
currentLogElement = new QTestElement(QTest::LET_TestCase);
|
currentLogElement = new QTestElement(QTest::LET_TestCase);
|
||||||
currentLogElement->addAttribute(QTest::AI_Name, function);
|
currentLogElement->addAttribute(QTest::AI_Name, function);
|
||||||
@ -136,12 +136,12 @@ void QTestLogger::enterTestFunction(const char *function)
|
|||||||
++testCounter;
|
++testCounter;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QTestLogger::leaveTestFunction()
|
void QXunitTestLogger::leaveTestFunction()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void QTestLogger::addIncident(IncidentTypes type, const char *description,
|
void QXunitTestLogger::addIncident(IncidentTypes type, const char *description,
|
||||||
const char *file, int line)
|
const char *file, int line)
|
||||||
{
|
{
|
||||||
const char *typeBuf = 0;
|
const char *typeBuf = 0;
|
||||||
char buf[100];
|
char buf[100];
|
||||||
@ -220,11 +220,11 @@ void QTestLogger::addIncident(IncidentTypes type, const char *description,
|
|||||||
have some information about the expected failure.
|
have some information about the expected failure.
|
||||||
*/
|
*/
|
||||||
if (type == QAbstractTestLogger::XFail) {
|
if (type == QAbstractTestLogger::XFail) {
|
||||||
QTestLogger::addMessage(QAbstractTestLogger::Info, description, file, line);
|
QXunitTestLogger::addMessage(QAbstractTestLogger::Info, description, file, line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QTestLogger::addBenchmarkResult(const QBenchmarkResult &result)
|
void QXunitTestLogger::addBenchmarkResult(const QBenchmarkResult &result)
|
||||||
{
|
{
|
||||||
QTestElement *benchmarkElement = new QTestElement(QTest::LET_Benchmark);
|
QTestElement *benchmarkElement = new QTestElement(QTest::LET_Benchmark);
|
||||||
|
|
||||||
@ -240,7 +240,7 @@ void QTestLogger::addBenchmarkResult(const QBenchmarkResult &result)
|
|||||||
currentLogElement->addLogElement(benchmarkElement);
|
currentLogElement->addLogElement(benchmarkElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QTestLogger::addTag(QTestElement* element)
|
void QXunitTestLogger::addTag(QTestElement* element)
|
||||||
{
|
{
|
||||||
const char *tag = QTestResult::currentDataTag();
|
const char *tag = QTestResult::currentDataTag();
|
||||||
const char *gtag = QTestResult::currentGlobalDataTag();
|
const char *gtag = QTestResult::currentGlobalDataTag();
|
||||||
@ -261,7 +261,7 @@ void QTestLogger::addTag(QTestElement* element)
|
|||||||
element->addAttribute(QTest::AI_Tag, buf.constData());
|
element->addAttribute(QTest::AI_Tag, buf.constData());
|
||||||
}
|
}
|
||||||
|
|
||||||
void QTestLogger::addMessage(MessageTypes type, const char *message, const char *file, int line)
|
void QXunitTestLogger::addMessage(MessageTypes type, const char *message, const char *file, int line)
|
||||||
{
|
{
|
||||||
QTestElement *errorElement = new QTestElement(QTest::LET_Error);
|
QTestElement *errorElement = new QTestElement(QTest::LET_Error);
|
||||||
const char *typeBuf = 0;
|
const char *typeBuf = 0;
|
@ -60,11 +60,11 @@ QT_BEGIN_NAMESPACE
|
|||||||
class QTestBasicStreamer;
|
class QTestBasicStreamer;
|
||||||
class QTestElement;
|
class QTestElement;
|
||||||
|
|
||||||
class QTestLogger : public QAbstractTestLogger
|
class QXunitTestLogger : public QAbstractTestLogger
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QTestLogger();
|
QXunitTestLogger();
|
||||||
~QTestLogger();
|
~QXunitTestLogger();
|
||||||
|
|
||||||
void startLogging(const char *filename);
|
void startLogging(const char *filename);
|
||||||
void stopLogging();
|
void stopLogging();
|
@ -55,7 +55,7 @@ SOURCES = qtestcase.cpp \
|
|||||||
qtestelementattribute.cpp \
|
qtestelementattribute.cpp \
|
||||||
qtestbasicstreamer.cpp \
|
qtestbasicstreamer.cpp \
|
||||||
qtestxunitstreamer.cpp \
|
qtestxunitstreamer.cpp \
|
||||||
qtestlogger.cpp
|
qxunittestlogger.cpp
|
||||||
DEFINES *= QT_NO_CAST_TO_ASCII \
|
DEFINES *= QT_NO_CAST_TO_ASCII \
|
||||||
QT_NO_CAST_FROM_ASCII \
|
QT_NO_CAST_FROM_ASCII \
|
||||||
QTESTLIB_MAKEDLL \
|
QTESTLIB_MAKEDLL \
|
||||||
|
Loading…
Reference in New Issue
Block a user