uiacceltk/hitchcock/tsrc/alfperfapp/inc/alfperfappmodel.h
changeset 0 15bf7259bb7c
equal deleted inserted replaced
-1:000000000000 0:15bf7259bb7c
       
     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 "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:  alfperfapp model class definition.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef C_ALFPERFAPPMODEL_H
       
    20 #define C_ALFPERFAPPMODEL_H
       
    21 
       
    22 #include <e32base.h>
       
    23 #include <f32file.h>
       
    24 
       
    25 #include "alfperfappconstants.h"
       
    26 class CDesC16ArrayFlat;
       
    27 class CAlfPerfAppModelTestSuite;
       
    28 
       
    29 
       
    30 /**
       
    31  *  CAlfPerfAppModel model class.
       
    32  *  This class records test cases to be executed as well as 
       
    33  *  results of those cases.
       
    34  */
       
    35 class CAlfPerfAppModel : public CBase
       
    36     {
       
    37 public:
       
    38 
       
    39     struct TTestCaseResultItem
       
    40         {
       
    41         // Header
       
    42         TBuf8<KAlfPerfAppMaxCharsInLine> iSuiteName;
       
    43         TBuf8<KAlfPerfAppMaxCharsInLine> iCaseName;
       
    44         TInt iCaseId;				// Case id
       
    45         TInt iPhase; 				// Phase: 0=startup, 1=run, 2=teardown
       
    46         
       
    47         // Data
       
    48         TUint32 iTimeStamp;         // Timestamp
       
    49         TUint32 imsSinceCase;       // ms since case start
       
    50         TUint32 imsSincePhase;      // ms since phase start
       
    51         
       
    52         // Application memory
       
    53         TInt iAppCells;
       
    54         TInt iAppMemory;
       
    55         TInt iAppFree;
       
    56         
       
    57         // Server memory
       
    58         TInt iServerCells;
       
    59         TInt iServerMemory;
       
    60         TInt iServerFree;
       
    61 
       
    62         // Frame count from server
       
    63         TUint iFrameCount; // Frames from beginning of phase
       
    64         TReal32 iFPS;        // During this phase
       
    65         
       
    66         // System total memory consumption
       
    67         TInt iSystemMemory;
       
    68         TInt iSystemFree;
       
    69         
       
    70         // Testcase specifig result
       
    71         TBuf8<KAlfPerfAppMaxCharsInSpecificResultText> specificResult8;
       
    72 		};
       
    73 
       
    74    
       
    75 public:
       
    76     static CAlfPerfAppModel* NewL();
       
    77     ~CAlfPerfAppModel();
       
    78     
       
    79     //
       
    80     // Test set management functions
       
    81     //
       
    82     
       
    83     /**
       
    84      * Loads test set.
       
    85      * @param aResourceId resource id for test set.
       
    86      */
       
    87     void LoadTestSetL( TInt aResourceId );
       
    88     
       
    89     /**
       
    90      * Returns amount of test suites.
       
    91      * @return amount of test suites.
       
    92      */
       
    93     TInt SuiteCount() const;
       
    94     
       
    95     /**
       
    96      * Returns name of specified suite.
       
    97      * @param aSuiteIndex index to suite.
       
    98      * @return name of suite.     
       
    99      */
       
   100     TPtrC SuiteName( TInt aSuiteIndex ) const;
       
   101 
       
   102     /**
       
   103      * Returns flags of specified suite.
       
   104      * @param aSuiteIndex index to suite.
       
   105      * @return flags of suite.     
       
   106      */
       
   107     TInt SuiteFlags( TInt aSuiteIndex ) const;
       
   108 
       
   109     /**
       
   110      * Returns amount of test cases in specified suite.
       
   111      * @param aSuiteIndex index to suite.
       
   112      * @return amount of test cases in the suite.
       
   113      */
       
   114     TInt TestCaseCount( TInt aSuiteIndex ) const;
       
   115 
       
   116     /**
       
   117      * Gets information about specified suite.
       
   118      * @param aSuiteIndex index to suite.
       
   119      * @param aTestCaseIndex index inside suite.
       
   120      * @param aTestCaseName this is updated to point to name.
       
   121      * @param aTestCaseId this is updated to hold case id.
       
   122      */
       
   123     void GetTestCase( 
       
   124         TInt aSuiteIndex, 
       
   125         TInt aTestCaseIndex, 
       
   126         TPtrC& aTestCaseName,
       
   127         TInt& aTestCaseId,
       
   128         TInt& aTestCaseFlags,
       
   129         TInt& aTestCaseSequenceLength ) const;
       
   130     
       
   131     /**
       
   132      * Finds test suite name & test case name by case id.
       
   133      * @param aCaseId test case id.
       
   134      * @param aSuiteName this is updated to point to suite name.
       
   135      * @param aTestCaseName this is updated to point to test case name.
       
   136      * @return KErrNone in success, KErrNotFound if not found.
       
   137      */
       
   138     TInt FindById( 
       
   139         TInt aCaseId,
       
   140         TPtrC& aSuiteName,
       
   141         TPtrC& aTestCaseName ) const;
       
   142         
       
   143    	//
       
   144     // Execute array management functions
       
   145     //    
       
   146     /**
       
   147      * Resets execute test cases array.
       
   148      */
       
   149     void ResetExecuteArray();
       
   150     
       
   151     /**
       
   152      * Appends a case to execute array.
       
   153      * @param aCaseId case to be added.
       
   154      */
       
   155     void AddToExecuteArrayL( TInt aCaseId );
       
   156         
       
   157     /**
       
   158      * Gets first test case to be executed.
       
   159      * This also removes that item from array.
       
   160      */
       
   161     TBool GetFromExecuteArray( TInt& aCaseId );
       
   162 
       
   163     //
       
   164     // Test results management functions
       
   165     //
       
   166     /**
       
   167      * Appends a result item to result files.
       
   168      * @param aItem result item to be added.
       
   169      */
       
   170 	void AddToResultFilesL( const TTestCaseResultItem& aItem);
       
   171 
       
   172 	   
       
   173 	/**
       
   174 	 * Adds error.
       
   175 	 * @param aMessage message to be added.
       
   176 	 */
       
   177 	void AddToErrorArrayL( const TDesC& aMessage );
       
   178 	
       
   179 	/**
       
   180 	 * Returns total amount of error messages.
       
   181 	 * @return total amounf of error messages.
       
   182 	 */
       
   183 	TInt ErrorArrayCount();
       
   184 	
       
   185 	/**
       
   186 	 * Gets error message.
       
   187 	 * @param aIndex index from which to take.
       
   188 	 * @param aMessage message.
       
   189 	 */
       
   190 	void GetFromErrorArray( TInt aIndex, TPtrC& aMessage );
       
   191     
       
   192     /**
       
   193      * Resets error array.
       
   194      */
       
   195     void ResetErrorArray();
       
   196     
       
   197     /*
       
   198      *  Tells if there are any results available in file.
       
   199      */
       
   200     TBool ResultsNotAddedToFile();
       
   201     
       
   202     /*
       
   203      *  Returns pointer to the file which results are written to
       
   204      */
       
   205     RFile* ResultFile();
       
   206     
       
   207 
       
   208     /*
       
   209      * Returns the target path location.
       
   210      */
       
   211     TFileName TargetPath();    
       
   212     
       
   213     /*
       
   214      * Returns if the files existed when the program was launched.
       
   215      */
       
   216     TBool TargetFilesExisted();
       
   217     
       
   218     /*
       
   219      * Opens the result files for appending. Creates new ones if necessary.
       
   220      * If reset is set to ETrue, forces recreation.
       
   221      */
       
   222     void OpenFilesL(TBool reset = EFalse);
       
   223     
       
   224 private:
       
   225 
       
   226     CAlfPerfAppModel();
       
   227     void ConstructL();
       
   228 
       
   229 private:
       
   230 
       
   231     /**
       
   232      * Test suites.
       
   233      * Owned.
       
   234      */
       
   235     RPointerArray< CAlfPerfAppModelTestSuite > iSuites;
       
   236     
       
   237     /**
       
   238      * Array of cases to be executed.
       
   239      * Owned.
       
   240      */
       
   241     RArray< TInt > iExecuteTestCases;
       
   242 
       
   243     /**
       
   244      * Array of error messages.
       
   245      * Owned.
       
   246      */
       
   247     CDesC16ArrayFlat* iErrorMessages;
       
   248 
       
   249     TBool   iFilesOpened;
       
   250     TBool   iFilesExisted;
       
   251     TFileName iTargetPath;
       
   252     
       
   253     RFs iTargetFileServerSession;
       
   254     TFileName iTargetFileName;
       
   255     RFile iTargetFile;
       
   256     
       
   257     TBool iResultItemsNotAddedToFile;
       
   258     
       
   259     TFileName iSummaryFileName;
       
   260     RFile iSummaryFile;
       
   261     TFileText iSummaryWriteFileText;
       
   262     
       
   263     };
       
   264 
       
   265 #endif // C_ALFPERFAPPMODEL_H
       
   266             
       
   267 // End of File