Exemplo n.º 1
0
void CTransactionsStep::MultipleCommitL(const TBool aTrans)
	{
	RPointerArray<CContactItem> itemarray( 500, 512 );
	TCleanupItem tclean(ArrayCleanup,&itemarray);
	CleanupStack::PushL( tclean );
	TInt k = 0;
	iIterate->Reset();
	for(; k < iContacts; ++k)
		{
		itemarray.Append( iContactsDatabase->OpenContactLX( iIterate->NextL(), *iViewAll ) );
		iFields = &( itemarray[k]->CardFields() );
		SetAllFieldsL( GetNextFieldL(KStringFields, KField, 0 == k ) );
		}

	iIterate->Reset();
	if(aTrans)
		{
		for( k = iContacts - 1; k >=0 ; --k )
			{
			iContactsDatabase->doCommitContactL(*itemarray[k], ETrue, ETrue );
			CleanupStack::Pop();
			}
		}
	else
		{
		for( k = iContacts - 1; k >=0 ; --k )
			{
			iContactsDatabase->CommitContactL(*itemarray[k]);
			CleanupStack::Pop();
			}
		}
	CleanupStack::PopAndDestroy();//tclean
	}
Exemplo n.º 2
0
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 );
		}
	}
/**
Iterate throught a list of values in the ini file, reset start iteration from beginning
*/
TPtrC CPerformanceFunctionalityBase::GetNextFieldL( const TDesC &aConfigSection,
													const TDesC &aName,
													const TBool aNewSection)
	{
	if( aNewSection )
		{
		iNextFieldPosition = 0;
		}
	++iNextFieldPosition;
	TPtrC ret = GetFieldL( aConfigSection, aName, iNextFieldPosition );
	if( ret == KNullDesC )
		{
		return GetNextFieldL(aConfigSection, aName, ETrue);
		}
	return ret;
	}
Exemplo n.º 4
0
/**
check that a field is generated for each view contact and that field matches list of missing of fields
remove generated field from contact item and repopulate contact view repeat until view contact field is null
*/
void CContactViewTest::doMissingFieldTestL(const CContactViewBase &aLView)
	{
	ClosePersistanceL(ETrue);
	TBool end = ETrue;
	TInt length = aLView.CountL();
	TInt manyfields = 0;
	TInt i;
	//iterate through ini file, that stores list of expected field in order
	const TPtrC mfield = GetNextFieldL();
	INTCOMPARE( length , ==,  iContacts, 0, 0 );
	iIterate->Reset();

	for(i = 0; i < length; ++i)
		{
		const TInt loc = aLView.FindL(iIterate->NextL());
		const CViewContact &vcontact = aLView.ContactAtL( loc );
		manyfields = vcontact.FieldCount();
		const TPtrC vfield = vcontact.Field(0);
		INTCOMPARE(  manyfields , ==,  1,  i, 0 );
		
		//compare view contact field to field stored in ini file
		STRINGCOMPARE( vfield, ==, mfield, i, 0 );
		//if view contact field is null, end test
		end = end && (vfield == KNullDesC);
		//find view contact field in contact item and set to null, if field not found, end test
		end = end || !FindAndClearFieldL( vcontact.Id(), vfield );
		}


	if( end )
		{
		iObserver->iMainFunc = NULL;
		iObserver->iDoFunc = NULL;
		iObserver->CleanView();
		}
	else
		{
		//if test not complete, reset view and repopulate
		OpenPersistanceL();
		iObserver->CleanView();
		iObserver->SetView( CreateViewL() );
		}
	}
Exemplo n.º 5
0
void CTransactionsStep::MultipleCommitTestL(const TBool aTrans)
	{
	iContacts = 40;
	CPerformanceFunctionalityBase::InitializeL();
	if(aTrans)
		{
		iContactsDatabase->DatabaseBeginLC(EFalse);
		}
	MultipleCommitL(aTrans);
	if(aTrans)
		{
		EndTransactionL(EFalse);
		}
	TInt k = 0;
	iIterate->Reset();
	for(; k < iContacts; ++k)
		{
		ReadL( iIterate->NextL() );
		TESTPRINTI( CheckAllFieldsL( GetNextFieldL(KStringFields, KField, 0 == k ) ), k );
		CloseL( ETrue );
		}
	}
Exemplo n.º 6
0
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 );
			}
		}
	}