Exemple #1
0
/**
check for unkownchange notification cause by the session queue being overloaded
*/	
TBool CNotificationStep::UnkownChangeCheck()
	{
	TBool SingleCheck = EFalse;
	TBool OverallResult = ETrue;
	
	TESTPRINT( SingleCheck = ( iSharedContacts->Count() == iDBContacts->Count()) );
	OverallResult = OverallResult && SingleCheck;
	
	TESTPRINT( SingleCheck = ( iSharedEvents->Count() == iDBEvents->Count() ) );
	OverallResult = OverallResult && SingleCheck;
	
	TESTPRINT( SingleCheck = ( iSharedEvents->Count() == iSharedContacts->Count() ) );
	OverallResult = OverallResult && SingleCheck;
	
	TInt length = iSharedContacts->Count();
	TInt i = 0;
	for(; i < length; ++i )
		{
		TESTPRINTI( SingleCheck = ( iSharedContacts->Find( (*iDBContacts)[i] ) > KErrNotFound ), i );
		OverallResult = OverallResult && SingleCheck;
		
		TESTPRINTI( SingleCheck = ( iSharedEvents->Find( (*iDBEvents)[i] ) > KErrNotFound ) , i );
		OverallResult = OverallResult && SingleCheck;
		}
	
	return OverallResult;
	}
void CTransactionsStep::CreateCommitTransactionTestL(const TBool aRevert)
	{
	iContacts = 0;
	CPerformanceFunctionalityBase::InitializeL();
	
	CContactItemFieldSet& templateFields = iTemplate->CardFields();
	TInt fieldsCount = templateFields.Count() - 1;
	
	iContactsDatabase->DatabaseBeginLC(EFalse);
	
	iContacts = 2;
	TInt k = 0;
	CContactCard* contact = CContactCard::NewLC(iTemplate);
	for(; k < iContacts; k++)
		{		
		iIterate->AddL( iContactsDatabase->doAddNewContactL(*contact,EFalse,ETrue) );
		}	
	CleanupStack::PopAndDestroy(contact);
	
	EndTransactionL(aRevert);
	
	if(aRevert)
		{
		iIterate->Reset();
		TInt err = KErrNone;
		TESTPRINT( iContactsDatabase->CountL() == 0 );
		
		for( k = 0; k < iContacts; ++k)
			{
			TRAP(err, ReadL( iIterate->NextL() ) );
			TESTPRINTI( KErrNotFound == err, k );
			CloseL( ETrue );
			}
		}
	else
		{
		iIterate->Reset();
		TESTPRINT( ( iContactsDatabase->CountL() == iContacts ) );
		
		for(k = 0; k < iContacts; ++k)
			{
			ReadL( iIterate->NextL() );
			TESTPRINTI( iFields->Count() == fieldsCount, k );
			TESTPRINTI( CheckAllFieldsL(KNullDesC), k );
			CloseL( ETrue );
			}
		}
	}	
Exemple #3
0
/**
Used by all tests to wait for listener to recive notification and send confirmation back.
timesout if no confirmation received
*/
void CConcurrentNotifierStep::ProcessWaitL()
	{
	iEnd.UniversalTime();
	if(ReceivedCountL() == iManyListeners)
		{
		if( iTests->Count() > 1 )
			{
			ClearSharedL();
			}
		iWaiting = EFalse;
		++iNextTest;
		}
	else if( iEnd.MicroSecondsFrom( iStart ).Int64() > KTimeout ) //test has timed out
		{
		_LIT(KTimedOut,"Notifier test %d has timed out");
		ERR_PRINTF2(KTimedOut, ++iNextTest);

		if( iTests->Count() > 1 )
			{
			ClearSharedL();
			}
		iWaiting = EFalse;
		TESTPRINT( EFalse );
		iNextTest = iTests->Count();
		}
	//else test is not complete and has not timed out... continue waiting
	}
/**
either release resource after countdown has reached the necessary value
or timeout test if countdown is not started after the timeout period has passed
*/
void CConcurrentTimeOutNotifierStep::ProcessWaitL(const TBool aTransaction)
	{
	StartCountdownL();
	iEnd.UniversalTime();
	const TInt64 KLockTime = iEnd.MicroSecondsFrom( iStart ).Int64();
	const TInt64 KTestTime = iEnd.MicroSecondsFrom( iTestStart ).Int64();
	if( iCountdown && ( KLockTime >= ((iSeconds - KTimeDiff) * KOneSecond) ) )
		{
		iWaiting = EFalse;
		iCountdown = EFalse;
		if(aTransaction)
			{
			iContactsDatabase->DatabaseCommitL( EFalse );//unlock database
			}
		else
			{
			CloseL( ETrue );//unlock contact
			}
		++iNextTest;
		SetSharedTextL(KSharedNextTest, KDoubleChar, EFalse);
		}
	else if( KTestTime > KTimeout ) //test has timed out
		{
		_LIT(KTimedOut,"Notifier test %d has timed out");
		ERR_PRINTF2(KTimedOut, ++iNextTest);
		iWaiting = EFalse;
		iCountdown = EFalse;
		TESTPRINT( EFalse );
		SetSharedTextL(KSharedNextTest, KDoubleChar, EFalse);
		iNextTest = iTests->Count();
		}
	//else test is not complete and has not timed out... continue waiting
	}
void CTransactionsStep::FullTransactionPerformanceTestL(const TBool aDelete)
	{
	TReal diffsecondsMin = 0;
	TReal commitsecondsMin = 0;
	TReal diffsecondsMid = 0;
	TReal commitsecondsMid = 0;
	TReal diffsecondsMan = 0;
	TReal commitsecondsMan = 0;
	TReal diffsecondsMax = 0;
#ifdef __WINSCW__
	TReal commitsecondsMax = 0;
#endif
	
	ALLPRINT(KMinContactsPrint); 
	TransactionPerformanceL(aDelete, EFull, KMinContacts, diffsecondsMin, commitsecondsMin);
	ALLPRINT(KMidContactsPrint); 
	TransactionPerformanceL(aDelete, EFull, KMidContacts, diffsecondsMid, commitsecondsMid);
	ALLPRINT(KManyContactsPrint); 
	TransactionPerformanceL(aDelete, EFull, KManyContacts, diffsecondsMan, commitsecondsMan);
	//is too slow on hardware, also takes up too much disk space
	#ifdef __WINSCW__
	ALLPRINT(KMaxContactsPrint); 
	TransactionPerformanceL(aDelete, EFull, KMaxContacts, diffsecondsMax, commitsecondsMax);
	#endif
	
	TESTPRINT( diffsecondsMax < KMaxTimeAllowed );
	}
void CTransactionsStep::NestedTransactionTestL()
	{
	TContactItemId cid = iIterate->NextL();
	
	iContactsDatabase->DatabaseBeginLC(EFalse);
	iContactsDatabase->DatabaseBeginLC(ETrue);
	OpenL(cid);
	SetFieldL(1, GetFieldL(KStringFields, KField, 1) );
	CommitL(ETrue);
	iContactsDatabase->DatabaseCommitLP(ETrue);
	OpenL(cid);
	SetFieldL(2, GetFieldL(KStringFields, KField, 2) );
	CommitL(ETrue);	
	EndTransactionL(ETrue);
	
	iIterate->Reset();
	TInt err = KErrNone;
	TInt k = 0;
	TESTPRINT( iContactsDatabase->CountL() == iContacts );
	
	for( k = 0; k < iContacts; ++k)
		{
		TRAP(err, ReadL( iIterate->NextL() ) );
		TESTPRINTI( KErrNone == err, k );
		TESTPRINTI( CheckAllFieldsL(KNullDesC), k );
		CloseL( ETrue );
		}	
	}
void CTransactionsStep::UpdateCommitTransactionTestL(const TBool aRevert)
	{
	CPerformanceFunctionalityBase::InitializeL();
	
	const TContactItemId cid = iIterate->NextL();
	const TContactItemId cid2 = iIterate->NextL();
	
	iContactsDatabase->DatabaseBeginLC(EFalse);
	OpenL( cid );
	SetAllFieldsL( GetNextFieldL(KStringFields, KField, ETrue) );
	CommitL(ETrue);
	EndTransactionL(aRevert);

	iContactsDatabase->DatabaseBeginLC(EFalse);
	ReadL( cid2 );
	SetAllFieldsL( GetNextFieldL(KStringFields, KField, EFalse) );
	iContactsDatabase->UpdateContactLC(cid2, iContactItem);
	CleanupStack::PopAndDestroy();
	CloseL( ETrue );
	EndTransactionL(aRevert);
	
	if(aRevert)
		{
		iIterate->Reset();
		TInt i = 0;
		for(; i < iContacts; ++i)
			{
			ReadL( iIterate->NextL() );
			TESTPRINTI( CheckAllFieldsL(KNullDesC), i );
			CloseL( ETrue );
			}
		}
	else
		{
		ReadL( cid );
		TESTPRINT( CheckAllFieldsL( GetNextFieldL(KStringFields, KField, ETrue) ) );
		CloseL( ETrue );
		
		ReadL( cid2 );
		TESTPRINT( CheckAllFieldsL( GetNextFieldL(KStringFields, KField, EFalse) ) );
		CloseL( ETrue );
		}
	}
void CTransactionsStep::DeleteCommitTransactionTestL(const TBool aRevert)
	{
	iContacts = 10;
	CPerformanceFunctionalityBase::InitializeL();
	iContactsDatabase->DatabaseBeginLC(EFalse);
	
	TInt k = 0;
	for(; k < iContacts; k++)
		{		
		iContactsDatabase->doDeleteContactL(iIterate->NextL(), ETrue, ETrue);
		}
	
	EndTransactionL(aRevert);
	
	if(aRevert)
		{
		TESTPRINT( iContactsDatabase->CountL() == iContacts );
		iIterate->Reset();
		TInt err = KErrNone;
		for(k = 0; k < iContacts; ++k)
			{
			TRAP(err, ReadL( iIterate->NextL() ) );
			TESTPRINTI( KErrNone == err, k );
			TESTPRINTI( CheckAllFieldsL( KNullDesC ), k );
			CloseL( ETrue );
			}
		}
	else
		{
		TESTPRINT( iContactsDatabase->CountL() == 0 );
		
		iIterate->Reset();
		TInt err = KErrNone;
		for(k = 0; k < iContacts; ++k)
			{
			TRAP(err, ReadL( iIterate->NextL() ) );
			TESTPRINTI( KErrNotFound == err, k );
			CloseL( ETrue );
			}
		iIterate->Clear();
		}
	}
void CTransactionsStep::EmptyTransactionPerformanceTestL(const TBool aDelete)
	{
	TReal diffsecondsMax = 0;
	TReal commitsecondsMax = 0;
	
	_LIT(KMaxContactsPrint,"$Max contacts$");
	ALLPRINT(KMaxContactsPrint); 
	TransactionPerformanceL(aDelete, EEmpty, KMaxContacts, diffsecondsMax, commitsecondsMax);
	
	TESTPRINT( diffsecondsMax < KMaxTimeAllowed );
	}
void CTransactionsStep::MediumTransactionPerformanceTestL(const TBool aDelete)
	{
	TReal diffsecondsMin = 0;
	TReal commitsecondsMin = 0;
	TReal diffsecondsMid = 0;
	TReal commitsecondsMid = 0;
	TReal diffsecondsMan = 0;
	TReal commitsecondsMan = 0;
	TReal diffsecondsMax = 0;
	TReal commitsecondsMax = 0;
		
	ALLPRINT(KMinContactsPrint); 
	TransactionPerformanceL(aDelete, EMedium, KMinContacts, diffsecondsMin, commitsecondsMin);
	ALLPRINT(KMidContactsPrint); 
	TransactionPerformanceL(aDelete, EMedium, KMidContacts, diffsecondsMid, commitsecondsMid);
	ALLPRINT(KManyContactsPrint); 
	TransactionPerformanceL(aDelete, EMedium, KManyContacts, diffsecondsMan, commitsecondsMan);
	ALLPRINT(KMaxContactsPrint); 
	TransactionPerformanceL(aDelete, EMedium, KMaxContacts, diffsecondsMax, commitsecondsMax);


	TESTPRINT( diffsecondsMax < KMaxTimeAllowed );
	}
void CTransactionsStep::ManyUpdateCommitTransactionTestL( const TBool aRevert )
	{
	iContacts = 1000;
	CPerformanceFunctionalityBase::InitializeL();
	RCntList backuplist;
	backuplist.CopyL( *iIterate );
	iContactsDatabase->DatabaseBeginLC(EFalse);
	
	TInt added = 0;
	TInt deleted = 0;
	TInt updated = 0;
	TInt k = 0;
	for(; k < iContacts; k++)
		{
		switch( k % KNumCUDOperations )
			{
			case ( EOpen ):
				{
				OpenL( iIterate->NextL() );
				//if setting first contact read first field from stringfields section
				//otherwise read next field in list of fields stored in ini file secion
				SetAllFieldsL( GetNextFieldL(KStringFields, KField, 0 == k ) );
				CommitL(ETrue);
				++updated;
				}
			break;
			case ( EUpdate ):
				{
				TContactItemId cid = iIterate->NextL();
				ReadL( cid );
				//if setting first contact read first field from stringfields section
				//otherwise read next field in list of fields stored in ini file secion
				SetAllFieldsL( GetNextFieldL(KStringFields, KField, 0 == k ) );
				iContactsDatabase->UpdateContactLC(cid, iContactItem);
				CleanupStack::PopAndDestroy();
				CloseL( ETrue );
				++updated;
				}
			break;
			case ( EAddDelete ):
				{
				DeleteContactL( iIterate->NextL(), ETrue );
				//iterator position is shifted back, so that next nextL call is correct
				iIterate->PreviousL();
				++deleted;
				//Empty contact is appended to the database, 
				//Contact id is stored at the end of iterator list not at current iterator position
				AddEmptyContactsL( 1, ETrue );
				++added;
				}
			break;
			default:
				{
				_LIT(KInvalidTest, "Invalid Case");
				User::Panic(KInvalidTest, 555);
				}
			break;
			}
		}
	
	EndTransactionL(aRevert);
	TESTPRINT( iContactsDatabase->CountL() == iContacts );
	
	CContactItemFieldSet& templateFields = iTemplate->CardFields();
	TInt fieldsCount = templateFields.Count() - 1;
	
	if(aRevert)
		{
		//if transaction is reverted / rolledback, all contacts should be
		//unchanged, i.e. they should all contain empty fields only
		backuplist.Reset();
		TInt err = KErrNone;
		for(k = 0; k < iContacts; ++k)
			{
			TRAP(err, ReadL( backuplist.NextL() ) );
			TESTPRINTI( KErrNone == err, k );
			TESTPRINTI( CheckAllFieldsL( KNullDesC ), k );
			CloseL( ETrue );
			}
		}
	else
		{
		iIterate->Reset();
		//all updated contact should contain the appropriated updated field value
		for(k = 0; k < updated; ++k)
			{
			ReadL( iIterate->NextL() );
			TESTPRINTI(iFields->Count() == fieldsCount, k);
			//if reading first contact read first field from stringfields section
			//otherwise read next field in list of fields stored in ini file secion
			TESTPRINTI( CheckAllFieldsL( GetNextFieldL(KStringFields, KField, 0 == k ) ), k );
			CloseL( ETrue );
			}
			
		//all newly	added contacts, should contain empty fields only.
		for(k = 0; k < added; ++k)
			{
			ReadL( iIterate->NextL() );
			TESTPRINTI( iFields->Count() == fieldsCount, k);
			TESTPRINTI( CheckAllFieldsL( KNullDesC ), k);
			CloseL( ETrue );
			}
		}
	}