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