Пример #1
0
void CHuiStatic::UpdateTime(TTlsData* aData)
    {
    ASSERT( aData );
    // Updates the toolkit's time counters. This includes the toolkit's
    // realtime clock, the internal absolute clock (which is affected by the
    // time factor), the amount of elapsed time since last UpdateTime()
    // invocation, and the amount of elapsed time since the first UpdateTime()
    // invocation (which was done in the beginning of the first refresh).

    if(aData->iIsFirstUpdateTime)
        {
        aData->iIsFirstUpdateTime = EFalse;
        aData->iFirstUpdateTime.UniversalTime();
        aData->iUniversalTime = aData->iFirstUpdateTime;
        aData->iRealUniversalTime = aData->iUniversalTime;
        return;
        }

    TTime now;
    now.UniversalTime();

    // Advance the toolkit's internal clock, applying the time factor.
    if(!aData->iTimePaused)
        {
        aData->iInternalElapsed = now.MicroSecondsFrom(aData->iRealUniversalTime).Int64();
        aData->iInternalElapsed = (TInt64)((TReal32)aData->iInternalElapsed * aData->iTimeFactor);
        aData->iUniversalTime += TTimeIntervalMicroSeconds(aData->iInternalElapsed);
        }
    else
        {
        aData->iInternalElapsed = aData->iInternalElapsedBeforePausing;
        aData->iInternalElapsedBeforePausing = 0;        
        }

    aData->iRealUniversalTime = now;      
    }
// -----------------------------------------------------------------------------
// CMPXAutoResumeHandler::DoHandleStateChangeL
// -----------------------------------------------------------------------------
//
void CMPXAutoResumeHandler::DoHandleStateChangeL()
    {
    MPX_FUNC("CMPXAutoResumeHandler::DoHandleStateChangeL()");
    MPX_DEBUG2("CMPXAutoResumeHandler::DoHandleStateChangeL(): iPausedForCall = %d", iPausedForCall);
    MPX_DEBUG2("CMPXAutoResumeHandler::DoHandleStateChangeL(): engineState = %d", iEngine.State());
    // if autoresume is disabled, do nothing
    if ( !iAutoResume )
        {
        return;
        }
    
    TBool shouldPause = ShouldPause();
    if (shouldPause &&
        !iPausedForCall &&
        iEngine.State() == EPbStatePlaying)
        {
        iEngine.HandleCommandL(EPbCmdPause);
        iPausedForCall = ETrue;
        }
    else if ( shouldPause &&
            !iPausedForCall &&
            ( iEngine.State() == EPbStateSeekingForward ||
            iEngine.State() == EPbStateSeekingBackward ) )
        {
        iEngine.HandleCommandL( EPbCmdStopSeeking );
        if ( iEngine.State() == EPbStatePlaying )
            {
            iEngine.HandleCommandL( EPbCmdPause );
            iPausedForCall = ETrue;
            }
        }
    else if(!shouldPause &&
            iPausedForCall &&
            iEngine.State() == EPbStatePaused)
        {
        MPX_DEBUG1("CMPXAutoResumeHandler::DoHandleStateChangeL(): starting resume timer");
        if ( iResumeTimer->IsActive() )
            iResumeTimer->Cancel();
        iResumeTimer->Start(
            KMPXResumeWaitTime,
            KMPXResumeWaitTime,
            TCallBack(ResumeTimerCallback, this) );
        iPausedForCall = EFalse;
        }
    else if ( shouldPause &&
             iEngine.State() == EPbStatePaused &&
             !iPausedForCall &&
             iKErrDiedTime.Int64())
        {
        // Check if we recently got a playcomplete with KErrDied,
        // it was most likely caused by an active call
        TTime now;
        now.HomeTime();
        TInt64 deltaTime = now.MicroSecondsFrom(iKErrDiedTime).Int64();
        if ( deltaTime > 0 &&
             deltaTime < KMPXErrDiedTimeout)
            {
            iResumeTimer->Cancel();
            iPausedForCall = ETrue;
            }
        }
    
    if ( shouldPause && iVoiceCmdResumeOngoing )
        {
        // Resume timer has been started after a voice command, cancel it now
        // so that playback is not resumed while calling
        if ( iResumeTimer->IsActive() )
            {
            iResumeTimer->Cancel();
            }
        iVoiceCmdResumeOngoing = EFalse;
        iPausedForCall = ETrue; // resume playback once call has been ended
        }
    
    MPX_DEBUG2("CMPXAutoResumeHandler::DoHandleStateChangeL(): iPausedForCall = %d", iPausedForCall);
    }
Пример #3
0
void CT_LbsNetProtocol::RunL()
	{
	TInt response(iStatus.Int());
	switch(iNetworkProtocolProxyStep)
		{
		case ENetworkProtocolProxyStepInitial:
			{
			switch(response)
				{
				case ENetMsgCancelSelfLocation:
					{
					// >> CancelSelfLocation()
					iStep.INFO_PRINTF1(_L("NetworkProtocolProxy >> CancelSelfLocation() for an older session"));
					iProxy->WaitForResponseL(KTimeOut, iStatus);
					SetActive();
					break;
					}
				case ENetMsgGetCurrentCapabilitiesResponse:
					{
					// >> AdviceSystemStatus()
					CLbsNetworkProtocolBase::TLbsSystemStatus status;
					TInt cleanupCnt = iProxy->GetArgsLC(ENetMsgGetCurrentCapabilitiesResponse, &status);
					iStep.TESTL(status == CLbsNetworkProtocolBase::ESystemStatusNone || status == CLbsNetworkProtocolBase::ESystemStatusClientTracking);
					if(status == CLbsNetworkProtocolBase::ESystemStatusClientTracking)
						{
						iStep.INFO_PRINTF1(_L("NetworkProtocolProxy >> AdviceSystemStatus(ESystemStatusClientTracking)"));
						}
					else if(status == CLbsNetworkProtocolBase::ESystemStatusNone)
						{
						iStep.INFO_PRINTF1(_L("NetworkProtocolProxy >> AdviceSystemStatus(ESystemStatusNone)"));
						}
					CleanupStack::PopAndDestroy(cleanupCnt);
					
					iNetworkProtocolProxyStep = ENetworkProtocolProxyStepNoSessionRunning;
					iProxy->WaitForResponseL(KTimeOut, iStatus);
					SetActive();
					break;
					}
				case ENetMsgRequestAssistanceData:
					{
					// >> RequestAssistanceData(0)
					iStep.INFO_PRINTF1(_L("NetworkProtocolProxy >> RequestAssistanceData(0)"));
					TLbsAsistanceDataGroup dataMask;
					TInt cleanupCnt = iProxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataMask);
					iStep.TESTL(dataMask == EAssistanceDataNone);
					CleanupStack::PopAndDestroy(cleanupCnt);
					
					iNetworkProtocolProxyStep = ENetworkProtocolProxyStepNoSessionRunning;
					iProxy->WaitForResponseL(KTimeOut, iStatus);
					SetActive();
					break;
					}
				case ENetMsgTimeoutExpired:
					{ // can happen that no request has been sent through, so start waiting again
					if(iClientsFinished)
						{
						iObserver.StopTest();						
						}
					else
						{
						iProxy->WaitForResponseL(KTimeOut, iStatus);
						SetActive();
						}
					break;
					}
				case ENetMsgRequestSelfLocation:
					{
					Process_RequestSelfLocationL();
					iProxy->WaitForResponseL(KTimeOut, iStatus);
					SetActive();
					break;
					}
				default:
					{
					iStep.INFO_PRINTF2(_L("Network in state ENetworkProtocolProxyStepInitial received unexpected response: %d"), response);
					User::Leave(KErrNotSupported);
					}
				}
			break;
			}

		case ENetworkProtocolProxyStepSessionNrhRequestSent:
			{
			switch(response)
				{
				case ENetMsgRequestAssistanceData:
					{
					// >> RequestAssistanceData(0)
					iStep.INFO_PRINTF1(_L("NetworkProtocolProxy >> RequestAssistanceData(0)"));
					TLbsAsistanceDataGroup dataMask;
					TInt cleanupCnt = iProxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataMask);
					iStep.TESTL(dataMask == EAssistanceDataNone);
					CleanupStack::PopAndDestroy(cleanupCnt);

					DecideWhatNetworkDoesntReceive();
					
					if(iNetworkExpectsMeasurments)
						{ // measurements should be sent to the network
						// Determine the value to take off the alpha2 value. This is required because we had to wait for the assistance data response.
						TTimeIntervalMicroSeconds microseconds;
						TTime stopTime;
						stopTime.HomeTime();
						microseconds = stopTime.MicroSecondsFrom(iAlpha2StartTime); 
						TInt64 timeElapsed = microseconds.Int64();

						// Test that we do not get response before alpha2 has expired:
						TInt timeOut = KAlphaTimer - timeElapsed - KDelta > 0 ? KAlphaTimer - timeElapsed - KDelta : 0;
						iNetworkProtocolProxyStep = ENetworkProtocolProxyStepSessionWaitingForFirstMeasurmentsTimeOut;
						iProxy->WaitForResponseL(timeOut, iStatus);
						SetActive();
						}
					else
						{
						iNetworkProtocolProxyStep = ENetworkProtocolProxyStepSessionMeasurmentsReceived;
						iProxy->WaitForResponseL(KTimeOut, iStatus);
						SetActive();
						}

					break;
					}
				case ENetMsgCancelSelfLocation:
					{
					// >> CancelSelfLocation()
					TLbsNetSessionId* sessionId = NULL;
					TInt cancelReason = KErrNone;
					TInt cleanupCnt;
					
					cleanupCnt = iProxy->GetArgsLC(ENetMsgCancelSelfLocation, &sessionId, &cancelReason);
					if(sessionId->SessionNum() == iSessionId.SessionNum())
						{ // should complete the session
						iStep.INFO_PRINTF1(_L("NetworkProtocolProxy >> CancelSelfLocation()"));
						CleanupStack::PopAndDestroy(cleanupCnt);
						
						// << ProcessSessionComplete()
						TInt reason = KErrNone;
						iStep.INFO_PRINTF1(_L("NetworkProtocolProxy << ProcessSessionComplete()"));			
						iProxy->CallL(ENetMsgProcessSessionComplete, &iSessionId, &reason);

						// << ProcessStatusUpdate()
						MLbsNetworkProtocolObserver::TLbsNetProtocolServiceMask activeServiceMask2 = MLbsNetworkProtocolObserver::EServiceNone;	
						iStep.INFO_PRINTF1(_L("NetworkProtocolProxy << ProcessStatusUpdate(EServiceNone)"));			
						iProxy->CallL(ENetMsgProcessStatusUpdate, &activeServiceMask2);

						iNetworkProtocolProxyStep = ENetworkProtocolProxyStepNoSessionRunning;
						iProxy->WaitForResponseL(KTimeOut, iStatus);
						SetActive();						
						}
					else
						{
						iStep.INFO_PRINTF1(_L("NetworkProtocolProxy >> CancelSelfLocation() for an older session"));
						iStep.TESTL(sessionId->SessionNum() < iSessionId.SessionNum());
						CleanupStack::PopAndDestroy(cleanupCnt);
						sessionId = NULL;
		
						iNetworkProtocolProxyStep = ENetworkProtocolProxyStepSessionWaitingForFirstMeasurments;
						iProxy->WaitForResponseL(KTimeOut, iStatus);
						SetActive();
						}
					break;
					}
				case ENetMsgGetCurrentCapabilitiesResponse:
					{
					// >> AdviceSystemStatus()
					CLbsNetworkProtocolBase::TLbsSystemStatus status;
					TInt cleanupCnt = iProxy->GetArgsLC(ENetMsgGetCurrentCapabilitiesResponse, &status);
					if(status == CLbsNetworkProtocolBase::ESystemStatusClientTracking)
						{
						iStep.INFO_PRINTF1(_L("NetworkProtocolProxy >> AdviceSystemStatus(ESystemStatusClientTracking)"));
						}
					else if(status == CLbsNetworkProtocolBase::ESystemStatusNone)
						{
						iStep.INFO_PRINTF1(_L("NetworkProtocolProxy >> AdviceSystemStatus(ESystemStatusNone)"));
						}
					else
						{
						iStep.INFO_PRINTF1(_L("NetworkProtocolProxy >> AdviceSystemStatus() with wrong status"));
						User::Leave(KErrNotSupported);
						}
					CleanupStack::PopAndDestroy(cleanupCnt);
					
					iProxy->WaitForResponseL(KSmallTimeOut, iStatus);
					SetActive();
					break;
					}					
				case ENetMsgRequestSelfLocation:
					{
					Process_RequestSelfLocationL();
					iProxy->WaitForResponseL(KTimeOut, iStatus);
					SetActive();
					break;
					}
				default:
					{
					iStep.INFO_PRINTF2(_L("Network in state ENetworkProtocolProxyStepSessionNrhRequestSent received unexpected response: %d"), response);
					User::Leave(KErrNotSupported);
					}
				}
			break;
			}
		case ENetworkProtocolProxyStepSessionWaitingForFirstMeasurmentsTimeOut:
			{
			switch(response)
				{
				case ENetMsgRequestAssistanceData:
					{
					// >> RequestAssistanceData(0)
					iStep.INFO_PRINTF1(_L("NetworkProtocolProxy >> RequestAssistanceData(0)"));
					TLbsAsistanceDataGroup dataMask;
					TInt cleanupCnt = iProxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataMask);
					iStep.TESTL(dataMask == EAssistanceDataNone);
					CleanupStack::PopAndDestroy(cleanupCnt);
					
					TTimeIntervalMicroSeconds microseconds;
					TTime stopTime;
					stopTime.HomeTime();
					microseconds = stopTime.MicroSecondsFrom(iAlpha2StartTime); 
					TInt64 timeElapsed = microseconds.Int64();

					// Test that we do not get response before alpha2 has expired:
					TInt timeOut = KAlphaTimer - timeElapsed - KDelta > 0 ? KAlphaTimer - timeElapsed - KDelta : 0;
					iProxy->WaitForResponseL(timeOut, iStatus);
					SetActive();
					break;
					}
				case ENetMsgGetCurrentCapabilitiesResponse:
					{
					// >> AdviceSystemStatus()
					CLbsNetworkProtocolBase::TLbsSystemStatus status;
					TInt cleanupCnt = iProxy->GetArgsLC(ENetMsgGetCurrentCapabilitiesResponse, &status);
					if(status == CLbsNetworkProtocolBase::ESystemStatusClientTracking)
						{
						iStep.INFO_PRINTF1(_L("NetworkProtocolProxy >> AdviceSystemStatus(ESystemStatusClientTracking)"));
						}
					else if(status == CLbsNetworkProtocolBase::ESystemStatusNone)
						{
						iStep.INFO_PRINTF1(_L("NetworkProtocolProxy >> AdviceSystemStatus(ESystemStatusNone)"));
						}
					else
						{
						iStep.INFO_PRINTF1(_L("NetworkProtocolProxy >> AdviceSystemStatus() with wrong status"));
						User::Leave(KErrNotSupported);
						}
					CleanupStack::PopAndDestroy(cleanupCnt);
					
					TTimeIntervalMicroSeconds microseconds;
					TTime stopTime;
					stopTime.HomeTime();
					microseconds = stopTime.MicroSecondsFrom(iAlpha2StartTime); 
					TInt64 timeElapsed = microseconds.Int64();

					// Test that we do not get response before alpha2 has expired:
					TInt timeOut = KAlphaTimer - timeElapsed - KDelta > 0 ? KAlphaTimer - timeElapsed - KDelta : 0;
					iProxy->WaitForResponseL(timeOut, iStatus);
					SetActive();
					break;
					}
				case ENetMsgCancelSelfLocation:
					{
					// >> CancelSelfLocation()
					TLbsNetSessionId* sessionId = NULL;
					TInt cancelReason = KErrNone;
					TInt cleanupCnt;
					
					cleanupCnt = iProxy->GetArgsLC(ENetMsgCancelSelfLocation, &sessionId, &cancelReason);
					if(sessionId->SessionNum() == iSessionId.SessionNum())
						{ // should complete the session
						iStep.INFO_PRINTF1(_L("NetworkProtocolProxy >> CancelSelfLocation()"));
						CleanupStack::PopAndDestroy(cleanupCnt);
						
						// << ProcessSessionComplete()
						TInt reason = KErrNone;
						iStep.INFO_PRINTF1(_L("NetworkProtocolProxy << ProcessSessionComplete()"));			
						iProxy->CallL(ENetMsgProcessSessionComplete, &iSessionId, &reason);

						// << ProcessStatusUpdate()
						MLbsNetworkProtocolObserver::TLbsNetProtocolServiceMask activeServiceMask2 = MLbsNetworkProtocolObserver::EServiceNone;	
						iStep.INFO_PRINTF1(_L("NetworkProtocolProxy << ProcessStatusUpdate(EServiceNone)"));			
						iProxy->CallL(ENetMsgProcessStatusUpdate, &activeServiceMask2);

						iNetworkProtocolProxyStep = ENetworkProtocolProxyStepNoSessionRunning;
						iProxy->WaitForResponseL(KTimeOut, iStatus);
						SetActive();						
						}
					else
						{
						iStep.INFO_PRINTF1(_L("NetworkProtocolProxy >> CancelSelfLocation() for an older session"));
						iStep.TESTL(sessionId->SessionNum() < iSessionId.SessionNum());
						CleanupStack::PopAndDestroy(cleanupCnt);
						sessionId = NULL;
		
						TTimeIntervalMicroSeconds microseconds;
						TTime stopTime;
						stopTime.HomeTime();
						microseconds = stopTime.MicroSecondsFrom(iAlpha2StartTime); 
						TInt64 timeElapsed = microseconds.Int64();
	
						// Test that we do not get response before alpha2 has expired:
						TInt timeOut = KAlphaTimer - timeElapsed - KDelta > 0 ? KAlphaTimer - timeElapsed - KDelta : 0;
						iProxy->WaitForResponseL(timeOut, iStatus);
						SetActive();
						}
					break;
					}
				case ENetMsgTimeoutExpired:
					{
					// >> Alpha2 timeout
					iStep.INFO_PRINTF1(_L("NetworkProtocolProxy - Network expecting measurements after timeout"));
					
					iNetworkProtocolProxyStep = ENetworkProtocolProxyStepSessionWaitingForFirstMeasurments;
					iProxy->WaitForResponseL(2 * 1000* KDelta, iStatus);
					SetActive();
					break;
					}
				case ENetMsgRespondLocationRequest:
					{ // If the module sends an accurate enough position then the Alpha2 timer might not time-out so check we received positions
					// >> RespondLocationRequest(gpspos)
					iStep.INFO_PRINTF1(_L("NetworkProtocolProxy >> RespondLocationRequest(gpspos)"));
					RequestNetworkMethod();
					DecideWhatNetworkDoesntReceive();
					iStep.TESTL(iNetworkExpectsPositions);
					TLbsNetSessionId* sessionId = NULL;
					TPositionInfo* positionInfo = NULL;
					TInt reason;
					TInt cleanupCnt = iProxy->GetArgsLC(ENetMsgRespondLocationRequest, &sessionId, &reason, &positionInfo);
					
					// check it is a position
					iStep.TESTL(positionInfo->PositionClassType() == (EPositionInfoClass|EPositionCourseInfoClass|EPositionSatelliteInfoClass|EPositionExtendedSatelliteInfoClass));
					iStep.TESTL(sessionId->SessionNum() == iSessionId.SessionNum());
					iStep.TESTL(reason == KErrNone);
					
					// << ProcessLocationUpdate(FNP)
					iStep.INFO_PRINTF1(_L("NetworkProtocolProxy << ProcessLocationUpdate(SessionId, FinalNetworkPosition)"));
					iProxy->CallL(ENetMsgProcessLocationUpdate, &iSessionId, positionInfo);
					CleanupStack::PopAndDestroy(cleanupCnt);

					iNetworkProtocolProxyStep = ENetworkProtocolProxyStepSessionPositionSent;
					iProxy->WaitForResponseL(KSmallTimeOut, iStatus);
					SetActive();
					break;
					}
				default:
					{
					iStep.INFO_PRINTF2(_L("Network in state ENetworkProtocolProxyStepSessionWaitingForFirstMeasurmentsTimeOut received unexpected response: %d"), response);
					User::Leave(KErrNotSupported);
					}
				}
			break;
			}
		case ENetworkProtocolProxyStepSessionWaitingForFirstMeasurments:
			{
			switch(response)
				{
				case ENetMsgRequestAssistanceData:
					{
					// >> RequestAssistanceData(0)
					iStep.INFO_PRINTF1(_L("NetworkProtocolProxy >> RequestAssistanceData(0)"));
					TLbsAsistanceDataGroup dataMask;
					TInt cleanupCnt = iProxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataMask);
					iStep.TESTL(dataMask == EAssistanceDataNone);
					CleanupStack::PopAndDestroy(cleanupCnt);
					
					iProxy->WaitForResponseL(KTimeOut, iStatus);
					SetActive();
					break;
					}
				case ENetMsgCancelSelfLocation:
					{
					// >> CancelSelfLocation()
					TLbsNetSessionId* sessionId = NULL;
					TInt cancelReason = KErrNone;
					TInt cleanupCnt;
					
					cleanupCnt = iProxy->GetArgsLC(ENetMsgCancelSelfLocation, &sessionId, &cancelReason);
					if(sessionId->SessionNum() == iSessionId.SessionNum())
						{ // should complete the session
						iStep.INFO_PRINTF1(_L("NetworkProtocolProxy >> CancelSelfLocation()"));
						CleanupStack::PopAndDestroy(cleanupCnt);
						
						// << ProcessSessionComplete()
						TInt reason = KErrNone;
						iStep.INFO_PRINTF1(_L("NetworkProtocolProxy << ProcessSessionComplete()"));			
						iProxy->CallL(ENetMsgProcessSessionComplete, &iSessionId, &reason);

						// << ProcessStatusUpdate()
						MLbsNetworkProtocolObserver::TLbsNetProtocolServiceMask activeServiceMask2 = MLbsNetworkProtocolObserver::EServiceNone;	
						iStep.INFO_PRINTF1(_L("NetworkProtocolProxy << ProcessStatusUpdate(EServiceNone)"));			
						iProxy->CallL(ENetMsgProcessStatusUpdate, &activeServiceMask2);

						iNetworkProtocolProxyStep = ENetworkProtocolProxyStepNoSessionRunning;
						iProxy->WaitForResponseL(KTimeOut, iStatus);
						SetActive();						
						}
					else
						{
						iStep.INFO_PRINTF1(_L("NetworkProtocolProxy >> CancelSelfLocation() for an older session"));
						iStep.TESTL(sessionId->SessionNum() < iSessionId.SessionNum());
						CleanupStack::PopAndDestroy(cleanupCnt);
						sessionId = NULL;
		
						iProxy->WaitForResponseL(KTimeOut, iStatus);
						SetActive();
						}
					break;
					}
				case ENetMsgRespondLocationRequest:
					{
					// >> RespondLocationRequest(meas)
					TLbsNetSessionId* sessionId = NULL;
					TPositionInfo* positionInfo = NULL;
					TInt reason;
					TInt cleanupCnt = iProxy->GetArgsLC(ENetMsgRespondLocationRequest, &sessionId, &reason, &positionInfo);
					RequestNetworkMethod();
					DecideWhatNetworkDoesntReceive();

					// check it is a position
					if(positionInfo->PositionClassType() == EPositionGpsMeasurementInfoClass)
						{
						iStep.INFO_PRINTF1(_L("NetworkProtocolProxy >> RespondLocationRequest(meas)"));
						iStep.TESTL(iNetworkExpectsMeasurments);
						iStep.TESTL(sessionId->SessionNum() == iSessionId.SessionNum());	// module sends NAN measurement first
						if(reason != KErrNone)
							{
							iStep.INFO_PRINTF2(_L("NetworkProtocolProxy reason = 0x%x"), reason);
							}
						iStep.TESTL(reason == KErrNone);
						CleanupStack::PopAndDestroy(cleanupCnt);
						if(iPlannedPositionOriginator == EPositionOriginatorModule)
							{
							if(iNetworkExpectsPositions)
								{
								// << ProcessLocationRequest(SessionId, HybridMode, t)
								iStep.INFO_PRINTF1(_L("NetworkProtocolProxy << ProcessLocationRequest(SessionId, HybridMode, t)"));
								TBool emergency = EFalse;
								MLbsNetworkProtocolObserver::TLbsNetProtocolService	service = MLbsNetworkProtocolObserver::EServiceSelfLocation;
								TLbsNetPosRequestQuality quality = ArgUtils::Quality();
								quality.SetMaxFixTime(KT);
								TLbsNetPosRequestMethod method  = RequestNetworkMethod();
								iProxy->CallL(ENetMsgProcessLocationRequest, &iSessionId, &emergency, &service, &quality, &method);
			
								iNetworkProtocolProxyStep = ENetworkProtocolProxyStepSessionMeasurmentsReceived;
								iProxy->WaitForResponseL(KTimeOut, iStatus);
								SetActive();
								}
							else
								{
								iNetworkProtocolProxyStep = ENetworkProtocolProxyStepSessionPositionSent;
								iProxy->WaitForResponseL(KSmallTimeOut, iStatus);
								SetActive();
								}
							}
						else if(iPlannedPositionOriginator == EPositionOriginatorNetwork)
							{
							TPositionInfo positionInfo = ArgUtils::AccurateNetworkPositionInfo();
							// << ProcessLocationUpdate(SessionId, FinalNetworkPosition)
							// Return FinalNetworkPosition
							iStep.INFO_PRINTF1(_L("NetworkProtocolProxy << ProcessLocationUpdate(SessionId, FNP)"));
							iProxy->CallL(ENetMsgProcessLocationUpdate, &iSessionId, &positionInfo);
							
							iNetworkProtocolProxyStep = ENetworkProtocolProxyStepSessionPositionSent;
							iProxy->WaitForResponseL(KSmallTimeOut, iStatus);
							SetActive();
							}
						}
					else
						{
						// >> RespondLocationRequest(gpspos)
						iStep.INFO_PRINTF1(_L("NetworkProtocolProxy >> RespondLocationRequest(gpspos)"));
						// check it is a position
						iStep.TESTL(positionInfo->PositionClassType() == (EPositionInfoClass|EPositionCourseInfoClass|EPositionSatelliteInfoClass|EPositionExtendedSatelliteInfoClass));
						iStep.TESTL(sessionId->SessionNum() == iSessionId.SessionNum());
						iStep.INFO_PRINTF3(_L("NetworkProtocolProxy reason = %d(0x%x)"), reason,reason);
						if(reason != KErrPositionNoGpsUpdate)
							{
							iStep.TESTL(reason == KErrNone);
							}
						iStep.TESTL(iNetworkExpectsPositions);
						
						// << ProcessLocationUpdate(FNP)
						iStep.INFO_PRINTF1(_L("NetworkProtocolProxy << ProcessLocationUpdate(SessionId, FinalNetworkPosition)"));
						iProxy->CallL(ENetMsgProcessLocationUpdate, &iSessionId, positionInfo);
						CleanupStack::PopAndDestroy(cleanupCnt);

						iNetworkProtocolProxyStep = ENetworkProtocolProxyStepSessionPositionSent;
						iProxy->WaitForResponseL(KSmallTimeOut, iStatus);
						SetActive();
						}
					break;
					}
				default:
					{
					iStep.INFO_PRINTF2(_L("Network in state ENetworkProtocolProxyStepSessionWaitingForFirstMeasurments received unexpected response: %d"), response);
					User::Leave(KErrNotSupported);
					}
				}
			break;
			}
		case ENetworkProtocolProxyStepSessionMeasurmentsReceived:
			{
			switch(response)
				{
				case ENetMsgRequestAssistanceData:
					{
					// >> RequestAssistanceData(0)
					iStep.INFO_PRINTF1(_L("NetworkProtocolProxy >> RequestAssistanceData(0)"));
					TLbsAsistanceDataGroup dataMask;
					TInt cleanupCnt = iProxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataMask);
					iStep.TESTL(dataMask == EAssistanceDataNone);
					CleanupStack::PopAndDestroy(cleanupCnt);
					
					iProxy->WaitForResponseL(KTimeOut, iStatus);
					SetActive();
					break;
					}
				case ENetMsgRespondLocationRequest:
					{ // If the module sends an accurate enough position then the Alpha2 timer might not time-out so check we received positions
					// >> RespondLocationRequest(gpspos/meas)
					TLbsNetSessionId* sessionId = NULL;
					TPositionInfo* positionInfo = NULL;
					TInt reason;
					TInt cleanupCnt = iProxy->GetArgsLC(ENetMsgRespondLocationRequest, &sessionId, &reason, &positionInfo);
					RequestNetworkMethod();
					DecideWhatNetworkDoesntReceive();
					
					// check it is a position
					if(positionInfo->PositionClassType() == EPositionGpsMeasurementInfoClass)
						{ // received more measurments
						// >> RespondLocationRequest(meas)
						iStep.TESTL(iNetworkExpectsMeasurments);
						iStep.INFO_PRINTF1(_L("NetworkProtocolProxy >> RespondLocationRequest(meas)"));
						iStep.TESTL(iNetworkExpectsMeasurments);
						iStep.TESTL(sessionId->SessionNum() == iSessionId.SessionNum());	// module sends NAN measurement first
						if(reason != KErrNone)
							{
							iStep.INFO_PRINTF2(_L("NetworkProtocolProxy reason = 0x%x"), reason);
							}
						iStep.TESTL(reason == KErrNone);
						iStep.TESTL(iPlannedPositionOriginator == EPositionOriginatorModule);
						iStep.TESTL(iNetworkExpectsPositions);
						// << ProcessLocationRequest(SessionId, HybridMode, t)
						iStep.INFO_PRINTF1(_L("NetworkProtocolProxy << ProcessLocationRequest(SessionId, HybridMode, t)"));
						TBool emergency = EFalse;
						MLbsNetworkProtocolObserver::TLbsNetProtocolService	service = MLbsNetworkProtocolObserver::EServiceSelfLocation;
						TLbsNetPosRequestQuality quality = ArgUtils::Quality();
						quality.SetMaxFixTime(KT);
						TLbsNetPosRequestMethod method  = RequestNetworkMethod();
						iProxy->CallL(ENetMsgProcessLocationRequest, &iSessionId, &emergency, &service, &quality, &method);
	
						iProxy->WaitForResponseL(KTimeOut, iStatus);
						SetActive();
						}
					else
						{ // received a position
						iStep.TESTL(iNetworkExpectsPositions);
						iStep.TESTL(positionInfo->PositionClassType() == (EPositionInfoClass|EPositionCourseInfoClass|EPositionSatelliteInfoClass|EPositionExtendedSatelliteInfoClass));
						iStep.TESTL(sessionId->SessionNum() == iSessionId.SessionNum());
						iStep.TESTL(reason == KErrNone);
						
						// << ProcessLocationUpdate(FNP)
						iStep.INFO_PRINTF1(_L("NetworkProtocolProxy << ProcessLocationUpdate(SessionId, FinalNetworkPosition)"));
						iProxy->CallL(ENetMsgProcessLocationUpdate, &iSessionId, positionInfo);

						iNetworkProtocolProxyStep = ENetworkProtocolProxyStepSessionPositionSent;
						iProxy->WaitForResponseL(KSmallTimeOut, iStatus);
						SetActive();
						}
					CleanupStack::PopAndDestroy(cleanupCnt);
					break;
					}
				default:
					{
					iStep.INFO_PRINTF2(_L("Network in state ENetworkProtocolProxyStepSessionMeasurmentsReceived received unexpected response: %d"), response);
					User::Leave(KErrNotSupported);
					}
				}
			break;
			}

		case ENetworkProtocolProxyStepSessionPositionSent:
			{
			switch(response)
				{
				case ENetMsgRequestAssistanceData:
					{
					// >> RequestAssistanceData(0)
					iStep.INFO_PRINTF1(_L("NetworkProtocolProxy >> RequestAssistanceData(0)"));
					TLbsAsistanceDataGroup dataMask;
					TInt cleanupCnt = iProxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataMask);
					iStep.TESTL(dataMask == EAssistanceDataNone);
					CleanupStack::PopAndDestroy(cleanupCnt);
					
					iProxy->WaitForResponseL(KSmallTimeOut, iStatus);
					SetActive();
					break;
					}
				case ENetMsgGetCurrentCapabilitiesResponse:
					{
					// >> AdviceSystemStatus()
					CLbsNetworkProtocolBase::TLbsSystemStatus status;
					TInt cleanupCnt = iProxy->GetArgsLC(ENetMsgGetCurrentCapabilitiesResponse, &status);
					if(status == CLbsNetworkProtocolBase::ESystemStatusClientTracking)
						{
						iStep.INFO_PRINTF1(_L("NetworkProtocolProxy >> AdviceSystemStatus(ESystemStatusClientTracking)"));
						}
					else if(status == CLbsNetworkProtocolBase::ESystemStatusNone)
						{
						iStep.INFO_PRINTF1(_L("NetworkProtocolProxy >> AdviceSystemStatus(ESystemStatusNone)"));
						}
					else
						{
						iStep.INFO_PRINTF1(_L("NetworkProtocolProxy >> AdviceSystemStatus() with wrong status"));
						User::Leave(KErrNotSupported);
						}
					CleanupStack::PopAndDestroy(cleanupCnt);
					
					iProxy->WaitForResponseL(KSmallTimeOut, iStatus);
					SetActive();
					break;
					}
				case ENetMsgCancelSelfLocation:
					{
					// >> CancelSelfLocation()
					iStep.INFO_PRINTF1(_L("NetworkProtocolProxy >> CancelSelfLocation() - as result of FNP"));

					// << ProcessSessionComplete()
					TInt reason = KErrNone;
					iStep.INFO_PRINTF1(_L("NetworkProtocolProxy << ProcessSessionComplete()"));			
					iProxy->CallL(ENetMsgProcessSessionComplete, &iSessionId, &reason);

					// << ProcessStatusUpdate()
					MLbsNetworkProtocolObserver::TLbsNetProtocolServiceMask activeServiceMask2 = MLbsNetworkProtocolObserver::EServiceNone;	
					iStep.INFO_PRINTF1(_L("NetworkProtocolProxy << ProcessStatusUpdate(EServiceNone)"));			
					iProxy->CallL(ENetMsgProcessStatusUpdate, &activeServiceMask2);

					iNetworkProtocolProxyStep = ENetworkProtocolProxyStepNoSessionRunning;
					iProxy->WaitForResponseL(KTimeOut, iStatus);
					SetActive();
					break;
					}
				case ENetMsgTimeoutExpired:
					{
					// << ProcessSessionComplete()
					TInt reason = KErrNone;
					iStep.INFO_PRINTF1(_L("NetworkProtocolProxy << ProcessSessionComplete()"));			
					iProxy->CallL(ENetMsgProcessSessionComplete, &iSessionId, &reason);

					// << ProcessStatusUpdate()
					MLbsNetworkProtocolObserver::TLbsNetProtocolServiceMask activeServiceMask2 = MLbsNetworkProtocolObserver::EServiceNone;	
					iStep.INFO_PRINTF1(_L("NetworkProtocolProxy << ProcessStatusUpdate(EServiceNone)"));			
					iProxy->CallL(ENetMsgProcessStatusUpdate, &activeServiceMask2);

					iNetworkProtocolProxyStep = ENetworkProtocolProxyStepNoSessionRunning;
					iProxy->WaitForResponseL(KTimeOut, iStatus);
					SetActive();
					break;
					}
				case ENetMsgRequestSelfLocation:
					{
					Process_RequestSelfLocationL();
					iProxy->WaitForResponseL(KTimeOut, iStatus);
					SetActive();
					break;
					}
				default:
					{
					iStep.INFO_PRINTF2(_L("Network in state ENetworkProtocolProxyStepSessionPositionSent received unexpected response: %d"), response);
					User::Leave(KErrNotSupported);
					}
				}
			break;
			}

		case ENetworkProtocolProxyStepNoSessionRunning:
			{
			switch(response)
				{
				case ENetMsgCancelSelfLocation:
					{
					// >> CancelSelfLocation()
					iStep.INFO_PRINTF1(_L("NetworkProtocolProxy >> CancelSelfLocation() for an older session"));
					iProxy->WaitForResponseL(KTimeOut, iStatus);
					SetActive();
					break;
					}
				case ENetMsgTimeoutExpired:
					{ // can happen that no request has been sent through, so start waiting again
					if(iClientsFinished)
						{
						iObserver.StopTest();						
						}
					else
						{
						iProxy->WaitForResponseL(KTimeOut, iStatus);
						SetActive();
						}
					break;
					}
				case ENetMsgRequestAssistanceData:
					{
					// >> RequestAssistanceData(0)
					iStep.INFO_PRINTF1(_L("NetworkProtocolProxy >> RequestAssistanceData(0)"));
					TLbsAsistanceDataGroup dataMask;
					TInt cleanupCnt = iProxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataMask);
					iStep.TESTL(dataMask == EAssistanceDataNone);
					CleanupStack::PopAndDestroy(cleanupCnt);
					
					iProxy->WaitForResponseL(KTimeOut, iStatus);
					SetActive();
					break;
					}
				case ENetMsgGetCurrentCapabilitiesResponse:
					{
					// >> AdviceSystemStatus()
					CLbsNetworkProtocolBase::TLbsSystemStatus status;
					TInt cleanupCnt = iProxy->GetArgsLC(ENetMsgGetCurrentCapabilitiesResponse, &status);
					if(status == CLbsNetworkProtocolBase::ESystemStatusClientTracking)
						{
						iStep.INFO_PRINTF1(_L("NetworkProtocolProxy >> AdviceSystemStatus(ESystemStatusClientTracking)"));
						}
					else if(status == CLbsNetworkProtocolBase::ESystemStatusNone)
						{
						iStep.INFO_PRINTF1(_L("NetworkProtocolProxy >> AdviceSystemStatus(ESystemStatusNone)"));
						}
					else
						{
						iStep.INFO_PRINTF1(_L("NetworkProtocolProxy >> AdviceSystemStatus() with wrong status"));
						User::Leave(KErrNotSupported);
						}
					CleanupStack::PopAndDestroy(cleanupCnt);
					
					iProxy->WaitForResponseL(KTimeOut, iStatus);
					SetActive();
					break;
					}
				case ENetMsgRequestSelfLocation:
					{
					Process_RequestSelfLocationL();
					iProxy->WaitForResponseL(KTimeOut, iStatus);
					SetActive();
					break;
					}
				default:
					{
					iStep.INFO_PRINTF2(_L("Network in state ENetworkProtocolProxyStepNoSessionRunning received unexpected response: %d"), response);
					User::Leave(KErrNotSupported);
					}
				}
			break;
			}

		default:
			{
			iStep.INFO_PRINTF1(_L("Network in unexpected state"));
			User::Leave(KErrCorrupt);
			}
		}
	iObserver.OnSignalNetworkStep(iRelativeSessionId, iNetworkProtocolProxyStep);
	}
// -----------------------------------------------------------------------------
// CSensrvTest::OpenChannelL
// Parameters: Open-Close Count(TInt)
// 
// -----------------------------------------------------------------------------
//
TInt CSensrvTest::OpenClosePerformanceL( CStifItemParser& aItem )
    {
    RDebug::Print( _L("CSensrvTest::OpenClosePerformanceL") );
    
    // Get parameter
    TInt count;
    TInt err = aItem.GetNextInt( count );
    if( err )
        {
        RDebug::Print( _L("CSensrvTest::OpenClosePerformanceL: parameter error = %d"), err );
        return err;
        }
    
    TBufC8<1> nullBuf( KNullDesC8 );
    TSensrvChannelInfo channelInfo( 0, ESensrvContextNotdefined, ESensrvQuantityNotdefined, 0, nullBuf, nullBuf, 0 );
    iChannelInfoList.Reset();
    err = FindChannels( iChannelInfoList, channelInfo );
    if( err )
        {
        RDebug::Print( _L("CSensrvTest::OpenClosePerformanceL: FindChanels error: %d"), err );
        return err;
        }
    if( iChannelInfoList.Count == 0 )
        {
        RDebug::Print( _L("CSensrvTest::OpenClosePerformanceL: Channel not found" ) );
        return KErrNotFound;
        }
    if( !iSensorChannel )
        {
        RDebug::Print( _L("CSensrvTest::OpenClosePerformanceL - Create iSensorChannel...") );
        RDebug::Print( _L("CSensrvTest::OpenClosePerformanceL - ChannelId = %d "), iChannelInfoList[ 0 ].iChannelId );
        iSensorChannel = CSensrvSensorChannel::NewL( iChannelInfoList[ 0 ] );
        RDebug::Print( _L("CSensrvTest::OpenClosePerformanceL - iSensorChannel Created") );
        }
        
    TTime startTime;
    startTime.HomeTime();
    
    for( TInt i = 1; i <= count; ++i )
        {
        TRAP( err, iSensorChannel->OpenChannelL() );
        if( err )
            {
            //RDebug::Print( _L("CSensrvTest::OpenClosePerformanceL - Open channel error %d"), err );
            }
            
        TRAP( err, iSensorChannel->CloseChannelL() );
        if( err )
            {
            //RDebug::Print( _L("CSensrvTest::OpenClosePerformanceL - Close channel error %d"), err );
            }
        
        //RDebug::Print( _L("CSensrvTest::OpenClosePerformanceL - Open-Close [%d]"), i );
        
        }
        
    TTime endTime;
    endTime.HomeTime();  
    
    TTimeIntervalMicroSeconds overallTime =  endTime.MicroSecondsFrom( startTime );
    
    RDebug::Print( _L("CSensrvTest::OpenClosePerformanceL - Overall time %d micro seconds"), overallTime );
     
    
    return KErrNone;
    
    }
Пример #5
0
// ---------------------------------------------------------------------------
// TEST CASE: Timer window works correctly
// ---------------------------------------------------------------------------
//
TInt CTestRFlexTimer::TestAfterTicksWindowL(
    TTestResult& aResult, 
    CTestFlexTimer* /* aCallback */ )
    {

    // T1: expiration after 4-8 sec
    const TTimeIntervalMicroSeconds32 KTimerOneInterval( 8000000 );
    const TTimeIntervalMicroSeconds32 KTimerOneWindow( 4000000 );

    // T2: expiration after 9-10 sec
    // T2's interval must not overlap with T1's -- otherwise T1 will be 
    // delayed
    const TTimeIntervalMicroSeconds32 KTimerTwoInterval( 10000000 );
    const TTimeIntervalMicroSeconds32 KTimerTwoWindow( 1000000 );

    // T3: expiration after 5 secs
    const TTimeIntervalMicroSeconds KAfterTimerInterval( 5000000 );
    const TTimeIntervalMicroSeconds KAfterTimerWindow( 0 );

    // System tick: 1/64 sec
    const TTimeIntervalMicroSeconds32 KOneTick( 1000000 / 64 );
    const TTimeIntervalMicroSeconds KNoWindow( 0 );

    
    
    // Initialize case
    aResult.SetResult( KErrGeneral, _L("Test case leaved") );

    TTime startTime;
    startTime.UniversalTime();
    TRequestStatus oneStatus, twoStatus, afterStatus;
    
    // Do the actual test
    //-----------------------------------------------------

    RFlexTimer timerOne;
    User::LeaveIfError( timerOne.Connect() );
    timerOne.Configure( KTimerOneWindow );
    timerOne.AfterTicks( oneStatus, KTimerOneInterval.Int() / KOneTick.Int() );

    RFlexTimer timerTwo;
    User::LeaveIfError( timerTwo.Connect() );
    timerTwo.Configure( KTimerTwoWindow );
    timerTwo.AfterTicks( twoStatus, KTimerTwoInterval.Int() / KOneTick.Int() );
    
    RFlexTimer afterTimer;
    User::LeaveIfError( afterTimer.Connect() );
    afterTimer.Configure( KAfterTimerWindow );
    afterTimer.After( afterStatus, KAfterTimerInterval );
    
                                        //    //  ___     _____
    User::WaitForRequest( oneStatus ); // // // //_ // //  //
                                      //_//_// //  // //  //

    TTime oneEndTime;
    oneEndTime.UniversalTime();
                                        //    //  ___     _____
    User::WaitForRequest( twoStatus ); // // // //_ // //  //
                                      //_//_// //  // //  //

    TTime twoEndTime;
    twoEndTime.UniversalTime();
    
    timerOne.Close();
    timerTwo.Close();
    afterTimer.Close();

    //-----------------------------------------------------
    
    // Handle afterStatus too - to get rid of unhandled asynchronous message
    // error from STIF.
    User::WaitForRequest( afterStatus );
    
    aResult.SetResult( KErrNone, _L("Test case passed") );
    
    // T1 should be expired at the same time than T3 - check with T3's values
    if ( !IsDelayOk( oneEndTime.MicroSecondsFrom( startTime ), KAfterTimerInterval, KNoWindow ) )
        {
        aResult.SetResult( KErrGeneral, _L("Test case failed. Timer one wrong expiration.") );
        }
    // T2 should be expired at it's max window
    else if ( !IsDelayOk( twoEndTime.MicroSecondsFrom( startTime ), KTimerTwoInterval, KNoWindow ) )
        {
        aResult.SetResult( KErrGeneral, _L("Test case failed. Timer two wrong expiration.") );
        }
    
    __UHEAP_MARKEND;

    return KErrNone;
    }
TVerdict CT_LbsHybridUEAssistedMTLRTimeout::doTestStepL()
	{
	INFO_PRINTF1(_L("CT_LbsHybridUEAssistedMTLRTimeout::doTestStepL()"));	
	// Stop the test if the preable failed
	TESTL(TestStepResult() == EPass);

	const TInt KTimeOut = 60*1000*1000;
	const TInt KAdviceSystemStatusTimeout = 40*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 MTLR Start
	// << ProcessStatusUpdate()
	MLbsNetworkProtocolObserver::TLbsNetProtocolServiceMask activeServiceMask = MLbsNetworkProtocolObserver::EServiceMobileTerminated;
	iProxy->CallL(ENetMsgProcessStatusUpdate, &activeServiceMask);

	// << ProcessPrivacyRequest()
	TBool emergency = ETrue;
	TLbsNetPosRequestPrivacy privacy    = ArgUtils::Privacy();
	TLbsExternalRequestInfo requestInfo = ArgUtils::RequestInfo();
	iProxy->CallL(ENetMsgProcessPrivacyRequest, &iSessionId, &emergency, &privacy, &requestInfo);

	// >> Callback from RespondNetworkLocationRequest(ERequestAccepted)
	CheckForObserverEventTestsL(KTimeOut, *this);
	
	// >> Respond Privacy Request
	TESTL(iProxy->WaitForResponse(KTimeOut) == ENetMsgRespondPrivacyRequest);
	TLbsNetSessionId* getSessionId = NULL;
	CLbsNetworkProtocolBase::TLbsPrivacyResponse getPrivacy;
	cleanupCnt = iProxy->GetArgsLC(ENetMsgRespondPrivacyRequest, &getSessionId, &getPrivacy);
	TESTL(getSessionId->SessionNum()==iSessionId.SessionNum());
	TESTL(getPrivacy==CLbsNetworkProtocolBase::EPrivacyResponseAccepted);
	CleanupStack::PopAndDestroy(cleanupCnt);
// Initiate MTLR End

// MTLR Reference Position Notification Start
	// << ProcessLocationUpdate()
	TPositionInfo positionInfo = ArgUtils::ReferencePositionInfo();
	iProxy->CallL(ENetMsgProcessLocationUpdate, &iSessionId, &positionInfo);
// MTLR Reference Position Notification Stop

// MTLR Assistance Data Notification Start
	// << ProcessAssistanceData()
	TLbsAsistanceDataGroup dataRequestMask = EAssistanceDataReferenceTime;
	RLbsAssistanceDataBuilderSet assistanceData;
	ArgUtils::PopulateLC(assistanceData);
	TInt reason = KErrNone;
	iProxy->CallL(ENetMsgProcessAssistanceData, &dataRequestMask, &assistanceData, &reason);
	CleanupStack::PopAndDestroy(); //assistanceData
// MTLR Assistance Data Notification Stop

// MTLR Network Location Request Start
	// << ProcessLocationRequest()
	MLbsNetworkProtocolObserver::TLbsNetProtocolService service = MLbsNetworkProtocolObserver::EServiceMobileTerminated;
	TLbsNetPosRequestQuality quality = ArgUtils::QualityAlpha2(); 
	TLbsNetPosRequestMethod method   = ArgUtils::RequestHybridMethod();
	iProxy->CallL(ENetMsgProcessLocationRequest, &iSessionId, &emergency, &service, &quality, &method);
// MTLR Network Location Request Stop

	//Start the timer
	TTime timerStart;
	timerStart.HomeTime();
	
	// >> Callback from ProcessNetworkPostionUpdate(refPosition)
	CheckForObserverEventTestsL(KTimeOut, *this);
	
// >> RequestAssistanceData(0)
	TESTL(iProxy->WaitForResponse(KTimeOut) == ENetMsgRequestAssistanceData); 
	TLbsAsistanceDataGroup dataGroup;
	cleanupCnt = iProxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataGroup);
	TESTL(dataGroup == EAssistanceDataNone);
	CleanupStack::PopAndDestroy(cleanupCnt);

	//Find the time elapsed from timer
	TTimeIntervalMicroSeconds microseconds;
 	TTime timerStop;
 	timerStop.HomeTime();
 	microseconds = timerStop.MicroSecondsFrom(timerStart); 
	TInt64 timeElapsed = microseconds.Int64();
		
	// >> RespondLocationRequest()
	//Test that we do not get response before alpha2 has expired
	//At the moment, the test below fails and leaves since respond reaches us before alpha2 times out. We are not in hybrid mode.
	TESTL(iProxy->WaitForResponse(ArgUtils::Alpha2()-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);

//NHR's timer alpha2 times out -> Hybrid Positioning Start	
	//<< ProcessLocationRequest() 
	quality = ArgUtils::Quality(); //Set timeout to t 
	iProxy->CallL(ENetMsgProcessLocationRequest, &iSessionId, &emergency, &service, &quality, &method);
	
	// >> RequestAssistanceData(0)
	TESTL(iProxy->WaitForResponse(KTimeOut) == ENetMsgRequestAssistanceData); 
	cleanupCnt = iProxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataGroup);
	TESTL(dataGroup == EAssistanceDataNone);
	CleanupStack::PopAndDestroy(cleanupCnt);

	// >> RespondLocationRequest()
	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);
	CleanupStack::PopAndDestroy(cleanupCnt);
		
	//<< ProcessNetworkPositionUpdate() | GPS Pos[Accurate Fix]
	CheckForObserverEventTestsL(KTimeOut, *this);
//Hybrid Positioning Stop

	/***Add extra delay to simulate the MC Release timing out ***/	
	User::After(2*KTimeOut);
	// Test that LBS is not sending any response to the Protocol Module
	TESTL(iProxy->WaitForResponse(KTimeOut) == ENetMsgTimeoutExpired); 
	
// MTLR Session Completion Start
	// << ProcessSessionComplete()
	iProxy->CallL(ENetMsgProcessSessionComplete, &iSessionId, &reason);

	// << ProcessStatusUpdate()
	MLbsNetworkProtocolObserver::TLbsNetProtocolServiceMask activeServiceMask2 = MLbsNetworkProtocolObserver::EServiceNone;	
	iProxy->CallL(ENetMsgProcessStatusUpdate, &activeServiceMask2);

	// >> Callback from ProcessRequestComplete()
	CheckForObserverEventTestsL(KTimeOut, *this);

	// Verify that the last callback was to ProcessSessionComplete()
	TESTL(iState==ERequestComplete);
// MTLR Session Completion Stop

	return TestStepResult();
	}
TVerdict CT_LbsX3PIntByMoLr::doTestStepL()
	{
	INFO_PRINTF1(_L("CT_LbsX3PIntByMoLr::doTestStepL()"));	
	// Stop the test if the preable failed
	TESTL(TestStepResult() == EPass);

	const TInt KTimeOut = 60*1000*1000;

	// Create Network Protocol Proxy
	CNetProtocolProxy* proxy = CNetProtocolProxy::NewL();
	CleanupStack::PushL(proxy);

	// >> AdviceSystemStatus(0) - GetCurrentCapabilitiesResponse
	TESTL(proxy->WaitForResponse(KTimeOut) == ENetMsgGetCurrentCapabilitiesResponse);
	CLbsNetworkProtocolBase::TLbsSystemStatus status;
	TInt cleanupCnt;
	cleanupCnt = proxy->GetArgsLC(ENetMsgGetCurrentCapabilitiesResponse, &status);
	TESTL(status == CLbsNetworkProtocolBase::ESystemStatusNone);
	CleanupStack::PopAndDestroy(cleanupCnt);
	
	// Start Test Step
	RPositionServer server;
	TESTL(KErrNone == server.Connect());
	CleanupClosePushL(server);	

	RPositioner pos;
	TESTL(KErrNone == pos.Open(server));
	CleanupClosePushL(pos);


	// Set the max fix time for the client request to ensure the location server does not complete the request too soon during the test.
	TPositionUpdateOptions posOpts(TTimeIntervalMicroSeconds(0), TTimeIntervalMicroSeconds(240000000));
	pos.SetUpdateOptions(posOpts);
	
	CPosServerWatcher *pWatch = CPosServerWatcher::NewLC(pos, *this);

	// Request a self-locate MoLr.
	pWatch->IssueNotifyPositionUpdate();

	// >> RequestSelfLocation()
	TESTL(proxy->WaitForResponse(KTimeOut) == ENetMsgRequestSelfLocation);

	// Process the response.
	TLbsNetSessionId* 					sessionId = NULL;
	TLbsNetPosRequestOptionsAssistance*	opts = NULL;
	
	cleanupCnt = proxy->GetArgsLC(ENetMsgRequestSelfLocation, &sessionId, &opts);
	
	iSessionId.SetSessionNum(sessionId->SessionNum());
	iSessionId.SetSessionOwner(sessionId->SessionOwner());

	CleanupStack::PopAndDestroy(cleanupCnt);
	sessionId = NULL;
	opts = NULL;	
	
	// << ProcessStatusUpdate(EServiceSelfLocation)
	MLbsNetworkProtocolObserver::TLbsNetProtocolServiceMask activeServiceMask = MLbsNetworkProtocolObserver::EServiceSelfLocation;
	proxy->CallL(ENetMsgProcessStatusUpdate, &activeServiceMask);

	// << ProcessLocationUpdate(SessionId, RefPosition)
	TPositionInfo refPosInfo = ArgUtils::MolrReferencePositionInfo();
	proxy->CallL(ENetMsgProcessLocationUpdate, &iSessionId, &refPosInfo);

	// TEST: Get the ref pos app side.
	CheckForObserverEventTestsL(KTimeOut, *this);

	// << ProcessAssistanceData()
	TLbsAsistanceDataGroup dataMask = EAssistanceDataReferenceTime;
	RLbsAssistanceDataBuilderSet assistanceData;
	ArgUtils::PopulateLC(assistanceData);
	TInt reason = KErrNone;
	proxy->CallL(ENetMsgProcessAssistanceData, &dataMask, &assistanceData, &reason);
	CleanupStack::PopAndDestroy(); // assistanceData

	// << ProcessLocationRequest(SessionId, HybridMode, alpha2)
	TBool emergency = EFalse;
	MLbsNetworkProtocolObserver::TLbsNetProtocolService service = MLbsNetworkProtocolObserver::EServiceSelfLocation;
	TLbsNetPosRequestQuality quality = ArgUtils::Quality(); 
	quality.SetMaxFixTime(ArgUtils::Alpha2());
	TLbsNetPosRequestMethod method   = ArgUtils::RequestHybridMethod();
	proxy->CallL(ENetMsgProcessLocationRequest, &iSessionId, &emergency, &service, &quality, &method);

	// Now that the hybrid/alpha2 has been requested, record current time to verify alpha2 timer expires correctly.
	TTime startTime;
	startTime.HomeTime();

	// >> RequestAssistanceData(0)
	TESTL(proxy->WaitForResponse(KTimeOut) == ENetMsgRequestAssistanceData); 
	cleanupCnt = proxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataMask);
	TESTL(dataMask == EAssistanceDataNone);
	CleanupStack::PopAndDestroy(cleanupCnt);

	// << NotifyPositionUpdate()
	pWatch->IssueNotifyPositionUpdate();

	// >> RequestAssistanceData(0)
	TESTL(proxy->WaitForResponse(KTimeOut) == ENetMsgRequestAssistanceData); 
	cleanupCnt = proxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataMask);
	TESTL(dataMask == EAssistanceDataNone);
	CleanupStack::PopAndDestroy(cleanupCnt);
	// Determine the value to take off the alpha2 value. This is required because we had to wait for the assistance data response.
	TTimeIntervalMicroSeconds microseconds;
	TTime stopTime;
	stopTime.HomeTime();
	microseconds = stopTime.MicroSecondsFrom(startTime); 
	TInt64 timeElapsed = microseconds.Int64();
	TInt delta = 2 * 1000 * 1000; // 2 secs.

	// >> RespondLocationRequest()
	TESTL(proxy->WaitForResponse(ArgUtils::Alpha2() - timeElapsed - delta) == ENetMsgTimeoutExpired);

	// Wait for and process the response.
	TESTL(proxy->WaitForResponse(2 * delta) == ENetMsgRespondLocationRequest);		// DONT get because the measurement data bus has not been created...

	sessionId = NULL;
	TPositionGpsMeasurementInfo* measurementInfo = NULL;
	cleanupCnt = proxy->GetArgsLC(ENetMsgRespondLocationRequest, &sessionId, &reason, &measurementInfo);
	TESTL(sessionId->SessionNum() == iSessionId.SessionNum());
	TESTL(reason == KErrNone);
	CleanupStack::PopAndDestroy(cleanupCnt);//sessionId, measurementInfo

	// Recv -> RequestAssistanceData - we get an extra msg as the result of the A-GPS manager re-issueing a location request when it's
	//									max fix time timer expries.
	TESTL(proxy->WaitForResponse(KTimeOut) == ENetMsgRequestAssistanceData); 
	cleanupCnt = proxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataMask);
	TESTL(dataMask == EAssistanceDataNone);
	CleanupStack::PopAndDestroy(cleanupCnt);

	const TInt t = 8 * 1000 * 1000; // 8 secs.
	quality.SetMaxFixTime(t);

	TPositionInfo* positionInfo = NULL;
	
	for (TInt i = 0; i < KN; i++)
		{
		// << ProcessLocationRequest(SessionId, HybridMode, t)
		proxy->CallL(ENetMsgProcessLocationRequest, &iSessionId, &emergency, &service, &quality, &method);

		// >> RequestAssistanceData(0)
		TESTL(proxy->WaitForResponse(KTimeOut) == ENetMsgRequestAssistanceData); 
		cleanupCnt = proxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataMask);
		TESTL(dataMask == EAssistanceDataNone);
		CleanupStack::PopAndDestroy(cleanupCnt);

		// >> RespondLocationRequest() - first measurement, second position.
		TESTL(proxy->WaitForResponse(t + delta) == ENetMsgRespondLocationRequest);

		sessionId = NULL;
		
		// Expect measurement first time.
		if (i < (KN-1))
			{
			measurementInfo = NULL;
			cleanupCnt = proxy->GetArgsLC(ENetMsgRespondLocationRequest, &sessionId, &reason, &measurementInfo);			

			// Check it is measurement
			TESTL(measurementInfo->PositionClassType() == EPositionGpsMeasurementInfoClass);

			// >> RequestAssistanceData - we get an extra msg as the result of the A-GPS manager re-issueing a location request when it's
			//									max fix time timer expries.
			TESTL(proxy->WaitForResponse(KTimeOut) == ENetMsgRequestAssistanceData);
			
			cleanupCnt += proxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataMask);

			TESTL(dataMask == EAssistanceDataNone);
			TESTL(sessionId->SessionNum() == iSessionId.SessionNum());
			TESTL(reason == KErrNone);
			}
		
		// Expect position second time.
		else
			{
			cleanupCnt = proxy->GetArgsLC(ENetMsgRespondLocationRequest, &sessionId, &reason, &positionInfo);
			
			// check it is a position
			TESTL(positionInfo->PositionClassType() == (EPositionInfoClass|EPositionCourseInfoClass|EPositionSatelliteInfoClass|EPositionExtendedSatelliteInfoClass));

			TESTL(sessionId->SessionNum() == iSessionId.SessionNum());
			TESTL(reason == KErrNone);
			
			// Client recv - the gps position determined by the gps module.
			CheckForObserverEventTestsL(KTimeOut, *this);
			TESTL(iState == EGpsLocReceived);
			
			// << ProcessLocationUpdate(SessionId, FinalNetworkPosition)
			// Return modules' position as FinalNetworkPosition
			proxy->CallL(ENetMsgProcessLocationUpdate, &iSessionId, positionInfo);
			}

		CleanupStack::PopAndDestroy(cleanupCnt);// sessionId, measurementInfo/positionInfo
		}
		

	// << ProcessSessionComplete(SessionId, KErrNone)	
	reason = KErrNone;
	proxy->CallL(ENetMsgProcessSessionComplete, &iSessionId, &reason);

	// << ENetMsgProcessStatusUpdate()
	MLbsNetworkProtocolObserver::TLbsNetProtocolServiceMask serviceMask = MLbsNetworkProtocolObserver::EServiceNone;
	proxy->CallL(ENetMsgProcessStatusUpdate, &serviceMask);
	

// Done. Now cleanup...
	CleanupStack::PopAndDestroy(pWatch);
	CleanupStack::PopAndDestroy(); // pos
	CleanupStack::PopAndDestroy(); // server	
	CleanupStack::PopAndDestroy(proxy);
		
	return TestStepResult();
	}
Пример #8
0
// ---------------------------------------------------------
// CPosTp29::TestCriticalLevelL
//
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CPosTp29::TestCriticalLevelL()
    {

    TTime startTime;
    TTime stopTime;

    startTime.UniversalTime();

    RemoveDefaultDbL();

    iLog->Put(_L("CPosLandmarkDatabase::OpenL();"));
    iLandmarksDb = CPosLandmarkDatabase::OpenL();
    if (iLandmarksDb->IsInitializingNeeded())
       {
       iLog->Put(_L("iLandmarksDb->InitializeL"));
       ExecuteAndDeleteLD(iLandmarksDb->InitializeL());        
       }

    iLog->Put(_L("CPosLmCategoryManager::NewL;"));
    iCategoryManager = CPosLmCategoryManager::NewL(*iLandmarksDb);

    // Asynchronous
    iLog->Put(_L("DoOutOfDiskTestL Asynchronous"));
//    iSearchCallback=ETrue;
    DoOutOfDiskTestL(ETrue);
  //  iSearchCallback=EFalse;

    // Delete "out-of-disk" file
    iFile1.Close();
    iFileServer.Delete(KFile1);
    iFile2.Close();
    iFileServer.Delete(KFile2);
    TInt err = iFile1.Open(iFileServer, KFile1, EFileWrite);
    if (err == KErrNotFound)
        {
        err = iFile1.Create(iFileServer, KFile1, EFileWrite);
        }
    User::LeaveIfError(err);
    
    err = iFile2.Open(iFileServer, KFile2, EFileWrite);
    if (err == KErrNotFound)
        {
        err = iFile2.Create(iFileServer, KFile2, EFileWrite);
        }
    User::LeaveIfError(err);

    // Synchronous
    iLog->Put(_L("DoOutOfDiskTestL Synchronous"));
    DoOutOfDiskTestL(EFalse);

    stopTime.UniversalTime();
    TTimeIntervalMicroSeconds executionTime = 
        stopTime.MicroSecondsFrom(startTime);

    //TInt64 resse = executionTime.Int64()/1000000;

    TInt resse = executionTime.Int64()/1000000;

    TBuf<50> buf;
    buf.Zero();
    buf.Format(_L("TP29 took %d seconds"), resse);
    iLog->Put(buf);
    }
TVerdict CT_LbsATAEarlyComplete::doTestStepL()
	{
   	INFO_PRINTF1(_L("&lt;&lt;CT_LbsATAEarlyComplete::doTestStepL()"));

    INFO_PRINTF1(_L("CT_LbsATAEarlyComplete::doTestStepL()"));	
	// Stop the test if the preable failed
	TESTL(TestStepResult() == EPass);

	INFO_PRINTF1(_L("&gt;&gt;CT_LbsStep_SetupRoamSelfLocate::doTestStepL()"));
   
   	CLbsAdmin* adminApi = CLbsAdmin::NewL();
   	CleanupStack::PushL(adminApi);
   	
   	// Switch on the self locate API when roaming.
   	CLbsAdmin::TSelfLocateService serviceSetting = CLbsAdmin::ESelfLocateUnknown;
   
   	TInt err = adminApi->Set(KLbsSettingRoamingSelfLocate, CLbsAdmin::ESelfLocateOn);
   	User::LeaveIfError(err);
   	err = adminApi->Get(KLbsSettingRoamingSelfLocate, serviceSetting);	
   	User::LeaveIfError(err);
   	
   	if(serviceSetting != CLbsAdmin::ESelfLocateOn)
   		{
   		INFO_PRINTF1(_L("Self locate API admin setting didn't work"));
   		SetTestStepResult(EFail);
   		}					
   	
   	// Set gps mode when roaming.
   	CLbsAdmin::TGpsMode gpsModeSetting = CLbsAdmin::EGpsModeUnknown;
   	
  	err = adminApi->Set(KLbsSettingRoamingGpsMode, CLbsAdmin::EGpsAlwaysTerminalAssisted);
   	User::LeaveIfError(err);
   	err = adminApi->Get(KLbsSettingRoamingGpsMode, gpsModeSetting);
   	User::LeaveIfError(err);
   	
 	if (gpsModeSetting != CLbsAdmin::EGpsAlwaysTerminalAssisted)
   		{
   		INFO_PRINTF1(_L("Gps mode admin setting didn't work"));
   		SetTestStepResult(EFail);
   		}
   		
	CLbsAdmin::TSpecialFeature	ignoreAccuracy;
   	TInt err1 = adminApi->Get(KLbsSpecialFeatureIgnoreAccuracy, ignoreAccuracy);
	if (err1 != KErrNone)
		{
	  	INFO_PRINTF1(_L("&lt;&lt KLbsSpecialFeatureIgnoreAccuracy is absent in admin;"));
		}	
		else
		{
	  	INFO_PRINTF2(_L("&lt;&lt KLbsSpecialFeatureIgnoreAccuracy is in admin and it's set to %d;"),ignoreAccuracy);
		}	

  	//INFO_PRINTF1(_L("&lt;&lt Setting KLbsSpecialFeatureIgnoreAccuracy to OFF"));
	//err = adminApi->Set(KLbsSpecialFeatureIgnoreAccuracy, CLbsAdmin::ESpecialFeatureOff;);
   		
   	CleanupStack::PopAndDestroy(adminApi);
   
   	// Allow the setting to be propagated
   	User::After(2*1000*1000);
   
	const TInt KTimeOut = 60*1000*1000;

	// Create Network Protocol Proxy
	CNetProtocolProxy* proxy = CNetProtocolProxy::NewL();
	CleanupStack::PushL(proxy);

	// Recv --> GetCurrentCapabilitiesResponse.
	// Soak up the Lbs System Status (produced by A-GPS Manager startup).}
	TESTL(proxy->WaitForResponse(KTimeOut) == ENetMsgGetCurrentCapabilitiesResponse);
	CLbsNetworkProtocolBase::TLbsSystemStatus status;
	TInt cleanupCnt;
	cleanupCnt = proxy->GetArgsLC(ENetMsgGetCurrentCapabilitiesResponse, &status);
	TESTL(status == CLbsNetworkProtocolBase::ESystemStatusNone);
	CleanupStack::PopAndDestroy(cleanupCnt);


	// Setup location session and position watcher.
	RPositionServer server;
	TESTL(KErrNone == server.Connect());
	CleanupClosePushL(server);	

	RPositioner pos;
	TESTL(KErrNone == pos.Open(server));
	CleanupClosePushL(pos);

	// Set the max fix time for the client request to ensure the location server does not complete the request too soon during the test.
	TPositionUpdateOptions posOpts(TTimeIntervalMicroSeconds(0), TTimeIntervalMicroSeconds(240000000));
	pos.SetUpdateOptions(posOpts);
	CPosServerWatcher *pWatch = CPosServerWatcher::NewLC(pos, *this);


	// Client Send - a self-locate request.
	pWatch->IssueNotifyPositionUpdate();


	TESTL(proxy->WaitForResponse(KTimeOut) == ENetMsgRequestSelfLocation);

	// Process the response.
	TLbsNetSessionId* 					sessionId = NULL;
	TLbsNetPosRequestOptionsAssistance*	opts = NULL;
	
	cleanupCnt = proxy->GetArgsLC(ENetMsgRequestSelfLocation, &sessionId, &opts);

	TBool qualitycheck = ArgUtils::CompareQuality(	opts, 
													ETrue, 
													KMinHorizontalAcc, 
													KMinVerticalAcc, 
													KMOLRFixTime,
													0, 
													EAssistanceDataReferenceTime, 
													(TPositionModuleInfo::ETechnologyNetwork 
													| TPositionModuleInfo::ETechnologyAssisted)
												);
		
	TESTL(qualitycheck);
	
	iSessionId.SetSessionNum(sessionId->SessionNum());
	iSessionId.SetSessionOwner(sessionId->SessionOwner());

	CleanupStack::PopAndDestroy(cleanupCnt);
	sessionId = NULL;
	opts = NULL;	

		
	// Send <-- ProcessStatusUpdate.
	MLbsNetworkProtocolObserver::TLbsNetProtocolService serviceMask = MLbsNetworkProtocolObserver::EServiceSelfLocation;
	proxy->CallL(ENetMsgProcessStatusUpdate, &serviceMask);

	// Send <-- ProcessAssistanceData.
	TLbsAsistanceDataGroup			dataMask = EAssistanceDataReferenceTime;
	RLbsAssistanceDataBuilderSet	data;
	TInt							reason = KErrNone;
	ArgUtils::PopulateLC(data);
	proxy->CallL(ENetMsgProcessAssistanceData, &dataMask, &data, &reason);
	CleanupStack::PopAndDestroy(); // data


	// Send <-- ProcessLocationRequest.
	TBool												emergency = EFalse;
	MLbsNetworkProtocolObserver::TLbsNetProtocolService	service = MLbsNetworkProtocolObserver::EServiceSelfLocation;
	TLbsNetPosRequestQuality							quality = ArgUtils::Quality();
	TLbsNetPosRequestMethod								method = ArgUtils::RequestTAPMethod();
	quality.SetMaxFixTime(ArgUtils::Alpha2());
	proxy->CallL(ENetMsgProcessLocationRequest, &iSessionId, &emergency, &service, &quality, &method);

	// Now that the hybrid/alpha2 has been requested, record current time to verify alpha2 timer expires correctly.
	TTime startTime;
	startTime.HomeTime();


	// Recv --> RequestAssistanceData.
	TESTL(proxy->WaitForResponse(KTimeOut) == ENetMsgRequestAssistanceData); 
	cleanupCnt = proxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataMask);
	TESTL(dataMask == EAssistanceDataNone);
	CleanupStack::PopAndDestroy(cleanupCnt);

	// Determine the value to take off the alpha2 value. This is required because we had to wait for the assistance data response.
	TTimeIntervalMicroSeconds microseconds;
	TTime stopTime;
	stopTime.HomeTime();
	microseconds = stopTime.MicroSecondsFrom(startTime); 
	TInt64 timeElapsed = microseconds.Int64();


	// Recv --> RespondLocationRequest.
	// First ensure we don't recv response before Alpha2.
	TInt delta = 2 * 1000 * 1000; // 2 secs.
	TESTL(proxy->WaitForResponse(ArgUtils::Alpha2() - timeElapsed - delta) == ENetMsgTimeoutExpired);
	
	// Wait for and process the response.
	TESTL(proxy->WaitForResponse(2 * delta) == ENetMsgRespondLocationRequest);

	TPositionGpsMeasurementInfo* measurementInfo = NULL;
	cleanupCnt = proxy->GetArgsLC(ENetMsgRespondLocationRequest, &sessionId, &reason, &measurementInfo);
	TESTL(sessionId->SessionNum() == iSessionId.SessionNum());
	TESTL(reason == KErrNone);
	TESTL(measurementInfo->PositionClassType() == EPositionGpsMeasurementInfoClass);
	
	CleanupStack::PopAndDestroy(cleanupCnt);
	sessionId = NULL;
	measurementInfo = NULL;


	// Recv -> RequestAssistanceData - we get an extra msg as the result of the A-GPS manager re-issueing a location request when it's
	//									max fix time timer expries.
	TESTL(proxy->WaitForResponse(KTimeOut) == ENetMsgRequestAssistanceData); 
	cleanupCnt = proxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataMask);
	TESTL(dataMask == EAssistanceDataNone);
	CleanupStack::PopAndDestroy(cleanupCnt);

	const TInt t = 8 * 1000 * 1000; // 8 secs.
	quality.SetMaxFixTime(t);
	
	
	// Send <-- ProcessLocationUpdate - return network calculated pos.
	TPositionInfo networkPosInfo = ArgUtils::MolrNetworkPositionInfo();
	proxy->CallL(ENetMsgProcessLocationUpdate, &iSessionId, &networkPosInfo);

	// Client Recv: Second update position - This should return with KPositionEarlyComplete
	CheckForObserverEventTestsL(KTimeOut, *this);

	// Wait to ensure no additional responses turn up.
	delta = 10 * 1000 * 1000;
	TNetProtocolResponseType rtype = proxy->WaitForResponse(delta);
	
	if (rtype == ENetMsgTimeoutExpired)
		{
		INFO_PRINTF1(_L("No additional messages turned up"));
	
 		}
	else
		{
		INFO_PRINTF1(_L("Got unexpected messages"));
 		}
		
	TESTL(rtype == ENetMsgCancelSelfLocation); 

	// Send <-- ProcessSessionComplete.
	reason = KErrNone;
	proxy->CallL(ENetMsgProcessSessionComplete, &iSessionId, &reason);


	// Carryout unique test actions (the ALT sections - see sequence diagrams.
	TInt testCaseId;
	if (GetIntFromConfig(ConfigSection(), KTestCaseId, testCaseId))
		{
		switch (testCaseId)
			{
			// Test case Stop_OutsideMoLr
			case 6:
				{
				User::After(2*1000*1000);
				
				iAGpsHandler->SendRequestModuleOption(ELbsHybridModuleOptions_DisableReqAssistData, ETrue);

				// Client Send: Notify Position Update
				pWatch->IssueNotifyPositionUpdate();
		
				// now ensure that intgration moulde does NOT RequestAssistanceData
				// and thus LBS will NOT send RequestSelfLopcation to protocol module
				// and a MoLr will NOT be started 
				
	 			// Client Send: Complete Request
				TESTL(pos.CompleteRequest(EPositionerNotifyPositionUpdate) == KErrNone);
	
				// Client Recv: Second update position - This should return with KPositionEarlyComplete
				CheckForObserverEventTestsL(KTimeOut, *this);

				TESTL(iState == EGotCompleteRequestPosition);
				
				}
				break;
					
			// Test case Stop_InsideMoLr
			case 5:
				{
				// Client Send: Notify Position Update

				User::After(2*1000*1000);

				pWatch->IssueNotifyPositionUpdate();

				rtype = proxy->WaitForResponse(KTimeOut);
				TESTL(rtype == ENetMsgRequestSelfLocation);

				// Process the response.
				sessionId = NULL;
				opts = NULL;
	
				cleanupCnt = proxy->GetArgsLC(ENetMsgRequestSelfLocation, &sessionId, &opts);

				qualitycheck = ArgUtils::CompareQuality(	opts, 
											EFalse, 
											KMinHorizontalAcc, 
											KMinVerticalAcc, 
											KMOLRFixTime,
											0, 
											EAssistanceDataNone, 
											(TPositionModuleInfo::ETechnologyNetwork 
											| TPositionModuleInfo::ETechnologyAssisted)
										);
		
				TESTL(qualitycheck);
	
				iSessionId.SetSessionNum(sessionId->SessionNum());
				iSessionId.SetSessionOwner(sessionId->SessionOwner());

				CleanupStack::PopAndDestroy(cleanupCnt);
				sessionId = NULL;
				opts = NULL;	
	

				// Send <-- ProcessLocationRequest.
				TBool	emergency = EFalse;
				MLbsNetworkProtocolObserver::TLbsNetProtocolService	service = MLbsNetworkProtocolObserver::EServiceSelfLocation;
				TLbsNetPosRequestQuality quality = ArgUtils::Quality();
				TLbsNetPosRequestMethod method = ArgUtils::RequestTAPMethod();
				quality.SetMaxFixTime(ArgUtils::Alpha2());
				proxy->CallL(ENetMsgProcessLocationRequest, &iSessionId, &emergency, &service, &quality, &method);

				// Now that the hybrid/alpha2 has been requested, record current time to verify alpha2 timer expires correctly.
				TTime startTime;
				startTime.HomeTime();

				// Recv --> RequestAssistanceData.
				TESTL(proxy->WaitForResponse(KTimeOut) == ENetMsgRequestAssistanceData); 
				cleanupCnt = proxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataMask);
				TESTL(dataMask == EAssistanceDataNone);
				CleanupStack::PopAndDestroy(cleanupCnt);

    			//Client Send: CompleteRequest
				TESTL(pos.CompleteRequest(EPositionerNotifyPositionUpdate) == KErrNone);
	
				// Client Recv: Second update position - This should return with KPositionEarlyComplete
				CheckForObserverEventTestsL(KTimeOut, *this);

				TESTL(iState == EDone);

				// Wait for and process the response. Should be aRespondLocationRequest(KErrNone,FinalNetworkPosition)
				rtype = proxy->WaitForResponse(KTimeOut);
				TESTL(rtype == ENetMsgRespondLocationRequest);

				sessionId = NULL;
				TPositionInfo* positionInfo = NULL;
			
				cleanupCnt = proxy->GetArgsLC(ENetMsgRespondLocationRequest, &sessionId, &reason, &positionInfo);
			
				// Check the response.
				TESTL(positionInfo->PositionClassType() == (EPositionInfoClass|EPositionCourseInfoClass|EPositionSatelliteInfoClass));
				TESTL(sessionId->SessionNum() == iSessionId.SessionNum());
				TESTL(reason == KErrNone);
				CleanupStack::PopAndDestroy(cleanupCnt);

				// Send <-- ProcessSessionComplete.
				reason = KErrNone;
				proxy->CallL(ENetMsgProcessSessionComplete, &iSessionId, &reason);	
				}
				break;
			default:
				{
				User::Leave(KErrArgument);	
				}
				break;
			}
		}
	else
		{
	INFO_PRINTF1(_L("<FONT><B>Failed to read from ini file correctly</B></FONT>"));
	SetTestStepResult(EFail);
		}

	// Wait for 10 seconds to ensure no additional responses turn up.
	delta = 10 * 1000 * 1000;
	TNetProtocolResponseType mType = proxy->WaitForResponse(delta);
	TESTL(mType == ENetMsgTimeoutExpired);
	
	// Done. Now cleanup...
	CleanupStack::PopAndDestroy(pWatch);
	CleanupStack::PopAndDestroy(); // pos
	CleanupStack::PopAndDestroy(); // server	
	CleanupStack::PopAndDestroy(proxy);
		
	return TestStepResult();
	}
void CBuddycloudListComponent::HandlePointerEventL(const TPointerEvent &aPointerEvent) {
	CCoeControl::HandlePointerEventL(aPointerEvent);
	
	if(aPointerEvent.iType == TPointerEvent::EButton1Up) {			
		if(iDraggingAllowed) {
			if(Abs(iDragVelocity) > 5.0) {
				TimerExpired(KDragTimerId);
			}
		}
		else {
			for(TInt i = 0; i < iListItems.Count(); i++) {
				if(iListItems[i].iRect.Contains(aPointerEvent.iPosition)) {
					// Provide feedback
					iTouchFeedback->InstantFeedback(ETouchFeedbackBasic);
					
					HandleItemSelection(iListItems[i].iId);			
					break;
				}
			}
		}
	}
	else if(aPointerEvent.iType == TPointerEvent::EButton1Down) {
		iDragTimer->Stop();
		iDragVelocity = 0.0;
		iDraggingAllowed = false;
		
		iStartDragPosition = aPointerEvent.iPosition.iY;
		iStartDragHandlePosition = iScrollbarHandlePosition;
		
		iLastDragTime.UniversalTime();
		iLastDragPosition = iStartDragPosition;
	}
	else if(aPointerEvent.iType == TPointerEvent::EDrag) {	
		if(!iDraggingAllowed && (aPointerEvent.iPosition.iY + 32 < iStartDragPosition || aPointerEvent.iPosition.iY - 32 > iStartDragPosition)) {
			iDraggingAllowed = true;			
			iSnapToItem = false;
		}
		
		if(iDraggingAllowed) {
			TTime aNow;			
			aNow.UniversalTime();
			
			iDragVelocity = TReal(TReal(iLastDragPosition - aPointerEvent.iPosition.iY) * (1000000.0 / TReal(aNow.MicroSecondsFrom(iLastDragTime).Int64()))) / 20.0;
			
			iLastDragTime.UniversalTime();
			iLastDragPosition = aPointerEvent.iPosition.iY;
			
			iScrollbarHandlePosition = iStartDragHandlePosition + (iStartDragPosition - aPointerEvent.iPosition.iY);
			
			CBuddycloudListComponent::RepositionItems(false);
			RenderScreen();
		}
	}
}
// ---------------------------------------------------------
// 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);
}
Пример #13
0
static void TestFileDelete()
//
//
//
{
    ClearSessionDirectory();
    test.Next(_L("Benchmark delete"));

    TInt64 total=0;
    TInt numberOfFiles=100;
    TInt cycles=1;

    TInt i=0;
    for (; i<cycles; i++)
    {
        //	Create many files
        CreateManyFiles(numberOfFiles);

        test.Next(_L("Time the delete"));
        //	Now delete them and time it
        TTime startTime;
        startTime.HomeTime();

        for (TInt index=0; index<numberOfFiles; index++)
        {
            TFileName baseName=_L("\\F32-TST\\BENCH_DELETE\\FILE");
            baseName.AppendNum(index);

            TInt r=TheFs.Delete(baseName);
            test_KErrNone(r);
        }

        TTime endTime;
        endTime.HomeTime();
        TTimeIntervalMicroSeconds timeTaken;
        timeTaken=endTime.MicroSecondsFrom(startTime);
        TInt64 time=timeTaken.Int64();
        total+=time;
    }
//	We deleted cycles*numberOfFiles files in total microseconds
    TInt64 fileDeleteTime=total/(numberOfFiles*cycles);
    test.Next(_L("Benchmarked RFs::Delete()"));
    test.Printf(_L("Delete time per file = %d microseconds\n"),fileDeleteTime);

    CFileMan* fMan=CFileMan::NewL(TheFs);
    total=0;
    numberOfFiles=100;
    cycles=1;
    i=0;
    for (; i<cycles; i++)
    {
        //	Create many files
        CreateManyFiles(numberOfFiles);

        test.Next(_L("Time the delete"));
        //	Now delete them and time it
        TTime startTime;
        startTime.HomeTime();

        for (TInt index=0; index<numberOfFiles; index++)
        {
            TInt r=fMan->Delete(_L("\\F32-TST\\BENCH_DELETE\\FILE*"));
            test_Value(r, r == KErrNone || r==KErrNotFound);
        }

        TTime endTime;
        endTime.HomeTime();
        TTimeIntervalMicroSeconds timeTaken;
        timeTaken=endTime.MicroSecondsFrom(startTime);
        TInt64 time=timeTaken.Int64();
        total+=time;
    }
//	We deleted cycles*numberOfFiles files in total microseconds
    fileDeleteTime=total/(numberOfFiles*cycles);
    test.Next(_L("Benchmarked CFileMan::Delete()"));
    test.Printf(_L("Delete time per file = %d microseconds\n"),fileDeleteTime);

    delete fMan;
}
Пример #14
0
static void TestLargeFileDelete()
//
// This test require MMC/SD card size >=4GB-2 in size
//
{
    ClearSessionDirectory();
    test.Next(_L("Benchmark delete large file"));

    TInt64 total=0;

    TInt cycles=1;

    TInt i=0;

    //check Disk space and decide how many files to create
    TVolumeInfo volInfo;
    TInt r;

    r = TheFs.Volume(volInfo);
    test_KErrNone(r);

    TInt numberOfFiles = (TUint)(volInfo.iFree/(K4GB -2));
#ifdef __WINS__
    // Fix a maximum number of large files to create on the emulator
    if (numberOfFiles > 5)
        numberOfFiles = 5;
#endif
    test.Printf(_L("Number of large files =%d \n"),numberOfFiles);

    if(numberOfFiles<=0)
    {
        test.Printf(_L("Large File delete is skipped \n"));
        return;
    }

    for (; i<cycles; i++)
    {
        //	Create many files
        CreateManyLargFiles(numberOfFiles);

        test.Next(_L("Time the delete"));
        //	Now delete them and time it
        TTime startTime;
        startTime.HomeTime();

        for (TInt index=0; index<numberOfFiles; index++)
        {
            TFileName baseName=_L("\\F32-TST\\BENCH_DELETE\\FILE");
            baseName.AppendNum(index);

            TInt r=TheFs.Delete(baseName);
            test_KErrNone(r);
        }

        TTime endTime;
        endTime.HomeTime();
        TTimeIntervalMicroSeconds timeTaken;
        timeTaken=endTime.MicroSecondsFrom(startTime);
        TInt64 time=timeTaken.Int64();
        total+=time;
    }
//	We deleted cycles*numberOfFiles files in total microseconds
    TInt64 fileDeleteTime=total/(numberOfFiles*cycles);
    test.Next(_L("Benchmarked RFs::Delete()"));
    test.Printf(_L("Delete time per file = %d microseconds\n"),fileDeleteTime);

    CFileMan* fMan=CFileMan::NewL(TheFs);
    total=0;

    cycles=1;
    i=0;
    for (; i<cycles; i++)
    {
        //	Create many files
        CreateManyLargFiles(numberOfFiles);

        test.Next(_L("Time the delete"));
        //	Now delete them and time it
        TTime startTime;
        startTime.HomeTime();

        for (TInt index=0; index<numberOfFiles; index++)
        {
            TInt r=fMan->Delete(_L("\\F32-TST\\BENCH_DELETE\\FILE*"));
            test_Value(r, r == KErrNone || r==KErrNotFound);
        }

        TTime endTime;
        endTime.HomeTime();
        TTimeIntervalMicroSeconds timeTaken;
        timeTaken=endTime.MicroSecondsFrom(startTime);
        TInt64 time=timeTaken.Int64();
        total+=time;
    }
//	We deleted cycles*numberOfFiles files in total microseconds
    fileDeleteTime=total/(numberOfFiles*cycles);
    test.Next(_L("Benchmarked CFileMan::Delete()"));
    test.Printf(_L("Delete time per file = %d microseconds\n"),fileDeleteTime);

    delete fMan;
}
Пример #15
0
static void DoTestFileWrite(TInt aBlockSize, TInt aFileSize = KMaxFileSize, TBool aUpdate = EFalse)
//
// Do Write benchmark
//
{
    DataBuf.SetLength(aBlockSize);
    const TInt maxWriteCount = aFileSize / aBlockSize;

    TFileName testDir(_L("?:\\F32-TST\\"));
    testDir[0] = (TText) gDriveToTest;
    TInt r = TheFs.MkDir(testDir);
    test_Value(r, r == KErrNone || r == KErrAlreadyExists);

    TFileName fileName;
    r = File.Temp(TheFs, testDir, fileName, EFileWrite | (gFileSequentialModeOn ? EFileSequential : 0)
                  | (gWriteCachingOn ? EFileWriteBuffered : EFileWriteDirectIO));
    test_KErrNone(r);

    if (aUpdate)
    {
        TInt r = File.SetSize(aFileSize);
        test_KErrNone(r);
    }

    TUint functionCalls = 0;

    TTime startTime;
    TTime endTime;
    TUint initTicks = 0;
    TUint finalTicks = 0;


    // we stop after the entire file has been written or after 10 seconds, whichever happens sooner
    RTimer timer;
    timer.CreateLocal();
    TRequestStatus reqStat;

    TInt pos = 0;
    File.Seek(ESeekStart, pos);

    timer.After(reqStat, 10000000); // After 10 secs

    startTime.HomeTime();
    initTicks = User::FastCounter();

    for (TInt i = 0 ; i<maxWriteCount && reqStat==KRequestPending; i++)
    {
        File.Write(pos, DataBuf, aBlockSize);

        pos += aBlockSize;
        if (pos > KMaxFileSize-aBlockSize)
            pos = 0;

        functionCalls++;
    }

    if (gFlushAfterWrite)
    {
        r = File.Flush();
        test_KErrNone(r)
    }

    // write file once only
    finalTicks = User::FastCounter();
    endTime.HomeTime();
//	TTimeIntervalMicroSeconds duration = endTime.MicroSecondsFrom(startTime);
    TTimeIntervalMicroSeconds duration = TInt64(finalTicks - initTicks) * TInt64(1000000) / TInt64(gFastCounterFreq) ;

    TInt dataTransferred = functionCalls * aBlockSize;
    TReal transferRate =
        TReal32(dataTransferred) /
        TReal(duration.Int64()) * TReal(1000000) / TReal(K1K); // KB/s
    test.Printf(_L("Write %7d bytes in %7d byte blocks:\t%11.3f KBytes/s (%d microsecs)\n"),
                dataTransferred, aBlockSize, transferRate, endTime.MicroSecondsFrom(startTime).Int64());

    timer.Close();

    File.Close();
    r = TheFs.Delete(fileName);
    test_KErrNone(r)

    return;
}
Пример #16
0
void CPlPerformanceAPI::CreateContactsBatchL(TInt aSize)
	{
	test.Next(_L("->... Create"));

	RDebug::Print(_L("CreateContactsTestL(TInt aSize)"));
	TBool testFlag = EFalse;
	testFlag = iCntTestImpl.DefaultContactDatabaseExistsL();
	test.Printf(_L("CreateContactsBatchL_1, DefaultContactDatabaseExistsL:%d \n"),testFlag);
	
				
	TTime startTime;
	startTime.UniversalTime();
	
	for (int ii = 0; ii < aSize; ii+=nsPlPerformance::KBatchSize)
		{
		CreateContactsTestL(aSize<nsPlPerformance::KBatchSize ?
							aSize:nsPlPerformance::KBatchSize);
		if (ii >= nsPlPerformance::KBatchSize - 1)
			{
			iCntTestImpl.CompactL();		
			}
		}	

	TTime finishTime;			
	finishTime.UniversalTime();
	// Temporary required for ARMv5, adress of Int64() is taken in
	// parameter to Format method otherwise.
	TReal lapsed = (TReal) finishTime.MicroSecondsFrom(startTime).Int64();
	
	TBuf8<64> row;
	// _LIT8 gives an error - illegal implicit conversion from long 
	row.Format(_L8("Create,%d,%.4f\r\n"), aSize, lapsed/1000000);
	iCsvWriter->WriteNextLineL(row);
	
	// API Tests
	testFlag = iCntTestImpl.CompressRequired();
	test.Printf(_L("CreateContactsBatchL, CompressRequired:%d \n"),testFlag);	
	
	testFlag = iCntTestImpl.IsDamaged();
	test.Printf(_L("CreateContactsBatchL, IsDamaged:%d \n"),testFlag);
	
	testFlag = iCntTestImpl.DefaultContactDatabaseExistsL();
	test.Printf(_L("CreateContactsBatchL, DefaultContactDatabaseExistsL:%d \n"),testFlag);
		
	testFlag = iCntTestImpl.ContactDatabaseExistsL(KTestContactFileName);
	test.Printf(_L("CreateContactsBatchL, ContactDatabaseExistsL:%d \n"),testFlag);
	
	TInt theCount;
	theCount = iCntTestImpl.FileSize();
	test.Printf(_L("CreateContactsBatchL, FileSize:%d \n"),theCount);
	
	theCount = iCntTestImpl.WastedSpaceInBytes();
	test.Printf(_L("CreateContactsBatchL, WastedSpaceInBytes:%d \n"),theCount);	
	
	TBuf<190> defaultName;
	iCntTestImpl.GetDefaultNameL(defaultName);
	test.Printf(_L("CreateContactsBatchL, GetDefaultNameL: %s \n"),defaultName.PtrZ());	
	defaultName.Delete(0,defaultName.Size());
	
	TDriveUnit driveUnit;
	iCntTestImpl.DatabaseDrive(driveUnit);
	TBuf<190> driveName = driveUnit.Name();
	test.Printf(_L("CreateContactsBatchL, DatabaseDrive: %s \n"),driveName.PtrZ());		

	}
Пример #17
0
// Function : ThreadFuncL()
// Description:Thread for performance read test(s)
// @return :TInt
TInt CT_ReadFileStep::ThreadFuncL(RFs& /*aSession*/)
	{
 	RFile	file;	//	File that all operations are acted upon
	//set up for either testcase
	TInt	result=KErrNone;
	HBufC8*	data=HBufC8::NewLC(iBlockSize);
	TPtr8	buf(data->Des());
	buf.SetLength(iBlockSize);
	//test scenarios
	if (iSeek)//perform seek read operation
		{
		TTime	startTime;
		TTime	endTime;
		TInt	pos=0;
		TInt	i=0;
		TInt	sizebuf=iFileSize-iBlockSize;
		//start timer
		startTime.UniversalTime();
		for(i=0; (i<iFuncCalls) && (result==KErrNone); i++)
			{
			pos=i%2?sizebuf-i/2:i/2;
			file=iFileArray[i%iNumOfFiles];
			result=file.Read(pos,buf,iBlockSize);
			}
		//end timer
		endTime.UniversalTime();

		//calculate extra time taken for pos calc (file offset calc)
		TInt	calls=i;
		TInt	res=KErrNone;
		TTime 	startPos;	// Start pos timer
		TTime	endPos;	//End Pos timer
		startPos.UniversalTime();
		for(TInt j=0; (j<calls) && (res==KErrNone); j++)
			{
			pos=j%2?sizebuf-j/2:j/2;
			file=iFileArray[j%iNumOfFiles];
			}
		endPos.UniversalTime();
		endTime=endTime-(endPos.MicroSecondsFrom(startPos));
		iTotalTime=endTime.MicroSecondsFrom(startTime);//Store time-taken
		}
	else //perform read operation only
		{
		TInt	i=0;
		TInt	pos=0;
		TInt	sizebuf=iFileSize-iBlockSize;
		TTime	startTime;
		TTime	endTime;	//End timer
		startTime.UniversalTime();	// Start timer
		for(i=0; (i<iFuncCalls) && (result==KErrNone); i++)
			{
			pos=i%2?sizebuf-i/2:i/2;
			file=iFileArray[i%iNumOfFiles];
			User::LeaveIfError(file.Seek(iSeekMode,pos));
			result=(file.Read(buf,iBlockSize));
			}
		endTime.UniversalTime();

		//calculate extra time taken during seek file and remove
		TInt	calls=i;
		TInt	res=KErrNone;
		TTime	startSeek;	// Start seek timer
		TTime 	endSeek;	//End Seek timer
		startSeek.UniversalTime();
		for(TInt j=0; (j<calls) && (res==KErrNone); j++)
			{
			pos=j%2?sizebuf-j/2:j/2;
			file=iFileArray[j%iNumOfFiles];
			User::LeaveIfError(file.Seek(iSeekMode,pos));
			}
		endSeek.UniversalTime();
		endTime=endTime-(endSeek.MicroSecondsFrom(startSeek));
		iTotalTime=endTime.MicroSecondsFrom(startTime);	//Store time-taken
		}
	//End Test Scenarios
	CleanupStack::PopAndDestroy(1, data);// data
	return result;
 	}
TVerdict CT_LbsHybridUEAssistedX3PNoGPSTimeout::doTestStepL()
	{
	// Generic test step used to test the LBS Client Notify position update API.
	INFO_PRINTF1(_L("CT_LbsHybridUEAssistedX3PNoGPSTimeout::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= 1;
	TLbsTransmitPositionOptions options(TTimeIntervalMicroSeconds(500*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 End

	//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);

	// here we wait for either of the asynchrnous requestst to complete
	User::WaitForRequest(refPosStatus, transPosStatus); 
	// but now we do expect that only the REF position asyn request to complete
	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);

	quality = ArgUtils::Quality(); 
	const TInt KN = 2;
	for(TInt i=0;i<KN;i++)
		{
		iProxy->CallL(ENetMsgProcessLocationRequest, &iSessionId, &emergency, &service, &quality, &method);
		
		timerStart.HomeTime();
		
		// RequestAssistanceData(0)
		TESTL(iProxy->WaitForResponse(KSmallTimeOut) == ENetMsgRequestAssistanceData); 
		cleanupCnt = iProxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataGroup);
		TESTL(dataGroup == EAssistanceDataNone);		
		CleanupStack::PopAndDestroy(cleanupCnt);

	 	timerStop.HomeTime();
 		microseconds = timerStop.MicroSecondsFrom(timerStart); 
		timeElapsed = microseconds.Int64();	
		
		TESTL(iProxy->WaitForResponse(KTTimeout-timeElapsed-KDelta) == ENetMsgTimeoutExpired); 
		TESTL(iProxy->WaitForResponse(2*KDelta) == ENetMsgRespondLocationRequest);	

		getSessionId = NULL;
		getReason = KErrNone;
		getPositionInfo = NULL;

		cleanupCnt = iProxy->GetArgsLC(ENetMsgRespondLocationRequest, &getSessionId, &getReason, &getPositionInfo);
		TESTL(getReason == KErrNone);
		TESTL(getSessionId->SessionNum() == iSessionId.SessionNum());
		CleanupStack::PopAndDestroy(cleanupCnt);
		} 
	
	// Alpha4 expires. 
	// The Protocol Module requests the network for the MC release
	
// Network Result Notification Start
	// Add extra delay to simulate the Facility timing out 	
	User::After(2*KTimeOut);
	// Test that LBS is not sending any response to the Protocol Module
	TESTL(iProxy->WaitForResponse(KTimeOut) == ENetMsgTimeoutExpired); 
// Network Result Notification End

// Session Complete Start
	// The network times out and pass an error to the Protocol Module, in this test, we use KErrTimedOut
	// The protocol module passes the error to the client app
	reason = KErrTimedOut; 
	iProxy->CallL(ENetMsgProcessSessionComplete, &iSessionId, &reason);

	MLbsNetworkProtocolObserver::TLbsNetProtocolServiceMask activeServiceMask = MLbsNetworkProtocolObserver::EServiceNone;
	iProxy->CallL(ENetMsgProcessStatusUpdate, &activeServiceMask);
// Session Complete End

	User::WaitForRequest(transPosStatus);  
	// We test the error returned from the network
	TESTL(transPosStatus==KErrTimedOut);
	    
	return TestStepResult();
	}
Пример #19
0
// ---------------------------------------------------------
// CPosTp29::DoOutOfDiskTestL
//
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CPosTp29::DoOutOfDiskTestL(TBool aSync)
    {
    TVolumeInfo volumeInfo;
    TBuf<200> buf;
    CPosLmOperation* op = NULL;

    _LIT(KUID,"Unique ID: %08x\r\n");
	_LIT(KSize,"Size: %d bytes\r\n");
	_LIT(KFree,"Free space: %d bytes\r\n");
	//_LIT(KVolName,"Volume name: %S\r\n");

    TInt err=iFileServer.Volume(volumeInfo, EDriveC);
    if (err != KErrNone) iLog->Put(_L("Error from iFileServer"));

    buf.AppendFormat(KUID, volumeInfo.iUniqueID);
	buf.AppendFormat(KSize, volumeInfo.iSize);
	buf.AppendFormat(KFree, volumeInfo.iFree);
	//buf.AppendFormat(KVolName, &volumeInfo.iName);
    iLog->Put(buf);

    TTime startTime;
    TTime stopTime;

    // Just in case
    ExecuteAndDeleteLD(iLandmarksDb->CompactL());

    RArray<TPosLmItemId> lmIdArray;
    CleanupClosePushL(lmIdArray);

    // 1) Create a low disc space situation
    startTime.UniversalTime();
    ConsumeDiscSpace1L(iCriticalLevel + KSizeLimitOffset1);
    ConsumeDiscSpace2L(iCriticalLevel + KSizeLimitOffset2);
    
    err=iFileServer.Volume(volumeInfo, EDriveC);
    if (err != KErrNone) iLog->Put(_L("Error from iFileServer"));
    buf.AppendFormat(KUID, volumeInfo.iUniqueID);
	buf.AppendFormat(KSize, volumeInfo.iSize);
	buf.AppendFormat(KFree, volumeInfo.iFree);
    iLog->Put(buf);

    stopTime.UniversalTime();
    TTimeIntervalMicroSeconds executionTime = 
        stopTime.MicroSecondsFrom(startTime);

    TInt resse = executionTime.Int64()/1000000;
    buf.Zero();
    buf.Format(_L("ConsumeDiscSpaceL took %d seconds"), resse);
    iLog->Put(buf);

    // 2) Add Landmarks until "disk full" error occur
    if (iLandmarksDb->IsInitializingNeeded())
        {
        iLog->Put(_L("InitializeL"));
        // Synchronous 
        ExecuteAndDeleteLD(iLandmarksDb->InitializeL());        
        }

    CPosLandmark* landmark = CPosLandmark::NewLC();
    landmark->SetLandmarkNameL(_L("LandMarkName1"));
    iLog->Put(_L("Adding landmark1"));
    lmIdArray.Append(iLandmarksDb->AddLandmarkL(*landmark));
    CleanupStack::Pop(landmark);

    landmark = CPosLandmark::NewLC();
    landmark->SetLandmarkNameL(_L("LandMarkName2"));
    iLog->Put(_L("Adding landmark2"));
    lmIdArray.Append(iLandmarksDb->AddLandmarkL(*landmark));
    CleanupStack::Pop(landmark);
    err = KErrNone;
    TPosLmItemId idde;
    TInt i=0;
    
    startTime.UniversalTime();
    iLog->Put(_L("Adding landmark until KErrDiskFull.....1"));
    // some while loop adding landmarks here until "disk full" error occur!!!
    while (err != KErrDiskFull)
        {
        buf.Zero();
        buf.Format(_L("Land Mark___________%d"), i++);
        landmark = CPosLandmark::NewLC();
        landmark->SetLandmarkNameL(buf);
        TRAP(err, idde = iLandmarksDb->AddLandmarkL(*landmark));
        if (err == KErrNone)
            {
            lmIdArray.Append(idde);
            }
        else if (err == KErrLocked) 
            {
            iLog->Put(_L("KErrLocked when adding 1"));
            User::After(100000);
            }
        CleanupStack::Pop(landmark);
        }
    stopTime.UniversalTime();
    executionTime = stopTime.MicroSecondsFrom(startTime);
    resse = executionTime.Int64()/1000000;
    buf.Zero();
    buf.Format(_L("Added %d nr of landmarks, took %d seconds"), i, resse);
    iLog->Put(buf);

    // Check that the filesize limit has not been exceeded 
    err=iFileServer.Volume(volumeInfo, EDriveC);
    buf.Zero();
	buf.AppendFormat(KFree, volumeInfo.iFree);
    iLog->Put(buf);
    if (volumeInfo.iFree < iCriticalLevel)
        {
        LogErrorAndLeave(_L("The max size limit has been exceeded!!!"));
        }

    //Check that the added landmarks can be read
    iLog->Put(_L("Check that it is possible to read landmark"));
    TInt nrOfLandmarks = lmIdArray.Count();
    TInt p=0;
    for (p=0;p<nrOfLandmarks;p++)
        {
        landmark = iLandmarksDb->ReadLandmarkLC(lmIdArray[p]);
        CleanupStack::Pop(landmark);
        }

    // 3) Remove two landmarks and compress landmarks db
    TInt nr = lmIdArray.Count()-1;
    TPosLmItemId id = lmIdArray[nr];
    iLog->Put(_L("Removing landmark1"));
    lmIdArray.Remove(nr);
    TRAP(err, iLandmarksDb->RemoveLandmarkL(id));
    if (err == KErrDiskFull) 
        {
        ExecuteAndDeleteLD(iLandmarksDb->CompactL());

        iLandmarksDb->RemoveLandmarkL(id);
        iLog->Put(_L("DiskFull when removing1"));
        }

    nr = lmIdArray.Count() - 1;
    id = lmIdArray[nr];
    iLog->Put(_L("Removing landmark2"));
    lmIdArray.Remove(nr);
    iLandmarksDb->RemoveLandmarkL(id);
    TRAP(err, iLandmarksDb->RemoveLandmarkL(id));
    if (err == KErrDiskFull) 
        {
        ExecuteAndDeleteLD(iLandmarksDb->CompactL());
        
        iLandmarksDb->RemoveLandmarkL(id);
        iLog->Put(_L("DiskFull when removing2"));
        }
    err = KErrNone;
    iLog->Put(_L("Compacting"));
    ExecuteAndDeleteLD(iLandmarksDb->CompactL());
    
    startTime.UniversalTime();
    iLog->Put(_L("Adding landmark until KErrDiskFull.....2"));
    // 4) Add landmarks until "disk full" error occur!!!
    while (err != KErrDiskFull)
        {
        buf.Zero();
        buf.Format(_L("Land Mark___________%d"), i++);
        landmark = CPosLandmark::NewLC();
        landmark->SetLandmarkNameL(buf);
        //iLog->Put(_L("Adding landmark id to idArray"));
        TRAP(err, idde = iLandmarksDb->AddLandmarkL(*landmark));
        if (err == KErrNone)
            {
            lmIdArray.Append(idde);
            }
        else if (err == KErrLocked) 
            {
            iLog->Put(_L("KErrLocked when adding 2"));
            User::After(100000);
            }
        CleanupStack::Pop(landmark);
        }

    stopTime.UniversalTime();
    executionTime = stopTime.MicroSecondsFrom(startTime);
    resse = executionTime.Int64()/1000000;
    buf.Zero();
    buf.Format(_L("Added %d nr of landmarks, took %d seconds"), i, resse);
    iLog->Put(buf);

    iLog->Put(_L("Check that it is possible to read landmark"));
    //Check that the added landmarks can be read
    nrOfLandmarks = lmIdArray.Count();
    for (p=0;p<nrOfLandmarks;p++)
        {
        landmark = iLandmarksDb->ReadLandmarkLC(lmIdArray[p]);
        CleanupStack::Pop(landmark);
        }

    iLog->Put(_L("Remove all landmarks"));
    err = KErrNone;
    // 5) Remove all landmarks and compact database
    if (!aSync)
        {
        TRAP(err, op = iLandmarksDb->RemoveAllLandmarksL());
        if (err == KErrNone) 
            {
            ExecuteAndDeleteLD(op);
            }
        else if (err == KErrDiskFull)
            {
            iLog->Put(_L("KErrDiskFull when removing all landmarks"));
            ExecuteAndDeleteLD(iLandmarksDb->CompactL());
            
            // Delete KFile2 to free more space on disc, method also open connection to iFile2 again
            DeleteFile2L();

            iLog->Put(_L("Removing after Compact sync"));
            TRAP(err, op = iLandmarksDb->RemoveAllLandmarksL());
            if (err == KErrDiskFull)
                {
                iLog->Put(_L("KErrDiskFull when Removing all landmarks after compact1"));
                RemoveAllLandmarksL();
                }
            else
                {
                ExecuteAndDeleteLD(op);
                }
            }
        }
    else
        {
        iLog->Put(_L("Before RemoveAllLandmarksL(this)"));
        TRAP(err, op = iLandmarksDb->RemoveAllLandmarksL());
        
        if (err == KErrNone) 
            {
            //***iActiveSchedulerWait->Start();
            //***delete op; op=NULL;
            RunAsyncOperationLD(op);
            }
        else if (err == KErrDiskFull)
            {
            iLog->Put(_L("KErrDiskFull when removing all landmarks"));
            ExecuteAndDeleteLD(iLandmarksDb->CompactL());
            
            // Delete KFile2 to free more space on disc, method also open connection to iFile2 again
            DeleteFile2L();

            iLog->Put(_L("Removing after Compact async"));
            TRAP(err, op = iLandmarksDb->RemoveAllLandmarksL());
            if (err == KErrDiskFull)
                {
                iLog->Put(_L("KErrDiskFull when removing all landmarks after compact2"));
                RemoveAllLandmarksL();
                }
            else
                {
                //***iActiveSchedulerWait->Start();
                //***delete op; op=NULL;
                RunAsyncOperationLD(op);
                }
            }
        iLog->Put(_L("After RemoveAllLandmarksL(this)"));
        }
    
    ConsumeDiscSpace2L(iCriticalLevel + KSizeLimitOffset2);

    if (err == KErrDiskFull) iLog->Put(_L("KErrDiskFull when RemoveAllLandmarksL"));
    iLog->Put(_L("Compacting"));
    ExecuteAndDeleteLD(iLandmarksDb->CompactL());
    
    lmIdArray.Reset();
    i=0;
    err = KErrNone;
    startTime.UniversalTime();
    iLog->Put(_L("Adding landmarkcategories until KErrDiskFull....."));

    // 6) Add LandmarkCategories until "disk full" error occur
    while (err != KErrDiskFull)
        {
        buf.Zero();
        buf.Format(_L("Landmark Category _________ %d"), i++);
        CPosLandmarkCategory* lmc = CPosLandmarkCategory::NewLC();
        lmc->SetCategoryNameL(buf);
        lmc->SetIconL(_L("Pelles Icon"), 111, KPosLmIconMaskNotUsed);

        TRAP(err, idde = iCategoryManager->AddCategoryL(*lmc));
        if (err == KErrNone)
            {
            lmIdArray.Append(idde);
            }
        else if (err== KErrLocked)
            {
            iLog->Put(_L("KErrLocked when adding category"));
            User::After(100000);
            }
        CleanupStack::PopAndDestroy(lmc);
        }

    stopTime.UniversalTime();
    executionTime = stopTime.MicroSecondsFrom(startTime);

    resse = executionTime.Int64()/1000000;
    buf.Zero();
    buf.Format(_L("Added %d nr of landmarkcategories, took %d seconds"), i, resse);
    iLog->Put(buf);

    //Check that the added landmarkcategories can be read
    TInt nrOfCategories = lmIdArray.Count();
    for (p=0;p<nrOfCategories;p++)
        {
        CPosLandmarkCategory* lmc = iCategoryManager->ReadCategoryLC(lmIdArray[p]);
        CleanupStack::Pop(lmc);
        }

    // 7) Remove two categories and compress landmarks db
    nr = lmIdArray.Count()-1;
    id = lmIdArray[nr];
    iLog->Put(_L("Removing landmarkcategory1"));
    lmIdArray.Remove(nr);
    op=NULL;
    TRAP(err, op = iCategoryManager->RemoveCategoryL(id));
    if (err == KErrDiskFull)
        {
        ExecuteAndDeleteLD(iLandmarksDb->CompactL());
        ExecuteAndDeleteLD(iCategoryManager->RemoveCategoryL(id));
        iLog->Put(_L("KErrDiskFull when removing landmarkcategory1"));
        }

    if (err == KErrNone)
        {
        ExecuteAndDeleteLD(op);
        }
    else
        {
        delete op;
        op = NULL;
        }

    TBuf<50> buffe;
    buffe.Format(_L("1) Err after RemoveCategoryL: %d"), err);
    iLog->Put(buffe);

    nr = lmIdArray.Count()-1;
    id = lmIdArray[nr];
    iLog->Put(_L("Removing landmarkcategory2"));
    lmIdArray.Remove(nr);

    if (!aSync)
        {
        TRAP(err, op = iCategoryManager->RemoveCategoryL(id));
        if (err == KErrDiskFull)
            {
            delete op;
            op = NULL;
            iLog->Put(_L("KErrDiskFull when removing landmarkcategory2"));
            ExecuteAndDeleteLD(iLandmarksDb->CompactL());
            
            iLog->Put(_L("After compact before removing landmarkcategory2"));
            ExecuteAndDeleteLD(iCategoryManager->RemoveCategoryL(id));
            }
        else if (err == KErrNone)
            {
            ExecuteAndDeleteLD(op);
            }
        else if (err == KErrLocked)
            {
            iLog->Put(_L("KErrLocked returned from iCategoryManager->RemoveCategoryL"));
            delete op;
            op = NULL;
            }
        } 
    else
        {
        TRAP(err, op = iCategoryManager->RemoveCategoryL(id));
        if (err == KErrNone)
            {
            //***iActiveSchedulerWait->Start();
            //***delete op;
            RunAsyncOperationLD(op);
            }
        else if (err == KErrDiskFull)
            {
            delete op;
            op = NULL;
            iLog->Put(_L("KErrDiskFull when removing landmarkcategory2 async"));
            ExecuteAndDeleteLD(iLandmarksDb->CompactL());
            
            iLog->Put(_L("After compact before removing landmarkcategory2 async"));
            op = iCategoryManager->RemoveCategoryL(id);
            
            //***iActiveSchedulerWait->Start();
            //***delete op;
            RunAsyncOperationLD(op);
            }
        else if (err == KErrLocked)
            {
            delete op;
            op = NULL;
            iLog->Put(_L("KErrLocked returned from iCategoryManager->RemoveCategoryL"));
            }
        }

    buffe.Zero();
    buffe.Format(_L("2) Err after RemoveCategoryL: %d"), err);
    iLog->Put(buffe);

    iLog->Put(_L("Compacting"));
    ExecuteAndDeleteLD(iLandmarksDb->CompactL());
    iLog->Put(_L("After Compacting"));
    
    lmIdArray.Reset();
    i=0;
    err = KErrNone;

    startTime.UniversalTime();
    // 8) Add LandmarkCategories until "disk full" error occur
    while (err != KErrDiskFull)
        {
        buf.Zero();
        buf.Format(_L("LandmarkCategory %d"), i++);

        CPosLandmarkCategory* lmc = CPosLandmarkCategory::NewLC();
        lmc->SetCategoryNameL(buf);
        lmc->SetIconL(_L("PellesIcon"), 111, KPosLmIconMaskNotUsed);
        iLog->Put(buf);
        
        TRAP(err, idde = iCategoryManager->AddCategoryL(*lmc));
        if (err == KErrNone)
            {
            lmIdArray.Append(idde);
            }
        else if (err == KErrLocked)
            {
            iLog->Put(_L("KerrLocked when addCategory"));
            User::After(100000);
            }
        CleanupStack::PopAndDestroy(lmc); 
    }
    stopTime.UniversalTime();
    executionTime = stopTime.MicroSecondsFrom(startTime);

    resse = executionTime.Int64()/1000000;
    buf.Zero();
    buf.Format(_L("Added %d nr of landmarkcategories, took %d seconds"), i, resse);
    iLog->Put(buf);

    // 9) Remove all categories and compact db
    // sync method
    // XXXX add async check here
    iLog->Put(_L("Removing all categories"));
    TRAP(err, iCategoryManager->RemoveCategoriesL(lmIdArray));
    if (err == KErrDiskFull) iLog->Put(_L("KErrDiskFull when RemoveCategoriesL"));
    iLog->Put(_L("Compacting"));
    ExecuteAndDeleteLD(iLandmarksDb->CompactL());
    

    // 10) Consume more space then the limit specified in resource file
    ConsumeDiscSpace1L(iCriticalLevel - KSizeLimitOffset2);

    // 11) Try to add a landmark
    buf.Zero();
    buf.Format(_L("LandMark%d"), i++);
    landmark = CPosLandmark::NewLC();
    landmark->SetLandmarkNameL(buf);

    TRAP(err, idde = iLandmarksDb->AddLandmarkL(*landmark));
    if (err != KErrDiskFull)
        {
        buf.Zero();
        buf.Format(_L("Should leave with KErrDiskFull instead %d"), err);
        //LogErrorAndLeave(buf);
        LogErrorAndLeave(buf);
        }
    CleanupStack::PopAndDestroy(landmark);
    CleanupStack::PopAndDestroy(&lmIdArray);
    }
Пример #20
0
LOCAL_C TInt testAsyncAccess(TAny* aData)
//
/// Test read file handling.
///
/// @param aData pointer to the thread data area
    {
	TThreadData& data = *(TThreadData*)aData;
	TFileName fileName = data.iFile;
	TBool     dowrite  = (data.iData != NULL);
	TBuf8<KBufLen>* buffer = gBufferArr[data.iNum];
	TRequestStatus* status = gStatusArr[data.iNum];

	RFs   myFs;
	TInt r = myFs.Connect();
	TEST(r==KErrNone);

	r = myFs.SetSessionPath(gSessionPath);
	if (r != KErrNone)
		TTest::Fail(HERE, _L("SetSessionPath returned %d"), r);

	TVolumeInfo vol;
	TInt        drv;
	r = myFs.CharToDrive(fileName[0], drv);
	if (r != KErrNone)
		TTest::Fail(HERE, _L("CharToDrive(%c) returned %d"), fileName[0], r);
	r = myFs.Volume(vol, drv);
	if (r != KErrNone)
		TTest::Fail(HERE, _L("Volume() returned %d"), r);

	TInt64 maxwrite = vol.iFree / 2 - KBufLen;
	if (maxwrite < KBufLen*2)
		TTest::Fail(HERE, _L("Not enough space to do test, only %d KB available"),
					 TInt(vol.iFree/1024));

    RFile f;
	RTimer timer;
	TRequestStatus tstat;
	TTime startTime;
	TTime endTime;
	TTimeIntervalMicroSeconds timeTaken;

	TInt wrnum = 0;
	TInt rdnum = 0;
	TInt opnum = 0;
	TInt opfin = 0;
	TInt i;

	timer.CreateLocal();

	if (dowrite)
		{
		r = f.Replace(myFs, fileName, EFileStreamText | EFileWrite);
		TEST(r==KErrNone);

		// wait for both tasks to have a chance to complete opening the files
		User::After(1000);

		for (i = 0; i < KNumBuf; i++)
			buffer[i].Fill('_', KBufLen);

		timer.After(tstat, KTimeBM * KSecond);

		startTime.HomeTime();

		while (tstat == KRequestPending)
			{
			TInt pos = TInt((wrnum * KBufLen) % maxwrite);
			TInt bnum = opnum++ % KNumBuf;
			f.Write(pos, buffer[bnum], status[bnum]);
			if (opnum - opfin > KMaxLag)
				{
				while (status[opfin % KNumBuf] == KRequestPending)
					User::WaitForRequest(status[opfin % KNumBuf]);
				opfin++;
				}
			++wrnum;
			}

		while (opfin < opnum)
			{
			while (status[opfin % KNumBuf] == KRequestPending)
				User::WaitForRequest(status[opfin % KNumBuf]);
			opfin++;
			}

		endTime.HomeTime();
		TTimeIntervalMicroSeconds timeTaken=endTime.MicroSecondsFrom(startTime);

		TInt64 dtime = timeTaken.Int64();
		TInt64 dsize = wrnum * KBufLen * TInt64(KSecond);
		TInt32 speed = TInt32((dsize + dtime/2) / dtime);
		AddStats(gWrStats, dsize, dtime);

		TTest::Printf(_L("%8d writes in %6d mS = %8d bytes per second\n"),
					  wrnum, TInt32(dtime)/1000, speed);
		}
	else
		{
		r = f.Open(myFs, fileName, EFileStreamText);
		TEST(r==KErrNone);

		timer.After(tstat, KTimeBM * KSecond);

		startTime.HomeTime();

		while (tstat == KRequestPending)
			{
			TInt pos = TInt((rdnum * KBufLen) % maxwrite);
			TInt bnum = opnum++ % KNumBuf;
			f.Read(pos, buffer[bnum], status[bnum]);
			if (opnum - opfin > KMaxLag)
				{
				User::WaitForRequest(status[opfin++ % KNumBuf]);
				}
			++rdnum;
			}

		while (opfin < opnum)
			{
			if (status[opfin % KNumBuf] == KRequestPending)
				User::WaitForRequest(status[opfin % KNumBuf]);
			opfin++;
			}

		endTime.HomeTime();
		timeTaken=endTime.MicroSecondsFrom(startTime);
		TInt64 dtime = timeTaken.Int64();
		TInt64 dsize = rdnum * KBufLen * TInt64(KSecond);
		TInt32 speed = TInt32((dsize + dtime/2) / dtime);
		AddStats(gRdStats, dsize, dtime);

		// wait to allow the dust to settle
		User::After(KSecond);

		TTest::Printf(_L("%8d reads  in %6d mS = %8d bytes per second\n"),
					  rdnum, TInt32(dtime)/1000, speed);

		myFs.Delete(fileName);
		}

	timer.Cancel();
	timer.Close();
	f.Close();
	myFs.Close();
	return r;
    }
void CAlfPerfAppAvkonTestCaseBasic::NextAnimFrameL()
    {
    // Begin drawing
    RWindow& window = static_cast< RWindow& >( *iAvkonControl->DrawableWindow() );
    CWindowGc& gc = iAvkonControl->SystemGc();
    TRect updateRect(iAvkonControl->Rect());
    window.Invalidate( updateRect );
    window.BeginRedraw( updateRect );
    gc.Activate(window);

    // Draw background
    TRgb color (KRgbWhite);
    gc.SetBrushColor(color);
    gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
    gc.SetPenStyle(CGraphicsContext::ESolidPen);
    gc.SetPenSize(TSize(10,10));
    gc.SetPenColor(color);    
    gc.DrawRect(updateRect);  
       
    // Calc timeline
    TTime now;
    now.UniversalTime();
    TUint millisecondFromCycleStart = now.MicroSecondsFrom(iCycleStartTime).Int64() / 1000;
    double timelinePercentage = (double)millisecondFromCycleStart / KCycleDurationMs; 
    timelinePercentage *= 0.5; // scale it a bit...
   
    // Calc rect
    TRect fullRect(updateRect);
    TSize size(fullRect.Width()*(1.0 - timelinePercentage), fullRect.Height()*(1.0 - timelinePercentage));
    TPoint windowCenter = fullRect.Center();
    TPoint tl(windowCenter.iX - size.iWidth/2, windowCenter.iY - size.iHeight/2);
    TRect rect(tl, size);
        
    // Draw
    gc.SetPenColor(KRgbBlue);
    gc.SetBrushColor(KRgbRed);
    const TPoint Point1(rect.iTl);
    const TPoint Point2(rect.iBr.iX, rect.iTl.iY);
    const TPoint Point3(rect.iBr);
    const TPoint Point4(rect.iTl.iX, rect.iBr.iY);
    const TPoint center(rect.Center());

    switch (iCycleCounter)
        {
        case 1: // DrawEllipse
            {
            gc.DrawEllipse(rect);   
            break;
            }
        case 2: // DrawRect
            {
            gc.DrawRect(rect);    
            break;
            }
        case 3: // DrawRoundRect
            {
            TSize corner(rect.Width()/5, rect.Height()/5);
            gc.DrawRoundRect(rect, corner);   
            break;
            }
        case 4: // Draw lines
            {
            gc.SetPenColor(TRgb(255,0,0));
            gc.DrawLine(Point1, Point2);       
            
            gc.SetPenColor(TRgb(200,50,0));
            gc.DrawLineTo(Point3);
            
            gc.SetPenColor(TRgb(150,100,0));
            gc.DrawLineTo(Point4);
            
            gc.SetPenColor(TRgb(100,150,0));
            gc.DrawLineBy(TPoint(0, -rect.Height()));
            
            gc.SetPenColor(TRgb(50,200,0));
            gc.MoveTo(Point2);
            gc.DrawLineTo(Point4);
                       
            gc.SetPenColor(TRgb(0,255,0));
            gc.MoveBy(TPoint(0, -rect.Height()));
            gc.DrawLineTo(Point3);
            
            gc.SetPenColor(TRgb(255,0,0));
            gc.Plot(center);
            
            break;
           }
            
        case 5: // Draw 
            {
            gc.SetPenColor(TRgb(255,0,0));
            gc.DrawArc(rect, Point2, Point1);
            gc.DrawPie(rect, Point4, Point3);
            break;
            }
            
        case 6: // Draw polygons
            {
            const TInt KNumPoints = 9;
            TPoint pointList[KNumPoints];
            pointList[0] = TPoint(Point1.iX+rect.Width()*0.25, Point1.iY);
            pointList[1] = TPoint(Point1.iX+rect.Width()*0.75, Point1.iY);
            pointList[2] = TPoint(Point2.iX, Point2.iY+rect.Height()*0.25);
            pointList[3] = TPoint(Point2.iX, Point2.iY+rect.Height()*0.75);
            pointList[4] = TPoint(Point3.iX-rect.Width()*0.25, Point3.iY);
            pointList[5] = TPoint(Point3.iX-rect.Width()*0.75, Point3.iY);
            pointList[6] = TPoint(Point4.iX, Point4.iY-rect.Height()*0.25);
            pointList[7] = TPoint(Point4.iX, Point4.iY-rect.Height()*0.75);
            pointList[8] = TPoint(Point1.iX+rect.Width()*0.25, Point1.iY);
            
            CArrayFix<TPoint>* mypoints = new CArrayFixFlat<TPoint>(KNumPoints);
            CleanupStack::PushL(mypoints);
            for(TInt i=0; i<KNumPoints; i++)
                {
                mypoints->AppendL(pointList[i]);
                }

            gc.SetPenColor(TRgb(255,0,0));
            gc.SetPenSize(TSize(20,20));
            gc.DrawPolyLine(mypoints);
            
            gc.SetPenColor(TRgb(0,255,0));
            gc.SetPenSize(TSize(15,15));
            gc.DrawPolyLine(pointList, KNumPoints);
            
            gc.SetPenColor(TRgb(255,255,0));
            gc.SetPenSize(TSize(10,10));
            gc.DrawPolygon(mypoints);
            
            gc.SetPenColor(TRgb(0,0,255));
            gc.SetPenSize(TSize(5,5));
            gc.DrawPolygon(pointList, KNumPoints);
            
            CleanupStack::PopAndDestroy(); // mypoints           
            break;
            }
            
        case 7: // Draw texts
            {
            gc.UseFont(iFont);
            gc.SetDrawMode(CGraphicsContext::EDrawModePEN);
            gc.SetPenStyle(CGraphicsContext::ESolidPen);
            gc.SetBrushStyle(CGraphicsContext::ESolidBrush);    
            
            TInt h = rect.Height() / 3;
            TInt y = rect.iTl.iY;
            TRect tinyBox(rect);
            tinyBox.SetHeight(h);
            TInt fontDescent=iFont->DescentInPixels();
            gc.SetBrushColor(TRgb(0, 0, 255)); // blue
            
            gc.SetPenColor(TRgb(0,255,0)); // green
            gc.DrawText(_L("Ilves"), tinyBox.iTl+TPoint(0, fontDescent));
            
            tinyBox.Move(0,h);
            TInt posY = tinyBox.Height()-fontDescent;
            gc.SetPenColor(TRgb(255,0,0)); 
            gc.DrawText(_L("Tappara"), tinyBox, posY);
            
            gc.SetPenColor(TRgb(0,255,0)); // green
            gc.DrawTextVertical(_L("Ilves"), tinyBox.iTl+TPoint(fontDescent, 0 ), ETrue);
            
            tinyBox.Move(0,h);
            posY = tinyBox.Height()-fontDescent;
            gc.SetPenColor(TRgb(255,0,0)); 
            gc.DrawTextVertical(_L("Tappara"), tinyBox, posY, ETrue);
            
            break;
            }

        case 8: // Draw bitmaps
            {
            TPoint pos(rect.iTl);
            gc.BitBlt(pos, iPictureBm);
            
            pos = TPoint(rect.iTl.iX + rect.Width()/3, rect.iTl.iY);
            gc.BitBlt(pos, iPictureBm, TRect(iPictureBm->SizeInPixels()));

            pos = TPoint(rect.iTl.iX + rect.Width()*2/3, rect.iTl.iY);
            gc.BitBltMasked(pos, iPictureBm, TRect(iPictureBm->SizeInPixels()), iMaskBm, EFalse);

            pos = TPoint(rect.iTl.iX, rect.iTl.iY+ rect.Height()/3);
            TRect dstRect(pos, TSize(rect.Width()/3, rect.Height()/3));
            gc.DrawBitmap(dstRect, iPictureBm, TRect(iPictureBm->SizeInPixels()));

            pos = TPoint(rect.iTl.iX + rect.Width()/3, rect.iTl.iY+ rect.Height()/3);
            dstRect =  TRect(pos, dstRect.Size());
            gc.DrawBitmap(dstRect, iPictureBm);

            pos = TPoint(rect.iTl.iX, rect.iTl.iY+ rect.Height()*2/3);
            gc.DrawBitmap(pos, iPictureBm);

            pos = TPoint(rect.iTl.iX + rect.Width()/3, rect.iTl.iY+ rect.Height()*2/3);
            dstRect =  TRect(pos, dstRect.Size());
            gc.DrawBitmapMasked(dstRect, iPictureBm, TRect(iPictureBm->SizeInPixels()), iMaskBm, EFalse);

            break;
            }
            
         case 9: // Miscellanious
            {
            TRect rect1(rect);
            rect1.SetWidth(rect.Width()/2);
            rect1.SetHeight(rect.Height()/2);
            TRect rect2(rect1);
            rect2.Move(rect1.Width(),0);
            TRect rect3(rect1);
            rect3.Move(0, rect1.Height());
            TRect rect4(rect1);
            rect4.Move(rect1.Width(), rect1.Height());
            
            // Clear
            gc.Clear();
            // Brush pattern
            gc.UseBrushPattern(iPictureBm);
            gc.SetBrushStyle(CGraphicsContext::EPatternedBrush);
            gc.DrawRect(rect1);
            gc.DiscardBrushPattern();
            // Fading & copy rect
            gc.SetFaded(ETrue);
            gc.CopyRect(rect2.iTl, rect1);
            gc.SetFadingParameters(255,0);
            gc.CopyRect(rect3.iTl, rect1);
            // Map colors  
            gc.SetPenColor(KRgbBlue);
            gc.SetBrushColor(KRgbRed);
            gc.DrawRect(rect4);   
            TRgb colors[2] = {KRgbRed, KRgbGreen}; // change brush color
            gc.MapColors(rect4,colors,1,ETrue);
             
            break;
            }
            
     default:
           gc.DrawRect(rect);          
       }

    // End drawing
    gc.Deactivate();
    window.EndRedraw();
 
    iTestCaseFrameCount++;
    }
Пример #22
0
LOCAL_C TInt testAsyncAccess(TChar dc1, TChar dc2)
//
// Test one drive against the other.
//
    {
	TFileOps f1;
	TFileOps f2;

	f1.Open(dc1, 1);
	if (dc1 != dc2)
		f2.Open(dc2, 2);

	TInt   op1 = 0;
	TInt   op2 = 0;
	RTimer timer;
	TRequestStatus tstat;
	TTime startTime;
	TTime endTime;
	TTimeIntervalMicroSeconds timeTaken;

	timer.CreateLocal();

	timer.After(tstat, KTimeBM * KSecond);

	startTime.HomeTime();

	while (tstat == KRequestPending)
		{
		TInt num = f1.Write();
		num += f2.Write();
		if (num == 0)
			User::WaitForAnyRequest();
		}

	op1 = f1.End();
	op2 = f2.End();

	endTime.HomeTime();
	timeTaken=endTime.MicroSecondsFrom(startTime);

	TInt64 dtime = timeTaken.Int64();

	TTest::Printf(_L("%c: %8d writes in %6d mS = %8d bytes per second\n"),
				  (TUint)dc1, op1, I64LOW(dtime)/1000, GetSpeed(op1, dtime));

	if (dc1 != dc2)
		TTest::Printf(_L("%c: %8d writes in %6d mS = %8d bytes per second\n"),
					  (TUint)dc2, op2, I64LOW(dtime)/1000, GetSpeed(op2, dtime));

	AddStats(gWrStats, MAKE_TINT64(0, op1 + op2) * MAKE_TINT64(0, KBufLen) * MAKE_TINT64(0, KSecond), dtime);

	// now the reads!

	f1.Reset();
	f2.Reset();

	timer.After(tstat, KTimeBM * KSecond);

	startTime.HomeTime();

	while (tstat == KRequestPending)
		{
		f1.Read();
		f2.Read();
		User::WaitForAnyRequest();
		}

	op1 = f1.End();
	op2 = f2.End();

	endTime.HomeTime();
	timeTaken=endTime.MicroSecondsFrom(startTime);

	dtime = timeTaken.Int64();

	TTest::Printf(_L("%c: %8d reads  in %6d mS = %8d bytes per second\n"),
				  (TUint)dc1, op1, I64LOW(dtime)/1000, GetSpeed(op1, dtime));

	if (dc1 != dc2)
		TTest::Printf(_L("%c: %8d reads  in %6d mS = %8d bytes per second\n"),
					  (TUint)dc2, op2, I64LOW(dtime)/1000, GetSpeed(op2, dtime));

	AddStats(gRdStats, MAKE_TINT64(0, op1 + op2) * MAKE_TINT64(0, KBufLen) * MAKE_TINT64(0, KSecond), dtime);

	test.Printf(_L("\n"));
	test.Printf(_L("average write throughput = %d bytes/sec\n"), GetSpeed(gWrStats));
	test.Printf(_L("average read  throughput = %d bytes/sec\n"), GetSpeed(gRdStats));
	test.Printf(_L("\n"));
	gWrStats.Init();
	gRdStats.Init();

	timer.Cancel();
	timer.Close();
	f1.Close();
	f2.Close();
	// delay for a second to allow the close to complete before dismounting.
	User::After(1000000);
	return KErrNone;
    }
Пример #23
0
// ---------------------------------------------------------------------------
// TEST CASE: Change system time while tick timer is active
// ---------------------------------------------------------------------------
//
TInt CTestRFlexTimer::ChangeTimeWhileAfterTicksL(
    TTestResult& aResult, 
    CTestFlexTimer* /* aCallback */ )
    {
    const TTimeIntervalMicroSeconds32 KTimerInterval( 10000000 );   // Time to wait timer
    const TTimeIntervalMicroSeconds KWaitTillChangeTime( 1000000 ); // Time to wait before change system time
    const TTimeIntervalMicroSeconds KTimeChange( 3000000 );         // Duration to change system time

    // Interval for check results
    const TTimeIntervalMicroSeconds KInterval( KTimerInterval.Int() + KTimeChange.Int64() );
    const TTimeIntervalMicroSeconds KWindow( 0 );                   // Window for check results
    const TTimeIntervalMicroSeconds32 KOneTick( 1000000 / 64 );     // System tick: 1/64 sec

    // Initialize case
    aResult.SetResult( KErrGeneral, _L("Test case leaved") );

    TTime startTime;
    startTime.UniversalTime();
    TRequestStatus status, helperStatus;
    
    // Do the actual test
    //-----------------------------------------------------

    RFlexTimer timer;
    User::LeaveIfError( timer.Connect() );
    
    timer.AfterTicks( status, KTimerInterval.Int() / KOneTick.Int() );

    //-----------------------------------------------------
    // ... meanwhile change system time

        RFlexTimer helper;
        
        User::LeaveIfError( helper.Connect() );
        helper.After( helperStatus, KWaitTillChangeTime );
    
                                               //    //  ___     _____
        User::WaitForRequest( helperStatus ); // // // //_ // //  //
                                             //_//_// //  // //  //
        
        TTime newNow;
        newNow.UniversalTime();
        newNow += KTimeChange;
        
        User::SetUTCTime( newNow );
    
        helper.Close();

    // The test continues...
    //-----------------------------------------------------
    
                                     //    //  ___     _____
    User::WaitForRequest( status ); // // // //_ // //  //
                                   //_//_// //  // //  //

    timer.Close();

    //-----------------------------------------------------

    // Verify the test
    TTime endTime;
    endTime.UniversalTime();

    aResult.SetResult( KErrNone, _L("Test case passed") );
    if ( !IsDelayOk( endTime.MicroSecondsFrom( startTime ), KInterval, KWindow ) )
        {
        //RDebug::Print( _L("Timer delay: %lld"), 
        //               endTime.MicroSecondsFrom( startTime ).Int64() );
        aResult.SetResult( KErrGeneral, _L("Test case failed. Wrong expiration.") );
        }
    
    __UHEAP_MARKEND;

    return KErrNone;
    }
Пример #24
0
/** Time the creation of a directory inside each type of directory with multiple threads ongoing

	@param aN Number of files in the directory
	@param aStep 	Test step
*/
LOCAL_C void MakeDirM(TInt aN, TInt aStep) 
	{
	TBuf16<100> dir1;
	TBuf16<100> dir2;
	TBuf16<100> dir3;
    TBuf16<100> dir4;
	
	TInt r = 0;
	TTime startTime;
	TTime endTime;
	TTimeIntervalMicroSeconds timeTaken(0);
	TInt timeTaken1 = -1, timeTaken2 = -1, timeTaken3 = -1; 
	
	if(aN <= gFilesLimit) 
		{
		dir1 = gSessionPath;
		dir2 = gSessionPath;
		dir3 = gSessionPath;
		
		dir4.Format(KDirMultipleName2, 1, aN);
		dir1.Append(dir4);
		dir4.Format(KDirMultipleName2, 2, aN);
		dir2.Append(dir4);	
		dir4.Format(KDirMultipleName2, 3, aN);
		dir3.Append(dir4);
		
		if(gTypes >= 1) 
			{
			gDelEntryDir = dir1;
			gDelEntryDir2 = dir1;
			
			dir1.Append(KNewDir);
			DoTest2(DeleteEntryAccess);
			
			startTime.HomeTime();
			
			r = TheFs.MkDir(dir1);
			FailIfError(r);
			
			endTime.HomeTime();
			
			DoTestKill();
			
			timeTaken = endTime.MicroSecondsFrom(startTime);
			timeTaken1 = I64LOW(timeTaken.Int64() / gTimeUnit);
			
			TheFs.RmDir(dir1);
			}
		
		if(gTypes >= 2) 
			{
			gDelEntryDir = dir2;
			gDelEntryDir2 = dir2;
			dir2.Append(KNewDir);
			
			DoTest2(DeleteEntryAccess);

			startTime.HomeTime();

			r = TheFs.MkDir(dir2);
			FailIfError(r);
			
			endTime.HomeTime();
			DoTestKill();

			timeTaken = endTime.MicroSecondsFrom(startTime);
			timeTaken2 = I64LOW(timeTaken.Int64() / gTimeUnit);
			
			TheFs.RmDir(dir2);
			}
		
		if(gTypes >= 3) 
			{
			gDelEntryDir = dir3;
			gDelEntryDir2 = dir3;
			dir3.Append(KNewDir);
			DoTest2(DeleteEntryAccess);

			startTime.HomeTime();

			r = TheFs.MkDir(dir3);
			FailIfError(r);
			
			endTime.HomeTime();
			DoTestKill();

			timeTaken = endTime.MicroSecondsFrom(startTime);
			timeTaken3 = I64LOW(timeTaken.Int64() / gTimeUnit);
			
			TheFs.RmDir(dir3);
			}
		}
	
	PrintResult(aStep, 1, aN);
	PrintResultTime(aStep, 2, timeTaken1);
	PrintResultTime(aStep, 3, timeTaken2);
	PrintResultTime(aStep, 4, timeTaken3);

	}
TVerdict CT_LbsHybridUEAssistedMOLRNoGPSUpdate::doTestStepL()
	{
	INFO_PRINTF1(_L("CT_LbsHybridUEAssistedMOLRNoGPSUpdate::doTestStepL()"));	
	// Stop the test if the preable failed
	TESTL(TestStepResult() == EPass);

	const TInt KTimeOut = 60*1000*1000;

	// Create Network Protocol Proxy
	CNetProtocolProxy* proxy = CNetProtocolProxy::NewL();
	CleanupStack::PushL(proxy);

	// waiting for >> AdviceSystemStatus(0) - GetCurrentCapabilitiesResponse
	INFO_PRINTF1(_L("waiting for << NotifyPositionUpdate()"));
	TESTL(proxy->WaitForResponse(KTimeOut) == ENetMsgGetCurrentCapabilitiesResponse);
	CLbsNetworkProtocolBase::TLbsSystemStatus status;
	proxy->GetArgsLC(ENetMsgGetCurrentCapabilitiesResponse, &status);
	TESTL(status == CLbsNetworkProtocolBase::ESystemStatusNone);
	//  >> AdviceSystemStatus(0) - GetCurrentCapabilitiesResponse
	INFO_PRINTF1(_L("<< NotifyPositionUpdate()"));


	// Start Test Step
	RPositionServer server;
	TESTL(KErrNone == server.Connect());
	CleanupClosePushL(server);	
	INFO_PRINTF1(_L("Connected to server"));

	RPositioner pos;
	TESTL(KErrNone == pos.Open(server));
	CleanupClosePushL(pos);
	INFO_PRINTF1(_L("Subsession created"));


	// Set the max fix time for the client request to ensure the location server does not complete the request too soon during the test.
	// after 30 secs the postion request will be timed out
	TPositionUpdateOptions posOpts(TTimeIntervalMicroSeconds(0), TTimeIntervalMicroSeconds(30* 1000 * 1000));

	pos.SetUpdateOptions(posOpts);
	
	INFO_PRINTF1(_L("Setupdate options timeout set to 30 seconds"));

	CPosServerWatcher *pWatch = CPosServerWatcher::NewLC(pos, *this);

	// Request a self-locate MoLr.
	pWatch->IssueNotifyPositionUpdate();
	INFO_PRINTF1(_L("<< NotifyPositionUpdate()"));
	// >> RequestSelfLocation()
	TESTL(proxy->WaitForResponse(KTimeOut) == ENetMsgRequestSelfLocation);
	INFO_PRINTF1(_L(">> RequestSelfLocation()"));	

	// Process the response.
	TLbsNetSessionId* 					sessionId = NULL;
	TLbsNetPosRequestOptionsAssistance*	opts = NULL;
	TInt								cleanupCnt;
	
	cleanupCnt = proxy->GetArgsLC(ENetMsgRequestSelfLocation, &sessionId, &opts);
	
	iSessionId.SetSessionNum(sessionId->SessionNum());
	iSessionId.SetSessionOwner(sessionId->SessionOwner());

	CleanupStack::PopAndDestroy(cleanupCnt);
	sessionId = NULL;
	opts = NULL;	
	
	// << ProcessStatusUpdate(EServiceSelfLocation)
	MLbsNetworkProtocolObserver::TLbsNetProtocolServiceMask activeServiceMask = MLbsNetworkProtocolObserver::EServiceSelfLocation;
	proxy->CallL(ENetMsgProcessStatusUpdate, &activeServiceMask);

	// << ProcessLocationUpdate(SessionId, RefPosition)
	TPositionInfo refPosInfo = ArgUtils::MolrReferencePositionInfo();
	proxy->CallL(ENetMsgProcessLocationUpdate, &iSessionId, &refPosInfo);
	INFO_PRINTF1(_L("<< ProcessLocationUpdate(SessionId, RefPosition)"));	


	// TEST: Get the ref pos app side.
	CheckForObserverEventTestsL(KTimeOut, *this);

	// << ProcessAssistanceData()
	TLbsAsistanceDataGroup dataMask = EAssistanceDataReferenceTime;
	RLbsAssistanceDataBuilderSet assistanceData;
	ArgUtils::PopulateLC(assistanceData);
	TInt reason = KErrNone;
	proxy->CallL(ENetMsgProcessAssistanceData, &dataMask, &assistanceData, &reason);
	CleanupStack::PopAndDestroy(); // assistanceData
	INFO_PRINTF1(_L("<< ProcessAssistanceData()"));	


	// << ProcessLocationRequest(SessionId, HybridMode, alpha2)
	TBool emergency = EFalse;
	MLbsNetworkProtocolObserver::TLbsNetProtocolService service = MLbsNetworkProtocolObserver::EServiceSelfLocation;
	TLbsNetPosRequestQuality quality = ArgUtils::Quality(); 
	quality.SetMaxFixTime(ArgUtils::Alpha2());
	TLbsNetPosRequestMethod method   = ArgUtils::RequestHybridMethod();
	proxy->CallL(ENetMsgProcessLocationRequest, &iSessionId, &emergency, &service, &quality, &method);
	INFO_PRINTF1(_L("<< ProcessLocationRequest(SessionId, HybridMode, alpha2)"));	

	// Now that the hybrid/alpha2 has been requested, record current time to verify alpha2 timer expires correctly.
	TTime startTime;
	startTime.HomeTime();

	// >> RequestAssistanceData(0)
	TESTL(proxy->WaitForResponse(KTimeOut) == ENetMsgRequestAssistanceData); 
	INFO_PRINTF1(_L(">> RequestAssistanceData(0)"));	

	CleanupStack::PopAndDestroy(proxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataMask));
	TESTL(dataMask == EAssistanceDataNone);

	// << NotifyPositionUpdate()
	pWatch->IssueNotifyPositionUpdate();
	INFO_PRINTF1(_L("<< NotifyPositionUpdate()"));	

	// >> RequestAssistanceData(0)
	TESTL(proxy->WaitForResponse(KTimeOut) == ENetMsgRequestAssistanceData); 
	CleanupStack::PopAndDestroy(proxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataMask));
	TESTL(dataMask == EAssistanceDataNone);
	INFO_PRINTF1(_L(">> RequestAssistanceData(0)"));	


	// Determine the value to take off the alpha2 value. This is required because we had to wait for the assistance data response.
	TTimeIntervalMicroSeconds microseconds;
	TTime stopTime;
	stopTime.HomeTime();
	microseconds = stopTime.MicroSecondsFrom(startTime); 
	TInt64 timeElapsed = microseconds.Int64();
	TInt delta = 2 * 1000 * 1000; // 2 secs.

	// >> RespondLocationRequest()
	TESTL(proxy->WaitForResponse(ArgUtils::Alpha2() - timeElapsed - delta) == ENetMsgTimeoutExpired);
	INFO_PRINTF1(_L(">> RespondLocationRequest()"));	

	// Wait for and process the response.
	TESTL(proxy->WaitForResponse(2 * delta) == ENetMsgRespondLocationRequest);
	INFO_PRINTF1(_L("Wait for and process the response"));	

	sessionId = NULL;
	TPositionGpsMeasurementInfo* measurementInfo = NULL;
	cleanupCnt = proxy->GetArgsLC(ENetMsgRespondLocationRequest, &sessionId, &reason, &measurementInfo);
	TESTL(sessionId->SessionNum() == iSessionId.SessionNum());
	TESTL(reason == KErrNone);
	CleanupStack::PopAndDestroy(cleanupCnt); //sessionId, measurementInfo

	// Recv -> RequestAssistanceData - we get an extra msg as the result of the A-GPS manager re-issueing a location request when it's
	//									max fix time timer expries.
	INFO_PRINTF1(_L("Wait for ENetMsgRequestAssistanceData"));	

	TESTL(proxy->WaitForResponse(KTimeOut) == ENetMsgRequestAssistanceData); 
	INFO_PRINTF1(_L("Got ENetMsgRequestAssistanceData"));	

	proxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataMask);
	TESTL(dataMask == EAssistanceDataNone);

	const TInt t = 4 * 1000 * 1000; // 4 secs, hybrid A-GPS module will deliver update after 6 + 1 seconds.
	quality.SetMaxFixTime(t);

	// << ProcessLocationRequest(SessionId, HybridMode, t)
	proxy->CallL(ENetMsgProcessLocationRequest, &iSessionId, &emergency, &service, &quality, &method);
	INFO_PRINTF1(_L("<< ProcessLocationRequest(SessionId, HybridMode, t)"));	

	// >> RequestAssistanceData(0)
	INFO_PRINTF1(_L("Wait for >> RequestAssistanceData(0) again"));	

	TESTL(proxy->WaitForResponse(KTimeOut) == ENetMsgRequestAssistanceData); 
	INFO_PRINTF1(_L(">> RequestAssistanceData(0)"));	

	proxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataMask);
	TESTL(dataMask == EAssistanceDataNone);

	// >> RespondLocationRequest().
	TESTL(proxy->WaitForResponse(t + delta) == ENetMsgRespondLocationRequest);
	INFO_PRINTF1(_L(">> RespondLocationRequest()"));	

	// Process response. Note measurement data is un-defined (and not verified) when reason contains
	// an error, which is expected here.
	sessionId = NULL;
	measurementInfo = NULL;
	cleanupCnt = proxy->GetArgsLC(ENetMsgRespondLocationRequest, &sessionId, &reason, &measurementInfo);			
	TESTL(sessionId->SessionNum() == iSessionId.SessionNum());
	TESTL(reason == KErrPositionNoGpsUpdate);
	CleanupStack::PopAndDestroy(cleanupCnt);// sessionId, measurementInfo/positionInfo
	
	// >> RequestAssistanceData - we get an extra msg as the result of the A-GPS manager re-issueing a location request when it's
	//									max fix time timer expries.
	TESTL(proxy->WaitForResponse(KTimeOut) == ENetMsgRequestAssistanceData);
	INFO_PRINTF1(_L(">>> RequestAssistanceData"));	

	proxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataMask);
	TESTL(dataMask == EAssistanceDataNone);
		
	// << ProcessSessionComplete(SessionId, KErrNone)	
	reason = KErrNone;
	proxy->CallL(ENetMsgProcessSessionComplete, &iSessionId, &reason);
	INFO_PRINTF1(_L("<< ProcessSessionComplete(SessionId, KErrNone)"));	


	// << ENetMsgProcessStatusUpdate()
	MLbsNetworkProtocolObserver::TLbsNetProtocolServiceMask serviceMask = MLbsNetworkProtocolObserver::EServiceNone;
	proxy->CallL(ENetMsgProcessStatusUpdate, &serviceMask);
	INFO_PRINTF1(_L("<< ENetMsgProcessStatusUpdate()"));	

	
	// Wait for the LBS responses due to the Session Complete. NPUD still outstanding so resend 
	// requests for SelfLocation and we may also get a request for Assistance Data. This is timing 
	// related since the PM's SessionComplete is sent to the AGPS Manager and the NRH, and the NRH
	// then sends a cancel message to the AGPS manager.  These events trigger active objects and
	// both AOs will make a RequestLocationUpdate call to the Int. Module.  Another AO in the Int.
	// module will respond with an assistance data request.  However, depending on timing, the 2nd
	// call to RequestLocationUpdate may cancel the AO set off by the 1st call.  Thus we may get 1
	// (most likely) or 2 assistance data requests.  These will result in a SelfLocation request 
	// always being sent to the PM but sometimes the PM may get a request for Assistance Data.
		
	// Some time later (imperically < 20 secs but could be worked out by going through the test code)
	// the NPUD maxFixTime timer will fire which will cause the SelfLocation request to be cancelled.
	
	// Sometimes it can happen that the session complete arrives quickly enough and no 
	// further response is given by LBS. This was seen in SMP.
		
		TInt selfLocationCount = 0;
		TInt assistanceDataCount = 0;
		TInt cancelCount = 0;
		TInt othersCount = 0;
		TBool noResponse(EFalse);
		TNetProtocolResponseType response = ENetMsgNullResponse;
		
		while ((cancelCount == 0) && (othersCount == 0) && !noResponse)
			{
			response = proxy->WaitForResponse(20*1000*1000);  // wait for a max of 20secs
			switch (response)
				{
				case ENetMsgTimeoutExpired:
					{
					noResponse = ETrue;
					INFO_PRINTF1(_L(">> No further response was received"));
					break;
					}
				case ENetMsgCancelSelfLocation:
					{
					cancelCount++;
					INFO_PRINTF1(_L(">> Wait for CancelSelfLocation"));	
					break;
					}
				case ENetMsgRequestSelfLocation:
					{
					selfLocationCount++;
					INFO_PRINTF1(_L(">> Wait for RequestSelfLocation"));	
					break;
					}
				case ENetMsgRequestAssistanceData:
					{
					assistanceDataCount++;
					INFO_PRINTF1(_L(">> Wait for RequestAssistanceData"));	
					break;
					}
				default:
					{
					othersCount++;
					INFO_PRINTF2(_L(">> Unexpected message %d"), response);	
					break;
					}
				}
			}
		if(!noResponse)
			{ // these tests should be done only if there was a response received
			TESTL(othersCount == 0);
			TESTL(selfLocationCount == 1);
			TESTL(cancelCount == 1);
			}
		
	CheckForObserverEventTestsL(KTimeOut, *this);

	// Listen for 10 seconds that there are note further messages
    TESTL(proxy->WaitForResponse(10*1000*1000) == ENetMsgTimeoutExpired);

	// Done. Now cleanup...
	CleanupStack::PopAndDestroy(pWatch);
	CleanupStack::PopAndDestroy(); // pos
	CleanupStack::PopAndDestroy(); // server	
	CleanupStack::PopAndDestroy(proxy);

	INFO_PRINTF1(_L("All DONE!"));	
	
	return TestStepResult();
	
	
	}
// -----------------------------------------------------------------------------
// COMASuplFallBackHandler::GetNextSLPAddressL
// -----------------------------------------------------------------------------
//    TODO: Merge if conditions...
TInt COMASuplFallBackHandler::GetNextSLPAddressL(TInt64& aSLPId, TDes& aHslpToBeUsedAddress,TDes& aIAPName,TBool& aTls,
        TBool& aPskTls,TInt aLastErrorCode,TBool& aIsIapDialogShown)
{
    iTrace->Trace(_L("COMASuplFallBackHandler::GetNextSLPAddressL"),KTraceFileName, __LINE__);

    _LIT(KFormatTxt,"%/0%1%/1%2%/2%3%/3 %-B%:0%J%:1%T%:2%S%:3%+B");

    TBuf<256> LogBuffer;

    if( aLastErrorCode != KErrNone)// If its KErrNone then its means server name is asked first time and no need for Tls failure check
    {

        if( CheckErrorCodeL(aLastErrorCode) )
        {

            if( iTLSAuthenticationFailed )
            {
                if(iErrorCode == KErrNone)
                {
                    aHslpToBeUsedAddress.Copy(iGenratedHslpAddress);
                    aIAPName.Zero();
                    aIAPName.Copy(iDefaultIAPName);
                    aTls = ETrue;
                    aPskTls = EFalse;
                    aIsIapDialogShown = ETrue;

                    CServerParams* param = CServerParams::NewL();
                    CleanupStack::PushL(param);

                    //Find out if this alternative generated SUPL server is in the SUPL Settings list
                    TInt err = iSuplSettings.GetSlpInfoAddress(iGenratedHslpAddress, param);
                    if(err == KErrNotFound)
                    {
                        //Server does not exist
                        iTrace->Trace(_L("Server does not exist in list so adding it in."),KTraceFileName, __LINE__);
                        CServerParams* newParam=CServerParams::NewL();
                        CleanupStack::PushL(newParam);
                        User::LeaveIfError(newParam->Set( iGenratedHslpAddress,iDefaultIAPName,ETrue,ETrue,ETrue,EFalse ));

                        err = iSuplSettings.AddNewServer( newParam, aSLPId ); //Ignore error
                        LogBuffer.Copy(_L("AddNewServer() completed with err: "));
                        LogBuffer.AppendNum(err);
                        iTrace->Trace(LogBuffer,KTraceFileName, __LINE__);

                        CleanupStack::PopAndDestroy(newParam);
                    }
                    else
                    {
                        //Server exists, get the SLP ID and the IAP Access point for this server
                        HBufC* hslpAddress =  HBufC::NewL(KHSLPAddressLength);
                        HBufC* iapName =  HBufC::NewL(KMaxIapNameLength);
                        TBool serverEnabled;
                        TBool simChangeRemove;
                        TBool usageInHomeNw;
                        TBool editable;

                        iTrace->Trace(_L("Server already exists, getting the SLP ID and Access Point."),KTraceFileName, __LINE__);

                        param->Get(aSLPId,hslpAddress->Des(),iapName->Des(),serverEnabled,simChangeRemove,usageInHomeNw,editable);
                        aIAPName.Copy(iapName->Des());

                        delete hslpAddress;
                        delete iapName;
                    }

                    CleanupStack::PopAndDestroy(param);

                    iTrace->Trace(_L("Fallback allowed & TLSAuth failed"),KTraceFileName, __LINE__);
                    iTrace->Trace(_L("Server being used:"),KTraceFileName, __LINE__);
                    LogBuffer.Copy(aHslpToBeUsedAddress);
                    iTrace->Trace(LogBuffer,KTraceFileName, __LINE__);

                    iTrace->Trace(_L("iap being used:"),KTraceFileName, __LINE__);
                    LogBuffer.Copy(aIAPName);
                    iTrace->Trace(LogBuffer,KTraceFileName, __LINE__);

                    iTrace->Trace(_L("iap dlg configuration:"),KTraceFileName, __LINE__);
                    LogBuffer.Delete(0,256);
                    LogBuffer.AppendNum(aIsIapDialogShown);
                    iTrace->Trace(LogBuffer,KTraceFileName, __LINE__);
                    return KErrNone;
                }
                else
                {
                    return KErrArgument;
                }
            }
        }

        else
        {
            return KErrNotFound;
        }
    }

    //Check to see if the server list is empty.  If it is create the HSLP Address from the IMSI and use that
    // as the server address.  This does not add the server to the list and this functionality should only
    // be tried once
    if(iSLPList->Count() <= 0 && (!iAttemptedBackupServer))
    {
        iTrace->Trace(_L("Going to create and use alternative HSLP Address from IMSI"),KTraceFileName, __LINE__);

        iAttemptedBackupServer = ETrue;

        //Generate the HSLP Address
        GenerateHslpAddressFromIMSIL();

        //Copy the generated address into the supplied function arguments
        aHslpToBeUsedAddress.Copy(iGenratedHslpAddress);
        aIAPName.Zero();
        aIAPName.Copy(iDefaultIAPName);
        aTls = ETrue;
        aPskTls = EFalse;
        aIsIapDialogShown = ETrue;

        iTrace->Trace(_L("Server being used:"),KTraceFileName, __LINE__);
        LogBuffer.Copy(aHslpToBeUsedAddress);
        iTrace->Trace(LogBuffer,KTraceFileName, __LINE__);

        iTrace->Trace(_L("iap being used:"),KTraceFileName, __LINE__);
        LogBuffer.Copy(aIAPName);
        iTrace->Trace(LogBuffer,KTraceFileName, __LINE__);

        //Add the server to the list for future connections
        CServerParams* param=CServerParams::NewL();
        CleanupStack::PushL(param);
        User::LeaveIfError(param->Set( iGenratedHslpAddress,iDefaultIAPName,ETrue,ETrue,ETrue,EFalse ));

        TInt err = iSuplSettings.AddNewServer( param, aSLPId ); //Ignore error
        LogBuffer.Copy(_L("AddNewServer() completed with err: "));
        LogBuffer.AppendNum(err);
        iTrace->Trace(LogBuffer,KTraceFileName, __LINE__);

        CleanupStack::PopAndDestroy(&param);

        return KErrNone;
    }

    if( iSLPList->Count() <= 0 || iCurrentServerCounter >= iSLPList->Count() )
    {
        LogBuffer.Copy(_L("No more servers available..."));
        iTrace->Trace(LogBuffer,KTraceFileName, __LINE__);
        return KErrNotFound;
    }

    iTrace->Trace(_L("Trying next server..."),KTraceFileName, __LINE__);

    //Fallback Timer...
    if(aLastErrorCode == KErrNone) //This means, server name is asked for first time only...
    {
        iTrace->Trace(_L("Start Time: "),KTraceFileName, __LINE__);
        iFallBackStartTime.HomeTime();
        LogBuffer.Zero();
        iFallBackStartTime.FormatL(LogBuffer,KFormatTxt);
        iTrace->Trace(LogBuffer,KTraceFileName, __LINE__);
    }
    else
    {
        TTime currentTime;
        currentTime.HomeTime();
        TTimeIntervalMicroSeconds diff = currentTime.MicroSecondsFrom(iFallBackStartTime);


        iTrace->Trace(_L("Current Time: "),KTraceFileName, __LINE__);
        LogBuffer.Zero();
        currentTime.FormatL(LogBuffer,KFormatTxt);
        iTrace->Trace(LogBuffer,KTraceFileName, __LINE__);

        LogBuffer.Copy(_L("Difference between time: "));
        LogBuffer.AppendNum(diff.Int64());
        iTrace->Trace(LogBuffer,KTraceFileName, __LINE__);

        if( diff.Int64() > iAllowedFallBackTimerValue)
        {
            LogBuffer.Copy(_L("Timeout happened..."));
            iTrace->Trace(LogBuffer,KTraceFileName, __LINE__);

            return KErrTimedOut;
        }
    }

    if(aLastErrorCode == KErrNone)  //This will be called only once...for first time only
    {
        aSLPId = (*iSLPList)[0].iSLPId;
        aHslpToBeUsedAddress.Copy((*iSLPList)[0].iHSLPAddress);
        aIAPName.Copy((*iSLPList)[0].iIapName);
        aTls = (*iSLPList)[0].iTls;
        aPskTls = (*iSLPList)[0].iPskTls;
        aIsIapDialogShown = (*iSLPList)[0].iIsIAPDialgShown;
        iCurrentServerCounter++;

        iTrace->Trace(_L("Server being used:"),KTraceFileName, __LINE__);
        LogBuffer.Copy(aHslpToBeUsedAddress);
        iTrace->Trace(LogBuffer,KTraceFileName, __LINE__);

        iTrace->Trace(_L("iap being used:"),KTraceFileName, __LINE__);
        LogBuffer.Copy(aIAPName);
        iTrace->Trace(LogBuffer,KTraceFileName, __LINE__);

        iTrace->Trace(_L("iap dlg configuration:"),KTraceFileName, __LINE__);
        LogBuffer.Delete(0,256);
        LogBuffer.AppendNum(aIsIapDialogShown);
        iTrace->Trace(LogBuffer,KTraceFileName, __LINE__);

        return KErrNone;
    }
    else
    {
        if(iIsFallBackAllowed && CheckErrorCodeL(aLastErrorCode))// Do not fallback in case if IMSI generated address failed for previous try.
        {
            aSLPId = (*iSLPList)[iCurrentServerCounter].iSLPId;
            aHslpToBeUsedAddress.Copy((*iSLPList)[iCurrentServerCounter].iHSLPAddress);
            aIAPName.Copy((*iSLPList)[iCurrentServerCounter].iIapName);
            aTls = (*iSLPList)[iCurrentServerCounter].iTls;
            aPskTls = (*iSLPList)[iCurrentServerCounter].iPskTls;
            aIsIapDialogShown = (*iSLPList)[iCurrentServerCounter].iIsIAPDialgShown;
            iCurrentServerCounter++;
            iTrace->Trace(_L("Fallback allowed & TLSAuth passed"),KTraceFileName, __LINE__);
            iTrace->Trace(_L("Server being used:"),KTraceFileName, __LINE__);
            LogBuffer.Copy(aHslpToBeUsedAddress);
            iTrace->Trace(LogBuffer,KTraceFileName, __LINE__);

            iTrace->Trace(_L("iap being used:"),KTraceFileName, __LINE__);
            LogBuffer.Copy(aIAPName);
            iTrace->Trace(LogBuffer,KTraceFileName, __LINE__);

            iTrace->Trace(_L("iap dlg configuration:"),KTraceFileName, __LINE__);
            LogBuffer.Delete(0,256);
            LogBuffer.AppendNum(aIsIapDialogShown);
            iTrace->Trace(LogBuffer,KTraceFileName, __LINE__);
            return KErrNone;
        }
        else
        {
            return KErrNotFound;
        }
    }

}
Пример #27
0
void CValidateTest::DoPerformPostrequisite(TRequestStatus& aStatus)
	{
	TInt err = KErrNone;

	switch (iState)
		{
	case EInit:
	case EValidationStoreInitStoreManager1:
	case EValidationStoreDepopulateStore1:
	case EValidationStorePopulateStoreRoots:
	case EValidationStorePopulateStoreExtras:
	case EValidationStoreValidate:
	case EValidationStoreValidated:
	case EValidationStoreInitStoreManager2:
	case EValidationStoreDepopulateStore2:
	case EValidationStoreEnd:
		break;	//	Nothing to do, for compiler
	case EValidationSuppliedInit:
			{
			iConsole.Printf(_L("started with supplied certs...\n"));
			iOut.writeString(_L("started with supplied certs..."));
			iOut.writeNewLine();

			iState = EValidationSuppliedValidate;
			TRequestStatus* status = &aStatus;
			User::RequestComplete(status, KErrNone);
			}
			break;

		case EValidationSuppliedValidate:
			{
			HBufC8* encodedCerts = ReadFilesLC(*iTestChain->iServerCerts);

			if(!encodedCerts)
				{
				TRequestStatus* status = &aStatus;
				iFinished = ETrue;
				User::RequestComplete(status, KErrNone);
				}
			else
				{
				TInt certCount = iTestChain->iRootCerts->MdcaCount();
				CArrayPtrFlat<CWTLSCertificate>* roots = 
					new(ELeave) CArrayPtrFlat<CWTLSCertificate>(1);
				TCleanupItem cleanup(CleanupCertArray, roots);
				CleanupStack::PushL(cleanup);
				for (TInt i = 0; i < certCount; i++)
					{
					// build the root certificates array including all the candidates.
					HBufC8* encCert = 
						ReadFileLC(iTestChain->iRootCerts->MdcaPoint(i));
					CWTLSCertificate* cert = CWTLSCertificate::NewLC(encCert->Des());
					roots->AppendL(cert);
					CleanupStack::Pop();	// cert
					CleanupStack::PopAndDestroy();	// encCert
					}

				__ASSERT_DEBUG(!iChain, User::Panic(_L("CValidateTest"), 1));
				iChain = CWTLSCertChain::NewL(iFs, *encodedCerts, *roots);

				CleanupStack::PopAndDestroy(2);	// encodedCerts, roots

				TDateTime dt(2000, EJuly, 0, 0, 0, 0, 0);
				if(iTestChain->iDateIssued == 1)
					{
					dt.SetYear(2002);
					}
				iTime = dt;
				
				iChain->ValidateL(*iValidationResult, iTime, aStatus);
				iState = EValidationSuppliedValidated;
				}
			}
			break;

		case EValidationSuppliedValidated:
			{
			delete iChain;
			iChain = 0;
			TWTLSValidationStatus* expectedStatus = iTestChain->iError;
			const TWTLSValidationStatus& actualStatus = iValidationResult->Error();

			iOut.writeString(_L("Expected Error = "));
			WriteError(expectedStatus->iReason);
			iOut.writeNewLine();

			iOut.writeString(_L("Actual Error = "));
			WriteError(actualStatus.iReason);
			iOut.writeNewLine();
					
			TInt wCount = iTestChain->iWarnings->Count();
			iOut.writeString(_L("Expected Warnings = "));
			iOut.writeNewLine();
			for (TInt i = 0; i < wCount; i++)
				{
				TWTLSValidationStatus warning = iTestChain->iWarnings->At(i);
				WriteError(warning.iReason);
				iOut.writeNewLine();
				}

			iOut.writeString(_L("Actual Warnings = "));
			iOut.writeNewLine();
			const CArrayFixFlat<TWTLSValidationStatus>& warnings = 
				iValidationResult->Warnings();
			wCount = warnings.Count();
			for (TInt j = 0; j < wCount; j++)
				{
				TWTLSValidationStatus warning = warnings.At(j);
				WriteError(warning.iReason);
				iOut.writeNewLine();
				}
			iOut.writeNewLine();

			if(expectedStatus->iReason != actualStatus.iReason)
				{
				iConsole.Printf(_L("FAILED!!!!\n"));
				iOut.writeString(_L("FAILED!!!!"));
				iOut.writeNewLine();
				iResult = EFalse;
				}
		
			// End of validatewith supplied
			if (err != KErrNone)
				{
				iOut.writeString(_L("Failed: leave code = "));
				iOut.writeNum(err);
				iOut.writeNewLine();
				}

			iState = EFinished;
			TRequestStatus* status = &aStatus;
			User::RequestComplete(status, KErrNone);
			}
			break;

		case EFinished:
			{
			TTime end;
			end.HomeTime();
			TTimeIntervalMicroSeconds intervalMS = end.MicroSecondsFrom(iStart);
			iConsole.Printf(_L("Time taken = %d milliseconds\n"), (intervalMS.Int64()/1000));
	
			TRequestStatus* status = &aStatus;
			iFinished = ETrue;
			User::RequestComplete(status, KErrNone);
			}
			break;
		}
	}
void CT_LbsMolrResetAssistance::DoNetworkProtocolProxyStepL()
	{
	if(iGPSModeNotSupported)
		{ // Do nothing, the network won't do much before the module rejects the request
		return;
		}
	TInt cleanupCnt;
	// INFO_PRINTF2(_L("CT_LbsMolrResetAssistance::DoNetworkProtocolProxyStepL() Step %d"),iNetworkProtocolProxyStep);
	switch(iNetworkProtocolProxyStep)
		{
		case ENetworkProtocolProxyStepInitial:
			{
			// >> AdviceSystemStatus()
			INFO_PRINTF1(_L("CT_LbsMolrResetAssistance::DoNetworkProtocolProxyStepL() >> AdviceSystemStatus()"));
			TESTL(iProxy->WaitForResponse(KTimeOut) == ENetMsgGetCurrentCapabilitiesResponse);
			CLbsNetworkProtocolBase::TLbsSystemStatus status;
			cleanupCnt = iProxy->GetArgsLC(ENetMsgGetCurrentCapabilitiesResponse, &status);
			TESTL(status == CLbsNetworkProtocolBase::ESystemStatusNone);
			CleanupStack::PopAndDestroy(cleanupCnt);
			iNetworkProtocolProxyStep = ENetworkProtocolProxyStepAfterFirstNPUD;
			break;
			}
		case ENetworkProtocolProxyStepAfterFirstNPUD:
			{
			// >> RequestSelfLocation()
			INFO_PRINTF1(_L("CT_LbsMolrResetAssistance::DoNetworkProtocolProxyStepL() >> RequestSelfLocation() - as result of assistance data request from module"));
			TESTL(iProxy->WaitForResponse(KTimeOut) == ENetMsgRequestSelfLocation);

			if(!iWarmUpModule && iStepForSendingReset == EBeginningOfSession)
				{
				SendResetAssistanceDataL();
				}

			// Process the response.
			TLbsNetSessionId* 					sessionId = NULL;
			TLbsNetPosRequestOptionsAssistance*	opts = NULL;
			
			cleanupCnt = iProxy->GetArgsLC(ENetMsgRequestSelfLocation, &sessionId, &opts);

			iSessionId.SetSessionNum(sessionId->SessionNum());
			iSessionId.SetSessionOwner(sessionId->SessionOwner());
			
			CleanupStack::PopAndDestroy(cleanupCnt);
			sessionId = NULL;
			opts = NULL;	
			
			// << ProcessStatusUpdate(EServiceSelfLocation)
			INFO_PRINTF1(_L("CT_LbsMolrResetAssistance::DoNetworkProtocolProxyStepL() << ProcessStatusUpdate(EServiceSelfLocation)"));
			MLbsNetworkProtocolObserver::TLbsNetProtocolServiceMask activeServiceMask1 = MLbsNetworkProtocolObserver::EServiceSelfLocation;
			iProxy->CallL(ENetMsgProcessStatusUpdate, &activeServiceMask1);

			// << ProcessLocationUpdate(SessionId, RefPosition)
			INFO_PRINTF1(_L("CT_LbsMolrResetAssistance::DoNetworkProtocolProxyStepL() << ProcessLocationUpdate(SessionId, RefPosition)"));
			TPositionInfo refPosInfo = ArgUtils::MolrReferencePositionInfo();
			iProxy->CallL(ENetMsgProcessLocationUpdate, &iSessionId, &refPosInfo);

			iNetworkProtocolProxyStep = ENetworkProtocolProxyStepAfterSecondNPUD;
			break;
			}
		case ENetworkProtocolProxyStepAfterSecondNPUD:
			{
			// >> RequestAssistanceData - as a result of the second client request.
			TLbsAsistanceDataGroup dataMask;	
			INFO_PRINTF1(_L("CT_LbsMolrResetAssistance::DoNetworkProtocolProxyStepL() >> RequestAssistanceData(0)"));
			TESTL(iProxy->WaitForResponse(KTimeOut) == ENetMsgRequestAssistanceData); 
			cleanupCnt = iProxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataMask);
			TESTL(dataMask == EAssistanceDataNone);
			CleanupStack::PopAndDestroy(cleanupCnt);

			// << ProcessAssistanceData()
			INFO_PRINTF1(_L("CT_LbsMolrResetAssistance::DoNetworkProtocolProxyStepL() << ProcessAssistanceData()"));
			dataMask = EAssistanceDataReferenceTime;
			RLbsAssistanceDataBuilderSet assistanceData;
			ArgUtils::PopulateLC(assistanceData);
			TInt reason = KErrNone;
			iProxy->CallL(ENetMsgProcessAssistanceData, &dataMask, &assistanceData, &reason);
			CleanupStack::PopAndDestroy(); // assistanceData

			if(!iWarmUpModule && iStepForSendingReset == EAfterAssistanceData)
				{
				iExpectExtraRequestForAssistanceData = SendResetAssistanceDataL();
				}

			// << ProcessLocationRequest() 
			TBool emergency = EFalse;
			MLbsNetworkProtocolObserver::TLbsNetProtocolService	service = MLbsNetworkProtocolObserver::EServiceSelfLocation;
			TLbsNetPosRequestQuality quality = ArgUtils::Quality();
			//quality.SetMaxFixTime(ArgUtils::Alpha2()/10);
		    quality.SetMaxFixTime(ArgUtils::Alpha2()/4);
			TLbsNetPosRequestMethod method   = RequestNetworkMethod();
			INFO_PRINTF1(_L("CT_LbsMolrResetAssistance::DoNetworkProtocolProxyStepL() << ProcessLocationRequest()"));			
			iProxy->CallL(ENetMsgProcessLocationRequest, &iSessionId, &emergency, &service, &quality, &method);
			// Now that the hybrid/alpha2 has been requested, record current time to verify alpha2 timer expires correctly.
			TTime startTime;
			startTime.HomeTime();

			TInt response = iProxy->WaitForResponse(KTimeOut);
			TLbsNetSessionId* sessionId = NULL;
			if(response == ENetMsgRespondLocationRequest)
				{
				// >> RespondLocationRequest(KErrNotSupported) - as a result of the NRH request conflicting with the module capabilities 
				INFO_PRINTF1(_L("CT_LbsMolrResetAssistance::DoNetworkProtocolProxyStepL() >> RespondLocationRequest(KErrNotSupported)"));
				sessionId = NULL;
				TPositionInfo* positionInfo = NULL;
				reason = KErrNone;
				cleanupCnt = iProxy->GetArgsLC(ENetMsgRespondLocationRequest, &sessionId, &reason, &positionInfo);
				TESTL(positionInfo->PositionClassType() == EPositionInfoClass);
				TESTL(sessionId->SessionNum() == iSessionId.SessionNum());
				TESTL(reason == KErrNotSupported);
				CleanupStack::PopAndDestroy(cleanupCnt);

				// << ProcessSessionComplete()
				INFO_PRINTF1(_L("CT_LbsMolrResetAssistance::DoNetworkProtocolProxyStepL() << ProcessSessionComplete()"));			
				iProxy->CallL(ENetMsgProcessSessionComplete, &iSessionId, &reason);
				iGPSModeNotSupported = ETrue;

				// << ProcessStatusUpdate()
				MLbsNetworkProtocolObserver::TLbsNetProtocolServiceMask activeServiceMask2 = MLbsNetworkProtocolObserver::EServiceNone;	
				INFO_PRINTF1(_L("CT_LbsMolrResetAssistance::DoNetworkProtocolProxyStepL() << ProcessStatusUpdate(EServiceNone)"));			
				iProxy->CallL(ENetMsgProcessStatusUpdate, &activeServiceMask2);
				
				iNetworkProtocolProxyStep = ENetworkProtocolProxyStepInitial;
				}
			else
				{
				// >> RequestAssistanceData() - as a result of the NRH request. 
				TESTL(response == ENetMsgRequestAssistanceData); 
				cleanupCnt = iProxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataMask);
				if(!iExpectExtraRequestForAssistanceData || (iNetworkMethod == EAutonomousNetworkMethod && !iWarmUpModule))
					{
					INFO_PRINTF1(_L("CT_LbsMolrResetAssistance::DoNetworkProtocolProxyStepL() >> RequestAssistanceData(0)"));	
					TESTL(dataMask == EAssistanceDataNone);
					}
				else
					{
					iExpectExtraRequestForAssistanceData = EFalse;
					INFO_PRINTF1(_L("CT_LbsMolrResetAssistance::DoNetworkProtocolProxyStepL() >> RequestAssistanceData(EAssistanceDataReferenceTime)"));	
					TESTL(dataMask == EAssistanceDataReferenceTime);
					// << ProcessAssistanceData(EAssistanceDataReferenceTime)
					TLbsAsistanceDataGroup dataRequestMask = EAssistanceDataReferenceTime;
					RLbsAssistanceDataBuilderSet assistanceData;
					ArgUtils::PopulateLC(assistanceData);
					reason = KErrNone;
					INFO_PRINTF1(_L("CT_LbsMolrResetAssistance::DoNetworkProtocolProxyStepL() << ProcessAssistanceData(EAssistanceDataReferenceTime)"));	
					iProxy->CallL(ENetMsgProcessAssistanceData, &dataRequestMask, &assistanceData, &reason);
					CleanupStack::PopAndDestroy(&assistanceData);
					}
				CleanupStack::PopAndDestroy(cleanupCnt);
	
				// lrm: need to update this for cases where network request is rejected:
				// Determine the value to take off the alpha2 value. This is required because we had to wait for the assistance data response.
				TTimeIntervalMicroSeconds microseconds;
				TTime stopTime;
				stopTime.HomeTime();
				microseconds = stopTime.MicroSecondsFrom(startTime); 
				TInt64 timeElapsed = microseconds.Int64();
				TInt delta = 2 * 1000 * 1000; // 2 secs.
				
				// >> RespondLocationRequest()
				sessionId = NULL;
				DecideWhatNetworkDoesntReceive();
				const TInt t = 8 * 1000 * 1000; // 8 secs.
				
				if(iNetworkExpectsMeasurments)
					{ // measurements should be sent to the network
					INFO_PRINTF1(_L("CT_LbsMolrResetAssistance::DoNetworkProtocolProxyStepL() Network expecting measurements"));
					// Test that we do not get response before alpha2 has expired:
					TInt alpha2timeout = ArgUtils::Alpha2()/4 - timeElapsed - delta > 0 ? ArgUtils::Alpha2()/4 - timeElapsed - delta : 0;
					TESTL(iProxy->WaitForResponse(alpha2timeout) == ENetMsgTimeoutExpired);
					INFO_PRINTF1(_L("				No RespondLocationRequest before Alpha2 timer expired"));
					// Wait for and process the response:
					TESTL(iProxy->WaitForResponse(2 * delta) == ENetMsgRespondLocationRequest);	
					INFO_PRINTF1(_L("CT_LbsMolrResetAssistance::DoNetworkProtocolProxyStepL() >> RespondLocationRequest(meas)"));
					sessionId = NULL;
					TPositionGpsMeasurementInfo* measurementInfo = NULL;
					cleanupCnt = iProxy->GetArgsLC(ENetMsgRespondLocationRequest, &sessionId, &reason, &measurementInfo);
					TESTL(sessionId->SessionNum() == iSessionId.SessionNum());	// module sends NAN measurement first
					TESTL(measurementInfo->PositionClassType() == EPositionGpsMeasurementInfoClass);
					if(reason != KErrNone)
						{
						INFO_PRINTF2(_L("CT_LbsMolrResetAssistance::DoNetworkProtocolProxyStepL() reason = 0x%x"), reason);
						}
					TESTL(reason == KErrNone);
					CleanupStack::PopAndDestroy(cleanupCnt);//sessionId, measurementInfo
	
					// Wait for Assistance Data before resetting assistance data ... otherwise 
					// who knows what mask we would receive!
					// Recv -> RequestAssistanceData - we get an extra msg as the result of the A-GPS manager re-issuing a location request when it's
					//									max fix time timer expries.
					INFO_PRINTF1(_L("CT_LbsMolrResetAssistance::DoNetworkProtocolProxyStepL() >> RequestAssistanceData(0)"));
					TESTL(iProxy->WaitForResponse(KTimeOut) == ENetMsgRequestAssistanceData); 
					cleanupCnt = iProxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataMask);
					TESTL(dataMask == EAssistanceDataNone);
					CleanupStack::PopAndDestroy(cleanupCnt);
	
					// now reset the asistance data
					if(!iWarmUpModule && iStepForSendingReset == EAfterMeasurements)
										{
										iExpectExtraRequestForAssistanceData = SendResetAssistanceDataL();
										}
					quality.SetMaxFixTime(t);
	
					// << ProcessLocationRequest()
					INFO_PRINTF1(_L("CT_LbsMolrResetAssistance::DoNetworkProtocolProxyStepL() << ProcessLocationRequest()"));
					iProxy->CallL(ENetMsgProcessLocationRequest, &iSessionId, &emergency, &service, &quality, &method);
	
					// now as we have reset the assistanvce datat we expect
					// to get a non-zero mask.
					// >> RequestAssistanceData()
					INFO_PRINTF1(_L("CT_LbsMolrResetAssistance::DoNetworkProtocolProxyStepL() >> RequestAssistanceData(0)"));
					TESTL(iProxy->WaitForResponse(KTimeOut) == ENetMsgRequestAssistanceData); 
					cleanupCnt = iProxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataMask);
					if(!iExpectExtraRequestForAssistanceData || (iNetworkMethod == EAutonomousNetworkMethod && !iWarmUpModule))
						{
						INFO_PRINTF1(_L("CT_LbsMolrResetAssistance::DoNetworkProtocolProxyStepL() >> RequestAssistanceData(EAssistanceDataReferenceTime)"));	
						TESTL(dataMask == EAssistanceDataReferenceTime);
						}
					else
						{
						iExpectExtraRequestForAssistanceData = EFalse;
						INFO_PRINTF1(_L("CT_LbsMolrResetAssistance::DoNetworkProtocolProxyStepL() >> RequestAssistanceData(EAssistanceDataReferenceTime)"));	
						TESTL(dataMask == EAssistanceDataReferenceTime);
						// << ProcessAssistanceData(EAssistanceDataReferenceTime)
						TLbsAsistanceDataGroup dataRequestMask = EAssistanceDataReferenceTime;
						RLbsAssistanceDataBuilderSet assistanceData;
						ArgUtils::PopulateLC(assistanceData);
						reason = KErrNone;
						INFO_PRINTF1(_L("CT_LbsMolrResetAssistance::DoNetworkProtocolProxyStepL() << ProcessAssistanceData(EAssistanceDataReferenceTime)"));	
						iProxy->CallL(ENetMsgProcessAssistanceData, &dataRequestMask, &assistanceData, &reason);
						CleanupStack::PopAndDestroy(&assistanceData);
						}
					CleanupStack::PopAndDestroy(cleanupCnt);
	
					}
	
				if(iPlannedPositionOriginator == EPositionOriginatorModule)
					{ // the module will deliver the location
					if(iNetworkExpectsPositions)
						{
						INFO_PRINTF1(_L("CT_LbsMolrResetAssistance::DoNetworkProtocolProxyStepL() Network expecting position"));
						TNetProtocolResponseType type = iProxy->WaitForResponse(t + delta);
						if(type == ENetMsgRequestAssistanceData)
							{
							// >> RequestAssistanceData(0)
							INFO_PRINTF1(_L("CT_LbsMolrResetAssistance::DoNetworkProtocolProxyStepL() >> RequestAssistanceData(0)"));
							cleanupCnt = iProxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataMask);
							TESTL(dataMask == EAssistanceDataNone);
							CleanupStack::PopAndDestroy(cleanupCnt);
							type = iProxy->WaitForResponse(t + delta);
							}
						// >> RespondLocationRequest() - first measurement, second position.
						INFO_PRINTF1(_L("CT_LbsMolrResetAssistance::DoNetworkProtocolProxyStepL() >> RespondLocationRequest(gpspos)"));
						TESTL(type == ENetMsgRespondLocationRequest);
						sessionId = NULL;
						TPositionInfo* positionInfo = NULL;
						cleanupCnt = iProxy->GetArgsLC(ENetMsgRespondLocationRequest, &sessionId, &reason, &positionInfo);
						
						// check it is a position
						TESTL(positionInfo->PositionClassType() == (EPositionInfoClass|EPositionCourseInfoClass|EPositionSatelliteInfoClass));
						TESTL(sessionId->SessionNum() == iSessionId.SessionNum());
						TESTL(reason == KErrNone);
						
						if(!iWarmUpModule && iStepForSendingReset == EAfterPosition)
							{
							SendResetAssistanceDataL();
							}

						// << ProcessLocationUpdate(SessionId, FinalNetworkPosition)
						// Return modules' position as FinalNetworkPosition
						INFO_PRINTF1(_L("CT_LbsMolrResetAssistance::DoNetworkProtocolProxyStepL() << ProcessLocationUpdate(SessionId, FinalNetworkPosition)"));
						iProxy->CallL(ENetMsgProcessLocationUpdate, &iSessionId, positionInfo);
						CleanupStack::PopAndDestroy(cleanupCnt);
						}
					else	
						{ // network doesn't expect the module to be calculating the position and will terminate 'normally' when it's satisfied
						// Not expecting anything else to arrive at the network, make sure it doesn't:
						TESTL(iProxy->WaitForResponse(t + delta) == ENetMsgTimeoutExpired);
						}
					}
				else if(iPlannedPositionOriginator == EPositionOriginatorNetwork)
					{ // The network should return the position
					TPositionInfo positionInfo = ArgUtils::AccurateNetworkPositionInfo();
					// << ProcessLocationUpdate(SessionId, FinalNetworkPosition)
					// Return FinalNetworkPosition
					INFO_PRINTF1(_L("CT_LbsMolrResetAssistance::DoNetworkProtocolProxyStepL() << ProcessLocationUpdate(SessionId, FNP)"));
					iProxy->CallL(ENetMsgProcessLocationUpdate, &iSessionId, &positionInfo);

					// >> RequestAssistanceData(0)
					INFO_PRINTF1(_L("CT_LbsMolrResetAssistance::DoNetworkProtocolProxyStepL() >> RequestAssistanceData(0)"));
					TESTL(iProxy->WaitForResponse(KTimeOut) == ENetMsgRequestAssistanceData); 
					cleanupCnt = iProxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataMask);
					TESTL(dataMask == EAssistanceDataNone);
					CleanupStack::PopAndDestroy(cleanupCnt);

					// >> CancelSelfLocation()
					INFO_PRINTF1(_L("CT_LbsMolrResetAssistance::DoNetworkProtocolProxyStepL() >> CancelSelfLocation()"));			
					TESTL(iProxy->WaitForResponse(KTimeOut) == ENetMsgCancelSelfLocation);

					// >> RequestAssistanceData(0)
					INFO_PRINTF1(_L("CT_LbsMolrResetAssistance::DoNetworkProtocolProxyStepL() >> RequestAssistanceData(0)"));
					TESTL(iProxy->WaitForResponse(KTimeOut) == ENetMsgRequestAssistanceData); 
					TLbsAsistanceDataGroup dataMask;
					TInt cleanupCnt = iProxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataMask);
					TESTL(dataMask == EAssistanceDataNone);
					CleanupStack::PopAndDestroy(cleanupCnt);
					}
				iNetworkProtocolProxyStep = ENetworkProtocolProxyStepFinal;
				}
			
			break;
			}
		case ENetworkProtocolProxyStepFinal:
			{
			// << ProcessSessionComplete()
			TInt reason = KErrNone;
			INFO_PRINTF1(_L("CT_LbsMolrResetAssistance::DoNetworkProtocolProxyStepL() << ProcessSessionComplete()"));			
			iProxy->CallL(ENetMsgProcessSessionComplete, &iSessionId, &reason);

			if(!iWarmUpModule && iStepForSendingReset == EAfterSessionClose)
				{
				SendResetAssistanceDataL();
				}

			// << ProcessStatusUpdate()
			MLbsNetworkProtocolObserver::TLbsNetProtocolServiceMask activeServiceMask2 = MLbsNetworkProtocolObserver::EServiceNone;	
			INFO_PRINTF1(_L("CT_LbsMolrResetAssistance::DoNetworkProtocolProxyStepL() << ProcessStatusUpdate(EServiceNone)"));			
			iProxy->CallL(ENetMsgProcessStatusUpdate, &activeServiceMask2);
			iProxy->WaitForResponse(KTimeoutWaitingForResetAssistanceData);
			
			iNetworkProtocolProxyStep = ENetworkProtocolProxyStepAfterFirstNPUD;
			break;
			}
		default:
			{
			User::Invariant();
			}
		}
	}
TVerdict CTestUTCParse::TestTime(TInt aCount,TTime* aTime)
	{
	
	TVerdict result=EFail;
	TTime currentUtcTime;
	TTimeIntervalMicroSeconds difference;
	TTime time;
	
	switch(aCount)
		{
	case 0:
		//the expected timestamp is Wed, 30 Apr 1997 10:12:18 +0100
		_LIT(KDateCorrect, "19970329:091218.000000"); 
		time.Set(KDateCorrect);	
		result = (time==*aTime? EPass:EFail);
		if(result==EFail) ERR_PRINTF2(_L("Test %d failed\n"), aCount+1);
	break;
			
	case 1:
		//there is no received header in this test so the date field should be used insted
		//the expected timestamp is Wed, 30 Apr 1997 10:02:38 +0100 (BST)
		_LIT(KDateCorrect55, "19970329:090238.000000"); 
		time.Set(KDateCorrect55);
		result = (time==*aTime? EPass:EFail);	
		if(result==EFail) ERR_PRINTF2(_L("Test %d failed\n"), aCount+1);	
	break;
	
	case 2:
		//the UTC offset in this test is invalid (+2500) and should be ignored
		//expected time-stamp is Wed, 30 Apr 1997 10:12:18 +2500
		_LIT(KDateCorrect2, "19970329:101218.000000"); 
		time.Set(KDateCorrect2);	
		result = (time==*aTime? EPass:EFail);		
		if(result==EFail) ERR_PRINTF2(_L("Test %d failed\n"), aCount+1);	
	break;
	
	case 3:
		//the UTC offset is invalid in this test and the current UTC time should be used to 
		//time-stamp the entry instead
		currentUtcTime.UniversalTime();
		difference=currentUtcTime.MicroSecondsFrom(*aTime);
		//the difference should be less than 1 second
		result = (difference<5000000? EPass:EFail);	
		if(result==EFail) ERR_PRINTF2(_L("Test %d failed\n"), aCount+1);	
	break;
	
	case 4:  
		//expected time-stamp is Thu, 3 Mar 2005 15:28:50 +0000
		_LIT(KDateCorrect3, "20050202:152850.000000"); 
		time.Set(KDateCorrect3);
		result = (time==*aTime? EPass:EFail);		
		if(result==EFail) ERR_PRINTF2(_L("Test %d failed\n"), aCount+1);
	break;
	
	case 5:
		//This is the time-stamp of an embedded entry 
		//expected time-stamp is Thu, 3 Mar 2005 15:27:12 +0000
		_LIT(KDateCorrect4, "20050202:152712.000000"); 
		time.Set(KDateCorrect4);
		result = (time==*aTime? EPass:EFail);	
		if(result==EFail) ERR_PRINTF2(_L("Test %d failed\n"), aCount+1);
	break;
	
	default:
	break;
			
		}
		return result;	
	}
Пример #30
0
/** Find last.txt with TFindFile and with two threads accessing the 2 directories

	@param aN 		Number of files in the directory
	@param aWild 	Wildcard string to be used in the search
	@param aStep 	Test step
*/
LOCAL_C void FindFileWild1(TInt aN, const TDesC& aWild, TInt aStep) 
	{
	TBuf16<100> dir1;
	TBuf16<100> dir2;
	TBuf16<100> dir3;
    TBuf16<100> dir4;

	CDir* dir;
	TInt r = 0;

	TFindFile find(TheFs);
	
	TTime startTime;
	TTime endTime;
	TTimeIntervalMicroSeconds timeTaken(0);
	TInt timeTaken1 = -1, timeTaken2 = -1, timeTaken3 = -1; 
	
	if(aN <= gFilesLimit) 
		{
		dir1 = gSessionPath;
		dir2 = gSessionPath;
		dir3 = gSessionPath;
		
		dir4.Format(KDirMultipleName2, 1, aN);
		dir1.Append(dir4);
		
		dir4.Format(KDirMultipleName2, 2, aN);
		dir2.Append(dir4);
		
		dir4.Format(KDirMultipleName2, 3, aN);
		dir3.Append(dir4);
		
		if(gTypes >= 1) 
			{	
			dir4.Format(KDirMultipleName, 1, aN);
			startTime.HomeTime();
			
			r = find.FindWildByPath(aWild, &dir1, dir);
			FailIfError(r);
			
			endTime.HomeTime();

			timeTaken = endTime.MicroSecondsFrom(startTime);
			timeTaken1 = I64LOW(timeTaken.Int64() / gTimeUnit);
			delete dir;
			}
		
		if(gTypes >= 2) 
			{	
			startTime.HomeTime();

			r = find.FindWildByPath(_L("*.txt"), &dir2, dir);
			FailIfError(r);

			endTime.HomeTime();
			timeTaken = endTime.MicroSecondsFrom(startTime);
			
			timeTaken2 = I64LOW(timeTaken.Int64() / gTimeUnit);
			delete dir;
			}
		
		if(gTypes >= 3) 
			{	
			startTime.HomeTime();
			
			r = find.FindWildByPath(_L("*.txt"), &dir3, dir);
			FailIfError(r);
			
			endTime.HomeTime();
			timeTaken=endTime.MicroSecondsFrom(startTime);
			timeTaken3 = I64LOW(timeTaken.Int64() / gTimeUnit);
			delete dir;
			}
		}
	
	PrintResult(aStep, 1, aN);
	PrintResultTime(aStep, 2, timeTaken1);
	PrintResultTime(aStep, 3, timeTaken2);
	PrintResultTime(aStep, 4, timeTaken3);
	}