Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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 }
 
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
}
 
enum  MouseAction {
  MousePress , MouseRelease , MouseClick , MouseDClick ,
  MouseMove
}
 
enum  TestFailMode { Abort = 1 , Continue = 2 }
 
enum class  ComparisonOperation {
  CustomCompare , Equal , NotEqual , LessThan ,
  LessThanOrEqual , GreaterThan , GreaterThanOrEqual
}
 

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 *widget, 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,...)
 
void Q_TESTLIB_EXPORT setBenchmarkResult (qreal result, QBenchmarkMetric metric)
 Sets the benchmark result for this test function to result.
 
int iterationCount () noexcept
 
void setIterationCountHint (int count)
 
void setIterationCount (int count)
 
void beginBenchmarkMeasurement ()
 
QList< QBenchmarkMeasurerBase::MeasurementendBenchmarkMeasurement ()
 
const char * benchmarkMetricName (QBenchmarkMetric metric)
 
const char * benchmarkMetricUnit (QBenchmarkMetric metric)
 
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)
 
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)
 
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)
 
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)
 
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)
 
 switch (ch)
 
return first (2)
 
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 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)
 
Q_TESTLIB_EXPORT 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)
 
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)
 
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 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)
 
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_GLOBAL_STATIC (TestRegistry, g_registry)
 
static void setFailed (bool failed)
 
static void resetFailed ()
 
static bool hasFailed ()
 
Q_TESTLIB_EXPORT bool compare_string_helper (const char *t1, const char *t2, const char *actual, const char *expected, const char *file, int line)
 
Q_TESTLIB_EXPORT char * toPrettyUnicode (QStringView string)
 
Q_TESTLIB_EXPORT char * toString (const char *)
 
Q_TESTLIB_EXPORT char * toString (const volatile void *)
 
Q_TESTLIB_EXPORT char * toString (const volatile QObject *)
 
template<typename T , Internal::is_suitable_type_v< T > = true>
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)
 
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)
 
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)
 
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)
 

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 repeatForever = false
 
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
 
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 const int mouseDoubleClickInterval = 500
 
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
 

Detailed Description

[15]

[16]

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
IndentSpacesCount 

Definition at line 30 of file qsignaldumper.cpp.

◆ anonymous enum

anonymous enum
Enumerator
Unresolved 
Passed 
Skipped 
Suppressed 
Failed 

Definition at line 81 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 

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 42 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 45 of file qtest.h.

References compare_helper(), expected, file, i, line, qsnprintf(), and toString().

Referenced by qCompare(), qCompare(), and qCompare().

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

◆ addColumn()

template<typename T >
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::addColumn<int>("intval");
QTest::addColumn<QString>("str");
QTest::addColumn<double>("dbl");
QTest::newRow("row1") << 1 << "hello" << 1.5;

To add custom types to the testdata, the type must be registered with QMetaType via \l Q_DECLARE_METATYPE().

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 498 of file qtestcase.h.

References addColumnInternal().

+ Here is the call graph for this function:

◆ addColumnInternal()

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

Definition at line 2545 of file qtestcase.cpp.

References QTestTable::currentTestTable(), and QTEST_ASSERT_X.

Referenced by addColumn().

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

◆ 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 qsnprintf() for formatting according to format. See the qvsnprintf() 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::addColumn<int>("input");
QTest::addColumn<QString>("output");
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 2610 of file qtestcase.cpp.

References QTestTable::currentTestTable(), QTEST_ASSERT_X, qvsnprintf(), and void.

Referenced by MyTestClass::addMultStringRows(), and for().

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

◆ 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.

References Qt::Key_0, Qt::Key_1, Qt::Key_2, Qt::Key_3, Qt::Key_4, Qt::Key_5, Qt::Key_6, Qt::Key_7, Qt::Key_8, Qt::Key_9, Qt::Key_A, Qt::Key_Aacute, Qt::Key_Acircumflex, Qt::Key_acute, Qt::Key_Adiaeresis, Qt::Key_AE, Qt::Key_Agrave, Qt::Key_Ampersand, Qt::Key_Apostrophe, Qt::Key_Aring, Qt::Key_AsciiCircum, Qt::Key_AsciiTilde, Qt::Key_Asterisk, Qt::Key_At, Qt::Key_Atilde, Qt::Key_B, Qt::Key_Backslash, Qt::Key_Backspace, Qt::Key_Backtab, Qt::Key_Bar, Qt::Key_BraceLeft, Qt::Key_BraceRight, Qt::Key_BracketLeft, Qt::Key_BracketRight, Qt::Key_brokenbar, Qt::Key_C, Qt::Key_Ccedilla, Qt::Key_cedilla, Qt::Key_cent, Qt::Key_Colon, Qt::Key_Comma, Qt::Key_copyright, Qt::Key_currency, Qt::Key_D, Qt::Key_degree, Qt::Key_diaeresis, Qt::Key_division, Qt::Key_Dollar, Qt::Key_Down, Qt::Key_E, Qt::Key_Eacute, Qt::Key_Ecircumflex, Qt::Key_Ediaeresis, Qt::Key_Egrave, Qt::Key_Equal, Qt::Key_Escape, Qt::Key_ETH, Qt::Key_Exclam, Qt::Key_exclamdown, Qt::Key_F, Qt::Key_G, Qt::Key_Greater, Qt::Key_guillemotleft, Qt::Key_guillemotright, Qt::Key_H, Qt::Key_hyphen, Qt::Key_I, Qt::Key_Iacute, Qt::Key_Icircumflex, Qt::Key_Idiaeresis, Qt::Key_Igrave, Qt::Key_J, Qt::Key_K, Qt::Key_L, Qt::Key_Less, Qt::Key_M, Qt::Key_macron, Qt::Key_masculine, Qt::Key_micro, Qt::Key_Minus, Qt::Key_multiply, Qt::Key_N, Qt::Key_nobreakspace, Qt::Key_notsign, Qt::Key_Ntilde, Qt::Key_NumberSign, Qt::Key_O, Qt::Key_Oacute, Qt::Key_Ocircumflex, Qt::Key_Odiaeresis, Qt::Key_Ograve, Qt::Key_onehalf, Qt::Key_onequarter, Qt::Key_onesuperior, Qt::Key_Ooblique, Qt::Key_ordfeminine, Qt::Key_Otilde, Qt::Key_P, Qt::Key_paragraph, Qt::Key_ParenLeft, Qt::Key_ParenRight, Qt::Key_Percent, Qt::Key_Period, Qt::Key_periodcentered, Qt::Key_Plus, Qt::Key_plusminus, Qt::Key_Q, Qt::Key_Question, Qt::Key_questiondown, Qt::Key_QuoteDbl, Qt::Key_QuoteLeft, Qt::Key_R, Qt::Key_registered, Qt::Key_Return, Qt::Key_S, Qt::Key_section, Qt::Key_Semicolon, Qt::Key_Slash, Qt::Key_Space, Qt::Key_ssharp, Qt::Key_sterling, Qt::Key_T, Qt::Key_Tab, Qt::Key_THORN, Qt::Key_threequarters, Qt::Key_threesuperior, Qt::Key_twosuperior, Qt::Key_U, Qt::Key_Uacute, Qt::Key_Ucircumflex, Qt::Key_Udiaeresis, Qt::Key_Ugrave, Qt::Key_Underscore, Qt::Key_Up, Qt::Key_V, Qt::Key_W, Qt::Key_X, Qt::Key_Y, Qt::Key_Yacute, Qt::Key_ydiaeresis, Qt::Key_yen, Qt::Key_Z, and QTEST_ASSERT.

Referenced by keyEvent().

+ Here is the caller graph for this function:

◆ beginBenchmarkMeasurement()

void QTest::beginBenchmarkMeasurement ( )

Definition at line 208 of file qbenchmark.cpp.

References QBenchmarkGlobalData::current.

Referenced by QTest::QBenchmarkIterationController::QBenchmarkIterationController(), and QTest::QBenchmarkIterationController::QBenchmarkIterationController().

+ Here is the caller graph for this function:

◆ 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.

Referenced by QCsvBenchmarkLogger::addBenchmarkResult().

+ Here is the caller graph for this function:

◆ 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 131 of file qplaintestlogger.cpp.

◆ benchmarkResultFormatString()

static const char * QTest::benchmarkResultFormatString ( )
static

Definition at line 192 of file qxmltestlogger.cpp.

Referenced by QXmlTestLogger::addBenchmarkResult().

+ Here is the caller graph for this function:

◆ classIsIgnored()

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

Definition at line 32 of file qsignaldumper.cpp.

References className, ignoreClassesMutex, isEmpty(), and Q_LIKELY.

Referenced by qSignalDumperCallback(), qSignalDumperCallbackEndSignal(), and qSignalDumperCallbackSlot().

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

◆ 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 2836 of file qtestcase.cpp.

References QTestResult::compare(), expected, file, and line.

+ Here is the call graph for this function:

◆ compare_helper() [2/2]

bool QTest::compare_helper ( bool success,
const char * failureMsg,
const void * actualPtr,
const void * expectedPtr,
const char *(*)(const void *) actualFormatter,
const char *(*)(const void *) expectedFormatter,
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 2812 of file qtestcase.cpp.

References CustomCompare, expected, file, line, and QTestResult::reportResult().

Referenced by _q_compareSequence(), compare_ptr_helper(), compare_ptr_helper(), compare_ptr_helper(), compare_ptr_helper(), compare_ptr_helper(), compare_ptr_helper(), compare_string_helper(), qCompare(), qCompare(), qCompare(), and qCompare().

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

◆ 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 564 of file qtestcase.h.

References compare_helper(), expected, file, line, and t2.

+ Here is the call graph for this function:

◆ 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 573 of file qtestcase.h.

References compare_helper(), expected, file, and line.

+ Here is the call graph for this function:

◆ 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 555 of file qtestcase.h.

References compare_helper(), expected, file, line, and t2.

Referenced by qCompare(), qCompare(), qCompare(), qCompare(), qCompare(), and qCompare().

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

◆ 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 593 of file qtestcase.h.

References compare_helper(), expected, file, and line.

+ Here is the call graph for this function:

◆ 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 583 of file qtestcase.h.

References compare_helper(), expected, file, line, and t2.

+ Here is the call graph for this function:

◆ 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 603 of file qtestcase.h.

References compare_helper(), expected, file, line, and t2.

+ Here is the call graph for this function:

◆ 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 3184 of file qtestcase.cpp.

References compare_helper(), expected, file, line, qstrcmp(), and t2.

Referenced by qCompare(), qCompare(), qCompare(), and qCompare().

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

◆ countSignificantDigits()

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

Definition at line 158 of file qplaintestlogger.cpp.

References digits().

+ Here is the call graph for this function:

◆ createTouchDevice()

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

Definition at line 1222 of file qwindowsysteminterface.cpp.

References createTouchDevice(), QPointingDevice::Finger, nextId, QWindowSystemInterface::registerInputDevice(), and ret.

Referenced by createTouchDevice(), and processTouchEvent().

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

◆ currentAppName()

const char * QTest::currentAppName ( )

Returns the name of the binary that is currently executed.

Definition at line 2658 of file qtestcase.cpp.

References QTestResult::currentAppName().

+ Here is the call graph for this function:

◆ 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 2679 of file qtestcase.cpp.

References QTestResult::currentDataTag().

+ Here is the call graph for this function:

◆ currentTestFailed()

bool QTest::currentTestFailed ( )

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

See also
QTest::currentTestResolved()

Definition at line 2689 of file qtestcase.cpp.

References QTestResult::currentTestFailed().

Referenced by QTestPrivate::testAllComparisonOperatorsCompile().

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

◆ 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 2670 of file qtestcase.cpp.

References QTestResult::currentTestFunction().

Referenced by MyTestClass::cleanup(), and QTest::CrashHandler::printTestRunTime().

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

◆ 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 2707 of file qtestcase.cpp.

References QTestResult::currentTestFailed(), and QTestResult::skipCurrentTest().

Referenced by QTestEventLoop::enterLoop().

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

◆ defaultEventDelay()

int QTest::defaultEventDelay ( )

Definition at line 463 of file qtestcase.cpp.

References QByteArray::constData(), eventDelay, QByteArray::isEmpty(), and qgetenv().

Referenced by defaultKeyDelay(), and defaultMouseDelay().

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

◆ defaultKeyDelay()

int Q_TESTLIB_EXPORT QTest::defaultKeyDelay ( )

Definition at line 487 of file qtestcase.cpp.

References QByteArray::constData(), defaultEventDelay(), QByteArray::isEmpty(), keyDelay, and qgetenv().

+ Here is the call graph for this function:

◆ defaultMouseDelay()

int Q_TESTLIB_EXPORT QTest::defaultMouseDelay ( )

Definition at line 475 of file qtestcase.cpp.

References QByteArray::constData(), defaultEventDelay(), QByteArray::isEmpty(), mouseDelay, and qgetenv().

Referenced by QuickTestEvent::defaultMouseDelay(), QtQuickTest::mouseEvent(), mouseEvent(), QQuickTest::pointerMove(), QQuickTest::pointerPress(), and QQuickTest::pointerRelease().

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

◆ endBenchmarkMeasurement()

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

Definition at line 216 of file qbenchmark.cpp.

References QBenchmarkGlobalData::current.

Referenced by QTest::QBenchmarkIterationController::~QBenchmarkIterationController().

+ Here is the caller graph for this function:

◆ failOnWarning() [1/2]

void QTest::failOnWarning ( )
related

Definition at line 2212 of file qtestcase.cpp.

References QTestLog::failOnWarning().

Referenced by QQmlDataTest::init().

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

◆ failOnWarning() [2/2]

void QTest::failOnWarning ( const char * message)

Definition at line 2225 of file qtestcase.cpp.

References QTestLog::failOnWarning().

+ Here is the call graph for this function:

◆ fetchData()

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

Definition at line 1414 of file qtestcase.cpp.

References QMetaType::name(), Q_UNLIKELY, qFatal, QTEST_ASSERT, and QTEST_ASSERT_X.

Referenced by qData(), and qGlobalData().

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

◆ first()

return QTest::first ( 2 )

◆ formatResult()

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

Definition at line 175 of file qplaintestlogger.cpp.

References QByteArray::append(), i, number, QByteArray::number(), and qMin().

+ Here is the call graph for this function:

◆ formatString()

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

Definition at line 1439 of file qtestcase.cpp.

References arguments, QList< T >::constData(), i, and qstrdup().

Referenced by toString(), and tupleToString().

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

◆ handleFailOnWarning()

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

Definition at line 180 of file qtestlog.cpp.

References QTestResult::addFailure(), context, failOnWarningList, maxMsgLen, qPrintable, and qsnprintf().

Referenced by messageHandler().

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

◆ handleIgnoredMessage()

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

Definition at line 154 of file qtestlog.cpp.

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

Referenced by messageHandler().

+ Here is the caller graph for this function:

◆ hasFailed()

static bool QTest::hasFailed ( )
static

Definition at line 51 of file qtestresult.cpp.

References QTest::Internal::failed.

Referenced by QTestResult::currentTestFailed(), and QTestResult::finishedCurrentTestDataCleanup().

+ Here is the caller graph for this function:

◆ 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 2177 of file qtestcase.cpp.

References QTestLog::ignoreMessage().

Referenced by tstQDir().

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

◆ incidentFormatString()

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

Definition at line 173 of file qxmltestlogger.cpp.

Referenced by QXmlTestLogger::addIncident().

+ Here is the caller graph for this function:

◆ invokeTestMethodIfExists()

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

Definition at line 455 of file qtestcase.cpp.

References invokeTestMethodIfValid(), metaObject(), and methodName().

Referenced by qPrintDataTags().

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

◆ invokeTestMethodIfValid()

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

Definition at line 443 of file qtestcase.cpp.

References ok.

Referenced by invokeTestMethodIfExists(), and QTest::TestMethods::invokeTests().

+ Here is the caller graph for this function:

◆ isEmpty()

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

Definition at line 168 of file qxmltestlogger.cpp.

References str.

Referenced by QXmlTestLogger::addIncident(), QXmlTestLogger::addMessage(), and classIsIgnored().

+ Here is the caller graph for this function:

◆ iterationCount()

int QTest::iterationCount ( )
noexcept

Definition at line 186 of file qbenchmark.cpp.

References QBenchmarkTestMethodData::current.

Referenced by QTest::QBenchmarkIterationController::isDone().

+ Here is the caller graph for this function:

◆ 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, keyEvent(), and window().

+ Here is the call graph for this function:

◆ 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(), and window().

Referenced by QQuickDialogTestUtils::enterText(), QuickTestEvent::keyClick(), and QuickTestEvent::keyClickChar().

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

◆ 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.

References asciiToKey(), sendKeyEvent(), and window().

Referenced by keyClick(), keyClick(), keyPress(), keyPress(), keyRelease(), and keyRelease().

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

◆ 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.

References keyToAscii(), sendKeyEvent(), and window().

+ Here is the call graph for this function:

◆ 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 keyEvent(), Press, and window().

Referenced by QuickTestEvent::keyPress(), and QuickTestEvent::keyPressChar().

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

◆ 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 keyEvent(), Press, and window().

+ Here is the call graph for this function:

◆ 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 keyEvent(), Release, and window().

Referenced by QuickTestEvent::keyRelease(), and QuickTestEvent::keyReleaseChar().

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

◆ 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 keyEvent(), Release, and window().

+ Here is the call graph for this function:

◆ 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.

References Qt::Key_0, Qt::Key_1, Qt::Key_2, Qt::Key_3, Qt::Key_4, Qt::Key_5, Qt::Key_6, Qt::Key_7, Qt::Key_8, Qt::Key_9, Qt::Key_A, Qt::Key_Aacute, Qt::Key_Acircumflex, Qt::Key_acute, Qt::Key_Adiaeresis, Qt::Key_AE, Qt::Key_Agrave, Qt::Key_Alt, Qt::Key_Ampersand, Qt::Key_Apostrophe, Qt::Key_Aring, Qt::Key_AsciiCircum, Qt::Key_AsciiTilde, Qt::Key_Asterisk, Qt::Key_At, Qt::Key_Atilde, Qt::Key_B, Qt::Key_Back, Qt::Key_Backslash, Qt::Key_Backspace, Qt::Key_Backtab, Qt::Key_Bar, Qt::Key_BassBoost, Qt::Key_BassDown, Qt::Key_BassUp, Qt::Key_BraceLeft, Qt::Key_BraceRight, Qt::Key_BracketLeft, Qt::Key_BracketRight, Qt::Key_brokenbar, Qt::Key_C, Qt::Key_CapsLock, Qt::Key_Ccedilla, Qt::Key_cedilla, Qt::Key_cent, Qt::Key_Clear, Qt::Key_Colon, Qt::Key_Comma, Qt::Key_Control, Qt::Key_copyright, Qt::Key_currency, Qt::Key_D, Qt::Key_degree, Qt::Key_Delete, Qt::Key_diaeresis, Qt::Key_Direction_L, Qt::Key_Direction_R, Qt::Key_division, Qt::Key_Dollar, Qt::Key_Down, Qt::Key_E, Qt::Key_Eacute, Qt::Key_Ecircumflex, Qt::Key_Ediaeresis, Qt::Key_Egrave, Qt::Key_End, Qt::Key_Enter, Qt::Key_Equal, Qt::Key_Escape, Qt::Key_ETH, Qt::Key_Exclam, Qt::Key_exclamdown, Qt::Key_F, Qt::Key_F1, Qt::Key_F10, Qt::Key_F11, Qt::Key_F12, Qt::Key_F13, Qt::Key_F14, Qt::Key_F15, Qt::Key_F16, Qt::Key_F17, Qt::Key_F18, Qt::Key_F19, Qt::Key_F2, Qt::Key_F20, Qt::Key_F21, Qt::Key_F22, Qt::Key_F23, Qt::Key_F24, Qt::Key_F25, Qt::Key_F26, Qt::Key_F27, Qt::Key_F28, Qt::Key_F29, Qt::Key_F3, Qt::Key_F30, Qt::Key_F31, Qt::Key_F32, Qt::Key_F33, Qt::Key_F34, Qt::Key_F35, Qt::Key_F4, Qt::Key_F5, Qt::Key_F6, Qt::Key_F7, Qt::Key_F8, Qt::Key_F9, Qt::Key_Favorites, Qt::Key_Forward, Qt::Key_G, Qt::Key_Greater, Qt::Key_guillemotleft, Qt::Key_guillemotright, Qt::Key_H, Qt::Key_Help, Qt::Key_Home, Qt::Key_HomePage, Qt::Key_Hyper_L, Qt::Key_Hyper_R, Qt::Key_hyphen, Qt::Key_I, Qt::Key_Iacute, Qt::Key_Icircumflex, Qt::Key_Idiaeresis, Qt::Key_Igrave, Qt::Key_Insert, Qt::Key_J, Qt::Key_K, Qt::Key_L, Qt::Key_Launch0, Qt::Key_Launch1, Qt::Key_Launch2, Qt::Key_Launch3, Qt::Key_Launch4, Qt::Key_Launch5, Qt::Key_Launch6, Qt::Key_Launch7, Qt::Key_Launch8, Qt::Key_Launch9, Qt::Key_LaunchA, Qt::Key_LaunchB, Qt::Key_LaunchC, Qt::Key_LaunchD, Qt::Key_LaunchE, Qt::Key_LaunchF, Qt::Key_LaunchMail, Qt::Key_LaunchMedia, Qt::Key_Left, Qt::Key_Less, Qt::Key_M, Qt::Key_macron, Qt::Key_masculine, Qt::Key_MediaNext, Qt::Key_MediaPlay, Qt::Key_MediaPrevious, Qt::Key_MediaRecord, Qt::Key_MediaStop, Qt::Key_Menu, Qt::Key_Meta, Qt::Key_micro, Qt::Key_Minus, Qt::Key_multiply, Qt::Key_N, Qt::Key_No, Qt::Key_nobreakspace, Qt::Key_notsign, Qt::Key_Ntilde, Qt::Key_NumberSign, Qt::Key_NumLock, Qt::Key_O, Qt::Key_Oacute, Qt::Key_Ocircumflex, Qt::Key_Odiaeresis, Qt::Key_Ograve, Qt::Key_onehalf, Qt::Key_onequarter, Qt::Key_onesuperior, Qt::Key_Ooblique, Qt::Key_OpenUrl, Qt::Key_ordfeminine, Qt::Key_Otilde, Qt::Key_P, Qt::Key_PageDown, Qt::Key_PageUp, Qt::Key_paragraph, Qt::Key_ParenLeft, Qt::Key_ParenRight, Qt::Key_Pause, Qt::Key_Percent, Qt::Key_Period, Qt::Key_periodcentered, Qt::Key_Plus, Qt::Key_plusminus, Qt::Key_Print, Qt::Key_Q, Qt::Key_Question, Qt::Key_questiondown, Qt::Key_QuoteDbl, Qt::Key_QuoteLeft, Qt::Key_R, Qt::Key_Refresh, Qt::Key_registered, Qt::Key_Return, Qt::Key_Right, Qt::Key_S, Qt::Key_ScrollLock, Qt::Key_Search, Qt::Key_section, Qt::Key_Select, Qt::Key_Semicolon, Qt::Key_Shift, Qt::Key_Slash, Qt::Key_Space, Qt::Key_ssharp, Qt::Key_Standby, Qt::Key_sterling, Qt::Key_Stop, Qt::Key_Super_L, Qt::Key_Super_R, Qt::Key_SysReq, Qt::Key_T, Qt::Key_Tab, Qt::Key_THORN, Qt::Key_threequarters, Qt::Key_threesuperior, Qt::Key_TrebleDown, Qt::Key_TrebleUp, Qt::Key_twosuperior, Qt::Key_U, Qt::Key_Uacute, Qt::Key_Ucircumflex, Qt::Key_Udiaeresis, Qt::Key_Ugrave, Qt::Key_Underscore, Qt::Key_Up, Qt::Key_V, Qt::Key_VolumeDown, Qt::Key_VolumeMute, Qt::Key_VolumeUp, Qt::Key_W, Qt::Key_X, Qt::Key_Y, Qt::Key_Yacute, Qt::Key_ydiaeresis, Qt::Key_yen, Qt::Key_Yes, Qt::Key_Z, and QTEST_ASSERT.

Referenced by keyEvent().

+ Here is the caller graph for this function:

◆ messageFormatString()

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

Definition at line 197 of file qxmltestlogger.cpp.

Referenced by QXmlTestLogger::addMessage().

+ Here is the caller graph for this function:

◆ messageHandler()

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

Definition at line 206 of file qtestlog.cpp.

References QTestResult::addFailure(), context, FOREACH_TEST_LOGGER, handleFailOnWarning(), handleIgnoredMessage(), QTestLog::hasLoggers(), QTestLog::leaveTestFunction(), maxWarnings, oldMessageHandler, Q_BASIC_ATOMIC_INITIALIZER, qInstallMessageHandler(), QStringLiteral, QTEST_ASSERT, QtFatalMsg, QtWarningMsg, QTestLog::stopLogging(), and QAbstractTestLogger::Warn.

Referenced by QTestLog::startLogging().

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

◆ mouseClick()

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

Definition at line 137 of file qtestmouse.h.

References button, MouseClick, mouseEvent(), pos, and window().

Referenced by QQuickControlsTestUtils::clickButton().

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

◆ mouseDClick()

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

Definition at line 141 of file qtestmouse.h.

References button, MouseDClick, mouseEvent(), pos, and window().

Referenced by QQuickControlsTestUtils::doubleClickButton().

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

◆ 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 67 of file qtestmouse.h.

References button, defaultMouseDelay(), global, QSize::height(), Qt::KeyboardModifierMask, lastMouseTimestamp, QEvent::MouseButtonPress, QEvent::MouseButtonRelease, MouseClick, MouseDClick, mouseDoubleClickInterval, QEvent::MouseMove, MouseMove, MousePress, MouseRelease, Qt::NoButton, pos, Q_FALLTHROUGH, qApp, qMax(), qt_handleMouseEvent(), QTEST_ASSERT, qWarning, QSize::width(), and window().

Referenced by mouseClick(), mouseDClick(), mouseMove(), mousePress(), and mouseRelease().

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

◆ mouseMove()

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

Definition at line 145 of file qtestmouse.h.

References mouseEvent(), MouseMove, Qt::NoButton, pos, and window().

Referenced by QQuickViewTestUtils::flick(), QQuickViewTestUtils::moveAndPress(), QQuickViewTestUtils::moveAndRelease(), and QQuickTest::pointerMove().

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

◆ mousePress()

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

Definition at line 129 of file qtestmouse.h.

References button, mouseEvent(), MousePress, pos, and window().

Referenced by QQuickViewTestUtils::moveAndPress(), and QQuickTest::pointerPress().

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

◆ mouseRelease()

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

Definition at line 133 of file qtestmouse.h.

References button, mouseEvent(), MouseRelease, pos, and window().

Referenced by QQuickViewTestUtils::moveAndRelease(), and QQuickTest::pointerRelease().

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

◆ 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::addColumn<QString>("aString");
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 2573 of file qtestcase.cpp.

References QTestTable::currentTestTable(), and QTEST_ASSERT_X.

Referenced by MyTestClass::addDataRow(), MyTestClass::addSingleStringRows(), QQuickControlsTestUtils::addTestRowForEachControl(), QuickTestResult::setDataTag(), tst_Skip::test_data(), and TestQString::toInt_data().

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

◆ printUnknownDataTagError()

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

Definition at line 1282 of file qtestcase.cpp.

References QTestTable::dataCount(), QTestData::dataTag(), i, tag, and QTestTable::testData().

+ Here is the call graph for this function:

◆ ptIncidentType2String()

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

Definition at line 106 of file qplaintestlogger.cpp.

References QAbstractTestLogger::BlacklistedFail, QAbstractTestLogger::BlacklistedPass, QAbstractTestLogger::BlacklistedXFail, QAbstractTestLogger::BlacklistedXPass, QAbstractTestLogger::Fail, QAbstractTestLogger::Pass, QAbstractTestLogger::Skip, QAbstractTestLogger::XFail, and QAbstractTestLogger::XPass.

Referenced by QPlainTestLogger::addIncident().

+ Here is the caller graph for this function:

◆ ptMessageType2String()

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

Definition at line 136 of file qplaintestlogger.cpp.

References QAbstractTestLogger::Info, QAbstractTestLogger::QCritical, QAbstractTestLogger::QDebug, QAbstractTestLogger::QFatal, QAbstractTestLogger::QInfo, QAbstractTestLogger::QWarning, and QAbstractTestLogger::Warn.

Referenced by QPlainTestLogger::addMessage(), and QPlainTestLogger::enterTestFunction().

+ Here is the caller graph for this function:

◆ 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 2135 of file qtestcase.cpp.

References expected, file, line, and qCaught().

+ Here is the call graph for this function:

◆ 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 2099 of file qtestcase.cpp.

References QString::asprintf(), expected, file, line, and qFail().

Referenced by qCaught().

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

◆ qCleanup()

void QTest::qCleanup ( )

Definition at line 1981 of file qtestcase.cpp.

References QBenchmarkGlobalData::CallgrindParentProcess, QBenchmarkGlobalData::current, currentTestObject, and QTestLog::stopLogging().

Referenced by qExec(), qRun(), and runTests().

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

◆ 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 682 of file qtestcase.h.

References compare_string_helper(), expected, file, line, and t2.

+ Here is the call graph for this function:

◆ 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 691 of file qtestcase.h.

References compare_string_helper(), expected, file, line, and t2.

+ Here is the call graph for this function:

◆ 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 696 of file qtestcase.h.

References compare_string_helper(), expected, file, line, and t2.

+ Here is the call graph for this function:

◆ 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 677 of file qtestcase.h.

References compare_string_helper(), expected, file, line, and t2.

+ Here is the call graph for this function:

◆ 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 2963 of file qtestcase.cpp.

References QTestResult::compare(), expected, file, line, and t2.

+ Here is the call graph for this function:

◆ 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 536 of file qtestcase.h.

References expected, file, line, qCompare(), and t2.

+ Here is the call graph for this function:

◆ qCompare() [7/38]

template<typename T >
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 639 of file qtestcase.h.

References compare_ptr_helper(), expected, file, line, and t2.

+ Here is the call graph for this function:

◆ qCompare() [8/38]

template<typename T1 , typename T2 = T1>
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 614 of file qtestcase.h.

References compare_helper(), expected, file, QTest::Internal::genericToString(), line, and t2.

+ Here is the call graph for this function:

◆ qCompare() [9/38]

template<typename T1 , typename T2 >
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 665 of file qtestcase.h.

References compare_ptr_helper(), expected, file, line, and t2.

+ Here is the call graph for this function:

◆ 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 2888 of file qtestcase.cpp.

References QTestResult::compare(), expected, file, floatingCompare(), line, and t2.

+ Here is the call graph for this function:

◆ 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 626 of file qtestcase.h.

References expected, file, line, qCompare(), and t2.

+ Here is the call graph for this function:

◆ 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 632 of file qtestcase.h.

References expected, file, line, qCompare(), and t2.

+ Here is the call graph for this function:

◆ 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 2877 of file qtestcase.cpp.

References QTestResult::compare(), expected, file, floatingCompare(), line, and t2.

+ Here is the call graph for this function:

◆ 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 2900 of file qtestcase.cpp.

References QTestResult::compare(), expected, file, line, and t2.

+ Here is the call graph for this function:

◆ qCompare() [15/38]

template<typename T >
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 131 of file qtest.h.

References expected, file, line, qCompare(), and t2.

+ Here is the call graph for this function:

◆ qCompare() [16/38]

template<typename T >
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 123 of file qtest.h.

References expected, file, line, qCompare(), and t2.

+ Here is the call graph for this function:

◆ 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 2864 of file qtestcase.cpp.

References compare_helper(), expected, file, floatingCompare(), line, and t2.

+ Here is the call graph for this function:

◆ 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 117 of file qtest_gui.h.

References expected, file, line, qCompare(), QTEST_ASSERT, and t2.

+ Here is the call graph for this function:

◆ 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 125 of file qtest_gui.h.

References compare_helper(), expected, file, line, qFuzzyCompare(), qsnprintf(), and t2.

+ Here is the call graph for this function:

◆ 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 160 of file qtest.h.

References expected, file, line, qCompare(), and t2.

+ Here is the call graph for this function:

◆ 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 139 of file qtest.h.

References expected, file, line, qCompare(), and t2.

+ Here is the call graph for this function:

◆ 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 146 of file qtest.h.

References expected, file, line, qCompare(), and t2.

+ Here is the call graph for this function:

◆ 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 37 of file qtest.h.

References expected, file, line, qCompare(), and t2.

+ Here is the call graph for this function:

◆ 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 114 of file qtest.h.

References _q_compareSequence(), expected, file, line, and t2.

+ Here is the call graph for this function:

◆ qCompare() [25/38]

template<typename T >
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 96 of file qtest.h.

References _q_compareSequence(), expected, file, line, and t2.

+ Here is the call graph for this function:

◆ 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 104 of file qtest.h.

References _q_compareSequence(), expected, file, line, and t2.

+ Here is the call graph for this function:

◆ 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 167 of file qtest_gui.h.

References compare_helper(), expected, file, line, qCompare(), qFuzzyCompare(), qsnprintf(), and t2.

+ Here is the call graph for this function:

◆ 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 31 of file qtest.h.

References expected, file, line, qCompare(), and t2.

Referenced by qCompare(), qCompare(), qCompare(), qCompare(), qCompare(), qCompare(), qCompare(), qCompare(), qCompare(), qCompare(), qCompare(), qCompare(), qCompare(), qCompare(), qCompare(), and qTest().

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

◆ 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 2951 of file qtestcase.cpp.

References QTestResult::compare(), expected, file, line, and t2.

+ Here is the call graph for this function:

◆ 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 2939 of file qtestcase.cpp.

References QTestResult::compare(), expected, file, line, and t2.

+ Here is the call graph for this function:

◆ 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 167 of file qtest.h.

References expected, file, line, qCompare(), and t2.

+ Here is the call graph for this function:

◆ 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 174 of file qtest.h.

References expected, file, line, qCompare(), and t2.

+ Here is the call graph for this function:

◆ 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 153 of file qtest.h.

References expected, file, line, qCompare(), and t2.

+ Here is the call graph for this function:

◆ qCompare() [34/38]

template<typename T >
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 658 of file qtestcase.h.

References compare_ptr_helper(), expected, file, line, and t2.

+ Here is the call graph for this function:

◆ qCompare() [35/38]

template<typename T >
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 652 of file qtestcase.h.

References compare_ptr_helper(), expected, file, and line.

+ Here is the call graph for this function:

◆ qCompare() [36/38]

template<typename T >
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 645 of file qtestcase.h.

References compare_ptr_helper(), expected, file, line, and t2.

+ Here is the call graph for this function:

◆ qCompare() [37/38]

template<typename T1 , typename T2 >
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 671 of file qtestcase.h.

References compare_ptr_helper(), expected, file, line, and t2.

+ Here is the call graph for this function:

◆ 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 2927 of file qtestcase.cpp.

References QTestResult::compare(), expected, file, line, and t2.

+ Here is the call graph for this function:

◆ 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 725 of file qtestcase.h.

References file, QTest::Internal::genericToString(), line, and reportResult().

+ Here is the call graph for this function:

◆ qData()

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

Definition at line 2515 of file qtestcase.cpp.

References QTestResult::currentTestData(), and fetchData().

+ Here is the call graph for this function:

◆ qElementData()

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

Definition at line 2529 of file qtestcase.cpp.

References QTestResult::currentTestData(), and QTEST_ASSERT.

Referenced by qTest().

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

◆ 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 2033 of file qtestcase.cpp.

References QList< T >::append(), args, arguments, QList< T >::at(), QVariant::constData(), i, QList< T >::last(), qExec(), QList< T >::reserve(), QList< T >::size(), and testObject().

+ Here is the call graph for this function:

◆ 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 1820 of file qtestcase.cpp.

References Module, qCleanup(), qInit(), qRun(), ret, and testObject().

Referenced by qExec(), and testObject().

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

◆ qExpectFail()

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

Definition at line 2077 of file qtestcase.cpp.

References QTestResult::expectFail(), file, line, and qstrdup().

+ Here is the call graph for this function:

◆ qFail()

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

Definition at line 2052 of file qtestcase.cpp.

References QTestResult::fail(), file, and line.

Referenced by qCaught().

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

◆ 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 2507 of file qtestcase.cpp.

References base, QFile::decodeName(), file, line, and qFindTestData().

Referenced by QTestPrivate::parseBlackList(), and qFindTestData().

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

◆ qFindTestData() [2/2]

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

◆ qGlobalData()

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

Definition at line 2522 of file qtestcase.cpp.

References QTestResult::currentGlobalTestData(), and fetchData().

+ Here is the call graph for this function:

◆ qInit()

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

Definition at line 1842 of file qtestcase.cpp.

References QBenchmarkGlobalData::CallgrindParentProcess, QBenchmarkGlobalData::current, currentTestObject, QTestPrivate::disableWindowRestore(), initEnvironment(), metaObject(), QTestPrivate::parseBlackList(), qApp, qstrcmp(), QTEST_ASSERT, qtest_qParseArgs(), QTestResult::reset(), QTestResult::setCurrentAppName(), QTestResult::setCurrentTestObject(), QTestLog::startLogging(), and testObject().

Referenced by runTests().

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

◆ qMedian()

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

Definition at line 1023 of file qtestcase.cpp.

◆ qPrintDataTags()

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

Definition at line 537 of file qtestcase.cpp.

References QByteArray::constData(), currentTestObject, QByteArray::data(), QTestTable::dataCount(), QTestData::dataTag(), QTestTable::globalTestTable(), i, invokeTestMethodIfExists(), isValidSlot(), j, QMetaMethod::methodSignature(), qsnprintf(), qstrdup(), qstrlen(), QByteArray::resize(), QTestLog::setPrintAvailableTagsMode(), QByteArray::size(), and QTestTable::testData().

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.

References ba, QByteArray::constData(), and QTestLog::info().

Referenced by qSignalDumperCallback(), and qSignalDumperCallbackSlot().

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

◆ qPrintTestSlots()

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

Definition at line 516 of file qtestcase.cpp.

References Qt::CaseInsensitive, QLatin1StringView::contains(), currentTestObject, i, isValidSlot(), matches(), and preamble.

Referenced by qRun(), and qtest_qParseArgs().

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

◆ qRun()

◆ qSignalDumperCallback()

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

Definition at line 42 of file qsignaldumper.cpp.

References QString::append(), arg, args, QList< T >::at(), QString::chop(), classIsIgnored(), QString::endsWith(), QString::fill(), QMetaType::fromName(), i, ignoreLevel, iLevel, IndentSpacesCount, QString::isEmpty(), QMetaMethod::isValid(), mo, QMetaMethod::name(), QByteArray::number(), QMetaMethod::parameterTypes(), Q_ASSERT, Q_UNUSED, qPrintMessage(), QMetaObjectPrivate::signal(), QList< T >::size(), str, QString::toLocal8Bit(), toLocal8Bit(), toString(), and QMetaType::UnknownType.

Referenced by QSignalDumper::startDump().

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

◆ qSignalDumperCallbackEndSignal()

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

Definition at line 132 of file qsignaldumper.cpp.

References classIsIgnored(), ignoreLevel, iLevel, and Q_ASSERT.

Referenced by QSignalDumper::startDump().

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

◆ qSignalDumperCallbackSlot()

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

Definition at line 101 of file qsignaldumper.cpp.

References classIsIgnored(), QString::fill(), ignoreLevel, iLevel, IndentSpacesCount, QString::isEmpty(), QMetaMethod::isValid(), QMetaMethod::methodSignature(), mo, QByteArray::number(), Q_ASSERT, Q_UNUSED, qPrintMessage(), str, and QString::toLocal8Bit().

Referenced by QSignalDumper::startDump().

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

◆ qSkip()

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

Definition at line 2068 of file qtestcase.cpp.

References QTestResult::addSkip(), file, line, and QTestResult::setSkipCurrentTest().

+ Here is the call graph for this function:

◆ 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(), quarterSecondSleep(), qWait(), and QuickTestResult::sleep().

+ 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.

References Q_ASSERT.

◆ qt_asprintf()

◆ qTest()

template<class T >
template< typename 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 703 of file qtestcase.h.

References expected, file, line, qCompare(), and qElementData().

+ Here is the call graph for this function:

◆ qtest_qParseArgs() [1/2]

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

Definition at line 1019 of file qtestcase.cpp.

References qtest_qParseArgs().

+ Here is the call 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 615 of file qtestcase.cpp.

References QTestLog::addLogger(), QBenchmarkGlobalData::CallgrindChildProcess, QBenchmarkGlobalData::CallgrindParentProcess, QXcodeTestLogger::canLogTestProgress(), QTestLog::CSV, QBenchmarkGlobalData::current, QTestResult::currentAppName(), QDir::currentPath(), QTestResult::currentTestObjectName(), QBenchmarkGlobalData::EventCounter, eventDelay, QString::fromLatin1(), QTestLog::hasLoggers(), QBenchmarkValgrindUtils::haveValgrind(), i, installCoverageTool(), installedTestCoverage, QBenchmarkPerfEventsMeasurer::isAvailable(), QTestLog::isRepeatSupported(), QTestLog::JUnitXML, keyDelay, QTestLog::LightXML, QBenchmarkPerfEventsMeasurer::listCounters(), QTestLog::loggerUsingStdout(), mouseDelay, QTest::Internal::noCrashHandler, QBenchmarkValgrindUtils::outFileBase(), QXcodeTestLogger::parseCommandLineArgument(), QBenchmarkGlobalData::PerfCounter, QTestLog::Plain, AppleUnifiedLogger::preventsStderrLogging(), printAvailableFunctions, qEnvironmentVariableIsSet(), qPrintDataTags(), qPrintTestSlots(), qToInt(), repeatForever, repetitions, QBenchmarkPerfEventsMeasurer::setCounter(), QSignalDumper::setEnabled(), QTestLog::setInstalledTestCoverage(), QTestLog::setMaxWarnings(), setThrowOnFail(), setThrowOnSkip(), QTestLog::setVerboseLevel(), skipBlacklisted, QTestLog::TAP, QTestLog::TeamCity, testFunctions, testTags, QBenchmarkGlobalData::TickCounter, and QTestLog::XML.

Referenced by QuickTestResult::parseArgs(), qInit(), and qtest_qParseArgs().

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

◆ qToInt()

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

Definition at line 604 of file qtestcase.cpp.

References str.

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 2059 of file qtestcase.cpp.

References file, line, and QTestResult::verify().

+ Here is the call graph for this function:

◆ 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.

References qWait().

Referenced by QQuickViewTestUtils::flick(), QQuickTest::initView(), MyObject::isReady(), QtQuickTest::mouseEvent(), QQuickVisualTestUtils::PointLerper::move(), quick_test_main_with_setup(), qWait(), and QuickTestResult::wait().

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

◆ 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.

References QEventLoop::AllEvents, deadline, QEvent::DeferredDelete, QDeadlineTimer::hasExpired(), QCoreApplication::instance(), QDeadlineTimer::isForever(), Qt::PreciseTimer, QCoreApplication::processEvents(), Q_ASSERT, qSleep(), QDeadlineTimer::remainingTimeAsDuration(), and QCoreApplication::sendPostedEvents().

+ Here is the call graph for this function:

◆ qWaitFor() [1/2]

template<typename Functor >
template< typename Functor > bool QTest::qWaitFor ( Functor predicate,
int timeout )
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.

References Qt::PreciseTimer, predicate, and qWaitFor().

+ Here is the call graph for this function:

◆ qWaitFor() [2/2]

template<typename Functor >
template< typename Functor > bool QTest::qWaitFor ( Functor predicate,
QDeadlineTimer deadline = QDeadlineTimer(std::chrono::seconds{5}) )
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:

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.

Referenced by PlatformQuirks::isClipboardAvailable(), qWaitFor(), QQuickTest::qWaitForPolish(), QQuickTest::qWaitForPolish(), qWaitForSignal(), qWaitForWidgetWindow(), qWaitForWindowActive(), qWaitForWindowExposed(), qWaitForWindowFocused(), and startup().

+ Here is the caller graph for this function:

◆ qWaitForWindowActive() [1/2]

Q_WIDGETS_EXPORT bool QTest::qWaitForWindowActive ( QWidget * widget,
int timeout = 5000 )
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.

References QGuiApplicationPrivate::platformIntegration(), Q_UNLIKELY, qWaitForWidgetWindow(), qWaitForWindowExposed(), qWarning, widget, window(), QWidget::window(), and QPlatformIntegration::WindowActivation.

+ Here is the call graph for this function:

◆ qWaitForWindowActive() [2/2]

QT_BEGIN_NAMESPACE Q_GUI_EXPORT bool QTest::qWaitForWindowActive ( QWindow * window,
int timeout = 5000 )
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 34 of file qtestsupport_gui.cpp.

References QGuiApplicationPrivate::platformIntegration(), Q_UNLIKELY, qWaitFor(), qWaitForWindowExposed(), qWarning, window(), and QPlatformIntegration::WindowActivation.

Referenced by quick_test_main_with_setup(), and QQuickDialogTestUtils::DialogTestHelper< DialogType, QuickDialogType >::waitForWindowActive().

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

◆ qWaitForWindowExposed() [1/2]

Q_WIDGETS_EXPORT bool QTest::qWaitForWindowExposed ( QWidget * widget,
int timeout = 5000 )
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.

References qWaitForWidgetWindow(), widget, window(), and QWidget::window().

+ Here is the call graph for this function:

◆ qWaitForWindowExposed() [2/2]

Q_GUI_EXPORT bool QTest::qWaitForWindowExposed ( QWindow * window,
int timeout = 5000 )
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 82 of file qtestsupport_gui.cpp.

References qWaitFor(), and window().

Referenced by quick_test_main_with_setup(), qWaitForWindowActive(), qWaitForWindowActive(), and QQuickTest::showView().

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

◆ qWaitForWindowFocused() [1/2]

Q_WIDGETS_EXPORT bool QTest::qWaitForWindowFocused ( QWidget * widget,
QDeadlineTimer timeout = std::chrono::seconds{5} )
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.

References qGuiApp, qWaitForWidgetWindow(), widget, window(), and QWidget::window().

+ Here is the call graph for this function:

◆ qWaitForWindowFocused() [2/2]

Q_GUI_EXPORT bool QTest::qWaitForWindowFocused ( QWindow * window,
QDeadlineTimer timeout = std::chrono::seconds{5} )
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 63 of file qtestsupport_gui.cpp.

References qGuiApp, qWaitFor(), and window().

+ Here is the call graph for this function:

◆ reportResult()

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

Referenced by qCompareOp().

+ Here is the caller graph for this function:

◆ resetFailed()

static void QTest::resetFailed ( )
static

Definition at line 46 of file qtestresult.cpp.

References setFailed().

Referenced by QTestResult::finishedCurrentTestDataCleanup(), QTestResult::finishedCurrentTestFunction(), QTestResult::reset(), QTestResult::setCurrentTestData(), and QTestResult::setCurrentTestFunction().

+ Here is the call graph for this function:
+ Here is the caller 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 2720 of file qtestcase.cpp.

References inTestFunction.

Referenced by QTestEventLoop::enterLoop().

+ Here is the caller graph for this function:

◆ 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.

References sendKeyEvent(), text, and window().

+ Here is the call graph for this function:

◆ 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 Qt::AltModifier, Click, Qt::ControlModifier, QGuiApplication::focusWindow(), Qt::Key_Alt, Qt::Key_Control, Qt::Key_Meta, Qt::Key_Shift, Qt::MetaModifier, Press, ptr(), qApp, qt_sendShortcutOverrideEvent(), QTEST_ASSERT, Release, sendKeyEvent(), Qt::ShiftModifier, Shortcut, simulateEvent(), text, and window().

Referenced by keyEvent(), keyEvent(), sendKeyEvent(), and sendKeyEvent().

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

◆ 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 239 of file qbenchmark.cpp.

References QBenchmarkTestMethodData::current.

◆ setFailed()

static void QTest::setFailed ( bool failed)
static

Definition at line 29 of file qtestresult.cpp.

References QTest::Internal::failed, ok, qEnvironmentVariableIntValue(), qEnvironmentVariableIsSet(), and qTerminate().

Referenced by QTestResult::addFailure(), checkStatement(), and resetFailed().

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

◆ setIterationCount()

void QTest::setIterationCount ( int count)

Definition at line 200 of file qbenchmark.cpp.

References QBenchmarkTestMethodData::current.

◆ setIterationCountHint()

void QTest::setIterationCountHint ( int count)

Definition at line 193 of file qbenchmark.cpp.

References QBenchmarkTestMethodData::current.

◆ setMainSourcePath()

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

Definition at line 2734 of file qtestcase.cpp.

References QFile::decodeName(), file, mainSourcePath, and QFileInfo::setFile().

+ Here is the call graph for this function:

◆ 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.

The default is {false}, unless the \l{Qt Test Environment Variables} {QTEST_THROW_ON_FAIL environment variable} is set.

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 325 of file qtestcase.cpp.

References g_throwOnFail.

Referenced by QTest::ThrowOnFailDisabler::ThrowOnFailDisabler(), QTest::ThrowOnFailEnabler::ThrowOnFailEnabler(), QTest::ThrowOnFailDisabler::~ThrowOnFailDisabler(), QTest::ThrowOnFailEnabler::~ThrowOnFailEnabler(), and qtest_qParseArgs().

+ Here is the caller graph for this function:

◆ 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.

The default is {false}, unless the \l{Qt Test Environment Variables} {QTEST_THROW_ON_SKIP environment variable} is set.

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 352 of file qtestcase.cpp.

References g_throwOnSkip.

Referenced by QTest::ThrowOnSkipDisabler::ThrowOnSkipDisabler(), QTest::ThrowOnSkipEnabler::ThrowOnSkipEnabler(), QTest::ThrowOnSkipDisabler::~ThrowOnSkipDisabler(), QTest::ThrowOnSkipEnabler::~ThrowOnSkipEnabler(), and qtest_qParseArgs().

+ Here is the caller graph for this function:

◆ simulateEvent()

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.

References QEvent::KeyPress, QEvent::KeyRelease, qApp, qt_handleKeyEvent(), text, and window().

Referenced by QQuickVisualTestUtils::MnemonicKeySimulator::press(), QQuickVisualTestUtils::MnemonicKeySimulator::release(), and sendKeyEvent().

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

◆ switch()

QTest::switch ( ch )

Definition at line 1633 of file qtestcase.cpp.

References ch.

◆ tcIncidentType2String()

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

Definition at line 24 of file qteamcitylogger.cpp.

References QAbstractTestLogger::BlacklistedFail, QAbstractTestLogger::BlacklistedPass, QAbstractTestLogger::BlacklistedXFail, QAbstractTestLogger::BlacklistedXPass, QAbstractTestLogger::Fail, QAbstractTestLogger::Pass, QAbstractTestLogger::Skip, QAbstractTestLogger::XFail, and QAbstractTestLogger::XPass.

Referenced by QTeamCityLogger::addIncident().

+ Here is the caller graph for this function:

◆ tcMessageType2String()

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

Definition at line 49 of file qteamcitylogger.cpp.

References QAbstractTestLogger::Info, QAbstractTestLogger::QCritical, QAbstractTestLogger::QDebug, QAbstractTestLogger::QFatal, QAbstractTestLogger::QInfo, QAbstractTestLogger::QWarning, and QAbstractTestLogger::Warn.

Referenced by QTeamCityLogger::addMessage().

+ Here is the caller graph for this function:

◆ testObject()

QObject * QTest::testObject ( )

Definition at line 2727 of file qtestcase.cpp.

References currentTestObject.

Referenced by QTest::TestMethods::invokeTests().

+ Here is the caller graph for this function:

◆ 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 1471 of file qtestcase.cpp.

References at, ba, i, o, qMin(), and qstrdup().

+ Here is the call graph for this function:

◆ 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 1530 of file qtestcase.cpp.

References Q_UNLIKELY.

Referenced by toString().

+ Here is the caller graph for this function:

◆ toPrettyUnicode()

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().

Referenced by toString().

+ Here is the caller graph for this function:

◆ toString() [1/38]

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

Definition at line 3120 of file qtestcase.cpp.

References qstrcpy(), and str.

+ Here is the call graph for this function:

◆ toString() [2/38]

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

◆ toString() [3/38]

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

Definition at line 164 of file qtesttostring.h.

References ba, i, QByteArray::size(), and str.

+ Here is the call graph for this function:

◆ toString() [4/38]

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

Definition at line 159 of file qtesttostring.h.

References ba, QByteArray::constData(), QByteArray::size(), and toPrettyCString().

+ Here is the call graph for this function:

◆ toString() [5/38]

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

Definition at line 442 of file qtesttostring.h.

References QTest::Internal::QCborValueFormatter::format().

+ Here is the call graph for this function:

◆ toString() [6/38]

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

Definition at line 197 of file qtesttostring.h.

References toString().

+ Here is the call graph for this function:

◆ toString() [7/38]

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

Definition at line 447 of file qtesttostring.h.

References QTest::Internal::QCborValueFormatter::format().

+ Here is the call graph for this function:

◆ toString() [8/38]

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

Definition at line 432 of file qtesttostring.h.

References QTest::Internal::QCborValueFormatter::format().

+ Here is the call graph for this function:

◆ toString() [9/38]

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

Definition at line 437 of file qtesttostring.h.

References QCborValue(), and toString().

+ Here is the call graph for this function:

◆ toString() [10/38]

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

Definition at line 203 of file qtesttostring.h.

References arg, QString::fromLatin1(), QString::number(), qPrintable, qsnprintf(), and qstrdup().

+ Here is the call graph for this function:

◆ toString() [11/38]

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

Definition at line 46 of file qtest_gui.h.

References QColor::HexArgb, and qstrdup().

+ Here is the call graph for this function:

◆ toString() [12/38]

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

Definition at line 396 of file qgeoareamonitorinfo.cpp.

References info, qPrintable, and qstrdup().

+ Here is the call graph for this function:

◆ toString() [13/38]

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

Definition at line 407 of file qgeopositioninfo.cpp.

References info, qPrintable, and qstrdup().

+ Here is the call graph for this function:

◆ toString() [14/38]

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

Definition at line 389 of file qgeosatelliteinfo.cpp.

References info, qPrintable, and qstrdup().

+ Here is the call graph for this function:

◆ toString() [15/38]

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

Definition at line 154 of file qtesttostring.h.

References str, and toString().

+ Here is the call graph for this function:

◆ toString() [16/38]

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

Definition at line 303 of file qtesttostring.h.

References QPartialOrdering::Equivalent, QPartialOrdering::Greater, QPartialOrdering::Less, o, qstrdup(), and QPartialOrdering::Unordered.

+ Here is the call graph for this function:

◆ toString() [17/38]

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

Definition at line 223 of file qtesttostring.h.

References qsnprintf(), and qstrdup().

+ Here is the call graph for this function:

◆ toString() [18/38]

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

Definition at line 245 of file qtesttostring.h.

References qsnprintf(), and qstrdup().

+ Here is the call graph for this function:

◆ toString() [19/38]

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

Definition at line 237 of file qtesttostring.h.

References qsnprintf(), and qstrdup().

+ Here is the call graph for this function:

◆ toString() [20/38]

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

Definition at line 259 of file qtesttostring.h.

References qsnprintf(), and qstrdup().

+ Here is the call graph for this function:

◆ toString() [21/38]

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

Definition at line 51 of file qtest_gui.h.

References QRegion::begin(), i, QRegion::isEmpty(), QRegion::isNull(), QByteArray::number(), qstrdup(), and QRegion::rectCount().

+ Here is the call graph for this function:

◆ toString() [22/38]

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

Definition at line 230 of file qtesttostring.h.

References qsnprintf(), and qstrdup().

+ Here is the call graph for this function:

◆ toString() [23/38]

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

Definition at line 252 of file qtesttostring.h.

References qsnprintf(), and qstrdup().

+ Here is the call graph for this function:

◆ toString() [24/38]

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

Definition at line 149 of file qtesttostring.h.

References str, and toString().

+ Here is the call graph for this function:

◆ toString() [25/38]

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

Definition at line 144 of file qtesttostring.h.

References str, and toPrettyUnicode().

+ Here is the call graph for this function:

◆ toString() [26/38]

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

Definition at line 267 of file qtesttostring.h.

References QByteArray::constData(), QUrl::errorString(), QUrl::isValid(), qPrintable, qstrdup(), and QUrl::toEncoded().

+ Here is the call graph for this function:

◆ toString() [27/38]

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

Definition at line 274 of file qtesttostring.h.

References QByteArray::constData(), qstrdup(), and QUuid::toByteArray().

+ Here is the call graph for this function:

◆ toString() [28/38]

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

Definition at line 279 of file qtesttostring.h.

References QByteArray::number(), and qstrdup().

+ Here is the call graph for this function:

◆ toString() [29/38]

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

Definition at line 85 of file qtest_gui.h.

References QByteArray::number(), and qstrdup().

+ Here is the call graph for this function:

◆ toString() [30/38]

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

Definition at line 93 of file qtest_gui.h.

References QByteArray::number(), and qstrdup().

+ Here is the call graph for this function:

◆ toString() [31/38]

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

Definition at line 101 of file qtest_gui.h.

References QByteArray::number(), and qstrdup().

+ Here is the call graph for this function:

◆ toString() [32/38]

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

Definition at line 466 of file qtesttostring.h.

References formatString(), and toString().

+ Here is the call graph for this function:

◆ toString() [33/38]

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

Definition at line 486 of file qtesttostring.h.

References tupleToString().

+ Here is the call graph for this function:

◆ toString() [34/38]

template<typename T , Internal::is_suitable_type_v< T > = true>
char * QTest::toString ( const T & t)
inline

Definition at line 108 of file qtesttostring.h.

References QTest::Internal::toString().

+ Here is the call graph for this function:

◆ toString() [35/38]

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

Definition at line 3142 of file qtestcase.cpp.

References className, o, qPrintable, qsnprintf(), and qstrdup().

+ Here is the call graph for this function:

◆ toString() [36/38]

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

Definition at line 3133 of file qtestcase.cpp.

References qsnprintf().

+ Here is the call graph for this function:

◆ toString() [37/38]

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

Definition at line 452 of file qtesttostring.h.

References d, qSetRealNumberPrecision(), and qstrdup().

+ Here is the call graph for this function:

◆ toString() [38/38]

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

Definition at line 491 of file qtesttostring.h.

References toString().

+ Here is the call graph for this function:

◆ toString< QHostAddress >()

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

Definition at line 32 of file qtest_network.h.

References QAbstractSocket::AnyIPProtocol, QAbstractSocket::IPv4Protocol, QAbstractSocket::IPv6Protocol, qstrdup(), toString(), and QAbstractSocket::UnknownNetworkLayerProtocol.

+ Here is the call graph for this function:

◆ touchEvent()

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

Definition at line 42 of file qtesttouch.h.

Referenced by QQuickTest::pointerMove(), QQuickTest::pointerPress(), QQuickTest::pointerRelease(), and processTouchEvent().

+ Here is the caller graph for this function:

◆ tupleToString()

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

Definition at line 474 of file qtesttostring.h.

References formatString(), get(), and toString().

Referenced by toString().

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

◆ 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 42 of file qtestwheel.h.

References global, QSize::height(), QPoint::isNull(), pos, qApp, qt_handleWheelEvent(), QTEST_ASSERT, qWarning, QSize::width(), and window().

+ Here is the call graph for this function:

◆ xmlIncidentType2String()

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

Definition at line 41 of file qxmltestlogger.cpp.

References QAbstractTestLogger::BlacklistedFail, QAbstractTestLogger::BlacklistedPass, QAbstractTestLogger::BlacklistedXFail, QAbstractTestLogger::BlacklistedXPass, QAbstractTestLogger::Fail, QAbstractTestLogger::Pass, QAbstractTestLogger::Skip, QAbstractTestLogger::XFail, and QAbstractTestLogger::XPass.

Referenced by QXmlTestLogger::addIncident().

+ Here is the caller graph for this function:

◆ xmlMessageType2String()

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

Definition at line 20 of file qxmltestlogger.cpp.

References QAbstractTestLogger::Info, QAbstractTestLogger::QCritical, QAbstractTestLogger::QDebug, QAbstractTestLogger::QFatal, QAbstractTestLogger::QInfo, QAbstractTestLogger::QWarning, and QAbstractTestLogger::Warn.

Referenced by QXmlTestLogger::addMessage().

+ Here is the caller graph for this function:

Variable Documentation

◆ blacklistCurrentTest

◆ blacklists

int QTest::blacklists = 0

◆ currentGlobalTestData

◆ currentTestData

◆ currentTestFunc

◆ currentTestObject

QObject* QTest::currentTestObject = nullptr
static

Definition at line 369 of file qtestcase.cpp.

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

◆ currentTestObjectName

const char* QTest::currentTestObjectName = nullptr
static

◆ []

◆ entries

const QBenchmarkMetricKey QTest::entries[]
static

Definition at line 17 of file qbenchmarkmetric.cpp.

Referenced by benchmarkMetricName(), and benchmarkMetricUnit().

◆ eventDelay

int QTest::eventDelay = -1
static

Definition at line 431 of file qtestcase.cpp.

Referenced by defaultEventDelay(), and qtest_qParseArgs().

◆ expectFailComment

const char* QTest::expectFailComment = nullptr
static

◆ expectFailMode

◆ failOnWarningList

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

◆ fails

int QTest::fails = 0

◆ g_throwOnFail

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

Definition at line 198 of file qtestcase.cpp.

Referenced by QTest::Internal::maybeThrowOnFail(), and setThrowOnFail().

◆ g_throwOnSkip

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

Definition at line 199 of file qtestcase.cpp.

Referenced by QTest::Internal::maybeThrowOnSkip(), and setThrowOnSkip().

◆ ignoreClassesMutex

Q_CONSTINIT QBasicMutex QTest::ignoreClassesMutex
static

◆ ignoreLevel

Q_CONSTINIT thread_local int QTest::ignoreLevel = 0

◆ ignoreResultList

◆ iLevel

Q_CONSTINIT thread_local int QTest::iLevel = 0

◆ installedTestCoverage

bool QTest::installedTestCoverage = true
static

◆ inTestFunction

bool QTest::inTestFunction = false
static

Definition at line 371 of file qtestcase.cpp.

Referenced by runningTest().

◆ keyDelay

int QTest::keyDelay = -1
static

Definition at line 429 of file qtestcase.cpp.

Referenced by defaultKeyDelay(), and qtest_qParseArgs().

◆ lastMouseTimestamp

Q_TESTLIB_EXPORT int QTest::lastMouseTimestamp = 0

◆ mainSourcePath

QString QTest::mainSourcePath
static

Definition at line 370 of file qtestcase.cpp.

Referenced by qFindTestData(), and setMainSourcePath().

◆ maxWarnings

int QTest::maxWarnings = 2002
static

Definition at line 149 of file qtestlog.cpp.

Referenced by messageHandler(), and QTestLog::setMaxWarnings().

◆ mouseDelay

int QTest::mouseDelay = -1
static

Definition at line 430 of file qtestcase.cpp.

Referenced by defaultMouseDelay(), and qtest_qParseArgs().

◆ mouseDoubleClickInterval

const int QTest::mouseDoubleClickInterval = 500
static

Definition at line 49 of file qtestmouse.h.

Referenced by mouseEvent().

◆ mutex

◆ NumEntries

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

Definition at line 50 of file qbenchmarkmetric.cpp.

Referenced by benchmarkMetricName(), and benchmarkMetricUnit().

◆ oldMessageHandler

QtMessageHandler QTest::oldMessageHandler
static

Definition at line 152 of file qtestlog.cpp.

Referenced by messageHandler(), QTestLog::startLogging(), and QTestLog::stopLogging().

◆ passes

int QTest::passes = 0

Definition at line 78 of file qtestlog.cpp.

Referenced by QTestLog::addPass(), QTestLog::passCount(), and QTestLog::resetCounters().

◆ PrettyUnicodeMaxIncrement

constexpr qsizetype QTest::PrettyUnicodeMaxIncrement
constexpr
Initial value:
= sizeof(R"(\uXXXX"...)"); // includes NUL
static char *writePrettyUnicodeChar(char16_t ch, char * const buffer)
{
auto dst = buffer;
auto first = [&](int n) { Q_ASSERT(dst - buffer == n); return dst; };
if (ch < 0x7f && ch >= 0x20 && ch != '\\' && ch != '"') {
*dst++ = ch;
return first(1);
}
*dst++ = '\\'
GLenum GLuint buffer
GLenum GLenum dst
GLint first
GLfloat n
#define Q_ASSERT(cond)
Definition qrandom.cpp:47

Definition at line 1620 of file qtestcase.cpp.

Referenced by toPrettyUnicode().

◆ PrettyUnicodeMaxOutputSize

constexpr qsizetype QTest::PrettyUnicodeMaxOutputSize = 256
constexpr

Definition at line 1618 of file qtestcase.cpp.

Referenced by toPrettyUnicode().

◆ printAvailableFunctions

Q_TESTLIB_EXPORT bool QTest::printAvailableFunctions = false

◆ repeatForever

bool QTest::repeatForever = false
static

Definition at line 436 of file qtestcase.cpp.

Referenced by qRun(), and qtest_qParseArgs().

◆ repetitions

int QTest::repetitions = 1
static

Definition at line 435 of file qtestcase.cpp.

Referenced by qRun(), and qtest_qParseArgs().

◆ skipBlacklisted

bool QTest::skipBlacklisted = false
static

Definition at line 437 of file qtestcase.cpp.

Referenced by qtest_qParseArgs().

◆ skipCurrentTest

bool QTest::skipCurrentTest = false
static

◆ skips

int QTest::skips = 0

Definition at line 79 of file qtestlog.cpp.

Referenced by QTestLog::addSkip(), QTestLog::resetCounters(), and QTestLog::skipCount().

◆ testFunctions

Q_TESTLIB_EXPORT QStringList QTest::testFunctions

◆ testTags

Q_TESTLIB_EXPORT QStringList QTest::testTags

◆ verbosity

int QTest::verbosity = 0
static

Definition at line 148 of file qtestlog.cpp.

Referenced by QTestLog::setVerboseLevel(), and QTestLog::verboseLevel().