Exemplo n.º 1
0
/*
 * QS60KeyCapture provides media key handling using services from RemCon.
 */
QS60KeyCapture::QS60KeyCapture(CCoeEnv *env, QObject *parent):
    QObject(parent), coeEnv(env), selector(0), target(0), handler(0)
{
    initRemCon();

    TTimeIntervalMicroSeconds32 initialTime;
    TTimeIntervalMicroSeconds32 time;
    coeEnv->WsSession().GetKeyboardRepeatRate(initialTime, time);
    initialRepeatTime = (initialTime.Int() / 1000); // msecs
    repeatTime = (time.Int() / 1000); // msecs

    int clickTimeout = initialRepeatTime + repeatTime;

    volumeUpClickTimer.setSingleShot(true);
    volumeDownClickTimer.setSingleShot(true);
    repeatTimer.setSingleShot(true);

    volumeUpClickTimer.setInterval(clickTimeout);
    volumeDownClickTimer.setInterval(clickTimeout);
    repeatTimer.setInterval(initialRepeatTime);

    connect(&volumeUpClickTimer, SIGNAL(timeout()), this, SLOT(volumeUpClickTimerExpired()));
    connect(&volumeDownClickTimer, SIGNAL(timeout()), this, SLOT(volumeDownClickTimerExpired()));
    connect(&repeatTimer, SIGNAL(timeout()), this, SLOT(repeatTimerExpired()));
}
void CSmsReplyToStep::StartWatcherL()
	{
	INFO_PRINTF1(_L("Start the Watcher"));

	if( WatchersAlreadyRunningL() )
		{
		INFO_PRINTF1(_L("Watchers are already running\n"));
		return;
		}

	iWatchers = CTestUtilsWatcherStarter::NewL();

	TTimeIntervalMicroSeconds32 wait = KWaitForWatchersToStart;
	TBool started = EFalse;
	while( !started && wait.Int() > 0 )
		{
		INFO_PRINTF2(_L("Waiting %d secs for watchers to start..."), wait.Int() / 1000000);
		wait = wait.Int() - KWaitForWatchersToStartDisplayInterval.Int();
		User::After(KWaitForWatchersToStartDisplayInterval);
		started = WatchersAlreadyRunningL();
		}

	if( !WatchersAlreadyRunningL() )
		{
		INFO_PRINTF1(_L("WARNING: NBS Watcher has not started yet\n"));
		}
	}
Exemplo n.º 3
0
// ---------------------------------------------------------------------------
// Configures the flex window sizes for both the initial delay and the
// consequent intervals after that.
// ---------------------------------------------------------------------------
//
EXPORT_C TInt CFlexPeriodic::Configure(
                                 TTimeIntervalMicroSeconds32 aDelayWindow,
                                 TTimeIntervalMicroSeconds32 aIntervalWindow )
    {

    OstTraceExt3( TRACE_NORMAL, CFLEXPERIODIC_CONFIGURE,
            "CFlexPeriodic::Configure32;this=%x;"
            "aDelayWindow=%d;aIntervalWindow=%d", ( TUint )this,
            aDelayWindow.Int(), aIntervalWindow.Int() );

    TTimeIntervalMicroSeconds32 zero( 0 );
    __ASSERT_ALWAYS(aDelayWindow >= zero,
            User::Panic(KCFlexPeriodicPanicCat,
                    EFlexPeriodicDelayWindowLessThanZero));
    __ASSERT_ALWAYS(aIntervalWindow >= zero,
            User::Panic(KCFlexPeriodicPanicCat,
                    EFlexPeriodicIntervalWindowLessThanZero));

    // interval window is saved for later use. Delay window is sent
    // immediately to server. 
    TInt ret = CFlexTimer::Configure( aDelayWindow );
    if ( ret == KErrNone )
        {
        // Interval window is changed only, if configuration is successful.
        iIntervalWindow = MAKE_TINT64( 0, aIntervalWindow.Int() );
        iSendConfigure = ETrue;
        }
    return ret;
    }
Exemplo n.º 4
0
// ---------------------------------------------------------------------------
// Starts the periodic timer. 32-bit delay and interval parameters.
// ---------------------------------------------------------------------------
//
EXPORT_C void CFlexPeriodic::Start( TTimeIntervalMicroSeconds32 aDelay,
                                    TTimeIntervalMicroSeconds32 anInterval,
                                    TCallBack aCallBack,
                                    TCallBack aCallBackError )
    {
    OstTraceExt4( TRACE_NORMAL, CFLEXPERIODIC_START32,
            "CFlexPeriodic::Start32;this=%x;aDelay=%d;"
            "anInterval=%d;aCallBack=%x", ( TUint )this,
            aDelay.Int(), anInterval.Int(), ( TUint )&( aCallBack ) );

    TTimeIntervalMicroSeconds32 zero( 0 );
    __ASSERT_ALWAYS(aDelay >= zero,
            User::Panic(KCFlexPeriodicPanicCat,
                    EFlexPeriodicDelayLessThanZero));
    __ASSERT_ALWAYS(anInterval > zero,
            User::Panic(KCFlexPeriodicPanicCat,
                    EFlexPeriodicIntervalTooSmall));
    __ASSERT_ALWAYS( aCallBack.iFunction != NULL,
            User::Panic(KCFlexPeriodicPanicCat,
                    EFlexPeriodicCallbackFunctionIsNull));
    // aCallBackError is left unasserted on purpose.
    // if error occurs and callback is null client is paniced.

    // Interval value is saved for later use, delay is sent immediately
    // to the server.
    iInterval = MAKE_TINT64( 0, anInterval.Int() );
    iCallBack = aCallBack;
    iCallBackError = aCallBackError;
    CFlexTimer::After( aDelay );
    }
Exemplo n.º 5
0
// ---------------------------------------------------------------------------
TBool CTestRFlexTimer::IsDelayOk( 
    const TTimeIntervalMicroSeconds aDelay,
    const TTimeIntervalMicroSeconds32 aInterval,
    const TTimeIntervalMicroSeconds32 aWindow )
    {
    TTimeIntervalMicroSeconds interval( aInterval.Int() );
    TTimeIntervalMicroSeconds window( aWindow.Int() );
    return IsDelayOk( aDelay, interval, window );
    }
Exemplo n.º 6
0
void CPhoneFactoryDummyBase::QueueTimer(TTsyTimer& aTsyTimer,
						const TTsyReqHandle aTsyReqHandle,
						TTimeIntervalMicroSeconds32 aTimeInMicroSeconds,
						TInt (*aFunction)(TAny *aPtr),TAny* aPtr)
	{
	TCallBack callBackFn(aFunction,aPtr);
 	aTsyTimer.iEntry.Set(callBackFn);

	aTsyTimer.iPending=ETrue;
	aTsyTimer.iTsyReqHandle=aTsyReqHandle;
	aTimeInMicroSeconds=aTimeInMicroSeconds.Int()+(KEtelTimerGranularity>>2);
	if(aTimeInMicroSeconds.Int()<100000)
		aTimeInMicroSeconds=aTimeInMicroSeconds.Int()+KEtelTimerGranularity;
	iTimer->Queue(aTimeInMicroSeconds,aTsyTimer.iEntry);
	}
Exemplo n.º 7
0
void CSmsCancelTest::DoRunSendingL()
	{
	CActiveScheduler::Stop();

	if (!iOperation) //scheduled
		{
		TTimeIntervalMicroSeconds32 wait = 5000000;
		iSmsTest.Printf(_L("\nWaiting %d seconds for SMSS to complete...\n\n"), wait.Int() / 1000000);
		User::After(wait);
		}

	if (iStatus == KErrNone)
		iStatus = iSmsTest.iProgress.iError;

	iState = EStateWaiting;
	iSmsTest.Printf(_L("Sending completed with error %d\n"), iStatus);

	if (iStatus == KErrCancel)
		{
		iSmsTest.Printf(_L("Error %d is expected and OK\n"), iStatus);
		iStatus = KErrNone;
		}

	iSmsTest.Printf(_L("Final Sending States of Messages:\n\n"), iStatus);
	iSmsTest.DisplaySendingStatesL(*iSelection);

	if (!iSmsTest.RunAuto())
		{
		iSmsTest.Test().Printf(_L("\nPress any key to continue...\n"));
		iSmsTest.Test().Getch();
		}
	}
Exemplo n.º 8
0
void CWsDeltaTimer::Queue(TTimeIntervalMicroSeconds32 aTimeInMicroSeconds,TWsDeltaTimerEntry& anEntry)
	{
	TInt intervals=aTimeInMicroSeconds.Int()/CWsDeltaTimerGranularity;
	if (intervals==0)
		intervals=1;
	iQueue.Add(anEntry,intervals);
	}
Exemplo n.º 9
0
// ---------------------------------------------------------------------------
// TEST CASE: Start a timer using AfterTicks and wait it to expire.
// ---------------------------------------------------------------------------
//
TInt CTestRFlexTimer::ExpireAfterTicksL(
    TTestResult& aResult, 
    CTestFlexTimer* /* aCallback */ )
    {
    __UHEAP_MARK;
    
    const TTimeIntervalMicroSeconds32 KInterval( 3000000 );     // Time to wait timer
    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;
    
    // Do the actual test
    //-----------------------------------------------------

    RFlexTimer timer;
    User::LeaveIfError( timer.Connect() );
    
    timer.AfterTicks( status, KInterval.Int() / KOneTick.Int() );
    
                                     //    //  ___     _____
    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 ) )
        {
        aResult.SetResult( KErrGeneral, _L("Test case failed. Wrong expiration.") );
        }
    
    __UHEAP_MARKEND;

    return KErrNone;
    }
Exemplo n.º 10
0
void SDL_StartTicks(void)
	{
	/* Set first ticks value */
    start = User::TickCount();

    TTimeIntervalMicroSeconds32 period;
	TInt tmp = UserHal::TickPeriod(period);
    tickPeriodMilliSeconds = period.Int() / 1000;
	}
Exemplo n.º 11
0
void ThreadSleepTicks(systick_t Ticks)
{
    if (Ticks)
    {
        TTimeIntervalMicroSeconds32 n;
	    UserHal::TickPeriod(n);
        Ticks *= n.Int();
    }
	User::After(Ticks);
}
Exemplo n.º 12
0
void CObexPacketTimer::SetTimer(TTimeIntervalMicroSeconds32 anInterval)
	{
	//Check if a timeout should be started on the request packet.
	if(anInterval.Int()>KLowestPossibleTimerValue)
		{
		Cancel();

		After(anInterval);
		}
	}
Exemplo n.º 13
0
void CTestCase0676::ContinueAfter(TTimeIntervalMicroSeconds32 aMicroSecs, TCaseSteps aStep)
	{
	LOG_VERBOSE2(_L("Wait %dms before drop VBus"), (TInt)(aMicroSecs.Int()/1000));
	if(gVerboseOutput)
	    {
	    OstTrace1(TRACE_VERBOSE, CTESTCASE0676_CONTINUEAFTER, "Wait %dms before drop VBus", (TInt)(aMicroSecs.Int()/1000));;
	    }
	iTimer.After(iStatus, aMicroSecs);
	iCaseStep = aStep;
	SetActive();
	}
Exemplo n.º 14
0
TBool CRKWindow::CheckResults()
	{
//
// Checks repeat results, first convert everything to 10th's as that what is actually used 
// for the timer in the window server.
//
// Return ETrue if the inacuracy in the average time is greater than 1/10th either way
// Allow initial 2/10ths either
// Allow min 2/10ths below
// Allow max 2/10ths above
//
	if (iState!=EStateInactive)
		return(ETrue);
	TInt initial=iInitialGap.Int()/100000;
	TInt initialX=iInitialRepeatSet.Int()/100000;
	if (initialX==0)
		initialX=1;
	TInt average=(iTotalGap.Int()/100000)/(iRepCount-1);
	TInt repeatX=iRepeatSet.Int()/100000;
	if (repeatX==0)
		repeatX=1;
	TInt min=iMinGap.Int()/100000;
	TInt max=iMaxGap.Int()/100000;
	if (average>(repeatX+1) || average<(repeatX-1))
		return(ETrue);
	if (initial>(initialX+2) || initial<(initialX-2))
		return(ETrue);
	if (min>(repeatX+1) || min<(repeatX-2))
		return(ETrue);
	if (max>(repeatX+3) || max<repeatX)
		return(ETrue);
	return(EFalse);
	}
Exemplo n.º 15
0
void CTKRepeat::TestKeyboardRepeatRateL(const TTimeIntervalMicroSeconds32 &aInitialTime, const TTimeIntervalMicroSeconds32 &aTime)
{
    do
    {
#if defined(LOGGING)
        const TInt KOneSec=1000000;
        const TInt KOneHundrethSec=KOneSec/100;
        TLogMessageText logMessageText;
        _LIT(KRepeatRate,"Repeat Rate Initial=%d.%02dsecs, Subsequent=%d.%02dsecs");
        logMessageText.Format(KRepeatRate,aInitialTime.Int()/KOneSec,(aInitialTime.Int()%KOneSec)/KOneHundrethSec
                              ,aTime.Int()/KOneSec,(aTime.Int()%KOneSec)/KOneHundrethSec);
        LOG_MESSAGE(logMessageText);
#endif
        TheClient->iWs.SetKeyboardRepeatRate(aInitialTime, aTime);
        iWin->SetKeyboardRepeatRate(aInitialTime, aTime);
        CActiveScheduler::Start();
        if (iAbort)
        {
            iTest->AbortL();
        }
    } while(CheckReportL());
}
Exemplo n.º 16
0
TInt requeue(TAny * anArg)
//
// Note that a requeue will run once every 200 ms until stop is called.
//
	{
	TTimeIntervalMicroSeconds32 tickPeriod;
	UserHal::TickPeriod(tickPeriod);
	const TInt K13Ticks = 13 * tickPeriod.Int();

	TInt index=(TInt)anArg;
	theTimer->Queue(K13Ticks*2/3,TheTimers[index]);
	return print(anArg);
	}
Exemplo n.º 17
0
TInt requeuePrevious(TAny * anArg)
//
// Requeue the previous entry (assumes previous entry is valid handle)
//
	{
	TTimeIntervalMicroSeconds32 tickPeriod;
	UserHal::TickPeriod(tickPeriod);
	const TInt K13Ticks = 13 * tickPeriod.Int();

	TInt index=(TInt)anArg - 1;
	theTimer->Queue(K13Ticks,TheTimers[index]);
	return print(anArg);
	}
Exemplo n.º 18
0
EXPORT_C TInt CBusyTestUnit::Start(TTimeIntervalMicroSeconds32 aDelayFor, TTimeIntervalMicroSeconds aRunFor)
	{
	iRunFor = aRunFor;
	if (!aDelayFor.Int())
		{
		// run immediately
		return RunThread();
		}
	else
		{
		iTimer = CPeriodic::NewL(CActive::EPriorityHigh);
		TCallBack callback(StaticTimerCallback, this);
		iTimer->Start(aDelayFor, 0, callback);
		return KErrNone;
		}
	}
Exemplo n.º 19
0
void CRKWindow::WinKeyL(const TKeyEvent &aKey,const TTime &aTime)
	{
	if (aKey.iCode==EKeyEscape)
		{
		CActiveScheduler::Stop();
		iTest->iAbort=ETrue;
		}
	if (aKey.iCode==32)
		{
		switch(iState)
			{
			case EStateWaitingForKeyCode:
				SetState(EStateWaitingForFirstRepeat);
				iPrevTime=aTime;
				break;
			case EStateWaitingForFirstRepeat:
				iRepCount=1;
				iInitialGap = I64LOW(aTime.MicroSecondsFrom(iPrevTime).Int64());
				SetState(EStateWaitingForNthRepeat);
				break;
			case EStateWaitingForNthRepeat:
				if (iRepCount==5)
					SetState(EStateWaitingForKeyUp);
				else
					{
					TTimeIntervalMicroSeconds32 gap(I64LOW(aTime.MicroSecondsFrom(iPrevTime).Int64()));
					if (gap<iMinGap)
						iMinGap=gap;
					if (gap>iMaxGap)
						iMaxGap=gap;
					iTotalGap=iTotalGap.Int()+gap.Int();	// Horrible way to do a +=
					iRepCount++;
					SetState(EStateWaitingForNthRepeat);
					}
			case EStateWaitingForKeyUp: 	// Do nothing here
				break;
			default:
				iTest->TestL(EFalse);
			}
		iPrevTime=aTime;
		}
	}
Exemplo n.º 20
0
TDesC& CRKWindow::Report()
	{
	if (iState!=EStateInactive)
		{
		iReport.Format(_L("Error, test not completed"));
		}
	else
		{
		TInt initial=iInitialGap.Int()/10000;
		TInt initialX=iInitialRepeatSet.Int()/10000;
		TInt average=(iTotalGap.Int()/10000/(iRepCount-1));
		TInt repeatX=iRepeatSet.Int()/10000;
		TInt min=iMinGap.Int()/10000;
		TInt max=iMaxGap.Int()/10000;
		iReport.Format(TRefByValue<const TDesC>(_L("Initial=%d [%d], Av=%d [%d], Min=%d, Max=%d")),initial,initialX,average,repeatX,min,max);
		}
	return(iReport);
	}
Exemplo n.º 21
0
void ScrShotsGenUtils::DumpJsFileL(CScrShotsSettings* scrShotsSettings)
{
    CGetImei* getImei = CGetImei::NewL();
    CleanupStack::PushL(getImei);
    RBuf8 formatBuf;
    formatBuf.Create(256);
    formatBuf.CleanupClosePushL();
    TFileName infoFile;
    
    User::LeaveIfError(CEikonEnv::Static()->FsSession().PrivatePath(infoFile));
    infoFile.Append( KDeviceJSFile );
    TParsePtrC parse((CEikonEnv::Static()->EikAppUi()->Application())->AppFullName());
    infoFile.Insert(0, KCDriveWithColon);
    
    RFs fsConn;
    User::LeaveIfError(fsConn.Connect());
    CleanupClosePushL(fsConn);
    RFile jsFile;
    if(BaflUtils::FileExists(fsConn, infoFile)){
        BaflUtils::DeleteFile(fsConn, infoFile);
    }
    //now create the file
    User::LeaveIfError(jsFile.Create(fsConn, infoFile, EFileWrite));
    CleanupClosePushL(jsFile);
    
//    User::LeaveIfError(jsFile.Write(KFunctionBlockStart));
    RBuf8 values;
    values.Create(256);
    for(int i = 0; i < KDeviceParamsCount ; i++){
        formatBuf.Zero();
        TInt sizeOfItem = User::StringLength((TText8 *)DeviceParams [i]);
        TPtr8 item((unsigned char*)DeviceParams [i],sizeOfItem ,sizeOfItem );
        switch(i){
            //device_model
            case 0:{
                CDeviceTypeInformation* devInfo = SysUtil::GetDeviceTypeInfoL();
                CleanupStack::PushL(devInfo);
                TPtrC manufName, modelCode, modelName;
                devInfo->GetManufacturerName(manufName);
                devInfo->GetModelCode(modelCode);
                devInfo->GetModelName(modelName);
                RBuf8 manufName8, modelName8, modelCode8;
                manufName8.Create(128); modelName8.Create(128); modelCode8.Create(128);
                manufName8.CleanupClosePushL(); modelName8.CleanupClosePushL(); modelCode8.CleanupClosePushL();
                manufName8.Copy(manufName);
                modelName8.Copy(modelName);
                modelCode8.Copy(modelCode);
                values.Format(KModelNameFormatString, &manufName8, &modelName8, &modelCode8);
                CleanupStack::PopAndDestroy(4);
                break;
            }
            //firmware_version
            case 1:{
                RBuf swVersion;
                swVersion.Create(128);
                SysUtil::GetSWVersion(swVersion);
                values.Copy(swVersion);
                TInt pos = 0;
                while((pos = values.Find(_L8("\n"))) != KErrNotFound){
                    //values.Delete(pos,1);
                    values.Replace(pos,1,_L8("_"));
                }
                swVersion.Close();
                break;
            }
            
            //ram_info
            case 2:{
                TInt totalram= 0;
                HAL::Get(HALData::EMemoryRAM, totalram);
                totalram /= 1024;
                values.Num(totalram);
                break;
            }
            
            //uptime
            case 3:{
                TTimeIntervalMicroSeconds32 iTickPeriod;
                UserHal::TickPeriod(iTickPeriod);
                TUint tickCount = User::TickCount();
                TUint noOfTicksPerSecond = (1000 * 1000) / iTickPeriod.Int();
                TInt noOfSecsSinceStartUp = tickCount / noOfTicksPerSecond;//noOfMicroSecsSinceStartup / (1000 * 1000);
                values.Num(noOfSecsSinceStartUp);
                break;
            }
            
            //scrshot count
            case 4:{
                values.Num(scrShotsSettings->TotalScrShotCount());
                break;
            }
            
            //symbian version
            case 5:{
                TVersion epocver = User::Version();
                values.Copy(epocver.Name());            
                break;
            }
            
            //series 60 version
            case 6:{
                VersionInfo::TPlatformVersion platformVersion;
                VersionInfo::GetVersion(platformVersion);
                TInt aMajor = platformVersion.iMajorVersion;
                TInt aMinor = platformVersion.iMinorVersion;
                values.Format(_L8("%d.%d"),aMajor, aMinor);
                break;
            }
            //country code
            case 7:{
            
                TLocale loc;
                int code = loc.CountryCode();
                values.Num(code);
                break;
            }
            //imei hash
            case 8:{
                TBuf8<256> inputimei;
                TBuf8<256> outimeihash;
                if(getImei->IsImeiFetched()){
                    getImei->GetImei(inputimei);
                    GetWhirlPoolHash(outimeihash,inputimei);
                    values.Copy(outimeihash);
                }
            }
            break;

        }
        
        formatBuf.Format(KStringVariableDeclaration, 
                &item, 
                &values);
        TRACE_ON(RDebug::Printf((const char*)formatBuf.PtrZ()));
        jsFile.Write(formatBuf);
    }
    values.Close();
    CleanupStack::PopAndDestroy(4);
    //TODO: This code should be commented in final release build
#if BRAHMA_DEBUG
    //code to copy the js file just created to the c:\ so that it can be analyzed
    _LIT(KTargetFileName, "c:\\device_info.js");
    BaflUtils::CopyFile(CEikonEnv::Static()->FsSession(),infoFile, KTargetFileName);
#endif
}
Exemplo n.º 22
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;
    }
Exemplo n.º 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;
    }
Exemplo n.º 24
0
int GetTimeFreq()
{ 
    TTimeIntervalMicroSeconds32 n;
	UserHal::TickPeriod(n);
    return Scale32(1000000,1,n.Int());
}
Exemplo n.º 25
0
TInt E32Main()
//
//
//
	{

	CMyActiveScheduler* s=NULL;
	TRAPD(ret,s=CMyActiveScheduler::NewL())
	test(ret==KErrNone);

	CActiveScheduler::Install(s);
	test.Title();
	test.Start(_L("Timer"));
	
	__KHEAP_MARK;

	TTimeIntervalMicroSeconds32 tickPeriod;
	UserHal::TickPeriod(tickPeriod);

	TRAP(ret,theTimer=CDeltaTimer::NewL(100, tickPeriod.Int()));
	test(ret==KErrNone);

	Mem::FillZ(theResults,10*sizeof(TInt));

	TCallBack callBacks[10]=
		{
		/* 0 */ TCallBack(print,(TAny*)0),
		/* 1 */ TCallBack(cancelNext,(TAny*)1),
		/* 2 */ TCallBack(print,(TAny*)2),	// Gets cancelled
		/* 3 */ TCallBack(print,(TAny*)3),		// Runs twice
		/* 4 */ TCallBack(requeuePrevious,(TAny*)4),
		/* 5 */ TCallBack(cancel2ndFollowing,(TAny*)5),
		/* 6 */ TCallBack(print,(TAny*)6),
		/* 7 */ TCallBack(cancelNext,(TAny*)7),	// Gets cancelled
		/* 8 */ TCallBack(requeue,(TAny*)8),	// Runs twice, once on the same RunL as the stop
		/* 9 */ TCallBack(stop,(TAny*)9),
		};

	theCallBacks=callBacks;
	for (TInt i=0;i<10;i++)
		TheTimers[i].Set(theCallBacks[i]);

	const TInt K13Ticks = 13 * tickPeriod.Int();

	theTimer->Queue(K13Ticks,TheTimers[0]);
	theTimer->Queue(2*K13Ticks,TheTimers[1]);
	theTimer->Queue(3*K13Ticks,TheTimers[2]);
	theTimer->Queue(4*K13Ticks,TheTimers[3]);
	theTimer->Queue(5*K13Ticks,TheTimers[4]);
	theTimer->Queue(6*K13Ticks,TheTimers[5]);
	theTimer->Queue(7*K13Ticks,TheTimers[6]);
	theTimer->Queue(8*K13Ticks,TheTimers[7]);
	theTimer->Queue(9*K13Ticks,TheTimers[8]);
	theTimer->Queue(10*K13Ticks,TheTimers[9]);

	CActiveScheduler::Start();

	test(theResults[0]==1);
	test(theResults[1]==1);
	test(theResults[2]==0);
	test(theResults[3]==2);
	test(theResults[4]==1);
	test(theResults[5]==1);
	test(theResults[6]==1);
	test(theResults[7]==0);
	test(theResults[8]==2);
	test(theResults[9]==1);

	delete theTimer;

	__KHEAP_MARKEND;

	test.End();
	return 0;
	}