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); }
LOCAL_C void AsyncDbOpenFollowedByAddGroupL() { test.Next(_L("Async database open & group creating")); 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(); delete op; CleanupStack::PushL(database); CContactItem* tempGroup = database->CreateContactGroupL(_L("New Group")); delete tempGroup; CleanupStack::PopAndDestroy(database); }
LOCAL_C void TestAsyncOpenDbAndDeleteTemplateL() { //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); //simulate a template remove event TContactDbObserverEvent event; event.iType = EContactDbObserverEventTemplateDeleted; database->HandleDatabaseEventL(event); CleanupStack::PopAndDestroy(database); }