lbs/lbsclient/src/ctlbsclientsteplastknownpos.cpp
branchSymbian2
changeset 1 8758140453c0
child 6 c108117318cb
equal deleted inserted replaced
0:e8c1ea2c6496 1:8758140453c0
       
     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_lastknownpos.cpp
       
    15 // This is the class implementation for the Last Known Position Tests
       
    16 // 
       
    17 //
       
    18  
       
    19 #include "ctlbsclientsteplastknownpos.h"
       
    20 
       
    21 #include <lbs.h>
       
    22 #include "lbsadmin.h"
       
    23 #include "lbssatellite.h"
       
    24 #include "tlbsutils.h"
       
    25 #include "ctlbsasyncwaiter.h"
       
    26 
       
    27 /**
       
    28  * Destructor
       
    29  */
       
    30 CT_LbsClientStep_LastKnownPos::~CT_LbsClientStep_LastKnownPos()
       
    31 	{
       
    32 	}
       
    33 
       
    34 
       
    35 /**
       
    36  * Constructor
       
    37  */
       
    38 CT_LbsClientStep_LastKnownPos::CT_LbsClientStep_LastKnownPos(CT_LbsClientServer& aParent) : CT_LbsClientStep(aParent)
       
    39 	{
       
    40 	SetTestStepName(KLbsClientStep_LastKnownPos);
       
    41 	}
       
    42 
       
    43 
       
    44 /**
       
    45 Static Constructor
       
    46 */
       
    47 CT_LbsClientStep_LastKnownPos* CT_LbsClientStep_LastKnownPos::New(CT_LbsClientServer& aParent)
       
    48 	{
       
    49 	return new CT_LbsClientStep_LastKnownPos(aParent);
       
    50 	// Note the lack of ELeave.
       
    51 	// This means that having insufficient memory will return NULL;
       
    52 	}
       
    53 
       
    54 
       
    55 void CT_LbsClientStep_LastKnownPos::SwitchOnselfLocateAPIL()
       
    56 	{
       
    57 	CLbsAdmin* adminApi = CLbsAdmin::NewL();
       
    58 	CleanupStack::PushL(adminApi);
       
    59 	adminApi->Set(KLbsSettingHomeSelfLocate, CLbsAdmin::ESelfLocateOn);	
       
    60 	CleanupStack::PopAndDestroy(adminApi);
       
    61 	}
       
    62 
       
    63 
       
    64 /**
       
    65  * @return - TVerdict code
       
    66  * Override of base class pure virtual
       
    67  * Our implementation only gets called if the base class doTestStepPreambleL() did
       
    68  * not leave. That being the case, the current test result value will be EPass.
       
    69  */
       
    70 TVerdict CT_LbsClientStep_LastKnownPos::doTestStepL()
       
    71 	{
       
    72 	// Generic test step used to test the LBS Client Notify position update API.
       
    73 	INFO_PRINTF1(_L("&gt;&gt;CT_LbsClientStep_LastKnownPos::doTestStepL()"));
       
    74 
       
    75 	if (TestStepResult() == EPass)
       
    76 		{
       
    77 		TInt err = KErrNone;
       
    78 		
       
    79 		// Wait for server to cease to be - thus ensuring cache is empty
       
    80 		//User::After(10000000);   //Not needed
       
    81 		
       
    82 		// Carryout unique test actions.
       
    83 		TInt testCaseId;
       
    84 		if (GetIntFromConfig(ConfigSection(), KTestCaseId, testCaseId))
       
    85 			{
       
    86 			if(testCaseId == 2)
       
    87 				{
       
    88 				//The delay below is to make sure that there is no request to server for at least 200 seconds
       
    89 				//so that it will shutdown and clear cache.
       
    90 
       
    91 				User::After(3*1000*1000);
       
    92 				}
       
    93 
       
    94 			// Connect to self locate server.
       
    95 			User::LeaveIfError(iServer.Connect());
       
    96 			CleanupClosePushL(iServer);
       
    97 				
       
    98 			switch (testCaseId)
       
    99 				{
       
   100 				// Test case LBS-LastKnownPos-0001
       
   101 				case 1:
       
   102 				// Test case LBS-LastKnownPos-0101
       
   103 				case 101:
       
   104 				    {
       
   105 					T_LbsUtils utils;
       
   106 					// Open positioner.
       
   107 					User::LeaveIfError(iPositioner.Open(iServer));
       
   108 					CleanupClosePushL(iPositioner);
       
   109                     if(testCaseId==101)
       
   110 	                    {
       
   111 	                    // For this test an additional reference position will be returned.
       
   112 					
       
   113 						// Setup netsim.
       
   114 						User::LeaveIfError(OpenNetSim());
       
   115 							
       
   116 						// Request notify for the expected reference position.
       
   117 						TPositionInfo actualRefPosInfo;
       
   118 							
       
   119 						err = DoNotifyUpdateL(actualRefPosInfo);
       
   120 						if (err)
       
   121 							{
       
   122 							INFO_PRINTF2(_L("Failed test, reference position request returned err %d."), err);
       
   123 							SetTestStepResult(EFail);							
       
   124 							}
       
   125 								
       
   126 						// Verify reference position.
       
   127 						TPositionInfo verifyRefPosInfo;
       
   128 							
       
   129 						verifyRefPosInfo.SetPosition(iRefPos);
       
   130 						if (!utils.Compare_PosInfo(verifyRefPosInfo, actualRefPosInfo))
       
   131 							{
       
   132 							INFO_PRINTF1(_L("Failed test, reference position incorrect."));
       
   133 							SetTestStepResult(EFail);
       
   134 							}	
       
   135 	                    }
       
   136 					
       
   137 					
       
   138 				    TPosition pos;		// original position
       
   139 					TTime timeStamp;	// timestamp inside original received position
       
   140 					
       
   141 				    // Carry out a notify update to ensure last known cache is filled.
       
   142 					TPositionInfo notifyPosInfo;
       
   143 					User::LeaveIfError(DoNotifyUpdateL(notifyPosInfo));
       
   144 
       
   145 					// get the position data:
       
   146 					notifyPosInfo.GetPosition(pos);
       
   147 					
       
   148 					timeStamp = pos.Time();
       
   149 					INFO_PRINTF1(_L("Original position timeStamp: "));
       
   150 					INFO_PRINTF4(_L("%d/%d/%d"), timeStamp.DateTime().Day() + 1, timeStamp.DateTime().Month() + 1, timeStamp.DateTime().Year());
       
   151 					INFO_PRINTF5(_L("at %d :%d :%d :%d"), timeStamp.DateTime().Hour(), timeStamp.DateTime().Minute(), timeStamp.DateTime().Second(), timeStamp.DateTime().Second());
       
   152 						
       
   153 					// Create a posinfo and store in our shared array for later verification.
       
   154 					RPointerArray<TAny>& posInfoArr = iParent.iSharedData->iCurrentPosInfoArr;
       
   155 					TPositionInfo* posInfo = new(ELeave) TPositionInfo();
       
   156 	
       
   157 					utils.ResetAndDestroy_PosInfoArr(posInfoArr);	// Clear previous entries before new entry is appended.
       
   158 
       
   159 					posInfoArr.Append(posInfo);
       
   160 
       
   161 					// Get the last known position
       
   162 					err = DoLastKnownPosL(*posInfo);
       
   163 					if (KErrNone != err)
       
   164 						{
       
   165 						SetTestStepResult(EFail);
       
   166 						}
       
   167 					else
       
   168 						{								
       
   169 						TTime timeStamp_cached;		
       
   170 						posInfo->GetPosition(pos);	
       
   171 						timeStamp_cached = pos.Time();
       
   172 						
       
   173 						timeStamp = pos.Time();
       
   174 						INFO_PRINTF1(_L("Cached position timeStamp: "));
       
   175 						INFO_PRINTF4(_L("%d/%d/%d"), timeStamp_cached.DateTime().Day() + 1, timeStamp_cached.DateTime().Month() + 1, timeStamp_cached.DateTime().Year());
       
   176 						INFO_PRINTF5(_L("at %d :%d :%d :%d"), timeStamp_cached.DateTime().Hour(), timeStamp_cached.DateTime().Minute(), timeStamp_cached.DateTime().Second(), timeStamp_cached.DateTime().Second());
       
   177 													
       
   178 						// verify that the timestamp matches the original one:
       
   179 						if(timeStamp_cached != timeStamp)
       
   180 							{
       
   181 							SetTestStepResult(EFail);
       
   182 							}
       
   183 						
       
   184 						}
       
   185 					CleanupStack::PopAndDestroy(&iPositioner);
       
   186 					if (testCaseId == 101)
       
   187 						{
       
   188 						CloseNetSim();
       
   189 						}
       
   190 					break;
       
   191 					}
       
   192 				
       
   193 				// NEGATIVE TEST
       
   194 				// Test case LBS-LastKnownPos-0002
       
   195 				case 2:
       
   196 					{
       
   197 					// Open positioner.
       
   198 					User::LeaveIfError(iPositioner.Open(iServer));
       
   199 					CleanupClosePushL(iPositioner);
       
   200 
       
   201 					// DONT carry out a notify update to ensure last known cache is filled.
       
   202 
       
   203 					// Create a posinfo to store position info from LastKnownPosition method.
       
   204 					TPositionInfo posInfo;
       
   205 
       
   206 					// Get the last known position
       
   207 					err = DoLastKnownPosL(posInfo);
       
   208 					if (KErrUnknown != err)
       
   209 						{
       
   210 						INFO_PRINTF2(_L("Failed with error %d when expecting error KErrUnknown, indicating no position in cache"), err);
       
   211 						SetTestStepResult(EFail);
       
   212 						}
       
   213 						
       
   214 					// Wait for a time period and verify that location info is not published.
       
   215 					// 10seconds
       
   216 					User::After(10000000);
       
   217 					
       
   218 					// Get the last known position
       
   219 					err = DoLastKnownPosL(posInfo);
       
   220 					if (KErrUnknown != err)
       
   221 						{
       
   222 						INFO_PRINTF2(_L("Failed with error %d when expecting error KErrUnknown, indicating no position in cache"), err);
       
   223 						SetTestStepResult(EFail);
       
   224 						}
       
   225 						
       
   226 					CleanupStack::PopAndDestroy(&iPositioner);
       
   227 					break;
       
   228 					}
       
   229 					
       
   230 
       
   231 				// NEGATIVE TEST	
       
   232 				// Test case LBS-LastKnownPos-0004
       
   233 				case 4:
       
   234 					{
       
   235 					T_LbsUtils utils;
       
   236 					TPositionModuleId networkModuleId = utils.GetNetworkModuleIdL(iServer);
       
   237 					// Open positioner.
       
   238 					User::LeaveIfError(iPositioner.Open(iServer, networkModuleId));
       
   239 					CleanupClosePushL(iPositioner);
       
   240 
       
   241 					// Setup netsim.
       
   242 					User::LeaveIfError(OpenNetSim());
       
   243 						
       
   244 					// Carry out a notify update to ensure last known cache is filled.
       
   245 					TPositionInfo actualRefPosInfo;
       
   246 						
       
   247 					err = DoNotifyUpdateL(actualRefPosInfo);
       
   248 										
       
   249 					if (err)
       
   250 						{
       
   251 						INFO_PRINTF2(_L("Failed test, reference position request returned err %d."), err);
       
   252 						SetTestStepResult(EFail);							
       
   253 						}
       
   254 							
       
   255 					// Verify reference position.
       
   256 					TPositionInfo verifyRefPosInfo;
       
   257 					verifyRefPosInfo.SetPosition(iRefPos);
       
   258 					if (!utils.Compare_PosInfo(verifyRefPosInfo, actualRefPosInfo))
       
   259 						{
       
   260 						INFO_PRINTF1(_L("Failed test, reference position incorrect."));
       
   261 						SetTestStepResult(EFail);
       
   262 						}
       
   263 				    
       
   264 				    // ** Create a position info which is not supported by the network module **
       
   265 					TPositionSatelliteInfo positionSatelliteInfo;
       
   266 
       
   267 					// Get the last known position
       
   268 					err = DoLastKnownPosL(positionSatelliteInfo);
       
   269 					if (KErrArgument != err)
       
   270 						{
       
   271 						SetTestStepResult(EFail);
       
   272 						}
       
   273 												
       
   274 					CleanupStack::PopAndDestroy(&iPositioner);
       
   275 					// Close netsim.
       
   276 					CloseNetSim();
       
   277 					break;
       
   278 					}
       
   279 									
       
   280 				// Test case LBS-LastKnownPos-0006
       
   281 				case 6:
       
   282 					{
       
   283 					// Open positioner.
       
   284 					User::LeaveIfError(iPositioner.Open(iServer));
       
   285 					CleanupClosePushL(iPositioner);
       
   286 											
       
   287 					CLbsAdmin* adminApi = CLbsAdmin::NewL();
       
   288 					CleanupStack::PushL(adminApi);
       
   289 					
       
   290 					adminApi->Set(KLbsSettingHomeSelfLocate, CLbsAdmin::ESelfLocateOff);
       
   291 					
       
   292 					TPositionInfo posInfo;
       
   293 
       
   294 					// Get the last known position
       
   295 					err = DoLastKnownPosL(posInfo);
       
   296 					if (KErrAccessDenied != err)
       
   297 						{
       
   298 						SetTestStepResult(EFail);
       
   299 						}
       
   300 
       
   301 					CleanupStack::PopAndDestroy(adminApi);
       
   302 					CleanupStack::PopAndDestroy(&iPositioner);
       
   303 
       
   304 					SwitchOnselfLocateAPIL();
       
   305 
       
   306 					break;		
       
   307 					}
       
   308 
       
   309 				// Test case LBS-LastKnownPos-0007
       
   310 				case 7:
       
   311 				// Test case LBS-LastKnownPos-0102
       
   312 				case 102:
       
   313 					{
       
   314 					T_LbsUtils utils;
       
   315 					// Open positioner.
       
   316 					User::LeaveIfError(iPositioner.Open(iServer));
       
   317 					CleanupClosePushL(iPositioner);
       
   318                     if(testCaseId==102)
       
   319 	                    {
       
   320 	                    // For this test an additional reference position will be returned.
       
   321 					
       
   322 						// Setup netsim.
       
   323 						User::LeaveIfError(OpenNetSim());
       
   324 							
       
   325 						// Request notify for the expected reference position.
       
   326 						TPositionInfo actualRefPosInfo;
       
   327 							
       
   328 						err = DoNotifyUpdateL(actualRefPosInfo);
       
   329 						if (err)
       
   330 							{
       
   331 							INFO_PRINTF2(_L("Failed test, reference position request returned err %d."), err);
       
   332 							SetTestStepResult(EFail);							
       
   333 							}
       
   334 								
       
   335 						// Verify reference position.
       
   336 						TPositionInfo verifyRefPosInfo;
       
   337 							
       
   338 						verifyRefPosInfo.SetPosition(iRefPos);
       
   339 						if (!utils.Compare_PosInfo(verifyRefPosInfo, actualRefPosInfo))
       
   340 							{
       
   341 							INFO_PRINTF1(_L("Failed test, reference position incorrect."));
       
   342 							SetTestStepResult(EFail);
       
   343 							}	
       
   344 	                    }
       
   345 														
       
   346 					// Carry out a notify update to ensure last known cache is filled.
       
   347 					TPositionInfo notifyPosInfo;
       
   348 					TInt err = DoNotifyUpdateL(notifyPosInfo);
       
   349 					User::LeaveIfError(err);
       
   350 
       
   351 					// Create a posinfo and store in our shared array for later verification.
       
   352 					RPointerArray<TAny>& posInfoArr = iParent.iSharedData->iCurrentPosInfoArr;
       
   353 					TPositionInfo* posInfo = new(ELeave) TPositionInfo();
       
   354 
       
   355 				
       
   356 					utils.ResetAndDestroy_PosInfoArr(posInfoArr);	// Clear previous entries before new entry is appended.
       
   357 
       
   358 					posInfoArr.Append(posInfo);
       
   359 
       
   360 					// Get the last known position
       
   361 					CT_LbsAsyncWaiter*	waiter = CT_LbsAsyncWaiter::NewL();
       
   362 					CleanupStack::PushL(waiter);
       
   363 
       
   364 					User::LeaveIfError(iPositioner.SetRequestor(	CRequestor::ERequestorService,
       
   365 																	CRequestor::EFormatApplication,
       
   366 																	_L("Tom Tom")));
       
   367 																	
       
   368 					iPositioner.GetLastKnownPosition(*posInfo, waiter->iStatus);
       
   369 									
       
   370 					TInt errCancel = iPositioner.CancelRequest(EPositionerGetLastKnownPosition);
       
   371 						
       
   372 					waiter->StartAndWait();
       
   373 
       
   374 					TInt errLkp = waiter->Result();
       
   375 
       
   376 					CleanupStack::PopAndDestroy(waiter);
       
   377 					
       
   378 					// Sync Cancel() call returns either KErrNone or KErrNotFound. 
       
   379 					if ( errCancel != KErrNone && errCancel != KErrNotFound )
       
   380 						{
       
   381 						INFO_PRINTF1(_L("<FONT><B>Cancel must return KErrNone or KErrNotFound</B></FONT>"));
       
   382 						SetTestStepResult(EFail);									
       
   383 						}
       
   384 					// If Cancel() returns KErrNone, then the original request may complete with KErrCancel.
       
   385 					if (errCancel != KErrNone &&  (errLkp != KErrCancel && errLkp != KErrNone )  )
       
   386 						{
       
   387 						INFO_PRINTF1(_L("<FONT><B>Cancel must return KErrCancel or KErrNone</B></FONT>"));
       
   388 						SetTestStepResult(EFail);									
       
   389 						}
       
   390 						
       
   391 						
       
   392 					CleanupStack::PopAndDestroy(&iPositioner);
       
   393 					if (testCaseId == 102)
       
   394 						{
       
   395 						CloseNetSim();
       
   396 						}			
       
   397 					break;		
       
   398 					}		
       
   399 					
       
   400 				// Test case LBS-LastKnownPos-0008
       
   401 				case 8:
       
   402 					{
       
   403 					// Open positioner.
       
   404 					User::LeaveIfError(iPositioner.Open(iServer));
       
   405 					CleanupClosePushL(iPositioner);
       
   406 
       
   407 					// DONT get the last known position, but DO cancel
       
   408 					err = iPositioner.CancelRequest(EPositionerNotifyPositionUpdate);
       
   409 					
       
   410 					if (KErrNotFound != err)
       
   411 						{
       
   412 						//Didnt cancel or complete successfully.
       
   413 						SetTestStepResult(EFail);
       
   414 						}
       
   415 
       
   416 					CleanupStack::PopAndDestroy(&iPositioner);
       
   417 									
       
   418 					break;		
       
   419 					}	
       
   420 					
       
   421 
       
   422 				// Test case LBS-LastKnownPos-0009
       
   423 				case 9:
       
   424 					{
       
   425 					//DONT open connection to Position Server
       
   426 
       
   427 					TPositionInfo posInfo;
       
   428 
       
   429 					// Get the last known position, THIS SHOULD PANIC WITH EPositionServerBadHandle
       
   430 					TRequestStatus status;
       
   431 					iPositioner.GetLastKnownPosition(posInfo, status);
       
   432 					err = iPositioner.CancelRequest(EPositionerNotifyPositionUpdate);
       
   433 
       
   434 					if (KErrNone == err)
       
   435 						{
       
   436 						//Completed Successfully.
       
   437 						SetTestStepResult(EFail);
       
   438 						}
       
   439 
       
   440 					CleanupStack::PopAndDestroy(&iPositioner);
       
   441 					
       
   442 					SwitchOnselfLocateAPIL();
       
   443 					
       
   444 					break;		
       
   445 					}	
       
   446 					
       
   447 
       
   448 				// Test case LBS-LastKnownPos-0012
       
   449 				case 12:
       
   450 					{
       
   451 					// Open positioner.
       
   452 					User::LeaveIfError(iPositioner.Open(iServer));
       
   453 					CleanupClosePushL(iPositioner);
       
   454 
       
   455 					// Carry out a notify update to ensure last known cache is filled.
       
   456 					TPositionInfo notifyPosInfo;
       
   457 					User::LeaveIfError(DoNotifyUpdateL(notifyPosInfo));
       
   458 
       
   459 					TPositionInfo posInfo;
       
   460 
       
   461 					// Get the last known position while self Locate Server is busy
       
   462 					err = DoLastKnownPosL(posInfo);
       
   463 
       
   464 					if (KErrServerBusy != err)
       
   465 						{
       
   466 						// Completed successfully.
       
   467 						INFO_PRINTF1(_L("<FONT><B>**Test should pass if GetLastKnownPosition() fails with KErrServerBusy **</B></FONT>"));
       
   468 						SetTestStepResult(EFail);
       
   469 						}
       
   470 					CleanupStack::PopAndDestroy(&iPositioner);
       
   471 					break;	
       
   472 					}
       
   473 			
       
   474 			
       
   475 				// Test case LBS-LastKnownPos-0014
       
   476 				case 14:
       
   477 					{
       
   478 					// Testcase placeholder
       
   479 					// Request multiples LKPs from different clients concurrently 
       
   480 					SetTestStepResult(EFail);						
       
   481 					break;
       
   482 					}
       
   483 			
       
   484 			
       
   485 				// Test case LBS-LastKnownPos-0015
       
   486 				case 15:
       
   487 				// Test case LBS-LastKnownPos-0103
       
   488 				case 103:
       
   489 					{
       
   490 					T_LbsUtils utils;
       
   491 					// Open positioner.
       
   492 					User::LeaveIfError(iPositioner.Open(iServer));
       
   493 					CleanupClosePushL(iPositioner);		
       
   494 					if(testCaseId==103)
       
   495 	                    {
       
   496 	                    // For this test an additional reference position will be returned.
       
   497 					
       
   498 						// Setup netsim.
       
   499 						User::LeaveIfError(OpenNetSim());
       
   500 							
       
   501 						// Request notify for the expected reference position.
       
   502 						TPositionInfo actualRefPosInfo;
       
   503 							
       
   504 						err = DoNotifyUpdateL(actualRefPosInfo);
       
   505 						if (err)
       
   506 							{
       
   507 							INFO_PRINTF2(_L("Failed test, reference position request returned err %d."), err);
       
   508 							SetTestStepResult(EFail);							
       
   509 							}
       
   510 								
       
   511 						// Verify reference position.
       
   512 						TPositionInfo verifyRefPosInfo;
       
   513 							
       
   514 						verifyRefPosInfo.SetPosition(iRefPos);
       
   515 						if (!utils.Compare_PosInfo(verifyRefPosInfo, actualRefPosInfo))
       
   516 							{
       
   517 							INFO_PRINTF1(_L("Failed test, reference position incorrect."));
       
   518 							SetTestStepResult(EFail);
       
   519 							}	
       
   520 	                    }
       
   521 																				
       
   522 					// Carry out a notify update to ensure last known cache is filled.
       
   523 					TPositionInfo notifyPosInfo;
       
   524 					TInt err = DoNotifyUpdateL(notifyPosInfo);
       
   525 					User::LeaveIfError(err);
       
   526 					
       
   527 					// Create a posinfo and store in our shared array for later verification.
       
   528 					RPointerArray<TAny>& posInfoArr = iParent.iSharedData->iCurrentPosInfoArr;
       
   529 					
       
   530 					
       
   531 					utils.ResetAndDestroy_PosInfoArr(posInfoArr);	// Clear previous entries before new entry is appended.
       
   532 					
       
   533 					CT_LbsAsyncWaiter*	waiter = CT_LbsAsyncWaiter::NewL();
       
   534 					CleanupStack::PushL(waiter);
       
   535 					
       
   536 					TInt numpositions = iParent.iSharedData->iVerifyPosInfoArr.Count();
       
   537 					while(numpositions--)
       
   538 						{
       
   539 						RPositioner positioner;
       
   540 						// Open positioner.
       
   541 						User::LeaveIfError(positioner.Open(iServer));
       
   542 						CleanupClosePushL(positioner);		
       
   543 												
       
   544 						TPositionInfo* posInfo = new(ELeave) TPositionInfo();
       
   545 						posInfoArr.Append(posInfo);
       
   546 
       
   547 						// LastKnownPosition from multiple sub sessions
       
   548 
       
   549 						User::LeaveIfError(positioner.SetRequestor(	CRequestor::ERequestorService,
       
   550 																		CRequestor::EFormatApplication,
       
   551 																		_L("Tom Tom")));
       
   552 																		
       
   553 						positioner.GetLastKnownPosition(*posInfo, waiter->iStatus);
       
   554 						waiter->StartAndWait();
       
   555 						TInt res = waiter->Result();
       
   556 						
       
   557 						if(KErrNone != res)
       
   558 							{
       
   559 							//One of the LKPs failed, so test fails.
       
   560 							SetTestStepResult(EFail);
       
   561 							}
       
   562 						CleanupStack::PopAndDestroy(&positioner);
       
   563 						}
       
   564 
       
   565 						CleanupStack::PopAndDestroy(waiter);
       
   566 						CleanupStack::PopAndDestroy(&iPositioner);
       
   567 					    if (testCaseId == 103)
       
   568 							{
       
   569 							CloseNetSim();
       
   570 							}
       
   571 					break;	
       
   572 					}
       
   573 				// Test case LBS-LastKnownPos-0016
       
   574 				case 16:
       
   575 				// Test case LBS-LastKnownPos-0104
       
   576 				case 104:
       
   577 					{
       
   578 					T_LbsUtils utils;
       
   579 					// Open positioner.
       
   580 					User::LeaveIfError(iPositioner.Open(iServer));
       
   581 					CleanupClosePushL(iPositioner);
       
   582                     if(testCaseId==104)
       
   583 	                    {
       
   584 	                    // For this test an additional reference position will be returned.
       
   585 					
       
   586 						// Setup netsim.
       
   587 						User::LeaveIfError(OpenNetSim());
       
   588 							
       
   589 						// Request notify for the expected reference position.
       
   590 						TPositionInfo actualRefPosInfo;
       
   591 							
       
   592 						err = DoNotifyUpdateL(actualRefPosInfo);
       
   593 						if (err)
       
   594 							{
       
   595 							INFO_PRINTF2(_L("Failed test, reference position request returned err %d."), err);
       
   596 							SetTestStepResult(EFail);							
       
   597 							}
       
   598 								
       
   599 						// Verify reference position.
       
   600 						TPositionInfo verifyRefPosInfo;
       
   601 							
       
   602 						verifyRefPosInfo.SetPosition(iRefPos);
       
   603 						if (!utils.Compare_PosInfo(verifyRefPosInfo, actualRefPosInfo))
       
   604 							{
       
   605 							INFO_PRINTF1(_L("Failed test, reference position incorrect."));
       
   606 							SetTestStepResult(EFail);
       
   607 							}	
       
   608 	                    }
       
   609 		
       
   610 					// Carry out a notify update to ensure last known cache is filled.
       
   611 					TPositionInfo notifyPosInfo;
       
   612 					User::LeaveIfError(DoNotifyUpdateL(notifyPosInfo));
       
   613 
       
   614 					// Create a posinfo and store in our shared array for later verification.
       
   615 					RPointerArray<TAny>& posInfoArr = iParent.iSharedData->iCurrentPosInfoArr;
       
   616 
       
   617 				
       
   618 					utils.ResetAndDestroy_PosInfoArr(posInfoArr);	// Clear previous entries before new entry is appended.
       
   619 
       
   620 					TInt numPositions = iParent.iSharedData->iVerifyPosInfoArr.Count();
       
   621 					while(numPositions--)
       
   622 						{
       
   623 						TPositionInfo* posInfo = new(ELeave) TPositionInfo();
       
   624 						posInfoArr.Append(posInfo);
       
   625 						
       
   626 						err = DoLastKnownPosL(*posInfo);
       
   627 						if (KErrNone != err)
       
   628 							{
       
   629 							SetTestStepResult(EFail);
       
   630 							}
       
   631 						}
       
   632 					
       
   633 					CleanupStack::PopAndDestroy(&iPositioner);
       
   634 					if (testCaseId == 104)
       
   635 						{
       
   636 						CloseNetSim();
       
   637 						}
       
   638 					break;	
       
   639 					}
       
   640 				// Test case LBS-LastKnownPos-0105	
       
   641 				case 105:
       
   642 			    	{
       
   643 			    	T_LbsUtils utils;
       
   644 			    	TPositionModuleId networkModuleId = utils.GetNetworkModuleIdL(iServer);
       
   645 					// Open positioner.
       
   646 					User::LeaveIfError(iPositioner.Open(iServer, networkModuleId));
       
   647 					CleanupClosePushL(iPositioner);
       
   648 
       
   649 					// Setup netsim.
       
   650 					User::LeaveIfError(OpenNetSim());
       
   651 						
       
   652 					TPosition pos;		// original position
       
   653 					TTime timeStamp;	// timestamp inside original received position
       
   654 					
       
   655 					// Carry out a notify update to ensure last known cache is filled.
       
   656 					TPositionInfo actualRefPosInfo;
       
   657 						
       
   658 					err = DoNotifyUpdateL(actualRefPosInfo);
       
   659 										
       
   660 					if (err)
       
   661 						{
       
   662 						INFO_PRINTF2(_L("Failed test, reference position request returned err %d."), err);
       
   663 						SetTestStepResult(EFail);							
       
   664 						}
       
   665 												
       
   666 					// get the position data:
       
   667 					actualRefPosInfo.GetPosition(pos);
       
   668 					
       
   669 					timeStamp = pos.Time();
       
   670 					INFO_PRINTF1(_L("Original position timeStamp: "));
       
   671 					INFO_PRINTF4(_L("%d/%d/%d"), timeStamp.DateTime().Day() + 1, timeStamp.DateTime().Month() + 1, timeStamp.DateTime().Year());
       
   672 					INFO_PRINTF5(_L("at %d :%d :%d :%d"), timeStamp.DateTime().Hour(), timeStamp.DateTime().Minute(), timeStamp.DateTime().Second(), timeStamp.DateTime().Second());
       
   673 						
       
   674 					// Create a posinfo and store in our shared array for later verification.
       
   675 					RPointerArray<TAny>& posInfoArr = iParent.iSharedData->iCurrentPosInfoArr;
       
   676 					TPositionInfo* posInfo = new(ELeave) TPositionInfo();
       
   677 	
       
   678 					utils.ResetAndDestroy_PosInfoArr(posInfoArr);	// Clear previous entries before new entry is appended.
       
   679 
       
   680 					posInfoArr.Append(posInfo);
       
   681 
       
   682 					// Get the last known position
       
   683 					err = DoLastKnownPosL(*posInfo);
       
   684 					if (KErrNone != err)
       
   685 						{
       
   686 						SetTestStepResult(EFail);
       
   687 						}
       
   688 					else
       
   689 						{								
       
   690 						TTime timeStamp_cached;		
       
   691 						posInfo->GetPosition(pos);	
       
   692 						timeStamp_cached = pos.Time();
       
   693 						
       
   694 						timeStamp = pos.Time();
       
   695 						INFO_PRINTF1(_L("Cached position timeStamp: "));
       
   696 						INFO_PRINTF4(_L("%d/%d/%d"), timeStamp_cached.DateTime().Day() + 1, timeStamp_cached.DateTime().Month() + 1, timeStamp_cached.DateTime().Year());
       
   697 						INFO_PRINTF5(_L("at %d :%d :%d :%d"), timeStamp_cached.DateTime().Hour(), timeStamp_cached.DateTime().Minute(), timeStamp_cached.DateTime().Second(), timeStamp_cached.DateTime().Second());
       
   698 													
       
   699 						// verify that the timestamp matches the original one:
       
   700 						if(timeStamp_cached != timeStamp)
       
   701 							{
       
   702 							SetTestStepResult(EFail);
       
   703 							}
       
   704 						
       
   705 						}
       
   706 														
       
   707 					CleanupStack::PopAndDestroy(&iPositioner);
       
   708 					// Close netsim.
       
   709 					CloseNetSim();
       
   710 					break;
       
   711 					}
       
   712 				
       
   713 				default:
       
   714 					{
       
   715 					User::Leave(KErrArgument);
       
   716 					}
       
   717 				}
       
   718 			}
       
   719 
       
   720 		// All done, clean up.
       
   721 
       
   722 		CleanupStack::PopAndDestroy(&iServer);		
       
   723 		}
       
   724 
       
   725 	INFO_PRINTF1(_L("&lt;&lt;CT_LbsClientStep_LastKnownPos::doTestStepL()"));
       
   726 
       
   727 	return TestStepResult();
       
   728 	}