traceservices/tracefw/ulogger/unit_test/te-client/testconnectstep.cpp
changeset 0 08ec8eefde2f
equal deleted inserted replaced
-1:000000000000 0:08ec8eefde2f
       
     1 // Copyright (c) 2005-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 // Example CTestStep derived implementation
       
    15 // 
       
    16 //
       
    17 
       
    18 /**
       
    19  @file TestConnectStep.cpp
       
    20  @internalTechnology
       
    21 */
       
    22 #include "testconnectstep.h"
       
    23 #include "te_uloggerclientsuitedefs.h"
       
    24 
       
    25 CTestConnectStep::~CTestConnectStep()
       
    26 /**
       
    27  * Destructor
       
    28  */
       
    29 	{
       
    30 	}
       
    31 
       
    32 CTestConnectStep::CTestConnectStep()
       
    33 /**
       
    34  * Constructor
       
    35  */
       
    36 	{
       
    37 	// **MUST** call SetTestStepName in the constructor as the controlling
       
    38 	// framework uses the test step name immediately following construction to set
       
    39 	// up the step's unique logging ID.
       
    40 	SetTestStepName(KTestConnectStep);
       
    41 	}
       
    42 
       
    43 TVerdict CTestConnectStep::doTestStepPreambleL()
       
    44 /**
       
    45  * @return - TVerdict code
       
    46  * Override of base class virtual
       
    47  */
       
    48 {
       
    49 	CTestUloggerClientApiStepBase::doTestStepPreambleL();
       
    50 	if(TestStepResult() == EPass)
       
    51 	{
       
    52 		INFO_PRINTF1(_L("Initailizing TestConnectStep"));
       
    53 		SetTestStepResult(EPass); //No initialization required just pass the step
       
    54 	}
       
    55 	
       
    56 	return TestStepResult();
       
    57 }
       
    58 
       
    59 
       
    60 TVerdict CTestConnectStep::doTestStepL()
       
    61 /**
       
    62  * @return - TVerdict code
       
    63  * Override of base class pure virtual
       
    64  * Our implementation only gets called if the base class doTestStepPreambleL() did
       
    65  * not leave. That being the case, the current test result value will be EPass.
       
    66  */
       
    67 {
       
    68 
       
    69 	TInt iErrCount = 0;
       
    70 	if (TestStepResult()==EPass)
       
    71 		{
       
    72 			if(iSession)
       
    73 			{	
       
    74 				if(KErrNone == iSession->Connect())
       
    75 				{
       
    76 					//connect again to test simultaneous connections
       
    77 					for(TInt i = 0; i <= 20;i++ )
       
    78 					 {
       
    79 					 	TInt iConnectRes = iSession->Connect();
       
    80 					 	if( iConnectRes != KErrAlreadyExists && iConnectRes != KErrNone )
       
    81 					 	{
       
    82 					 		iErrCount++;
       
    83 					 		break;
       
    84 					 	}
       
    85 						
       
    86 					 }
       
    87 					 if(iErrCount == 0)
       
    88 					 {
       
    89 					 	SetTestStepResult(EPass);
       
    90 					 }
       
    91 					 else
       
    92 					 {
       
    93 					 	TBuf<128> iInfoMsg;
       
    94 					 	iInfoMsg.AppendFormat(_L("Simultaneous connection failed on %d atempt"), iErrCount);
       
    95 					 	INFO_PRINTF1(iInfoMsg);
       
    96 					 	SetTestStepResult(EFail);
       
    97 					 }
       
    98 				}
       
    99 				else
       
   100 				{
       
   101 					INFO_PRINTF1(_L("connection to server failed"));
       
   102 					SetTestStepResult(EFail);
       
   103 				}
       
   104 			}
       
   105 		}
       
   106 	  return TestStepResult();
       
   107 }
       
   108 
       
   109 
       
   110 
       
   111 TVerdict CTestConnectStep::doTestStepPostambleL()
       
   112 /**
       
   113  * @return - TVerdict code
       
   114  * Override of base class virtual
       
   115  */
       
   116 {
       
   117 	INFO_PRINTF1(_L("TestConnectStep completed"));
       
   118 
       
   119 	iSession->Close(); //close the session in either case
       
   120 	CTestUloggerClientApiStepBase::doTestStepPostambleL();
       
   121 
       
   122 	return TestStepResult();
       
   123 }