commsprocess/commsrootserverconfig/ts_rootserver/RootServerTestSection4.cpp
changeset 72 ae47d0499bee
parent 68 5da8188e392b
child 77 c9776eadbffd
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 "TestSuiteRootServer.h"
       
    29 #include "TestAsynchHandler.h"
       
    30 
       
    31 #include "RootServerTest.h"
       
    32 #include "RootServerTestSection4.h"
       
    33 
       
    34 // Test step 4.1 - SuddenDeathListener
       
    35 CRootServerTest4_1::CRootServerTest4_1()
       
    36 	{
       
    37 	// store the name of this test case
       
    38 	iTestStepName = _L("Test4.1");
       
    39 	}
       
    40 
       
    41 
       
    42 TVerdict CRootServerTest4_1::doTestStepL( void )
       
    43 	{
       
    44 	TVerdict verdict = EPass;
       
    45 
       
    46 	Log(_L("Test Purpose: SuddenDeathListener"));
       
    47 
       
    48 	// Create scheduler/active object framework 
       
    49 	CSelfPopScheduler* scheduler = CSelfPopScheduler::CreateLC();
       
    50     CTestAsynchHandler* asynchHandler = CTestAsynchHandler::NewLC(&iRootServerSuite->RootSess());
       
    51 
       
    52 	TRSStartModuleParams startParams;
       
    53 	TTestModuleIniData iniData;
       
    54 	DefaultStartParams(startParams, iniData);
       
    55 	startParams.iParams.iName = KModule1;
       
    56 #if defined(SYMBIAN_C32ROOT_API_V3)
       
    57 	startParams.iParams.iControlFlags = TRSStartModuleParamContainer::KCF_UnstableModule;
       
    58 #endif
       
    59 	iniData.iParams.iDeathDelay = isTestServerLifeTime;
       
    60 
       
    61 	Log(_L8("02 Loading module: %S"), &startParams.iParams.iName);
       
    62 	asynchHandler->TryLoad(startParams, iniData);
       
    63 
       
    64 	CActiveScheduler::Start();
       
    65     if (asynchHandler->iStatus != KErrNone)
       
    66 		{
       
    67 		Log(_L("LoadServer returned error: <%d> "), asynchHandler->iStatus.Int());
       
    68 		User::Leave(asynchHandler->iStatus.Int());
       
    69 		}
       
    70 
       
    71 	// create a new active object for the sudden death handler
       
    72 	CTestAsynchHandler* suddenDeathHandler = CTestAsynchHandler::NewLC(&iRootServerSuite->RootSess());
       
    73 
       
    74 	// wait for either sudden death indication or timeout
       
    75 	Log(_L("03 Waiting for sudden death for up to %1.3f seconds"), isTestServerWaitTime / 1000.0);
       
    76 	asynchHandler->WaitForTimer(isTestServerWaitTime);
       
    77 	suddenDeathHandler->TryWaitForDeath();
       
    78 	CActiveScheduler::Start();
       
    79 
       
    80 	// uninstall active scheduler
       
    81 	asynchHandler->Cancel();
       
    82 	suddenDeathHandler->Cancel();
       
    83 
       
    84 	// see which events have occurred 
       
    85 	// if root server worked then timer should not have expired
       
    86 	// and sudden death handler AO should have returned to idle
       
    87 	if (CTestAsynchHandler::EWaitingforTimer != asynchHandler->GetiState())
       
    88 		{
       
    89 		Log(_L("Timer expired"));
       
    90 		verdict = EFail;
       
    91 		}
       
    92 	
       
    93 	if (CTestAsynchHandler::EIdle != suddenDeathHandler->GetiState())
       
    94 		{
       
    95 		Log(_L("SuddenDeathHandler was not triggered"));
       
    96 		verdict = EFail;
       
    97 		}
       
    98 
       
    99 	// enumerate servers
       
   100 	Log(_L("04 Enumerating modules"));
       
   101 
       
   102 	TCFModuleName moduleName;
       
   103 	TRSIter position;
       
   104 	TInt ret = iRootServerSuite->RootSess().EnumerateModules(position, moduleName);
       
   105 	Log(_L("Enumerate returned %d"), ret);
       
   106 	if (KErrEof != ret)
       
   107 		{
       
   108 		Log(_L("Module left alive"));
       
   109 		verdict = EFail;
       
   110 		}
       
   111 
       
   112 
       
   113 	// destroy active objects and scheduler
       
   114 	CleanupStack::PopAndDestroy(suddenDeathHandler);
       
   115 	CleanupStack::PopAndDestroy(asynchHandler);
       
   116 	CleanupStack::PopAndDestroy(scheduler);
       
   117 
       
   118 	return verdict;
       
   119 	}
       
   120 
       
   121