aboutsummaryrefslogtreecommitdiffstats
path: root/src/qmltest
diff options
context:
space:
mode:
authorCaroline Chao <caroline.chao@nokia.com>2011-11-29 10:48:21 +0100
committerQt by Nokia <qt-info@nokia.com>2011-12-09 13:08:36 +0100
commit5456784005655ec9277832f0a07beda4e3d0a55f (patch)
treee02322c87741875c1d248286f9cd92aaba0ac318 /src/qmltest
parentf6416183d36a260f3cbf6f89753f8a0ee27df7cc (diff)
Integrate testcocoon support into QtQuickTest.
Add support to install and save coverage data when a test is run using quick_test_main. Change-Id: I39ddd678d748979c335139b3f8bda43b3d05720d Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
Diffstat (limited to 'src/qmltest')
-rw-r--r--src/qmltest/quicktest.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/qmltest/quicktest.cpp b/src/qmltest/quicktest.cpp
index 65107ee717..2f0f7ef9bc 100644
--- a/src/qmltest/quicktest.cpp
+++ b/src/qmltest/quicktest.cpp
@@ -68,6 +68,35 @@
#include <QtCore/QTranslator>
QT_BEGIN_NAMESPACE
+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
+}
+
class QTestRootObject : public QObject
{
@@ -152,6 +181,8 @@ int quick_test_main(int argc, char **argv, const char *name, quick_test_viewport
QuickTestResult::parseArgs(argc, argv);
QuickTestResult::setProgramName(name);
+ installCoverageTool(argv[0], name);
+
QTranslator translator;
if (!translationFile.isEmpty()) {
if (translator.load(translationFile)) {
@@ -313,6 +344,8 @@ int quick_test_main(int argc, char **argv, const char *name, quick_test_viewport
// Flush the current logging stream.
QuickTestResult::setProgramName(0);
+ saveCoverageTool(argv[0], QuickTestResult::exitCode());
+
delete app;
// Return the number of failures as the exit code.
return QuickTestResult::exitCode();