stif/TestEngine/inc/TestReport.h
branchRCL_3
changeset 59 8ad140f3dd41
equal deleted inserted replaced
49:7fdc9a71d314 59:8ad140f3dd41
       
     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 file contains the header file of the CTestReport.
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef TEST_REPORT_H
       
    19 #define TEST_REPORT_H
       
    20 
       
    21 //  INCLUDES
       
    22 #include <e32std.h>
       
    23 #include <e32base.h>
       
    24 #include "TestEngineClient.h"
       
    25 #include "TestEngine.h"
       
    26 
       
    27 // CONSTANTS
       
    28 // Maximum length for date or time definitions 'Thursday 06th November 2003'
       
    29 const TInt KMaxDateAndTimeStamp = 30;
       
    30 
       
    31 // MACROS
       
    32 // None
       
    33 
       
    34 // DATA TYPES
       
    35 // None
       
    36 
       
    37 // FUNCTION PROTOTYPES
       
    38 // None
       
    39 
       
    40 // FORWARD DECLARATIONS
       
    41 class CStifLogger;
       
    42 
       
    43 // CLASS DECLARATION
       
    44 // None
       
    45 
       
    46 // DESCRIPTION
       
    47 // CTestReport is a class that can generate different test reports.
       
    48 class CTestReport
       
    49         : public CBase
       
    50     {
       
    51     public:     // Enumerations
       
    52 
       
    53         // TTestReportMode defines the mode of test report
       
    54         enum TTestReportMode
       
    55             {
       
    56             ETestReportBlank = 0x00000000,
       
    57             ETestReportSummary = 0x00000001,
       
    58             ETestReportEnvironment = 0x00000002,
       
    59             ETestReportCases = 0x00000004,
       
    60             ETestReportFull = ETestReportSummary | ETestReportEnvironment | ETestReportCases
       
    61             };
       
    62 
       
    63         // TTestReportOutput defines the type of test report output
       
    64         enum TTestReportOutput
       
    65             {
       
    66             ETestReportNone = 0x00000000,
       
    67             ETestReportDebug = 0x00000001,
       
    68             ETestReportPlainText = 0x00000002,
       
    69             ETestReportHtml = 0x00000004,
       
    70             ETestReportAll = ETestReportDebug | ETestReportPlainText | ETestReportHtml
       
    71             };
       
    72 
       
    73     public:     // Structured classes
       
    74 
       
    75         /**
       
    76         *  TTestReportHeader includes header information for test report.
       
    77         *
       
    78         */
       
    79         struct THwInfo
       
    80             {
       
    81             TInt iManufacturer;
       
    82             TInt iMachineUid;
       
    83             TInt iModel;
       
    84             TInt iHwRev;
       
    85             TInt iCpu;
       
    86             TInt iCpuSpeed;
       
    87             TInt iLanguage;
       
    88             };
       
    89 
       
    90         struct TSwInfo
       
    91             {
       
    92             TInt iSwRev;
       
    93             TInt iSwBuild;
       
    94             };
       
    95 
       
    96         struct TMemoryInfo
       
    97             {
       
    98             TInt iRAM;
       
    99             TInt iRAMFree;
       
   100             };
       
   101 
       
   102         class TTestHWInfo
       
   103             {
       
   104             public: // New functions
       
   105                 TTestHWInfo();
       
   106 
       
   107             public: // Data
       
   108                 // HW Info
       
   109                 THwInfo         iHwInfo;
       
   110                 // SW Info
       
   111                 TSwInfo         iSwInfo;
       
   112                 // Memory Info
       
   113                 TMemoryInfo     iMemoryInfo;
       
   114             };
       
   115 
       
   116         /**
       
   117         *  TTestCaseSummary includes information for summary of test cases.
       
   118         */
       
   119         class TTestCaseSummary
       
   120             {
       
   121             public:     // New functions
       
   122                 TTestCaseSummary();
       
   123 
       
   124             public:     // Data
       
   125                 // Test Info
       
   126                 TTestInfo           iTestInfo;
       
   127                 // Test Result
       
   128                 TFullTestResult     iFullTestResult;
       
   129             };
       
   130 
       
   131         /**
       
   132         *  TTestSummary includes information for test report summary.
       
   133         */
       
   134         class TTestSummary
       
   135             {
       
   136             public:     // New functions
       
   137                 TTestSummary( const TName& aName );
       
   138 
       
   139             public:     // Data
       
   140                 // Name (e.g. test module name )
       
   141                 const TName     iName;
       
   142                 // Count of passed test cases
       
   143                 TInt            iPassedCases;
       
   144                 // Count of failed test cases
       
   145                 TInt            iFailedCases;
       
   146                 // Count of crashed cases
       
   147                 TInt            iCrashedCases;
       
   148                 // Count of timed out cases
       
   149                 TInt            iTimeoutCases;
       
   150             };
       
   151 
       
   152     private:    // Enumerations
       
   153 
       
   154     public:     // Constructors and destructor
       
   155         
       
   156         /**
       
   157         * Two-phased constructor.
       
   158         */
       
   159         static CTestReport* NewL( CTestReportSettings& aTestReportSettings,
       
   160                                   const TTestReportMode aReportMode );
       
   161         
       
   162         /**
       
   163         * Destructor.
       
   164         */
       
   165         ~CTestReport();
       
   166         
       
   167     public:     // New functions
       
   168         
       
   169         /**
       
   170         * Add test case result.
       
   171         */
       
   172         void AddTestCaseResultL( const TTestInfo& aTestInfo,
       
   173                                  const TFullTestResult& aTestResult,
       
   174                                  const TInt aError );
       
   175 
       
   176         /**
       
   177         * Generate result reports.
       
   178         */
       
   179         void GenerateReportL();
       
   180         
       
   181         /**
       
   182         * Update result reports.
       
   183         */
       
   184         void UpdateReportSummaryL();
       
   185         
       
   186         /**
       
   187          * Adds version of test module to RPointerArray
       
   188          */
       
   189         void AddTestModuleVersion(TTestModuleVersionInfo& aVersion);
       
   190 
       
   191     public:     // Functions from base classes
       
   192         
       
   193     protected:  // New functions
       
   194 
       
   195     protected:  // Functions from base classes
       
   196 
       
   197     private:
       
   198 
       
   199         /**
       
   200         * By default Symbian OS constructor is private.
       
   201         */
       
   202         void ConstructL(  CTestReportSettings& aTestReportSettings );
       
   203 
       
   204         /**
       
   205         * Default C++ constructor.
       
   206         */
       
   207         CTestReport( const TTestReportMode aReportMode );
       
   208         
       
   209         /**
       
   210         * Write result file header.
       
   211         */
       
   212         void WriteHeaderL();
       
   213         
       
   214         /**
       
   215         * Write result file trailer.
       
   216         */
       
   217         void WriteTrailerL();
       
   218         
       
   219         /**
       
   220         * Write data to file.
       
   221         */
       
   222         void WriteLineL( TRefByValue<const TDesC> aStr,... );
       
   223         
       
   224         /**
       
   225         * Write delimiter line.
       
   226         */
       
   227         void WriteDelimiterL( const TDesC& aDelimiter, TInt aCount );
       
   228         
       
   229         /**
       
   230         * Adds needed tags to get valid xml file.
       
   231         */
       
   232         void CloseXMLTagsInUnfinishedFileL(void);
       
   233 
       
   234     public:     // Data
       
   235     
       
   236     protected:  // Data
       
   237 
       
   238     private:    // Data
       
   239 
       
   240         // Report file handles
       
   241         RFs                             iFs;
       
   242         RFile                           iFile;
       
   243         CStifLogger::TLoggerType        iFormat;
       
   244         CStifLogger::TOutput            iOutput;
       
   245     
       
   246         // Report Mode
       
   247         TTestReportMode                 iReportMode;
       
   248 
       
   249         // Report HW info
       
   250         TTestHWInfo                     iReportHWInfo;
       
   251 
       
   252         // Total summary
       
   253         TTestSummary*                   iTotalSummary;
       
   254 
       
   255         // Test summary array
       
   256         RPointerArray<TTestSummary>     iTestSummaries;
       
   257         
       
   258         // Summary start position
       
   259         TInt                            iSummaryPos;
       
   260         
       
   261         // Versions of test modules position
       
   262         TInt							iModulesVersionsPos;
       
   263         
       
   264         // Test modules versions
       
   265         RPointerArray<TTestModuleVersionInfo> iTestModulesVersionsInfo;
       
   266 
       
   267         // Will report be written in xml format 
       
   268         TBool                           iXML;
       
   269 
       
   270     public:     // Friend classes
       
   271 
       
   272     protected:  // Friend classes
       
   273 
       
   274     private:    // Friend classes
       
   275 
       
   276     };
       
   277 
       
   278 #endif // TEST_REPORT_H
       
   279 
       
   280 // End of File