void CConcurrentNotifierStep::DeleteTestL() { INFO_PRINTF1(KTest4); SetSharedTextL(KSharedNextTest, KSingleCharacter, ETrue); iWaiting = ETrue; TContactItemId cid = iIterate->NextL(); DeleteContactL( cid, EFalse ); AddEventL(EContactDbObserverEventContactDeleted); AddContactL( cid ); SetMessageCountL(); iStart.UniversalTime(); }
void CConcurrentNotifierStep::OwnCardDeleteTestL() { INFO_PRINTF1(KTest9); SetSharedTextL(KSharedNextTest, KSingleCharacter, ETrue); iWaiting = ETrue; iMyActive->Activate(); TContactItemId cid = iContactsDatabase->OwnCardId(); ReadL( cid ); CloseL( EFalse ); DeleteContactL( cid, EFalse ); AddEventL( EContactDbObserverEventOwnCardDeleted ); AddContactL( cid); SetMessageCountL(); iStart.UniversalTime(); }
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(); }
void CPlTransMgrTest::OutOfMemoryDeleteTestL() { TInt ret = KErrNoMemory; TInt failAt = 0; while (ret!=KErrNone) { failAt++; TInt cntID = AddAndCommitContactL(); iPersistLayer->TransactionManager().StartTransactionL(); __UHEAP_SETFAIL(RHeap::EDeterministic,failAt); __UHEAP_MARK; TRAPD(err, DeleteContactL(cntID)); if (err==KErrNone) { TRAP(err, iPersistLayer->TransactionManager().CommitCurrentTransactionL(0)); if (err==KErrNone) { test.Next(_L("-> TEST SUCCESS - Delete Contact committed during OOM Test")); __UHEAP_RESET; return; } } __UHEAP_RESET; if (err!=KErrNoMemory && err!=KErrNone) { test.Printf(_L("Non standard error: %d\n"),err); } if (err == KErrNoMemory) { iPersistLayer->TransactionManager().RollbackCurrentTransactionL(0); // Close the database to allow recovery iPersistLayer->ContactsFileL().Close(); iPersistLayer->ContactsFileL().RecoverL(nsPlTransMgr::KFilename); if (IsContactInDbL(cntID)) { test.Printf(_L(" ->Correct result - Delete rollback during OOM - Contact Found... Step: %d \n\r"),failAt); } else { test.Printf(_L(" ->Error - Delete rollback during OOM - Contact NOT Found... Step: %d \n\r"),failAt); User::Leave(KErrNotFound); } } } }
void CConcurrentNotifierStep::DeleteSpeedDialTestL() { INFO_PRINTF1(KTest15); SetSharedTextL(KSharedNextTest, KSingleCharacter, ETrue); iWaiting = ETrue; iMyActive->Activate(); TBuf<200> ptr; TContactItemId cid = iContactsDatabase->GetSpeedDialFieldL(iSpeedPosition, ptr); DeleteContactL( cid, EFalse ); AddEventL( EContactDbObserverEventSpeedDialsChanged ); AddContactL( cid ); AddEventL( EContactDbObserverEventContactDeleted ); AddContactL( cid); SetMessageCountL(); iStart.UniversalTime(); }
void CPlTransMgrTest::DeleteAndCommitTestL() { test.Next(_L("-> Contact and Commit Test")); TInt cntID = AddAndCommitContactL(); iPersistLayer->TransactionManager().StartTransactionL(); DeleteContactL(cntID); iPersistLayer->TransactionManager().CommitCurrentTransactionL(0); if (!IsContactInDbL(cntID)) { test.Next(_L("-> TEST SUCCESS - Contact FOUND after Update commit test")); return; } test.Next(_L("-> TEST FAILED - Contact NOT FOUND after Update commit test")); }
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 ); } } }