void CSuplProxyPrivacySession::NewPrivacyRequest(const RMessage2& aMessage)
	{
	LBSLOG(ELogP1, "CSuplProxyPrivacySession::NewPrivacyRequest() Begin\n");

	TLbsNetSessionId sessionId;
	iPrivacyProtocol.GetNextSessionId(sessionId);

	TPckg<TUint32> pkgReqId(sessionId.SessionNum());
	TInt error = aMessage.Write(0,pkgReqId);
	if(error != KErrNone)
		{
		aMessage.Complete(error);
		return;
		}
	
	RSemaphore semaphore;
	error = semaphore.Open(aMessage, 3, EOwnerThread);
	if(error != KErrNone)
		{
		aMessage.Complete(error);
		return;
		}
	semaphore.Signal();
	semaphore.Close();

	PrivacyRequest(aMessage, sessionId.SessionNum());

	LBSLOG(ELogP1, "CSuplProxyPrivacySession::NewPrivacyRequest() End\n");
	}
/**
Submit a notification request.

@param aMessage The message from the client.
*/
void CSuplProxyPrivacySession::NotifyLocationRequest(const RMessage2& aMessage)
	{
	LBSLOG(ELogP1, "CSuplProxyPrivacySession::NotifyLocationRequest() Begin\n");

	TLbsNetSessionId sessionId;
	iPrivacyProtocol.GetNextSessionId(sessionId);

	TPckg<TInt> pkgReqId(sessionId.SessionNum());
	TInt error = aMessage.Write(1,pkgReqId);
	if(error != KErrNone)
		{
		aMessage.Complete(error);
		return;
		}

	// NOTE: requestInfo does not complete the message in this case
	CSuplProxyPrivacyRequestInfo* requestInfo = NULL;
	TRAPD(err, requestInfo = CSuplProxyPrivacyRequestInfo::NewL(aMessage));
	if (err != KErrNone)
		{
		// Error creating request info object, complete with the error and return
		aMessage.Complete(err);
		return;
		}

	TLbsExternalRequestInfo2 extRequestInfo;
    TPckg<TLbsExternalRequestInfo2> extRequestInfoPkg(extRequestInfo);
    aMessage.Read(0,extRequestInfoPkg);
    requestInfo->SetRequestInfo(extRequestInfo);

	requestInfo->SetRequestId(sessionId.SessionNum());
	
	TLbsNetPosRequestPrivacy netPosRequestPrivacy;
	TPckg<TLbsNetPosRequestPrivacy>	netPosRequestPrivacyPkg(netPosRequestPrivacy);
	aMessage.Read(2,netPosRequestPrivacyPkg);
	requestInfo->SetRequestPrivacy(netPosRequestPrivacy);
    
    requestInfo->SetIsResponseRequired(EFalse);
    
	if (!IsRequestInfoValid(*requestInfo))
		{
		aMessage.Panic(KPosPrivacyPanicCategory,
					   EPosPrivSrvPanicInvalidArguments);
		delete requestInfo;
		return;
		}

	iPrivacyProtocol.NotifyLocationRequest(requestInfo);
	aMessage.Complete(KErrNone);

	LBSLOG(ELogP1, "CSuplProxyPrivacySession::NotifyLocationRequest() End\n");
	}
예제 #3
0
void CT_LbsNetProtocol::Process_RequestSelfLocationL()
	{
	// >> RequestSelfLocation()
	iStep.INFO_PRINTF1(_L("NetworkProtocolProxy >> RequestSelfLocation()"));
	TLbsNetSessionId* sessionId = NULL;
	TLbsNetPosRequestOptionsAssistance*	opts = NULL;
	TInt cleanupCnt = iProxy->GetArgsLC(ENetMsgRequestSelfLocation, &sessionId, &opts);
	++iRelativeSessionId;
	iSessionId.SetSessionNum(sessionId->SessionNum());
	iSessionId.SetSessionOwner(sessionId->SessionOwner());

	iStep.INFO_PRINTF2(_L("NetworkProtocolProxy >> RequestSelfLocation() mode = 0x%x"), opts->PosMode());
	if(opts->PosMode() == TPositionModuleInfo::ETechnologyTerminal)	// autonomous request, just complete the session
		{
		// << ProcessSessionComplete()
		TInt reason = KErrNone;
		iStep.INFO_PRINTF1(_L("NetworkProtocolProxy << ProcessSessionComplete()"));			
		iProxy->CallL(ENetMsgProcessSessionComplete, &iSessionId, &reason);

		// << ProcessStatusUpdate()
		MLbsNetworkProtocolObserver::TLbsNetProtocolServiceMask activeServiceMask = MLbsNetworkProtocolObserver::EServiceNone;	
		iStep.INFO_PRINTF1(_L("NetworkProtocolProxy << ProcessStatusUpdate(EServiceNone)"));			
		iProxy->CallL(ENetMsgProcessStatusUpdate, &activeServiceMask);						
		iNetworkProtocolProxyStep = ENetworkProtocolProxyStepNoSessionRunning;
		}					
	else
		{
		// << ProcessStatusUpdate(EServiceSelfLocation)
		iStep.INFO_PRINTF1(_L("NetworkProtocolProxy << ProcessStatusUpdate(EServiceSelfLocation)"));
		MLbsNetworkProtocolObserver::TLbsNetProtocolServiceMask activeServiceMask1 = MLbsNetworkProtocolObserver::EServiceSelfLocation;
		iProxy->CallL(ENetMsgProcessStatusUpdate, &activeServiceMask1);

		if(opts->DataRequestMask() != EAssistanceDataNone)
			{
			// << ProcessAssistanceData()
			iStep.INFO_PRINTF1(_L("NetworkProtocolProxy << ProcessAssistanceData"));
			TLbsAsistanceDataGroup dataMask = EAssistanceDataReferenceTime;
			RLbsAssistanceDataBuilderSet assistanceData;
			ArgUtils::PopulateLC(assistanceData);
			TInt reason = KErrNone;
			iProxy->CallL(ENetMsgProcessAssistanceData, &dataMask, &assistanceData, &reason);
			CleanupStack::PopAndDestroy(&assistanceData);
			}

		// << ProcessLocationRequest()
		iStep.INFO_PRINTF1(_L("NetworkProtocolProxy << ProcessLocationRequest"));			
		TBool emergency = EFalse;
		MLbsNetworkProtocolObserver::TLbsNetProtocolService	service = MLbsNetworkProtocolObserver::EServiceSelfLocation;
		TLbsNetPosRequestQuality quality = ArgUtils::Quality();
		quality.SetMaxFixTime(KAlphaTimer);
		TLbsNetPosRequestMethod method  = RequestNetworkMethod();
		iProxy->CallL(ENetMsgProcessLocationRequest, &iSessionId, &emergency, &service, &quality, &method);
		
		// Now that the hybrid/alpha2 has been requested, record current time to verify alpha2 timer expires correctly.
		iAlpha2StartTime.HomeTime();
		
		iNetworkProtocolProxyStep = ENetworkProtocolProxyStepSessionNrhRequestSent;
		}	
	CleanupStack::PopAndDestroy(cleanupCnt);
	}
/** Finds out which sequence relates to the session ID and checks that the received message was expected
 *
 * @param aSessionId Session ID that was past into the message
 * @param aMessageType ID of the message that was received by the PM
 *
 * @return The ID of the sequence that this message relates to, or KErrNotFound
 */
TInt CT_LbsHybridMultipleTest::WasMessageExpectedSessionId(TInt aSessionId, TNetProtocolResponseType aMessageType)
{
    //Loop through all the sequences
    for(TInt i=0; i<iSequences.Count(); ++i)
    {
        //Get the session id and the current sequence action
        TLbsNetSessionId sessionId = iSequences[i]->GetSessionId();
        TInt currentAction = iSequences[i]->GetCurrentAction();

        //Check the session ID of any sequence that is currently active with the session id past in
        if((sessionId.SessionNum() == aSessionId) && (currentAction != KErrArgument))
        {
            //Found the sequence with the requested session id, now check if the message type was expected
            if(currentAction == aMessageType)
            {
                //Message type was found, return sequence number
                return i;
            }
            else
            {
                //Message not expected by this sequence
                INFO_PRINTF3(_L("Error - Received unexpected message %d for session Id: %d"), aMessageType, aSessionId);
                INFO_PRINTF3(_L(" -> On Sequence: %d, at position: %d"), i , iSequences[i]->GetCurrentPosition());
                return KErrNotFound;
            }
        }
    }

    //Error, session ID not found in any sequence
    INFO_PRINTF3(_L("Error - Received unexpected session Id (%d) for message: %d"), aSessionId, aMessageType);

    return KErrNotFound;
}
예제 #5
0
void CT_LbsNetProtocol::RunL()
	{
	TInt response(iStatus.Int());
	switch(iNetworkProtocolProxyStep)
		{
		case ENetworkProtocolProxyStepInitial:
			{
			switch(response)
				{
				case ENetMsgCancelSelfLocation:
					{
					// >> CancelSelfLocation()
					iStep.INFO_PRINTF1(_L("NetworkProtocolProxy >> CancelSelfLocation() for an older session"));
					iProxy->WaitForResponseL(KTimeOut, iStatus);
					SetActive();
					break;
					}
				case ENetMsgGetCurrentCapabilitiesResponse:
					{
					// >> AdviceSystemStatus()
					CLbsNetworkProtocolBase::TLbsSystemStatus status;
					TInt cleanupCnt = iProxy->GetArgsLC(ENetMsgGetCurrentCapabilitiesResponse, &status);
					iStep.TESTL(status == CLbsNetworkProtocolBase::ESystemStatusNone || status == CLbsNetworkProtocolBase::ESystemStatusClientTracking);
					if(status == CLbsNetworkProtocolBase::ESystemStatusClientTracking)
						{
						iStep.INFO_PRINTF1(_L("NetworkProtocolProxy >> AdviceSystemStatus(ESystemStatusClientTracking)"));
						}
					else if(status == CLbsNetworkProtocolBase::ESystemStatusNone)
						{
						iStep.INFO_PRINTF1(_L("NetworkProtocolProxy >> AdviceSystemStatus(ESystemStatusNone)"));
						}
					CleanupStack::PopAndDestroy(cleanupCnt);
					
					iNetworkProtocolProxyStep = ENetworkProtocolProxyStepNoSessionRunning;
					iProxy->WaitForResponseL(KTimeOut, iStatus);
					SetActive();
					break;
					}
				case ENetMsgRequestAssistanceData:
					{
					// >> RequestAssistanceData(0)
					iStep.INFO_PRINTF1(_L("NetworkProtocolProxy >> RequestAssistanceData(0)"));
					TLbsAsistanceDataGroup dataMask;
					TInt cleanupCnt = iProxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataMask);
					iStep.TESTL(dataMask == EAssistanceDataNone);
					CleanupStack::PopAndDestroy(cleanupCnt);
					
					iNetworkProtocolProxyStep = ENetworkProtocolProxyStepNoSessionRunning;
					iProxy->WaitForResponseL(KTimeOut, iStatus);
					SetActive();
					break;
					}
				case ENetMsgTimeoutExpired:
					{ // can happen that no request has been sent through, so start waiting again
					if(iClientsFinished)
						{
						iObserver.StopTest();						
						}
					else
						{
						iProxy->WaitForResponseL(KTimeOut, iStatus);
						SetActive();
						}
					break;
					}
				case ENetMsgRequestSelfLocation:
					{
					Process_RequestSelfLocationL();
					iProxy->WaitForResponseL(KTimeOut, iStatus);
					SetActive();
					break;
					}
				default:
					{
					iStep.INFO_PRINTF2(_L("Network in state ENetworkProtocolProxyStepInitial received unexpected response: %d"), response);
					User::Leave(KErrNotSupported);
					}
				}
			break;
			}

		case ENetworkProtocolProxyStepSessionNrhRequestSent:
			{
			switch(response)
				{
				case ENetMsgRequestAssistanceData:
					{
					// >> RequestAssistanceData(0)
					iStep.INFO_PRINTF1(_L("NetworkProtocolProxy >> RequestAssistanceData(0)"));
					TLbsAsistanceDataGroup dataMask;
					TInt cleanupCnt = iProxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataMask);
					iStep.TESTL(dataMask == EAssistanceDataNone);
					CleanupStack::PopAndDestroy(cleanupCnt);

					DecideWhatNetworkDoesntReceive();
					
					if(iNetworkExpectsMeasurments)
						{ // measurements should be sent to the network
						// Determine the value to take off the alpha2 value. This is required because we had to wait for the assistance data response.
						TTimeIntervalMicroSeconds microseconds;
						TTime stopTime;
						stopTime.HomeTime();
						microseconds = stopTime.MicroSecondsFrom(iAlpha2StartTime); 
						TInt64 timeElapsed = microseconds.Int64();

						// Test that we do not get response before alpha2 has expired:
						TInt timeOut = KAlphaTimer - timeElapsed - KDelta > 0 ? KAlphaTimer - timeElapsed - KDelta : 0;
						iNetworkProtocolProxyStep = ENetworkProtocolProxyStepSessionWaitingForFirstMeasurmentsTimeOut;
						iProxy->WaitForResponseL(timeOut, iStatus);
						SetActive();
						}
					else
						{
						iNetworkProtocolProxyStep = ENetworkProtocolProxyStepSessionMeasurmentsReceived;
						iProxy->WaitForResponseL(KTimeOut, iStatus);
						SetActive();
						}

					break;
					}
				case ENetMsgCancelSelfLocation:
					{
					// >> CancelSelfLocation()
					TLbsNetSessionId* sessionId = NULL;
					TInt cancelReason = KErrNone;
					TInt cleanupCnt;
					
					cleanupCnt = iProxy->GetArgsLC(ENetMsgCancelSelfLocation, &sessionId, &cancelReason);
					if(sessionId->SessionNum() == iSessionId.SessionNum())
						{ // should complete the session
						iStep.INFO_PRINTF1(_L("NetworkProtocolProxy >> CancelSelfLocation()"));
						CleanupStack::PopAndDestroy(cleanupCnt);
						
						// << ProcessSessionComplete()
						TInt reason = KErrNone;
						iStep.INFO_PRINTF1(_L("NetworkProtocolProxy << ProcessSessionComplete()"));			
						iProxy->CallL(ENetMsgProcessSessionComplete, &iSessionId, &reason);

						// << ProcessStatusUpdate()
						MLbsNetworkProtocolObserver::TLbsNetProtocolServiceMask activeServiceMask2 = MLbsNetworkProtocolObserver::EServiceNone;	
						iStep.INFO_PRINTF1(_L("NetworkProtocolProxy << ProcessStatusUpdate(EServiceNone)"));			
						iProxy->CallL(ENetMsgProcessStatusUpdate, &activeServiceMask2);

						iNetworkProtocolProxyStep = ENetworkProtocolProxyStepNoSessionRunning;
						iProxy->WaitForResponseL(KTimeOut, iStatus);
						SetActive();						
						}
					else
						{
						iStep.INFO_PRINTF1(_L("NetworkProtocolProxy >> CancelSelfLocation() for an older session"));
						iStep.TESTL(sessionId->SessionNum() < iSessionId.SessionNum());
						CleanupStack::PopAndDestroy(cleanupCnt);
						sessionId = NULL;
		
						iNetworkProtocolProxyStep = ENetworkProtocolProxyStepSessionWaitingForFirstMeasurments;
						iProxy->WaitForResponseL(KTimeOut, iStatus);
						SetActive();
						}
					break;
					}
				case ENetMsgGetCurrentCapabilitiesResponse:
					{
					// >> AdviceSystemStatus()
					CLbsNetworkProtocolBase::TLbsSystemStatus status;
					TInt cleanupCnt = iProxy->GetArgsLC(ENetMsgGetCurrentCapabilitiesResponse, &status);
					if(status == CLbsNetworkProtocolBase::ESystemStatusClientTracking)
						{
						iStep.INFO_PRINTF1(_L("NetworkProtocolProxy >> AdviceSystemStatus(ESystemStatusClientTracking)"));
						}
					else if(status == CLbsNetworkProtocolBase::ESystemStatusNone)
						{
						iStep.INFO_PRINTF1(_L("NetworkProtocolProxy >> AdviceSystemStatus(ESystemStatusNone)"));
						}
					else
						{
						iStep.INFO_PRINTF1(_L("NetworkProtocolProxy >> AdviceSystemStatus() with wrong status"));
						User::Leave(KErrNotSupported);
						}
					CleanupStack::PopAndDestroy(cleanupCnt);
					
					iProxy->WaitForResponseL(KSmallTimeOut, iStatus);
					SetActive();
					break;
					}					
				case ENetMsgRequestSelfLocation:
					{
					Process_RequestSelfLocationL();
					iProxy->WaitForResponseL(KTimeOut, iStatus);
					SetActive();
					break;
					}
				default:
					{
					iStep.INFO_PRINTF2(_L("Network in state ENetworkProtocolProxyStepSessionNrhRequestSent received unexpected response: %d"), response);
					User::Leave(KErrNotSupported);
					}
				}
			break;
			}
		case ENetworkProtocolProxyStepSessionWaitingForFirstMeasurmentsTimeOut:
			{
			switch(response)
				{
				case ENetMsgRequestAssistanceData:
					{
					// >> RequestAssistanceData(0)
					iStep.INFO_PRINTF1(_L("NetworkProtocolProxy >> RequestAssistanceData(0)"));
					TLbsAsistanceDataGroup dataMask;
					TInt cleanupCnt = iProxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataMask);
					iStep.TESTL(dataMask == EAssistanceDataNone);
					CleanupStack::PopAndDestroy(cleanupCnt);
					
					TTimeIntervalMicroSeconds microseconds;
					TTime stopTime;
					stopTime.HomeTime();
					microseconds = stopTime.MicroSecondsFrom(iAlpha2StartTime); 
					TInt64 timeElapsed = microseconds.Int64();

					// Test that we do not get response before alpha2 has expired:
					TInt timeOut = KAlphaTimer - timeElapsed - KDelta > 0 ? KAlphaTimer - timeElapsed - KDelta : 0;
					iProxy->WaitForResponseL(timeOut, iStatus);
					SetActive();
					break;
					}
				case ENetMsgGetCurrentCapabilitiesResponse:
					{
					// >> AdviceSystemStatus()
					CLbsNetworkProtocolBase::TLbsSystemStatus status;
					TInt cleanupCnt = iProxy->GetArgsLC(ENetMsgGetCurrentCapabilitiesResponse, &status);
					if(status == CLbsNetworkProtocolBase::ESystemStatusClientTracking)
						{
						iStep.INFO_PRINTF1(_L("NetworkProtocolProxy >> AdviceSystemStatus(ESystemStatusClientTracking)"));
						}
					else if(status == CLbsNetworkProtocolBase::ESystemStatusNone)
						{
						iStep.INFO_PRINTF1(_L("NetworkProtocolProxy >> AdviceSystemStatus(ESystemStatusNone)"));
						}
					else
						{
						iStep.INFO_PRINTF1(_L("NetworkProtocolProxy >> AdviceSystemStatus() with wrong status"));
						User::Leave(KErrNotSupported);
						}
					CleanupStack::PopAndDestroy(cleanupCnt);
					
					TTimeIntervalMicroSeconds microseconds;
					TTime stopTime;
					stopTime.HomeTime();
					microseconds = stopTime.MicroSecondsFrom(iAlpha2StartTime); 
					TInt64 timeElapsed = microseconds.Int64();

					// Test that we do not get response before alpha2 has expired:
					TInt timeOut = KAlphaTimer - timeElapsed - KDelta > 0 ? KAlphaTimer - timeElapsed - KDelta : 0;
					iProxy->WaitForResponseL(timeOut, iStatus);
					SetActive();
					break;
					}
				case ENetMsgCancelSelfLocation:
					{
					// >> CancelSelfLocation()
					TLbsNetSessionId* sessionId = NULL;
					TInt cancelReason = KErrNone;
					TInt cleanupCnt;
					
					cleanupCnt = iProxy->GetArgsLC(ENetMsgCancelSelfLocation, &sessionId, &cancelReason);
					if(sessionId->SessionNum() == iSessionId.SessionNum())
						{ // should complete the session
						iStep.INFO_PRINTF1(_L("NetworkProtocolProxy >> CancelSelfLocation()"));
						CleanupStack::PopAndDestroy(cleanupCnt);
						
						// << ProcessSessionComplete()
						TInt reason = KErrNone;
						iStep.INFO_PRINTF1(_L("NetworkProtocolProxy << ProcessSessionComplete()"));			
						iProxy->CallL(ENetMsgProcessSessionComplete, &iSessionId, &reason);

						// << ProcessStatusUpdate()
						MLbsNetworkProtocolObserver::TLbsNetProtocolServiceMask activeServiceMask2 = MLbsNetworkProtocolObserver::EServiceNone;	
						iStep.INFO_PRINTF1(_L("NetworkProtocolProxy << ProcessStatusUpdate(EServiceNone)"));			
						iProxy->CallL(ENetMsgProcessStatusUpdate, &activeServiceMask2);

						iNetworkProtocolProxyStep = ENetworkProtocolProxyStepNoSessionRunning;
						iProxy->WaitForResponseL(KTimeOut, iStatus);
						SetActive();						
						}
					else
						{
						iStep.INFO_PRINTF1(_L("NetworkProtocolProxy >> CancelSelfLocation() for an older session"));
						iStep.TESTL(sessionId->SessionNum() < iSessionId.SessionNum());
						CleanupStack::PopAndDestroy(cleanupCnt);
						sessionId = NULL;
		
						TTimeIntervalMicroSeconds microseconds;
						TTime stopTime;
						stopTime.HomeTime();
						microseconds = stopTime.MicroSecondsFrom(iAlpha2StartTime); 
						TInt64 timeElapsed = microseconds.Int64();
	
						// Test that we do not get response before alpha2 has expired:
						TInt timeOut = KAlphaTimer - timeElapsed - KDelta > 0 ? KAlphaTimer - timeElapsed - KDelta : 0;
						iProxy->WaitForResponseL(timeOut, iStatus);
						SetActive();
						}
					break;
					}
				case ENetMsgTimeoutExpired:
					{
					// >> Alpha2 timeout
					iStep.INFO_PRINTF1(_L("NetworkProtocolProxy - Network expecting measurements after timeout"));
					
					iNetworkProtocolProxyStep = ENetworkProtocolProxyStepSessionWaitingForFirstMeasurments;
					iProxy->WaitForResponseL(2 * 1000* KDelta, iStatus);
					SetActive();
					break;
					}
				case ENetMsgRespondLocationRequest:
					{ // If the module sends an accurate enough position then the Alpha2 timer might not time-out so check we received positions
					// >> RespondLocationRequest(gpspos)
					iStep.INFO_PRINTF1(_L("NetworkProtocolProxy >> RespondLocationRequest(gpspos)"));
					RequestNetworkMethod();
					DecideWhatNetworkDoesntReceive();
					iStep.TESTL(iNetworkExpectsPositions);
					TLbsNetSessionId* sessionId = NULL;
					TPositionInfo* positionInfo = NULL;
					TInt reason;
					TInt cleanupCnt = iProxy->GetArgsLC(ENetMsgRespondLocationRequest, &sessionId, &reason, &positionInfo);
					
					// check it is a position
					iStep.TESTL(positionInfo->PositionClassType() == (EPositionInfoClass|EPositionCourseInfoClass|EPositionSatelliteInfoClass|EPositionExtendedSatelliteInfoClass));
					iStep.TESTL(sessionId->SessionNum() == iSessionId.SessionNum());
					iStep.TESTL(reason == KErrNone);
					
					// << ProcessLocationUpdate(FNP)
					iStep.INFO_PRINTF1(_L("NetworkProtocolProxy << ProcessLocationUpdate(SessionId, FinalNetworkPosition)"));
					iProxy->CallL(ENetMsgProcessLocationUpdate, &iSessionId, positionInfo);
					CleanupStack::PopAndDestroy(cleanupCnt);

					iNetworkProtocolProxyStep = ENetworkProtocolProxyStepSessionPositionSent;
					iProxy->WaitForResponseL(KSmallTimeOut, iStatus);
					SetActive();
					break;
					}
				default:
					{
					iStep.INFO_PRINTF2(_L("Network in state ENetworkProtocolProxyStepSessionWaitingForFirstMeasurmentsTimeOut received unexpected response: %d"), response);
					User::Leave(KErrNotSupported);
					}
				}
			break;
			}
		case ENetworkProtocolProxyStepSessionWaitingForFirstMeasurments:
			{
			switch(response)
				{
				case ENetMsgRequestAssistanceData:
					{
					// >> RequestAssistanceData(0)
					iStep.INFO_PRINTF1(_L("NetworkProtocolProxy >> RequestAssistanceData(0)"));
					TLbsAsistanceDataGroup dataMask;
					TInt cleanupCnt = iProxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataMask);
					iStep.TESTL(dataMask == EAssistanceDataNone);
					CleanupStack::PopAndDestroy(cleanupCnt);
					
					iProxy->WaitForResponseL(KTimeOut, iStatus);
					SetActive();
					break;
					}
				case ENetMsgCancelSelfLocation:
					{
					// >> CancelSelfLocation()
					TLbsNetSessionId* sessionId = NULL;
					TInt cancelReason = KErrNone;
					TInt cleanupCnt;
					
					cleanupCnt = iProxy->GetArgsLC(ENetMsgCancelSelfLocation, &sessionId, &cancelReason);
					if(sessionId->SessionNum() == iSessionId.SessionNum())
						{ // should complete the session
						iStep.INFO_PRINTF1(_L("NetworkProtocolProxy >> CancelSelfLocation()"));
						CleanupStack::PopAndDestroy(cleanupCnt);
						
						// << ProcessSessionComplete()
						TInt reason = KErrNone;
						iStep.INFO_PRINTF1(_L("NetworkProtocolProxy << ProcessSessionComplete()"));			
						iProxy->CallL(ENetMsgProcessSessionComplete, &iSessionId, &reason);

						// << ProcessStatusUpdate()
						MLbsNetworkProtocolObserver::TLbsNetProtocolServiceMask activeServiceMask2 = MLbsNetworkProtocolObserver::EServiceNone;	
						iStep.INFO_PRINTF1(_L("NetworkProtocolProxy << ProcessStatusUpdate(EServiceNone)"));			
						iProxy->CallL(ENetMsgProcessStatusUpdate, &activeServiceMask2);

						iNetworkProtocolProxyStep = ENetworkProtocolProxyStepNoSessionRunning;
						iProxy->WaitForResponseL(KTimeOut, iStatus);
						SetActive();						
						}
					else
						{
						iStep.INFO_PRINTF1(_L("NetworkProtocolProxy >> CancelSelfLocation() for an older session"));
						iStep.TESTL(sessionId->SessionNum() < iSessionId.SessionNum());
						CleanupStack::PopAndDestroy(cleanupCnt);
						sessionId = NULL;
		
						iProxy->WaitForResponseL(KTimeOut, iStatus);
						SetActive();
						}
					break;
					}
				case ENetMsgRespondLocationRequest:
					{
					// >> RespondLocationRequest(meas)
					TLbsNetSessionId* sessionId = NULL;
					TPositionInfo* positionInfo = NULL;
					TInt reason;
					TInt cleanupCnt = iProxy->GetArgsLC(ENetMsgRespondLocationRequest, &sessionId, &reason, &positionInfo);
					RequestNetworkMethod();
					DecideWhatNetworkDoesntReceive();

					// check it is a position
					if(positionInfo->PositionClassType() == EPositionGpsMeasurementInfoClass)
						{
						iStep.INFO_PRINTF1(_L("NetworkProtocolProxy >> RespondLocationRequest(meas)"));
						iStep.TESTL(iNetworkExpectsMeasurments);
						iStep.TESTL(sessionId->SessionNum() == iSessionId.SessionNum());	// module sends NAN measurement first
						if(reason != KErrNone)
							{
							iStep.INFO_PRINTF2(_L("NetworkProtocolProxy reason = 0x%x"), reason);
							}
						iStep.TESTL(reason == KErrNone);
						CleanupStack::PopAndDestroy(cleanupCnt);
						if(iPlannedPositionOriginator == EPositionOriginatorModule)
							{
							if(iNetworkExpectsPositions)
								{
								// << ProcessLocationRequest(SessionId, HybridMode, t)
								iStep.INFO_PRINTF1(_L("NetworkProtocolProxy << ProcessLocationRequest(SessionId, HybridMode, t)"));
								TBool emergency = EFalse;
								MLbsNetworkProtocolObserver::TLbsNetProtocolService	service = MLbsNetworkProtocolObserver::EServiceSelfLocation;
								TLbsNetPosRequestQuality quality = ArgUtils::Quality();
								quality.SetMaxFixTime(KT);
								TLbsNetPosRequestMethod method  = RequestNetworkMethod();
								iProxy->CallL(ENetMsgProcessLocationRequest, &iSessionId, &emergency, &service, &quality, &method);
			
								iNetworkProtocolProxyStep = ENetworkProtocolProxyStepSessionMeasurmentsReceived;
								iProxy->WaitForResponseL(KTimeOut, iStatus);
								SetActive();
								}
							else
								{
								iNetworkProtocolProxyStep = ENetworkProtocolProxyStepSessionPositionSent;
								iProxy->WaitForResponseL(KSmallTimeOut, iStatus);
								SetActive();
								}
							}
						else if(iPlannedPositionOriginator == EPositionOriginatorNetwork)
							{
							TPositionInfo positionInfo = ArgUtils::AccurateNetworkPositionInfo();
							// << ProcessLocationUpdate(SessionId, FinalNetworkPosition)
							// Return FinalNetworkPosition
							iStep.INFO_PRINTF1(_L("NetworkProtocolProxy << ProcessLocationUpdate(SessionId, FNP)"));
							iProxy->CallL(ENetMsgProcessLocationUpdate, &iSessionId, &positionInfo);
							
							iNetworkProtocolProxyStep = ENetworkProtocolProxyStepSessionPositionSent;
							iProxy->WaitForResponseL(KSmallTimeOut, iStatus);
							SetActive();
							}
						}
					else
						{
						// >> RespondLocationRequest(gpspos)
						iStep.INFO_PRINTF1(_L("NetworkProtocolProxy >> RespondLocationRequest(gpspos)"));
						// check it is a position
						iStep.TESTL(positionInfo->PositionClassType() == (EPositionInfoClass|EPositionCourseInfoClass|EPositionSatelliteInfoClass|EPositionExtendedSatelliteInfoClass));
						iStep.TESTL(sessionId->SessionNum() == iSessionId.SessionNum());
						iStep.INFO_PRINTF3(_L("NetworkProtocolProxy reason = %d(0x%x)"), reason,reason);
						if(reason != KErrPositionNoGpsUpdate)
							{
							iStep.TESTL(reason == KErrNone);
							}
						iStep.TESTL(iNetworkExpectsPositions);
						
						// << ProcessLocationUpdate(FNP)
						iStep.INFO_PRINTF1(_L("NetworkProtocolProxy << ProcessLocationUpdate(SessionId, FinalNetworkPosition)"));
						iProxy->CallL(ENetMsgProcessLocationUpdate, &iSessionId, positionInfo);
						CleanupStack::PopAndDestroy(cleanupCnt);

						iNetworkProtocolProxyStep = ENetworkProtocolProxyStepSessionPositionSent;
						iProxy->WaitForResponseL(KSmallTimeOut, iStatus);
						SetActive();
						}
					break;
					}
				default:
					{
					iStep.INFO_PRINTF2(_L("Network in state ENetworkProtocolProxyStepSessionWaitingForFirstMeasurments received unexpected response: %d"), response);
					User::Leave(KErrNotSupported);
					}
				}
			break;
			}
		case ENetworkProtocolProxyStepSessionMeasurmentsReceived:
			{
			switch(response)
				{
				case ENetMsgRequestAssistanceData:
					{
					// >> RequestAssistanceData(0)
					iStep.INFO_PRINTF1(_L("NetworkProtocolProxy >> RequestAssistanceData(0)"));
					TLbsAsistanceDataGroup dataMask;
					TInt cleanupCnt = iProxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataMask);
					iStep.TESTL(dataMask == EAssistanceDataNone);
					CleanupStack::PopAndDestroy(cleanupCnt);
					
					iProxy->WaitForResponseL(KTimeOut, iStatus);
					SetActive();
					break;
					}
				case ENetMsgRespondLocationRequest:
					{ // If the module sends an accurate enough position then the Alpha2 timer might not time-out so check we received positions
					// >> RespondLocationRequest(gpspos/meas)
					TLbsNetSessionId* sessionId = NULL;
					TPositionInfo* positionInfo = NULL;
					TInt reason;
					TInt cleanupCnt = iProxy->GetArgsLC(ENetMsgRespondLocationRequest, &sessionId, &reason, &positionInfo);
					RequestNetworkMethod();
					DecideWhatNetworkDoesntReceive();
					
					// check it is a position
					if(positionInfo->PositionClassType() == EPositionGpsMeasurementInfoClass)
						{ // received more measurments
						// >> RespondLocationRequest(meas)
						iStep.TESTL(iNetworkExpectsMeasurments);
						iStep.INFO_PRINTF1(_L("NetworkProtocolProxy >> RespondLocationRequest(meas)"));
						iStep.TESTL(iNetworkExpectsMeasurments);
						iStep.TESTL(sessionId->SessionNum() == iSessionId.SessionNum());	// module sends NAN measurement first
						if(reason != KErrNone)
							{
							iStep.INFO_PRINTF2(_L("NetworkProtocolProxy reason = 0x%x"), reason);
							}
						iStep.TESTL(reason == KErrNone);
						iStep.TESTL(iPlannedPositionOriginator == EPositionOriginatorModule);
						iStep.TESTL(iNetworkExpectsPositions);
						// << ProcessLocationRequest(SessionId, HybridMode, t)
						iStep.INFO_PRINTF1(_L("NetworkProtocolProxy << ProcessLocationRequest(SessionId, HybridMode, t)"));
						TBool emergency = EFalse;
						MLbsNetworkProtocolObserver::TLbsNetProtocolService	service = MLbsNetworkProtocolObserver::EServiceSelfLocation;
						TLbsNetPosRequestQuality quality = ArgUtils::Quality();
						quality.SetMaxFixTime(KT);
						TLbsNetPosRequestMethod method  = RequestNetworkMethod();
						iProxy->CallL(ENetMsgProcessLocationRequest, &iSessionId, &emergency, &service, &quality, &method);
	
						iProxy->WaitForResponseL(KTimeOut, iStatus);
						SetActive();
						}
					else
						{ // received a position
						iStep.TESTL(iNetworkExpectsPositions);
						iStep.TESTL(positionInfo->PositionClassType() == (EPositionInfoClass|EPositionCourseInfoClass|EPositionSatelliteInfoClass|EPositionExtendedSatelliteInfoClass));
						iStep.TESTL(sessionId->SessionNum() == iSessionId.SessionNum());
						iStep.TESTL(reason == KErrNone);
						
						// << ProcessLocationUpdate(FNP)
						iStep.INFO_PRINTF1(_L("NetworkProtocolProxy << ProcessLocationUpdate(SessionId, FinalNetworkPosition)"));
						iProxy->CallL(ENetMsgProcessLocationUpdate, &iSessionId, positionInfo);

						iNetworkProtocolProxyStep = ENetworkProtocolProxyStepSessionPositionSent;
						iProxy->WaitForResponseL(KSmallTimeOut, iStatus);
						SetActive();
						}
					CleanupStack::PopAndDestroy(cleanupCnt);
					break;
					}
				default:
					{
					iStep.INFO_PRINTF2(_L("Network in state ENetworkProtocolProxyStepSessionMeasurmentsReceived received unexpected response: %d"), response);
					User::Leave(KErrNotSupported);
					}
				}
			break;
			}

		case ENetworkProtocolProxyStepSessionPositionSent:
			{
			switch(response)
				{
				case ENetMsgRequestAssistanceData:
					{
					// >> RequestAssistanceData(0)
					iStep.INFO_PRINTF1(_L("NetworkProtocolProxy >> RequestAssistanceData(0)"));
					TLbsAsistanceDataGroup dataMask;
					TInt cleanupCnt = iProxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataMask);
					iStep.TESTL(dataMask == EAssistanceDataNone);
					CleanupStack::PopAndDestroy(cleanupCnt);
					
					iProxy->WaitForResponseL(KSmallTimeOut, iStatus);
					SetActive();
					break;
					}
				case ENetMsgGetCurrentCapabilitiesResponse:
					{
					// >> AdviceSystemStatus()
					CLbsNetworkProtocolBase::TLbsSystemStatus status;
					TInt cleanupCnt = iProxy->GetArgsLC(ENetMsgGetCurrentCapabilitiesResponse, &status);
					if(status == CLbsNetworkProtocolBase::ESystemStatusClientTracking)
						{
						iStep.INFO_PRINTF1(_L("NetworkProtocolProxy >> AdviceSystemStatus(ESystemStatusClientTracking)"));
						}
					else if(status == CLbsNetworkProtocolBase::ESystemStatusNone)
						{
						iStep.INFO_PRINTF1(_L("NetworkProtocolProxy >> AdviceSystemStatus(ESystemStatusNone)"));
						}
					else
						{
						iStep.INFO_PRINTF1(_L("NetworkProtocolProxy >> AdviceSystemStatus() with wrong status"));
						User::Leave(KErrNotSupported);
						}
					CleanupStack::PopAndDestroy(cleanupCnt);
					
					iProxy->WaitForResponseL(KSmallTimeOut, iStatus);
					SetActive();
					break;
					}
				case ENetMsgCancelSelfLocation:
					{
					// >> CancelSelfLocation()
					iStep.INFO_PRINTF1(_L("NetworkProtocolProxy >> CancelSelfLocation() - as result of FNP"));

					// << ProcessSessionComplete()
					TInt reason = KErrNone;
					iStep.INFO_PRINTF1(_L("NetworkProtocolProxy << ProcessSessionComplete()"));			
					iProxy->CallL(ENetMsgProcessSessionComplete, &iSessionId, &reason);

					// << ProcessStatusUpdate()
					MLbsNetworkProtocolObserver::TLbsNetProtocolServiceMask activeServiceMask2 = MLbsNetworkProtocolObserver::EServiceNone;	
					iStep.INFO_PRINTF1(_L("NetworkProtocolProxy << ProcessStatusUpdate(EServiceNone)"));			
					iProxy->CallL(ENetMsgProcessStatusUpdate, &activeServiceMask2);

					iNetworkProtocolProxyStep = ENetworkProtocolProxyStepNoSessionRunning;
					iProxy->WaitForResponseL(KTimeOut, iStatus);
					SetActive();
					break;
					}
				case ENetMsgTimeoutExpired:
					{
					// << ProcessSessionComplete()
					TInt reason = KErrNone;
					iStep.INFO_PRINTF1(_L("NetworkProtocolProxy << ProcessSessionComplete()"));			
					iProxy->CallL(ENetMsgProcessSessionComplete, &iSessionId, &reason);

					// << ProcessStatusUpdate()
					MLbsNetworkProtocolObserver::TLbsNetProtocolServiceMask activeServiceMask2 = MLbsNetworkProtocolObserver::EServiceNone;	
					iStep.INFO_PRINTF1(_L("NetworkProtocolProxy << ProcessStatusUpdate(EServiceNone)"));			
					iProxy->CallL(ENetMsgProcessStatusUpdate, &activeServiceMask2);

					iNetworkProtocolProxyStep = ENetworkProtocolProxyStepNoSessionRunning;
					iProxy->WaitForResponseL(KTimeOut, iStatus);
					SetActive();
					break;
					}
				case ENetMsgRequestSelfLocation:
					{
					Process_RequestSelfLocationL();
					iProxy->WaitForResponseL(KTimeOut, iStatus);
					SetActive();
					break;
					}
				default:
					{
					iStep.INFO_PRINTF2(_L("Network in state ENetworkProtocolProxyStepSessionPositionSent received unexpected response: %d"), response);
					User::Leave(KErrNotSupported);
					}
				}
			break;
			}

		case ENetworkProtocolProxyStepNoSessionRunning:
			{
			switch(response)
				{
				case ENetMsgCancelSelfLocation:
					{
					// >> CancelSelfLocation()
					iStep.INFO_PRINTF1(_L("NetworkProtocolProxy >> CancelSelfLocation() for an older session"));
					iProxy->WaitForResponseL(KTimeOut, iStatus);
					SetActive();
					break;
					}
				case ENetMsgTimeoutExpired:
					{ // can happen that no request has been sent through, so start waiting again
					if(iClientsFinished)
						{
						iObserver.StopTest();						
						}
					else
						{
						iProxy->WaitForResponseL(KTimeOut, iStatus);
						SetActive();
						}
					break;
					}
				case ENetMsgRequestAssistanceData:
					{
					// >> RequestAssistanceData(0)
					iStep.INFO_PRINTF1(_L("NetworkProtocolProxy >> RequestAssistanceData(0)"));
					TLbsAsistanceDataGroup dataMask;
					TInt cleanupCnt = iProxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataMask);
					iStep.TESTL(dataMask == EAssistanceDataNone);
					CleanupStack::PopAndDestroy(cleanupCnt);
					
					iProxy->WaitForResponseL(KTimeOut, iStatus);
					SetActive();
					break;
					}
				case ENetMsgGetCurrentCapabilitiesResponse:
					{
					// >> AdviceSystemStatus()
					CLbsNetworkProtocolBase::TLbsSystemStatus status;
					TInt cleanupCnt = iProxy->GetArgsLC(ENetMsgGetCurrentCapabilitiesResponse, &status);
					if(status == CLbsNetworkProtocolBase::ESystemStatusClientTracking)
						{
						iStep.INFO_PRINTF1(_L("NetworkProtocolProxy >> AdviceSystemStatus(ESystemStatusClientTracking)"));
						}
					else if(status == CLbsNetworkProtocolBase::ESystemStatusNone)
						{
						iStep.INFO_PRINTF1(_L("NetworkProtocolProxy >> AdviceSystemStatus(ESystemStatusNone)"));
						}
					else
						{
						iStep.INFO_PRINTF1(_L("NetworkProtocolProxy >> AdviceSystemStatus() with wrong status"));
						User::Leave(KErrNotSupported);
						}
					CleanupStack::PopAndDestroy(cleanupCnt);
					
					iProxy->WaitForResponseL(KTimeOut, iStatus);
					SetActive();
					break;
					}
				case ENetMsgRequestSelfLocation:
					{
					Process_RequestSelfLocationL();
					iProxy->WaitForResponseL(KTimeOut, iStatus);
					SetActive();
					break;
					}
				default:
					{
					iStep.INFO_PRINTF2(_L("Network in state ENetworkProtocolProxyStepNoSessionRunning received unexpected response: %d"), response);
					User::Leave(KErrNotSupported);
					}
				}
			break;
			}

		default:
			{
			iStep.INFO_PRINTF1(_L("Network in unexpected state"));
			User::Leave(KErrCorrupt);
			}
		}
	iObserver.OnSignalNetworkStep(iRelativeSessionId, iNetworkProtocolProxyStep);
	}
TVerdict CT_LbsHybridUEAssistedMOLRNoGPSUpdate::doTestStepL()
	{
	INFO_PRINTF1(_L("CT_LbsHybridUEAssistedMOLRNoGPSUpdate::doTestStepL()"));	
	// Stop the test if the preable failed
	TESTL(TestStepResult() == EPass);

	const TInt KTimeOut = 60*1000*1000;

	// Create Network Protocol Proxy
	CNetProtocolProxy* proxy = CNetProtocolProxy::NewL();
	CleanupStack::PushL(proxy);

	// waiting for >> AdviceSystemStatus(0) - GetCurrentCapabilitiesResponse
	INFO_PRINTF1(_L("waiting for << NotifyPositionUpdate()"));
	TESTL(proxy->WaitForResponse(KTimeOut) == ENetMsgGetCurrentCapabilitiesResponse);
	CLbsNetworkProtocolBase::TLbsSystemStatus status;
	proxy->GetArgsLC(ENetMsgGetCurrentCapabilitiesResponse, &status);
	TESTL(status == CLbsNetworkProtocolBase::ESystemStatusNone);
	//  >> AdviceSystemStatus(0) - GetCurrentCapabilitiesResponse
	INFO_PRINTF1(_L("<< NotifyPositionUpdate()"));


	// Start Test Step
	RPositionServer server;
	TESTL(KErrNone == server.Connect());
	CleanupClosePushL(server);	
	INFO_PRINTF1(_L("Connected to server"));

	RPositioner pos;
	TESTL(KErrNone == pos.Open(server));
	CleanupClosePushL(pos);
	INFO_PRINTF1(_L("Subsession created"));


	// Set the max fix time for the client request to ensure the location server does not complete the request too soon during the test.
	// after 30 secs the postion request will be timed out
	TPositionUpdateOptions posOpts(TTimeIntervalMicroSeconds(0), TTimeIntervalMicroSeconds(30* 1000 * 1000));

	pos.SetUpdateOptions(posOpts);
	
	INFO_PRINTF1(_L("Setupdate options timeout set to 30 seconds"));

	CPosServerWatcher *pWatch = CPosServerWatcher::NewLC(pos, *this);

	// Request a self-locate MoLr.
	pWatch->IssueNotifyPositionUpdate();
	INFO_PRINTF1(_L("<< NotifyPositionUpdate()"));
	// >> RequestSelfLocation()
	TESTL(proxy->WaitForResponse(KTimeOut) == ENetMsgRequestSelfLocation);
	INFO_PRINTF1(_L(">> RequestSelfLocation()"));	

	// Process the response.
	TLbsNetSessionId* 					sessionId = NULL;
	TLbsNetPosRequestOptionsAssistance*	opts = NULL;
	TInt								cleanupCnt;
	
	cleanupCnt = proxy->GetArgsLC(ENetMsgRequestSelfLocation, &sessionId, &opts);
	
	iSessionId.SetSessionNum(sessionId->SessionNum());
	iSessionId.SetSessionOwner(sessionId->SessionOwner());

	CleanupStack::PopAndDestroy(cleanupCnt);
	sessionId = NULL;
	opts = NULL;	
	
	// << ProcessStatusUpdate(EServiceSelfLocation)
	MLbsNetworkProtocolObserver::TLbsNetProtocolServiceMask activeServiceMask = MLbsNetworkProtocolObserver::EServiceSelfLocation;
	proxy->CallL(ENetMsgProcessStatusUpdate, &activeServiceMask);

	// << ProcessLocationUpdate(SessionId, RefPosition)
	TPositionInfo refPosInfo = ArgUtils::MolrReferencePositionInfo();
	proxy->CallL(ENetMsgProcessLocationUpdate, &iSessionId, &refPosInfo);
	INFO_PRINTF1(_L("<< ProcessLocationUpdate(SessionId, RefPosition)"));	


	// TEST: Get the ref pos app side.
	CheckForObserverEventTestsL(KTimeOut, *this);

	// << ProcessAssistanceData()
	TLbsAsistanceDataGroup dataMask = EAssistanceDataReferenceTime;
	RLbsAssistanceDataBuilderSet assistanceData;
	ArgUtils::PopulateLC(assistanceData);
	TInt reason = KErrNone;
	proxy->CallL(ENetMsgProcessAssistanceData, &dataMask, &assistanceData, &reason);
	CleanupStack::PopAndDestroy(); // assistanceData
	INFO_PRINTF1(_L("<< ProcessAssistanceData()"));	


	// << ProcessLocationRequest(SessionId, HybridMode, alpha2)
	TBool emergency = EFalse;
	MLbsNetworkProtocolObserver::TLbsNetProtocolService service = MLbsNetworkProtocolObserver::EServiceSelfLocation;
	TLbsNetPosRequestQuality quality = ArgUtils::Quality(); 
	quality.SetMaxFixTime(ArgUtils::Alpha2());
	TLbsNetPosRequestMethod method   = ArgUtils::RequestHybridMethod();
	proxy->CallL(ENetMsgProcessLocationRequest, &iSessionId, &emergency, &service, &quality, &method);
	INFO_PRINTF1(_L("<< ProcessLocationRequest(SessionId, HybridMode, alpha2)"));	

	// Now that the hybrid/alpha2 has been requested, record current time to verify alpha2 timer expires correctly.
	TTime startTime;
	startTime.HomeTime();

	// >> RequestAssistanceData(0)
	TESTL(proxy->WaitForResponse(KTimeOut) == ENetMsgRequestAssistanceData); 
	INFO_PRINTF1(_L(">> RequestAssistanceData(0)"));	

	CleanupStack::PopAndDestroy(proxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataMask));
	TESTL(dataMask == EAssistanceDataNone);

	// << NotifyPositionUpdate()
	pWatch->IssueNotifyPositionUpdate();
	INFO_PRINTF1(_L("<< NotifyPositionUpdate()"));	

	// >> RequestAssistanceData(0)
	TESTL(proxy->WaitForResponse(KTimeOut) == ENetMsgRequestAssistanceData); 
	CleanupStack::PopAndDestroy(proxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataMask));
	TESTL(dataMask == EAssistanceDataNone);
	INFO_PRINTF1(_L(">> RequestAssistanceData(0)"));	


	// Determine the value to take off the alpha2 value. This is required because we had to wait for the assistance data response.
	TTimeIntervalMicroSeconds microseconds;
	TTime stopTime;
	stopTime.HomeTime();
	microseconds = stopTime.MicroSecondsFrom(startTime); 
	TInt64 timeElapsed = microseconds.Int64();
	TInt delta = 2 * 1000 * 1000; // 2 secs.

	// >> RespondLocationRequest()
	TESTL(proxy->WaitForResponse(ArgUtils::Alpha2() - timeElapsed - delta) == ENetMsgTimeoutExpired);
	INFO_PRINTF1(_L(">> RespondLocationRequest()"));	

	// Wait for and process the response.
	TESTL(proxy->WaitForResponse(2 * delta) == ENetMsgRespondLocationRequest);
	INFO_PRINTF1(_L("Wait for and process the response"));	

	sessionId = NULL;
	TPositionGpsMeasurementInfo* measurementInfo = NULL;
	cleanupCnt = proxy->GetArgsLC(ENetMsgRespondLocationRequest, &sessionId, &reason, &measurementInfo);
	TESTL(sessionId->SessionNum() == iSessionId.SessionNum());
	TESTL(reason == KErrNone);
	CleanupStack::PopAndDestroy(cleanupCnt); //sessionId, measurementInfo

	// Recv -> RequestAssistanceData - we get an extra msg as the result of the A-GPS manager re-issueing a location request when it's
	//									max fix time timer expries.
	INFO_PRINTF1(_L("Wait for ENetMsgRequestAssistanceData"));	

	TESTL(proxy->WaitForResponse(KTimeOut) == ENetMsgRequestAssistanceData); 
	INFO_PRINTF1(_L("Got ENetMsgRequestAssistanceData"));	

	proxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataMask);
	TESTL(dataMask == EAssistanceDataNone);

	const TInt t = 4 * 1000 * 1000; // 4 secs, hybrid A-GPS module will deliver update after 6 + 1 seconds.
	quality.SetMaxFixTime(t);

	// << ProcessLocationRequest(SessionId, HybridMode, t)
	proxy->CallL(ENetMsgProcessLocationRequest, &iSessionId, &emergency, &service, &quality, &method);
	INFO_PRINTF1(_L("<< ProcessLocationRequest(SessionId, HybridMode, t)"));	

	// >> RequestAssistanceData(0)
	INFO_PRINTF1(_L("Wait for >> RequestAssistanceData(0) again"));	

	TESTL(proxy->WaitForResponse(KTimeOut) == ENetMsgRequestAssistanceData); 
	INFO_PRINTF1(_L(">> RequestAssistanceData(0)"));	

	proxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataMask);
	TESTL(dataMask == EAssistanceDataNone);

	// >> RespondLocationRequest().
	TESTL(proxy->WaitForResponse(t + delta) == ENetMsgRespondLocationRequest);
	INFO_PRINTF1(_L(">> RespondLocationRequest()"));	

	// Process response. Note measurement data is un-defined (and not verified) when reason contains
	// an error, which is expected here.
	sessionId = NULL;
	measurementInfo = NULL;
	cleanupCnt = proxy->GetArgsLC(ENetMsgRespondLocationRequest, &sessionId, &reason, &measurementInfo);			
	TESTL(sessionId->SessionNum() == iSessionId.SessionNum());
	TESTL(reason == KErrPositionNoGpsUpdate);
	CleanupStack::PopAndDestroy(cleanupCnt);// sessionId, measurementInfo/positionInfo
	
	// >> RequestAssistanceData - we get an extra msg as the result of the A-GPS manager re-issueing a location request when it's
	//									max fix time timer expries.
	TESTL(proxy->WaitForResponse(KTimeOut) == ENetMsgRequestAssistanceData);
	INFO_PRINTF1(_L(">>> RequestAssistanceData"));	

	proxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataMask);
	TESTL(dataMask == EAssistanceDataNone);
		
	// << ProcessSessionComplete(SessionId, KErrNone)	
	reason = KErrNone;
	proxy->CallL(ENetMsgProcessSessionComplete, &iSessionId, &reason);
	INFO_PRINTF1(_L("<< ProcessSessionComplete(SessionId, KErrNone)"));	


	// << ENetMsgProcessStatusUpdate()
	MLbsNetworkProtocolObserver::TLbsNetProtocolServiceMask serviceMask = MLbsNetworkProtocolObserver::EServiceNone;
	proxy->CallL(ENetMsgProcessStatusUpdate, &serviceMask);
	INFO_PRINTF1(_L("<< ENetMsgProcessStatusUpdate()"));	

	
	// Wait for the LBS responses due to the Session Complete. NPUD still outstanding so resend 
	// requests for SelfLocation and we may also get a request for Assistance Data. This is timing 
	// related since the PM's SessionComplete is sent to the AGPS Manager and the NRH, and the NRH
	// then sends a cancel message to the AGPS manager.  These events trigger active objects and
	// both AOs will make a RequestLocationUpdate call to the Int. Module.  Another AO in the Int.
	// module will respond with an assistance data request.  However, depending on timing, the 2nd
	// call to RequestLocationUpdate may cancel the AO set off by the 1st call.  Thus we may get 1
	// (most likely) or 2 assistance data requests.  These will result in a SelfLocation request 
	// always being sent to the PM but sometimes the PM may get a request for Assistance Data.
		
	// Some time later (imperically < 20 secs but could be worked out by going through the test code)
	// the NPUD maxFixTime timer will fire which will cause the SelfLocation request to be cancelled.
	
	// Sometimes it can happen that the session complete arrives quickly enough and no 
	// further response is given by LBS. This was seen in SMP.
		
		TInt selfLocationCount = 0;
		TInt assistanceDataCount = 0;
		TInt cancelCount = 0;
		TInt othersCount = 0;
		TBool noResponse(EFalse);
		TNetProtocolResponseType response = ENetMsgNullResponse;
		
		while ((cancelCount == 0) && (othersCount == 0) && !noResponse)
			{
			response = proxy->WaitForResponse(20*1000*1000);  // wait for a max of 20secs
			switch (response)
				{
				case ENetMsgTimeoutExpired:
					{
					noResponse = ETrue;
					INFO_PRINTF1(_L(">> No further response was received"));
					break;
					}
				case ENetMsgCancelSelfLocation:
					{
					cancelCount++;
					INFO_PRINTF1(_L(">> Wait for CancelSelfLocation"));	
					break;
					}
				case ENetMsgRequestSelfLocation:
					{
					selfLocationCount++;
					INFO_PRINTF1(_L(">> Wait for RequestSelfLocation"));	
					break;
					}
				case ENetMsgRequestAssistanceData:
					{
					assistanceDataCount++;
					INFO_PRINTF1(_L(">> Wait for RequestAssistanceData"));	
					break;
					}
				default:
					{
					othersCount++;
					INFO_PRINTF2(_L(">> Unexpected message %d"), response);	
					break;
					}
				}
			}
		if(!noResponse)
			{ // these tests should be done only if there was a response received
			TESTL(othersCount == 0);
			TESTL(selfLocationCount == 1);
			TESTL(cancelCount == 1);
			}
		
	CheckForObserverEventTestsL(KTimeOut, *this);

	// Listen for 10 seconds that there are note further messages
    TESTL(proxy->WaitForResponse(10*1000*1000) == ENetMsgTimeoutExpired);

	// Done. Now cleanup...
	CleanupStack::PopAndDestroy(pWatch);
	CleanupStack::PopAndDestroy(); // pos
	CleanupStack::PopAndDestroy(); // server	
	CleanupStack::PopAndDestroy(proxy);

	INFO_PRINTF1(_L("All DONE!"));	
	
	return TestStepResult();
	
	
	}
TVerdict CT_LbsPTAMOLRPartialEarlyComplete::doTestStepL()
{
    INFO_PRINTF1(_L("CT_LbsPTAMOLRPartialEarlyComplete::doTestStepL()"));
    // Stop the test if the preable failed
    TESTL(TestStepResult() == EPass);

    const TInt KTimeOut = 60*1000*1000;

    // Create Network Protocol Proxy
    CNetProtocolProxy* proxy = CNetProtocolProxy::NewL();
    CleanupStack::PushL(proxy);

    // >> AdviceSystemStatus(0) - GetCurrentCapabilitiesResponse
    TESTL(proxy->WaitForResponse(KTimeOut) == ENetMsgGetCurrentCapabilitiesResponse);
    CLbsNetworkProtocolBase::TLbsSystemStatus status;
    TInt cleanupCnt;
    cleanupCnt = proxy->GetArgsLC(ENetMsgGetCurrentCapabilitiesResponse, &status);
    TESTL(status == CLbsNetworkProtocolBase::ESystemStatusNone);
    CleanupStack::PopAndDestroy(cleanupCnt);


    // Start Actual Test Step
    RPositionServer server;
    TESTL(KErrNone == server.Connect());
    CleanupClosePushL(server);

    RPositioner pos;
    TESTL(KErrNone == pos.Open(server));
    CleanupClosePushL(pos);

    // Set the max fix time for the client request to ensure the location server does not complete the request too soon during the test.
    TPositionUpdateOptions posOpts(TTimeIntervalMicroSeconds(0), TTimeIntervalMicroSeconds(KMOLRFixTime), 0 , ETrue);
    pos.SetUpdateOptions(posOpts);

    CPosServerWatcher *pWatch = CPosServerWatcher::NewLC(pos, *this);


    // Client Send: Request a self-locate MoLr.
    pWatch->IssueNotifyPositionUpdate();


    //Recv: RequestSelfLocation()
    TESTL(proxy->WaitForResponse(KTimeOut) == ENetMsgRequestSelfLocation);

    // Process the response.
    TLbsNetSessionId* 					sessionId = NULL;
    TLbsNetPosRequestOptionsAssistance*	opts = NULL;

    cleanupCnt = proxy->GetArgsLC(ENetMsgRequestSelfLocation, &sessionId, &opts);

    TBool qualitycheck = ArgUtils::CompareQuality(	opts,
                         ETrue,
                         KMinHorizontalAcc, 	/* as read from quality profile on z: */
                         KMinVerticalAcc,
                         KMOLRFixTime,
                         0,
                         EAssistanceDataReferenceTime,
                         (TPositionModuleInfo::ETechnologyNetwork
                          | TPositionModuleInfo::ETechnologyAssisted)
                                                 );
    TESTL(qualitycheck);

    iSessionId.SetSessionNum(sessionId->SessionNum());
    iSessionId.SetSessionOwner(sessionId->SessionOwner());

    CleanupStack::PopAndDestroy(cleanupCnt);


    //Send: ProcessStatusUpdate(EServiceSelfLocation)
    MLbsNetworkProtocolObserver::TLbsNetProtocolServiceMask activeServiceMask = MLbsNetworkProtocolObserver::EServiceSelfLocation;
    proxy->CallL(ENetMsgProcessStatusUpdate, &activeServiceMask);


    // Client Recv: (KPositionPartialUpdate, GPS Info)
//	in  TAP mode dont get any AGPS psotions! CheckForObserverEventTestsL(KTimeOut, *this);
//	TESTL(iState == EGpsPartialInitReceived);
//Client Send: Notify Position Update
//	pWatch->IssueNotifyPositionUpdate();


    //Recv: RequestAssistanceData(Mask=0) - as result of the second client noitfy update request.
    TLbsAsistanceDataGroup dataMask;
    TESTL(proxy->WaitForResponse(KTimeOut) == ENetMsgRequestAssistanceData);
    cleanupCnt = proxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataMask);
    TESTL(dataMask == EAssistanceDataNone);
    CleanupStack::PopAndDestroy(cleanupCnt);


    //Client Send: CompleteRequest
    TESTL(pos.CompleteRequest(EPositionerNotifyPositionUpdate) == KErrNone);

    // Client Recv: Second Partial update position - This should return with KPositionEarlyComplete
    CheckForObserverEventTestsL(KTimeOut, *this);
    TESTL(iState == EGpsPartialEarlyReceived);


    //Send: ProcessLocationUpdate(SessionId, RefPosition)
    TPositionInfo refPosInfo = ArgUtils::MolrReferencePositionInfo();
    proxy->CallL(ENetMsgProcessLocationUpdate, &iSessionId, &refPosInfo);


    //Send: ProcessAssistanceData()
    dataMask = EAssistanceDataReferenceTime;
    RLbsAssistanceDataBuilderSet assistanceData;
    ArgUtils::PopulateLC(assistanceData);
    TInt reason = KErrNone;
    proxy->CallL(ENetMsgProcessAssistanceData, &dataMask, &assistanceData, &reason);
    CleanupStack::PopAndDestroy();


    //Send: ProcessLocationRequest(SessionId, HybridMode, alpha2)
    TBool emergency = EFalse;
    MLbsNetworkProtocolObserver::TLbsNetProtocolService service = MLbsNetworkProtocolObserver::EServiceSelfLocation;
    TLbsNetPosRequestQuality quality = ArgUtils::Quality();
    quality.SetMaxFixTime(ArgUtils::Alpha2());
    TLbsNetPosRequestMethod method   = ArgUtils::RequestHybridMethod();
    proxy->CallL(ENetMsgProcessLocationRequest, &iSessionId, &emergency, &service, &quality, &method);


    //Recv: RequestAssistanceData(Mask=0)
    TESTL(proxy->WaitForResponse(KTimeOut) == ENetMsgRequestAssistanceData);
    cleanupCnt = proxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataMask);
    TESTL(dataMask == EAssistanceDataNone);
    CleanupStack::PopAndDestroy(cleanupCnt);

    //Recv: Wait for and process the response (SessionId=1, KErrNone, GpsPos2)
    TESTL(proxy->WaitForResponse(KTimeOut) == ENetMsgRespondLocationRequest);

    TPositionInfo* positionInfo = NULL;
    sessionId = NULL;
    cleanupCnt = proxy->GetArgsLC(ENetMsgRespondLocationRequest, &sessionId, &reason, &positionInfo);
    TESTL(positionInfo->PositionClassType() == (EPositionInfoClass|EPositionCourseInfoClass|EPositionSatelliteInfoClass));
    TESTL(sessionId->SessionNum() == iSessionId.SessionNum());
    TESTL(reason == KErrNone);
    CleanupStack::PopAndDestroy(cleanupCnt);


    //Send: ProcessLocationUpdate(SessionId, FinalNetworkPosition)
    TPositionInfo networkPosInfo = ArgUtils::MolrNetworkPositionInfo();
    proxy->CallL(ENetMsgProcessLocationUpdate, &iSessionId, &networkPosInfo);


    //Send: ProcessSessionComplete(SessionId, KErrNone)
    reason = KErrNone;
    proxy->CallL(ENetMsgProcessSessionComplete, &iSessionId, &reason);


    //Send: ENetMsgProcessStatusUpdate()
    MLbsNetworkProtocolObserver::TLbsNetProtocolServiceMask serviceMask = MLbsNetworkProtocolObserver::EServiceNone;
    proxy->CallL(ENetMsgProcessStatusUpdate, &serviceMask);

    // Wait for 10 seconds to ensure no additional responses turn up.
    TInt delta = 10 * 1000 * 1000;
    TNetProtocolResponseType mType = proxy->WaitForResponse(delta);
    TESTL(mType == ENetMsgTimeoutExpired);


    //Done. Now cleanup...
    CleanupStack::PopAndDestroy(pWatch);
    CleanupStack::PopAndDestroy(); // pos
    CleanupStack::PopAndDestroy(); // server
    CleanupStack::PopAndDestroy(proxy);
    return TestStepResult();
}
TVerdict CT_LbsHybridUEAssistedMTLRTimeout::doTestStepL()
	{
	INFO_PRINTF1(_L("CT_LbsHybridUEAssistedMTLRTimeout::doTestStepL()"));	
	// Stop the test if the preable failed
	TESTL(TestStepResult() == EPass);

	const TInt KTimeOut = 60*1000*1000;
	const TInt KAdviceSystemStatusTimeout = 40*1000*1000;

	// >> AdviceSystemStatus(0)
	TESTL(iProxy->WaitForResponse(KAdviceSystemStatusTimeout) == ENetMsgGetCurrentCapabilitiesResponse);
	CLbsNetworkProtocolBase::TLbsSystemStatus status;
	TInt cleanupCnt;
	cleanupCnt = iProxy->GetArgsLC(ENetMsgGetCurrentCapabilitiesResponse, &status); 
	TESTL(status == CLbsNetworkProtocolBase::ESystemStatusNone);
	CleanupStack::PopAndDestroy(cleanupCnt);

// Initiate MTLR Start
	// << ProcessStatusUpdate()
	MLbsNetworkProtocolObserver::TLbsNetProtocolServiceMask activeServiceMask = MLbsNetworkProtocolObserver::EServiceMobileTerminated;
	iProxy->CallL(ENetMsgProcessStatusUpdate, &activeServiceMask);

	// << ProcessPrivacyRequest()
	TBool emergency = ETrue;
	TLbsNetPosRequestPrivacy privacy    = ArgUtils::Privacy();
	TLbsExternalRequestInfo requestInfo = ArgUtils::RequestInfo();
	iProxy->CallL(ENetMsgProcessPrivacyRequest, &iSessionId, &emergency, &privacy, &requestInfo);

	// >> Callback from RespondNetworkLocationRequest(ERequestAccepted)
	CheckForObserverEventTestsL(KTimeOut, *this);
	
	// >> Respond Privacy Request
	TESTL(iProxy->WaitForResponse(KTimeOut) == ENetMsgRespondPrivacyRequest);
	TLbsNetSessionId* getSessionId = NULL;
	CLbsNetworkProtocolBase::TLbsPrivacyResponse getPrivacy;
	cleanupCnt = iProxy->GetArgsLC(ENetMsgRespondPrivacyRequest, &getSessionId, &getPrivacy);
	TESTL(getSessionId->SessionNum()==iSessionId.SessionNum());
	TESTL(getPrivacy==CLbsNetworkProtocolBase::EPrivacyResponseAccepted);
	CleanupStack::PopAndDestroy(cleanupCnt);
// Initiate MTLR End

// MTLR Reference Position Notification Start
	// << ProcessLocationUpdate()
	TPositionInfo positionInfo = ArgUtils::ReferencePositionInfo();
	iProxy->CallL(ENetMsgProcessLocationUpdate, &iSessionId, &positionInfo);
// MTLR Reference Position Notification Stop

// MTLR Assistance Data Notification Start
	// << ProcessAssistanceData()
	TLbsAsistanceDataGroup dataRequestMask = EAssistanceDataReferenceTime;
	RLbsAssistanceDataBuilderSet assistanceData;
	ArgUtils::PopulateLC(assistanceData);
	TInt reason = KErrNone;
	iProxy->CallL(ENetMsgProcessAssistanceData, &dataRequestMask, &assistanceData, &reason);
	CleanupStack::PopAndDestroy(); //assistanceData
// MTLR Assistance Data Notification Stop

// MTLR Network Location Request Start
	// << ProcessLocationRequest()
	MLbsNetworkProtocolObserver::TLbsNetProtocolService service = MLbsNetworkProtocolObserver::EServiceMobileTerminated;
	TLbsNetPosRequestQuality quality = ArgUtils::QualityAlpha2(); 
	TLbsNetPosRequestMethod method   = ArgUtils::RequestHybridMethod();
	iProxy->CallL(ENetMsgProcessLocationRequest, &iSessionId, &emergency, &service, &quality, &method);
// MTLR Network Location Request Stop

	//Start the timer
	TTime timerStart;
	timerStart.HomeTime();
	
	// >> Callback from ProcessNetworkPostionUpdate(refPosition)
	CheckForObserverEventTestsL(KTimeOut, *this);
	
// >> RequestAssistanceData(0)
	TESTL(iProxy->WaitForResponse(KTimeOut) == ENetMsgRequestAssistanceData); 
	TLbsAsistanceDataGroup dataGroup;
	cleanupCnt = iProxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataGroup);
	TESTL(dataGroup == EAssistanceDataNone);
	CleanupStack::PopAndDestroy(cleanupCnt);

	//Find the time elapsed from timer
	TTimeIntervalMicroSeconds microseconds;
 	TTime timerStop;
 	timerStop.HomeTime();
 	microseconds = timerStop.MicroSecondsFrom(timerStart); 
	TInt64 timeElapsed = microseconds.Int64();
		
	// >> RespondLocationRequest()
	//Test that we do not get response before alpha2 has expired
	//At the moment, the test below fails and leaves since respond reaches us before alpha2 times out. We are not in hybrid mode.
	TESTL(iProxy->WaitForResponse(ArgUtils::Alpha2()-timeElapsed-KDelta) == ENetMsgTimeoutExpired); 
	TESTL(iProxy->WaitForResponse(2*KDelta) == ENetMsgRespondLocationRequest); 

	getSessionId = NULL;
	TInt getReason = KErrNone;
	TPositionSatelliteInfo* getPositionInfo = NULL;
	cleanupCnt = iProxy->GetArgsLC(ENetMsgRespondLocationRequest, &getSessionId, &getReason, &getPositionInfo);
	TESTL(getSessionId->SessionNum() == iSessionId.SessionNum());
	TESTL(getReason==KErrNone); 
	CleanupStack::PopAndDestroy(cleanupCnt);

//NHR's timer alpha2 times out -> Hybrid Positioning Start	
	//<< ProcessLocationRequest() 
	quality = ArgUtils::Quality(); //Set timeout to t 
	iProxy->CallL(ENetMsgProcessLocationRequest, &iSessionId, &emergency, &service, &quality, &method);
	
	// >> RequestAssistanceData(0)
	TESTL(iProxy->WaitForResponse(KTimeOut) == ENetMsgRequestAssistanceData); 
	cleanupCnt = iProxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataGroup);
	TESTL(dataGroup == EAssistanceDataNone);
	CleanupStack::PopAndDestroy(cleanupCnt);

	// >> RespondLocationRequest()
	TESTL(iProxy->WaitForResponse(KTTimeout) == ENetMsgRespondLocationRequest); 
	getSessionId = NULL;
	getReason = KErrNone;
	getPositionInfo = NULL;
	cleanupCnt = iProxy->GetArgsLC(ENetMsgRespondLocationRequest, &getSessionId, &getReason, &getPositionInfo);
	TESTL(getSessionId->SessionNum() == iSessionId.SessionNum());
	TESTL(getReason==KErrNone);
	CleanupStack::PopAndDestroy(cleanupCnt);
		
	//<< ProcessNetworkPositionUpdate() | GPS Pos[Accurate Fix]
	CheckForObserverEventTestsL(KTimeOut, *this);
//Hybrid Positioning Stop

	/***Add extra delay to simulate the MC Release timing out ***/	
	User::After(2*KTimeOut);
	// Test that LBS is not sending any response to the Protocol Module
	TESTL(iProxy->WaitForResponse(KTimeOut) == ENetMsgTimeoutExpired); 
	
// MTLR Session Completion Start
	// << ProcessSessionComplete()
	iProxy->CallL(ENetMsgProcessSessionComplete, &iSessionId, &reason);

	// << ProcessStatusUpdate()
	MLbsNetworkProtocolObserver::TLbsNetProtocolServiceMask activeServiceMask2 = MLbsNetworkProtocolObserver::EServiceNone;	
	iProxy->CallL(ENetMsgProcessStatusUpdate, &activeServiceMask2);

	// >> Callback from ProcessRequestComplete()
	CheckForObserverEventTestsL(KTimeOut, *this);

	// Verify that the last callback was to ProcessSessionComplete()
	TESTL(iState==ERequestComplete);
// MTLR Session Completion Stop

	return TestStepResult();
	}
TVerdict CT_LbsX3PIntByMoLr::doTestStepL()
	{
	INFO_PRINTF1(_L("CT_LbsX3PIntByMoLr::doTestStepL()"));	
	// Stop the test if the preable failed
	TESTL(TestStepResult() == EPass);

	const TInt KTimeOut = 60*1000*1000;

	// Create Network Protocol Proxy
	CNetProtocolProxy* proxy = CNetProtocolProxy::NewL();
	CleanupStack::PushL(proxy);

	// >> AdviceSystemStatus(0) - GetCurrentCapabilitiesResponse
	TESTL(proxy->WaitForResponse(KTimeOut) == ENetMsgGetCurrentCapabilitiesResponse);
	CLbsNetworkProtocolBase::TLbsSystemStatus status;
	TInt cleanupCnt;
	cleanupCnt = proxy->GetArgsLC(ENetMsgGetCurrentCapabilitiesResponse, &status);
	TESTL(status == CLbsNetworkProtocolBase::ESystemStatusNone);
	CleanupStack::PopAndDestroy(cleanupCnt);
	
	// Start Test Step
	RPositionServer server;
	TESTL(KErrNone == server.Connect());
	CleanupClosePushL(server);	

	RPositioner pos;
	TESTL(KErrNone == pos.Open(server));
	CleanupClosePushL(pos);


	// Set the max fix time for the client request to ensure the location server does not complete the request too soon during the test.
	TPositionUpdateOptions posOpts(TTimeIntervalMicroSeconds(0), TTimeIntervalMicroSeconds(240000000));
	pos.SetUpdateOptions(posOpts);
	
	CPosServerWatcher *pWatch = CPosServerWatcher::NewLC(pos, *this);

	// Request a self-locate MoLr.
	pWatch->IssueNotifyPositionUpdate();

	// >> RequestSelfLocation()
	TESTL(proxy->WaitForResponse(KTimeOut) == ENetMsgRequestSelfLocation);

	// Process the response.
	TLbsNetSessionId* 					sessionId = NULL;
	TLbsNetPosRequestOptionsAssistance*	opts = NULL;
	
	cleanupCnt = proxy->GetArgsLC(ENetMsgRequestSelfLocation, &sessionId, &opts);
	
	iSessionId.SetSessionNum(sessionId->SessionNum());
	iSessionId.SetSessionOwner(sessionId->SessionOwner());

	CleanupStack::PopAndDestroy(cleanupCnt);
	sessionId = NULL;
	opts = NULL;	
	
	// << ProcessStatusUpdate(EServiceSelfLocation)
	MLbsNetworkProtocolObserver::TLbsNetProtocolServiceMask activeServiceMask = MLbsNetworkProtocolObserver::EServiceSelfLocation;
	proxy->CallL(ENetMsgProcessStatusUpdate, &activeServiceMask);

	// << ProcessLocationUpdate(SessionId, RefPosition)
	TPositionInfo refPosInfo = ArgUtils::MolrReferencePositionInfo();
	proxy->CallL(ENetMsgProcessLocationUpdate, &iSessionId, &refPosInfo);

	// TEST: Get the ref pos app side.
	CheckForObserverEventTestsL(KTimeOut, *this);

	// << ProcessAssistanceData()
	TLbsAsistanceDataGroup dataMask = EAssistanceDataReferenceTime;
	RLbsAssistanceDataBuilderSet assistanceData;
	ArgUtils::PopulateLC(assistanceData);
	TInt reason = KErrNone;
	proxy->CallL(ENetMsgProcessAssistanceData, &dataMask, &assistanceData, &reason);
	CleanupStack::PopAndDestroy(); // assistanceData

	// << ProcessLocationRequest(SessionId, HybridMode, alpha2)
	TBool emergency = EFalse;
	MLbsNetworkProtocolObserver::TLbsNetProtocolService service = MLbsNetworkProtocolObserver::EServiceSelfLocation;
	TLbsNetPosRequestQuality quality = ArgUtils::Quality(); 
	quality.SetMaxFixTime(ArgUtils::Alpha2());
	TLbsNetPosRequestMethod method   = ArgUtils::RequestHybridMethod();
	proxy->CallL(ENetMsgProcessLocationRequest, &iSessionId, &emergency, &service, &quality, &method);

	// Now that the hybrid/alpha2 has been requested, record current time to verify alpha2 timer expires correctly.
	TTime startTime;
	startTime.HomeTime();

	// >> RequestAssistanceData(0)
	TESTL(proxy->WaitForResponse(KTimeOut) == ENetMsgRequestAssistanceData); 
	cleanupCnt = proxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataMask);
	TESTL(dataMask == EAssistanceDataNone);
	CleanupStack::PopAndDestroy(cleanupCnt);

	// << NotifyPositionUpdate()
	pWatch->IssueNotifyPositionUpdate();

	// >> RequestAssistanceData(0)
	TESTL(proxy->WaitForResponse(KTimeOut) == ENetMsgRequestAssistanceData); 
	cleanupCnt = proxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataMask);
	TESTL(dataMask == EAssistanceDataNone);
	CleanupStack::PopAndDestroy(cleanupCnt);
	// Determine the value to take off the alpha2 value. This is required because we had to wait for the assistance data response.
	TTimeIntervalMicroSeconds microseconds;
	TTime stopTime;
	stopTime.HomeTime();
	microseconds = stopTime.MicroSecondsFrom(startTime); 
	TInt64 timeElapsed = microseconds.Int64();
	TInt delta = 2 * 1000 * 1000; // 2 secs.

	// >> RespondLocationRequest()
	TESTL(proxy->WaitForResponse(ArgUtils::Alpha2() - timeElapsed - delta) == ENetMsgTimeoutExpired);

	// Wait for and process the response.
	TESTL(proxy->WaitForResponse(2 * delta) == ENetMsgRespondLocationRequest);		// DONT get because the measurement data bus has not been created...

	sessionId = NULL;
	TPositionGpsMeasurementInfo* measurementInfo = NULL;
	cleanupCnt = proxy->GetArgsLC(ENetMsgRespondLocationRequest, &sessionId, &reason, &measurementInfo);
	TESTL(sessionId->SessionNum() == iSessionId.SessionNum());
	TESTL(reason == KErrNone);
	CleanupStack::PopAndDestroy(cleanupCnt);//sessionId, measurementInfo

	// Recv -> RequestAssistanceData - we get an extra msg as the result of the A-GPS manager re-issueing a location request when it's
	//									max fix time timer expries.
	TESTL(proxy->WaitForResponse(KTimeOut) == ENetMsgRequestAssistanceData); 
	cleanupCnt = proxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataMask);
	TESTL(dataMask == EAssistanceDataNone);
	CleanupStack::PopAndDestroy(cleanupCnt);

	const TInt t = 8 * 1000 * 1000; // 8 secs.
	quality.SetMaxFixTime(t);

	TPositionInfo* positionInfo = NULL;
	
	for (TInt i = 0; i < KN; i++)
		{
		// << ProcessLocationRequest(SessionId, HybridMode, t)
		proxy->CallL(ENetMsgProcessLocationRequest, &iSessionId, &emergency, &service, &quality, &method);

		// >> RequestAssistanceData(0)
		TESTL(proxy->WaitForResponse(KTimeOut) == ENetMsgRequestAssistanceData); 
		cleanupCnt = proxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataMask);
		TESTL(dataMask == EAssistanceDataNone);
		CleanupStack::PopAndDestroy(cleanupCnt);

		// >> RespondLocationRequest() - first measurement, second position.
		TESTL(proxy->WaitForResponse(t + delta) == ENetMsgRespondLocationRequest);

		sessionId = NULL;
		
		// Expect measurement first time.
		if (i < (KN-1))
			{
			measurementInfo = NULL;
			cleanupCnt = proxy->GetArgsLC(ENetMsgRespondLocationRequest, &sessionId, &reason, &measurementInfo);			

			// Check it is measurement
			TESTL(measurementInfo->PositionClassType() == EPositionGpsMeasurementInfoClass);

			// >> RequestAssistanceData - we get an extra msg as the result of the A-GPS manager re-issueing a location request when it's
			//									max fix time timer expries.
			TESTL(proxy->WaitForResponse(KTimeOut) == ENetMsgRequestAssistanceData);
			
			cleanupCnt += proxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataMask);

			TESTL(dataMask == EAssistanceDataNone);
			TESTL(sessionId->SessionNum() == iSessionId.SessionNum());
			TESTL(reason == KErrNone);
			}
		
		// Expect position second time.
		else
			{
			cleanupCnt = proxy->GetArgsLC(ENetMsgRespondLocationRequest, &sessionId, &reason, &positionInfo);
			
			// check it is a position
			TESTL(positionInfo->PositionClassType() == (EPositionInfoClass|EPositionCourseInfoClass|EPositionSatelliteInfoClass|EPositionExtendedSatelliteInfoClass));

			TESTL(sessionId->SessionNum() == iSessionId.SessionNum());
			TESTL(reason == KErrNone);
			
			// Client recv - the gps position determined by the gps module.
			CheckForObserverEventTestsL(KTimeOut, *this);
			TESTL(iState == EGpsLocReceived);
			
			// << ProcessLocationUpdate(SessionId, FinalNetworkPosition)
			// Return modules' position as FinalNetworkPosition
			proxy->CallL(ENetMsgProcessLocationUpdate, &iSessionId, positionInfo);
			}

		CleanupStack::PopAndDestroy(cleanupCnt);// sessionId, measurementInfo/positionInfo
		}
		

	// << ProcessSessionComplete(SessionId, KErrNone)	
	reason = KErrNone;
	proxy->CallL(ENetMsgProcessSessionComplete, &iSessionId, &reason);

	// << ENetMsgProcessStatusUpdate()
	MLbsNetworkProtocolObserver::TLbsNetProtocolServiceMask serviceMask = MLbsNetworkProtocolObserver::EServiceNone;
	proxy->CallL(ENetMsgProcessStatusUpdate, &serviceMask);
	

// Done. Now cleanup...
	CleanupStack::PopAndDestroy(pWatch);
	CleanupStack::PopAndDestroy(); // pos
	CleanupStack::PopAndDestroy(); // server	
	CleanupStack::PopAndDestroy(proxy);
		
	return TestStepResult();
	}
/* Called when one of the stub PM's receives a message from the NG
 *
 * @param aPmId The ID of the PM that received this message
 * @param aMessageType The ID of the message type received from the PM
 */
void CT_LbsHybridMultipleTest::OnHandleNGMessage(TUint aPmId, TInt aMessageType)
{
    //Get the correct proxy
    CLbsTestNgMessageHandler* proxy = LookupProtocolModuleProxy(aPmId);
    if (!proxy)
    {
        INFO_PRINTF2(_L("ERROR: No NG proxy setup for PM%d"), aPmId);
        User::Leave(KErrNotFound);
    }

    TInt cleanupCnt;
    TInt sequenceId = KErrNotFound;

    //For each of the different message types, find out whether the message type was expected by the
    // sequence (if a session Id is sent with the message) or by any sequence (if the session Id is not
    // present).  Then confirm the message parameters are expected and then move the correct sequence
    // onto the next message.
    switch(aMessageType)
    {
    // >> AdviceSystemStatus() [2009]
    case ENetMsgGetCurrentCapabilitiesResponse:
    {
        sequenceId = WasMessageExpectedPmId(aPmId, ENetMsgGetCurrentCapabilitiesResponse);
        INFO_PRINTF2(_L("-> AdviceSystemStatus() [2009] Sq: %d"), sequenceId);

        if(sequenceId != KErrNotFound)
        {
            CLbsNetworkProtocolBase::TLbsSystemStatus status;
            cleanupCnt = proxy->ProtocolProxy()->GetArgsLC(ENetMsgGetCurrentCapabilitiesResponse, &status);
            TESTL(status == CLbsNetworkProtocolBase::ESystemStatusNone);
            CleanupStack::PopAndDestroy(cleanupCnt);
        }

        break;
    }

    // >> RespondPrivacyRequest() [2000]
    case ENetMsgRespondPrivacyRequest:
    {
        TLbsNetSessionId* getSessionId = NULL;
        CLbsNetworkProtocolBase::TLbsPrivacyResponse getPrivacy;
        cleanupCnt = proxy->ProtocolProxy()->GetArgsLC(ENetMsgRespondPrivacyRequest, &getSessionId, &getPrivacy);

        sequenceId = WasMessageExpectedSessionId(getSessionId->SessionNum(), ENetMsgRespondPrivacyRequest);
        INFO_PRINTF3(_L("-> RespondPrivacyRequest(%d) [2000] Sq: %d"), getPrivacy, sequenceId);

        if(sequenceId != KErrNotFound)
        {
            iSequences[sequenceId]->CheckRespondPrivacyRequest(getPrivacy);
        }
        CleanupStack::PopAndDestroy(cleanupCnt);//getSessionId

        break;
    }

    // >> RequestAssistanceData() [2004]
    case ENetMsgRequestAssistanceData:
    {
        sequenceId = WasMessageExpectedPmId(aPmId, ENetMsgRequestAssistanceData);

        //Request Assistance Data is a special case.  Depending upon the timing of when the messages
        // will be sent/received, it is not possible to predict in advance whether this message will
        // always arrive in some of the later sequences.  As such, a RequestAssistanceData message can
        // arrive and even if it is not expected by any of the sequences, it will not fail the test.

        if(sequenceId != KErrNotFound)
        {
            INFO_PRINTF2(_L("-> RequestAssistanceData() [2004] Sq: %d"), sequenceId);
            TLbsAsistanceDataGroup dataGroup;
            cleanupCnt = proxy->ProtocolProxy()->GetArgsLC(ENetMsgRequestAssistanceData, &dataGroup);
            CleanupStack::PopAndDestroy(cleanupCnt);
        }
        else
        {
            //Message was not expected by any sequence.  Manually set the Net Proxy off listening
            // again, so the sequence can receive the message it expected.
            INFO_PRINTF2(_L("-> RequestAssistanceData() [2004] Sq: unknown, PM: %d"), aPmId);
            proxy->WaitForResponseL(80 * 1000 * 1000);

            //Break out of the function now
            return;
        }

        break;
    }

    // >> ResponsdLocationRequest() [2001]
    case ENetMsgRespondLocationRequest:
    {
        TLbsNetSessionId* getSessionId = NULL;
        getSessionId = NULL;
        TInt getReason = KErrNone;
        TPositionSatelliteInfo* getPositionInfo = NULL;
        cleanupCnt = proxy->ProtocolProxy()->GetArgsLC(ENetMsgRespondLocationRequest, &getSessionId, &getReason, &getPositionInfo);
        sequenceId = WasMessageExpectedSessionId(getSessionId->SessionNum(), ENetMsgRespondLocationRequest);
        INFO_PRINTF3(_L("-> RespondLocationRequest(%d) [2001] Sq: %d"), getReason, sequenceId);
        CleanupStack::PopAndDestroy(cleanupCnt);
        break;
    }

    // >> RequestSelfLocation() [2005]
    case ENetMsgRequestSelfLocation:
    {
        TLbsNetSessionId* sessionId = NULL;
        TLbsNetPosRequestOptionsAssistance*	opts = NULL;
        cleanupCnt = proxy->ProtocolProxy()->GetArgsLC(ENetMsgRequestSelfLocation, &sessionId, &opts);

        sequenceId = WasMessageExpectedPmId(aPmId, ENetMsgRequestSelfLocation);
        INFO_PRINTF2(_L("-> RequestSelfLocation() [2005] Sq: %d"), sequenceId);

        if(sequenceId != KErrNotFound)
        {
            iSequences[sequenceId]->CheckSelfLocationRequest(sessionId);
        }

        CleanupStack::PopAndDestroy(cleanupCnt);
        break;
    }

    // >> CancelSelfLocation() [2006]
    case ENetMsgCancelSelfLocation:
    {
        TLbsNetSessionId* sessionId = NULL;
        TInt reason = 0;
        cleanupCnt = proxy->ProtocolProxy()->GetArgsLC(ENetMsgCancelSelfLocation, &sessionId, &reason);

        sequenceId = WasMessageExpectedSessionId(sessionId->SessionNum(), ENetMsgRequestSelfLocation);
        INFO_PRINTF2(_L("-> CancelSelfLocation() [2006] Sq: %d"), sequenceId);

        CleanupStack::PopAndDestroy(cleanupCnt);

        break;
    }

    // >> RequestTransmitLocation() [2002]
    case ENetMsgRequestTransmitLocation:
    {
        HBufC16* getThirdParty = NULL;
        TLbsNetSessionId* getSessionId = NULL;
        TInt getPriority(0);
        TInt cleanupCnt;
        cleanupCnt = proxy->ProtocolProxy()->GetArgsLC(ENetMsgRequestTransmitLocation, &getSessionId, &getThirdParty, &getPriority);

        sequenceId = WasMessageExpectedPmId(aPmId, ENetMsgRequestTransmitLocation);
        INFO_PRINTF2(_L("-> RequestTransmitLocation() [2002] Sq: %d"), sequenceId);

        if(sequenceId != KErrNotFound)
        {
            iSequences[sequenceId]->CheckRequestTransmitLocation(getSessionId, getPriority, *getThirdParty);
        }

        CleanupStack::PopAndDestroy(cleanupCnt);
        break;
    }

    // >> CancelTransmitLocation() [2003]
    case ENetMsgCancelTransmitLocation:
    {
        TLbsNetSessionId* sessionId = NULL;
        TInt reason = 0;

        cleanupCnt = proxy->ProtocolProxy()->GetArgsLC(ENetMsgCancelTransmitLocation, &sessionId, &reason);

        sequenceId = WasMessageExpectedSessionId(sessionId->SessionNum(), ENetMsgCancelTransmitLocation);
        INFO_PRINTF2(_L("-> CancelTransmitLocation() [2003] Sq: %d"), sequenceId);

        CleanupStack::PopAndDestroy(cleanupCnt);

        break;
    }

    // >> RequestNetworkLocation() [2007]
    case ENetMsgRequestNetworkLocation:
    {
        TLbsNetSessionId* sessionId = NULL;
        TLbsNetPosRequestOptionsAssistance* opts = NULL;
        cleanupCnt = proxy->ProtocolProxy()->GetArgsLC(ENetMsgRequestNetworkLocation, &sessionId, &opts);

        sequenceId = WasMessageExpectedPmId(aPmId, ENetMsgRequestNetworkLocation);

        INFO_PRINTF2(_L("-> RequestNetworkLocation() [2007] Sq: %d"), sequenceId);

        if(sequenceId != KErrNotFound)
        {
            iSequences[sequenceId]->CheckNetworkLocationRequest(sessionId);
        }

        break;
    }

    // >> CancelNetworkLocation [2008]
    case ENetMsgCancelNetworkLocation:
    {
        sequenceId = WasMessageExpectedPmId(aPmId, ENetMsgCancelNetworkLocation);

        INFO_PRINTF2(_L("-> CancelNetworkLocation() [2008] Sq: %d"), sequenceId);

        //NOTE: Currently no handling implemented for this message type

        break;
    }

    // Timeout occurred waiting for a NG Message
    case -1000:
    {
        INFO_PRINTF2(_L("Error - Timeout occurred waiting for NG message on PM: %d"), aPmId);
        break;
    }

    //Error occurred, not a recognised message.  Fail the test.
    default:
    {
        INFO_PRINTF3(_L("Error - Received invalid NG message: %d on PM: %d"), aMessageType, aPmId);
        return StopTest(KErrArgument);
    }
    }

    //If the message was expected, continue the test
    if(sequenceId != KErrNotFound)
    {
        iSequences[sequenceId]->SignalCallbackIdleStart();
    }
    else
    {
        // when an unexpected message arrives merley ignore and wait for next one!
        proxy->WaitForResponseL(80 * 1000 * 1000);
    }
}
예제 #11
0
TVerdict CT_LbsPTBMTLRCancel::doTestStepL()
	{
	INFO_PRINTF1(_L("CT_LbsPTBMTLRCancel::doTestStepL()"));	
	// Stop the test if the preamble failed
	TESTL(TestStepResult() == EPass);
	
	const TInt KTimeOut = 60*1000*1000;
	const TInt KAdviceSystemStatusTimeout = 40*1000*1000;
	const TInt KSmallTimeOut = 3*1000*1000;

	// reset integration modules count of number of cancels recieved from LBS 
	T_LbsUtils utils;
	utils.ResetIntegrationModulesCountOfCancelsL();

	// >> AdviceSystemStatus(0)
	
	TInt response = iProxy->WaitForResponse(KAdviceSystemStatusTimeout);
	if(response!=ENetMsgGetCurrentCapabilitiesResponse)
		{
		INFO_PRINTF2(_L("Response was %d"),response);
		}
	
	TESTL(response == ENetMsgGetCurrentCapabilitiesResponse);
	CLbsNetworkProtocolBase::TLbsSystemStatus status;
	TInt cleanupCnt;
	cleanupCnt = iProxy->GetArgsLC(ENetMsgGetCurrentCapabilitiesResponse, &status); 
	TESTL(status == CLbsNetworkProtocolBase::ESystemStatusNone);
	CleanupStack::PopAndDestroy(cleanupCnt);

// Initiate MTLR Start
	// << ProcessStatusUpdate()
	MLbsNetworkProtocolObserver::TLbsNetProtocolServiceMask activeServiceMask = MLbsNetworkProtocolObserver::EServiceMobileTerminated;
	iProxy->CallL(ENetMsgProcessStatusUpdate, &activeServiceMask);

	// << ProcessPrivacyRequest()
	const TBool emergency = EFalse;
	TLbsNetPosRequestPrivacy privacy    = ArgUtils::Privacy();
	TLbsExternalRequestInfo requestInfo = ArgUtils::RequestInfo();
	iProxy->CallL(ENetMsgProcessPrivacyRequest, &iSessionId, &emergency, &privacy, &requestInfo);

	// >> Callback from RespondNetworkLocationRequest(ERequestAccepted)
	CheckForObserverEventTestsL(KTimeOut, *this);
	
	// >> Respond Privacy Request
	TESTL(iProxy->WaitForResponse(KTimeOut) == ENetMsgRespondPrivacyRequest);
	TLbsNetSessionId* getSessionId = NULL;
	CLbsNetworkProtocolBase::TLbsPrivacyResponse getPrivacy;
	cleanupCnt = iProxy->GetArgsLC(ENetMsgRespondPrivacyRequest, &getSessionId, &getPrivacy);
	TESTL(getSessionId->SessionNum()==iSessionId.SessionNum());
	TESTL(getPrivacy==CLbsNetworkProtocolBase::EPrivacyResponseAccepted);
	CleanupStack::PopAndDestroy(cleanupCnt);//getSessionId
// Initiate MTLR End

// MTLR Reference Position Notification Start
	// << ProcessLocationUpdate()
	TPositionInfo positionInfo = ArgUtils::ReferencePositionInfo();
	iProxy->CallL(ENetMsgProcessLocationUpdate, &iSessionId, &positionInfo);
// MTLR Reference Position Notification Stop

// MTLR Assistance Data Notification Start
	// << ProcessAssistanceData()
	TLbsAsistanceDataGroup dataRequestMask = EAssistanceDataReferenceTime;
	RLbsAssistanceDataBuilderSet assistanceData;
	ArgUtils::PopulateLC(assistanceData);
	TInt reason = KErrNone;
	iProxy->CallL(ENetMsgProcessAssistanceData, &dataRequestMask, &assistanceData, &reason);
	CleanupStack::PopAndDestroy(); //assistanceData
// MTLR Assistance Data Notification Stop

// MTLR Network Location Request Start
	// << ProcessLocationRequest()
	MLbsNetworkProtocolObserver::TLbsNetProtocolService service = MLbsNetworkProtocolObserver::EServiceMobileTerminated;
	TLbsNetPosRequestQuality quality = ArgUtils::QualityAlpha2(); 
	TLbsNetPosRequestMethod method   = ArgUtils::RequestTerminalBasedMethod();
	iProxy->CallL(ENetMsgProcessLocationRequest, &iSessionId, &emergency, &service, &quality, &method);
// MTLR Network Location Request Stop

	// >> Callback from ProcessNetworkPostionUpdate(refPosition)
	CheckForObserverEventTestsL(KSmallTimeOut, *this);
	
// >> RequestAssistanceData(0)
	TESTL(iProxy->WaitForResponse(KSmallTimeOut) == ENetMsgRequestAssistanceData); 
	TLbsAsistanceDataGroup dataGroup;
	cleanupCnt = iProxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataGroup);
	TESTL(dataGroup == EAssistanceDataNone);
	CleanupStack::PopAndDestroy(cleanupCnt);

	InitiateCancelMTLR(iSessionId.SessionNum());
	// >> RespondLocationRequest()

	response = iProxy->WaitForResponse(KSmallTimeOut);
	TESTL(response == ENetMsgRespondLocationRequest);
	 
	getSessionId = NULL;
	TInt getReason = KErrCancel;
	TPositionSatelliteInfo* getPositionInfo = NULL;
	cleanupCnt = iProxy->GetArgsLC(ENetMsgRespondLocationRequest, &getSessionId, &getReason, &getPositionInfo);
	TESTL(getSessionId->SessionNum() == iSessionId.SessionNum());
	TESTL(getReason==KErrCancel);
	CleanupStack::PopAndDestroy(cleanupCnt); //getSessionId,getPositionInfo

// MTLR Session Completion Start
	// << ProcessSessionComplete() 
	reason = KErrCancel;
	iProxy->CallL(ENetMsgProcessSessionComplete, &iSessionId, &reason);

	// >> Callback from ProcessRequestComplete()
	CheckForObserverEventTestsL(KTimeOut, *this);

	// Verify that the last callback was to ProcessSessionComplete()
	TESTL(iState==ERequestComplete);
// MTLR Session Completion Stop
	
	// and finally check that one cancel was sent to test integration module

	TInt cancelCount  = utils.IntegrationModulesCountOfCancelsL();

	INFO_PRINTF2(_L("--- cancel count = %d"), cancelCount);
	TESTL(cancelCount== 1);
	INFO_PRINTF1(_L("CT_LbsPTBMTLRCancel::doTestStepL() END"));	

	return TestStepResult();
	}
TVerdict CT_LbsHybridUEAssistedX3PNoGPSTimeout::doTestStepL()
	{
	// Generic test step used to test the LBS Client Notify position update API.
	INFO_PRINTF1(_L("CT_LbsHybridUEAssistedX3PNoGPSTimeout::doTestStepL()"));

	// Stop the test if the preamble failed
	TESTL(TestStepResult() == EPass);
	
	const TInt KTimeOut = 30*1000*1000;
	const TInt KAdviceSystemStatusTimeout = 40*1000*1000;
	const TInt KSmallTimeOut = 3*1000*1000; 
	
	// >> AdviceSystemStatus(0)
	TESTL(iProxy->WaitForResponse(KAdviceSystemStatusTimeout) == ENetMsgGetCurrentCapabilitiesResponse);
	CLbsNetworkProtocolBase::TLbsSystemStatus status;
	TInt cleanupCnt;
	cleanupCnt = iProxy->GetArgsLC(ENetMsgGetCurrentCapabilitiesResponse, &status);
	TESTL(status == CLbsNetworkProtocolBase::ESystemStatusNone);
	CleanupStack::PopAndDestroy(cleanupCnt);
	
//Initiate X3P start
	// TransmitPosition()
	_LIT(KThirdParty,"+4407463842101"); 
	const TInt KPriority= 1;
	TLbsTransmitPositionOptions options(TTimeIntervalMicroSeconds(500*1000*1000));
	TRequestStatus refPosStatus=KRequestPending;
	TRequestStatus transPosStatus=KRequestPending;
	TPositionInfo refPosInfo;
	TPositionInfo transPosInfo;
	iTransmitter.SetTransmitOptions(options);
	iTransmitter.TransmitPosition(KThirdParty, KPriority, refPosStatus, refPosInfo, transPosStatus, transPosInfo);
	
	// RequestTransmitLocation()
	TESTL(iProxy->WaitForResponse(KTimeOut) == ENetMsgRequestTransmitLocation);
	TBufC16<14> thirdParty(KThirdParty);
	TPtr16 ptr = thirdParty.Des(); 
	HBufC16* getThirdParty = NULL;
	TLbsNetSessionId* getSessionId = NULL;
	TInt getPriority(0);
	cleanupCnt = iProxy->GetArgsLC(ENetMsgRequestTransmitLocation, &getSessionId, &getThirdParty, &getPriority); 
	TESTL(ptr.Compare(*getThirdParty)==KErrNone);	
	TESTL(getPriority == KPriority);
	iSessionId = *getSessionId; //session ID is initialised by LBS
	CleanupStack::PopAndDestroy(cleanupCnt);

	// ProcessStatusUpdate()
	MLbsNetworkProtocolObserver::TLbsNetProtocolService service = MLbsNetworkProtocolObserver::EServiceTransmitThirdParty;		
	iProxy->CallL(ENetMsgProcessStatusUpdate, &service);
//End Initiate

//Reference Position Notification Start	
	// ProcessLocationUpdate()
	refPosInfo = ArgUtils::ReferencePositionInfo();
	iProxy->CallL(ENetMsgProcessLocationUpdate, &iSessionId, &refPosInfo);
//Reference Position Notification End

//Assistance Data Notification Start
	// ProcessAssistanceData()
	TLbsAsistanceDataGroup dataRequestMask = EAssistanceDataReferenceTime;
	RLbsAssistanceDataBuilderSet assistanceData;
	ArgUtils::PopulateLC(assistanceData);
	TInt reason(KErrNone);
	iProxy->CallL(ENetMsgProcessAssistanceData, &dataRequestMask, &assistanceData, &reason);
	CleanupStack::PopAndDestroy(1); //assistanceData
// Assistance Data Notification End
	

// Network Location Request Start
	// ProcessLocationRequest()
	const TBool emergency(EFalse);
	TLbsNetPosRequestQuality quality = ArgUtils::QualityAlpha2(); 
	TLbsNetPosRequestMethod method   = ArgUtils::RequestHybridMethod();	
	iProxy->CallL(ENetMsgProcessLocationRequest, &iSessionId, &emergency, &service, &quality, &method);
// Network Location Request End

	//Start the timer
	TTime timerStart;
	timerStart.HomeTime();
	
	// RequestAssistanceData(0)
	TESTL(iProxy->WaitForResponse(KSmallTimeOut) == ENetMsgRequestAssistanceData); 
	TLbsAsistanceDataGroup dataGroup;
	cleanupCnt = iProxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataGroup);
	TESTL(dataGroup == EAssistanceDataNone);
	CleanupStack::PopAndDestroy(cleanupCnt);

	// here we wait for either of the asynchrnous requestst to complete
	User::WaitForRequest(refPosStatus, transPosStatus); 
	// but now we do expect that only the REF position asyn request to complete
	TESTL(refPosStatus==KErrNone);
	TESTL(transPosStatus.Int() == KRequestPending);

	//Find the time elapsed from timer
	TTimeIntervalMicroSeconds microseconds;
 	TTime timerStop;
 	timerStop.HomeTime();
 	microseconds = timerStop.MicroSecondsFrom(timerStart); 
	TInt64 timeElapsed = microseconds.Int64();
						
/*** NRH's Alpha2 timer expires. We enter Hybrid mode.***/
	//Test that we do not get response before alpha2 has expired
	TESTL(iProxy->WaitForResponse(KAlpha2Timeout-timeElapsed-KDelta) == ENetMsgTimeoutExpired); 
	TESTL(iProxy->WaitForResponse(2*KDelta) == ENetMsgRespondLocationRequest); 
	getSessionId = NULL;
	TInt getReason = KErrNone;
	TPositionSatelliteInfo* getPositionInfo = NULL;
	cleanupCnt = iProxy->GetArgsLC(ENetMsgRespondLocationRequest, &getSessionId, &getReason, &getPositionInfo);
	TESTL(getSessionId->SessionNum() == iSessionId.SessionNum());
	TESTL(getReason == KErrNone); 
	CleanupStack::PopAndDestroy(cleanupCnt);

	quality = ArgUtils::Quality(); 
	const TInt KN = 2;
	for(TInt i=0;i<KN;i++)
		{
		iProxy->CallL(ENetMsgProcessLocationRequest, &iSessionId, &emergency, &service, &quality, &method);
		
		timerStart.HomeTime();
		
		// RequestAssistanceData(0)
		TESTL(iProxy->WaitForResponse(KSmallTimeOut) == ENetMsgRequestAssistanceData); 
		cleanupCnt = iProxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataGroup);
		TESTL(dataGroup == EAssistanceDataNone);		
		CleanupStack::PopAndDestroy(cleanupCnt);

	 	timerStop.HomeTime();
 		microseconds = timerStop.MicroSecondsFrom(timerStart); 
		timeElapsed = microseconds.Int64();	
		
		TESTL(iProxy->WaitForResponse(KTTimeout-timeElapsed-KDelta) == ENetMsgTimeoutExpired); 
		TESTL(iProxy->WaitForResponse(2*KDelta) == ENetMsgRespondLocationRequest);	

		getSessionId = NULL;
		getReason = KErrNone;
		getPositionInfo = NULL;

		cleanupCnt = iProxy->GetArgsLC(ENetMsgRespondLocationRequest, &getSessionId, &getReason, &getPositionInfo);
		TESTL(getReason == KErrNone);
		TESTL(getSessionId->SessionNum() == iSessionId.SessionNum());
		CleanupStack::PopAndDestroy(cleanupCnt);
		} 
	
	// Alpha4 expires. 
	// The Protocol Module requests the network for the MC release
	
// Network Result Notification Start
	// Add extra delay to simulate the Facility timing out 	
	User::After(2*KTimeOut);
	// Test that LBS is not sending any response to the Protocol Module
	TESTL(iProxy->WaitForResponse(KTimeOut) == ENetMsgTimeoutExpired); 
// Network Result Notification End

// Session Complete Start
	// The network times out and pass an error to the Protocol Module, in this test, we use KErrTimedOut
	// The protocol module passes the error to the client app
	reason = KErrTimedOut; 
	iProxy->CallL(ENetMsgProcessSessionComplete, &iSessionId, &reason);

	MLbsNetworkProtocolObserver::TLbsNetProtocolServiceMask activeServiceMask = MLbsNetworkProtocolObserver::EServiceNone;
	iProxy->CallL(ENetMsgProcessStatusUpdate, &activeServiceMask);
// Session Complete End

	User::WaitForRequest(transPosStatus);  
	// We test the error returned from the network
	TESTL(transPosStatus==KErrTimedOut);
	    
	return TestStepResult();
	}
/**
Submit a verify location request.

@param aMessage The message from the client.
*/
void CSuplProxyPrivacySession::VerifyLocationRequest(const RMessage2& aMessage)
	{
	LBSLOG(ELogP1, "CSuplProxyPrivacySession::VerifyLocationRequest() Begin\n");

	TLbsNetSessionId sessionId;
	iPrivacyProtocol.GetNextSessionId(sessionId);

	TPckg<TInt> pkgReqId(sessionId.SessionNum());
	TInt error = aMessage.Write(0,pkgReqId);
	if(error != KErrNone)
		{
		aMessage.Complete(error);
		return;
		}
	
	RSemaphore semaphore;
	error = semaphore.Open(aMessage, 3, EOwnerThread);
	if(error != KErrNone)
		{
		aMessage.Complete(error);
		return;
		}
	semaphore.Signal();
	semaphore.Close();

	CSuplProxyPrivacyRequestInfo* requestInfo = NULL;
	TRAPD(err, requestInfo = CSuplProxyPrivacyRequestInfo::NewL(aMessage));
	if (err != KErrNone)
		{
		// Error creating request info object, complete with the error and return
		aMessage.Complete(err);
		return;
		}

	requestInfo->SetRequestId(sessionId.SessionNum());

    TLbsExternalRequestInfo2 extRequestInfo;
    TPckg<TLbsExternalRequestInfo2> extRequestInfoPkg(extRequestInfo);
    aMessage.Read(1,extRequestInfoPkg);
    requestInfo->SetRequestInfo(extRequestInfo);

	TLbsNetPosRequestPrivacy netPosRequestPrivacy;
	TPckg<TLbsNetPosRequestPrivacy>	netPosRequestPrivacyPkg(netPosRequestPrivacy);
	aMessage.Read(2,netPosRequestPrivacyPkg);
	requestInfo->SetRequestPrivacy(netPosRequestPrivacy);
	
	requestInfo->SetIsResponseRequired(ETrue);

	if (!IsRequestInfoValid(*requestInfo))
		{
		aMessage.Panic(KPosPrivacyPanicCategory,
					   EPosPrivSrvPanicInvalidArguments);
		delete requestInfo;
		return;
		}
	
	iPrivacyProtocol.VerifyLocationRequest(requestInfo);
	// The message should be completed later in this case

	LBSLOG(ELogP1, "CSuplProxyPrivacySession::VerifyLocationRequest() End\n");
	}
TVerdict CT_LbsATAEarlyComplete::doTestStepL()
	{
   	INFO_PRINTF1(_L("&lt;&lt;CT_LbsATAEarlyComplete::doTestStepL()"));

    INFO_PRINTF1(_L("CT_LbsATAEarlyComplete::doTestStepL()"));	
	// Stop the test if the preable failed
	TESTL(TestStepResult() == EPass);

	INFO_PRINTF1(_L("&gt;&gt;CT_LbsStep_SetupRoamSelfLocate::doTestStepL()"));
   
   	CLbsAdmin* adminApi = CLbsAdmin::NewL();
   	CleanupStack::PushL(adminApi);
   	
   	// Switch on the self locate API when roaming.
   	CLbsAdmin::TSelfLocateService serviceSetting = CLbsAdmin::ESelfLocateUnknown;
   
   	TInt err = adminApi->Set(KLbsSettingRoamingSelfLocate, CLbsAdmin::ESelfLocateOn);
   	User::LeaveIfError(err);
   	err = adminApi->Get(KLbsSettingRoamingSelfLocate, serviceSetting);	
   	User::LeaveIfError(err);
   	
   	if(serviceSetting != CLbsAdmin::ESelfLocateOn)
   		{
   		INFO_PRINTF1(_L("Self locate API admin setting didn't work"));
   		SetTestStepResult(EFail);
   		}					
   	
   	// Set gps mode when roaming.
   	CLbsAdmin::TGpsMode gpsModeSetting = CLbsAdmin::EGpsModeUnknown;
   	
  	err = adminApi->Set(KLbsSettingRoamingGpsMode, CLbsAdmin::EGpsAlwaysTerminalAssisted);
   	User::LeaveIfError(err);
   	err = adminApi->Get(KLbsSettingRoamingGpsMode, gpsModeSetting);
   	User::LeaveIfError(err);
   	
 	if (gpsModeSetting != CLbsAdmin::EGpsAlwaysTerminalAssisted)
   		{
   		INFO_PRINTF1(_L("Gps mode admin setting didn't work"));
   		SetTestStepResult(EFail);
   		}
   		
	CLbsAdmin::TSpecialFeature	ignoreAccuracy;
   	TInt err1 = adminApi->Get(KLbsSpecialFeatureIgnoreAccuracy, ignoreAccuracy);
	if (err1 != KErrNone)
		{
	  	INFO_PRINTF1(_L("&lt;&lt KLbsSpecialFeatureIgnoreAccuracy is absent in admin;"));
		}	
		else
		{
	  	INFO_PRINTF2(_L("&lt;&lt KLbsSpecialFeatureIgnoreAccuracy is in admin and it's set to %d;"),ignoreAccuracy);
		}	

  	//INFO_PRINTF1(_L("&lt;&lt Setting KLbsSpecialFeatureIgnoreAccuracy to OFF"));
	//err = adminApi->Set(KLbsSpecialFeatureIgnoreAccuracy, CLbsAdmin::ESpecialFeatureOff;);
   		
   	CleanupStack::PopAndDestroy(adminApi);
   
   	// Allow the setting to be propagated
   	User::After(2*1000*1000);
   
	const TInt KTimeOut = 60*1000*1000;

	// Create Network Protocol Proxy
	CNetProtocolProxy* proxy = CNetProtocolProxy::NewL();
	CleanupStack::PushL(proxy);

	// Recv --> GetCurrentCapabilitiesResponse.
	// Soak up the Lbs System Status (produced by A-GPS Manager startup).}
	TESTL(proxy->WaitForResponse(KTimeOut) == ENetMsgGetCurrentCapabilitiesResponse);
	CLbsNetworkProtocolBase::TLbsSystemStatus status;
	TInt cleanupCnt;
	cleanupCnt = proxy->GetArgsLC(ENetMsgGetCurrentCapabilitiesResponse, &status);
	TESTL(status == CLbsNetworkProtocolBase::ESystemStatusNone);
	CleanupStack::PopAndDestroy(cleanupCnt);


	// Setup location session and position watcher.
	RPositionServer server;
	TESTL(KErrNone == server.Connect());
	CleanupClosePushL(server);	

	RPositioner pos;
	TESTL(KErrNone == pos.Open(server));
	CleanupClosePushL(pos);

	// Set the max fix time for the client request to ensure the location server does not complete the request too soon during the test.
	TPositionUpdateOptions posOpts(TTimeIntervalMicroSeconds(0), TTimeIntervalMicroSeconds(240000000));
	pos.SetUpdateOptions(posOpts);
	CPosServerWatcher *pWatch = CPosServerWatcher::NewLC(pos, *this);


	// Client Send - a self-locate request.
	pWatch->IssueNotifyPositionUpdate();


	TESTL(proxy->WaitForResponse(KTimeOut) == ENetMsgRequestSelfLocation);

	// Process the response.
	TLbsNetSessionId* 					sessionId = NULL;
	TLbsNetPosRequestOptionsAssistance*	opts = NULL;
	
	cleanupCnt = proxy->GetArgsLC(ENetMsgRequestSelfLocation, &sessionId, &opts);

	TBool qualitycheck = ArgUtils::CompareQuality(	opts, 
													ETrue, 
													KMinHorizontalAcc, 
													KMinVerticalAcc, 
													KMOLRFixTime,
													0, 
													EAssistanceDataReferenceTime, 
													(TPositionModuleInfo::ETechnologyNetwork 
													| TPositionModuleInfo::ETechnologyAssisted)
												);
		
	TESTL(qualitycheck);
	
	iSessionId.SetSessionNum(sessionId->SessionNum());
	iSessionId.SetSessionOwner(sessionId->SessionOwner());

	CleanupStack::PopAndDestroy(cleanupCnt);
	sessionId = NULL;
	opts = NULL;	

		
	// Send <-- ProcessStatusUpdate.
	MLbsNetworkProtocolObserver::TLbsNetProtocolService serviceMask = MLbsNetworkProtocolObserver::EServiceSelfLocation;
	proxy->CallL(ENetMsgProcessStatusUpdate, &serviceMask);

	// Send <-- ProcessAssistanceData.
	TLbsAsistanceDataGroup			dataMask = EAssistanceDataReferenceTime;
	RLbsAssistanceDataBuilderSet	data;
	TInt							reason = KErrNone;
	ArgUtils::PopulateLC(data);
	proxy->CallL(ENetMsgProcessAssistanceData, &dataMask, &data, &reason);
	CleanupStack::PopAndDestroy(); // data


	// Send <-- ProcessLocationRequest.
	TBool												emergency = EFalse;
	MLbsNetworkProtocolObserver::TLbsNetProtocolService	service = MLbsNetworkProtocolObserver::EServiceSelfLocation;
	TLbsNetPosRequestQuality							quality = ArgUtils::Quality();
	TLbsNetPosRequestMethod								method = ArgUtils::RequestTAPMethod();
	quality.SetMaxFixTime(ArgUtils::Alpha2());
	proxy->CallL(ENetMsgProcessLocationRequest, &iSessionId, &emergency, &service, &quality, &method);

	// Now that the hybrid/alpha2 has been requested, record current time to verify alpha2 timer expires correctly.
	TTime startTime;
	startTime.HomeTime();


	// Recv --> RequestAssistanceData.
	TESTL(proxy->WaitForResponse(KTimeOut) == ENetMsgRequestAssistanceData); 
	cleanupCnt = proxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataMask);
	TESTL(dataMask == EAssistanceDataNone);
	CleanupStack::PopAndDestroy(cleanupCnt);

	// Determine the value to take off the alpha2 value. This is required because we had to wait for the assistance data response.
	TTimeIntervalMicroSeconds microseconds;
	TTime stopTime;
	stopTime.HomeTime();
	microseconds = stopTime.MicroSecondsFrom(startTime); 
	TInt64 timeElapsed = microseconds.Int64();


	// Recv --> RespondLocationRequest.
	// First ensure we don't recv response before Alpha2.
	TInt delta = 2 * 1000 * 1000; // 2 secs.
	TESTL(proxy->WaitForResponse(ArgUtils::Alpha2() - timeElapsed - delta) == ENetMsgTimeoutExpired);
	
	// Wait for and process the response.
	TESTL(proxy->WaitForResponse(2 * delta) == ENetMsgRespondLocationRequest);

	TPositionGpsMeasurementInfo* measurementInfo = NULL;
	cleanupCnt = proxy->GetArgsLC(ENetMsgRespondLocationRequest, &sessionId, &reason, &measurementInfo);
	TESTL(sessionId->SessionNum() == iSessionId.SessionNum());
	TESTL(reason == KErrNone);
	TESTL(measurementInfo->PositionClassType() == EPositionGpsMeasurementInfoClass);
	
	CleanupStack::PopAndDestroy(cleanupCnt);
	sessionId = NULL;
	measurementInfo = NULL;


	// Recv -> RequestAssistanceData - we get an extra msg as the result of the A-GPS manager re-issueing a location request when it's
	//									max fix time timer expries.
	TESTL(proxy->WaitForResponse(KTimeOut) == ENetMsgRequestAssistanceData); 
	cleanupCnt = proxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataMask);
	TESTL(dataMask == EAssistanceDataNone);
	CleanupStack::PopAndDestroy(cleanupCnt);

	const TInt t = 8 * 1000 * 1000; // 8 secs.
	quality.SetMaxFixTime(t);
	
	
	// Send <-- ProcessLocationUpdate - return network calculated pos.
	TPositionInfo networkPosInfo = ArgUtils::MolrNetworkPositionInfo();
	proxy->CallL(ENetMsgProcessLocationUpdate, &iSessionId, &networkPosInfo);

	// Client Recv: Second update position - This should return with KPositionEarlyComplete
	CheckForObserverEventTestsL(KTimeOut, *this);

	// Wait to ensure no additional responses turn up.
	delta = 10 * 1000 * 1000;
	TNetProtocolResponseType rtype = proxy->WaitForResponse(delta);
	
	if (rtype == ENetMsgTimeoutExpired)
		{
		INFO_PRINTF1(_L("No additional messages turned up"));
	
 		}
	else
		{
		INFO_PRINTF1(_L("Got unexpected messages"));
 		}
		
	TESTL(rtype == ENetMsgCancelSelfLocation); 

	// Send <-- ProcessSessionComplete.
	reason = KErrNone;
	proxy->CallL(ENetMsgProcessSessionComplete, &iSessionId, &reason);


	// Carryout unique test actions (the ALT sections - see sequence diagrams.
	TInt testCaseId;
	if (GetIntFromConfig(ConfigSection(), KTestCaseId, testCaseId))
		{
		switch (testCaseId)
			{
			// Test case Stop_OutsideMoLr
			case 6:
				{
				User::After(2*1000*1000);
				
				iAGpsHandler->SendRequestModuleOption(ELbsHybridModuleOptions_DisableReqAssistData, ETrue);

				// Client Send: Notify Position Update
				pWatch->IssueNotifyPositionUpdate();
		
				// now ensure that intgration moulde does NOT RequestAssistanceData
				// and thus LBS will NOT send RequestSelfLopcation to protocol module
				// and a MoLr will NOT be started 
				
	 			// Client Send: Complete Request
				TESTL(pos.CompleteRequest(EPositionerNotifyPositionUpdate) == KErrNone);
	
				// Client Recv: Second update position - This should return with KPositionEarlyComplete
				CheckForObserverEventTestsL(KTimeOut, *this);

				TESTL(iState == EGotCompleteRequestPosition);
				
				}
				break;
					
			// Test case Stop_InsideMoLr
			case 5:
				{
				// Client Send: Notify Position Update

				User::After(2*1000*1000);

				pWatch->IssueNotifyPositionUpdate();

				rtype = proxy->WaitForResponse(KTimeOut);
				TESTL(rtype == ENetMsgRequestSelfLocation);

				// Process the response.
				sessionId = NULL;
				opts = NULL;
	
				cleanupCnt = proxy->GetArgsLC(ENetMsgRequestSelfLocation, &sessionId, &opts);

				qualitycheck = ArgUtils::CompareQuality(	opts, 
											EFalse, 
											KMinHorizontalAcc, 
											KMinVerticalAcc, 
											KMOLRFixTime,
											0, 
											EAssistanceDataNone, 
											(TPositionModuleInfo::ETechnologyNetwork 
											| TPositionModuleInfo::ETechnologyAssisted)
										);
		
				TESTL(qualitycheck);
	
				iSessionId.SetSessionNum(sessionId->SessionNum());
				iSessionId.SetSessionOwner(sessionId->SessionOwner());

				CleanupStack::PopAndDestroy(cleanupCnt);
				sessionId = NULL;
				opts = NULL;	
	

				// Send <-- ProcessLocationRequest.
				TBool	emergency = EFalse;
				MLbsNetworkProtocolObserver::TLbsNetProtocolService	service = MLbsNetworkProtocolObserver::EServiceSelfLocation;
				TLbsNetPosRequestQuality quality = ArgUtils::Quality();
				TLbsNetPosRequestMethod method = ArgUtils::RequestTAPMethod();
				quality.SetMaxFixTime(ArgUtils::Alpha2());
				proxy->CallL(ENetMsgProcessLocationRequest, &iSessionId, &emergency, &service, &quality, &method);

				// Now that the hybrid/alpha2 has been requested, record current time to verify alpha2 timer expires correctly.
				TTime startTime;
				startTime.HomeTime();

				// Recv --> RequestAssistanceData.
				TESTL(proxy->WaitForResponse(KTimeOut) == ENetMsgRequestAssistanceData); 
				cleanupCnt = proxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataMask);
				TESTL(dataMask == EAssistanceDataNone);
				CleanupStack::PopAndDestroy(cleanupCnt);

    			//Client Send: CompleteRequest
				TESTL(pos.CompleteRequest(EPositionerNotifyPositionUpdate) == KErrNone);
	
				// Client Recv: Second update position - This should return with KPositionEarlyComplete
				CheckForObserverEventTestsL(KTimeOut, *this);

				TESTL(iState == EDone);

				// Wait for and process the response. Should be aRespondLocationRequest(KErrNone,FinalNetworkPosition)
				rtype = proxy->WaitForResponse(KTimeOut);
				TESTL(rtype == ENetMsgRespondLocationRequest);

				sessionId = NULL;
				TPositionInfo* positionInfo = NULL;
			
				cleanupCnt = proxy->GetArgsLC(ENetMsgRespondLocationRequest, &sessionId, &reason, &positionInfo);
			
				// Check the response.
				TESTL(positionInfo->PositionClassType() == (EPositionInfoClass|EPositionCourseInfoClass|EPositionSatelliteInfoClass));
				TESTL(sessionId->SessionNum() == iSessionId.SessionNum());
				TESTL(reason == KErrNone);
				CleanupStack::PopAndDestroy(cleanupCnt);

				// Send <-- ProcessSessionComplete.
				reason = KErrNone;
				proxy->CallL(ENetMsgProcessSessionComplete, &iSessionId, &reason);	
				}
				break;
			default:
				{
				User::Leave(KErrArgument);	
				}
				break;
			}
		}
	else
		{
	INFO_PRINTF1(_L("<FONT><B>Failed to read from ini file correctly</B></FONT>"));
	SetTestStepResult(EFail);
		}

	// Wait for 10 seconds to ensure no additional responses turn up.
	delta = 10 * 1000 * 1000;
	TNetProtocolResponseType mType = proxy->WaitForResponse(delta);
	TESTL(mType == ENetMsgTimeoutExpired);
	
	// Done. Now cleanup...
	CleanupStack::PopAndDestroy(pWatch);
	CleanupStack::PopAndDestroy(); // pos
	CleanupStack::PopAndDestroy(); // server	
	CleanupStack::PopAndDestroy(proxy);
		
	return TestStepResult();
	}
TVerdict CT_LbsHybridUEAssistedX3PAccurateGPS::doTestStepL()
	{
	// Generic test step used to test the LBS Client Notify position update API.
	INFO_PRINTF1(_L("CT_LbsHybridUEAssistedX3PAccurateGPS::doTestStepL()"));

	// Stop the test if the preamble failed
	TESTL(TestStepResult() == EPass);
	
	const TInt KTimeOut = 30*1000*1000;
	const TInt KAdviceSystemStatusTimeout = 40*1000*1000;
	const TInt KSmallTimeOut = 3*1000*1000; 
	
	// >> AdviceSystemStatus(0)
	TESTL(iProxy->WaitForResponse(KAdviceSystemStatusTimeout) == ENetMsgGetCurrentCapabilitiesResponse);
	CLbsNetworkProtocolBase::TLbsSystemStatus status;
	TInt cleanupCnt;
	cleanupCnt = iProxy->GetArgsLC(ENetMsgGetCurrentCapabilitiesResponse, &status);
	TESTL(status == CLbsNetworkProtocolBase::ESystemStatusNone);
	CleanupStack::PopAndDestroy(cleanupCnt);

//Initiate X3P start
	// TransmitPosition()
	_LIT(KThirdParty,"+4407463842101"); 
	const TInt KPriority= 6;
	TLbsTransmitPositionOptions options(TTimeIntervalMicroSeconds(50*1000*1000));
	TRequestStatus refPosStatus=KRequestPending;
	TRequestStatus transPosStatus=KRequestPending;
	TPositionInfo refPosInfo;
	TPositionInfo transPosInfo;
	iTransmitter.SetTransmitOptions(options);
	iTransmitter.TransmitPosition(KThirdParty, KPriority, refPosStatus, refPosInfo, transPosStatus, transPosInfo);
	
	// RequestTransmitLocation()
	TESTL(iProxy->WaitForResponse(KTimeOut) == ENetMsgRequestTransmitLocation);
	TBufC16<14> thirdParty(KThirdParty);
	TPtr16 ptr = thirdParty.Des(); 
	HBufC16* getThirdParty = NULL;
	TLbsNetSessionId* getSessionId = NULL;
	TInt getPriority(0);
	cleanupCnt = iProxy->GetArgsLC(ENetMsgRequestTransmitLocation, &getSessionId, &getThirdParty, &getPriority); 
	TESTL(ptr.Compare(*getThirdParty)==KErrNone);	
	TESTL(getPriority == KPriority);
	iSessionId = *getSessionId; //session ID is initialised by LBS
	CleanupStack::PopAndDestroy(cleanupCnt);

	// ProcessStatusUpdate()
	MLbsNetworkProtocolObserver::TLbsNetProtocolService service = MLbsNetworkProtocolObserver::EServiceTransmitThirdParty;		
	iProxy->CallL(ENetMsgProcessStatusUpdate, &service);
//End Initiate

//Reference Position Notification Start	
	// ProcessLocationUpdate()
	refPosInfo = ArgUtils::ReferencePositionInfo();
	iProxy->CallL(ENetMsgProcessLocationUpdate, &iSessionId, &refPosInfo);
//Reference Position Notification End

	
//Assistance Data Notification Start
	// ProcessAssistanceData()
	TLbsAsistanceDataGroup dataRequestMask = EAssistanceDataReferenceTime;
	RLbsAssistanceDataBuilderSet assistanceData;
	ArgUtils::PopulateLC(assistanceData);
	TInt reason = KErrNone;
	iProxy->CallL(ENetMsgProcessAssistanceData, &dataRequestMask, &assistanceData, &reason);
	CleanupStack::PopAndDestroy(1); //assistanceData
// Assistance Data Notification End
	
// Network Location Request Start
	// ProcessLocationRequest()
	const TBool emergency(EFalse);
	TLbsNetPosRequestQuality quality = ArgUtils::QualityAlpha2(); 
	TLbsNetPosRequestMethod method   = ArgUtils::RequestHybridMethod();	
	iProxy->CallL(ENetMsgProcessLocationRequest, &iSessionId, &emergency, &service, &quality, &method);
// Network Location Request Stop

	//Start the timer
	TTime timerStart;
	timerStart.HomeTime();
	
	// RequestAssistanceData(0)
	TESTL(iProxy->WaitForResponse(KSmallTimeOut) == ENetMsgRequestAssistanceData); 
	TLbsAsistanceDataGroup dataGroup;
	cleanupCnt = iProxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataGroup);
	TESTL(dataGroup == EAssistanceDataNone);
	CleanupStack::PopAndDestroy(cleanupCnt);

	// now wait for either to complete - but we will expect only the asynchrous request
	// waiting for the REF position to complete with KErrNone
	User::WaitForRequest(refPosStatus, transPosStatus); 
	TESTL(refPosStatus==KErrNone);
	TESTL(transPosStatus.Int() == KRequestPending);
	
	//Find the time elapsed from timer
	TTimeIntervalMicroSeconds microseconds;
 	TTime timerStop;
 	timerStop.HomeTime();
 	microseconds = timerStop.MicroSecondsFrom(timerStart); 
	TInt64 timeElapsed = microseconds.Int64();
						
/*** NRH's Alpha2 timer expires. We enter Hybrid mode.***/
	//Test that we do not get response before alpha2 has expired
	TESTL(iProxy->WaitForResponse(KAlpha2Timeout-timeElapsed-KDelta) == ENetMsgTimeoutExpired); 
	TESTL(iProxy->WaitForResponse(2*KDelta) == ENetMsgRespondLocationRequest); 	
	getSessionId = NULL;
	TInt getReason = KErrNone;
	TPositionSatelliteInfo* getPositionInfo = NULL;
	cleanupCnt = iProxy->GetArgsLC(ENetMsgRespondLocationRequest, &getSessionId, &getReason, &getPositionInfo);
	TESTL(getSessionId->SessionNum() == iSessionId.SessionNum());
	TESTL(getReason==KErrNone);
	CleanupStack::PopAndDestroy(cleanupCnt);

	// no need for looping, we assume that the next update location from GPS will give accurate fix
	quality = ArgUtils::Quality(); 
	iProxy->CallL(ENetMsgProcessLocationRequest, &iSessionId, &emergency, &service, &quality, &method);

	// RequestAssistanceData(0)
	TESTL(iProxy->WaitForResponse(KSmallTimeOut) == ENetMsgRequestAssistanceData); 
	cleanupCnt = iProxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataGroup);
	TESTL(dataGroup == EAssistanceDataNone);		
	CleanupStack::PopAndDestroy(cleanupCnt);
	
	//	GPS positions meets required accuracy. This is sent immediately to protocol module
	// The ini file should contain accurate gps fix for this test case to work
	TESTL(iProxy->WaitForResponse(KTTimeout) == ENetMsgRespondLocationRequest);	
	getSessionId = NULL;
	getReason = KErrNone;
	getPositionInfo = NULL;
	cleanupCnt = iProxy->GetArgsLC(ENetMsgRespondLocationRequest, &getSessionId, &getReason, &getPositionInfo);
	TESTL(getSessionId->SessionNum() == iSessionId.SessionNum());
	TESTL(getReason == KErrNone);
	// Test position is the same as in the ini file data fed to the GPS module
	// $update,1,2,51.5015,-0.105,50,2,3*
	TPosition gpsPos;
	getPositionInfo->GetPosition(gpsPos);
	TESTL(gpsPos.Latitude()==51.5015 && gpsPos.Longitude()==-0.105 && gpsPos.Altitude()==50 && gpsPos.HorizontalAccuracy()==2 && gpsPos.VerticalAccuracy()==3); 
	CleanupStack::PopAndDestroy(cleanupCnt);
				
// Network Result Notification Start
	// ProcessLocationUpdate()
	//Final Network Position is the GPS position
	TPositionInfo gpsPosInfo;
	gpsPosInfo.SetPosition(gpsPos);
	gpsPosInfo.SetUpdateType(EPositionUpdateGeneral);
	gpsPosInfo.SetPositionMode(TPositionModuleInfo::ETechnologyNetwork | TPositionModuleInfo::ETechnologyAssisted);
	gpsPosInfo.SetPositionModeReason(EPositionModeReasonNone);
	iProxy->CallL(ENetMsgProcessLocationUpdate, &iSessionId, &gpsPosInfo);
// Network Result Notification Stop
	
// Session Complete Start
	reason = KErrNone;
	iProxy->CallL(ENetMsgProcessSessionComplete, &iSessionId, &reason);
	MLbsNetworkProtocolObserver::TLbsNetProtocolServiceMask activeServiceMask = MLbsNetworkProtocolObserver::EServiceNone;
	iProxy->CallL(ENetMsgProcessStatusUpdate, &activeServiceMask);
// Session Complete Stop

	// the REF position request has completed, so now, after injecting the FNP and Session Complete
	// we expect that the other request to complete with KErrNone
	User::WaitForRequest(transPosStatus);
 
	TESTL(transPosStatus==KErrNone);
	return TestStepResult();
	}
TVerdict CT_LbsHybridCombinedStep_Tracking02::doTestStepL()
	{
 	INFO_PRINTF1(_L("CT_LbsHybridCombinedStep_Tracking02::doTestStepL()"));	
	// Stop the test if the preable failed
	TESTL(TestStepResult() == EPass);
	const TInt KTimeOut = 80*1000*1000;

	// data declarations common to MOLR & MTLR
    TBool emergency = EFalse;
    TInt reason = KErrNone;
    MLbsNetworkProtocolObserver::TLbsNetProtocolService service = MLbsNetworkProtocolObserver::EServiceSelfLocation;
    TLbsNetPosRequestQuality quality = ArgUtils::Quality();
    TLbsNetPosRequestMethod method   = ArgUtils::RequestHybridMethod();
    TPositionSatelliteInfo* getPositionInfo = NULL;
    MLbsNetworkProtocolObserver::TLbsNetProtocolServiceMask serviceMask1 = MLbsNetworkProtocolObserver::EServiceSelfLocation;
    MLbsNetworkProtocolObserver::TLbsNetProtocolServiceMask serviceMask2 = MLbsNetworkProtocolObserver::EServiceNone;
    TLbsNetPosRequestPrivacy privacy    = ArgUtils::Privacy();
    TLbsExternalRequestInfo requestInfo = ArgUtils::RequestInfo();
    TNetProtocolResponseType mType;
    
    // Protocol Module receives the cababilities message as LBS starts up...
    TESTL(iProxy->WaitForResponse(KTimeOut) == ENetMsgGetCurrentCapabilitiesResponse);
	
	CLbsNetworkProtocolBase::TLbsSystemStatus status;
	TInt cleanupCnt;
	cleanupCnt = iProxy->GetArgsLC(ENetMsgGetCurrentCapabilitiesResponse, &status);
	TESTL(status == CLbsNetworkProtocolBase::ESystemStatusNone);
	CleanupStack::PopAndDestroy(cleanupCnt);
    INFO_PRINTF1(_L("ENetMsgGetCurrentCapabilitiesResponse got"));
	// Create Client Objects...
	RPositionServer server;
	TInt connectError = server.Connect();
	TESTL(KErrNone == connectError);
	CleanupClosePushL(server);	
	RPositioner pos;
	TESTL(KErrNone == pos.Open(server));
	CleanupClosePushL(pos);
	CPosServerWatcher *pWatch = CPosServerWatcher::NewLC(pos, *this);
	
	// set client update options
	TBool trackingEnabled = ETrue;
	if (trackingEnabled)
	{
		T_LbsUtils utils;
	    TPtrC configFileName;
	    _LIT(KUpdateOptionsFile, "agps_module_update_file");
	    GetStringFromConfig(ConfigSection(), KUpdateOptionsFile, configFileName);
	    utils.GetConfigured_ModuleUpdateOptionsL(configFileName, ConfigSection(), iUpdateOpts);
	    pos.SetUpdateOptions(iUpdateOpts);
	}
	
	// Client Send - self locate request... TB mode selected in Admin...
	pWatch->IssueNotifyPositionUpdate();
    INFO_PRINTF1(_L("NotifyPositionUpdate sent"));
    // Get current time.
    iClientInitialRequestTime.UniversalTime();
	
	// LBS->PM :: RequestSelfLocation()
	TESTL(iProxy->WaitForResponse(KTimeOut) == ENetMsgRequestSelfLocation);
    INFO_PRINTF1(_L("RequestSelfLocation got"));

	// check the Client AGPS Usage Flag is as expected at the NPE Hybrid GPS module...
	
        // Process the response.
        TLbsNetSessionId* 					sessionId = NULL;
        TLbsNetPosRequestOptionsAssistance*	opts = NULL;
        cleanupCnt = iProxy->GetArgsLC(ENetMsgRequestSelfLocation, &sessionId, &opts);
        TBool qualitycheck = 	ArgUtils::CompareQuality(	opts, 
                                                            ETrue, 
                                                            KMinHorizontalAcc, 
                                                            KMinVerticalAcc, 
                                                            KTestMaxFixTime,
                                                            0, 
														EAssistanceDataReferenceTime, 
														(TPositionModuleInfo::ETechnologyTerminal 
														| TPositionModuleInfo::ETechnologyAssisted)
													);
		
        TESTL(qualitycheck);
        
        iSessionId.SetSessionNum(sessionId->SessionNum());
        iSessionId.SetSessionOwner(sessionId->SessionOwner());
        CleanupStack::PopAndDestroy(cleanupCnt);
        sessionId = NULL;
        opts = NULL;

    // PM->LBS ProcessStatusUpdate(EServiceSelfLocation)
    serviceMask1 = MLbsNetworkProtocolObserver::EServiceSelfLocation;
    iProxy->CallL(ENetMsgProcessStatusUpdate, &serviceMask1);
    INFO_PRINTF1(_L("ProcessStatusUpdate sent"));
    // PM->LBS ProcessLocationUpdate(SessionId, RefPosition)
    TPositionInfo refPosInfo = ArgUtils::MolrReferencePositionInfo();
    iProxy->CallL(ENetMsgProcessLocationUpdate, &iSessionId, &refPosInfo);
    INFO_PRINTF1(_L("ProcessLocationUpdate sent"));
    // LBS->CLIENT OnNotifyPositionUpdate()
    CheckForObserverEventTestsL(KTimeOut, *this);
    TEST(iClientPosUpdateCount==1);
    
    // second request... the interval is 5 seconds..
    // CLIENT->LBS IssueNotifyPositionUpdate();
    pWatch->IssueNotifyPositionUpdate();
    INFO_PRINTF1(_L("second NotifyPositionUpdate sent"));
    
        // an MTLR now happens with Max Fix Time before the client interval expires..
        //    (max fix time == 12 seconds)
    
        // << ProcessStatusUpdate()
        serviceMask1 |= MLbsNetworkProtocolObserver::EServiceMobileTerminated;
        iProxy->CallL(ENetMsgProcessStatusUpdate, &serviceMask1);
        INFO_PRINTF1(_L("ProcessStatusUpdate sent"));
        // PM->LBS ProcessPrivacyRequest()
        emergency = ETrue;
        privacy    = ArgUtils::Privacy();
        requestInfo = ArgUtils::RequestInfo();
        iProxy->CallL(ENetMsgProcessPrivacyRequest, &iSessionId2, &emergency, &privacy, &requestInfo);
        INFO_PRINTF1(_L("ProcessPrivacyRequest sent"));
        // LBS->NRH Callback from RespondNetworkLocationRequest(ERequestAccepted)
        CheckForObserverEventTestsL(KTimeOut, *this);
        
        // NRH->PM Respond Privacy Request
        TESTL(iProxy->WaitForResponse(KTimeOut) == ENetMsgRespondPrivacyRequest);
        INFO_PRINTF1(_L("RespondPrivacyRequest got")); 
		
        TLbsNetSessionId* getSessionId = NULL;
        CLbsNetworkProtocolBase::TLbsPrivacyResponse getPrivacy;
        cleanupCnt = 0;
        cleanupCnt = iProxy->GetArgsLC(ENetMsgRespondPrivacyRequest, &getSessionId, &getPrivacy);
        TESTL(getSessionId->SessionNum()==iSessionId2.SessionNum());
        TESTL(getPrivacy==CLbsNetworkProtocolBase::EPrivacyResponseAccepted);
        CleanupStack::PopAndDestroy(cleanupCnt);
    
        // PM->LBS ProcessLocationUpdate()
        TPositionInfo positionInfo = ArgUtils::ReferencePositionInfo();
        iProxy->CallL(ENetMsgProcessLocationUpdate, &iSessionId2, &positionInfo);
        INFO_PRINTF1(_L("ProcessLocationUpdate sent"));
        // PM->LBS ProcessAssistanceData()
        TLbsAsistanceDataGroup dataRequestMask = EAssistanceDataReferenceTime;
        RLbsAssistanceDataBuilderSet assistanceData2;
        ArgUtils::PopulateLC(assistanceData2);
        reason = KErrNone;
        iProxy->CallL(ENetMsgProcessAssistanceData, &dataRequestMask, &assistanceData2, &reason);
        CleanupStack::PopAndDestroy();
        INFO_PRINTF1(_L("ProcessAssistanceData sent"));
        
		// PM->LBS ProcessLocationRequest(TB) (max fix time == 12 seconds)
        service = MLbsNetworkProtocolObserver::EServiceMobileTerminated;
        quality = ArgUtils::QualityAlpha2(); 
        method   = ArgUtils::RequestTerminalBasedMethod();
        iProxy->CallL(ENetMsgProcessLocationRequest, &iSessionId2, &emergency, &service, &quality, &method);
        INFO_PRINTF1(_L("PM->LBS ProcessLocationRequest(TB) sent"));
            
        // LBS->NRH Callback from ProcessNetworkPostionUpdate(refPosition)
        CheckForObserverEventTestsL(KTimeOut, *this);
        
        // LBS->NRH Callback from ProcessNetworkPostionUpdate(GPS Location)
        CheckForObserverEventTestsL(KTimeOut, *this);
        // check the Client AGPS Usage Flag is as expected at the NPE Hybrid GPS module...
        
        // LBS->PM RequestAssistanceData(0)
        TESTL(iProxy->WaitForResponse(KTimeOut) == ENetMsgRequestAssistanceData); 
        INFO_PRINTF1(_L("RequestAssistanceData got"));
		TLbsAsistanceDataGroup dataGroup;
        CleanupStack::PopAndDestroy(iProxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataGroup));
        TESTL(dataGroup == EAssistanceDataNone);
    
        // LBS->PM RespondLocationRequest()
        TESTL(iProxy->WaitForResponse(KTimeOut) == ENetMsgRespondLocationRequest); 
        getSessionId = NULL;
        TInt getReason = KErrNone;
        getPositionInfo = NULL;
        cleanupCnt = iProxy->GetArgsLC(ENetMsgRespondLocationRequest, &getSessionId, &getReason, &getPositionInfo);
        TESTL(getSessionId->SessionNum() == iSessionId2.SessionNum());
        TESTL(getReason == KErrNone);
        CleanupStack::PopAndDestroy(cleanupCnt);
        INFO_PRINTF1(_L("RespondLocationRequest got"));
        // PM->LBS ProcessSessionComplete()
        reason = KErrNone;
        iProxy->CallL(ENetMsgProcessSessionComplete, &iSessionId2, &reason);
        INFO_PRINTF1(_L("ProcessSessionComplete sent"));
        // PM->LBS ProcessStatusUpdate() - still doing the self locate...
        serviceMask2 = MLbsNetworkProtocolObserver::EServiceSelfLocation; 
        iProxy->CallL(ENetMsgProcessStatusUpdate, &serviceMask2);
        INFO_PRINTF1(_L("ProcessStatusUpdate sent"));
        // LBS->NRH Callback from ProcessRequestComplete()
        CheckForObserverEventTestsL(KTimeOut, *this);

        
    // the GPS Module should wait *nearly* 10 seconds (the tracking interval
    // for this test) before continuing to process the location request...

    // LBS->PM CurrentCapabilitiesResponse - informing the PM we're tracking...
    mType = iProxy->WaitForResponse(KTimeOut);
    TESTL(mType == ENetMsgGetCurrentCapabilitiesResponse);
    
    // LBS->PM RequestAssistanceData()
    TLbsAsistanceDataGroup dataMask;    
    mType = iProxy->WaitForResponse(KTimeOut);
    TESTL(mType == ENetMsgRequestAssistanceData); 
    cleanupCnt = iProxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataMask);
    TESTL(dataMask == EAssistanceDataNone);
    CleanupStack::PopAndDestroy(cleanupCnt);
    
    // check the Client AGPS Usage Flag is as expected at the NPE Hybrid GPS module...

    // PM->LBS ProcessAssistanceData()
    dataMask = EAssistanceDataReferenceTime;
    RLbsAssistanceDataBuilderSet assistanceData;
    ArgUtils::PopulateLC(assistanceData);
    reason = KErrNone;
    iProxy->CallL(ENetMsgProcessAssistanceData, &dataMask, &assistanceData, &reason);
    CleanupStack::PopAndDestroy(); // assistanceData
    
    // PM->LBS ProcessLocationRequest() (NRH Request)
    service = MLbsNetworkProtocolObserver::EServiceSelfLocation;
    quality = ArgUtils::Quality();
    method   = ArgUtils::RequestHybridMethod();
    iProxy->CallL(ENetMsgProcessLocationRequest, &iSessionId, &emergency, &service, &quality, &method);

    // LBS->PM RequestAssistanceData()
    TESTL(iProxy->WaitForResponse(KTimeOut) == ENetMsgRequestAssistanceData); 
    cleanupCnt = iProxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataMask);
    TESTL(dataMask == EAssistanceDataNone);
    CleanupStack::PopAndDestroy(cleanupCnt);
    
    // check the Client AGPS Usage Flag is as expected at the NPE Hybrid GPS module...

    // LBS->PM RespondLocationRequest()
    TESTL(iProxy->WaitForResponse(KTimeOut) == ENetMsgRespondLocationRequest);
    sessionId = NULL;
    reason = KErrNone;
    getPositionInfo = NULL;
    cleanupCnt = iProxy->GetArgsLC(ENetMsgRespondLocationRequest, &sessionId, &reason, &getPositionInfo);
    TESTL(sessionId->SessionNum() == iSessionId.SessionNum());
    TESTL(reason == KErrNone);

    // PM->LBS ProcessLocationUpdate(SessionId, FinalNetworkPosition)
    iProxy->CallL(ENetMsgProcessLocationUpdate, &iSessionId, getPositionInfo);

    CleanupStack::PopAndDestroy(cleanupCnt);
    
    // Client recv - the gps position determined by the gps module.
    CheckForObserverEventTestsL(KTimeOut, *this);
    TESTL(iClientPosUpdateCount==2);
    
    // End of second client request ********************
 
    // close the client session
    pos.Close();
    
    // LBS->PM CurrentCapabilitiesResponse - informing the PM we're no longer tracking...
    TESTL(iProxy->WaitForResponse(KTimeOut) == ENetMsgGetCurrentCapabilitiesResponse);

    // LBS->PM CurrentCapabilitiesResponse - cancel the self location request.
    TESTL(iProxy->WaitForResponse(KTimeOut) == ENetMsgCancelSelfLocation);

    // PM->LBS ProcessSessionComplete()
    reason = KErrNone;
    iProxy->CallL(ENetMsgProcessSessionComplete, &iSessionId, &reason);

    // PM->LBS ProcessStatusUpdate()
    serviceMask2 = MLbsNetworkProtocolObserver::EServiceNone; 
    iProxy->CallL(ENetMsgProcessStatusUpdate, &serviceMask2);
    
    // Wait for 10 seconds to ensure no additional responses turn up.
    TInt delta = 10 * 1000 * 1000;
    mType = iProxy->WaitForResponse(delta);
    TESTL(mType == ENetMsgTimeoutExpired);
    
    
    // Done. Now cleanup...
    // all associated with MOLR Positioning Client 
    CleanupStack::PopAndDestroy(pWatch);
    CleanupStack::PopAndDestroy(); // pos
    CleanupStack::PopAndDestroy(); // server
    
	return TestStepResult();
	}
TVerdict CT_LbsHybridUEBasedX3PGPSFutile::doTestStepL()
	{
	// Generic test step used to test the LBS Client Notify position update API.
	INFO_PRINTF1(_L("CT_LbsHybridUEBasedX3PGPSFutile::doTestStepL()"));

	// Stop the test if the preamble failed
	TESTL(TestStepResult() == EPass);
	
	
	const TInt KTimeOut = 30*1000*1000;
	const TInt KAdviceSystemStatusTimeout = 40*1000*1000;
	const TInt KSmallTimeOut = 3*1000*1000; 

	
	// Carryout unique test actions.
	if (GetIntFromConfig(ConfigSection(), KTestCaseId, iTestCaseId))
		{
		INFO_PRINTF2(_L("Test id %d."), iTestCaseId);
		}
			
	// >> AdviceSystemStatus(0)
	TESTL(iProxy->WaitForResponse(KAdviceSystemStatusTimeout) == ENetMsgGetCurrentCapabilitiesResponse);
	CLbsNetworkProtocolBase::TLbsSystemStatus status;
	CleanupStack::PopAndDestroy(iProxy->GetArgsLC(ENetMsgGetCurrentCapabilitiesResponse, &status));
	TESTL(status == CLbsNetworkProtocolBase::ESystemStatusNone);
	
    //Initiate X3P start
	// TransmitPosition()
	_LIT(KThirdParty,"+4407463842101"); 
	const TInt KPriority= 1;
	TLbsTransmitPositionOptions options(TTimeIntervalMicroSeconds(50*1000*1000));
	TRequestStatus refPosStatus=KRequestPending;
	TRequestStatus transPosStatus=KRequestPending;
	TPositionInfo refPosInfo;
	TPositionInfo transPosInfo;
	iTransmitter.SetTransmitOptions(options);
	iTransmitter.TransmitPosition(KThirdParty, KPriority, refPosStatus, refPosInfo, transPosStatus, transPosInfo);
	
	// RequestTransmitLocation()
	TESTL(iProxy->WaitForResponse(KTimeOut) == ENetMsgRequestTransmitLocation);
	TBufC16<14> thirdParty(KThirdParty);
	TPtr16 ptr = thirdParty.Des(); 
	HBufC16* getThirdParty = NULL;
	TLbsNetSessionId* getSessionId = NULL;
	TInt getPriority(0);
	TInt cleanupCnt;
	cleanupCnt = iProxy->GetArgsLC(ENetMsgRequestTransmitLocation, &getSessionId, &getThirdParty, &getPriority); 
	TESTL(ptr.Compare(*getThirdParty)==KErrNone);	
	TESTL(getPriority == KPriority);
	iSessionId = *getSessionId; //session ID is initialised by LBS
	CleanupStack::PopAndDestroy(cleanupCnt);

	// ProcessStatusUpdate()
	MLbsNetworkProtocolObserver::TLbsNetProtocolService service = MLbsNetworkProtocolObserver::EServiceTransmitThirdParty;		
	iProxy->CallL(ENetMsgProcessStatusUpdate, &service);
//End Initiate

//Reference Position Notification Start	
	// ProcessLocationUpdate()
	refPosInfo = ArgUtils::ReferencePositionInfo();
	iProxy->CallL(ENetMsgProcessLocationUpdate, &iSessionId, &refPosInfo);
//Reference Position Notification End

	
//Assistance Data Notification Start
	// ProcessAssistanceData()
	TLbsAsistanceDataGroup dataRequestMask = EAssistanceDataReferenceTime;
	RLbsAssistanceDataBuilderSet assistanceData;
	ArgUtils::PopulateLC(assistanceData);
	TInt reason = KErrNone;
	iProxy->CallL(ENetMsgProcessAssistanceData, &dataRequestMask, &assistanceData, &reason);
	CleanupStack::PopAndDestroy(1); //assistanceData
// Assistance Data Notification End
	
// Network Location Request Start
	// ProcessLocationRequest()
	const TBool emergency(EFalse);
	TLbsNetPosRequestQuality quality = ArgUtils::QualityAlpha2();
	TLbsNetPosRequestMethod method;
	
	if (iTestCaseId == 1)
	{
	method   = ArgUtils::RequestHybridMethod();
	}
	else if (iTestCaseId == 2)
	{
	method   = ArgUtils::RequestMethod();
	}
	iProxy->CallL(ENetMsgProcessLocationRequest, &iSessionId, &emergency, &service, &quality, &method);
// Network Location Request Stop

	// RequestAssistanceData(0)
	TESTL(iProxy->WaitForResponse(KSmallTimeOut) == ENetMsgRequestAssistanceData); 
	TLbsAsistanceDataGroup dataGroup;
	CleanupStack::PopAndDestroy(iProxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataGroup));
	TESTL(dataGroup == EAssistanceDataNone);

	// User expects Reference Position
	User::WaitForRequest(refPosStatus); 
	TESTL(refPosStatus==KErrNone);

	// Network expects location request response with KPositionCalculationFutile
	TESTL(iProxy->WaitForResponse(KAlpha2Timeout) == ENetMsgRespondLocationRequest);	
	getSessionId = NULL;
	TInt getReason = KErrNone;
	TPositionSatelliteInfo* getPositionInfo = NULL;
	cleanupCnt = iProxy->GetArgsLC(ENetMsgRespondLocationRequest, &getSessionId, &getReason, &getPositionInfo);
	TESTL(getSessionId->SessionNum() == iSessionId.SessionNum());
	TESTL(getReason==KPositionCalculationFutile);
	CleanupStack::PopAndDestroy(cleanupCnt);
					
// Network Result Notification Start
	// ProcessLocationUpdate() , final network position = ref position
	refPosInfo.SetPositionMode(TPositionModuleInfo::ETechnologyNetwork | TPositionModuleInfo::ETechnologyAssisted);
	iProxy->CallL(ENetMsgProcessLocationUpdate, &iSessionId, &refPosInfo);
// Network Result Notification Stop
	
// Session Complete Start
	reason =KErrNone;
	iProxy->CallL(ENetMsgProcessSessionComplete, &iSessionId, &reason);
	
	MLbsNetworkProtocolObserver::TLbsNetProtocolServiceMask activeServiceMask = MLbsNetworkProtocolObserver::EServiceNone;
	
	iProxy->CallL(ENetMsgProcessStatusUpdate, &activeServiceMask);
// Session Complete Stop

// this call back has been changed, the seq diag was incorrect
	User::WaitForRequest(transPosStatus);  
	TESTL(transPosStatus==KPositionQualityLoss);
	
	return TestStepResult();
	}
void CT_LbsMolrResetAssistance::DoNetworkProtocolProxyStepL()
	{
	if(iGPSModeNotSupported)
		{ // Do nothing, the network won't do much before the module rejects the request
		return;
		}
	TInt cleanupCnt;
	// INFO_PRINTF2(_L("CT_LbsMolrResetAssistance::DoNetworkProtocolProxyStepL() Step %d"),iNetworkProtocolProxyStep);
	switch(iNetworkProtocolProxyStep)
		{
		case ENetworkProtocolProxyStepInitial:
			{
			// >> AdviceSystemStatus()
			INFO_PRINTF1(_L("CT_LbsMolrResetAssistance::DoNetworkProtocolProxyStepL() >> AdviceSystemStatus()"));
			TESTL(iProxy->WaitForResponse(KTimeOut) == ENetMsgGetCurrentCapabilitiesResponse);
			CLbsNetworkProtocolBase::TLbsSystemStatus status;
			cleanupCnt = iProxy->GetArgsLC(ENetMsgGetCurrentCapabilitiesResponse, &status);
			TESTL(status == CLbsNetworkProtocolBase::ESystemStatusNone);
			CleanupStack::PopAndDestroy(cleanupCnt);
			iNetworkProtocolProxyStep = ENetworkProtocolProxyStepAfterFirstNPUD;
			break;
			}
		case ENetworkProtocolProxyStepAfterFirstNPUD:
			{
			// >> RequestSelfLocation()
			INFO_PRINTF1(_L("CT_LbsMolrResetAssistance::DoNetworkProtocolProxyStepL() >> RequestSelfLocation() - as result of assistance data request from module"));
			TESTL(iProxy->WaitForResponse(KTimeOut) == ENetMsgRequestSelfLocation);

			if(!iWarmUpModule && iStepForSendingReset == EBeginningOfSession)
				{
				SendResetAssistanceDataL();
				}

			// Process the response.
			TLbsNetSessionId* 					sessionId = NULL;
			TLbsNetPosRequestOptionsAssistance*	opts = NULL;
			
			cleanupCnt = iProxy->GetArgsLC(ENetMsgRequestSelfLocation, &sessionId, &opts);

			iSessionId.SetSessionNum(sessionId->SessionNum());
			iSessionId.SetSessionOwner(sessionId->SessionOwner());
			
			CleanupStack::PopAndDestroy(cleanupCnt);
			sessionId = NULL;
			opts = NULL;	
			
			// << ProcessStatusUpdate(EServiceSelfLocation)
			INFO_PRINTF1(_L("CT_LbsMolrResetAssistance::DoNetworkProtocolProxyStepL() << ProcessStatusUpdate(EServiceSelfLocation)"));
			MLbsNetworkProtocolObserver::TLbsNetProtocolServiceMask activeServiceMask1 = MLbsNetworkProtocolObserver::EServiceSelfLocation;
			iProxy->CallL(ENetMsgProcessStatusUpdate, &activeServiceMask1);

			// << ProcessLocationUpdate(SessionId, RefPosition)
			INFO_PRINTF1(_L("CT_LbsMolrResetAssistance::DoNetworkProtocolProxyStepL() << ProcessLocationUpdate(SessionId, RefPosition)"));
			TPositionInfo refPosInfo = ArgUtils::MolrReferencePositionInfo();
			iProxy->CallL(ENetMsgProcessLocationUpdate, &iSessionId, &refPosInfo);

			iNetworkProtocolProxyStep = ENetworkProtocolProxyStepAfterSecondNPUD;
			break;
			}
		case ENetworkProtocolProxyStepAfterSecondNPUD:
			{
			// >> RequestAssistanceData - as a result of the second client request.
			TLbsAsistanceDataGroup dataMask;	
			INFO_PRINTF1(_L("CT_LbsMolrResetAssistance::DoNetworkProtocolProxyStepL() >> RequestAssistanceData(0)"));
			TESTL(iProxy->WaitForResponse(KTimeOut) == ENetMsgRequestAssistanceData); 
			cleanupCnt = iProxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataMask);
			TESTL(dataMask == EAssistanceDataNone);
			CleanupStack::PopAndDestroy(cleanupCnt);

			// << ProcessAssistanceData()
			INFO_PRINTF1(_L("CT_LbsMolrResetAssistance::DoNetworkProtocolProxyStepL() << ProcessAssistanceData()"));
			dataMask = EAssistanceDataReferenceTime;
			RLbsAssistanceDataBuilderSet assistanceData;
			ArgUtils::PopulateLC(assistanceData);
			TInt reason = KErrNone;
			iProxy->CallL(ENetMsgProcessAssistanceData, &dataMask, &assistanceData, &reason);
			CleanupStack::PopAndDestroy(); // assistanceData

			if(!iWarmUpModule && iStepForSendingReset == EAfterAssistanceData)
				{
				iExpectExtraRequestForAssistanceData = SendResetAssistanceDataL();
				}

			// << ProcessLocationRequest() 
			TBool emergency = EFalse;
			MLbsNetworkProtocolObserver::TLbsNetProtocolService	service = MLbsNetworkProtocolObserver::EServiceSelfLocation;
			TLbsNetPosRequestQuality quality = ArgUtils::Quality();
			//quality.SetMaxFixTime(ArgUtils::Alpha2()/10);
		    quality.SetMaxFixTime(ArgUtils::Alpha2()/4);
			TLbsNetPosRequestMethod method   = RequestNetworkMethod();
			INFO_PRINTF1(_L("CT_LbsMolrResetAssistance::DoNetworkProtocolProxyStepL() << ProcessLocationRequest()"));			
			iProxy->CallL(ENetMsgProcessLocationRequest, &iSessionId, &emergency, &service, &quality, &method);
			// Now that the hybrid/alpha2 has been requested, record current time to verify alpha2 timer expires correctly.
			TTime startTime;
			startTime.HomeTime();

			TInt response = iProxy->WaitForResponse(KTimeOut);
			TLbsNetSessionId* sessionId = NULL;
			if(response == ENetMsgRespondLocationRequest)
				{
				// >> RespondLocationRequest(KErrNotSupported) - as a result of the NRH request conflicting with the module capabilities 
				INFO_PRINTF1(_L("CT_LbsMolrResetAssistance::DoNetworkProtocolProxyStepL() >> RespondLocationRequest(KErrNotSupported)"));
				sessionId = NULL;
				TPositionInfo* positionInfo = NULL;
				reason = KErrNone;
				cleanupCnt = iProxy->GetArgsLC(ENetMsgRespondLocationRequest, &sessionId, &reason, &positionInfo);
				TESTL(positionInfo->PositionClassType() == EPositionInfoClass);
				TESTL(sessionId->SessionNum() == iSessionId.SessionNum());
				TESTL(reason == KErrNotSupported);
				CleanupStack::PopAndDestroy(cleanupCnt);

				// << ProcessSessionComplete()
				INFO_PRINTF1(_L("CT_LbsMolrResetAssistance::DoNetworkProtocolProxyStepL() << ProcessSessionComplete()"));			
				iProxy->CallL(ENetMsgProcessSessionComplete, &iSessionId, &reason);
				iGPSModeNotSupported = ETrue;

				// << ProcessStatusUpdate()
				MLbsNetworkProtocolObserver::TLbsNetProtocolServiceMask activeServiceMask2 = MLbsNetworkProtocolObserver::EServiceNone;	
				INFO_PRINTF1(_L("CT_LbsMolrResetAssistance::DoNetworkProtocolProxyStepL() << ProcessStatusUpdate(EServiceNone)"));			
				iProxy->CallL(ENetMsgProcessStatusUpdate, &activeServiceMask2);
				
				iNetworkProtocolProxyStep = ENetworkProtocolProxyStepInitial;
				}
			else
				{
				// >> RequestAssistanceData() - as a result of the NRH request. 
				TESTL(response == ENetMsgRequestAssistanceData); 
				cleanupCnt = iProxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataMask);
				if(!iExpectExtraRequestForAssistanceData || (iNetworkMethod == EAutonomousNetworkMethod && !iWarmUpModule))
					{
					INFO_PRINTF1(_L("CT_LbsMolrResetAssistance::DoNetworkProtocolProxyStepL() >> RequestAssistanceData(0)"));	
					TESTL(dataMask == EAssistanceDataNone);
					}
				else
					{
					iExpectExtraRequestForAssistanceData = EFalse;
					INFO_PRINTF1(_L("CT_LbsMolrResetAssistance::DoNetworkProtocolProxyStepL() >> RequestAssistanceData(EAssistanceDataReferenceTime)"));	
					TESTL(dataMask == EAssistanceDataReferenceTime);
					// << ProcessAssistanceData(EAssistanceDataReferenceTime)
					TLbsAsistanceDataGroup dataRequestMask = EAssistanceDataReferenceTime;
					RLbsAssistanceDataBuilderSet assistanceData;
					ArgUtils::PopulateLC(assistanceData);
					reason = KErrNone;
					INFO_PRINTF1(_L("CT_LbsMolrResetAssistance::DoNetworkProtocolProxyStepL() << ProcessAssistanceData(EAssistanceDataReferenceTime)"));	
					iProxy->CallL(ENetMsgProcessAssistanceData, &dataRequestMask, &assistanceData, &reason);
					CleanupStack::PopAndDestroy(&assistanceData);
					}
				CleanupStack::PopAndDestroy(cleanupCnt);
	
				// lrm: need to update this for cases where network request is rejected:
				// Determine the value to take off the alpha2 value. This is required because we had to wait for the assistance data response.
				TTimeIntervalMicroSeconds microseconds;
				TTime stopTime;
				stopTime.HomeTime();
				microseconds = stopTime.MicroSecondsFrom(startTime); 
				TInt64 timeElapsed = microseconds.Int64();
				TInt delta = 2 * 1000 * 1000; // 2 secs.
				
				// >> RespondLocationRequest()
				sessionId = NULL;
				DecideWhatNetworkDoesntReceive();
				const TInt t = 8 * 1000 * 1000; // 8 secs.
				
				if(iNetworkExpectsMeasurments)
					{ // measurements should be sent to the network
					INFO_PRINTF1(_L("CT_LbsMolrResetAssistance::DoNetworkProtocolProxyStepL() Network expecting measurements"));
					// Test that we do not get response before alpha2 has expired:
					TInt alpha2timeout = ArgUtils::Alpha2()/4 - timeElapsed - delta > 0 ? ArgUtils::Alpha2()/4 - timeElapsed - delta : 0;
					TESTL(iProxy->WaitForResponse(alpha2timeout) == ENetMsgTimeoutExpired);
					INFO_PRINTF1(_L("				No RespondLocationRequest before Alpha2 timer expired"));
					// Wait for and process the response:
					TESTL(iProxy->WaitForResponse(2 * delta) == ENetMsgRespondLocationRequest);	
					INFO_PRINTF1(_L("CT_LbsMolrResetAssistance::DoNetworkProtocolProxyStepL() >> RespondLocationRequest(meas)"));
					sessionId = NULL;
					TPositionGpsMeasurementInfo* measurementInfo = NULL;
					cleanupCnt = iProxy->GetArgsLC(ENetMsgRespondLocationRequest, &sessionId, &reason, &measurementInfo);
					TESTL(sessionId->SessionNum() == iSessionId.SessionNum());	// module sends NAN measurement first
					TESTL(measurementInfo->PositionClassType() == EPositionGpsMeasurementInfoClass);
					if(reason != KErrNone)
						{
						INFO_PRINTF2(_L("CT_LbsMolrResetAssistance::DoNetworkProtocolProxyStepL() reason = 0x%x"), reason);
						}
					TESTL(reason == KErrNone);
					CleanupStack::PopAndDestroy(cleanupCnt);//sessionId, measurementInfo
	
					// Wait for Assistance Data before resetting assistance data ... otherwise 
					// who knows what mask we would receive!
					// Recv -> RequestAssistanceData - we get an extra msg as the result of the A-GPS manager re-issuing a location request when it's
					//									max fix time timer expries.
					INFO_PRINTF1(_L("CT_LbsMolrResetAssistance::DoNetworkProtocolProxyStepL() >> RequestAssistanceData(0)"));
					TESTL(iProxy->WaitForResponse(KTimeOut) == ENetMsgRequestAssistanceData); 
					cleanupCnt = iProxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataMask);
					TESTL(dataMask == EAssistanceDataNone);
					CleanupStack::PopAndDestroy(cleanupCnt);
	
					// now reset the asistance data
					if(!iWarmUpModule && iStepForSendingReset == EAfterMeasurements)
										{
										iExpectExtraRequestForAssistanceData = SendResetAssistanceDataL();
										}
					quality.SetMaxFixTime(t);
	
					// << ProcessLocationRequest()
					INFO_PRINTF1(_L("CT_LbsMolrResetAssistance::DoNetworkProtocolProxyStepL() << ProcessLocationRequest()"));
					iProxy->CallL(ENetMsgProcessLocationRequest, &iSessionId, &emergency, &service, &quality, &method);
	
					// now as we have reset the assistanvce datat we expect
					// to get a non-zero mask.
					// >> RequestAssistanceData()
					INFO_PRINTF1(_L("CT_LbsMolrResetAssistance::DoNetworkProtocolProxyStepL() >> RequestAssistanceData(0)"));
					TESTL(iProxy->WaitForResponse(KTimeOut) == ENetMsgRequestAssistanceData); 
					cleanupCnt = iProxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataMask);
					if(!iExpectExtraRequestForAssistanceData || (iNetworkMethod == EAutonomousNetworkMethod && !iWarmUpModule))
						{
						INFO_PRINTF1(_L("CT_LbsMolrResetAssistance::DoNetworkProtocolProxyStepL() >> RequestAssistanceData(EAssistanceDataReferenceTime)"));	
						TESTL(dataMask == EAssistanceDataReferenceTime);
						}
					else
						{
						iExpectExtraRequestForAssistanceData = EFalse;
						INFO_PRINTF1(_L("CT_LbsMolrResetAssistance::DoNetworkProtocolProxyStepL() >> RequestAssistanceData(EAssistanceDataReferenceTime)"));	
						TESTL(dataMask == EAssistanceDataReferenceTime);
						// << ProcessAssistanceData(EAssistanceDataReferenceTime)
						TLbsAsistanceDataGroup dataRequestMask = EAssistanceDataReferenceTime;
						RLbsAssistanceDataBuilderSet assistanceData;
						ArgUtils::PopulateLC(assistanceData);
						reason = KErrNone;
						INFO_PRINTF1(_L("CT_LbsMolrResetAssistance::DoNetworkProtocolProxyStepL() << ProcessAssistanceData(EAssistanceDataReferenceTime)"));	
						iProxy->CallL(ENetMsgProcessAssistanceData, &dataRequestMask, &assistanceData, &reason);
						CleanupStack::PopAndDestroy(&assistanceData);
						}
					CleanupStack::PopAndDestroy(cleanupCnt);
	
					}
	
				if(iPlannedPositionOriginator == EPositionOriginatorModule)
					{ // the module will deliver the location
					if(iNetworkExpectsPositions)
						{
						INFO_PRINTF1(_L("CT_LbsMolrResetAssistance::DoNetworkProtocolProxyStepL() Network expecting position"));
						TNetProtocolResponseType type = iProxy->WaitForResponse(t + delta);
						if(type == ENetMsgRequestAssistanceData)
							{
							// >> RequestAssistanceData(0)
							INFO_PRINTF1(_L("CT_LbsMolrResetAssistance::DoNetworkProtocolProxyStepL() >> RequestAssistanceData(0)"));
							cleanupCnt = iProxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataMask);
							TESTL(dataMask == EAssistanceDataNone);
							CleanupStack::PopAndDestroy(cleanupCnt);
							type = iProxy->WaitForResponse(t + delta);
							}
						// >> RespondLocationRequest() - first measurement, second position.
						INFO_PRINTF1(_L("CT_LbsMolrResetAssistance::DoNetworkProtocolProxyStepL() >> RespondLocationRequest(gpspos)"));
						TESTL(type == ENetMsgRespondLocationRequest);
						sessionId = NULL;
						TPositionInfo* positionInfo = NULL;
						cleanupCnt = iProxy->GetArgsLC(ENetMsgRespondLocationRequest, &sessionId, &reason, &positionInfo);
						
						// check it is a position
						TESTL(positionInfo->PositionClassType() == (EPositionInfoClass|EPositionCourseInfoClass|EPositionSatelliteInfoClass));
						TESTL(sessionId->SessionNum() == iSessionId.SessionNum());
						TESTL(reason == KErrNone);
						
						if(!iWarmUpModule && iStepForSendingReset == EAfterPosition)
							{
							SendResetAssistanceDataL();
							}

						// << ProcessLocationUpdate(SessionId, FinalNetworkPosition)
						// Return modules' position as FinalNetworkPosition
						INFO_PRINTF1(_L("CT_LbsMolrResetAssistance::DoNetworkProtocolProxyStepL() << ProcessLocationUpdate(SessionId, FinalNetworkPosition)"));
						iProxy->CallL(ENetMsgProcessLocationUpdate, &iSessionId, positionInfo);
						CleanupStack::PopAndDestroy(cleanupCnt);
						}
					else	
						{ // network doesn't expect the module to be calculating the position and will terminate 'normally' when it's satisfied
						// Not expecting anything else to arrive at the network, make sure it doesn't:
						TESTL(iProxy->WaitForResponse(t + delta) == ENetMsgTimeoutExpired);
						}
					}
				else if(iPlannedPositionOriginator == EPositionOriginatorNetwork)
					{ // The network should return the position
					TPositionInfo positionInfo = ArgUtils::AccurateNetworkPositionInfo();
					// << ProcessLocationUpdate(SessionId, FinalNetworkPosition)
					// Return FinalNetworkPosition
					INFO_PRINTF1(_L("CT_LbsMolrResetAssistance::DoNetworkProtocolProxyStepL() << ProcessLocationUpdate(SessionId, FNP)"));
					iProxy->CallL(ENetMsgProcessLocationUpdate, &iSessionId, &positionInfo);

					// >> RequestAssistanceData(0)
					INFO_PRINTF1(_L("CT_LbsMolrResetAssistance::DoNetworkProtocolProxyStepL() >> RequestAssistanceData(0)"));
					TESTL(iProxy->WaitForResponse(KTimeOut) == ENetMsgRequestAssistanceData); 
					cleanupCnt = iProxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataMask);
					TESTL(dataMask == EAssistanceDataNone);
					CleanupStack::PopAndDestroy(cleanupCnt);

					// >> CancelSelfLocation()
					INFO_PRINTF1(_L("CT_LbsMolrResetAssistance::DoNetworkProtocolProxyStepL() >> CancelSelfLocation()"));			
					TESTL(iProxy->WaitForResponse(KTimeOut) == ENetMsgCancelSelfLocation);

					// >> RequestAssistanceData(0)
					INFO_PRINTF1(_L("CT_LbsMolrResetAssistance::DoNetworkProtocolProxyStepL() >> RequestAssistanceData(0)"));
					TESTL(iProxy->WaitForResponse(KTimeOut) == ENetMsgRequestAssistanceData); 
					TLbsAsistanceDataGroup dataMask;
					TInt cleanupCnt = iProxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataMask);
					TESTL(dataMask == EAssistanceDataNone);
					CleanupStack::PopAndDestroy(cleanupCnt);
					}
				iNetworkProtocolProxyStep = ENetworkProtocolProxyStepFinal;
				}
			
			break;
			}
		case ENetworkProtocolProxyStepFinal:
			{
			// << ProcessSessionComplete()
			TInt reason = KErrNone;
			INFO_PRINTF1(_L("CT_LbsMolrResetAssistance::DoNetworkProtocolProxyStepL() << ProcessSessionComplete()"));			
			iProxy->CallL(ENetMsgProcessSessionComplete, &iSessionId, &reason);

			if(!iWarmUpModule && iStepForSendingReset == EAfterSessionClose)
				{
				SendResetAssistanceDataL();
				}

			// << ProcessStatusUpdate()
			MLbsNetworkProtocolObserver::TLbsNetProtocolServiceMask activeServiceMask2 = MLbsNetworkProtocolObserver::EServiceNone;	
			INFO_PRINTF1(_L("CT_LbsMolrResetAssistance::DoNetworkProtocolProxyStepL() << ProcessStatusUpdate(EServiceNone)"));			
			iProxy->CallL(ENetMsgProcessStatusUpdate, &activeServiceMask2);
			iProxy->WaitForResponse(KTimeoutWaitingForResetAssistanceData);
			
			iNetworkProtocolProxyStep = ENetworkProtocolProxyStepAfterFirstNPUD;
			break;
			}
		default:
			{
			User::Invariant();
			}
		}
	}