cbsref/telephonyrefplugins/atltsy/integrationtest/src/testltsyphonestepbase.cpp
branchRCL_3
changeset 20 07a122eea281
parent 19 630d2f34d719
child 21 4814c5a49428
equal deleted inserted replaced
19:630d2f34d719 20:07a122eea281
     1 // TestTelephonyPktTestStepBase.cpp
       
     2 // Copyright (c) Symbian Software Ltd 2008. All rights reserved.
       
     3 //
       
     4 // Implementation of the Class CTestTelephonyPktTestStepBase
       
     5 #include <mmlist.h>
       
     6 #include <mmretrieve.h>
       
     7 // 	user include
       
     8 #include "TestLtsyPhoneStepBase.h"
       
     9 #include "te_integration_stltsysuitestepbase.h"
       
    10 #include "te_integration_stltsysuitedefs.h"
       
    11 
       
    12 // 
       
    13 _LIT(KTsyModuleName, "PhoneTsy");
       
    14 /**
       
    15  * Constructor
       
    16  */
       
    17 CTestLtsyPhoneStepBase::CTestLtsyPhoneStepBase(CTestLtsyModel& aModel)
       
    18 	:iModel(aModel),iSharedPhone(aModel.SharedEnv().Phone())
       
    19 	{
       
    20 	}
       
    21 
       
    22 /**
       
    23  * Destructor
       
    24  * 
       
    25  */
       
    26 CTestLtsyPhoneStepBase::~CTestLtsyPhoneStepBase()
       
    27 	{
       
    28 
       
    29 	}
       
    30 /**
       
    31  * Get the shared phone
       
    32  * 
       
    33  */
       
    34 RMobilePhone& CTestLtsyPhoneStepBase::SharedPhone() 
       
    35 	{
       
    36 	return iSharedPhone;
       
    37 	}
       
    38 	
       
    39 TVerdict CTestLtsyPhoneStepBase::doTestStepPreambleL()
       
    40 	{
       
    41 	INFO_PRINTF1(_L("CTestLtsyPhoneStepBase::doTestStepPreambleL()"));
       
    42 	// uncomment the following 3 lines if you have common pre setting to all the test steps in there
       
    43 	// CTe_integration_stltsySuiteStepBase::doTestStepPreambleL();
       
    44 	// if (TestStepResult()!=EPass)
       
    45 	//    return   TestStepResult();
       
    46 	// process some pre setting to this test step then set SetTestStepResult to EFail or Epass.
       
    47 	SetTestStepResult(EPass);
       
    48 	return TestStepResult();
       
    49 	}
       
    50 TVerdict CTestLtsyPhoneStepBase::doTestStepPostambleL()
       
    51 	{
       
    52 	INFO_PRINTF1(_L("CTestLtsyPhoneStepBase::doTestStepPostambleL()"));
       
    53 	// process something post setting to the test step
       
    54 	// uncomment the following line if you have common post setting to all the test steps in there
       
    55 	// CTe_integration_stltsySuiteStepBase::doTestStepPostambleL();
       
    56 	// uncomment the following line if you have post process or remove the following line if no post process
       
    57 	// SetTestStepResult(EPass);		// or EFail
       
    58 	return TestStepResult();
       
    59 	}
       
    60 void CTestLtsyPhoneStepBase::TestOpenPhoneL()
       
    61 	{
       
    62 	// reset all shared data to make sure we are going to run on a clean environment
       
    63 	//Open the shared phone
       
    64 	iModel.SharedEnv().OpenPhoneL(KTsyModuleName);
       
    65 	}
       
    66 void CTestLtsyPhoneStepBase::TestClosePhone()
       
    67 	{
       
    68 	iModel.SharedEnv().ClosePhone();	
       
    69 	}
       
    70 
       
    71 void CTestLtsyPhoneStepBase::GetFdnStatus()
       
    72 	{
       
    73 	INFO_PRINTF1(_L("GetFdnStatus() invoked......\n"));
       
    74 	TRequestStatus Status;
       
    75 	RMobilePhone::TMobilePhoneFdnStatus FdnStatus;
       
    76 	iSharedPhone.GetFdnStatus(Status,FdnStatus);
       
    77 	User::WaitForRequest(Status);
       
    78 	INFO_PRINTF2(_L("GetFdnStatus() complete = %d\n"), Status.Int());
       
    79 	}
       
    80 void CTestLtsyPhoneStepBase::GetNetworkRegistrationStatus()
       
    81 	{
       
    82 	TRequestStatus Status;
       
    83 	INFO_PRINTF1(_L("GetNetworkRegistrationStatus() invoked......\n"));
       
    84 	RMobilePhone::TMobilePhoneRegistrationStatus RegStatus;
       
    85 	iSharedPhone.GetNetworkRegistrationStatus(Status,RegStatus);
       
    86 	User::WaitForRequest(Status);
       
    87 	INFO_PRINTF2(_L("GetNetworkRegistrationStatus() complete = %d\n"), Status.Int());
       
    88 	}
       
    89 void CTestLtsyPhoneStepBase::GetHomeNetwork()
       
    90 	{
       
    91 	TRequestStatus Status;
       
    92 	INFO_PRINTF1(_L("GetHomeNetwork() invoked......\n"));
       
    93 	RMobilePhone::TMobilePhoneNetworkInfoV1  aNetworkInfo;
       
    94 	RMobilePhone::TMobilePhoneNetworkInfoV1Pckg aNetworkInfoBuf(aNetworkInfo); // package TMobilePhoneNetworkInfoV1 into a buffer
       
    95 	RMobilePhone::TMobilePhoneLocationAreaV1 aArea;
       
    96 	iSharedPhone.GetHomeNetwork(Status, aNetworkInfoBuf) ;
       
    97 	User::WaitForRequest(Status);
       
    98 	INFO_PRINTF2(_L("GetHomeNetwork() complete = %d\n"), Status.Int());
       
    99 	}
       
   100 
       
   101 //void CTestLtsyPhoneStepBase::GetServiceProviderName()
       
   102 //	{
       
   103 //	
       
   104 //	}
       
   105 void CTestLtsyPhoneStepBase::GetPhoneId()
       
   106 	{
       
   107 	TRequestStatus Status;
       
   108 	INFO_PRINTF1(_L("GetPhoneId() invoked......\n"));
       
   109 	RMobilePhone::TMobilePhoneIdentityV1 aPhoneId;
       
   110 	iSharedPhone.GetPhoneId(Status,aPhoneId);
       
   111 	User::WaitForRequest(Status);
       
   112 	INFO_PRINTF2(_L("GetPhoneId() complete = %d\n"), Status.Int());
       
   113 	
       
   114 	}
       
   115 void CTestLtsyPhoneStepBase::GetDetectedNetworksL()
       
   116 	{
       
   117 	TRequestStatus Status;
       
   118 	INFO_PRINTF1(_L("GetDetectedNetworks() invoked......\n"));
       
   119 	CRetrieveMobilePhoneDetectedNetworks* Retriever = CRetrieveMobilePhoneDetectedNetworks::NewL(iSharedPhone);
       
   120 	Retriever->StartV2(Status);
       
   121 	User::After(50*1000*1000);
       
   122 	delete Retriever;
       
   123 	INFO_PRINTF1(_L("GetDetectedNetworks() invoked......OK\n"));
       
   124 	
       
   125 //	iList = iRetriever->RetrieveListV2L();
       
   126 	}
       
   127 void CTestLtsyPhoneStepBase::GetDetectedNetworksCancelL()
       
   128 	{
       
   129 	TRequestStatus Status;
       
   130 	INFO_PRINTF1(_L("GetDetectedNetworksCancel() invoked......\n"));
       
   131 	CRetrieveMobilePhoneDetectedNetworks* Retriever = CRetrieveMobilePhoneDetectedNetworks::NewL(iSharedPhone);
       
   132 	Retriever->StartV2(Status);
       
   133 	Retriever->Cancel();
       
   134 	User::After(50*1000*1000);
       
   135 	delete Retriever;
       
   136 	INFO_PRINTF1(_L("GetDetectedNetworksCancel() invoked......OK\n"));
       
   137 	}
       
   138 void CTestLtsyPhoneStepBase::SetNetworkSelectionSetting()
       
   139 /**
       
   140 *	3.10.12 Set Network Selection Setting
       
   141 *	void RMobilePhone::SetNetworkSelectionSetting(TRequestStatus& aReqStatus,
       
   142 *		const TDes8& aSetting) const
       
   143 *	This method is used by client application to set the way a phone will select a
       
   144 *	network. The new setting is supplied within the aSetting parameter, which is a
       
   145 *	packaged version of the TMobilePhoneNetworkSelectionV1V1 class above.
       
   146 *	In manual network selection, the user is able to select a network to camp on to
       
   147 *	from a list of detected networks. The selected network has to be accessible by the
       
   148 *	user, i.e. it is not a forbidden network.
       
   149 *	When a phone is using manual network selection, at power-up or after signal loss,
       
   150 *	it will try to register to the network that the user last selected. If this network
       
   151 *	is not available then it is up to the phone whether it tries to fall-back to
       
   152 *	automatic selection or leaves the phone in no service.
       
   153 *
       
   154 */
       
   155 	{
       
   156 	TRequestStatus Status;
       
   157 	INFO_PRINTF1(_L("GetNetworkSelectionSetting() invoked......\n"));
       
   158 	RMobilePhone::TMobilePhoneNetworkSelectionV1  localNetworkSel;
       
   159 	localNetworkSel.iMethod = RMobilePhone::ENetworkSelectionManual;
       
   160 	
       
   161 	RMobilePhone::TMobilePhoneNetworkSelectionV1Pckg localNetworkSelBuf(localNetworkSel) ;
       
   162     
       
   163 	INFO_PRINTF1(_L("SetNetworkSelectionSetting() invoked......\n"));
       
   164 	iSharedPhone.SetNetworkSelectionSetting(Status, localNetworkSelBuf) ;
       
   165 	User::WaitForRequest(Status);
       
   166 	INFO_PRINTF2(_L("SetNetworkSelectionSetting() complete = %d\n"), Status.Int());
       
   167 	}
       
   168 void CTestLtsyPhoneStepBase::SelectNetwork()
       
   169 	{
       
   170 	TRequestStatus Status;
       
   171 	RMobilePhone::TMobilePhoneNetworkManualSelection tempsel;
       
   172 	tempsel.iCountry = _L("460");
       
   173 	tempsel.iNetwork = _L("00");
       
   174 	INFO_PRINTF1(_L("SelectNetwork() invoked......\n"));
       
   175 	iSharedPhone.SelectNetwork(Status,ETrue,tempsel);
       
   176 //	iSharedPhone.CancelAsyncRequest(Status);
       
   177 	User::WaitForRequest(Status);
       
   178 	INFO_PRINTF2(_L("SelectNetwork() complete = %d\n"), Status.Int());
       
   179 	
       
   180 	}
       
   181 void CTestLtsyPhoneStepBase::SetAndSelectNetwork()
       
   182 	{
       
   183 	INFO_PRINTF1(_L("SetAndSelectNetwork() invoked......\n"));
       
   184 	SetNetworkSelectionSetting();
       
   185 	SelectNetwork();
       
   186 	}
       
   187 void CTestLtsyPhoneStepBase::GetCurrentNetworkInfo()
       
   188 	{
       
   189 	TRequestStatus Status;
       
   190 	INFO_PRINTF1(_L("GetCurrentNetworkInfo() invoked......\n"));	
       
   191 	RMobilePhone::TMobilePhoneNetworkInfoV5  aNetworkInfo;
       
   192 	RMobilePhone::TMobilePhoneNetworkInfoV5Pckg aNetworkInfoBuf(aNetworkInfo); // package TMobilePhoneNetworkInfoV1 into a buffer
       
   193 	RMobilePhone::TMobilePhoneLocationAreaV1 aArea;
       
   194 	iSharedPhone.GetCurrentNetwork(Status, aNetworkInfoBuf, aArea);
       
   195 	User::WaitForRequest(Status);
       
   196 
       
   197 	if (Status==KErrNone)
       
   198 		{
       
   199 		INFO_PRINTF1(_L("Get Get Current Network Information OK\n"));
       
   200 		}
       
   201 	else
       
   202 		{
       
   203 		INFO_PRINTF2(_L("Get Get Current Network Information, Error %d returned.\n"), Status.Int());
       
   204 		}
       
   205 
       
   206 	}
       
   207 //void CTestLtsyPhoneStepBase::GetNetworkMode()
       
   208 //	{
       
   209 //	TRequestStatus Status;
       
   210 //	INFO_PRINTF1(_L("SetAndSelectNetwork() invoked......\n")));
       
   211 //	User::WaitForRequest(Status);
       
   212 //	INFO_PRINTF1(_L("SetAndSelectNetwork() complete = %d\n")), Status.Int());
       
   213 //	}
       
   214 void CTestLtsyPhoneStepBase::GetNitzInfo()
       
   215 	{
       
   216 	TRequestStatus Status;
       
   217 	INFO_PRINTF1(_L("SetAndSelectNetwork() invoked......\n"));
       
   218 	RMobilePhone::TMobilePhoneNITZ NITZInfo;
       
   219 	iSharedPhone.GetNITZInfo(NITZInfo);
       
   220 	
       
   221     User::After(15*1000*1000);
       
   222 	INFO_PRINTF1(_L("SetAndSelectNetwork() invoked......OK\n"));
       
   223 	
       
   224 	}
       
   225 void CTestLtsyPhoneStepBase::GetSignalStrength()
       
   226 	{
       
   227 	TRequestStatus Status;
       
   228 	INFO_PRINTF1(_L("GetSignalStrength() invoked......\n"));
       
   229 	TInt32 signalStrength;
       
   230 	TInt8 bars;
       
   231 
       
   232 	iSharedPhone.GetSignalStrength(Status, signalStrength, bars);
       
   233 	User::WaitForRequest(Status);
       
   234 	
       
   235 	if (Status==KErrNone)
       
   236 		{
       
   237 		INFO_PRINTF2(_L("Signal strength (in dBm) : %d\n"), signalStrength);
       
   238 		INFO_PRINTF2(_L("Signal strength (in display bars) : %d\n"), bars);
       
   239 		}
       
   240 	else
       
   241 		{
       
   242 		INFO_PRINTF2(_L("Signal strength, Error %d returned.\n"), Status.Int());
       
   243 		}
       
   244 		
       
   245 	User::After(3000000);		// Give user time to see the test results 
       
   246 	}
       
   247 void CTestLtsyPhoneStepBase::GetSignalCaps()
       
   248 	{
       
   249 	TRequestStatus Status;
       
   250 	INFO_PRINTF1(_L("GetSignalCaps() invoked......\n"));
       
   251 	// Signal Caps
       
   252     TUint32 mmSignalCaps;
       
   253 	TInt retCap;
       
   254 	retCap = iSharedPhone.GetSignalCaps(mmSignalCaps);
       
   255 	if (retCap==KErrNotSupported)
       
   256 		{
       
   257 		INFO_PRINTF1(_L("Signal Capabilities NOT Supported\n"));		
       
   258 		}
       
   259 	else
       
   260 		{
       
   261 		INFO_PRINTF2(_L("Phone Signal Strength Caps = 0x%x\n"), mmSignalCaps);
       
   262 		if (mmSignalCaps & RMobilePhone::KCapsGetSignalStrength)
       
   263 			{
       
   264 			INFO_PRINTF1(_L("  Get Signal Strength Supported\n"));
       
   265 			}
       
   266 		if (mmSignalCaps & RMobilePhone::KCapsNotifySignalStrengthChange)
       
   267 			{
       
   268 			INFO_PRINTF1(_L("  Notify Signal Strength Supported\n"));
       
   269 			}
       
   270 		}
       
   271 	}
       
   272 void CTestLtsyPhoneStepBase::GetBatteryInfo()
       
   273 	{
       
   274 	TRequestStatus Status;
       
   275 	INFO_PRINTF1(_L("GetBatteryInfo() invoked......\n"));
       
   276 	RMobilePhone::TMobilePhoneBatteryInfoV1 battery;
       
   277 	iSharedPhone.GetBatteryInfo(Status, battery);
       
   278 	User::WaitForRequest(Status);
       
   279 	if (Status==KErrNone)
       
   280 		{
       
   281 		INFO_PRINTF2(_L("Battery status : %d\n"), battery.iStatus);
       
   282 		INFO_PRINTF2(_L("Battery charge level : %d\n"), battery.iChargeLevel);
       
   283 		}
       
   284 	else
       
   285 		{
       
   286 		INFO_PRINTF2(_L("Battery charge, Error %d returned.\n"), Status.Int());
       
   287 		}
       
   288 	}
       
   289 
       
   290 void CTestLtsyPhoneStepBase::GetSignalStrengthCancel()
       
   291 /** 
       
   292  * This method retrieves a phone's Signal and Battery Strength Information.
       
   293  */
       
   294 	{
       
   295 	TRequestStatus Status;
       
   296 	// Cancel Requests
       
   297 	INFO_PRINTF1(_L("GetSignalStrengthCancel() invoked......\n"));
       
   298 	TInt32 signalStrength;
       
   299 	TInt8 bars;
       
   300 	iSharedPhone.GetSignalStrength(Status, signalStrength, bars);
       
   301 	iSharedPhone.CancelAsyncRequest(EMobilePhoneGetSignalStrength);
       
   302 	User::WaitForRequest(Status);
       
   303 	INFO_PRINTF2(_L("GetSignalStrength Cancel status = %d\n\n"), Status.Int());
       
   304 	}
       
   305 
       
   306 /**
       
   307  * Notify signal strength change
       
   308  * 
       
   309  */
       
   310 void CTestLtsyPhoneStepBase::NotifySignalStrengthChange()
       
   311 	{
       
   312 	TRequestStatus reqStatus;
       
   313 	TInt32 signalStrength(0);
       
   314 	TInt8 bar(0);
       
   315 	TInt32 completeSignalStrength(70);
       
   316 	TInt8 completeBar(3);
       
   317 	SharedPhone().NotifySignalStrengthChange(reqStatus, signalStrength, bar);
       
   318 	User::WaitForRequest(reqStatus);
       
   319 	if(bar != completeBar)
       
   320 		{
       
   321 		ERR_PRINTF1(_L("bar is not expect."));
       
   322 		}
       
   323 	if(signalStrength != completeSignalStrength)
       
   324 		{
       
   325 		ERR_PRINTF1(_L("signalStrength is not expect."));
       
   326 		}
       
   327 	}
       
   328 void CTestLtsyPhoneStepBase::GetBatteryCaps()
       
   329 	{
       
   330 	TRequestStatus Status;
       
   331 	INFO_PRINTF1(_L("GetBatteryCaps() invoked......\n"));
       
   332 	// Battery Caps
       
   333     TUint32 mmBatteryCaps;
       
   334 	TInt retCap;
       
   335 	retCap = iSharedPhone.GetBatteryCaps(mmBatteryCaps);
       
   336 
       
   337 	if (retCap==KErrNotSupported)
       
   338 		{
       
   339 		INFO_PRINTF1(_L("Battery Capabilities NOT Supported\n"));		
       
   340 		}
       
   341 	else
       
   342 		{
       
   343 		INFO_PRINTF2(_L("Phone Battery Caps = 0x%x\n"), mmBatteryCaps);
       
   344 		}
       
   345 	}
       
   346 void CTestLtsyPhoneStepBase::GetBatteryStrengthCancel()
       
   347 /** 
       
   348  * This method retrieves a phone's Signal and Battery Strength Information.
       
   349  */
       
   350 	{
       
   351 	TRequestStatus Status;
       
   352 	// Cancel Requests
       
   353 	INFO_PRINTF1(_L("GetBatteryStrengthCancel() invoked......\n"));
       
   354 	RMobilePhone::TMobilePhoneBatteryInfoV1 battery;
       
   355 
       
   356 	iSharedPhone.GetBatteryInfo(Status, battery);
       
   357 	iSharedPhone.CancelAsyncRequest(EMobilePhoneGetBatteryInfo);
       
   358 	User::WaitForRequest(Status);
       
   359 	INFO_PRINTF2(_L("GetBatteryInfo Cancel status = %d\n"), Status.Int());
       
   360 	}
       
   361 /**
       
   362  * 
       
   363  * Notify battery info change or not
       
   364  * 
       
   365  */
       
   366 void CTestLtsyPhoneStepBase::NotifyBatteryInfoChange()
       
   367 	{
       
   368 	TRequestStatus status;
       
   369 	RMobilePhone::TMobilePhoneBatteryInfoV1 batInfo;
       
   370 	TUint twentyCharge = 20;
       
   371 	iSharedPhone.NotifyBatteryInfoChange(status, batInfo);
       
   372 
       
   373 	User::WaitForRequest(status);
       
   374 	if(batInfo.iStatus != RMobilePhone::EBatteryConnectedButExternallyPowered)
       
   375 		{
       
   376 		INFO_PRINTF1(_L("Failed to Check Phone battery status."));
       
   377 		}
       
   378 	if(batInfo.iChargeLevel != twentyCharge)
       
   379 		{
       
   380 		INFO_PRINTF1(_L("Failed to Check Phone battery charge level."));
       
   381 		}
       
   382 	}
       
   383 //void CTestLtsyPhoneStepBase::GetCurrentSystemNetworkModes()
       
   384 //	{
       
   385 //	TRequestStatus Status;
       
   386 //	INFO_PRINTF1(_L("GetCellInfo() invoked......\n")));
       
   387 //	User::WaitForRequest(Status);
       
   388 //	INFO_PRINTF1(_L("GetCellInfo() complete = %d\n")), Status.Int());	
       
   389 //	}
       
   390 //void CTestLtsyPhoneStepBase::GetNetworkProviderName()
       
   391 //	{
       
   392 //	TRequestStatus Status;
       
   393 //	INFO_PRINTF1(_L("GetCellInfo() invoked......\n")));
       
   394 //	User::WaitForRequest(Status);
       
   395 //	INFO_PRINTF1(_L("GetCellInfo() complete = %d\n")), Status.Int());	
       
   396 //	}
       
   397 //void CTestLtsyPhoneStepBase::GetOperatorName()
       
   398 //	{
       
   399 //	TRequestStatus Status;
       
   400 //	INFO_PRINTF1(_L("GetCellInfo() invoked......\n")));
       
   401 //	User::WaitForRequest(Status);
       
   402 //	INFO_PRINTF1(_L("GetCellInfo() complete = %d\n")), Status.Int());	
       
   403 //	}
       
   404 void CTestLtsyPhoneStepBase::RegisterCellInfoChangeNotification()
       
   405 	{
       
   406 	TRequestStatus Status;
       
   407 	INFO_PRINTF1(_L("NotifyCellInfoChange() invoked......\n"));
       
   408 	RMobilePhone::TMobilePhoneCellInfoV9 phoneCellinfo1;
       
   409 	RMobilePhone::TMobilePhoneCellInfoV9Pckg Packaged1(phoneCellinfo1);
       
   410 	iSharedPhone.NotifyCellInfoChange(Status,Packaged1);
       
   411 	User::WaitForRequest(Status);
       
   412 	INFO_PRINTF2(_L("NotifyCellInfoChange() complete = %d\n"), Status.Int());
       
   413 	
       
   414 	}
       
   415 void CTestLtsyPhoneStepBase::GetCellInfo()
       
   416 	{
       
   417 	TRequestStatus Status;
       
   418 	RMobilePhone::TMobilePhoneCellInfoV9 phoneCellinfo;
       
   419 	RMobilePhone::TMobilePhoneCellInfoV9Pckg Packaged(phoneCellinfo);
       
   420 	
       
   421 	INFO_PRINTF1(_L("GetCellInfo() invoked......\n"));
       
   422 	iSharedPhone.GetCellInfo(Status,Packaged);
       
   423 	User::WaitForRequest(Status);
       
   424 	INFO_PRINTF2(_L("GetCellInfo() complete = %d\n"), Status.Int());	
       
   425 	}
       
   426 //void CTestLtsyPhoneStepBase::GetPhoneCellInfo()
       
   427 //	{
       
   428 //	}
       
   429 
       
   430 
       
   431 // end of file