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