bluetooth/btexample/test/cit/ROMConfig/src/cteststepbtromconfiguser003.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 "cteststepbtromconfiguser003.h"
       
    17 
       
    18 /** 
       
    19 Panic string if an invalid test subcase is specified
       
    20 Panic number is the invalid subcase
       
    21 */
       
    22 _LIT(KInvalidTestPanicString, "Invalid Test subcase specified");
       
    23 
       
    24 CTestStepBtRomConfigUser003::~CTestStepBtRomConfigUser003()
       
    25 	{
       
    26 	if ( iSocketServ.Handle() )
       
    27 		{
       
    28 		iSocketServ.Close();
       
    29 		}
       
    30     }	
       
    31 
       
    32 CTestStepBtRomConfigUser003::CTestStepBtRomConfigUser003
       
    33 	(CTestServer& aParent) 
       
    34 	: CTestStepBtRomConfigBase(aParent)
       
    35 	{
       
    36 	SetTestStepName(KTestNameUser003);
       
    37 	}
       
    38 
       
    39 /**
       
    40 Static Constructor
       
    41 Note the lack of ELeave. This means that having insufficient memory will return NULL;
       
    42 */
       
    43 CTestStepBtRomConfigUser003* CTestStepBtRomConfigUser003::New
       
    44 	(CTestServer& aParent)
       
    45 	{
       
    46 	return new CTestStepBtRomConfigUser003(aParent); 
       
    47 	}
       
    48 
       
    49 /**
       
    50 See BT_ROMCONFIG_USER_003.script
       
    51 */
       
    52 TVerdict CTestStepBtRomConfigUser003::doTestStepL()
       
    53 	{
       
    54 	INFO_PRINTF1(\
       
    55 		_L(">>CTestStepBtRomConfigUser003::doTestStepL()"));
       
    56 	User::LeaveIfError( iSocketServ.Connect() );
       
    57 
       
    58 	CActiveScheduler* sched = new (ELeave)CActiveScheduler;
       
    59 	CActiveScheduler::Install(sched);
       
    60 	CleanupStack::PushL(sched);
       
    61 	
       
    62 	const TInt expectedError = ( iBtExcluded ? KErrBadName : KErrNone );
       
    63 	// this is only used for logging readability purposes
       
    64 	const TDesC* expectedErrorDesPtr = ( iBtExcluded ? &KErrBadNameLit : &KErrNoneLit );
       
    65 	
       
    66 	TRAPD(err, TestSynchronousLinkConstructorL(1));
       
    67 	if ( err!=expectedError )
       
    68 		{
       
    69 		INFO_PRINTF4(\
       
    70 			_L("Failed: Expected %S(%d) and got %d calling CBluetoothSynchronousLink::NewL"),\
       
    71 			expectedErrorDesPtr, expectedError, err);
       
    72 		SetTestStepResult(EFail);
       
    73 		}
       
    74 	
       
    75 	TRAPD(err2, TestSynchronousLinkConstructorL(2));
       
    76 	if ( err2!=expectedError )
       
    77 		{
       
    78 		INFO_PRINTF4(\
       
    79 			_L("Failed: Expected %S(%d) and got %d calling CBluetoothSynchronousLink::NewLC"),\
       
    80 			expectedErrorDesPtr, expectedError, err2);
       
    81 		SetTestStepResult(EFail);
       
    82 		}	
       
    83 		
       
    84 	iSocketServ.Close();
       
    85 	
       
    86 	CleanupStack::PopAndDestroy(sched);
       
    87 	INFO_PRINTF1(\
       
    88 		_L("<<CTestStepBtRomConfigUser003::doTestStepL()"));
       
    89 	CheckAndSetTestResult();
       
    90 	return TestStepResult(); 
       
    91 	}
       
    92 
       
    93 void CTestStepBtRomConfigUser003::TestSynchronousLinkConstructorL(TInt aTestSubCase)
       
    94 	{
       
    95 	switch(aTestSubCase)
       
    96 		{
       
    97 		case 1:
       
    98 			{
       
    99 			CBluetoothSynchronousLink* linkCase1 = 
       
   100 			CBluetoothSynchronousLink::NewL(*this, iSocketServ);
       
   101 			CleanupStack::PushL(linkCase1);
       
   102 			User::LeaveIfError(linkCase1->AcceptConnection());	
       
   103 			CleanupStack::PopAndDestroy(linkCase1);
       
   104 			}
       
   105 			break;
       
   106 			
       
   107 		case 2:
       
   108 			{
       
   109 			CBluetoothSynchronousLink* linkCase2 = 
       
   110 			CBluetoothSynchronousLink::NewLC(*this, iSocketServ);
       
   111 			User::LeaveIfError(linkCase2->AcceptConnection());					
       
   112 			CleanupStack::PopAndDestroy(linkCase2);	
       
   113 			}
       
   114 			break;
       
   115 		
       
   116 		default:
       
   117 			SetTestStepResult(EFail);
       
   118 			User::Panic(KInvalidTestPanicString, aTestSubCase);
       
   119 			break;
       
   120 		}
       
   121 	}
       
   122 
       
   123 // stubs from MBluetoothSynchronousLinkNotifier
       
   124 void CTestStepBtRomConfigUser003::HandleSetupConnectionCompleteL(TInt /*aErr*/)
       
   125 	{
       
   126 	}
       
   127 	
       
   128 void CTestStepBtRomConfigUser003::HandleDisconnectionCompleteL(TInt /*aErr*/)
       
   129 	{
       
   130 	}
       
   131 	
       
   132 void CTestStepBtRomConfigUser003::HandleAcceptConnectionCompleteL(TInt /*aErr*/)
       
   133 	{
       
   134 	}
       
   135 	
       
   136 void CTestStepBtRomConfigUser003::HandleSendCompleteL(TInt /*aErr*/)
       
   137 	{
       
   138 	}
       
   139 	
       
   140 void CTestStepBtRomConfigUser003::HandleReceiveCompleteL(TInt /*aErr*/)
       
   141 	{
       
   142 	}
       
   143 	
       
   144 // EOF