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

#include <qplaintestlogger_p.h>

Inheritance diagram for QPlainTestLogger:
QAbstractTestLogger

Public Functions

void addBenchmarkResult (const QBenchmarkResult &result)
 
void addIncident (IncidentTypes type, const char *description, const char *file=0, int line=0)
 
void addMessage (MessageTypes type, const char *message, const char *file=0, int line=0)
 
void enterTestFunction (const char *function)
 
void leaveTestFunction ()
 
 QPlainTestLogger ()
 
void registerRandomSeed (unsigned int seed)
 
void startLogging ()
 
void stopLogging ()
 
 ~QPlainTestLogger ()
 
- Public Functions inherited from QAbstractTestLogger
 QAbstractTestLogger ()
 
virtual ~QAbstractTestLogger ()
 

Properties

bool hasRandomSeed
 
unsigned int randomSeed
 

Additional Inherited Members

- Public Types inherited from QAbstractTestLogger
enum  IncidentTypes { Pass, XFail, Fail, XPass }
 
enum  MessageTypes {
  Warn, QWarning, QDebug, QSystem,
  QFatal, Skip, Info
}
 
- Static Public Functions inherited from QAbstractTestLogger
static bool isTtyOutput ()
 
static void outputString (const char *msg)
 

Detailed Description

Definition at line 60 of file qplaintestlogger_p.h.

Constructors and Destructors

◆ QPlainTestLogger()

QPlainTestLogger::QPlainTestLogger ( )

Definition at line 386 of file qplaintestlogger.cpp.

387 : randomSeed(9), hasRandomSeed(false)
388 {
389 #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
390  InitializeCriticalSection(&QTest::outputCriticalSection);
391  QTest::hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
392  if (QTest::hConsole != INVALID_HANDLE_VALUE) {
393  CONSOLE_SCREEN_BUFFER_INFO info;
394  if (GetConsoleScreenBufferInfo(QTest::hConsole, &info)) {
395  QTest::consoleAttributes = info.wAttributes;
396  } else {
397  QTest::hConsole = INVALID_HANDLE_VALUE;
398  }
399  }
400 #endif
401 }
static mach_timebase_info_data_t info
unsigned int randomSeed

◆ ~QPlainTestLogger()

QPlainTestLogger::~QPlainTestLogger ( )

Definition at line 403 of file qplaintestlogger.cpp.

404 {
405 #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
406  DeleteCriticalSection(&QTest::outputCriticalSection);
407 #endif
408 }

Functions

◆ addBenchmarkResult()

void QPlainTestLogger::addBenchmarkResult ( const QBenchmarkResult result)
virtual

Implements QAbstractTestLogger.

Definition at line 474 of file qplaintestlogger.cpp.

475 {
476 // QTest::printBenchmarkResult(QTest::benchmarkResult2String(), value, iterations);
478 }
static void printBenchmarkResult(const QBenchmarkResult &result)

◆ addIncident()

void QPlainTestLogger::addIncident ( IncidentTypes  type,
const char *  description,
const char *  file = 0,
int  line = 0 
)
virtual

Implements QAbstractTestLogger.

Definition at line 464 of file qplaintestlogger.cpp.

466 {
467  // suppress PASS in silent mode
469  return;
470 
471  QTest::printMessage(QTest::incidentType2String(type), description, file, line);
472 }
static int verboseLevel()
Definition: qtestlog.cpp:363
int type
Definition: qmetatype.cpp:239
static const char * incidentType2String(QAbstractTestLogger::IncidentTypes type)
static void printMessage(const char *type, const char *msg, const char *file=0, int line=0)

◆ addMessage()

void QPlainTestLogger::addMessage ( MessageTypes  type,
const char *  message,
const char *  file = 0,
int  line = 0 
)
virtual

Implements QAbstractTestLogger.

Definition at line 480 of file qplaintestlogger.cpp.

482 {
483  // suppress PASS in silent mode
485  && QTestLog::verboseLevel() < 0)
486  return;
487 
488  QTest::printMessage(QTest::messageType2String(type), message, file, line);
489 }
static int verboseLevel()
Definition: qtestlog.cpp:363
int type
Definition: qmetatype.cpp:239
static const char * messageType2String(QAbstractTestLogger::MessageTypes type)
static void printMessage(const char *type, const char *msg, const char *file=0, int line=0)

◆ enterTestFunction()

void QPlainTestLogger::enterTestFunction ( const char *  function)
virtual

Implements QAbstractTestLogger.

Definition at line 454 of file qplaintestlogger.cpp.

455 {
456  if (QTestLog::verboseLevel() >= 1)
458 }
static int verboseLevel()
Definition: qtestlog.cpp:363
static const char * messageType2String(QAbstractTestLogger::MessageTypes type)
static void printMessage(const char *type, const char *msg, const char *file=0, int line=0)

◆ leaveTestFunction()

void QPlainTestLogger::leaveTestFunction ( )
virtual

Implements QAbstractTestLogger.

Definition at line 460 of file qplaintestlogger.cpp.

461 {
462 }

◆ registerRandomSeed()

void QPlainTestLogger::registerRandomSeed ( unsigned int  seed)
virtual

Implements QAbstractTestLogger.

Definition at line 491 of file qplaintestlogger.cpp.

492 {
493  randomSeed = seed;
494  hasRandomSeed = true;
495 }
unsigned int randomSeed
static unsigned int seed
Definition: qtestcase.cpp:943

◆ startLogging()

void QPlainTestLogger::startLogging ( )
virtual

Reimplemented from QAbstractTestLogger.

Definition at line 410 of file qplaintestlogger.cpp.

411 {
413 
414  char buf[1024];
415  if (QTestLog::verboseLevel() < 0) {
416  QTest::qt_snprintf(buf, sizeof(buf), "Testing %s\n",
418  } else {
419  if (hasRandomSeed) {
420  QTest::qt_snprintf(buf, sizeof(buf),
421  "********* Start testing of %s *********\n"
422  "Config: Using QTest library " QTEST_VERSION_STR
423  ", Qt %s, Random seed %d\n", QTestResult::currentTestObjectName(), qVersion(), randomSeed);
424  } else {
425  QTest::qt_snprintf(buf, sizeof(buf),
426  "********* Start testing of %s *********\n"
427  "Config: Using QTest library " QTEST_VERSION_STR
428  ", Qt %s\n", QTestResult::currentTestObjectName(), qVersion());
429  }
430  }
432 }
static int verboseLevel()
Definition: qtestlog.cpp:363
unsigned int randomSeed
Q_CORE_EXPORT const char * qVersion()
static const char * currentTestObjectName()
static void outputMessage(const char *str)
#define QTEST_VERSION_STR
Definition: qtest_global.h:78
int Q_TESTLIB_EXPORT qt_snprintf(char *str, int size, const char *format,...)
Definition: qtestcase.cpp:961

◆ stopLogging()

void QPlainTestLogger::stopLogging ( )
virtual

Reimplemented from QAbstractTestLogger.

Definition at line 434 of file qplaintestlogger.cpp.

435 {
436  char buf[1024];
437  if (QTestLog::verboseLevel() < 0) {
438  QTest::qt_snprintf(buf, sizeof(buf), "Totals: %d passed, %d failed, %d skipped\n",
441  } else {
442  QTest::qt_snprintf(buf, sizeof(buf),
443  "Totals: %d passed, %d failed, %d skipped\n"
444  "********* Finished testing of %s *********\n",
447  }
449 
451 }
static int verboseLevel()
Definition: qtestlog.cpp:363
static int failCount()
static const char * currentTestObjectName()
static int skipCount()
static void outputMessage(const char *str)
int Q_TESTLIB_EXPORT qt_snprintf(char *str, int size, const char *format,...)
Definition: qtestcase.cpp:961
static int passCount()

Properties

◆ hasRandomSeed

bool QPlainTestLogger::hasRandomSeed
private

Definition at line 81 of file qplaintestlogger_p.h.

Referenced by registerRandomSeed(), and startLogging().

◆ randomSeed

unsigned int QPlainTestLogger::randomSeed
private

Definition at line 80 of file qplaintestlogger_p.h.

Referenced by registerRandomSeed(), and startLogging().


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