summaryrefslogtreecommitdiffstats
path: root/src/testlib
diff options
context:
space:
mode:
Diffstat (limited to 'src/testlib')
-rw-r--r--src/testlib/doc/qttestlib.qdocconf3
-rw-r--r--src/testlib/doc/src/qttest.qdoc1
-rw-r--r--src/testlib/doc/src/qttestlib-manual.qdoc3
-rw-r--r--src/testlib/qabstracttestlogger.cpp10
-rw-r--r--src/testlib/qtestcase.cpp35
-rw-r--r--src/testlib/qtestresult.cpp8
6 files changed, 44 insertions, 16 deletions
diff --git a/src/testlib/doc/qttestlib.qdocconf b/src/testlib/doc/qttestlib.qdocconf
index 2eea4f246a..ab2bdc1948 100644
--- a/src/testlib/doc/qttestlib.qdocconf
+++ b/src/testlib/doc/qttestlib.qdocconf
@@ -40,3 +40,6 @@ exampledirs += ../../../examples/qtestlib \
excludedirs += ../../../examples/widgets/doc
imagedirs += images
+
+navigation.landingpage = "Qt Test"
+navigation.cppclassespage = "Qt Test C++ Classes"
diff --git a/src/testlib/doc/src/qttest.qdoc b/src/testlib/doc/src/qttest.qdoc
index 6e0bd3c070..c9e1683f83 100644
--- a/src/testlib/doc/src/qttest.qdoc
+++ b/src/testlib/doc/src/qttest.qdoc
@@ -29,6 +29,7 @@
\module QtTest
\title Qt Test C++ Classes
\ingroup modules
+ \qtvariable testlib
\keyword QtTest
diff --git a/src/testlib/doc/src/qttestlib-manual.qdoc b/src/testlib/doc/src/qttestlib-manual.qdoc
index c44bb49ae3..613d2c220c 100644
--- a/src/testlib/doc/src/qttestlib-manual.qdoc
+++ b/src/testlib/doc/src/qttestlib-manual.qdoc
@@ -247,6 +247,9 @@
2000.
\li \c -nocrashhandler \br
Disables the crash handler on Unix platforms.
+ On Windows, it re-enables the Windows Error Reporting dialog, which is
+ turned off by default.
+
\li \c -platform \e name \br
This command line argument applies to all Qt applications, but might be
especially useful in the context of auto-testing. By using the "offscreen"
diff --git a/src/testlib/qabstracttestlogger.cpp b/src/testlib/qabstracttestlogger.cpp
index d039c3c342..41f8f37872 100644
--- a/src/testlib/qabstracttestlogger.cpp
+++ b/src/testlib/qabstracttestlogger.cpp
@@ -52,6 +52,10 @@
#include <unistd.h>
#endif
+#ifdef Q_OS_ANDROID
+#include <sys/stat.h>
+#endif
+
QT_BEGIN_NAMESPACE
QAbstractTestLogger::QAbstractTestLogger(const char *filename)
@@ -69,6 +73,12 @@ QAbstractTestLogger::QAbstractTestLogger(const char *filename)
fprintf(stderr, "Unable to open file for logging: %s\n", filename);
::exit(1);
}
+#ifdef Q_OS_ANDROID
+ else {
+ // Make sure output is world-readable on Android
+ ::chmod(filename, 0666);
+ }
+#endif
}
QAbstractTestLogger::~QAbstractTestLogger()
diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp
index 77a59d0cf0..5d5a976201 100644
--- a/src/testlib/qtestcase.cpp
+++ b/src/testlib/qtestcase.cpp
@@ -1130,9 +1130,7 @@ namespace QTest
static int keyDelay = -1;
static int mouseDelay = -1;
static int eventDelay = -1;
-#if defined(Q_OS_UNIX)
static bool noCrashHandler = false;
-#endif
/*! \internal
Invoke a method of the object without generating warning if the method does not exist
@@ -1335,9 +1333,7 @@ Q_TESTLIB_EXPORT void qtest_qParseArgs(int argc, char *argv[], bool qml)
" -mousedelay ms : Set default delay for mouse simulation to ms milliseconds\n"
" -maxwarnings n : Sets the maximum amount of messages to output.\n"
" 0 means unlimited, default: 2000\n"
-#if defined(Q_OS_UNIX)
" -nocrashhandler : Disables the crash handler\n"
-#endif
"\n"
" Benchmarking options:\n"
#ifdef QTESTLIB_USE_VALGRIND
@@ -1468,10 +1464,8 @@ Q_TESTLIB_EXPORT void qtest_qParseArgs(int argc, char *argv[], bool qml)
} else {
QTestLog::setMaxWarnings(qToInt(argv[++i]));
}
-#if defined(Q_OS_UNIX)
} else if (strcmp(argv[i], "-nocrashhandler") == 0) {
QTest::noCrashHandler = true;
-#endif
#ifdef QTESTLIB_USE_VALGRIND
} else if (strcmp(argv[i], "-callgrind") == 0) {
if (QBenchmarkValgrindUtils::haveValgrind())
@@ -2083,6 +2077,18 @@ FatalSignalHandler::~FatalSignalHandler()
} // namespace
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
+static LONG WINAPI windowsFaultHandler(struct _EXCEPTION_POINTERS *exInfo)
+{
+ char appName[MAX_PATH];
+ if (!GetModuleFileNameA(NULL, appName, MAX_PATH))
+ appName[0] = 0;
+ fprintf(stderr, "A crash occurred in %s (exception code 0x%lx).",
+ appName, exInfo->ExceptionRecord->ExceptionCode);
+ return EXCEPTION_EXECUTE_HANDLER;
+}
+#endif // Q_OS_WIN) && !Q_OS_WINCE
+
/*!
Executes tests declared in \a testObject. In addition, the private slots
\c{initTestCase()}, \c{cleanupTestCase()}, \c{init()} and \c{cleanup()}
@@ -2138,13 +2144,6 @@ int QTest::qExec(QObject *testObject, int argc, char **argv)
try {
#endif
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
-# if !defined(Q_CC_MINGW)
- _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_DEBUG);
-# endif
- SetErrorMode(SetErrorMode(0) | SEM_NOGPFAULTERRORBOX);
-#endif
-
#if defined(Q_OS_MACX)
if (macNeedsActivate) {
CFStringRef reasonForActivity= CFSTR("No Display Sleep");
@@ -2170,6 +2169,16 @@ int QTest::qExec(QObject *testObject, int argc, char **argv)
qtest_qParseArgs(argc, argv, false);
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
+ if (!noCrashHandler) {
+# ifndef Q_CC_MINGW
+ _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_DEBUG);
+# endif
+ SetErrorMode(SetErrorMode(0) | SEM_NOGPFAULTERRORBOX);
+ SetUnhandledExceptionFilter(windowsFaultHandler);
+ } // !noCrashHandler
+#endif // Q_OS_WIN) && !Q_OS_WINCE
+
#ifdef QTESTLIB_USE_VALGRIND
if (QBenchmarkGlobalData::current->mode() == QBenchmarkGlobalData::CallgrindParentProcess) {
const QStringList origAppArgs(QCoreApplication::arguments());
diff --git a/src/testlib/qtestresult.cpp b/src/testlib/qtestresult.cpp
index a6a8ee0cc1..7ab317f209 100644
--- a/src/testlib/qtestresult.cpp
+++ b/src/testlib/qtestresult.cpp
@@ -268,10 +268,12 @@ bool QTestResult::compare(bool success, const char *failureMsg,
if (success && QTest::expectFailMode) {
qsnprintf(msg, 1024, "QCOMPARE(%s, %s) returned TRUE unexpectedly.", actual, expected);
} else if (val1 || val2) {
- qsnprintf(msg, 1024, "%s\n Actual (%s): %s\n Expected (%s): %s",
+ size_t len1 = strlen(actual);
+ size_t len2 = strlen(expected);
+ qsnprintf(msg, 1024, "%s\n Actual (%s)%*s %s\n Expected (%s)%*s %s",
failureMsg,
- actual, val1 ? val1 : "<null>",
- expected, val2 ? val2 : "<null>");
+ actual, qMax(len1, len2) - len1 + 1, ":", val1 ? val1 : "<null>",
+ expected, qMax(len1, len2) - len2 + 1, ":", val2 ? val2 : "<null>");
} else
qsnprintf(msg, 1024, "%s", failureMsg);