telephonyserverplugins/multimodetsy/test/TE_Voice/TE_VoiceTestStepBase.cpp
changeset 0 3553901f7fa8
equal deleted inserted replaced
-1:000000000000 0:3553901f7fa8
       
     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 // Voice API Test base test code.
       
    15 // 
       
    16 //
       
    17 
       
    18 /**
       
    19  @file
       
    20 */
       
    21 
       
    22 #include "TE_VoiceTestStepBase.h"
       
    23 
       
    24 void CTestVoiceStep::WaitWithTimeout(TRequestStatus& aStatus, TInt aNumberOfMicroSeconds)
       
    25 /**
       
    26  * Timeout function
       
    27  */
       
    28 	{
       
    29 	TRequestStatus timerStatus;
       
    30 	RTimer timer ;
       
    31 	timer.CreateLocal() ;
       
    32 	timer.After(timerStatus,aNumberOfMicroSeconds);
       
    33 
       
    34 	User::WaitForRequest(aStatus, timerStatus);
       
    35 	if (timerStatus == KRequestPending)
       
    36 		{
       
    37 		timer.Cancel();
       
    38 		User::WaitForRequest(timerStatus);
       
    39 		}
       
    40 	else
       
    41 		{
       
    42 		INFO_PRINTF1(_L("Time is over!!!")) ;
       
    43 		}
       
    44 	timer.Close() ;
       
    45 	}
       
    46 
       
    47 //
       
    48 // CTestVoiceStep Implementation
       
    49 //
       
    50 CTestVoiceStep::CTestVoiceStep()
       
    51 	{
       
    52 	 //
       
    53  	 // Change this process and thread to a higher priority so that we can be in control
       
    54  	 // when performing tests such as monitoring async request status values.
       
    55  	 //
       
    56 	 iOrgProcessPriority = RProcess().Priority();
       
    57 	 iOrgThreadPriority  = RThread().Priority();
       
    58    
       
    59 	 RProcess().SetPriority(EPriorityHigh);
       
    60 	 RThread().SetPriority(EPriorityMuchMore);
       
    61 	
       
    62 	} // CTestVoiceStep::CTestVoiceStep
       
    63 
       
    64 CTestVoiceStep::~CTestVoiceStep()
       
    65 	{
       
    66 	 //
       
    67 	 // Restore the process and thread priority...
       
    68 	 //
       
    69 	 RProcess().SetPriority(iOrgProcessPriority);
       
    70 	 RThread().SetPriority(iOrgThreadPriority);
       
    71 	 
       
    72 	} // CTestVoiceStep::~CTestVoiceStep
       
    73 
       
    74 void CTestVoiceStep::Print_RCall_TStatus(RCall::TStatus& aArg)
       
    75 /** Display value of enum RCall::TStatus to screen.
       
    76  * @param value to print
       
    77 */
       
    78 	{
       
    79 	switch(aArg)
       
    80 		{
       
    81 		case RCall::EStatusUnknown:
       
    82 			INFO_PRINTF1(_L("Value of enum is RCall::EStatusUnknown")) ;
       
    83 		break ;
       
    84 		case RCall::EStatusIdle:
       
    85 			INFO_PRINTF1(_L("Value of enum is RCall::EStatusIdle")) ;
       
    86 		break ;
       
    87 		case RCall::EStatusDialling:
       
    88 			INFO_PRINTF1(_L("Value of enum is RCall::EStatusDialling")) ;
       
    89 		break ;
       
    90 		case RCall::EStatusRinging:
       
    91 			INFO_PRINTF1(_L("Value of enum is RCall::EStatusRinging")) ;
       
    92 		break ;
       
    93 		case RCall::EStatusAnswering:
       
    94 			INFO_PRINTF1(_L("Value of enum is RCall::EStatusAnswering")) ;
       
    95 		break ;
       
    96 		case RCall::EStatusConnecting:
       
    97 			INFO_PRINTF1(_L("Value of enum is RCall::EStatusConnecting")) ;
       
    98 		break ;
       
    99 		case RCall::EStatusConnected:
       
   100 			INFO_PRINTF1(_L("Value of enum is RCall::EStatusConnected")) ;
       
   101 		break ;
       
   102 		case RCall::EStatusHangingUp:
       
   103 			INFO_PRINTF1(_L("Value of enum is RCall::EStatusHangingUp")) ;
       
   104 		break ;
       
   105 		}
       
   106 	}
       
   107 
       
   108 void CTestVoiceStep::GetGoodNumber(TDes& aNum)
       
   109 /**Returns string with number for outgoing call.
       
   110  * For.ex Good number is 1234 Vodaphone test line - recorded message.
       
   111  * Function tries to read value of switch /modem, otherwise it use defualt value.
       
   112  * @return phone number string
       
   113  * @note have to be updated to read information from cmd line or config. file
       
   114 */
       
   115 	{
       
   116 		aNum.Copy(KGoodNumber) ;
       
   117 	}
       
   118 
       
   119 void CTestVoiceStep::Print_TCapsEnum(RCall::TCaps& aArg)
       
   120 /** Display value of enum RCall::TCapsEnum to screen.
       
   121  * @param value to print
       
   122 */
       
   123 	{
       
   124 	if(aArg.iFlags & RCall::KCapsData)
       
   125 		{
       
   126 			INFO_PRINTF1(_L("Has a flag TCapsEnum::KCapsData")) ;
       
   127 		}
       
   128 	if(aArg.iFlags & RCall::KCapsFax)
       
   129 		{
       
   130 			INFO_PRINTF1(_L("Has a flag TCapsEnum::KCapsFax")) ;
       
   131 		}
       
   132 	if(aArg.iFlags & RCall::KCapsVoice)
       
   133 		{
       
   134 			INFO_PRINTF1(_L("Has a flag TCapsEnum::KCapsVoice")) ;
       
   135 		}
       
   136 	if(aArg.iFlags & RCall::KCapsDial)
       
   137 		{
       
   138 			INFO_PRINTF1(_L("Has a flag TCapsEnum::KCapsDial")) ;
       
   139 		}
       
   140 	if(aArg.iFlags & RCall::KCapsConnect)
       
   141 		{
       
   142 			INFO_PRINTF1(_L("Has a flag TCapsEnum::KCapsConnect")) ;
       
   143 		}
       
   144 	if(aArg.iFlags & RCall::KCapsHangUp)
       
   145 		{
       
   146 			INFO_PRINTF1(_L("Has a flag TCapsEnum::KCapsHangUp")) ;
       
   147 		}
       
   148 	if(aArg.iFlags & RCall::KCapsAnswer)
       
   149 		{
       
   150 			INFO_PRINTF1(_L("Has a flag TCapsEnum::KCapsAnswer")) ;
       
   151 		}
       
   152 	if(aArg.iFlags & RCall::KCapsLoanDataPort)
       
   153 		{
       
   154 			INFO_PRINTF1(_L("Has a flag TCapsEnum::KCapsLoanDataPort")) ;
       
   155 		}
       
   156 	if(aArg.iFlags & RCall::KCapsRecoverDataPort)
       
   157 		{
       
   158 			INFO_PRINTF1(_L("Has a flag TCapsEnum::KCapsRecoverDataPort")) ;
       
   159 		}
       
   160 	}
       
   161 
       
   162 void CTestVoiceStep::TestGetCallCapabilitiesL(RMobileCall& aCall)
       
   163 /**
       
   164  * call's capabilities to screen
       
   165  * @test GT83-TVOICE-016.01 "Test retrieval of the current call status when the call's status is ""Unknown"""
       
   166  * @test GT83-TVOICE-032.01 Test retrieval of the voice call's dynamic call control and call event capabilities. Display the call's capabilities to screen
       
   167 */
       
   168 	{
       
   169 	_LIT(KStartText, "Test Call Capabilities") ;
       
   170 	TEST_START(&KStartText) ;
       
   171 
       
   172 	// Call Capabilities
       
   173 	RCall::TCaps callCaps;
       
   174 	TRAPD(ret, ret=aCall.GetCaps(callCaps));
       
   175 	CHECKPOINT_EXPR((ret==KErrNone||ret==KErrNotSupported), _L("*** Failed RMobileCall::GetCaps() ***"));
       
   176 	if (ret==KErrNotSupported)
       
   177 		{
       
   178 		INFO_PRINTF1(_L("Get Line Capabilities is NOT supported"));
       
   179 		}
       
   180 	else
       
   181 		{
       
   182 		Print_TCapsEnum(callCaps)	;
       
   183 		}
       
   184 		// Get the mobile call capabilities
       
   185 	RMobileCall::TMobileCallCapsV1 mobileCallCaps;
       
   186 	RMobileCall::TMobileCallCapsV1Pckg mobileCallCapsPckg(mobileCallCaps);
       
   187 
       
   188 	ret=aCall.GetMobileCallCaps(mobileCallCapsPckg);
       
   189 	TESTL(ret==KErrNone||ret==KErrNotSupported); 
       
   190 	TESTCHECKL(ret,KErrNone);
       
   191 	if (ret==KErrNotSupported)
       
   192 		{
       
   193 		INFO_PRINTF1(_L("Get Mobile Call Capabilities is NOT Supported"));
       
   194 		}
       
   195 
       
   196 	else
       
   197 		{
       
   198 		INFO_PRINTF1(_L("Get Mobile Call Capabilities is Successful"));
       
   199 		PrintCallCaps(mobileCallCaps.iCallControlCaps);
       
   200 		}
       
   201 
       
   202 	TEST_END() ;
       
   203 
       
   204 	}
       
   205 
       
   206 void CTestVoiceStep::PrintCallCaps(TUint32 aCaps)
       
   207 	{
       
   208 	if ((aCaps&RCall::KCapsData) !=0)
       
   209 		{
       
   210 		INFO_PRINTF1(_L("This call supports Data calls"));
       
   211 		}
       
   212 	if ((aCaps&RCall::KCapsFax) !=0)
       
   213 		INFO_PRINTF1(_L("This call supports Fax calls"));
       
   214 	if ((aCaps&RCall::KCapsVoice) !=0)
       
   215 		INFO_PRINTF1(_L("This call supports Voice calls"));
       
   216 	if ((aCaps&RCall::KCapsDial) !=0)
       
   217 		INFO_PRINTF1(_L("The Dial Request is currently a valid action"));
       
   218 	if ((aCaps&RCall::KCapsConnect) !=0)
       
   219 		INFO_PRINTF1(_L("The Connect Request is currently a valid action"));
       
   220 	if ((aCaps&RCall::KCapsHangUp) !=0)
       
   221 		INFO_PRINTF1(_L("The HangUp Request is currently a valid action"));
       
   222 	if ((aCaps&RCall::KCapsAnswer) !=0)
       
   223 		INFO_PRINTF1(_L("The Answer Request is currently a valid action"));
       
   224 	if ((aCaps&RCall::KCapsLoanDataPort) !=0)
       
   225 		INFO_PRINTF1(_L("The LoanDataPort Request is currently a valid action"));
       
   226 	if ((aCaps&RCall::KCapsRecoverDataPort) !=0)
       
   227 		INFO_PRINTF1(_L("The RecoverDataPort Request is currently a valid action"));
       
   228 	}
       
   229 
       
   230 void CTestVoiceStep::TestLineCapabilitiesL()
       
   231 /**
       
   232  * @test GT83-TVOICE-002.01 Test retrieval of a voice line's capabilities. Display the capabilities to screen
       
   233 */
       
   234 	{
       
   235 	_LIT(KStartText, "Test Line Capabilities") ; TEST_START(&KStartText) ;
       
   236 
       
   237 	// Line Capabilities
       
   238 	RLine::TCaps lineCaps;
       
   239 	TInt ret=iLine.GetCaps(lineCaps);
       
   240 	CHECKPOINT_EXPR((ret==KErrNone || ret==KErrNotSupported), _L("*** Failed RMobileLine::GetCaps() ***"));
       
   241 	if (ret==KErrNotSupported)
       
   242 		{
       
   243 		INFO_PRINTF1(_L("Get Line Capabilities is NOT supported"));
       
   244 		}
       
   245 	else
       
   246 		{
       
   247 		if ((lineCaps.iFlags&RLine::KCapsData) !=0)
       
   248 			{
       
   249 			INFO_PRINTF1(_L("This line supports Data connections"));
       
   250 			}
       
   251 		if ((lineCaps.iFlags&RLine::KCapsFax) !=0)
       
   252 			{
       
   253 			INFO_PRINTF1(_L("This line supports Fax connections"));
       
   254 			}
       
   255 		if ((lineCaps.iFlags&RLine::KCapsVoice) !=0)
       
   256 			{
       
   257 			INFO_PRINTF1(_L("This line supports Voice connections"));
       
   258 			}
       
   259 		if ((lineCaps.iFlags&RLine::KCapsEventIncomingCall) !=0)
       
   260 			{
       
   261 			INFO_PRINTF1(_L("This line supports Incoming Call Notification requests"));
       
   262 			}
       
   263 		}
       
   264 	TEST_END() ;
       
   265 	}
       
   266 
       
   267 
       
   268 void CTestVoiceStep::Print_TMobilePhoneModeCaps(RMobilePhone::TMobilePhoneModeCaps& aArg)
       
   269 /** Display value of enum RMobilePhone::TMobilePhoneModeCaps to screen.
       
   270  * @param value to print
       
   271 */
       
   272 	{
       
   273 	if(aArg & RMobilePhone::KCapsGsmSupported)
       
   274 		{
       
   275 			INFO_PRINTF1(_L("Has a flag TMobilePhoneModeCaps::KCapsGsmSupported")) ;
       
   276 		}
       
   277 	if(aArg & RMobilePhone::KCapsGprsSupported)
       
   278 		{
       
   279 			INFO_PRINTF1(_L("Has a flag TMobilePhoneModeCaps::KCapsGprsSupported")) ;
       
   280 		}
       
   281 	if(aArg & RMobilePhone::KCapsAmpsSupported)
       
   282 		{
       
   283 			INFO_PRINTF1(_L("Has a flag TMobilePhoneModeCaps::KCapsAmpsSupported")) ;
       
   284 		}
       
   285 	if(aArg & RMobilePhone::KCapsCdma95Supported)
       
   286 		{
       
   287 			INFO_PRINTF1(_L("Has a flag TMobilePhoneModeCaps::KCapsCdma95Supported")) ;
       
   288 		}
       
   289 	if(aArg & RMobilePhone::KCapsCdma2000Supported)
       
   290 		{
       
   291 			INFO_PRINTF1(_L("Has a flag TMobilePhoneModeCaps::KCapsCdma2000Supported")) ;
       
   292 		}
       
   293 	if(aArg & RMobilePhone::KCapsWcdmaSupported)
       
   294 		{
       
   295 			INFO_PRINTF1(_L("Has a flag TMobilePhoneModeCaps::KCapsWcdmaSupported")) ;
       
   296 		}
       
   297 	}
       
   298 
       
   299 
       
   300 TVerdict CTestVoiceStep::doTestStepPreambleL()
       
   301 	{
       
   302 	//
       
   303 	// Mark for memory leaks!!!
       
   304 	//
       
   305 	__UHEAP_MARK;
       
   306 
       
   307 	// Connect to the root telephony server, in order to use the Etel server
       
   308    	User::LeaveIfError(iTelServer.Connect()) ;
       
   309 	User::LeaveIfError(iTelServer.LoadPhoneModule(KMmtsyName)) ;
       
   310 	// Open a subsession for the phone in use
       
   311 	User::LeaveIfError(iPhone.Open(iTelServer,KPhoneName)) ;
       
   312 	
       
   313 	// Initialize the Phone
       
   314 	INFO_PRINTF1(_L("Initialising the phone..."));
       
   315 	
       
   316 	TInt ret = iPhone.Initialise();
       
   317 	if (ret!=KErrNone)
       
   318 		{
       
   319 		ERR_PRINTF2(_L("Failed to initialise the phone (%d)"), ret);
       
   320 		User::Leave(ret);
       
   321 		}
       
   322 
       
   323 	RPhone::TCaps oPhoneCaps;
       
   324 	INFO_PRINTF1(_L("Get the Phone's Capabilities..."));
       
   325 	ret = iPhone.GetCaps(oPhoneCaps) ;
       
   326 	if ((KErrNone != ret) || !(oPhoneCaps.iFlags & RPhone::KCapsVoice))
       
   327 		{
       
   328 		ERR_PRINTF2(_L("This phone does not support Voice Calls (caps=0x%x)"), oPhoneCaps.iFlags);
       
   329 		User::Leave(ret);
       
   330 		}	
       
   331 
       
   332 	return EPass;
       
   333 	} // CTestVoiceStep::doTestStepPreambleL
       
   334 
       
   335 TVerdict CTestVoiceStep::doTestStepPostambleL()
       
   336 	{
       
   337 	iPhone.Close();
       
   338 	iTelServer.Close();	// disconnect from etel
       
   339 	
       
   340 	//
       
   341 	// Check the heap for memory leaks...
       
   342 	//
       
   343 	__UHEAP_MARKEND;
       
   344 	
       
   345 	return TestStepResult();
       
   346 	} // CTestVoiceStep::doTestStepPostambleL
       
   347