//===============================================================================================
// SEARCHING entries
//===============================================================================================
void TestFindLC(CContactDatabase& aDb, TContactItemId aIccId, TContactItemId aNonIccId)
	{
	test.Next(_L("Test FindLC"));
	// Successful find of icc entry
	CContactItemFieldDef* fieldDef=new(ELeave) CContactItemFieldDef;
	CleanupStack::PushL(fieldDef);
	fieldDef->AppendL(KUidContactFieldFamilyName);
	syncChecker->ResetMethodCallCountsL();
	CContactIdArray* array = aDb.FindLC(KIccName,fieldDef);
	test(syncChecker->ValidateMethodCallCountL() == 1);
	test(array!=NULL);
	test(array->Count() == 1);
	test((*array)[0]==aIccId);
	CleanupStack::PopAndDestroy(array);
	array=NULL;

	test.Next(_L("Test searching when ICC locked"));
	// Unsuccessful find of icc entry because icc locked
	syncChecker->SetValidateResponseL(MContactSynchroniser::ESearch,KErrLocked);
	syncChecker->ResetMethodCallCountsL();
	TRAPD(err,array = aDb.FindLC(KIccName,fieldDef));
	test(syncChecker->ValidateMethodCallCountL() == 1);
	test(err==KErrLocked);
	test(array==NULL);

	// successful find of non-icc entry, even though icc locked
	syncChecker->ResetMethodCallCountsL();
	array = aDb.FindLC(KNonIccName,fieldDef);
	test(syncChecker->ValidateMethodCallCountL() == 0);
	test(array!=NULL);
	test(array->Count() == 1);
	test((*array)[0]==aNonIccId);
	CleanupStack::PopAndDestroy(2,fieldDef); // array, fieldDef
	}
Exemplo n.º 2
0
void  CTestResources::CheckFoundL(TInt i)
	{
	if(i<0 || i>GNumberOfFieldNames)
		{
		User::Leave(KErrNotSupported);
		}
	iFindFields->Reset();
	if(i==GNumberOfFieldNames)
		{
		for(TInt k =0; k<i; k++)
			{
			iFindFields->AppendL(TUid::Uid(GFieldNames[k]));
			}
		}
	else
		{
		iFindFields->AppendL(TUid::Uid(GFieldNames[i]));
		}
	CContactIdArray* ids = iDb->FindLC(KStringToFind, iFindFields);
	TInt count = ids->Count();
	test(count == GNumberOfFinds[i]);
	CleanupStack::PopAndDestroy(ids);
	 }