videoutils_plat/videoconnutility_api/tsrc/VCXTestCommon/inc/VCXTestStatsKeeper.h
branchRCL_3
changeset 22 826cea16efd9
parent 21 798ee5f1972c
child 23 13a33d82ad98
equal deleted inserted replaced
21:798ee5f1972c 22:826cea16efd9
     1 /*
       
     2 * Copyright (c) 2008 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 the License "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: 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef VCXTESTSTATSKEEPER_H
       
    20 #define VCXTESTSTATSKEEPER_H
       
    21 
       
    22 //  INCLUDES
       
    23 #include <e32base.h>
       
    24 
       
    25 // CONSTANTS
       
    26 
       
    27 // MACROS
       
    28 
       
    29 // DATA TYPES
       
    30 
       
    31 // FUNCTION PROTOTYPES
       
    32 
       
    33 // FORWARD DECLARATIONS
       
    34 
       
    35 // CLASS DECLARATION
       
    36 
       
    37 /**
       
    38 * Class to hold a single statistics item.
       
    39 */
       
    40 class CVCXTestStatsItem : public CBase
       
    41     {
       
    42     public:  // Constructors and destructor
       
    43     
       
    44         /**
       
    45         * Two-phased constructor.
       
    46         */
       
    47         static CVCXTestStatsItem* NewL();
       
    48 
       
    49         /**
       
    50         * Destructor.
       
    51         */
       
    52         virtual ~CVCXTestStatsItem();
       
    53 	
       
    54     private:
       
    55 
       
    56         /**
       
    57         * C++ default constructor.
       
    58         */
       
    59         CVCXTestStatsItem();
       
    60 
       
    61         /**
       
    62         * By default Symbian 2nd phase constructor is private.
       
    63         */
       
    64         void ConstructL();
       
    65     
       
    66     public: // Data
       
    67 
       
    68         TBool iIsActive;
       
    69         
       
    70         TInt32 iId;
       
    71         HBufC* iDescId;
       
    72         HBufC* iDesc;
       
    73         TInt iError;
       
    74         TTime iStartTime;
       
    75         TTime iEndTime;
       
    76         
       
    77         RPointerArray<HBufC> iTraces;
       
    78         RPointerArray<CVCXTestStatsItem> iProgresses;
       
    79     };
       
    80 
       
    81 /**
       
    82 * Class to hold summary for statistics.
       
    83 */
       
    84 class CVCXTestStatsItemSummary : public CBase
       
    85     {
       
    86     public:  // Constructors and destructor
       
    87         
       
    88         /**
       
    89         * Two-phased constructor.
       
    90         */
       
    91         static CVCXTestStatsItemSummary* NewL();
       
    92 
       
    93         /**
       
    94         * Destructor.
       
    95         */
       
    96         virtual ~CVCXTestStatsItemSummary();
       
    97     
       
    98     private:
       
    99 
       
   100         /**
       
   101         * C++ default constructor.
       
   102         */
       
   103         CVCXTestStatsItemSummary();
       
   104 
       
   105         /**
       
   106         * By default Symbian 2nd phase constructor is private.
       
   107         */
       
   108         void ConstructL();
       
   109     
       
   110     public: // Data
       
   111         TInt32 iId;
       
   112         HBufC* iDescId;
       
   113         HBufC* iDesc;
       
   114         
       
   115         TUint iCount;
       
   116         TUint iFailCount;
       
   117 
       
   118         // These are all microseconds.
       
   119         TInt64 iMinTime;
       
   120         TInt64 iMaxTime;
       
   121         TReal iAvgTime;
       
   122         
       
   123         TInt64 iTotalTime;
       
   124         TInt64 iFailTime;
       
   125     };
       
   126 
       
   127 /**
       
   128 * Class to keep track of statistics.
       
   129 */
       
   130 class CVCXTestStatsKeeper : public CBase
       
   131     {
       
   132     public:  // Constructors and destructor
       
   133     
       
   134         /**
       
   135         * Two-phased constructor.
       
   136         */
       
   137         IMPORT_C static CVCXTestStatsKeeper* NewL();
       
   138 
       
   139         /**
       
   140         * Destructor.
       
   141         */
       
   142         virtual ~CVCXTestStatsKeeper ();
       
   143 
       
   144     public: // New functions
       
   145 
       
   146     	/**
       
   147     	* Sets the name and filename for statistics. Report is written when class is desctructed.
       
   148     	*/
       
   149 		IMPORT_C void StartStatsKeepingL( const TDesC& aName, const TDesC& aFileName );
       
   150 
       
   151 		/**
       
   152 		 * Adds an action to the statistics lists.
       
   153 		 */
       
   154 		IMPORT_C void ActionStartL( TInt32 aId, const TDesC& aDesc );
       
   155 
       
   156         /**
       
   157          * Adds an action to the statistics lists. 
       
   158          * if param aDescMerge is true then action descsription will contain the descid. 
       
   159          */
       
   160         IMPORT_C void ActionStartL( const TDesC& aDescId, const TDesC& aDesc, TBool aDescMerge = EFalse );
       
   161 		
       
   162 		/**
       
   163 		 * Ends an action.
       
   164 		 * Leaves with KErrAbort if more than 33% of actions have failed. Test should abort itself in that case.
       
   165 		 */
       
   166 		IMPORT_C void ActionEndL( TInt32 aId, TInt aError );
       
   167 
       
   168         /**
       
   169          * Ends an action.
       
   170          * Leaves with KErrAbort if more than 33% of actions have failed. Test should abort itself in that case.
       
   171          */
       
   172         IMPORT_C void ActionEndL( const TDesC& aDescId, TInt aError );
       
   173 		
       
   174 		/**
       
   175 		 * Sets progress information for an action. These are saved in the report.
       
   176 		 */
       
   177 		IMPORT_C void ActionProgressL( TInt32 aId, const TDesC& aProgressDesc );
       
   178 
       
   179         /**
       
   180          * Sets progress information for an action. These are saved in the report.
       
   181          */
       
   182         IMPORT_C void ActionProgressL( const TDesC& aDescId, const TDesC& aProgressDesc );
       
   183 		
       
   184 		/**
       
   185 		 * Generic trace for different actions. Last 20 of these are saved in the report only if action fails.
       
   186 		 */
       
   187 		IMPORT_C void ActionTraceL( const TDesC& aDesc );
       
   188 		
       
   189     private:
       
   190 
       
   191         /**
       
   192         * C++ default constructor.
       
   193         */
       
   194         CVCXTestStatsKeeper();
       
   195 
       
   196         /**
       
   197         * By default Symbian 2nd phase constructor is private.
       
   198         */
       
   199         void ConstructL();
       
   200 
       
   201     private: // New functions.
       
   202         
       
   203         CVCXTestStatsItem* GetActiveAction( TInt32 aId );
       
   204         
       
   205         CVCXTestStatsItem* GetActiveAction( const TDesC& aDesc );
       
   206         
       
   207         CVCXTestStatsItem* GetLastActiveAction( TBool aOnlyDescId );
       
   208         
       
   209         TInt FormatDate( const TTime& aDate, TDes& aStr );
       
   210         
       
   211         void GenerateReportL( const TDesC& aFileName, TBool aFullReport );
       
   212         
       
   213         TUint DataSizeL();
       
   214         
       
   215         void CheckFailsL();
       
   216 
       
   217         void GetActionSummariesL( RPointerArray<CVCXTestStatsItemSummary>& aSummaries, TBool aFailActiveActions );
       
   218         
       
   219     private:    // Data
       
   220 
       
   221         TBool iStarted;
       
   222         
       
   223         HBufC* iReportName;
       
   224         
       
   225         HBufC* iReportFileName;       
       
   226         
       
   227         RPointerArray<CVCXTestStatsItem> iActions;
       
   228         
       
   229         RPointerArray<HBufC> iTraces;
       
   230         
       
   231         TBool iAbortedBecauseTooManyFails;
       
   232     };
       
   233 
       
   234 #endif      // VCXTESTSTATSKEEPER_H
       
   235 
       
   236 // End of File