websrv_pub/hostlet_connection_api/tsrc/hostconnTester/inc/hostconnTester.h
changeset 0 62f9d29f7211
equal deleted inserted replaced
-1:000000000000 0:62f9d29f7211
       
     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: Header declaration
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 
       
    25 
       
    26 #ifndef HOSTCONNTESTER_H
       
    27 #define HOSTCONNTESTER_H
       
    28 
       
    29 //  INCLUDES
       
    30 #include <StifLogger.h>
       
    31 #include <MSenHostlet.h>
       
    32 #include <f32file.h>
       
    33 #include <TestScripterInternal.h>
       
    34 #include <StifTestModule.h>
       
    35 #include <SenXmlServiceDescription.h>
       
    36 #include <SenHostletConnection.h>
       
    37 
       
    38 
       
    39 #include <SenBaseElement.h>
       
    40 #include <SenSoapMessage.h>
       
    41 #include <SenDateUtils.h>
       
    42 #include <TestclassAssert.h>
       
    43 
       
    44 // CONSTANTS
       
    45 //const ?type ?constant_var = ?constant;
       
    46 
       
    47 // MACROS
       
    48 //#define ?macro ?macro_def
       
    49 #define TEST_CLASS_VERSION_MAJOR 0
       
    50 #define TEST_CLASS_VERSION_MINOR 0
       
    51 #define TEST_CLASS_VERSION_BUILD 0
       
    52 
       
    53 // Logging path
       
    54 _LIT( KSenHostletConnection_stifLogPath, "\\logs\\testframework\\SenHostletConnection_stif\\" ); 
       
    55 // Log file
       
    56 _LIT( KSenHostletConnection_stifLogFile, "SenHostletConnection_stif.txt" ); 
       
    57 
       
    58 
       
    59 
       
    60 // FUNCTION PROTOTYPES
       
    61 //?type ?function_name(?arg_list);
       
    62 
       
    63 // FORWARD DECLARATIONS
       
    64 //class ?FORWARD_CLASSNAME;
       
    65 class CSenHostletConnection;
       
    66 class CTestConsumer;
       
    67 class CTestHostlet;
       
    68 class ChostconnTester;
       
    69 
       
    70 // DATA TYPES
       
    71 //enum ?declaration
       
    72 //typedef ?declaration
       
    73 //extern ?data_type;
       
    74 typedef TInt (ChostconnTester::* TestFunction)(CStifItemParser&);
       
    75 
       
    76 // CLASS DECLARATION
       
    77 
       
    78 /**
       
    79 *  ChostconnTester test class for STIF Test Framework TestScripter.
       
    80 *  ?other_description_lines
       
    81 *
       
    82 *  @lib ?library
       
    83 *  @since ?Series60_version
       
    84 */
       
    85 class TCaseInfoInternal
       
    86     {
       
    87     public:
       
    88         const TText*    iCaseName;
       
    89         TestFunction    iMethod;
       
    90         TBool           iIsOOMTest;
       
    91         TInt            iFirstMemoryAllocation;
       
    92         TInt            iLastMemoryAllocation;
       
    93     };
       
    94 // CLASS DECLARATION
       
    95 
       
    96 /**
       
    97 *  A structure containing a test case name and
       
    98 *  the pointer to function doing the test
       
    99 *
       
   100 *  @lib ?library
       
   101 *  @since ?Series60_version
       
   102 */
       
   103 class TCaseInfo
       
   104     {
       
   105     public:
       
   106         TPtrC iCaseName;
       
   107         TestFunction iMethod;
       
   108         TBool           iIsOOMTest;
       
   109         TInt            iFirstMemoryAllocation;
       
   110         TInt            iLastMemoryAllocation;
       
   111 
       
   112     TCaseInfo( const TText* a ) : iCaseName( (TText*) a )
       
   113         {
       
   114         };
       
   115 
       
   116     };
       
   117 //  CLASS DEFINITIONS
       
   118 
       
   119 // FORWARD DECLARATIONS
       
   120 class CActiveConsumerTestTask;
       
   121 //class ChostconnTester;
       
   122 
       
   123 NONSHARABLE_CLASS( TConsumerTestTask )
       
   124     {
       
   125     public:
       
   126         enum TJob
       
   127             {
       
   128             ECreateConnAndSubmit = 0,
       
   129             ESubmit,
       
   130             EActiveSubmit
       
   131             };
       
   132     
       
   133     
       
   134         inline TConsumerTestTask(CSenServiceConnection& aConnection, const TDesC8& aWsRequest, const TDesC8& aFrameworkId, TJob aJob, HBufC8*& apResult)
       
   135             : iConnection(aConnection),
       
   136             iRequest(aWsRequest),
       
   137             iFrameworkId(aFrameworkId),
       
   138             iJob(aJob),
       
   139             iStatusCode(KErrNone),
       
   140             ipNotOwnedData(apResult),
       
   141             ipSoapMsg(NULL)
       
   142             {
       
   143             }
       
   144             
       
   145         void Execute();
       
   146 
       
   147 
       
   148     public: // Data (which is NOT OWNED, as this is a T-class)...      
       
   149         CSenServiceConnection&      iConnection;
       
   150         TPtrC8                      iRequest;
       
   151         TPtrC8                      iFrameworkId;
       
   152         TJob                        iJob;
       
   153         TInt                        iStatusCode;
       
   154         HBufC8*&                    ipNotOwnedData;
       
   155         CActiveConsumerTestTask*    ipActive;
       
   156         ChostconnTester*       ipOwner;
       
   157         TPtrC8                      iProperties;
       
   158         TPtrC8                      iEndpoint;
       
   159         CSenSoapMessage*            ipSoapMsg; // ... never & none owned.
       
   160     };
       
   161 NONSHARABLE_CLASS( CActiveConsumerTestTask ) : public CActive
       
   162     {
       
   163     friend class ChostconnTester;
       
   164     
       
   165     public:
       
   166         enum TStatus
       
   167             {
       
   168             EInvokeService = 1,
       
   169             EDeliverResponse
       
   170             };    
       
   171 
       
   172         static CActiveConsumerTestTask* NewL(TConsumerTestTask& aTask, const TDesC& aThreadName, ChostconnTester& aOwner);
       
   173         static CActiveConsumerTestTask* NewLC(TConsumerTestTask& aTask, const TDesC& aThreadName, ChostconnTester& aOwner);
       
   174         
       
   175         ~CActiveConsumerTestTask();
       
   176         
       
   177         void RunL();
       
   178         void DoCancel();
       
   179 
       
   180     private:
       
   181         void ConstructL(const TDesC& aThreadName);
       
   182         CActiveConsumerTestTask(TConsumerTestTask& aTask, ChostconnTester& aOwner);
       
   183 
       
   184     public: // Data
       
   185         TThreadId               iOwnerThreadId;
       
   186 
       
   187 
       
   188     private: // Data
       
   189         TConsumerTestTask&      iTask;
       
   190         RThread                 iTaskThread;
       
   191         ChostconnTester&   iOwner;
       
   192     };
       
   193 NONSHARABLE_CLASS(ChostconnTester) : public CScriptBase
       
   194     {
       
   195     public:  // Constructors and destructor
       
   196 
       
   197         /**
       
   198         * Two-phased constructor.
       
   199         */
       
   200         static ChostconnTester* NewL( CTestModuleIf& aTestModuleIf );
       
   201 
       
   202         /**
       
   203         * Destructor.
       
   204         */
       
   205         virtual ~ChostconnTester();
       
   206 
       
   207     public: // New functions
       
   208 
       
   209         /**
       
   210         * ?member_description.
       
   211         * @since ?Series60_version
       
   212         * @param ?arg1 ?description
       
   213         * @return ?description
       
   214         */
       
   215         //?type ?member_function( ?type ?arg1 );
       
   216         void StopActiveScheduler();
       
   217          void StartActiveScheduler(TInt aNumberOfExpectedOperationsPriorStop);
       
   218 
       
   219     public: // Functions from base classes
       
   220 
       
   221         /**
       
   222         * From CScriptBase Runs a script line.
       
   223         * @since ?Series60_version
       
   224         * @param aItem Script line containing method name and parameters
       
   225         * @return Symbian OS error code
       
   226         */
       
   227         virtual TInt RunMethodL( CStifItemParser& aItem );
       
   228                                        
       
   229 
       
   230     protected:  // New functions
       
   231 
       
   232         /**
       
   233         * ?member_description.
       
   234         * @since ?Series60_version
       
   235         * @param ?arg1 ?description
       
   236         * @return ?description
       
   237         */
       
   238         //?type ?member_function( ?type ?arg1 );
       
   239 
       
   240     protected:  // Functions from base classes
       
   241 
       
   242         /**
       
   243         * From ?base_class ?member_description
       
   244         */
       
   245         //?type ?member_function();
       
   246 
       
   247     private:
       
   248 
       
   249         /**
       
   250         * C++ default constructor.
       
   251         */
       
   252         ChostconnTester( CTestModuleIf& aTestModuleIf );
       
   253 
       
   254         /**
       
   255         * By default Symbian 2nd phase constructor is private.
       
   256         */
       
   257         void ConstructL();
       
   258 
       
   259         // Prohibit copy constructor if not deriving from CBase.
       
   260         // ?classname( const ?classname& );
       
   261         // Prohibit assigment operator if not deriving from CBase.
       
   262         // ?classname& operator=( const ?classname& );
       
   263 
       
   264         /**
       
   265         * Frees all resources allocated from test methods.
       
   266         * @since ?Series60_version
       
   267         */
       
   268         const TCaseInfo Case ( const TInt aCaseNumber ) const;
       
   269         void Delete();
       
   270         
       
   271 
       
   272 	    friend class CTestConsumer;
       
   273     	friend class CTestHostlet;
       
   274     public: // Public data => OK in testers, no benefit gained from getters => in real apps, these should be private:
       
   275         CSenServiceConnection*      ipConnection;
       
   276         CSenServiceConnection*      ipConnection1;
       
   277         CSenHostletConnection*      ipHostletConnection;
       
   278         CSenHostletConnection*      ipHostletConnection1;
       
   279         CSenHostletConnection*		ipUsedHostletConnection;
       
   280     private:    // New methods
       
   281 
       
   282          static void UT_CSenHostletConnection_WSI_DescribeServiceL(CSenXmlServiceDescription&);
       
   283          static void UT_CSenHostletConnection_WSI_DescribeService_2L(CSenXmlServiceDescription&);
       
   284          static void UT_CSenHostletConnection_NewLL_SetStatus(ChostconnTester* apTestSuite, TInt aStatus);
       
   285          static void UT_CSenHostletConnection_NewLL_HandleMessageL(ChostconnTester* apTestSuite, const TDesC8& aMessage );
       
   286          static void UT_CSenHostletConnection_NewLL_HandleErrorL(ChostconnTester* apTestSuite, const TInt aErrorCode, const TDesC8& aMessage );
       
   287          static TInt UT_CSenHostletConnection_NewLL_OnServiceL(ChostconnTester* apTestSuite, MSenHostletRequest& aRequest, MSenHostletResponse& aResponse);
       
   288          static TInt UT_CSenHostletConnection_NewLL_OnServiceCompleteL(ChostconnTester* apTestSuite, const TInt aTxnId, TInt aCompletionCode, const TDesC8& aDesc );
       
   289 				 static TInt UT_CSenHostletConnection_NewLL_OnService1L(ChostconnTester* apTestSuite, MSenHostletRequest& aRequest, MSenHostletResponse& aResponse);
       
   290          static TInt UT_CSenHostletConnection_NewLL_OnServiceComplete1L(ChostconnTester* apTestSuite, const TInt aTxnId, TInt aCompletionCode, const TDesC8& aDesc );
       
   291 				 static TInt UT_CSenHostletConnection_NewLL_OnService2L(ChostconnTester* apTestSuite, MSenHostletRequest& aRequest, MSenHostletResponse& aResponse);
       
   292 		 		 static TInt UT_CSenHostletConnection_NewLL_OnService3L(ChostconnTester* apTestSuite, MSenHostletRequest& aRequest, MSenHostletResponse& aResponse);
       
   293          static TInt UT_CSenHostletConnection_NewLL_OnServiceComplete2L(ChostconnTester* apTestSuite, const TInt aTxnId, TInt aCompletionCode, const TDesC8& aDesc );                        
       
   294          static void UT_CSenHostletConnection_NewLL_HandleError1L(ChostconnTester* apTestSuite, const TInt aErrorCode, const TDesC8& aMessage );
       
   295          static TInt UT_CSenHostletConnection_RespondWithPropertiesL_OnServiceL(ChostconnTester* apTestSuite, MSenHostletRequest& aRequest, MSenHostletResponse& aResponse);
       
   296 		 		 CSenSoapMessage* CreateAuthRequestLC();
       
   297 
       
   298          TInt UT_CSenHostletConnection_NewLL(CStifItemParser& aItem);
       
   299          
       
   300          TInt UT_CSenHostletConnection_NewLCL(CStifItemParser& aItem);
       
   301         
       
   302          TInt UT_CSenHostletConnection_NewLC_3InvokesL(CStifItemParser& aItem);
       
   303         
       
   304          TInt UT_CSenHostletConnection_RespondL1L(CStifItemParser& aItem);
       
   305 
       
   306          TInt UT_CSenHostletConnection_RespondL2L(CStifItemParser& aItem);
       
   307          
       
   308          TInt UT_CSenHostletConnection_RespondL3L(CStifItemParser& aItem);
       
   309          
       
   310          TInt UT_CSenHostletConnection_Negative_ResponseCodeL(CStifItemParser& aItem);
       
   311          
       
   312          TInt UT_CSenHostletConnection_HC_SelfDef_URIL(CStifItemParser& aItem);
       
   313          
       
   314          TInt UT_CSenHostletConnection_Delete_HCL(CStifItemParser& aItem);
       
   315          
       
   316          TInt UT_CSenHostletConnection_Two_Equal_UID3L(CStifItemParser& aItem);
       
   317          
       
   318          TInt UT_CSenHostletConnection_Two_Equal_EndpointsL(CStifItemParser& aItem);
       
   319          
       
   320          TInt UT_CSenHostletConnection_Two_HC_Two_SC1L(CStifItemParser& aItem);
       
   321          
       
   322          TInt UT_CSenHostletConnection_Two_HC_Two_SC2L(CStifItemParser& aItem);
       
   323          
       
   324          TInt UT_CSenHostletConnection_Two_HC_Two_SC3L(CStifItemParser& aItem);
       
   325          
       
   326          TInt UT_CSenHostletConnection_DeleteSC_before_HCRespondLL(CStifItemParser& aItem);
       
   327          
       
   328          TInt UT_CSenHostletConnection_RespondL_4multipleTimesL(CStifItemParser& aItem);
       
   329          
       
   330          TInt UT_CSenHostletConnection_SC_Cancel_After_RequestL(CStifItemParser& aItem);
       
   331          
       
   332          TInt UT_CSenHostletConnection_Set_Expose_FacetL(CStifItemParser& aItem);
       
   333          
       
   334          TInt UT_CSenHostletConnection_RespondWithPropertiesL(CStifItemParser& aItem);
       
   335 
       
   336          //TInt UT_CSenHostletConnection_CreateConnAndSubmit_Rest_MultiThreadL(CStifItemParser& aItem);
       
   337 
       
   338          TInt UT_CSenHostletConnection_CreateConnAndSubmit_WSI_MultiThreadL(CStifItemParser& aItem);
       
   339 
       
   340          TInt UT_CSenHostletConnection_Send_WSIL(CStifItemParser& aItem);
       
   341 
       
   342          TInt UT_CSenHostletConnection_DescEndpoint_Send_WSIL(CStifItemParser& aItem);
       
   343 
       
   344          TInt UT_CSenHostletConnection_2SC1HCL(CStifItemParser& aItem);
       
   345 
       
   346          TInt UT_CSenHostletConnection_Submit_Rest_MultiThreadL(CStifItemParser& aItem); // Just for debugging, won't pass
       
   347 
       
   348          TInt UT_CSenHostletConnection_Submit_Rest_ActiveL(CStifItemParser& aItem); // Just for debugging, won't pass
       
   349          
       
   350          // TInt UT_CSenHostletConnection_Submit_WSIL(CStifItemParser& aItem); // non-working version, just to keep note
       
   351          TInt UT_CSenHostletConnection_IdentifierL(CStifItemParser& aItem );
       
   352 		 TInt UT_CSenHostletConnection_FrameworkIdL(CStifItemParser& aItem );
       
   353 		 TInt UT_CSenHostletConnection_RequestUtf8L(CStifItemParser& aItem );
       
   354 		 TInt UT_CSenHostletConnection_ThreadIdL(CStifItemParser& aItem );
       
   355 		 TInt UT_CSenHostletConnection_ConsumerIdL(CStifItemParser& aItem );
       
   356 		 TInt UT_CSenHostletConnection_RequestIdL(CStifItemParser& aItem );
       
   357         /**
       
   358         * Test methods are listed below. 
       
   359         */
       
   360 
       
   361         
       
   362         /**
       
   363          * Method used to log version of test class
       
   364          */
       
   365         void SendTestClassVersion();
       
   366 
       
   367         
       
   368     public:     // Data
       
   369         // ?one_line_short_description_of_data
       
   370         //?data_declaration;
       
   371 
       
   372     protected:  // Data
       
   373         // ?one_line_short_description_of_data
       
   374         //?data_declaration;
       
   375 
       
   376     private:    // Data
       
   377         TInt                        iNumberOfPendingOps;
       
   378         TInt                        iRespondRetCode;
       
   379         TInt                        iNumOfReqs;
       
   380         TBool                       iWas_HandleErrorL_Accessed;
       
   381         TBool                       iWas_OnServiceL_Accessed;        
       
   382         TInt                        iTxnID;       
       
   383         
       
   384         CTestConsumer*              ipConsumer;        
       
   385         CTestConsumer*              ipConsumer1;        
       
   386         CTestHostlet*               ipHostlet;
       
   387 				CTestHostlet*               ipHostlet1;   
       
   388 		
       
   389 				CActiveScheduler* iActiveScheduler;
       
   390         // Pointer to test (function) to be executed
       
   391         TestFunction iMethod;
       
   392 
       
   393         // Pointer to logger
       
   394         CStifLogger * iLog; 
       
   395         // ?one_line_short_description_of_data
       
   396         //?data_declaration;
       
   397 
       
   398         // Reserved pointer for future extension
       
   399         //TAny* iReserved;
       
   400 
       
   401     public:     // Friend classes
       
   402         //?friend_class_declaration;
       
   403     protected:  // Friend classes
       
   404         //?friend_class_declaration;
       
   405     private:    // Friend classes
       
   406         //?friend_class_declaration;
       
   407 
       
   408     };
       
   409 
       
   410 #endif      // HOSTCONNTESTER_H
       
   411 
       
   412 // End of File