summaryrefslogtreecommitdiff
path: root/src/testlib
diff options
context:
space:
mode:
authorRohan McGovern <rohan.mcgovern@nokia.com>2010-04-16 15:29:08 +1000
committerRohan McGovern <rohan.mcgovern@nokia.com>2010-04-19 17:31:22 +1000
commitcf2996cceb1ee07d8969867981c8caeabf2d35c3 (patch)
treeaa205394766a6c9e979e650f461979252aec61dd /src/testlib
parent47fc8188c76cf4f2d2cec7155c8293c634f6c653 (diff)
downloadqt4-tools-cf2996cceb1ee07d8969867981c8caeabf2d35c3.tar.gz
Fixed DataTag missing from testlib XML in some cases.
Task-number: QTBUG-6320
Diffstat (limited to 'src/testlib')
-rw-r--r--src/testlib/qtestlogger.cpp27
-rw-r--r--src/testlib/qtestlogger_p.h1
-rw-r--r--src/testlib/qtestxmlstreamer.cpp10
3 files changed, 33 insertions, 5 deletions
diff --git a/src/testlib/qtestlogger.cpp b/src/testlib/qtestlogger.cpp
index fa76b9ec3f..4e4bc3c596 100644
--- a/src/testlib/qtestlogger.cpp
+++ b/src/testlib/qtestlogger.cpp
@@ -211,10 +211,7 @@ void QTestLogger::addIncident(IncidentTypes type, const char *description,
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);
}
@@ -277,6 +274,27 @@ void QTestLogger::addBenchmarkResult(const QBenchmarkResult &result)
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);
@@ -318,6 +336,7 @@ void QTestLogger::addMessage(MessageTypes type, const char *message, const char
errorElement->addAttribute(QTest::AI_Type, typeBuf);
errorElement->addAttribute(QTest::AI_Description, message);
+ addTag(errorElement);
if(file)
errorElement->addAttribute(QTest::AI_File, file);
diff --git a/src/testlib/qtestlogger_p.h b/src/testlib/qtestlogger_p.h
index 31f7d55f0d..bb7a3581fb 100644
--- a/src/testlib/qtestlogger_p.h
+++ b/src/testlib/qtestlogger_p.h
@@ -83,6 +83,7 @@ class QTestLogger : public QAbstractTestLogger
void addIncident(IncidentTypes type, const char *description,
const char *file = 0, int line = 0);
void addBenchmarkResult(const QBenchmarkResult &result);
+ void addTag(QTestElement* element);
void addMessage(MessageTypes type, const char *message,
const char *file = 0, int line = 0);
diff --git a/src/testlib/qtestxmlstreamer.cpp b/src/testlib/qtestxmlstreamer.cpp
index a44ea50e18..f63c2216ca 100644
--- a/src/testlib/qtestxmlstreamer.cpp
+++ b/src/testlib/qtestxmlstreamer.cpp
@@ -111,12 +111,20 @@ void QTestXmlStreamer::formatStart(const QTestElement *element, QTestCharBuffer
QXmlTestLogger::xmlQuote(&quotedFile, element->attributeValue(QTest::AI_File));
QXmlTestLogger::xmlCdata(&cdataDesc, element->attributeValue(QTest::AI_Description));
- QTest::qt_asprintf(formatted, "<Message type=\"%s\" %s=\"%s\" %s=\"%s\">\n <Description><![CDATA[%s]]></Description>\n</Message>\n",
+ QTestCharBuffer tagbuf;
+ if (element->attribute(QTest::AI_Tag)) {
+ QTestCharBuffer cdataTag;
+ QXmlTestLogger::xmlCdata(&cdataTag, element->attributeValue(QTest::AI_Tag));
+ QTest::qt_asprintf(&tagbuf, " <DataTag><![CDATA[%s]]></DataTag>\n", cdataTag.constData());
+ }
+
+ QTest::qt_asprintf(formatted, "<Message type=\"%s\" %s=\"%s\" %s=\"%s\">\n%s <Description><![CDATA[%s]]></Description>\n</Message>\n",
element->attributeValue(QTest::AI_Type),
element->attributeName(QTest::AI_File),
quotedFile.constData(),
element->attributeName(QTest::AI_Line),
element->attributeValue(QTest::AI_Line),
+ tagbuf.constData(),
cdataDesc.constData());
break;
}