diff --git a/src/testlib/qtest.h b/src/testlib/qtest.h index e671828b77d..66e747a2ac5 100644 --- a/src/testlib/qtest.h +++ b/src/testlib/qtest.h @@ -290,6 +290,14 @@ int main(int argc, char *argv[]) \ #endif // QT_GUI_LIB +#define QTEST_GUILESS_MAIN(TestObject) \ +int main(int argc, char *argv[]) \ +{ \ + QCoreApplication app(argc, argv); \ + TestObject tc; \ + return QTest::qExec(&tc, argc, argv); \ +} + QT_END_HEADER #endif diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp index b49d5c2aa56..d4703b7b3dc 100644 --- a/src/testlib/qtestcase.cpp +++ b/src/testlib/qtestcase.cpp @@ -314,7 +314,8 @@ QT_BEGIN_NAMESPACE Example: \snippet doc/src/snippets/code/src_qtestlib_qtestcase.cpp 11 - \sa QTEST_APPLESS_MAIN(), QTest::qExec(), QApplication::setNavigationMode() + \sa QTEST_APPLESS_MAIN(), QTEST_GUILESS_MAIN(), QTest::qExec(), + QApplication::setNavigationMode() */ /*! \macro QTEST_APPLESS_MAIN(TestClass) @@ -342,6 +343,21 @@ QT_BEGIN_NAMESPACE \sa QTEST_MAIN() */ +/*! \macro QTEST_GUILESS_MAIN(TestClass) + + \relates QTest + + Implements a main() function that instantiates a QCoreApplication object + and the \a TestClass, and executes all tests in the order they were + defined. Use this macro to build stand-alone executables. + + Behaves like \l QTEST_MAIN(), but instantiates a QCoreApplication instead + of the QApplication object. Use this macro if your test case doesn't need + functionality offered by QApplication, but the event loop is still necessary. + + \sa QTEST_MAIN() +*/ + /*! \macro QBENCHMARK