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