コード例 #1
0
// ---------------------------------------------------------
// CT_LbsClientPosTp194::StartL
//
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CT_LbsClientPosTp194::StartL()
    {
    
	SetupPsyL(iUidMultiPsy);

	TInt numberOfRuns = 100;
	TTimeIntervalMicroSeconds interval5 = TTimeIntervalMicroSeconds(4000000);
	TUid uid = iUidMultiPsy;
	
	CT_LbsClientPeriodicTester* periodicTester1 = CT_LbsClientPeriodicTester::NewL(interval5, KServiceName1, iLog, uid, numberOfRuns);
	CleanupStack::PushL(periodicTester1);

	CT_LbsClientPeriodicTester* periodicTester2 = CT_LbsClientPeriodicTester::NewL(interval5, KServiceName2, iLog, uid, numberOfRuns);
	CleanupStack::PushL(periodicTester2);

	periodicTester1->RequestNotification();
	periodicTester2->RequestNotification();
	
	// Active scheduler is stopped two times.
	CActiveScheduler::Start();
	CActiveScheduler::Start();

    //check for errors
    TBool test1 = periodicTester1 -> IsCompletedOK(); 
    TBool test2 = periodicTester2 -> IsCompletedOK();

    CleanupStack::PopAndDestroy(2,periodicTester1);
    
    if (!test1 || !test2)
        {
        _LIT(KError, "Test did not complete with no error, check log file");
        LogErrorAndLeaveL(KError);
        }

	}
コード例 #2
0
// ---------------------------------------------------------
// CT_LbsClientPosTp76::AssertTrueSecL
//
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CT_LbsClientPosTp76::AssertTrueSecL(TBool aCondition, const TDesC& aErrorMsg, TInt aErrorCode)
    {
  	if (!aCondition)
		{
		TBuf<100> buf;
		buf.Format(aErrorMsg, aErrorCode);
		LogErrorAndLeaveL(buf);
		}
    }
コード例 #3
0
void CT_LbsSimulationPsyPosTp400::TestTrpMultiClientSpsStoredFixExistL()
	{
	_LIT(KTrpMultiClientRequestError, "Error, the fixes are different.");
	
	if (!TwoClientRequestL(ETrue, K0seconds, K30seconds))
		{
		LogErrorAndLeaveL(KTrpMultiClientRequestError);
		}
	
	INFO_PRINTF1(_L("The fixes are identical."));
	}
コード例 #4
0
void CT_LbsSimulationPsyPosTp400::TestTrpMultiClientNmeaNoUpdateAgeL()
	{
	_LIT(KTrpMultiClientRequestError, "Error, The fixes are identical.");
	
	if (TwoClientRequestL(EFalse, K0seconds, K0seconds))
		{
		LogErrorAndLeaveL(KTrpMultiClientRequestError);
		}
	
	INFO_PRINTF1(_L("The fixes are different."));
	}
コード例 #5
0
// ---------------------------------------------------------
// CT_LbsClientPosTp76::CheckModuleInfoL
//
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CT_LbsClientPosTp76::CheckModuleInfoL(const TPositionModuleInfo& dbInfo,
                                const TPositionModuleInfo& clientInfo)
    {
    _LIT(KNotSame, "Module Info from settings is not the same as when read by GetModuleInfoById");
    if (dbInfo.IsAvailable() != clientInfo.IsAvailable() ||
        dbInfo.ModuleId() != clientInfo.ModuleId() ||
        dbInfo.DeviceLocation() != clientInfo.DeviceLocation() ||
        dbInfo.Capabilities() != clientInfo.Capabilities() ||
        dbInfo.TechnologyType() != clientInfo.TechnologyType() ||
        dbInfo.Version().iBuild != clientInfo.Version().iBuild ||
        dbInfo.Version().iMajor != clientInfo.Version().iMajor ||
        dbInfo.Version().iMinor != clientInfo.Version().iMinor ||
        dbInfo.Version().Name() != clientInfo.Version().Name() ||
        dbInfo.ClassesSupported(EPositionInfoFamily) != clientInfo.ClassesSupported(EPositionInfoFamily))
        {
        LogErrorAndLeaveL(KNotSame);
        }
    TPositionQuality dbQuality;
    TPositionQuality clientQuality;
    dbInfo.GetPositionQuality(dbQuality);
    clientInfo.GetPositionQuality(clientQuality);
    if (dbQuality.TimeToFirstFix() != clientQuality.TimeToFirstFix() ||
        dbQuality.TimeToNextFix() != clientQuality.TimeToNextFix() ||
        dbQuality.HorizontalAccuracy() != clientQuality.HorizontalAccuracy() ||
        dbQuality.VerticalAccuracy() != clientQuality.VerticalAccuracy() ||
        dbQuality.CostIndicator() != clientQuality.CostIndicator() || 
        dbQuality.PowerConsumption() != clientQuality.PowerConsumption() )
        {
        LogErrorAndLeaveL(KNotSame);
        }


    TBuf<30> name1;
    TBuf<30> name2;
    dbInfo.GetModuleName(name1);
    clientInfo.GetModuleName(name2);
    if (name1 != name2)
        {
        LogErrorAndLeaveL(KNotSame);
        }
    }
コード例 #6
0
void CT_LbsSimulationPsyPosTp400::TestTrpMultiClientSpsNoUpdateAgeL()
	{
	_LIT(KTrpMultiClientRequestError, "Error, The fixes are identical.");
	_LIT(KTrpMultiClientDirectionError, "Error, the position differences doesn't correspond direction of movement.");

	TReal latitudeDifference;
	TReal longitudeDifference;

	if (TwoClientRequestL(ETrue, K0seconds, K0seconds, &latitudeDifference,
			&longitudeDifference))
		{
		LogErrorAndLeaveL(KTrpMultiClientRequestError);
		}
	//The latitude and longitude difference should be positive 
	//to correspond movement direction specified in SPS file.
	if (latitudeDifference >= 0 || longitudeDifference <= 0)
		{
		LogErrorAndLeaveL(KTrpMultiClientDirectionError);
		}
	
	INFO_PRINTF3(_L("The fixes are different and Client 2 is further than Client 1.: %d/%d"), longitudeDifference, latitudeDifference);
	}
コード例 #7
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);
		}
	}
コード例 #8
0
void CT_LbsClientPosTp2::CheckPositionCourseInfoL(TPositionCourseInfo& aCourseInfo)
	{
	CheckPositionInfoL(aCourseInfo);
	TCourse course;
	aCourseInfo.GetCourse(course);
	if (course.Heading() != KHeading ||
		course.Speed() != KSpeed ||
		course.SpeedAccuracy() != KSpeedAcc ||
		course.HeadingAccuracy() != KHeadingAcc )
		{
		_LIT(KErrCourse, "Course not correct");
		LogErrorAndLeaveL(KErrCourse);
		}
	}
コード例 #9
0
void CT_LbsClientPosTp2::RequestL(TPositionInfoBase& aInfoBase)
	{
	_LIT(KService, "service");
    TInt err = PerformSyncRequest(KService, &aInfoBase);

    if (err != KErrNone)
        {
        _LIT(KErrorRequest, "The request was not completed with KErrorNone, errCode = %d");
		TBuf<100> buf;
		buf.Format(KErrorRequest, err);
        LogErrorAndLeaveL(buf);
        }

	_LIT(KIncorrectPsySyncRequestError,
          "TP2. Position from wrong PSY received (sync request).");
	AssertTrueL(iUidMultiPsy == aInfoBase.ModuleId(), KIncorrectPsySyncRequestError);
	}
コード例 #10
0
void CT_LbsClientPosTp178::TestOptionL()
    {
    SetupPsyL(iUidTestPsy3);
    
    RPositioner positioner;
    
    ConnectL();
    
    User::LeaveIfError(positioner.Open(iPosServer,iUidTestPsy3));
    CleanupClosePushL(positioner);
    
    _LIT(KKalle, "Kalle");
    positioner.SetRequestor(CRequestor::ERequestorService,
        CRequestor::EFormatApplication, KKalle);
    
    TPositionUpdateOptions updateOptions;
    
    TTimeIntervalMicroSeconds timeoutInterval(4000000);
    TTimeIntervalMicroSeconds periodicInterval(7000000);
    
    updateOptions.SetUpdateTimeOut(timeoutInterval);
    updateOptions.SetUpdateInterval(periodicInterval);
    TInt err = positioner.SetUpdateOptions(updateOptions);
    if (err != KErrArgument)
        {
        _LIT(KErrArg, "Possible to set timout < update interval, error code = %d");
        TBuf<100> buf;
        buf.Format(KErrArg, err);
        INFO_PRINTF1(buf);
        LogErrorAndLeaveL(buf);
        }

    //should never be runned;
    CleanupStack::PopAndDestroy(1); //positioner
    Disconnect();
    }
コード例 #11
0
// ---------------------------------------------------------
// CT_LbsClientPosTp193::StartL
//
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CT_LbsClientPosTp193::StartL()
    { 
	SetupPsyL(iUidTestPsy2);
	
	User::After(2000000);

	const TInt KNrOfClients = 25;
	CT_LbsPosClientHolder* clients = CT_LbsPosClientHolder::NewLC(KNrOfClients,iUidTestPsy2);	
    
    TTime starttime,stoptime;
    
    starttime.UniversalTime();
    
    clients->MakeRequests();
    
    stoptime.UniversalTime();
    
    // Substract total delay incurred due to TestPsy2...i.e 2sec
    TInt duration=stoptime.Int64()-starttime.Int64()-2000000;
    
    _LIT(KMessage,"25 simultaneous requests from 25 different sessions with a psy completed in %d microsec");
    TBuf<256> message;
    message.Format(KMessage,duration);
    INFO_PRINTF1(message);
    
    if(duration>3000000)
	    {
	    _LIT(KTime, "Time taken>3 sec");
	    INFO_PRINTF1(KTime);
	    }

	//check the result of the request
	//only KErrNoMemory or KErrNone is allowed.
	// CONSTANTS
    
   TPositionInfo position[KNrOfClients];

    TTimeIntervalMicroSeconds reqTime[KNrOfClients];
    TInt status;
    TBool error = EFalse;
    TBuf<150> buf;

	//some printing mostly used for information purpose.
    for (TInt i = 0; i < KNrOfClients; i++)
        {
        clients->GetResult(status, position[i], reqTime[i], i);
        if (status != 0)
            {
            _LIT(KError, "The position requested could not be retrieved, status = %d");
            buf.Format(KError, status);
            ERR_PRINTF1(buf);
            if (status != -4)
                {
                error = ETrue;
                }
            }
            _LIT(KReqMsg, "client %d request time: %d");

            buf.Format(KReqMsg, i, reqTime[i].Int64());
            INFO_PRINTF1(buf);
            _LIT(KSeparator, "********");
            INFO_PRINTF1(KSeparator);
        }

    if (error)
        {
        _LIT(KErrorCode, "The requests was not completed with KErrNoMemory or KErrNone");
        LogErrorAndLeaveL(KErrorCode);
        }
    CleanupStack::PopAndDestroy(clients); //clients
    }
コード例 #12
0
// ---------------------------------------------------------
// CT_LbsClientPosTp1::StartL
//
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CT_LbsClientPosTp1::StartL()
    {
    ConnectL();
    
    CPosModules* db = CPosModules::OpenL();
    CleanupStack::PushL(db); 

    SetupPsyL(iUidMultiPsy);

    _LIT(KSetupPSY, "TP1: Has Setup Multi PSY");
    INFO_PRINTF1(KSetupPSY);
    
    //setting priority
	TPositionModuleInfo moduleInfoHp;//Hp - high prio;
	TPositionModuleInfo moduleInfoLp;//Lp - low prio;

    CPosModuleIdList* prioList = db->ModuleIdListLC();	
    db->GetModuleInfoL(prioList->At(0), moduleInfoHp);

    CPosModuleUpdate* moduleUpdate = CPosModuleUpdate::NewLC();
    moduleUpdate->SetUpdateAvailability(ETrue);

    if (iUidMultiPsy.iUid == moduleInfoHp.ModuleId().iUid)
		{
		// Case when Multi PSY has highest prio: 
		// Ensuring it is enabled
	    _LIT(KMultiHighest, "TP1: Case when Multi PSY has highest prio");
	    INFO_PRINTF1(KMultiHighest);	    
		db->UpdateModuleL((*prioList)[0], *moduleUpdate);
		}
	else
		{
		// Case when Multi PSY has not highest prio: 
		// 
	    _LIT(KMultiNotHighest, "TP1: Case when Multi PSY has NOT highest prio");	    
	    INFO_PRINTF1(KMultiNotHighest);	    
        db->GetModuleInfoL(iUidMultiPsy, moduleInfoLp);
		// Ensuring it is enabled
		db->UpdateModuleL(iUidMultiPsy, *moduleUpdate);

		TUint hp = db->PriorityL(moduleInfoHp.ModuleId());
		TUint lp = db->PriorityL(moduleInfoLp.ModuleId());

		// Changing prio of highest prio PSY and Multi PSY.
		// Setting Multi PSY to highest prio
		db->SetModulePriorityL(iUidMultiPsy, hp);
        db->SetModulePriorityL((*prioList)[0], lp); 
		}

	_LIT(KTestPSY1On, "TP1: Enabling Test PSY 1");
    INFO_PRINTF1(KTestPSY1On);	    
	db -> UpdateModuleL(iUidTestPsy1, *moduleUpdate);
	_LIT(KTestPSY2On, "TP1: Enabling Test PSY 2");
    INFO_PRINTF1(KTestPSY2On);
	db -> UpdateModuleL(iUidTestPsy2, *moduleUpdate);
    
	CleanupStack::PopAndDestroy(moduleUpdate);
	CleanupStack::PopAndDestroy(2, db); // db, prioList

    User::LeaveIfError(OpenPositioner());

    // Request data from default psy should be Multi psy
    _LIT(KService, "service");
    TPositionInfo posInfo = TPositionInfo();
    TInt err = PerformSyncRequest(KService, &posInfo);
    if (err != KErrNone)
        {
        _LIT(KErrorRequest, "The request was not completed with KErrNone");
        LogErrorAndLeaveL(KErrorRequest, err);
        }
	
    if (iUidMultiPsy.iUid != posInfo.ModuleId().iUid)
		{
		_LIT(KIncorrectPsyError, "TP1. Position from wrong PSY received");
		LogErrorAndLeaveL(KIncorrectPsyError);
		}

	HPositionGenericInfo* genericInfo = HPositionGenericInfo::NewLC();
	err = PerformSyncRequest(KService, &(*genericInfo));
    if (err != KErrNone)
        {
        _LIT(KErrorRequest, "The request was not completed with KErrNone");
        LogErrorAndLeaveL(KErrorRequest);
        }

	 if (iUidMultiPsy.iUid != (genericInfo -> ModuleId()).iUid)
		{
		_LIT(KIncorrectPsyError,
           "TP1. Position from wrong PSY received");
		LogErrorAndLeaveL(KIncorrectPsyError);
		}

	TPositionCourseInfo courseInfo = TPositionCourseInfo();
	err = PerformSyncRequest(KService, &courseInfo);
    if (err != KErrNone)
        {
        _LIT(KErrorRequest, "Course info supported by default, but request failed");
        LogErrorAndLeaveL(KErrorRequest);
        }

	TPositionSatelliteInfo satelliteInfo = TPositionSatelliteInfo();
	err = PerformSyncRequest(KService, &satelliteInfo);
    if (err != KErrNone)
        {
        _LIT(KErrorRequest, "Satellite info supported by default, but request failed");
        LogErrorAndLeaveL(KErrorRequest);
        }	

    //Changing the priority and verifiy that it still possilbe
    //to request updated from a psy if basic position information
    //is used and that it is not possilbe to request sat or cource
    //any more.
    SetupPsyL(iUidTestPsy2);
    User::After(3000000);

    // Request data from default psy should be test psy 2 now
    err = PerformSyncRequest(KService, &posInfo);
    if (err != KErrNone)
        {
        _LIT(KErrorRequest, "The request was not completed with KErrNone");
        LogErrorAndLeaveL(KErrorRequest);
        }
	
    if (iUidTestPsy2.iUid != posInfo.ModuleId().iUid)
		{
		_LIT(KIncorrectPsyError,
           "TP1. Position from wrong PSY received");
		LogErrorAndLeaveL(KIncorrectPsyError);
		}

	err = PerformSyncRequest(KService, &(*genericInfo));
    if (err != KErrNone)
        {
        _LIT(KErrorRequest, "The request was not completed with KErrNone");
        LogErrorAndLeaveL(KErrorRequest);
        }

	 if (iUidTestPsy2.iUid != (genericInfo -> ModuleId()).iUid)
		{
		_LIT(KIncorrectPsyError,
           "TP1. Position from wrong PSY received");
		LogErrorAndLeaveL(KIncorrectPsyError);
        }

    err = PerformSyncRequest(KService, &courseInfo);
    if (err != KErrArgument)
        {
        _LIT(KErrorRequest, "Course info not supported by default, KErrArgument not returned");
        LogErrorAndLeaveL(KErrorRequest);
        }


	err = PerformSyncRequest(KService, &satelliteInfo);
    if (err != KErrArgument)
        {
        _LIT(KErrorRequest, "Satellite info not supported by default, KErrArgument not returned");
        LogErrorAndLeaveL(KErrorRequest);
        }

    //check that it is possilbe to change the different
    //type of class info during periodic request and
    //that the periodic update will fail if the class
    //type is incorrect.
    TTimeIntervalMicroSeconds interval = TTimeIntervalMicroSeconds(1000000);
    TPositionUpdateOptions posOption;
	posOption.SetUpdateInterval(interval);
	_LIT(KUpdateErr, "Error when setting update interval,  %d");
	err = iPositioner.SetUpdateOptions(posOption);
    AssertTrueL(err == KErrNone, KUpdateErr, err);

    _LIT(KErrPeriodic, "The periodic request did not return KErrNone, %d");
    err = PerformSyncRequest(KService, &posInfo);
    AssertTrueL(err == KErrNone , KErrPeriodic, err);
    
    _LIT(KErrPeriodicArr, "The periodic request did not return KErrArgument, %d");
    err = PerformSyncRequest(KService, &satelliteInfo);
    AssertTrueL(err == KErrArgument , KErrPeriodicArr, err);
    SetupPsyL(iUidMultiPsy);
    User::After(3000000);
    err = PerformSyncRequest(KService, &satelliteInfo);
    AssertTrueL(err == KErrNone , KErrPeriodic, err);

    CleanupStack::PopAndDestroy(genericInfo);
    ClosePositioner();
    Disconnect();
    }
コード例 #13
0
// ---------------------------------------------------------
// CT_LbsClientPosTp178::TestTimeout
//
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CT_LbsClientPosTp178::TestTimeoutL()
    {
    _LIT(KSTART, "TestTimeout()");
    _LIT(KEND, "TestTimeout() passed");
    _LIT(KTIME, "Request took %d us");
    
    // Setup verification stuff
    INFO_PRINTF1(KSTART);
    
    //TPrivDlgDiagnostics tmpdiag;
    TTime requestStartTime;
    TTime requestStopTime;
    TTimeIntervalMicroSeconds durationMicro;
    
    TBuf<100> buf;
    
	_LIT(KService, "SAAA");
    TPositionUpdateOptions updateOptions;
    
    TTimeIntervalMicroSeconds longInterval(7000000);
    ConnectL();
    SetupPsyL(iUidTestPsy3);

    OpenPositionerByName(iUidTestPsy3);    
    updateOptions.SetUpdateTimeOut(longInterval);
    
    // Access protected member (iPositioner) here
    iPositioner.SetUpdateOptions(updateOptions);
    
    _LIT(KONE, "Perform first request, should NOT time out");
    INFO_PRINTF1(KONE);
    
    requestStartTime.UniversalTime();
    //Make one request to verify psy
    PerformRequestL(KService, CRequestor::ERequestorService, CRequestor::EFormatApplication);
    
    CheckRequestResultL(KErrNone);
    requestStopTime.UniversalTime();

    durationMicro = requestStopTime.MicroSecondsFrom(requestStartTime);
    TInt duration = durationMicro.Int64();
    
    buf.Format(KTIME, duration);
    INFO_PRINTF1(buf);
    
    ClosePositioner();
    
    OpenPositionerByName(iUidTestPsy3);
    // ECancelButton means that the Automatised class should wait for a cancel call
    // before returning result
    
    updateOptions.SetUpdateTimeOut(longInterval);
    
    // Access protected (iPositioner) member here
    iPositioner.SetUpdateOptions(updateOptions);
    
    _LIT(KTWO, "Perform second request, should not time out");
    INFO_PRINTF1(KTWO);
    
    //Make one request to verify psy
    TPositionInfo info = TPositionInfo();
    requestStartTime.UniversalTime();
    TInt err = PerformSyncRequest(KService, &info);
    requestStopTime.UniversalTime();
    
    if (err != KErrNone)
    {
        _LIT(KError, "Wrong result from iStatus, should be KErrNone, was %d");
        TBuf<100> buf;
        buf.Format(KError, err);
        LogErrorAndLeaveL(buf);
    }
    
    durationMicro = requestStopTime.MicroSecondsFrom(requestStartTime); 
    duration = durationMicro.Int64();
    
    buf.Format(KTIME, duration);
    INFO_PRINTF1(buf);
    
    ClosePositioner();
    Disconnect();

    INFO_PRINTF1(KEND);
}
コード例 #14
0
// ---------------------------------------------------------
// CT_LbsClientPosTp261::StartL
//
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CT_LbsClientPosTp261::StartL()
    {
    _LIT(KService1, "Service1");
    _LIT(KService2, "Service2");
    _LIT(KService3, "Service3");

    _LIT(KContact1, "Contact1");
    _LIT(KContact2, "Contact2");
    _LIT(KContact3, "Contact3");

    CRequestor* serviceId1 = 
		CRequestor::NewL(CRequestor::ERequestorService, CRequestor::EFormatApplication, 
                    KService1);

    CRequestor* serviceId2 = 
        CRequestor::NewL(CRequestor::ERequestorService, CRequestor::EFormatApplication, 
                    KService2);

    CRequestor* serviceId3 = 
        CRequestor::NewL(CRequestor::ERequestorService, CRequestor::EFormatApplication, 
                    KService3);

    CRequestor* contactId1 = 
        CRequestor::NewL(CRequestor::ERequestorContact, CRequestor::EFormatTelephone, 
                    KContact1);

    CRequestor* contactId2 = 
        CRequestor::NewL(CRequestor::ERequestorContact, CRequestor::EFormatUrl, 
                    KContact2);

    CRequestor* contactId3 = 
        CRequestor::NewL(CRequestor::ERequestorContact, CRequestor::EFormatMail, 
                    KContact3);

    RRequestorStack stack = RRequestorStack();
    CleanupStack::PushL(TCleanupItem(CleanOp ,&stack));

    CleanupStack::PushL(serviceId1);
    CleanupStack::PushL(serviceId2);
    CleanupStack::PushL(serviceId3);
    CleanupStack::PushL(contactId1);
    CleanupStack::PushL(contactId2);
    CleanupStack::PushL(contactId3);
    
    ConnectL();
    OpenPositioner();
    
    stack.Append(serviceId1);
    stack.Append(contactId1);
    stack.Append(contactId2);
    stack.Append(serviceId2);
    stack.Append(contactId3);
    stack.Append(serviceId3);

    CleanupStack::Pop(contactId3);
    CleanupStack::Pop(contactId2);
    CleanupStack::Pop(contactId1);
    CleanupStack::Pop(serviceId3);
    CleanupStack::Pop(serviceId2);
    CleanupStack::Pop(serviceId1);

    TInt err = iPositioner.SetRequestor(stack);
    if (err != KErrNone)
    	{
    	_LIT(KErrorAndLeave, "Problems setting requestorstack");
    	LogErrorAndLeaveL(KErrorAndLeave);
    	}
    	
    const TInt KPosBufFlatExpandSize = 100;
    
    //ExternalizeL
    CBufFlat* bufFlat = CBufFlat::NewL(KPosBufFlatExpandSize);
    CleanupStack::PushL(bufFlat);
    
    RBufWriteStream stream(*bufFlat);
    CleanupClosePushL(stream);        
    stack.ExternalizeL(stream);
    
    TPtr8 dataPtr((TUint8*)NULL, 0);
    dataPtr.Set(bufFlat->Ptr(0));    

    CleanupStack::PopAndDestroy(&stream);                

    HBufC8* tempBuf = HBufC8::NewLC(bufFlat->Size());
    TPtr8 ptr = tempBuf->Des();
    ptr = dataPtr;
    
    //Internalize
    bufFlat->InsertL(0, ptr);
    
    RBufReadStream rstream(*bufFlat);
    CleanupClosePushL(rstream);
    
    RRequestorStack stack2 = RRequestorStack();
    CleanupStack::PushL(TCleanupItem(CleanOp ,&stack2));

    stack2.InternalizeL(rstream);
    
    // Verify the requestor stack
    VerifyRequestorStackL(stack2);
    _LIT(KResult, "The RequestorStack is correct after Externalize/Internalize");
    INFO_PRINTF1(KResult);

    CleanupStack::PopAndDestroy(1); // CleanupOp stack2

    CleanupStack::PopAndDestroy(&rstream);
    CleanupStack::PopAndDestroy(tempBuf);
    CleanupStack::PopAndDestroy(bufFlat);
    CleanupStack::PopAndDestroy(1); // CleanupOp stack1

    ClosePositioner();
    Disconnect();
    }
コード例 #15
0
// ---------------------------------------------------------
// CT_LbsClientPosTp261::VerifyRequestorStackL
//
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CT_LbsClientPosTp261::VerifyRequestorStackL(RRequestorStack& aStack)
    {    
    TInt count = aStack.Count();
    
    _LIT(KService1, "Service1");
    _LIT(KService2, "Service2");
    _LIT(KService3, "Service3");

    _LIT(KContact1, "Contact1");
    _LIT(KContact2, "Contact2");
    _LIT(KContact3, "Contact3");

    // Hardcoded number of requestors
    if (count != 6)
        {
        _LIT(KErrorAndLeave, "Wrong number of requestors in the stack");
        LogErrorAndLeaveL(KErrorAndLeave);
        }

    if (aStack[0]->RequestorType() != CRequestor::ERequestorService
           || aStack[0]->RequestorFormat() != CRequestor::EFormatApplication
           || aStack[0]->RequestorData() != KService1)
            {
            _LIT(KErrorAndLeave, "Wrong requestor(1) in stack");
            LogErrorAndLeaveL(KErrorAndLeave);
            }

    if (aStack[1]->RequestorType() != CRequestor::ERequestorContact
           || aStack[1]->RequestorFormat() != CRequestor::EFormatTelephone
           || aStack[1]->RequestorData() != KContact1)
            {
            _LIT(KErrorAndLeave, "Wrong requestor(2) in stack");
            LogErrorAndLeaveL(KErrorAndLeave);
            }

    if (aStack[2]->RequestorType() != CRequestor::ERequestorContact
           || aStack[2]->RequestorFormat() != CRequestor::EFormatUrl
           || aStack[2]->RequestorData() != KContact2)
            {
            _LIT(KErrorAndLeave, "Wrong requestor(3) in stack");
            LogErrorAndLeaveL(KErrorAndLeave);
            }

    if (aStack[3]->RequestorType() != CRequestor::ERequestorService
           || aStack[3]->RequestorFormat() != CRequestor::EFormatApplication
           || aStack[3]->RequestorData() != KService2)
            {
            _LIT(KErrorAndLeave, "Wrong requestor(4) in stack");
            LogErrorAndLeaveL(KErrorAndLeave);
            }

    if (aStack[4]->RequestorType() != CRequestor::ERequestorContact
           || aStack[4]->RequestorFormat() != CRequestor::EFormatMail
           || aStack[4]->RequestorData() != KContact3)
            {
            _LIT(KErrorAndLeave, "Wrong requestor(5) in stack");
            LogErrorAndLeaveL(KErrorAndLeave);
            }

    if (aStack[5]->RequestorType() != CRequestor::ERequestorService
           || aStack[5]->RequestorFormat() != CRequestor::EFormatApplication
           || aStack[5]->RequestorData() != KService3)
            {
            _LIT(KErrorAndLeave, "Wrong requestor(6) in stack");
            LogErrorAndLeaveL(KErrorAndLeave);
            }    
    }
コード例 #16
0
// ---------------------------------------------------------
// CPosTp208::StartL
//
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CT_LbsClientPosTp208::StartL()
    {
    //first do a simple connection test
    TInt fasterr = DoFastConnectionL();
    _LIT(KFailConnect, "Fast connection failed");
    AssertTrueL(fasterr == KErrNone, KFailConnect, fasterr);  

    SetupPsyL(iUidMultiPsy);

    TInt nrOfRounds = 1;
    TBuf<100> buf;
    
    _LIT(KPsitionUpdate, 
    		">>>>>>>>>>Running StartThreads(ETrue) requesting position updates<<<<<<<<");
    INFO_PRINTF1(KPsitionUpdate);

    _LIT(KEmptySpace, "");
    _LIT(KRound, ">>>>>>Round nr %d :");
    _LIT(KErrorsFound, "Errors found!!!");
    
    for (TInt i=0; i<nrOfRounds; i++)
        {
        INFO_PRINTF1(KEmptySpace);
        buf.Format(KRound, i);
        INFO_PRINTF1(buf);
        TTime now, startTime;
        TTimeIntervalMicroSeconds requestTime;
        
        startTime.UniversalTime();
        TInt res = StartThreads(ETrue);
        if (res != KErrNone) 
        	LogErrorAndLeaveL(KErrorsFound, res);
        now.UniversalTime();
        
        requestTime = now.MicroSecondsFrom(startTime);
        _LIT(KDebug, "%d requests from %d threads took: %d microsecs.");
        buf.Zero();
        TInt64 reqTime = requestTime.Int64();
        buf.Format(KDebug, KNrOfClients * KNrOfRuns, KNrOfClients, reqTime);
        INFO_PRINTF1(buf);
      
        }

    _LIT(KConnectDisconnect, 
    		">>>>>>>>>>Running StartThreads(EFalse) connect/disconnect Epos<<<<<<<<");
    INFO_PRINTF1(KConnectDisconnect);
    nrOfRounds = 5;
    for (TInt j=0; j<nrOfRounds; j++)
        {
        INFO_PRINTF1(KEmptySpace);
        buf.Format(KRound, j);
        INFO_PRINTF1(buf);
        TTime now, startTime;
        TTimeIntervalMicroSeconds requestTime;
       
        startTime.UniversalTime();

        // Threads only connects to Epos server and then disconnect
        TInt res = StartThreads(EFalse);
        if (res != KErrNone) 
        	LogErrorAndLeaveL(KErrorsFound, res);
        now.UniversalTime();
        
        requestTime = now.MicroSecondsFrom(startTime);
        _LIT(KDebug, "%d threads connecting and disconnecting to Epos server took: %d microsecs.");
        buf.Zero();
        TInt64 reqTime = requestTime.Int64();
        buf.Format(KDebug, KNrOfClients, reqTime);
        INFO_PRINTF1(buf);
        }
    }
コード例 #17
0
// ---------------------------------------------------------
// CT_LbsClientPosTp76::StartL
//
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CT_LbsClientPosTp76::StartL()
    {
	// Open connection to Epos    
	RPositionServer posServer;
	CleanupClosePushL(posServer);
	TInt err = posServer.Connect();    
	_LIT(KConnectError, "TP76. Unable to open connection to Epos, return code %d");
	AssertTrueSecL(err == KErrNone, KConnectError, err);

	// Set priority for those psys that will be used in this tp.
	// The order will be testpsy1(externalgps),testpsy2,testpsy3
	TUid uidPsy1 = iUidTestPsy1;
	TUid uidPsy2 = iUidTestPsy2;
	TUid uidPsy3 = iUidTestPsy3;

    SetupPsyL(uidPsy1); // will disable all except uidPsy1

    CPosModules* db = CPosModules::OpenL();
    CleanupStack::PushL(db);

    // Enable the PSY test psys 
    CPosModuleUpdate* moduleUpdate = CPosModuleUpdate::NewLC();
    moduleUpdate -> SetUpdateAvailability(ETrue);
    db->SetModulePriorityL(uidPsy1, 0);
    db->SetModulePriorityL(uidPsy2, 1);
    db->SetModulePriorityL(uidPsy3, 1);
    db->UpdateModuleL(uidPsy1, *moduleUpdate);
    db->UpdateModuleL(uidPsy2, *moduleUpdate);
    db->UpdateModuleL(uidPsy3, *moduleUpdate);
    CleanupStack::PopAndDestroy(moduleUpdate);

    // Setup the PSY:s in the correct order
    CPosModuleIdList* prioList = db->ModuleIdListLC();
    TInt numModules = prioList->Count();
    TPositionModuleInfo modInfoPsy2; //used to comapre that the same result is returned.
    db -> GetModuleInfoL(uidPsy2, modInfoPsy2);
    CleanupStack::PopAndDestroy(2); // db, prioList
	
	// Get default positioning module info. (testpsy1 or externalgps)
	TPositionModuleInfo modInfo;
    TPositionModuleId defaultId;
    err = posServer.GetDefaultModuleId(defaultId);
    _LIT(KDefaultModuleId, "Not possible to get default module id");
    AssertTrueSecL(err == KErrNone, KDefaultModuleId, err);
    // Check that the correct id was returned.
    if (defaultId != uidPsy1)
        {
        _LIT(KErrorWrongModule, "Default module was not returned in GetDefaultModuleId()");
        LogErrorAndLeaveL(KErrorWrongModule);
        }

    // Get default module info by using the id returned.
    err = posServer.GetModuleInfoById(defaultId, modInfo);
	_LIT(KGetDefPosModInfoError,
            "TP76. Error occured at GetModuleInfoById, return code %d");
	AssertTrueSecL(err == KErrNone, KGetDefPosModInfoError, err);
	// Check if the received psy is the right one
	_LIT(KIncorrectPsyError,
           "TP76. Incorrect PSY returned from Epos.");
	AssertTrueL(uidPsy1 == modInfo.ModuleId(), KIncorrectPsyError);
    //END TEST DEFAULT//

	//
    // TestGetModuleInfoById //
	//

    // Get info from specific psy (testpsy2)
	_LIT(KGetPosModInfoError, "Wrong data received from Epos");
    err = posServer.GetModuleInfoById(uidPsy2, modInfo);
	AssertTrueSecL(err == 0, KGetPosModInfoError, err);
	AssertTrueL(modInfo.ModuleId() == uidPsy2, KGetPosModInfoError);
    CheckModuleInfoL(modInfoPsy2, modInfo);
    //END TEST GetModuleInfoById//

	//
    // Test GetModuleInfoByIndex //
	//

	// Get info from the testpsys (testpsy1, testpsy2, testpsy3)
    TPositionModuleId id1;
    TPositionModuleId id2;
    TPositionModuleId id3;
    TUint count;
	err = posServer.GetNumModules(count);
	_LIT(KNumPosModInfoError,
            "TP76. Error occured at GetNumModules error code returned, return code %d");
	AssertTrueSecL(err == 0,KNumPosModInfoError,err);
	_LIT(KIncorrectNoOfModules,
           "TP76. Incorrect number of modules.");
    TUint no = (TUint) numModules; //Bad API implementation
	AssertTrueL(count == no, KIncorrectNoOfModules);

    err = posServer.GetModuleInfoByIndex(0, modInfo);
    AssertTrueSecL(err == KErrNone, KGetDefPosModInfoError, err);
    id1 = modInfo.ModuleId();
    if (!(id1 == uidPsy1 ||
        id1 == uidPsy2 ||
        id1 == uidPsy3))
        {
        LogErrorAndLeaveL(KGetPosModInfoError);
        }

    err = posServer.GetModuleInfoByIndex(1, modInfo);
    AssertTrueSecL(err == 0, KGetDefPosModInfoError, err);
    id2 = modInfo.ModuleId();
    if (!(id2 == uidPsy1 ||
        id2 == uidPsy2 ||
        id2 == uidPsy3))
        {
        LogErrorAndLeaveL(KGetPosModInfoError);
        }

    err = posServer.GetModuleInfoByIndex(2, modInfo);
    AssertTrueSecL(err == 0, KGetDefPosModInfoError, err);
    id3 = modInfo.ModuleId();
    if (!(id3 == uidPsy1 ||
        id3 == uidPsy2 ||
        id3 == uidPsy3))
        {
        LogErrorAndLeaveL(KGetPosModInfoError);
        }
    
    // Assuming that only 3 PSYs are installed
    err = posServer.GetModuleInfoByIndex(3, modInfo);
    AssertTrueSecL(err == 0, KGetDefPosModInfoError, err);

    // END TEST GetModuleInfoByIndex //

	CleanupStack::PopAndDestroy(); //posServer
	}
コード例 #18
0
// ---------------------------------------------------------
// CT_LbsClientPosTp178::StartL
//
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CT_LbsClientPosTp178::StartL()
    {
    _LIT(KServiceAccept, "SAAA");
    
    SetupPsyL(iUidTestPsy3);
    
    RPositioner positioner;
    TPositionInfo info = TPositionInfo();
    
    ConnectL();
    
    User::LeaveIfError(positioner.Open(iPosServer,iUidTestPsy3));
    CleanupClosePushL(positioner);
    
    TInt Err = positioner.SetRequestor(CRequestor::ERequestorService,
        CRequestor::EFormatApplication, KServiceAccept);
    
    TPositionUpdateOptions updateOptionsLong, updateOptionsShort;
    
    TTimeIntervalMicroSeconds longInterval(7000000);
    
    updateOptionsLong.SetUpdateTimeOut(longInterval);
    Err = positioner.SetUpdateOptions(updateOptionsLong);
    
    TTimeIntervalMicroSeconds shortInterval(2000000);
    updateOptionsShort.SetUpdateTimeOut(shortInterval);
    
    TPositionUpdateOptions theUpdateOptions;
    Err = positioner.GetUpdateOptions(theUpdateOptions);
    
    if (theUpdateOptions.UpdateTimeOut() != updateOptionsLong.UpdateTimeOut() ||
        updateOptionsLong.UpdateTimeOut() != longInterval)
    {
        _LIT(KUpdateOptions, "The update option was not set correctly");
        LogErrorAndLeaveL(KUpdateOptions);
    }
    
    _LIT(KDelayMsg, "The successfull requests was completed within %d microsecs.");
    _LIT(KCancelMsg, "The canceled requests was completed within %d microsecs.");
    
    TRequestStatus status;
    
    for (TInt i = 0; i < 10; i++) // makes 10 test inorder to get some statistic
    {         
        
        positioner.SetUpdateOptions(updateOptionsLong);
        TTime requestStartTime;
        
        requestStartTime.UniversalTime();
        positioner.NotifyPositionUpdate(info, status);
        User::WaitForRequest(status);
        TTime requestStopTime;
        requestStopTime.UniversalTime();
        
        TTimeIntervalMicroSeconds durationMicro = requestStopTime.MicroSecondsFrom(requestStartTime);
        
        TInt duration = durationMicro.Int64();
        
        TBuf<100> timeMsg;
        timeMsg.Format(KDelayMsg, duration);
        INFO_PRINTF1(timeMsg);
        
        //check error status
        if (status != KErrNone)
        {
            _LIT(KErrPositionRequest, "error code returned from NotifyPositionUpdate, error code = %d");
            TBuf<100> buf;
            buf.Format(KErrPositionRequest, status.Int());
            LogErrorAndLeaveL(buf);
        }
        
        
        TTimeIntervalMicroSeconds shortInterval(2000000);
        updateOptionsShort.SetUpdateTimeOut(shortInterval);
        
        positioner.SetUpdateOptions(updateOptionsShort);
        
        requestStartTime.UniversalTime();
        positioner.NotifyPositionUpdate(info, status);
        User::WaitForRequest(status);
        requestStopTime.UniversalTime();
        
        durationMicro = requestStopTime.MicroSecondsFrom(requestStartTime);
        
        duration = durationMicro.Int64();
        
#ifdef __WINS__
        TTimeIntervalMicroSeconds winsFail(100000);
        durationMicro = TTimeIntervalMicroSeconds(durationMicro.Int64()+winsFail.Int64());
#endif
        
        timeMsg.Format(KCancelMsg, duration);
        INFO_PRINTF1(timeMsg);
        
        
        if (status != KErrTimedOut)
        {
            _LIT(KErrPositionRequest, "Request did not returned KErrTimedOut, status code = %d.");
            TBuf<100> buf;
            buf.Format(KErrPositionRequest, status.Int());
            LogErrorAndLeaveL(buf);
        }

        //Check that the request was not aborted before the Interval
        //Remove this condition if a lot of data is needed in test log.
        if (durationMicro < shortInterval)
        {
            _LIT(KErrInterval, " The request was aborted before the set timed out ");
            LogErrorAndLeaveL(KErrInterval);
        }
        
        
    } // end for loop
    CleanupStack::PopAndDestroy(1); //positioner
    Disconnect();

    // Do timeout test
    TestTimeoutL();

    // Do cancel test
    TestCancelL();

    // ESLI-5QRA7U just check that it is not possible to set a timeout that is less than
    // the update interval
    TestOptionL();
    }