Qt 4.8
Public Functions | List of all members
QTestLightXmlStreamer Class Reference

#include <qtestlightxmlstreamer.h>

Inheritance diagram for QTestLightXmlStreamer:
QTestBasicStreamer

Public Functions

void formatBeforeAttributes (const QTestElement *element, QTestCharBuffer *formatted) const
 
void formatEnd (const QTestElement *element, QTestCharBuffer *formatted) const
 
void formatStart (const QTestElement *element, QTestCharBuffer *formatted) const
 
void output (QTestElement *element) const
 
 QTestLightXmlStreamer ()
 
 ~QTestLightXmlStreamer ()
 
- Public Functions inherited from QTestBasicStreamer
bool isTtyOutput ()
 
const QTestLoggerlogger () const
 
void outputString (const char *msg) const
 
 QTestBasicStreamer ()
 
void setLogger (const QTestLogger *tstLogger)
 
void startStreaming ()
 
void stopStreaming ()
 
virtual ~QTestBasicStreamer ()
 

Additional Inherited Members

- Protected Functions inherited from QTestBasicStreamer
virtual void formatAfterAttributes (const QTestElement *element, QTestCharBuffer *formatted) const
 
virtual void formatAttributes (const QTestElement *element, const QTestElementAttribute *attribute, QTestCharBuffer *formatted) const
 
virtual void outputElementAttributes (const QTestElement *element, QTestElementAttribute *attribute) const
 
virtual void outputElements (QTestElement *element, bool isChildElement=false) const
 

Detailed Description

Definition at line 56 of file qtestlightxmlstreamer.h.

Constructors and Destructors

◆ QTestLightXmlStreamer()

QTestLightXmlStreamer::QTestLightXmlStreamer ( )

Definition at line 55 of file qtestlightxmlstreamer.cpp.

57 {
58 }

◆ ~QTestLightXmlStreamer()

QTestLightXmlStreamer::~QTestLightXmlStreamer ( )

Definition at line 60 of file qtestlightxmlstreamer.cpp.

61 {}

Functions

◆ formatBeforeAttributes()

void QTestLightXmlStreamer::formatBeforeAttributes ( const QTestElement element,
QTestCharBuffer formatted 
) const
virtual

Reimplemented from QTestBasicStreamer.

Definition at line 138 of file qtestlightxmlstreamer.cpp.

139 {
140  if(!element || !formatted)
141  return;
142 
143  if (element->elementType() == QTest::LET_TestCase && element->attribute(QTest::AI_Result)) {
144  QTestCharBuffer buf;
145  QTestCharBuffer quotedFile;
147 
148  QTest::qt_asprintf(&buf, "%s=\"%s\" %s=\"%s\"",
149  element->attributeName(QTest::AI_File),
150  quotedFile.constData(),
151  element->attributeName(QTest::AI_Line),
152  element->attributeValue(QTest::AI_Line));
153 
154  if( !element->childElements() )
155  QTest::qt_asprintf(formatted, "<Incident type=\"%s\" %s/>\n",
156  element->attributeValue(QTest::AI_Result), buf.constData());
157  else
158  QTest::qt_asprintf(formatted, "<Incident type=\"%s\" %s>\n",
159  element->attributeValue(QTest::AI_Result), buf.constData());
160  } else {
161  formatted->data()[0] = '\0';
162  }
163 }
int qt_asprintf(QTestCharBuffer *str, const char *format,...)
const char * attributeName(QTest::AttributeIndex index) const
QTestElement * childElements() const
const char * constData() const
const char * attributeValue(QTest::AttributeIndex index) const
static int xmlQuote(QTestCharBuffer *dest, char const *src)
const QTestElementAttribute * attribute(QTest::AttributeIndex index) const
QTest::LogElementType elementType() const

◆ formatEnd()

void QTestLightXmlStreamer::formatEnd ( const QTestElement element,
QTestCharBuffer formatted 
) const
virtual

Reimplemented from QTestBasicStreamer.

Definition at line 123 of file qtestlightxmlstreamer.cpp.

124 {
125  if(!element || !formatted)
126  return;
127 
128  if (element->elementType() == QTest::LET_TestCase) {
129  if( element->attribute(QTest::AI_Result) && element->childElements())
130  QTest::qt_asprintf(formatted, "</Incident>\n</TestFunction>\n");
131  else
132  QTest::qt_asprintf(formatted, "</TestFunction>\n");
133  } else {
134  formatted->data()[0] = '\0';
135  }
136 }
int qt_asprintf(QTestCharBuffer *str, const char *format,...)
QTestElement * childElements() const
const QTestElementAttribute * attribute(QTest::AttributeIndex index) const
QTest::LogElementType elementType() const

◆ formatStart()

void QTestLightXmlStreamer::formatStart ( const QTestElement element,
QTestCharBuffer formatted 
) const
virtual

Reimplemented from QTestBasicStreamer.

Definition at line 63 of file qtestlightxmlstreamer.cpp.

64 {
65  if(!element || !formatted)
66  return;
67 
68  switch(element->elementType()){
69  case QTest::LET_TestCase: {
70  QTestCharBuffer quotedTf;
72 
73  QTest::qt_asprintf(formatted, "<TestFunction name=\"%s\">\n", quotedTf.constData());
74  break;
75  }
76  case QTest::LET_Failure: {
77  QTestCharBuffer cdataDesc;
79 
80  QTest::qt_asprintf(formatted, " <Description><![CDATA[%s]]></Description>\n",
81  cdataDesc.constData());
82  break;
83  }
84  case QTest::LET_Error: {
85  // assuming type and attribute names don't need quoting
86  QTestCharBuffer quotedFile;
87  QTestCharBuffer cdataDesc;
90 
91  QTest::qt_asprintf(formatted, "<Message type=\"%s\" %s=\"%s\" %s=\"%s\">\n <Description><![CDATA[%s]]></Description>\n</Message>\n",
93  element->attributeName(QTest::AI_File),
94  quotedFile.constData(),
95  element->attributeName(QTest::AI_Line),
97  cdataDesc.constData());
98  break;
99  }
100  case QTest::LET_Benchmark: {
101  // assuming value and iterations don't need quoting
102  QTestCharBuffer quotedMetric;
103  QTestCharBuffer quotedTag;
104  QXmlTestLogger::xmlQuote(&quotedMetric, element->attributeValue(QTest::AI_Metric));
106 
107  QTest::qt_asprintf(formatted, "<BenchmarkResult %s=\"%s\" %s=\"%s\" %s=\"%s\" %s=\"%s\" />\n",
109  quotedMetric.constData(),
110  element->attributeName(QTest::AI_Tag),
111  quotedTag.constData(),
112  element->attributeName(QTest::AI_Value),
116  break;
117  }
118  default:
119  formatted->data()[0] = '\0';
120  }
121 }
int qt_asprintf(QTestCharBuffer *str, const char *format,...)
const char * attributeName(QTest::AttributeIndex index) const
static int xmlCdata(QTestCharBuffer *dest, char const *src)
const char * constData() const
const char * attributeValue(QTest::AttributeIndex index) const
static int xmlQuote(QTestCharBuffer *dest, char const *src)
QTest::LogElementType elementType() const

◆ output()

void QTestLightXmlStreamer::output ( QTestElement element) const
virtual

Reimplemented from QTestBasicStreamer.

Definition at line 165 of file qtestlightxmlstreamer.cpp.

166 {
167  QTestCharBuffer buf;
168  if (logger()->hasRandomSeed()) {
169  QTest::qt_asprintf(&buf, "<Environment>\n <QtVersion>%s</QtVersion>\n <QTestVersion>%s</QTestVersion>\n <RandomSeed>%d</RandomSeed>\n",
170  qVersion(), QTEST_VERSION_STR, logger()->randomSeed() );
171  } else {
172  QTest::qt_asprintf(&buf, "<Environment>\n <QtVersion>%s</QtVersion>\n <QTestVersion>%s</QTestVersion>\n",
174  }
175  outputString(buf.constData());
176 
177  QTest::qt_asprintf(&buf, "</Environment>\n");
178  outputString(buf.constData());
179 
181 }
int qt_asprintf(QTestCharBuffer *str, const char *format,...)
virtual void output(QTestElement *element) const
Q_CORE_EXPORT const char * qVersion()
const char * constData() const
const QTestLogger * logger() const
#define QTEST_VERSION_STR
Definition: qtest_global.h:78
void outputString(const char *msg) const

The documentation for this class was generated from the following files: