websrv_pub/web_service_connection_api/tsrc/bc/connection/src/senserviceconnection.cpp
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 class member functions
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 
       
    25 
       
    26 // INCLUDE FILES
       
    27 #include <StifTestInterface.h>
       
    28 #include "SenServiceConnectionBCTest.h"
       
    29 
       
    30 // EXTERNAL DATA STRUCTURES
       
    31 //extern  ?external_data;
       
    32 
       
    33 // EXTERNAL FUNCTION PROTOTYPES  
       
    34 //extern ?external_function( ?arg_type,?arg_type );
       
    35 
       
    36 // CONSTANTS
       
    37 //const ?type ?constant_var = ?constant;
       
    38 
       
    39 // MACROS
       
    40 //#define ?macro ?macro_def
       
    41 
       
    42 // LOCAL CONSTANTS AND MACROS
       
    43 //const ?type ?constant_var = ?constant;
       
    44 //#define ?macro_name ?macro_def
       
    45 
       
    46 // MODULE DATA STRUCTURES
       
    47 //enum ?declaration
       
    48 //typedef ?declaration
       
    49 
       
    50 // LOCAL FUNCTION PROTOTYPES
       
    51 //?type ?function_name( ?arg_type, ?arg_type );
       
    52 
       
    53 // FORWARD DECLARATIONS
       
    54 //class ?FORWARD_CLASSNAME;
       
    55 
       
    56 // ============================= LOCAL FUNCTIONS ===============================
       
    57 
       
    58 // -----------------------------------------------------------------------------
       
    59 // ?function_name ?description.
       
    60 // ?description
       
    61 // Returns: ?value_1: ?description
       
    62 //          ?value_n: ?description_line1
       
    63 //                    ?description_line2
       
    64 // -----------------------------------------------------------------------------
       
    65 //
       
    66 /*
       
    67 ?type ?function_name(
       
    68     ?arg_type arg,  // ?description
       
    69     ?arg_type arg)  // ?description
       
    70     {
       
    71 
       
    72     ?code  // ?comment
       
    73 
       
    74     // ?comment
       
    75     ?code
       
    76     }
       
    77 */
       
    78 
       
    79 // ============================ MEMBER FUNCTIONS ===============================
       
    80 
       
    81 // -----------------------------------------------------------------------------
       
    82 // CSenServiceConnectionBCTest::CSenServiceConnectionBCTest
       
    83 // C++ default constructor can NOT contain any code, that
       
    84 // might leave.
       
    85 // -----------------------------------------------------------------------------
       
    86 //
       
    87 CSenServiceConnectionBCTest::CSenServiceConnectionBCTest()
       
    88     {
       
    89     iUseALR = EFalse;
       
    90     iCoBrandingCallbackOption = EFalse;
       
    91     iHostletConsumerOption = EFalse;
       
    92     iGetDataTrafficDetails = EFalse;
       
    93     isMigratedToPrefferedCarrier = EFalse;
       
    94     isNewCarrierAccepted = EFalse;
       
    95     iAlrCallBackRetryCount = 0;
       
    96     iSOAPMessage = NULL;
       
    97     }
       
    98 
       
    99 // -----------------------------------------------------------------------------
       
   100 // CSenServiceConnectionBCTest::ConstructL
       
   101 // Symbian 2nd phase constructor can leave.
       
   102 //
       
   103 // Note: If OOM test case uses STIF Logger, then STIF Logger must be created
       
   104 // with static buffer size parameter (aStaticBufferSize). Otherwise Logger 
       
   105 // allocates memory from heap and therefore causes error situations with OOM 
       
   106 // testing. For more information about STIF Logger construction, see STIF Users 
       
   107 // Guide.
       
   108 // -----------------------------------------------------------------------------
       
   109 //
       
   110 void CSenServiceConnectionBCTest::ConstructL()
       
   111     {
       
   112     
       
   113     
       
   114     iLog = CStifLogger::NewL( KSenServiceConnectionLogPath, 
       
   115                           KSenServiceConnectionLogFile);
       
   116 
       
   117     // Sample how to use logging
       
   118     _LIT( KLogStart, "CSenServiceConnectionBCTest logging starts!" );
       
   119     iLog->Log( KLogStart );
       
   120     
       
   121     iActiveScheduler = new CActiveScheduler;
       
   122 	CActiveScheduler::Install( iActiveScheduler );
       
   123 
       
   124     }
       
   125 //-----------------------------------------------------------------------------
       
   126 // CSenServiceConnectionBCTest::SendTestClassVersion
       
   127 // Method used to send version of test class
       
   128 //-----------------------------------------------------------------------------
       
   129 //
       
   130 void CSenServiceConnectionBCTest::SendTestModuleVersion()
       
   131 	{
       
   132 	TVersion moduleVersion;
       
   133 	moduleVersion.iMajor = TEST_MODULE_VERSION_MAJOR;
       
   134 	moduleVersion.iMinor = TEST_MODULE_VERSION_MINOR;
       
   135 	moduleVersion.iBuild = TEST_MODULE_VERSION_BUILD;
       
   136 	
       
   137 	TFileName moduleName;
       
   138 	moduleName = _L("CSenServiceConnectionBCTest.dll");
       
   139 	
       
   140 
       
   141 	TBool newVersionOfMethod = ETrue;
       
   142 	CTestModuleIf &test=TestModuleIf();
       
   143 	test.SendTestModuleVersion(moduleVersion, moduleName, newVersionOfMethod);
       
   144 	test.SetBehavior(CTestModuleIf::ETestLeaksHandles);
       
   145 	}
       
   146 
       
   147 
       
   148 // -----------------------------------------------------------------------------
       
   149 // CSenServiceConnectionBCTest::NewL
       
   150 // Two-phased constructor.
       
   151 // -----------------------------------------------------------------------------
       
   152 //
       
   153 CSenServiceConnectionBCTest* CSenServiceConnectionBCTest::NewL()
       
   154     {
       
   155     CSenServiceConnectionBCTest* self = new (ELeave) CSenServiceConnectionBCTest;
       
   156 
       
   157     CleanupStack::PushL( self );
       
   158     self->ConstructL();
       
   159     CleanupStack::Pop();
       
   160 
       
   161     return self;
       
   162 
       
   163     }
       
   164 
       
   165 // Destructor
       
   166 CSenServiceConnectionBCTest::~CSenServiceConnectionBCTest()
       
   167     {
       
   168     if(iServiceConnection!=NULL)
       
   169         {
       
   170         delete iServiceConnection;
       
   171         iServiceConnection = NULL;
       
   172         }
       
   173 
       
   174     if(iSOAPMessage!=NULL)
       
   175         {
       
   176         delete iSOAPMessage;
       
   177         iSOAPMessage = NULL;
       
   178         }
       
   179 		        
       
   180     delete iLog;
       
   181     if(iFsSessionHandle.Handle())
       
   182     	iFsSessionHandle.Close();
       
   183     delete iActiveScheduler;
       
   184     }
       
   185 
       
   186 // -----------------------------------------------------------------------------
       
   187 // CSenServiceConnectionBCTest::InitL
       
   188 // InitL is used to initialize the Test Module.
       
   189 // -----------------------------------------------------------------------------
       
   190 //
       
   191 TInt CSenServiceConnectionBCTest::InitL( 
       
   192     TFileName& /*aIniFile*/, 
       
   193     TBool /*aFirstTime*/ )
       
   194     {
       
   195     return KErrNone;
       
   196 
       
   197     }
       
   198 
       
   199 // -----------------------------------------------------------------------------
       
   200 // CSenServiceConnectionBCTest::GetTestCasesL
       
   201 // GetTestCases is used to inquire test cases from the Test Module. Test
       
   202 // cases are stored to array of test cases. The Test Framework will be 
       
   203 // the owner of the data in the RPointerArray after GetTestCases return
       
   204 // and it does the memory deallocation. 
       
   205 // -----------------------------------------------------------------------------
       
   206 //
       
   207 TInt CSenServiceConnectionBCTest::GetTestCasesL( 
       
   208     const TFileName& /*aConfig*/, 
       
   209     RPointerArray<TTestCaseInfo>& aTestCases )
       
   210     {
       
   211 
       
   212     // Loop through all test cases and create new
       
   213     // TTestCaseInfo items and append items to aTestCase array    
       
   214     for( TInt i = 0; Case(i).iMethod != NULL; i++ )
       
   215         {
       
   216 
       
   217         // Allocate new TTestCaseInfo from heap for a testcase definition.
       
   218         TTestCaseInfo* newCase = new( ELeave ) TTestCaseInfo();
       
   219 
       
   220         // PushL TTestCaseInfo to CleanupStack.    
       
   221         CleanupStack::PushL( newCase );
       
   222 
       
   223         // Set number for the testcase.
       
   224         // When the testcase is run, this comes as a parameter to RunTestCaseL.
       
   225         newCase->iCaseNumber = i;
       
   226 
       
   227         // Set title for the test case. This is shown in UI to user.
       
   228         newCase->iTitle.Copy( Case(i).iCaseName );
       
   229 
       
   230         // Append TTestCaseInfo to the testcase array. After appended 
       
   231         // successfully the TTestCaseInfo object is owned (and freed) 
       
   232         // by the TestServer. 
       
   233         User::LeaveIfError(aTestCases.Append ( newCase ) );
       
   234 
       
   235         // Pop TTestCaseInfo from the CleanupStack.
       
   236         CleanupStack::Pop( newCase );
       
   237 
       
   238         }
       
   239 
       
   240     return KErrNone;
       
   241 
       
   242     }
       
   243 
       
   244 // -----------------------------------------------------------------------------
       
   245 // CSenServiceConnectionBCTest::RunTestCaseL
       
   246 // RunTestCaseL is used to run an individual test case specified 
       
   247 // by aTestCase. Test cases that can be run may be requested from 
       
   248 // Test Module by GetTestCases method before calling RunTestCase.
       
   249 // -----------------------------------------------------------------------------
       
   250 //
       
   251 TInt CSenServiceConnectionBCTest::RunTestCaseL( 
       
   252     const TInt aCaseNumber,   
       
   253     const TFileName& /*aConfig*/,
       
   254     TTestResult& aResult )
       
   255     {
       
   256 		SendTestModuleVersion();
       
   257     // Return value
       
   258     TInt execStatus = KErrNone;
       
   259 
       
   260     // Get the pointer to test case function
       
   261     TCaseInfo tmp = Case ( aCaseNumber );
       
   262 
       
   263     _LIT( KLogStartTC, "Starting testcase [%S]" );
       
   264     iLog->Log( KLogStartTC, &tmp.iCaseName);
       
   265 
       
   266     // Check that case number was valid
       
   267     if ( tmp.iMethod != NULL )
       
   268         {
       
   269         // Valid case was found, call it via function pointer
       
   270         iMethod = tmp.iMethod;        
       
   271         execStatus  = ( this->*iMethod )( aResult );
       
   272         }
       
   273     else
       
   274         {
       
   275         // Valid case was not found, return error.
       
   276         execStatus = KErrNotFound;
       
   277         }
       
   278 
       
   279     // Return case execution status (not the result of the case execution)
       
   280     return execStatus;
       
   281 
       
   282     }
       
   283 
       
   284 // -----------------------------------------------------------------------------
       
   285 // CSenServiceConnectionBCTest::OOMTestQueryL
       
   286 // Used to check if a particular test case should be run in OOM conditions and 
       
   287 // which memory allocations should fail.    
       
   288 // -----------------------------------------------------------------------------
       
   289 //
       
   290 TBool CSenServiceConnectionBCTest::OOMTestQueryL( 
       
   291                                 const TFileName& /* aTestCaseFile */, 
       
   292                                 const TInt aCaseNumber, 
       
   293                                 TOOMFailureType& /* aFailureType */, 
       
   294                                 TInt& aFirstMemFailure, 
       
   295                                 TInt& aLastMemFailure ) 
       
   296     {
       
   297     _LIT( KLogOOMTestQueryL, "CSenServiceConnectionBCTest::OOMTestQueryL" );
       
   298     iLog->Log( KLogOOMTestQueryL );     
       
   299 
       
   300     aFirstMemFailure = Case( aCaseNumber ).iFirstMemoryAllocation;
       
   301     aLastMemFailure = Case( aCaseNumber ).iLastMemoryAllocation;
       
   302 
       
   303     return Case( aCaseNumber ).iIsOOMTest;
       
   304 
       
   305     }
       
   306 
       
   307 // -----------------------------------------------------------------------------
       
   308 // CSenServiceConnectionBCTest::OOMTestInitializeL
       
   309 // Used to perform the test environment setup for a particular OOM test case. 
       
   310 // Test Modules may use the initialization file to read parameters for Test 
       
   311 // Module initialization but they can also have their own configure file or 
       
   312 // some other routine to initialize themselves.  
       
   313 //
       
   314 // NOTE: User may add implementation for OOM test environment initialization.
       
   315 // Usually no implementation is required.
       
   316 // -----------------------------------------------------------------------------
       
   317 //
       
   318 void CSenServiceConnectionBCTest::OOMTestInitializeL( 
       
   319                                 const TFileName& /* aTestCaseFile */, 
       
   320                                 const TInt /* aCaseNumber */ )
       
   321     {
       
   322     }
       
   323 
       
   324 // -----------------------------------------------------------------------------
       
   325 // CSenServiceConnectionBCTest::OOMHandleWarningL
       
   326 // In some cases the heap memory allocation should be skipped, either due to
       
   327 // problems in the OS code or components used by the code being tested, or even 
       
   328 // inside the tested components which are implemented this way on purpose (by 
       
   329 // design), so it is important to give the tester a way to bypass allocation 
       
   330 // failures.
       
   331 //
       
   332 // NOTE: User may add implementation for OOM test warning handling. Usually no
       
   333 // implementation is required.
       
   334 // -----------------------------------------------------------------------------
       
   335 //
       
   336 void CSenServiceConnectionBCTest::OOMHandleWarningL( 
       
   337                                 const TFileName& /* aTestCaseFile */,
       
   338                                 const TInt /* aCaseNumber */, 
       
   339                                 TInt& /* aFailNextValue */ )
       
   340     {
       
   341     }
       
   342 
       
   343 // -----------------------------------------------------------------------------
       
   344 // CSenServiceConnectionBCTest::OOMTestFinalizeL
       
   345 // Used to perform the test environment cleanup for a particular OOM test case.
       
   346 //
       
   347 // NOTE: User may add implementation for OOM test environment finalization.
       
   348 // Usually no implementation is required.
       
   349 // -----------------------------------------------------------------------------
       
   350 //
       
   351 void CSenServiceConnectionBCTest::OOMTestFinalizeL( 
       
   352                                 const TFileName& /* aTestCaseFile */, 
       
   353                                 const TInt /* aCaseNumber */ )
       
   354     {
       
   355     }
       
   356 
       
   357 // ========================== OTHER EXPORTED FUNCTIONS =========================
       
   358 
       
   359 // -----------------------------------------------------------------------------
       
   360 // LibEntryL is a polymorphic Dll entry point
       
   361 // Returns: CTestModuleBase*: Pointer to Test Module object
       
   362 // -----------------------------------------------------------------------------
       
   363 //
       
   364 EXPORT_C CTestModuleBase* LibEntryL()
       
   365     {
       
   366     return CSenServiceConnectionBCTest::NewL();
       
   367 
       
   368     }
       
   369 
       
   370 // -----------------------------------------------------------------------------
       
   371 // SetRequirements handles test module parameters(implements evolution
       
   372 // version 1 for test module's heap and stack sizes configuring).
       
   373 // Returns: TInt: Symbian error code.
       
   374 // -----------------------------------------------------------------------------
       
   375 //
       
   376 EXPORT_C TInt SetRequirements( CTestModuleParam*& /*aTestModuleParam*/, 
       
   377                                 TUint32& /*aParameterValid*/ )
       
   378     {
       
   379 
       
   380     /* --------------------------------- NOTE ---------------------------------
       
   381     USER PANICS occurs in test thread creation when:
       
   382     1) "The panic occurs when the value of the stack size is negative."
       
   383     2) "The panic occurs if the minimum heap size specified is less
       
   384        than KMinHeapSize".
       
   385        KMinHeapSize: "Functions that require a new heap to be allocated will
       
   386        either panic, or will reset the required heap size to this value if
       
   387        a smaller heap size is specified".
       
   388     3) "The panic occurs if the minimum heap size specified is greater than
       
   389        the maximum size to which the heap can grow".
       
   390     Other:
       
   391     1) Make sure that your hardware or Symbian OS is supporting given sizes.
       
   392        e.g. Hardware might support only sizes that are divisible by four.
       
   393     ------------------------------- NOTE end ------------------------------- */
       
   394 
       
   395     // Normally STIF uses default heap and stack sizes for test thread, see:
       
   396     // KTestThreadMinHeap, KTestThreadMinHeap and KStackSize.
       
   397     // If needed heap and stack sizes can be configured here by user. Remove
       
   398     // comments and define sizes.
       
   399 
       
   400 /*
       
   401     aParameterValid = KStifTestModuleParameterChanged;
       
   402 
       
   403     CTestModuleParamVer01* param = CTestModuleParamVer01::NewL();
       
   404     // Stack size
       
   405     param->iTestThreadStackSize= 16384; // 16K stack
       
   406     // Heap sizes
       
   407     param->iTestThreadMinHeap = 4096;   // 4K heap min
       
   408     param->iTestThreadMaxHeap = 1048576;// 1M heap max
       
   409 
       
   410     aTestModuleParam = param;
       
   411 */
       
   412     return KErrNone;
       
   413 
       
   414     }
       
   415 
       
   416 // -----------------------------------------------------------------------------
       
   417 // E32Dll is a DLL entry point function
       
   418 // Returns: KErrNone: No error
       
   419 // -----------------------------------------------------------------------------
       
   420 //
       
   421 #ifndef EKA2 // Hide Dll entry point to EKA2
       
   422 GLDEF_C TInt E32Dll(
       
   423     TDllReason /*aReason*/) // Reason
       
   424     {
       
   425     return(KErrNone);
       
   426 
       
   427     }
       
   428 #endif // EKA2
       
   429 //  End of File