Qt 4.8
Public Types | Public Functions | Static Public Functions | List of all members
QAbstractTestLogger Class Referenceabstract

#include <qabstracttestlogger_p.h>

Inheritance diagram for QAbstractTestLogger:
QPlainTestLogger QTestLogger QXmlTestLogger

Public Types

enum  IncidentTypes { Pass, XFail, Fail, XPass }
 
enum  MessageTypes {
  Warn, QWarning, QDebug, QSystem,
  QFatal, Skip, Info
}
 

Public Functions

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

Static Public Functions

static bool isTtyOutput ()
 
static void outputString (const char *msg)
 

Detailed Description

Definition at line 62 of file qabstracttestlogger_p.h.

Enumerations

◆ IncidentTypes

◆ MessageTypes

Constructors and Destructors

◆ QAbstractTestLogger()

QAbstractTestLogger::QAbstractTestLogger ( )
inline

Definition at line 82 of file qabstracttestlogger_p.h.

82 {}

◆ ~QAbstractTestLogger()

virtual QAbstractTestLogger::~QAbstractTestLogger ( )
inlinevirtual

Definition at line 83 of file qabstracttestlogger_p.h.

83 {}

Functions

◆ addBenchmarkResult()

virtual void QAbstractTestLogger::addBenchmarkResult ( const QBenchmarkResult result)
pure virtual

◆ addIncident()

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

◆ addMessage()

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

◆ enterTestFunction()

virtual void QAbstractTestLogger::enterTestFunction ( const char *  function)
pure virtual

◆ isTtyOutput()

bool QAbstractTestLogger::isTtyOutput ( )
static

Definition at line 71 of file qabstracttestlogger.cpp.

Referenced by ~QAbstractTestLogger().

72 {
74 
75 #if defined(Q_OS_WIN) || defined(Q_OS_INTEGRITY)
76  return true;
77 #else
78  static bool ttyoutput = isatty(fileno(QTest::stream));
79  return ttyoutput;
80 #endif
81 }
static FILE * stream
#define QTEST_ASSERT(cond)
Definition: qtestassert.h:53

◆ leaveTestFunction()

virtual void QAbstractTestLogger::leaveTestFunction ( )
pure virtual

◆ outputString()

void QAbstractTestLogger::outputString ( const char *  msg)
static

◆ registerRandomSeed()

virtual void QAbstractTestLogger::registerRandomSeed ( unsigned int  seed)
pure virtual

◆ startLogging()

void QAbstractTestLogger::startLogging ( )
virtual

Reimplemented in QTestLogger, QXmlTestLogger, and QPlainTestLogger.

Definition at line 84 of file qabstracttestlogger.cpp.

Referenced by QPlainTestLogger::startLogging(), QXmlTestLogger::startLogging(), QTestLog::startLogging(), and ~QAbstractTestLogger().

85 {
87 
88  const char *out = QTestLog::outputFileName();
89  if (!out) {
90  QTest::stream = stdout;
91  return;
92  }
93 #if defined(_MSC_VER) && _MSC_VER >= 1400 && !defined(Q_OS_WINCE)
94  if (::fopen_s(&QTest::stream, out, "wt")) {
95 #else
96  QTest::stream = ::fopen(out, "wt");
97  if (!QTest::stream) {
98 #endif
99  printf("Unable to open file for logging: %s", out);
100  ::exit(1);
101  }
102 }
static const char * outputFileName()
Definition: qtestlog.cpp:389
static FILE * stream
#define QTEST_ASSERT(cond)
Definition: qtestassert.h:53

◆ stopLogging()

void QAbstractTestLogger::stopLogging ( )
virtual

Reimplemented in QTestLogger, QXmlTestLogger, and QPlainTestLogger.

Definition at line 104 of file qabstracttestlogger.cpp.

Referenced by QPlainTestLogger::stopLogging(), QXmlTestLogger::stopLogging(), QTestLog::stopLogging(), and ~QAbstractTestLogger().

105 {
107  if (QTest::stream != stdout) {
108  fclose(QTest::stream);
109  } else {
110 #ifdef Q_OS_SYMBIAN
111  // Convenience sleep for Symbian and TRK. Without this sleep depending on the timing the
112  // user would not see the complete output because it is still pending in any of the buffers
113  // before arriving via the USB port on the development PC
114  User::AfterHighRes(2*1000*1000);
115 #endif
116  }
117  QTest::stream = 0;
118 }
static FILE * stream
#define QTEST_ASSERT(cond)
Definition: qtestassert.h:53

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