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