IM/inc/IMApiTest.h
branchSymbian2
changeset 1 8758140453c0
child 6 c108117318cb
equal deleted inserted replaced
0:e8c1ea2c6496 1:8758140453c0
       
     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 the License "Symbian Foundation License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: This class contains all test framework related parts of
       
    15     this test module.
       
    16 *
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 
       
    22 /*
       
    23 -------------------------------------------------------------------------------
       
    24 
       
    25     DESCRIPTION
       
    26 
       
    27     This file contains the header file of IMApiTest of
       
    28     STIF TestFramework.
       
    29 
       
    30 -------------------------------------------------------------------------------
       
    31 */
       
    32 #ifndef IMApiTest_H
       
    33 #define IMApiTest_H
       
    34 
       
    35 // INCLUDES
       
    36 #include "StifTestModule.h"
       
    37 #include <StifLogger.h>
       
    38 #include "IMApiMTHandlers.h"
       
    39 #include "imerrors.h"
       
    40 #include "imconnection.h"
       
    41 #include "imclient.h"
       
    42 #include "TestRunner.h"
       
    43 
       
    44 // CONSTANTS
       
    45 // None
       
    46 
       
    47 // MACROS
       
    48 // None
       
    49 
       
    50 // Logging path
       
    51 _LIT( KIMApiTestLogPath, "\\logs\\testframework\\IMApiTest\\" );
       
    52 // Log file
       
    53 _LIT( KIMApiTestLogFile, "IMApiTest.txt" );
       
    54 
       
    55 // Function pointer related internal definitions
       
    56 
       
    57 #define GETPTR &
       
    58 #define ENTRY(str,func) {_S(str), GETPTR func,0,0,0}
       
    59 #define FUNCENTRY(func) {_S(#func), GETPTR func,0,0,0}
       
    60 #define OOM_ENTRY(str,func,a,b,c) {_S(str), GETPTR func,a,b,c}
       
    61 #define OOM_FUNCENTRY(func,a,b,c) {_S(#func), GETPTR func,a,b,c}
       
    62 
       
    63 // FUNCTION PROTOTYPES
       
    64 // None
       
    65 
       
    66 // FORWARD DECLARATIONS
       
    67 class CIMApiTest;
       
    68 
       
    69 // DATA TYPES
       
    70 // None
       
    71 
       
    72 // A typedef for function that does the actual testing,
       
    73 // function is a type
       
    74 // TInt CIMApiTest::<NameOfFunction> ( TTestResult& aResult )
       
    75 typedef TInt ( CIMApiTest::* TestFunction )( TTestResult& );
       
    76 
       
    77 // CLASS DECLARATION
       
    78 
       
    79 /**
       
    80 *  An internal 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 TCaseInfoInternal
       
    87     {
       
    88     public:
       
    89         const TText* iCaseName;
       
    90         TestFunction iMethod;
       
    91         TBool           iIsOOMTest;
       
    92         TInt            iFirstMemoryAllocation;
       
    93         TInt            iLastMemoryAllocation;
       
    94     };
       
    95 
       
    96 // CLASS DECLARATION
       
    97 
       
    98 /**
       
    99 *  A structure containing a test case name and
       
   100 *  the pointer to function doing the test
       
   101 *
       
   102 *  @lib ?library
       
   103 *  @since ?Series60_version
       
   104 */
       
   105 class TCaseInfo
       
   106     {
       
   107     public:
       
   108         TPtrC iCaseName;
       
   109         TestFunction iMethod;
       
   110         TBool           iIsOOMTest;
       
   111         TInt            iFirstMemoryAllocation;
       
   112         TInt            iLastMemoryAllocation;
       
   113 
       
   114         TCaseInfo( const TText* a ) : iCaseName( ( TText* ) a )
       
   115             {
       
   116             };
       
   117 
       
   118     };
       
   119 
       
   120 
       
   121 // CLASS DECLARATION
       
   122 
       
   123 /**
       
   124 *  This a IMApiTest class.
       
   125 *  ?other_description_lines
       
   126 *
       
   127 *  @lib ?library
       
   128 *  @since ?Series60_version
       
   129 */
       
   130 NONSHARABLE_CLASS( CIMApiTest ) : public CTestModuleBase
       
   131     {
       
   132 public:  // Constructors and destructor
       
   133 
       
   134 
       
   135     /**
       
   136     * Two-phased constructor.
       
   137     */
       
   138     static CIMApiTest* NewL();
       
   139 
       
   140     /**
       
   141     * Destructor.
       
   142     */
       
   143     virtual ~CIMApiTest();
       
   144 
       
   145 public: // New functions
       
   146     // None
       
   147 
       
   148 public: // Functions from base classes
       
   149 
       
   150     /**
       
   151     * From CTestModuleBase InitL is used to initialize the
       
   152     *       IMApiTest. It is called once for every instance of
       
   153     *       TestModuleIMApiTest after its creation.
       
   154     * @since ?Series60_version
       
   155     * @param aIniFile Initialization file for the test module (optional)
       
   156     * @param aFirstTime Flag is true when InitL is executed for first
       
   157     *               created instance of IMApiTest.
       
   158     * @return Symbian OS error code
       
   159     */
       
   160     TInt InitL( TFileName& aIniFile, TBool aFirstTime );
       
   161 
       
   162     /**
       
   163     * From CTestModuleBase GetTestCasesL is used to inquiry test cases
       
   164     *   from IMApiTest.
       
   165     * @since ?Series60_version
       
   166     * @param aTestCaseFile Test case file (optional)
       
   167     * @param aTestCases  Array of TestCases returned to test framework
       
   168     * @return Symbian OS error code
       
   169     */
       
   170     TInt GetTestCasesL( const TFileName& aTestCaseFile,
       
   171                         RPointerArray<TTestCaseInfo>& aTestCases );
       
   172 
       
   173     /**
       
   174     * From CTestModuleBase RunTestCaseL is used to run an individual
       
   175     *   test case.
       
   176     * @since ?Series60_version
       
   177     * @param aCaseNumber Test case number
       
   178     * @param aTestCaseFile Test case file (optional)
       
   179     * @param aResult Test case result returned to test framework (PASS/FAIL)
       
   180     * @return Symbian OS error code (test case execution error, which is
       
   181     *           not reported in aResult parameter as test case failure).
       
   182     */
       
   183     TInt RunTestCaseL( const TInt aCaseNumber,
       
   184                        const TFileName& aTestCaseFile,
       
   185                        TTestResult& aResult );
       
   186 
       
   187     /**
       
   188     * From CTestModuleBase; OOMTestQueryL is used to specify is particular
       
   189     * test case going to be executed using OOM conditions
       
   190     * @param aTestCaseFile Test case file (optional)
       
   191     * @param aCaseNumber Test case number (optional)
       
   192     * @param aFailureType OOM failure type (optional)
       
   193     * @param aFirstMemFailure The first heap memory allocation failure value (optional)
       
   194     * @param aLastMemFailure The last heap memory allocation failure value (optional)
       
   195     * @return TBool
       
   196     */
       
   197     virtual TBool OOMTestQueryL( const TFileName& /* aTestCaseFile */,
       
   198                                  const TInt /* aCaseNumber */,
       
   199                                  TOOMFailureType& aFailureType,
       
   200                                  TInt& /* aFirstMemFailure */,
       
   201                                  TInt& /* aLastMemFailure */ );
       
   202 
       
   203     /**
       
   204     * From CTestModuleBase; OOMTestInitializeL may be used to initialize OOM
       
   205     * test environment
       
   206     * @param aTestCaseFile Test case file (optional)
       
   207     * @param aCaseNumber Test case number (optional)
       
   208     * @return None
       
   209     */
       
   210     virtual void OOMTestInitializeL( const TFileName& /* aTestCaseFile */,
       
   211                                      const TInt /* aCaseNumber */ );
       
   212     /**
       
   213     * From CTestModuleBase; OOMTestFinalizeL may be used to finalize OOM
       
   214     * test environment
       
   215     * @param aTestCaseFile Test case file (optional)
       
   216     * @param aCaseNumber Test case number (optional)
       
   217     * @return None
       
   218     */
       
   219     virtual void OOMTestFinalizeL( const TFileName& /* aTestCaseFile */,
       
   220                                    const TInt /* aCaseNumber */ );
       
   221 
       
   222     /**
       
   223     * From CTestModuleBase; OOMHandleWarningL
       
   224     * @param aTestCaseFile Test case file (optional)
       
   225     * @param aCaseNumber Test case number (optional)
       
   226     * @param aFailNextValue FailNextValue for OOM test execution (optional)
       
   227     * @return None
       
   228     */
       
   229     virtual void OOMHandleWarningL( const TFileName& /* aTestCaseFile */,
       
   230                                     const TInt /* aCaseNumber */,
       
   231                                     TInt& /* aFailNextValue */ );
       
   232 protected:  // New functions
       
   233     // None
       
   234 
       
   235 protected:  // Functions from base classes
       
   236     // None
       
   237 
       
   238 private:
       
   239 
       
   240     /**
       
   241     * C++ default constructor.
       
   242     */
       
   243     CIMApiTest();
       
   244 
       
   245     /**
       
   246     * By default Symbian 2nd phase constructor is private.
       
   247     */
       
   248     void ConstructL();
       
   249 
       
   250     // Prohibit copy constructor if not deriving from CBase.
       
   251     // ?classname( const ?classname& );
       
   252     // Prohibit assigment operator if not deriving from CBase.
       
   253     // ?classname& operator=( const ?classname& );
       
   254 
       
   255     /**
       
   256     * Function returning test case name and pointer to test case function.
       
   257     * @since ?Series60_version
       
   258     * @param aCaseNumber test case number
       
   259     * @return TCaseInfo
       
   260     */
       
   261     const TCaseInfo Case ( const TInt aCaseNumber ) const;
       
   262 
       
   263     /**
       
   264     * Printing loop test case.
       
   265     * @since ?Series60_version
       
   266     * @param aResult Test case result (PASS/FAIL)
       
   267     * @return Symbian OS error code (test case execution error
       
   268     *   that is not returned as test case result in aResult)
       
   269     */
       
   270     TInt CreateImClientL( TTestResult& aResult );
       
   271 	TInt InvalidLoginL( TTestResult& aResult );
       
   272     TInt LoginL( TTestResult& aResult );
       
   273     TInt SendPToPValidUserIDL( TTestResult& aResult );
       
   274     TInt SendPToPValidTwoUserIDL( TTestResult& aResult );
       
   275     TInt SendPToPValidContactL( TTestResult& aResult );
       
   276     TInt SendPToPValidTwoContactL( TTestResult& aResult );
       
   277     TInt SendPToPContactContentTypeL( TTestResult& aResult );
       
   278     TInt SendPToPUserIDContentTypeL( TTestResult& aResult );
       
   279     TInt LogoutL( TTestResult& aResult );
       
   280     TInt CancelLoginL( TTestResult& aResult );
       
   281 
       
   282 public:     // Data
       
   283     // None
       
   284 
       
   285 protected:  // Data
       
   286     // None
       
   287 
       
   288 private:    // Data
       
   289     // Pointer to test (function) to be executed
       
   290     TestFunction iMethod;
       
   291 
       
   292     // Pointer to logger
       
   293     CStifLogger * iLog;
       
   294     CTestRunner*   iRunner;
       
   295 
       
   296     CIMApiClientHandler*     iImObserver;
       
   297     CConnectionObserver*    iConnObserver;
       
   298     CImConnection*          iOpenApi;
       
   299     MImClient*              iImClient;
       
   300     CConsoleBase*           iConsole;
       
   301     TBool                   iRepeat;
       
   302 
       
   303     /*TInt      iAP;
       
   304     TBuf<50>  iUser;
       
   305     TBuf<50>  iPwd;
       
   306     TBuf<50>  iRecipient;
       
   307     TBuf<50>  iRecipient1;
       
   308     TBuf<50>  iMySapAp;
       
   309     TBuf<50>  iClientId;
       
   310     */
       
   311     // ?one_line_short_description_of_data
       
   312     //?data_declaration;
       
   313 
       
   314     // Reserved pointer for future extension
       
   315     //TAny* iReserved;
       
   316 
       
   317 public:     // Friend classes
       
   318     // None
       
   319     friend class CTestRunner;
       
   320 protected:  // Friend classes
       
   321     // None
       
   322 
       
   323 private:    // Friend classes
       
   324     // None
       
   325 
       
   326     };
       
   327 
       
   328 #endif      // IMApiTest_H
       
   329 
       
   330 // End of File