Remove ability to change XML logger during a test.

It doesn't make sense to change the logger associated with a streamer in
the middle of a test run, so only allow the logger to be set when
constructing a streamer.

Change-Id: I02661de2b6071c74d10bc854cbe436581978d2d9
Reviewed-on: http://codereview.qt.nokia.com/3622
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
This commit is contained in:
Jason McDonald 2011-08-26 11:44:17 +10:00 committed by Qt by Nokia
parent e8e9b62f72
commit 36533edf71
9 changed files with 17 additions and 23 deletions

View File

@ -43,6 +43,7 @@
#include "qtestlogger_p.h"
#include "qtestelement.h"
#include "qtestelementattribute.h"
#include "qtestassert.h"
#include <stdio.h>
#include <stdlib.h>
@ -53,9 +54,10 @@
QT_BEGIN_NAMESPACE
QTestBasicStreamer::QTestBasicStreamer()
:testLogger(0)
QTestBasicStreamer::QTestBasicStreamer(QTestLogger *logger)
:testLogger(logger)
{
QTEST_ASSERT(testLogger);
}
QTestBasicStreamer::~QTestBasicStreamer()
@ -154,11 +156,6 @@ void QTestBasicStreamer::outputString(const char *msg) const
testLogger->outputString(msg);
}
void QTestBasicStreamer::setLogger(QTestLogger *tstLogger)
{
testLogger = tstLogger;
}
QTestLogger *QTestBasicStreamer::logger() const
{
return testLogger;

View File

@ -58,14 +58,13 @@ struct QTestCharBuffer;
class QTestBasicStreamer
{
public:
QTestBasicStreamer();
QTestBasicStreamer(QTestLogger *logger);
virtual ~QTestBasicStreamer();
virtual void output(QTestElement *element) const;
void outputString(const char *msg) const;
void setLogger(QTestLogger *tstLogger);
QTestLogger *logger() const;
protected:

View File

@ -52,8 +52,8 @@
QT_BEGIN_NAMESPACE
QTestLightXmlStreamer::QTestLightXmlStreamer()
:QTestBasicStreamer()
QTestLightXmlStreamer::QTestLightXmlStreamer(QTestLogger *logger)
: QTestBasicStreamer(logger)
{
}

View File

@ -56,7 +56,7 @@ class QTestElementAttribute;
class QTestLightXmlStreamer: public QTestBasicStreamer
{
public:
QTestLightXmlStreamer();
QTestLightXmlStreamer(QTestLogger *logger);
~QTestLightXmlStreamer();
void formatStart(const QTestElement *element, QTestCharBuffer *formatted) const;

View File

@ -84,23 +84,21 @@ void QTestLogger::startLogging(const char *filename)
switch(format){
case TLF_LightXml:{
logFormatter = new QTestLightXmlStreamer;
logFormatter = new QTestLightXmlStreamer(this);
filelogger->init();
break;
}case TLF_XML:{
logFormatter = new QTestXmlStreamer;
logFormatter = new QTestXmlStreamer(this);
filelogger->init();
break;
}case TLF_XunitXml:{
logFormatter = new QTestXunitStreamer;
logFormatter = new QTestXunitStreamer(this);
delete errorLogElement;
errorLogElement = new QTestElement(QTest::LET_SystemError);
filelogger->init();
break;
}
}
logFormatter->setLogger(this);
}
void QTestLogger::stopLogging()

View File

@ -53,8 +53,8 @@
QT_BEGIN_NAMESPACE
QTestXmlStreamer::QTestXmlStreamer()
:QTestBasicStreamer()
QTestXmlStreamer::QTestXmlStreamer(QTestLogger *logger)
: QTestBasicStreamer(logger)
{
}

View File

@ -56,7 +56,7 @@ class QTestElementAttribute;
class QTestXmlStreamer: public QTestBasicStreamer
{
public:
QTestXmlStreamer();
QTestXmlStreamer(QTestLogger *logger);
~QTestXmlStreamer();
void formatStart(const QTestElement *element, QTestCharBuffer *formatted) const;

View File

@ -48,8 +48,8 @@
QT_BEGIN_NAMESPACE
QTestXunitStreamer::QTestXunitStreamer()
:QTestBasicStreamer()
QTestXunitStreamer::QTestXunitStreamer(QTestLogger *logger)
: QTestBasicStreamer(logger)
{}
QTestXunitStreamer::~QTestXunitStreamer()

View File

@ -55,7 +55,7 @@ class QTestLogger;
class QTestXunitStreamer: public QTestBasicStreamer
{
public:
QTestXunitStreamer();
QTestXunitStreamer(QTestLogger *logger);
~QTestXunitStreamer();
void formatStart(const QTestElement *element, QTestCharBuffer *formatted) const;