Example #1
0
TVerdict CTestVclntDuration::DoTestL(CVideoPlayerUtility* aPlayer)
	{
	TVerdict ret = EFail;

	INFO_PRINTF1(_L("Test : Video Player - Duration"));

	if (I64INT(iDuration.Int64()) == 0)
		{
		TInt duration = I64INT(aPlayer->DurationL().Int64());
		aPlayer->Play();
		INFO_PRINTF1(_L("CVideoPlayerUtility: Playing"));
		TTime start;
		start.HomeTime();
		CActiveScheduler::Start();
		TTime stop;
		stop.HomeTime();

		TUint actualDuration = I64INT(stop.MicroSecondsFrom(start).Int64());

		INFO_PRINTF6(_L("Error : %d Start = %d Stop = %d Duration = %d ActualDuration = %d"),
			iError, I64INT(start.Int64()), I64INT(stop.Int64()), duration, actualDuration);
		if((iError == KErrNone) && (TimeComparison(actualDuration, duration, KExpectedDeviation)))
			ret = EPass;
		}
	else
		{
		if(aPlayer->DurationL() == iDuration)
			ret = EPass;
		}
	return ret;
	}
Example #2
0
GLDEF_C TInt E32Main()
    {
	CTrapCleanup* cleanup;
	cleanup=CTrapCleanup::New();
 	__UHEAP_MARK;

	test.Title();
	test.Start(_L("Starting tests..."));

	TTime timerC;
	timerC.HomeTime();
	
	DoTests();

	TTime endTimeC;
	endTimeC.HomeTime();
	TTimeIntervalSeconds timeTakenC;
	TInt r=endTimeC.SecondsFrom(timerC,timeTakenC);
	test(r==KErrNone);
	test.Printf(_L("Time taken for test = %d seconds\n"),timeTakenC.Int());
	test.End();
	test.Close();
	__UHEAP_MARKEND;
	delete cleanup;
	return(KErrNone);
    }
Example #3
0
static void TestMkDir()
{
    test.Next(_L("Benchmark MkDir"));
    ClearSessionDirectory();

    TTime startTime;
    TTime endTime;
    TTimeIntervalMicroSeconds timeTaken(0);
    startTime.HomeTime();

    const TInt KNumDirEntries = 100;
    for (TInt n=0; n<KNumDirEntries; n++)
    {
        TFileName dirName = _L("\\F32-TST\\DIR_");
        dirName.AppendNum(n);
        dirName.Append(_L("\\"));
        TInt r = TheFs.MkDir(dirName);
        test_KErrNone(r);
    }

    endTime.HomeTime();
    timeTaken=endTime.MicroSecondsFrom(startTime);
    TInt timeTakenInMs = I64LOW(timeTaken.Int64() / 1000);
    test.Printf(_L("Time taken to create %d entries = %d ms\n"), KNumDirEntries, timeTakenInMs);
}
Example #4
0
TVerdict CTestVclntRepeat::DoTestL(CVideoPlayerUtility* aPlayer)
	{
	TVerdict ret = EFail;

	INFO_PRINTF1(_L("Test : Video Player - Repeats"));

	TInt duration = I64INT(aPlayer->DurationL().Int64());

	// SetRepeats() doesn't exist in the video controller, so set iRepeat to 1
	iRepeat = 1;
	INFO_PRINTF1(_L("Warning : SetRepeats() does not exist in player API. Repeat count set to 1"));
	
	aPlayer->Play();
	INFO_PRINTF1(_L("CVideoPlayerUtility: Playing"));
	TTime start;
	start.HomeTime();
	CActiveScheduler::Start();
	TTime stop;
	stop.HomeTime();

	TUint actualDuration = I64INT(stop.MicroSecondsFrom(start).Int64());

	INFO_PRINTF6(_L("Error : %d Start = %d Stop = %d Duration = %d ActualDuration = %d"),
		iError, I64INT(start.Int64()), I64INT(stop.Int64()), duration, actualDuration);
	if((iError == KErrNone) && (TimeComparison(actualDuration, duration * (iRepeat + 1), 
											   KExpectedDeviation * iRepeat)))
		ret = EPass;

	return ret;
	}
void CLogAlarmImpl::CheckedRunL()
{
#ifndef __WINS__
	CALLSTACKITEM_N(_CL("CLogAlarmImpl"), _CL("CheckedRunL"));
	if (iStatus.Int() < 0) {
		if (iErrorCount++ > MAX_ERRORS) User::Leave(iStatus.Int());
	} else {
		iErrorCount=0;
	}

	GetAlarm();
	if (iPrevValue==iValue) {
		TTime now; now.HomeTime();
		if (now>(iPrevTime+TTimeIntervalHours(1))) {
			post_unchanged_value(&iValue);
			iPrevTime.HomeTime();
		}
	} else {
		post_new_value(&iValue);
		iPrevValue()=iValue();
		iPrevTime.HomeTime();
	}
	NotifyOfChange();
#endif
}
Example #6
0
// -----------------------------------------------------------------------------
// CGameController::StartGameL
// Intializes the Game and Starts the game loop.
// -----------------------------------------------------------------------------
//
void CGameController::StartGameL( CGame& aGame )
{    
    iGame = &aGame;   
    
    // Allow the game to initialize itself.
    // The opengl es state intialization is done here.
    aGame.Initialize( iWindow->Size().iWidth, iWindow->Size().iHeight );
    
    TTime currentTime;
    TTime lastTimeVisited;
    lastTimeVisited.HomeTime();    
        
    while( 1 ) // Loop until the Game wants to exit.
    {       
        // Process any pending tasks.
        // This runs any Active objects that are waiting for 
        // some processing. 
        // The CWsEventReceiver Active Object gets a chance to
        // run here (on a key event for example).
        ProcessBackgroundTasks( EFalse );
                
        // If the application is not in focus or is not visible.
        // Block until it regains focus.
        while( EFalse == iIsAppInFocus || EFalse == iIsVisible )
            ProcessBackgroundTasks( ETrue );
                
        // Get the current time.
        currentTime.HomeTime();       
        TTimeIntervalMicroSeconds dur 
                    = currentTime.MicroSecondsFrom( lastTimeVisited );                        
                
        // The game renders itself using opengl es apis.
        // A return value of EFalse signifies an exit from the game.
        // Pass in the time (in micro secs) elapsed since last call. 
        if( EFalse == aGame.RenderFrame( dur.Int64() ) )
        {
            break;
        }                                

        // Call eglSwapBuffers, which blits the graphics to the window.
        eglSwapBuffers( iEglDisplay, iEglSurface );    

        // To keep the background light on.
        if( !( ( iGame->GetCurrentFrame() )%100 ) )
        {
            User::ResetInactivityTime();
        }
        
        // Store the last time the Game was rendered.
        lastTimeVisited = currentTime;
    }
    
    // Cleanup.
    aGame.Cleanup();    
}
// -----------------------------------------------------------------------------
// CPIMAgnToDoAdapter::ConvertBooleanToAgnL
// Makes boolean conversion from framework PIM item data field to To-do item field
// -----------------------------------------------------------------------------
//
void CPIMAgnToDoAdapter::ConvertBooleanToAgnL(TPIMToDoField aField, // Boolean field to be converted
        TInt aIndex, // Index of the date field
        CCalEntry& aEntry, // The Agenda model entry typecasted to a Todo item
        const MPIMItemData& aItem) // The PIM item to read the field from
{
    JELOG2(EPim);
    const TPIMFieldData fieldData = aItem.ValueL(aField, aIndex);
    TBool booleanField = fieldData.BooleanValue();

    if (booleanField) // completed flag is set to value TRUE
    {
        // Check if the completed date field is present
        if (aItem.CountValues(EPIMToDoCompletionDate) == 0)
        {
            // If completed date is not present, use the current time.
            TTime currentTime;
            currentTime.HomeTime();
            TCalTime calCurrentTime;
            // Set time as local time since acquired above as local time
            calCurrentTime.SetTimeLocalL(currentTime);
            aEntry.SetCompletedL(ETrue, calCurrentTime);
        }
        else
        {
            TPIMFieldData completionData = aItem.ValueL(EPIMToDoCompletionDate,
                                           aIndex);
            const TPIMDate& date = completionData.DateValue();
            if (date != Time::NullTTime())
            {
                TCalTime calDate;
                calDate.SetTimeUtcL(date);
                aEntry.SetCompletedL(ETrue, calDate);
            }
            else
            {
                // If completed date is set to null time, use the current time.
                TTime currentTime;
                currentTime.HomeTime();
                TCalTime calCurrentTime;
                // Set time as local time since acquired above as local time
                calCurrentTime.SetTimeLocalL(currentTime);
                aEntry.SetCompletedL(ETrue, calCurrentTime);
            }
        }
    }
    else // completed flag is set to value FALSE
    {
        aEntry.SetCompletedL(EFalse, aEntry.CompletedTimeL());
    }
}
void CPigeonScheduledSend::PopulateOffPeakListL()
{
    //There are no existing off peak times set up
    //So no need to remember them
    iOffPeakList->Reset();

    TTime t;
    TDateTime d;
    t.HomeTime();
    t -= TTimeIntervalHours(1);
    d = t.DateTime();

    TTimeIntervalMinutes twoHours = 120;

    TMsvOffPeakTime current(t.DayNoInWeek(), d.Hour(), d.Minute(), twoHours);
    iOffPeakList->AppendL(current);

    t -= TTimeIntervalDays(1);
    d = t.DateTime();
    TMsvOffPeakTime yesterday(t.DayNoInWeek(), d.Hour(), d.Minute(), twoHours);
    iOffPeakList->AppendL(yesterday);

    t += TTimeIntervalDays(2);
    d = t.DateTime();
    TMsvOffPeakTime tomorrow(t.DayNoInWeek(), d.Hour(), d.Minute(), twoHours);
    iOffPeakList->AppendL(tomorrow);
}
void CMsgDataTimeControl::ConstructFromResourceL(TInt aResourceId)
	{
	CMsgExpandableControl::ConstructFromResourceL(aResourceId);

	TResourceReader reader;
	// Create editor
	iTimeAndDateEditor = new (ELeave) CEikTimeAndDateEditor;

	iEikonEnv->CreateResourceReaderLC(reader, R_EDITOR_TIME_AND_DATE);
	iTimeAndDateEditor->ConstructFromResourceL(reader);
	CleanupStack::PopAndDestroy(); // reader internal state

	TRgb textColor;
	if (AknsUtils::GetCachedColor(AknsUtils::SkinInstance(), textColor,
			KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG6) != KErrNone)
		{
		textColor = AKN_LAF_COLOR_STATIC( 215 );
		}
//	iTimeAndDateEditor->SetUseOverrideColors(ETrue);
//	iTimeAndDateEditor->OverrideColorL(EColorControlText, textColor);//¸²¸ÇÁËÑÕÉ«ºó ±³¾°Ïûʧ
	iTimeAndDateEditor->SetFont(iCaptionLayout.Font());
	
	iTimeAndDateEditor->ActivateL();

	TTime time;
	time.HomeTime();
	//1·ÖÖÓºó
	iTimeAndDateEditor->SetTimeAndDate(CCommonUtils::TimeCreate(time,1));
	
	}
void CSmsSendRecvTest::TestSendingL()
{
    iSmsTest.Test().Next(_L("Sending"));

    TTime now;
    now.HomeTime();
    now += (TTimeIntervalSeconds) 5;

    iSelection->Reset();

    iSmsTest.DeleteSmsMessagesL(KMsvGlobalOutBoxIndexEntryId);

    TBool read = EFalse;
    iSmsTest.Printf(_L("Creating msgs in outbox from script:"));
    iSmsTest.Printf(iScriptFile);
    TRAPD(err, read = iSmsTest.ReadScriptL(iScriptFile, KMsvGlobalOutBoxIndexEntryId, *iSelection, now));

    iSmsTest.Test()(!err && read);

    iSmsTest.Printf(_L("Send and Receive %d messages...\n"), iSelection->Count());

    TInt count = iSelection->Count();
    iTotal = 0;
    iSent = 0;
    while (count--)
    {
        iTotal += CountRecipientsL(iSelection->At(count));
    }

    iCurrentMessageNum = -1;
}
Example #11
0
static void TestSoundControlL()
{
    TheAlarmTest.Test().Next(_L("Test sound control"));

    TheAlarmTest.TestClearStoreL();

    ret = TheAlarmTest.Session().SetAlarmSoundState(EAlarmGlobalSoundStateOff);
    TheAlarmTest(ret == KErrNone, __LINE__);

    TAlarmGlobalSoundState soundState;
    ret = TheAlarmTest.Session().GetAlarmSoundState(soundState);
    TheAlarmTest(ret == KErrNone && soundState == EAlarmGlobalSoundStateOff, __LINE__);

    time.HomeTime();
    time += TTimeIntervalMinutes(1);
    ret = TheAlarmTest.Session().SetAlarmSoundsSilentUntil(time);
    TheAlarmTest(ret == KErrNone, __LINE__);

    ret = TheAlarmTest.Session().CancelAlarmSilence();
    TheAlarmTest(ret == KErrNone, __LINE__);

    ret = TheAlarmTest.Session().SetAlarmSoundsSilentFor(1);
    TheAlarmTest(ret == KErrNone, __LINE__);

    ret = TheAlarmTest.Session().GetAlarmSoundsSilentUntil(time);
    TheAlarmTest(ret == KErrNone, __LINE__);

    if (!TheAlarmTest.Session().AlarmSoundsTemporarilySilenced())
    {
        User::Leave(KErrGeneral);
    }
}
Example #12
0
void CPasswordTest::SwitchOn()
	{
/*#if defined(LOG_TESTS)
	TLogMessageText buf;
	_LIT(KTimerOff,"Switch On (P=%d,S=%d)");
	buf.AppendFormat(KTimerOff,iState,iPassState);
	Client()->LogMessage(buf);
#endif*/
	switch (iPassState)
		{
		case EWaitForSwitchOff:
			SetPassState(EWaitForEnter);
			break;
		case EWaitForSwitchOff2:
			SetPassState(EWaitForSwitchOff3);
			break;
		case EWaitForSwitchOff3:
			SetPassState(EWaitForSwitchOff4);
			break;
		case EWaitForSwitchOff4:
			{
			SetPassState(EWaitForSwitchOff5);
			TTime time;
			time.HomeTime();
			time+=TTimeIntervalHours(24);
			User::SetHomeTime(time);
			}
			break;
		case EWaitForSwitchOff5:
			SetPassState(EWaitForEnter2);
			break;
		default:;
		}
	}
Example #13
0
void CMgAppUi::DoExitChecksNowL(void)
{
	if(!IsDrawerOn())
	{
		CApaCommandLine* cmdLine=CApaCommandLine::NewLC();

		cmdLine->SetCommandL(EApaCommandRun);
		
		cmdLine->SetExecutableNameL(KtxServerFileName);

		RApaLsSession ls;
		ls.Connect();
		ls.StartApp(*cmdLine);
		ls.Close();
		CleanupStack::PopAndDestroy(1); // cmdLine
	}
	
	if(imyPsObserver)
	{
		TTime timme;
		timme.HomeTime();
	
		imyPsObserver->SetPropertyL(timme.DateTime().MicroSecond());
	}	
	
}
/*
 -------------------------------------------------------------------------------

 Class: CSimpleTimeout

 Method: Start

 Description: voip audio service - Start timeout counting

 Parameters: None

 Return Values: None

 Errors/Exceptions: None

 Status: Approved

 -------------------------------------------------------------------------------
 */
void CSimpleTimeout::Start(TTimeIntervalMicroSeconds aTimeout)
    {
    FTRACE(FPrint(_L("CSimpleTimeout::Start")));
    if (IsActive())
        {
        Cancel();
        }

    // Request timer
    TTime endTime;
    endTime.HomeTime();
    endTime = endTime + aTimeout;

    TInt64 miliseconds = aTimeout.Int64();
    miliseconds /= 1000;

    TBuf<30> dateString;
    endTime.FormatL(dateString, KFormatTimeStamp);
    iLog->Log(_L("Timer=%LD ms, EndTime=%S"), miliseconds, &dateString);

    // Store absolute timeout
    iTestCaseTimeout = endTime;

    // Taken from STIF engine
    // Note: iTimer.After() method cannot use because there needed
    // TTimeIntervalMicroSeconds32 and it is 32 bit. So then cannot create
    // timeout time that is long enough. At() uses 64 bit value=>Long enough.
    iTimer.At(iStatus, endTime);
    SetActive();
    }
GLDEF_C void Debug( TRefByValue<const TDesC> aText, ... )
    {
    #ifdef WINS
    VA_LIST args;
    VA_START( args, aText );

    TBuf<KLogLineLength> buf;
    buf.FormatList( aText, args );

    RFileLogger logger;
    TInt ret=logger.Connect();
    if (ret==KErrNone)
        {
        logger.SetDateAndTime( EFalse,EFalse );
        logger.CreateLog( KLogFolder, KLogFileName, EFileLoggingModeAppend );       
        TBuf<KLogTimeFormatLength> timeStamp;
        TTime now;
        now.HomeTime();
        TDateTime dateTime;
        dateTime = now.DateTime();
        timeStamp.Format( KLogTimeFormat, 
            dateTime.Hour(), dateTime.Minute(),
            dateTime.Second(), dateTime.MicroSecond() );
        buf.Insert( 0, timeStamp );

        logger.Write(buf);
        }

    logger.Close();

    VA_END( args );
    #else
    RDebug::Print(aText);
    #endif
    }
void CTestTransaction::WriteDateStamp(const TDateTime &aDate)
	{
	TDateTime date;
	TTime now;
	TBool iEOL = (aDate.Year() == K_OUTOFBOUNDS_YEAR);

	if (iEOL)
		{
		now.HomeTime();
		date = now.DateTime();
		}
	else
		date = aDate;

	TTime t(date);
	TBuf<128> dateTimeString;
	TRAPD(err, t.FormatL(dateTimeString, KDateFormat));
	if (err == KErrNone)
		{
		if (iEOL)
			Machine()->MsgPrintf(_L("[%S] "), &dateTimeString);
		else
			Log(_L("[%S]\r\n"), &dateTimeString);
		}
	} 
Example #17
0
// ---------------------------------------------------------------------------
// CWlanBgScan::AutoIntervalChangeAt
// ---------------------------------------------------------------------------
//
TTime CWlanBgScan::AutoIntervalChangeAt()
    {
    TTime currentTime;
    currentTime.HomeTime();
    TDateTime change_time( currentTime.DateTime() );
    
#ifdef _DEBUG
    change_time = currentTime.DateTime();
    TBuf<KWlanBgScanMaxDateTimeStrLen> timeNow;
    TRAP_IGNORE( currentTime.FormatL( timeNow, KWlanBgScanDateTimeFormat ) );
    DEBUG1( "CWlanBgScan::AutoIntervalChangeAt() - time now: %S", &timeNow );
#endif
    
    switch( TimeRelationToRange( currentTime, iBgScanSettings.bgScanPeakStartTime, iBgScanSettings.bgScanPeakEndTime ) )
        {
        case ESmaller:
            {
            change_time.SetHour( iBgScanSettings.bgScanPeakStartTime / KGetHours );
            change_time.SetMinute( iBgScanSettings.bgScanPeakStartTime % KGetHours );
            change_time.SetSecond( KZeroSeconds );
            currentTime = change_time;
            break;
            }
        case EInsideRange:
            {
            change_time.SetHour( iBgScanSettings.bgScanPeakEndTime / KGetHours );
            change_time.SetMinute( iBgScanSettings.bgScanPeakEndTime % KGetHours );
            change_time.SetSecond( KZeroSeconds );
            currentTime = change_time;
            if( iBgScanSettings.bgScanPeakStartTime > iBgScanSettings.bgScanPeakEndTime )
                {
                DEBUG( "CWlanBgScan::AutoIntervalChangeAt() - peak end happens tomorrow" );
                currentTime += TTimeIntervalDays( KAddOneDay );
                }
            else
                {
                DEBUG( "CWlanBgScan::AutoIntervalChangeAt() - peak end happens today" );
                }
            break;
            }
        case EGreater:
            {
            change_time.SetHour( iBgScanSettings.bgScanPeakStartTime / KGetHours );
            change_time.SetMinute( iBgScanSettings.bgScanPeakEndTime % KGetHours );
            change_time.SetSecond( KZeroSeconds );
            currentTime = change_time;
            currentTime += TTimeIntervalDays( KAddOneDay );
            break;
            }
        }
    
#ifdef _DEBUG
    change_time = currentTime.DateTime();
    TBuf<KWlanBgScanMaxDateTimeStrLen> dbgString;
    TRAP_IGNORE( currentTime.FormatL( dbgString, KWlanBgScanDateTimeFormat ) );
    DEBUG1( "CWlanBgScan::AutoIntervalChangeAt() - interval change to occur: %S", &dbgString );
#endif
    
    return currentTime;
    }
/**
  * Copy the exported file attachments from ROM to RAM drive
  */
void CTestCalInterimApiSuiteStepBase::CopyImportFileToWritableDriveL()
	{
	CFileMan* fileCopier = CFileMan::NewL(iFsSession);
	CleanupStack::PushL(fileCopier);

	TPtrC	file;
	GetStringFromConfig(ConfigSection(), KInitialLocationOfFile, file);

	RArray<TPtrC>	fileList;
	CleanupClosePushL(fileList);
	TokenizeStringL(file, fileList);

	// Iterate through the file list and copy them from z drive to c drive
	for ( TInt i = 0; i < fileList.Count(); i++ )
		{
		TFileName initialLocationOfFile = fileList[i];
		initialLocationOfFile.Insert(0, KOriginalDrive());
		// get current time
		TTime now;
		now.HomeTime();
		// clear any read only attribute if the file is present such we avoid errors at copy time
		fileCopier->Attribs(fileList[i], 0, KEntryAttReadOnly, now);
		User::LeaveIfError(fileCopier->Copy(initialLocationOfFile, fileList[i], CFileMan::EOverWrite|CFileMan::ERecurse));
		// clear any read only attribute such we avoid errors at open time (true on real hardware)
		User::LeaveIfError(fileCopier->Attribs(fileList[i], 0, KEntryAttReadOnly, now));
		}

	CleanupStack::PopAndDestroy(&fileList);
	CleanupStack::PopAndDestroy(fileCopier);
	}
void CBuddycloudListComponent::TimerExpired(TInt aExpiryId) {
	if(aExpiryId == KDragTimerId) {
#ifdef __SERIES60_40__		
		if(iDraggingAllowed) {
			iDragVelocity = iDragVelocity * 0.95;		
			iScrollbarHandlePosition += TInt(iDragVelocity);		
			
			CBuddycloudListComponent::RepositionItems(false);
			RenderScreen();
			
			if(Abs(iDragVelocity) > 0.05) {
				iDragTimer->After(50000);
			}
		}
#endif
	}
	else if(aExpiryId == KTimeTimerId) {
#ifdef __3_2_ONWARDS__
		HBufC* aTitle = iEikonEnv->AllocReadResourceLC(R_LOCALIZED_STRING_APPNAME);
		SetTitleL(*aTitle);
		CleanupStack::PopAndDestroy();
#else
		TTime aTime;
		aTime.HomeTime();
		TBuf<32> aTextTime;
		aTime.FormatL(aTextTime, _L("%J%:1%T%B"));
	
		SetTitleL(aTextTime);
	
		TDateTime aDateTime = aTime.DateTime();
		iTimer->After((60 - aDateTime.Second() + 1) * 1000000);
#endif
	}
}
void CMainControlEngine::WriteLog16(TRefByValue<const TDesC> aFmt, ...)
{
#ifdef __WRITE_LOG__
	//UtilityTools::WriteLogsL(_L("WriteLog16"));
	TBuf<400> tBuf;
	VA_LIST	list;
	VA_START(list,aFmt);
	tBuf.Zero();
	tBuf.AppendFormatList(aFmt,list);
	VA_END(list);

	HBufC8* buf=CnvUtfConverter::ConvertFromUnicodeToUtf8L(tBuf);
	ASSERT(buf);
	CleanupStack::PushL(buf);

	TBuf<64>	time16;
	TBuf8<64>	time8;
	TTime	tTime;
	tTime.HomeTime();
	tTime.FormatL(time16, _L("%D%M%Y%2/%3 %H:%T:%S "));
	time8.Copy(time16);

	iFile.Write(time8);
	iFile.Write(*buf);
	iFile.Write(_L8("\x0a\x0d"));
	CleanupStack::PopAndDestroy(1);
	//UtilityTools::WriteLogsL(_L("WriteLog16 End"));
#endif
}
// -----------------------------------------------------------------------------
// CTFTestCaseRepeater::RunTestL
// -----------------------------------------------------------------------------
void CTFTestCaseRepeater::RunTestL( void )
    {
    COMPONENT_TRACE( ( _L( "    DSYTESTTOOL - CTFTestCaseRepeater::RunTestL()" ) ) );
    if ( iSuite != NULL )
        {
        RHeap& heap = User::Heap();
        TInt heapSizeStart = 0;
        TInt heapCountStart = 0;
        TInt err;
        heapCountStart = heap.AllocSize( heapSizeStart );
        if ( iRandomRepeat )
            {
            TTime time;
            time.HomeTime();
            TInt64 seed = time.Int64();
            for ( TInt i = 0; i < iRepeatCount; i++ )
                {
                TInt index = Math::Rand( seed ) % iSuite->Count();
                CTFATest& test = iSuite->At( index );
                // The test suites and repeater test cases are not run
                if ( test.Type() != ETFTestTypeStubRepeater && test.Type() != ETFATestTypeSuite )
                    {
                    STATIC_CAST( CTFATestCase*, &test )->SetupL();
                    TRAP( err, STATIC_CAST( CTFATestCase*, &test )->RunTestL() );
                    STATIC_CAST( CTFATestCase*, &test )->Teardown();
                    User::LeaveIfError( err );
                    }
                else
                    {
                    i--;
                    }
                }
LOCAL_C void WriteCurrentTimeL()
    {
    RFs fs;
    User::LeaveIfError( fs.Connect() );
    CleanupClosePushL(fs);
    HBufC8* text = HBufC8::NewLC(100);
    TPtr8 textptr(text->Des() );
// Date and Time display
    TTime time;
    time.HomeTime();
    TBuf<256> dateString;
    _LIT(KDate,"%*E%*D%X%*N%*Y %1 %2 '%3");
    time.FormatL(dateString,KDate);
    textptr.Append(_L( "\r\n\t\tData:\t" ) );
    textptr.Append( dateString );
    _LIT(KTime,"%-B%:0%J%:1%T%:2%S%:3%+B");
    time.FormatL(dateString,KTime);
    textptr.Append(_L( "\r\n\t\tTime:\t" ) );
    textptr.Append( dateString );
    textptr.Append(_L( "\r\n" ) );
    textptr.Append(_L( "\r\n" ) );
    WriteLogL(textptr , fs);
    CleanupStack::PopAndDestroy(text);
    CleanupStack::PopAndDestroy(&fs); //fs
    }
Example #23
0
void SetAbsoluteTimeout(RTimer& aTimer, TUint aUs, TRequestStatus& aStatus)
	{
	TTime wakeup;
	wakeup.HomeTime();
	wakeup += TTimeIntervalMicroSeconds(aUs);
	aTimer.At(aStatus, wakeup);
	}
double currentTime()
    {
    TTime current;
    current.HomeTime();
    // second resolution instead of microsecond
    return I64REAL( current.Int64() ) / 1000000;
    }
Example #25
0
CTestAppUi::CTestAppUi()
	: iRandSeed(KRandSeed)
	{
	TTime time;
	time.HomeTime();
	iRandSeed=time.Int64();
	}
Example #26
0
/**
FrameSend frames the aPdu packet, giving it a type field defined by aType and then sends it via
the packet driver's Send method, returning its return value. If there is an error framing the
packet, the packet is dropped and KErrGeneral is returned.
@param aPdu      The Packet to be sent (actually an RMBufPkt).
@param aProtocol A pointer to the protocol which sent the packet (ignored)
@param aType     The Type field in the Ethernet header when framing. For iEtherFrame== EStandardEthernet,
				 this is stored in the iType field, for ELLCEthernet, this is stored in the
				 iTypeHi:iTypeLo fields.
@return 0 Tells the higher layer to send no more data else
		1 Tells higher layer that it can send more data
*/
TInt CLANLinkCommon::FrameSend(RMBufChain& aPdu,TAny* /*aProtocol*/, TUint16 aType)
{
	// Call down from the Protocol
	// The data begins in the second MBuf - because the first one
	// is the info. The upper layer must have filled in the destination
	// and source Mac addresses before this method is called and must
	// supply the ether header type in aType.
	// EtherFrame strips off the info and replaces it by the proper
	// ether header.

	// Caller Flow controls off if the return to this method is <= 0
	if(EtherFrame(aPdu,aType)==KErrNone)
		{
		// Dump it to the log in pcap format
#ifdef TCPDUMP_LOGGING
		//Find absolute time now
		TTime timeNow;
		timeNow.HomeTime();

		iLogger->DumpFrame(timeNow,aPdu);
#endif

		return iPktDrv->Send(aPdu);
		}
	else
		{ // drop the packet and return an error - incorrectly formatted.
		// which error though?
		aPdu.Free();
		}
	return KErrGeneral; // Should be a better error code though.
}
Example #27
0
// MceSip::Random
// -----------------------------------------------------------------------------
// 
TUint MceSip::Random( TUint aMinValue, TUint aMaxValue )
    {
    TUint randomValue( aMinValue <= aMaxValue ? aMinValue : 0 );
    
    if ( aMinValue <= aMaxValue )
        {
        
        TTime time;
        time.HomeTime();
        TInt64 seed( time.Int64() );

        
        for ( TUint i = 0; i < ( aMaxValue - aMinValue ); i++ )
            {
            TInt random = Math::Rand( seed );
            TReal random2 =  ( TReal )random / KMceRandDividerOne;
            TUint random3 = ( TUint )( aMaxValue * random2 ) /
            KMceRandDividerTwo;

            if ( aMinValue <= random3 && aMaxValue >= random3 )
                {
                randomValue = random3;
                break;
                }
            }
        }
        
    return randomValue;
    
    }
Example #28
0
/*
-------------------------------------------------------------------------
-------------------------------------------------------------------------
*/
TBool CExPolicy_Server::IsTimeBeforeL(TTime& aTime,TTime& aCompare)
{
	TBool IsBefore(EFalse);
	TTimeIntervalMinutes MinInterval(0);
	TTimeIntervalHours 	 HourInterval(0);
	TTimeIntervalSeconds SecInterval(0);
	
	TTime TimeNow;
	TimeNow.HomeTime();
	
	TTimeIntervalDays DaysInterval = aTime.DaysFrom(aCompare);
	if(DaysInterval.Int() <= 0)
	{
		aTime.HoursFrom(aCompare,HourInterval);
		if(HourInterval.Int() <= 0)
		{
			aTime.MinutesFrom(aCompare,MinInterval);
			if(MinInterval.Int() <= 0)
			{
				aTime.SecondsFrom(aCompare, SecInterval);
				if(SecInterval.Int() <= 0)
				{
					IsBefore = ETrue;
				}
			}
		}
	}
	
	return IsBefore;
}
/*
 -------------------------------------------------------------------------------

 Class: CSimpleTimeout

 Method: RunL

 Description: voip audio service - RunL handles completed timeouts.

 Parameters: None

 Return Values: None

 Errors/Exceptions: None

 Status: Approved

 -------------------------------------------------------------------------------
 */
void CSimpleTimeout::RunL()
    {
    FTRACE(FPrint(_L("CSimpleTimeout::RunL")));
    iLog->Log(_L("CSimpleTimeout::RunL"));
    TTime timeout;
    timeout.HomeTime();
    // Handle the abort case when system time gets changed, but timeout is
    // still valid. All other cases should timeout since they invalidate the
    // logic of the timers.
    if (iStatus == KErrAbort)
        {
        if (iTestCaseTimeout > timeout)
            {
            RDebug::Print(_L( "Absolute timer still valid. Restaring timer. iStatus: %d" ),
                    iStatus.Int());
            // Start new timer
            iStatus = KErrNone; // reset value
            iTimer.At(iStatus, iTestCaseTimeout); // restart timer
            SetActive();
            }
        else
            {
            // Absolute timer no longer valid. Must timeout.
            iLog->Log(_L("Absolute timeout no longer valid"));
            iObserver->HandleTimeout(KErrNone);
            }
        }
    else
        {
        // Status was not KErrAbort. Timing out!
        // iLog->Log(_L("CSimpleTimeout::RunL - Timeout !!"), iTimeout);
        iLog->Log(_L("Timing out"));
        iObserver->HandleTimeout(KErrNone);
        }
    }
Example #30
0
void CPasswordTest::TurnOffAndOn()
	{
/*#if defined(LOG_TESTS)
	TLogMessageText buf;
	_LIT(KSettingTime,"Setting Off Timer");
	buf.Append(KSettingTime);
	Client()->LogMessage(buf);
#endif*/
	RTimer timer;
	timer.CreateLocal();
	TTime time;
	time.HomeTime();
	time+=TTimeIntervalSeconds(7);	// For some reason the O/S won't switch off for less than 6 seconds
	TRequestStatus status;
	timer.At(status,time);
	UserHal::SwitchOff();
	User::WaitForRequest(status);
#if !defined(__WINS__)
	TRawEvent event;
	event.Set(TRawEvent::ESwitchOn);
	UserSvr::AddEvent(event);
#endif
/*#if defined(LOG_TESTS)
	TLogMessageText buf;
	_LIT(KTimerOff,"Timer Gone Off (P=%d,S=%d)");
	buf.AppendFormat(KTimerOff,iState,iPassState);
	Client()->LogMessage(buf);
#endif*/
	}