phonebookengines/contactsmodel/tsrc/Integration/CntPerfTest/src/AccessCountTests.cpp
changeset 0 e686773b3f54
child 24 0ba2181d7c28
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 /**
       
    17  @file
       
    18  @publishedAll
       
    19  @released
       
    20 */
       
    21 
       
    22 #include <test/testexecutelog.h>
       
    23 #include <cntfldst.h>
       
    24 #include "ClientServer.h"
       
    25 #include "AccessCountTests.h"
       
    26 
       
    27 _LIT(KRun1,"DeleteAccessed");
       
    28 _LIT(KRun2,"ForwardDeletion");
       
    29 _LIT(KRun3,"ReverseDeletion");
       
    30 _LIT(KRun4,"AgentGetSet");
       
    31 _LIT(KRun5,"AgentAccess");
       
    32 _LIT(KRun6,"AgentImportExport");
       
    33 
       
    34 _LIT(KTest1,"Testing deletion of contacts with access count > 0...");
       
    35 _LIT(KTest2,"Testing agent fields and forward deletion of items with those fields...");
       
    36 _LIT(KTest3,"Testing agent fields and reverse deletion of items with those fields...");
       
    37 _LIT(KTest4,"Agent retrieve and set test...");
       
    38 _LIT(KTest5,"Agent access count test...");
       
    39 _LIT(KTest6,"Agent import/export access count test...");
       
    40 
       
    41 _LIT(KVcardFile,"c:\\ExportedContacts.vcf");
       
    42 _LIT(KAgentValue,"Agent value: %d");
       
    43 
       
    44 //Number of contacts
       
    45 CAccessCountTests::CAccessCountTests(CCntPerfServer &aParent):CCntBaseStep(30, aParent)
       
    46 	{
       
    47 	// Call base class method to set up the human readable name for logging
       
    48 	SetTestStepName(SharedConstants::KAccessCountTests);
       
    49 	}
       
    50 
       
    51 void CAccessCountTests::PreTestL()
       
    52 	{
       
    53 	User::LeaveIfError( iParent->Fs().Connect() );
       
    54 	}
       
    55 
       
    56 TVerdict CAccessCountTests::doTestStepL()
       
    57 	{
       
    58 	
       
    59 	__UHEAP_MARK;
       
    60 
       
    61 	InitializeL();
       
    62 	iIterate->Reset();
       
    63 	
       
    64 	const TDesC &run = ConfigSection();
       
    65 	
       
    66 	if( run == KRun1 )
       
    67 		{
       
    68 		INFO_PRINTF1(KTest1);
       
    69 		AccessCountTestL( iIterate->NextL() );
       
    70 		}
       
    71 	else if( run == KRun2 )
       
    72 		{
       
    73 		INFO_PRINTF1(KTest2);
       
    74 		ForwardAgentDeletionTestL( 10 );
       
    75 		}
       
    76 	else if( run == KRun3 )
       
    77 		{
       
    78 		INFO_PRINTF1(KTest3);
       
    79 		ReverseAgentDeletionTestL( 10 );
       
    80 		}
       
    81 	else if( run == KRun4 )
       
    82 		{
       
    83 		INFO_PRINTF1(KTest4);
       
    84 		AddGetAgentTestL(iIterate->NextL());
       
    85 		}
       
    86 	else if( run == KRun5 )
       
    87 		{
       
    88 		INFO_PRINTF1(KTest5);
       
    89 		AgentAccessCountTestL();
       
    90 		}
       
    91 	else if( run == KRun6 )
       
    92 		{
       
    93 		INFO_PRINTF1(KTest6);
       
    94 		AgentExportImportAccessTestL();
       
    95 		}
       
    96 	else
       
    97 		{
       
    98 		MissngTestPanic();
       
    99 		}
       
   100 	Cleanup();
       
   101 	__UHEAP_MARKEND;
       
   102 
       
   103 	
       
   104 	return TestStepResult();
       
   105 	}
       
   106 
       
   107 /**
       
   108 open acid, increase access count to 1, attempt to delete contact, check that it has
       
   109 not been deleted, set access count to 0, delete, and check that it has been deleted.
       
   110 */
       
   111 void CAccessCountTests::AccessCountTestL(const TContactItemId aCid)
       
   112 	{
       
   113 	TInt err = KErrNone;
       
   114 	static const TInt KAccessCount = 1;//increase access count of contact by 1, 
       
   115 										
       
   116 	TInt i = 0;
       
   117 	
       
   118 	OpenL(aCid,*iViewAll);
       
   119 	SetContactFieldsL(*iContactItem);
       
   120 	for(i = 0; i < KAccessCount; ++i )
       
   121 		{
       
   122 		iContactItem->IncAccessCount();
       
   123 		}
       
   124 	CommitL();
       
   125 	
       
   126 	ReadL(aCid, *iViewAll);
       
   127 	const TInt KInitialAccessCount = iContactItem->AccessCount();//facount
       
   128 	const TInt KInitialFieldCount = iFields->Count(); //fcount
       
   129 	const TInt KInitialEmptyFields = CountEmpty(*iFields);//fhcount
       
   130 	Close();
       
   131 	
       
   132 	INTCOMPARE(  KInitialEmptyFields , ==,  0 , 0, 0 );
       
   133 	INTCOMPARE(  KInitialFieldCount , >,  0 , 0, 0 );
       
   134 	
       
   135 	for(i = 0; i < KAccessCount; ++i )
       
   136 		{
       
   137 		iContactsDatabase->DeleteContactL(aCid);
       
   138 		}
       
   139 		
       
   140 	ReadL(aCid,*iViewAll);
       
   141 	const TInt KModifiedAccessCount = iContactItem->AccessCount();//dacount
       
   142 	const TInt KModifiedFieldCount 	= iFields->Count();//dcount
       
   143 	const TInt KModifiedEmptyFields = CountEmpty(*iFields);//dHcount
       
   144 	Close();
       
   145 	
       
   146 	/*
       
   147 	check that deleting a contact doesnt modify its access count
       
   148 	check that deleting a contact with access count > 1, 
       
   149 	deletes all fields associated with contact but not the contact item itself
       
   150 	*/
       
   151 	INTCOMPARE(  KModifiedAccessCount , ==,  KInitialAccessCount , 0, 0 ); 
       
   152 	INTCOMPARE(  KInitialFieldCount , ==,  KModifiedFieldCount , 0, 0 );
       
   153 	INTCOMPARE(  KModifiedEmptyFields , ==,  KInitialFieldCount , 0, 0 ); 
       
   154 	INTCOMPARE(  KModifiedFieldCount , ==,  KModifiedEmptyFields , 0, 0 );
       
   155 	
       
   156 	OpenL(aCid,*iViewAll);
       
   157 	for(i = 0; i < KAccessCount; ++i )
       
   158 		{
       
   159 		iContactItem->DecAccessCount();
       
   160 		}
       
   161 	const TInt lAcount = iContactItem->AccessCount();
       
   162 	CommitL();
       
   163 	
       
   164 	INTCOMPARE( lAcount , ==,  0, 0, 0 );
       
   165 	
       
   166 	TRAP( err, ReadL(aCid, *iViewAll) );
       
   167 	Close();
       
   168 	
       
   169 	INTCOMPARE(  err , ==,  KErrNotFound , 0, 0 );
       
   170 	}
       
   171 
       
   172 /*
       
   173 test that contactitems can be delete successfull irregardless of the contents of their agent value
       
   174 */
       
   175 void CAccessCountTests::ReverseAgentDeletionTestL(const TInt aNumContacts)
       
   176 	{
       
   177 	TContactItemId PreviousContactId = -1;
       
   178 	TContactItemId CurrentContactId = iIterate->NextL();
       
   179 	TInt i = 0;
       
   180 	TInt err = KErrNone;
       
   181 	
       
   182 	for(; i < aNumContacts; ++i)
       
   183 		{
       
   184 		PreviousContactId = CurrentContactId;
       
   185 		CurrentContactId = iIterate->NextL();
       
   186 		//open contact item
       
   187 		OpenL(CurrentContactId, *iViewAll);
       
   188 		//add agent field and set to previous contact id
       
   189 		AddAgentFieldL(PreviousContactId);
       
   190 		CommitL();
       
   191 		//print agent values useful for debugging
       
   192 		INFO_PRINTF2(KAgentValue, GetAgentFieldL(CurrentContactId) );
       
   193 		}
       
   194 
       
   195 	//attempt to delete contacts starting from last contact to frist contact
       
   196 	TBool DeleteSuccess = EFalse;
       
   197 	for(i = aNumContacts ; i > 0 ; --i)
       
   198 		{
       
   199 		//attempt to delete contact
       
   200 		iContactsDatabase->DeleteContactL(CurrentContactId);
       
   201 		//remove contact id from iterator
       
   202 		iIterate->RemoveL(CurrentContactId);
       
   203 		//attempt to read deleted contact
       
   204 		TRAP( err, ReadL(CurrentContactId, *iViewAll) );
       
   205 		Close();
       
   206 		//fail test if contact is still present
       
   207 		DeleteSuccess = INTCOMPARE( err, ==, KErrNotFound, i, 0 );
       
   208 		CurrentContactId = iIterate->PreviousL();
       
   209 		if( ! DeleteSuccess )
       
   210 			{
       
   211 			break;
       
   212 			}
       
   213 		}
       
   214 	//if test fails
       
   215 	if( ! DeleteSuccess )
       
   216 		{
       
   217 		//remove rest of contacts from iterator
       
   218 		for(; i > 0 ; --i)
       
   219 			{
       
   220 			iIterate->RemoveL(CurrentContactId);
       
   221 			CurrentContactId = iIterate->PreviousL();
       
   222 			}
       
   223 		}
       
   224 	}
       
   225 
       
   226 /*
       
   227 test that contactitems can be deleted successfully irregardless of the contents of their agent value
       
   228 */
       
   229 void CAccessCountTests::ForwardAgentDeletionTestL(const TInt aNumContacts)
       
   230 	{
       
   231 	TBool DeleteSuccess = EFalse;
       
   232 	TContactItemId PreviousContactId = -1;
       
   233 	TContactItemId CurrentContactId = iIterate->NextL();
       
   234 	TInt err = KErrNone;
       
   235 	TInt i = 0;
       
   236 	
       
   237 	for(; i < aNumContacts; ++i)
       
   238 		{
       
   239 		PreviousContactId = CurrentContactId;
       
   240 		CurrentContactId = iIterate->NextL();
       
   241 		//open contact item
       
   242 		OpenL(CurrentContactId, *iViewAll);
       
   243 		//add agent field and set to previous contact id
       
   244 		AddAgentFieldL(PreviousContactId);
       
   245 		CommitL();
       
   246 		//print agent values useful for debugging
       
   247 		INFO_PRINTF2(KAgentValue, GetAgentFieldL(CurrentContactId) );
       
   248 		}
       
   249 	
       
   250 	//move iterator to start first contact in list
       
   251 	for( i = 0 ; i < aNumContacts; ++i )
       
   252 		{
       
   253 		CurrentContactId = iIterate->PreviousL();
       
   254 		}
       
   255 	
       
   256 	//attempt to delete contacts starting from first contact to last contact
       
   257 	for( i = 0 ; i < aNumContacts ; ++i )
       
   258 		{
       
   259 		//attempt to delete contact
       
   260 		iContactsDatabase->DeleteContactL(CurrentContactId);
       
   261 		//attempt to read deleted contact
       
   262 		TRAP( err, ReadL(CurrentContactId, *iViewAll) );
       
   263 		Close();
       
   264 		//fail test if contact is still present
       
   265 		DeleteSuccess = INTCOMPARE( err, ==, KErrNotFound , i, 0 );
       
   266 		CurrentContactId = iIterate->NextL();
       
   267 		if( ! DeleteSuccess )
       
   268 			{
       
   269 			break;
       
   270 			}
       
   271 		}
       
   272 	//if test fails
       
   273 	if(!DeleteSuccess)
       
   274 		{
       
   275 		//remove rest of contacts from iterator
       
   276 		const TInt end = i + 1;
       
   277 		for(i = 0 ; i < end ; ++i)
       
   278 			{
       
   279 			iIterate->RemoveL(CurrentContactId);
       
   280 			CurrentContactId = iIterate->PreviousL();
       
   281 			}
       
   282 		CurrentContactId = iIterate->NextL();
       
   283 		for(i = end ; i < aNumContacts ; ++i)
       
   284 			{
       
   285 			iIterate->RemoveL(CurrentContactId);
       
   286 			CurrentContactId = iIterate->CurrentL();
       
   287 			}
       
   288 		}
       
   289 	}
       
   290 
       
   291 /**
       
   292 * Open aCid, add agent field, set value of agent field, and get value of agent.
       
   293 * Check this is correct, repeat this for minint, 0, 1, Maxint. Setting the 
       
   294 * agent id should only accept values > 0, all other values are ignored.
       
   295 */
       
   296 void CAccessCountTests::AddGetAgentTestL(const TContactItemId aCid)
       
   297 	{
       
   298 	TContactItemId retrievedAgentId = -1;
       
   299 	const TInt KInitialAgentId = 5;
       
   300 	
       
   301 	OpenL(aCid,*iViewAll);
       
   302 	AddAgentFieldL( KInitialAgentId );
       
   303 	CommitL();
       
   304 	
       
   305 	TRAPD( error, SetAgentFieldL( aCid, KMinTInt ) );
       
   306 	INTCOMPARE(  error , ==,  KErrNone , 0, 0 );
       
   307 	retrievedAgentId = GetAgentFieldL( aCid );
       
   308 	INTCOMPARE(  retrievedAgentId , ==,  KInitialAgentId , 0, 0 );
       
   309 	
       
   310 	TRAP( error, SetAgentFieldL( aCid, -1 ) );
       
   311 	INTCOMPARE(  error , ==,  KErrNone , 0, 0 );
       
   312 	retrievedAgentId = GetAgentFieldL( aCid );
       
   313 	INTCOMPARE(  retrievedAgentId , ==,  KInitialAgentId , 0, 0 );
       
   314 	
       
   315 	TRAP( error, SetAgentFieldL( aCid, 0 ) );
       
   316 	INTCOMPARE(  error , ==,  KErrNone , 0, 0 );
       
   317 	retrievedAgentId = GetAgentFieldL( aCid );
       
   318 	INTCOMPARE(  retrievedAgentId , ==,  KInitialAgentId , 0, 0 );
       
   319 
       
   320 	TRAP( error, SetAgentFieldL( aCid, 1 ) );
       
   321 	INTCOMPARE(  error , ==,  KErrNone , 0, 0 );
       
   322 	retrievedAgentId = GetAgentFieldL( aCid );
       
   323 	INTCOMPARE(  retrievedAgentId , ==,  1 , 0, 0 );
       
   324 	
       
   325 	TRAP( error, SetAgentFieldL( aCid, KMaxTInt ) );
       
   326 	INTCOMPARE(  error , ==,  KErrNone , 0, 0 );
       
   327 	retrievedAgentId = GetAgentFieldL( aCid );
       
   328 	INTCOMPARE(  retrievedAgentId , ==,  KMaxTInt , 0, 0 );
       
   329 	}
       
   330 
       
   331 /**
       
   332 add agent field to contact b, set value of agent in b to id of contact a.
       
   333 check that agent field is retrieved/stored correctly, check that access count is
       
   334 not modified for either contact
       
   335 */	
       
   336 void CAccessCountTests::AgentAccessCountTestL()
       
   337 	{
       
   338 	TContactItemId RetrievedAgentId = -1;
       
   339 	TContactItemId PreviousContactId = iIterate->NextL();//contact a
       
   340 	TContactItemId CurrentContactId = iIterate->NextL();//contact b
       
   341 	
       
   342 	//open current contact
       
   343 	OpenL(CurrentContactId,*iViewAll);
       
   344 	//add new agent field, set to previous contact id
       
   345 	AddAgentFieldL(PreviousContactId);
       
   346 	CommitL();
       
   347 	
       
   348 	//get agent id store for current contact
       
   349 	RetrievedAgentId = GetAgentFieldL(CurrentContactId);
       
   350 	
       
   351 	//get access count of current contact
       
   352 	ReadL(CurrentContactId, *iViewAll);
       
   353 	const TInt KCurrentContactAccessCount = iContactItem->AccessCount();
       
   354 	Close();
       
   355 	
       
   356 	//get access count of previous contact
       
   357 	ReadL(PreviousContactId, *iViewAll);
       
   358 	const TInt KPreviousContactAccessCount = iContactItem->AccessCount();
       
   359 	Close();
       
   360 	
       
   361 	//check that retrieved agent id equals previous contact id
       
   362 	INTCOMPARE( RetrievedAgentId , ==,  PreviousContactId, 0, 0 );
       
   363 	//check that changing the agent field values doesnt not affect the access count
       
   364 	//of involved contacts
       
   365 	INTCOMPARE( KCurrentContactAccessCount , ==,  0, 0, 0 ); 
       
   366 	INTCOMPARE( KPreviousContactAccessCount , ==,  0, 0, 0 );
       
   367 	}
       
   368 
       
   369 /**
       
   370 add agent field to contact b. set value of agent to contact a.
       
   371 export contacts a & b. check access count for a & b(should be 0), 
       
   372 check value of agent(should equal b) open contact b, delete all fields.
       
   373 commit. import contacts a and b. check that agent field is not imported.
       
   374 */
       
   375 void CAccessCountTests::AgentExportImportAccessTestL()
       
   376 	{
       
   377 	const TContactItemId KFirstContactId = iIterate->NextL();//contact a
       
   378 	const TContactItemId KSecondContactId = iIterate->NextL();//contact b
       
   379 	
       
   380 	//open contact a and populate all fields
       
   381 	OpenL(KFirstContactId, *iViewAll);
       
   382 	SetContactFieldsL(*iContactItem);
       
   383 	CommitL();
       
   384 	
       
   385 	//open contact b
       
   386 	OpenL(KSecondContactId,*iViewAll);
       
   387 	//populate all fields
       
   388 	SetContactFieldsL(*iContactItem);
       
   389 	//add contact a id as an agent field value
       
   390 	AddAgentFieldL(KFirstContactId);
       
   391 	CommitL();
       
   392 	
       
   393 	CContactIdArray *ArrayOfExportedContactIds = CContactIdArray::NewLC();
       
   394 	//set contact a and b to be export
       
   395 	ArrayOfExportedContactIds->AddL(KFirstContactId);
       
   396 	ArrayOfExportedContactIds->AddL(KSecondContactId);
       
   397 	
       
   398 	//export contact a & b
       
   399 	ExportVcardL(*ArrayOfExportedContactIds);
       
   400 	
       
   401 	const TInt KFirstContactAccessCountAfterExport = GetAccessCountL(KFirstContactId);
       
   402 	const TInt KSecondContactAccessCountAfterExport = GetAccessCountL(KSecondContactId);
       
   403 	const TInt KSecondContactAgentFieldAfterExport = GetAgentFieldL(KSecondContactId);
       
   404 	CleanupStack::PopAndDestroy(ArrayOfExportedContactIds);
       
   405 	
       
   406 	//delete all fields from contact b
       
   407 	OpenL(KSecondContactId,*iViewAll);
       
   408 	iFields->Reset();
       
   409 	CommitL();
       
   410 	
       
   411 	//import exported contacts
       
   412 	ImportVcardL();
       
   413 	
       
   414 	const TInt KFirstContactAccessCountAfterImport = GetAccessCountL(KFirstContactId);
       
   415 	const TInt KSecondContactAccessCountAfterImport = GetAccessCountL(KSecondContactId);
       
   416 	const TContactItemId KSecondContactAgentFieldAfterImport = GetAgentFieldL(KSecondContactId);
       
   417 	
       
   418 	//importing & exporting contacts should not affect the access count
       
   419 	INTCOMPARE( KFirstContactAccessCountAfterExport , ==,  0, 0, 0 ); 
       
   420 	INTCOMPARE( KSecondContactAccessCountAfterExport , ==,  0, 0, 0 ); 
       
   421 	INTCOMPARE( KFirstContactAccessCountAfterExport , ==,  KFirstContactAccessCountAfterImport, 0, 0 );
       
   422 	INTCOMPARE( KSecondContactAccessCountAfterExport , ==,  KSecondContactAccessCountAfterImport, 0, 0 );
       
   423 	
       
   424 	//agent field values should not be exported/imported
       
   425 	INTCOMPARE( KFirstContactId , ==,  KSecondContactAgentFieldAfterImport, 0, 0 ); 
       
   426 	//exporting contacts should not affect the internal state of the contacts agent field
       
   427 	INTCOMPARE( KSecondContactAgentFieldAfterExport , ==,  KFirstContactId, 0, 0 );
       
   428 	
       
   429 	iParent->Fs().Delete(KVcardFile);//cleanup of exported vcard file
       
   430 	}
       
   431 	
       
   432 void CAccessCountTests::AddAgentFieldL(const TContactItemId aCid)
       
   433 	{
       
   434 	_LIT(KAgentName, "ImAnAgent");
       
   435 	CContactItemField * field = CContactItemField::NewLC(KStorageTypeContactItemId, KUidContactFieldVCardMapAGENT );
       
   436 	field->SetMapping(KUidContactFieldVCardMapAGENT);
       
   437 	field->SetLabelL(KAgentName);
       
   438 	field->AgentStorage()->SetAgentId(aCid);
       
   439 	iFields->AddL(*field);
       
   440 	CleanupStack::Pop(field);
       
   441 	field = NULL;
       
   442 	}
       
   443 
       
   444 TContactItemId CAccessCountTests::GetAgentFieldL(const TContactItemId aCid)
       
   445 	{
       
   446 	ReadL(aCid, *iViewAll);
       
   447 	const TInt count = iFields->Count();
       
   448 	TContactItemId ret = KErrNotFound;
       
   449 	TInt i = 0;
       
   450 	for(; i < count; ++i)
       
   451 		{
       
   452 		if( (*iFields)[i].StorageType() == KStorageTypeContactItemId )
       
   453 			{
       
   454 			ret = (*iFields)[i].AgentStorage()->Value();
       
   455 			break;
       
   456 			}
       
   457 		}
       
   458 	Close();
       
   459 	return ret;
       
   460 	}
       
   461 
       
   462 void CAccessCountTests::SetAgentFieldL(const TContactItemId aCid, const TContactItemId aVal)
       
   463 	{
       
   464 	
       
   465 	TBool FoundAgentField = EFalse;
       
   466 	OpenL(aCid, *iViewAll);
       
   467 	const TInt count = iFields->Count();
       
   468 	TInt i = 0;
       
   469 	
       
   470 	for(; i < count; ++i)
       
   471 		{
       
   472 		if( (*iFields)[i].StorageType() == KStorageTypeContactItemId )
       
   473 			{
       
   474 			(*iFields)[i].AgentStorage()->SetAgentId(aVal);
       
   475 			FoundAgentField = ETrue;
       
   476 			break;
       
   477 			}
       
   478 		}
       
   479 		
       
   480 	if( !FoundAgentField )
       
   481 		{
       
   482 		AddAgentFieldL(aVal);
       
   483 		}
       
   484 		
       
   485 	CommitL();
       
   486 	}
       
   487 
       
   488 void CAccessCountTests::ExportVcardL(const CContactIdArray &aConids)
       
   489 	{	
       
   490 	RFileWriteStream rfws;
       
   491 	CleanupClosePushL(rfws);
       
   492 	User::LeaveIfError( rfws.Replace( iParent->Fs(), KVcardFile, EFileWrite | EFileShareAny ) );
       
   493 	
       
   494 	iContactsDatabase->ExportSelectedContactsL(	TUid::Uid(KUidVCardConvDefaultImpl), aConids, rfws,
       
   495 										CContactDatabase::EIncludeX | CContactDatabase::ETTFormat );
       
   496 	
       
   497 	CleanupStack::PopAndDestroy(&rfws);		
       
   498 	}	
       
   499 	
       
   500 void CAccessCountTests::ImportVcardL()
       
   501 	{
       
   502 	TBool sucess = EFalse;
       
   503 	RFileReadStream rfrs;
       
   504 	CleanupClosePushL( rfrs );
       
   505 	User::LeaveIfError( rfrs.Open( iParent->Fs(), KVcardFile, EFileRead | EFileShareAny ) );
       
   506 	
       
   507 	FOREVER
       
   508 		{
       
   509 		CArrayPtr<CContactItem>* imported= 	iContactsDatabase->ImportContactsL( 
       
   510 											TUid::Uid( KUidVCardConvDefaultImpl ), rfrs, sucess, 
       
   511 											CContactDatabase::EIncludeX | CContactDatabase::ETTFormat |
       
   512 											CContactDatabase::EImportSingleContact
       
   513 											);	
       
   514 		if(sucess)
       
   515 			{
       
   516 			imported->ResetAndDestroy();
       
   517 			CLEAR(imported);	
       
   518 			}
       
   519 		else
       
   520 			{
       
   521 			imported->ResetAndDestroy();
       
   522 			CLEAR(imported);
       
   523 			break;	
       
   524 			}
       
   525 		sucess = EFalse;
       
   526 		}
       
   527 
       
   528 	CleanupStack::PopAndDestroy(&rfrs);
       
   529 	}
       
   530 
       
   531 TInt CAccessCountTests::GetAccessCountL(const TContactItemId aCid)
       
   532 	{
       
   533 	ReadL( aCid, *iViewAll );
       
   534 	TInt ret = iContactItem->AccessCount();
       
   535 	Close();
       
   536 	return ret;
       
   537 	}
       
   538 
       
   539