src/testlib/qtestlogger.cpp
branchGCC_SURGE
changeset 31 5daf16870df6
parent 30 5dc02b23752f
--- a/src/testlib/qtestlogger.cpp	Mon Jun 21 22:38:13 2010 +0100
+++ b/src/testlib/qtestlogger.cpp	Thu Jul 22 16:41:55 2010 +0100
@@ -211,10 +211,7 @@
         QTest::qt_snprintf(buf, sizeof(buf), "%i", line);
         failureElement->addAttribute(QTest::AI_Line, buf);
         failureElement->addAttribute(QTest::AI_Description, description);
-        const char* tag = QTestResult::currentDataTag();
-        if (tag) {
-            failureElement->addAttribute(QTest::AI_Tag, tag);
-        }
+        addTag(failureElement);
         currentLogElement->addLogElement(failureElement);
     }
 
@@ -267,7 +264,9 @@
     QTestElement *benchmarkElement = new QTestElement(QTest::LET_Benchmark);
 //    printf("element %i", benchmarkElement->elementType());
 
-    benchmarkElement->addAttribute(QTest::AI_Metric, QBenchmarkGlobalData::current->measurer->metricText().toAscii().data());
+    benchmarkElement->addAttribute(
+        QTest::AI_Metric,
+        QTest::benchmarkMetricName(QBenchmarkTestMethodData::current->result.metric));
     benchmarkElement->addAttribute(QTest::AI_Tag, result.context.tag.toAscii().data());
     benchmarkElement->addAttribute(QTest::AI_Value, QByteArray::number(result.value).constData());
 
@@ -277,6 +276,27 @@
     currentLogElement->addLogElement(benchmarkElement);
 }
 
+void QTestLogger::addTag(QTestElement* element)
+{
+    const char *tag = QTestResult::currentDataTag();
+    const char *gtag = QTestResult::currentGlobalDataTag();
+    const char *filler = (tag && gtag) ? ":" : "";
+    if ((!tag || !tag[0]) && (!gtag || !gtag[0])) {
+        return;
+    }
+
+    if (!tag) {
+        tag = "";
+    }
+    if (!gtag) {
+        gtag = "";
+    }
+
+    QTestCharBuffer buf;
+    QTest::qt_asprintf(&buf, "%s%s%s", gtag, filler, tag);
+    element->addAttribute(QTest::AI_Tag, buf.constData());
+}
+
 void QTestLogger::addMessage(MessageTypes type, const char *message, const char *file, int line)
 {
     QTestElement *errorElement = new QTestElement(QTest::LET_Error);
@@ -297,7 +317,7 @@
         break;
     case QAbstractTestLogger::QWarning:
         ++qwarnCounter;
-        typeBuf = "qwarning";
+        typeBuf = "qwarn";
         break;
     case QAbstractTestLogger::QFatal:
         ++qfatalCounter;
@@ -318,6 +338,7 @@
 
     errorElement->addAttribute(QTest::AI_Type, typeBuf);
     errorElement->addAttribute(QTest::AI_Description, message);
+    addTag(errorElement);
 
     if(file)
         errorElement->addAttribute(QTest::AI_File, file);