Qt 4.8
Public Functions | Protected Functions | Properties | List of all members
QTestBasicStreamer Class Reference

#include <qtestbasicstreamer.h>

Inheritance diagram for QTestBasicStreamer:
QTestLightXmlStreamer QTestXmlStreamer QTestXunitStreamer

Public Functions

bool isTtyOutput ()
 
const QTestLoggerlogger () const
 
virtual void output (QTestElement *element) const
 
void outputString (const char *msg) const
 
 QTestBasicStreamer ()
 
void setLogger (const QTestLogger *tstLogger)
 
void startStreaming ()
 
void stopStreaming ()
 
virtual ~QTestBasicStreamer ()
 

Protected Functions

virtual void formatAfterAttributes (const QTestElement *element, QTestCharBuffer *formatted) const
 
virtual void formatAttributes (const QTestElement *element, const QTestElementAttribute *attribute, QTestCharBuffer *formatted) const
 
virtual void formatBeforeAttributes (const QTestElement *element, QTestCharBuffer *formatted) const
 
virtual void formatEnd (const QTestElement *element, QTestCharBuffer *formatted) const
 
virtual void formatStart (const QTestElement *element, QTestCharBuffer *formatted) const
 
virtual void outputElementAttributes (const QTestElement *element, QTestElementAttribute *attribute) const
 
virtual void outputElements (QTestElement *element, bool isChildElement=false) const
 

Properties

const QTestLoggertestLogger
 

Detailed Description

Definition at line 58 of file qtestbasicstreamer.h.

Constructors and Destructors

◆ QTestBasicStreamer()

QTestBasicStreamer::QTestBasicStreamer ( )

Definition at line 63 of file qtestbasicstreamer.cpp.

64  :testLogger(0)
65 {
66 }
const QTestLogger * testLogger

◆ ~QTestBasicStreamer()

QTestBasicStreamer::~QTestBasicStreamer ( )
virtual

Definition at line 68 of file qtestbasicstreamer.cpp.

69 {}

Functions

◆ formatAfterAttributes()

void QTestBasicStreamer::formatAfterAttributes ( const QTestElement element,
QTestCharBuffer formatted 
) const
protectedvirtual

Reimplemented in QTestXunitStreamer.

Definition at line 92 of file qtestbasicstreamer.cpp.

Referenced by outputElements().

93 {
94  if(!element || !formatted )
95  return;
96  formatted->data()[0] = '\0';
97 }

◆ formatAttributes()

void QTestBasicStreamer::formatAttributes ( const QTestElement element,
const QTestElementAttribute attribute,
QTestCharBuffer formatted 
) const
protectedvirtual

Reimplemented in QTestXunitStreamer.

Definition at line 99 of file qtestbasicstreamer.cpp.

Referenced by outputElementAttributes().

100 {
101  if(!attribute || !formatted )
102  return;
103  formatted->data()[0] = '\0';
104 }

◆ formatBeforeAttributes()

void QTestBasicStreamer::formatBeforeAttributes ( const QTestElement element,
QTestCharBuffer formatted 
) const
protectedvirtual

Reimplemented in QTestLightXmlStreamer, and QTestXmlStreamer.

Definition at line 85 of file qtestbasicstreamer.cpp.

Referenced by QTestXunitStreamer::outputElements(), and outputElements().

86 {
87  if(!element || !formatted )
88  return;
89  formatted->data()[0] = '\0';
90 }

◆ formatEnd()

void QTestBasicStreamer::formatEnd ( const QTestElement element,
QTestCharBuffer formatted 
) const
protectedvirtual

Reimplemented in QTestLightXmlStreamer, QTestXmlStreamer, and QTestXunitStreamer.

Definition at line 78 of file qtestbasicstreamer.cpp.

Referenced by outputElements().

79 {
80  if(!element || !formatted )
81  return;
82  formatted->data()[0] = '\0';
83 }

◆ formatStart()

void QTestBasicStreamer::formatStart ( const QTestElement element,
QTestCharBuffer formatted 
) const
protectedvirtual

Reimplemented in QTestLightXmlStreamer, QTestXmlStreamer, and QTestXunitStreamer.

Definition at line 71 of file qtestbasicstreamer.cpp.

Referenced by outputElements().

72 {
73  if(!element || !formatted )
74  return;
75  formatted->data()[0] = '\0';
76 }

◆ isTtyOutput()

bool QTestBasicStreamer::isTtyOutput ( )

Definition at line 187 of file qtestbasicstreamer.cpp.

188 {
190 
191 #if defined(Q_OS_WIN) || defined(Q_OS_INTEGRITY)
192  return true;
193 #else
194  static bool ttyoutput = isatty(fileno(QTest::stream));
195  return ttyoutput;
196 #endif
197 }
static FILE * stream
#define QTEST_ASSERT(cond)
Definition: qtestassert.h:53

◆ logger()

const QTestLogger * QTestBasicStreamer::logger ( ) const

Definition at line 213 of file qtestbasicstreamer.cpp.

Referenced by QTestLightXmlStreamer::output(), and QTestXmlStreamer::output().

214 {
215  return testLogger;
216 }
const QTestLogger * testLogger

◆ output()

void QTestBasicStreamer::output ( QTestElement element) const
virtual

Reimplemented in QTestLightXmlStreamer, QTestXmlStreamer, and QTestXunitStreamer.

Definition at line 106 of file qtestbasicstreamer.cpp.

Referenced by QTestLightXmlStreamer::output(), QTestXunitStreamer::output(), QTestXmlStreamer::output(), and QTestLogger::stopLogging().

107 {
108  if(!element)
109  return;
110 
111  outputElements(element);
112 }
virtual void outputElements(QTestElement *element, bool isChildElement=false) const

◆ outputElementAttributes()

void QTestBasicStreamer::outputElementAttributes ( const QTestElement element,
QTestElementAttribute attribute 
) const
protectedvirtual

Definition at line 149 of file qtestbasicstreamer.cpp.

Referenced by QTestXunitStreamer::outputElements(), and outputElements().

150 {
151  QTestCharBuffer buf;
152  while(attribute){
153  formatAttributes(element, attribute, &buf);
154  outputString(buf.data());
155  attribute = attribute->nextElement();
156  }
157 }
virtual void formatAttributes(const QTestElement *element, const QTestElementAttribute *attribute, QTestCharBuffer *formatted) const
void outputString(const char *msg) const

◆ outputElements()

void QTestBasicStreamer::outputElements ( QTestElement element,
bool  isChildElement = false 
) const
protectedvirtual

Reimplemented in QTestXunitStreamer.

Definition at line 114 of file qtestbasicstreamer.cpp.

Referenced by output().

115 {
116  QTestCharBuffer buf;
117  bool hasChildren;
118  /*
119  Elements are in reverse order of occurrence, so start from the end and work
120  our way backwards.
121  */
122  while (element && element->nextElement()) {
123  element = element->nextElement();
124  }
125  while (element) {
126  hasChildren = element->childElements();
127 
128  formatStart(element, &buf);
129  outputString(buf.data());
130 
131  formatBeforeAttributes(element, &buf);
132  outputString(buf.data());
133 
134  outputElementAttributes(element, element->attributes());
135 
136  formatAfterAttributes(element, &buf);
137  outputString(buf.data());
138 
139  if(hasChildren)
140  outputElements(element->childElements(), true);
141 
142  formatEnd(element, &buf);
143  outputString(buf.data());
144 
145  element = element->previousElement();
146  }
147 }
virtual void outputElementAttributes(const QTestElement *element, QTestElementAttribute *attribute) const
virtual void formatStart(const QTestElement *element, QTestCharBuffer *formatted) const
QTestElement * childElements() const
virtual void formatEnd(const QTestElement *element, QTestCharBuffer *formatted) const
virtual void formatBeforeAttributes(const QTestElement *element, QTestCharBuffer *formatted) const
QTestElementAttribute * attributes() const
void outputString(const char *msg) const
T * previousElement()
virtual void formatAfterAttributes(const QTestElement *element, QTestCharBuffer *formatted) const
virtual void outputElements(QTestElement *element, bool isChildElement=false) const

◆ outputString()

void QTestBasicStreamer::outputString ( const char *  msg) const

◆ setLogger()

void QTestBasicStreamer::setLogger ( const QTestLogger tstLogger)

Definition at line 208 of file qtestbasicstreamer.cpp.

Referenced by QTestLogger::startLogging().

209 {
210  testLogger = tstLogger;
211 }
const QTestLogger * testLogger

◆ startStreaming()

void QTestBasicStreamer::startStreaming ( )

Definition at line 167 of file qtestbasicstreamer.cpp.

Referenced by QTestLogger::startLogging().

168 {
170 
171  const char *out = QTestLog::outputFileName();
172  if (!out) {
173  QTest::stream = stdout;
174  return;
175  }
176  #if defined(_MSC_VER) && _MSC_VER >= 1400 && !defined(Q_OS_WINCE)
177  if (::fopen_s(&QTest::stream, out, "wt")) {
178  #else
179  QTest::stream = ::fopen(out, "wt");
180  if (!QTest::stream) {
181  #endif
182  printf("Unable to open file for logging: %s", out);
183  ::exit(1);
184  }
185 }
static const char * outputFileName()
Definition: qtestlog.cpp:389
static FILE * stream
#define QTEST_ASSERT(cond)
Definition: qtestassert.h:53

◆ stopStreaming()

void QTestBasicStreamer::stopStreaming ( )

Definition at line 199 of file qtestbasicstreamer.cpp.

Referenced by QTestLogger::stopLogging().

200 {
202  if (QTest::stream != stdout)
203  fclose(QTest::stream);
204 
205  QTest::stream = 0;
206 }
static FILE * stream
#define QTEST_ASSERT(cond)
Definition: qtestassert.h:53

Properties

◆ testLogger

const QTestLogger* QTestBasicStreamer::testLogger
private

Definition at line 84 of file qtestbasicstreamer.h.

Referenced by logger(), and setLogger().


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