Пример #1
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;
	}
Пример #2
0
EXPORT_C TBool TWsGraphicMsgAnimation::IsPlaying(const TTime& aNow,const TTimeIntervalMicroSeconds& aAnimationLength) const
	{
	// an animation to time?
	if(aAnimationLength <= 0LL)
		{
		return EFalse;
		}
	switch(iFlags & EStateMask)
		{
		case EPaused:
			return EFalse;
		case EStopping:
			{
			const TInt64 elapsed = (aNow.Int64() - iPlay.Int64());
			if(elapsed <= aAnimationLength.Int64())
				{
				return ETrue;
				}
			return EFalse;
			}
		case EStopped:
			return EFalse;
		case EPlaying:
			{
			const TInt64 elapsed = (aNow.Int64() - iPlay.Int64());
			if((iFlags & ELoop) || (elapsed <= aAnimationLength.Int64()))
				{
				return ETrue;
				}
			return EFalse;
			}
		default:
			return EFalse;
		}
	}
/**
Tests UpdateVisited() API
@internalTechnology
@test
@param		Reference to handle to the bookmark that is under test
@return		None
*/
void CTestUpdateVisitedStep::DoTest(RBkBookmark& aBookmark)
	{
	const TInt KOneSecond = 1000000;
	TTime initialTime;
	// Set the time to universal time
	initialTime.UniversalTime();
	INFO_PRINTF2(_L("Current time before updating = %Ld"), initialTime.Int64());
	INFO_PRINTF1(_L("Updating LastVisited..."));

	// Call updatevisited after one second
	User::After(KOneSecond);
	aBookmark.UpdateVisited();
	TTime lastVisitedTime = aBookmark.LastVisited();
	INFO_PRINTF2(_L("LastVisitedTime after updating = %Ld"), lastVisitedTime.Int64());

	// Check whether last visited is greater than the initial time
	if(lastVisitedTime <= initialTime)
		{
		INFO_PRINTF1(_L("LastVisited was not updated properly"));
		SetTestStepResult(EFail);
		}
	else
		{
		INFO_PRINTF1(_L("LastVisited was updated properly"));
		}
	}	// DoTest
Пример #4
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;
	}
Пример #5
0
//Returns approximate difference (rounded down?) in seconds
EXPORT_C TInt CSchSendTestUtils::DiffInSecs(TTime d1, TTime d2)
	{
	iRTest<<d1<<d2;
	TInt64 diffUs64 = d1.Int64() - d2.Int64();
	TInt64 diffSecs64 = diffUs64 / (1000000);
	TInt diffSecs32 = I64INT(diffSecs64);
	return diffSecs32;
	}
// --------------------------------------------------------------------------------------
// Generates random CID
// --------------------------------------------------------------------------------------
//
void CXmlEngSerializerXOP::GenerateRandomCid(TDes8& aCid)
    {
    _LIT8(KAt, "@");
    //generate random CID as <randomNumber>@<homeTime>
	TTime now;
	now.HomeTime();
	TInt64 homeTime = now.Int64();
	TUint32 randomNumber = Math::Random();
	aCid.AppendNum(randomNumber);
	aCid.Append(KAt);
	aCid.AppendNum(now.Int64());
    }
// -----------------------------------------------------------------------------
// CSTSCredentialManager::CheckSearchResultsL
// Check key search results, generate CSR
// -----------------------------------------------------------------------------
void CSTSCredentialManager::CheckSearchResultsL()
{
    // we take the first key with valid dates
    TInt keyCount = iKeyInfoArray->Count();
    CCTKeyInfo* keyInfo = NULL;
    TTime timeNow;
    timeNow.UniversalTime();

    TBool found = EFalse;
    TInt keyIndex = 0;

    for (TInt i = 0; (i < keyCount) && (!found); i++)
    {
        keyInfo = iKeyInfoArray->operator[](i);
        TTime startDate = keyInfo->StartDate();
        if ((startDate.Int64() == 0) || (timeNow >= startDate))
        {
            // startDate was not set or is before current time
            // exactly same time is valid as well
            TTime endDate = keyInfo->EndDate();
            if ((endDate.Int64() == 0) || (timeNow < endDate))
            {
                // endDate was not set or is after current time
                // exactly same time is not valid
                // (the key expires immediatelly)
                if (keyInfo->Size() == iKeyLen)
                {
                    // key must have same size
                    found = ETrue;
                    keyIndex = i;
                }
            }
        }
    }
    if (!found)
    {
        Complete(KSTSErrSeNoKeys);
        return;
    }

    if (iKeyInfo)
    {
        iKeyInfo->Release();
    }
    iKeyInfo = keyInfo;
    // iKeyInfo is no longer owned by iKeyInfoArray
    iKeyInfoArray->Remove(keyIndex);

    CSRDialog();
}
Пример #8
0
void CSyncEngineWrap::ConstructL()
	{
	//create suspended thread
	_LIT(KThreadName, "SyncThreadEntryPoint");

	TBuf<30> threadName;
	threadName.Append(KThreadName);

	TTime time;
	time.HomeTime();

	TInt64 aSeed = time.Int64();
	TInt randNum = Math::Rand(aSeed) % 1000;
	threadName.AppendNum(randNum);

	//KMinHeapSize, 256*KMinHeapSize                                 
	//TInt res = thread.Create(threadName, SyncThreadEntryPoint, 20000, 0x100000, 0x3D4000, this);
	TInt res = thread.Create(threadName, SyncThreadEntryPoint, 20000, 0x5000,
			0x600000, this);

	if (res != KErrNone)
		Panic(ERhodesSyncEngineInit);

	thread.SetPriority(EPriorityNormal);
	}
Пример #9
0
TVpnPolicyId CPolicyStore::NewPolicyIdL()
    {
    TUuid uuid;
    TUuidString uuidString;
    
    Uuid::MakeUuidL(uuid);

    // It has become apparent that certain
    // Symbian OS devices generate duplicate random
    // number sequences after gold boot due to improper
    // seeding of the random number generator. Should
    // this happen to be the case, we insert at least
    // one component to the UUID that depends on the 
    // current system time. This is not perfect, but 
    // should give us policy IDs that are unique enough.
    TTime now;
	now.UniversalTime();
    TInt64 randSeed = now.Int64();
    TInt randomNum = Math::Rand(randSeed);
    uuid.iTimeLow = static_cast<TUint32>(randomNum);
    
    Uuid::UuidToString(uuid, uuidString);

    TVpnPolicyId newPolicyId;
    newPolicyId.Copy(uuidString);
    
    return newPolicyId;
    }
Пример #10
0
LOCAL_C void baseRomImage()
//
// Set base addresses for the ROM image.
//
	{

	test.Start(_L("Setting up the header"));
	Mem::FillZ(&TheRomHeader,sizeof(TRomHeader));
	test.Printf(_L("1"));
	TheRomHeader.iVersion=TVersion(1,0,1);
	test.Printf(_L("2"));
	TTime t;
	t.HomeTime();
	test.Printf(_L("3"));
	TheRomHeader.iTime=t.Int64();
	test.Printf(_L("4"));
	TheRomHeader.iRomBase=UserSvr::RomHeaderAddress();
	test.Printf(_L("5"));
	TheRomHeader.iRomRootDirectoryList=TheCurrentBase=UserSvr::RomHeaderAddress()+sizeof(TRomHeader);
	test.Printf(_L("6"));
//
	test.Next(_L("Set dirs base"));
	TheRootDir->SetBaseDirs();
//
	test.Next(_L("Set files base"));
	TheRootDir->SetBaseFiles();
	TheRomHeader.iRomSize=TheCurrentBase-UserSvr::RomHeaderAddress();
//
	test.End();
	}
Пример #11
0
double currentTime()
    {
    TTime current;
    current.HomeTime();
    // second resolution instead of microsecond
    return I64REAL( current.Int64() ) / 1000000;
    }
Пример #12
0
EXPORT_C CWatcherBase::CWatcherBase(TInt aPriority)
:	CActive(aPriority)
	{
	CActiveScheduler::Add(this);

#ifdef WATCHER_TESTING    
    //-- this section of code is used by TE_TelWatchers(Unit) test 
	TTime now;
	now.UniversalTime();
	TheSeed = now.Int64();

    //-- define properties for test purposes
    OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CWATCHERBASE_CTOR_1, "CTelWatcherBase : defining properties for testing");
   
    //-- For debugging purposes only, used by TE_TelWatchers(Unit).

    //- this property change (to any value) informs that CTelPhoneWatcher has re-read modem table from commdb in
    //- CTelPhoneWatcher::DoRetrieveTSYNameL(). 
    RProperty::Define(KUidSystemCategory, KUidTestProp_ModemTableRefreshed.iUid, RProperty::EInt);  
  
    //- this property changes in CTelPhoneWatcher::HandleModemChangedL()
    //- when the commsdb modem record has changed
    RProperty::Define(KUidSystemCategory, KUidTestProp_ModemRecordChanged.iUid, RProperty::EInt);
    
    //-- this property is used in CIndicatorWatcher::HandleIndicatorUpdateL()
    //-- to simulate call state change by t_watchers test
    RProperty::Define(KUidSystemCategory, KUidTestProp_CallStateChange.iUid, RProperty::EInt);

    //-- this property is used to disable and reset phone watchers
    RProperty::Define(KUidSystemCategory, KUidTestProp_WatchersDisable.iUid, RProperty::EInt);    
#endif
	}
Пример #13
0
CTestAppUi::CTestAppUi()
	: iRandSeed(KRandSeed)
	{
	TTime time;
	time.HomeTime();
	iRandSeed=time.Int64();
	}
Пример #14
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;
    
    }
// ---------------------------------------------------------
// CT_LbsInstallPsyTp273::NotifyPositionUpdate
// 
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CT_LbsInstallPsyTp273::NotifyPositionUpdate(
	TPositionInfoBase& aPosInfo,
    TRequestStatus& aStatus)
	{
	TInt err = KErrNone;
    
    TTime tt;
    tt.UniversalTime();
    //Request ID must be unique, use universalime as seed
    // to give a random number
    TInt64 seed = tt.Int64();
    TReal lat = 90 * Math::FRand(seed);
    TReal lon = 90 * Math::FRand(seed);
    TReal32 alt = (TReal32)(90 * Math::FRand(seed));
    TPositionInfo* position = static_cast<TPositionInfo*> (&aPosInfo);
    TUid implUid = { KPosImplementationUid };
    position->SetModuleId(implUid);

    TTime now;
    now.UniversalTime();          

    TPosition posse;
    posse.SetCoordinate(lat, lon, alt);
    posse.SetTime(now);
    position->SetPosition(posse);

    TRequestStatus* status = &aStatus;
	User::RequestComplete(status, err);
    }
// -----------------------------------------------------------------------------
// 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--;
                    }
                }
Пример #17
0
CRandomBlobStep::CRandomBlobStep() : CPerformanceFunctionalityBase( KNumberOfContacts )
	{
	SetTestStepName(KRandomBlobStep);
	TTime time;
	time.UniversalTime();
	iSeed = time.Int64();
	}
Пример #18
0
OrganizerItemGuidTransform::OrganizerItemGuidTransform()
{
    // Set seed for qrand()
    TTime homeTime;
    homeTime.HomeTime();
    uint seed = (uint) homeTime.Int64();
    qsrand(seed);
}
Пример #19
0
CDnsSocketWriter::CDnsSocketWriter(CDnsSocket &aMaster) : CActive(0), iMaster(aMaster)
	{
	LOG(Log::Printf(_L("CDnsSocketWriter[%u]::CDnsSocketWriter([%u])"), this, &aMaster));
	CActiveScheduler::Add(this);

	TTime seed;
	seed.UniversalTime();
	iSequence = seed.Int64();
	}
Пример #20
0
void FillRandomData(TDes& aData)
	{
	// get random seed
	TTime time;
	time.UniversalTime();
	TInt64 seed = time.Int64();
	// do the filling
	FillRandomData(aData, seed);
	}
Пример #21
0
CTestAppUi::CTestAppUi()
	: iRandSeed(KRandSeed),
	  iDoKills(EFalse),
	  iIsServerEventTimeOutEnabled(ETrue)
	{
	TTime time;
	time.HomeTime();
	iRandSeed=time.Int64();
	}
Пример #22
0
TInt CCommonUtils::Rand(TInt aMax,TInt aMin)
	{
	TTime now;
	now.HomeTime();
	TInt64 iSeed = now.Int64();
	
	TInt random = (Math::Rand(iSeed) % aMax) + aMin;
	return random;
	}
Пример #23
0
void get_random_seed(void **randseed, int *randseedsize) {
    TInt64 *now = snew(TInt64);
    
    TTime time;
    time.UniversalTime();
    *now = time.Int64();
    
    *randseed = now;
    *randseedsize = sizeof(now);
}
// ---------------------------------------------------------------------------
// CTransactionIDGenerator::CTransactionIDGenerator
// ---------------------------------------------------------------------------
//
CTransactionIDGenerator::CTransactionIDGenerator()
    {
    TUint ticks = User::TickCount();
    TTime now;
    now.UniversalTime();
    TInt64 us = now.Int64();

    iSeed = static_cast<TInt64>( ticks ) + us;
    iCounter = I64LOW( us ) - ticks;
    }
Пример #25
0
/*
** Find the current time (in Universal Coordinated Time).  Write the
** current time and date as a Julian Day number into *prNow and
** return 0.  Return 1 if the time and date cannot be found.
*/
int symTime(
    sqlite3_vfs* /*pVfs*/, 
    double* prNow )
{
    TTime now;
    now.UniversalTime();
    
    *(TInt64*)prNow = now.Int64();
    return 0;
}
Пример #26
0
void DoInserts(TInt aProcId, TInt aRecId1, TInt aRecId2)
	{
	TEST(TheDb != 0);
	
	TTime now;
	now.UniversalTime();
	TInt64 seed = now.Int64();
	
	const TInt KMaxFailingAllocationNo = 20;
	TInt lockcnt = 0;
	
	for(TInt recno=0;recno<KTestRecordCnt;)
		{
		//Insert record 1 under OOM simulation
		TInt failingAllocationNo = Math::Rand(seed) % (KMaxFailingAllocationNo + 1);
		__UHEAP_SETFAIL(RHeap::EDeterministic, failingAllocationNo );
		TBuf8<100> sql;
		sql.Format(_L8("INSERT INTO A VALUES(%d)"), aRecId1);
		TInt err = sqlite3_exec(TheDb, (const char*)sql.PtrZ(), 0, 0, 0);
		__UHEAP_SETFAIL(RHeap::ENone, 0);	
		TEST(err == SQLITE_NOMEM || err == SQLITE_BUSY || err == SQLITE_OK);
		if(err == SQLITE_BUSY)
			{
			++lockcnt;
			User::After(1);
			continue;	
			}
		else if(err == SQLITE_OK)
			{
			++recno;
			if((recno % 100) == 0)
				{
				RDebug::Print(_L("Process %d: %d records inserted.\r\n"), aProcId, recno);	
				}
			continue;	
			}
		//Insert record 2
		sql.Format(_L8("INSERT INTO A VALUES(%d)"), aRecId2);
		err = sqlite3_exec(TheDb, (const char*)sql.PtrZ(), 0, 0, 0);
		TEST(err == SQLITE_BUSY || err == SQLITE_OK);
		if(err == SQLITE_BUSY)
			{
			++lockcnt;
			User::After(1);
			continue;	
			}
		//SQLITE_OK case
		++recno;
		if((recno % 100) == 0)
			{
			RDebug::Print(_L("Process %d: %d records inserted.\r\n"), aProcId, recno);	
			}
		}
	RDebug::Print(_L("Process %d inserted %d records. %d locks occured.\r\n"), aProcId, KTestRecordCnt, lockcnt);
	}
// -----------------------------------------------------------------------------
// CBTGPSRequestManager::HandleMessage
// -----------------------------------------------------------------------------
void CBTGPSRequestManager::HandleMessage(const TBTGPSNmeaParser& aParser)
    {
    //Add the received message to buffer
    iNmeaBuffer->AddSentences(aParser.NmeaSentence());
    //Add 0x0d 0x0a
    iNmeaBuffer->AddSentences(KBTGPSNmeaTerminator);
    
    //Parse the message
    CBTGPSFix::TParsingStatus err = iFix->ParseMessage(aParser);

    //Check if we have received a valid sentence
    if(err == CBTGPSFix::EInfoUpdated)
        {
        if(iFix->IfFullNmeaPatternReceived())
            {
            TTime gsvTime = iFix->GsvTime();
            TTime now;
            now.UniversalTime();
            TRACESTRING2("CBTGPSRequestManager:: Now time = %d", now.Int64())
            TRACESTRING2("CBTGPSRequestManager:: GSV time = %d", gsvTime.Int64())
            if(gsvTime!=0 && now.MicroSecondsFrom(gsvTime)< 
                CBTGPSRequestHandler::ConstantsManager().iSatelliteInfoLifeTime)
                {
                //GSV information is still valid, set fix as valid
                TRACESTRING("CBTGPSRequestManager:: GSV information is still valid")
                iTimer->Cancel();
                InformListeners();
                }
            else
                {
                if(!iTimer->IsActive())
                    {
                    //GSV information is not valid, start timer
                    iTimer->Start(
                        KBTGPSGsvWaitTime,
                        KBTGPSGsvWaitTime,
                        TCallBack(TimerCallback, this));
                    }
                }
            }
        }
// ----------------------------------------------------------------------------
// Constructor
// ----------------------------------------------------------------------------
//
CSipSecIpsecMechanism::CSipSecIpsecMechanism(
    TSIPSecMechanismInitParams* aInitParams ) :
    iTimerMgr( aInitParams->iTimer ),
    iEngineContext( aInitParams->iEngineContext ),
    iTransportMgr( aInitParams->iTransportMgr ),
    iT1( aInitParams->iT1 ),
    iStates( KStatesGranularity )
{
    TTime time;
    time.HomeTime();
    iSeed = time.Int64();
}
// -----------------------------------------------------------------------------
// CTransactionIDGenerator::AddClockInfo
// -----------------------------------------------------------------------------
//
void CTransactionIDGenerator::AddClockInfo( TDes8& aBuf ) const
    {
    TTime now;
    now.UniversalTime();
    TInt64 timeAsInt = now.Int64();

    aBuf.Append( reinterpret_cast<const TUint8*>( &timeAsInt ),
                 sizeof( timeAsInt ) );

    TUint ticks = User::TickCount();
    aBuf.Append( reinterpret_cast<const TUint8*>( &ticks ), sizeof( ticks ) );
    }
Пример #30
0
TStsTransactionId CStsServer::CreateTransactionID()
	{
	TTime currentTime;
	TStsTransactionId transactionID;
	do
		{
		currentTime.UniversalTime();
		transactionID = I64LOW(currentTime.Int64());
		}
    while(IsExistingTransaction(transactionID));
    return transactionID;
	}