209 else |
209 else |
210 failureElement->addAttribute(QTest::AI_File, ""); |
210 failureElement->addAttribute(QTest::AI_File, ""); |
211 QTest::qt_snprintf(buf, sizeof(buf), "%i", line); |
211 QTest::qt_snprintf(buf, sizeof(buf), "%i", line); |
212 failureElement->addAttribute(QTest::AI_Line, buf); |
212 failureElement->addAttribute(QTest::AI_Line, buf); |
213 failureElement->addAttribute(QTest::AI_Description, description); |
213 failureElement->addAttribute(QTest::AI_Description, description); |
214 const char* tag = QTestResult::currentDataTag(); |
214 addTag(failureElement); |
215 if (tag) { |
|
216 failureElement->addAttribute(QTest::AI_Tag, tag); |
|
217 } |
|
218 currentLogElement->addLogElement(failureElement); |
215 currentLogElement->addLogElement(failureElement); |
219 } |
216 } |
220 |
217 |
221 /* |
218 /* |
222 Only one result can be shown for the whole testfunction. |
219 Only one result can be shown for the whole testfunction. |
275 QTest::qt_snprintf(buf, sizeof(buf), "%i", result.iterations); |
272 QTest::qt_snprintf(buf, sizeof(buf), "%i", result.iterations); |
276 benchmarkElement->addAttribute(QTest::AI_Iterations, buf); |
273 benchmarkElement->addAttribute(QTest::AI_Iterations, buf); |
277 currentLogElement->addLogElement(benchmarkElement); |
274 currentLogElement->addLogElement(benchmarkElement); |
278 } |
275 } |
279 |
276 |
|
277 void QTestLogger::addTag(QTestElement* element) |
|
278 { |
|
279 const char *tag = QTestResult::currentDataTag(); |
|
280 const char *gtag = QTestResult::currentGlobalDataTag(); |
|
281 const char *filler = (tag && gtag) ? ":" : ""; |
|
282 if ((!tag || !tag[0]) && (!gtag || !gtag[0])) { |
|
283 return; |
|
284 } |
|
285 |
|
286 if (!tag) { |
|
287 tag = ""; |
|
288 } |
|
289 if (!gtag) { |
|
290 gtag = ""; |
|
291 } |
|
292 |
|
293 QTestCharBuffer buf; |
|
294 QTest::qt_asprintf(&buf, "%s%s%s", gtag, filler, tag); |
|
295 element->addAttribute(QTest::AI_Tag, buf.constData()); |
|
296 } |
|
297 |
280 void QTestLogger::addMessage(MessageTypes type, const char *message, const char *file, int line) |
298 void QTestLogger::addMessage(MessageTypes type, const char *message, const char *file, int line) |
281 { |
299 { |
282 QTestElement *errorElement = new QTestElement(QTest::LET_Error); |
300 QTestElement *errorElement = new QTestElement(QTest::LET_Error); |
283 const char *typeBuf = 0; |
301 const char *typeBuf = 0; |
284 |
302 |
316 break; |
334 break; |
317 } |
335 } |
318 |
336 |
319 errorElement->addAttribute(QTest::AI_Type, typeBuf); |
337 errorElement->addAttribute(QTest::AI_Type, typeBuf); |
320 errorElement->addAttribute(QTest::AI_Description, message); |
338 errorElement->addAttribute(QTest::AI_Description, message); |
|
339 addTag(errorElement); |
321 |
340 |
322 if(file) |
341 if(file) |
323 errorElement->addAttribute(QTest::AI_File, file); |
342 errorElement->addAttribute(QTest::AI_File, file); |
324 else |
343 else |
325 errorElement->addAttribute(QTest::AI_File, ""); |
344 errorElement->addAttribute(QTest::AI_File, ""); |