Ejemplo n.º 1
0
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 );
		}	
	}
Ejemplo n.º 2
0
/**
open acid, increase access count to 1, attempt to delete contact, check that it has
not been deleted, set access count to 0, delete, and check that it has been deleted.
*/
void CAccessCountTests::AccessCountTestL(const TContactItemId aCid)
	{
	TInt err = KErrNone;
	static const TInt KAccessCount = 1;//increase access count of contact by 1, 
										
	TInt i = 0;
	
	OpenL(aCid,*iViewAll);
	SetContactFieldsL(*iContactItem);
	for(i = 0; i < KAccessCount; ++i )
		{
		iContactItem->IncAccessCount();
		}
	CommitL();
	
	ReadL(aCid, *iViewAll);
	const TInt KInitialAccessCount = iContactItem->AccessCount();//facount
	const TInt KInitialFieldCount = iFields->Count(); //fcount
	const TInt KInitialEmptyFields = CountEmpty(*iFields);//fhcount
	Close();
	
	INTCOMPARE(  KInitialEmptyFields , ==,  0 , 0, 0 );
	INTCOMPARE(  KInitialFieldCount , >,  0 , 0, 0 );
	
	for(i = 0; i < KAccessCount; ++i )
		{
		iContactsDatabase->DeleteContactL(aCid);
		}
		
	ReadL(aCid,*iViewAll);
	const TInt KModifiedAccessCount = iContactItem->AccessCount();//dacount
	const TInt KModifiedFieldCount 	= iFields->Count();//dcount
	const TInt KModifiedEmptyFields = CountEmpty(*iFields);//dHcount
	Close();
	
	/*
	check that deleting a contact doesnt modify its access count
	check that deleting a contact with access count > 1, 
	deletes all fields associated with contact but not the contact item itself
	*/
	INTCOMPARE(  KModifiedAccessCount , ==,  KInitialAccessCount , 0, 0 ); 
	INTCOMPARE(  KInitialFieldCount , ==,  KModifiedFieldCount , 0, 0 );
	INTCOMPARE(  KModifiedEmptyFields , ==,  KInitialFieldCount , 0, 0 ); 
	INTCOMPARE(  KModifiedFieldCount , ==,  KModifiedEmptyFields , 0, 0 );
	
	OpenL(aCid,*iViewAll);
	for(i = 0; i < KAccessCount; ++i )
		{
		iContactItem->DecAccessCount();
		}
	const TInt lAcount = iContactItem->AccessCount();
	CommitL();
	
	INTCOMPARE( lAcount , ==,  0, 0, 0 );
	
	TRAP( err, ReadL(aCid, *iViewAll) );
	Close();
	
	INTCOMPARE(  err , ==,  KErrNotFound , 0, 0 );
	}
Ejemplo n.º 3
0
/**
add agent field to contact b. set value of agent to contact a.
export contacts a & b. check access count for a & b(should be 0), 
check value of agent(should equal b) open contact b, delete all fields.
commit. import contacts a and b. check that agent field is not imported.
*/
void CAccessCountTests::AgentExportImportAccessTestL()
	{
	const TContactItemId KFirstContactId = iIterate->NextL();//contact a
	const TContactItemId KSecondContactId = iIterate->NextL();//contact b
	
	//open contact a and populate all fields
	OpenL(KFirstContactId, *iViewAll);
	SetContactFieldsL(*iContactItem);
	CommitL();
	
	//open contact b
	OpenL(KSecondContactId,*iViewAll);
	//populate all fields
	SetContactFieldsL(*iContactItem);
	//add contact a id as an agent field value
	AddAgentFieldL(KFirstContactId);
	CommitL();
	
	CContactIdArray *ArrayOfExportedContactIds = CContactIdArray::NewLC();
	//set contact a and b to be export
	ArrayOfExportedContactIds->AddL(KFirstContactId);
	ArrayOfExportedContactIds->AddL(KSecondContactId);
	
	//export contact a & b
	ExportVcardL(*ArrayOfExportedContactIds);
	
	const TInt KFirstContactAccessCountAfterExport = GetAccessCountL(KFirstContactId);
	const TInt KSecondContactAccessCountAfterExport = GetAccessCountL(KSecondContactId);
	const TInt KSecondContactAgentFieldAfterExport = GetAgentFieldL(KSecondContactId);
	CleanupStack::PopAndDestroy(ArrayOfExportedContactIds);
	
	//delete all fields from contact b
	OpenL(KSecondContactId,*iViewAll);
	iFields->Reset();
	CommitL();
	
	//import exported contacts
	ImportVcardL();
	
	const TInt KFirstContactAccessCountAfterImport = GetAccessCountL(KFirstContactId);
	const TInt KSecondContactAccessCountAfterImport = GetAccessCountL(KSecondContactId);
	const TContactItemId KSecondContactAgentFieldAfterImport = GetAgentFieldL(KSecondContactId);
	
	//importing & exporting contacts should not affect the access count
	INTCOMPARE( KFirstContactAccessCountAfterExport , ==,  0, 0, 0 ); 
	INTCOMPARE( KSecondContactAccessCountAfterExport , ==,  0, 0, 0 ); 
	INTCOMPARE( KFirstContactAccessCountAfterExport , ==,  KFirstContactAccessCountAfterImport, 0, 0 );
	INTCOMPARE( KSecondContactAccessCountAfterExport , ==,  KSecondContactAccessCountAfterImport, 0, 0 );
	
	//agent field values should not be exported/imported
	INTCOMPARE( KFirstContactId , ==,  KSecondContactAgentFieldAfterImport, 0, 0 ); 
	//exporting contacts should not affect the internal state of the contacts agent field
	INTCOMPARE( KSecondContactAgentFieldAfterExport , ==,  KFirstContactId, 0, 0 );
	
	iParent->Fs().Delete(KVcardFile);//cleanup of exported vcard file
	}
Ejemplo n.º 4
0
/**
create local view with sortorder containing all (existing) uids,
database contains 10 contacts with a fieldset containing no fields.
*/
void CContactViewTest::EmptyFieldsetTestL()
	{
	ALLPRINT(KTest5);
	ClosePersistanceL(EFalse);
	ResetDatabaseL();
	TInt i;
	for(i = 0; i < iContacts; ++i)
		{
		const TContactItemId cid = iIterate->NextL();
		OpenL(cid, *iViewAll);
		iFields->Reset();
		CommitL();
		}


	TInt length = iExistingUidsArray->Count();
	ResetSortL();
	for(i = 0 ; i < length ; ++i)
		{
		iSortOrder->AppendL( TUid::Uid( (*iExistingUidsArray)[i] ) );
		}

	OpenPersistanceL();
	iObserver->SetView( CreateViewL() );
	iObserver->iMainFunc = NULL;
	iObserver->iDoFunc = &CContactViewTest::doEmptyFieldsetTestL;
	}
Ejemplo n.º 5
0
void CAccessCountTests::SetAgentFieldL(const TContactItemId aCid, const TContactItemId aVal)
	{
	
	TBool FoundAgentField = EFalse;
	OpenL(aCid, *iViewAll);
	const TInt count = iFields->Count();
	TInt i = 0;
	
	for(; i < count; ++i)
		{
		if( (*iFields)[i].StorageType() == KStorageTypeContactItemId )
			{
			(*iFields)[i].AgentStorage()->SetAgentId(aVal);
			FoundAgentField = ETrue;
			break;
			}
		}
		
	if( !FoundAgentField )
		{
		AddAgentFieldL(aVal);
		}
		
	CommitL();
	}
Ejemplo n.º 6
0
/**
add agent field to contact b, set value of agent in b to id of contact a.
check that agent field is retrieved/stored correctly, check that access count is
not modified for either contact
*/	
void CAccessCountTests::AgentAccessCountTestL()
	{
	TContactItemId RetrievedAgentId = -1;
	TContactItemId PreviousContactId = iIterate->NextL();//contact a
	TContactItemId CurrentContactId = iIterate->NextL();//contact b
	
	//open current contact
	OpenL(CurrentContactId,*iViewAll);
	//add new agent field, set to previous contact id
	AddAgentFieldL(PreviousContactId);
	CommitL();
	
	//get agent id store for current contact
	RetrievedAgentId = GetAgentFieldL(CurrentContactId);
	
	//get access count of current contact
	ReadL(CurrentContactId, *iViewAll);
	const TInt KCurrentContactAccessCount = iContactItem->AccessCount();
	Close();
	
	//get access count of previous contact
	ReadL(PreviousContactId, *iViewAll);
	const TInt KPreviousContactAccessCount = iContactItem->AccessCount();
	Close();
	
	//check that retrieved agent id equals previous contact id
	INTCOMPARE( RetrievedAgentId , ==,  PreviousContactId, 0, 0 );
	//check that changing the agent field values doesnt not affect the access count
	//of involved contacts
	INTCOMPARE( KCurrentContactAccessCount , ==,  0, 0, 0 ); 
	INTCOMPARE( KPreviousContactAccessCount , ==,  0, 0, 0 );
	}
Ejemplo n.º 7
0
/**
* Open aCid, add agent field, set value of agent field, and get value of agent.
* Check this is correct, repeat this for minint, 0, 1, Maxint. Setting the 
* agent id should only accept values > 0, all other values are ignored.
*/
void CAccessCountTests::AddGetAgentTestL(const TContactItemId aCid)
	{
	TContactItemId retrievedAgentId = -1;
	const TInt KInitialAgentId = 5;
	
	OpenL(aCid,*iViewAll);
	AddAgentFieldL( KInitialAgentId );
	CommitL();
	
	TRAPD( error, SetAgentFieldL( aCid, KMinTInt ) );
	INTCOMPARE(  error , ==,  KErrNone , 0, 0 );
	retrievedAgentId = GetAgentFieldL( aCid );
	INTCOMPARE(  retrievedAgentId , ==,  KInitialAgentId , 0, 0 );
	
	TRAP( error, SetAgentFieldL( aCid, -1 ) );
	INTCOMPARE(  error , ==,  KErrNone , 0, 0 );
	retrievedAgentId = GetAgentFieldL( aCid );
	INTCOMPARE(  retrievedAgentId , ==,  KInitialAgentId , 0, 0 );
	
	TRAP( error, SetAgentFieldL( aCid, 0 ) );
	INTCOMPARE(  error , ==,  KErrNone , 0, 0 );
	retrievedAgentId = GetAgentFieldL( aCid );
	INTCOMPARE(  retrievedAgentId , ==,  KInitialAgentId , 0, 0 );

	TRAP( error, SetAgentFieldL( aCid, 1 ) );
	INTCOMPARE(  error , ==,  KErrNone , 0, 0 );
	retrievedAgentId = GetAgentFieldL( aCid );
	INTCOMPARE(  retrievedAgentId , ==,  1 , 0, 0 );
	
	TRAP( error, SetAgentFieldL( aCid, KMaxTInt ) );
	INTCOMPARE(  error , ==,  KErrNone , 0, 0 );
	retrievedAgentId = GetAgentFieldL( aCid );
	INTCOMPARE(  retrievedAgentId , ==,  KMaxTInt , 0, 0 );
	}
/**
attempt to load aCid with viewdef containing multiple identical uids, this test
will panic in debug mode as CContactItemViewDef does not allow multiple identical uids
*/
void CViewDefAnyFieldsTest::doIdenticalUidsTestL(const TContactItemId &aCid)
	{
	OpenL(aCid,*iViewAll, EFalse);// ETrue);
	SetContactFieldsL(*iContactItem);	
	CommitL();
	//multiple identical uids
	SINGLECOMPARE( FieldCountCompL(aCid, *iViewII, EFalse, EFalse, EFalse, ETrue), 0 , 0 );
	}
Ejemplo n.º 9
0
void CNotificationStep::PlusTransactionUnkownChangeTestL(const TBool aRevert)
	{
	INFO_PRINTF1(KTest3);
	
	TContactItemId cid = iIterate->NextL();
	TInt i = 0;
	for( ; i < KPlusContacts; ++i )
		{
		OpenL( cid );
		CommitL( EFalse );
		}
		
	TInt many = aRevert ? KPlusContacts : 1;
	for( i = 0; i < many; ++i )
		{
		AddEventL( EContactDbObserverEventContactChanged );
		AddContactL( cid );
		}
	
	cid = iIterate->NextL();
	iContactsDatabase->DatabaseBeginLC(EFalse);
	for( i = 0; i < KMaxNumberOfEventsInEventQueue + 1; ++i )
		{
		OpenL( cid );
		CommitL( ETrue );
		}
	EndTransactionL( aRevert );
	
	if( !aRevert )
		{
		AddEventL( EContactDbObserverEventUnknownChanges );
		AddContactL( -1 );
		iMyActive->iCheck = &CNotificationStep::UnkownChangeCheck;
		}
	else
		{
		iMyActive->iCheck = &CNotificationStep::TransactionUnkownChangeCheck;
		}
	iMyActive->Activate();
	iStart.UniversalTime();
	CActiveScheduler::Start();
	}					
Ejemplo n.º 10
0
void CConcurrentNotifierStep::CommitTestL()
	{
	INFO_PRINTF1(KTest2);
	SetSharedTextL(KSharedNextTest, KSingleCharacter, ETrue);
	iWaiting = ETrue;
	TContactItemId cid = iIterate->NextL();
	OpenL( cid );
	CommitL( EFalse );
	AddEventL(EContactDbObserverEventContactChanged);
	AddContactL( cid );
	SetMessageCountL();
	iStart.UniversalTime();
	}
Ejemplo n.º 11
0
/**
sets the value of all blobs in a contact (aCid) with aBuf
*/
void CRandomBlobStep::SetAllBlobsL(const TContactItemId aCid, const HBufC8 &aBuf)
	{
	OpenL( aCid );
	TInt length = iFields->Count();
	for( TInt i = 0; i < length; ++i )
		{
		if( (*iFields)[i].StorageType() == KStorageTypeStore )
			{
			(*iFields)[i].StoreStorage()->SetThingL(aBuf);
			}
		}
	CommitL( EFalse );
	}
Ejemplo n.º 12
0
/*
test that contactitems can be delete successfull irregardless of the contents of their agent value
*/
void CAccessCountTests::ReverseAgentDeletionTestL(const TInt aNumContacts)
	{
	TContactItemId PreviousContactId = -1;
	TContactItemId CurrentContactId = iIterate->NextL();
	TInt i = 0;
	TInt err = KErrNone;
	
	for(; i < aNumContacts; ++i)
		{
		PreviousContactId = CurrentContactId;
		CurrentContactId = iIterate->NextL();
		//open contact item
		OpenL(CurrentContactId, *iViewAll);
		//add agent field and set to previous contact id
		AddAgentFieldL(PreviousContactId);
		CommitL();
		//print agent values useful for debugging
		INFO_PRINTF2(KAgentValue, GetAgentFieldL(CurrentContactId) );
		}

	//attempt to delete contacts starting from last contact to frist contact
	TBool DeleteSuccess = EFalse;
	for(i = aNumContacts ; i > 0 ; --i)
		{
		//attempt to delete contact
		iContactsDatabase->DeleteContactL(CurrentContactId);
		//remove contact id from iterator
		iIterate->RemoveL(CurrentContactId);
		//attempt to read deleted contact
		TRAP( err, ReadL(CurrentContactId, *iViewAll) );
		Close();
		//fail test if contact is still present
		DeleteSuccess = INTCOMPARE( err, ==, KErrNotFound, i, 0 );
		CurrentContactId = iIterate->PreviousL();
		if( ! DeleteSuccess )
			{
			break;
			}
		}
	//if test fails
	if( ! DeleteSuccess )
		{
		//remove rest of contacts from iterator
		for(; i > 0 ; --i)
			{
			iIterate->RemoveL(CurrentContactId);
			CurrentContactId = iIterate->PreviousL();
			}
		}
	}
/**
tests loading aCid with different viewdefs, it is tested with all possible uids for each viewdef,
check to see that expected fields are excluded/included
*/
void CViewDefAnyFieldsTest::doAnyFieldsTestL(const TContactItemId &aCid)
	{
	OpenL(aCid,*iViewAll, EFalse);//ETrue);
	SetContactFieldsL(*iContactItem);	
	CommitL();
	/*viewdefs ignore primary mappings stored as mapping in contenttype rather
	than within the array*/
	SINGLECOMPARE( FieldCountCompL(aCid, *iViewII, EFalse, EFalse), 0, 0);
	//hidden is reversed
	SINGLECOMPARE( FieldCountCompL(aCid, *iViewMI, ETrue, ETrue), 0, 0 );
	//"all" hidden fields are excluded
	SINGLECOMPARE( FieldCountCompL(aCid, *iViewIM, EFalse, ETrue, ETrue), 0, 0 );
	//"all" hidden fields are excluded
	SINGLECOMPARE( FieldCountCompL(aCid, *iViewMM, ETrue, ETrue, ETrue), 0, 0 );
	}
Ejemplo n.º 14
0
void CConcurrentNotifierStep::MultipleChangeTransactionTestL()
	{
	if( iRevert )
		{
		INFO_PRINTF1(KTest112);
		}
	else
		{
		INFO_PRINTF1(KTest11);
		}
	SetSharedTextL(KSharedNextTest, KSingleCharacter, ETrue);
	iWaiting = ETrue;
	TContactItemId cid = iIterate->NextL();

	iContactsDatabase->DatabaseBeginLC(EFalse);
	OpenL( cid );
	CommitL( ETrue );
	AddEventL(EContactDbObserverEventContactChanged);
	AddContactL( cid );

	cid = iIterate->NextL();
	ReadL( cid );
	iContactsDatabase->UpdateContactLC( cid, iContactItem);
	CleanupStack::PopAndDestroy();
	CloseL( ETrue );
	AddEventL(EContactDbObserverEventContactChanged);
	AddContactL( cid );

	CContactCard* contact = CContactCard::NewLC(iTemplate);
	cid = iContactsDatabase->doAddNewContactL(*contact, EFalse, ETrue);
	if(!iRevert)
		{
		iIterate->AddL( cid );
		}
	CleanupStack::PopAndDestroy(contact);
	AddEventL(EContactDbObserverEventContactAdded);
	AddContactL( cid );

	cid = iIterate->NextL();
	DeleteContactL( cid, ETrue );
	AddEventL(EContactDbObserverEventContactDeleted);
	AddContactL( cid );

	EndTransactionL();
	SetMessageCountL();

	iStart.UniversalTime();
	}
Ejemplo n.º 15
0
/**
Set all fields of all contacts to contain their own label string
use empty sort order
*/
void CContactViewTest::MissingFieldTestL()
	{
	ALLPRINT(KTest7);
	ClosePersistanceL(EFalse);
	ResetDatabaseL();
	for(TInt i = 0; i < iContacts; ++i)
		{
		const TContactItemId cid = iIterate->NextL();
		OpenL(cid, *iViewAll);
		SetContactL();
		CommitL();
		}
	ResetSortL();
	OpenPersistanceL();
	iObserver->SetView( CreateViewL() );
	iObserver->iMainFunc = NULL;
	iObserver->iDoFunc = &CContactViewTest::doMissingFieldTestL;
	}
Ejemplo n.º 16
0
void CNotificationStep::UnkownChangeTestL()
	{
	INFO_PRINTF1(KTest1);
	TContactItemId cid = iIterate->NextL();
	TInt i = 0;
	for( ; i < KMaxNumberOfEventsInEventQueue + 10; ++i )
		{
		OpenL( cid );
		CommitL( EFalse );
		}
	AddEventL( EContactDbObserverEventContactChanged );
	AddContactL( cid );
	AddEventL( EContactDbObserverEventUnknownChanges );
	AddContactL( -1 );
	iMyActive->iCheck = &CNotificationStep::UnkownChangeCheck;
	iMyActive->Activate();
	iStart.UniversalTime();
	CActiveScheduler::Start();
	}	
Ejemplo n.º 17
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 );
		}
	}
Ejemplo n.º 18
0
void CConcurrentNotifierStep::UnkownChangeTestL()
	{
	INFO_PRINTF1(KTest13);
	SetSharedTextL(KSharedNextTest, KSingleCharacter, ETrue);
	iWaiting = ETrue;
	iMyActive->Activate();
	TContactItemId cid = iIterate->NextL();
	TInt i = 0;
	iContactsDatabase->DatabaseBeginLC(EFalse);
	for( ; i < KMaxNumberOfEventsInEventQueue + 1; ++i )
		{
		OpenL( cid );
		CommitL( EFalse );
		}
	AddEventL( EContactDbObserverEventUnknownChanges );
	AddContactL( -1 );
	EndTransactionL();
	SetMessageCountL();
	iStart.UniversalTime();
	}
Ejemplo n.º 19
0
/**
Delete all fields from all contacts
*/
void CContactViewTest::EmptyFieldsetSortTestL()
	{
	ALLPRINT(KTest6);
	ClosePersistanceL(EFalse);
	ResetDatabaseL();
	TInt i;
	for(i = 0; i < iContacts; ++i)
		{
		const TContactItemId cid = iIterate->NextL();
		OpenL(cid, *iViewAll);
		//deletes all fields
		iFields->Reset();
		CommitL();
		}

	ResetSortL();
	OpenPersistanceL();
	iObserver->SetView( CreateViewL() );
	iObserver->iMainFunc = NULL;
	iObserver->iDoFunc = &CContactViewTest::doEmptyFieldsetSortTestL;
	}
Ejemplo n.º 20
0
TVerdict CConcurrentInitializerStep::doTestStepL()
	{
	__UHEAP_MARK;
	_LIT(KStartTest,"CConcurrentInitializerStep::doTestStepL()");
	INFO_PRINTF1(KStartTest);  //Block start

	InitializeL();
	iIterate->Reset();
	TInt j = 0;
	for(; j < iContacts; ++j)
		{
		OpenL(iIterate->NextL());
		TInt fieldId=iFields->Find(KUidContactFieldPhoneNumber);
		SetFieldL(fieldId,GetFieldL(KStringFields, KField, 1));// if this is not set, speeddial cant be set
		CommitL(EFalse);
		}
	iIterate->Reset();
	Cleanup();
	__UHEAP_MARKEND;

	return TestStepResult();
	}
Ejemplo n.º 21
0
/**
populates all contacts either moderately, fully, or not at all
*/
void CTransactionsStep::ModifyContactsL(const FieldFullness aField)
	{
	if(aField == EEmpty)
		{
		return;
		}
	iIterate->Reset();
	TInt j = 0;
	for(; j < iContacts; ++j)
		{
		OpenL(iIterate->NextL());
		if(aField == EFull)
			{
			SetAllFieldsL( GetFieldL(KStringFields, KField, 2) );
			}
		else
			{
			SetManyFieldsL(GetFieldL(KStringFields, KField, 4) , KMediumFields);
			}
		CommitL(EFalse);
		}
	}
Ejemplo n.º 22
0
void CConcurrentNotifierStep::SingleCommitTransactionTestL()
	{
	if( iRevert )
		{
		INFO_PRINTF1(KTest102);
		}
	else
		{
		INFO_PRINTF1(KTest10);
		}
	SetSharedTextL(KSharedNextTest, KSingleCharacter, ETrue);
	iWaiting = ETrue;
	TContactItemId cid = iIterate->NextL();

	iContactsDatabase->DatabaseBeginLC(EFalse);
	OpenL( cid );
	CommitL( ETrue );
	AddEventL(EContactDbObserverEventContactChanged);
	AddContactL( cid );
	EndTransactionL();
	SetMessageCountL();

	iStart.UniversalTime();
	}
Ejemplo n.º 23
0
/**
populate database with full, medium or empty contacts
*/
void CContactViewTest::PerformanceTestL()
	{
	ClosePersistanceL( EFalse );
	ResetDatabaseL(iPerformanceContacts);

	//populate contacts
	if( EMedium == iFullness )
		{
		if( EFew == iPerformanceContacts )
			{
			ALLPRINT(KTest81);
			}
		TInt i = 0;
		for(; i < iContacts; ++i)
			{
			const TContactItemId cid = iIterate->NextL();
			OpenL(cid, *iViewAll);
			SetMediumL();
			CommitL();
			}
		}
	else if( EFull == iFullness )
		{
		if( EFew == iPerformanceContacts )
			{
			ALLPRINT(KTest82);
			}
		TInt i = 0;
		for(; i < iContacts; ++i)
			{
			const TContactItemId cid = iIterate->NextL();
			OpenL(cid, *iViewAll);
			SetFullL();
			CommitL();
			}
		}
	else
		{
		if( EFew == iPerformanceContacts )
			{
			ALLPRINT(KTest8);
			}
		}

	/**
	Print the number of contacts used for this test
	*/
	switch( iPerformanceContacts )
		{
		case EFew:
			{
			_LIT(KFewContacts,"Few contacts");
			ALLPRINT( KFewContacts );
			iPerformanceContacts = EMid;
			break;
			}
		case EMid:
			{
			_LIT(KMidContacts,"Mid contacts");
			ALLPRINT( KMidContacts );
			iPerformanceContacts = EMany;
			break;
			}
		case EMany:
			{
			_LIT(KManyContacts,"Many contacts");
			ALLPRINT( KManyContacts );
			iPerformanceContacts = EMax;
			break;
			}
		case EMax:
			{
			_LIT(KMaxContacts,"Max contacts");
			ALLPRINT( KMaxContacts );
			iPerformanceContacts = EDone;
			break;
			}
		default:
			{
			_LIT(KInvalidContacts,"bad performance contacts");
			User::Panic(KInvalidContacts, 333 );
			break;
			}
		}

	_LIT(KStartCompact,"Start Compact");
	ALLPRINT( KStartCompact );
	iContactsDatabase->CompactL();//to make sure that the server is not busy doing automatic compaction
	_LIT(KEndCompact,"End Compact");
	ALLPRINT( KEndCompact );


	//Create sortorder with typical uids
	ResetSortL();
	iSortOrder->AppendL(KUidContactFieldGivenName);
	iSortOrder->AppendL(KUidContactFieldAdditionalName);
	iSortOrder->AppendL(KUidContactFieldFamilyName);
	iSortOrder->AppendL(KUidContactFieldPhoneNumber);

	OpenPersistanceL();
	_LIT(KStartView,"Start view creation");
	ALLPRINT( KStartView );
	//note time view is created
	iStartC.UniversalTime();
	iObserver->SetView( CreateViewL() );
	//note time vie creat is completed
	iStartP.UniversalTime();
	_LIT(KEndView,"End view creation, wait for view to be populated");
	ALLPRINT( KEndView );
	iObserver->iMainFunc = NULL;
	iObserver->iDoFunc = &CContactViewTest::doPerformanceTestL;
	}
/**opens and read contct aCid using the default viewdefs. 
then it reads and minimally reads aCid using aView, it stores the number relevant fields after
each read/open, then checks that the values match the expected resluts as constrained by aZeroN/H,
aZeroN == all normal fields should be excluded, aZeroH == all hidden fields should be excluded*/
TBool CViewDefAllFieldsTest::FieldCountCompL(	const TContactItemId aCid,
										const CContactItemViewDef &aView, 
										const TBool aDefault, 
										const TBool aZeroN, 
										const TBool aZeroH)
	{
	TBool SingleCheck = EFalse;
	TBool OverallResult = ETrue;
	
	TInt counti = 0;
	TInt countr = 0;
	TInt countrv = 0;
	TInt countrAll = 0;
	TInt countrAllv = 0;
	TInt countrm = 0;
	
	TInt hcounti = 0;
	TInt hcountr = 0;
	TInt hcountrv = 0;
	TInt hcountrm = 0;
	
	OpenL(aCid,aView, ETrue);
	SetContactFieldsL(*iContactItem);
	counti = iFields->Count();
	hcounti = CountHiddenFields(*iFields);
	CommitL();
	
	ReadL(aCid,*iViewAll,EFalse);
	countrv = CountEmpty(*iFields);
	countrAllv = iFields->Count();
	hcountrv = CountHiddenFields(*iFields);
	Close();
	
	ReadL(aCid,aView,aDefault);
	countr = CountEmpty(*iFields);
	countrAll = iFields->Count();
	hcountr = CountHiddenFields(*iFields);
	Close();
	
	ReadMinimalL(aCid, aView, *iDefView, aDefault);
	countrm = iFields->Count();
	hcountrm = CountHiddenFields(*iFields);
	Close();
		
	SingleCheck = INTCOMPARE( countrAllv, ==, counti, 0, 0 );
	OverallResult = OverallResult && SingleCheck;
	
	SingleCheck = INTCOMPARE(hcounti , ==,  hcountrv, 0, 0 );
	OverallResult = OverallResult && SingleCheck;
	
	SingleCheck = INTCOMPARE(countrv , ==,  0, 0, 0 );
	OverallResult = OverallResult && SingleCheck;
	
	SingleCheck = INTCOMPARE( ( countrAll - countr) , ==,  countrm , 0, 0 ); 
	OverallResult = OverallResult && SingleCheck;
	
	
	if(aZeroN)
		{
		SingleCheck = INTCOMPARE( ( countr - hcountr ) , ==,  ( counti - hcounti ) , 0, 0 );
		OverallResult = OverallResult && SingleCheck;
	
		SingleCheck = INTCOMPARE( ( countrm - hcountrm ) , ==,  0 , 0, 0 );
		OverallResult = OverallResult && SingleCheck;
	
		}
	else
		{
Ejemplo n.º 25
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 );
			}
		}
	}