Qt 4.8
Public Types | Static Public Functions | Private Functions | List of all members
QTestLog Class Reference

#include <qtestlog_p.h>

Public Types

enum  FlushMode { NoFlush = 0, FLushOn }
 
enum  LogMode { Plain = 0, XML, LightXML, XunitXML }
 

Static Public Functions

static void addBenchmarkResult (const QBenchmarkResult &result)
 
static void addFail (const char *msg, const char *file, int line)
 
static void addIgnoreMessage (QtMsgType type, const char *msg)
 
static void addPass (const char *msg)
 
static void addSkip (const char *msg, QTest::SkipMode mode, const char *file, int line)
 
static void addXFail (const char *msg, const char *file, int line)
 
static void addXPass (const char *msg, const char *file, int line)
 
static void enterTestFunction (const char *function)
 
static void info (const char *msg, const char *file, int line)
 
static void leaveTestFunction ()
 
static LogMode logMode ()
 
static const char * outputFileName ()
 
static void printUnhandledIgnoreMessages ()
 
static void redirectOutput (const char *fileName)
 
static void setFlushMode (FlushMode mode)
 
static void setLogMode (LogMode mode)
 
static void setMaxWarnings (int max)
 
static void setVerboseLevel (int level)
 
static void startLogging ()
 
static void startLogging (unsigned int randomSeed)
 
static void stopLogging ()
 
static int unhandledIgnoreMessages ()
 
static int verboseLevel ()
 
static void warn (const char *msg)
 

Private Functions

 QTestLog ()
 
 ~QTestLog ()
 

Detailed Description

Definition at line 62 of file qtestlog_p.h.

Enumerations

◆ FlushMode

Enumerator
NoFlush 
FLushOn 

Definition at line 66 of file qtestlog_p.h.

◆ LogMode

Enumerator
Plain 
XML 
LightXML 
XunitXML 

Definition at line 65 of file qtestlog_p.h.

Constructors and Destructors

◆ QTestLog()

QTestLog::QTestLog ( )
private

Definition at line 198 of file qtestlog.cpp.

199 {
200 }

◆ ~QTestLog()

QTestLog::~QTestLog ( )
private

Definition at line 202 of file qtestlog.cpp.

203 {
204 }

Functions

◆ addBenchmarkResult()

void QTestLog::addBenchmarkResult ( const QBenchmarkResult result)
static

Definition at line 299 of file qtestlog.cpp.

Referenced by QTest::qInvokeTestMethodDataEntry().

300 {
303 }
static QAbstractTestLogger * testLogger
Definition: qtestlog.cpp:92
#define QTEST_ASSERT(cond)
Definition: qtestassert.h:53
virtual void addBenchmarkResult(const QBenchmarkResult &result)=0

◆ addFail()

void QTestLog::addFail ( const char *  msg,
const char *  file,
int  line 
)
static

Definition at line 264 of file qtestlog.cpp.

Referenced by QTestResult::addFailure().

265 {
267 
269 }
virtual void addIncident(IncidentTypes type, const char *description, const char *file=0, int line=0)=0
static QAbstractTestLogger * testLogger
Definition: qtestlog.cpp:92
#define QTEST_ASSERT(cond)
Definition: qtestassert.h:53

◆ addIgnoreMessage()

void QTestLog::addIgnoreMessage ( QtMsgType  type,
const char *  msg 
)
static

Definition at line 368 of file qtestlog.cpp.

Referenced by QTestResult::ignoreMessage().

369 {
371 
373  if (!list) {
375  return;
376  }
377  while (list->next)
378  list = list->next;
379  list->next = item;
380 }
int type
Definition: qmetatype.cpp:239
static IgnoreResultList * ignoreResultList
Definition: qtestlog.cpp:85
IgnoreResultList * next
Definition: qtestlog.cpp:82

◆ addPass()

void QTestLog::addPass ( const char *  msg)
static

Definition at line 253 of file qtestlog.cpp.

Referenced by QTestResult::finishedCurrentTestFunction().

254 {
256  return;
257 
259  QTEST_ASSERT(msg);
260 
262 }
virtual void addIncident(IncidentTypes type, const char *description, const char *file=0, int line=0)=0
static QAbstractTestLogger * testLogger
Definition: qtestlog.cpp:92
Q_TESTLIB_EXPORT bool printAvailableTags
Definition: qtestcase.cpp:1087
#define QTEST_ASSERT(cond)
Definition: qtestassert.h:53

◆ addSkip()

void QTestLog::addSkip ( const char *  msg,
QTest::SkipMode  mode,
const char *  file,
int  line 
)
static

Definition at line 289 of file qtestlog.cpp.

Referenced by QTestResult::addSkip().

291 {
293  QTEST_ASSERT(msg);
294  QTEST_ASSERT(file);
295 
297 }
static QAbstractTestLogger * testLogger
Definition: qtestlog.cpp:92
#define QTEST_ASSERT(cond)
Definition: qtestassert.h:53
virtual void addMessage(MessageTypes type, const char *message, const char *file=0, int line=0)=0

◆ addXFail()

void QTestLog::addXFail ( const char *  msg,
const char *  file,
int  line 
)
static

Definition at line 271 of file qtestlog.cpp.

Referenced by checkStatement().

272 {
274  QTEST_ASSERT(msg);
275  QTEST_ASSERT(file);
276 
278 }
virtual void addIncident(IncidentTypes type, const char *description, const char *file=0, int line=0)=0
static QAbstractTestLogger * testLogger
Definition: qtestlog.cpp:92
#define QTEST_ASSERT(cond)
Definition: qtestassert.h:53

◆ addXPass()

void QTestLog::addXPass ( const char *  msg,
const char *  file,
int  line 
)
static

Definition at line 280 of file qtestlog.cpp.

Referenced by checkStatement().

281 {
283  QTEST_ASSERT(msg);
284  QTEST_ASSERT(file);
285 
287 }
virtual void addIncident(IncidentTypes type, const char *description, const char *file=0, int line=0)=0
static QAbstractTestLogger * testLogger
Definition: qtestlog.cpp:92
#define QTEST_ASSERT(cond)
Definition: qtestassert.h:53

◆ enterTestFunction()

void QTestLog::enterTestFunction ( const char *  function)
static

Definition at line 206 of file qtestlog.cpp.

Referenced by QTestResult::setCurrentTestFunction().

207 {
209  return;
210 
212  QTEST_ASSERT(function);
213 
215 }
static QAbstractTestLogger * testLogger
Definition: qtestlog.cpp:92
Q_TESTLIB_EXPORT bool printAvailableTags
Definition: qtestcase.cpp:1087
#define QTEST_ASSERT(cond)
Definition: qtestassert.h:53
virtual void enterTestFunction(const char *function)=0

◆ info()

void QTestLog::info ( const char *  msg,
const char *  file,
int  line 
)
static

Definition at line 340 of file qtestlog.cpp.

Referenced by QTestResult::compare(), QTest::qPrintMessage(), and QTestResult::verify().

341 {
342  QTEST_ASSERT(msg);
343 
344  if (QTest::testLogger)
346 }
static QAbstractTestLogger * testLogger
Definition: qtestlog.cpp:92
#define QTEST_ASSERT(cond)
Definition: qtestassert.h:53
virtual void addMessage(MessageTypes type, const char *message, const char *file=0, int line=0)=0

◆ leaveTestFunction()

void QTestLog::leaveTestFunction ( )
static

Definition at line 228 of file qtestlog.cpp.

Referenced by QTestResult::finishedCurrentTestFunction(), and QTest::messageHandler().

229 {
231  return;
232 
234 
237 }
static IgnoreResultList * ignoreResultList
Definition: qtestlog.cpp:85
static void clearList(IgnoreResultList *&list)
Definition: qtestlog.cpp:71
static QAbstractTestLogger * testLogger
Definition: qtestlog.cpp:92
Q_TESTLIB_EXPORT bool printAvailableTags
Definition: qtestcase.cpp:1087
#define QTEST_ASSERT(cond)
Definition: qtestassert.h:53
virtual void leaveTestFunction()=0

◆ logMode()

QTestLog::LogMode QTestLog::logMode ( )
static

Definition at line 353 of file qtestlog.cpp.

354 {
355  return QTest::logMode;
356 }
static QTestLog::LogMode logMode
Definition: qtestlog.cpp:87

◆ outputFileName()

const char * QTestLog::outputFileName ( )
static

Definition at line 389 of file qtestlog.cpp.

Referenced by QTest::outputMessage(), QAbstractTestLogger::startLogging(), and QTestBasicStreamer::startStreaming().

390 {
391  return QTest::outFile;
392 }
static const char * outFile
Definition: qtestlog.cpp:93

◆ printUnhandledIgnoreMessages()

void QTestLog::printUnhandledIgnoreMessages ( )
static

Definition at line 239 of file qtestlog.cpp.

Referenced by QTestResult::finishedCurrentTestFunction().

240 {
242 
243  char msg[1024];
245  while (list) {
246  QTest::qt_snprintf(msg, 1024, "Did not receive message: \"%s\"", list->msg);
248 
249  list = list->next;
250  }
251 }
static IgnoreResultList * ignoreResultList
Definition: qtestlog.cpp:85
static QAbstractTestLogger * testLogger
Definition: qtestlog.cpp:92
int Q_TESTLIB_EXPORT qt_snprintf(char *str, int size, const char *format,...)
Definition: qtestcase.cpp:961
#define QTEST_ASSERT(cond)
Definition: qtestassert.h:53
IgnoreResultList * next
Definition: qtestlog.cpp:82
virtual void addMessage(MessageTypes type, const char *message, const char *file=0, int line=0)=0

◆ redirectOutput()

void QTestLog::redirectOutput ( const char *  fileName)
static

Definition at line 382 of file qtestlog.cpp.

Referenced by QTest::qtest_qParseArgs().

383 {
385 
387 }
#define QTEST_ASSERT(cond)
Definition: qtestassert.h:53
static const char * outFile
Definition: qtestlog.cpp:93
static QString fileName(const QString &fileUrl)

◆ setFlushMode()

void QTestLog::setFlushMode ( FlushMode  mode)
static

Definition at line 399 of file qtestlog.cpp.

Referenced by QTest::qtest_qParseArgs().

400 {
401  QTest::flushMode = mode;
402 }
static QTestLog::FlushMode flushMode
Definition: qtestlog.cpp:88

◆ setLogMode()

void QTestLog::setLogMode ( LogMode  mode)
static

Definition at line 348 of file qtestlog.cpp.

Referenced by QTest::qtest_qParseArgs().

349 {
350  QTest::logMode = mode;
351 }
static QTestLog::LogMode logMode
Definition: qtestlog.cpp:87

◆ setMaxWarnings()

void QTestLog::setMaxWarnings ( int  max)
static

Definition at line 394 of file qtestlog.cpp.

Referenced by QTest::qtest_qParseArgs().

395 {
396  QTest::maxWarnings = m <= 0 ? INT_MAX : m + 2;
397 }
static int maxWarnings
Definition: qtestlog.cpp:90
#define INT_MAX

◆ setVerboseLevel()

void QTestLog::setVerboseLevel ( int  level)
static

Definition at line 358 of file qtestlog.cpp.

Referenced by QTest::qtest_qParseArgs().

359 {
360  QTest::verbosity = level;
361 }
static int verbosity
Definition: qtestlog.cpp:89

◆ startLogging() [1/2]

void QTestLog::startLogging ( )
static

Definition at line 314 of file qtestlog.cpp.

Referenced by QTest::qInvokeTestMethods().

315 {
320 }
void initLogger()
Definition: qtestlog.cpp:171
static QAbstractTestLogger * testLogger
Definition: qtestlog.cpp:92
static QtMsgHandler oldMessageHandler
Definition: qtestlog.cpp:95
QtMsgHandler qInstallMsgHandler(QtMsgHandler h)
Definition: qglobal.cpp:2698
static void messageHandler(QtMsgType type, const char *msg)
Definition: qtestlog.cpp:121
#define QTEST_ASSERT(cond)
Definition: qtestassert.h:53

◆ startLogging() [2/2]

void QTestLog::startLogging ( unsigned int  randomSeed)
static

Definition at line 305 of file qtestlog.cpp.

306 {
312 }
virtual void registerRandomSeed(unsigned int seed)=0
void initLogger()
Definition: qtestlog.cpp:171
static QAbstractTestLogger * testLogger
Definition: qtestlog.cpp:92
static QtMsgHandler oldMessageHandler
Definition: qtestlog.cpp:95
QtMsgHandler qInstallMsgHandler(QtMsgHandler h)
Definition: qglobal.cpp:2698
static void messageHandler(QtMsgType type, const char *msg)
Definition: qtestlog.cpp:121
#define QTEST_ASSERT(cond)
Definition: qtestassert.h:53

◆ stopLogging()

void QTestLog::stopLogging ( )
static

Definition at line 322 of file qtestlog.cpp.

Referenced by QTest::messageHandler(), QTest::qExec(), and QTest::qInvokeTestMethods().

323 {
325 
328  delete QTest::testLogger;
329  QTest::testLogger = 0;
330 }
static QAbstractTestLogger * testLogger
Definition: qtestlog.cpp:92
static QtMsgHandler oldMessageHandler
Definition: qtestlog.cpp:95
QtMsgHandler qInstallMsgHandler(QtMsgHandler h)
Definition: qglobal.cpp:2698
#define QTEST_ASSERT(cond)
Definition: qtestassert.h:53

◆ unhandledIgnoreMessages()

int QTestLog::unhandledIgnoreMessages ( )
static

Definition at line 217 of file qtestlog.cpp.

Referenced by QTestResult::finishedCurrentTestFunction().

218 {
219  int i = 0;
221  while (list) {
222  ++i;
223  list = list->next;
224  }
225  return i;
226 }
static IgnoreResultList * ignoreResultList
Definition: qtestlog.cpp:85
IgnoreResultList * next
Definition: qtestlog.cpp:82

◆ verboseLevel()

int QTestLog::verboseLevel ( )
static

◆ warn()

void QTestLog::warn ( const char *  msg)
static

Definition at line 332 of file qtestlog.cpp.

Referenced by QTest::qWarn().

333 {
335  QTEST_ASSERT(msg);
336 
338 }
static QAbstractTestLogger * testLogger
Definition: qtestlog.cpp:92
#define QTEST_ASSERT(cond)
Definition: qtestassert.h:53
virtual void addMessage(MessageTypes type, const char *message, const char *file=0, int line=0)=0

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