summaryrefslogtreecommitdiffstats
path: root/src/testlib
diff options
context:
space:
mode:
Diffstat (limited to 'src/testlib')
-rw-r--r--src/testlib/qtestcase.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp
index 4e0205ccbc..f01c588e6d 100644
--- a/src/testlib/qtestcase.cpp
+++ b/src/testlib/qtestcase.cpp
@@ -857,6 +857,35 @@ QT_BEGIN_NAMESPACE
QTouchEventSequence is called (ie when the object returned runs out of scope).
*/
+static void installCoverageTool(const char * appname, const char * testname)
+{
+#ifdef __COVERAGESCANNER__
+ // Install Coverage Tool
+ __coveragescanner_install(appname);
+ __coveragescanner_testname(testname);
+ __coveragescanner_clear();
+#else
+ Q_UNUSED(appname);
+ Q_UNUSED(testname);
+#endif
+}
+
+static void saveCoverageTool(const char * appname, bool testfailed)
+{
+#ifdef __COVERAGESCANNER__
+ // install again to make sure the filename is correct.
+ // without this, a plugin or similar may have changed the filename.
+ __coveragescanner_install(appname);
+ __coveragescanner_teststate(testfailed ? "FAILED" : "PASSED");
+ __coveragescanner_save();
+ __coveragescanner_testname("");
+ __coveragescanner_clear();
+#else
+ Q_UNUSED(appname);
+ Q_UNUSED(testfailed);
+#endif
+}
+
namespace QTest
{
static QObject *currentTestObject = 0;
@@ -1904,6 +1933,8 @@ int QTest::qExec(QObject *testObject, int argc, char **argv)
const QMetaObject *metaObject = testObject->metaObject();
QTEST_ASSERT(metaObject);
+ installCoverageTool(argv[0], metaObject->className());
+
QTestResult::setCurrentTestObject(metaObject->className());
qtest_qParseArgs(argc, argv, false);
#ifdef QTESTLIB_USE_VALGRIND
@@ -1954,6 +1985,8 @@ int QTest::qExec(QObject *testObject, int argc, char **argv)
}
#endif
+ saveCoverageTool(argv[0], QTestResult::failCount());
+
#ifdef QTESTLIB_USE_VALGRIND
if (QBenchmarkGlobalData::current->mode() == QBenchmarkGlobalData::CallgrindParentProcess)
return callgrindChildExitCode;