Пример #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);
        }

	}
void CT_LbsSimulationPsyPosTp400::StartL()
	{
	// Setup test environment
	iNrOfRequests = 0;
	ConnectL();
	SetupPsyL(iUidSimulationPsy);
	RunTestsL(iIndex);
	}
// ---------------------------------------------------------
// CT_LbsClientPosTp272::StartL
//
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CT_LbsClientPosTp272::StartL()
    {
    _LIT(KOpenErr, "Error when opening MultiPSY, %d");
    _LIT(KServiceName, "TP272");
    
    SetupPsyL(iUidMultiPsy);
    
    ConnectL();
    
    TInt err = OpenPositionerByName(iUidMultiPsy);
    AssertTrueSecL(err == KErrNone, KOpenErr, err);
    
    iPositioner.SetRequestor(CRequestor::ERequestorService, CRequestor::EFormatApplication, KServiceName);

    SetPeriodicUpdateL(KUpdateInterval);
    
    TInt request=0;
    // NotifyPositionUpdate should be called direct by the server on the first request 
    // even if update interval is used
    RequestL(++request, KMinTimeLimitRequest1, KMaxTimeLimitRequest1);    
   
    // Even if same update interval is set again should the first request complete direct
    SetPeriodicUpdateL(KUpdateInterval);
    RequestL(++request, KMinTimeLimitRequest2, KMaxTimeLimitRequest2);

    // NotifyPositionUpdate should be called after the update interval on the second request 
    // but when the update interval is changed should it be called direct
    RequestL(++request, KMinTimeLimitRequest2, KMaxTimeLimitRequest2, KUpdateInterval2);
    
    // Now should the request time be about 10 sec
    RequestL(++request, KMinTimeLimitRequest3, KMaxTimeLimitRequest3); 

    SetPeriodicUpdateL(KUpdateInterval3);

    // Should return direct since update interval changed again
    RequestL(++request, KMinTimeLimitRequest4, KMaxTimeLimitRequest4);
    

    }
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();
    }
// ---------------------------------------------------------
// CT_LbsClientPosTp178::TestCancel
//
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CT_LbsClientPosTp178::TestCancelL()
    {
    _LIT(KSTART, "TestCancel()");
    _LIT(KEND, "TestCancel() passed");
    
    // Setup verification stuff
    INFO_PRINTF1(KSTART);
    
	_LIT(KService, "SAAA");
    ConnectL();
    SetupPsyL(iUidTestPsy3);    
   
    OpenPositionerByName(iUidTestPsy3);
    
    PerformRequestL(KService, CRequestor::ERequestorService, CRequestor::EFormatApplication);
    StartSchedulerForAWhile178L(2000000);
    iPositioner.CancelRequest(EPositionerNotifyPositionUpdate); 
    CheckRequestResultL(KErrCancel);

    ClosePositioner();
    Disconnect();

    INFO_PRINTF1(KEND);
}
// ---------------------------------------------------------
// CT_LbsClientPosTp2::StartL
//
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CT_LbsClientPosTp2::StartL()
    {
	SetupPsyL(iUidMultiPsy);

    //synchronous request
    ConnectL();

    User::LeaveIfError(OpenPositionerByName(iUidMultiPsy));

    TPositionInfo info = TPositionInfo();

	RequestL(info);
	CheckPositionInfoL(info);
	
	TPositionCourseInfo courseInfo;

	RequestL(courseInfo);
	CheckPositionCourseInfoL(courseInfo);

	TPositionSatelliteInfo satelliteInfo;

	RequestL(satelliteInfo);
	CheckPositionSatelliteInfoL(satelliteInfo);


    HPositionGenericInfo* genericInfo = HPositionGenericInfo::NewLC();

	RequestL(*genericInfo);
	CheckGenericInfoL(*genericInfo);

    CleanupStack::PopAndDestroy(); //genericInfo

	ClosePositioner();

	Disconnect();
	}
// ---------------------------------------------------------
// 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
	}
// ---------------------------------------------------------
// 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
    }
Пример #9
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();
    }
// ---------------------------------------------------------
// 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();
    }
// ---------------------------------------------------------
// 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);
}
// ---------------------------------------------------------
// 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);
        }
    }
Пример #13
0
/**
* Performes the test by connecting to MLFW and makes 50 Location request
*/
TInt DoTestL()
{
    TBuf<40> traceFile = GenerateFileNameForTraceL();

    RFs fileserver;
    RFile file;
    User::LeaveIfError(fileserver.Connect());
    CleanupClosePushL(fileserver);
    User::LeaveIfError(file.Open(fileserver, traceFile, EFileWrite));
    CleanupClosePushL(file);
    _LIT(KClientStarted, "Client Started");
    TraceL(KClientStarted, file);

    const TInt32 KUidMultiPsy = 0x01010176;
    TUid uidMultiPsy;
    uidMultiPsy.iUid = KUidMultiPsy;
    SetupPsyL(uidMultiPsy);

    _LIT(KMultiPsySetup, "MultiPsy set up");
    TraceL(KMultiPsySetup, file);

    TInt numberOfRuns = 50;

    RPositionServer	posServer;
    CleanupClosePushL(posServer);
    RPositioner positioner;
    CleanupClosePushL(positioner);
    TPositionInfo positionInfo = TPositionInfo();

    _LIT(KConnectErr, "ERROR: Error when connecing to EPos server,  %d");
    TInt err = posServer.Connect();
    AssertTrueL(err == KErrNone, KConnectErr, err, file);

    _LIT(KOpenErr, "ERROR: Error when opening positioner,  %d");
    err = positioner.Open(posServer, uidMultiPsy);
    AssertTrueL(err == KErrNone, KOpenErr, err, file);

    _LIT(KService ,"Service");
    err = positioner.SetRequestor(CRequestor::ERequestorService,
                                  CRequestor::EFormatApplication, KService);
    _LIT(KRequestor, "ERROR: Not possible to set requestor");
    AssertTrueL(err == KErrNone, KRequestor, err, file);

    TTime now, startTime;
    TTimeIntervalMicroSeconds requestTime;
    TRequestStatus status;
    TInt64 reqTime;
    TCoordinate corr(0,0,0);
    TLocality loca(corr,0);
    TPosition pos(loca, TTime(0));
    TBool success = ETrue;
    _LIT(KStartingRequests, "Starting requests");
    TraceL(KStartingRequests, file);

    for (TInt i = 0; i < numberOfRuns; i++)
    {
        startTime.UniversalTime();
        positionInfo.SetPosition(pos);
        positioner.NotifyPositionUpdate(positionInfo, status);
        User::WaitForRequest(status);
        err = status.Int();
        if (err != KErrNone)
        {
            success=EFalse;
        }
        now.UniversalTime();
        requestTime = now.MicroSecondsFrom(startTime);
        _LIT(KError, "Request time, %d µs. Error code from Notify = %d");
        TBuf<100> buf;
        reqTime = requestTime.Int64();
        buf.Format(KError, reqTime, err);
        TraceL(buf, file);
        TPosition result;
        positionInfo.GetPosition(result);
        // Sanity check
        if (result.Latitude() == pos.Latitude() ||
                result.Longitude() == pos.Longitude() ||
                result.Altitude() == pos.Altitude())
        {
            success = EFalse;
            _LIT(KErrorPositon, "ERROR:: The postion was not updated");
            TraceL(KErrorPositon, file);
        }
    }

    CleanupStack::PopAndDestroy(&positioner);
    CleanupStack::PopAndDestroy(&posServer);

    if (success)
    {
        _LIT(KOk, "SUCCESS");
        TraceL(KOk, file);
    }
    else
    {
        _LIT(KErr, "FAILED");
        TraceL(KErr, file);
    }

    CleanupStack::PopAndDestroy(&file);
    CleanupStack::PopAndDestroy(&fileserver);

    return (success) ? 0 : 1;
}