예제 #1
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);
	}
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_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_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();
	}
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();
			}
		}
	}
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();
	}