Qt 4.8
Namespaces | Macros | Functions
qtest.h File Reference
#include <QtTest/qtest_global.h>
#include <QtTest/qtestcase.h>
#include <QtTest/qtestdata.h>
#include <QtTest/qbenchmark.h>
#include <QtCore/qbytearray.h>
#include <QtCore/qstring.h>
#include <QtCore/qstringlist.h>
#include <QtCore/qdatetime.h>
#include <QtCore/qobject.h>
#include <QtCore/qvariant.h>
#include <QtCore/qurl.h>
#include <QtCore/qpoint.h>
#include <QtCore/qsize.h>
#include <QtCore/qrect.h>
#include <QtTest/qtestsystem.h>
#include <QtTest/qtest_gui.h>

Go to the source code of this file.

Namespaces

 QTest
 The QTest namespace contains all the functions and declarations that are related to the QTestLib tool.
 

Macros

#define QTEST_APPLESS_MAIN(TestObject)
 Implements a main() function that executes all tests in TestClass. More...
 
#define QTEST_MAIN(TestObject)
 Implements a main() function that instantiates an application object and the TestClass, and executes all tests in the order they were defined. More...
 
#define QTEST_NOOP_MAIN
 Implements a main() function with a test class that does absolutely nothing. More...
 

Functions

template<>
bool QTest::qCompare (QString const &t1, QLatin1String const &t2, const char *actual, const char *expected, const char *file, int line)
 
template<>
bool QTest::qCompare (QLatin1String const &t1, QString const &t2, const char *actual, const char *expected, const char *file, int line)
 
template<>
bool QTest::qCompare (QStringList const &t1, QStringList const &t2, const char *actual, const char *expected, const char *file, int line)
 
template<typename T >
bool QTest::qCompare (QFlags< T > const &t1, T const &t2, const char *actual, const char *expected, const char *file, int line)
 
template<typename T >
bool QTest::qCompare (QFlags< T > const &t1, int const &t2, const char *actual, const char *expected, const char *file, int line)
 
template<>
char * QTest::toString (const QLatin1String &str)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns a textual representation of the given string. More...
 
template<>
char * QTest::toString (const QString &str)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns a textual representation of the given string. More...
 
template<>
char * QTest::toString (const QByteArray &ba)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns a textual representation of the byte array ba. More...
 
template<>
char * QTest::toString (const QTime &time)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns a textual representation of the given time. More...
 
template<>
char * QTest::toString (const QDate &date)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns a textual representation of the given date. More...
 
template<>
char * QTest::toString (const QDateTime &dateTime)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns a textual representation of the date and time specified by dateTime. More...
 
template<>
char * QTest::toString (const QChar &c)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns a textual representation of the given character. More...
 
template<>
char * QTest::toString (const QPoint &p)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns a textual representation of the given point. More...
 
template<>
char * QTest::toString (const QSize &s)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns a textual representation of the given size. More...
 
template<>
char * QTest::toString (const QRect &s)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns a textual representation of the given rectangle. More...
 
template<>
char * QTest::toString (const QPointF &p)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns a textual representation of the given point. More...
 
template<>
char * QTest::toString (const QSizeF &s)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns a textual representation of the given size. More...
 
template<>
char * QTest::toString (const QRectF &s)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns a textual representation of the given rectangle. More...
 
template<>
char * QTest::toString (const QUrl &uri)
 
template<>
char * QTest::toString (const QVariant &v)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns a textual representation of the given variant. More...
 

Macro Definition Documentation

◆ QTEST_APPLESS_MAIN

#define QTEST_APPLESS_MAIN (   TestObject)
Value:
int main(int argc, char *argv[]) \
{ \
TestObject tc; \
return QTest::qExec(&tc, argc, argv); \
}
int main(int argc, char **argv)
Definition: qaxmain.cpp:46
Q_TESTLIB_EXPORT int qExec(QObject *testObject, int argc=0, char **argv=0)
Executes tests declared in testObject.
Definition: qtestcase.cpp:1913

Implements a main() function that executes all tests in TestClass.

Behaves like QTEST_MAIN() , but doesn't instantiate a QApplication object. Use this macro for really simple stand-alone non-GUI tests.

See also
QTEST_MAIN()

◆ QTEST_MAIN

#define QTEST_MAIN (   TestObject)
Value:
int main(int argc, char *argv[]) \
{ \
QCoreApplication app(argc, argv); \
TestObject tc; \
return QTest::qExec(&tc, argc, argv); \
}
int main(int argc, char **argv)
Definition: qaxmain.cpp:46
Q_TESTLIB_EXPORT int qExec(QObject *testObject, int argc=0, char **argv=0)
Executes tests declared in testObject.
Definition: qtestcase.cpp:1913

Implements a main() function that instantiates an application object and the TestClass, and executes all tests in the order they were defined.

Use this macro to build stand-alone executables.

If QT_GUI_LIB is defined, the application object will be a QApplication, otherwise it will be a QCoreApplication. If qmake is used and the configuration includes QT += gui, then QT_GUI_LIB will be defined automatically.

Note: On platforms that have keypad navigation enabled by default (eg: Symbian), this macro will forcfully disable it to simplify the usage of key events when writing autotests. If you wish to write a test case that uses keypad navigation, you should enable it either in the {initTestCase()} or {init()} functions of your test case.

Example:

class TestQString: public QObject { ... };
QTEST_MAIN(TestQString)
See also
QTEST_APPLESS_MAIN(), QTest::qExec(), QApplication::setNavigationMode()

◆ QTEST_NOOP_MAIN

#define QTEST_NOOP_MAIN
Value:
int main(int argc, char *argv[]) \
{ \
QObject tc; \
return QTest::qExec(&tc, argc, argv); \
}
int main(int argc, char **argv)
Definition: qaxmain.cpp:46
Q_TESTLIB_EXPORT int qExec(QObject *testObject, int argc=0, char **argv=0)
Executes tests declared in testObject.
Definition: qtestcase.cpp:1913

Implements a main() function with a test class that does absolutely nothing.

Use this macro to create a test that produces valid test output but just doesn't execute any test, for example in conditional compilations:

#ifdef Q_WS_X11
QTEST_MAIN(MyX11Test)
#else
// do nothing on non-X11 platforms
#endif
See also
QTEST_MAIN()