void CTestResources::ConstructL() { iDb = CContactDatabase::ReplaceL(KTestDbName); iDbEventQueue = CContactDbEventQueue::NewL(iDb); iViewEventQueue = CContactViewEventQueue::NewL(); iViewSortOrder.AppendL(KUidContactFieldFamilyName); iViewSortOrder.AppendL(KUidContactFieldGivenName); iViewSortOrder.AppendL(KUidContactFieldCompanyName); iLocalView = CContactLocalView::NewL (*iViewEventQueue, *iDb, iViewSortOrder, EContactsOnly); iFilteredViewEventQueue = CContactViewEventQueue::NewL(); // Create a filtered view which contains contacts with phone numbers iFilteredView = CContactFilteredView::NewL (*iFilteredViewEventQueue, *iDb, *iLocalView, CContactDatabase::EPhonable); // Wait for filtered view to get ready TContactViewEvent event; __ASSERT_ALWAYS(iFilteredViewEventQueue->ListenForEvent(10,event), User::Invariant()); __ASSERT_ALWAYS(event.iEventType == TContactViewEvent::EReady, User::Invariant()); // Flush all other events iDbEventQueue->Flush(); iViewEventQueue->Flush(); iFilteredViewEventQueue->Flush(); }
void CTestResources::ConstructL() { iDb = CContactDatabase::ReplaceL(KTestDbName); iDbEventQueue = CContactDbEventQueue::NewL(iDb); CreateTestContactsL(); iViewEventQueue = CContactViewEventQueue::NewL(); iViewSortOrder.AppendL(KUidContactFieldFamilyName); iViewSortOrder.AppendL(KUidContactFieldGivenName); iViewSortOrder.AppendL(KUidContactFieldCompanyName); iLocalView = CContactLocalView::NewL (*iViewEventQueue, *iDb, iViewSortOrder, EGroupsOnly); iGroupViewEventQueue = CContactViewEventQueue::NewL(); iGroupView = CContactGroupView::NewL (*iDb, *iLocalView, *iGroupViewEventQueue, iGroupId, CContactGroupView::EShowContactsInGroup); // Wait for group view to get ready TContactViewEvent event; test(iGroupViewEventQueue->ListenForEvent(10, event)); test(event.iEventType == TContactViewEvent::EReady); // Flush all other events iDbEventQueue->Flush(); iViewEventQueue->Flush(); iGroupViewEventQueue->Flush(); }
void CTestResources::StartTestOneL() { // Create an empty database iDb = CContactDatabase::ReplaceL(KTestDbName); CreateTestOneContactsL(); test.Next(_L("Starting Test 1")); iViewEventQueue = CContactViewEventQueue::NewL(); iViewEventQueueReverse = CContactViewEventQueue::NewL(); iViewSortOrder.AppendL(KUidContactFieldGivenName); iViewSortOrder.AppendL(KUidContactFieldFamilyName); iViewSortOrder.AppendL(KUidContactFieldCompanyName); iLocalView = CContactLocalView::NewL(*iViewEventQueue, *iDb, iViewSortOrder, EContactsOnly); TRAPD(err, iLocalReverseView = CContactLocalView::NewL(*iViewEventQueueReverse, *iDb, iViewSortOrder, EContactsOnly, KReverseSortPlugin)); // KErrNotFound means Sort Plug-in was not found test(err == KErrNone); // Wait 5 seconds for the view to get ready TContactViewEvent event; test(iViewEventQueue->ListenForEvent(5,event)); test(event.iEventType == TContactViewEvent::EReady); // Wait 5 seconds for the reverse view to get ready test(iViewEventQueueReverse->ListenForEvent(5,event)); test(event.iEventType == TContactViewEvent::EReady); }
void CTestResources::ConstructL() { iDb = CContactDatabase::ReplaceL(KTestDbName); iContacts = CContactIdArray::NewL(); // Create some contacts into the database (don't create any groups) CreateTestContactsL(); // Close and reopen the DB (this does not help with the bug) /* delete iDb; iDb = NULL; iDb = CContactDatabase::OpenL(KTestDbName); */ iViewEventQueue = CContactViewEventQueue::NewL(); iViewSortOrder.AppendL(KUidContactFieldTemplateLabel); // Create a groups only contact view const TContactViewPreferences prefs = static_cast<TContactViewPreferences>(EGroupsOnly); iLocalView = CContactLocalView::NewL (*iViewEventQueue, *iDb, iViewSortOrder, prefs); #if defined (_DEBUG) // Wait for view to get ready TContactViewEvent event; #endif ASSERT(iViewEventQueue->ListenForEvent(10,event)); ASSERT(event.iEventType == TContactViewEvent::EReady); }
/** * Listen for contact view notifications and update the actual view validation information * @param aViewObserver desired contact view observer * @param aActualData contact view validation object that will be updated with actual results */ void CContactViews::ListenForContactViewEvents(CContactViewEventQueue& aViewObserver, TContactViewValidationData& aActualData) { const TInt KViewEventTimeOut = 20; // ms TContactViewEvent viewEvent; while(aViewObserver.ListenForEvent(KViewEventTimeOut,viewEvent)) { TContactViewValidationData::TContactViewNotificationType notificationType; aActualData.NotificationType(viewEvent, notificationType); aActualData.IncrementNotificationCount(notificationType); } }
LOCAL_C void TestOpenLocalViewL (CTestResources& aRes, TInt aCount) { // Create a local view on the DB CContactViewEventQueue* viewEvents = CContactViewEventQueue::NewL(); CleanupStack::PushL(viewEvents); CContactLocalView* testView = CContactLocalView::NewL (*viewEvents, *aRes.iDb, aRes.iViewSortOrder, EContactsOnly); CleanupStack::PushL(testView); // Wait for the view to initialize TContactViewEvent event; test(viewEvents->ListenForEvent(10,event)); test(event.iEventType == TContactViewEvent::EReady); // Check view count is correct test(testView->CountL() == aCount); // Check view doesn't contain any duplicates TestNoDuplicatesL(*testView); CleanupStack::PopAndDestroy(2,viewEvents); }
void CRemoteViewTestResources::ConstructL() { iDb = CContactDatabase::ReplaceL(KTestDbName); iContacts = CContactIdArray::NewL(); iViewEventQueue = CContactViewEventQueue::NewL(); iViewSortOrder.AppendL(KUidContactFieldTemplateLabel); const TContactViewPreferences prefs = static_cast<TContactViewPreferences> (EGroupsOnly |ESingleWhiteSpaceIsEmptyField | EUnSortedAtEnd); iRemoteView = CContactRemoteView::NewL(*iViewEventQueue, *iDb, iViewSortOrder, prefs); // Wait for view to get ready TContactViewEvent event; TBool eventReady = iViewEventQueue->ListenForEvent(10,event); __ASSERT_ALWAYS(eventReady,User::Invariant()); ASSERT(event.iEventType == TContactViewEvent::EReady); }
void CTestResources::ConstructL() { iDb = CContactDatabase::ReplaceL(KTestDbName); CreateTestContactsL(); iViewEventQueue = CContactViewEventQueue::NewL(); iViewSortOrder.AppendL(KUidContactFieldFamilyName); iViewSortOrder.AppendL(KUidContactFieldGivenName); iViewSortOrder.AppendL(KUidContactFieldCompanyName); const TContactViewPreferences prefs = static_cast<TContactViewPreferences>(EContactsOnly); iLocalView = CContactLocalView::NewL (*iViewEventQueue, *iDb, iViewSortOrder, prefs); // Wait for view to get ready TContactViewEvent event; __ASSERT_ALWAYS(iViewEventQueue->ListenForEvent(10,event),User::Invariant()); __ASSERT_ALWAYS(event.iEventType == TContactViewEvent::EReady ,User::Invariant()); }
void CTestResources::ConstructL(TInt aNumberOfContactsToAddToExistingDatabase, TBool aCreateNewDatabase) { if (aCreateNewDatabase) iDb = CContactDatabase::ReplaceL(KTestDbName); else iDb = CContactDatabase::OpenL(KTestDbName); if(!iRandomGenerator) { iRandomGenerator=CRandomContactGenerator::NewL(); } iRandomGenerator->SetDbL(*iDb); CreateContactsL(aNumberOfContactsToAddToExistingDatabase); // done adding everything to the database TCntProfile profile[1]; CCntTest::ProfileReset(0,1); CCntTest::ProfileStart(0); iDb->CompactL(); CCntTest::ProfileEnd(0); CCntTest::ProfileResult(&profile[0],0,1); TInt timeToCompact = profile[0].iTime/1000; CCntTest::ProfileReset(0,1); CCntTest::ProfileStart(0); delete iDb; iDb=NULL; CCntTest::ProfileEnd(0); CCntTest::ProfileResult(&profile[0],0,1); TInt timeToClose = profile[0].iTime; // in microseconds CCntTest::ProfileReset(0,1); CCntTest::ProfileStart(0); iDb = CContactDatabase::OpenL(KTestDbName); CCntTest::ProfileEnd(0); CCntTest::ProfileResult(&profile[0],0,1); iRandomGenerator->SetDbL(*iDb); TInt timeToOpen = profile[0].iTime/1000; TInt numberOfContactsInDb=iDb->CountL(); iViewEventQueue = CContactViewEventQueue::NewL(NULL, numberOfContactsInDb*2); TInt i; for(i = 0; i< GNumberOfFieldsToSort; i++) { iViewSortOrder.AppendL(TUid::Uid(GFieldsToSort[i])); } iLocalView = CContactLocalView::NewL(*iViewEventQueue, *iDb, iViewSortOrder, EContactsOnly); // Wait 100 seconds for the view to get ready TContactViewEvent event; CCntTest::ProfileReset(0,1); CCntTest::ProfileStart(0); test(iViewEventQueue->ListenForEvent(100,event)); CCntTest::ProfileEnd(0); CCntTest::ProfileResult(&profile[0],0,1); test(event.iEventType == TContactViewEvent::EReady); TBuf<128> result; result.Format(_L("*%C Contacts: %d\t"),static_cast<TUint>(GChar),numberOfContactsInDb); RDebug::Print(result); result.Format(_L("\tView ready: %d ms\t\tOpen: %d ms\t\tClose: %d us\t\tCompact: %d ms\t"), profile[0].iTime/1000, timeToOpen, timeToClose, timeToCompact); RDebug::Print(result); result.Format(_L("\tSize: %d bytes\n"),iDb->FileSize()); RDebug::Print(result); iFindFields = new(ELeave)CContactItemFieldDef; }
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); }