testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/utils/src/teftestreport.cpp
changeset 2 8bb370ba6d1d
equal deleted inserted replaced
1:bbd31066657e 2:8bb370ba6d1d
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 * 
       
    14 * Description: This module contains implementation of CTEFTestReport 
       
    15 * class member functions.
       
    16 *
       
    17 */
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include <e32svr.h>
       
    21 #include <f32file.h>
       
    22 #include <hal.h>
       
    23 #include "teftestreport.h"
       
    24 
       
    25 
       
    26 // EXTERNAL DATA STRUCTURES
       
    27 // None
       
    28 
       
    29 // EXTERNAL FUNCTION PROTOTYPES  
       
    30 // None
       
    31 
       
    32 // CONSTANTS
       
    33 // None
       
    34 
       
    35 // MACROS
       
    36 const TInt KMaxLenEol = 6;
       
    37 const TInt KMaxReportData = 256;
       
    38 typedef TBuf<KMaxReportData> TPrintInfo;
       
    39 const TInt KSummaryLineEndLen = 12;
       
    40 _LIT( KSummaryLineEnd,  "            ");
       
    41 
       
    42 // XML Tags (alphabetically)
       
    43 _LIT(KXMLCaseNumberTag,          "<CaseNumber>");
       
    44 _LIT(KXMLCaseNumberTagEnd,       "</CaseNumber>");
       
    45 _LIT(KXMLCaseTitleTag,           "<Title>");
       
    46 _LIT(KXMLCaseTitleTagEnd,        "</Title>");
       
    47 _LIT(KXMLConfigFileTag,          "<Config>");
       
    48 _LIT(KXMLConfigFileTagEnd,       "</Config>");
       
    49 _LIT(KXMLCpuSpeedTag,            "<CPUSpeed>");
       
    50 _LIT(KXMLCpuSpeedTagEnd,         "</CPUSpeed>");
       
    51 _LIT(KXMLCpuTag,                 "<CPU>");
       
    52 _LIT(KXMLCpuTagEnd,              "</CPU>");
       
    53 _LIT(KXMLCrashedTag,             "<Crashed>");
       
    54 _LIT(KXMLCrashedTagEnd,          "</Crashed>");
       
    55 _LIT(KXMLDateTag,                "<Date>");
       
    56 _LIT(KXMLDateTagEnd,             "</Date>");
       
    57 _LIT(KXMLDllSummaryTag,          "<Dlls>");
       
    58 _LIT(KXMLDllSummaryTagEnd,       "</Dlls>");
       
    59 _LIT(KXMLDllTag,                 "<Dll>");
       
    60 _LIT(KXMLDllTagEnd,              "</Dll>");
       
    61 _LIT(KXMLEndTimeTag,             "<EndTime>");
       
    62 _LIT(KXMLEndTimeTagEnd,          "</EndTime>");
       
    63 _LIT(KXMLEnvironmentInfoTag,     "<EnvironmentInfo>");
       
    64 _LIT(KXMLEnvironmentInfoTagEnd,  "</EnvironmentInfo>");
       
    65 _LIT(KXMLExecutionResultTag,     "<ExecutionResultCode>");
       
    66 _LIT(KXMLExecutionResultTagEnd,  "</ExecutionResultCode>");
       
    67 _LIT(KXMLFailedTag,              "<Failed>");
       
    68 _LIT(KXMLFailedTagEnd,           "</Failed>");
       
    69 _LIT(KXMLFileNameTag,            "<FileName>");
       
    70 _LIT(KXMLFileNameTagEnd,         "</FileName>");
       
    71 _LIT(KXMLHardwareInfoTag,        "<HardwareInfo>");
       
    72 _LIT(KXMLHardwareInfoTagEnd,     "</HardwareInfo>");
       
    73 _LIT(KXMLHwRevisionTag,          "<HwRevision>");
       
    74 _LIT(KXMLHwRevisionTagEnd,       "</HwRevision>");
       
    75 _LIT(KXMLLanguageTag,            "<Language>");
       
    76 _LIT(KXMLLanguageTagEnd,         "</Language>");
       
    77 _LIT(KXMLMachineUidTag,          "<MachineUID>");
       
    78 _LIT(KXMLMachineUidTagEnd,       "</MachineUID>");
       
    79 _LIT(KXMLManufacturerTag,        "<Manufacturer>");
       
    80 _LIT(KXMLManufacturerTagEnd,     "</Manufacturer>");
       
    81 _LIT(KXMLMemoryInfoTag,          "<MemoryInfo>");
       
    82 _LIT(KXMLMemoryInfoTagEnd,       "</MemoryInfo>");
       
    83 _LIT(KXMLModelTag,               "<Model>");
       
    84 _LIT(KXMLModelTagEnd,            "</Model>");
       
    85 _LIT(KXMLModuleNameTag,          "<ModuleName>");
       
    86 _LIT(KXMLModuleNameTagEnd,       "</ModuleName>");
       
    87 _LIT(KXMLModuleSummaryTag,       "<Modules>");
       
    88 _LIT(KXMLModuleSummaryTagEnd,    "</Modules>");
       
    89 _LIT(KXMLModuleTag,              "<Module>");
       
    90 _LIT(KXMLModuleTagEnd,           "</Module>");
       
    91 _LIT(KXMLPassedTag,              "<Passed>");
       
    92 _LIT(KXMLPassedTagEnd,           "</Passed>");
       
    93 _LIT(KXMLRamFreeTag,             "<RAMFree>");
       
    94 _LIT(KXMLRamFreeTagEnd,          "</RAMFree>");
       
    95 _LIT(KXMLRamTag,                 "<RAM>");
       
    96 _LIT(KXMLRamTagEnd,              "</RAM>");
       
    97 _LIT(KXMLResultDescrTag,         "<ResultDescription>");
       
    98 _LIT(KXMLResultDescrTagEnd,      "</ResultDescription>");
       
    99 _LIT(KXMLResultTag,              "<Result>");
       
   100 _LIT(KXMLResultTagEnd,           "</Result>");
       
   101 _LIT(KXMLSoftwareInfoTag,        "<SoftwareInfo>");
       
   102 _LIT(KXMLSoftwareInfoTagEnd,     "</SoftwareInfo>");
       
   103 _LIT(KXMLStartTimeTag,           "<StartTime>");
       
   104 _LIT(KXMLStartTimeTagEnd,        "</StartTime>");
       
   105 _LIT(KXMLSwBuildTag,             "<SwBuild>");
       
   106 _LIT(KXMLSwBuildTagEnd,          "</SwBuild>");
       
   107 _LIT(KXMLSwRevisionTag,          "<SwRevision>");
       
   108 _LIT(KXMLSwRevisionTagEnd,       "</SwRevision>");
       
   109 _LIT(KXMLTestCasesSummaryTag,    "<TestCasesSummary>");
       
   110 _LIT(KXMLTestCasesSummaryTagEnd, "</TestCasesSummary>");
       
   111 _LIT(KXMLTestCasesTag,           "<TestCases>");
       
   112 _LIT(KXMLTestCasesTagEnd,        "</TestCases>");
       
   113 _LIT(KXMLTestCaseTag,            "<TestCase>");
       
   114 _LIT(KXMLTestCaseTagEnd,         "</TestCase>");
       
   115 _LIT(KXMLTestReportTag,          "<TestReport>");
       
   116 _LIT(KXMLTestReportTagEnd,       "</TestReport>");
       
   117 _LIT(KXMLTestResultTag,          "<ResultCode>");
       
   118 _LIT(KXMLTestResultTagEnd,       "</ResultCode>");
       
   119 _LIT(KXMLTimeoutedTag,           "<Timeout>");
       
   120 _LIT(KXMLTimeoutedTagEnd,        "</Timeout>");
       
   121 _LIT(KXMLTimeTag,                "<Time>");
       
   122 _LIT(KXMLTimeTagEnd,             "</Time>");
       
   123 _LIT(KXMLTotalTag,               "<Total>");
       
   124 _LIT(KXMLTotalTagEnd,            "</Total>");
       
   125 _LIT(KXMLVersionTag,             "<Version>");
       
   126 _LIT(KXMLVersionTagEnd,          "</Version>");
       
   127 
       
   128 // LOCAL CONSTANTS AND MACROS
       
   129 // None
       
   130 
       
   131 // MODULE DATA STRUCTURES
       
   132 // None
       
   133 
       
   134 // LOCAL FUNCTION PROTOTYPES
       
   135 // None
       
   136 
       
   137 // FORWARD DECLARATIONS
       
   138 // None
       
   139 
       
   140 // ==================== LOCAL FUNCTIONS =======================================
       
   141 // None
       
   142 
       
   143 // ================= MEMBER FUNCTIONS =========================================
       
   144 
       
   145 /*
       
   146 -------------------------------------------------------------------------------
       
   147 
       
   148     Class: CTEFTestReport
       
   149 
       
   150     Method: CTEFTestReport
       
   151 
       
   152     Description: Default constructor
       
   153 
       
   154     C++ default constructor can NOT contain any code, that
       
   155     might leave.
       
   156 
       
   157     Parameters: const TTestReportMode aReportMode: in: Report mode
       
   158 
       
   159     Return Values: None
       
   160 
       
   161     Errors/Exceptions: None
       
   162 
       
   163     Status: Approved
       
   164 
       
   165 -------------------------------------------------------------------------------
       
   166 */
       
   167 CTEFTestReport::CTEFTestReport( const TTestReportMode aReportMode ):
       
   168     iReportMode( aReportMode ) 
       
   169     {
       
   170     iXML = EFalse;
       
   171     iReportHWInfo = TTestHWInfo();
       
   172 
       
   173     }
       
   174 
       
   175 /*
       
   176 -------------------------------------------------------------------------------
       
   177 
       
   178     Class: CTEFTestReport
       
   179 
       
   180     Method: ConstructL
       
   181 
       
   182     Description: Symbian OS second phase constructor
       
   183 
       
   184     Symbian OS default constructor can leave.
       
   185 
       
   186     Parameters: CTEFTestReportSettings& aTestReportSettings: in: Report settings
       
   187 
       
   188     Return Values: None
       
   189 
       
   190     Errors/Exceptions: Leaves if memory allocation for iTotalSummary fails
       
   191 
       
   192     Status: Approved
       
   193 
       
   194 -------------------------------------------------------------------------------
       
   195 */
       
   196 void CTEFTestReport::ConstructL( TTEFTestReportSettings& aTestReportSettings )
       
   197     {
       
   198     // Create summary for all test cases
       
   199     _LIT( KName, "All test cases" );
       
   200     iTotalSummary = new ( ELeave ) TTestSummary( KName() );
       
   201 
       
   202     User::LeaveIfError( iFs.Connect() );
       
   203     
       
   204     TPtrC path;
       
   205     path.Set( aTestReportSettings.iPath->Des() );
       
   206     TPtrC name;
       
   207     name.Set( aTestReportSettings.iName->Des() );
       
   208 
       
   209     iFormat = aTestReportSettings.iFormat;
       
   210     iOutput = aTestReportSettings.iOutput;
       
   211     iXML = aTestReportSettings.iXML;
       
   212     
       
   213     // XML format can be used only when report is of txt file type.
       
   214     if(iFormat != ETEFTestReportLoggerType_Txt && iOutput != ETEFTestReportOutput_File && iXML)
       
   215         {
       
   216         RDebug::Print(_L("Stif: XML report is available only when TestReportFormat is TXT and TestReportOutput is FILE"));
       
   217         iXML = EFalse;
       
   218         }
       
   219     
       
   220     if( iOutput == ETEFTestReportOutput_File )
       
   221         {
       
   222         iFs.MkDirAll( path );
       
   223         
       
   224         HBufC* pathAndFileBuf = HBufC::NewLC( path.Length() + name.Length() + 5 );
       
   225         TPtr pathAndFile(pathAndFileBuf->Des() );
       
   226         pathAndFile.Append( path );
       
   227         pathAndFile.Append( name );
       
   228 
       
   229         if(iXML)
       
   230             {
       
   231             pathAndFile.Append( _L(".xml") );
       
   232             }
       
   233         else
       
   234             {
       
   235             if( ( iFormat == ETEFTestReportLoggerType_Html ) && 
       
   236                 ( iOutput == ETEFTestReportOutput_File ) )
       
   237                 {
       
   238                 pathAndFile.Append( _L(".html") );
       
   239                 }
       
   240             else 
       
   241                 {
       
   242                 pathAndFile.Append( _L(".txt") );
       
   243                 }
       
   244             }
       
   245         
       
   246         if( aTestReportSettings.iOverwrite )
       
   247             {
       
   248             User::LeaveIfError( iFile.Replace( iFs, 
       
   249                            pathAndFile,
       
   250                            EFileWrite | EFileStreamText | EFileShareAny ) );
       
   251             }
       
   252         else
       
   253             {
       
   254             TInt fileOpen = iFile.Open( iFs, 
       
   255                                         pathAndFile, 
       
   256                                         EFileWrite | EFileStreamText | EFileShareAny );
       
   257             if( fileOpen == KErrNotFound )
       
   258                 {
       
   259                 User::LeaveIfError( 
       
   260                     iFile.Create( iFs, 
       
   261                                   pathAndFile, 
       
   262                                   EFileWrite | EFileStreamText | EFileShareExclusive ) );
       
   263                 }
       
   264             else if( fileOpen == KErrNone )
       
   265                 {
       
   266                 TInt endPosOfFile = 0;
       
   267                 User::LeaveIfError( iFile.Seek( ESeekEnd, endPosOfFile ) );
       
   268                 }
       
   269             else
       
   270                 {
       
   271                 User::Leave( fileOpen );
       
   272                 }
       
   273             }
       
   274        
       
   275         CleanupStack::PopAndDestroy( pathAndFileBuf );
       
   276         }
       
   277             
       
   278     WriteHeaderL();
       
   279     
       
   280     // Add temporarily closing tags to keep valid xml structure
       
   281     CloseXMLTagsInUnfinishedFileL();
       
   282     }
       
   283 
       
   284 /*
       
   285 -------------------------------------------------------------------------------
       
   286 
       
   287     Class: CTEFTestReport
       
   288 
       
   289     Method: NewL
       
   290 
       
   291     Description: Two-phased constructor.
       
   292 
       
   293     Parameters: CTEFTestReportSettings& aTestReportSettings: in: Report settings
       
   294                 const TTestReportMode aReportMode: in: Report mode
       
   295     
       
   296     Return Values: CTEFTestReport* : pointer to created object
       
   297 
       
   298     Errors/Exceptions: Leaves if memory allocation for object fails
       
   299                        Leaves if ConstructL leaves
       
   300 
       
   301     Status: Approved
       
   302 
       
   303 -------------------------------------------------------------------------------
       
   304 */
       
   305 CTEFTestReport* CTEFTestReport::NewL( TTEFTestReportSettings& aTestReportSettings,
       
   306                                 const TTestReportMode aReportMode )
       
   307     {
       
   308     CTEFTestReport* self = new ( ELeave ) CTEFTestReport( aReportMode );
       
   309     CleanupStack::PushL( self );
       
   310     self->ConstructL( aTestReportSettings );
       
   311     CleanupStack::Pop( self );
       
   312     return self;
       
   313 
       
   314     }
       
   315 
       
   316 /*
       
   317 -------------------------------------------------------------------------------
       
   318 
       
   319     Class: CTEFTestReport
       
   320 
       
   321     Method: ~CTEFTestReport
       
   322 
       
   323     Description: Destructor
       
   324 
       
   325     Parameters: None
       
   326 
       
   327     Return Values: None
       
   328 
       
   329     Errors/Exceptions: None
       
   330 
       
   331     Status: Approved
       
   332 
       
   333 -------------------------------------------------------------------------------
       
   334 */
       
   335 CTEFTestReport::~CTEFTestReport()
       
   336     {
       
   337     // Reset and destroy arrays
       
   338     iTestSummaries.ResetAndDestroy();
       
   339     delete iTotalSummary;
       
   340     if( iOutput != ETEFTestReportOutput_RDebug )
       
   341         {
       
   342         // Delete file
       
   343         iFile.Close();
       
   344         iFs.Close();
       
   345         }
       
   346     }
       
   347 
       
   348 /*
       
   349 -------------------------------------------------------------------------------
       
   350 
       
   351     Class: CTEFTestReport
       
   352 
       
   353     Method: AddTestCaseResultL
       
   354 
       
   355     Description: Add new test case result.
       
   356 
       
   357     Parameters: const TTestInfo& aTestInfo: in: TTestInfo: Test info
       
   358                 const TFullTestResult& aTestResult: in: TTestResult: Testresult
       
   359                 const TInt aError: in: Symbian OS error: Additional error code
       
   360 
       
   361     Return Values: None
       
   362 
       
   363     Errors/Exceptions: Leave is iReportGenerated is generated
       
   364                        Leave if summary creation fails
       
   365                        Leave if summary adding fails
       
   366 
       
   367     Status: Approved
       
   368 
       
   369 -------------------------------------------------------------------------------
       
   370 */
       
   371 void CTEFTestReport::AddTestCaseResultL( const TTEFTestInfo& aTestInfo,
       
   372                                         const TTEFFullTestResult& aTestResult,
       
   373                                         const TInt aError )
       
   374     {
       
   375     // Create summary for this test case
       
   376     TTestCaseSummary summary;
       
   377     
       
   378     summary.iTestInfo = aTestInfo;
       
   379     summary.iFullTestResult = aTestResult;
       
   380 
       
   381     TBool passed( EFalse );
       
   382     TBool crashed( EFalse );
       
   383     TBool timeout( EFalse );
       
   384     if( ( aError == KErrNone ) && 
       
   385          ( summary.iFullTestResult.iCaseExecutionResultType == TTEFFullTestResult::ECaseExecuted ) &&
       
   386          ( KErrNone == summary.iFullTestResult.iTestResult.iResult ) )
       
   387         {
       
   388         passed = ETrue;
       
   389         }
       
   390     else if( summary.iFullTestResult.iCaseExecutionResultType == TTEFFullTestResult::ECaseTimeout )
       
   391         {
       
   392         timeout = ETrue;
       
   393         }
       
   394     else if( ( summary.iFullTestResult.iCaseExecutionResultCode != KErrNone )
       
   395             || ( summary.iFullTestResult.iCaseExecutionResultType == TTEFFullTestResult::ECasePanic )
       
   396             || ( summary.iFullTestResult.iCaseExecutionResultType == TTEFFullTestResult::ECaseException ) )
       
   397         {
       
   398         crashed = ETrue;
       
   399         }
       
   400 
       
   401     if ( iReportMode & ETestReportCases )
       
   402         {
       
   403         // Print summary to file
       
   404         if(iXML)
       
   405             {
       
   406             WriteLineL(_L("%S"), &KXMLTestCaseTag);
       
   407             WriteLineL(_L("%S%S%S"), &KXMLModuleNameTag, &summary.iTestInfo.iModuleName, &KXMLModuleNameTagEnd);
       
   408             if(summary.iTestInfo.iConfig != KNullDesC)
       
   409                 {
       
   410                 WriteLineL(_L("%S%S%S"), &KXMLConfigFileTag, &summary.iTestInfo.iConfig, &KXMLConfigFileTagEnd);
       
   411                 }
       
   412             WriteLineL(_L("%S%d%S"), &KXMLCaseNumberTag, summary.iTestInfo.iTestCaseInfo.iCaseNumber, &KXMLCaseNumberTagEnd);
       
   413             WriteLineL(_L("%S%S%S"), &KXMLCaseTitleTag, &summary.iTestInfo.iTestCaseInfo.iTitle, &KXMLCaseTitleTagEnd);
       
   414             }
       
   415         else
       
   416             {
       
   417             WriteLineL( _L("[%S][%S][%d] Title:[%S]"),
       
   418                 &summary.iTestInfo.iModuleName,
       
   419                 &summary.iTestInfo.iConfig,
       
   420                 summary.iTestInfo.iTestCaseInfo.iCaseNumber,
       
   421                 &summary.iTestInfo.iTestCaseInfo.iTitle );
       
   422             }
       
   423 
       
   424         const TInt KTimeFieldLength = 30;
       
   425         TBuf<KTimeFieldLength> startTime;
       
   426         TBuf<KTimeFieldLength> endTime;
       
   427         _LIT(KDateString4,"%-B%:0%J%:1%T%:2%S%.%*C4%:3%+B");
       
   428         summary.iFullTestResult.iStartTime.FormatL(
       
   429             startTime,KDateString4 );
       
   430         summary.iFullTestResult.iEndTime.FormatL(
       
   431             endTime,KDateString4 );
       
   432             
       
   433         // Result description needs max length 0x80(Must be same as
       
   434         // TResultDes length) + specific characters see below.
       
   435         TBuf<KMaxReportData> printBuf2;
       
   436         TInt code = ENoStyle;
       
   437         if( ( summary.iFullTestResult.iCaseExecutionResultType 
       
   438             != TTEFFullTestResult::ECasePanic ) &&
       
   439             ( summary.iFullTestResult.iCaseExecutionResultCode 
       
   440             == KErrNone ) )
       
   441             {
       
   442             printBuf2.AppendFormat( _L("\tResult: %d [%S]"),
       
   443                 summary.iFullTestResult.iTestResult.iResult,
       
   444                 &summary.iFullTestResult.iTestResult.iResultDes );
       
   445 
       
   446             if ( KErrNone == 
       
   447                  summary.iFullTestResult.iTestResult.iResult )
       
   448                 {
       
   449                 printBuf2.AppendFormat( _L(" ==> PASSED"));
       
   450                 }
       
   451             else
       
   452                 {
       
   453                 code = ERed;
       
   454                 printBuf2.AppendFormat( _L(" ==> FAILED"));
       
   455                 }
       
   456             }
       
   457         else
       
   458             {
       
   459             code = ERed;
       
   460             printBuf2.AppendFormat( _L("\tCaseExecutionResult: %S with %d"),
       
   461                 &summary.iFullTestResult.iTestResult.iResultDes,
       
   462                 summary.iFullTestResult.iCaseExecutionResultCode );
       
   463             }
       
   464 
       
   465         if(iXML)
       
   466             {
       
   467             WriteLineL(_L("%S%S%S"), &KXMLStartTimeTag, &startTime, &KXMLStartTimeTagEnd);
       
   468             WriteLineL(_L("%S%S%S"), &KXMLEndTimeTag, &endTime, &KXMLEndTimeTagEnd);
       
   469             WriteLineL(_L("%S%d%S"), &KXMLTestResultTag, summary.iFullTestResult.iTestResult.iResult, &KXMLTestResultTagEnd);
       
   470             WriteLineL(_L("%S%S%S"), &KXMLResultDescrTag, &summary.iFullTestResult.iTestResult.iResultDes, &KXMLResultDescrTagEnd);
       
   471             WriteLineL(_L("%S%d%S"), &KXMLExecutionResultTag, summary.iFullTestResult.iCaseExecutionResultCode, &KXMLExecutionResultTagEnd);
       
   472             }
       
   473         else
       
   474             {
       
   475             WriteLineL( _L("\tStartTime: %S, EndTime: %S"),
       
   476                 &startTime,
       
   477                 &endTime );
       
   478             WriteLineL( printBuf2, code );
       
   479             WriteDelimiterL( _L( "- " ), 10 );
       
   480             WriteLineL( _L( "" ) );
       
   481             }
       
   482         }
       
   483         
       
   484     // Add test summary
       
   485     // Check if the module already exists for this test case
       
   486     TTestSummary* moduleSummary = NULL;
       
   487     TInt count = iTestSummaries.Count();
       
   488     for( TInt i = 0; i < count; i++ )
       
   489         {
       
   490         if ( iTestSummaries[i]->iName == aTestInfo.iModuleName )
       
   491             {
       
   492             moduleSummary = iTestSummaries[i];
       
   493             break;
       
   494             }
       
   495         }
       
   496     
       
   497     if( moduleSummary == NULL )
       
   498         {
       
   499         // Create new module array
       
   500         moduleSummary = new ( ELeave ) TTestSummary( aTestInfo.iModuleName );
       
   501         User::LeaveIfError( iTestSummaries.Append( moduleSummary ) );
       
   502         }
       
   503 
       
   504     if( passed )
       
   505         {
       
   506         moduleSummary->iPassedCases++;
       
   507         iTotalSummary->iPassedCases++;
       
   508         if(iXML && (iReportMode & ETestReportCases))
       
   509             {
       
   510             WriteLineL(_L("%SPASSED%S"), &KXMLResultTag, &KXMLResultTagEnd);
       
   511             }
       
   512         }
       
   513     else if( timeout )
       
   514         {
       
   515         moduleSummary->iTimeoutCases++;
       
   516         iTotalSummary->iTimeoutCases++;
       
   517         if(iXML && (iReportMode & ETestReportCases))
       
   518             {
       
   519             WriteLineL(_L("%STIMEOUT%S"), &KXMLResultTag, &KXMLResultTagEnd);
       
   520             }
       
   521         }
       
   522     else if( crashed ||
       
   523            ( aError != KErrNone ) )
       
   524         {
       
   525         moduleSummary->iCrashedCases++;
       
   526         iTotalSummary->iCrashedCases++;
       
   527         if(iXML && (iReportMode & ETestReportCases))
       
   528             {
       
   529             WriteLineL(_L("%SCRASHED%S"), &KXMLResultTag, &KXMLResultTagEnd);
       
   530             }
       
   531         }
       
   532     else
       
   533         {
       
   534         moduleSummary->iFailedCases++;
       
   535         iTotalSummary->iFailedCases++;
       
   536         if(iXML && (iReportMode & ETestReportCases))
       
   537             {
       
   538             WriteLineL(_L("%SFAILED%S"), &KXMLResultTag, &KXMLResultTagEnd);
       
   539             }
       
   540         }
       
   541 
       
   542     if(iXML && (iReportMode & ETestReportCases))
       
   543         {
       
   544         WriteLineL(_L("%S"), &KXMLTestCaseTagEnd);
       
   545         }
       
   546 
       
   547     // Add temporarily closing tags to keep valid xml structure
       
   548     CloseXMLTagsInUnfinishedFileL();
       
   549     }
       
   550 
       
   551 
       
   552 /*
       
   553 -------------------------------------------------------------------------------
       
   554 
       
   555     Class: CTEFTestReport
       
   556 
       
   557     Method: WriteHeaderL
       
   558 
       
   559     Description: Write test report header.
       
   560 
       
   561     Parameters: None
       
   562 
       
   563     Return Values: None
       
   564 
       
   565     Errors/Exceptions: None
       
   566 
       
   567     Status: Proposal
       
   568 
       
   569 -------------------------------------------------------------------------------
       
   570 */
       
   571 void CTEFTestReport::WriteHeaderL()
       
   572     {
       
   573     if( ( iFormat == ETEFTestReportLoggerType_Html ) && 
       
   574         ( iOutput == ETEFTestReportOutput_File ) )
       
   575         {        
       
   576         // Html start tags to whole page and header section
       
   577         iFile.Write(
       
   578             _L8( "\n<html>\n<head>\n<title>TestReport</title>\n</head>\n\n\n<body>\n" ) );
       
   579         }
       
   580     
       
   581     if(iXML)
       
   582         {
       
   583         WriteLineL(_L("<?xml version=\"1.0\" ?>"));
       
   584         WriteLineL(_L("%S"), &KXMLTestReportTag);            
       
   585         }
       
   586     else
       
   587         {
       
   588         WriteDelimiterL( _L( "***" ), 25 );
       
   589         }
       
   590 
       
   591     // Generate date and time
       
   592     TTime time;
       
   593     time.HomeTime();
       
   594     TBuf<30> date;
       
   595     TBuf<30> clock;
       
   596     // Date
       
   597     _LIT( KDate, "%E%D%X%N%Y %1 %2 %3" );
       
   598     time.FormatL( date, KDate );
       
   599     // Time
       
   600     _LIT( KClock,"%-B%:0%J%:1%T%:2%S%:3%+B" );
       
   601     time.FormatL( clock,KClock );
       
   602     // Add date and time
       
   603     if(iXML)
       
   604         {
       
   605         WriteLineL(_L("%S%S%S"), &KXMLDateTag, &date, &KXMLDateTagEnd);
       
   606         WriteLineL(_L("%S%S%S"), &KXMLTimeTag, &clock, &KXMLTimeTagEnd);
       
   607         }
       
   608     else
       
   609         {
       
   610         WriteLineL( _L( "%S" ), &date );
       
   611         WriteLineL( _L( "%S" ), &clock );
       
   612         }
       
   613     
       
   614     if ( iReportMode & ETestReportSummary )
       
   615         {
       
   616         if( iOutput == ETEFTestReportOutput_File )
       
   617             {
       
   618             // Get current file position
       
   619             iSummaryPos = 0;
       
   620             User::LeaveIfError( iFile.Seek( ESeekCurrent, iSummaryPos ) );
       
   621             }
       
   622         // Generate Summary to Report
       
   623         if(iXML)
       
   624             {
       
   625             WriteLineL(_L("%S"), &KXMLTestCasesSummaryTag);
       
   626             WriteLineL(_L("%S%S%S"), &KXMLPassedTag, &KXMLPassedTagEnd, &KSummaryLineEnd);
       
   627             WriteLineL(_L("%S%S%S"), &KXMLFailedTag, &KXMLFailedTagEnd, &KSummaryLineEnd);
       
   628             WriteLineL(_L("%S%S%S"), &KXMLTimeoutedTag, &KXMLTimeoutedTagEnd, &KSummaryLineEnd);
       
   629             WriteLineL(_L("%S%S%S"), &KXMLCrashedTag, &KXMLCrashedTagEnd, &KSummaryLineEnd);
       
   630             WriteLineL(_L("%S%S%S"), &KXMLTotalTag, &KXMLTotalTagEnd, &KSummaryLineEnd);
       
   631             WriteLineL(_L("%S"), &KXMLTestCasesSummaryTagEnd);
       
   632             }
       
   633         else
       
   634             {
       
   635             WriteDelimiterL( _L( "-- " ), 25 );
       
   636             WriteLineL(_L("SUMMARY:") );
       
   637             WriteLineL(_L("\tPassed cases: %S"), &KSummaryLineEnd );
       
   638             WriteLineL(_L("\tFailed cases: %S"), &KSummaryLineEnd );
       
   639             WriteLineL(_L("\tTimeout cases: %S"), &KSummaryLineEnd );
       
   640             WriteLineL(_L("\tCrashed cases: %S"), &KSummaryLineEnd );
       
   641             WriteLineL(_L("\tTotal cases: %S"), &KSummaryLineEnd );
       
   642             WriteLineL( _L( "" ));
       
   643             }   
       
   644         }
       
   645 
       
   646     if ( iReportMode & ETestReportEnvironment )
       
   647         {
       
   648         const TInt KMegaByte = 1024*1024;
       
   649         if(iXML)
       
   650             {
       
   651             WriteLineL(_L("%S"), &KXMLEnvironmentInfoTag);
       
   652             WriteLineL(_L("%S"), &KXMLHardwareInfoTag);
       
   653             WriteLineL(_L("%S0x%x%S"), &KXMLManufacturerTag, iReportHWInfo.iHwInfo.iManufacturer, &KXMLManufacturerTagEnd);
       
   654             WriteLineL(_L("%S0x%x%S"), &KXMLMachineUidTag, iReportHWInfo.iHwInfo.iMachineUid, &KXMLMachineUidTagEnd);
       
   655             WriteLineL(_L("%S0x%x%S"), &KXMLModelTag, iReportHWInfo.iHwInfo.iModel, &KXMLModelTagEnd);
       
   656             WriteLineL(_L("%S0x%x%S"), &KXMLHwRevisionTag, iReportHWInfo.iHwInfo.iHwRev, &KXMLHwRevisionTagEnd);
       
   657             WriteLineL(_L("%S0x%x%S"), &KXMLCpuTag, iReportHWInfo.iHwInfo.iCpu, &KXMLCpuTagEnd);
       
   658             WriteLineL(_L("%S%d%S"), &KXMLCpuSpeedTag, iReportHWInfo.iHwInfo.iCpuSpeed/1000, &KXMLCpuSpeedTagEnd);
       
   659             WriteLineL(_L("%S%d%S"), &KXMLLanguageTag, iReportHWInfo.iHwInfo.iLanguage, &KXMLLanguageTagEnd);
       
   660             WriteLineL(_L("%S"), &KXMLHardwareInfoTagEnd);
       
   661             WriteLineL(_L("%S"), &KXMLSoftwareInfoTag);
       
   662             WriteLineL(_L("%S0x%x%S"), &KXMLSwRevisionTag, iReportHWInfo.iSwInfo.iSwRev, &KXMLSwRevisionTagEnd);
       
   663             WriteLineL(_L("%S0x%x%S"), &KXMLSwBuildTag, iReportHWInfo.iSwInfo.iSwBuild, &KXMLSwBuildTagEnd);
       
   664             WriteLineL(_L("%S"), &KXMLSoftwareInfoTagEnd);
       
   665             WriteLineL(_L("%S"), &KXMLMemoryInfoTag);
       
   666             WriteLineL(_L("%S%d%S"), &KXMLRamTag, iReportHWInfo.iMemoryInfo.iRAM/KMegaByte, &KXMLRamTagEnd);
       
   667             WriteLineL(_L("%S%d%S"), &KXMLRamFreeTag, iReportHWInfo.iMemoryInfo.iRAMFree/KMegaByte, &KXMLRamFreeTagEnd);
       
   668             WriteLineL(_L("%S"), &KXMLMemoryInfoTagEnd);            
       
   669             WriteLineL(_L("%S"), &KXMLEnvironmentInfoTagEnd);            
       
   670             }
       
   671         else
       
   672             {
       
   673             // HW Info
       
   674             WriteDelimiterL( _L( "-- " ), 25 );
       
   675             WriteLineL( _L("ENVIRONMENT INFO:") );
       
   676             WriteLineL( _L("HW Info:") );
       
   677     
       
   678             WriteLineL(
       
   679                 _L("\tManufacturer: 0x%x, MachineUid: 0x%x, Model: 0x%x "),
       
   680                     iReportHWInfo.iHwInfo.iManufacturer,
       
   681                     iReportHWInfo.iHwInfo.iMachineUid,
       
   682                     iReportHWInfo.iHwInfo.iModel );
       
   683             WriteLineL(
       
   684                 _L("\tHW Rev: 0x%x, CPU: 0x%x, CPU Speed: %d MHz "),
       
   685                     iReportHWInfo.iHwInfo.iHwRev,
       
   686                     iReportHWInfo.iHwInfo.iCpu,
       
   687                     iReportHWInfo.iHwInfo.iCpuSpeed/1000 );
       
   688             WriteLineL(_L("\tLanguage: %d "),
       
   689                 iReportHWInfo.iHwInfo.iLanguage );
       
   690     
       
   691             // SW Info
       
   692             WriteLineL(_L("SW Info:") );
       
   693             WriteLineL(_L("\tSW Rev: 0x%x, SW Build: 0x%x"),
       
   694                 iReportHWInfo.iSwInfo.iSwRev,
       
   695                 iReportHWInfo.iSwInfo.iSwBuild );
       
   696     
       
   697             // Memory Info
       
   698             WriteLineL(_L("Memory Info:") );
       
   699             WriteLineL(_L("\tRAM: %d MB, RAM Free: %d MB"),
       
   700                 ( iReportHWInfo.iMemoryInfo.iRAM/KMegaByte ),
       
   701                 ( iReportHWInfo.iMemoryInfo.iRAMFree/KMegaByte ) );
       
   702     
       
   703             WriteLineL( _L( "" ) );
       
   704             }
       
   705         }
       
   706         
       
   707     if ( iReportMode & ETestReportCases )
       
   708         {
       
   709         if(iXML)
       
   710             {
       
   711             WriteLineL(_L("%S"), &KXMLTestCasesTag);
       
   712             }
       
   713         else
       
   714             {
       
   715             // Generate Test Cases to Report
       
   716             WriteDelimiterL( _L( "-- " ), 25 );
       
   717             WriteLineL( _L("TESTCASE SUMMARY:") );
       
   718             }
       
   719         }
       
   720 
       
   721     if ( iReportMode == ETestReportBlank )
       
   722         {
       
   723         if(!iXML)
       
   724             {
       
   725             WriteLineL( _L( "") );
       
   726             WriteLineL( _L( "'Empty' configuration given in initialization file's [Engine_Defaults] section" ) );
       
   727             WriteLineL( _L( "No test report created" ) );
       
   728             }
       
   729         }
       
   730     }
       
   731 
       
   732 /*
       
   733 -------------------------------------------------------------------------------
       
   734 
       
   735     Class: CTEFTestReport
       
   736 
       
   737     Method: WriteTrailerL
       
   738 
       
   739     Description: Write test report trailer.
       
   740 
       
   741     Parameters: None
       
   742 
       
   743     Return Values: None
       
   744 
       
   745     Errors/Exceptions: None
       
   746 
       
   747     Status: Proposal
       
   748 
       
   749 -------------------------------------------------------------------------------
       
   750 */
       
   751 void CTEFTestReport::WriteTrailerL()
       
   752     {
       
   753     if(iXML && (iReportMode & ETestReportCases))
       
   754         {
       
   755         WriteLineL(_L("%S"), &KXMLTestCasesTagEnd);
       
   756         }
       
   757 
       
   758     if ( iReportMode & ETestReportSummary )
       
   759         {
       
   760         if(iXML)
       
   761             {
       
   762             WriteLineL(_L("%S"), &KXMLModuleSummaryTag);            
       
   763             }
       
   764         else
       
   765             {
       
   766             WriteDelimiterL( _L( "-- " ), 25 );
       
   767             WriteLineL(_L("TESTMODULE SUMMARIES:") );
       
   768             }
       
   769         // Generate module related reports
       
   770         for ( TInt k = 0; k < iTestSummaries.Count(); k++ )
       
   771             {
       
   772             if(iXML)
       
   773                 {
       
   774                 WriteLineL(_L("%S"), &KXMLModuleTag);
       
   775                 WriteLineL(_L("%S%S%S"), &KXMLModuleNameTag, &iTestSummaries[k]->iName, &KXMLModuleNameTagEnd);
       
   776                 WriteLineL(_L("%S%d%S"), &KXMLPassedTag, iTestSummaries[k]->iPassedCases, &KXMLPassedTagEnd);
       
   777                 WriteLineL(_L("%S%d%S"), &KXMLFailedTag, iTestSummaries[k]->iFailedCases, &KXMLFailedTagEnd);
       
   778                 WriteLineL(_L("%S%d%S"), &KXMLTimeoutedTag, iTestSummaries[k]->iTimeoutCases, &KXMLTimeoutedTagEnd);
       
   779                 WriteLineL(_L("%S%d%S"), &KXMLCrashedTag, iTestSummaries[k]->iCrashedCases, &KXMLCrashedTagEnd);
       
   780                 WriteLineL(_L("%S%d%S"), &KXMLTotalTag, iTestSummaries[k]->iPassedCases + iTestSummaries[k]->iFailedCases + iTestSummaries[k]->iTimeoutCases + iTestSummaries[k]->iCrashedCases, &KXMLTotalTagEnd);
       
   781                 WriteLineL(_L("%S"), &KXMLModuleTagEnd);
       
   782                 }
       
   783             else
       
   784                 {
       
   785                 WriteLineL(_L("Module: [%S]"),
       
   786                     &iTestSummaries[k]->iName );
       
   787                 WriteLineL(_L("\tPassed cases: %d"),
       
   788                     iTestSummaries[k]->iPassedCases );
       
   789                 WriteLineL(_L("\tFailed cases: %d"),
       
   790                     iTestSummaries[k]->iFailedCases );
       
   791                 WriteLineL(_L("\tTimeout cases: %d"),
       
   792                     iTestSummaries[k]->iTimeoutCases );
       
   793                 WriteLineL(_L("\tCrashed cases: %d"),
       
   794                     iTestSummaries[k]->iCrashedCases );
       
   795                 TInt moduleTotal = iTestSummaries[k]->iPassedCases +
       
   796                     iTestSummaries[k]->iFailedCases +
       
   797                     iTestSummaries[k]->iTimeoutCases +
       
   798                     iTestSummaries[k]->iCrashedCases;
       
   799                 WriteLineL(_L("\tTotal cases: %d"), moduleTotal );
       
   800                 WriteLineL( _L( "" ) );
       
   801                 }
       
   802             }
       
   803 
       
   804         if(iXML)
       
   805             {
       
   806             WriteLineL(_L("%S"), &KXMLModuleSummaryTagEnd);            
       
   807             }
       
   808 
       
   809         if(iXML)
       
   810             {
       
   811             WriteLineL(_L("%S"), &KXMLDllSummaryTag);            
       
   812             }
       
   813         else
       
   814             {
       
   815             WriteDelimiterL(_L( "-- " ), 25 );
       
   816             WriteLineL(_L("TEST MODULES VERSIONS:"));
       
   817             }
       
   818 
       
   819         // Generate test module versions info
       
   820         for( TInt i = 0; i < iTestModulesVersionsInfo.Count(); i++ )
       
   821             {
       
   822             TTEFTestModuleVersionInfo* versionInfo = (TTEFTestModuleVersionInfo*)iTestModulesVersionsInfo[i];
       
   823             if(iXML)
       
   824                 {
       
   825                 WriteLineL(_L("%S"), &KXMLDllTag);
       
   826                 WriteLineL(_L("%S%S%S"), &KXMLFileNameTag, &(versionInfo->iTestModuleName), &KXMLFileNameTagEnd);
       
   827                 WriteLineL(_L("%S%d.%d.%d%S"), &KXMLVersionTag, versionInfo->iMajor, versionInfo->iMinor, versionInfo->iBuild, &KXMLVersionTagEnd);
       
   828                 WriteLineL(_L("%S"), &KXMLDllTagEnd);
       
   829                 }
       
   830             else
       
   831                 {
       
   832                 WriteLineL(_L("%S %d.%d.%d"), &(versionInfo->iTestModuleName), versionInfo->iMajor, versionInfo->iMinor, versionInfo->iBuild);
       
   833                 }
       
   834             }
       
   835 
       
   836         if(iXML)
       
   837             {
       
   838             WriteLineL(_L("%S"), &KXMLDllSummaryTagEnd);            
       
   839             }
       
   840         }
       
   841     
       
   842     if(!iXML)
       
   843         {
       
   844         WriteLineL( _L( "" ) );
       
   845         }
       
   846     
       
   847     if( ( iFormat == ETEFTestReportLoggerType_Html ) && 
       
   848         ( iOutput == ETEFTestReportOutput_File ) )
       
   849         {        
       
   850         // Html start tags to whole page and header section
       
   851         iFile.Write(
       
   852             _L8( "\n\n\n</html>\n</body>\n\n\n" ) );
       
   853         }
       
   854 
       
   855     if(iXML)
       
   856         {
       
   857         WriteLineL(_L("%S"), &KXMLTestReportTagEnd);            
       
   858         }
       
   859     }
       
   860             
       
   861 /*
       
   862 -------------------------------------------------------------------------------
       
   863 
       
   864     Class: CTEFTestReport
       
   865 
       
   866     Method: UpdateReportSummaryL
       
   867 
       
   868     Description: Updates the test report summary.
       
   869 
       
   870     Parameters: None
       
   871 
       
   872     Return Values: None
       
   873 
       
   874     Errors/Exceptions: None
       
   875 
       
   876     Status: Draft
       
   877 
       
   878 -------------------------------------------------------------------------------
       
   879 */
       
   880 void CTEFTestReport::UpdateReportSummaryL()
       
   881     {
       
   882     TInt currentPos = 0;
       
   883     // Add numeric information to summary
       
   884     if ( iReportMode & ETestReportSummary )
       
   885         {
       
   886         // Go to the summary start position of the file
       
   887         if( iOutput == ETEFTestReportOutput_File )
       
   888             {
       
   889             User::LeaveIfError(iFile.Seek(ESeekCurrent, currentPos));//Get current position
       
   890             User::LeaveIfError( iFile.Seek( ESeekStart, iSummaryPos ) );
       
   891             }
       
   892         TBuf<KSummaryLineEndLen> numStr;        
       
   893         // Generate Summary to Report
       
   894         if(iXML)
       
   895             {
       
   896             WriteLineL(_L("%S"), &KXMLTestCasesSummaryTag);
       
   897             }
       
   898         else
       
   899             {
       
   900             WriteDelimiterL( _L( "-- " ), 25 );
       
   901             WriteLineL(_L("SUMMARY:") );
       
   902             }
       
   903         numStr.Num( iTotalSummary->iPassedCases );
       
   904         if(iXML)
       
   905             {
       
   906             TPtrC spaces(KSummaryLineEnd().Ptr(), KSummaryLineEnd().Length() - numStr.Length());
       
   907             WriteLineL(_L("%S%S%S%S"), &KXMLPassedTag, &numStr, &KXMLPassedTagEnd, &spaces);
       
   908             }
       
   909         else
       
   910             {
       
   911             numStr.Append( KSummaryLineEnd().Ptr(), 
       
   912                            KSummaryLineEnd().Length() - numStr.Length() );
       
   913             WriteLineL(_L("\tPassed cases: %S"), &numStr );
       
   914             }
       
   915         
       
   916         numStr.Num( iTotalSummary->iFailedCases );
       
   917         if(iXML)
       
   918             {
       
   919             TPtrC spaces(KSummaryLineEnd().Ptr(), KSummaryLineEnd().Length() - numStr.Length());
       
   920             WriteLineL(_L("%S%S%S%S"), &KXMLFailedTag, &numStr, &KXMLFailedTagEnd, &spaces);
       
   921             }
       
   922         else
       
   923             {
       
   924             numStr.Append( KSummaryLineEnd().Ptr(), 
       
   925                            KSummaryLineEnd().Length() - numStr.Length() );
       
   926             WriteLineL(_L("\tFailed cases: %S"), &numStr );
       
   927             }
       
   928             
       
   929         numStr.Num( iTotalSummary->iTimeoutCases );
       
   930         if(iXML)
       
   931             {
       
   932             TPtrC spaces(KSummaryLineEnd().Ptr(), KSummaryLineEnd().Length() - numStr.Length());
       
   933             WriteLineL(_L("%S%S%S%S"), &KXMLTimeoutedTag, &numStr, &KXMLTimeoutedTagEnd, &spaces);
       
   934             }
       
   935         else
       
   936             {
       
   937             numStr.Append( KSummaryLineEnd().Ptr(), 
       
   938                            KSummaryLineEnd().Length() - numStr.Length() );
       
   939             WriteLineL(_L("\tTimeout cases: %S"), &numStr );
       
   940             }
       
   941         
       
   942         numStr.Num( iTotalSummary->iCrashedCases );
       
   943         if(iXML)
       
   944             {
       
   945             TPtrC spaces(KSummaryLineEnd().Ptr(), KSummaryLineEnd().Length() - numStr.Length());
       
   946             WriteLineL(_L("%S%S%S%S"), &KXMLCrashedTag, &numStr, &KXMLCrashedTagEnd, &spaces);
       
   947             }
       
   948         else
       
   949             {
       
   950             numStr.Append( KSummaryLineEnd().Ptr(), 
       
   951                            KSummaryLineEnd().Length() - numStr.Length() );
       
   952             WriteLineL(_L("\tCrashed cases: %S"), &numStr );
       
   953             }
       
   954         
       
   955         TInt total = iTotalSummary->iPassedCases +
       
   956             iTotalSummary->iFailedCases +
       
   957             iTotalSummary->iTimeoutCases +
       
   958             iTotalSummary->iCrashedCases;
       
   959         numStr.Num( total );
       
   960         if(iXML)
       
   961             {
       
   962             TPtrC spaces(KSummaryLineEnd().Ptr(), KSummaryLineEnd().Length() - numStr.Length());
       
   963             WriteLineL(_L("%S%S%S%S"), &KXMLTotalTag, &numStr, &KXMLTotalTagEnd, &spaces);
       
   964             }
       
   965         else
       
   966             {
       
   967             numStr.Append( KSummaryLineEnd().Ptr(), 
       
   968                            KSummaryLineEnd().Length() - numStr.Length() );
       
   969             WriteLineL(_L("\tTotal cases: %S"), &numStr );
       
   970             }
       
   971 
       
   972         if(iXML)
       
   973             {
       
   974             WriteLineL(_L("%S"), &KXMLTestCasesSummaryTagEnd);
       
   975             }
       
   976 
       
   977         if(iOutput == ETEFTestReportOutput_File)
       
   978             {
       
   979             User::LeaveIfError(iFile.Seek(ESeekStart, currentPos));
       
   980             }
       
   981         }
       
   982     }
       
   983             
       
   984 /*
       
   985 -------------------------------------------------------------------------------
       
   986 
       
   987     Class: CTEFTestReport
       
   988 
       
   989     Method: GenerateReportL
       
   990 
       
   991     Description: Generate the test report.
       
   992 
       
   993     Parameters: None
       
   994 
       
   995     Return Values: None
       
   996 
       
   997     Errors/Exceptions: None
       
   998 
       
   999     Status: Approved
       
  1000 
       
  1001 -------------------------------------------------------------------------------
       
  1002 */
       
  1003 void CTEFTestReport::GenerateReportL()
       
  1004     {
       
  1005     WriteTrailerL();
       
  1006     
       
  1007     // Add numeric information to summary
       
  1008     if ( iReportMode & ETestReportSummary )
       
  1009         {
       
  1010         // Go to the summary start position of the file
       
  1011         if( iOutput == ETEFTestReportOutput_File )
       
  1012             {
       
  1013             User::LeaveIfError( iFile.Seek( ESeekStart, iSummaryPos ) );
       
  1014             }
       
  1015         TBuf<KSummaryLineEndLen> numStr;
       
  1016         // Generate Summary to Report
       
  1017         if(iXML)
       
  1018             {
       
  1019             WriteLineL(_L("%S"), &KXMLTestCasesSummaryTag);
       
  1020             }
       
  1021         else
       
  1022             {
       
  1023             WriteDelimiterL( _L( "-- " ), 25 );
       
  1024             WriteLineL(_L("SUMMARY:") );
       
  1025             }
       
  1026 
       
  1027         numStr.Num( iTotalSummary->iPassedCases );
       
  1028         if(iXML)
       
  1029             {
       
  1030             TPtrC spaces(KSummaryLineEnd().Ptr(), KSummaryLineEnd().Length() - numStr.Length());
       
  1031             WriteLineL(_L("%S%S%S%S"), &KXMLPassedTag, &numStr, &KXMLPassedTagEnd, &spaces);
       
  1032             }
       
  1033         else
       
  1034             {
       
  1035             numStr.Append( KSummaryLineEnd().Ptr(), 
       
  1036                            KSummaryLineEnd().Length() - numStr.Length() );
       
  1037             WriteLineL(_L("\tPassed cases: %S"), &numStr );
       
  1038             }
       
  1039 
       
  1040         numStr.Num( iTotalSummary->iFailedCases );
       
  1041         if(iXML)
       
  1042             {
       
  1043             TPtrC spaces(KSummaryLineEnd().Ptr(), KSummaryLineEnd().Length() - numStr.Length());
       
  1044             WriteLineL(_L("%S%S%S%S"), &KXMLFailedTag, &numStr, &KXMLFailedTagEnd, &spaces);
       
  1045             }
       
  1046         else
       
  1047             {
       
  1048             numStr.Append( KSummaryLineEnd().Ptr(), 
       
  1049                            KSummaryLineEnd().Length() - numStr.Length() );
       
  1050             WriteLineL(_L("\tFailed cases: %S"), &numStr );
       
  1051             }
       
  1052         
       
  1053         numStr.Num( iTotalSummary->iTimeoutCases );
       
  1054         if(iXML)
       
  1055             {
       
  1056             TPtrC spaces(KSummaryLineEnd().Ptr(), KSummaryLineEnd().Length() - numStr.Length());
       
  1057             WriteLineL(_L("%S%S%S%S"), &KXMLTimeoutedTag, &numStr, &KXMLTimeoutedTagEnd, &spaces);
       
  1058             }
       
  1059         else
       
  1060             {
       
  1061             numStr.Append( KSummaryLineEnd().Ptr(), 
       
  1062                            KSummaryLineEnd().Length() - numStr.Length() );
       
  1063             WriteLineL(_L("\tTimeout cases: %S"), &numStr );
       
  1064             }
       
  1065         
       
  1066         numStr.Num( iTotalSummary->iCrashedCases );
       
  1067         if(iXML)
       
  1068             {
       
  1069             TPtrC spaces(KSummaryLineEnd().Ptr(), KSummaryLineEnd().Length() - numStr.Length());
       
  1070             WriteLineL(_L("%S%S%S%S"), &KXMLCrashedTag, &numStr, &KXMLCrashedTagEnd, &spaces);
       
  1071             }
       
  1072         else
       
  1073             {
       
  1074             numStr.Append( KSummaryLineEnd().Ptr(), 
       
  1075                            KSummaryLineEnd().Length() - numStr.Length() );
       
  1076             WriteLineL(_L("\tCrashed cases: %S"), &numStr );
       
  1077             }
       
  1078         
       
  1079         TInt total = iTotalSummary->iPassedCases +
       
  1080             iTotalSummary->iFailedCases +
       
  1081             iTotalSummary->iTimeoutCases +
       
  1082             iTotalSummary->iCrashedCases;
       
  1083         numStr.Num( total );
       
  1084         if(iXML)
       
  1085             {
       
  1086             TPtrC spaces(KSummaryLineEnd().Ptr(), KSummaryLineEnd().Length() - numStr.Length());
       
  1087             WriteLineL(_L("%S%S%S%S"), &KXMLTotalTag, &numStr, &KXMLTotalTagEnd, &spaces);
       
  1088             }
       
  1089         else
       
  1090             {
       
  1091             numStr.Append( KSummaryLineEnd().Ptr(), 
       
  1092                            KSummaryLineEnd().Length() - numStr.Length() );
       
  1093             WriteLineL(_L("\tTotal cases: %S"), &numStr );
       
  1094             }
       
  1095 
       
  1096         if(iXML)
       
  1097             {
       
  1098             WriteLineL(_L("%S"), &KXMLTestCasesSummaryTagEnd);
       
  1099             }
       
  1100         }
       
  1101     }
       
  1102 
       
  1103 /*
       
  1104 -------------------------------------------------------------------------------
       
  1105 
       
  1106     Class: CTEFTestReport
       
  1107 
       
  1108     Method: WriteLine
       
  1109 
       
  1110     Description: Write line to file.
       
  1111 
       
  1112     Parameters: TRefByValue<const TDesC> aStr: in: test to print
       
  1113 
       
  1114     Return Values: None
       
  1115 
       
  1116     Errors/Exceptions: None
       
  1117 
       
  1118     Status: Proposal
       
  1119 
       
  1120 -------------------------------------------------------------------------------
       
  1121 */
       
  1122 void CTEFTestReport::WriteLineL( TRefByValue<const TDesC> aStr,... )
       
  1123     {
       
  1124     
       
  1125     VA_LIST list;
       
  1126     VA_START( list, aStr );
       
  1127     TPrintInfo line;
       
  1128 
       
  1129     // Parse parameters
       
  1130     line.AppendFormatList( aStr, list, NULL );
       
  1131     
       
  1132     if( iOutput == ETEFTestReportOutput_RDebug )
       
  1133         {
       
  1134         // RDebug output
       
  1135         RDebug::Print( line );
       
  1136         return;
       
  1137         }
       
  1138     
       
  1139     HBufC8* buf = HBufC8::NewLC( line.Length() + KMaxLenEol );
       
  1140     TPtr8 ptr( buf->Des() );
       
  1141     ptr.Copy( line );    
       
  1142             
       
  1143     if( ( iFormat == ETEFTestReportLoggerType_Html ) && 
       
  1144         ( iOutput == ETEFTestReportOutput_File ) )
       
  1145         {
       
  1146         // Html output, add linefeed
       
  1147         ptr.Append( _L8("<BR>\r\n") );
       
  1148         }
       
  1149     else 
       
  1150         {
       
  1151         // Default: Text format to file
       
  1152         // Add linefeed
       
  1153         ptr.Append( _L8("\r\n") );
       
  1154         }
       
  1155     
       
  1156     // Write to file    
       
  1157     iFile.Write( ptr );
       
  1158     CleanupStack::PopAndDestroy( buf );
       
  1159     
       
  1160     }
       
  1161         
       
  1162 /*
       
  1163 -------------------------------------------------------------------------------
       
  1164 
       
  1165     Class: CTEFTestReport
       
  1166 
       
  1167     Method: WriteDelimiter
       
  1168 
       
  1169     Description: Write delimiter line to file.
       
  1170 
       
  1171     Parameters: const TDesC& aDelimiter: in: delimiter mark
       
  1172                 TInt aCount: in: number of delimiters written
       
  1173 
       
  1174     Return Values: None
       
  1175 
       
  1176     Errors/Exceptions: None
       
  1177 
       
  1178     Status: Proposal
       
  1179 
       
  1180 -------------------------------------------------------------------------------
       
  1181 */
       
  1182 void CTEFTestReport::WriteDelimiterL( const TDesC& aDelimiter, TInt aCount )
       
  1183     {
       
  1184     
       
  1185      if( iOutput == ETEFTestReportOutput_RDebug )
       
  1186         {
       
  1187         // RDebug output
       
  1188         // Nothing is printed
       
  1189         return;
       
  1190         }
       
  1191     
       
  1192     HBufC8* buf = HBufC8::NewLC( aDelimiter.Length() );
       
  1193     TPtr8 ptr( buf->Des() );
       
  1194     ptr.Copy( aDelimiter );    
       
  1195     
       
  1196     for( TInt i = 0; i<aCount; i++ )
       
  1197         {
       
  1198         // Write to file    
       
  1199         iFile.Write( ptr );
       
  1200         }
       
  1201     CleanupStack::PopAndDestroy( buf );
       
  1202     
       
  1203     TBuf8<KMaxLenEol> linefeed;        
       
  1204     if( ( iFormat == ETEFTestReportLoggerType_Html ) && 
       
  1205         ( iOutput == ETEFTestReportOutput_File ) )
       
  1206         {
       
  1207         // Html output, add linefeed
       
  1208         linefeed.Append( _L8("<BR>\r\n") );
       
  1209         }
       
  1210     else 
       
  1211         {
       
  1212         // Default: Text format to file
       
  1213         // Add linefeed
       
  1214         linefeed.Append( _L8("\r\n") );
       
  1215         }
       
  1216      // Write to file    
       
  1217     iFile.Write( linefeed );
       
  1218     
       
  1219     }        
       
  1220         
       
  1221 /*
       
  1222 -------------------------------------------------------------------------------
       
  1223 
       
  1224     Class: CTEFTestReport
       
  1225 
       
  1226     Method: TTestReportHeader::TTestReportHeader
       
  1227 
       
  1228     Description: Constructor of TTestReportHeader
       
  1229 
       
  1230     Parameters: None
       
  1231 
       
  1232     Return Values: None
       
  1233 
       
  1234     Errors/Exceptions: None
       
  1235 
       
  1236     Status: Approved
       
  1237 
       
  1238 -------------------------------------------------------------------------------
       
  1239 */
       
  1240 CTEFTestReport::TTestHWInfo::TTestHWInfo()
       
  1241     {
       
  1242     // Initialize, fills a specified block of data with binary zeroes
       
  1243     Mem::FillZ( this, sizeof( CTEFTestReport::TTestHWInfo ) );
       
  1244 
       
  1245     // Get HW Info
       
  1246     HAL::Get( HALData::EManufacturer, iHwInfo.iManufacturer );
       
  1247     HAL::Get( HALData::EMachineUid, iHwInfo.iMachineUid );
       
  1248     HAL::Get( HALData::EManufacturerHardwareRev, iHwInfo.iHwRev );
       
  1249     HAL::Get( HALData::EModel, iHwInfo.iModel );
       
  1250     HAL::Get( HALData::ECPU, iHwInfo.iCpu );
       
  1251     HAL::Get( HALData::ECPUSpeed, iHwInfo.iCpuSpeed );
       
  1252     HAL::Get( HALData::ELanguageIndex, iHwInfo.iLanguage );
       
  1253 
       
  1254     // Get SW Info
       
  1255     HAL::Get( HALData::EManufacturerSoftwareRev, iSwInfo.iSwRev );
       
  1256     HAL::Get( HALData::EManufacturerSoftwareBuild, iSwInfo.iSwBuild );
       
  1257 
       
  1258     // Memory Info
       
  1259     HAL::Get( HALData::EMemoryRAM, iMemoryInfo.iRAM );
       
  1260     HAL::Get( HALData::EMemoryRAMFree, iMemoryInfo.iRAMFree );
       
  1261 
       
  1262     }
       
  1263         
       
  1264 /*
       
  1265 -------------------------------------------------------------------------------
       
  1266 
       
  1267     Class: CTEFTestReport
       
  1268 
       
  1269     Method: TTestSummary::TTestSummary
       
  1270 
       
  1271     Description: Constructor of TTestSummary.
       
  1272 
       
  1273     Parameters: const TName& aName: in: Name of summary
       
  1274 
       
  1275     Return Values: None
       
  1276 
       
  1277     Errors/Exceptions: None
       
  1278 
       
  1279     Status: Approved
       
  1280 
       
  1281 -------------------------------------------------------------------------------
       
  1282 */
       
  1283 CTEFTestReport::TTestSummary::TTestSummary( const TName& aName ) :
       
  1284     iName( aName ),
       
  1285     iPassedCases( 0 ),
       
  1286     iFailedCases( 0 ),
       
  1287     iCrashedCases( 0 ),
       
  1288     iTimeoutCases( 0 )
       
  1289     {
       
  1290 
       
  1291     }
       
  1292 
       
  1293 /*
       
  1294 -------------------------------------------------------------------------------
       
  1295 
       
  1296     Class: CTEFTestReport
       
  1297 
       
  1298     Method: AddTestModuleVersion
       
  1299     
       
  1300     Description: Method adds version of a test module to the list of versions
       
  1301                  that will be printed when stif is stopped.
       
  1302                  
       
  1303     Parameters: TTEFTestModuleVersionInfo aVersion : object contains information about version and
       
  1304                 name of test module.
       
  1305 
       
  1306     Return Values: None
       
  1307 
       
  1308     Errors/Exceptions: None
       
  1309 
       
  1310 -------------------------------------------------------------------------------
       
  1311 */
       
  1312 
       
  1313 void CTEFTestReport::AddTestModuleVersion(TTEFTestModuleVersionInfo& aVersion)
       
  1314     {
       
  1315     for(TInt i = 0; i < iTestModulesVersionsInfo.Count(); i++)
       
  1316         {
       
  1317         if( aVersion.iTestModuleName == iTestModulesVersionsInfo[i]->iTestModuleName )
       
  1318             {
       
  1319             return;
       
  1320             }
       
  1321         }
       
  1322     
       
  1323     TTEFTestModuleVersionInfo* testModuleVersionInfo = new (ELeave) TTEFTestModuleVersionInfo;
       
  1324     testModuleVersionInfo->iMajor = aVersion.iMajor;
       
  1325     testModuleVersionInfo->iMinor = aVersion.iMinor;
       
  1326     testModuleVersionInfo->iBuild = aVersion.iBuild;
       
  1327     testModuleVersionInfo->iTestModuleName = aVersion.iTestModuleName;
       
  1328     
       
  1329     TInt res = iTestModulesVersionsInfo.Append(testModuleVersionInfo);
       
  1330     if( res != KErrNone )
       
  1331         {
       
  1332         delete testModuleVersionInfo;
       
  1333         }
       
  1334     }
       
  1335 
       
  1336 /*
       
  1337 -------------------------------------------------------------------------------
       
  1338 
       
  1339     Class: CTEFTestReport
       
  1340 
       
  1341     Method: TTestCaseSummary::TTestCaseSummary
       
  1342 
       
  1343     Description: Constructor of TTestCaseSummary.
       
  1344 
       
  1345     Parameters: None
       
  1346 
       
  1347     Return Values: None
       
  1348 
       
  1349     Errors/Exceptions: None
       
  1350 
       
  1351     Status: Approved
       
  1352 
       
  1353 -------------------------------------------------------------------------------
       
  1354 */
       
  1355 CTEFTestReport::TTestCaseSummary::TTestCaseSummary()
       
  1356     {
       
  1357 
       
  1358     }
       
  1359 
       
  1360 /*
       
  1361 -------------------------------------------------------------------------------
       
  1362 
       
  1363     Class: CTEFTestReport
       
  1364 
       
  1365     Method: CloseXMLTagsInUnfinishedFileL
       
  1366 
       
  1367     Description: Adds needed tags to get valid xml file.
       
  1368 
       
  1369     Parameters: None
       
  1370 
       
  1371     Return Values: None
       
  1372 
       
  1373     Errors/Exceptions: Seek operations may cause leaves
       
  1374 
       
  1375     Status: Approved
       
  1376 
       
  1377 -------------------------------------------------------------------------------
       
  1378 */
       
  1379 void CTEFTestReport::CloseXMLTagsInUnfinishedFileL(void)
       
  1380     {
       
  1381     // For xml file keep current position in file.
       
  1382     if(iXML)
       
  1383         {
       
  1384         TInt currentPos = 0;
       
  1385         User::LeaveIfError(iFile.Seek(ESeekCurrent, currentPos));
       
  1386         
       
  1387         // Add closing tags to get valid xml file
       
  1388         WriteLineL(_L("%S"), &KXMLTestCasesTagEnd);
       
  1389         WriteLineL(_L("%S"), &KXMLTestReportTagEnd);
       
  1390         
       
  1391         // Move back to previous position
       
  1392         User::LeaveIfError(iFile.Seek(ESeekStart, currentPos));
       
  1393         }
       
  1394     }
       
  1395 
       
  1396 // ================= OTHER EXPORTED FUNCTIONS =================================
       
  1397 
       
  1398 // None
       
  1399 
       
  1400 // End of File