common/tools/ats/smoketest/IM/src/IMApiTestcases.cpp
changeset 756 736214c0060b
child 872 17498133d9ad
equal deleted inserted replaced
755:cdb4af7acafc 756:736214c0060b
       
     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 module contains the implementation of CIMApiTest class
       
    15     member functions that does the actual tests.
       
    16 *
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 
       
    22 // INCLUDE FILES
       
    23 #include <e32math.h>
       
    24 #include "IMApiTest.h"
       
    25 
       
    26 // EXTERNAL DATA STRUCTURES
       
    27 // None
       
    28 
       
    29 // EXTERNAL FUNCTION PROTOTYPES
       
    30 // None
       
    31 
       
    32 // CONSTANTS
       
    33 // None
       
    34 
       
    35 // MACROS
       
    36 // None
       
    37 
       
    38 // LOCAL CONSTANTS AND MACROS
       
    39 // None
       
    40 
       
    41 // MODULE DATA STRUCTURES
       
    42 // None
       
    43 
       
    44 // LOCAL FUNCTION PROTOTYPES
       
    45 // None
       
    46 
       
    47 // FORWARD DECLARATIONS
       
    48 // None
       
    49 
       
    50 // ==================== LOCAL FUNCTIONS =======================================
       
    51 
       
    52 /*
       
    53 -------------------------------------------------------------------------------
       
    54 
       
    55     DESCRIPTION
       
    56 
       
    57     This module contains the implementation of CIMApiTest class
       
    58     member functions that does the actual tests.
       
    59 
       
    60 -------------------------------------------------------------------------------
       
    61 */
       
    62 
       
    63 // ============================ MEMBER FUNCTIONS ===============================
       
    64 
       
    65 /*
       
    66 -------------------------------------------------------------------------------
       
    67 
       
    68     Class: CIMApiTest
       
    69 
       
    70     Method: Case
       
    71 
       
    72     Description: Returns a test case by number.
       
    73 
       
    74     This function contains an array of all available test cases
       
    75     i.e pair of case name and test function. If case specified by parameter
       
    76     aCaseNumber is found from array, then that item is returned.
       
    77 
       
    78     The reason for this rather complicated function is to specify all the
       
    79     test cases only in one place. It is not necessary to understand how
       
    80     function pointers to class member functions works when adding new test
       
    81     cases. See function body for instructions how to add new test case.
       
    82 
       
    83     Parameters:    const TInt aCaseNumber :in:      Test case number
       
    84 
       
    85     Return Values: const TCaseInfo Struct containing case name & function
       
    86 
       
    87     Errors/Exceptions: None
       
    88 
       
    89     Status: Proposal
       
    90 
       
    91 -------------------------------------------------------------------------------
       
    92 */
       
    93 const TCaseInfo CIMApiTest::Case (
       
    94     const TInt aCaseNumber ) const
       
    95     {
       
    96 
       
    97     /*
       
    98     * To add new test cases, implement new test case function and add new
       
    99     * line to KCases array specify the name of the case and the function
       
   100     * doing the test case
       
   101     * In practice, do following
       
   102     *
       
   103     * 1) Make copy of existing test case function and change its name
       
   104     *    and functionality. Note that the function must be added to
       
   105     *    OOMHard.cpp file and to OOMHard.h
       
   106     *    header file.
       
   107     *
       
   108     * 2) Add entry to following KCases array either by using:
       
   109     *
       
   110     * 2.1: FUNCENTRY or ENTRY macro
       
   111     * ENTRY macro takes two parameters: test case name and test case
       
   112     * function name.
       
   113     *
       
   114     * FUNCENTRY macro takes only test case function name as a parameter and
       
   115     * uses that as a test case name and test case function name.
       
   116     *
       
   117     * Or
       
   118     *
       
   119     * 2.2: OOM_FUNCENTRY or OOM_ENTRY macro. Note that these macros are used
       
   120     * only with OOM (Out-Of-Memory) testing!
       
   121     *
       
   122     * OOM_ENTRY macro takes five parameters: test case name, test case
       
   123     * function name, TBool which specifies is method supposed to be run using
       
   124     * OOM conditions, TInt value for first heap memory allocation failure and
       
   125     * TInt value for last heap memory allocation failure.
       
   126     *
       
   127     * OOM_FUNCENTRY macro takes test case function name as a parameter and uses
       
   128     * that as a test case name, TBool which specifies is method supposed to be
       
   129     * run using OOM conditions, TInt value for first heap memory allocation
       
   130     * failure and TInt value for last heap memory allocation failure.
       
   131     */
       
   132 
       
   133     static TCaseInfoInternal const KCases[] =
       
   134         {
       
   135         // To add new test cases, add new items to this array
       
   136 
       
   137         // NOTE: When compiled to GCCE, there must be Classname::
       
   138         // declaration in front of the method name, e.g.
       
   139         // CIMApiTest::PrintTest. Otherwise the compiler
       
   140         // gives errors.
       
   141 
       
   142 		ENTRY( "Create IM Client", CIMApiTest::CreateImClientL ),
       
   143 //        ENTRY( "Invalid Login", CIMApiTest::InvalidLoginL ),
       
   144 //        ENTRY( "Login", CIMApiTest::LoginL ),
       
   145 //        ENTRY( "Send P To P ValidUserID", CIMApiTest::SendPToPValidUserIDL ),
       
   146 //        ENTRY( "Send P To P ValidTvoUserID", CIMApiTest::SendPToPValidTwoUserIDL ),
       
   147 //        ENTRY( "Send P To P ValidContact", CIMApiTest::SendPToPValidContactL ),
       
   148 //        ENTRY( "Send P To P ValidTwoContact", CIMApiTest::SendPToPValidTwoContactL ),
       
   149 //        ENTRY( "Send P To P ContactContentType", CIMApiTest::SendPToPContactContentTypeL ),
       
   150 //        ENTRY( "Send P To P UserIDContentType", CIMApiTest::SendPToPUserIDContentTypeL ),
       
   151 //        ENTRY( "Logout", CIMApiTest::LogoutL ),
       
   152 //        ENTRY( "Cancel Login", CIMApiTest::CancelLoginL ),
       
   153         };
       
   154 
       
   155     // Verify that case number is valid
       
   156     if ( ( TUint ) aCaseNumber >= sizeof( KCases ) /
       
   157          sizeof( TCaseInfoInternal ) )
       
   158         {
       
   159 
       
   160         // Invalid case, construct empty object
       
   161         TCaseInfo null( ( const TText* ) L"" );
       
   162         null.iMethod = NULL;
       
   163         null.iIsOOMTest = EFalse;
       
   164         null.iFirstMemoryAllocation = 0;
       
   165         null.iLastMemoryAllocation = 0;
       
   166         return null;
       
   167 
       
   168         }
       
   169 
       
   170     // Construct TCaseInfo object and return it
       
   171     TCaseInfo tmp ( KCases[ aCaseNumber ].iCaseName );
       
   172     tmp.iMethod = KCases[ aCaseNumber ].iMethod;
       
   173     tmp.iIsOOMTest = KCases[ aCaseNumber ].iIsOOMTest;
       
   174     tmp.iFirstMemoryAllocation = KCases[ aCaseNumber ].iFirstMemoryAllocation;
       
   175     tmp.iLastMemoryAllocation = KCases[ aCaseNumber ].iLastMemoryAllocation;
       
   176     return tmp;
       
   177 
       
   178     }
       
   179 
       
   180 TInt CIMApiTest::CreateImClientL( TTestResult& aResult )
       
   181     {
       
   182     iRunner->StartRunL( CreateImClient );
       
   183     // Sets test case result and description(Maximum size is KStifMaxResultDes)
       
   184     _LIT( KDescription, "CreateImClientL Passed" );
       
   185     aResult.SetResult( KErrNone, KDescription );
       
   186     // Case was executed
       
   187     return KErrNone;
       
   188 
       
   189     }
       
   190 	
       
   191 TInt CIMApiTest::InvalidLoginL( TTestResult& aResult )
       
   192     {
       
   193     iRunner->StartRunL( InvalidLogin );
       
   194     // Sets test case result and description(Maximum size is KStifMaxResultDes)
       
   195     _LIT( KDescription, "LoginL Passed" );
       
   196     aResult.SetResult( KErrNone, KDescription );
       
   197     // Case was executed
       
   198     return KErrNone;
       
   199 
       
   200     }
       
   201 
       
   202 TInt CIMApiTest::LoginL( TTestResult& aResult )
       
   203     {
       
   204     iRunner->StartRunL( Login );
       
   205     // Sets test case result and description(Maximum size is KStifMaxResultDes)
       
   206     _LIT( KDescription, "LoginL Passed" );
       
   207     aResult.SetResult( KErrNone, KDescription );
       
   208     // Case was executed
       
   209     return KErrNone;
       
   210     }
       
   211 
       
   212 
       
   213 TInt CIMApiTest::SendPToPValidUserIDL( TTestResult& aResult )
       
   214     {
       
   215     iRunner->StartRunL( SendMessageValidUserId );
       
   216     // Sets test case result and description(Maximum size is KStifMaxResultDes)
       
   217     _LIT( KDescription, "SendPToPValidUserIDL Passed" );
       
   218     aResult.SetResult( KErrNone, KDescription );
       
   219     // Case was executed
       
   220     return KErrNone;
       
   221     }
       
   222 
       
   223 
       
   224 TInt CIMApiTest::SendPToPValidTwoUserIDL( TTestResult& aResult )
       
   225     {
       
   226     iRunner->StartRunL( SendMessageValidTwoUserId );
       
   227     // Sets test case result and description(Maximum size is KStifMaxResultDes)
       
   228     _LIT( KDescription, "SendPToPValidTwoUserIDL Passed" );
       
   229     aResult.SetResult( KErrNone, KDescription );
       
   230     // Case was executed
       
   231     return KErrNone;
       
   232     }
       
   233 
       
   234 
       
   235 TInt CIMApiTest::SendPToPValidContactL( TTestResult& aResult )
       
   236     {
       
   237     iRunner->StartRunL( SendMessageValidContact );
       
   238     // Sets test case result and description(Maximum size is KStifMaxResultDes)
       
   239     _LIT( KDescription, "SendPToPValidContactL Passed" );
       
   240     aResult.SetResult( KErrNone, KDescription );
       
   241     // Case was executed
       
   242     return KErrNone;
       
   243     }
       
   244 
       
   245 
       
   246 TInt CIMApiTest::SendPToPValidTwoContactL( TTestResult& aResult )
       
   247     {
       
   248     iRunner->StartRunL( SendMessageValidTwoContact );
       
   249     // Sets test case result and description(Maximum size is KStifMaxResultDes)
       
   250     _LIT( KDescription, "SendPToPValidTwoContactL Passed" );
       
   251     aResult.SetResult( KErrNone, KDescription );
       
   252     // Case was executed
       
   253     return KErrNone;
       
   254     }
       
   255 
       
   256 TInt CIMApiTest::SendPToPContactContentTypeL( TTestResult& aResult )
       
   257     {
       
   258     iRunner->StartRunL( SendPToPContactContentType );
       
   259     // Sets test case result and description(Maximum size is KStifMaxResultDes)
       
   260     _LIT( KDescription, "SendPToPContactContentTypeL Passed" );
       
   261     aResult.SetResult( KErrNone, KDescription );
       
   262     // Case was executed
       
   263     return KErrNone;
       
   264     }
       
   265 
       
   266 TInt CIMApiTest::SendPToPUserIDContentTypeL( TTestResult& aResult )
       
   267     {
       
   268     iRunner->StartRunL( SendPToPUserIDContentType );
       
   269     // Sets test case result and description(Maximum size is KStifMaxResultDes)
       
   270     _LIT( KDescription, "SendPToPUserIDContentTypeL Passed" );
       
   271     aResult.SetResult( KErrNone, KDescription );
       
   272     // Case was executed
       
   273     return KErrNone;
       
   274     }
       
   275 
       
   276 TInt CIMApiTest::LogoutL( TTestResult& aResult )
       
   277     {
       
   278     iRunner->StartRunL( Logout );
       
   279     // Sets test case result and description(Maximum size is KStifMaxResultDes)
       
   280     _LIT( KDescription, "LogoutL Passed" );
       
   281     aResult.SetResult( KErrNone, KDescription );
       
   282     // Case was executed
       
   283     return KErrNone;
       
   284     }
       
   285 
       
   286 
       
   287 TInt CIMApiTest::CancelLoginL( TTestResult& aResult )
       
   288     {
       
   289     iRunner->StartRunL( CancelLogin );
       
   290     // Sets test case result and description(Maximum size is KStifMaxResultDes)
       
   291     _LIT( KDescription, "CancelLoginL Passed" );
       
   292     aResult.SetResult( KErrNone, KDescription );
       
   293     // Case was executed
       
   294     return KErrNone;
       
   295     }
       
   296 
       
   297 // End of File