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