websrv_pub/web_service_messaging_api/tsrc/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 // -----------------------------------------------------------------------------
       
   121 // CNewSoapClassesBCTest::NewL
       
   122 // Two-phased constructor.
       
   123 // -----------------------------------------------------------------------------
       
   124 //
       
   125 CNewSoapClassesBCTest* CNewSoapClassesBCTest::NewL()
       
   126     {
       
   127     CNewSoapClassesBCTest* self = new (ELeave) CNewSoapClassesBCTest;
       
   128 
       
   129     CleanupStack::PushL( self );
       
   130     self->ConstructL();
       
   131     CleanupStack::Pop();
       
   132 
       
   133     return self;
       
   134 
       
   135     }
       
   136 
       
   137 // Destructor
       
   138 CNewSoapClassesBCTest::~CNewSoapClassesBCTest()
       
   139     {
       
   140     if (iLog)  delete iLog;
       
   141     //if ( iXmlReader)
       
   142     	//{
       
   143         //delete iXmlReader;
       
   144       //  iXmlReader = NULL;
       
   145     //  }
       
   146     }
       
   147 
       
   148 // -----------------------------------------------------------------------------
       
   149 // CNewSoapClassesBCTest::InitL
       
   150 // InitL is used to initialize the Test Module.
       
   151 // -----------------------------------------------------------------------------
       
   152 //
       
   153 TInt CNewSoapClassesBCTest::InitL( 
       
   154     TFileName& /*aIniFile*/, 
       
   155     TBool /*aFirstTime*/ )
       
   156     {
       
   157     return KErrNone;
       
   158 
       
   159     }
       
   160 
       
   161 // -----------------------------------------------------------------------------
       
   162 // CNewSoapClassesBCTest::GetTestCasesL
       
   163 // GetTestCases is used to inquire test cases from the Test Module. Test
       
   164 // cases are stored to array of test cases. The Test Framework will be 
       
   165 // the owner of the data in the RPointerArray after GetTestCases return
       
   166 // and it does the memory deallocation. 
       
   167 // -----------------------------------------------------------------------------
       
   168 //
       
   169 TInt CNewSoapClassesBCTest::GetTestCasesL( 
       
   170     const TFileName& /*aConfig*/, 
       
   171     RPointerArray<TTestCaseInfo>& aTestCases )
       
   172     {
       
   173 
       
   174     // Loop through all test cases and create new
       
   175     // TTestCaseInfo items and append items to aTestCase array    
       
   176     for( TInt i = 0; Case(i).iMethod != NULL; i++ )
       
   177         {
       
   178 
       
   179         // Allocate new TTestCaseInfo from heap for a testcase definition.
       
   180         TTestCaseInfo* newCase = new( ELeave ) TTestCaseInfo();
       
   181 
       
   182         // PushL TTestCaseInfo to CleanupStack.    
       
   183         CleanupStack::PushL( newCase );
       
   184 
       
   185         // Set number for the testcase.
       
   186         // When the testcase is run, this comes as a parameter to RunTestCaseL.
       
   187         newCase->iCaseNumber = i;
       
   188 
       
   189         // Set title for the test case. This is shown in UI to user.
       
   190         newCase->iTitle.Copy( Case(i).iCaseName );
       
   191 
       
   192         // Append TTestCaseInfo to the testcase array. After appended 
       
   193         // successfully the TTestCaseInfo object is owned (and freed) 
       
   194         // by the TestServer. 
       
   195         User::LeaveIfError(aTestCases.Append ( newCase ) );
       
   196 
       
   197         // Pop TTestCaseInfo from the CleanupStack.
       
   198         CleanupStack::Pop( newCase );
       
   199 
       
   200         }
       
   201 
       
   202     return KErrNone;
       
   203 
       
   204     }
       
   205 
       
   206 // -----------------------------------------------------------------------------
       
   207 // CNewSoapClassesBCTest::RunTestCaseL
       
   208 // RunTestCaseL is used to run an individual test case specified 
       
   209 // by aTestCase. Test cases that can be run may be requested from 
       
   210 // Test Module by GetTestCases method before calling RunTestCase.
       
   211 // -----------------------------------------------------------------------------
       
   212 //
       
   213 TInt CNewSoapClassesBCTest::RunTestCaseL( 
       
   214     const TInt aCaseNumber,   
       
   215     const TFileName& /*aConfig*/,
       
   216     TTestResult& aResult )
       
   217     {
       
   218 
       
   219     // Return value
       
   220     TInt execStatus = KErrNone;
       
   221 
       
   222     // Get the pointer to test case function
       
   223     TCaseInfo tmp = Case ( aCaseNumber );
       
   224 		iLog->Log( _L("-------------------------------------------------------------"));
       
   225     _LIT( KLogStartTC, "Starting testcase [%S]" );
       
   226     iLog->Log( KLogStartTC, &tmp.iCaseName);
       
   227 
       
   228     // Check that case number was valid
       
   229     if ( tmp.iMethod != NULL )
       
   230         {
       
   231         // Valid case was found, call it via function pointer
       
   232         iMethod = tmp.iMethod;        
       
   233         execStatus  = ( this->*iMethod )( aResult );
       
   234         }
       
   235     else
       
   236         {
       
   237         // Valid case was not found, return error.
       
   238         execStatus = KErrNotFound;
       
   239         }
       
   240         CloseSTDLIB();
       
   241     // Return case execution status (not the result of the case execution)
       
   242     return execStatus;
       
   243 
       
   244     }
       
   245 
       
   246 // -----------------------------------------------------------------------------
       
   247 // CNewSoapClassesBCTest::OOMTestQueryL
       
   248 // Used to check if a particular test case should be run in OOM conditions and 
       
   249 // which memory allocations should fail.    
       
   250 // -----------------------------------------------------------------------------
       
   251 //
       
   252 TBool CNewSoapClassesBCTest::OOMTestQueryL( 
       
   253                                 const TFileName& /* aTestCaseFile */, 
       
   254                                 const TInt aCaseNumber, 
       
   255                                 TOOMFailureType& /* aFailureType */, 
       
   256                                 TInt& aFirstMemFailure, 
       
   257                                 TInt& aLastMemFailure ) 
       
   258     {
       
   259     _LIT( KLogOOMTestQueryL, "CNewSoapClassesBCTest::OOMTestQueryL" );
       
   260     iLog->Log( KLogOOMTestQueryL );     
       
   261 
       
   262     aFirstMemFailure = Case( aCaseNumber ).iFirstMemoryAllocation;
       
   263     aLastMemFailure = Case( aCaseNumber ).iLastMemoryAllocation;
       
   264 
       
   265     return Case( aCaseNumber ).iIsOOMTest;
       
   266 
       
   267     }
       
   268 
       
   269 // -----------------------------------------------------------------------------
       
   270 // CNewSoapClassesBCTest::OOMTestInitializeL
       
   271 // Used to perform the test environment setup for a particular OOM test case. 
       
   272 // Test Modules may use the initialization file to read parameters for Test 
       
   273 // Module initialization but they can also have their own configure file or 
       
   274 // some other routine to initialize themselves.  
       
   275 //
       
   276 // NOTE: User may add implementation for OOM test environment initialization.
       
   277 // Usually no implementation is required.
       
   278 // -----------------------------------------------------------------------------
       
   279 //
       
   280 void CNewSoapClassesBCTest::OOMTestInitializeL( 
       
   281                                 const TFileName& /* aTestCaseFile */, 
       
   282                                 const TInt /* aCaseNumber */ )
       
   283     {
       
   284     }
       
   285 
       
   286 // -----------------------------------------------------------------------------
       
   287 // CNewSoapClassesBCTest::OOMHandleWarningL
       
   288 // In some cases the heap memory allocation should be skipped, either due to
       
   289 // problems in the OS code or components used by the code being tested, or even 
       
   290 // inside the tested components which are implemented this way on purpose (by 
       
   291 // design), so it is important to give the tester a way to bypass allocation 
       
   292 // failures.
       
   293 //
       
   294 // NOTE: User may add implementation for OOM test warning handling. Usually no
       
   295 // implementation is required.
       
   296 // -----------------------------------------------------------------------------
       
   297 //
       
   298 void CNewSoapClassesBCTest::OOMHandleWarningL( 
       
   299                                 const TFileName& /* aTestCaseFile */,
       
   300                                 const TInt /* aCaseNumber */, 
       
   301                                 TInt& /* aFailNextValue */ )
       
   302     {
       
   303     }
       
   304 
       
   305 // -----------------------------------------------------------------------------
       
   306 // CNewSoapClassesBCTest::OOMTestFinalizeL
       
   307 // Used to perform the test environment cleanup for a particular OOM test case.
       
   308 //
       
   309 // NOTE: User may add implementation for OOM test environment finalization.
       
   310 // Usually no implementation is required.
       
   311 // -----------------------------------------------------------------------------
       
   312 //
       
   313 void CNewSoapClassesBCTest::OOMTestFinalizeL( 
       
   314                                 const TFileName& /* aTestCaseFile */, 
       
   315                                 const TInt /* aCaseNumber */ )
       
   316     {
       
   317     }
       
   318 
       
   319 // ========================== OTHER EXPORTED FUNCTIONS =========================
       
   320 
       
   321 // -----------------------------------------------------------------------------
       
   322 // LibEntryL is a polymorphic Dll entry point
       
   323 // Returns: CTestModuleBase*: Pointer to Test Module object
       
   324 // -----------------------------------------------------------------------------
       
   325 //
       
   326 EXPORT_C CTestModuleBase* LibEntryL()
       
   327     {
       
   328     return CNewSoapClassesBCTest::NewL();
       
   329 
       
   330     }
       
   331 
       
   332 // -----------------------------------------------------------------------------
       
   333 // SetRequirements handles test module parameters(implements evolution
       
   334 // version 1 for test module's heap and stack sizes configuring).
       
   335 // Returns: TInt: Symbian error code.
       
   336 // -----------------------------------------------------------------------------
       
   337 //
       
   338 EXPORT_C TInt SetRequirements( CTestModuleParam*& /*aTestModuleParam*/, 
       
   339                                 TUint32& /*aParameterValid*/ )
       
   340     {
       
   341 
       
   342     /* --------------------------------- NOTE ---------------------------------
       
   343     USER PANICS occurs in test thread creation when:
       
   344     1) "The panic occurs when the value of the stack size is negative."
       
   345     2) "The panic occurs if the minimum heap size specified is less
       
   346        than KMinHeapSize".
       
   347        KMinHeapSize: "Functions that require a new heap to be allocated will
       
   348        either panic, or will reset the required heap size to this value if
       
   349        a smaller heap size is specified".
       
   350     3) "The panic occurs if the minimum heap size specified is greater than
       
   351        the maximum size to which the heap can grow".
       
   352     Other:
       
   353     1) Make sure that your hardware or Symbian OS is supporting given sizes.
       
   354        e.g. Hardware might support only sizes that are divisible by four.
       
   355     ------------------------------- NOTE end ------------------------------- */
       
   356 
       
   357     // Normally STIF uses default heap and stack sizes for test thread, see:
       
   358     // KTestThreadMinHeap, KTestThreadMinHeap and KStackSize.
       
   359     // If needed heap and stack sizes can be configured here by user. Remove
       
   360     // comments and define sizes.
       
   361 
       
   362 /*
       
   363     aParameterValid = KStifTestModuleParameterChanged;
       
   364 
       
   365     CTestModuleParamVer01* param = CTestModuleParamVer01::NewL();
       
   366     // Stack size
       
   367     param->iTestThreadStackSize= 16384; // 16K stack
       
   368     // Heap sizes
       
   369     param->iTestThreadMinHeap = 4096;   // 4K heap min
       
   370     param->iTestThreadMaxHeap = 1048576;// 1M heap max
       
   371 
       
   372     aTestModuleParam = param;
       
   373 */
       
   374     return KErrNone;
       
   375 
       
   376     }
       
   377 
       
   378 // -----------------------------------------------------------------------------
       
   379 // E32Dll is a DLL entry point function
       
   380 // Returns: KErrNone: No error
       
   381 // -----------------------------------------------------------------------------
       
   382 //
       
   383 #ifndef EKA2 // Hide Dll entry point to EKA2
       
   384 GLDEF_C TInt E32Dll(
       
   385     TDllReason /*aReason*/) // Reason
       
   386     {
       
   387     return(KErrNone);
       
   388 
       
   389     }
       
   390 #endif // EKA2
       
   391 
       
   392 //  End of File