Example #1
0
/**
 * Creates a new, nondamaged DB.
 */
void CTestResources::ConstructL(TBool aDamaged)
    {
    if (aDamaged)
        {
        // Create an empty DB...
        CContactDatabase* db = CContactDatabase::ReplaceL(KTestDbName);
        CleanupStack::PushL(db);
        // Damage the DB...
        db->DamageDatabaseL(0x666);
        // Close the DB.
        CleanupStack::PopAndDestroy(db);
        // Open the damaged database. CContactDatabase::OpenL() does recovery
        // by calling RecoverL().
		iDb = CContactDatabase::OpenL(KTestDbName);
        }
    else
        {
        // Just create an empty DB
        iDb = CContactDatabase::ReplaceL(KTestDbName);
        }

    iViewEventQueue = CContactViewEventQueue::NewL();

    iViewSortOrder.AppendL(KUidContactFieldFamilyName);
    iViewSortOrder.AppendL(KUidContactFieldGivenName);
    iViewSortOrder.AppendL(KUidContactFieldCompanyName);
    
    iLocalView = CContactLocalView::NewL
        (*iViewEventQueue, *iDb, iViewSortOrder, EContactsOnly);
    }
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();
    }
Example #4
0
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 CFilteredViewTester::ConstructL()
	{
	CTimer::ConstructL();
	iContactDb = CContactDatabase::CreateL(KDbName);
	iSortOrder.AppendL(KUidContactFieldFamilyName);
	iSortOrder.AppendL(KUidContactFieldGivenName);
	iIdArray = CContactIdArray::NewL ();
	}
void CTestResources::ConstructL()
    {
    iDb = CContactDatabase::ReplaceL(KTestDbName);
    iDbEventQueue = CDbEventListener::NewL(*iDb);
    iViewSortOrder.AppendL(KUidContactFieldFamilyName);
    iViewSortOrder.AppendL(KUidContactFieldGivenName);
    iViewSortOrder.AppendL(KUidContactFieldCompanyName);
    }
Example #7
0
void CTestResources::ConstructL()
{
    iDb = CContactDatabase::ReplaceL(KTestDbName);

    iViewSortOrder.AppendL(KUidContactFieldFamilyName);
    iViewSortOrder.AppendL(KUidContactFieldGivenName);
    iViewSortOrder.AppendL(KUidContactFieldCompanyName);

    iRemoteView = CContactRemoteView::NewL(*this, *iDb, iViewSortOrder, EContactsOnly);
    CreateTestContactsL();
}
/**
 Creates a named remote view
*/
void CViewResort::CreateRemoteViewL()
	{
	RContactViewSortOrder viewSortOrder;
	CleanupClosePushL(viewSortOrder);
	viewSortOrder.AppendL(KUidContactFieldFamilyName);
	viewSortOrder.AppendL(KUidContactFieldGivenName);
	viewSortOrder.AppendL(KUidContactFieldCompanyName);

	_LIT(KViewName, "resortTestRemoteNamedView");
	iNamedRemoteView = CContactNamedRemoteView::NewL(*this, KViewName, *iContactsDb, viewSortOrder, EContactsOnly);

	CleanupStack::PopAndDestroy(&viewSortOrder);
	iViewState = ECreatedView;
	}
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);
    }
/**
 Resorts the remote view.
*/
void CViewResort::ResortL()
	{
	RContactViewSortOrder viewSortOrder;
	CleanupClosePushL(viewSortOrder);

	switch 	(iViewState)
		{
		case ECreatedView:
			// sort in a different order from the original view sort order
			// but with the same three fields from the identity table
			viewSortOrder.AppendL(KUidContactFieldCompanyName);
			viewSortOrder.AppendL(KUidContactFieldFamilyName);
			viewSortOrder.AppendL(KUidContactFieldGivenName);
			iNamedRemoteView->ChangeSortOrderL(viewSortOrder);
			iViewState = EResortedViewByName;
			break;
		case EResortedViewByName:
			// sorting in a different order from the original view sort order
			// but with the phonenumber field from the phone table
			viewSortOrder.AppendL(KUidContactFieldPhoneNumber);
			viewSortOrder.AppendL(KUidContactFieldGivenName);
			viewSortOrder.AppendL(KUidContactFieldFamilyName);
			iNamedRemoteView->ChangeSortOrderL(viewSortOrder);
			iViewState = EResortedViewByNumber;
			break;
		}
    CleanupStack::PopAndDestroy(&viewSortOrder);
	}
Example #11
0
void CSubViewTest::CreateNamedLocalViewL()
	{
	test.Next(_L("Creating local view."));

	
	RContactViewSortOrder sortOrder;
	CleanupClosePushL(sortOrder);
	sortOrder.AppendL(KUidContactFieldFamilyName);
	sortOrder.AppendL(KUidContactFieldGivenName);
	sortOrder.AppendL(KUidContactFieldCompanyName);
	sortOrder.AppendL(KUidContactFieldPhoneNumber);

	// set the field indexes to reflect the order above
	iLnameIdx = 0;
	iFnameIdx = 1;
	iCnameIdx = 2;
	iNumIdx   = 3;
	
	iNamedLocalView = CContactNamedLocalView::NewL(*this, KTestName(), *iContactsDb, sortOrder, EContactsOnly);
	
	CleanupStack::PopAndDestroy(&sortOrder);
	}
Example #12
0
void CSubViewTest::ResortNamedLocalViewL()
	{
	test.Next(_L("Resorting local view."));


	RContactViewSortOrder sortOrder;
	CleanupClosePushL(sortOrder);
	sortOrder.AppendL(KUidContactFieldCompanyName);
	sortOrder.AppendL(KUidContactFieldGivenName);
	sortOrder.AppendL(KUidContactFieldFamilyName);
	sortOrder.AppendL(KUidContactFieldPhoneNumber);

	// set the field indexes to reflect the order above
	iCnameIdx = 0;
	iFnameIdx = 1;
	iLnameIdx = 2;
	iNumIdx   = 3;
	
	iNamedLocalView->ChangeSortOrderL(sortOrder);

	CleanupStack::PopAndDestroy(&sortOrder);
	}
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());
  
    }
Example #14
0
/**
 Times the synchronous part of remote view creation.
*/
void CStartUp::CreateRemoteViewL()
	{
	iTimer.ResetTimer();
	iTimer.StartTimer();

	RContactViewSortOrder viewSortOrder;
	CleanupClosePushL(viewSortOrder);
	
	viewSortOrder.AppendL(KUidContactFieldFamilyName);
	viewSortOrder.AppendL(KUidContactFieldGivenName);
	viewSortOrder.AppendL(KUidContactFieldCompanyName);

	if (iViewType == ERemoteContactsView)
		{
		iContactRemoteView = CContactRemoteView::NewL(*this, *iContactsDb, viewSortOrder, EContactsOnly);
		}
	else if (iViewType == ERemoteGroupsView)
		{
		iContactRemoteView = CContactRemoteView::NewL(*this, *iContactsDb, viewSortOrder, EGroupsOnly);
		}
	
	CleanupStack::PopAndDestroy(&viewSortOrder);
	}
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(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 CContactsRamTest::ConstructL()
	{
	CActiveScheduler::Add(this);
	iViewSortOrder.AppendL(KUidContactFieldGivenName);	
	iViewSortOrder.AppendL(KUidContactFieldFamilyName);
	}
void CTestMachine::StepNamedRemoteViewsL()
	{
	const TContactViewPreferences viewPrefs = TContactViewPreferences(EUnSortedAtEnd | EContactsOnly);
	_LIT(KNamedRemoteView, "NamedRemoteView");

	RContactViewSortOrder theNameSurnSortOrder;
	theNameSurnSortOrder.AppendL(KUidContactFieldGivenName);
	theNameSurnSortOrder.AppendL(KUidContactFieldFamilyName);
	theNameSurnSortOrder.AppendL(KUidContactFieldPrefixName); //Contains order numbers for given name

	BEGIN_ASYNC_TEST
		//Actions:	Create named remote view a reverse sorting plugin. Check sorting order.
		iNamedRemoteView = CContactNamedRemoteView::NewL(*this, KNamedRemoteView, *iDb,iSurnNameSortOrder,viewPrefs, KReverseSortPlugin);

	WAIT_EVENT(1)
		//Expected Result:	Named remote view must be created - sorting order must be reverse.
		test.Printf(_L("Named Remote View:\n"));
		CheckViewOrderL(iNamedRemoteView, ETrue);
		test.Printf(_L("\n\n"));

		//Actions:	Create another instance of the named remote view with the same name, 
		//			but without a sorting plugin this time. Check sorting order.
		TESTTRAP(iNamedRemoteView2 = CContactNamedRemoteView::NewL(*this, KNamedRemoteView, *iDb, iSurnNameSortOrder,viewPrefs));
	WAIT_EVENT(2)

		//Expected Result:	When we create another named remote view with the name of existing view 
		// - another copy of the view will not be created, instead will receive the handle 
		//to existing view. That is why sort order should be as first time - reverse.
		test.Printf(_L("Another Copy of Named Remote View:\n"));
		CheckViewOrderL(iNamedRemoteView2, ETrue);
		test.Printf(_L("\n\n"));

		//Actions:	Change the sort order of the named remote view to sort on 
		//	Name and then Surname of the contacts. Check sorting for both handles of the view.
		iNamedRemoteView2->ChangeSortOrderL(theNameSurnSortOrder);
	WAIT_EVENTS(3,4) //2 EUnavailable and 2 EOrderChanged

		//Expected Result:	Both instances of the view must be sorted in reverse order on 
		//Names and Surnames of the contacts.
		test.Printf(_L("First Copy of Named Remote View:\n"));
		CheckViewOrderL(iNamedRemoteView, ETrue);
		test.Printf(_L("\n\n"));

		test.Printf(_L("Another Copy of Named Remote View:\n"));
		CheckViewOrderL(iNamedRemoteView2, ETrue);
		test.Printf(_L("\n\n"));

		/////////////////////////////////////////
		//Actions:	Create a Find view on top of the first instance of named remote view, 
		//using "Ma" search string 
		iFindDesArray =new(ELeave)CPtrC16Array(1);
		_LIT(KMa,"Ma");
		iFindDesArray->AppendL(TPtrC(KMa));

		iNamedRemoteFindView= CContactFindView::NewL(*iDb,*iNamedRemoteView,*this,iFindDesArray);
	WAIT_EVENT(4)

		//Expected Result:	Check the order of entries in the find view - it must be reverse,
		// sorting on Names and Surnames
		test.Printf(_L("NamedRemoteFind View created:\n"));
		CheckViewOrderL(iNamedRemoteFindView, ETrue);
		test.Printf(_L("\n\n"));

		/////////////////////////////////////////
		//Actions:	Create a Find view on top of the second instance of named remote view, 
		// using "el" search string 
		iFindDesArray->Reset();
		_LIT(Kel,"el");
		iFindDesArray->AppendL(TPtrC(Kel));
		iNamedRemoteFindView2 = CContactFindView::NewL(*iDb,*iNamedRemoteView2,*this,iFindDesArray);
	WAIT_EVENT(5)

		//Expected Result:	Check the order of entries in the find view - it must be reverse, 
		//sorting on Names and Surnames
		test.Printf(_L("NamedRemoteFind View 2 created:\n"));
		CheckViewOrderL(iNamedRemoteFindView2, ETrue);
		test.Printf(_L("\n\n"));
		
		CloseView(iNamedRemoteFindView);
		CloseView(iNamedRemoteFindView2);
		CloseView(iNamedRemoteView);
		CloseView(iNamedRemoteView2);

		iFindDesArray->Reset();
		delete iFindDesArray; iFindDesArray = NULL;

	END_ASYNC_TEST

	theNameSurnSortOrder.Close();
	}