Пример #1
0
void CViewTester::HandleContactViewEvent(const CContactViewBase& aView,const TContactViewEvent& aEvent)
	{

	if (aEvent.iEventType == TContactViewEvent::EReady)
		{
		TInt err(KErrNone);
		++iEventsReceived;
		if (&aView == iCNRView)
			{//Ignore main view
			test.Printf(_L("Main view ready\n"));
			}
		else if (&aView == iRingToneView)
			{
			test.Printf(_L("RingTone view ready"));
			TRAP(err, TestNoErrL(aView.CountL() ) );
			test(err == KErrNone);
			test.Printf(_L(" and empty!\n"));
			}
		else if (&aView == iVoiceDialView)
			{
			test.Printf(_L("VoiceDial view ready"));
			TRAP(err, TestNoErrL(aView.CountL() ) );
			test(err == KErrNone);
			test.Printf(_L(" and empty!\n"));
			}
		else
			{
			test.Printf(_L("Unknown view in CViewTester::HandleContactViewEvent"));
			test(EFalse);
			}

		if (iEventsReceived == 3) //events from, iCNRView, iRingToneView and iVoiceDialView
			CActiveScheduler::Stop();
		}
	}
/**
 * Removes contacts from the underlying view based on the data available with contact view update objects
 */ 
void CTestContactViewUnderlyingViewUpdateStep::RemoveContactsFromTheUnderLyingViewsL()
	{
	for(TInt i = 0; i < iViewUpdateArray.Count(); ++i)
		{
		TViewModificationData contactViewValidationObject = iViewUpdateArray[i];		
		CContactViewBase* contactView = ViewCollectionReference().GetDesiredView
							(contactViewValidationObject.ViewTypeInStringFormat(), contactViewValidationObject.ViewIndex());
	

		RArray<TContactItemId> contactItemIdArray;
		CleanupClosePushL(contactItemIdArray);
		
		for(TInt j = 0; j < contactViewValidationObject.NumberOfContactsToBeRemoved(); ++j)
			{
			TContactItemId contactItemId = contactView->AtL(j);
			contactItemIdArray.AppendL(contactItemId);
			}

		for(TInt j = 0; j < contactItemIdArray.Count(); ++j)
			{
			DatabaseReference().DeleteContactL(contactItemIdArray[j]);
			}
			
		CleanupStack::PopAndDestroy(&contactItemIdArray); 
		}
	}
LOCAL_C void TestNoDuplicatesL(const CContactViewBase& aView)
    {
    const TInt count = aView.CountL();
    for (TInt i=0; i < count; ++i)
        {
        const TContactItemId id = aView.AtL(i);
        for (TInt i2=i+1; i2 < count; ++i2)
            {
            test(aView.AtL(i2) != id);
            }
        }
    }
Пример #4
0
void CGroupViewTester::ExceriseViewL(CContactViewBase& aView)
	{
	TContactItemId lastId=0;
	const TInt numItems=aView.CountL();
	for (TInt ii=0;ii<numItems;++ii)
		{
		if (ii==numItems-1)
			{
			lastId=aView.AtL(ii);
			}
		iDb.ReadContactTextDefL(aView.AtL(ii),iScratchBuf,iTextDef);
		iLog.LogLineNoEcho(iScratchBuf);
		iScratchBuf.SetLength(0);
		}

	test(aView.FindL(lastId)==numItems-1);
	}
Пример #5
0
/**
Check that view contains 1 field for each contact and that field is null
*/
void CContactViewTest::doEmptyFieldsetSortTestL(const CContactViewBase &aLView)
	{
	TInt length = aLView.CountL();
	TInt manyfields = 0;
	TInt i;
	INTCOMPARE( length , ==,  iContacts, 0, 0 );

	for(i = 0; i < length; ++i)
		{
		const CViewContact &vcontact = aLView.ContactAtL(i);
		manyfields = vcontact.FieldCount();
		INTCOMPARE( manyfields , ==,  1,  i, 0 );
		SINGLECOMPARE(  CheckViewContact( aLView.ContactAtL(i), KNullDesC ),  i ,  0 );
		}
	iObserver->iMainFunc = NULL;
	iObserver->iDoFunc = NULL;
	iObserver->CleanView();
	}
Пример #6
0
/**
check that local view contains 10 contacts, each containing 1 empty field
*/
void CContactViewTest::doViewEmptyTestL(const CContactViewBase &aLView)
	{
	TInt length = aLView.CountL();
	TInt manyfields = 0;
	TInt i;
	INTCOMPARE( length , ==,  iContacts, 0, 0 );
	iIterate->Reset();
	for(i = 0; i < length; ++i)
		{
		const CViewContact &vcontact = aLView.ContactAtL(i);
		manyfields = vcontact.FieldCount();
		INTCOMPARE( manyfields , ==,  1,  i, 0 );
		SINGLECOMPARE(  CheckViewContact( vcontact, GetFieldL(1) ),  i,  0 );
		}
	iObserver->iMainFunc = NULL;
	iObserver->iDoFunc = NULL;
	iObserver->CleanView();
	}
Пример #7
0
/**
check that local view contains 10 contacts, each containing 1 empty field
*/
void CContactViewTest::doAllEmptyTestL(const CContactViewBase &aLView)
	{
	ClosePersistanceL(ETrue);
	TInt length = aLView.CountL();
	TInt manyfields = 0;
	TInt i;
	INTCOMPARE( length , ==,  iContacts, 0, 0 );

	for(i = 0; i < length; ++i)
		{
		manyfields = aLView.ContactAtL(i).FieldCount();
		INTCOMPARE( manyfields , ==,  1,  i, 0 );
		SINGLECOMPARE(  CheckViewContact( aLView.ContactAtL(i), KNullDesC ),  i ,  0 );
		}
	iObserver->iMainFunc = NULL;
	iObserver->iDoFunc = NULL;
	iObserver->CleanView();
	}
Пример #8
0
/**
check that a field is generated for each view contact and that field matches list of missing of fields
remove generated field from contact item and repopulate contact view repeat until view contact field is null
*/
void CContactViewTest::doMissingFieldTestL(const CContactViewBase &aLView)
	{
	ClosePersistanceL(ETrue);
	TBool end = ETrue;
	TInt length = aLView.CountL();
	TInt manyfields = 0;
	TInt i;
	//iterate through ini file, that stores list of expected field in order
	const TPtrC mfield = GetNextFieldL();
	INTCOMPARE( length , ==,  iContacts, 0, 0 );
	iIterate->Reset();

	for(i = 0; i < length; ++i)
		{
		const TInt loc = aLView.FindL(iIterate->NextL());
		const CViewContact &vcontact = aLView.ContactAtL( loc );
		manyfields = vcontact.FieldCount();
		const TPtrC vfield = vcontact.Field(0);
		INTCOMPARE(  manyfields , ==,  1,  i, 0 );
		
		//compare view contact field to field stored in ini file
		STRINGCOMPARE( vfield, ==, mfield, i, 0 );
		//if view contact field is null, end test
		end = end && (vfield == KNullDesC);
		//find view contact field in contact item and set to null, if field not found, end test
		end = end || !FindAndClearFieldL( vcontact.Id(), vfield );
		}


	if( end )
		{
		iObserver->iMainFunc = NULL;
		iObserver->iDoFunc = NULL;
		iObserver->CleanView();
		}
	else
		{
		//if test not complete, reset view and repopulate
		OpenPersistanceL();
		iObserver->CleanView();
		iObserver->SetView( CreateViewL() );
		}
	}
/**
 * Validates the contact view count against expected data specified in the contact view validation objects
 */
void CTestContactViewUnderlyingViewUpdateStep::ValidateViewCountL()
	{
	for(TInt i = 0; i < iViewValidationArray.Count(); ++i)
		{
		TViewValidationData validationInfo =	iViewValidationArray[i];
		CContactViewBase* contactView = ViewCollectionReference().GetDesiredView(validationInfo.ViewTypeInStringFormat(), validationInfo.ViewIndex());

		if(contactView->CountL() != validationInfo.ExpectedViewCount())
			{
			_LIT(KErrContactViewMisMatch, "The contact view doesnt reflect the desired view count \n");
			ERR_PRINTF1(KErrContactViewMisMatch);
			
			_LIT(KInfoViewCountData, "The expected view count is %d while the actual view count is %d \n");
			INFO_PRINTF3(KInfoViewCountData, validationInfo.ExpectedViewCount(), contactView->CountL());
			
			SetTestStepResult(EFail);
			}
		}
	}
Пример #10
0
/**
check that local view contains 10 contacts, each containing as many fields
as there are uids (114), all field that have a corresponding uid should be
non-empty
*/
void CContactViewTest::doAllFullTestL(const CContactViewBase &aLView)
	{
	ClosePersistanceL(ETrue);
	TInt length = aLView.CountL();
	TInt arrayLength = iExistingUidsArray->Count();
	TInt manyfields = 0;
	TInt i;
	INTCOMPARE( length , ==,  iContacts, 0, 0 );

	for(i = 0; i < length; ++i)
		{
		const CViewContact &vcontact = aLView.ContactAtL(i);
		manyfields = vcontact.FieldCount();
		INTCOMPARE( manyfields , ==,  arrayLength,  i, 0 );
		SINGLECOMPARE(  CheckViewContactL( vcontact ),  i ,  0 );
		}
	iObserver->iMainFunc = NULL;
	iObserver->iDoFunc = NULL;
	iObserver->CleanView();
	}
Пример #11
0
LOCAL_C void CheckConsistentL
        (CContactDatabase& aDb,
        const CContactGroupView& aGroupView, 
        const CContactViewBase& aBaseView,
        TContactItemId aGroupId)
    {
    const TInt groupViewCount = aGroupView.CountL();
    test(groupViewCount <= aBaseView.CountL());
    CContactGroup* group = static_cast<CContactGroup*>(aDb.ReadContactLC(aGroupId));

    const TInt count = aBaseView.CountL();
    TInt checked = 0;
    for (TInt i=0; i < count; ++i)
        {
        const TContactItemId id = aBaseView.AtL(i);
        if (group->ContainsItem(id))
            {
            test(aGroupView.FindL(id) != KErrNotFound);
            ++checked;
            }
        }
    test(checked == groupViewCount);
    CleanupStack::PopAndDestroy(group);
    }
void CGroupViewTester::HandleContactViewEvent(const CContactViewBase& aView,const TContactViewEvent& aEvent)
	{
	switch (iCurrentTest)
		{
		case ECreateLocalView:
			iLog.LogLine(_L("==== Handling the local view creation \n"));
			test(iLocalView==&aView);
			test(aEvent.iEventType==TContactViewEvent::EReady);
			break;

		case ECreateGroupOne:
			iLog.LogLine(_L("==== Handling the group creation \n"));
		break;

		case ECreateGroupOneView:
			iLog.LogLine(_L("==== Handling the group view creation \n"));
			test(iGroupViewOne==&aView);
			test(aEvent.iEventType==TContactViewEvent::EReady);
		break;

		case EAddContactToGroupOne:
			iLog.LogLine(_L("==== Handling the addition of a contact to the group \n"));
		break;

		case EAddContact:
			iLog.LogLine(_L("==== Handling the addition of a contact \n"));
		break;

		case EModifyContactInGroupOne:
		iLog.LogLine(_L("==== Handling Contact being modified. \n"));

			switch (aEvent.iEventType)
			{
				case TContactViewEvent::EItemRemoved:
					iLog.LogLine(_L("==== Contact Is removed for modify \n"));
				break;

				case TContactViewEvent::EItemAdded:
					iLog.LogLine(_L("==== Contact Is added for modify \n"));
					{
					TInt numberOfEntries = 0;
					TRAPD(err, numberOfEntries = aView.CountL() );
					test(err == KErrNone && numberOfEntries != 0);
					}
				break;
				default:
					break;
			}
		break;

		case ENumTests:
		default:
			test(EFalse);
			break;
		}
	if (--iNumNotificationExpected<=0)
		{
		NextTest();
		iNumNotificationExpected=0;
		}
	}