void CTe_LbsLocationMonitorSuiteStepBase::ComparePositions(TPosition& aLeft, TPosition& aRight)
	{
	TEST(aLeft.HorizontalAccuracy() == aRight.HorizontalAccuracy());
	TEST(aLeft.VerticalAccuracy() == aRight.VerticalAccuracy());
	TEST(aLeft.Latitude() == aRight.Latitude());
	TEST(aLeft.Longitude() == aRight.Longitude());
	TEST(aLeft.Altitude() == aRight.Altitude());
		
	}
Ejemplo n.º 2
0
void CT_LbsClientPosTp2::CheckPositionL(TPosition& aPos)
	{
	if (aPos.Time() != TTime(KPositionTime) ||
		aPos.HorizontalAccuracy() != KHorizontalAcc ||
		aPos.VerticalAccuracy() != KVerticalAcc ||
		aPos.Latitude() != KLatitude ||
		aPos.Longitude() != KLongitude ||
		aPos.Altitude() != KAltitude)
		{
		_LIT(KErrPosition, "Wrong position returned");
		LogErrorAndLeaveL(KErrPosition);
		}
	}
EXPORT_C void MTe_LbsPsyStaticData::PrintPosInfo(const TPositionInfo& aPosInfo) const
	{	
	_LIT(KTimeFormat, "%H:%T:%S.%C");
	TBuf<100> cTimeStr;
	
	INFO_PRINTF2(_L("classSize=%d"), aPosInfo.PositionClassSize());
	INFO_PRINTF2(_L("classType=0x%x"), aPosInfo.PositionClassType());
	INFO_PRINTF2(_L("moduleId=0x%x"), aPosInfo.ModuleId());
	INFO_PRINTF2(_L("updateType=%d"), aPosInfo.UpdateType());
	INFO_PRINTF2(_L("positionMode=%d"), aPosInfo.PositionMode());
	INFO_PRINTF2(_L("positionModeReason=%d"), aPosInfo.PositionModeReason());
	
	TPosition pos;
	aPosInfo.GetPosition(pos);
	INFO_PRINTF2(_L("pos altitude=%f"), pos.Altitude());
	INFO_PRINTF2(_L("pos latitude=%f"), pos.Latitude());
	INFO_PRINTF2(_L("pos longitude=%f"), pos.Longitude());
	INFO_PRINTF2(_L("pos datum=0x%x"), pos.Datum());
	INFO_PRINTF2(_L("pos horAccuracy=%f"), pos.HorizontalAccuracy());
	INFO_PRINTF2(_L("pos verAccuracy=%f"), pos.VerticalAccuracy());
						
	TRAP_IGNORE(pos.Time().FormatL(cTimeStr, KTimeFormat);)
// ---------------------------------------------------------
// CPosPSYClearPositionDataTest::CheckPositionClearsL
//
// (other items were commented in a header).
// ---------------------------------------------------------
// 
void CPosPSYClearPositionDataTest::CheckPositionClearsL(
	const TDesC& aPositionType)
    {
	TPosition position;
	iPosInfo->GetPosition(position);
    
	TBool allIsCleared = ETrue;

	if (position.Time() == KTime)
		{
		_LIT(KError, "Time not cleared for ");
		AddMessageL(KError, aPositionType, EErrorMessage);
		allIsCleared = EFalse;
		}
	if (!Math::IsNaN(position.HorizontalAccuracy()))
		{
		if (position.HorizontalAccuracy() == KHorizontalAccuracy)
			{
			_LIT(KError, "Horizontal Accuracy not cleared for ");
			AddMessageL(KError, aPositionType, EErrorMessage);
			allIsCleared = EFalse;
			}
		}
	if (!Math::IsNaN(position.VerticalAccuracy()))
		{
		if (position.VerticalAccuracy() == KVerticalAccuracy)
			{
			_LIT(KError, "Vertical Accuracy not cleared for ");
			AddMessageL(KError, aPositionType, EErrorMessage);
			allIsCleared = EFalse;
			}	
		}
	if (!Math::IsNaN(position.Latitude()))
		{
		if (position.Latitude() == KLatitude)
			{
			_LIT(KError, "Latitude not cleared for ");
			AddMessageL(KError, aPositionType, EErrorMessage);
			allIsCleared = EFalse;
			}
		}
	if (!Math::IsNaN(position.Longitude()))
		{
		if (position.Longitude() == KLongitude)
			{
			_LIT(KError, "Longitude not cleared for ");
			AddMessageL(KError, aPositionType, EErrorMessage);
			allIsCleared = EFalse;
			}
		}
	if (!Math::IsNaN(position.Altitude()))
		{
		if (position.Altitude() == KAltitude)
			{
			_LIT(KError, "Altitude not cleared for ");
			AddMessageL(KError, aPositionType, EErrorMessage);
			allIsCleared = EFalse;
			}
		}
	
	if (allIsCleared)
		{
		_LIT(KInfo, "All TPositionInfo fields were cleared for ");
		AddMessageL(KInfo, aPositionType, EInfoMessage);
		}
	}
void CT_LbsHybridUEAssistedMTLRTimeout::ProcessNetworkPositionUpdate(TUint /*aRequestId*/, const TPositionInfo& aPosInfo)
	{
	if(iState==EPrivacyCheckOk)
		{
		iState=ERefLocReceived;	
		INFO_PRINTF1(_L("&gt;&gt;CT_LbsHybridUEAssistedMTLRTimeout::ProcessNetworkPositionUpdate(RefPosition)"));
		}
	else if(iState==ERefLocReceived)
		{
		// Test for $update,1,2,51.5015,-0.105,50,2,3*
		TPosition getPos;
		aPosInfo.GetPosition(getPos);
		if(getPos.Latitude()==51.5015 && getPos.Longitude()==-0.105 && getPos.Altitude()==50 && getPos.HorizontalAccuracy()==2 && getPos.VerticalAccuracy()==3) 		
			{
			INFO_PRINTF1(_L("&gt;&gt;CT_LbsHybridUEAssistedMTLRTimeout::ProcessNetworkPositionUpdate(GpsPosition)"));
			iState=EGpsLocReceived;	
			}
		}
	ReturnToTestStep();
	}
Ejemplo n.º 6
0
EXPORT_C TBool T_LbsUtils::Compare_PosInfo(const TPositionInfoBase& aPosInfoSideA, const TPositionInfoBase& aPosInfoSideB, TComparisonAccuracyType aCmpAccuracy)
	{
	// TODO compare base class items, such as module id, position mode, etc.

	TUint32 typeA = aPosInfoSideA.PositionClassType();
	TUint32 typeB = aPosInfoSideB.PositionClassType();
	
	// Compare TPositionInfo type items.
	if(typeA & typeB & EPositionInfoClass)
		{
		TESTLOG(ELogP1, "T_LbsUtils::Compare_PosInfo() Both positions are of type EPositionInfoClass");
		const TPositionInfo& posInfoSideA = reinterpret_cast<const TPositionInfo&>(aPosInfoSideA);
		const TPositionInfo& posInfoSideB = reinterpret_cast<const TPositionInfo&>(aPosInfoSideB);
		
		TPosition posSideA;
		TPosition posSideB;
		posInfoSideA.GetPosition(posSideA);
		posInfoSideB.GetPosition(posSideB);

		// Carry out an exact check when comparing items.
		if (EExactAccuracy == aCmpAccuracy)
			{
			TESTLOG(ELogP1, "T_LbsUtils::Compare_PosInfo() Comparing positions for exact match");
			// Compare latitude. 
			if (Math::IsNaN(posSideA.Latitude()) && Math::IsNaN(posSideB.Latitude()))
				;
			else if (posSideA.Latitude() != posSideB.Latitude())
				{
				TESTLOG(ELogP1, "T_LbsUtils::Compare_PosInfo() Positions don't match!");
				TESTLOG3(ELogP1, "Latitudes %d and %d respectively", posSideA.Latitude(), posSideB.Latitude());
				return EFalse;
				}
			
			// Compare longitude.
			if (Math::IsNaN(posSideA.Longitude()) && Math::IsNaN(posSideB.Longitude()))
				;
			else if (posSideA.Longitude() != posSideB.Longitude())
				{
				TESTLOG(ELogP1, "T_LbsUtils::Compare_PosInfo() Positions don't match!");
				TESTLOG3(ELogP1, "Longitudes %d and %d respectively", posSideA.Longitude(), posSideB.Longitude());
				return EFalse;
				}		
			
			// Compare altitude.
			if (Math::IsNaN(posSideA.Altitude()) && Math::IsNaN(posSideB.Altitude()))
				;
			else if (posSideA.Altitude() != posSideB.Altitude())
				{
				TESTLOG(ELogP1, "T_LbsUtils::Compare_PosInfo() Positions don't match!");
				TESTLOG3(ELogP1, "Altitudes %d and %d respectively", posSideA.Altitude(), posSideB.Altitude());				
				return EFalse;
				}
			
			// Compare datum.
			if (posSideA.Datum() != posSideB.Datum())
				{
				TESTLOG(ELogP1, "T_LbsUtils::Compare_PosInfo() Positions don't match!");
				TESTLOG3(ELogP1, "Datums %d and %d respectively", posSideA.Datum(), posSideB.Datum());				
				return EFalse;
				}				
			
			// Compare horizontal accuracy.
			if (Math::IsNaN(posSideA.HorizontalAccuracy()) && Math::IsNaN(posSideB.HorizontalAccuracy()))
				;
			else if (posSideA.HorizontalAccuracy() != posSideB.HorizontalAccuracy())
				{
				TESTLOG(ELogP1, "T_LbsUtils::Compare_PosInfo() Positions don't match!");
				TESTLOG3(ELogP1, "Horizontal Accuracies %d and %d respectively", posSideA.HorizontalAccuracy(), posSideB.HorizontalAccuracy());				
				return EFalse;
				}		
			
			// Compare vertical accuracy.
			if (Math::IsNaN(posSideA.VerticalAccuracy()) && Math::IsNaN(posSideB.VerticalAccuracy()))
				;
			else if (posSideA.VerticalAccuracy() != posSideB.VerticalAccuracy())
				{
				TESTLOG(ELogP1, "T_LbsUtils::Compare_PosInfo() Positions don't match!");
				TESTLOG3(ELogP1, "Vertical Accuracies %d and %d respectively", posSideA.VerticalAccuracy(), posSideB.VerticalAccuracy());				
				return EFalse;
				}		
			}
		else
			{
			// Check latitude + longitude using horz accuracy.
			TReal horzAct = posSideA.HorizontalAccuracy(); // Use the verify accuracy value (which is side A).
			TReal distance ;			
	
			TESTLOG(ELogP1, "T_LbsUtils::Compare_PosInfo() Comparing positions for 'rough' match");			
		//	if(NAN != horzAct)
				{
				// The following is a temporary patch until TPositionInfo.Distance() is implemented:				
/* 
	from http://www.movable-type.co.uk/scripts/GIS-FAQ-5.1.html
	
	presuming a spherical Earth with radius R (see below), and the locations of the two points in spherical coordinates (longitude and latitude) are lon1,lat1 and lon2,lat2 then the

	Haversine Formula (from R.W. Sinnott, "Virtues of the Haversine", Sky and Telescope, vol. 68, no. 2, 1984, p. 159):

	dlon = lon2 - lon1
	dlat = lat2 - lat1
	a = sin^2(dlat/2) + cos(lat1) * cos(lat2) * sin^2(dlon/2)
	c = 2 * arcsin(min(1,sqrt(a)))
	d = R * c

	will give mathematically and computationally exact results. 
	
*/				
				const TReal pi = 3.141592653589793;
				const TReal earthRadius = 6367 * 1000;	// earth radius in metres
				
				TReal32 latA = posSideA.Latitude() * (pi/180);
				TReal32 latB = posSideB.Latitude() * (pi/180);
				TReal32 lonA = posSideA.Longitude() * (pi/180);
				TReal32 lonB = posSideB.Longitude() * (pi/180);
				
				TReal dlon = (lonB - lonA);	
				TReal dlat = (latB - latA);
				TReal sin_half_dlat, sin_half_dlon, coslatA, coslatB;
				
				Math::Sin(sin_half_dlat, dlat/2);
				Math::Sin(sin_half_dlon, dlon/2);
				Math::Cos(coslatA, latA);
				Math::Cos(coslatB, latB);
				
				TReal a = (sin_half_dlat * sin_half_dlat) + (coslatA * coslatB * (sin_half_dlon * sin_half_dlon));
				TReal sqrt_a;
				Math::Sqrt(sqrt_a, a);
				TReal arcsinmin;
				
				TReal min = Min(static_cast<TReal>(1), sqrt_a);
				Math::ASin(arcsinmin, min);
				
				distance = earthRadius * (2 * arcsinmin);
				
				//__ASSERT_ALWAYS(!Math::IsNaN(distance), User::Panic(_L("Lbs Test Utils"), KErrGeneral));
				if(Math::IsNaN(latA) || Math::IsNaN(lonA) || Math::IsNaN(horzAct))
					{	
					TESTLOG(ELogP1, "T_LbsUtils::Compare_PosInfo() Positions don't match because contains NaNs!");	
					return EFalse;			
					}
				else if(distance > horzAct + 30)	// lrm allow for 30m discrepency for now TO DO figure out whether we should be able to check finer accuracy
					{
					TESTLOG(ELogP1, "T_LbsUtils::Compare_PosInfo() Positions don't match because distance greater than reported accuracy + margin!");
					return EFalse;
					}
				}
				
			/*	put back later:	
			TReal32 horzAct = posSideA.HorizontalAccuracy(); // Use the verify accuracy value (which is side A).
			TReal32 distance ;			
			
			posSideA.Distance(posSideB, distance);
			if (distance > horzAct)
				return EFalse;
		
			// Check altitude using vert accuracy.
			TReal32 vertAct = posSideA.VerticalAccuracy(); // Use the verify accuracy value (which is side A).
			TReal32 height = Abs(posSideA.Altitude() - posSideB.Altitude());
			if (height > vertAct)
				return EFalse;
			*/
			
			}
			
		// TODO, we don't compare times, not sure if this is something we would do later on
//		if (posSideA.Time() != posSideB.Time())
//			return EFalse;
		
		return ETrue;
		}

	// Compare TPositionCourseInfo type items.		
	if (typeA & typeB & EPositionCourseInfoClass)
		{
		TESTLOG(ELogP1, "T_LbsUtils::Compare_PosInfo() Both positions are of type EPositionCourseInfoClass");
		// TODO
		}

	// Compare TPositionSatelliteInfo type items.
	if (typeA & typeB & EPositionSatelliteInfoClass)
		{
		TESTLOG(ELogP1, "T_LbsUtils::Compare_PosInfo() Both positions are of type EPositionSatelliteInfoClass");
		// TODO
		}

/* For extended tests when we have them.
	if (infoBase.PositionClassType() & EPositionClassTestExtension)
		{
		}
*/
	return EFalse;
	}
void XQLocationPrivate::DeliverPositionerResults(TPositionSatelliteInfo aPositionInfo)
{
    TPosition pos; 
    aPositionInfo.GetPosition(pos);
    
    // Handle speed reporting
    float speed = 0;
    if (speedAvailable) {
        // Positioning module is able to offer speed information
        TCourse course;
        aPositionInfo.GetCourse(course);
        speed = course.Speed();
        if (isnan(speed)) {
            speed = 0;
        }
    } else {
        // Positioning module does not offer speed information
        // => Speed is calculated using position information & timestamps
        TTime posTime;
        TTimeIntervalSeconds interval;
        for (int i = iPositions.Count()-1 ; i >= 0; i--) {
            if (pos.Time().SecondsFrom(iPositions[i].Time(),interval) == KErrNone) {
                if (interval.Int() > 10) {
                    pos.Speed(iPositions[i], speed);
                    break;
                }
            }
        }
        while (iPositions.Count() > 0) {
            if (pos.Time().SecondsFrom(iPositions[0].Time(),interval) == KErrNone) {
                if (interval.Int() > 60) {
                    iPositions.Remove(0);
                } else {
                    break;
                }
            }
        }
        if (iPositions.Count() > 0) {
    	    if (pos.Time().SecondsFrom(iPositions[iPositions.Count()-1].Time(),interval) == KErrNone) {
                if (interval.Int() > 1) {
                    iPositions.Append(pos);
                }
        	}
        } else {
            iPositions.Append(pos);
        }
        // Accept speed from range 0.01 m/s (0.036 km/h) to 200 m/s (720 km/h)  
        if (speed < 0.01 || speed > 200) {
            speed = 0;
        }
    }
    if (speed != iPreviousSpeed) {
        emit ipParent->speedChanged(speed);
    }
    iPreviousSpeed = speed;
    
    // Handle satellite information reporting
    if (satelliteInfoAvailable) {
        if (aPositionInfo.NumSatellitesInView() != iPreviousNumSatellitesInView) {
            emit ipParent->numberOfSatellitesInViewChanged(aPositionInfo.NumSatellitesInView());
        }
        iPreviousNumSatellitesInView = aPositionInfo.NumSatellitesInView(); 

		if (aPositionInfo.NumSatellitesUsed() != iPreviousNumSatellitesUsed) { 
            emit ipParent->numberOfSatellitesUsedChanged(aPositionInfo.NumSatellitesUsed());
        }
        iPreviousNumSatellitesUsed = aPositionInfo.NumSatellitesUsed();
    }
    
    // Handle position information reporting
    if (iPreviousPosition.Latitude() != pos.Latitude() ||
        iPreviousPosition.Longitude() != pos.Longitude() ||
        iPreviousPosition.Altitude() != pos.Altitude()) {
        if (!isnan(pos.Latitude()) || !isnan(pos.Longitude()) || !isnan(pos.Altitude())) {
            emit ipParent->locationChanged(pos.Latitude(),pos.Longitude(),pos.Altitude(),speed);
        }
        
        if (iPreviousPosition.Latitude() != pos.Latitude()) {
            if (!isnan(pos.Latitude())) {
                emit ipParent->latitudeChanged(pos.Latitude(),pos.HorizontalAccuracy());
            }
        }
        if (iPreviousPosition.Longitude() != pos.Longitude()) {
            if (!isnan(pos.Longitude())) {
                emit ipParent->longitudeChanged(pos.Longitude(),pos.HorizontalAccuracy());
            }
        }
        if (iPreviousPosition.Altitude() != pos.Altitude()) {
            if (!isnan(pos.Altitude())) {
                emit ipParent->altitudeChanged(pos.Altitude(),pos.VerticalAccuracy());
            }
        }
    }
    iPreviousPosition = pos;
    
    if (iSingleUpdate) {
        stopUpdates();
        iSingleUpdate = EFalse;
    }
}
/**
 * @return - TVerdict code
 * Override of base class pure virtual
 * Our implementation only gets called if the base class doTestStepPreambleL() did
 * not leave. That being the case, the current test result value will be EPass.
 */
TVerdict CT_LbsX3PStep_Cancel::doTestStepL()
	{
	// Generic test step used to test the LBS Client Notify position update API.
	INFO_PRINTF1(_L("&gt;&gt;CT_LbsX3PStep_Cancel::doTestStepL()"));

	if (TestStepResult() == EPass)
		{
		
		TInt err = KErrNone;
		RLbsTransmitPositionServer server;

		// Carry out common test actions (such as connecting to a server).

		User::LeaveIfError(server.Connect());
		CleanupClosePushL(server);

		INFO_PRINTF1(_L("server opened"));
	
		User::LeaveIfError(iTransmitPositioner.Open(server));
		CleanupClosePushL(iTransmitPositioner);

		// Create the active object to carry out the Transmit Position functionality.					
		iDoTransmitPosAO = CT_LbsX3PDoTransmitPos::NewL(this, iTransmitPositioner);
		
		//T_LbsUtils utils;
		//TModuleDataIn modDataIn; // Used to send test information to the test module.

	    iRefPosFlag = GetIntFromConfig(ConfigSection(), KLbsRefPos, iRefPosFlag);
	    

		// Carry out unique test actions.
		if (GetIntFromConfig(ConfigSection(), KTestCaseId, iTestCaseId))
			{
			switch (iTestCaseId)
				{
				// Test case LBS-X3P-Cancel-0001
				case 1:
					{
					//Try to cancel Transmition without X3P
					iTransmitPositioner.CancelTransmitPosition();  

					//Below code might not be needed...added as Netsim panics if I dont start scheduler
					iFlagsToHaltOn = KLbsCallback_NetSim_Got_Connect;
					
					}
					break;
					
				// Test case LBS-X3P-Cancel-0002
				case 2:
					{
					iFlagsToHaltOn = KLbsCallback_NetSim_Got_Connect| 
									 KLbsCallback_NetSim_Got_NotifyRegisterLcsMoLr |
									 KLbsCallback_NetSim_Got_NotifyReleaseLcsMoLr |
									 (iRefPosFlag? KLbsCallback_Got_NotifyDoTransmitReferencePos:0)|
									 KLbsCallback_Got_NotifyDoTransmitPos;
					}
					break;
					
				// Test case LBS-X3P-Cancel-0003
				case 3:
					{
					iFlagsToHaltOn = KLbsCallback_NetSim_Got_Connect | 
									 KLbsCallback_NetSim_Got_NotifyRegisterLcsMoLr |
									 KLbsCallback_NetSim_Got_NotifyReleaseLcsMoLr |
									 (iRefPosFlag? KLbsCallback_Got_NotifyDoTransmitReferencePos:0)|
									 KLbsCallback_Got_NotifyDoTransmitPos;
					}
					break;
					
				// Test case LBS-X3P-Cancel-0004
				case 4:
					{
					//SetExtendedTimerInterval(30000000);
					iFlagsToHaltOn = KLbsCallback_NetSim_Got_Connect | 
									 KLbsCallback_NetSim_Got_NotifyRegisterLcsMoLr |
									 KLbsCallback_NetSim_Got_NotifyMeasurementControlLocation |
									 KLbsCallback_NetSim_Got_NotifyMeasurementReportLocation |
									 KLbsCallback_NetSim_Got_NotifyFacilityLcsMoLrResult |
									 KLbsCallback_NetSim_Got_NotifyReleaseLcsMoLr|
									 (iRefPosFlag? KLbsCallback_Got_NotifyDoTransmitReferencePos:0)|
									 KLbsCallback_Got_NotifyDoTransmitPos;
					}
					break;
					
				// Test case LBS-X3P-Cancel-0005
				case 5:
				case 6:
					{
					iFlagsToHaltOn = KLbsCallback_NetSim_Got_Connect | 
									 KLbsCallback_NetSim_Got_NotifyRegisterLcsMoLr |
									 KLbsCallback_NetSim_Got_NotifyMeasurementControlLocation |
									 KLbsCallback_NetSim_Got_NotifyMeasurementReportLocation |
									 KLbsCallback_NetSim_Got_NotifyFacilityLcsMoLrResult |
									 KLbsCallback_NetSim_Got_NotifyReleaseLcsMoLr|
									 (iRefPosFlag? KLbsCallback_Got_NotifyDoTransmitReferencePos:0)|
									 KLbsCallback_Got_NotifyDoTransmitPos;
					}
					break;
					
													
				// Test case LBS-X3P-Cancel-0007
				case 7:
					{
					iFlagsToHaltOn = KLbsCallback_NetSim_Got_Connect | 
									 KLbsCallback_NetSim_Got_NotifyRegisterLcsMoLr |
									 KLbsCallback_NetSim_Got_NotifyReleaseLcsMoLr |
									 (iRefPosFlag? KLbsCallback_Got_NotifyDoTransmitReferencePos:0);

					//Not sure how we will get status in this case when the request is cancelled from Cancel() - TBD
					}
					break;

				
				// Test case LBS-X3P-Cancel-0009-0010
				case 8:
				case 9:
					{
					User::LeaveIfError(iTransmitPositioner2.Open(server));
					CleanupClosePushL(iTransmitPositioner2);

					// Create the active object to carry out the Transmit Position functionality.					
					iDoTransmitPosAO2 = CT_LbsX3PDoTransmitPos::NewL(this, iTransmitPositioner2);

					iFlagsToHaltOn = KLbsCallback_NetSim_Got_Connect | 
									 KLbsCallback_NetSim_Got_NotifyRegisterLcsMoLr |
									 KLbsCallback_NetSim_Got_NotifyMeasurementControlLocation |
									 KLbsCallback_NetSim_Got_NotifyMeasurementReportLocation |								 
									 KLbsCallback_NetSim_Got_NotifyFacilityLcsMoLrResult |
									 KLbsCallback_NetSim_Got_NotifyReleaseLcsMoLr|
									 (iRefPosFlag? KLbsCallback_Got_NotifyDoTransmitReferencePos:0)|
									 KLbsCallback_Got_NotifyDoTransmitPos;
					}
					break;


				case 10:
					{
					//Cancel at NotifyMeasurementReportRequestMoreAssitanceData

					//Configure gps-test-module to request for more assitance data.
					if(iParent.iSharedData->iTestModuleInUse)
						{
						T_LbsUtils utils;
						TModuleDataIn modDataIn; // Used to send test information to the test module.
						modDataIn.iRequestType = TModuleDataIn::EModuleRequestTestMode;
						modDataIn.iAssDataEventType = TModuleDataIn::EAssDataEventExpectSingle;
						modDataIn.iAssDataTestMode = TModuleDataIn::EModuleTestModeAssDataOn_SomeDataNotAvailable;
						
						utils.NotifyModuleOfConfigChangeL(modDataIn);
						}
						
					iFlagsToHaltOn = KLbsCallback_NetSim_Got_Connect | 
									 KLbsCallback_NetSim_Got_NotifyRegisterLcsMoLr |
									 KLbsCallback_NetSim_Got_NotifyMeasurementReportRequestMoreAssistanceData |
									 KLbsCallback_NetSim_Got_NotifyMeasurementReportControlFailure |
									 KLbsCallback_NetSim_Got_NotifyMeasurementControlLocation |
									 KLbsCallback_NetSim_Got_NotifyReleaseLcsMoLr|
									 (iRefPosFlag? KLbsCallback_Got_NotifyDoTransmitReferencePos:0)|
									 KLbsCallback_Got_NotifyDoTransmitPos;
					}
					break;					
					
				case 11:
					{
					iFlagsToHaltOn = KLbsCallback_NetSim_Got_Connect | 
									 KLbsCallback_NetSim_Got_NotifyRegisterLcsMoLr |
									 KLbsCallback_NetSim_Got_NotifyMeasurementControlLocation |
									 KLbsCallback_NetSim_Got_NotifyMeasurementReportLocation |
									 KLbsCallback_NetSim_Got_NotifyFacilityLcsMoLrResult |
									 KLbsCallback_NetSim_Got_NotifyReleaseLcsMoLr|
									 (iRefPosFlag? KLbsCallback_Got_NotifyDoTransmitReferencePos:0)|
									 KLbsCallback_Got_NotifyDoTransmitPos;
					}
					break;

				case 12:
					{
					
					//Note sure which callbacks would be needed - TBD
					if(iRefPosFlag)
						{
						iFlagsToHaltOn = KLbsCallback_NetSim_Got_Connect | 
										 KLbsCallback_NetSim_Got_NotifyRegisterLcsMoLr |
										 KLbsCallback_NetSim_Got_NotifyMeasurementControlLocation |
										 KLbsCallback_NetSim_Got_NotifyMeasurementReportLocation |
										 KLbsCallback_NetSim_Got_NotifyFacilityLcsMoLrResult |
										 KLbsCallback_NetSim_Got_NotifyReleaseLcsMoLr|
										 KLbsCallback_Got_NotifyDoTransmitPos;
						}
					else
						{
						INFO_PRINTF2(_L("This test case is invalid for this interface: Testcase ID-  %d"), iTestCaseId);
						ASSERT(FALSE);	
						}
					}
					break;

				case 13:
					{
					if(iRefPosFlag)
						{
						iFlagsToHaltOn = KLbsCallback_NetSim_Got_Connect | 
										 KLbsCallback_NetSim_Got_NotifyRegisterLcsMoLr |
										 KLbsCallback_NetSim_Got_NotifyMeasurementControlLocation |
										 KLbsCallback_NetSim_Got_NotifyMeasurementReportControlFailure |
										 KLbsCallback_NetSim_Got_NotifyReleaseLcsMoLr|
										 KLbsCallback_Got_NotifyDoTransmitReferencePos|
										 KLbsCallback_Got_NotifyDoTransmitPos;
						}
					else
						{
						INFO_PRINTF2(_L("This test case is invalid for this interface: Testcase ID-  %d"), iTestCaseId);
						ASSERT(FALSE);	
						}
					}
					break;

				default:
					{
					INFO_PRINTF2(_L("Unrecognised test case id %d"), iTestCaseId);
					ASSERT(FALSE);	
					}					
				}
			}
		else
			{
			INFO_PRINTF1(_L("Error in reading config file"));
			ASSERT(FALSE);
			}

		RPointerArray<TAny>& srcPosInfoArr = iParent.iSharedData->iVerifyPosInfoArr;
		TPositionInfo* srcPosInfo = reinterpret_cast<TPositionInfo*>(srcPosInfoArr[0]);
		TPosition srcPos;
		srcPosInfo->GetPosition(srcPos);

		// Conect to the NetSim.
		iNetSim.ConnectL(this); // Once we have connected, we will get NetSim callbacks.
		//iNetSim.SetStepMode(ETrue);

		// Set plugin to use.
		TUid pluginUid;
		if(iParent.iSharedData->iTestModuleInUse)
			{
			pluginUid = TUid::Uid(KSimpleAssistanceDataProviderPluginUidValue);
			}
		else
			{
			pluginUid = TUid::Uid(KSuplAssistanceDataProviderPluginUidValue);
			}
			
		if (!iNetSim.SetAssistanceDataProvider(pluginUid))
			{
			INFO_PRINTF1(_L("Failed test, can't set NetSim's assistance data plugin uid."));
			SetTestStepResult(EFail);
			iNetSim.Close();
			return TestStepResult();
			}

		if (!iNetSim.SetReferenceLocation(srcPos))
			{
				INFO_PRINTF1(_L("Failed test, can't set NetSim's reference location."));
				SetTestStepResult(EFail);
				iNetSim.Close();
				return TestStepResult();
			}	

		// Set the MaxFix time required by the network.
		TTimeIntervalMicroSeconds maxFixTime(150*1000000);
		TLbsNetPosRequestQuality netPosQuality;

		netPosQuality.SetMaxFixTime(maxFixTime);
		netPosQuality.SetMinHorizontalAccuracy(srcPos.HorizontalAccuracy());
		netPosQuality.SetMinVerticalAccuracy(srcPos.VerticalAccuracy());
		if (!iNetSim.SetQuality(netPosQuality))
			{
			INFO_PRINTF1(_L("Failed test, can't set NetSim's quality."));
			SetTestStepResult(EFail);
			iNetSim.Close();
			return TestStepResult();
			}
		
		//Timeout for Transmit Location
		TLbsTransmitPositionOptions transmitOptions;
		transmitOptions.SetTimeOut(120*1000000);
		iTransmitPositioner.SetTransmitOptions(transmitOptions);

		// Kick off the keep alive timer.
		TTimeIntervalMicroSeconds32 interval(KLbsKeepAlivePeriod);
		iKeepAliveTimer->SetTimer(interval);

		if(iTestCaseId == 3)
			{
			const TInt32 time=1000;
			iNetSim.SetResponseTime(time, ETrue);  //TBD
			}
		
		CActiveScheduler::Start();
		
		err = iStatus.Int();
		switch(iTestCaseId)
			{
			case 1:
			case 7:
				break;
				
			case 2:
			case 3:
			case 10:
			case 13:
				{
				if(KErrCancel != err)
					{
					INFO_PRINTF2(_L("<FONT><B>CancelTransmitPosition() should have returned KErrCancel, got %d</B></FONT>"), err);
					SetTestStepResult(EFail);	
					}
				}
				break;
			
			case 4:
				{
				if(KErrCancel == err && !(iCallbackFlags & KLbsCallback_NetSim_Got_NotifyMeasurementReportControlFailure))
					{
					INFO_PRINTF2(_L("<FONT><B>Should have been completed with KErrCancel,  got %d</B></FONT>"), err);
					SetTestStepResult(EFail);	
					}
				}
				//not using break as want to go ahead with below check.
				
			case 5:
			case 6:				
			case 11:
			case 12: //TBD
     			// In testcases that cancel "late" in the X3P proceudure, cancellation may arrive to NRH before
				// or after the session has finished. Therefore the error code will sometimes be
				// KErrCancel (session cancelled) and other times KErrNone (nothing to cancel due to session complete).
				//
				{
				if(!(KErrCancel == err || KErrNone == err))
					{
					INFO_PRINTF2(_L("<FONT><B>CancelTransmitPosition() should have returned KErrCancel or KErrNone, got %d</B></FONT>"), err);
					SetTestStepResult(EFail);	
					}
				}
			break;
			
			case 8:
			case 9:
				{
				if(KErrNone != err)
					{
					INFO_PRINTF2(_L("<FONT><B>CancelTransmitPosition() should have returned KErrNone, got %d</B></FONT>"), err);
					SetTestStepResult(EFail);	
					}
				}
				break;
			
			default:
				{
				INFO_PRINTF2(_L("Unrecognised test case id %d"), iTestCaseId);
				ASSERT(FALSE);	
				}	
			}

		// Clean up.
		// Clear A-GPS timeout.
		//if(iParent.iSharedData->iTestModuleInUse)
		//	{
		//	modDataIn.iRequestType = TModuleDataIn::EModuleRequestTimeOut;
		//	modDataIn.iTimeOut = 0;
		//	utils.NotifyModuleOfConfigChangeL(modDataIn);
		//	}

		iNetSim.ClearAssistanceDataFilters();
		iNetSim.Close();  

		if(iTestCaseId == 8 || iTestCaseId == 9)
			{
			CleanupStack::PopAndDestroy(&iTransmitPositioner2);					
			}
		//CleanupStack::PopAndDestroy(iKeepAliveTimer);
		CleanupStack::PopAndDestroy(&iTransmitPositioner);					
		CleanupStack::PopAndDestroy(&server);	
		
		
		if(iTestCaseId==13) //Wait while all activities in the PM stop and not interfere with the remaining tests 
			{
			User::After(5000000);
			}
		}

	INFO_PRINTF1(_L("&lt;&lt;CT_LbsX3PStep_Cancel::doTestStepL()"));

	return TestStepResult();
	}
Ejemplo n.º 9
0
void PsyUtils::TPositionInfo2QGeoPositionInfo(TPositionInfoBase &aPosInfoBase, QGeoPositionInfo& aQPosInfo)
{
    if (aPosInfoBase.PositionClassType() & EPositionInfoClass  ||
            aPosInfoBase.PositionClassType() & EPositionSatelliteInfoClass) {
        TPositionInfo *posInfo = static_cast<TPositionInfo*>(&aPosInfoBase);
        TPosition pos;
        QGeoCoordinate  coord;

        posInfo->GetPosition(pos);
        coord.setLatitude(pos.Latitude());
        coord.setLongitude(pos.Longitude());
        coord.setAltitude(pos.Altitude());

        //store the QGeoCoordinate values
        aQPosInfo.setCoordinate(coord);

        TDateTime datetime = pos.Time().DateTime();
        QDateTime dt(QDate(datetime.Year() , datetime.Month() + 1, datetime.Day() + 1),
                     QTime(datetime.Hour() , datetime.Minute(), datetime.Second(),
                           datetime.MicroSecond() / 1000),
                     Qt::UTC);

        //store the time stamp
        aQPosInfo.setTimestamp(dt);

        //store the horizontal accuracy
        aQPosInfo.setAttribute(QGeoPositionInfo::HorizontalAccuracy, pos.HorizontalAccuracy());

        //store the vertical accuracy
        aQPosInfo.setAttribute(QGeoPositionInfo::VerticalAccuracy, pos.VerticalAccuracy());

        if (aPosInfoBase.PositionClassType() & EPositionSatelliteInfoClass) {
            TCourse course;
            TPositionSatelliteInfo *satInfo = static_cast<TPositionSatelliteInfo*>(&aPosInfoBase);
            satInfo->GetCourse(course);
            aQPosInfo.setAttribute(QGeoPositionInfo::Direction, course.Heading());
            aQPosInfo.setAttribute(QGeoPositionInfo::GroundSpeed, course.Speed());
            aQPosInfo.setAttribute(QGeoPositionInfo::VerticalSpeed, course.VerticalSpeed());
        }
    }

    if (aPosInfoBase.PositionClassType() & EPositionGenericInfoClass) {
        HPositionGenericInfo *genInfo = static_cast<HPositionGenericInfo*>(&aPosInfoBase);
        float val;
        //check for the horizontal speed
        if (genInfo->IsFieldAvailable(EPositionFieldHorizontalSpeed)) {
            genInfo->GetValue(EPositionFieldHorizontalSpeed, val);
            aQPosInfo.setAttribute(QGeoPositionInfo::GroundSpeed, val);
        }
        //check for the vertcal speed
        if (genInfo->IsFieldAvailable(EPositionFieldVerticalSpeed)) {
            genInfo->GetValue(EPositionFieldVerticalSpeed, val);
            aQPosInfo.setAttribute(QGeoPositionInfo::VerticalSpeed, val);
        }

        //check for the magnetic variation
        if (genInfo->IsFieldAvailable(EPositionFieldMagneticCourseError)) {
            genInfo->GetValue(EPositionFieldMagneticCourseError, val);
            aQPosInfo.setAttribute(QGeoPositionInfo::MagneticVariation, val);
        }

        //check for the heading
        if (genInfo->IsFieldAvailable(EPositionFieldHeading)) {
            genInfo->GetValue(EPositionFieldHeading, val);
            aQPosInfo.setAttribute(QGeoPositionInfo::Direction, val);
        }
    }
}
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();
	}