localconnectivityservice/locod/tsrc/locodTest/inc/daemonmt.h
changeset 54 4dc88a4ac6f4
equal deleted inserted replaced
52:866b4af7ffbe 54:4dc88a4ac6f4
       
     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:  daemonmt test module.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef DAEMONMT_H
       
    21 #define DAEMONMT_H
       
    22 
       
    23 // INCLUDES
       
    24 #include "StifTestModule.h"
       
    25 #include <StifLogger.h>
       
    26 #include <e32property.h>
       
    27 #include "BtSettings.h"
       
    28 
       
    29 // CONSTANTS
       
    30 //const ?type ?constant_var = ?constant;
       
    31 
       
    32 // MACROS
       
    33 //#define ?macro ?macro_def
       
    34 
       
    35 // Logging path
       
    36 _LIT( KdaemonmtLogPath, "\\logs\\testframework\\daemonmt\\" ); 
       
    37 // Log file
       
    38 _LIT( KdaemonmtLogFile, "daemonmt.txt" ); 
       
    39 
       
    40 // Function pointer related internal definitions
       
    41 // Visual studio 6.0 (__VC32__) needs different type of handling 
       
    42 #ifdef __VC32__
       
    43 #define GETPTR
       
    44 #else
       
    45 #define GETPTR &
       
    46 #endif  
       
    47 #define ENTRY(str,func) {_S(str), GETPTR func,0,0,0}
       
    48 #define FUNCENTRY(func) {_S(#func), GETPTR func,0,0,0}
       
    49 #define OOM_ENTRY(str,func,a,b,c) {_S(str), GETPTR func,a,b,c}
       
    50 #define OOM_FUNCENTRY(func,a,b,c) {_S(#func), GETPTR func,a,b,c}
       
    51 
       
    52 // FUNCTION PROTOTYPES
       
    53 //?type ?function_name(?arg_list);
       
    54 
       
    55 // FORWARD DECLARATIONS
       
    56 //class ?FORWARD_CLASSNAME;
       
    57 class Cdaemonmt;
       
    58 
       
    59 // DATA TYPES
       
    60 //enum ?declaration
       
    61 //typedef ?declaration
       
    62 //extern ?data_type;
       
    63 // A typedef for function that does the actual testing,
       
    64 // function is a type 
       
    65 // TInt Cdaemonmt::<NameOfFunction> ( TTestResult& aResult )
       
    66 typedef TInt (Cdaemonmt::* TestFunction)(TTestResult&);
       
    67 
       
    68 // CLASS DECLARATION
       
    69 
       
    70 /**
       
    71 *  An internal structure containing a test case name and
       
    72 *  the pointer to function doing the test
       
    73 *
       
    74 *  @lib ?library
       
    75 *  @since ?Series60_version
       
    76 */
       
    77 class TCaseInfoInternal
       
    78     {
       
    79     public:
       
    80         const TText*    iCaseName;
       
    81         TestFunction    iMethod;
       
    82         TBool           iIsOOMTest;
       
    83         TInt            iFirstMemoryAllocation;
       
    84         TInt            iLastMemoryAllocation;
       
    85     };
       
    86 
       
    87 // CLASS DECLARATION
       
    88 
       
    89 /**
       
    90 *  A structure containing a test case name and
       
    91 *  the pointer to function doing the test
       
    92 *
       
    93 *  @lib ?library
       
    94 *  @since ?Series60_version
       
    95 */
       
    96 class TCaseInfo
       
    97     {
       
    98     public:
       
    99         TPtrC iCaseName;
       
   100         TestFunction iMethod;
       
   101         TBool           iIsOOMTest;
       
   102         TInt            iFirstMemoryAllocation;
       
   103         TInt            iLastMemoryAllocation;
       
   104 
       
   105     TCaseInfo( const TText* a ) : iCaseName( (TText*) a )
       
   106         {
       
   107         };
       
   108 
       
   109     };
       
   110 
       
   111 
       
   112 // CLASS DECLARATION
       
   113 
       
   114 /**
       
   115 *  This a daemonmt class.
       
   116 *  ?other_description_lines
       
   117 *
       
   118 *  @lib ?library
       
   119 *  @since ?Series60_version
       
   120 */
       
   121 NONSHARABLE_CLASS(Cdaemonmt) : public CTestModuleBase
       
   122     {
       
   123     public:  // Constructors and destructor
       
   124 
       
   125 
       
   126         /**
       
   127         * Two-phased constructor.
       
   128         */
       
   129         static Cdaemonmt* NewL();
       
   130 
       
   131         /**
       
   132         * Destructor.
       
   133         */
       
   134         virtual ~Cdaemonmt();
       
   135 
       
   136     public: // New functions
       
   137 
       
   138         /**
       
   139         * ?member_description.
       
   140         * @since ?Series60_version
       
   141         * @param ?arg1 ?description
       
   142         * @return ?description
       
   143         */
       
   144         //?type ?member_function( ?type ?arg1 );
       
   145 
       
   146     public: // Functions from base classes
       
   147 
       
   148         /**
       
   149         * From CTestModuleBase InitL is used to initialize the 
       
   150         *       daemonmt. It is called once for every instance of 
       
   151         *       TestModuledaemonmt after its creation.
       
   152         * @since ?Series60_version
       
   153         * @param aIniFile Initialization file for the test module (optional)
       
   154         * @param aFirstTime Flag is true when InitL is executed for first 
       
   155         *               created instance of daemonmt.
       
   156         * @return Symbian OS error code
       
   157         */
       
   158         TInt InitL( TFileName& aIniFile, TBool aFirstTime );
       
   159 
       
   160         /**
       
   161         * From CTestModuleBase GetTestCasesL is used to inquiry test cases 
       
   162         *   from daemonmt. 
       
   163         * @since ?Series60_version
       
   164         * @param aTestCaseFile Test case file (optional)
       
   165         * @param aTestCases  Array of TestCases returned to test framework
       
   166         * @return Symbian OS error code
       
   167         */
       
   168         TInt GetTestCasesL( const TFileName& aTestCaseFile, 
       
   169                             RPointerArray<TTestCaseInfo>& aTestCases );
       
   170 
       
   171         /**
       
   172         * From CTestModuleBase RunTestCaseL is used to run an individual 
       
   173         *   test case. 
       
   174         * @since ?Series60_version
       
   175         * @param aCaseNumber Test case number
       
   176         * @param aTestCaseFile Test case file (optional)
       
   177         * @param aResult Test case result returned to test framework (PASS/FAIL)
       
   178         * @return Symbian OS error code (test case execution error, which is 
       
   179         *           not reported in aResult parameter as test case failure).
       
   180         */   
       
   181         TInt RunTestCaseL( const TInt aCaseNumber, 
       
   182                            const TFileName& aTestCaseFile,
       
   183                            TTestResult& aResult );
       
   184 
       
   185         /**
       
   186         * From CTestModuleBase; OOMTestQueryL is used to specify is particular
       
   187         * test case going to be executed using OOM conditions
       
   188         * @param aTestCaseFile Test case file (optional)
       
   189         * @param aCaseNumber Test case number (optional)
       
   190         * @param aFailureType OOM failure type (optional)
       
   191         * @param aFirstMemFailure The first heap memory allocation failure value (optional)
       
   192         * @param aLastMemFailure The last heap memory allocation failure value (optional)
       
   193         * @return TBool
       
   194         */
       
   195         virtual TBool OOMTestQueryL( const TFileName& /* aTestCaseFile */, 
       
   196                                      const TInt /* aCaseNumber */, 
       
   197                                      TOOMFailureType& aFailureType, 
       
   198                                      TInt& /* aFirstMemFailure */, 
       
   199                                      TInt& /* aLastMemFailure */ );
       
   200 
       
   201         /**
       
   202         * From CTestModuleBase; OOMTestInitializeL may be used to initialize OOM
       
   203         * test environment
       
   204         * @param aTestCaseFile Test case file (optional)
       
   205         * @param aCaseNumber Test case number (optional)
       
   206         * @return None
       
   207         */
       
   208         virtual void OOMTestInitializeL( const TFileName& /* aTestCaseFile */, 
       
   209                                     const TInt /* aCaseNumber */ ); 
       
   210 
       
   211         /**
       
   212         * From CTestModuleBase; OOMHandleWarningL
       
   213         * @param aTestCaseFile Test case file (optional)
       
   214         * @param aCaseNumber Test case number (optional)
       
   215         * @param aFailNextValue FailNextValue for OOM test execution (optional)
       
   216         * @return None
       
   217         *
       
   218         * User may add implementation for OOM test warning handling. Usually no
       
   219         * implementation is required.           
       
   220         */
       
   221         virtual void OOMHandleWarningL( const TFileName& /* aTestCaseFile */,
       
   222                                         const TInt /* aCaseNumber */, 
       
   223                                         TInt& /* aFailNextValue */); 
       
   224 
       
   225         /**
       
   226         * From CTestModuleBase; OOMTestFinalizeL may be used to finalize OOM
       
   227         * test environment
       
   228         * @param aTestCaseFile Test case file (optional)
       
   229         * @param aCaseNumber Test case number (optional)
       
   230         * @return None
       
   231         *
       
   232         */
       
   233         virtual void OOMTestFinalizeL( const TFileName& /* aTestCaseFile */, 
       
   234                                        const TInt /* aCaseNumber */ );
       
   235 
       
   236     protected:  // New functions
       
   237 
       
   238         /**
       
   239         * ?member_description.
       
   240         * @since ?Series60_version
       
   241         * @param ?arg1 ?description
       
   242         * @return ?description
       
   243         */
       
   244         //?type ?member_function( ?type ?arg1 );
       
   245 
       
   246     protected:  // Functions from base classes
       
   247 
       
   248         /**
       
   249         * From ?base_class ?member_description
       
   250         */
       
   251         //?type ?member_function();
       
   252 
       
   253     private:
       
   254 
       
   255         /**
       
   256         * C++ default constructor.
       
   257         */
       
   258         Cdaemonmt();
       
   259 
       
   260         /**
       
   261         * By default Symbian 2nd phase constructor is private.
       
   262         */
       
   263         void ConstructL();
       
   264 
       
   265         /**
       
   266          * Callback for CPeriodic.
       
   267          */
       
   268         static TInt PeriodicTimerCallBack(TAny* aAny);
       
   269         
       
   270         /**
       
   271         * Function returning test case name and pointer to test case function.
       
   272         * @since ?Series60_version
       
   273         * @param aCaseNumber test case number
       
   274         * @return TCaseInfo 
       
   275         */
       
   276         const TCaseInfo Case ( const TInt aCaseNumber ) const;
       
   277 
       
   278         /**
       
   279         * Actual Hardcoded test case functions are listed below.
       
   280         */
       
   281         
       
   282         TInt StartDaemon( TTestResult& aResult );
       
   283 
       
   284         
       
   285     private:    // Data
       
   286         // Pointer to test (function) to be executed
       
   287         TestFunction iMethod;
       
   288 
       
   289         // Pointer to logger
       
   290         CStifLogger * iLog;
       
   291         
       
   292         CActiveScheduler* iScheduler;
       
   293         
       
   294         RProperty iProperty;
       
   295         
       
   296         CBtSettings* iBtSettings;
       
   297     };
       
   298 
       
   299 #endif      // DAEMONMT_H
       
   300 
       
   301 // End of File