42 #include "QtTest/qtestcase.h" 43 #include "QtTest/qtestassert.h" 45 #include <QtCore/qbytearray.h> 46 #include <QtCore/qmetaobject.h> 47 #include <QtCore/qobject.h> 48 #include <QtCore/qstringlist.h> 49 #include <QtCore/qvector.h> 50 #include <QtCore/qvarlengtharray.h> 51 #include <QtCore/qcoreapplication.h> 52 #include <QtCore/qfile.h> 53 #include <QtCore/qfileinfo.h> 54 #include <QtCore/qdir.h> 55 #include <QtCore/qprocess.h> 56 #include <QtCore/qdebug.h> 58 #include "QtTest/private/qtestlog_p.h" 59 #include "QtTest/private/qtesttable_p.h" 60 #include "QtTest/qtestdata.h" 61 #include "QtTest/private/qtestresult_p.h" 62 #include "QtTest/private/qsignaldumper_p.h" 63 #include "QtTest/private/qbenchmark_p.h" 80 #include <Carbon/Carbon.h> 81 #ifdef QT_MAC_USE_COCOA 82 #include <IOKit/pwr_mgt/IOPMLib.h> 84 #include <Security/AuthSession.h> 945 #if defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN) 953 if (((*idx < 0x20 && *idx !=
'\n' && *idx !=
'\t') || *idx > 0x7e))
966 va_start(ap, format);
969 str[size - 1] =
'\0';
983 if (funcIndex >= 0) {
991 if (keyVerbose == -1) {
994 return keyVerbose == 1;
999 if (eventDelay == -1) {
1000 if (
qgetenv(
"QTEST_EVENT_DELAY").constData())
1001 eventDelay = atoi(
qgetenv(
"QTEST_EVENT_DELAY"));
1010 if (mouseDelay == -1) {
1011 if (
qgetenv(
"QTEST_MOUSEEVENT_DELAY").constData())
1012 mouseDelay = atoi((
qgetenv(
"QTEST_MOUSEEVENT_DELAY")));
1021 if (keyDelay == -1) {
1022 if (
qgetenv(
"QTEST_KEYEVENT_DELAY").constData())
1023 keyDelay = atoi(
qgetenv(
"QTEST_KEYEVENT_DELAY").constData());
1032 static bool randomSeeded =
false;
1033 if (!randomSeeded) {
1040 randomSeeded =
true;
1050 template<
typename T>
1051 void swap(T * array,
int pos,
int otherPos)
1054 array[pos] = array[otherPos];
1055 array[otherPos] = tmp;
1058 template<
typename T>
1061 for (
int i = 0; i != size; i++) {
1062 int pos =
qrand() % size;
1063 swap(array, pos, i);
1076 if (sig[len - 2] !=
'(' || sig[len - 1] !=
')')
1078 if (len > 7 && strcmp(sig + (len - 7),
"_data()") == 0)
1080 if (strcmp(sig,
"initTestCase()") == 0 || strcmp(sig,
"cleanupTestCase()") == 0
1081 || strcmp(sig,
"cleanup()") == 0 || strcmp(sig,
"init()") == 0)
1110 for (
int i = 0; i < currTestMetaObj->
methodCount(); ++i) {
1118 slot[strlen(slot) - 2] =
'\0';
1121 for (
int j = 0; j < table.
dataCount(); ++j)
1126 if (localTags.
count() == 0) {
1128 printf(
"%s %s\n", currTestMetaObj->
className(), slot);
1131 for (
int k = 0; k < localTags.
size(); ++k)
1137 for (
int j = 0; j < gTable->
dataCount(); ++j) {
1138 if (localTags.
count() == 0) {
1141 "%s %s __global__ %s\n",
1146 for (
int k = 0; k < localTags.
size(); ++k)
1148 "%s %s %s __global__ %s\n", currTestMetaObj->
className(), slot,
1162 int l = (int)strtol(str, &pEnd, 10);
1164 printf(
"Invalid numeric parameter: '%s'\n", str);
1172 const char *testOptions =
1174 " -functions : Returns a list of current testfunctions\n" 1175 " -datatags : Returns a list of current data tags.\n" 1176 " A global data tag is preceded by ' __global__ '.\n" 1177 " -xunitxml : Outputs results as XML XUnit document\n" 1178 " -xml : Outputs results as XML document\n" 1179 " -lightxml : Outputs results as stream of XML tags\n" 1180 " -flush : Flushes the results\n" 1181 " -o filename: Writes all output into a file\n" 1182 " -silent : Only outputs warnings and failures\n" 1183 " -v1 : Print enter messages for each testfunction\n" 1184 " -v2 : Also print out each QVERIFY/QCOMPARE/QTEST\n" 1185 " -vs : Print every signal emitted\n" 1186 " -random : Run testcases within each test in random order\n" 1187 " -seed n : Positive integer to be used as seed for -random. If not specified,\n" 1188 " the current time will be used as seed.\n" 1189 " -eventdelay ms : Set default delay for mouse and keyboard simulation to ms milliseconds\n" 1190 " -keydelay ms : Set default delay for keyboard simulation to ms milliseconds\n" 1191 " -mousedelay ms : Set default delay for mouse simulation to ms milliseconds\n" 1192 " -keyevent-verbose : Turn on verbose messages for keyboard simulation\n" 1193 " -maxwarnings n : Sets the maximum amount of messages to output.\n" 1194 " 0 means unlimited, default: 2000\n" 1195 #if defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN) 1196 " -nocrashhandler : Disables the crash handler\n" 1199 " Benchmark related options:\n" 1200 #ifdef QTESTLIB_USE_VALGRIND 1201 " -callgrind : Use callgrind to time benchmarks\n" 1203 #ifdef HAVE_TICK_COUNTER 1204 " -tickcounter : Use CPU tick counters to time benchmarks\n" 1206 " -eventcounter : Counts events received during benchmarks\n" 1207 " -minimumvalue n : Sets the minimum acceptable measurement value\n" 1208 " -iterations n : Sets the number of accumulation iterations.\n" 1209 " -median n : Sets the number of median iterations.\n" 1210 " -vb : Print out verbose benchmarking information.\n" 1212 " -help : This help\n";
1214 for (
int i = 1; i < argc; ++i) {
1215 if (strcmp(argv[i],
"-help") == 0 || strcmp(argv[i],
"--help") == 0
1216 || strcmp(argv[i],
"/?") == 0) {
1217 printf(
" Usage: %s [options] [testfunction[:testdata]]...\n" 1218 " By default, all testfunctions will be run.\n\n" 1219 "%s", argv[0], testOptions);
1221 }
else if (strcmp(argv[i],
"-functions") == 0) {
1228 }
else if (strcmp(argv[i],
"-datatags") == 0) {
1234 }
else if(strcmp(argv[i],
"-xunitxml") == 0){
1236 }
else if (strcmp(argv[i],
"-xml") == 0) {
1238 }
else if (strcmp(argv[i],
"-lightxml") == 0) {
1240 }
else if(strcmp(argv[i],
"-flush") == 0){
1242 }
else if (strcmp(argv[i],
"-silent") == 0) {
1244 }
else if (strcmp(argv[i],
"-v1") == 0) {
1246 }
else if (strcmp(argv[i],
"-v2") == 0) {
1248 }
else if (strcmp(argv[i],
"-vs") == 0) {
1250 }
else if (strcmp(argv[i],
"-o") == 0) {
1251 if (i + 1 >= argc) {
1252 printf(
"-o needs an extra parameter specifying the filename\n");
1257 }
else if (strcmp(argv[i],
"-eventdelay") == 0) {
1258 if (i + 1 >= argc) {
1259 printf(
"-eventdelay needs an extra parameter to indicate the delay(ms)\n");
1264 }
else if (strcmp(argv[i],
"-keydelay") == 0) {
1265 if (i + 1 >= argc) {
1266 printf(
"-keydelay needs an extra parameter to indicate the delay(ms)\n");
1271 }
else if (strcmp(argv[i],
"-mousedelay") == 0) {
1272 if (i + 1 >= argc) {
1273 printf(
"-mousedelay needs an extra parameter to indicate the delay(ms)\n");
1278 }
else if (strcmp(argv[i],
"-maxwarnings") == 0) {
1279 if (i + 1 >= argc) {
1280 printf(
"-maxwarnings needs an extra parameter with the amount of warnings\n");
1285 #if defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN) 1286 }
else if (strcmp(argv[i],
"-nocrashhandler") == 0) {
1289 }
else if (strcmp(argv[i],
"-keyevent-verbose") == 0) {
1291 #ifdef QTESTLIB_USE_VALGRIND 1292 }
else if (strcmp(argv[i],
"-callgrind") == 0) {
1297 printf(
"WARNING: Current directory not writable. Using the walltime measurer.\n");
1300 printf(
"WARNING: Valgrind not found or too old. Make sure it is installed and in your path. " 1301 "Using the walltime measurer.\n");
1303 }
else if (strcmp(argv[i],
"-callgrindchild") == 0) {
1308 #ifdef HAVE_TICK_COUNTER 1309 }
else if (strcmp(argv[i],
"-tickcounter") == 0) {
1312 }
else if (strcmp(argv[i],
"-eventcounter") == 0) {
1314 }
else if (strcmp(argv[i],
"-random") == 0) {
1316 }
else if (strcmp(argv[i],
"-seed") == 0) {
1317 bool argumentOk =
false;
1320 long longSeed = strtol(argv[++i], &endpt, 10);
1321 argumentOk = (*endpt ==
'\0' && longSeed >= 0);
1325 printf(
"-seed needs an extra positive integer parameter to specify the seed\n");
1330 }
else if (strcmp(argv[i],
"-minimumvalue") == 0) {
1331 if (i + 1 >= argc) {
1332 printf(
"-minimumvalue needs an extra parameter to indicate the minimum time(ms)\n");
1337 }
else if (strcmp(argv[i],
"-iterations") == 0) {
1338 if (i + 1 >= argc) {
1339 printf(
"-iterations needs an extra parameter to indicate the number of iterations\n");
1344 }
else if (strcmp(argv[i],
"-median") == 0) {
1345 if (i + 1 >= argc) {
1346 printf(
"-median needs an extra parameter to indicate the number of median iterations\n");
1352 }
else if (strcmp(argv[i],
"-vb") == 0) {
1354 }
else if (strcmp(argv[i],
"-chart") == 0) {
1355 fprintf(stderr,
"Warning: `-chart' option is not available\n");
1356 }
else if (strcmp(argv[i],
"-qws") == 0) {
1358 }
else if (strcmp(argv[i],
"-graphicssystem") == 0) {
1360 if (i + 1 >= argc) {
1361 printf(
"-graphicssystem needs an extra parameter specifying the graphics system\n");
1366 }
else if (argv[i][0] ==
'-') {
1367 printf(
"Unknown option: '%s'\n\n%s", argv[i], testOptions);
1374 for(offset = 0; *(argv[i]+offset); ++offset) {
1375 if (*(argv[i]+offset) ==
':') {
1376 if (*(argv[i]+offset+1) ==
':') {
1401 char buf[512], *
data=0;
1403 for(off = 0; *(argv[i]+off); ++off) {
1404 if (*(argv[i]+off) ==
':') {
1410 data =
qstrdup(argv[i]+colon+1);
1416 printf(
"Unknown testfunction: '%s'\n", buf);
1417 printf(
"Available testfunctions:\n");
1428 printf(
"-seed requires -random\n");
1435 const int count = container.
count();
1440 return container.
at(0);
1443 qSort(containerCopy);
1445 const int middle = count / 2;
1448 return containerCopy.
at(middle);
1521 && (++i < QBenchmarkGlobalData::current->adjustMedianIterationCount()));
1552 char *slot =
qstrdup(slotName);
1553 slot[strlen(slot) - 2] =
'\0';
1557 const int globalDataCount = gTable->
dataCount();
1558 int curGlobalDataIndex = 0;
1565 if (curGlobalDataIndex == 0) {
1578 bool foundFunction =
false;
1580 int curDataIndex = 0;
1581 const int dataCount = table.
dataCount();
1585 if (
data && !dataCount) {
1590 printf(
"Unknown testdata for function %s: '%s'\n", slotName,
data);
1591 printf(
"Function has no testdata.\n");
1599 foundFunction =
true;
1600 QTestDataSetter s(curDataIndex >= dataCount ? static_cast<QTestData *>(0)
1612 }
while (curDataIndex < dataCount);
1615 if (
data && !foundFunction) {
1616 printf(
"Unknown testdata for function %s: '%s'\n", slotName,
data);
1617 printf(
"Available testdata:\n");
1618 for(
int i = 0; i < table.
dataCount(); ++i)
1624 ++curGlobalDataIndex;
1625 }
while (curGlobalDataIndex < globalDataCount);
1638 QTEST_ASSERT_X(data,
"QTest::fetchData()",
"Test data requested, but no testdata available.");
1643 if (idx == -1 || idx >= data->
dataCount()) {
1644 qFatal(
"QFETCH: Requested testdata '%s' not available, check your _data function.",
1649 qFatal(
"Requested type '%s' does not match available type '%s'.",
1654 return data->
data(idx);
1679 const int maxLen = 50;
1680 const int len =
qMin(maxLen, length);
1683 if(length > maxLen) {
1684 const int size = len * 3 + 4;
1685 result =
new char[size];
1687 char *
const forElipsis = result + size - 5;
1688 forElipsis[0] =
' ';
1689 forElipsis[1] =
'.';
1690 forElipsis[2] =
'.';
1691 forElipsis[3] =
'.';
1692 result[size - 1] =
'\0';
1695 const int size = len * 3;
1696 result =
new char[size];
1697 result[size - 1] =
'\0';
1700 const char toHex[] =
"0123456789ABCDEF";
1705 const char at = ba[i];
1707 result[o] = toHex[(at >> 4) & 0x0F];
1709 result[o] = toHex[at & 0x0F];
1761 for (
int i = 0; i != methodCount; i++)
1762 testMethods[i] = metaObject->
method(i);
1765 for (
int i = 0; i != methodCount; i++) {
1771 delete[] testMethods;
1787 #if defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN) 1795 static void signal(
int);
1801 qFatal(
"Received signal %d", signum);
1802 #if defined(Q_OS_INTEGRITY) 1805 memset(&act, 0,
sizeof(
struct sigaction));
1806 act.sa_handler = SIG_DFL;
1814 sigemptyset(&handledSignals);
1816 const int fatalSignals[] = {
1817 SIGHUP, SIGINT, SIGQUIT, SIGILL, SIGFPE, SIGSEGV, SIGPIPE, SIGTERM, 0 };
1820 memset(&act, 0,
sizeof(act));
1824 #if !defined(Q_OS_INTEGRITY) 1825 act.sa_flags = SA_RESETHAND;
1829 sigemptyset(&act.sa_mask);
1830 for (
int i = 0; fatalSignals[i]; ++i)
1831 sigaddset(&act.sa_mask, fatalSignals[i]);
1835 for (
int i = 0; fatalSignals[i]; ++i) {
1836 sigaction(fatalSignals[i], &act, &oldact);
1842 oldact.sa_flags & SA_SIGINFO ||
1844 oldact.sa_handler != SIG_DFL) {
1849 sigaddset(&handledSignals, fatalSignals[i]);
1859 memset(&act, 0,
sizeof(act));
1860 act.sa_handler = SIG_DFL;
1864 for (
int i = 1; i < 32; ++i) {
1865 if (!sigismember(&handledSignals, i))
1918 #ifdef QTESTLIB_USE_VALGRIND 1919 int callgrindChildExitCode = 0;
1923 bool macNeedsActivate =
qApp && (
qstrcmp(
qApp->metaObject()->className(),
"QApplication") == 0);
1924 #ifdef QT_MAC_USE_COCOA 1925 IOPMAssertionID powerID;
1928 #ifndef QT_NO_EXCEPTIONS 1932 #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) 1940 if (macNeedsActivate) {
1941 ProcessSerialNumber psn = { 0, kCurrentProcess };
1942 SetFrontProcess(&psn);
1943 # ifdef QT_MAC_USE_COCOA 1944 IOReturn ok = IOPMAssertionCreate(kIOPMAssertionTypeNoDisplaySleep, kIOPMAssertionLevelOn, &powerID);
1945 if (ok != kIOReturnSuccess)
1946 macNeedsActivate =
false;
1948 UpdateSystemActivity(1);
1953 #if defined(Q_OS_SYMBIAN) && defined(Q_CC_NOKIAX86) 1978 #ifdef QTESTLIB_USE_VALGRIND 1989 #if defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN) 1997 #ifndef QT_NO_EXCEPTIONS 2006 #ifdef QT_MAC_USE_COCOA 2007 if (macNeedsActivate) {
2008 IOPMAssertionRelease(powerID);
2020 #ifdef QT_MAC_USE_COCOA 2021 if (macNeedsActivate) {
2022 IOPMAssertionRelease(powerID);
2026 #if defined(QTEST_NOEXITCODE) 2030 #ifdef QTESTLIB_USE_VALGRIND 2032 return callgrindChildExitCode;
2050 const int argc = arguments.
count();
2056 for(
int i = 0; i < argc; ++i)
2062 return qExec(testObject, argc, argv.
data());
2074 bool QTest::qVerify(
bool statement,
const char *statementStr,
const char *description,
2075 const char *file,
int line)
2084 const char *file,
int line)
2163 QTEST_ASSERT_X(tbl,
"QTest::addColumn()",
"Cannot add testdata outside of a _data slot.");
2186 QTEST_ASSERT_X(tbl,
"QTest::addColumn()",
"Cannot add testdata outside of a _data slot.");
2188 return *tbl->
newData(dataTag);
2276 struct timespec ts = { ms / 1000, (ms % 1000) * 1000 * 1000 };
2277 nanosleep(&ts, NULL);
2298 const char *actual,
const char *expected,
const char *file,
int line)
2308 const char *file,
int line)
2312 :
compare_helper(
false,
"Compared floats are not the same (fuzzy compare)",
2321 const char *file,
int line)
2325 :
compare_helper(
false,
"Compared doubles are not the same (fuzzy compare)",
2329 #define COMPARE_IMPL2(TYPE, FORMAT) \ 2330 template <> Q_TESTLIB_EXPORT char *QTest::toString<TYPE >(const TYPE &t) \ 2332 char *msg = new char[128]; \ 2333 qt_snprintf(msg, 128, #FORMAT, t); \ 2343 #if defined(Q_OS_WIN) 2361 char *msg =
new char[strlen(str) + 1];
2369 char *msg =
new char[128];
2377 const char *expected,
const char *file,
int line)
static bool rerunThroughCallgrind(const QStringList &origAppArgs, int &exitCode)
static void setMaxWarnings(int max)
static const char * currentTestFunction()
#define COMPARE_IMPL2(TYPE, FORMAT)
Q_CORE_EXPORT QByteArray qgetenv(const char *varName)
static QString outFileBase(qint64 pid=-1)
static QBenchmarkGlobalData * current
void filter_unprintable(char *str)
QTestData * testData(int index) const
Q_CORE_EXPORT char * qstrcpy(char *dst, const char *src)
static TestFunction * testFuncs
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
static void addBenchmarkResult(const QBenchmarkResult &result)
#define QT_END_NAMESPACE
This macro expands to.
static const char * currentAppName
Q_TESTLIB_EXPORT const char * currentTestFunction()
Returns the name of the test function that is currently executed.
char * data()
Returns a pointer to the data stored in the byte array.
static void invokeMethod(QObject *obj, const char *methodName)
Q_TESTLIB_EXPORT QObject * testObject()
Q_TESTLIB_EXPORT void ignoreMessage(QtMsgType type, const char *message)
Ignores messages created by qDebug() or qWarning().
SkipMode
This enum describes the modes for skipping tests during execution of the test data.
static void setCurrentTestLocation(TestLocation loc)
#define at(className, varName)
static QObject * currentTestObject
const char * dataTag() const
static void ignoreMessage(QtMsgType type, const char *msg)
static bool isValidSlot(const QMetaMethod &sl)
static void clearGlobalTestTable()
Q_TESTLIB_EXPORT void * qElementData(const char *elementName, int metaTypeId)
static void setCurrentTestFunction(const char *func)
Q_TESTLIB_EXPORT bool qExpectFail(const char *dataIndex, const char *comment, TestFailMode mode, const char *file, int line)
static Q_DECL_CONSTEXPR bool qFuzzyCompare(double p1, double p2)
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
static void addFailure(const char *message, const char *file, int line)
static void addSkip(const char *message, QTest::SkipMode mode, const char *file, int line)
int count(const T &t) const
Returns the number of occurrences of value in the list.
static void qInvokeTestMethodDataEntry(char *slot)
The QString class provides a Unicode character string.
Q_CORE_EXPORT int qrand()
static QString currentPath()
Returns the absolute path of the application's current directory.
QBenchmarkMeasurerBase * measurer
Q_TESTLIB_EXPORT void addColumnInternal(int id, const char *name)
Q_TESTLIB_EXPORT int qExec(QObject *testObject, int argc=0, char **argv=0)
Executes tests declared in testObject.
The QVector class is a template class that provides a dynamic array.
The QObject class is the base class of all Qt objects.
static void redirectOutput(const char *fileName)
QtMsgType
This enum describes the messages that can be sent to a message handler (QtMsgHandler).
Q_TESTLIB_EXPORT void qFail(const char *statementStr, const char *file, int line)
The QElapsedTimer class provides a fast way to calculate elapsed times.
static void qPrintTestSlots()
QTestData * newData(const char *tag)
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
The QScopedPointer class stores a pointer to a dynamically allocated object, and deletes it upon dest...
static struct QTest::TestFuncCleanup testFuncCleaner
static bool expectFail(const char *dataIndex, const char *comment, QTest::TestFailMode mode, const char *file, int line)
Q_CORE_EXPORT void qDebug(const char *,...)
Q_TESTLIB_EXPORT void * qData(const char *tagName, int typeId)
static char toHex(quint8 c)
static void finishedCurrentTestFunction()
QBenchmarkResult qMedian(const QList< QBenchmarkResult > &container)
void append(const T &t)
Inserts value at the end of the list.
static void warn(const char *msg)
QString callgrindOutFileBase
#define QT_BEGIN_NAMESPACE
This macro expands to.
QTestTable * parent() const
static QTestData * currentTestData()
static bool verify(bool statement, const char *statementStr, const char *extraInfo, const char *file, int line)
static void qPrintDataTags()
static const char * currentAppName()
char * toHexRepresentation(const char *ba, int length)
Returns a pointer to a string that is the string ba represented as a space-separated sequence of hex ...
void set(int function, char *data)
const T & at(int i) const
Returns the item at index position i in the list.
The QStringList class provides a list of strings.
char * toString(const QLatin1String &str)
This is an overloaded member function, provided for convenience. It differs from the above function o...
void append(const T &t)
Inserts value at the end of the vector.
static QTestData * currentGlobalTestData()
Q_CORE_EXPORT int qvsnprintf(char *str, size_t n, const char *fmt, va_list ap)
QByteArray toLatin1() const Q_REQUIRED_RESULT
Returns a Latin-1 representation of the string as a QByteArray.
static bool noCrashHandler
static bool haveValgrind()
int elementTypeId(int index) const
QByteArray toLocal8Bit() const Q_REQUIRED_RESULT
Returns the local 8-bit representation of the string as a QByteArray.
static QTestTable * globalTestTable()
void qSort(RandomAccessIterator start, RandomAccessIterator end)
void reset(T *other=0)
Deletes the existing object it is pointing to if any, and sets its pointer to other.
static void startLogging()
virtual bool needsWarmupIteration()
static void setFlushMode(FlushMode mode)
static bool compare(bool success, const char *msg, const char *file, int line)
const char * constData() const
Returns a pointer to the data stored in the byte array.
int Q_TESTLIB_EXPORT qt_snprintf(char *str, int size, const char *format,...)
Q_TESTLIB_EXPORT bool qCompare< double >(double const &t1, double const &t2, const char *actual, const char *expected, const char *file, int line)
static void stopLogging()
Q_TESTLIB_EXPORT const char * currentDataTag()
Returns the name of the current test data.
void * data(int index) const
static bool qInvokeTestMethod(const char *slotName, const char *data=0)
Call init(), slot_data(), slot(), slot(), slot().
uint qstrlen(const char *str)
Q_CORE_EXPORT void qFatal(const char *,...)
void addColumn(int elementType, const char *elementName)
static void setCurrentGlobalTestData(QTestData *data)
bool Q_TESTLIB_EXPORT defaultKeyVerbose()
void * fetchData(QTestData *data, const char *tagName, int typeId)
Q_TESTLIB_EXPORT void qWarn(const char *message)
static void setCurrentTestData(QTestData *data)
Q_CORE_EXPORT char * qstrdup(const char *)
Q_TESTLIB_EXPORT bool qCompare< float >(float const &t1, float const &t2, const char *actual, const char *expected, const char *file, int line)
int indexOf(const char *elementName) const
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Q_TESTLIB_EXPORT bool printAvailableTags
int sigaction(int, const struct sigaction *, struct sigaction *)
qint64 msecsSinceReference() const
Returns the number of milliseconds between last time this QElapsedTimer object was started and its re...
static int qToInt(char *str)
#define QTEST_ASSERT(cond)
T & last()
Returns a reference to the last item in the vector.
Q_TESTLIB_EXPORT bool qVerify(bool statement, const char *statementStr, const char *description, const char *file, int line)
int size() const
Returns the number of items in the list.
Q_TESTLIB_EXPORT bool printAvailableFunctions
static void setSkipCurrentTest(bool value)
static void setCurrentAppName(const char *appName)
Q_TESTLIB_EXPORT QStringList testTags
static QByteArray methodName(const char *signature, int nameLength)
Makes a deep copy of the first nameLength characters of the given method signature and returns the co...
Q_TESTLIB_EXPORT void qSkip(const char *message, SkipMode mode, const char *file, int line)
static QTestTable * currentTestTable()
TestFailMode
This enum describes the modes for handling an expected failure of the QVERIFY() or QCOMPARE() macros...
#define QTEST_ASSERT_X(cond, where, what)
static const char * currentDataTag()
static bool skipCurrentTest()
Q_TESTLIB_EXPORT bool compare_helper(bool success, const char *msg, const char *file, int line)
int Q_TESTLIB_EXPORT defaultMouseDelay()
int Q_TESTLIB_EXPORT defaultKeyDelay()
static void qInvokeTestMethods(QObject *testObject)
Q_TESTLIB_EXPORT void * qGlobalData(const char *tagName, int typeId)
static QBenchmarkTestMethodData * current
int qstrcmp(const QByteArray &str1, const char *str2)
QBenchmarkContext context
static QStringList arguments()
Returns the list of command-line arguments.
Q_CORE_EXPORT void qsrand(uint seed)
static bool currentTestFailed()
static void setVerboseLevel(int level)
void reserve(int size)
Attempts to allocate memory for at least size elements.
Q_TESTLIB_EXPORT QStringList testFunctions
The QFileInfo class provides system-independent file information.
QImageIOHandler * handler
Q_TESTLIB_EXPORT bool currentTestFailed()
Returns true if the current test function failed, otherwise false.
Q_TESTLIB_EXPORT QTestData & newRow(const char *dataTag)
Appends a new row to the current test data.
Q_TESTLIB_EXPORT bool compare_string_helper(const char *t1, const char *t2, const char *actual, const char *expected, const char *file, int line)
static void setCurrentTestObject(const char *name)
void start()
Starts this timer.
The QTest namespace contains all the functions and declarations that are related to the QTestLib tool...
void swap(T *array, int pos, int otherPos)
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.
static void randomizeList(T *array, int size)
Q_TESTLIB_EXPORT void qtest_qParseArgs(int argc, char *argv[], bool qml)
Q_TESTLIB_EXPORT void qSleep(int ms)
Sleeps for ms milliseconds, blocking execution of the test.
The QList class is a template class that provides lists.
static void setLogMode(LogMode mode)
QTestDataSetter(QTestData *data)