sl@0: // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0: // All rights reserved.
sl@0: // This component and the accompanying materials are made available
sl@0: // under the terms of "Eclipse Public License v1.0"
sl@0: // which accompanies this distribution, and is available
sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0: //
sl@0: // Initial Contributors:
sl@0: // Nokia Corporation - initial contribution.
sl@0: //
sl@0: // Contributors:
sl@0: //
sl@0: // Description:
sl@0: // Example CTestStep derived implementation
sl@0: // 
sl@0: //
sl@0: 
sl@0: /**
sl@0:  @file TestConnectStep.cpp
sl@0:  @internalTechnology
sl@0: */
sl@0: #include "testconnectstep.h"
sl@0: #include "te_uloggerclientsuitedefs.h"
sl@0: 
sl@0: CTestConnectStep::~CTestConnectStep()
sl@0: /**
sl@0:  * Destructor
sl@0:  */
sl@0: 	{
sl@0: 	}
sl@0: 
sl@0: CTestConnectStep::CTestConnectStep()
sl@0: /**
sl@0:  * Constructor
sl@0:  */
sl@0: 	{
sl@0: 	// **MUST** call SetTestStepName in the constructor as the controlling
sl@0: 	// framework uses the test step name immediately following construction to set
sl@0: 	// up the step's unique logging ID.
sl@0: 	SetTestStepName(KTestConnectStep);
sl@0: 	}
sl@0: 
sl@0: TVerdict CTestConnectStep::doTestStepPreambleL()
sl@0: /**
sl@0:  * @return - TVerdict code
sl@0:  * Override of base class virtual
sl@0:  */
sl@0: {
sl@0: 	CTestUloggerClientApiStepBase::doTestStepPreambleL();
sl@0: 	if(TestStepResult() == EPass)
sl@0: 	{
sl@0: 		INFO_PRINTF1(_L("Initailizing TestConnectStep"));
sl@0: 		SetTestStepResult(EPass); //No initialization required just pass the step
sl@0: 	}
sl@0: 	
sl@0: 	return TestStepResult();
sl@0: }
sl@0: 
sl@0: 
sl@0: TVerdict CTestConnectStep::doTestStepL()
sl@0: /**
sl@0:  * @return - TVerdict code
sl@0:  * Override of base class pure virtual
sl@0:  * Our implementation only gets called if the base class doTestStepPreambleL() did
sl@0:  * not leave. That being the case, the current test result value will be EPass.
sl@0:  */
sl@0: {
sl@0: 
sl@0: 	TInt iErrCount = 0;
sl@0: 	if (TestStepResult()==EPass)
sl@0: 		{
sl@0: 			if(iSession)
sl@0: 			{	
sl@0: 				if(KErrNone == iSession->Connect())
sl@0: 				{
sl@0: 					//connect again to test simultaneous connections
sl@0: 					for(TInt i = 0; i <= 20;i++ )
sl@0: 					 {
sl@0: 					 	TInt iConnectRes = iSession->Connect();
sl@0: 					 	if( iConnectRes != KErrAlreadyExists && iConnectRes != KErrNone )
sl@0: 					 	{
sl@0: 					 		iErrCount++;
sl@0: 					 		break;
sl@0: 					 	}
sl@0: 						
sl@0: 					 }
sl@0: 					 if(iErrCount == 0)
sl@0: 					 {
sl@0: 					 	SetTestStepResult(EPass);
sl@0: 					 }
sl@0: 					 else
sl@0: 					 {
sl@0: 					 	TBuf<128> iInfoMsg;
sl@0: 					 	iInfoMsg.AppendFormat(_L("Simultaneous connection failed on %d atempt"), iErrCount);
sl@0: 					 	INFO_PRINTF1(iInfoMsg);
sl@0: 					 	SetTestStepResult(EFail);
sl@0: 					 }
sl@0: 				}
sl@0: 				else
sl@0: 				{
sl@0: 					INFO_PRINTF1(_L("connection to server failed"));
sl@0: 					SetTestStepResult(EFail);
sl@0: 				}
sl@0: 			}
sl@0: 		}
sl@0: 	  return TestStepResult();
sl@0: }
sl@0: 
sl@0: 
sl@0: 
sl@0: TVerdict CTestConnectStep::doTestStepPostambleL()
sl@0: /**
sl@0:  * @return - TVerdict code
sl@0:  * Override of base class virtual
sl@0:  */
sl@0: {
sl@0: 	INFO_PRINTF1(_L("TestConnectStep completed"));
sl@0: 
sl@0: 	iSession->Close(); //close the session in either case
sl@0: 	CTestUloggerClientApiStepBase::doTestStepPostambleL();
sl@0: 
sl@0: 	return TestStepResult();
sl@0: }