void CPersistenceTests::OomTestL() { test.Next(_L("ReadLC OOM test")); CContactItem* cnt = iCntTestImpl.ReadLC(1, *iMatchAll); POPD(cnt); TInt ret = 0; for(TInt i=1; i < 2000; ++i) { __UHEAP_SETFAIL(RHeap::EDeterministic, i); __UHEAP_MARK; TRAP(ret, CContactItem* cnt = iCntTestImpl.ReadLC(1, *iMatchAll); POPD(cnt); ); __UHEAP_MARKEND; __UHEAP_RESET; if (ret == KErrNone) { break; } else if (ret != KErrNoMemory) { TESTVALUE(ret, KErrNoMemory); break; } if (!(i % 100)) { test.Printf(_L("."), i/100); } }
void CPersistenceTests::IccL() { CContactSyncChecker::ResetL(); CContactItem* iccEntry = CContactICCEntry::NewL(iCntTestImpl.GetSysTemplate()); PUSH(iccEntry); TCnt theCnt(iccEntry); theCnt[KUidContactFieldGivenName] = _L("Johny"); theCnt[KUidContactFieldFamilyName] = _L("Herbert"); iCntTestImpl.CreateL(*iccEntry); POPD(iccEntry); }
void CTestMachine::StepFindViewsL() { const TContactViewPreferences viewPrefs = TContactViewPreferences(EUnSortedAtEnd | EContactsOnly); _LIT(KMansell, "Mansell"); BEGIN_ASYNC_TEST ///////////////////////////////////////// //Actions: Create a local view with reverse sort plugin TESTTRAP(iLocalView = CContactLocalView::NewL(*this, *iDb, iSurnNameSortOrder, viewPrefs, KReverseSortPlugin)); WAIT_EVENT(1) //Expected Result: Check the order of entries in the view - it must be reverse. test.Printf(_L("Local View created:\n")); CheckViewOrderL(iLocalView); test.Printf(_L("\n\n")); ///////////////////////////////////////// //Actions: Create a remote view with reverse sort plugin TESTTRAP(iRemoteViewReverse = CContactRemoteView::NewL(*this, *iDb, iSurnNameSortOrder, viewPrefs, KReverseSortPlugin)); WAIT_EVENT(2) //Expected Result: Check the order of entries in the view - it must be reverse. test.Printf(_L("Remote View created:\n")); CheckViewOrderL(iRemoteViewReverse); test.Printf(_L("\n\n")); ///////////////////////////////////////// //Actions: Create a remote view with default sorting behaviour TESTTRAP(iRemoteViewForward = CContactRemoteView::NewL(*this, *iDb, iSurnNameSortOrder, viewPrefs)); WAIT_EVENT(3) //Expected Result: Check the order of entries in the view - it must be forward test.Printf(_L("Remote View created:\n")); CheckViewOrderL(iRemoteViewForward, EFalse, EFalse); //do not Print, forward order test.Printf(_L("\n\n")); ///////////////////////////////////////// //Actions: Create a Find view on top of the local view, using "Ma" search string iFindDesArray =new(ELeave)CPtrC16Array(1); _LIT(KMa,"Ma"); iFindDesArray->AppendL(TPtrC(KMa)); iLocalFindView= CContactFindView::NewL(*iDb,*iLocalView,*this,iFindDesArray); WAIT_EVENT(4) //Expected Result: Check the order of entries in the find view - it must be reverse test.Printf(_L("LocalFind View created:\n")); CheckViewOrderL(iLocalFindView); test.Printf(_L("\n\n")); ///////////////////////////////////////// //Actions: Create a Find view on top of the reverse remote view, using "el" search string iFindDesArray->Reset(); _LIT(Kel,"el"); iFindDesArray->AppendL(TPtrC(Kel)); iRemoteFindView = CContactFindView::NewL(*iDb,*iRemoteViewReverse,*this,iFindDesArray); WAIT_EVENT(5) //Expected Result: Check the order of entries in the find view - it must be reverse test.Printf(_L("RemoteFind View created:\n")); CheckViewOrderL(iRemoteFindView); test.Printf(_L("\n\n")); ///////////////// //Actions: Add a new contact to the database, it must have "ma" and "el" substrings in it // to appear in either find view. Check the sorting in every view. _LIT8(KIrvVCard, "BEGIN:VCARD\r\nVERSION:2.1\r\nN:Mansell;Nigel;11\r\nPensioner\r\nEND:VCARD"); RDesReadStream stream(KIrvVCard); stream.PushL(); TBool success(EFalse); CArrayPtr<CContactItem>* contactItems=iDb->ImportContactsL(TUid::Uid(KUidVCardConvDefaultImpl), stream, success, NULL); CleanupStack::PopAndDestroy(); // stream PUSH(contactItems); TESTTRUE(success); test.Printf(_L("%d entry was added created\n"), contactItems->Count()); contactItems->ResetAndDestroy(); //Potential memory leak - must be pushed onto the stack with ResetAndDestroy POPD(contactItems); WAIT_EVENTS(6,5) //Waiting for 5 events to arrive (one from each view) //Note, that if all 5 events won't arrive the code will stuck here //It can be solved with another "timeout" active object, but not yet implemented //Expected Result: Every view must send an event (5 events in total). //Sort order for all the views except for RemoteForward view must be reverse. //New entry must be inserted in every view. test.Printf(_L("Local View:\n")); CheckViewOrderL(iLocalView); test.Printf(_L("\n\n")); test.Printf(_L("Remote View Reverse:\n")); CheckViewOrderL(iRemoteViewReverse); test.Printf(_L("\n\n")); test.Printf(_L("Remote View Forward:\n")); CheckViewOrderL(iRemoteViewForward, EFalse, EFalse); //do not Print, forward order test.Printf(_L("\n\n")); test.Printf(_L("Local Find View:\n")); CheckViewOrderL(iLocalFindView); test.Printf(_L("\n\n")); test.Printf(_L("Remote Find View:\n")); CheckViewOrderL(iRemoteFindView); test.Printf(_L("\n\n")); //Searching for Mansell in the DB. TContactItemId manselId = SearchInViewL(iLocalFindView, KMansell); TESTTRUEL(manselId != 0); //Have we found it? //Actions: Change a newly added contact from "Nigel Mansell" to "Ayrton Senna". CContactItem* mansContact = iDb->OpenContactLX(manselId); PUSH(mansContact); CContactItemFieldSet& fieldSet = mansContact->CardFields(); CContactItemField& givenNameField = fieldSet[fieldSet.Find(KUidContactFieldGivenName)]; givenNameField.TextStorage()->SetTextL(_L("Ayrton")); CContactItemField& familyNameField = fieldSet[fieldSet.Find(KUidContactFieldFamilyName)]; familyNameField.TextStorage()->SetTextL(_L("Senna")); CContactItemField& ordinalNumField = fieldSet[fieldSet.Find(KUidContactFieldAdditionalName)]; ordinalNumField.TextStorage()->SetTextL(_L("20")); //Number is used for sorting checking iDb->CommitContactL(*mansContact); POPD(mansContact); CleanupStack::PopAndDestroy(); //record lock WAIT_EVENTS(7,10) //Waiting for 10 events to arrive (delele and insert event from each view) //Actions: Check the sorting in every view. //Expected Result: 10 events should arrive - 5 deletes and 5 inserts. //Sort order for all the views except for RemoteForward view must be reverse. //The entry must be updated in local and remote views and should disappear //from Find views because it doesn't contain substrings "Ma" or "el" anymore. test.Printf(_L("Local View:\n")); CheckViewOrderL(iLocalView, ETrue); test.Printf(_L("\n\n")); test.Printf(_L("Remote View Reverse:\n")); CheckViewOrderL(iRemoteViewReverse, ETrue); test.Printf(_L("\n\n")); test.Printf(_L("Remote View Forward:\n")); CheckViewOrderL(iRemoteViewForward, EFalse, EFalse); //do not Print, forward order test.Printf(_L("\n\n")); test.Printf(_L("Local Find View:\n")); CheckViewOrderL(iLocalFindView, ETrue); test.Printf(_L("\n\n")); test.Printf(_L("Remote Find View:\n")); CheckViewOrderL(iRemoteFindView, ETrue); test.Printf(_L("\n\n")); //We changed Mansell to Senna - the entry shouldn't appear in either find views TContactItemId manselId = SearchInViewL(iLocalFindView, KMansell); TESTTRUE(manselId == 0); manselId = SearchInViewL(iRemoteFindView, KMansell); TESTTRUE(manselId == 0); CloseView(iLocalFindView); CloseView(iLocalView); CloseView(iRemoteFindView); CloseView(iRemoteViewReverse); CloseView(iRemoteViewForward); iFindDesArray->Reset(); delete iFindDesArray; iFindDesArray = NULL; END_ASYNC_TEST }