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