Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
QTest Namespace Reference

[15] More...

Namespaces

namespace  CrashHandler
 
namespace  Internal
 

Classes

struct  IgnoreResultList
 
class  QBenchmarkIterationController
 
struct  QBenchmarkMetricKey
 
struct  QTestDataSetter
 
class  QTouchEventSequence
 
class  QTouchEventWidgetSequence
 
class  TestMethods
 
class  TestRegistry
 
class  ThrowOnFailDisabler
 
class  ThrowOnFailEnabler
 
class  ThrowOnSkipDisabler
 
class  ThrowOnSkipEnabler
 
class  WatchDog
 

Enumerations

enum  QBenchmarkMetric {
  FramesPerSecond , BitsPerSecond , BytesPerSecond , WalltimeMilliseconds ,
  CPUTicks , InstructionReads , Events , WalltimeNanoseconds ,
  BytesAllocated , CPUMigrations , CPUCycles , BusCycles ,
  StalledCycles , Instructions , BranchInstructions , BranchMisses ,
  CacheReferences , CacheReads , CacheWrites , CachePrefetches ,
  CacheMisses , CacheReadMisses , CacheWriteMisses , CachePrefetchMisses ,
  ContextSwitches , PageFaults , MinorPageFaults , MajorPageFaults ,
  AlignmentFaults , EmulationFaults , RefCPUCycles
}
 
enum  { IndentSpacesCount = 4 , IndentSpacesCount = 4 }
 
enum  {
  Unresolved , Passed , Skipped , Suppressed ,
  Failed , Unresolved , Passed , Skipped ,
  Suppressed , Failed
}
 
enum  { IndentSpacesCount = 4 , IndentSpacesCount = 4 }
 
enum  AttributeIndex {
  AI_Undefined = -1 , AI_Name , AI_Tests , AI_Failures ,
  AI_Errors , AI_Type , AI_Message , AI_PropertyValue ,
  AI_Value , AI_Time , AI_Timestamp , AI_Hostname ,
  AI_Classname , AI_Skipped
}
 
enum  LogElementType {
  LET_Undefined = -1 , LET_Property , LET_Properties , LET_Failure ,
  LET_Error , LET_TestCase , LET_TestSuite , LET_Text ,
  LET_SystemError , LET_SystemOutput , LET_Skipped
}
 
enum  KeyAction { Press , Release , Click , Shortcut }
 
enum  {
  Unresolved , Passed , Skipped , Suppressed ,
  Failed , Unresolved , Passed , Skipped ,
  Suppressed , Failed
}
 
enum  MouseAction {
  MousePress , MouseRelease , MouseClick , MouseDClick ,
  MouseMove
}
 
enum  TestFailMode { Abort = 1 , Continue = 2 }
 
enum class  ComparisonOperation {
  CustomCompare , Equal , NotEqual , LessThan ,
  LessThanOrEqual , GreaterThan , GreaterThanOrEqual , ThreeWayCompare
}
 

Functions

Q_CORE_EXPORT void qSleep (int ms)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Sleeps for ms milliseconds, blocking execution of the test.
 
Q_CORE_EXPORT void qSleep (std::chrono::milliseconds msecs)
 
template<typename Functor>
bool qWaitFor (Functor predicate, QDeadlineTimer deadline=QDeadlineTimer(std::chrono::seconds{5}))
 
template<typename Functor>
bool qWaitFor (Functor predicate, int timeout)
 
Q_CORE_EXPORT void qWait (int ms)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Waits for msecs.
 
Q_CORE_EXPORT void qWait (std::chrono::milliseconds msecs)
 
Q_GUI_EXPORT bool qWaitForWindowActive (QWindow *window, int timeout=5000)
 
Q_GUI_EXPORT bool qWaitForWindowFocused (QWindow *window, QDeadlineTimer timeout=std::chrono::seconds{5})
 
Q_GUI_EXPORT bool qWaitForWindowExposed (QWindow *window, int timeout=5000)
 
Q_GUI_EXPORT QPointingDevicecreateTouchDevice (QInputDevice::DeviceType devType=QInputDevice::DeviceType::TouchScreen, QInputDevice::Capabilities caps=QInputDevice::Capability::Position)
 
template<>
char * toString (const MyPoint &point)
 
int qt_asprintf (QTestCharBuffer *str, const char *format,...)
 
int iterationCount () noexcept
 
void setIterationCountHint (int count)
 
void setIterationCount (int count)
 
void beginBenchmarkMeasurement ()
 
QList< QBenchmarkMeasurerBase::MeasurementendBenchmarkMeasurement ()
 
static const char * ptIncidentType2String (QAbstractTestLogger::IncidentTypes type)
 
static const char * benchmarkResult2String ()
 
static const char * ptMessageType2String (QAbstractTestLogger::MessageTypes type)
 
template<typename T>
static int countSignificantDigits (T num)
 
template<typename T>
QByteArray formatResult (T number, int significantDigits)
 
static void qPrintMessage (const QByteArray &ba)
 
static bool classIsIgnored (const char *className)
 
static void qSignalDumperCallback (QObject *caller, int signal_index, void **argv)
 
static void qSignalDumperCallbackSlot (QObject *caller, int method_index, void **argv)
 
static void qSignalDumperCallbackEndSignal (QObject *caller, int)
 
static const char * tcIncidentType2String (QAbstractTestLogger::IncidentTypes type)
 
static const char * tcMessageType2String (QAbstractTestLogger::MessageTypes type)
 
void setThrowOnFail (bool enable) noexcept
 
void setThrowOnSkip (bool enable) noexcept
 
static bool invokeTestMethodIfValid (QMetaMethod m, QObject *obj=QTest::currentTestObject)
 
static void invokeTestMethodIfExists (const char *methodName, QObject *obj=QTest::currentTestObject)
 
int defaultEventDelay ()
 
int Q_TESTLIB_EXPORT defaultMouseDelay ()
 
int Q_TESTLIB_EXPORT defaultKeyDelay ()
 
static bool qPrintTestSlots (FILE *stream, const char *filter=nullptr, const char *preamble="")
 
static void qPrintDataTags (FILE *stream)
 
static int qToInt (const char *str)
 
Q_TESTLIB_EXPORT void qtest_qParseArgs (int argc, const char *const argv[], bool qml)
 
Q_TESTLIB_EXPORT void qtest_qParseArgs (int argc, char *argv[], bool qml)
 
static QList< QBenchmarkResultqMedian (const QList< QList< QBenchmarkResult > > &container)
 
template<typename Functor>
void runWithWatchdog (std::optional< WatchDog > &watchDog, Functor &&f)
 
static void printUnknownDataTagError (QLatin1StringView name, QLatin1StringView tag, const QTestTable &lTable, const QTestTable &gTable)
 
voidfetchData (QTestData *data, const char *tagName, int typeId)
 
char * formatString (const char *prefix, const char *suffix, size_t numArguments,...)
 
char * toHexRepresentation (const char *ba, qsizetype length)
 Returns a pointer to a string that is the string ba represented as a space-separated sequence of hex characters.
 
char * toPrettyCString (const char *p, qsizetype length)
 
static char * writePrettyUnicodeChar (char16_t ch, char *const buffer)
 
char * toPrettyUnicode (QStringView string)
 
bool reportResult (bool success, const void *lhs, const void *rhs, const char *(*lhsFormatter)(const void *), const char *(*rhsFormatter)(const void *), const char *lhsExpr, const char *rhsExpr, ComparisonOperation op, const char *file, int line)
 
static bool handleIgnoredMessage (QtMsgType type, const QString &message)
 
static bool handleFailOnWarning (const QMessageLogContext &context, const QString &message)
 
static void messageHandler (QtMsgType type, const QMessageLogContext &context, const QString &message)
 
 Q_GLOBAL_STATIC (TestRegistry, g_registry)
 
static void setFailed (bool failed)
 
static void resetFailed ()
 
static bool hasFailed ()
 
static const char * xmlMessageType2String (QAbstractTestLogger::MessageTypes type)
 
static const char * xmlIncidentType2String (QAbstractTestLogger::IncidentTypes type)
 
static bool isEmpty (const char *str)
 
static const char * incidentFormatString (bool noDescription, bool noTag)
 
static const char * benchmarkResultFormatString ()
 
static const char * messageFormatString (bool noDescription, bool noTag)
 
template<>
bool qCompare (QString const &t1, QLatin1StringView const &t2, const char *actual, const char *expected, const char *file, int line)
 
template<>
bool qCompare (QLatin1StringView const &t1, QString const &t2, const char *actual, const char *expected, const char *file, int line)
 
template<typename ActualIterator, typename ExpectedIterator>
bool _q_compareSequence (ActualIterator actualIt, ActualIterator actualEnd, ExpectedIterator expectedBegin, ExpectedIterator expectedEnd, const char *actual, const char *expected, const char *file, int line)
 
template<typename T>
bool qCompare (QList< T > const &t1, QList< T > const &t2, const char *actual, const char *expected, const char *file, int line)
 
template<typename T, int N>
bool qCompare (QList< T > const &t1, std::initializer_list< T > t2, const char *actual, const char *expected, const char *file, int line)
 
template<typename T, int N>
bool qCompare (QList< T > const &t1, const T(&t2)[N], const char *actual, const char *expected, const char *file, int line)
 
template<typename T>
bool qCompare (QFlags< T > const &t1, T const &t2, const char *actual, const char *expected, const char *file, int line)
 
template<typename T>
bool qCompare (QFlags< T > const &t1, int const &t2, const char *actual, const char *expected, const char *file, int line)
 
template<>
bool qCompare (qint64 const &t1, qint32 const &t2, const char *actual, const char *expected, const char *file, int line)
 
template<>
bool qCompare (qint64 const &t1, quint32 const &t2, const char *actual, const char *expected, const char *file, int line)
 
template<>
bool qCompare (quint64 const &t1, quint32 const &t2, const char *actual, const char *expected, const char *file, int line)
 
template<>
bool qCompare (qint32 const &t1, qint64 const &t2, const char *actual, const char *expected, const char *file, int line)
 
template<>
bool qCompare (quint32 const &t1, qint64 const &t2, const char *actual, const char *expected, const char *file, int line)
 
template<>
bool qCompare (quint32 const &t1, quint64 const &t2, const char *actual, const char *expected, const char *file, int line)
 
Q_WIDGETS_EXPORT bool qWaitForWindowActive (QWidget *widget, int timeout=5000)
 
Q_WIDGETS_EXPORT bool qWaitForWindowFocused (QWidget *widget, QDeadlineTimer timeout=std::chrono::seconds{5})
 
Q_WIDGETS_EXPORT bool qWaitForWindowExposed (QWidget *widget, int timeout=5000)
 
char * toString (const QGeoAreaMonitorInfo &info)
 
char * toString (const QGeoPositionInfo &info)
 
char * toString (const QGeoSatelliteInfo &info)
 
template<>
char * toString (const MyPoint &point)
 
void Q_TESTLIB_EXPORT setBenchmarkResult (qreal result, QBenchmarkMetric metric)
 Sets the benchmark result for this test function to result.
 
const char * benchmarkMetricName (QBenchmarkMetric metric)
 
const char * benchmarkMetricUnit (QBenchmarkMetric metric)
 
template<>
char * toString (const QColor &color)
 
template<>
char * toString (const QRegion &region)
 
template<>
char * toString (const QVector2D &v)
 
template<>
char * toString (const QVector3D &v)
 
template<>
char * toString (const QVector4D &v)
 
bool qCompare (QIcon const &t1, QIcon const &t2, const char *actual, const char *expected, const char *file, int line)
 
bool qCompare (QImage const &t1, QImage const &t2, const char *actual, const char *expected, const char *file, int line)
 
bool qCompare (QPixmap const &t1, QPixmap const &t2, const char *actual, const char *expected, const char *file, int line)
 
template<>
char * toString< QHostAddress > (const QHostAddress &addr)
 
Q_TESTLIB_EXPORT void qInit (QObject *testObject, int argc=0, char **argv=nullptr)
 
Q_TESTLIB_EXPORT int qRun ()
 
Q_TESTLIB_EXPORT void qCleanup ()
 
Q_TESTLIB_EXPORT int qExec (QObject *testObject, int argc=0, char **argv=nullptr)
 Executes tests declared in testObject.
 
Q_TESTLIB_EXPORT int qExec (QObject *testObject, const QStringList &arguments)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
Q_TESTLIB_EXPORT void setMainSourcePath (const char *file, const char *builddir=nullptr)
 
Q_TESTLIB_EXPORT bool qVerify (bool statement, const char *statementStr, const char *description, const char *file, int line)
 
Q_DECL_COLD_FUNCTION Q_TESTLIB_EXPORT void qFail (const char *message, const char *file, int line)
 
Q_TESTLIB_EXPORT void qSkip (const char *message, const char *file, int line)
 
Q_TESTLIB_EXPORT bool qExpectFail (const char *dataIndex, const char *comment, TestFailMode mode, const char *file, int line)
 
Q_DECL_COLD_FUNCTION Q_TESTLIB_EXPORT void qCaught (const char *expected, const char *what, const char *file, int line)
 
Q_DECL_COLD_FUNCTION Q_TESTLIB_EXPORT void qCaught (const char *expected, const char *file, int line)
 
Q_TESTLIB_EXPORT void ignoreMessage (QtMsgType type, const char *message)
 Ignores messages created by qDebug(), qInfo() or qWarning().
 
Q_TESTLIB_EXPORT void failOnWarning ()
 
Q_TESTLIB_EXPORT void failOnWarning (const char *message)
 
Q_TESTLIB_EXPORT QString qFindTestData (const char *basepath, const char *file=nullptr, int line=0, const char *builddir=nullptr, const char *sourcedir=nullptr)
 
Q_TESTLIB_EXPORT QString qFindTestData (const QString &basepath, const char *file=nullptr, int line=0, const char *builddir=nullptr, const char *sourcedir=nullptr)
 
Q_TESTLIB_EXPORT voidqData (const char *tagName, int typeId)
 
Q_TESTLIB_EXPORT voidqGlobalData (const char *tagName, int typeId)
 
Q_TESTLIB_EXPORT voidqElementData (const char *elementName, int metaTypeId)
 
Q_TESTLIB_EXPORT QObjecttestObject ()
 
Q_TESTLIB_EXPORT const char * currentAppName ()
 Returns the name of the binary that is currently executed.
 
Q_TESTLIB_EXPORT const char * currentTestFunction ()
 Returns the name of the test function that is currently executed.
 
Q_TESTLIB_EXPORT const char * currentDataTag ()
 Returns the name of the current test data.
 
Q_TESTLIB_EXPORT bool currentTestFailed ()
 Returns true if the current test function has failed, otherwise false.
 
Q_TESTLIB_EXPORT bool currentTestResolved ()
 
Q_TESTLIB_EXPORT bool runningTest ()
 
Q_TESTLIB_EXPORT Qt::Key asciiToKey (char ascii)
 
Q_TESTLIB_EXPORT char keyToAscii (Qt::Key key)
 
Q_TESTLIB_EXPORT bool compare_helper (bool success, const char *failureMsg, const void *actualPtr, const void *expectedPtr, const char *(*actualFormatter)(const void *), const char *(*expectedFormatter)(const void *), const char *actual, const char *expected, const char *file, int line)
 
Q_TESTLIB_EXPORT bool compare_helper (bool success, const char *failureMsg, const char *actual, const char *expected, const char *file, int line)
 
Q_TESTLIB_EXPORT bool compare_3way_helper (bool success, const char *failureMsg, const void *lhsPtr, const void *rhsPtr, const char *(*lhsFormatter)(const void *), const char *(*rhsFormatter)(const void *), const char *lhsStr, const char *rhsStr, const char *(*actualOrderFormatter)(const void *), const char *(*expectedOrderFormatter)(const void *), const void *actualOrderPtr, const void *expectedOrderPtr, const char *expectedExpression, const char *file, int line)
 
Q_TESTLIB_EXPORT void addColumnInternal (int id, const char *name)
 
template<typename T>
void addColumn (const char *name, T *=nullptr)
 Adds a column with type {T} to the current test data.
 
Q_TESTLIB_EXPORT QTestDatanewRow (const char *dataTag)
 Appends a new row to the current test data.
 
Q_TESTLIB_EXPORT QTestDataaddRow (const char *format,...) Q_ATTRIBUTE_FORMAT_PRINTF(1
 
Q_TESTLIB_EXPORT QTestData Q_TESTLIB_EXPORT bool qCompare (qfloat16 const &t1, qfloat16 const &t2, const char *actual, const char *expected, const char *file, int line)
 
Q_TESTLIB_EXPORT bool qCompare (float const &t1, float const &t2, const char *actual, const char *expected, const char *file, int line)
 
Q_TESTLIB_EXPORT bool qCompare (double const &t1, double const &t2, const char *actual, const char *expected, const char *file, int line)
 
Q_TESTLIB_EXPORT bool qCompare (int t1, int t2, const char *actual, const char *expected, const char *file, int line)
 
Q_TESTLIB_EXPORT bool qCompare (unsigned t1, unsigned t2, const char *actual, const char *expected, const char *file, int line)
 
Q_TESTLIB_EXPORT bool qCompare (QStringView t1, QStringView t2, const char *actual, const char *expected, const char *file, int line)
 
Q_TESTLIB_EXPORT bool qCompare (QStringView t1, const QLatin1StringView &t2, const char *actual, const char *expected, const char *file, int line)
 
Q_TESTLIB_EXPORT bool qCompare (const QLatin1StringView &t1, QStringView t2, const char *actual, const char *expected, const char *file, int line)
 
bool qCompare (const QString &t1, const QString &t2, const char *actual, const char *expected, const char *file, int line)
 
bool compare_ptr_helper (const volatile void *t1, const volatile void *t2, const char *actual, const char *expected, const char *file, int line)
 
bool compare_ptr_helper (const volatile QObject *t1, const volatile QObject *t2, const char *actual, const char *expected, const char *file, int line)
 
bool compare_ptr_helper (const volatile QObject *t1, std::nullptr_t, const char *actual, const char *expected, const char *file, int line)
 
bool compare_ptr_helper (std::nullptr_t, const volatile QObject *t2, const char *actual, const char *expected, const char *file, int line)
 
bool compare_ptr_helper (const volatile void *t1, std::nullptr_t, const char *actual, const char *expected, const char *file, int line)
 
bool compare_ptr_helper (std::nullptr_t, const volatile void *t2, const char *actual, const char *expected, const char *file, int line)
 
template<typename T1, typename T2 = T1>
bool qCompare (const T1 &t1, const T2 &t2, const char *actual, const char *expected, const char *file, int line)
 
bool qCompare (double const &t1, float const &t2, const char *actual, const char *expected, const char *file, int line)
 
bool qCompare (float const &t1, double const &t2, const char *actual, const char *expected, const char *file, int line)
 
template<typename T>
bool qCompare (const T *t1, const T *t2, const char *actual, const char *expected, const char *file, int line)
 
template<typename T>
bool qCompare (T *t1, T *t2, const char *actual, const char *expected, const char *file, int line)
 
template<typename T>
bool qCompare (T *t1, std::nullptr_t, const char *actual, const char *expected, const char *file, int line)
 
template<typename T>
bool qCompare (std::nullptr_t, T *t2, const char *actual, const char *expected, const char *file, int line)
 
template<typename T1, typename T2>
bool qCompare (const T1 *t1, const T2 *t2, const char *actual, const char *expected, const char *file, int line)
 
template<typename T1, typename T2>
bool qCompare (T1 *t1, T2 *t2, const char *actual, const char *expected, const char *file, int line)
 
bool qCompare (const char *t1, const char *t2, const char *actual, const char *expected, const char *file, int line)
 
bool qCompare (char *t1, char *t2, const char *actual, const char *expected, const char *file, int line)
 
bool qCompare (char *t1, const char *t2, const char *actual, const char *expected, const char *file, int line)
 
bool qCompare (const char *t1, char *t2, const char *actual, const char *expected, const char *file, int line)
 
template<class T>
bool qTest (const T &actual, const char *elementName, const char *actualStr, const char *expected, const char *file, int line)
 
template<ComparisonOperation op, typename T1, typename T2 = T1>
bool qCompareOp (T1 &&lhs, T2 &&rhs, const char *lhsExpr, const char *rhsExpr, const char *file, int line)
 
template<typename OrderingType, typename LHS, typename RHS = LHS>
void qCompare3Way (LHS &&lhs, RHS &&rhs, OrderingType order, const char *lhsExpression, const char *rhsExpression, const char *resultExpression, const char *file, int line)=delete
 
static void simulateEvent (QWindow *window, bool press, int code, Qt::KeyboardModifiers modifier, QString text, bool repeat, int delay=-1)
 
static void sendKeyEvent (KeyAction action, QWindow *window, Qt::Key code, QString text, Qt::KeyboardModifiers modifier, int delay=-1)
 
static void sendKeyEvent (KeyAction action, QWindow *window, Qt::Key code, char ascii, Qt::KeyboardModifiers modifier, int delay=-1)
 
static void keyEvent (KeyAction action, QWindow *window, char ascii, Qt::KeyboardModifiers modifier=Qt::NoModifier, int delay=-1)
 
static void keyEvent (KeyAction action, QWindow *window, Qt::Key key, Qt::KeyboardModifiers modifier=Qt::NoModifier, int delay=-1)
 
static void keyClick (QWindow *window, Qt::Key key, Qt::KeyboardModifiers modifier=Qt::NoModifier, int delay=-1)
 
static void keyClick (QWindow *window, char key, Qt::KeyboardModifiers modifier=Qt::NoModifier, int delay=-1)
 
static void keyRelease (QWindow *window, char key, Qt::KeyboardModifiers modifier=Qt::NoModifier, int delay=-1)
 
static void keyRelease (QWindow *window, Qt::Key key, Qt::KeyboardModifiers modifier=Qt::NoModifier, int delay=-1)
 
static void keyPress (QWindow *window, char key, Qt::KeyboardModifiers modifier=Qt::NoModifier, int delay=-1)
 
static void keyPress (QWindow *window, Qt::Key key, Qt::KeyboardModifiers modifier=Qt::NoModifier, int delay=-1)
 
static void mouseEvent (MouseAction action, QWindow *window, Qt::MouseButton button, Qt::KeyboardModifiers stateKey, QPoint pos, int delay=-1)
 
void mousePress (QWindow *window, Qt::MouseButton button, Qt::KeyboardModifiers stateKey=Qt::KeyboardModifiers(), QPoint pos=QPoint(), int delay=-1)
 
void mouseRelease (QWindow *window, Qt::MouseButton button, Qt::KeyboardModifiers stateKey=Qt::KeyboardModifiers(), QPoint pos=QPoint(), int delay=-1)
 
void mouseClick (QWindow *window, Qt::MouseButton button, Qt::KeyboardModifiers stateKey=Qt::KeyboardModifiers(), QPoint pos=QPoint(), int delay=-1)
 
void mouseDClick (QWindow *window, Qt::MouseButton button, Qt::KeyboardModifiers stateKey=Qt::KeyboardModifiers(), QPoint pos=QPoint(), int delay=-1)
 
void mouseMove (QWindow *window, QPoint pos=QPoint(), int delay=-1)
 
Q_TESTLIB_EXPORT bool compare_string_helper (const char *t1, const char *t2, const char *actual, const char *expected, const char *file, int line)
 
template<typename T>
char * toString (const T &t)
 
template<typename T1, typename T2>
char * toString (const std::pair< T1, T2 > &pair)
 
template<class... Types>
char * toString (const std::tuple< Types... > &tuple)
 
template<typename Rep, typename Period>
char * toString (std::chrono::duration< Rep, Period > duration)
 
Q_TESTLIB_EXPORT char * toString (const char *)
 
Q_TESTLIB_EXPORT char * toString (const volatile void *)
 
Q_TESTLIB_EXPORT char * toString (const QObject *)
 
Q_TESTLIB_EXPORT char * toString (const volatile QObject *)
 
template<>
char * toString (const QStringView &str)
 
template<>
char * toString (const QString &str)
 
template<>
char * toString (const QLatin1StringView &str)
 
template<>
char * toString (const QByteArray &ba)
 
template<>
char * toString (const QBitArray &ba)
 
template<>
char * toString (const QCborError &c)
 
template<>
char * toString (const QChar &c)
 
template<>
char * toString (const QPoint &p)
 
template<>
char * toString (const QSize &s)
 
template<>
char * toString (const QRect &s)
 
template<>
char * toString (const QPointF &p)
 
template<>
char * toString (const QSizeF &s)
 
template<>
char * toString (const QRectF &s)
 
template<>
char * toString (const QUrl &uri)
 
template<>
char * toString (const QUuid &uuid)
 
template<>
char * toString (const QVariant &v)
 
template<>
char * toString (const QPartialOrdering &o)
 
template<>
char * toString (const QCborValue &v)
 
template<>
char * toString (const QCborValueRef &v)
 
template<>
char * toString (const QCborArray &a)
 
template<>
char * toString (const QCborMap &m)
 
template<typename Tuple, std::size_t... I>
char * tupleToString (const Tuple &tuple, std::index_sequence< I... >)
 
char * toString (std::nullptr_t)
 
QTouchEventSequence touchEvent (QWindow *window, QPointingDevice *device, bool autoCommit=true)
 
static void wheelEvent (QWindow *window, QPointF pos, QPoint angleDelta, QPoint pixelDelta=QPoint(0, 0), Qt::KeyboardModifiers stateKey=Qt::NoModifier, Qt::ScrollPhase phase=Qt::NoScrollPhase)
 

Variables

static const QBenchmarkMetricKey entries []
 
static const int NumEntries = sizeof(entries) / sizeof(entries[0])
 
static Q_CONSTINIT QBasicMutex ignoreClassesMutex
 
Q_CONSTINIT thread_local int iLevel = 0
 
Q_CONSTINIT thread_local int ignoreLevel = 0
 
static Q_CONSTINIT QBasicAtomicInt g_throwOnFail = Q_BASIC_ATOMIC_INITIALIZER(0)
 
static Q_CONSTINIT QBasicAtomicInt g_throwOnSkip = Q_BASIC_ATOMIC_INITIALIZER(0)
 
Q_TESTLIB_EXPORT int lastMouseTimestamp = 0
 
static QObjectcurrentTestObject = nullptr
 
static QString mainSourcePath
 
static bool inTestFunction = false
 
static int keyDelay = -1
 
static int mouseDelay = -1
 
static int eventDelay = -1
 
static int repetitions = 1
 
static bool skipBlacklisted = false
 
Q_TESTLIB_EXPORT bool printAvailableFunctions = false
 
Q_TESTLIB_EXPORT QStringList testFunctions
 
Q_TESTLIB_EXPORT QStringList testTags
 
constexpr qsizetype PrettyUnicodeMaxOutputSize = 256
 
constexpr qsizetype PrettyUnicodeMaxIncrement = sizeof(R"(\uXXXX"...)")
 
int fails = 0
 
int passes = 0
 
int skips = 0
 
int blacklists = 0
 
enum QTest:: { ... }  currentTestState
 
static IgnoreResultListignoreResultList = nullptr
 
static Q_CONSTINIT QBasicMutex mutex
 
static std::vector< QVariantfailOnWarningList
 
static int verbosity = 0
 
static int maxWarnings = 2002
 
static bool installedTestCoverage = true
 
static QtMessageHandler oldMessageHandler
 
static QTestDatacurrentTestData = nullptr
 
static QTestDatacurrentGlobalTestData = nullptr
 
static const char * currentTestFunc = nullptr
 
static const char * currentTestObjectName = nullptr
 
static bool skipCurrentTest = false
 
static bool blacklistCurrentTest = false
 
static const char * expectFailComment = nullptr
 
static int expectFailMode = 0
 
static const int mouseDoubleClickInterval = 500
 

Detailed Description

[15]

[16]

Enumeration Type Documentation

◆ anonymous enum [1/2]

anonymous enum
Enumerator
IndentSpacesCount 
IndentSpacesCount 

Definition at line 30 of file qsignaldumper.cpp.

◆ anonymous enum [2/2]

anonymous enum
Enumerator
IndentSpacesCount 
IndentSpacesCount 

Definition at line 30 of file qsignaldumper.cpp.

◆ anonymous enum [1/2]

anonymous enum
Enumerator
Unresolved 
Passed 
Skipped 
Suppressed 
Failed 
Unresolved 
Passed 
Skipped 
Suppressed 
Failed 

Definition at line 144 of file qtestlog.cpp.

◆ anonymous enum [2/2]

anonymous enum
Enumerator
Unresolved 
Passed 
Skipped 
Suppressed 
Failed 
Unresolved 
Passed 
Skipped 
Suppressed 
Failed 

Definition at line 144 of file qtestlog.cpp.

◆ AttributeIndex

Enumerator
AI_Undefined 
AI_Name 
AI_Tests 
AI_Failures 
AI_Errors 
AI_Type 
AI_Message 
AI_PropertyValue 
AI_Value 
AI_Time 
AI_Timestamp 
AI_Hostname 
AI_Classname 
AI_Skipped 

Definition at line 26 of file qtestelementattribute_p.h.

◆ ComparisonOperation

enum class QTest::ComparisonOperation
strong
Enumerator
CustomCompare 
Equal 
NotEqual 
LessThan 
LessThanOrEqual 
GreaterThan 
GreaterThanOrEqual 
ThreeWayCompare 

Definition at line 26 of file qttestglobal.h.

◆ KeyAction

Enumerator
Press 
Release 
Click 
Shortcut 

Definition at line 37 of file qtestkeyboard.h.

◆ LogElementType

Enumerator
LET_Undefined 
LET_Property 
LET_Properties 
LET_Failure 
LET_Error 
LET_TestCase 
LET_TestSuite 
LET_Text 
LET_SystemError 
LET_SystemOutput 
LET_Skipped 

Definition at line 44 of file qtestelementattribute_p.h.

◆ MouseAction

Enumerator
MousePress 
MouseRelease 
MouseClick 
MouseDClick 
MouseMove 

Definition at line 40 of file qtestmouse.h.

◆ QBenchmarkMetric

Since
4.7

This enum lists all the things that can be benchmarked.

\value FramesPerSecond Frames per second \value BitsPerSecond Bits per second \value BytesPerSecond Bytes per second \value WalltimeMilliseconds Clock time in milliseconds \value WalltimeNanoseconds Clock time in nanoseconds \value BytesAllocated Memory usage in bytes \value Events Event count \value CPUTicks CPU time \value CPUMigrations Process migrations between CPUs \value CPUCycles CPU cycles \value RefCPUCycles Reference CPU cycles \value BusCycles Bus cycles \value StalledCycles Cycles stalled \value InstructionReads Instruction reads \value Instructions Instructions executed \value BranchInstructions Branch-type instructions \value BranchMisses Branch instructions that were mispredicted \value CacheReferences Cache accesses of any type \value CacheMisses Cache misses of any type \value CacheReads Cache reads / loads \value CacheReadMisses Cache read / load misses \value CacheWrites Cache writes / stores \value CacheWriteMisses Cache write / store misses \value CachePrefetches Cache prefetches \value CachePrefetchMisses Cache prefetch misses \value ContextSwitches Context switches \value PageFaults Page faults of any type \value MinorPageFaults Minor page faults \value MajorPageFaults Major page faults \value AlignmentFaults Faults caused due to misalignment \value EmulationFaults Faults that needed software emulation

See also
QTest::benchmarkMetricName(), QTest::benchmarkMetricUnit()

Note that WalltimeNanoseconds and BytesAllocated are only provided for use via \l setBenchmarkResult(), and results in those metrics are not able to be provided automatically by the QTest framework.

Enumerator
FramesPerSecond 
BitsPerSecond 
BytesPerSecond 
WalltimeMilliseconds 
CPUTicks 
InstructionReads 
Events 
WalltimeNanoseconds 
BytesAllocated 
CPUMigrations 
CPUCycles 
BusCycles 
StalledCycles 
Instructions 
BranchInstructions 
BranchMisses 
CacheReferences 
CacheReads 
CacheWrites 
CachePrefetches 
CacheMisses 
CacheReadMisses 
CacheWriteMisses 
CachePrefetchMisses 
ContextSwitches 
PageFaults 
MinorPageFaults 
MajorPageFaults 
AlignmentFaults 
EmulationFaults 
RefCPUCycles 

Definition at line 15 of file qbenchmarkmetric.h.

◆ TestFailMode

Enumerator
Abort 
Continue 

Definition at line 25 of file qttestglobal.h.

Function Documentation

◆ _q_compareSequence()

template<typename ActualIterator, typename ExpectedIterator>
bool QTest::_q_compareSequence ( ActualIterator actualIt,
ActualIterator actualEnd,
ExpectedIterator expectedBegin,
ExpectedIterator expectedEnd,
const char * actual,
const char * expected,
const char * file,
int line )

Definition at line 46 of file qtest.h.

◆ addColumn()

template<typename T>
void QTest::addColumn ( const char * name,
T * dummy = nullptr )
inline

Adds a column with type {T} to the current test data.

name is the name of the column. dummy is a workaround for buggy compilers and can be ignored.

To populate the column with values, newRow() can be used. Use \l QFETCH() to fetch the data in the actual test.

Example:

QTest::newRow("row1") << 1 << "hello" << 1.5;
Note
This function can only be used called as part of a test's data function that is invoked by the test framework.

See \l {Chapter 2: Data Driven Testing}{Data Driven Testing} for a more extensive example.

See also
QTest::newRow(), QFETCH(), QMetaType

Definition at line 538 of file qtestcase.h.

◆ addColumnInternal()

void QTest::addColumnInternal ( int id,
const char * name )

Definition at line 2559 of file qtestcase.cpp.

◆ addRow()

QTestData & QTest::addRow ( const char * format,
... )
Since
5.9

Appends a new row to the current test data.

The function's arguments are passed to std::snprintf() for formatting according to format. See the \l{https://en.cppreference.com/w/cpp/io/c/fprintf}{std::snprintf() documentation} for caveats and limitations.

The test output will identify the test run with this test data using the name that results from this formatting.

Returns a QTestData reference that can be used to stream in data, one value for each column in the table.

Example:

QTest::addRow("%d", 0) << 0 << QString("0");
QTest::addRow("%d", 1) << 1 << QString("1");
Note
This function can only be called as part of a test's data function that is invoked by the test framework.

See \l {Chapter 2: Data Driven Testing}{Data Driven Testing} for a more extensive example.

See also
newRow(), addColumn(), QFETCH()

Definition at line 2625 of file qtestcase.cpp.

◆ asciiToKey()

QT_BEGIN_NAMESPACE Qt::Key QTest::asciiToKey ( char ascii)

Convert an ascii char key value to a Qt Key value. If the key is unknown a 0 is returned.

Note: this may happen more than you like since not all known ascii keys are converted already. So feel free to add all the keys you need.

Definition at line 16 of file qasciikey.cpp.

◆ beginBenchmarkMeasurement()

void QTest::beginBenchmarkMeasurement ( )

Definition at line 207 of file qbenchmark.cpp.

◆ benchmarkMetricName()

const char * QTest::benchmarkMetricName ( QBenchmarkMetric metric)
Since
4.7 Returns the enum value metric as a character string.

Definition at line 104 of file qbenchmarkmetric.cpp.

References entries, and NumEntries.

◆ benchmarkMetricUnit()

const char * QTest::benchmarkMetricUnit ( QBenchmarkMetric metric)
Since
4.7 Returns the units of measure for the specified metric.

Definition at line 116 of file qbenchmarkmetric.cpp.

References entries, and NumEntries.

◆ benchmarkResult2String()

static const char * QTest::benchmarkResult2String ( )
static

Definition at line 132 of file qplaintestlogger.cpp.

◆ benchmarkResultFormatString()

static const char * QTest::benchmarkResultFormatString ( )
static

Definition at line 192 of file qxmltestlogger.cpp.

◆ classIsIgnored()

static bool QTest::classIsIgnored ( const char * className)
static

Definition at line 32 of file qsignaldumper.cpp.

◆ compare_3way_helper()

bool QTest::compare_3way_helper ( bool success,
const char * failureMsg,
const void * lhsPtr,
const void * rhsPtr,
const char *(* lhsFormatter )(const void *),
const char *(* rhsFormatter )(const void *),
const char * lhsExpression,
const char * rhsExpression,
const char *(* actualOrderFormatter )(const void *),
const char *(* expectedOrderFormatter )(const void *),
const void * actualOrderPtr,
const void * expectedOrderPtr,
const char * expectedExpression,
const char * file,
int line )
Since
6.9 This function reports the result of a three-way comparison, when needed.

Aside from logging every check if in verbose mode and reporting an unexpected pass when failure was expected, if success is true this produces no output. Otherwise, a failure is reported. The output on failure reports the expressions compared, their values, the actual result of the comparison and the expected result of comparison, along with the supplied failure message failureMsg and the file and line number at which the error arose.

The expressions compared are supplied as lhsExpression and rhsExpression. These are combined, with {"<=>"}, to obtain the actual comparison expression. Their actual values are pointed to by lhsPtr and rhsPtr, which are formatted by lhsFormatter and rhsFormatter as, respectively, lhsFormatter(lhsPtr) and rhsFormatter(rhsPtr). The actual comparison expression is contrasted, in the output, with the expected comparison expression expectedExpression. Their respective values are supplied by actualOrderPtr and expectedOrderPtr pointers, which are formatted by actualOrderFormatter and expectedOrderFormatter.

If failureMsg is \nullptr a default is used. If a formatter function returns nullptr, the text {"<null>"} is used.

Definition at line 2865 of file qtestcase.cpp.

◆ compare_helper() [1/2]

bool QTest::compare_helper ( bool success,
const char * failureMsg,
const char * actual,
const char * expected,
const char * file,
int line )
Since
6.4 This function is called by various specializations of QTest::qCompare to decide whether to report a failure and to produce verbose test output.

This overload should be used when there is no string representation of actual and expected values, so only the failureMsg is shown when the comparison fails. Because of that, failureMsg can't be {nullptr}. If the comparison succeeds, failureMsg will not be output.

Definition at line 2897 of file qtestcase.cpp.

◆ compare_helper() [2/2]

bool QTest::compare_helper ( bool success,
const char * failureMsg,
const void * actualPtr,
const void * expectedPtr,
const char *(* actualFormatter )(const void *),
const char *(* expectedFormatter )(const void *),
const char * actual,
const char * expected,
const char * file,
int line )
Since
6.8 This function is called by various specializations of QTest::qCompare to decide whether to report a failure and to produce verbose test output.

The failureMsg parameter can be {nullptr}, in which case a default message will be output if the compare fails. If the comparison succeeds, failureMsg will not be output.

Definition at line 2823 of file qtestcase.cpp.

◆ compare_ptr_helper() [1/6]

bool QTest::compare_ptr_helper ( const volatile QObject * t1,
const volatile QObject * t2,
const char * actual,
const char * expected,
const char * file,
int line )
inline

Definition at line 604 of file qtestcase.h.

◆ compare_ptr_helper() [2/6]

bool QTest::compare_ptr_helper ( const volatile QObject * t1,
std::nullptr_t ,
const char * actual,
const char * expected,
const char * file,
int line )
inline

Definition at line 613 of file qtestcase.h.

◆ compare_ptr_helper() [3/6]

bool QTest::compare_ptr_helper ( const volatile void * t1,
const volatile void * t2,
const char * actual,
const char * expected,
const char * file,
int line )
inline

Definition at line 595 of file qtestcase.h.

◆ compare_ptr_helper() [4/6]

bool QTest::compare_ptr_helper ( const volatile void * t1,
std::nullptr_t ,
const char * actual,
const char * expected,
const char * file,
int line )
inline

Definition at line 633 of file qtestcase.h.

◆ compare_ptr_helper() [5/6]

bool QTest::compare_ptr_helper ( std::nullptr_t ,
const volatile QObject * t2,
const char * actual,
const char * expected,
const char * file,
int line )
inline

Definition at line 623 of file qtestcase.h.

◆ compare_ptr_helper() [6/6]

bool QTest::compare_ptr_helper ( std::nullptr_t ,
const volatile void * t2,
const char * actual,
const char * expected,
const char * file,
int line )
inline

Definition at line 643 of file qtestcase.h.

◆ compare_string_helper()

bool QTest::compare_string_helper ( const char * t1,
const char * t2,
const char * actual,
const char * expected,
const char * file,
int line )

Definition at line 3227 of file qtestcase.cpp.

◆ countSignificantDigits()

template<typename T>
static int QTest::countSignificantDigits ( T num)
static

Definition at line 159 of file qplaintestlogger.cpp.

◆ createTouchDevice()

Q_GUI_EXPORT QPointingDevice * QTest::createTouchDevice ( QInputDevice::DeviceType devType = QInputDevice::DeviceType::TouchScreen,
QInputDevice::Capabilities caps = QInputDevice::Capability::Position )

Definition at line 1221 of file qwindowsysteminterface.cpp.

◆ currentAppName()

const char * QTest::currentAppName ( )

Returns the name of the binary that is currently executed.

Definition at line 2669 of file qtestcase.cpp.

◆ currentDataTag()

const char * QTest::currentDataTag ( )

Returns the name of the current test data.

If the test doesn't have any assigned testdata, the function returns \nullptr.

Definition at line 2690 of file qtestcase.cpp.

◆ currentTestFailed()

bool QTest::currentTestFailed ( )

Returns true if the current test function has failed, otherwise false.

See also
QTest::currentTestResolved()

Definition at line 2700 of file qtestcase.cpp.

◆ currentTestFunction()

const char * QTest::currentTestFunction ( )

Returns the name of the test function that is currently executed.

Example:

{
if (qstrcmp(QTest::currentTestFunction(), "myDatabaseTest") == 0) {
// clean up all database connections
}
}

Definition at line 2681 of file qtestcase.cpp.

◆ currentTestResolved()

bool QTest::currentTestResolved ( )
Since
6.5 Returns true if the current test function has failed or skipped.

This applies if the test has failed or exercised a skip. When it is true, the test function should return early. In particular, the {QTRY_*} macros and the test event loop terminate their loops early if executed during the test function (but not its cleanup()). After a test has called a helper function that uses this module's macros, it can use this function to test whether to return early.

See also
QTest::currentTestFailed()

Definition at line 2718 of file qtestcase.cpp.

◆ defaultEventDelay()

int QTest::defaultEventDelay ( )

Definition at line 449 of file qtestcase.cpp.

References eventDelay.

◆ defaultKeyDelay()

int Q_TESTLIB_EXPORT QTest::defaultKeyDelay ( )

Definition at line 473 of file qtestcase.cpp.

◆ defaultMouseDelay()

int Q_TESTLIB_EXPORT QTest::defaultMouseDelay ( )

Definition at line 461 of file qtestcase.cpp.

◆ endBenchmarkMeasurement()

QList< QBenchmarkMeasurerBase::Measurement > QTest::endBenchmarkMeasurement ( )

Definition at line 215 of file qbenchmark.cpp.

◆ failOnWarning() [1/2]

void QTest::failOnWarning ( )
related

Definition at line 2226 of file qtestcase.cpp.

◆ failOnWarning() [2/2]

void QTest::failOnWarning ( const char * message)

Definition at line 2239 of file qtestcase.cpp.

◆ fetchData()

void * QTest::fetchData ( QTestData * data,
const char * tagName,
int typeId )

Definition at line 1393 of file qtestcase.cpp.

◆ formatResult()

template<typename T>
QByteArray QTest::formatResult ( T number,
int significantDigits )

Definition at line 176 of file qplaintestlogger.cpp.

◆ formatString()

Q_TESTLIB_EXPORT char * QTest::formatString ( const char * prefix,
const char * suffix,
size_t numArguments,
... )

Definition at line 1418 of file qtestcase.cpp.

◆ handleFailOnWarning()

static bool QTest::handleFailOnWarning ( const QMessageLogContext & context,
const QString & message )
static

Definition at line 243 of file qtestlog.cpp.

◆ handleIgnoredMessage()

static bool QTest::handleIgnoredMessage ( QtMsgType type,
const QString & message )
static

Definition at line 217 of file qtestlog.cpp.

References ignoreResultList, and QTest::IgnoreResultList::next.

◆ hasFailed()

static bool QTest::hasFailed ( )
static

Definition at line 55 of file qtestresult.cpp.

References QTest::Internal::failed.

◆ ignoreMessage()

void QTest::ignoreMessage ( QtMsgType type,
const char * message )

Ignores messages created by qDebug(), qInfo() or qWarning().

If the message with the corresponding type is outputted, it will be removed from the test log. If the test finished and the message was not outputted, a test failure is appended to the test log.

Note
Invoking this function will only ignore one message. If the message you want to ignore is output twice, you have to call ignoreMessage() twice, too.

Example:

QTest::ignoreMessage(QtWarningMsg, "QDir::mkdir: Empty or null file name(s)");
dir.mkdir("");

The example above tests that QDir::mkdir() outputs the right warning when invoked with an invalid file name.

Definition at line 2191 of file qtestcase.cpp.

◆ incidentFormatString()

static const char * QTest::incidentFormatString ( bool noDescription,
bool noTag )
static

Definition at line 173 of file qxmltestlogger.cpp.

◆ invokeTestMethodIfExists()

static void QTest::invokeTestMethodIfExists ( const char * methodName,
QObject * obj = QTest::currentTestObject )
static

Definition at line 441 of file qtestcase.cpp.

Referenced by qPrintDataTags().

+ Here is the caller graph for this function:

◆ invokeTestMethodIfValid()

static bool QTest::invokeTestMethodIfValid ( QMetaMethod m,
QObject * obj = QTest::currentTestObject )
static

Definition at line 429 of file qtestcase.cpp.

◆ isEmpty()

static bool QTest::isEmpty ( const char * str)
inlinestatic

Definition at line 168 of file qxmltestlogger.cpp.

◆ iterationCount()

int QTest::iterationCount ( )
noexcept

Definition at line 185 of file qbenchmark.cpp.

◆ keyClick() [1/2]

static void QTest::keyClick ( QWindow * window,
char key,
Qt::KeyboardModifiers modifier = Qt::NoModifier,
int delay = -1 )
inlinestatic

Definition at line 127 of file qtestkeyboard.h.

References Click.

◆ keyClick() [2/2]

static void QTest::keyClick ( QWindow * window,
Qt::Key key,
Qt::KeyboardModifiers modifier = Qt::NoModifier,
int delay = -1 )
inlinestatic

Definition at line 125 of file qtestkeyboard.h.

References Click.

◆ keyEvent() [1/2]

static void QTest::keyEvent ( KeyAction action,
QWindow * window,
char ascii,
Qt::KeyboardModifiers modifier = Qt::NoModifier,
int delay = -1 )
inlinestatic

Definition at line 118 of file qtestkeyboard.h.

◆ keyEvent() [2/2]

static void QTest::keyEvent ( KeyAction action,
QWindow * window,
Qt::Key key,
Qt::KeyboardModifiers modifier = Qt::NoModifier,
int delay = -1 )
inlinestatic

Definition at line 121 of file qtestkeyboard.h.

◆ keyPress() [1/2]

static void QTest::keyPress ( QWindow * window,
char key,
Qt::KeyboardModifiers modifier = Qt::NoModifier,
int delay = -1 )
inlinestatic

Definition at line 133 of file qtestkeyboard.h.

References Press.

◆ keyPress() [2/2]

static void QTest::keyPress ( QWindow * window,
Qt::Key key,
Qt::KeyboardModifiers modifier = Qt::NoModifier,
int delay = -1 )
inlinestatic

Definition at line 135 of file qtestkeyboard.h.

References Press.

◆ keyRelease() [1/2]

static void QTest::keyRelease ( QWindow * window,
char key,
Qt::KeyboardModifiers modifier = Qt::NoModifier,
int delay = -1 )
inlinestatic

Definition at line 129 of file qtestkeyboard.h.

References Release.

◆ keyRelease() [2/2]

static void QTest::keyRelease ( QWindow * window,
Qt::Key key,
Qt::KeyboardModifiers modifier = Qt::NoModifier,
int delay = -1 )
inlinestatic

Definition at line 131 of file qtestkeyboard.h.

References Release.

◆ keyToAscii()

char QTest::keyToAscii ( Qt::Key key)

Convert a Qt Key to an ascii char value. If the Qt key is unknown a 0 is returned.

Note: this may happen more than you like since not all known Qt keys are converted already. So feel free to add all the keys you need.

Definition at line 203 of file qasciikey.cpp.

◆ messageFormatString()

static const char * QTest::messageFormatString ( bool noDescription,
bool noTag )
static

Definition at line 197 of file qxmltestlogger.cpp.

◆ messageHandler()

static void QTest::messageHandler ( QtMsgType type,
const QMessageLogContext & context,
const QString & message )
static

Definition at line 269 of file qtestlog.cpp.

References maxWarnings, and oldMessageHandler.

◆ mouseClick()

void QTest::mouseClick ( QWindow * window,
Qt::MouseButton button,
Qt::KeyboardModifiers stateKey = Qt::KeyboardModifiers(),
QPoint pos = QPoint(),
int delay = -1 )
inline

Definition at line 139 of file qtestmouse.h.

References MouseClick.

◆ mouseDClick()

void QTest::mouseDClick ( QWindow * window,
Qt::MouseButton button,
Qt::KeyboardModifiers stateKey = Qt::KeyboardModifiers(),
QPoint pos = QPoint(),
int delay = -1 )
inline

Definition at line 143 of file qtestmouse.h.

References MouseDClick.

◆ mouseEvent()

static void QTest::mouseEvent ( MouseAction action,
QWindow * window,
Qt::MouseButton button,
Qt::KeyboardModifiers stateKey,
QPoint pos,
int delay = -1 )
static

This function creates a QPA mouse event of type specified by action and calls QWindowSystemInterface::handleMouseEvent(), simulating the windowing system and bypassing the platform plugin. delay is the amount of time to be added to the simulated clock so that QInputEvent::timestamp() will be greater than that of the previous event. We expect all event-handling code to rely on the event timestamps, not the system clock; therefore tests can be run faster than real-time.

If delay is not given, a default minimum mouse delay is used, and unintended double-click events are prevented by incrementing the timestamp by 500ms after each mouse release. Therefore, to test double-clicks, it's necessary to give a realistic delay value (for example, 10ms).

Definition at line 65 of file qtestmouse.h.

References lastMouseTimestamp, mouseDoubleClickInterval, MouseMove, and MousePress.

◆ mouseMove()

void QTest::mouseMove ( QWindow * window,
QPoint pos = QPoint(),
int delay = -1 )
inline

Definition at line 147 of file qtestmouse.h.

◆ mousePress()

void QTest::mousePress ( QWindow * window,
Qt::MouseButton button,
Qt::KeyboardModifiers stateKey = Qt::KeyboardModifiers(),
QPoint pos = QPoint(),
int delay = -1 )
inline

Definition at line 131 of file qtestmouse.h.

References MousePress.

◆ mouseRelease()

void QTest::mouseRelease ( QWindow * window,
Qt::MouseButton button,
Qt::KeyboardModifiers stateKey = Qt::KeyboardModifiers(),
QPoint pos = QPoint(),
int delay = -1 )
inline

Definition at line 135 of file qtestmouse.h.

References MouseRelease.

◆ newRow()

QTestData & QTest::newRow ( const char * dataTag)

Appends a new row to the current test data.

The test output will identify the test run with this test data using the name dataTag.

Returns a QTestData reference that can be used to stream in data, one value for each column in the table.

Example:

{
QTest::newRow("just.hello") << QString("hello");
QTest::newRow("a.null.string") << QString();
}
Note
This function can only be called as part of a test's data function that is invoked by the test framework.

See \l {Chapter 2: Data Driven Testing}{Data Driven Testing} for a more extensive example.

See also
addRow(), addColumn(), QFETCH()

Definition at line 2587 of file qtestcase.cpp.

◆ printUnknownDataTagError()

static void QTest::printUnknownDataTagError ( QLatin1StringView name,
QLatin1StringView tag,
const QTestTable & lTable,
const QTestTable & gTable )
static

Definition at line 1257 of file qtestcase.cpp.

◆ ptIncidentType2String()

static const char * QTest::ptIncidentType2String ( QAbstractTestLogger::IncidentTypes type)
static

Definition at line 107 of file qplaintestlogger.cpp.

◆ ptMessageType2String()

static const char * QTest::ptMessageType2String ( QAbstractTestLogger::MessageTypes type)
static

Definition at line 137 of file qplaintestlogger.cpp.

◆ Q_GLOBAL_STATIC()

QTest::Q_GLOBAL_STATIC ( TestRegistry ,
g_registry  )

◆ qCaught() [1/2]

void QTest::qCaught ( const char * expected,
const char * file,
int line )

Contains the implementation of the catch(...) block of QVERIFY_THROWS_EXCEPTION.

The function inspects std::current_exception() by rethrowing it using std::rethrow_exception().

The function must be called from a catch handler.

If the exception inherits std::exception, its what() message is logged and this function returns normally. The caller of this function must then execute a {QTEST_FAIL_ACTION} to exit from the test function.

Otherwise, a message saying an unknown exception was caught is logged and this function rethrows the exception, skipping the {QTEST_FAIL_ACTION} that follows this function call in the caller.

Definition at line 2149 of file qtestcase.cpp.

◆ qCaught() [2/2]

void QTest::qCaught ( const char * expected,
const char * what,
const char * file,
int line )

Executes qFail() following a failed QVERIFY_THROWS_EXCEPTION or QVERIFY_THROWS_NO_EXCEPTION, passing a suitable message created from expected, what, along with file and line.

The expected parameter contains the type of the exception that is expected to be thrown, or \nullptr, if no exception was expected.

The what parameter contains the result of {std::exception::what()}, or nullptr, if a non-{std::exception}-derived exception was caught.

The file and line parameters hold expansions of the {FILE} and {LINE} macros, respectively.

Definition at line 2113 of file qtestcase.cpp.

◆ qCleanup()

void QTest::qCleanup ( )

Definition at line 1995 of file qtestcase.cpp.

References currentTestObject.

◆ qCompare() [1/38]

bool QTest::qCompare ( char * t1,
char * t2,
const char * actual,
const char * expected,
const char * file,
int line )
inline

Definition at line 728 of file qtestcase.h.

◆ qCompare() [2/38]

bool QTest::qCompare ( char * t1,
const char * t2,
const char * actual,
const char * expected,
const char * file,
int line )
inline

Definition at line 737 of file qtestcase.h.

◆ qCompare() [3/38]

bool QTest::qCompare ( const char * t1,
char * t2,
const char * actual,
const char * expected,
const char * file,
int line )
inline

Definition at line 742 of file qtestcase.h.

◆ qCompare() [4/38]

bool QTest::qCompare ( const char * t1,
const char * t2,
const char * actual,
const char * expected,
const char * file,
int line )
inline

Definition at line 723 of file qtestcase.h.

◆ qCompare() [5/38]

bool QTest::qCompare ( const QLatin1StringView & t1,
QStringView t2,
const char * actual,
const char * expected,
const char * file,
int line )
Since
5.14

Definition at line 3024 of file qtestcase.cpp.

◆ qCompare() [6/38]

bool QTest::qCompare ( const QString & t1,
const QString & t2,
const char * actual,
const char * expected,
const char * file,
int line )
inline
Since
5.14

Definition at line 576 of file qtestcase.h.

◆ qCompare() [7/38]

template<typename T>
bool QTest::qCompare ( const T * t1,
const T * t2,
const char * actual,
const char * expected,
const char * file,
int line )
inline

Definition at line 685 of file qtestcase.h.

◆ qCompare() [8/38]

template<typename T1, typename T2 = T1>
bool QTest::qCompare ( const T1 & t1,
const T2 & t2,
const char * actual,
const char * expected,
const char * file,
int line )
inline

Definition at line 654 of file qtestcase.h.

◆ qCompare() [9/38]

template<typename T1, typename T2>
bool QTest::qCompare ( const T1 * t1,
const T2 * t2,
const char * actual,
const char * expected,
const char * file,
int line )
inline

Definition at line 711 of file qtestcase.h.

◆ qCompare() [10/38]

bool QTest::qCompare ( double const & t1,
double const & t2,
const char * actual,
const char * expected,
const char * file,
int line )

Definition at line 2949 of file qtestcase.cpp.

◆ qCompare() [11/38]

bool QTest::qCompare ( double const & t1,
float const & t2,
const char * actual,
const char * expected,
const char * file,
int line )
inline

Definition at line 672 of file qtestcase.h.

◆ qCompare() [12/38]

bool QTest::qCompare ( float const & t1,
double const & t2,
const char * actual,
const char * expected,
const char * file,
int line )
inline

Definition at line 678 of file qtestcase.h.

◆ qCompare() [13/38]

bool QTest::qCompare ( float const & t1,
float const & t2,
const char * actual,
const char * expected,
const char * file,
int line )

Definition at line 2938 of file qtestcase.cpp.

◆ qCompare() [14/38]

bool QTest::qCompare ( int t1,
int t2,
const char * actual,
const char * expected,
const char * file,
int line )
Since
5.14

Definition at line 2961 of file qtestcase.cpp.

◆ qCompare() [15/38]

template<typename T>
bool QTest::qCompare ( QFlags< T > const & t1,
int const & t2,
const char * actual,
const char * expected,
const char * file,
int line )
inline

Definition at line 134 of file qtest.h.

◆ qCompare() [16/38]

template<typename T>
bool QTest::qCompare ( QFlags< T > const & t1,
T const & t2,
const char * actual,
const char * expected,
const char * file,
int line )
inline

Definition at line 126 of file qtest.h.

◆ qCompare() [17/38]

bool QTest::qCompare ( qfloat16 const & t1,
qfloat16 const & t2,
const char * actual,
const char * expected,
const char * file,
int line )

Definition at line 2925 of file qtestcase.cpp.

◆ qCompare() [18/38]

bool QTest::qCompare ( QIcon const & t1,
QIcon const & t2,
const char * actual,
const char * expected,
const char * file,
int line )
inline

Definition at line 119 of file qtest_gui.h.

◆ qCompare() [19/38]

bool QTest::qCompare ( QImage const & t1,
QImage const & t2,
const char * actual,
const char * expected,
const char * file,
int line )
inline

Definition at line 127 of file qtest_gui.h.

◆ qCompare() [20/38]

template<>
bool QTest::qCompare ( qint32 const & t1,
qint64 const & t2,
const char * actual,
const char * expected,
const char * file,
int line )
inline

Definition at line 163 of file qtest.h.

◆ qCompare() [21/38]

template<>
bool QTest::qCompare ( qint64 const & t1,
qint32 const & t2,
const char * actual,
const char * expected,
const char * file,
int line )
inline

Definition at line 142 of file qtest.h.

◆ qCompare() [22/38]

template<>
bool QTest::qCompare ( qint64 const & t1,
quint32 const & t2,
const char * actual,
const char * expected,
const char * file,
int line )
inline

Definition at line 149 of file qtest.h.

◆ qCompare() [23/38]

template<>
bool QTest::qCompare ( QLatin1StringView const & t1,
QString const & t2,
const char * actual,
const char * expected,
const char * file,
int line )
inline
Since
5.14

Definition at line 38 of file qtest.h.

◆ qCompare() [24/38]

template<typename T, int N>
bool QTest::qCompare ( QList< T > const & t1,
const T(&) t2[N],
const char * actual,
const char * expected,
const char * file,
int line )

Definition at line 117 of file qtest.h.

◆ qCompare() [25/38]

template<typename T>
bool QTest::qCompare ( QList< T > const & t1,
QList< T > const & t2,
const char * actual,
const char * expected,
const char * file,
int line )
inline

Definition at line 99 of file qtest.h.

◆ qCompare() [26/38]

template<typename T, int N>
bool QTest::qCompare ( QList< T > const & t1,
std::initializer_list< T > t2,
const char * actual,
const char * expected,
const char * file,
int line )

Definition at line 107 of file qtest.h.

◆ qCompare() [27/38]

bool QTest::qCompare ( QPixmap const & t1,
QPixmap const & t2,
const char * actual,
const char * expected,
const char * file,
int line )
inline

Definition at line 169 of file qtest_gui.h.

◆ qCompare() [28/38]

template<>
bool QTest::qCompare ( QString const & t1,
QLatin1StringView const & t2,
const char * actual,
const char * expected,
const char * file,
int line )
inline
Since
5.14

Definition at line 32 of file qtest.h.

◆ qCompare() [29/38]

bool QTest::qCompare ( QStringView t1,
const QLatin1StringView & t2,
const char * actual,
const char * expected,
const char * file,
int line )
Since
5.14

Definition at line 3012 of file qtestcase.cpp.

◆ qCompare() [30/38]

bool QTest::qCompare ( QStringView t1,
QStringView t2,
const char * actual,
const char * expected,
const char * file,
int line )
Since
5.14

Definition at line 3000 of file qtestcase.cpp.

◆ qCompare() [31/38]

template<>
bool QTest::qCompare ( quint32 const & t1,
qint64 const & t2,
const char * actual,
const char * expected,
const char * file,
int line )
inline

Definition at line 170 of file qtest.h.

◆ qCompare() [32/38]

template<>
bool QTest::qCompare ( quint32 const & t1,
quint64 const & t2,
const char * actual,
const char * expected,
const char * file,
int line )
inline

Definition at line 177 of file qtest.h.

◆ qCompare() [33/38]

template<>
bool QTest::qCompare ( quint64 const & t1,
quint32 const & t2,
const char * actual,
const char * expected,
const char * file,
int line )
inline

Definition at line 156 of file qtest.h.

◆ qCompare() [34/38]

template<typename T>
bool QTest::qCompare ( std::nullptr_t ,
T * t,
const char * actual,
const char * expected,
const char * file,
int line )
inline

Definition at line 704 of file qtestcase.h.

◆ qCompare() [35/38]

template<typename T>
bool QTest::qCompare ( T * t,
std::nullptr_t ,
const char * actual,
const char * expected,
const char * file,
int line )
inline

Definition at line 698 of file qtestcase.h.

◆ qCompare() [36/38]

template<typename T>
bool QTest::qCompare ( T * t1,
T * t2,
const char * actual,
const char * expected,
const char * file,
int line )
inline

Definition at line 691 of file qtestcase.h.

◆ qCompare() [37/38]

template<typename T1, typename T2>
bool QTest::qCompare ( T1 * t1,
T2 * t2,
const char * actual,
const char * expected,
const char * file,
int line )
inline

Definition at line 717 of file qtestcase.h.

◆ qCompare() [38/38]

bool QTest::qCompare ( unsigned t1,
unsigned t2,
const char * actual,
const char * expected,
const char * file,
int line )
Since
5.14

Definition at line 2988 of file qtestcase.cpp.

◆ qCompare3Way()

template<typename OrderingType, typename LHS, typename RHS = LHS>
void QTest::qCompare3Way ( LHS && lhs,
RHS && rhs,
OrderingType order,
const char * lhsExpression,
const char * rhsExpression,
const char * resultExpression,
const char * file,
int line )
delete

◆ qCompareOp()

template<ComparisonOperation op, typename T1, typename T2 = T1>
bool QTest::qCompareOp ( T1 && lhs,
T2 && rhs,
const char * lhsExpr,
const char * rhsExpr,
const char * file,
int line )
inline

Definition at line 771 of file qtestcase.h.

◆ qData()

void * QTest::qData ( const char * tagName,
int typeId )

Definition at line 2529 of file qtestcase.cpp.

◆ qElementData()

void * QTest::qElementData ( const char * tagName,
int metaTypeId )

Definition at line 2543 of file qtestcase.cpp.

◆ qExec() [1/2]

int QTest::qExec ( QObject * testObject,
const QStringList & arguments )

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Since
4.4

Behaves identically to qExec(QObject *, int, char**) but takes a QStringList of arguments instead of a char** list.

Definition at line 2047 of file qtestcase.cpp.

◆ qExec() [2/2]

int QTest::qExec ( QObject * testObject,
int argc = 0,
char ** argv = nullptr )

Executes tests declared in testObject.

In addition, the private slots {initTestCase()}, {cleanupTestCase()}, {init()} and {cleanup()} are executed if they exist. See \l{Creating a Test} for more details.

Optionally, the command line arguments argc and argv can be provided. For a list of recognized arguments, read \l {Qt Test Command Line Arguments}.

The following example will run all tests in MyTestObject:

MyTestObject test1;
QTest::qExec(&test1);

This function returns 0 if no tests failed, or a value other than 0 if one or more tests failed or in case of unhandled exceptions. (Skipped tests do not influence the return value.)

For stand-alone test applications, the convenience macro \l QTEST_MAIN() can be used to declare a main() function that parses the command line arguments and executes the tests, avoiding the need to call this function explicitly.

The return value from this function is also the exit code of the test application when the \l QTEST_MAIN() macro is used.

For stand-alone test applications, this function should not be called more than once, as command-line options for logging test output to files and executing individual test functions will not behave correctly.

Note
This function is not reentrant, only one test can run at a time. A test that was executed with qExec() can't run another test via qExec() and threads are not allowed to call qExec() simultaneously.

If you have programmatically created the arguments, as opposed to getting them from the arguments in main(), it is likely of interest to use QTest::qExec(QObject *, const QStringList &) since it is Unicode safe.

See also
QTEST_MAIN(), QTEST_GUILESS_MAIN(), QTEST_APPLESS_MAIN()

Definition at line 1816 of file qtestcase.cpp.

◆ qExpectFail()

bool QTest::qExpectFail ( const char * dataIndex,
const char * comment,
QTest::TestFailMode mode,
const char * file,
int line )

Definition at line 2091 of file qtestcase.cpp.

◆ qFail()

void QTest::qFail ( const char * message,
const char * file,
int line )

Definition at line 2066 of file qtestcase.cpp.

◆ qFindTestData() [1/2]

QString QTest::qFindTestData ( const char * base,
const char * file = nullptr,
int line = 0,
const char * builddir = nullptr,
const char * sourcedir = nullptr )

Definition at line 2521 of file qtestcase.cpp.

◆ qFindTestData() [2/2]

QString QTest::qFindTestData ( const QString & base,
const char * file = nullptr,
int line = 0,
const char * builddir = nullptr,
const char * sourcedir = nullptr )

Definition at line 2384 of file qtestcase.cpp.

◆ qGlobalData()

void * QTest::qGlobalData ( const char * tagName,
int typeId )

Definition at line 2536 of file qtestcase.cpp.

◆ qInit()

void QTest::qInit ( QObject * testObject,
int argc = 0,
char ** argv = nullptr )

Definition at line 1838 of file qtestcase.cpp.

References currentTestObject, initEnvironment(), and qtest_qParseArgs().

+ Here is the call graph for this function:

◆ qMedian()

static QList< QBenchmarkResult > QTest::qMedian ( const QList< QList< QBenchmarkResult > > & container)
static

Definition at line 987 of file qtestcase.cpp.

◆ qPrintDataTags()

static void QTest::qPrintDataTags ( FILE * stream)
static

Definition at line 523 of file qtestcase.cpp.

References invokeTestMethodIfExists().

Referenced by qtest_qParseArgs().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ qPrintMessage()

static void QTest::qPrintMessage ( const QByteArray & ba)
inlinestatic

Definition at line 21 of file qsignaldumper.cpp.

◆ qPrintTestSlots()

static bool QTest::qPrintTestSlots ( FILE * stream,
const char * filter = nullptr,
const char * preamble = "" )
static

Definition at line 502 of file qtestcase.cpp.

References currentTestObject.

Referenced by qtest_qParseArgs().

+ Here is the caller graph for this function:

◆ qRun()

int QTest::qRun ( )

Definition at line 1886 of file qtestcase.cpp.

References currentTestObject, QTest::Internal::noCrashHandler, and repetitions.

◆ qSignalDumperCallback()

static void QTest::qSignalDumperCallback ( QObject * caller,
int signal_index,
void ** argv )
static

Definition at line 42 of file qsignaldumper.cpp.

References IndentSpacesCount.

◆ qSignalDumperCallbackEndSignal()

static void QTest::qSignalDumperCallbackEndSignal ( QObject * caller,
int  )
static

Definition at line 132 of file qsignaldumper.cpp.

◆ qSignalDumperCallbackSlot()

static void QTest::qSignalDumperCallbackSlot ( QObject * caller,
int method_index,
void ** argv )
static

Definition at line 101 of file qsignaldumper.cpp.

References ignoreLevel, and IndentSpacesCount.

◆ qSkip()

void QTest::qSkip ( const char * message,
const char * file,
int line )

Definition at line 2082 of file qtestcase.cpp.

◆ qSleep() [1/2]

QT_BEGIN_NAMESPACE void QTest::qSleep ( int ms)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Sleeps for ms milliseconds, blocking execution of the test.

Equivalent to calling:

QTest::qSleep(std::chrono::milliseconds{ms});
Q_CORE_EXPORT void qSleep(int ms)
This is an overloaded member function, provided for convenience. It differs from the above function o...

Definition at line 22 of file qtestsupport_core.cpp.

References qSleep().

Referenced by qSleep().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ qSleep() [2/2]

void QTest::qSleep ( std::chrono::milliseconds msecs)
Since
6.7

Sleeps for msecs, blocking execution of the test.

This method will not do any event processing and will leave your test unresponsive. Network communication might time out while sleeping. Use \l {QTest::qWait()} to do non-blocking sleeping.

msecs must be greater than 0ms.

Note
Starting from Qt 6.7, this function is implemented using {std::this_thread::sleep_for}, so the accuracy of time spent depends on the Standard Library implementation. Before Qt 6.7 this function called either nanosleep() on Unix or Sleep() on Windows, so the accuracy of time spent in this function depended on the operating system.

Example:

using namespace std::chrono_literals;
See also
{QTest::qWait()}

Definition at line 49 of file qtestsupport_core.cpp.

◆ qt_asprintf()

int QTest::qt_asprintf ( QTestCharBuffer * str,
const char * format,
... )

Definition at line 399 of file qabstracttestlogger.cpp.

Referenced by QTestPrivate::generateTestIdentifier().

+ Here is the caller graph for this function:

◆ qTest()

template<class T>
bool QTest::qTest ( const T & actual,
const char * elementName,
const char * actualStr,
const char * expected,
const char * file,
int line )
inline

Definition at line 749 of file qtestcase.h.

◆ qtest_qParseArgs() [1/2]

void QTest::qtest_qParseArgs ( int argc,
char * argv[],
bool qml )

Definition at line 983 of file qtestcase.cpp.

Referenced by qInit().

+ Here is the caller graph for this function:

◆ qtest_qParseArgs() [2/2]

Q_TESTLIB_EXPORT void QTest::qtest_qParseArgs ( int argc,
const char *const argv[],
bool qml )

Definition at line 600 of file qtestcase.cpp.

References eventDelay, keyDelay, mouseDelay, QTest::Internal::noCrashHandler, printAvailableFunctions, qPrintDataTags(), qPrintTestSlots(), qToInt(), repetitions, and skipBlacklisted.

+ Here is the call graph for this function:

◆ qToInt()

static int QTest::qToInt ( const char * str)
static

Definition at line 589 of file qtestcase.cpp.

Referenced by qtest_qParseArgs().

+ Here is the caller graph for this function:

◆ qVerify()

bool QTest::qVerify ( bool statement,
const char * statementStr,
const char * description,
const char * file,
int line )

Definition at line 2073 of file qtestcase.cpp.

◆ qWait() [1/2]

Q_CORE_EXPORT void QTest::qWait ( int msecs)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Waits for msecs.

Equivalent to calling:

QTest::qWait(std::chrono::milliseconds{msecs});
Q_CORE_EXPORT void qWait(int ms)
This is an overloaded member function, provided for convenience. It differs from the above function o...

Definition at line 92 of file qtestsupport_core.cpp.

◆ qWait() [2/2]

Q_CORE_EXPORT void QTest::qWait ( std::chrono::milliseconds msecs)
Since
6.7

Waits for msecs. While waiting, events will be processed and your test will stay responsive to user interface events or network communication.

Example:

using namespace std::chrono_literals;
int i = 0;
while (myNetworkServerNotResponding() && i++ < 50)
QTest::qWait(250ms);

The code above will wait until the network server is responding for a maximum of about 12.5 seconds.

See also
QTest::qSleep(), QSignalSpy::wait()

Definition at line 112 of file qtestsupport_core.cpp.

◆ qWaitFor() [1/2]

template<typename Functor>
bool QTest::qWaitFor ( Functor predicate,
int timeout )
nodiscard
Since
5.10 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Waits for timeout milliseconds or until the predicate returns true.

This is equivalent to calling:

\inmodule QtCore
const auto predicate
bool qWaitFor(Functor predicate, QDeadlineTimer deadline=QDeadlineTimer(std::chrono::seconds{5}))
GLbitfield GLuint64 timeout
[4]

Definition at line 55 of file qtestsupport_core.h.

◆ qWaitFor() [2/2]

template<typename Functor>
bool QTest::qWaitFor ( Functor predicate,
QDeadlineTimer deadline = QDeadlineTimer(std::chrono::seconds{5}) )
nodiscard
Since
6.7

Waits until deadline has expired, or until predicate returns true, whichever happens first.

Returns true if predicate returned true at any point, otherwise returns false.

Example:

obj.startup();
using namespace std::chrono_literals;
const bool result = QTest::qWaitFor([&obj]() { return obj.isReady(); },

The code above will wait for the object to become ready, for a maximum of three seconds.

Definition at line 21 of file qtestsupport_core.h.

◆ qWaitForWindowActive() [1/2]

Q_WIDGETS_EXPORT bool QTest::qWaitForWindowActive ( QWidget * widget,
int timeout = 5000 )
nodiscard
Since
5.0

Returns true if widget is active within timeout milliseconds. Otherwise returns false.

The method is useful in tests that call QWidget::show() and rely on the widget actually being active (i.e. being visible and having focus) before proceeding.

Note
The method will time out and return false if another window prevents widget from becoming active.
Since focus is an exclusive property, widget may loose its focus to another window at any time - even after the method has returned true.
See also
qWaitForWindowExposed(), QWidget::isActiveWindow()

Definition at line 48 of file qtestsupport_widgets.cpp.

◆ qWaitForWindowActive() [2/2]

QT_BEGIN_NAMESPACE Q_GUI_EXPORT bool QTest::qWaitForWindowActive ( QWindow * window,
int timeout = 5000 )
nodiscard
Since
5.0

Returns true, if window is active within timeout milliseconds. Otherwise returns false.

The method is useful in tests that call QWindow::show() and rely on the window actually being active (i.e. being visible and having focus) before proceeding.

Note
The method will time out and return false if another window prevents window from becoming active.
Since focus is an exclusive property, window may loose its focus to another window at any time - even after the method has returned true.
See also
qWaitForWindowExposed(), qWaitForWindowFocused(), QWindow::isActive()

Definition at line 41 of file qtestsupport_gui.cpp.

◆ qWaitForWindowExposed() [1/2]

Q_WIDGETS_EXPORT bool QTest::qWaitForWindowExposed ( QWidget * widget,
int timeout = 5000 )
nodiscard
Since
5.0

Returns true if widget is exposed within timeout milliseconds. Otherwise returns false.

The method is useful in tests that call QWidget::show() and rely on the widget actually being being visible before proceeding.

Note
A window mapped to screen may still not be considered exposed, if the window client area is not visible, e.g. because it is completely covered by other windows. In such cases, the method will time out and return false.
See also
qWaitForWindowActive(), QWidget::isVisible(), QWindow::isExposed()

Definition at line 103 of file qtestsupport_widgets.cpp.

◆ qWaitForWindowExposed() [2/2]

Q_GUI_EXPORT bool QTest::qWaitForWindowExposed ( QWindow * window,
int timeout = 5000 )
nodiscard
Since
5.0

Returns true, if window is exposed within timeout milliseconds. Otherwise returns false.

The method is useful in tests that call QWindow::show() and rely on the window actually being being visible before proceeding.

Note
A window mapped to screen may still not be considered exposed, if the window client area is not visible, e.g. because it is completely covered by other windows. In such cases, the method will time out and return false.
See also
qWaitForWindowActive(), QWindow::isExposed()

Definition at line 89 of file qtestsupport_gui.cpp.

◆ qWaitForWindowFocused() [1/2]

Q_WIDGETS_EXPORT bool QTest::qWaitForWindowFocused ( QWidget * widget,
QDeadlineTimer timeout = std::chrono::seconds{5} )
nodiscard
Since
6.7

Returns true, if widget is the focus window within timeout. Otherwise returns false.

The method is useful in tests that call QWidget::show() and rely on the widget having focus (for receiving keyboard events e.g.) before proceeding.

Note
The method will time out and return false if another window prevents widget from becoming focused.
Since focus is an exclusive property, widget may loose its focus to another window at any time - even after the method has returned true.
See also
qWaitForWindowExposed(), qWaitForWindowActive(), QGuiApplication::focusWindow()

Definition at line 80 of file qtestsupport_widgets.cpp.

◆ qWaitForWindowFocused() [2/2]

Q_GUI_EXPORT bool QTest::qWaitForWindowFocused ( QWindow * window,
QDeadlineTimer timeout = std::chrono::seconds{5} )
nodiscard
Since
6.7

Returns true, if window is the focus window within timeout. Otherwise returns false.

The method is useful in tests that call QWindow::show() and rely on the window having focus (for receiving keyboard events e.g.) before proceeding.

Note
The method will time out and return false if another window prevents window from becoming focused.
Since focus is an exclusive property, window may loose its focus to another window at any time - even after the method has returned true.
See also
qWaitForWindowExposed(), qWaitForWindowActive(), QGuiApplication::focusWindow()

Definition at line 70 of file qtestsupport_gui.cpp.

◆ reportResult()

Q_TESTLIB_EXPORT bool QTest::reportResult ( bool success,
const void * lhs,
const void * rhs,
const char *(* lhsFormatter )(const void *),
const char *(* rhsFormatter )(const void *),
const char * lhsExpr,
const char * rhsExpr,
ComparisonOperation op,
const char * file,
int line )

Definition at line 1754 of file qtestcase.cpp.

◆ resetFailed()

static void QTest::resetFailed ( )
static

Definition at line 50 of file qtestresult.cpp.

References setFailed().

+ Here is the call graph for this function:

◆ runningTest()

bool QTest::runningTest ( )
Since
6.4 Returns true during the run of the test-function and its set-up.

Used by the {QTRY_*} macros and \l QTestEventLoop to check whether to return when QTest::currentTestResolved() is true.

Definition at line 2731 of file qtestcase.cpp.

References inTestFunction.

◆ runWithWatchdog()

template<typename Functor>
void QTest::runWithWatchdog ( std::optional< WatchDog > & watchDog,
Functor && f )

Definition at line 1246 of file qtestcase.cpp.

◆ sendKeyEvent() [1/2]

static void QTest::sendKeyEvent ( KeyAction action,
QWindow * window,
Qt::Key code,
char ascii,
Qt::KeyboardModifiers modifier,
int delay = -1 )
static

Definition at line 109 of file qtestkeyboard.h.

◆ sendKeyEvent() [2/2]

static void QTest::sendKeyEvent ( KeyAction action,
QWindow * window,
Qt::Key code,
QString text,
Qt::KeyboardModifiers modifier,
int delay = -1 )
static

Definition at line 48 of file qtestkeyboard.h.

References Click, Press, Release, and Shortcut.

◆ setBenchmarkResult()

void QTest::setBenchmarkResult ( qreal result,
QTest::QBenchmarkMetric metric )

Sets the benchmark result for this test function to result.

Use this function if you want to report benchmark results without using the QBENCHMARK macro. Use metric to specify how Qt Test should interpret the results.

The context for the result will be the test function name and any data tag from the _data function. This function can only be called once in each test function, subsequent calls will replace the earlier reported results.

Note that the -iterations command line argument has no effect on test functions without the QBENCHMARK macro.

Since
4.7

Definition at line 238 of file qbenchmark.cpp.

◆ setFailed()

static void QTest::setFailed ( bool failed)
static

Definition at line 33 of file qtestresult.cpp.

References QTest::Internal::failed.

Referenced by checkStatement(), and resetFailed().

+ Here is the caller graph for this function:

◆ setIterationCount()

void QTest::setIterationCount ( int count)

Definition at line 199 of file qbenchmark.cpp.

◆ setIterationCountHint()

void QTest::setIterationCountHint ( int count)

Definition at line 192 of file qbenchmark.cpp.

◆ setMainSourcePath()

void QTest::setMainSourcePath ( const char * file,
const char * builddir = nullptr )

Definition at line 2745 of file qtestcase.cpp.

References mainSourcePath.

◆ setThrowOnFail()

Q_TESTLIB_EXPORT void QTest::setThrowOnFail ( bool enable)
noexcept
Since
6.8

Enables (enable = true) or disables (\ enable = false) throwing on QCOMPARE()/QVERIFY() failures (as opposed to just returning from the immediately-surrounding function context).

The feature is reference-counted: If you call this function {N} times with {true}, you need to call it {N} times with {false} to get back to where you started.

This call has no effect when the \l{QTEST_THROW_ON_FAIL} C++ macro is defined.

Note
You must compile your tests with exceptions enabled to use this feature.
See also
setThrowOnSkip(), ThrowOnFailEnabler, ThrowOnFailDisabler, QTEST_THROW_ON_FAIL

Definition at line 316 of file qtestcase.cpp.

◆ setThrowOnSkip()

Q_TESTLIB_EXPORT void QTest::setThrowOnSkip ( bool enable)
noexcept
Since
6.8

Enables (enable = true) or disables (\ enable = false) throwing on QSKIP() (as opposed to just returning from the immediately-surrounding function context).

The feature is reference-counted: If you call this function {N} times with {true}, you need to call it {N} times with {false} to get back to where you started.

This call has no effect when the \l{QTEST_THROW_ON_SKIP} C++ macro is defined.

Note
You must compile your tests with exceptions enabled to use this feature.
See also
setThrowOnFail(), ThrowOnSkipEnabler, ThrowOnSkipDisabler, QTEST_THROW_ON_SKIP

Definition at line 340 of file qtestcase.cpp.

◆ simulateEvent()

static void QTest::simulateEvent ( QWindow * window,
bool press,
int code,
Qt::KeyboardModifiers modifier,
QString text,
bool repeat,
int delay = -1 )
static

Definition at line 39 of file qtestkeyboard.h.

◆ tcIncidentType2String()

static const char * QTest::tcIncidentType2String ( QAbstractTestLogger::IncidentTypes type)
static

Definition at line 24 of file qteamcitylogger.cpp.

◆ tcMessageType2String()

static const char * QTest::tcMessageType2String ( QAbstractTestLogger::MessageTypes type)
static

Definition at line 49 of file qteamcitylogger.cpp.

◆ testObject()

QObject * QTest::testObject ( )

Definition at line 2738 of file qtestcase.cpp.

◆ toHexRepresentation()

Q_TESTLIB_EXPORT char * QTest::toHexRepresentation ( const char * ba,
qsizetype length )

Returns a pointer to a string that is the string ba represented as a space-separated sequence of hex characters.

If the input is considered too long, it is truncated. A trucation is indicated in the returned string as an ellipsis at the end. The caller has ownership of the returned pointer and must ensure it is later passed to operator delete[].

length is the length of the string ba.

Definition at line 1450 of file qtestcase.cpp.

◆ toPrettyCString()

Q_TESTLIB_EXPORT char * QTest::toPrettyCString ( const char * p,
qsizetype length )

Returns the same QByteArray but with only the ASCII characters still shown; everything else is replaced with {\xHH }.

Definition at line 1509 of file qtestcase.cpp.

◆ toPrettyUnicode()

Q_TESTLIB_EXPORT char * QTest::toPrettyUnicode ( QStringView string)

Returns the same QString but with only the ASCII characters still shown; everything else is replaced with {\uXXXX }.

Similar to QDebug::putString().

Definition at line 1643 of file qtestcase.cpp.

◆ toString() [1/40]

char * QTest::toString ( const char * str)

Definition at line 3153 of file qtestcase.cpp.

◆ toString() [2/40]

template<>
char * QTest::toString ( const MyPoint & point)

Definition at line 24 of file src_qtestlib_qtestcase_snippet.cpp.

◆ toString() [3/40]

template<>
char * QTest::toString ( const MyPoint & point)

Definition at line 24 of file src_qtestlib_qtestcase_snippet.cpp.

◆ toString() [4/40]

template<>
char * QTest::toString ( const QBitArray & ba)
inline

Definition at line 159 of file qtesttostring.h.

◆ toString() [5/40]

template<>
char * QTest::toString ( const QByteArray & ba)
inline

Definition at line 154 of file qtesttostring.h.

◆ toString() [6/40]

template<>
char * QTest::toString ( const QCborArray & a)
inline

Definition at line 447 of file qtesttostring.h.

◆ toString() [7/40]

template<>
char * QTest::toString ( const QCborError & c)
inline

Definition at line 192 of file qtesttostring.h.

◆ toString() [8/40]

template<>
char * QTest::toString ( const QCborMap & m)
inline

Definition at line 452 of file qtesttostring.h.

◆ toString() [9/40]

template<>
char * QTest::toString ( const QCborValue & v)
inline

Definition at line 437 of file qtesttostring.h.

◆ toString() [10/40]

template<>
char * QTest::toString ( const QCborValueRef & v)
inline

Definition at line 442 of file qtesttostring.h.

◆ toString() [11/40]

template<>
char * QTest::toString ( const QChar & c)
inline

Definition at line 198 of file qtesttostring.h.

◆ toString() [12/40]

template<>
char * QTest::toString ( const QColor & color)
inline

Definition at line 48 of file qtest_gui.h.

◆ toString() [13/40]

Q_POSITIONING_EXPORT char * QTest::toString ( const QGeoAreaMonitorInfo & info)

Definition at line 402 of file qgeoareamonitorinfo.cpp.

◆ toString() [14/40]

char * QTest::toString ( const QGeoPositionInfo & info)

Definition at line 413 of file qgeopositioninfo.cpp.

◆ toString() [15/40]

char * QTest::toString ( const QGeoSatelliteInfo & info)

Definition at line 395 of file qgeosatelliteinfo.cpp.

◆ toString() [16/40]

template<>
char * QTest::toString ( const QLatin1StringView & str)
inline

Definition at line 149 of file qtesttostring.h.

◆ toString() [17/40]

char * QTest::toString ( const QObject * o)

Definition at line 3185 of file qtestcase.cpp.

◆ toString() [18/40]

template<>
char * QTest::toString ( const QPartialOrdering & o)
inline

Definition at line 300 of file qtesttostring.h.

◆ toString() [19/40]

template<>
char * QTest::toString ( const QPoint & p)
inline

Definition at line 220 of file qtesttostring.h.

◆ toString() [20/40]

template<>
char * QTest::toString ( const QPointF & p)
inline

Definition at line 242 of file qtesttostring.h.

◆ toString() [21/40]

template<>
char * QTest::toString ( const QRect & s)
inline

Definition at line 234 of file qtesttostring.h.

◆ toString() [22/40]

template<>
char * QTest::toString ( const QRectF & s)
inline

Definition at line 256 of file qtesttostring.h.

◆ toString() [23/40]

template<>
char * QTest::toString ( const QRegion & region)
inline

Definition at line 53 of file qtest_gui.h.

◆ toString() [24/40]

template<>
char * QTest::toString ( const QSize & s)
inline

Definition at line 227 of file qtesttostring.h.

◆ toString() [25/40]

template<>
char * QTest::toString ( const QSizeF & s)
inline

Definition at line 249 of file qtesttostring.h.

◆ toString() [26/40]

template<>
char * QTest::toString ( const QString & str)
inline

Definition at line 144 of file qtesttostring.h.

◆ toString() [27/40]

template<>
char * QTest::toString ( const QStringView & str)
inline

Definition at line 139 of file qtesttostring.h.

◆ toString() [28/40]

template<>
char * QTest::toString ( const QUrl & uri)
inline

Definition at line 264 of file qtesttostring.h.

◆ toString() [29/40]

template<>
char * QTest::toString ( const QUuid & uuid)
inline

Definition at line 271 of file qtesttostring.h.

◆ toString() [30/40]

template<>
char * QTest::toString ( const QVariant & v)
inline

Definition at line 276 of file qtesttostring.h.

◆ toString() [31/40]

template<>
char * QTest::toString ( const QVector2D & v)
inline

Definition at line 87 of file qtest_gui.h.

◆ toString() [32/40]

template<>
char * QTest::toString ( const QVector3D & v)
inline

Definition at line 95 of file qtest_gui.h.

◆ toString() [33/40]

template<>
char * QTest::toString ( const QVector4D & v)
inline

Definition at line 103 of file qtest_gui.h.

◆ toString() [34/40]

template<typename T1, typename T2>
char * QTest::toString ( const std::pair< T1, T2 > & pair)
inline

Definition at line 471 of file qtesttostring.h.

◆ toString() [35/40]

template<class... Types>
char * QTest::toString ( const std::tuple< Types... > & tuple)
inline

Definition at line 491 of file qtesttostring.h.

◆ toString() [36/40]

template<typename T>
char * QTest::toString ( const T & t)
inline

Definition at line 98 of file qtesttostring.h.

◆ toString() [37/40]

char * QTest::toString ( const volatile QObject * vo)

Definition at line 3175 of file qtestcase.cpp.

◆ toString() [38/40]

char * QTest::toString ( const volatile void * p)

Definition at line 3166 of file qtestcase.cpp.

◆ toString() [39/40]

template<typename Rep, typename Period>
char * QTest::toString ( std::chrono::duration< Rep, Period > duration)
inline

Definition at line 457 of file qtesttostring.h.

◆ toString() [40/40]

char * QTest::toString ( std::nullptr_t )
inline

Definition at line 496 of file qtesttostring.h.

◆ toString< QHostAddress >()

template<>
char * QTest::toString< QHostAddress > ( const QHostAddress & addr)
inline

Definition at line 32 of file qtest_network.h.

◆ touchEvent()

QTouchEventSequence QTest::touchEvent ( QWindow * window,
QPointingDevice * device,
bool autoCommit = true )
inline

Definition at line 42 of file qtesttouch.h.

◆ tupleToString()

template<typename Tuple, std::size_t... I>
char * QTest::tupleToString ( const Tuple & tuple,
std::index_sequence< I... >  )
inline

Definition at line 479 of file qtesttostring.h.

◆ wheelEvent()

static void QTest::wheelEvent ( QWindow * window,
QPointF pos,
QPoint angleDelta,
QPoint pixelDelta = QPoint(0, 0),
Qt::KeyboardModifiers stateKey = Qt::NoModifier,
Qt::ScrollPhase phase = Qt::NoScrollPhase )
static

This function creates a mouse wheel event and calls QWindowSystemInterface::handleWheelEvent(). window is the window that should be receiving the event and pos provides the location of the event in the window's local coordinates. angleDelta contains the wheel rotation angle, while pixelDelta contains the scrolling distance in pixels on screen. The keyboard states at the time of the event are specified by stateKey. The scrolling phase of the event is specified by phase.

Definition at line 40 of file qtestwheel.h.

◆ writePrettyUnicodeChar()

static char * QTest::writePrettyUnicodeChar ( char16_t ch,
char *const buffer )
static

Definition at line 1601 of file qtestcase.cpp.

◆ xmlIncidentType2String()

static const char * QTest::xmlIncidentType2String ( QAbstractTestLogger::IncidentTypes type)
static

Definition at line 41 of file qxmltestlogger.cpp.

◆ xmlMessageType2String()

static const char * QTest::xmlMessageType2String ( QAbstractTestLogger::MessageTypes type)
static

Definition at line 20 of file qxmltestlogger.cpp.

Variable Documentation

◆ blacklistCurrentTest

static bool QTest::blacklistCurrentTest = false
static

Definition at line 65 of file qtestresult.cpp.

◆ blacklists

int QTest::blacklists = 0

Definition at line 143 of file qtestlog.cpp.

◆ currentGlobalTestData

static QTestData * QTest::currentGlobalTestData = nullptr
static

Definition at line 61 of file qtestresult.cpp.

◆ currentTestData

static QTestData * QTest::currentTestData = nullptr
static

Definition at line 60 of file qtestresult.cpp.

◆ currentTestFunc

static const char * QTest::currentTestFunc = nullptr
static

Definition at line 62 of file qtestresult.cpp.

◆ currentTestObject

static QObject * QTest::currentTestObject = nullptr
static

Definition at line 356 of file qtestcase.cpp.

Referenced by qCleanup(), qInit(), qPrintTestSlots(), and qRun().

◆ currentTestObjectName

static const char * QTest::currentTestObjectName = nullptr
static

Definition at line 63 of file qtestresult.cpp.

◆ []

enum { ... } QTest::currentTestState

◆ entries

static const QBenchmarkMetricKey QTest::entries
static

Definition at line 17 of file qbenchmarkmetric.cpp.

Referenced by benchmarkMetricName(), and benchmarkMetricUnit().

◆ eventDelay

static int QTest::eventDelay = -1
static

Definition at line 418 of file qtestcase.cpp.

Referenced by defaultEventDelay(), and qtest_qParseArgs().

◆ expectFailComment

static const char * QTest::expectFailComment = nullptr
static

Definition at line 67 of file qtestresult.cpp.

Referenced by clearExpectFail().

◆ expectFailMode

static int QTest::expectFailMode = 0
static

Definition at line 68 of file qtestresult.cpp.

Referenced by checkStatement(), clearExpectFail(), compareHelper(), and compareHelper().

◆ failOnWarningList

static std::vector< QVariant > QTest::failOnWarningList
static

Definition at line 207 of file qtestlog.cpp.

◆ fails

int QTest::fails = 0

Definition at line 140 of file qtestlog.cpp.

◆ g_throwOnFail

static Q_CONSTINIT QBasicAtomicInt QTest::g_throwOnFail = Q_BASIC_ATOMIC_INITIALIZER(0)
static

Definition at line 192 of file qtestcase.cpp.

◆ g_throwOnSkip

static Q_CONSTINIT QBasicAtomicInt QTest::g_throwOnSkip = Q_BASIC_ATOMIC_INITIALIZER(0)
static

Definition at line 193 of file qtestcase.cpp.

◆ ignoreClassesMutex

static Q_CONSTINIT QBasicMutex QTest::ignoreClassesMutex
static

Definition at line 27 of file qsignaldumper.cpp.

◆ ignoreLevel

Q_CONSTINIT thread_local int QTest::ignoreLevel = 0

Definition at line 29 of file qsignaldumper.cpp.

Referenced by qSignalDumperCallbackSlot().

◆ ignoreResultList

static IgnoreResultList * QTest::ignoreResultList = nullptr
static

Definition at line 204 of file qtestlog.cpp.

Referenced by handleIgnoredMessage().

◆ iLevel

Q_CONSTINIT thread_local int QTest::iLevel = 0

Definition at line 28 of file qsignaldumper.cpp.

◆ installedTestCoverage

static bool QTest::installedTestCoverage = true
static

Definition at line 213 of file qtestlog.cpp.

◆ inTestFunction

static bool QTest::inTestFunction = false
static

Definition at line 358 of file qtestcase.cpp.

Referenced by runningTest().

◆ keyDelay

static int QTest::keyDelay = -1
static

Definition at line 416 of file qtestcase.cpp.

Referenced by qtest_qParseArgs().

◆ lastMouseTimestamp

Q_TESTLIB_EXPORT int QTest::lastMouseTimestamp = 0

Definition at line 12 of file qtestmouse.cpp.

Referenced by mouseEvent().

◆ mainSourcePath

static QString QTest::mainSourcePath
static

Definition at line 357 of file qtestcase.cpp.

Referenced by setMainSourcePath().

◆ maxWarnings

static int QTest::maxWarnings = 2002
static

Definition at line 212 of file qtestlog.cpp.

Referenced by messageHandler().

◆ mouseDelay

static int QTest::mouseDelay = -1
static

Definition at line 417 of file qtestcase.cpp.

Referenced by qtest_qParseArgs().

◆ mouseDoubleClickInterval

const int QTest::mouseDoubleClickInterval = 500
static

Definition at line 47 of file qtestmouse.h.

Referenced by mouseEvent().

◆ mutex

static Q_CONSTINIT QBasicMutex QTest::mutex
static

Definition at line 205 of file qtestlog.cpp.

◆ NumEntries

static const int QTest::NumEntries = sizeof(entries) / sizeof(entries[0])
static

Definition at line 50 of file qbenchmarkmetric.cpp.

Referenced by benchmarkMetricName(), and benchmarkMetricUnit().

◆ oldMessageHandler

static QtMessageHandler QTest::oldMessageHandler
static

Definition at line 215 of file qtestlog.cpp.

Referenced by messageHandler().

◆ passes

int QTest::passes = 0

Definition at line 141 of file qtestlog.cpp.

◆ PrettyUnicodeMaxIncrement

qsizetype QTest::PrettyUnicodeMaxIncrement = sizeof(R"(\uXXXX"...)")
constexpr

Definition at line 1599 of file qtestcase.cpp.

◆ PrettyUnicodeMaxOutputSize

qsizetype QTest::PrettyUnicodeMaxOutputSize = 256
constexpr

Definition at line 1597 of file qtestcase.cpp.

◆ printAvailableFunctions

Q_TESTLIB_EXPORT bool QTest::printAvailableFunctions = false

Definition at line 498 of file qtestcase.cpp.

Referenced by qtest_qParseArgs().

◆ repetitions

static int QTest::repetitions = 1
static

Definition at line 422 of file qtestcase.cpp.

Referenced by qRun(), and qtest_qParseArgs().

◆ skipBlacklisted

static bool QTest::skipBlacklisted = false
static

Definition at line 423 of file qtestcase.cpp.

Referenced by qtest_qParseArgs().

◆ skipCurrentTest

static bool QTest::skipCurrentTest = false
static

Definition at line 64 of file qtestresult.cpp.

◆ skips

int QTest::skips = 0

Definition at line 142 of file qtestlog.cpp.

◆ testFunctions

Q_TESTLIB_EXPORT QStringList QTest::testFunctions

Definition at line 499 of file qtestcase.cpp.

◆ testTags

Q_TESTLIB_EXPORT QStringList QTest::testTags

Definition at line 500 of file qtestcase.cpp.

◆ verbosity

static int QTest::verbosity = 0
static

Definition at line 211 of file qtestlog.cpp.