telephonyserverplugins/common_tsy/test/integration/src/tnetworktsytesthelper.cpp
changeset 0 3553901f7fa8
child 15 fc69e1e37771
equal deleted inserted replaced
-1:000000000000 0:3553901f7fa8
       
     1 // Copyright (c) 2007-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 "tnetworktsytesthelper.h" 
       
    17 
       
    18 #include "cctsyinidata.h"
       
    19 
       
    20 
       
    21 /**
       
    22 * Constructor
       
    23 */	
       
    24 TNetworkTsyTestHelper::TNetworkTsyTestHelper(CCTSYIntegrationTestSuiteStepBase& aTestStep)
       
    25 			: TTsyTestHelperBase( aTestStep )
       
    26 	{
       
    27 	}
       
    28 /**
       
    29 * Notify reset for RMobilePhone::NotifyModeChange
       
    30 */	
       
    31 void TNetworkTsyTestHelper::WaitForMobilePhoneNotifyModeChange( 
       
    32 				RMobilePhone& aMobilePhone,
       
    33 				TEtelRequestBase& aRequestStatus,
       
    34 				RMobilePhone::TMobilePhoneNetworkMode& aNetworkMode, 
       
    35 				RMobilePhone::TMobilePhoneNetworkMode aExpectedNetworkMode,
       
    36 				TInt aWantedStatus )
       
    37 
       
    38 	{
       
    39 	// Wait for the request to complete	
       
    40 	TInt err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort);	
       
    41 	ASSERT_EQUALS(err, KErrNone, _L("RMobilePhone::NotifyModeChange did not complete"))
       
    42 	
       
    43 	while (	err == KErrNone && aRequestStatus.Int() == KErrNone  	
       
    44 							&& aNetworkMode != aExpectedNetworkMode )
       
    45 		{
       
    46 		// Request has completed with incorrect result. Consume any outstanding
       
    47 		// Repost notification until timeout or we get the right result.
       
    48 		
       
    49 		aMobilePhone.NotifyModeChange(aRequestStatus, aNetworkMode);
       
    50 		err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort);
       
    51 		}
       
    52 		
       
    53 	ASSERT_EQUALS(aRequestStatus.Int(), aWantedStatus, _L("RMobilePhone::NotifyModeChange Wrong completion status"))	
       
    54 	ASSERT_EQUALS(aNetworkMode, aExpectedNetworkMode, 
       
    55 				_L("RMobilePhone::NotifyModeChange Wrong result"))	
       
    56 	
       
    57 	// Cancel request if it is still pending	
       
    58 	if (aRequestStatus.Int() == KRequestPending)	
       
    59 		{
       
    60 		aRequestStatus.Cancel();
       
    61 		}
       
    62 	}
       
    63 
       
    64 		
       
    65 /**
       
    66 * Notify reset for RMobilePhone::NotifyNetworkInvScanChange
       
    67 */	
       
    68 void TNetworkTsyTestHelper::WaitForMobilePhoneNotifyNetworkInvScanChange( 
       
    69 				RMobilePhone& aMobilePhone,
       
    70 				TEtelRequestBase& aRequestStatus,
       
    71 				RMobilePhone::TMobilePhoneInvestigationScan& aSetting, 
       
    72 				RMobilePhone::TMobilePhoneInvestigationScan aExpectedSetting,
       
    73 				TInt aWantedStatus )
       
    74 
       
    75 	{
       
    76 	// Wait for the request to complete	
       
    77 	TInt err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort);	
       
    78 	ASSERT_EQUALS(err, KErrNone, _L("RMobilePhone::NotifyNetworkInvScanChange did not complete"))
       
    79 	
       
    80 	while (	err == KErrNone && aRequestStatus.Int() == KErrNone  	
       
    81 							&& aSetting != aExpectedSetting )
       
    82 		{
       
    83 		// Request has completed with incorrect result. Consume any outstanding
       
    84 		// Repost notification until timeout or we get the right result.
       
    85 		
       
    86 		aMobilePhone.NotifyNetworkInvScanChange(aRequestStatus, aSetting);
       
    87 		err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort);
       
    88 		}
       
    89 		
       
    90 	ASSERT_EQUALS(aRequestStatus.Int(), aWantedStatus, _L("RMobilePhone::NotifyNetworkInvScanChange Wrong completion status"))	
       
    91 	ASSERT_EQUALS(aSetting, aExpectedSetting, 
       
    92 				_L("RMobilePhone::NotifyNetworkInvScanChange Wrong result"))	
       
    93 	
       
    94 	// Cancel request if it is still pending	
       
    95 	if (aRequestStatus.Int() == KRequestPending)	
       
    96 		{
       
    97 		aRequestStatus.Cancel();
       
    98 		}
       
    99 	}
       
   100 
       
   101 		
       
   102 /**
       
   103 * Notify reset for RMobilePhone::NotifyNetworkInvScanEvent
       
   104 */	
       
   105 void TNetworkTsyTestHelper::WaitForMobilePhoneNotifyNetworkInvScanEvent( 
       
   106 				RMobilePhone& aMobilePhone,
       
   107 				TEtelRequestBase& aRequestStatus,
       
   108 				RMobilePhone::TMobilePhoneInvestigationScanEvent& aEvent, 
       
   109 				RMobilePhone::TMobilePhoneInvestigationScanEvent aExpectedEvent,
       
   110 				TInt aWantedStatus )
       
   111 
       
   112 	{
       
   113 	// Wait for the request to complete	
       
   114 	TInt err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort);	
       
   115 	ASSERT_EQUALS(err, KErrNone, _L("RMobilePhone::NotifyNetworkInvScanEvent did not complete"))
       
   116 	
       
   117 	while (	err == KErrNone && aRequestStatus.Int() == KErrNone  	
       
   118 							&& aEvent != aExpectedEvent )
       
   119 		{
       
   120 		// Request has completed with incorrect result. Consume any outstanding
       
   121 		// Repost notification until timeout or we get the right result.
       
   122 		
       
   123 		aMobilePhone.NotifyNetworkInvScanEvent(aRequestStatus, aEvent);
       
   124 		err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort);
       
   125 		}
       
   126 		
       
   127 	ASSERT_EQUALS(aRequestStatus.Int(), aWantedStatus, _L("RMobilePhone::NotifyNetworkInvScanEvent Wrong completion status"))	
       
   128 	ASSERT_EQUALS(aEvent, aExpectedEvent, 
       
   129 				_L("RMobilePhone::NotifyNetworkInvScanEvent Wrong result"))	
       
   130 	
       
   131 	// Cancel request if it is still pending	
       
   132 	if (aRequestStatus.Int() == KRequestPending)	
       
   133 		{
       
   134 		aRequestStatus.Cancel();
       
   135 		}
       
   136 	}
       
   137 
       
   138 		
       
   139 /**
       
   140 * Notify reset for RMobilePhone::NotifyNetworkRegistrationStatusChange
       
   141 */	
       
   142 void TNetworkTsyTestHelper::WaitForMobilePhoneNotifyNetworkRegistrationStatusChange( 
       
   143 				RMobilePhone& aMobilePhone,
       
   144 				TEtelRequestBase& aRequestStatus,
       
   145 				RMobilePhone::TMobilePhoneRegistrationStatus& aStatus, 
       
   146 				RMobilePhone::TMobilePhoneRegistrationStatus aExpectedStatus,
       
   147 				TInt aWantedStatus )
       
   148 
       
   149 	{
       
   150 	// Wait for the request to complete	
       
   151 	TInt err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeVeryLong);	
       
   152 	ASSERT_EQUALS(err, KErrNone, _L("RMobilePhone::NotifyNetworkRegistrationStatusChange did not complete"))
       
   153 	
       
   154 	while (	err == KErrNone && aRequestStatus.Int() == KErrNone  	
       
   155 							&& aStatus != aExpectedStatus )
       
   156 		{
       
   157 		// Request has completed with incorrect result. Consume any outstanding
       
   158 		// Repost notification until timeout or we get the right result.
       
   159 		
       
   160 		aMobilePhone.NotifyNetworkRegistrationStatusChange(aRequestStatus, aStatus);
       
   161 		err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeMedium);
       
   162 		}
       
   163 		
       
   164 	ASSERT_EQUALS(aRequestStatus.Int(), aWantedStatus, _L("RMobilePhone::NotifyNetworkRegistrationStatusChange Wrong completion status"))	
       
   165 	ASSERT_EQUALS(aStatus, aExpectedStatus, 
       
   166 				_L("RMobilePhone::NotifyNetworkRegistrationStatusChange Wrong result"))	
       
   167 	
       
   168 	// Cancel request if it is still pending	
       
   169 	if (aRequestStatus.Int() == KRequestPending)	
       
   170 		{
       
   171 		aRequestStatus.Cancel();
       
   172 		}
       
   173 	}
       
   174 
       
   175 		
       
   176 /**
       
   177 * Notify reset for RMobilePhone::NotifyNetworkSecurityLevelChange
       
   178 */	
       
   179 void TNetworkTsyTestHelper::WaitForMobilePhoneNotifyNetworkSecurityLevelChange( 
       
   180 				RMobilePhone& aMobilePhone,
       
   181 				TEtelRequestBase& aRequestStatus,
       
   182 				RMobilePhone::TMobilePhoneNetworkSecurity& aSecurity, 
       
   183 				RMobilePhone::TMobilePhoneNetworkSecurity aExpectedSecurity,
       
   184 				TInt aWantedStatus )
       
   185 
       
   186 	{
       
   187 	// Wait for the request to complete	
       
   188 	TInt err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort);	
       
   189 	ASSERT_EQUALS(err, KErrNone, _L("RMobilePhone::NotifyNetworkSecurityLevelChange did not complete"))
       
   190 	
       
   191 	while (	err == KErrNone && aRequestStatus.Int() == KErrNone  	
       
   192 							&& aSecurity != aExpectedSecurity )
       
   193 		{
       
   194 		// Request has completed with incorrect result. Consume any outstanding
       
   195 		// Repost notification until timeout or we get the right result.
       
   196 		
       
   197 		aMobilePhone.NotifyNetworkSecurityLevelChange(aRequestStatus, aSecurity);
       
   198 		err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort);
       
   199 		}
       
   200 		
       
   201 	ASSERT_EQUALS(aRequestStatus.Int(), aWantedStatus, _L("RMobilePhone::NotifyNetworkSecurityLevelChange Wrong completion status"))	
       
   202 	ASSERT_EQUALS(aSecurity, aExpectedSecurity, 
       
   203 				_L("RMobilePhone::NotifyNetworkSecurityLevelChange Wrong result"))	
       
   204 	
       
   205 	// Cancel request if it is still pending	
       
   206 	if (aRequestStatus.Int() == KRequestPending)	
       
   207 		{
       
   208 		aRequestStatus.Cancel();
       
   209 		}
       
   210 	}
       
   211 
       
   212 		
       
   213 /**
       
   214 * Notify reset for RMobilePhone::NotifyPreferredNetworksListChange
       
   215 */	
       
   216 void TNetworkTsyTestHelper::WaitForMobilePhoneNotifyPreferredNetworksListChange( 
       
   217 				TEtelRequestBase& aRequestStatus,
       
   218 				TInt aWantedStatus )
       
   219 
       
   220 	{
       
   221 	// Wait for the request to complete	
       
   222 	TInt err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort);	
       
   223 	ASSERT_EQUALS(err, KErrNone, _L("RMobilePhone::NotifyPreferredNetworksListChange did not complete"))
       
   224 	ASSERT_EQUALS(aRequestStatus.Int(), aWantedStatus, _L("RMobilePhone::NotifyPreferredNetworksListChange Wrong completion status"))		
       
   225 	// Cancel request if it is still pending	
       
   226 	if (aRequestStatus.Int() == KRequestPending)	
       
   227 		{
       
   228 		aRequestStatus.Cancel();
       
   229 		}
       
   230 	}
       
   231 
       
   232 		
       
   233 /**
       
   234 * Notify reset for RMobilePhone::NotifyCurrentNetworkChange
       
   235 */	
       
   236 void TNetworkTsyTestHelper::WaitForMobilePhoneNotifyCurrentNetworkChange( 
       
   237 				RMobilePhone& aMobilePhone,
       
   238 				TEtelRequestBase& aRequestStatus,
       
   239 				TCmpBase<RMobilePhone::TMobilePhoneNetworkInfoV1> &aMobilePhoneNetworkInfoV1,
       
   240 				TInt aWantedStatus )
       
   241 
       
   242 	{
       
   243 	// Wait for the request to complete	
       
   244 	TInt err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort);	
       
   245 	ASSERT_EQUALS(err, KErrNone, _L("RMobilePhone::NotifyCurrentNetworkChange did not complete"))
       
   246 	
       
   247 	while (	err == KErrNone && aRequestStatus.Int() == KErrNone  	
       
   248 							&& !aMobilePhoneNetworkInfoV1.IsEqual(ENoLogError) )
       
   249 		{
       
   250 		// Request has completed with incorrect result. Consume any outstanding
       
   251 		// Repost notification until timeout or we get the right result.		
       
   252 		RMobilePhone::TMobilePhoneNetworkInfoV1Pckg pkgParam( aMobilePhoneNetworkInfoV1.GetValue() );
       
   253 		aMobilePhone.NotifyCurrentNetworkChange(aRequestStatus, pkgParam);
       
   254 		err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort);
       
   255 		}
       
   256 
       
   257 	ASSERT_EQUALS(aRequestStatus.Int(), aWantedStatus, _L("RMobilePhone::NotifyCurrentNetworkChange Wrong completion status"))	
       
   258 	ASSERT_TRUE(aMobilePhoneNetworkInfoV1.IsEqual(ELogError), 
       
   259 				_L("RMobilePhone::NotifyCurrentNetworkChange Wrong result"))	
       
   260 	
       
   261 	// Cancel request if it is still pending	
       
   262 	if (aRequestStatus.Int() == KRequestPending)	
       
   263 		{
       
   264 		aRequestStatus.Cancel();
       
   265 		}
       
   266 	}
       
   267 
       
   268 		
       
   269 /**
       
   270 * Notify reset for RMobilePhone::NotifyCurrentNetworkChange
       
   271 */	
       
   272 void TNetworkTsyTestHelper::WaitForMobilePhoneNotifyCurrentNetworkChange( 
       
   273 				RMobilePhone& aMobilePhone,
       
   274 				TEtelRequestBase& aRequestStatus,
       
   275 				TCmpBase<RMobilePhone::TMobilePhoneNetworkInfoV2> &aMobilePhoneNetworkInfoV2,
       
   276 				TInt aWantedStatus )
       
   277 
       
   278 	{
       
   279 	// Wait for the request to complete	
       
   280 	TInt err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort);	
       
   281 	ASSERT_EQUALS(err, KErrNone, _L("RMobilePhone::NotifyCurrentNetworkChange did not complete"))
       
   282 	
       
   283 	while (	err == KErrNone && aRequestStatus.Int() == KErrNone  	
       
   284 							&& !aMobilePhoneNetworkInfoV2.IsEqual(ENoLogError) )
       
   285 		{
       
   286 		// Request has completed with incorrect result. Consume any outstanding
       
   287 		// Repost notification until timeout or we get the right result.		
       
   288 		RMobilePhone::TMobilePhoneNetworkInfoV2Pckg pkgParam( aMobilePhoneNetworkInfoV2.GetValue() );
       
   289 		aMobilePhone.NotifyCurrentNetworkChange(aRequestStatus, pkgParam);
       
   290 		err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort);
       
   291 		}
       
   292 
       
   293 	ASSERT_EQUALS(aRequestStatus.Int(), aWantedStatus, _L("RMobilePhone::NotifyCurrentNetworkChange Wrong completion status"))	
       
   294 	ASSERT_TRUE(aMobilePhoneNetworkInfoV2.IsEqual(ELogError), 
       
   295 				_L("RMobilePhone::NotifyCurrentNetworkChange Wrong result"))	
       
   296 	
       
   297 	// Cancel request if it is still pending	
       
   298 	if (aRequestStatus.Int() == KRequestPending)	
       
   299 		{
       
   300 		aRequestStatus.Cancel();
       
   301 		}
       
   302 	}
       
   303 
       
   304 		
       
   305 /**
       
   306 * Notify reset for RMobilePhone::NotifyCurrentNetworkChange
       
   307 */	
       
   308 void TNetworkTsyTestHelper::WaitForMobilePhoneNotifyCurrentNetworkChange( 
       
   309 				RMobilePhone& aMobilePhone,
       
   310 				TEtelRequestBase& aRequestStatus,
       
   311 				TCmpBase<RMobilePhone::TMobilePhoneNetworkInfoV5> &aMobilePhoneNetworkInfoV5,
       
   312 				TInt aWantedStatus )
       
   313 
       
   314 	{
       
   315 	// Wait for the request to complete	
       
   316 	TInt err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort);	
       
   317 	ASSERT_EQUALS(err, KErrNone, _L("RMobilePhone::NotifyCurrentNetworkChange did not complete"))
       
   318 	
       
   319 	while (	err == KErrNone && aRequestStatus.Int() == KErrNone  	
       
   320 							&& !aMobilePhoneNetworkInfoV5.IsEqual(ENoLogError) )
       
   321 		{
       
   322 		// Request has completed with incorrect result. Consume any outstanding
       
   323 		// Repost notification until timeout or we get the right result.		
       
   324 		RMobilePhone::TMobilePhoneNetworkInfoV5Pckg pkgParam( aMobilePhoneNetworkInfoV5.GetValue() );
       
   325 		aMobilePhone.NotifyCurrentNetworkChange(aRequestStatus, pkgParam);
       
   326 		err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort);
       
   327 		}
       
   328 
       
   329 	ASSERT_EQUALS(aRequestStatus.Int(), aWantedStatus, _L("RMobilePhone::NotifyCurrentNetworkChange Wrong completion status"))	
       
   330 	ASSERT_TRUE(aMobilePhoneNetworkInfoV5.IsEqual(ELogError), 
       
   331 				_L("RMobilePhone::NotifyCurrentNetworkChange Wrong result"))	
       
   332 	
       
   333 	// Cancel request if it is still pending	
       
   334 	if (aRequestStatus.Int() == KRequestPending)	
       
   335 		{
       
   336 		aRequestStatus.Cancel();
       
   337 		}
       
   338 	}
       
   339 
       
   340 		
       
   341 /**
       
   342 * Notify reset for RMobilePhone::NotifyCurrentNetworkChange
       
   343 */	
       
   344 void TNetworkTsyTestHelper::WaitForMobilePhoneNotifyCurrentNetworkChange( 
       
   345 				RMobilePhone& aMobilePhone,
       
   346 				TEtelRequestBase& aRequestStatus,
       
   347 				TCmpBase<RMobilePhone::TMobilePhoneNetworkInfoV1> &aMobilePhoneNetworkInfoV1,
       
   348 				RMobilePhone::TMobilePhoneLocationAreaV1 &aArea,
       
   349 				TInt aWantedStatus )
       
   350 
       
   351 	{
       
   352 	// Wait for the request to complete	
       
   353 	TInt err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort);	
       
   354 	ASSERT_EQUALS(err, KErrNone, _L("RMobilePhone::NotifyCurrentNetworkChange did not complete"))
       
   355 	
       
   356 	while (	err == KErrNone && aRequestStatus.Int() == KErrNone  	
       
   357 							&& !aMobilePhoneNetworkInfoV1.IsEqual(ENoLogError) )
       
   358 		{
       
   359 		// Request has completed with incorrect result. Consume any outstanding
       
   360 		// Repost notification until timeout or we get the right result.		
       
   361 		RMobilePhone::TMobilePhoneNetworkInfoV1Pckg pkgParam( aMobilePhoneNetworkInfoV1.GetValue() );
       
   362 		aMobilePhone.NotifyCurrentNetworkChange(aRequestStatus, pkgParam, aArea);
       
   363 		err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort);
       
   364 		}
       
   365 
       
   366 	ASSERT_EQUALS(aRequestStatus.Int(), aWantedStatus, _L("RMobilePhone::NotifyCurrentNetworkChange Wrong completion status"))	
       
   367 	ASSERT_TRUE(aMobilePhoneNetworkInfoV1.IsEqual(ELogError), 
       
   368 				_L("RMobilePhone::NotifyCurrentNetworkChange Wrong result"))	
       
   369 	
       
   370 	// Cancel request if it is still pending	
       
   371 	if (aRequestStatus.Int() == KRequestPending)	
       
   372 		{
       
   373 		aRequestStatus.Cancel();
       
   374 		}
       
   375 	}
       
   376 
       
   377 		
       
   378 /**
       
   379 * Notify reset for RMobilePhone::NotifyCurrentNetworkChange
       
   380 */	
       
   381 void TNetworkTsyTestHelper::WaitForMobilePhoneNotifyCurrentNetworkChange( 
       
   382 				RMobilePhone& aMobilePhone,
       
   383 				TEtelRequestBase& aRequestStatus,
       
   384 				TCmpBase<RMobilePhone::TMobilePhoneNetworkInfoV2> &aMobilePhoneNetworkInfoV2,
       
   385 				RMobilePhone::TMobilePhoneLocationAreaV1 &aArea,
       
   386 				TInt aWantedStatus )
       
   387 
       
   388 	{
       
   389 	// Wait for the request to complete	
       
   390 	TInt err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort);	
       
   391 	ASSERT_EQUALS(err, KErrNone, _L("RMobilePhone::NotifyCurrentNetworkChange did not complete"))
       
   392 	
       
   393 	while (	err == KErrNone && aRequestStatus.Int() == KErrNone  	
       
   394 							&& !aMobilePhoneNetworkInfoV2.IsEqual(ENoLogError) )
       
   395 		{
       
   396 		// Request has completed with incorrect result. Consume any outstanding
       
   397 		// Repost notification until timeout or we get the right result.		
       
   398 		RMobilePhone::TMobilePhoneNetworkInfoV2Pckg pkgParam( aMobilePhoneNetworkInfoV2.GetValue() );
       
   399 		aMobilePhone.NotifyCurrentNetworkChange(aRequestStatus, pkgParam, aArea);
       
   400 		err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort);
       
   401 		}
       
   402 
       
   403 	ASSERT_EQUALS(aRequestStatus.Int(), aWantedStatus, _L("RMobilePhone::NotifyCurrentNetworkChange Wrong completion status"))	
       
   404 	ASSERT_TRUE(aMobilePhoneNetworkInfoV2.IsEqual(ELogError), 
       
   405 				_L("RMobilePhone::NotifyCurrentNetworkChange Wrong result"))	
       
   406 	
       
   407 	// Cancel request if it is still pending	
       
   408 	if (aRequestStatus.Int() == KRequestPending)	
       
   409 		{
       
   410 		aRequestStatus.Cancel();
       
   411 		}
       
   412 	}
       
   413 
       
   414 		
       
   415 /**
       
   416 * Notify reset for RMobilePhone::NotifyCurrentNetworkChange
       
   417 */	
       
   418 void TNetworkTsyTestHelper::WaitForMobilePhoneNotifyCurrentNetworkChange( 
       
   419 				RMobilePhone& aMobilePhone,
       
   420 				TEtelRequestBase& aRequestStatus,
       
   421 				TCmpBase<RMobilePhone::TMobilePhoneNetworkInfoV5> &aMobilePhoneNetworkInfoV5,
       
   422 				RMobilePhone::TMobilePhoneLocationAreaV1 &aArea,
       
   423 				TInt aWantedStatus )
       
   424 
       
   425 	{
       
   426 	// Wait for the request to complete	
       
   427 	TInt err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort);	
       
   428 	ASSERT_EQUALS(err, KErrNone, _L("RMobilePhone::NotifyCurrentNetworkChange did not complete"))
       
   429 	
       
   430 	while (	err == KErrNone && aRequestStatus.Int() == KErrNone  	
       
   431 							&& !aMobilePhoneNetworkInfoV5.IsEqual(ENoLogError) )
       
   432 		{
       
   433 		// Request has completed with incorrect result. Consume any outstanding
       
   434 		// Repost notification until timeout or we get the right result.		
       
   435 		RMobilePhone::TMobilePhoneNetworkInfoV5Pckg pkgParam( aMobilePhoneNetworkInfoV5.GetValue() );
       
   436 		aMobilePhone.NotifyCurrentNetworkChange(aRequestStatus, pkgParam, aArea);
       
   437 		err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort);
       
   438 		}
       
   439 
       
   440 	ASSERT_EQUALS(aRequestStatus.Int(), aWantedStatus, _L("RMobilePhone::NotifyCurrentNetworkChange Wrong completion status"))	
       
   441 	ASSERT_TRUE(aMobilePhoneNetworkInfoV5.IsEqual(ELogError), 
       
   442 				_L("RMobilePhone::NotifyCurrentNetworkChange Wrong result"))	
       
   443 	
       
   444 	// Cancel request if it is still pending	
       
   445 	if (aRequestStatus.Int() == KRequestPending)	
       
   446 		{
       
   447 		aRequestStatus.Cancel();
       
   448 		}
       
   449 	}
       
   450 
       
   451 		
       
   452 /**
       
   453 * Notify reset for RMobilePhone::NotifyAPNListChanged
       
   454 */	
       
   455 void TNetworkTsyTestHelper::WaitForMobilePhoneNotifyAPNListChanged( 
       
   456 				TEtelRequestBase& aRequestStatus,
       
   457 				TInt aWantedStatus )
       
   458 
       
   459 	{
       
   460 	// Wait for the request to complete	
       
   461 	TInt err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort);	
       
   462 	ASSERT_EQUALS(err, KErrNone, _L("RMobilePhone::NotifyAPNListChanged did not complete"))
       
   463 	ASSERT_EQUALS(aRequestStatus.Int(), aWantedStatus, _L("RMobilePhone::NotifyAPNListChanged Wrong completion status"))		
       
   464 	// Cancel request if it is still pending	
       
   465 	if (aRequestStatus.Int() == KRequestPending)	
       
   466 		{
       
   467 		aRequestStatus.Cancel();
       
   468 		}
       
   469 	}
       
   470 
       
   471 		
       
   472 /**
       
   473 * Notify reset for RMobilePhone::NotifyAPNControlListServiceStatusChange
       
   474 */	
       
   475 void TNetworkTsyTestHelper::WaitForMobilePhoneNotifyAPNControlListServiceStatusChange( 
       
   476 				RMobilePhone& aMobilePhone,
       
   477 				TEtelRequestBase& aRequestStatus,
       
   478 				RMobilePhone::TAPNControlListServiceStatus& aAPNControlListServiceStatus, 
       
   479 				RMobilePhone::TAPNControlListServiceStatus aExpectedAPNControlListServiceStatus,
       
   480 				TInt aWantedStatus )
       
   481 
       
   482 	{
       
   483 	// Wait for the request to complete	
       
   484 	TInt err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort);	
       
   485 	ASSERT_EQUALS(err, KErrNone, _L("RMobilePhone::NotifyAPNControlListServiceStatusChange did not complete"))
       
   486 	
       
   487 	while (	err == KErrNone && aRequestStatus.Int() == KErrNone  	
       
   488 							&& aAPNControlListServiceStatus != aExpectedAPNControlListServiceStatus )
       
   489 		{
       
   490 		// Request has completed with incorrect result. Consume any outstanding
       
   491 		// Repost notification until timeout or we get the right result.
       
   492 		
       
   493 		aMobilePhone.NotifyAPNControlListServiceStatusChange(aRequestStatus, aAPNControlListServiceStatus);
       
   494 		err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort);
       
   495 		}
       
   496 		
       
   497 	ASSERT_EQUALS(aRequestStatus.Int(), aWantedStatus, _L("RMobilePhone::NotifyAPNControlListServiceStatusChange Wrong completion status"))	
       
   498 	ASSERT_EQUALS(aAPNControlListServiceStatus, aExpectedAPNControlListServiceStatus, 
       
   499 				_L("RMobilePhone::NotifyAPNControlListServiceStatusChange Wrong result"))	
       
   500 	
       
   501 	// Cancel request if it is still pending	
       
   502 	if (aRequestStatus.Int() == KRequestPending)	
       
   503 		{
       
   504 		aRequestStatus.Cancel();
       
   505 		}
       
   506 	}
       
   507 
       
   508 
       
   509 /**
       
   510 * Notify reset for RMobilePhone::NotifyNetworkSelectionSettingChange
       
   511 */	
       
   512 void TNetworkTsyTestHelper::WaitForMobilePhoneNotifyNetworkSelectionSettingChange( 
       
   513 				RMobilePhone& aMobilePhone,
       
   514 				TEtelRequestBase& aRequestStatus,
       
   515 				RMobilePhone::TMobilePhoneNetworkSelectionV1 &aNetSel,
       
   516 				RMobilePhone::TMobilePhoneSelectionMethod aDesiredMethod,
       
   517 				TInt aWantedStatus )
       
   518 	{
       
   519 	// Wait for the request to complete	
       
   520 	TInt err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeMedium);	
       
   521 	ASSERT_EQUALS(err, KErrNone, _L("RMobilePhone::NotifyNetworkSelectionSettingChange timed out"))
       
   522 	
       
   523 	while (	err == KErrNone && 
       
   524 			aRequestStatus.Int() == KErrNone  &&
       
   525 			aNetSel.iMethod != aDesiredMethod )
       
   526 		{
       
   527 		// Request has completed with incorrect result. Consume any outstanding
       
   528 		// Repost notification until timeout or we get the right result.		
       
   529 		RMobilePhone::TMobilePhoneNetworkSelectionV1Pckg pkg( aNetSel );
       
   530 		aMobilePhone.NotifyNetworkSelectionSettingChange(aRequestStatus, pkg);
       
   531 		err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort);
       
   532 		}
       
   533 
       
   534 	ASSERT_EQUALS(aRequestStatus.Int(), aWantedStatus, 
       
   535 						_L("RMobilePhone::NotifyNetworkSelectionSettingChange Wrong completion status"))
       
   536 	
       
   537 	// Cancel request if it is still pending	
       
   538 	if (aRequestStatus.Int() == KRequestPending)	
       
   539 		{
       
   540 		aRequestStatus.Cancel();
       
   541 		}
       
   542 	}
       
   543 		
       
   544 /**
       
   545  * Get the current network info 
       
   546  * @param aPhone RMobilePhone object
       
   547  * @param aPhoneNetwork Packaged descriptor carrying a TMobilePhoneNetworkInfoV1 object or derived class
       
   548  * @param aArea current location of the phone (see RMobilePhone::GetCUrrentNetwork)
       
   549  */
       
   550  TInt TNetworkTsyTestHelper::GetCurrentNetworkL( RMobilePhone& aPhone, RMobilePhone::TMobilePhoneNetworkInfoV1Pckg& aPhoneNetwork, 
       
   551  									RMobilePhone::TMobilePhoneLocationAreaV1& aArea,TOperatorName& aOperatorName )
       
   552  	{
       
   553  	
       
   554  	TExtEtelRequestStatus reqStatus(aPhone, EMobilePhoneGetCurrentNetwork);
       
   555  	CleanupStack::PushL(reqStatus);
       
   556  	
       
   557  	aPhone.GetCurrentNetwork( reqStatus, aPhoneNetwork, aArea );
       
   558  	
       
   559  	TInt reqResult = iTestStep.WaitForRequestWithTimeOut(reqStatus, ETimeLong);
       
   560  		
       
   561  	if(KErrNone == reqResult)
       
   562  		{
       
   563  		reqResult = reqStatus.Int();
       
   564  		}
       
   565 	DEBUG_PRINTF2(_L("Current network is %S"), &(aPhoneNetwork().iShortName));
       
   566 	if( aPhoneNetwork().iShortName.Find(_L("O2")) >=0 )
       
   567 		{
       
   568 		aOperatorName = EOperatorO2;
       
   569 		}
       
   570 	else if ( aPhoneNetwork().iShortName.Find(_L("voda")) >=0 )
       
   571 		{
       
   572 		aOperatorName = EOperatorVodafone;
       
   573 		}
       
   574 	else if ( aPhoneNetwork().iShortName.Find(_L("Orange")) >=0 )
       
   575 		{
       
   576 		aOperatorName = EOperatorOrange;
       
   577 		}
       
   578 	else if ( aPhoneNetwork().iShortName.Find(_L("Elisa")) >=0 )
       
   579 		{
       
   580 		aOperatorName = EOperatorElisa;
       
   581 		}
       
   582     else if ( aPhoneNetwork().iShortName.Find(_L("DNA")) >=0 )
       
   583 		{
       
   584 		aOperatorName = EOperatorDNA;
       
   585 		}
       
   586 	else if ( aPhoneNetwork().iShortName.Find(_L("dna")) >=0 )
       
   587 		{
       
   588 		aOperatorName = EOperatorDNA;
       
   589 		}
       
   590 	else if ( aPhoneNetwork().iShortName.Find(_L("SONERA")) >=0 )
       
   591 		{
       
   592 		aOperatorName = EOperatorSonera;
       
   593 		}
       
   594 	else if ( aPhoneNetwork().iShortName.Find(_L("T-Mobile")) >=0 
       
   595 			||	aPhoneNetwork().iShortName.Find(_L("One2One")) >=0)
       
   596 		{
       
   597 		aOperatorName = EOperatorTMobile;
       
   598 		}
       
   599 	else if( (aPhoneNetwork().iShortName.Find(_L("01")) >=0) || 
       
   600 			(aPhoneNetwork().iShortName.Find(_L("ANITE")) >=0) )
       
   601 		{
       
   602 		aOperatorName = EOperatorAnite;
       
   603 		}
       
   604 	else
       
   605 		{
       
   606 		aOperatorName = EOperatorUnknown;
       
   607 		}
       
   608 
       
   609  	CleanupStack::PopAndDestroy(1);
       
   610 
       
   611  	return reqResult;
       
   612  	}
       
   613 
       
   614 /** 
       
   615 * Determine the network registration status
       
   616 * @param aPhone RMobilePhone object
       
   617 * @param aRegistrationStatus - (out) returned phone registration status
       
   618 * @return KErrNone if registered on home network, KErrNotReady if not on home network. 
       
   619 */
       
   620 TInt TNetworkTsyTestHelper::GetNetworkRegistrationStatusL( RMobilePhone& aPhone, 
       
   621 							RMobilePhone::TMobilePhoneRegistrationStatus &aRegistrationStatus )
       
   622 	{
       
   623 	TExtEtelRequestStatus reqStatus(aPhone, EMobilePhoneGetNetworkRegistrationStatus);
       
   624 	CleanupStack::PushL(reqStatus);
       
   625 
       
   626 	aPhone.GetNetworkRegistrationStatus(reqStatus, aRegistrationStatus);
       
   627 	TInt reqResult = iTestStep.WaitForRequestWithTimeOut(reqStatus, ETimeLong );	
       
   628 
       
   629 	if(KErrNone == reqResult)
       
   630 		{
       
   631 		reqResult = reqStatus.Int();
       
   632 		}
       
   633 
       
   634 	CleanupStack::PopAndDestroy(1);
       
   635 	
       
   636 	return reqResult;
       
   637 	}
       
   638 	
       
   639 	
       
   640 	
       
   641 	
       
   642 /** 
       
   643 * Determine the network registration status and if we are not on the network, wait
       
   644 * @param aPhone RMobilePhone object
       
   645 * @return KErrNone if registered on home network, KErrNotReady if not on home network. 
       
   646 * Other error codes as from RMobilePhone::GetNetworkRegistrationStatus
       
   647 */
       
   648 TInt TNetworkTsyTestHelper::WaitForRegisteredOnHomeNetworkL( RMobilePhone& aPhone )
       
   649 	{
       
   650 
       
   651 	RMobilePhone::TMobilePhoneRegistrationStatus registrationStatus;
       
   652 	TInt err = GetNetworkRegistrationStatusL(aPhone, registrationStatus);
       
   653 	
       
   654 	if( KErrNone != err )
       
   655 		{
       
   656 		return err;
       
   657 		}
       
   658 	
       
   659 	if( registrationStatus == RMobilePhone::ERegisteredOnHomeNetwork )
       
   660 		{
       
   661 		return KErrNone;
       
   662 		}
       
   663 		
       
   664 	TExtEtelRequestStatus reqStatus(aPhone, EMobilePhoneNotifyNetworkRegistrationStatusChange );
       
   665 	CleanupStack::PushL(reqStatus);
       
   666 	
       
   667 	aPhone.NotifyNetworkRegistrationStatusChange(reqStatus, registrationStatus);
       
   668 	 		
       
   669 	WaitForMobilePhoneNotifyNetworkRegistrationStatusChange( aPhone, 
       
   670 									reqStatus, registrationStatus,
       
   671 									RMobilePhone::ERegisteredOnHomeNetwork, KErrNone );
       
   672 
       
   673 	// If the wait has timed out, we check again to see if we missed the notification									
       
   674 	if( KErrNone == err )
       
   675 		{
       
   676 		err = reqStatus.Int();		
       
   677 		}
       
   678 
       
   679 	if( KErrNone != err )
       
   680 		{
       
   681 		err = GetNetworkRegistrationStatusL(aPhone, registrationStatus);
       
   682 		}		
       
   683 								
       
   684 	if( KErrNone == err )
       
   685 		{
       
   686 		err = (registrationStatus == RMobilePhone::ERegisteredOnHomeNetwork) ? KErrNone : KErrNotReady;
       
   687 		}
       
   688 									
       
   689 	CleanupStack::PopAndDestroy(1);
       
   690 	
       
   691 	return err;
       
   692 	
       
   693 	}
       
   694 
       
   695 void TNetworkTsyTestHelper::CheckPhoneConnectedToAniteL(RMobilePhone &aPhone)
       
   696 	{
       
   697 /*
       
   698  * @param aPhone - Handle to the subsession of a phone
       
   699  * 
       
   700  * This function checks to see if we are connected to the Anite Network Simulator.  
       
   701  * It leaves if we connected to any other network.  It does this because we don't want to 
       
   702  * actually connect to an operator answering emergency calls and then just hangup on them.
       
   703  * People can be fined for making prank calls to emergency numbers, and we don't want that.
       
   704  */
       
   705 	RMobilePhone::TMobilePhoneNetworkInfoV1 netInfo;
       
   706 	RMobilePhone::TMobilePhoneNetworkInfoV1Pckg netInfoPkg(netInfo);
       
   707 	RMobilePhone::TMobilePhoneLocationAreaV1 area;
       
   708 	TOperatorName operatorName = EOperatorUnknown;
       
   709 	TInt err = GetCurrentNetworkL( aPhone, netInfoPkg, area, operatorName );
       
   710 	CHECK_EQUALS_L( err, KErrNone, _L("RMobilePhone::GetCurrentNetwork failed to get network id"));
       
   711 	CHECK_EQUALS_L( operatorName, EOperatorAnite, _L("RMobilePhone::GetCurrentNetwork did not return Anite.  Simulation tests should be tested using the Anite network simulator."));
       
   712 	}
       
   713 
       
   714 void TNetworkTsyTestHelper::GetNetworkPasswordsSectionL(RMobilePhone& aMobilePhone, const TDesC*& aNetworkSection)
       
   715 /**
       
   716  * member function for obtaining the network section of the INI file to be read returning void
       
   717  *
       
   718  * @param aMobilePhone a reference to RMobilePhone object
       
   719  * @param aNetworkSection a reference to a pointer to hold the network section in INI file
       
   720 
       
   721  * @return void
       
   722  */
       
   723 
       
   724 	{
       
   725 	   static TBool firstTime = ETrue;
       
   726 	   if(firstTime) // register to network only once
       
   727 		   {
       
   728 	       TInt ret = WaitForRegisteredOnHomeNetworkL(aMobilePhone);
       
   729 	       ASSERT_EQUALS(ret, KErrNone,
       
   730 	                _L("RMobilePhone::NotifyNetworkRegistrationStatusChange network registration failed"));
       
   731 	       firstTime = EFalse;
       
   732 	       }
       
   733 	
       
   734 	RMobilePhone::TMobilePhoneNetworkInfoV1 info;
       
   735 	RMobilePhone::TMobilePhoneNetworkInfoV1Pckg infopckg(info);
       
   736 	RMobilePhone::TMobilePhoneLocationAreaV1 area;
       
   737 	TOperatorName operatorName = EOperatorUnknown;
       
   738 	TInt err = GetCurrentNetworkL( aMobilePhone, infopckg, area, operatorName );	
       
   739 	ASSERT_EQUALS( err, KErrNone, _L("RMobilePhone::GetCurrentNetwork failed to get current network id (1)"));
       
   740 	
       
   741 	switch ( operatorName )
       
   742 		{
       
   743 		case EOperatorO2:
       
   744 			aNetworkSection = &KIniSectionO2Passwords;
       
   745 			break;
       
   746 		case EOperatorVodafone:
       
   747 			aNetworkSection = &KIniSectionVodafonePasswords;
       
   748 			break;
       
   749 		case EOperatorOrange:
       
   750 			aNetworkSection = &KIniSectionOrangePasswords;
       
   751 			break;
       
   752 		case EOperatorTMobile:
       
   753 			aNetworkSection = &KIniSectionTMobilePasswords;
       
   754 			break;
       
   755 		case EOperatorAnite:
       
   756 			aNetworkSection = &KIniSectionAnitePasswords;
       
   757 			break;
       
   758 		case EOperatorUnknown:
       
   759 		default:
       
   760 		    CHECK_TRUE_L( EFail, _L("Failed to identify current network"));
       
   761 			break;
       
   762 		}
       
   763 }