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