Ejemplo n.º 1
0
void CLcfPsyDummy3::GetPositionCourseInfoL(TPositionInfoBase& aPosInfo)
    {
    TPositionCourseInfo* courseInfo = static_cast<TPositionCourseInfo*>(&aPosInfo);
    TCourse course;

    // fill in course data
    course.SetHeading(DUMMY_HEADING);
    course.SetSpeed(DUMMY_SPEED);
    course.SetHeadingAccuracy(DUMMY_HEADING_ACCURACY);
    course.SetSpeedAccuracy(DUMMY_SPEED_ACCURACY);

    // store it in course info
    courseInfo->SetCourse(course);

    courseInfo->SetModuleId(ImplementationUid());
    }
Ejemplo n.º 2
0
void CNetworkGateway::ProcessNetworkLocationMessage(const TLbsNetLocMsgBase& aMessage)
	{
	LBSLOG(ELogP2, "CNetworkGateway::ProcessNetworkLocationMessage:");
	LBSLOG2(ELogP3, "Type : %d", aMessage.Type());

	switch (aMessage.Type())
		{
		case TLbsNetLocMsgBase::ENetLocMsgNetworkLocationRequest:
			{
			TInt reason = KErrNone;
			const TLbsNetLocNetworkLocationRequestMsg& req = static_cast<const TLbsNetLocNetworkLocationRequestMsg&>(aMessage);
			iCurrentNetLocReqId = req.SessionId();
			
			if (req.Quality().MaxFixTime() == 0)//answer req with incorrect session id
				{		
				iCurrentNetLocReqId.SetSessionNum(999);
				TLbsNetLocNetworkLocationCompleteMsg msg(iCurrentNetLocReqId, reason);	
				iNetworkLocationChannel->SendNetworkLocationMessage(msg);
				}

			else if (req.Quality().MaxFixTime() == 1)//answer req with unknown response type
				{		
				TLbsNetLocNetworkLocationCancelMsg msg(iCurrentNetLocReqId, reason);
				iNetworkLocationChannel->SendNetworkLocationMessage(msg);
				}
				
			else
				{
				TLbsNetLocNetworkLocationCompleteMsg msg(iCurrentNetLocReqId, reason);	
				iNetworkLocationChannel->SendNetworkLocationMessage(msg);
				}
				
			// for testing return a fixed test location
			TPositionCourseInfo posInfo;
			TPosition pos;
			pos.SetCoordinate(50, 80);
			posInfo.SetPosition(pos);
			
			TCourse course;
            course.SetSpeed(10.0);
            course.SetVerticalSpeed(20.0);
            course.SetHeading(30.0);
            course.SetSpeedAccuracy(1.0);
            course.SetVerticalSpeedAccuracy(2.0);
            course.SetHeadingAccuracy(3.0);
            course.SetCourse(40.0);
            course.SetCourseAccuracy(4.0);
            
            posInfo.SetCourse(course);
			
			iNetworkLocationChannel->SetReferencePosition(iCurrentNetLocReqId, posInfo);
			break;
			}
		case TLbsNetLocMsgBase::ENetLocMsgNetworkLocationCancel:
			{
			const TLbsNetLocNetworkLocationCancelMsg& cancel = static_cast<const TLbsNetLocNetworkLocationCancelMsg&>(aMessage);
			// for test netlocmanager, return the location info directly without sending request to network protocol
			iCurrentNetLocReqId = cancel.SessionId();
			TInt reason = KErrNone;
			TLbsNetLocNetworkLocationCompleteMsg msg(iCurrentNetLocReqId, reason);
			iNetworkLocationChannel->SendNetworkLocationMessage(msg);
			break;
			}
		case TLbsNetLocMsgBase::ENetLocMsgNetworkLocationComplete:
		default:
			{
			break;
			}
		}
	}
TVerdict ClbsinternalapiTest3Step::doTestStepL()
/**
 * @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.
 */
	{
	  if (TestStepResult()==EPass)
		{
		//Let's test!

	    TPositionExtendedSatelliteInfo posSatInfo;
		RLbsPositionUpdates::InitializeL(posSatInfo);
		
		RLbsPositionUpdates posUpdates;
		
		//First Open, Close, re-Open to check for handle leaks etc.
		posUpdates.OpenL(KLbsGpsLocManagerUid);
		CleanupClosePushL(posUpdates);
		CleanupStack::PopAndDestroy(&posUpdates);
		
		posUpdates.OpenL(KLbsGpsLocManagerUid);
		CleanupClosePushL(posUpdates);
		
		//First, check the default data is OK.
		//Should be a default TPositionExtendedSatelliteInfo.
		TPositionExtendedSatelliteInfo satInfo;
		//Put some non-default data in it, then check we get the default data back.
		satInfo.SetSatelliteTime(TTime(500));
		
		TInt error=1;
		TTime targetTime(100);
		TTime actualTime(200);
		TBool conflictControl;
		error = posUpdates.GetPositionInfo(conflictControl, &satInfo, sizeof(satInfo),targetTime, actualTime);
		//Now check we got deviuce not ready
		
		if(error!=KErrNotReady)
			User::Leave(KErrGeneral);
			
		//Now check that the same for TPositionInfo and TPositionCourseInfo
		
		TPositionInfo posInfo;
		posInfo.SetModuleId(KLbsGpsLocManagerUid);
		error = posUpdates.GetPositionInfo(conflictControl, &posInfo, sizeof(posInfo),targetTime, actualTime);

		if(error!=KErrNotReady)
			User::Leave(KErrGeneral);
	
				
		TPositionCourseInfo courseInfo;
		TCourse course;
		course.SetSpeed(TReal32(100));
		courseInfo.SetCourse(course);
		
		error = posUpdates.GetPositionInfo(conflictControl, &courseInfo, sizeof(courseInfo),targetTime, actualTime);
		if(error!=KErrNotReady)
			User::Leave(KErrGeneral);

	
		
		//OK - we are now reasonably happy with Getting - it donsn't mash up the class size/type data
		//and it seems to be doing the data copying OK.
		
		//Next move onto the set method...
		//Choose some dummy values.
		error = KErrGeneral;
		targetTime = 1000;
		actualTime = 1001;
		satInfo.SetSatelliteTime(TTime(4020));
		
		User::LeaveIfError(posUpdates.SetPositionInfo(error, EFalse, &satInfo, sizeof(satInfo),targetTime, actualTime));
		error = posUpdates.GetPositionInfo(conflictControl, &satInfo, sizeof(satInfo),targetTime, actualTime);
		if(error!=KErrGeneral)
			User::Leave(KErrGeneral);
		if(conflictControl!=EFalse)
			User::Leave(KErrGeneral);
		if(targetTime!=1000)
			User::Leave(KErrGeneral);
		if(actualTime!=1001)
			User::Leave(KErrGeneral);
		if(satInfo.SatelliteTime()!=TTime(4020))
			User::Leave(KErrGeneral);
		
		
		//Go on to check out notifications.
		//Open another handle.
		
		RLbsPositionUpdates posUpdates2;
		
		//First Open, Close, re-Open to check for handle leaks etc.
		posUpdates2.OpenL(KLbsGpsLocManagerUid);
		CleanupClosePushL(posUpdates2);
		
		TRequestStatus stat;
		posUpdates2.NotifyPositionUpdate(stat);
		User::LeaveIfError(posUpdates.SetPositionInfo(error, EFalse, &satInfo, sizeof(satInfo),targetTime, actualTime));
		User::WaitForRequest(stat);
		
		if(stat.Int()!=KErrNone)
			User::Leave(KErrGeneral);
		
		//Now check the cancel.
		posUpdates2.NotifyPositionUpdate(stat);
		posUpdates2.CancelNotifyPositionUpdate();
		User::WaitForRequest(stat);
		
		if(stat.Int()!=KErrCancel)
			User::Leave(KErrGeneral);

		CleanupStack::PopAndDestroy(2, &posUpdates);
		SetTestStepResult(EPass);
		}
	  return TestStepResult();
	}