bluetooth/btexample/test/cit/ROMConfig/src/cteststepbtromconfigrsocketserv001.cpp
changeset 0 29b1cd4cb562
equal deleted inserted replaced
-1:000000000000 0:29b1cd4cb562
       
     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 #include "cteststepbtromconfigrsocketserv001.h"
       
    17 #include <bt_sock.h>
       
    18 #include <bluetoothav.h>
       
    19 
       
    20 _LIT(KProtocolSdp, "SDP");
       
    21 _LIT(KProtocolBtLinkManager, "BTLinkManager");
       
    22 _LIT(KProtocolAvctp, "AVCTP");
       
    23 
       
    24 CTestStepBtRomConfigRSocketServ001::~CTestStepBtRomConfigRSocketServ001()
       
    25 	{
       
    26 	if ( iSocketServ.Handle() )
       
    27 		{
       
    28 		iSocketServ.Close();
       
    29 		}
       
    30     }
       
    31 	
       
    32 CTestStepBtRomConfigRSocketServ001::CTestStepBtRomConfigRSocketServ001
       
    33 	(CTestServer& aParent) 
       
    34 	: CTestStepBtRomConfigBase(aParent)
       
    35 	{
       
    36 	SetTestStepName(KTestNameRSocketServ001);
       
    37 	}
       
    38 
       
    39 /**
       
    40 Static Constructor
       
    41 Note the lack of ELeave. This means that having insufficient memory will return NULL;
       
    42 */
       
    43 CTestStepBtRomConfigRSocketServ001* CTestStepBtRomConfigRSocketServ001::New
       
    44 	(CTestServer& aParent)
       
    45 	{
       
    46 	return new CTestStepBtRomConfigRSocketServ001(aParent); 
       
    47 	}
       
    48 
       
    49 /**
       
    50 See BT_ROMCONFIG_RSOCKETSERV_001.script
       
    51 */
       
    52 TVerdict CTestStepBtRomConfigRSocketServ001::doTestStepL()
       
    53 	{
       
    54 	INFO_PRINTF1(\
       
    55 		_L("&gt;&gt;CTestStepBtRomConfigRSocketServ001::doTestStepL()"));
       
    56 	
       
    57 	User::LeaveIfError(iSocketServ.Connect());
       
    58 
       
    59 	TestFindProtocol(KRFCOMMDesC);
       
    60 	TestFindProtocol(KL2CAPDesC);
       
    61 	TestFindProtocol(KProtocolSdp);
       
    62 	TestFindProtocol(KProtocolBtLinkManager);
       
    63 	TestFindProtocol(KProtocolAvctp);
       
    64 	TestFindProtocol(KAVDTPProtocolName);
       
    65 	
       
    66 	iSocketServ.Close();
       
    67 	
       
    68 	INFO_PRINTF1(\
       
    69 		_L("&lt;&lt;CTestStepBtRomConfigRSocketServ001::doTestStepL()"));
       
    70 	CheckAndSetTestResult();
       
    71 	return TestStepResult(); 
       
    72 	}
       
    73 
       
    74 void CTestStepBtRomConfigRSocketServ001::TestFindProtocol(const TDesC& aProtocolName)
       
    75 	{
       
    76 	const TInt expectedError = ( iBtExcluded ? KErrNotFound : KErrNone );
       
    77 	// this is only used for logging readability purposes
       
    78 	const TDesC* expectedErrorDesPtr = ( iBtExcluded ? &KErrNotFoundLit : &KErrNoneLit ); 
       
    79 	TProtocolDesc protocolDesc;
       
    80 	TInt err = iSocketServ.FindProtocol(TProtocolName(aProtocolName), protocolDesc);
       
    81 	if ( err!=expectedError )
       
    82 		{
       
    83 		INFO_PRINTF5(\
       
    84 			_L("Failed: Expected %S(%d) and got %d when calling FindProtocol for %S"),\
       
    85 			expectedErrorDesPtr, expectedError, err, &aProtocolName);
       
    86 		SetTestStepResult(EFail);
       
    87 		}
       
    88 	}
       
    89 
       
    90 // EOF