testexecfw/stf/stfext/testmodules/teftestmod/teftestmodulefw/utils/inc/teftestreport.h
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 file contains the header file of the CTestReport.
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef TEF_TEST_REPORT_H
       
    19 #define TEF_TEST_REPORT_H
       
    20 
       
    21 //  INCLUDES
       
    22 #include <e32std.h>
       
    23 #include <e32base.h>
       
    24 
       
    25 const TInt KTEFMaxResultDes = 128; // Maximum test result description length
       
    26 typedef TBuf<KTEFMaxResultDes> TTEFResultDes;
       
    27 
       
    28 // Different StifLogger presentations types.
       
    29 enum TTEFTestReportLoggerType
       
    30     {
       
    31     ETEFTestReportLoggerType_Txt,       // txt file logging
       
    32     ETEFTestReportLoggerType_Data,      // data file logging(e.g. web page downloading )
       
    33     ETEFTestReportLoggerType_Html       // html file logging
       
    34     };
       
    35 
       
    36 // Different StifLogger output modules.
       
    37 enum TTEFTestReportOutput
       
    38     {
       
    39     ETEFTestReportOutput_File,      // File logging
       
    40     ETEFTestReportOutput_RDebug     // RDebug logging
       
    41     };
       
    42 
       
    43 // TTestCaseInfo defines the information for test case execution.
       
    44 class TTEFTestCaseInfo
       
    45     {
       
    46     public:
       
    47         // Default test case priority values
       
    48         enum TPriority
       
    49             {    
       
    50             EPriorityLow = -100,
       
    51             EPriorityNormal = 0,
       
    52             EPriorityHigh = 100,
       
    53             };
       
    54 
       
    55     public:
       
    56 
       
    57         /**
       
    58         * Default constructor of TTestCaseInfo.
       
    59         */
       
    60         inline TTEFTestCaseInfo()
       
    61         {
       
    62         iCaseNumber = -1;
       
    63         iTitle.Zero();
       
    64         iTimeout = 0;
       
    65         iPriority = EPriorityNormal;
       
    66         };
       
    67 
       
    68     public:
       
    69 
       
    70         // Test case number.
       
    71         TInt iCaseNumber;
       
    72         // Test case title.
       
    73         TName iTitle;
       
    74         // Test Case Timeout ( 0 == No timeout )
       
    75         TTimeIntervalMicroSeconds iTimeout; 
       
    76         // Test case priority
       
    77         TInt iPriority;
       
    78 
       
    79     };
       
    80 
       
    81 // TTestResult defines the test case result information.
       
    82 class TTEFTestResult 
       
    83     {
       
    84     public:
       
    85 
       
    86         /**
       
    87         * Default constructor of TTestResult.
       
    88         */
       
    89         inline TTEFTestResult()
       
    90         {
       
    91             iResult = 0;
       
    92             iResultDes.Zero();
       
    93         };
       
    94 
       
    95         /**
       
    96         * Sets result and result description of the test case.
       
    97         */
       
    98         inline void SetResult( TInt aResultCode, const TDesC& aResultDes )
       
    99         {
       
   100             iResult = aResultCode;
       
   101             // If description is too length then cut.
       
   102             if( aResultDes.Length() > KTEFMaxResultDes )
       
   103                 {
       
   104                 iResultDes = aResultDes.Left( KTEFMaxResultDes );
       
   105                 }
       
   106             else
       
   107                 {
       
   108                 iResultDes = aResultDes;
       
   109                 }
       
   110         };
       
   111 
       
   112     public:
       
   113 
       
   114         // Test case result as Symbian OS error code.
       
   115         TInt iResult;
       
   116         // Descriptive test case result.
       
   117         TTEFResultDes iResultDes;
       
   118     };
       
   119 
       
   120 // TTestInfo defines the information for test case and Test Module.
       
   121 class TTEFTestInfo 
       
   122     {
       
   123     public:
       
   124         inline TTEFTestInfo()
       
   125         {
       
   126             iModuleName.Zero();
       
   127             iConfig.Zero();
       
   128         };
       
   129     public:
       
   130         // The name of Test Module.
       
   131         TName iModuleName;
       
   132         // Test case info for test case execution.
       
   133         TTEFTestCaseInfo iTestCaseInfo;
       
   134         // Config file to be used.
       
   135         TFileName iConfig;
       
   136     };
       
   137 
       
   138 // TFullTestResult defines the full test case result information.
       
   139 class TTEFFullTestResult
       
   140     {
       
   141     public:
       
   142         inline TTEFFullTestResult()
       
   143         {
       
   144             iStartTime=0;
       
   145             iEndTime=0;
       
   146         };
       
   147 
       
   148         enum TCaseExecutionResult
       
   149         {
       
   150             ECaseOngoing,
       
   151             ECaseExecuted,
       
   152             ECaseCancelled,
       
   153             ECaseErrorFromModule,
       
   154             ECaseLeave,
       
   155             ECasePanic,
       
   156             ECaseException,
       
   157             ECaseTimeout,
       
   158             ECaseSuicided,
       
   159         };
       
   160 
       
   161     public:
       
   162         // Test case result.
       
   163         TTEFTestResult iTestResult;
       
   164         // Timestamp when test case was started.
       
   165         TTime iStartTime;
       
   166         // Timestamp when test case was ended.
       
   167         TTime iEndTime;
       
   168         
       
   169         // Test result type
       
   170         TCaseExecutionResult iCaseExecutionResultType;      
       
   171         // Test result code
       
   172         TInt iCaseExecutionResultCode;
       
   173     };
       
   174 
       
   175         
       
   176 // Struct to Test report settings
       
   177 class TTEFTestReportSettings
       
   178     {
       
   179     public:
       
   180         
       
   181         TTEFTestReportSettings(){ iCreateTestReport = ETrue;
       
   182                                 iPath = NULL;
       
   183                                 iName = NULL;
       
   184                                 iFormat = ETEFTestReportLoggerType_Txt;
       
   185                                 iOutput = ETEFTestReportOutput_File;
       
   186                                 iOverwrite = ETrue; 
       
   187                                 iXML = EFalse;
       
   188                              }
       
   189 
       
   190        ~TTEFTestReportSettings(){ delete iPath; delete iName; }
       
   191 
       
   192     public:
       
   193 
       
   194         TBool                   iCreateTestReport; // Test report creation mode
       
   195         HBufC*                  iPath;             // Test report path
       
   196         HBufC*                  iName;             // Test report name
       
   197         TTEFTestReportLoggerType iFormat;          // Test report file type
       
   198         TTEFTestReportOutput    iOutput;           // Test report output
       
   199         TBool                   iOverwrite;        // Test report overwrite
       
   200         TBool                   iXML;              // Test report in xml format
       
   201 
       
   202     };
       
   203 
       
   204 
       
   205 // DESCRIPTION
       
   206 // Class used to store version information of test module.
       
   207 // iTestModuleName field keeps name of test module dll
       
   208 // iVersion keeps version of test module dll
       
   209         
       
   210     struct TTEFTestModuleVersionInfo
       
   211     {
       
   212         TFileName iTestModuleName;
       
   213         TInt iMajor;
       
   214         TInt iMinor;
       
   215         TInt iBuild;
       
   216     };
       
   217 
       
   218     
       
   219 // CONSTANTS
       
   220 // Maximum length for date or time definitions 'Thursday 06th November 2003'
       
   221 const TInt KMaxDateAndTimeStamp = 30;
       
   222 
       
   223 // MACROS
       
   224 // None
       
   225 
       
   226 // DATA TYPES
       
   227 // None
       
   228 
       
   229 // FUNCTION PROTOTYPES
       
   230 // None
       
   231 
       
   232 // FORWARD DECLARATIONS
       
   233 
       
   234 
       
   235 // CLASS DECLARATION
       
   236 // None
       
   237 
       
   238 // DESCRIPTION
       
   239 // CTEFTestReport is a class that can generate different test reports.
       
   240 class CTEFTestReport
       
   241         : public CBase
       
   242     {
       
   243     public:     // Enumerations
       
   244 
       
   245         // TTestReportMode defines the mode of test report
       
   246         enum TTestReportMode
       
   247             {
       
   248             ETestReportBlank = 0x00000000,
       
   249             ETestReportSummary = 0x00000001,
       
   250             ETestReportEnvironment = 0x00000002,
       
   251             ETestReportCases = 0x00000004,
       
   252             ETestReportFull = ETestReportSummary | ETestReportEnvironment | ETestReportCases
       
   253             };
       
   254 
       
   255         // TTestReportOutput defines the type of test report output
       
   256         enum TTestReportOutput
       
   257             {
       
   258             ETestReportNone = 0x00000000,
       
   259             ETestReportDebug = 0x00000001,
       
   260             ETestReportPlainText = 0x00000002,
       
   261             ETestReportHtml = 0x00000004,
       
   262             ETestReportAll = ETestReportDebug | ETestReportPlainText | ETestReportHtml
       
   263             };
       
   264 
       
   265         enum TStyle
       
   266             {
       
   267             ENoStyle    = 0x00000,  // No style parameter
       
   268             EBold       = 0x00001,  // Bold
       
   269             ECursive    = 0x00002,  // Cursive
       
   270             EUnderline  = 0x00004,  // Underline
       
   271             EBlue       = 0x00008,  // Blue
       
   272             EGreen      = 0x00010,  // Green
       
   273             ERed        = 0x00020,  // Red
       
   274             EImportant  = 0x00040,  // Important (Line will starts a 'IMPORTANT' text)
       
   275             EWarning    = 0x00080,  // Warning (Line will starts a 'WARNING' text)
       
   276             EError      = 0x00100   // Error (Line will starts a 'ERROR' text)
       
   277             };
       
   278         
       
   279     public:     // Structured classes
       
   280 
       
   281         /**
       
   282         *  TTestReportHeader includes header information for test report.
       
   283         *
       
   284         */
       
   285         struct THwInfo
       
   286             {
       
   287             TInt iManufacturer;
       
   288             TInt iMachineUid;
       
   289             TInt iModel;
       
   290             TInt iHwRev;
       
   291             TInt iCpu;
       
   292             TInt iCpuSpeed;
       
   293             TInt iLanguage;
       
   294             };
       
   295 
       
   296         struct TSwInfo
       
   297             {
       
   298             TInt iSwRev;
       
   299             TInt iSwBuild;
       
   300             };
       
   301 
       
   302         struct TMemoryInfo
       
   303             {
       
   304             TInt iRAM;
       
   305             TInt iRAMFree;
       
   306             };
       
   307 
       
   308         class TTestHWInfo
       
   309             {
       
   310             public: // New functions
       
   311                 TTestHWInfo();
       
   312 
       
   313             public: // Data
       
   314                 // HW Info
       
   315                 THwInfo         iHwInfo;
       
   316                 // SW Info
       
   317                 TSwInfo         iSwInfo;
       
   318                 // Memory Info
       
   319                 TMemoryInfo     iMemoryInfo;
       
   320             };
       
   321 
       
   322         /**
       
   323         *  TTestCaseSummary includes information for summary of test cases.
       
   324         */
       
   325         class TTestCaseSummary
       
   326             {
       
   327             public:     // New functions
       
   328                 TTestCaseSummary();
       
   329 
       
   330             public:     // Data
       
   331                 // Test Info
       
   332                 TTEFTestInfo           iTestInfo;
       
   333                 // Test Result
       
   334                 TTEFFullTestResult     iFullTestResult;
       
   335             };
       
   336 
       
   337         /**
       
   338         *  TTestSummary includes information for test report summary.
       
   339         */
       
   340         class TTestSummary
       
   341             {
       
   342             public:     // New functions
       
   343                 TTestSummary( const TName& aName );
       
   344 
       
   345             public:     // Data
       
   346                 // Name (e.g. test module name )
       
   347                 const TName     iName;
       
   348                 // Count of passed test cases
       
   349                 TInt            iPassedCases;
       
   350                 // Count of failed test cases
       
   351                 TInt            iFailedCases;
       
   352                 // Count of crashed cases
       
   353                 TInt            iCrashedCases;
       
   354                 // Count of timed out cases
       
   355                 TInt            iTimeoutCases;
       
   356             };
       
   357 
       
   358     private:    // Enumerations
       
   359 
       
   360     public:     // Constructors and destructor
       
   361         
       
   362         /**
       
   363         * Two-phased constructor.
       
   364         */
       
   365         static CTEFTestReport* NewL( TTEFTestReportSettings& aTestReportSettings,
       
   366                                   const TTestReportMode aReportMode );
       
   367         
       
   368         /**
       
   369         * Destructor.
       
   370         */
       
   371         ~CTEFTestReport();
       
   372         
       
   373     public:     // New functions
       
   374         
       
   375         /**
       
   376         * Add test case result.
       
   377         */
       
   378         void AddTestCaseResultL( const TTEFTestInfo& aTestInfo,
       
   379                                  const TTEFFullTestResult& aTestResult,
       
   380                                  const TInt aError );
       
   381 
       
   382         /**
       
   383         * Generate result reports.
       
   384         */
       
   385         void GenerateReportL();
       
   386         
       
   387         /**
       
   388         * Update result reports.
       
   389         */
       
   390         void UpdateReportSummaryL();
       
   391         
       
   392         /**
       
   393          * Adds version of test module to RPointerArray
       
   394          */
       
   395         void AddTestModuleVersion(TTEFTestModuleVersionInfo& aVersion);
       
   396 
       
   397     public:     // Functions from base classes
       
   398         
       
   399     protected:  // New functions
       
   400 
       
   401     protected:  // Functions from base classes
       
   402 
       
   403     private:
       
   404 
       
   405         /**
       
   406         * By default Symbian OS constructor is private.
       
   407         */
       
   408         void ConstructL(  TTEFTestReportSettings& aTestReportSettings );
       
   409 
       
   410         /**
       
   411         * Default C++ constructor.
       
   412         */
       
   413         CTEFTestReport( const TTestReportMode aReportMode );
       
   414         
       
   415         /**
       
   416         * Write result file header.
       
   417         */
       
   418         void WriteHeaderL();
       
   419         
       
   420         /**
       
   421         * Write result file trailer.
       
   422         */
       
   423         void WriteTrailerL();
       
   424         
       
   425         /**
       
   426         * Write data to file.
       
   427         */
       
   428         void WriteLineL( TRefByValue<const TDesC> aStr,... );
       
   429         
       
   430         /**
       
   431         * Write delimiter line.
       
   432         */
       
   433         void WriteDelimiterL( const TDesC& aDelimiter, TInt aCount );
       
   434         
       
   435         /**
       
   436         * Adds needed tags to get valid xml file.
       
   437         */
       
   438         void CloseXMLTagsInUnfinishedFileL(void);
       
   439 
       
   440     public:     // Data
       
   441     
       
   442     protected:  // Data
       
   443 
       
   444     private:    // Data
       
   445 
       
   446         // Report file handles
       
   447         RFs                             iFs;
       
   448         RFile                           iFile;
       
   449         TTEFTestReportLoggerType        iFormat;
       
   450         TTEFTestReportOutput            iOutput;
       
   451     
       
   452         // Report Mode
       
   453         TTestReportMode                 iReportMode;
       
   454 
       
   455         // Report HW info
       
   456         TTestHWInfo                     iReportHWInfo;
       
   457 
       
   458         // Total summary
       
   459         TTestSummary*                   iTotalSummary;
       
   460 
       
   461         // Test summary array
       
   462         RPointerArray<TTestSummary>     iTestSummaries;
       
   463         
       
   464         // Summary start position
       
   465         TInt                            iSummaryPos;
       
   466         
       
   467         // Versions of test modules position
       
   468         TInt                            iModulesVersionsPos;
       
   469         
       
   470         // Test modules versions
       
   471         RPointerArray<TTEFTestModuleVersionInfo> iTestModulesVersionsInfo;
       
   472 
       
   473         // Will report be written in xml format 
       
   474         TBool                           iXML;
       
   475 
       
   476     public:     // Friend classes
       
   477 
       
   478     protected:  // Friend classes
       
   479 
       
   480     private:    // Friend classes
       
   481 
       
   482     };
       
   483 
       
   484 #endif // TEF_TEST_REPORT_H
       
   485 
       
   486 // End of File