datacommsserver/esockserver/test/TE_EsockTestSteps/src/startrconnectionStep.cpp
changeset 0 dfb7c4ff071f
equal deleted inserted replaced
-1:000000000000 0:dfb7c4ff071f
       
     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 //
       
    15 
       
    16 /**
       
    17  @file startrconnectionStep.cpp
       
    18 */
       
    19 
       
    20 #include "Connections.TestSteps.h"
       
    21 #include "Sockets.TestSteps.h"
       
    22 #include "cdbcols.h"
       
    23 
       
    24 
       
    25 
       
    26 CStartRConnectionStep::CStartRConnectionStep(CCEsockTestBase*& aEsockTest)
       
    27 :   CTe_EsockStepBase(aEsockTest)
       
    28 	{
       
    29 	SetTestStepName(KStartRConnectionStep);
       
    30 	}
       
    31 
       
    32 TInt CStartRConnectionStep::ConfigureFromIni()
       
    33 	{
       
    34 	iParams.Reset();
       
    35 	
       
    36 	// Read in appropriate fields
       
    37 	if((GetStringFromConfig(iSection, KTe_ConnectionName, iParams.iConnectionName) != 1)
       
    38 		|| (iParams.iConnectionName.Length() == 0))
       
    39 		{
       
    40 		INFO_PRINTF1(_L("Couldn't find appropriate field in config file"));
       
    41 		return KErrNotFound;
       
    42 		}
       
    43 		
       
    44 	TPtrC16 bearerSet;
       
    45 	TBool bearerPresent = ((GetStringFromConfig(iSection,KTe_BearerName,bearerSet)==1)
       
    46 		&& (bearerSet.Length()>0));
       
    47 
       
    48 	TBool IAPpresent = (GetIntFromConfig(iSection,KTe_IAPIndexName,iParams.iIAP)==1);
       
    49 	TBool SNAPpresent = (GetIntFromConfig(iSection,KTe_SNAPIndexName,iParams.iSNAP)==1);
       
    50 
       
    51 	iParams.iStartWithOldPreferences = bearerPresent && IAPpresent;
       
    52 	iParams.iStartWithSnapPreferences = SNAPpresent;
       
    53 
       
    54 	if (iParams.iStartWithOldPreferences && iParams.iStartWithSnapPreferences)
       
    55 		{
       
    56 		INFO_PRINTF2(_L("Connection preferences for (%S) have both snap and IAP."),&iParams.iConnectionName);
       
    57 		return KErrNotFound;
       
    58 		}
       
    59 
       
    60 	//with preferences?
       
    61 	if (iParams.iStartWithOldPreferences)
       
    62 		{
       
    63 		if (bearerSet.Compare(KTe_CommDbBearerCSD)==0)
       
    64 			{ iParams.iBearer = KCommDbBearerCSD; }
       
    65 		else if (bearerSet.Compare(KTe_CommDbBearerWcdma)==0)
       
    66 			{ iParams.iBearer = KCommDbBearerWcdma; }
       
    67 		else if (bearerSet.Compare(KTe_CommDbBearerLAN)==0)
       
    68 			{ iParams.iBearer = KCommDbBearerLAN; }
       
    69 		else
       
    70 			{
       
    71 			INFO_PRINTF3(_L("%S: Bearer type (%S) not recognised."),&iParams.iConnectionName,&bearerSet);
       
    72 			return KErrNotFound;
       
    73 			}
       
    74 		}
       
    75 
       
    76 	if (!GetIntFromConfig(iSection,KTe_ExpectedError,iExpectedError))  
       
    77 		{
       
    78 		iExpectedError = KErrNone;
       
    79 		}
       
    80 
       
    81 	else 
       
    82 		{
       
    83 		INFO_PRINTF2(_L("Error to be expected: %d"),iExpectedError);
       
    84 		}
       
    85 
       
    86     // All ok if we got this far
       
    87     return KErrNone;
       
    88 	}
       
    89 
       
    90 TVerdict CStartRConnectionStep::doSingleTestStep()
       
    91 	{
       
    92     TInt error = iEsockTest->StartConnection(iParams);
       
    93 
       
    94 	if (error!=KErrNone)
       
    95           {
       
    96           INFO_PRINTF2(_L("Could not start connection (%S)."),&iParams.iConnectionName);
       
    97           INFO_PRINTF2(_L("Error: %d."),error);
       
    98           } 
       
    99 
       
   100     if (error!=iExpectedError)
       
   101           {
       
   102           INFO_PRINTF3(_L("Returned error (%d) differs from expected (%d)."), error, iExpectedError);
       
   103           return EFail;
       
   104           }
       
   105           
       
   106          return EPass;
       
   107          
       
   108 	}
       
   109 
       
   110