コード例 #1
0
/**
 * Verify that the synchroniser is called when deleting an icc entry, and that the 
 * deletion of an icc entry fails if the icc is locked.
 * @param aDb Contact database
 */
void TestDeleteL(CContactDatabase& aDb)
	{
	test.Next(_L("Test delete when ICC locked"));
	syncChecker->SetDeleteContactResponseL(KErrLocked);
	TContactItemId iccId=AddIccEntryL(aDb,KUidIccGlobalAdnPhonebook);
	syncChecker->ResetMethodCallCountsL();
	TRAPD(err,aDb.DeleteContactL(iccId));
	test(err==KErrLocked);
	test(syncChecker->ValidateMethodCallCountL() == 2);
	syncChecker->ResetMethodCallCountsL();
	CContactItem* item=aDb.ReadContactLC(iccId);
	test(syncChecker->ValidateMethodCallCountL() == 1);
	test(item!=NULL);
	CleanupStack::PopAndDestroy(item);
	item=NULL;

	test.Next(_L("Test successful delete of non-icc entry when ICC locked"));
	TContactItemId nonIccId=AddContactCardL(aDb);
	syncChecker->ResetMethodCallCountsL();
	TRAP(err,aDb.DeleteContactL(nonIccId));
	test(err==KErrNone);
	test(syncChecker->ValidateMethodCallCountL() == 0);

	test.Next(_L("Test successful delete"));
	syncChecker->SetDeleteContactResponseL(KErrNone);
	syncChecker->ResetMethodCallCountsL();
	TRAP(err,aDb.DeleteContactL(iccId));
	test(syncChecker->ValidateMethodCallCountL() == 2);
	test(err==KErrNone);
	syncChecker->ResetMethodCallCountsL();
	TRAP(err,aDb.ReadContactLC(iccId));
	test(syncChecker->ValidateMethodCallCountL() == 0);
	test(err==KErrNotFound);
	}
コード例 #2
0
/**
 * Verify that the synchroniser is called when reading an icc entry
 * @param aDb Contact database
 */
void TestReadL(CContactDatabase& aDb)
	{
	TContactItemId iccId=AddIccEntryL(aDb,KUidIccGlobalAdnPhonebook);
	SetNameField(aDb,iccId,KIccName);
	TContactItemId nonIccId = AddContactCardL(aDb);
	SetNameField(aDb,nonIccId,KNonIccName);
	TestReadMinimalContactL(aDb,iccId,nonIccId);
	TestReadContactL(aDb,iccId,nonIccId);
	TestReadTextDefinitionL(aDb,iccId,nonIccId);
	syncChecker->SetValidateResponseL(MContactSynchroniser::ERead,KErrNone);
	syncChecker->ResetMethodCallCountsL();
	aDb.DeleteContactL(iccId);
	aDb.DeleteContactL(nonIccId);
	test(syncChecker->ValidateMethodCallCountL() == 2);
	}
コード例 #3
0
void CFilteredViewTester::DeleteContactsDescL(TInt aCount)
    {
    for (TInt i = aCount - 1; i >= 0; --i)
        {
        iContactDb->DeleteContactL((*iIdArray)[i]);
        }       
    }
コード例 #4
0
ファイル: t_iccentry.cpp プロジェクト: Esclapion/qt-mobility
void TestDeleteL(CContactDatabase& aDb)
	{
	test.Next(_L("Test successful delete"));

	TContactItemId id = CreateTestICCEntryL(aDb);
	syncChecker->ResetMethodCallCountsL();
	aDb.DeleteContactL(id);
	test(syncChecker->ValidateMethodCallCountL() == 2);
	test.Next(_L("Test unsuccessful delete"));

	TestUnsuccessfulDeleteL(aDb);
	}
コード例 #5
0
LOCAL_C void TestAsyncOpenDbAndDeleteContactL() 
	{
	//test if necesary sanity check was made
	test.Next( _L("Open async database and simulate a template delete event"));
	
	TRequestStatus requestStatus(0);
	CContactOpenOperation* op = CContactDatabase::Open(KDatabaseFileName, requestStatus); 
	// note: op doesn't have to be on CS
	User::WaitForRequest(requestStatus);
	CContactDatabase* database = op->TakeDatabase();
	CleanupStack::PushL(database);
	
	TContactItemId contactId = 1; //anything but not system template
	database->DeleteContactL(contactId); //aim is to check if it's safe to delete from template
	
	CleanupStack::PopAndDestroy(database);
	}
コード例 #6
0
ファイル: t_iccentry.cpp プロジェクト: Esclapion/qt-mobility
/** 
 * Test an unsuccessful delete
 * @param aDb Contact database
 */
void TestUnsuccessfulDeleteL(CContactDatabase& aDb)
	{
	syncChecker->SetValidateResponseL(MContactSynchroniser::ERead,KErrNone);
	syncChecker->SetValidateResponseL(MContactSynchroniser::EEdit, KErrNone);
	TContactItemId id = CreateTestICCEntryL(aDb);
	// Creating the contact sets the delete error to KErrNone, so must do this afterwards
	syncChecker->SetDeleteContactResponseL(KErrCorrupt);
	syncChecker->ResetMethodCallCountsL();
	TRAPD(err, aDb.DeleteContactL(id));
	test(syncChecker->ValidateMethodCallCountL() == 2);
	test(err==KErrCorrupt);
	//Read contact to check it wasn't deleted anyway
	CContactItem* item = NULL;
	TRAP(err,item = aDb.ReadContactL(id));
	test(err==KErrNone);
	delete item;
	}
コード例 #7
0
void CTestContactOperations::DeleteContactsL()
	{
	// existing database
   	TPtrC databaseFile(_L("C:contactDB.cdb"));
   	
   	TContactItemId itemId = KErrNotFound;
	CContactDatabase* dBase = NULL;
	CContactIdArray* idArray = NULL;
	
	dBase = CContactDatabase::OpenL(databaseFile);
	CleanupStack::PushL(dBase);
	
	// Set the filter to select all the contact items in the database
	CCntFilter* exportFilter = CCntFilter::NewL();
	CleanupStack::PushL(exportFilter);
	exportFilter->SetContactFilterTypeCard(ETrue);
	dBase->FilterDatabaseL(*exportFilter);
	idArray = exportFilter->iIds;	
	CleanupStack::PushL(idArray);
	
	TInt numberOfContacts;
   	GetIntFromConfig(ConfigSection(), KNumberOfCont, numberOfContacts);
	
	INFO_PRINTF1(_L("Deleting Contacts....."));

	// Delete the contacts one at a time
	for(TInt i=(idArray->Count()-1);i>=0;i--)
		{
		dBase->DeleteContactL((*idArray)[i]);
		}
			
	_LIT(KCount, "The number of contacts in the database is %d \n");
	INFO_PRINTF2(KCount, dBase->CountL());
	
	// Close the contacts
    dBase->CloseContactL(itemId);
	
	// Cleanup
	CleanupStack::Pop(idArray);
    CleanupStack::PopAndDestroy(exportFilter);
    CleanupStack::PopAndDestroy(dBase);
    }
コード例 #8
0
void CRemoteViewTestResources::CreateTestGroupsL()
    {
	test.Next(_L("Test for creating a remote view and validating that queued events are received in the correct order."));

	TContactViewEvent event;

	// Create A then "unnanmed", then rename "unnamed" to B
	test.Next(_L("Test for Create group A, then create group B"));

	CContactItem* group1 = iDb->CreateContactGroupLC(_L("A"));	
	iViewEventQueue->ListenForEvent(2,event);
	CheckEvent(event, TContactViewEvent::EItemAdded, 0, group1->Id());

	CContactItem* group0 = iDb->CreateContactGroupLC(_L(""));
	iViewEventQueue->ListenForEvent(2,event);
	CheckEvent(event, TContactViewEvent::EItemAdded, 1, group0->Id());
	 	
	CContactItem *group00 = iDb->OpenContactL(group0->Id());
	static_cast<CContactGroup*> (group00)->SetGroupLabelL(_L("B"));
	iDb->CommitContactL(*group00);
		
	// Received 3 events, grp changed, removed and added
	iViewEventQueue->ListenForEvent(2,event);
	CheckEvent(event, TContactViewEvent::EGroupChanged, 0, group00->Id());
	iViewEventQueue->ListenForEvent(2,event);
	CheckEvent(event, TContactViewEvent::EItemRemoved, 1, group00->Id());
	iViewEventQueue->ListenForEvent(2,event);
	CheckEvent(event, TContactViewEvent::EItemAdded, 1, group00->Id()); 	

	// Create D then "unnamed", then rename "unnamed" to C
	test.Next(_L("Test for Create group D, then create group C"));

	CContactItem* group2 = iDb->CreateContactGroupLC(_L("D"));	
	iViewEventQueue->ListenForEvent(2,event);
	CheckEvent(event, TContactViewEvent::EItemAdded, 2, group2->Id());

	CContactItem* group3 = iDb->CreateContactGroupLC(_L(""));
	iViewEventQueue->ListenForEvent(2,event);
	CheckEvent(event, TContactViewEvent::EItemAdded, 3, group3->Id());
	 	
	CContactItem *group4 = iDb->OpenContactL(group3->Id());
	static_cast<CContactGroup*> (group4)->SetGroupLabelL(_L("C"));
	iDb->CommitContactL(*group4);
		
	// Received 3 events, grp changed, removed and added
	iViewEventQueue->ListenForEvent(2,event);
	CheckEvent(event, TContactViewEvent::EGroupChanged, 0, group4->Id());
	iViewEventQueue->ListenForEvent(2,event);
	CheckEvent(event, TContactViewEvent::EItemRemoved, 3, group4->Id());
	iViewEventQueue->ListenForEvent(2,event);
	CheckEvent(event, TContactViewEvent::EItemAdded, 2, group4->Id()); 

	// More complex set of add and deletes.
	test.Next(_L("Test-Addgroup E, Addgroup F, Addgroup G , RemoveGroup G Addgroup H RenameGroup H as EA"));

	CContactItem* group5 = iDb->CreateContactGroupLC(_L("E"));	   
	CContactItem* group6 = iDb->CreateContactGroupLC(_L("F"));	    
	CContactItem* group7 = iDb->CreateContactGroupLC(_L("G"));    
	iDb->DeleteContactL(group7->Id());	    
	CContactItem* group8 = iDb->CreateContactGroupLC(_L("H"));	

	CContactItem *group01 = iDb->OpenContactL(group8->Id());
	static_cast<CContactGroup*> (group01)->SetGroupLabelL(_L("EA"));
	iDb->CommitContactL(*group01);


	// Should receive events for operations above, order is not important 
	// Should receive events as add for E F EA(H) - In the order E EA(H) F 
	// (none for G as add, then remove)
    iViewEventQueue->ListenForEvent( 2, event );
    CheckEvent( event, TContactViewEvent::EItemAdded, 4, group5->Id() );
    iViewEventQueue->ListenForEvent( 2, event );
    CheckEvent( event, TContactViewEvent::EItemAdded, 5, group6->Id() );
    iViewEventQueue->ListenForEvent( 2, event );
    CheckEvent( event, TContactViewEvent::EItemAdded, 6, group8->Id() );
    iViewEventQueue->ListenForEvent( 2, event );
    CheckEvent( event, TContactViewEvent::EItemAdded, 7, group7->Id() );
    iViewEventQueue->ListenForEvent( 2, event );
    CheckEvent( event, TContactViewEvent::EItemRemoved, 7, group7->Id() );
    iViewEventQueue->ListenForEvent( 2, event );
    CheckEvent( event, TContactViewEvent::EGroupChanged, 0, group8->Id() );

	// Cleanup
	delete group01;
	delete group00;
	delete group4;    
	CleanupStack::PopAndDestroy(group8);
	CleanupStack::PopAndDestroy(group7);
	CleanupStack::PopAndDestroy(group6);
	CleanupStack::PopAndDestroy(group5);
	CleanupStack::PopAndDestroy(group3);
	CleanupStack::PopAndDestroy(group2);     
	CleanupStack::PopAndDestroy(group0);
	CleanupStack::PopAndDestroy(group1);
    }