websrv_pub/hostlet_connection_api/tsrc/bc/hostconn/inc/senhostletconnectionbctest.h
changeset 0 62f9d29f7211
equal deleted inserted replaced
-1:000000000000 0:62f9d29f7211
       
     1 /*
       
     2 * Copyright (c) 2002-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:          SenHostletConnection test module.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 
       
    25 #ifndef __SENHOSTLETCONNECTION_H__
       
    26 #define __SENHOSTLETCONNECTION_H__
       
    27 
       
    28 //  EXTERNAL INCLUDES
       
    29 // INCLUDES
       
    30 #include "StifTestModule.h"
       
    31 #include <StifLogger.h>
       
    32 #include <MSenHostlet.h>
       
    33 #include <f32file.h>
       
    34 
       
    35 
       
    36 #include <SenXmlServiceDescription.h>
       
    37 #include <SenHostletConnection.h>
       
    38 
       
    39 
       
    40 #include <SenBaseElement.h>
       
    41 #include <SenSoapMessage.h>
       
    42 #include <SenDateUtils.h>
       
    43 
       
    44 //  INTERNAL INCLUDES
       
    45 
       
    46 //#include <e32def.h>
       
    47 //#ifndef NONSHARABLE_CLASS
       
    48 //    #define NONSHARABLE_CLASS(x) class x
       
    49 //#endif
       
    50 // CONSTANTS
       
    51 //const ?type ?constant_var = ?constant;
       
    52 
       
    53 // MACROS
       
    54 //#define ?macro ?macro_def
       
    55 #define TEST_MODULE_VERSION_MAJOR 50
       
    56 #define TEST_MODULE_VERSION_MINOR 9
       
    57 #define TEST_MODULE_VERSION_BUILD 6
       
    58 
       
    59 // Logging path
       
    60 _LIT( KSenHostletConnection_stifLogPath, "\\logs\\testframework\\SenHostletConnection_stif\\" ); 
       
    61 // Log file
       
    62 _LIT( KSenHostletConnection_stifLogFile, "SenHostletConnection_stif.txt" ); 
       
    63 
       
    64 
       
    65 #define GETPTR &
       
    66 #define ENTRY(str,func) {_S(str), GETPTR func,0,0,0}
       
    67 #define FUNCENTRY(func) {_S(#func), GETPTR func,0,0,0}
       
    68 #define OOM_ENTRY(str,func,a,b,c) {_S(str), GETPTR func,a,b,c}
       
    69 #define OOM_FUNCENTRY(func,a,b,c) {_S(#func), GETPTR func,a,b,c}
       
    70 
       
    71 // FUNCTION PROTOTYPES
       
    72 //?type ?function_name(?arg_list);
       
    73 
       
    74 // FORWARD DECLARATIONS
       
    75 //class ?FORWARD_CLASSNAME;
       
    76 class CSenHostletConnection;
       
    77 class CSenHostletConnectionBCTest;
       
    78 class CTestConsumer;
       
    79 class CTestHostlet;
       
    80 
       
    81 
       
    82 // DATA TYPES
       
    83 //enum ?declaration
       
    84 //typedef ?declaration
       
    85 //extern ?data_type;
       
    86 // A typedef for function that does the actual testing,
       
    87 // function is a type 
       
    88 // TInt CSenHostletConnectionBCTest::<NameOfFunction> ( TTestResult& aResult )
       
    89 typedef TInt (CSenHostletConnectionBCTest::* TestFunction)(TTestResult&);
       
    90 
       
    91 // CLASS DECLARATION
       
    92 
       
    93 /**
       
    94 *  An internal structure containing a test case name and
       
    95 *  the pointer to function doing the test
       
    96 *
       
    97 *  @lib ?library
       
    98 *  @since ?Series60_version
       
    99 */
       
   100 class TCaseInfoInternal
       
   101     {
       
   102     public:
       
   103         const TText*    iCaseName;
       
   104         TestFunction    iMethod;
       
   105         TBool           iIsOOMTest;
       
   106         TInt            iFirstMemoryAllocation;
       
   107         TInt            iLastMemoryAllocation;
       
   108     };
       
   109 
       
   110 // CLASS DECLARATION
       
   111 
       
   112 /**
       
   113 *  A structure containing a test case name and
       
   114 *  the pointer to function doing the test
       
   115 *
       
   116 *  @lib ?library
       
   117 *  @since ?Series60_version
       
   118 */
       
   119 class TCaseInfo
       
   120     {
       
   121     public:
       
   122         TPtrC iCaseName;
       
   123         TestFunction iMethod;
       
   124         TBool           iIsOOMTest;
       
   125         TInt            iFirstMemoryAllocation;
       
   126         TInt            iLastMemoryAllocation;
       
   127 
       
   128     TCaseInfo( const TText* a ) : iCaseName( (TText*) a )
       
   129         {
       
   130         };
       
   131 
       
   132     };
       
   133 //  CLASS DEFINITIONS
       
   134 
       
   135 // FORWARD DECLARATIONS
       
   136 class CActiveConsumerTestTask;
       
   137 //class CSenHostletConnectionBCTest;
       
   138 
       
   139 NONSHARABLE_CLASS( TConsumerTestTask )
       
   140     {
       
   141     public:
       
   142         enum TJob
       
   143             {
       
   144             ECreateConnAndSubmit = 0,
       
   145             ESubmit,
       
   146             EActiveSubmit
       
   147             };
       
   148     
       
   149     
       
   150         inline TConsumerTestTask(CSenServiceConnection& aConnection, const TDesC8& aWsRequest, const TDesC8& aFrameworkId, TJob aJob, HBufC8*& apResult)
       
   151             : iConnection(aConnection),
       
   152             iRequest(aWsRequest),
       
   153             iFrameworkId(aFrameworkId),
       
   154             iJob(aJob),
       
   155             iStatusCode(KErrNone),
       
   156             ipNotOwnedData(apResult),
       
   157             ipSoapMsg(NULL)
       
   158             {
       
   159             }
       
   160             
       
   161         void Execute();
       
   162 
       
   163 
       
   164     public: // Data (which is NOT OWNED, as this is a T-class)...      
       
   165         CSenServiceConnection&      iConnection;
       
   166         TPtrC8                      iRequest;
       
   167         TPtrC8                      iFrameworkId;
       
   168         TJob                        iJob;
       
   169         TInt                        iStatusCode;
       
   170         HBufC8*&                    ipNotOwnedData;
       
   171         CActiveConsumerTestTask*    ipActive;
       
   172         CSenHostletConnectionBCTest*       ipOwner;
       
   173         TPtrC8                      iProperties;
       
   174         TPtrC8                      iEndpoint;
       
   175         CSenSoapMessage*            ipSoapMsg; // ... never & none owned.
       
   176     };
       
   177 
       
   178 
       
   179 NONSHARABLE_CLASS( CActiveConsumerTestTask ) : public CActive
       
   180     {
       
   181     friend class CSenHostletConnectionBCTest;
       
   182     
       
   183     public:
       
   184         enum TStatus
       
   185             {
       
   186             EInvokeService = 1,
       
   187             EDeliverResponse
       
   188             };    
       
   189 
       
   190         static CActiveConsumerTestTask* NewL(TConsumerTestTask& aTask, const TDesC& aThreadName, CSenHostletConnectionBCTest& aOwner);
       
   191         static CActiveConsumerTestTask* NewLC(TConsumerTestTask& aTask, const TDesC& aThreadName, CSenHostletConnectionBCTest& aOwner);
       
   192         
       
   193         ~CActiveConsumerTestTask();
       
   194         
       
   195         void RunL();
       
   196         void DoCancel();
       
   197 
       
   198     private:
       
   199         void ConstructL(const TDesC& aThreadName);
       
   200         CActiveConsumerTestTask(TConsumerTestTask& aTask, CSenHostletConnectionBCTest& aOwner);
       
   201 
       
   202     public: // Data
       
   203         TThreadId               iOwnerThreadId;
       
   204 
       
   205 
       
   206     private: // Data
       
   207         TConsumerTestTask&      iTask;
       
   208         RThread                 iTaskThread;
       
   209         CSenHostletConnectionBCTest&   iOwner;
       
   210     };
       
   211 
       
   212 // CLASS DECLARATION
       
   213 
       
   214 /**
       
   215 *  This a SenServiceManager_stif class.
       
   216 *  ?other_description_lines
       
   217 *
       
   218 *  @lib ?library
       
   219 *  @since ?Series60_version
       
   220 */
       
   221 NONSHARABLE_CLASS(CSenHostletConnectionBCTest) : public CTestModuleBase
       
   222     {
       
   223     public:  // Constructors and destructor
       
   224 
       
   225         /**
       
   226         * Two-phased constructor.
       
   227         */
       
   228         static CSenHostletConnectionBCTest* NewL();
       
   229 
       
   230         /**
       
   231         * Destructor.
       
   232         */
       
   233         virtual ~CSenHostletConnectionBCTest();
       
   234 
       
   235     public: // New functions
       
   236 
       
   237         /**
       
   238         * ?member_description.
       
   239         * @since ?Series60_version
       
   240         * @param ?arg1 ?description
       
   241         * @return ?description
       
   242         */
       
   243         //?type ?member_function( ?type ?arg1 );
       
   244 
       
   245     public: // Functions from base classes
       
   246 
       
   247         /**
       
   248         * From CTestModuleBase InitL is used to initialize the 
       
   249         *       SenServiceManager_stif. It is called once for every instance of 
       
   250         *       TestModuleSenServiceManager_stif after its creation.
       
   251         * @since ?Series60_version
       
   252         * @param aIniFile Initialization file for the test module (optional)
       
   253         * @param aFirstTime Flag is true when InitL is executed for first 
       
   254         *               created instance of SenServiceManager_stif.
       
   255         * @return Symbian OS error code
       
   256         */
       
   257         TInt InitL( TFileName& aIniFile, TBool aFirstTime );
       
   258 
       
   259         /**
       
   260         * From CTestModuleBase GetTestCasesL is used to inquiry test cases 
       
   261         *   from SenServiceManager_stif. 
       
   262         * @since ?Series60_version
       
   263         * @param aTestCaseFile Test case file (optional)
       
   264         * @param aTestCases  Array of TestCases returned to test framework
       
   265         * @return Symbian OS error code
       
   266         */
       
   267         TInt GetTestCasesL( const TFileName& aTestCaseFile, 
       
   268                             RPointerArray<TTestCaseInfo>& aTestCases );
       
   269 
       
   270         /**
       
   271         * From CTestModuleBase RunTestCaseL is used to run an individual 
       
   272         *   test case. 
       
   273         * @since ?Series60_version
       
   274         * @param aCaseNumber Test case number
       
   275         * @param aTestCaseFile Test case file (optional)
       
   276         * @param aResult Test case result returned to test framework (PASS/FAIL)
       
   277         * @return Symbian OS error code (test case execution error, which is 
       
   278         *           not reported in aResult parameter as test case failure).
       
   279         */   
       
   280         TInt RunTestCaseL( const TInt aCaseNumber, 
       
   281                            const TFileName& aTestCaseFile,
       
   282                            TTestResult& aResult );
       
   283 
       
   284         /**
       
   285         * From CTestModuleBase; OOMTestQueryL is used to specify is particular
       
   286         * test case going to be executed using OOM conditions
       
   287         * @param aTestCaseFile Test case file (optional)
       
   288         * @param aCaseNumber Test case number (optional)
       
   289         * @param aFailureType OOM failure type (optional)
       
   290         * @param aFirstMemFailure The first heap memory allocation failure value (optional)
       
   291         * @param aLastMemFailure The last heap memory allocation failure value (optional)
       
   292         * @return TBool
       
   293         */
       
   294         virtual TBool OOMTestQueryL( const TFileName& /* aTestCaseFile */, 
       
   295                                      const TInt /* aCaseNumber */, 
       
   296                                      TOOMFailureType& aFailureType, 
       
   297                                      TInt& /* aFirstMemFailure */, 
       
   298                                      TInt& /* aLastMemFailure */ );
       
   299 
       
   300         /**
       
   301         * From CTestModuleBase; OOMTestInitializeL may be used to initialize OOM
       
   302         * test environment
       
   303         * @param aTestCaseFile Test case file (optional)
       
   304         * @param aCaseNumber Test case number (optional)
       
   305         * @return None
       
   306         */
       
   307         virtual void OOMTestInitializeL( const TFileName& /* aTestCaseFile */, 
       
   308                                     const TInt /* aCaseNumber */ ); 
       
   309 
       
   310         /**
       
   311         * From CTestModuleBase; OOMHandleWarningL
       
   312         * @param aTestCaseFile Test case file (optional)
       
   313         * @param aCaseNumber Test case number (optional)
       
   314         * @param aFailNextValue FailNextValue for OOM test execution (optional)
       
   315         * @return None
       
   316         *
       
   317         * User may add implementation for OOM test warning handling. Usually no
       
   318         * implementation is required.           
       
   319         */
       
   320         virtual void OOMHandleWarningL( const TFileName& /* aTestCaseFile */,
       
   321                                         const TInt /* aCaseNumber */, 
       
   322                                         TInt& /* aFailNextValue */); 
       
   323 
       
   324         /**
       
   325         * From CTestModuleBase; OOMTestFinalizeL may be used to finalize OOM
       
   326         * test environment
       
   327         * @param aTestCaseFile Test case file (optional)
       
   328         * @param aCaseNumber Test case number (optional)
       
   329         * @return None
       
   330         *
       
   331         */
       
   332         virtual void OOMTestFinalizeL( const TFileName& /* aTestCaseFile */, 
       
   333                                        const TInt /* aCaseNumber */ );
       
   334          void StopActiveScheduler();
       
   335          void StartActiveScheduler(TInt aNumberOfExpectedOperationsPriorStop);
       
   336           				/**
       
   337          * Method used to log version of test module
       
   338          */
       
   339         void SendTestModuleVersion();
       
   340                               
       
   341 
       
   342     protected:  // New functions
       
   343 
       
   344         /**
       
   345         * ?member_description.
       
   346         * @since ?Series60_version
       
   347         * @param ?arg1 ?description
       
   348         * @return ?description
       
   349         */
       
   350         //?type ?member_function( ?type ?arg1 );
       
   351 
       
   352     protected:  // Functions from base classes
       
   353 
       
   354         /**
       
   355         * From ?base_class ?member_description
       
   356         */
       
   357         //?type ?member_function();
       
   358 
       
   359     private:
       
   360 
       
   361         /**
       
   362         * C++ default constructor.
       
   363         */
       
   364         CSenHostletConnectionBCTest();
       
   365 
       
   366         /**
       
   367         * By default Symbian 2nd phase constructor is private.
       
   368         */
       
   369         void ConstructL();
       
   370 
       
   371         // Prohibit copy constructor if not deriving from CBase.
       
   372         // ?classname( const ?classname& );
       
   373         // Prohibit assigment operator if not deriving from CBase.
       
   374         // ?classname& operator=( const ?classname& );
       
   375 
       
   376         /**
       
   377         * Function returning test case name and pointer to test case function.
       
   378         * @since ?Series60_version
       
   379         * @param aCaseNumber test case number
       
   380         * @return TCaseInfo 
       
   381         */
       
   382         const TCaseInfo Case ( const TInt aCaseNumber ) const;
       
   383 
       
   384 
       
   385 	    friend class CTestConsumer;
       
   386     	friend class CTestHostlet;
       
   387     
       
   388 
       
   389     public: // Public data => OK in testers, no benefit gained from getters => in real apps, these should be private:
       
   390         CSenServiceConnection*      ipConnection;
       
   391         CSenServiceConnection*      ipConnection1;
       
   392         CSenHostletConnection*      ipHostletConnection;
       
   393         CSenHostletConnection*      ipHostletConnection1;
       
   394         CSenHostletConnection*		ipUsedHostletConnection;
       
   395         
       
   396 
       
   397     private:    // New methods
       
   398 
       
   399          void SetupL();
       
   400         
       
   401          void Teardown();
       
   402         
       
   403          static void UT_CSenHostletConnection_WSI_DescribeServiceL(CSenXmlServiceDescription&);
       
   404          static void UT_CSenHostletConnection_WSI_DescribeService_2L(CSenXmlServiceDescription&);
       
   405          static void UT_CSenHostletConnection_NewLL_SetStatus(CSenHostletConnectionBCTest* apTestSuite, TInt aStatus);
       
   406          static void UT_CSenHostletConnection_NewLL_HandleMessageL(CSenHostletConnectionBCTest* apTestSuite, const TDesC8& aMessage );
       
   407          static void UT_CSenHostletConnection_NewLL_HandleErrorL(CSenHostletConnectionBCTest* apTestSuite, const TInt aErrorCode, const TDesC8& aMessage );
       
   408          static TInt UT_CSenHostletConnection_NewLL_OnServiceL(CSenHostletConnectionBCTest* apTestSuite, MSenHostletRequest& aRequest, MSenHostletResponse& aResponse);
       
   409          static TInt UT_CSenHostletConnection_NewLL_OnServiceCompleteL(CSenHostletConnectionBCTest* apTestSuite, const TInt aTxnId, TInt aCompletionCode, const TDesC8& aDesc );
       
   410 		 static TInt UT_CSenHostletConnection_NewLL_OnService1L(CSenHostletConnectionBCTest* apTestSuite, MSenHostletRequest& aRequest, MSenHostletResponse& aResponse);
       
   411          static TInt UT_CSenHostletConnection_NewLL_OnServiceComplete1L(CSenHostletConnectionBCTest* apTestSuite, const TInt aTxnId, TInt aCompletionCode, const TDesC8& aDesc );
       
   412 		 static TInt UT_CSenHostletConnection_NewLL_OnService2L(CSenHostletConnectionBCTest* apTestSuite, MSenHostletRequest& aRequest, MSenHostletResponse& aResponse);
       
   413 		 static TInt UT_CSenHostletConnection_NewLL_OnService3L(CSenHostletConnectionBCTest* apTestSuite, MSenHostletRequest& aRequest, MSenHostletResponse& aResponse);
       
   414          static TInt UT_CSenHostletConnection_NewLL_OnServiceComplete2L(CSenHostletConnectionBCTest* apTestSuite, const TInt aTxnId, TInt aCompletionCode, const TDesC8& aDesc );                        
       
   415          static void UT_CSenHostletConnection_NewLL_HandleError1L(CSenHostletConnectionBCTest* apTestSuite, const TInt aErrorCode, const TDesC8& aMessage );
       
   416          static TInt UT_CSenHostletConnection_RespondWithPropertiesL_OnServiceL(CSenHostletConnectionBCTest* apTestSuite, MSenHostletRequest& aRequest, MSenHostletResponse& aResponse);
       
   417 		 CSenSoapMessage* CreateAuthRequestLC();
       
   418 		         
       
   419          TInt UT_CSenHostletConnection_NewLL(TTestResult& aResult);
       
   420          
       
   421          TInt UT_CSenHostletConnection_NewLCL(TTestResult& aResult);
       
   422         
       
   423          TInt UT_CSenHostletConnection_NewLC_3InvokesL(TTestResult& aResult);
       
   424         
       
   425          TInt UT_CSenHostletConnection_RespondL1L(TTestResult& aResult);
       
   426 
       
   427          TInt UT_CSenHostletConnection_RespondL2L(TTestResult& aResult);
       
   428          
       
   429          TInt UT_CSenHostletConnection_RespondL3L(TTestResult& aResult);
       
   430          
       
   431          TInt UT_CSenHostletConnection_Negative_ResponseCodeL(TTestResult& aResult);
       
   432          
       
   433          TInt UT_CSenHostletConnection_HC_SelfDef_URIL(TTestResult& aResult);
       
   434          
       
   435          TInt UT_CSenHostletConnection_Delete_HCL(TTestResult& aResult);
       
   436          
       
   437          TInt UT_CSenHostletConnection_Two_Equal_UID3L(TTestResult& aResult);
       
   438          
       
   439          TInt UT_CSenHostletConnection_Two_Equal_EndpointsL(TTestResult& aResult);
       
   440          
       
   441          TInt UT_CSenHostletConnection_Two_HC_Two_SC1L(TTestResult& aResult);
       
   442          
       
   443          TInt UT_CSenHostletConnection_Two_HC_Two_SC2L(TTestResult& aResult);
       
   444          
       
   445          TInt UT_CSenHostletConnection_Two_HC_Two_SC3L(TTestResult& aResult);
       
   446          
       
   447          TInt UT_CSenHostletConnection_DeleteSC_before_HCRespondLL(TTestResult& aResult);
       
   448          
       
   449          TInt UT_CSenHostletConnection_RespondL_4multipleTimesL(TTestResult& aResult);
       
   450          
       
   451          TInt UT_CSenHostletConnection_SC_Cancel_After_RequestL(TTestResult& aResult);
       
   452          
       
   453          TInt UT_CSenHostletConnection_Set_Expose_FacetL(TTestResult& aResult);
       
   454          
       
   455          TInt UT_CSenHostletConnection_RespondWithPropertiesL(TTestResult& aResult);
       
   456 
       
   457          //TInt UT_CSenHostletConnection_CreateConnAndSubmit_Rest_MultiThreadL(TTestResult& aResult);
       
   458 
       
   459          TInt UT_CSenHostletConnection_CreateConnAndSubmit_WSI_MultiThreadL(TTestResult& aResult);
       
   460 
       
   461          TInt UT_CSenHostletConnection_Send_WSIL(TTestResult& aResult);
       
   462 
       
   463          TInt UT_CSenHostletConnection_DescEndpoint_Send_WSIL(TTestResult& aResult);
       
   464 
       
   465          TInt UT_CSenHostletConnection_2SC1HCL(TTestResult& aResult);
       
   466 
       
   467          TInt UT_CSenHostletConnection_Submit_Rest_MultiThreadL(TTestResult& aResult); // Just for debugging, won't pass
       
   468 
       
   469          TInt UT_CSenHostletConnection_Submit_Rest_ActiveL(TTestResult& aResult); // Just for debugging, won't pass
       
   470          
       
   471          // TInt UT_CSenHostletConnection_Submit_WSIL(TTestResult& aResult); // non-working version, just to keep note
       
   472          TInt UT_CSenHostletConnection_IdentifierL(TTestResult& aResult);
       
   473 		 TInt UT_CSenHostletConnection_FrameworkIdL(TTestResult& aResult);
       
   474 		 TInt UT_CSenHostletConnection_RequestUtf8L(TTestResult& aResult);
       
   475 		 TInt UT_CSenHostletConnection_ThreadIdL(TTestResult& aResult);
       
   476 		 TInt UT_CSenHostletConnection_ConsumerIdL(TTestResult& aResult);
       
   477 		 TInt UT_CSenHostletConnection_RequestIdL(TTestResult& aResult);
       
   478          
       
   479 
       
   480     private:    // Data
       
   481     
       
   482         TInt                        iNumberOfPendingOps;
       
   483         TInt                        iRespondRetCode;
       
   484         TInt                        iNumOfReqs;
       
   485         TBool                       iWas_HandleErrorL_Accessed;
       
   486         TBool                       iWas_OnServiceL_Accessed;        
       
   487         TInt                        iTxnID;       
       
   488         
       
   489         CTestConsumer*              ipConsumer;        
       
   490         CTestConsumer*              ipConsumer1;        
       
   491         CTestHostlet*               ipHostlet;
       
   492 		CTestHostlet*               ipHostlet1;   
       
   493 		
       
   494 		CActiveScheduler* iActiveScheduler;
       
   495 		
       
   496         // Pointer to test (function) to be executed
       
   497         TestFunction iMethod;
       
   498 
       
   499         // Pointer to logger
       
   500         CStifLogger * iLog; 
       
   501 
       
   502         // ?one_line_short_description_of_data
       
   503         //?data_declaration;
       
   504 
       
   505         // Reserved pointer for future extension
       
   506         //TAny* iReserved;
       
   507 
       
   508 		// RThread                     iThread;
       
   509     };
       
   510 
       
   511 #endif      //  __SENHOSTLETCONNECTION_H__
       
   512 
       
   513 // End of file