telephonyserverplugins/multimodetsy/test/Te_LoopBack/Te_LoopBackCCalls.cpp
changeset 0 3553901f7fa8
child 24 6638e7f4bd8f
equal deleted inserted replaced
-1:000000000000 0:3553901f7fa8
       
     1 // Copyright (c) 1997-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
       
    18 */
       
    19 
       
    20 #include <e32test.h>
       
    21 #include "Te_LoopBackCCalls.h"
       
    22 
       
    23 #include "../../hayes/TSYCONFG.H" // for KInternetAccessPoint
       
    24 
       
    25 const TInt KOneSecond=1000000;		// One second Pause
       
    26 
       
    27 //
       
    28 // Test-side class
       
    29 // With the assistance of the base class, this class must start the emulator
       
    30 // and drive the ETel API.
       
    31 //
       
    32 CTestDriveAllCalls* CTestDriveAllCalls::NewL(const TScriptList aScriptListEntry)
       
    33 	{
       
    34 	CTestDriveAllCalls* phoneLine=new(ELeave) CTestDriveAllCalls(aScriptListEntry);
       
    35 	CleanupStack::PushL(phoneLine);
       
    36 	phoneLine->ConstructL();
       
    37 	CleanupStack::Pop();
       
    38 	return phoneLine;
       
    39 	}
       
    40 
       
    41 CTestDriveAllCalls::CTestDriveAllCalls(const TScriptList aScriptListEntry) : iScriptListEntry(aScriptListEntry)
       
    42 	{
       
    43 	
       
    44 	}
       
    45 
       
    46 
       
    47 TInt CTestDriveAllCalls::RunTestL()
       
    48 	{
       
    49 	iCurrentScript=iScriptListEntry;
       
    50 	return StartEmulatorL();
       
    51 	}
       
    52 
       
    53 TInt CTestDriveAllCalls::DriveETelApiL()
       
    54 //
       
    55 // This function contains the real meat of the Client-side test code
       
    56 //
       
    57 	{
       
    58 	TRequestStatus	reqStatus;
       
    59 	INFO_PRINTF1(_L("Initialising the Phone..."));
       
    60 
       
    61 	RMobilePhone::TMMTableSettings tableSettings;
       
    62 	tableSettings.iLocId=KInternetAccessPoint;
       
    63 	RMobilePhone::TMMTableSettingsPckg tableSettingsPckg(tableSettings);
       
    64 	iPhone.InitialiseMM(reqStatus , tableSettingsPckg); 	
       
    65 
       
    66 	User::WaitForRequest(reqStatus);
       
    67 
       
    68 	TESTL(reqStatus == KErrNone);
       
    69 
       
    70 	ERR_PRINTF1(_L("Voice Call tests"));
       
    71 	TestVoiceCallL();
       
    72 	User::After(5*KOneSecond);		// Give the user time to see the test results
       
    73 
       
    74 	ERR_PRINTF1(_L("Cancel Requests test"));
       
    75 	TestCancelRequestsL();
       
    76 	User::After(5*KOneSecond);		// Give the user time to see the test results
       
    77 
       
    78 	ERR_PRINTF1(_L("Data Call tests"));
       
    79 	TestDataCallL();
       
    80 	
       
    81 	return KErrNone;
       
    82 	}
       
    83 
       
    84 void CTestDriveAllCalls::TestVoiceCallL()
       
    85 /**
       
    86  * This function performs Voice call tests
       
    87  */
       
    88 	{
       
    89 	RProcess().SetPriority(EPriorityForeground);
       
    90 	RThread().SetPriority(EPriorityNormal);
       
    91 	_LIT(KVoiceLineName,"Voice");
       
    92 	TRequestStatus status1;
       
    93 	
       
    94 	// Open a voice line and call
       
    95 	RLine voiceLine;
       
    96 	INFO_PRINTF1(_L("Opening Voice Line"));
       
    97 	TESTL(voiceLine.Open(iPhone,KVoiceLineName)==KErrNone);
       
    98 
       
    99 	RCall voiceCall;
       
   100 	INFO_PRINTF1(_L("Opening New Voice Call"));
       
   101 	TESTL(voiceCall.OpenNewCall(voiceLine)==KErrNone);
       
   102 
       
   103 	// Get the call capabilities
       
   104 	INFO_PRINTF1(_L("\nGet Call Capabilities...\n"));
       
   105 	RCall::TCaps callCaps;
       
   106 	TInt ret=voiceCall.GetCaps(callCaps);
       
   107 	CHECKPOINT_EXPR((ret == KErrNone || ret == KErrNotSupported), _L("*** Failed RCall::GetCaps() ***"));
       
   108 	if (ret==KErrNotSupported)
       
   109 		INFO_PRINTF1(_L("Get Call Capabilities is NOT Supported\n"));
       
   110 	if (ret==KErrNone)
       
   111 		{
       
   112 		INFO_PRINTF1(_L("Get Call Capabilities is Successful\n"));
       
   113 		
       
   114 		if ((callCaps.iFlags&RCall::KCapsVoice) !=0)
       
   115 			INFO_PRINTF1(_L("This call supports Voice calls\n"));
       
   116 		}
       
   117 
       
   118 	// Get the Call Status (The script has posted +CRING: VOICE, so the call is ringing!
       
   119 	INFO_PRINTF1(_L("\nGet Call Status...\n"));
       
   120 	RCall::TStatus callStatus;
       
   121 	ret=voiceCall.GetStatus(callStatus);
       
   122 	CHECKPOINT_EXPR((ret == KErrNone || ret == KErrNotSupported), _L("*** Failed RCall::GetStatus() ***"));
       
   123 	if (ret==KErrNotSupported)
       
   124 		INFO_PRINTF1(_L("Get Call Status is NOT Supported\n"));
       
   125 	if (ret==KErrNone)
       
   126 		{
       
   127 		TESTL(callStatus==RCall::EStatusRinging);
       
   128 		INFO_PRINTF1(_L("This Voice call is currently ringing\n"));
       
   129 		}
       
   130 
       
   131 	// Answer an incoming call 
       
   132 	voiceCall.AnswerIncomingCall(status1);		
       
   133 	User::WaitForRequest(status1);
       
   134 	TESTL(status1 == KErrNone);
       
   135 
       
   136 	// Call Parameters
       
   137 	INFO_PRINTF1(_L("\nGet Call Parameters...\n"));
       
   138 	RCall::TCallParams callParams; 
       
   139 	RCall::TCallParamsPckg callParamsPckg(callParams);
       
   140 	ret=voiceCall.GetCallParams(callParamsPckg);
       
   141 	CHECKPOINT_EXPR((ret == KErrNone || ret == KErrNotSupported), _L("*** Failed RCall::GetCallParams() ***"));
       
   142 	if (ret==KErrNotSupported)
       
   143 		INFO_PRINTF1(_L("Get Call Parameters is NOT Supported\n"));
       
   144 	if (ret==KErrNone)
       
   145 		INFO_PRINTF1(_L("Get Call Parameters is successful\n"));
       
   146 	
       
   147 	INFO_PRINTF1(_L("The call is in progress...\n"));
       
   148 	User::After(5*KOneSecond);
       
   149 
       
   150 	// Bearer Service Information
       
   151 	INFO_PRINTF1(_L("\nGet Bearer Service Info...\n"));
       
   152 	RCall::TBearerService bearerServiceInfo;
       
   153 	ret=voiceCall.GetBearerServiceInfo(bearerServiceInfo);
       
   154 	CHECKPOINT_EXPR((ret == KErrNone || ret == KErrNotSupported), _L("*** Failed RCall::GetBearerServiceInfo() ***"));
       
   155 	if (ret==KErrNotSupported)
       
   156 		INFO_PRINTF1(_L("Get BearerService Information is NOT Supported\n"));
       
   157 	if (ret==KErrNone)
       
   158 		INFO_PRINTF1(_L("Get BearerService Information is successful\n"));
       
   159 
       
   160 	// Call Duration
       
   161 	INFO_PRINTF1(_L("Get Call Duration...\n"));
       
   162 	TTimeIntervalSeconds callDuration;
       
   163 	ret=voiceCall.GetCallDuration(callDuration);
       
   164 	CHECKPOINT_EXPR((ret == KErrNone || ret == KErrNotSupported), _L("*** Failed RCall::GetCallDuration() ***"));
       
   165 	if (ret==KErrNotSupported)
       
   166 		{
       
   167 		INFO_PRINTF1(_L("Get Current Call Duration is NOT Supported"));
       
   168 		}
       
   169 	if (ret==KErrNone)
       
   170 		{
       
   171 		INFO_PRINTF2(_L("Call duration = %d"), callDuration.Int());
       
   172 		}
       
   173 
       
   174 	// Call Information
       
   175 	INFO_PRINTF1(_L("\nGet Current Call Info..."));
       
   176 	RCall::TCallInfo callInfo;
       
   177 	ret=voiceCall.GetInfo(callInfo);
       
   178 	CHECKPOINT_EXPR((ret == KErrNone || ret == KErrNotSupported), _L("*** Failed RCall::GetCallInfo() ***"));
       
   179 	if (ret==KErrNotSupported)
       
   180 		INFO_PRINTF1(_L("Get Current Call info is NOT Supported"));
       
   181 	if (ret==KErrNone)
       
   182 		{
       
   183 		INFO_PRINTF1(_L("Displaying Information about the Current Call"));
       
   184 		INFO_PRINTF2(_L("Call name: %S"), &callInfo.iCallName);
       
   185 		INFO_PRINTF2(_L("Line name: %S"), &callInfo.iLineName);
       
   186 		if (callInfo.iHookStatus==RCall::EHookStatusOff)
       
   187 			{
       
   188 			INFO_PRINTF1(_L("Current Hook Status: Off"));
       
   189 			}
       
   190 		if (callInfo.iStatus==RCall::EStatusConnected)
       
   191 			{
       
   192 			INFO_PRINTF1(_L("Current Call Status: Connected"));
       
   193 			}
       
   194 		}
       
   195 
       
   196 
       
   197 	User::After(5*KOneSecond);		// Give the user time to see the test results
       
   198 
       
   199 	// Call Ownership information
       
   200 	INFO_PRINTF1(_L("Get Call Ownership..\n"));
       
   201 	RCall::TOwnershipStatus callOwner;
       
   202 	ret=voiceCall.GetOwnershipStatus(callOwner);
       
   203 	CHECKPOINT_EXPR((ret == KErrNone || ret == KErrNotSupported), _L("*** Failed RCall::GetOwnershipStatus() ***"));
       
   204 	if (ret==KErrNotSupported)
       
   205 		{
       
   206 		INFO_PRINTF1(_L("Get Call OwnerShip is NOT Supported"));
       
   207 		}
       
   208 	else if (ret==KErrNone)
       
   209 		{
       
   210 		INFO_PRINTF1(_L("Get Call OwnerShip is Supported"));
       
   211 		
       
   212 		switch(callOwner)
       
   213 			{
       
   214 			case RCall::EOwnershipUnowned:
       
   215 				INFO_PRINTF1(_L("The call is unowned"));
       
   216 				break;
       
   217 			case RCall::EOwnershipOwnedByAnotherClient:
       
   218 				INFO_PRINTF1(_L("The call is owned by another Client"));
       
   219 				break;
       
   220 			case RCall::EOwnershipOwnedByThisClient:
       
   221 				INFO_PRINTF1(_L("The call is owned by this client"));
       
   222 				break;
       
   223 			default:
       
   224 				INFO_PRINTF1(_L("Error in Call Ownership details"));
       
   225 				break;
       
   226 			}	
       
   227 		}
       
   228 	else
       
   229 		INFO_PRINTF2(_L("Get Call Ownership returned Error: %d"), ret);
       
   230 		
       
   231 	
       
   232 	// Transfer Ownership Request (Note that no other client is interested in this call!)
       
   233 	INFO_PRINTF1(_L("Voice Call 1 is trying to Transfer Ownership of the Call.."));
       
   234 	ret=voiceCall.TransferOwnership();
       
   235 	INFO_PRINTF2(_L("Transfer Ownership Request returned %d"), ret);
       
   236 	if (ret==KErrEtelNoClientInterestedInThisCall)
       
   237 		INFO_PRINTF1(_L("There is no Client interested in this call."));
       
   238 
       
   239 
       
   240 	// Hang up Cancel Request
       
   241 	TRequestStatus cancelStatus;
       
   242 	INFO_PRINTF1(_L("Hang Up Cancel Request")); 
       
   243 	voiceCall.HangUp(cancelStatus);
       
   244 	User::After(3*KOneSecond);		// Want the TSY to receive the Hang up command.
       
   245 	voiceCall.HangUpCancel();
       
   246 	User::WaitForRequest(cancelStatus);
       
   247 	TESTL(cancelStatus==KErrNone);
       
   248 	if (cancelStatus==KErrNone)
       
   249 		{
       
   250 		INFO_PRINTF1(_L("Hang up cancel Request Unsuccessful."));
       
   251 		INFO_PRINTF1(_L("The Voice call has been dropped."));
       
   252 		INFO_PRINTF1(_L("This is expected behaviour!."));
       
   253 		}
       
   254 	else 
       
   255 		{
       
   256 		INFO_PRINTF1(_L("Hang up cancel Request Successful."));
       
   257 		INFO_PRINTF1(_L("This is unexpected!. Going to assume that the call has been dropped"));
       
   258 		}
       
   259 	
       
   260 	// Close the voice line and calls
       
   261 	voiceLine.Close();
       
   262 	voiceCall.Close();
       
   263  	RProcess().SetPriority(EPriorityHigh);
       
   264  	RThread().SetPriority(EPriorityMuchMore);	
       
   265 	}
       
   266 
       
   267 void CTestDriveAllCalls::TestCancelRequestsL()
       
   268 /**
       
   269  * This function tests Cancel Requests, Notifications in particular.
       
   270  */
       
   271 	{
       
   272 	_LIT(KVoiceLineName,"Voice");
       
   273 	
       
   274 	// Open a voice line and call
       
   275 	RLine voiceLine;
       
   276 	INFO_PRINTF1(_L("Opening Voice Line"));
       
   277 	TESTL(voiceLine.Open(iPhone,KVoiceLineName)==KErrNone);
       
   278 
       
   279 	RCall voiceCall;
       
   280 	INFO_PRINTF1(_L("Opening a new Voice Call"));
       
   281 	TESTL(voiceCall.OpenNewCall(voiceLine)==KErrNone);
       
   282 
       
   283 	RCall voiceCall2;
       
   284 	INFO_PRINTF1(_L("Opening a 2nd Voice Call"));
       
   285 	TESTL(voiceCall2.OpenNewCall(voiceLine)==KErrNone);
       
   286 
       
   287 	// Answer Incoming call Cancel Request
       
   288 	TRequestStatus cancelStatus;
       
   289 	INFO_PRINTF1(_L("Answer Incoming Call Cancel Request")); 
       
   290 	voiceCall.AnswerIncomingCall(cancelStatus);
       
   291 	voiceCall.AnswerIncomingCallCancel();
       
   292 	User::WaitForRequest(cancelStatus);
       
   293 	INFO_PRINTF2(_L("Answer Incoming Cancel status = %d"), cancelStatus.Int());
       
   294 
       
   295 	// Notify Hook Change Cancel Request
       
   296 	INFO_PRINTF1(_L("Notify Hook Change Cancel Request")); 
       
   297 	RCall::THookStatus hookStatus;
       
   298 	voiceCall.NotifyHookChange(cancelStatus, hookStatus);
       
   299 	voiceCall.NotifyHookChangeCancel();
       
   300 	User::WaitForRequest(cancelStatus);
       
   301 	INFO_PRINTF2(_L("Notify Hook Change Cancel status = %d"), cancelStatus.Int());
       
   302 
       
   303 	// Notify Caps Change Cancel Request
       
   304 	INFO_PRINTF1(_L("Notify Caps change Cancel Request")); 
       
   305 	RLine::TCaps lineCaps;
       
   306 	voiceLine.NotifyCapsChange(cancelStatus, lineCaps);
       
   307 	voiceLine.NotifyCapsChangeCancel();
       
   308 	User::WaitForRequest(cancelStatus);
       
   309 	INFO_PRINTF2(_L("Notify caps Change Cancel status = %d"), cancelStatus.Int());
       
   310 
       
   311 	// Notify Call Status Change Cancel Request
       
   312 	INFO_PRINTF1(_L("Notify CallStatusChange Cancel Request...")); 
       
   313 	RCall::TStatus callStatus1;
       
   314 	voiceCall.NotifyStatusChange(cancelStatus, callStatus1);
       
   315 	voiceCall.NotifyStatusChangeCancel();
       
   316 	User::WaitForRequest(cancelStatus);
       
   317 	INFO_PRINTF2(_L("Notify CallStatusChange Cancel: %d"), cancelStatus.Int());
       
   318 
       
   319 	// Notify CallDuration Change Cancel Request
       
   320 	INFO_PRINTF1(_L("NotifyCallDurationChange Cancel Request...")); 
       
   321 	TTimeIntervalSeconds callDuration;
       
   322 	voiceCall.NotifyCallDurationChange(cancelStatus, callDuration);
       
   323 	voiceCall.NotifyCallDurationChangeCancel();
       
   324 	User::WaitForRequest(cancelStatus);
       
   325 	INFO_PRINTF2(_L("Notify CallDurationChange Cancel: %d"), cancelStatus.Int());
       
   326 
       
   327 	// Acquire Ownership Cancel Request 
       
   328 	INFO_PRINTF1(_L("AcquireOwnership Cancel Request..."));
       
   329 	voiceCall2.AcquireOwnership(cancelStatus);
       
   330 	voiceCall2.AcquireOwnershipCancel();
       
   331 	User::WaitForRequest(cancelStatus);
       
   332 	if (cancelStatus==KErrEtelCallNotActive)
       
   333 		{
       
   334 		INFO_PRINTF1(_L("Voice Call 2 is not currently active"));
       
   335 		}
       
   336 	else
       
   337 		{
       
   338 		INFO_PRINTF2(_L("AcquireOwnership Cancel status: %d"), cancelStatus.Int());
       
   339 		}
       
   340 
       
   341 	// Close the voice line and call
       
   342 	voiceLine.Close();
       
   343 	voiceCall.Close();
       
   344 	voiceCall2.Close();
       
   345 	}
       
   346 
       
   347 void CTestDriveAllCalls::TestDataCallL()
       
   348 /**
       
   349  * This function performs Data calls tests.
       
   350  */
       
   351 	{
       
   352 	// The script has posted a +CRING: REL ASYNC, so a data call is expected
       
   353 	INFO_PRINTF1(_L("\nAnswering an incoming data call.\n"));
       
   354 
       
   355 	_LIT(KDataLineName,"Data");
       
   356 	
       
   357 	// Open a Data line
       
   358 	RLine dataLine;
       
   359 	INFO_PRINTF1(_L("Opening Data Line"));
       
   360 	TESTL(dataLine.Open(iPhone,KDataLineName)==KErrNone);
       
   361 
       
   362 	// Post a Notification on an Incoming call
       
   363 	TRequestStatus notifyStatus;
       
   364 	TName callName;
       
   365 	dataLine.NotifyIncomingCall(notifyStatus, callName);
       
   366 	User::WaitForRequest(notifyStatus);
       
   367 	TESTL(notifyStatus==KErrNone);	
       
   368 	INFO_PRINTF1(_L("An incoming data call has been detected."));
       
   369 
       
   370 	// Open and answer a Data call
       
   371 	RCall dataCall;
       
   372 	TRequestStatus status1;
       
   373 	TESTL(dataCall.OpenExistingCall(dataLine, callName)==KErrNone);
       
   374 	
       
   375 	dataCall.AnswerIncomingCall(status1);		
       
   376 	User::WaitForRequest(status1);
       
   377 	TESTL(status1 == KErrNone);
       
   378 
       
   379 	// Get the call's status
       
   380 	RCall::TStatus callStatus;
       
   381 	TESTL(dataCall.GetStatus(callStatus)==KErrNone);
       
   382 	if (callStatus==RCall::EStatusConnected)
       
   383 		{
       
   384 		INFO_PRINTF1(_L("Call Status: CONNECTED"));
       
   385 		}
       
   386 
       
   387 	// LoanDataPort (Cancel) request
       
   388 	INFO_PRINTF1(_L("Loan Data Port Cancel request."));
       
   389 	RCall::TCommPort commPort;
       
   390 	TRequestStatus cancelStatus;
       
   391 	dataCall.LoanDataPort(cancelStatus,commPort);
       
   392 	User::After(3*KOneSecond);		// Want the request to get through to the TSY
       
   393 	dataCall.LoanDataPortCancel();
       
   394 	User::WaitForRequest(cancelStatus);
       
   395 	INFO_PRINTF2(_L("LoanDataPort Cancel: %d"), cancelStatus.Int());
       
   396 	
       
   397 	if (cancelStatus==KErrNone)
       
   398 		{
       
   399 		INFO_PRINTF1(_L("LoanDataPort Cancel request NOT successful."));
       
   400 		}
       
   401 	else
       
   402 		{
       
   403 		INFO_PRINTF1(_L("LoanDataPort cancel request was successful."));
       
   404 		INFO_PRINTF1(_L("This is unexpected, the rest of the test will not be executed!!"));
       
   405 		INFO_PRINTF1(_L("Closing the data line and call."));
       
   406 		dataLine.Close();	
       
   407 		dataCall.Close();		
       
   408 		return;
       
   409 		}
       
   410 
       
   411 	// Connect to the Comms Server and Open a serial port
       
   412 	INFO_PRINTF1(_L("Connecting to the Comms server and opening a serial port."));
       
   413 	RCommServ commServer;
       
   414 	TESTL(commServer.Connect()==KErrNone);
       
   415 
       
   416 	RComm port;
       
   417 	TESTL(port.Open(commServer,commPort.iPort,ECommShared)==KErrNone);
       
   418 
       
   419 	// Write some data to the serial port
       
   420 	TRequestStatus writeStatus;
       
   421 	_LIT8(KTestData,"Telephony Test Code\r\n");
       
   422 	port.Write(writeStatus,KTestData);
       
   423 	User::WaitForRequest(writeStatus);
       
   424 	TESTL(writeStatus==KErrNone);
       
   425 	INFO_PRINTF1(_L("Data has been successfully written to the serial port"));
       
   426 
       
   427 	// Close the serial port & the comms Server. Recover the data port & hang up the call.
       
   428 	port.Close();
       
   429 	commServer.Close();
       
   430 	TESTL(dataCall.RecoverDataPort()==KErrNone);
       
   431 
       
   432 	INFO_PRINTF1(_L("Hanging up the Data call."));
       
   433 	TESTL(dataCall.HangUp()==KErrNone);
       
   434 
       
   435 	// Close the Data line and call
       
   436 	dataLine.Close();
       
   437 	dataCall.Close();		
       
   438 	}
       
   439 
       
   440 
       
   441 //
       
   442 // Emulator-side class
       
   443 // With the assistance of the base class, this class must run the designated script
       
   444 //
       
   445 CTestAllCalls* CTestAllCalls::NewL(const TScript* aScript)
       
   446 	{
       
   447 	CTestAllCalls* allCalls=new(ELeave) CTestAllCalls(aScript);
       
   448 	CleanupStack::PushL(allCalls);
       
   449 	allCalls->ConstructL();
       
   450 	CleanupStack::Pop();
       
   451 	return allCalls;
       
   452 	}
       
   453 
       
   454 CTestAllCalls::CTestAllCalls(const TScript* aScript) : iScript(aScript)
       
   455 	{}
       
   456 
       
   457 void CTestAllCalls::ConstructL()
       
   458 	{
       
   459 	CATScriptEng::ConstructL();
       
   460 	}
       
   461 
       
   462 TInt CTestAllCalls::Start()
       
   463 	{
       
   464 	StartScript(iScript);
       
   465 	return KErrNone;
       
   466 	}
       
   467 
       
   468 void CTestAllCalls::SpecificAlgorithmL(TInt /* aParam */)
       
   469 	{
       
   470     }
       
   471 
       
   472 void CTestAllCalls::Complete(TInt aError)
       
   473 	{
       
   474 	iReturnValue=aError;
       
   475 	CActiveScheduler::Stop();
       
   476 	}