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