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