common/tools/ats/smoketest/lbs/lbsclient/src/ctlbsclientstepnotifyposupdate.cpp
changeset 748 e13acd883fbe
child 872 17498133d9ad
equal deleted inserted replaced
747:76f9aaeefbab 748:e13acd883fbe
       
     1 // Copyright (c) 2006-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 the License "Symbian Foundation License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // @file ctlbsclientstep_notifyposupdate.cpp
       
    15 // This is the class implementation for the Notify Position Update Tests
       
    16 // 
       
    17 //
       
    18  
       
    19 #include "ctlbsclientstepnotifyposupdate.h"
       
    20 
       
    21 #include <lbs.h>
       
    22 #include <lbssatellite.h>
       
    23 
       
    24 #include "tlbsutils.h"
       
    25 #include "ctlbsasyncwaiter.h"
       
    26 
       
    27 
       
    28 // constant definitions
       
    29 _LIT(KLbsClientStepNotifyPosUpdate, "LbsClientStepNotifyPosUpdate");
       
    30 
       
    31 //profile_id in ini file
       
    32 _LIT(KLbsProfileId, "profile_id");
       
    33 
       
    34 //max_time in ini file
       
    35 _LIT(KLbsMaxTime, "max_time");
       
    36 
       
    37 
       
    38 const TTimeIntervalMicroSeconds KModuleTimeout = 6000000;//makes test module time out(which should be more than the Maxtime in lbsprofile.ini)
       
    39 
       
    40 /**
       
    41  *	Sets a Requestor for now - TODO will be removed with new location server
       
    42  */
       
    43 void CT_LbsClientStep_NotifyPosUpdate::TempSetRequestorL()
       
    44  	{	
       
    45 	User::LeaveIfError(iPositioner.SetRequestor(	CRequestor::ERequestorService,
       
    46 												CRequestor::EFormatApplication,
       
    47 												_L("Tom Tom")));
       
    48  	}
       
    49 
       
    50 
       
    51 /**
       
    52  * Destructor
       
    53  */
       
    54 CT_LbsClientStep_NotifyPosUpdate::~CT_LbsClientStep_NotifyPosUpdate()
       
    55 	{
       
    56 	delete 	iLbsAdmin;	
       
    57 	}
       
    58 
       
    59 
       
    60 /**
       
    61  * Constructor
       
    62  */
       
    63 CT_LbsClientStep_NotifyPosUpdate::CT_LbsClientStep_NotifyPosUpdate(CT_LbsClientServer& aParent) : CT_LbsClientStep(aParent),iLbsAdmin(NULL),iRequestedAssData(FALSE), iReceivedAssData(FALSE)
       
    64 	{
       
    65 	
       
    66 	SetTestStepName(KLbsClientStep_NotifyPosUpdate);
       
    67 	}
       
    68 
       
    69 
       
    70 /**
       
    71 Static Constructor
       
    72 */
       
    73 CT_LbsClientStep_NotifyPosUpdate* CT_LbsClientStep_NotifyPosUpdate::New(CT_LbsClientServer& aParent)
       
    74 	{
       
    75 	
       
    76 	// Note the lack of ELeave.
       
    77 	// This means that having insufficient memory will return NULL;
       
    78 	
       
    79 	CT_LbsClientStep_NotifyPosUpdate* testStep = new CT_LbsClientStep_NotifyPosUpdate(aParent);
       
    80 	if (testStep)
       
    81 		{
       
    82 		TInt err = KErrNone;
       
    83 
       
    84 		TRAP(err, testStep->ConstructL());
       
    85 		if (err)
       
    86 			{
       
    87 			delete testStep;
       
    88 			testStep = NULL;
       
    89 			}
       
    90 		}
       
    91 	return testStep;
       
    92 	}
       
    93 
       
    94 
       
    95 void CT_LbsClientStep_NotifyPosUpdate::ConstructL()
       
    96 	{
       
    97 	// create the admin
       
    98 	iLbsAdmin = CLbsAdmin::NewL();
       
    99 
       
   100 	}
       
   101 
       
   102 //from MT_NotifyPosUpdateObserver:
       
   103 /**
       
   104  * 	Callback - called when NotifyPositionUpdate request completes
       
   105  */
       
   106 
       
   107 void CT_LbsClientStep_NotifyPosUpdate::NotifyPositionUpdateCallback(TRequestStatus& aStatus)
       
   108 	{
       
   109 	TInt err = aStatus.Int();
       
   110 	if (KErrCancel != err)	
       
   111 		{
       
   112 		SetTestStepResult(EFail); // the request always gets cancelled (see test 0122)
       
   113 		}
       
   114 	CActiveScheduler::Stop();
       
   115 	}
       
   116 
       
   117 /**
       
   118  * @return - TVerdict code
       
   119  * Override of base class pure virtual
       
   120  * Our implementation only gets called if the base class doTestStepPreambleL() did
       
   121  * not leave. That being the case, the current test result value will be EPass.
       
   122  */
       
   123 TVerdict CT_LbsClientStep_NotifyPosUpdate::doTestStepL()
       
   124 	{
       
   125 	// Generic test step used to test the LBS Client Notify position update API.
       
   126 	INFO_PRINTF1(_L("&gt;&gt;CT_LbsClientStep_NotifyPosUpdate::doTestStepL()"));
       
   127 
       
   128 	if (TestStepResult()==EPass)
       
   129 		{
       
   130 		TInt err = KErrNone;
       
   131 				
       
   132 		// Connect to self locate server.
       
   133 		err = iServer.Connect();
       
   134 		User::LeaveIfError(err);
       
   135 		CleanupClosePushL(iServer);
       
   136 		
       
   137 		// Carryout unique test actions.
       
   138 		TInt testCaseId;
       
   139 		if (GetIntFromConfig(ConfigSection(), KTestCaseId, testCaseId))
       
   140 			{
       
   141 				switch (testCaseId)
       
   142 				{
       
   143 				// Test case LBS-NotifyPosUpdate-0001
       
   144 				case 1:
       
   145 				case 29: // Test case LBS-NotifyPosUpdate-0029
       
   146 				case 30: // Test case LBS-NotifyPosUpdate-0030
       
   147 				case 101:
       
   148 				case 105:
       
   149 				case 201: // in Lbs "original" mode no ref position!	
       
   150 					{
       
   151 					T_LbsUtils utils;
       
   152 
       
   153 					// Open positioner.
       
   154 					err = iPositioner.Open(iServer);
       
   155 					User::LeaveIfError(err);
       
   156 					CleanupClosePushL(iPositioner);
       
   157 
       
   158 					// For this test an additional reference position will be returned.
       
   159 					if ((testCaseId == 101) || (testCaseId == 105))
       
   160 						{
       
   161 						
       
   162 						if (testCaseId == 105)
       
   163 							{	
       
   164 							TModuleDataIn modDataIn; // Used to send test information to the test module.
       
   165 							modDataIn.iRequestType = TModuleDataIn::EModuleRequestTestMode;
       
   166 							modDataIn.iAssDataTestMode = TModuleDataIn::EModuleTestModeAssDataOn_EarlyPosUpdates;
       
   167 							// Inform the test module of the required test mode - will block.
       
   168 							utils.NotifyModuleOfConfigChangeL(modDataIn);
       
   169 							}
       
   170 						
       
   171 						// Setup netsim.
       
   172 						User::LeaveIfError(OpenNetSim());
       
   173 						
       
   174 						// Request notify for the expected reference position.
       
   175 						TPositionInfo actualRefPosInfo;
       
   176 						
       
   177 						err = DoNotifyUpdateL(actualRefPosInfo);
       
   178 						if (err)
       
   179 							{
       
   180 							INFO_PRINTF2(_L("Failed test, reference position request returned err %d."), err);
       
   181 
       
   182 							SetTestStepResult(EFail);							
       
   183 							}
       
   184 							
       
   185 						// Verify reference position.
       
   186 						TPositionInfo verifyRefPosInfo;
       
   187 						
       
   188 						verifyRefPosInfo.SetPosition(iRefPos);
       
   189 						if (!utils.Compare_PosInfo(verifyRefPosInfo, actualRefPosInfo))
       
   190 							{
       
   191 							if(!iParent.iSharedData->iTestModuleInUse)
       
   192 								{
       
   193 								WARN_PRINTF1(_L("WARNING: position received was not reference position"));	
       
   194 								}
       
   195 							else
       
   196 								{	
       
   197 								INFO_PRINTF1(_L("Failed test, reference position incorrect."));
       
   198 								SetTestStepResult(EFail);
       
   199 								}
       
   200 							}
       
   201 						}
       
   202 
       
   203 
       
   204 					// Create a posinfo and store in our shared array for later verification.
       
   205 					RPointerArray<TAny>& posInfoArr = iParent.iSharedData->iCurrentPosInfoArr;
       
   206 					TPositionInfo* posInfo = new(ELeave) TPositionInfo();
       
   207 	
       
   208 					utils.ResetAndDestroy_PosInfoArr(posInfoArr);	// Clear previous entries before new entry is appended.
       
   209 
       
   210 					posInfoArr.Append(posInfo);
       
   211 	
       
   212 					// Get the actual position
       
   213 					err = DoNotifyUpdateL(*posInfo);
       
   214 					if (KErrNone != err)
       
   215 						{
       
   216 						SetTestStepResult(EFail);
       
   217 						}
       
   218 
       
   219 					// Cleanup.
       
   220 					CleanupStack::PopAndDestroy(&iPositioner);
       
   221 					if ((testCaseId == 101) || (testCaseId == 105))
       
   222 						{
       
   223 						CloseNetSim();
       
   224 						}
       
   225 				 
       
   226 					break;
       
   227 					}
       
   228 
       
   229 				
       
   230 				// Test case LBS-NotifyPosUpdate-0003		
       
   231 				case 3:
       
   232 					{
       
   233 					// Select the Network module because it does not support TPositionSatelliteInfo,
       
   234 					// then request position update and expect satellite info, which should return
       
   235 					// in KErrArgument.
       
   236 					TPositionModuleId	modId;
       
   237 					
       
   238 					T_LbsUtils utils;
       
   239 					modId = utils.GetNetworkModuleIdL(iServer);
       
   240 
       
   241 					// Select the network module.
       
   242 					User::LeaveIfError(iPositioner.Open(iServer, modId));
       
   243 					CleanupClosePushL(iPositioner);
       
   244 
       
   245 					// Try to get the actual position, using TPositionSatellite which is not
       
   246 					// supported by the selected module.
       
   247 					TPositionSatelliteInfo posInfo;
       
   248 					
       
   249 					err = DoNotifyUpdateL(posInfo);
       
   250 					if (KErrArgument == err)
       
   251 						{
       
   252 						INFO_PRINTF2(_L("correct err %d returned"), err);
       
   253 						}
       
   254 					else
       
   255 						{
       
   256 						INFO_PRINTF2(_L("incorrect err %d returned"), err);
       
   257 						SetTestStepResult(EFail);
       
   258 						}						
       
   259 					
       
   260 					CleanupStack::PopAndDestroy(&iPositioner);
       
   261 					break;
       
   262 					}
       
   263 					
       
   264 				// Test case LBS-NotifyPosUpdate-0005						
       
   265 				case 5:	
       
   266 					{
       
   267 				
       
   268 					CLbsAdmin::TSelfLocateService selflocate;
       
   269 					
       
   270 					
       
   271 					User::LeaveIfError(iLbsAdmin->Set(KLbsSettingHomeSelfLocate, CLbsAdmin::ESelfLocateOff));
       
   272 					User::LeaveIfError(iLbsAdmin->Get(KLbsSettingHomeSelfLocate, selflocate));
       
   273 					
       
   274 					if(selflocate != CLbsAdmin::ESelfLocateOff)
       
   275 						{
       
   276 						SetTestStepResult(EFail);
       
   277 						}
       
   278 					else
       
   279 						{
       
   280 						// Open positioner.
       
   281 						err = iPositioner.Open(iServer);
       
   282 						User::LeaveIfError(err);
       
   283 						CleanupClosePushL(iPositioner);
       
   284 
       
   285 						TPositionInfo notifyPosInfo;
       
   286 						err = DoNotifyUpdateL(notifyPosInfo);
       
   287 						if(KErrAccessDenied != err)
       
   288 							{
       
   289 							SetTestStepResult(EFail);
       
   290 							}
       
   291 						}
       
   292 					User::LeaveIfError(iLbsAdmin->Set(KLbsSettingHomeSelfLocate, CLbsAdmin::ESelfLocateOn));
       
   293 
       
   294 				    CleanupStack::PopAndDestroy(&iPositioner);
       
   295 	
       
   296 					}
       
   297 					break;
       
   298 				
       
   299 				// Test case LBS-NotifyPosUpdate-0006	
       
   300 				case 6:	
       
   301 					{
       
   302 					// Open positioner.
       
   303 					User::LeaveIfError(iPositioner.Open(iServer));
       
   304 					CleanupClosePushL(iPositioner);
       
   305 
       
   306 					TPositionInfo posInfoNotifyUpd;
       
   307 					
       
   308 					TRequestStatus status;
       
   309 					TBool cancelled;
       
   310 					
       
   311 					TempSetRequestorL();
       
   312 					iPositioner.NotifyPositionUpdate(posInfoNotifyUpd, status);
       
   313 					
       
   314 					TInt err = iPositioner.CancelRequest(EPositionerNotifyPositionUpdate);
       
   315 					
       
   316 					if(KErrNone == err)
       
   317 						{
       
   318 							cancelled = TRUE;
       
   319 						}
       
   320 					else
       
   321 						{
       
   322 							cancelled = FALSE;
       
   323 						}
       
   324 											
       
   325 					// this should complete with either KErrNone or KErrCancel
       
   326 					User::WaitForRequest(status);
       
   327 					
       
   328 					err = status.Int();
       
   329 					
       
   330 					if(cancelled)
       
   331 						{
       
   332 						if((KErrCancel != err) && (KErrNone != err))
       
   333 							{
       
   334 							SetTestStepResult(EFail); 
       
   335 							}
       
   336 						}
       
   337 					else
       
   338 						{
       
   339 						if(KErrNone != err)
       
   340 							{
       
   341 							SetTestStepResult(EFail);
       
   342 							}
       
   343 						}
       
   344 											
       
   345 					CleanupStack::PopAndDestroy(&iPositioner);					
       
   346 
       
   347 					}
       
   348 					break;
       
   349 					
       
   350 			  	// Test case LBS-NotifyPosUpdate-0007
       
   351 				case 7:
       
   352 					{
       
   353 					// Note: Not connecting to position server.
       
   354 					TPositionInfo notifyPosInfo;
       
   355 					TRequestStatus status;
       
   356 					
       
   357 					// should panic with EPositionServerBadHandle 
       
   358 					iPositioner.NotifyPositionUpdate(notifyPosInfo, status);
       
   359 					}
       
   360 					break;
       
   361 					
       
   362 				// Test case LBS-NotifyPosUpdate-0008
       
   363 				case 8:	
       
   364 					{
       
   365 					// Open positioner.
       
   366 					User::LeaveIfError(iPositioner.Open(iServer));
       
   367 					CleanupClosePushL(iPositioner);
       
   368 				
       
   369 					TPositionInfo notifyPosInfo, notifyPosInfo2;
       
   370 					TRequestStatus status, status2;
       
   371 					
       
   372 					TempSetRequestorL();
       
   373 					// attempt multiple NotifyPositionUpdates on same subsession:
       
   374 					iPositioner.NotifyPositionUpdate(notifyPosInfo, status);
       
   375 					
       
   376 					// expected to panic with EPositionDuplicateRequest:
       
   377 					iPositioner.NotifyPositionUpdate(notifyPosInfo2, status2);
       
   378 					
       
   379 					// need to block here so that loc server can run and recieve both
       
   380 					// requests - its the second request that causes the panic!
       
   381 					User::After(1);
       
   382 					// if we get here, we've failed to panic
       
   383 					SetTestStepResult(EFail);
       
   384 										
       
   385 					CleanupStack::PopAndDestroy(&iPositioner);					
       
   386 					}
       
   387 					break;						
       
   388 					
       
   389 				// Test case LBS-NotifyPosUpdate-0014	INCOMPLETE
       
   390 				case 14:
       
   391 					{
       
   392 					// Set 'autonomous' mode
       
   393 					CLbsAdmin::TGpsMode mode;
       
   394 					
       
   395 					User::LeaveIfError(iLbsAdmin->Set(KLbsSettingHomeGpsMode, CLbsAdmin::EGpsAutonomous));
       
   396 					User::LeaveIfError(iLbsAdmin->Get(KLbsSettingHomeGpsMode, mode));
       
   397 					
       
   398 					// TODO: figure out how to get notifications of assistance data requests (MLbsNetSimTestObserver?)
       
   399 					// If we get notification before Notify Update completes, then we fail
       
   400 					
       
   401 					if(mode != CLbsAdmin::EGpsAutonomous)
       
   402 						{
       
   403 						SetTestStepResult(EFail);
       
   404 						}
       
   405 					else	// Request a location update
       
   406 						{
       
   407 						// Open positioner.
       
   408 						User::LeaveIfError(iPositioner.Open(iServer));
       
   409 						CleanupClosePushL(iPositioner);
       
   410 				
       
   411 						// Create a posinfos and store in our shared array for later verification.
       
   412 						RPointerArray<TAny>& posInfoArr = iParent.iSharedData->iCurrentPosInfoArr;
       
   413 								
       
   414 						T_LbsUtils utils;
       
   415 						utils.ResetAndDestroy_PosInfoArr(posInfoArr);	// Clear previous entries before new entry is appended.
       
   416 						
       
   417 						TPositionInfo* posInfoNotifyUpd = new(ELeave) TPositionInfo();
       
   418 
       
   419 						posInfoArr.Append(posInfoNotifyUpd);
       
   420 						
       
   421 						err = DoNotifyUpdateL(*posInfoNotifyUpd);
       
   422 						if (KErrNone != err)
       
   423 							{
       
   424 							SetTestStepResult(EFail);
       
   425 							}
       
   426 							
       
   427 						CleanupStack::PopAndDestroy(&iPositioner);
       
   428 						}
       
   429 					
       
   430 					
       
   431 					}
       
   432 					break;
       
   433 
       
   434 				// Test case LBS-NotifyPosUpdate-0015	UNSUPPORTED
       
   435 				case 15:
       
   436 					{
       
   437 					// this test should not be run; lbs currently doesn't support AlwaysTerminalBased mode
       
   438 					__ASSERT_ALWAYS(FALSE, User::Panic(_L("LBS-NotifyPosUpdate-0015 should not be run"), KErrNotSupported));					
       
   439 					
       
   440 					// Set 'assisted-only' (EGpsAlwaysTerminalBased) mode
       
   441 					CLbsAdmin::TGpsMode mode;
       
   442 					
       
   443 					User::LeaveIfError(iLbsAdmin->Set(KLbsSettingHomeGpsMode, CLbsAdmin::EGpsAlwaysTerminalBased));
       
   444 					User::LeaveIfError(iLbsAdmin->Get(KLbsSettingHomeGpsMode, mode));
       
   445 					
       
   446 					// TODO: figure out how to get notifications of assistance data requests (MLbsNetSimTestObserver?)
       
   447 					// If we do not get notification before Notify Update completes, then we fail
       
   448 					
       
   449 					if(mode != CLbsAdmin::EGpsAlwaysTerminalBased)
       
   450 						{
       
   451 						SetTestStepResult(EFail);
       
   452 						}
       
   453 					else	// Request a location update
       
   454 						{
       
   455 						// Open positioner.
       
   456 						User::LeaveIfError(iPositioner.Open(iServer));
       
   457 						CleanupClosePushL(iPositioner);
       
   458 				
       
   459 						// Create a posinfos and store in our shared array for later verification.
       
   460 						RPointerArray<TAny>& posInfoArr = iParent.iSharedData->iCurrentPosInfoArr;
       
   461 								
       
   462 						T_LbsUtils utils;
       
   463 						utils.ResetAndDestroy_PosInfoArr(posInfoArr);	// Clear previous entries before new entry is appended.
       
   464 						
       
   465 						TPositionInfo* posInfoNotifyUpd = new(ELeave) TPositionInfo();
       
   466 
       
   467 						posInfoArr.Append(posInfoNotifyUpd);
       
   468 						
       
   469 						err = DoNotifyUpdateL(*posInfoNotifyUpd);	// can use this blocking version if netsim uses callbacks for assistance data notifications
       
   470 						// TODO iRequestedAssData needs to be set in assist data callback
       
   471 						if (KErrNone != err || !iRequestedAssData || !iReceivedAssData)
       
   472 							{
       
   473 							SetTestStepResult(EFail);
       
   474 							}
       
   475 							
       
   476 						// verify that preferred positioning mode was used:
       
   477 						if(EPositionModeReasonNone != posInfoNotifyUpd->PositionMode())
       
   478 							{
       
   479 							SetTestStepResult(EFail);
       
   480 							}
       
   481 						
       
   482 						CleanupStack::PopAndDestroy(&iPositioner);
       
   483 						}
       
   484 					}
       
   485 					break;
       
   486 					
       
   487 				// Test case LBS-NotifyPosUpdate-0016	INCOMPLETE
       
   488 				case 16:
       
   489 					{
       
   490 					// Set 'assisted-if-possible' (EGpsPreferTerminalBased) mode
       
   491 					CLbsAdmin::TGpsMode mode;
       
   492 					
       
   493 					User::LeaveIfError(iLbsAdmin->Set(KLbsSettingHomeGpsMode, CLbsAdmin::EGpsPreferTerminalBased));
       
   494 					User::LeaveIfError(iLbsAdmin->Get(KLbsSettingHomeGpsMode, mode));
       
   495 					
       
   496 					#pragma message("TO DO: LBS-NotifyPosUpdate-0016	INCOMPLETE")					
       
   497 					// figure out how to get notifications of assistance data requests (MLbsNetSimTestObserver?)
       
   498 					// If we do not get notification before Notify Update completes, then we fail
       
   499 					
       
   500 					// do we need to do something to make sure that we require assistancce data (no assistance data already retrieved)?
       
   501 					
       
   502 					// Configure NetSim to indciate that network is not available
       
   503 					
       
   504 					
       
   505 					if(mode != CLbsAdmin::EGpsPreferTerminalBased)
       
   506 						{
       
   507 						SetTestStepResult(EFail);
       
   508 						}
       
   509 					else	// Request a location update
       
   510 						{
       
   511 						// Open positioner.
       
   512 						User::LeaveIfError(iPositioner.Open(iServer));
       
   513 						CleanupClosePushL(iPositioner);
       
   514 				
       
   515 						// Create a posinfos and store in our shared array for later verification.
       
   516 						RPointerArray<TAny>& posInfoArr = iParent.iSharedData->iCurrentPosInfoArr;
       
   517 								
       
   518 						T_LbsUtils utils;
       
   519 						utils.ResetAndDestroy_PosInfoArr(posInfoArr);	// Clear previous entries before new entry is appended.
       
   520 						
       
   521 						TPositionInfo* posInfoNotifyUpd = new(ELeave) TPositionInfo();
       
   522 
       
   523 						posInfoArr.Append(posInfoNotifyUpd);
       
   524 						
       
   525 						err = DoNotifyUpdateL(*posInfoNotifyUpd);	// can use this blocking version if netsim uses callbacks for assistance data notifications
       
   526 						if (KErrNone != err || !iRequestedAssData)
       
   527 							{
       
   528 							SetTestStepResult(EFail);
       
   529 							}
       
   530 							
       
   531 						// verify that preferred positioning mode was not used:
       
   532 						if(EPositionModeReasonNetworkError != posInfoNotifyUpd->PositionMode())
       
   533 							{
       
   534 							SetTestStepResult(EFail);
       
   535 							}
       
   536 						
       
   537 						CleanupStack::PopAndDestroy(&iPositioner);
       
   538 						}
       
   539 					}
       
   540 					break;
       
   541 					
       
   542 				// Test case LBS-NotifyPosUpdate-0017	UNSUPPORTED
       
   543 				case 17:
       
   544 					{
       
   545 					// this test should not be run; lbs currently doesn't support AlwaysTerminalBased mode
       
   546 					__ASSERT_ALWAYS(FALSE, User::Panic(_L("LBS-NotifyPosUpdate-0017 should not be run"), KErrNotSupported));
       
   547 										
       
   548 					// Set 'assisted-only' (EGpsAlwaysTerminalBased) mode
       
   549 					CLbsAdmin::TGpsMode mode;
       
   550 					
       
   551 					User::LeaveIfError(iLbsAdmin->Set(KLbsSettingHomeGpsMode, CLbsAdmin::EGpsAlwaysTerminalBased));
       
   552 					User::LeaveIfError(iLbsAdmin->Get(KLbsSettingHomeGpsMode, mode));					
       
   553 					
       
   554 					// Configure NetSim to indciate that network is not available
       
   555 					
       
   556 					
       
   557 					if(mode != CLbsAdmin::EGpsAlwaysTerminalBased)
       
   558 						{
       
   559 						SetTestStepResult(EFail);
       
   560 						}
       
   561 					else	// Request a location update
       
   562 						{
       
   563 						// Open positioner.
       
   564 						User::LeaveIfError(iPositioner.Open(iServer));
       
   565 						CleanupClosePushL(iPositioner);
       
   566 										
       
   567 						TPositionInfo posInfoNotifyUpd;
       
   568 						
       
   569 						err = DoNotifyUpdateL(posInfoNotifyUpd);	// can use this blocking version if netsim uses callbacks for assistance data notifications
       
   570 						if (KErrPositionMethodFailure != err)
       
   571 							{
       
   572 							SetTestStepResult(EFail);
       
   573 							}
       
   574 						
       
   575 						CleanupStack::PopAndDestroy(&iPositioner);
       
   576 						}
       
   577 					}
       
   578 					break;
       
   579 					
       
   580 				// Test case LBS-NotifyPosUpdate-0018	INCOMPLETE
       
   581 				case 18:
       
   582 					{
       
   583 					#pragma message("TO DO: LBS-NotifyPosUpdate-0018	INCOMPLETE")
       
   584 					// Set 'assisted-if-possible' (EGpsPreferTerminalBased) mode
       
   585 					CLbsAdmin::TGpsMode mode;
       
   586 					
       
   587 					User::LeaveIfError(iLbsAdmin->Set(KLbsSettingHomeGpsMode, CLbsAdmin::EGpsPreferTerminalBased));
       
   588 					User::LeaveIfError(iLbsAdmin->Get(KLbsSettingHomeGpsMode, mode));
       
   589 					
       
   590 					// TODO: figure out how to get notifications of assistance data requests (MLbsNetSimTestObserver?)
       
   591 					// If we do not get notification before Notify Update completes, then we fail
       
   592 					
       
   593 					// TODO: do we need to do something to make sure that we require assistancce data (no assistance data already retrieved)?
       
   594 					
       
   595 					// TODO Configure NetSim to return bad/no assistance data
       
   596 					// this may involve writing an assistance data plugin to provide bad data!?
       
   597 					
       
   598 					if(mode != CLbsAdmin::EGpsPreferTerminalBased)
       
   599 						{
       
   600 						SetTestStepResult(EFail);
       
   601 						}
       
   602 					else	// Request a location update
       
   603 						{
       
   604 						// Open positioner.
       
   605 						User::LeaveIfError(iPositioner.Open(iServer));
       
   606 						CleanupClosePushL(iPositioner);
       
   607 				
       
   608 						// Create a posinfos and store in our shared array for later verification.
       
   609 						RPointerArray<TAny>& posInfoArr = iParent.iSharedData->iCurrentPosInfoArr;
       
   610 								
       
   611 						T_LbsUtils utils;
       
   612 						utils.ResetAndDestroy_PosInfoArr(posInfoArr);	// Clear previous entries before new entry is appended.
       
   613 						
       
   614 						TPositionInfo* posInfoNotifyUpd = new(ELeave) TPositionInfo();
       
   615 
       
   616 						posInfoArr.Append(posInfoNotifyUpd);
       
   617 						
       
   618 						err = DoNotifyUpdateL(*posInfoNotifyUpd);	// can use this blocking version if netsim uses callbacks for assistance data notifications
       
   619 						if (KErrNone != err || !iRequestedAssData)
       
   620 							{
       
   621 							SetTestStepResult(EFail);
       
   622 							}
       
   623 							
       
   624 						// verify that preferred positioning mode was not used and appropriate reason given:
       
   625 						if(EPositionModeReasonDataError != posInfoNotifyUpd->PositionMode())
       
   626 							{
       
   627 							SetTestStepResult(EFail);
       
   628 							}
       
   629 						
       
   630 						CleanupStack::PopAndDestroy(&iPositioner);
       
   631 						}
       
   632 					}
       
   633 					break;
       
   634 
       
   635 				// Test case LBS-NotifyPosUpdate-0019
       
   636 				case 19:
       
   637 					{
       
   638 					// Open positioner.
       
   639 					User::LeaveIfError(iPositioner.Open(iServer));
       
   640 					CleanupClosePushL(iPositioner);
       
   641 			
       
   642 					// Create a posinfos and store in our shared array for later verification.
       
   643 					RPointerArray<TAny>& posInfoArr = iParent.iSharedData->iCurrentPosInfoArr;
       
   644 							
       
   645 					T_LbsUtils utils;
       
   646 					utils.ResetAndDestroy_PosInfoArr(posInfoArr);	// Clear previous entries before new entry is appended.
       
   647 					
       
   648 					TInt numPositions = iParent.iSharedData->iVerifyPosInfoArr.Count();
       
   649 					while(numPositions--)
       
   650 						{
       
   651 						TPositionInfo* posInfoNotifyUpd = new(ELeave) TPositionInfo();
       
   652 
       
   653 						posInfoArr.Append(posInfoNotifyUpd);
       
   654 						
       
   655 						User::After(500*1000); 	// on Winscw all the target time requests
       
   656 												// can get stamped with exactly the same
       
   657 												// time and thus all three requests may be
       
   658 												// satified from the one the bus
       
   659 												// then the test fails! This behaviour is OK but 
       
   660 												// not what the test is trying to test for . Hence ensure
       
   661 												// all three target times are different by the delay
       
   662 
       
   663 						err = DoNotifyUpdateL(*posInfoNotifyUpd);
       
   664 						if (KErrNone != err)
       
   665 							{
       
   666 							SetTestStepResult(EFail);
       
   667 							}
       
   668 						}
       
   669 	
       
   670 					// Cleanup.
       
   671 					CleanupStack::PopAndDestroy(&iPositioner);
       
   672 					}
       
   673 					break;									
       
   674 
       
   675 			    // Test case LBS-NotifyPosUpdate-0022	
       
   676 			    case 22:
       
   677 					{
       
   678 					TInt profileid_ini,maxtime_ini;
       
   679 			        TBool profileid_exists,maxtime_exists;
       
   680 			        profileid_exists = GetIntFromConfig(ConfigSection(), KLbsProfileId, profileid_ini);
       
   681 		            if(!profileid_exists)
       
   682 						{
       
   683 						INFO_PRINTF1(_L("Could not get profileid from ini file"));
       
   684 			    		SetTestStepResult(EFail);
       
   685 			    		}
       
   686 					
       
   687 			    	maxtime_exists = GetIntFromConfig(ConfigSection(), KLbsMaxTime, maxtime_ini);
       
   688 		            if(!maxtime_exists)
       
   689 						{
       
   690 						INFO_PRINTF1(_L("Could not get maxtime from ini file"));
       
   691 			    		SetTestStepResult(EFail);
       
   692 			    		}
       
   693 										
       
   694 					TLbsQualityProfileId profileId;
       
   695 					//Set SelfLocate quality profile & valid id(which is exist in lbsprofile.ini)
       
   696 					User::LeaveIfError(iLbsAdmin->Set(KLbsSettingQualityProfileSelfLocate, TLbsQualityProfileId(profileid_ini)));
       
   697 					// Verify that the setting is what we expect
       
   698 					User::LeaveIfError(iLbsAdmin->Get(KLbsSettingQualityProfileSelfLocate, profileId));
       
   699 					if(profileId != TLbsQualityProfileId(profileid_ini))
       
   700 						{
       
   701 						SetTestStepResult(EFail);
       
   702 						}
       
   703 					else	// Request a location update
       
   704 						{
       
   705 						// Open positioner.
       
   706 						User::LeaveIfError(iPositioner.Open(iServer));
       
   707 						CleanupClosePushL(iPositioner);
       
   708 				
       
   709 						// Create a posinfos and store in our shared array for later verification.
       
   710 						RPointerArray<TAny>& posInfoArr = iParent.iSharedData->iCurrentPosInfoArr;
       
   711 								
       
   712 						T_LbsUtils utils;
       
   713 						utils.ResetAndDestroy_PosInfoArr(posInfoArr);	// Clear previous entries before new entry is appended.
       
   714 						
       
   715 						TPositionInfo* posInfoNotifyUpd = new(ELeave) TPositionInfo();
       
   716 						posInfoArr.Append(posInfoNotifyUpd);
       
   717                         
       
   718                         TTime timeRequested,timeReceived;
       
   719                                                
       
   720                         // Position requested at
       
   721 						timeRequested.UniversalTime();
       
   722                                                                       
       
   723                         //Do request position update
       
   724                         err = DoNotifyUpdateL(*posInfoNotifyUpd);
       
   725 						if ((KErrNone != err) && (KPositionQualityLoss != err))
       
   726 							{
       
   727 							INFO_PRINTF2(_L("NotifyUpdate failed with %d "), err);	
       
   728 							SetTestStepResult(EFail);
       
   729 							}
       
   730                         //Need to verify MaxTime 
       
   731                         else						
       
   732 					     {
       
   733 					     // Check we dont have a final network postion
       
   734 					     if (posInfoNotifyUpd->PositionMode() & TPositionModuleInfo::ETechnologyNetwork)
       
   735 					     	{
       
   736 					     	INFO_PRINTF1(_L("Failed: Recieved a final network postion"));
       
   737 					     	SetTestStepResult(EFail);
       
   738 					     	}
       
   739 					     
       
   740 					     TPosition pos;
       
   741 						 posInfoNotifyUpd->GetPosition(pos);
       
   742 						 //Position received at
       
   743 						 timeReceived = pos.Time();
       
   744 					     
       
   745 					     //Timedifference between position actually received and position actually requested
       
   746 					     TInt64 timediff;
       
   747 	                     timediff = timeReceived.Int64() - timeRequested.Int64();
       
   748 	                	 //compare timediff with maxtime 
       
   749 						 if(timediff > maxtime_ini)
       
   750 							{
       
   751 							INFO_PRINTF1(_L("Failed: Position received outside time range"));
       
   752 							SetTestStepResult(EFail);									
       
   753 						    }
       
   754 					     					     
       
   755 					    }
       
   756 						
       
   757 						CleanupStack::PopAndDestroy(&iPositioner);
       
   758 						}
       
   759 					}
       
   760 					break;
       
   761 					
       
   762 				// Test case LBS-NotifyPosUpdate-0024						
       
   763 				case 24: 					
       
   764 				// Test case LBS-NotifyPosUpdate-0025
       
   765 				case 25:
       
   766 					{
       
   767 				    TInt profileid_ini;
       
   768 			        TBool profileid_exists;
       
   769 			        profileid_exists = GetIntFromConfig(ConfigSection(), KLbsProfileId, profileid_ini);
       
   770 		            if(!profileid_exists)
       
   771 						{
       
   772 						INFO_PRINTF1(_L("Could not get profileid from section"));
       
   773 			    		SetTestStepResult(EFail);
       
   774 			    		}
       
   775 										
       
   776 					TLbsQualityProfileId profileId;
       
   777 					//Set SelfLocate quality profile & valid id(which is exist in lbsprofile.ini) 
       
   778 					User::LeaveIfError(iLbsAdmin->Set(KLbsSettingQualityProfileSelfLocate, TLbsQualityProfileId(profileid_ini)));
       
   779 					// Verify that the setting is what we expect
       
   780 					User::LeaveIfError(iLbsAdmin->Get(KLbsSettingQualityProfileSelfLocate, profileId));
       
   781 					if(profileId != TLbsQualityProfileId(profileid_ini))
       
   782 						{
       
   783 						SetTestStepResult(EFail);
       
   784 						}
       
   785 					else	// Request a location update
       
   786 						{
       
   787 						if(testCaseId==24) 
       
   788 						   {
       
   789 							//makes test module timeout
       
   790 							if (iParent.iSharedData->iTestModuleInUse)
       
   791 								{
       
   792 								T_LbsUtils utils;
       
   793 								TModuleDataIn modDataIn;
       
   794 
       
   795 								modDataIn.iRequestType = TModuleDataIn::EModuleRequestTimeOut;
       
   796 								modDataIn.iTimeOut = KModuleTimeout;
       
   797 							
       
   798 								utils.NotifyModuleOfConfigChangeL(modDataIn);	// This will block.
       
   799 								}
       
   800 						   }
       
   801 						// Open positioner.
       
   802 						User::LeaveIfError(iPositioner.Open(iServer));
       
   803 						CleanupClosePushL(iPositioner);
       
   804 				
       
   805 						TPositionInfo posInfoNotifyUpd;
       
   806 						//Do request to position update
       
   807                         err = DoNotifyUpdateL(posInfoNotifyUpd);
       
   808 				        //Position received at
       
   809 						
       
   810 						if (testCaseId == 24)
       
   811 							{
       
   812 							if (err != KErrTimedOut)
       
   813 								{
       
   814 								INFO_PRINTF1(_L("<FONT><B>position update not failed with error -33</B></FONT>"));
       
   815 								SetTestStepResult(EFail);
       
   816 								}
       
   817 
       
   818 							}
       
   819 						else
       
   820 							{
       
   821 							if (err != KPositionQualityLoss)
       
   822 								SetTestStepResult(EFail);
       
   823 							}				
       
   824 					    											
       
   825 						CleanupStack::PopAndDestroy(&iPositioner);
       
   826 						}
       
   827 					}
       
   828 					break;
       
   829 
       
   830 				// Test case LBS-NotifyPosUpdate-0027
       
   831 				case 27:
       
   832 				// Test case LBS-NotifyPosUpdate-0028
       
   833 				case 28:
       
   834 					{
       
   835 					TInt profileid_ini;
       
   836 			        TBool profileid_exists;
       
   837 			        TPositionUpdateOptions options;
       
   838 					T_LbsUtils utils;
       
   839 
       
   840 					profileid_exists = GetIntFromConfig(ConfigSection(), KLbsProfileId, profileid_ini);
       
   841 		            if(!profileid_exists)
       
   842 						{
       
   843 						INFO_PRINTF1(_L("Could not get profileid from ini file"));
       
   844 			    		SetTestStepResult(EFail);
       
   845 			    		}
       
   846 					
       
   847 					//Set SelfLocate quality profile & valid id(which is exist in lbsprofile.ini)
       
   848 					User::LeaveIfError(iLbsAdmin->Set(KLbsSettingQualityProfileSelfLocate, TLbsQualityProfileId(profileid_ini)));
       
   849 
       
   850 					if(testCaseId==28) 
       
   851 					   {
       
   852 						//makes test module timeout
       
   853 						const TTimeIntervalMicroSeconds KModuleTimeout = 60000000; // 1 minute
       
   854 						if (iParent.iSharedData->iTestModuleInUse)
       
   855 							{
       
   856 							T_LbsUtils utils;
       
   857 							TModuleDataIn modDataIn;
       
   858 
       
   859 							modDataIn.iRequestType = TModuleDataIn::EModuleRequestTimeOut;
       
   860 							modDataIn.iTimeOut = KModuleTimeout;
       
   861 								
       
   862 							utils.NotifyModuleOfConfigChangeL(modDataIn);	// This will block.
       
   863 							}
       
   864 					   }
       
   865 					// Open positioner.
       
   866 					User::LeaveIfError(iPositioner.Open(iServer));
       
   867 					CleanupClosePushL(iPositioner);
       
   868 			
       
   869 					// Create a posinfos and store in our shared array for later verification.
       
   870 					RPointerArray<TAny>& posInfoArr = iParent.iSharedData->iCurrentPosInfoArr;
       
   871 					utils.ResetAndDestroy_PosInfoArr(posInfoArr);	// Clear previous entries before new entry is appended.
       
   872 
       
   873 					TPositionInfo* posInfoUpd = new(ELeave) TPositionInfo();
       
   874 					posInfoArr.Append(posInfoUpd);
       
   875 					
       
   876 					
       
   877  					options.SetUpdateInterval(0);
       
   878  					const TTimeIntervalMicroSeconds KMaxFix = 30000000; // 30s
       
   879 					options.SetUpdateTimeOut(KMaxFix); 					
       
   880  					iPositioner.SetUpdateOptions(options);
       
   881 	
       
   882 					err = DoNotifyUpdateL(*posInfoUpd);
       
   883 					
       
   884 					if (testCaseId == 27)
       
   885 						{
       
   886 						if (err != KPositionQualityLoss)
       
   887 							SetTestStepResult(EFail);
       
   888 						}
       
   889 					else
       
   890 						{
       
   891 						if (err != KErrTimedOut)
       
   892 							SetTestStepResult(EFail);
       
   893 						}				
       
   894 					// Cleanup.
       
   895 					CleanupStack::PopAndDestroy(&iPositioner);
       
   896 					}
       
   897 					break;									
       
   898 				
       
   899 				case 26:
       
   900 					{
       
   901 					//Set up a 15 second interval between updates, with a 5 second timeout
       
   902 					TPositionUpdateOptions posUpdateOpts(15000000, 5000000, 0, EFalse);
       
   903 
       
   904 					// Open positioner.											    
       
   905 					err = iPositioner.Open(iServer);
       
   906 					User::LeaveIfError(err);
       
   907 					if(err != KErrNone)
       
   908 						{
       
   909 						INFO_PRINTF1(_L("** SubSession Failed to open **"));
       
   910 						SetTestStepResult(EFail);	
       
   911 						}
       
   912 					CleanupClosePushL(iPositioner);
       
   913 
       
   914 					TPositionInfo* posInfo = new(ELeave) TPositionInfo();
       
   915 					CleanupStack::PushL(posInfo);
       
   916 
       
   917 					iPositioner.SetUpdateOptions(posUpdateOpts);	
       
   918 					User::LeaveIfError(iPositioner.SetRequestor(	CRequestor::ERequestorService,
       
   919 																CRequestor::EFormatApplication,
       
   920 																_L("Tom Tom")));
       
   921 					TRequestStatus status;		
       
   922 																			
       
   923 					//Ask for a position update (should get this one)
       
   924 					iPositioner.NotifyPositionUpdate(*posInfo,status);
       
   925 
       
   926 					User::WaitForRequest(status);						 	
       
   927 					if(status != KErrNone)
       
   928 						{
       
   929 						INFO_PRINTF2(_L("Failed test, expected KErrNone, request finished with err %d."), status.Int());
       
   930 						SetTestStepResult(EFail);
       
   931 						}			   
       
   932 
       
   933 const TTimeIntervalMicroSeconds KModuleTimeout = 60000000; // 1 minute
       
   934 const TTimeIntervalMicroSeconds KModuleNoTimeout = 0; 
       
   935 					// Set a delay in the test AGPS manager big enough to guarantee 
       
   936 					// we won't get a response to the next one
       
   937 					if (iParent.iSharedData->iTestModuleInUse)
       
   938 						{
       
   939 						T_LbsUtils utils;
       
   940 						TModuleDataIn modDataIn;
       
   941 
       
   942 						modDataIn.iRequestType = TModuleDataIn::EModuleRequestTimeOut;
       
   943 						modDataIn.iTimeOut = KModuleTimeout;
       
   944 							
       
   945 						utils.NotifyModuleOfConfigChangeL(modDataIn);	// This will block.
       
   946 						}
       
   947 
       
   948 					// Try again. Shouldn't get a response this time as it times out.
       
   949 					iPositioner.NotifyPositionUpdate(*posInfo,status);
       
   950 
       
   951 					User::WaitForRequest(status);	
       
   952 					if(status != KErrTimedOut)
       
   953 						{
       
   954 						INFO_PRINTF2(_L("Failed test, expected KErrTimedOut, request finished with err %d."), status.Int());
       
   955 						SetTestStepResult(EFail);
       
   956 						}			   
       
   957 
       
   958 					// Get rid of the AGPS manager delay.
       
   959 					if (iParent.iSharedData->iTestModuleInUse)
       
   960 						{
       
   961 						T_LbsUtils utils;
       
   962 						TModuleDataIn modDataIn;
       
   963 
       
   964 						modDataIn.iRequestType = TModuleDataIn::EModuleRequestTimeOut;
       
   965 						modDataIn.iTimeOut = KModuleNoTimeout;
       
   966 							
       
   967 						utils.NotifyModuleOfConfigChangeL(modDataIn);	// This will block.
       
   968 						}
       
   969 	
       
   970 					//Ask for a position update (should get this one again)
       
   971 					iPositioner.NotifyPositionUpdate(*posInfo,status);
       
   972 
       
   973 					User::WaitForRequest(status);						 	
       
   974 					if(status != KErrNone)
       
   975 						{
       
   976 						INFO_PRINTF2(_L("Failed test, expected KErrNone, request finished with err %d."), status.Int());
       
   977 						SetTestStepResult(EFail);
       
   978 						}			   
       
   979 						
       
   980 					iPositioner.Close();
       
   981 
       
   982 					CleanupStack::PopAndDestroy(posInfo);
       
   983 					CleanupStack::PopAndDestroy(&iPositioner);
       
   984 					} // case 26
       
   985 				break;
       
   986 				 // Test case LBS-NotifyPosUpdate-0122	
       
   987 			    case 122:
       
   988 					{
       
   989 					const TLbsQualityProfileId KLbsTest0122QualityProfileId = 5;
       
   990 					TLbsQualityProfileId profileId122(KLbsTest0122QualityProfileId);
       
   991 					TLbsQualityProfileId oldProfileId(9);
       
   992     				iLbsAdmin->Get(KLbsSettingQualityProfileSelfLocate, oldProfileId);
       
   993 	
       
   994     				iLbsAdmin->Set(KLbsSettingQualityProfileSelfLocate, profileId122);
       
   995     				
       
   996     				iLbsAdmin->Get(KLbsSettingQualityProfileSelfLocate, profileId122);
       
   997 					if (profileId122 != KLbsTest0122QualityProfileId)
       
   998 						{
       
   999 						INFO_PRINTF2(_L("Fail test: profile should be 5 but its %d."), profileId122);
       
  1000 						SetTestStepResult(EFail);
       
  1001 						}
       
  1002 					
       
  1003 					// the profile.ini file contains a MaxTime= 2147483647
       
  1004 					CT_LbsClientNotifyPosUpdAO* notifyPosUpdateAO;
       
  1005 					// Open positioner.
       
  1006 					User::LeaveIfError(iPositioner.Open(iServer));
       
  1007 					CleanupClosePushL(iPositioner);
       
  1008 
       
  1009 					// Create a posinfo and store in our shared array for later verification.
       
  1010 					RPointerArray<TAny>& posInfoArr = iParent.iSharedData->iCurrentPosInfoArr;
       
  1011 					TPositionInfo* posInfoNotifyUpd = new(ELeave) TPositionInfo();
       
  1012 							
       
  1013 					T_LbsUtils utils;
       
  1014 					utils.ResetAndDestroy_PosInfoArr(posInfoArr);	// Clear previous entries before new entry is appended.
       
  1015 
       
  1016 					// this gets deleted by the base class destructor:
       
  1017 					posInfoArr.Append(posInfoNotifyUpd);
       
  1018 					
       
  1019 					TModuleDataIn modDataIn;
       
  1020 
       
  1021 					modDataIn.iRequestType = TModuleDataIn::EModuleRequestTimeOut;
       
  1022 					modDataIn.iTimeOut = KModuleTimeout;
       
  1023 						
       
  1024 					utils.NotifyModuleOfConfigChangeL(modDataIn);	// This will block.
       
  1025 			
       
  1026 					// Start NotifyPositionUpdate request:
       
  1027 					notifyPosUpdateAO = CT_LbsClientNotifyPosUpdAO::NewL(*this);
       
  1028 					
       
  1029 					notifyPosUpdateAO->NotifyPosUpdateL(iPositioner, *posInfoNotifyUpd);
       
  1030 			//		User::After(3*1000*1000);
       
  1031 		
       
  1032 					
       
  1033 					TInt err;
       
  1034 					err = iPositioner.CancelRequest(EPositionerNotifyPositionUpdate);
       
  1035 					if(KErrNone != err)
       
  1036 						{
       
  1037 						SetTestStepResult(EFail);
       
  1038 						}
       
  1039 						
       
  1040 					// can start the scheduler now as there are async requests issued
       
  1041 					CActiveScheduler::Start();
       
  1042 						
       
  1043 					CleanupStack::PopAndDestroy(&iPositioner);	
       
  1044 					
       
  1045 	 				iLbsAdmin->Set(KLbsSettingQualityProfileSelfLocate, oldProfileId);
       
  1046   
       
  1047 				
       
  1048 					}
       
  1049 					break;
       
  1050 						
       
  1051  				// Test that the final network position is not passed on to the client if they
       
  1052  				// switch to autonomous mode mid-way through a session.
       
  1053  				case 1001:
       
  1054  					{
       
  1055  					// Set preferred TB mode
       
  1056  					// Set 'assisted-if-possible' (EGpsPreferTerminalBased) mode
       
  1057  					CLbsAdmin::TGpsMode mode;
       
  1058  					
       
  1059  					User::LeaveIfError(iLbsAdmin->Set(KLbsSettingHomeGpsMode, CLbsAdmin::EGpsPreferTerminalBased));
       
  1060  					User::LeaveIfError(iLbsAdmin->Get(KLbsSettingHomeGpsMode, mode));
       
  1061  					
       
  1062  					if(mode != CLbsAdmin::EGpsPreferTerminalBased)
       
  1063  						{
       
  1064  						SetTestStepResult(EFail);
       
  1065  						}
       
  1066  					else	// Request a location update
       
  1067  						{
       
  1068  
       
  1069  						// Open positioner.
       
  1070  						User::LeaveIfError(iPositioner.Open(iServer));
       
  1071  
       
  1072  						const TTimeIntervalMicroSeconds KMicroSecondsValue(60*1000*1000);
       
  1073  						TPositionUpdateOptions posOption;
       
  1074  						posOption.SetUpdateTimeOut(KMicroSecondsValue);
       
  1075  						User::LeaveIfError(iPositioner.SetUpdateOptions(posOption));
       
  1076  
       
  1077  						CleanupClosePushL(iPositioner);
       
  1078  
       
  1079  						// Create a posinfos and store in our shared array for later verification.
       
  1080  						RPointerArray<TAny>& posInfoArr = iParent.iSharedData->iCurrentPosInfoArr;
       
  1081  								
       
  1082  						T_LbsUtils utils;
       
  1083  						utils.ResetAndDestroy_PosInfoArr(posInfoArr);	// Clear previous entries before new entry is appended.
       
  1084  						
       
  1085  						// Setup netsim.
       
  1086  						User::LeaveIfError(OpenNetSim());
       
  1087  						TLbsNetPosRequestQuality quality;
       
  1088  						quality.SetMinHorizontalAccuracy(200);
       
  1089  						quality.SetMinVerticalAccuracy(20000);
       
  1090  						iNetSim.SetQuality(quality);
       
  1091  						
       
  1092  						TPositionInfo* posInfoNotifyUpd = new(ELeave) TPositionInfo();
       
  1093  
       
  1094  						posInfoArr.Append(posInfoNotifyUpd);
       
  1095  						
       
  1096  						// Send the first NPUD & block on response
       
  1097  						err = DoNotifyUpdateL(*posInfoNotifyUpd);
       
  1098  						if (KErrNone != err)
       
  1099  							{
       
  1100  							SetTestStepResult(EFail);
       
  1101  							}
       
  1102  							
       
  1103  						// Set autonomous mode
       
  1104  						CLbsAdmin::TGpsMode mode;
       
  1105  						
       
  1106  						User::LeaveIfError(iLbsAdmin->Set(KLbsSettingHomeGpsMode, CLbsAdmin::EGpsAutonomous));
       
  1107  						User::LeaveIfError(iLbsAdmin->Get(KLbsSettingHomeGpsMode, mode));
       
  1108  						
       
  1109  						if(mode != CLbsAdmin::EGpsAutonomous)
       
  1110  							{
       
  1111  							SetTestStepResult(EFail);
       
  1112  							}
       
  1113  						else	// Request a location update
       
  1114  							{
       
  1115  							//TPositionModuleInfo::TTechnologyType techType;
       
  1116  
       
  1117  							// Send the second NPUD & block on response
       
  1118  							err = DoNotifyUpdateL(*posInfoNotifyUpd);
       
  1119  							
       
  1120  							// This should not give a final network position response
       
  1121  							//techType = posInfoNotifyUpd->PositionMode();
       
  1122  							
       
  1123  							if(err != KPositionQualityLoss)
       
  1124  								{							
       
  1125  								SetTestStepResult(EFail);
       
  1126  								}
       
  1127  							}
       
  1128  							
       
  1129  						CleanupStack::PopAndDestroy(&iPositioner);
       
  1130  						CloseNetSim();
       
  1131  						}
       
  1132  
       
  1133  					break;
       
  1134  					}						
       
  1135 								
       
  1136 				// Test that the final network position is not passed on to the client if they
       
  1137 				// switch to autonomous mode mid-way through a session.
       
  1138 				case 1002:
       
  1139 					{
       
  1140 					// Set preferred TB mode
       
  1141 					// Set 'assisted-if-possible' (EGpsPreferTerminalBased) mode
       
  1142 					CLbsAdmin::TGpsMode mode;
       
  1143 					
       
  1144 					User::LeaveIfError(iLbsAdmin->Set(KLbsSettingHomeGpsMode, CLbsAdmin::EGpsPreferTerminalBased));
       
  1145 					User::LeaveIfError(iLbsAdmin->Get(KLbsSettingHomeGpsMode, mode));
       
  1146 					
       
  1147 					if(mode != CLbsAdmin::EGpsPreferTerminalBased)
       
  1148 						{
       
  1149 						SetTestStepResult(EFail);
       
  1150 						}
       
  1151 					else	// Request a location update
       
  1152 						{
       
  1153 
       
  1154 						// Open positioner.
       
  1155 						User::LeaveIfError(iPositioner.Open(iServer));
       
  1156 
       
  1157 						const TTimeIntervalMicroSeconds KMicroSecondsValue(60*1000*1000);
       
  1158 						TPositionUpdateOptions posOption;
       
  1159 						posOption.SetUpdateTimeOut(KMicroSecondsValue);
       
  1160 						User::LeaveIfError(iPositioner.SetUpdateOptions(posOption));
       
  1161 
       
  1162 						CleanupClosePushL(iPositioner);
       
  1163 
       
  1164 						// Create a posinfos and store in our shared array for later verification.
       
  1165 						RPointerArray<TAny>& posInfoArr = iParent.iSharedData->iCurrentPosInfoArr;
       
  1166 								
       
  1167 						T_LbsUtils utils;
       
  1168 						utils.ResetAndDestroy_PosInfoArr(posInfoArr);	// Clear previous entries before new entry is appended.
       
  1169 						
       
  1170 						// Setup netsim.
       
  1171 						User::LeaveIfError(OpenNetSim());
       
  1172 						TLbsNetPosRequestQuality quality;
       
  1173 						quality.SetMinHorizontalAccuracy(200);
       
  1174 						quality.SetMinVerticalAccuracy(20000);
       
  1175 						iNetSim.SetQuality(quality);
       
  1176 						
       
  1177 						TPositionInfo* posInfoNotifyUpd = new(ELeave) TPositionInfo();
       
  1178 
       
  1179 						posInfoArr.Append(posInfoNotifyUpd);
       
  1180 						
       
  1181 						// Send the first NPUD & block on response
       
  1182 						err = DoNotifyUpdateL(*posInfoNotifyUpd);
       
  1183 						if (KErrNone != err)
       
  1184 							{
       
  1185 							SetTestStepResult(EFail);
       
  1186 							}
       
  1187 							
       
  1188 						TPositionModuleInfo::TTechnologyType techType;
       
  1189 						
       
  1190 						// Wait for 10 seconds to allow the FNP to come in then send the next NPUD
       
  1191 						User::After(10*1000*1000);
       
  1192 
       
  1193 						// Send the second NPUD & block on response
       
  1194 						err = DoNotifyUpdateL(*posInfoNotifyUpd);
       
  1195 						
       
  1196 						// This should give a final network position response
       
  1197 						techType = posInfoNotifyUpd->PositionMode();
       
  1198 						
       
  1199 						if(techType != (TPositionModuleInfo::ETechnologyNetwork | 
       
  1200 										TPositionModuleInfo::ETechnologyAssisted))
       
  1201 							{							
       
  1202 							INFO_PRINTF1(_L("Failed test, did not get a final network position."));
       
  1203 							SetTestStepResult(EFail);
       
  1204 							}
       
  1205 							
       
  1206 						CleanupStack::PopAndDestroy(&iPositioner);
       
  1207 						CloseNetSim();
       
  1208 						}
       
  1209 
       
  1210 					break;
       
  1211 					}
       
  1212 				
       
  1213 				//Tests within SetUpdateOptions test to ensure that the correct Location Position
       
  1214 				// is retured from the cache on a second NPUD (with correct MaxAge set).  This test
       
  1215 				// tests to make sure that if the last position to arrive was a reference position
       
  1216 				// that the reference position is returned
       
  1217 				case 1003:
       
  1218 					{
       
  1219 					//Setup in the TB mode
       
  1220 					CLbsAdmin::TGpsMode mode;
       
  1221 					
       
  1222 					User::LeaveIfError(iLbsAdmin->Set(KLbsSettingHomeGpsMode, CLbsAdmin::EGpsPreferTerminalBased));
       
  1223 					User::LeaveIfError(iLbsAdmin->Get(KLbsSettingHomeGpsMode, mode));
       
  1224 					
       
  1225 					if(mode != CLbsAdmin::EGpsPreferTerminalBased)
       
  1226 						{
       
  1227 						SetTestStepResult(EFail);
       
  1228 						}
       
  1229 					else	// Request a location update
       
  1230 						{
       
  1231 					
       
  1232 						// Open positioner.
       
  1233 						User::LeaveIfError(iPositioner.Open(iServer));
       
  1234 						CleanupClosePushL(iPositioner);
       
  1235 						
       
  1236 						//Setup netsim
       
  1237 						User::LeaveIfError(OpenNetSim());
       
  1238 						TLbsNetPosRequestQuality quality;
       
  1239 						quality.SetMinHorizontalAccuracy(200);
       
  1240 						quality.SetMinVerticalAccuracy(20000);
       
  1241 						iNetSim.SetQuality(quality);
       
  1242 						
       
  1243 						//xx
       
  1244 			 			// Set the reference position, which also be used for any required verification.
       
  1245 			 			TPosition refPos;
       
  1246 
       
  1247 						#define REFPOS_LAT				1
       
  1248 						#define REFPOS_LONG				1
       
  1249 						#define REFPOS_ALT				1
       
  1250 						#define REFPOS_HORZ_ACCURACY	1
       
  1251 						#define REFPOS_VERT_ACCURACY	1
       
  1252 						
       
  1253 						refPos.SetCoordinate(REFPOS_LAT, REFPOS_LONG, REFPOS_ALT);
       
  1254 						refPos.SetAccuracy(REFPOS_HORZ_ACCURACY, REFPOS_VERT_ACCURACY);
       
  1255 						refPos.SetCurrentTime();
       
  1256 						iNetSim.SetReferenceLocation(refPos);
       
  1257 						User::After(500*1000);	
       
  1258 						//xx;
       
  1259 						//Do first NPUD, this should get a reference position on the reference cache
       
  1260 						TPositionInfo posInfo;
       
  1261 						TPositionInfo posInfob;
       
  1262 						
       
  1263 						// Send the first NPUD & block on response
       
  1264 						err = DoNotifyUpdateL(posInfo);
       
  1265 						if (KErrNone != err)
       
  1266 							{
       
  1267 							SetTestStepResult(EFail);
       
  1268 							}
       
  1269 						
       
  1270 						//Change the update options to set the MaxUpdateAge
       
  1271 						TPositionUpdateOptions posOpts;
       
  1272 						posOpts.SetMaxUpdateAge(1*1000000);
       
  1273 							
       
  1274 						iPositioner.SetUpdateOptions(posOpts);
       
  1275 						
       
  1276 						//Do the second NPUD, which should return a position from the cache
       
  1277 						// At this point in time the AGPS module will not yet have produced a position
       
  1278 						err = DoNotifyUpdateL(posInfob);
       
  1279 						if (KErrNone != err)
       
  1280 							{
       
  1281 							SetTestStepResult(EFail);
       
  1282 							}
       
  1283 						
       
  1284 						//Check to see if the returned position is a reference position
       
  1285 						TPositionModuleInfo::TTechnologyType techType;
       
  1286 						techType = posInfob.PositionMode();
       
  1287 						
       
  1288 						if(techType != TPositionModuleInfo::ETechnologyNetwork)
       
  1289 							{							
       
  1290 							INFO_PRINTF1(_L("Failed test, did not get a Network Reference Position."));
       
  1291 							SetTestStepResult(EFail);
       
  1292 							}
       
  1293 						
       
  1294 						//Since the second position is taken from the cache, check to see the two positions match
       
  1295 						T_LbsUtils utils;
       
  1296 						if(!utils.Compare_PosInfo(posInfo, posInfob))
       
  1297 							{
       
  1298 							INFO_PRINTF1(_L("Failed test, the two positions are not the same!"));
       
  1299 							SetTestStepResult(EFail);
       
  1300 							}
       
  1301 						
       
  1302 						CleanupStack::PopAndDestroy(&iPositioner);
       
  1303 						CloseNetSim();
       
  1304 						}
       
  1305 					
       
  1306 					break;
       
  1307 					}
       
  1308 				case 1004:
       
  1309 					{       
       
  1310 				     	TTimeIntervalMicroSeconds iTimeOut;
       
  1311 			     		TTime iStartTime;
       
  1312 	     				TPositionSatelliteInfo iPos, iPos2;
       
  1313 	     				TBool iEOP;
       
  1314 	     				// Open positioner.
       
  1315      					User::LeaveIfError(iPositioner.Open(iServer));
       
  1316 	     				CleanupClosePushL(iPositioner);
       
  1317 
       
  1318 	     				TPositionUpdateOptions updateOptions;
       
  1319 	     				iTimeOut = 2000000; // Two second timeout.
       
  1320 	     
       
  1321 	     				const TTimeIntervalMicroSeconds KTimeOut(iTimeOut);
       
  1322 	     				updateOptions.SetUpdateTimeOut(KTimeOut);
       
  1323 	     				updateOptions.SetAcceptPartialUpdates(ETrue);
       
  1324      					iPositioner.SetUpdateOptions(updateOptions);
       
  1325      
       
  1326 	     				// Store initial time
       
  1327 	    			 	iStartTime.UniversalTime();
       
  1328          
       
  1329      					TInt err = DoNotifyUpdateL(iPos);
       
  1330 						if (KErrNone != err)
       
  1331 							{
       
  1332 							SetTestStepResult(EFail);
       
  1333 							}
       
  1334      
       
  1335      					TTimeIntervalMicroSeconds timeLeft,maxUpdate;
       
  1336 	     				TTime cTime;
       
  1337 	     				//TPositionSatelliteInfo pos = iPos;
       
  1338         
       
  1339 	     				cTime.UniversalTime();
       
  1340 	     				iEOP = EFalse;
       
  1341      					while (!iEOP)
       
  1342      						{
       
  1343 	     					cTime.UniversalTime();
       
  1344 	     					// Requesting another update must be the first thing done in RunL
       
  1345      						timeLeft = (iTimeOut.Int64() - cTime.MicroSecondsFrom(iStartTime).Int64());
       
  1346 	     					maxUpdate = 100000;
       
  1347     
       
  1348     	 					if (timeLeft <= 0) 
       
  1349      							{
       
  1350 	     						iEOP = ETrue;
       
  1351 	     						timeLeft = 1; // Use a very small value for the last update
       
  1352 		     					}
       
  1353     	 					else
       
  1354      							{
       
  1355 	     						const TTimeIntervalMicroSeconds KTimeOut(timeLeft);
       
  1356 	     						TPositionUpdateOptions posOpts;
       
  1357 	     						posOpts.SetUpdateTimeOut(KTimeOut);
       
  1358 	     						posOpts.SetMaxUpdateAge(maxUpdate);
       
  1359 	     						posOpts.SetAcceptPartialUpdates(ETrue);
       
  1360 	     						iPositioner.SetUpdateOptions(posOpts);
       
  1361      
       
  1362 	     						err = DoNotifyUpdateL(iPos);
       
  1363      							if (KErrNone != err)
       
  1364      								{
       
  1365      								SetTestStepResult(EFail);
       
  1366 	     							} 
       
  1367      							else
       
  1368 		  	   						{	
       
  1369 									// We have a valid position, test passed
       
  1370 		     							SetTestStepResult(EPass);
       
  1371 	     								iEOP = ETrue;
       
  1372 	     								}
       
  1373 	     							}
       
  1374 		     				} // end while
       
  1375 	     				CleanupStack::PopAndDestroy(&iPositioner);
       
  1376      					break;
       
  1377 					}								
       
  1378 
       
  1379 				// Test case LBS-NotifyPosUpdate-0106 for demonstration of INC117582
       
  1380 				case 106:
       
  1381 					{
       
  1382 					
       
  1383 					TPositionModuleId id;
       
  1384 					iServer.GetDefaultModuleId(id);
       
  1385 					
       
  1386 					
       
  1387 					RPositioner positioner1;
       
  1388 					err = positioner1.Open(iServer, id);
       
  1389 					User::LeaveIfError(err);
       
  1390 
       
  1391 					RPositioner positioner2;
       
  1392 					err = positioner2.Open(iServer, id);
       
  1393 					User::LeaveIfError(err);
       
  1394 
       
  1395 					RPositioner positioner3;
       
  1396 					err = positioner3.Open(iServer, id);
       
  1397 					User::LeaveIfError(err);
       
  1398 
       
  1399 					RPositioner positioner4;
       
  1400 					err = positioner4.Open(iServer, id);
       
  1401 					User::LeaveIfError(err);
       
  1402 
       
  1403 					RPositioner positioner5;
       
  1404 					err = positioner5.Open(iServer, id);
       
  1405 					User::LeaveIfError(err);
       
  1406 
       
  1407 					RPositioner positioner6;
       
  1408 					err = positioner6.Open(iServer, id);
       
  1409 					User::LeaveIfError(err);
       
  1410 
       
  1411 					RPositioner positioner7;
       
  1412 					err = positioner7.Open(iServer, id);
       
  1413 					User::LeaveIfError(err);
       
  1414 
       
  1415 					
       
  1416 					positioner1.Close();
       
  1417 					positioner2.Close();
       
  1418 					positioner3.Close();
       
  1419 					positioner6.Close();
       
  1420 					positioner7.Close();	// leaving 4 and 5 still open
       
  1421 					
       
  1422 					User::After(2000000);  //allow time for close to work through the locserver
       
  1423 					
       
  1424 				 
       
  1425 					break;
       
  1426 					}
       
  1427 				
       
  1428 				default:
       
  1429 					User::Panic(KLbsClientStepNotifyPosUpdate, KErrUnknown);					
       
  1430 						
       
  1431     		    }
       
  1432 			}
       
  1433 			
       
  1434 		// All done, clean up.
       
  1435 		CleanupStack::PopAndDestroy(&iServer);		
       
  1436 		}
       
  1437 
       
  1438 	INFO_PRINTF1(_L("&lt;&lt;CT_LbsClientStep_NotifyPosUpdate::doTestStepL()"));
       
  1439 
       
  1440 	return TestStepResult();
       
  1441 	}