commsprocess/commsrootserverconfig/TE_rootserver/src/RootServerTestSection4.cpp
changeset 72 ae47d0499bee
equal deleted inserted replaced
68:5da8188e392b 72:ae47d0499bee
       
     1 // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // This contains ESock Test cases from section 4
       
    15 // 
       
    16 //
       
    17 
       
    18 // EPOC includes
       
    19 #include <e32base.h>
       
    20 #include <es_mbman.h>
       
    21 
       
    22 // Test system includes
       
    23 #include <comms-infras/commsdebugutility.h>
       
    24 //#include <networking/teststep.h>
       
    25 //#include <networking/testsuite.h>
       
    26 
       
    27 #include "TestStepRootServer.h"
       
    28 #include "TestAsynchHandler.h"
       
    29 
       
    30 #include "RootServerTest.h"
       
    31 #include "RootServerTestSection4.h"
       
    32 
       
    33 // Test step 4.1 - SuddenDeathListener
       
    34 CRootServerTest4_1::CRootServerTest4_1(CTE_RootServerServer *aSuite) : CTestStepRootServer(aSuite)
       
    35 	{
       
    36 	// store the name of this test case
       
    37 	SetTestStepName(_L("Test4.1"));
       
    38 	}
       
    39 
       
    40 
       
    41 TVerdict CRootServerTest4_1::doTestStepL( void )
       
    42 	{
       
    43 										SetTestStepResult(EPass);
       
    44 	INFO_PRINTF1(_L("Test Purpose: SuddenDeathListener"));
       
    45 
       
    46 	// Create scheduler/active object framework 
       
    47 	CSelfPopScheduler* scheduler = CSelfPopScheduler::CreateLC();
       
    48     CTestAsynchHandler* asynchHandler = CTestAsynchHandler::NewLC(&iRootServerSuite->RootSess());
       
    49 
       
    50 	TRSStartModuleParams startParams;
       
    51 	TTestModuleIniData iniData;
       
    52 	DefaultStartParams(startParams, iniData);
       
    53 	startParams.iParams.iName = KModule1;
       
    54 #if defined(SYMBIAN_C32ROOT_API_V3)
       
    55 	startParams.iParams.iControlFlags = TRSStartModuleParamContainer::KCF_UnstableModule;
       
    56 #endif
       
    57 	iniData.iParams.iDeathDelay = isTestServerLifeTime;
       
    58 
       
    59 	INFO_PRINTF2(_L("02 Loading module: %S"), &startParams.iParams.iName);
       
    60 	asynchHandler->TryLoad(startParams, iniData);
       
    61 
       
    62 	CActiveScheduler::Start();
       
    63     if (asynchHandler->iStatus != KErrNone)
       
    64 		{
       
    65 		INFO_PRINTF2(_L("LoadServer returned error: <%d> "), asynchHandler->iStatus.Int());
       
    66 		User::Leave(asynchHandler->iStatus.Int());
       
    67 		}
       
    68 
       
    69 	// create a new active object for the sudden death handler
       
    70 	CTestAsynchHandler* suddenDeathHandler = CTestAsynchHandler::NewLC(&iRootServerSuite->RootSess());
       
    71 
       
    72 	// wait for either sudden death indication or timeout
       
    73 	INFO_PRINTF2(_L("03 Waiting for sudden death for up to %1.3f seconds"), isTestServerWaitTime / 1000.0);
       
    74 	asynchHandler->WaitForTimer(isTestServerWaitTime);
       
    75 	suddenDeathHandler->TryWaitForDeath();
       
    76 	CActiveScheduler::Start();
       
    77 
       
    78 	// uninstall active scheduler
       
    79 	asynchHandler->Cancel();
       
    80 	suddenDeathHandler->Cancel();
       
    81 
       
    82 	// see which events have occurred 
       
    83 	// if root server worked then timer should not have expired
       
    84 	// and sudden death handler AO should have returned to idle
       
    85 	if (CTestAsynchHandler::EWaitingforTimer != asynchHandler->GetiState())
       
    86 		{
       
    87 		INFO_PRINTF1(_L("Timer expired"));
       
    88 		SetTestStepResult(EFail);	
       
    89 		}
       
    90 	
       
    91 	if (CTestAsynchHandler::EIdle != suddenDeathHandler->GetiState())
       
    92 		{
       
    93 		INFO_PRINTF1(_L("SuddenDeathHandler was not triggered"));
       
    94 		SetTestStepResult(EFail);	
       
    95 		}
       
    96 
       
    97 	// enumerate servers
       
    98 	INFO_PRINTF1(_L("04 Enumerating modules"));
       
    99 
       
   100 	TCFModuleName moduleName;
       
   101 	TRSIter position;
       
   102 	TInt ret = iRootServerSuite->RootSess().EnumerateModules(position, moduleName);
       
   103 	INFO_PRINTF2(_L("Enumerate returned %d"), ret);
       
   104 	if (KErrEof != ret)
       
   105 		{
       
   106 		INFO_PRINTF1(_L("Module left alive"));
       
   107 		SetTestStepResult(EFail);	
       
   108 		}
       
   109 	// destroy active objects and scheduler
       
   110 	CleanupStack::PopAndDestroy(suddenDeathHandler);
       
   111 	CleanupStack::PopAndDestroy(asynchHandler);
       
   112 	CleanupStack::PopAndDestroy(scheduler);
       
   113 
       
   114 	return TestStepResult();
       
   115 	}
       
   116