camera_plat/camcorder_ui_constants_api/tsrc/inc/CamAppPerfTest.h
branchRCL_3
changeset 24 bac7acad7cb3
parent 0 1ddebce53859
equal deleted inserted replaced
23:61bc0f252b2b 24:bac7acad7cb3
       
     1 /*
       
     2 * Copyright (c) 2002 - 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:  CamAppPerfTest test module.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef CAMAPPPERFTEST_H
       
    21 #define CAMAPPPERFTEST_H
       
    22 
       
    23 // INCLUDES
       
    24 #include "StifTestModule.h"
       
    25 #include <StifLogger.h>
       
    26 
       
    27 
       
    28 // MACROS
       
    29 #define TEST_MODULE_VERSION_MAJOR 0
       
    30 #define TEST_MODULE_VERSION_MINOR 0
       
    31 #define TEST_MODULE_VERSION_BUILD 0
       
    32 
       
    33 // Logging path
       
    34 _LIT( KCamAppPerfTestLogPath, "\\logs\\testframework\\CamAppPerfTest\\" ); 
       
    35 // Log file
       
    36 _LIT( KCamAppPerfTestLogFile, "CamAppPerfTest.txt" ); 
       
    37 _LIT( KCamAppPerfTestLogFileWithTitle, "CamAppPerfTest_[%S].txt" );
       
    38 
       
    39 #define GETPTR &
       
    40 #define ENTRY(str,func) {_S(str), GETPTR func,0,0,0}
       
    41 #define FUNCENTRY(func) {_S(#func), GETPTR func,0,0,0}
       
    42 #define OOM_ENTRY(str,func,a,b,c) {_S(str), GETPTR func,a,b,c}
       
    43 #define OOM_FUNCENTRY(func,a,b,c) {_S(#func), GETPTR func,a,b,c}
       
    44 
       
    45 // FORWARD DECLARATIONS
       
    46 class CCamAppPerfTest;
       
    47 
       
    48 // DATA TYPES
       
    49 // A typedef for function that does the actual testing,
       
    50 // function is a type 
       
    51 // TInt CCamAppPerfTest::<NameOfFunction> ( TTestResult& aResult )
       
    52 typedef TInt (CCamAppPerfTest::* TestFunction)(TTestResult&);
       
    53 
       
    54 // CLASS DECLARATION
       
    55 
       
    56 /**
       
    57 *  An internal structure containing a test case name and
       
    58 *  the pointer to function doing the test
       
    59 *
       
    60 *  @lib ?library
       
    61 *  @since ?Series60_version
       
    62 */
       
    63 class TCaseInfoInternal
       
    64     {
       
    65     public:
       
    66         const TText*    iCaseName;
       
    67         TestFunction    iMethod;
       
    68         TBool           iIsOOMTest;
       
    69         TInt            iFirstMemoryAllocation;
       
    70         TInt            iLastMemoryAllocation;
       
    71     };
       
    72 
       
    73 // CLASS DECLARATION
       
    74 
       
    75 /**
       
    76 *  A structure containing a test case name and
       
    77 *  the pointer to function doing the test
       
    78 *
       
    79 *  @lib ?library
       
    80 *  @since ?Series60_version
       
    81 */
       
    82 class TCaseInfo
       
    83     {
       
    84     public:
       
    85         TPtrC iCaseName;
       
    86         TestFunction iMethod;
       
    87         TBool           iIsOOMTest;
       
    88         TInt            iFirstMemoryAllocation;
       
    89         TInt            iLastMemoryAllocation;
       
    90 
       
    91     TCaseInfo( const TText* a ) : iCaseName( (TText*) a )
       
    92         {
       
    93         };
       
    94 
       
    95     };
       
    96 
       
    97 
       
    98 // CLASS DECLARATION
       
    99 
       
   100 /**
       
   101 *  This a CamAppPerfTest class.
       
   102 *  ?other_description_lines
       
   103 *
       
   104 *  @lib ?library
       
   105 *  @since ?Series60_version
       
   106 */
       
   107 NONSHARABLE_CLASS(CCamAppPerfTest) : public CTestModuleBase
       
   108     {
       
   109     public:  // Constructors and destructor
       
   110 
       
   111 
       
   112         /**
       
   113         * Two-phased constructor.
       
   114         */
       
   115         static CCamAppPerfTest* NewL();
       
   116 
       
   117         /**
       
   118         * Destructor.
       
   119         */
       
   120         virtual ~CCamAppPerfTest();
       
   121 
       
   122     public: // New functions
       
   123 
       
   124         /**
       
   125         * ?member_description.
       
   126         * @since ?Series60_version
       
   127         * @param ?arg1 ?description
       
   128         * @return ?description
       
   129         */
       
   130         //?type ?member_function( ?type ?arg1 );
       
   131 
       
   132     public: // Functions from base classes
       
   133 
       
   134         /**
       
   135         * From CTestModuleBase InitL is used to initialize the 
       
   136         *       CamAppPerfTest. It is called once for every instance of 
       
   137         *       TestModuleCamAppPerfTest after its creation.
       
   138         * @since ?Series60_version
       
   139         * @param aIniFile Initialization file for the test module (optional)
       
   140         * @param aFirstTime Flag is true when InitL is executed for first 
       
   141         *               created instance of CamAppPerfTest.
       
   142         * @return Symbian OS error code
       
   143         */
       
   144         TInt InitL( TFileName& aIniFile, TBool aFirstTime );
       
   145 
       
   146         /**
       
   147         * From CTestModuleBase GetTestCasesL is used to inquiry test cases 
       
   148         *   from CamAppPerfTest. 
       
   149         * @since ?Series60_version
       
   150         * @param aTestCaseFile Test case file (optional)
       
   151         * @param aTestCases  Array of TestCases returned to test framework
       
   152         * @return Symbian OS error code
       
   153         */
       
   154         TInt GetTestCasesL( const TFileName& aTestCaseFile, 
       
   155                             RPointerArray<TTestCaseInfo>& aTestCases );
       
   156 
       
   157         /**
       
   158         * From CTestModuleBase RunTestCaseL is used to run an individual 
       
   159         *   test case. 
       
   160         * @since ?Series60_version
       
   161         * @param aCaseNumber Test case number
       
   162         * @param aTestCaseFile Test case file (optional)
       
   163         * @param aResult Test case result returned to test framework (PASS/FAIL)
       
   164         * @return Symbian OS error code (test case execution error, which is 
       
   165         *           not reported in aResult parameter as test case failure).
       
   166         */   
       
   167         TInt RunTestCaseL( const TInt aCaseNumber, 
       
   168                            const TFileName& aTestCaseFile,
       
   169                            TTestResult& aResult );
       
   170 
       
   171         /**
       
   172         * From CTestModuleBase; OOMTestQueryL is used to specify is particular
       
   173         * test case going to be executed using OOM conditions
       
   174         * @param aTestCaseFile Test case file (optional)
       
   175         * @param aCaseNumber Test case number (optional)
       
   176         * @param aFailureType OOM failure type (optional)
       
   177         * @param aFirstMemFailure The first heap memory allocation failure value (optional)
       
   178         * @param aLastMemFailure The last heap memory allocation failure value (optional)
       
   179         * @return TBool
       
   180         */
       
   181         virtual TBool OOMTestQueryL( const TFileName& /* aTestCaseFile */, 
       
   182                                      const TInt /* aCaseNumber */, 
       
   183                                      TOOMFailureType& aFailureType, 
       
   184                                      TInt& /* aFirstMemFailure */, 
       
   185                                      TInt& /* aLastMemFailure */ );
       
   186 
       
   187         /**
       
   188         * From CTestModuleBase; OOMTestInitializeL may be used to initialize OOM
       
   189         * test environment
       
   190         * @param aTestCaseFile Test case file (optional)
       
   191         * @param aCaseNumber Test case number (optional)
       
   192         * @return None
       
   193         */
       
   194         virtual void OOMTestInitializeL( const TFileName& /* aTestCaseFile */, 
       
   195                                     const TInt /* aCaseNumber */ ); 
       
   196 
       
   197         /**
       
   198         * From CTestModuleBase; OOMHandleWarningL
       
   199         * @param aTestCaseFile Test case file (optional)
       
   200         * @param aCaseNumber Test case number (optional)
       
   201         * @param aFailNextValue FailNextValue for OOM test execution (optional)
       
   202         * @return None
       
   203         *
       
   204         * User may add implementation for OOM test warning handling. Usually no
       
   205         * implementation is required.           
       
   206         */
       
   207         virtual void OOMHandleWarningL( const TFileName& /* aTestCaseFile */,
       
   208                                         const TInt /* aCaseNumber */, 
       
   209                                         TInt& /* aFailNextValue */); 
       
   210 
       
   211         /**
       
   212         * From CTestModuleBase; OOMTestFinalizeL may be used to finalize OOM
       
   213         * test environment
       
   214         * @param aTestCaseFile Test case file (optional)
       
   215         * @param aCaseNumber Test case number (optional)
       
   216         * @return None
       
   217         *
       
   218         */
       
   219         virtual void OOMTestFinalizeL( const TFileName& /* aTestCaseFile */, 
       
   220                                        const TInt /* aCaseNumber */ );
       
   221         
       
   222         /**
       
   223          * Method used to log version of test module
       
   224          */
       
   225         void SendTestModuleVersion();
       
   226 
       
   227     protected:  // New functions
       
   228 
       
   229         /**
       
   230         * ?member_description.
       
   231         * @since ?Series60_version
       
   232         * @param ?arg1 ?description
       
   233         * @return ?description
       
   234         */
       
   235         //?type ?member_function( ?type ?arg1 );
       
   236 
       
   237     protected:  // Functions from base classes
       
   238 
       
   239         /**
       
   240         * From ?base_class ?member_description
       
   241         */
       
   242         //?type ?member_function();
       
   243 
       
   244     private:
       
   245 
       
   246         /**
       
   247         * C++ default constructor.
       
   248         */
       
   249         CCamAppPerfTest();
       
   250 
       
   251         /**
       
   252         * By default Symbian 2nd phase constructor is private.
       
   253         */
       
   254         void ConstructL();
       
   255 
       
   256         // Prohibit copy constructor if not deriving from CBase.
       
   257         // ?classname( const ?classname& );
       
   258         // Prohibit assigment operator if not deriving from CBase.
       
   259         // ?classname& operator=( const ?classname& );
       
   260 
       
   261         /**
       
   262         * Function returning test case name and pointer to test case function.
       
   263         * @since ?Series60_version
       
   264         * @param aCaseNumber test case number
       
   265         * @return TCaseInfo 
       
   266         */
       
   267         const TCaseInfo Case ( const TInt aCaseNumber ) const;
       
   268 
       
   269         /**
       
   270         * [test case declarations] - do not remove
       
   271         */
       
   272         //ADD NEW METHOD DEC HERE"
       
   273         
       
   274         /**
       
   275         * Camera App Performance Test
       
   276         * @since ?Series60_version
       
   277         * @param aResult Test case result (PASS/FAIL)
       
   278         * @return Symbian OS error code (test case execution error 
       
   279         *   that is not returned as test case result in aResult)
       
   280         */
       
   281         TInt PerfTest( TTestResult& aResult );
       
   282         void StartWaiting( TInt period );
       
   283         void KillIfAlive();
       
   284         void SendCaptureKeyEventToCamApp();
       
   285         void SendExitKeyEventToCamApp();
       
   286 
       
   287         /**
       
   288         * Printing test case.
       
   289         * @since ?Series60_version
       
   290         * @param aResult Test case result (PASS/FAIL)
       
   291         * @return Symbian OS error code (test case execution error 
       
   292         *   that is not returned as test case result in aResult)
       
   293         */
       
   294         TInt PrintTest( TTestResult& aResult );
       
   295 
       
   296         /**
       
   297         * Printing loop test case.
       
   298         * @since ?Series60_version
       
   299         * @param aResult Test case result (PASS/FAIL)
       
   300         * @return Symbian OS error code (test case execution error 
       
   301         *   that is not returned as test case result in aResult)
       
   302         */
       
   303         TInt LoopTest( TTestResult& aResult );
       
   304 
       
   305     private:    // Data
       
   306         // Pointer to test (function) to be executed
       
   307         TestFunction iMethod;
       
   308 
       
   309         // Pointer to logger
       
   310         CStifLogger * iLog; 
       
   311 
       
   312         // Normal logger
       
   313         CStifLogger* iStdLog;
       
   314 
       
   315         // Test case logger
       
   316         CStifLogger* iTCLog;
       
   317 
       
   318         // Flag saying if test case title should be added to log file name
       
   319         TBool iAddTestCaseTitleToLogName;
       
   320 
       
   321         // Flag saying if version of test module was already sent
       
   322         TBool iVersionLogged;
       
   323     };
       
   324 
       
   325 #endif      // CAMAPPPERFTEST_H
       
   326 
       
   327 // End of File