wvsettings20/tsrc/basic/private/inc/wvsapsettingstest.h
branchRCL_3
changeset 13 a941bc465d9f
parent 0 094583676ce7
equal deleted inserted replaced
12:6ca72c0fe49a 13:a941bc465d9f
       
     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:  wvsapsettingstest test module.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef WVSAPSETTINGSTEST_H
       
    21 #define WVSAPSETTINGSTEST_H
       
    22 
       
    23 // INCLUDES
       
    24 #include "StifTestModule.h"
       
    25 #include <StifLogger.h>
       
    26 
       
    27 //header files needed for the test cases
       
    28 #include <CIMPSSAPSettings.h>
       
    29 #include <CIMPSSAPSettingsStore.h>
       
    30 
       
    31 #include "WVSAPSettingsObserverTestCases.h"
       
    32 
       
    33 // CONSTANTS
       
    34 //const ?type ?constant_var = ?constant;
       
    35 
       
    36 // MACROS
       
    37 //#define ?macro ?macro_def
       
    38 
       
    39 // Logging path
       
    40 _LIT( KwvsapsettingstestLogPath, "\\logs\\testframework\\wvsapsettingstest\\" );
       
    41 // Log file
       
    42 _LIT( KwvsapsettingstestLogFile, "wvsapsettingstest.txt" );
       
    43 _LIT( KwvsapsettingstestLogFileWithTitle, "wvsapsettingstest_[%S].txt" );
       
    44 
       
    45 #define GETPTR &
       
    46 #define ENTRY(str,func) {_S(str), GETPTR func,0,0,0}
       
    47 #define FUNCENTRY(func) {_S(#func), GETPTR func,0,0,0}
       
    48 #define OOM_ENTRY(str,func,a,b,c) {_S(str), GETPTR func,a,b,c}
       
    49 #define OOM_FUNCENTRY(func,a,b,c) {_S(#func), GETPTR func,a,b,c}
       
    50 
       
    51 // FUNCTION PROTOTYPES
       
    52 //?type ?function_name(?arg_list);
       
    53 
       
    54 // FORWARD DECLARATIONS
       
    55 //class ?FORWARD_CLASSNAME;
       
    56 class Cwvsapsettingstest;
       
    57 
       
    58 // DATA TYPES
       
    59 //enum ?declaration
       
    60 //typedef ?declaration
       
    61 //extern ?data_type;
       
    62 // A typedef for function that does the actual testing,
       
    63 // function is a type
       
    64 // TInt Cwvsapsettingstest::<NameOfFunction> ( TTestResult& aResult )
       
    65 typedef TInt ( Cwvsapsettingstest::* TestFunction )( TTestResult& );
       
    66 //typedef TInt (WVSAPSettingsObserverTestCases:: * 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 wvsapsettingstest class.
       
   116 *  ?other_description_lines
       
   117 *
       
   118 *  @lib ?library
       
   119 *  @since ?Series60_version
       
   120 */
       
   121 NONSHARABLE_CLASS( Cwvsapsettingstest ) : public CTestModuleBase
       
   122     {
       
   123 public:  // Constructors and destructor
       
   124 
       
   125 
       
   126     /**
       
   127     * Two-phased constructor.
       
   128     */
       
   129     static Cwvsapsettingstest* NewL();
       
   130 
       
   131     /**
       
   132     * Destructor.
       
   133     */
       
   134     virtual ~Cwvsapsettingstest();
       
   135     //~Cwvsapsettingstest();
       
   136 
       
   137 public: // New functions
       
   138 
       
   139     /**
       
   140     * ?member_description.
       
   141     * @since ?Series60_version
       
   142     * @param ?arg1 ?description
       
   143     * @return ?description
       
   144     */
       
   145     //?type ?member_function( ?type ?arg1 );
       
   146 
       
   147 public: // Functions from base classes
       
   148 
       
   149     /**
       
   150     * From CTestModuleBase InitL is used to initialize the
       
   151     *       wvsapsettingstest. It is called once for every instance of
       
   152     *       TestModulewvsapsettingstest after its creation.
       
   153     * @since ?Series60_version
       
   154     * @param aIniFile Initialization file for the test module (optional)
       
   155     * @param aFirstTime Flag is true when InitL is executed for first
       
   156     *               created instance of wvsapsettingstest.
       
   157     * @return Symbian OS error code
       
   158     */
       
   159     TInt InitL( TFileName& aIniFile, TBool aFirstTime );
       
   160 
       
   161     /**
       
   162     * From CTestModuleBase GetTestCasesL is used to inquiry test cases
       
   163     *   from wvsapsettingstest.
       
   164     * @since ?Series60_version
       
   165     * @param aTestCaseFile Test case file (optional)
       
   166     * @param aTestCases  Array of TestCases returned to test framework
       
   167     * @return Symbian OS error code
       
   168     */
       
   169     TInt GetTestCasesL( const TFileName& aTestCaseFile,
       
   170                         RPointerArray<TTestCaseInfo>& aTestCases );
       
   171 
       
   172     /**
       
   173     * From CTestModuleBase RunTestCaseL is used to run an individual
       
   174     *   test case.
       
   175     * @since ?Series60_version
       
   176     * @param aCaseNumber Test case number
       
   177     * @param aTestCaseFile Test case file (optional)
       
   178     * @param aResult Test case result returned to test framework (PASS/FAIL)
       
   179     * @return Symbian OS error code (test case execution error, which is
       
   180     *           not reported in aResult parameter as test case failure).
       
   181     */
       
   182     TInt RunTestCaseL( const TInt aCaseNumber,
       
   183                        const TFileName& aTestCaseFile,
       
   184                        TTestResult& aResult );
       
   185 
       
   186     /**
       
   187     * From CTestModuleBase; OOMTestQueryL is used to specify is particular
       
   188     * test case going to be executed using OOM conditions
       
   189     * @param aTestCaseFile Test case file (optional)
       
   190     * @param aCaseNumber Test case number (optional)
       
   191     * @param aFailureType OOM failure type (optional)
       
   192     * @param aFirstMemFailure The first heap memory allocation failure value (optional)
       
   193     * @param aLastMemFailure The last heap memory allocation failure value (optional)
       
   194     * @return TBool
       
   195     */
       
   196     virtual TBool OOMTestQueryL( const TFileName& /* aTestCaseFile */,
       
   197                                  const TInt /* aCaseNumber */,
       
   198                                  TOOMFailureType& aFailureType,
       
   199                                  TInt& /* aFirstMemFailure */,
       
   200                                  TInt& /* aLastMemFailure */ );
       
   201 
       
   202     /**
       
   203     * From CTestModuleBase; OOMTestInitializeL may be used to initialize OOM
       
   204     * test environment
       
   205     * @param aTestCaseFile Test case file (optional)
       
   206     * @param aCaseNumber Test case number (optional)
       
   207     * @return None
       
   208     */
       
   209     virtual void OOMTestInitializeL( const TFileName& /* aTestCaseFile */,
       
   210                                      const TInt /* aCaseNumber */ );
       
   211 
       
   212     /**
       
   213     * From CTestModuleBase; OOMHandleWarningL
       
   214     * @param aTestCaseFile Test case file (optional)
       
   215     * @param aCaseNumber Test case number (optional)
       
   216     * @param aFailNextValue FailNextValue for OOM test execution (optional)
       
   217     * @return None
       
   218     *
       
   219     * User may add implementation for OOM test warning handling. Usually no
       
   220     * implementation is required.
       
   221     */
       
   222     virtual void OOMHandleWarningL( const TFileName& /* aTestCaseFile */,
       
   223                                     const TInt /* aCaseNumber */,
       
   224                                     TInt& /* aFailNextValue */ );
       
   225 
       
   226     /**
       
   227     * From CTestModuleBase; OOMTestFinalizeL may be used to finalize OOM
       
   228     * test environment
       
   229     * @param aTestCaseFile Test case file (optional)
       
   230     * @param aCaseNumber Test case number (optional)
       
   231     * @return None
       
   232     *
       
   233     */
       
   234     virtual void OOMTestFinalizeL( const TFileName& /* aTestCaseFile */,
       
   235                                    const TInt /* aCaseNumber */ );
       
   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     Cwvsapsettingstest();
       
   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     * Actual Hardcoded test case functions are listed below.
       
   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 public: //test functions
       
   302 
       
   303     //TInt SetupOpenStoreL(TTestResult& aResult);
       
   304 
       
   305     TInt SetupEmptySAPL( TTestResult& aResult );
       
   306 
       
   307     TInt SetupPartiallyFilledSAPL( TTestResult& aResult );
       
   308 
       
   309     TInt SetupFullSAPL( TTestResult& aResult );
       
   310 
       
   311     // TEST METHODS
       
   312     TInt Test_DataSetAndGetL( TTestResult& aResult );
       
   313 
       
   314     TInt TestBrandProtection_StoreL( TTestResult& aResult );
       
   315 
       
   316     TInt TestBrandProtection_UpdateL( TTestResult& aResult );
       
   317 
       
   318     TInt TestBrandProtection_DeleteL( TTestResult& aResult );
       
   319     TInt TestLoginCountHandlingL( TTestResult& aResult );
       
   320 
       
   321     TInt TestLoginCountStorageL( TTestResult& aResult );
       
   322 
       
   323     TInt TestSAPContainerExternalizeInternalizeL( TTestResult& aResult );
       
   324 
       
   325     TInt TestSAPContainerPackUnpackL( TTestResult& aResult );
       
   326 
       
   327     TInt TestSAPContainerKeyValuePairsL( TTestResult& aResult );
       
   328 
       
   329     TInt TestSAPContainerCopyL( TTestResult& aResult );
       
   330 
       
   331     TInt TestPopulateSettingsListL( TTestResult& aResult );
       
   332 
       
   333     TInt TestIterateTroughSettingsListAscendL( TTestResult& aResult );
       
   334 
       
   335     TInt TestIterateTroughSettingsListDescendL( TTestResult& aResult );
       
   336 
       
   337     TInt TestObsForAddingSAP( TTestResult& aResult );
       
   338     TInt TestObsForRemoveSAP( TTestResult& aResult );
       
   339 
       
   340     // Teardown
       
   341     TInt Teardown();
       
   342 
       
   343 public: //Installing the active scheduler
       
   344     void SetupSchedulerL();
       
   345     void CloseScheduler();
       
   346 
       
   347 public: //Some utility functions
       
   348 
       
   349     //void SetupOpenFilledStore1L();
       
   350     //void SetupOpenFilledStore10L();
       
   351 
       
   352 private:    // Data
       
   353     // Pointer to test (function) to be executed
       
   354     TestFunction iMethod;
       
   355 
       
   356     // Pointer to logger
       
   357     CStifLogger * iLog;
       
   358 
       
   359     // Normal logger
       
   360     CStifLogger* iStdLog;
       
   361 
       
   362     // Test case logger
       
   363     CStifLogger* iTCLog;
       
   364 
       
   365     // Flag saying if test case title should be added to log file name
       
   366     TBool iAddTestCaseTitleToLogName;
       
   367 
       
   368     // ?one_line_short_description_of_data
       
   369     //?data_declaration;
       
   370 
       
   371     // Reserved pointer for future extension
       
   372     //TAny* iReserved;
       
   373 
       
   374 private:
       
   375     //needed to execute the test cases
       
   376     CIMPSSAPSettingsStore* iStore;
       
   377 
       
   378     CIMPSSAPSettings*   iSAP;
       
   379     CIMPSSAPSettings*	iTempSAP;
       
   380     CIMPSSAPSettings*	iTmpSAP;
       
   381 
       
   382     //CIMPSSAPSettingsList*  iList;
       
   383 
       
   384     WVSAPSettingsObserverTestCases *obstestitnf;
       
   385 
       
   386     TInt iStoredCount;
       
   387     TUint32 iTheNameUid;
       
   388 
       
   389     };
       
   390 
       
   391 #endif      // WVSAPSETTINGSTEST_H
       
   392 
       
   393 // End of File