src/testlib/qtestlogger.cpp
branchRCL_3
changeset 13 c0432d11811c
parent 4 3b1da2848fc7
equal deleted inserted replaced
12:cc75c76972ee 13:c0432d11811c
   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 
   295         ++qdebugCounter;
   313         ++qdebugCounter;
   296         typeBuf = "qdebug";
   314         typeBuf = "qdebug";
   297         break;
   315         break;
   298     case QAbstractTestLogger::QWarning:
   316     case QAbstractTestLogger::QWarning:
   299         ++qwarnCounter;
   317         ++qwarnCounter;
   300         typeBuf = "qwarning";
   318         typeBuf = "qwarn";
   301         break;
   319         break;
   302     case QAbstractTestLogger::QFatal:
   320     case QAbstractTestLogger::QFatal:
   303         ++qfatalCounter;
   321         ++qfatalCounter;
   304         typeBuf = "qfatal";
   322         typeBuf = "qfatal";
   305         break;
   323         break;
   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, "");