pimprotocols/phonebooksync/Test/TE_cntsync/te_cntsyncutils.cpp
changeset 0 e686773b3f54
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 // Copyright (c) 2002-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 #include "te_cntsyncutils.h"
       
    17 #include "te_cntsyncbase.h"
       
    18 
       
    19 /** 
       
    20  * Factory construction method.
       
    21  * @return Pointer to CPhbkDeleteIntegrationTest object
       
    22  */
       
    23 CPhbkIntegrationTestUtility* CPhbkIntegrationTestUtility::NewL()
       
    24 	{
       
    25 	CPhbkIntegrationTestUtility* self = new(ELeave) CPhbkIntegrationTestUtility();
       
    26 	CleanupStack::PushL(self);
       
    27 	self->ConstructL();
       
    28 	CleanupStack::Pop();
       
    29 	return self;
       
    30 	}
       
    31 
       
    32 /** Destructor. */
       
    33 CPhbkIntegrationTestUtility::~CPhbkIntegrationTestUtility()
       
    34 	{
       
    35 	iSession.Close();
       
    36 	delete iDb;
       
    37 	}
       
    38 
       
    39 /** 
       
    40  * Second-phase constructor.
       
    41  * This is required because the SIM test configuration must be set before
       
    42  * the CSimPhone is constructed.
       
    43  */
       
    44 void CPhbkIntegrationTestUtility::ConstructL()
       
    45 	{
       
    46 	User::LeaveIfError(iSession.Connect());
       
    47 	User::After(3000000); // wait for session to startup
       
    48 
       
    49 	//
       
    50 	// Attempt to open the Contacts DB up to three times.
       
    51 	//
       
    52 	TInt  err(KErrNone);
       
    53 
       
    54 	for (TInt count = 0;  count < 3;  count++)
       
    55 		{
       
    56 		TRAP(err, iDb = CContactDatabase::OpenL());
       
    57 		if (err != KErrLocked)
       
    58 			{
       
    59 			break;
       
    60 			}
       
    61 
       
    62 		if (count + 1 < 3)
       
    63 			{
       
    64 			User::After(1000000);
       
    65 			}
       
    66 		}
       
    67 	User::LeaveIfError(err);
       
    68 	User::After(3000000); // wait for session to startup
       
    69 	}
       
    70 
       
    71 /** Default constructor */
       
    72 CPhbkIntegrationTestUtility::CPhbkIntegrationTestUtility()
       
    73 	{
       
    74 	}
       
    75 
       
    76 
       
    77 /** 
       
    78  * Check group membership.
       
    79  * All ICC entries synchronised should belong to a single group. This group 
       
    80  * should contain all the ADN phonebook entries
       
    81  *
       
    82  * @param aItem             ICC entry 
       
    83  * @param aExpectedMembers  Expected number of members of the ADN phonebook
       
    84  */
       
    85 void CPhbkIntegrationTestUtility::CheckGroupMembershipL(CContactICCEntry& aItem, TInt aExpectedMembers)
       
    86 	{
       
    87 	const CContactIdArray* owned = aItem.GroupsJoined();	
       
    88 	__ASSERT_ALWAYS(owned != NULL, User::Leave(EFail));
       
    89 	__ASSERT_ALWAYS(owned->Count() == 1, User::Leave(EFail));
       
    90 	TContactItemId groupId = (*owned)[0];
       
    91 
       
    92 	CContactGroup* group = static_cast<CContactGroup*>(iDb->ReadContactLC(groupId));
       
    93 	const CContactIdArray* itemsContained = group->ItemsContained();
       
    94 	__ASSERT_ALWAYS(itemsContained->Count() == aExpectedMembers, User::Leave(EFail));
       
    95 	CleanupStack::PopAndDestroy(group);	
       
    96 	}
       
    97 
       
    98 /** 
       
    99  * Check that the field of type aFieldType has the same content as 
       
   100  * aExpectedContent
       
   101  * @param aFieldset Contact item fieldset
       
   102  * @param aFieldType Field type to test
       
   103  * @param aExpectedContent Expected data
       
   104  */
       
   105 void CPhbkIntegrationTestUtility::CheckFieldContentL(CContactItemFieldSet& aFieldset, TFieldType aFieldType, const TDesC& aExpectedContent)
       
   106 	{
       
   107 	TInt pos = aFieldset.Find(aFieldType);
       
   108 	CContactItemField& field = aFieldset[pos];
       
   109 	CContactTextField* textField = field.TextStorage();
       
   110 	__ASSERT_ALWAYS(textField != NULL, User::Leave(EFail));
       
   111 	__ASSERT_ALWAYS(textField->Text() == aExpectedContent, User::Leave(EFail));
       
   112 	}
       
   113 
       
   114 /** 
       
   115  * Check that aEntry contains correct number of fields.
       
   116  *
       
   117  * @param aPhonebook  ICC Phonebook to check.
       
   118  * @param aEntry      Contact ICC Entry
       
   119  */
       
   120 void CPhbkIntegrationTestUtility::CheckFieldCountL(const TUid aPhonebook, CContactICCEntry* aEntry)
       
   121 	{
       
   122 	CContactItemFieldSet& fieldset = aEntry->CardFields();
       
   123 	const TInt fieldsetCount = fieldset.Count(); //for debugging
       
   124 	if ((aPhonebook == KUidUsimAppAdnPhonebook) || (aPhonebook == KUidIccGlobalAdnPhonebook))
       
   125 		{
       
   126 		__ASSERT_ALWAYS(fieldsetCount >= 6, User::Leave(EFail)); //Name,Number,email,ICC slot, phonebook
       
   127 		}
       
   128 	else
       
   129 		{
       
   130 		__ASSERT_ALWAYS(fieldsetCount == 5, User::Leave(EFail)); //Name,Number,ICC slot, phonebook
       
   131 		}
       
   132 	}
       
   133 
       
   134 /** 
       
   135  * Check that aEntry contains correct number of fields for minimal contact item.
       
   136  *
       
   137  * @param aPhonebook  ICC Phonebook to check.
       
   138  * @param aEntry      Contact ICC Entry
       
   139  */
       
   140 void CPhbkIntegrationTestUtility::CheckMinimalFieldCountL(const TUid aPhonebook, CContactICCEntry* aEntry)
       
   141 	{
       
   142 	CContactItemFieldSet& fieldset = aEntry->CardFields();
       
   143 	const TInt fieldsetCount = fieldset.Count(); //for debugging
       
   144 	if (aPhonebook == KUidUsimAppAdnPhonebook)
       
   145 		{
       
   146 		__ASSERT_ALWAYS(fieldsetCount >= 5, User::Leave(EFail)); //Name,Number,email,ICC slot, phonebook
       
   147 		}
       
   148 	else
       
   149 		{
       
   150 		__ASSERT_ALWAYS(fieldsetCount == 4, User::Leave(EFail)); //Name,Number,ICC slot, phonebook
       
   151 		}
       
   152 	}
       
   153 
       
   154 /** 
       
   155  * Check that the field data stored on the SIM is identical to the
       
   156  * data stored in Contacts model.
       
   157  * @param aItem ICC item to test
       
   158  * @param aSlotNumber Slot number 
       
   159  */
       
   160 void CPhbkIntegrationTestUtility::CheckFieldsL(CContactICCEntry& aItem, TInt aSlotNumber)
       
   161 	{
       
   162 	TBuf<20> buf;
       
   163 	CContactItemFieldSet& fieldset = aItem.CardFields();
       
   164 	buf.Format(KNameFormat,aSlotNumber);
       
   165 	CheckFieldContentL(fieldset,KUidContactFieldFamilyName,buf);
       
   166 	buf.Format(KNumberFormat,aSlotNumber);
       
   167 	CheckFieldContentL(fieldset,KUidContactFieldPhoneNumber,buf);
       
   168 	}
       
   169 
       
   170 /** 
       
   171  * Read an ICC entry - normal case.
       
   172  * Check group membership is correct and correct number of fields have
       
   173  * been created.
       
   174  */
       
   175 void CPhbkIntegrationTestUtility::ReadContactL(const TUid aPhonebook, TInt aExpectedCount)
       
   176 	{
       
   177 	iDb->SetDbViewContactType(KUidContactICCEntry);
       
   178 	// get the unique groupId for the given phonebook
       
   179 	TContactItemId groupId(KNullContactId);
       
   180 	User::LeaveIfError(iSession.GetPhoneBookId(groupId, 
       
   181 						RPhoneBookSession::ESyncGroupId,
       
   182 						aPhonebook));
       
   183 	__ASSERT_ALWAYS(groupId != KNullContactId, User::Leave(EFail));
       
   184   
       
   185 	// based on the groupId, get items belonging to the phonebook
       
   186 	CContactGroup* group = NULL;
       
   187 	TRAPD(err, group = static_cast<CContactGroup*>(iDb->ReadContactL(groupId)));
       
   188 	__ASSERT_ALWAYS(err == KErrNone, User::Leave(EFail));
       
   189 	CleanupStack::PushL(group);
       
   190 	const CContactIdArray* array = group->ItemsContained();
       
   191 
       
   192 	// Verify correct number of entries created for this phonebook
       
   193 	TInt count = array->Count(); // for debugging
       
   194 	__ASSERT_ALWAYS(count == aExpectedCount, User::Leave(EFail));
       
   195 
       
   196 	// Read all items
       
   197 	for (TInt i=0; i<count; ++i)
       
   198 		{
       
   199 		TContactItemId id = (*array)[i];
       
   200 		CContactICCEntry* entry = NULL;
       
   201 		TRAP(err, entry = static_cast<CContactICCEntry*>(iDb->ReadContactL(id)));
       
   202 		__ASSERT_ALWAYS(err == KErrNone, User::Leave(EFail));
       
   203 		CleanupStack::PushL(entry);
       
   204 		// Verify correct number of fields created for entry
       
   205 		CheckFieldCountL(aPhonebook, entry);
       
   206 		CleanupStack::PopAndDestroy(); // entry
       
   207 		}
       
   208 
       
   209 	CleanupStack::PopAndDestroy(); // group
       
   210 
       
   211 	}
       
   212 
       
   213 /**
       
   214  * Read an ICC contact - minimal read operation.
       
   215  */
       
   216 void CPhbkIntegrationTestUtility::ReadMinimalContactL(const TUid aPhonebook, TInt aExpectedCount)
       
   217 	{
       
   218 	iDb->SetDbViewContactType(KUidContactICCEntry);
       
   219 	// get the unique groupId for the given phonebook
       
   220 	TContactItemId groupId(KNullContactId);
       
   221 	User::LeaveIfError(iSession.GetPhoneBookId(groupId, 
       
   222 						RPhoneBookSession::ESyncGroupId,
       
   223 						aPhonebook));
       
   224 	__ASSERT_ALWAYS(groupId != KNullContactId, User::Leave(EFail));
       
   225   
       
   226 	// based on the groupId, get items belonging to the phonebook
       
   227 	CContactGroup* group = NULL;
       
   228 	TRAPD(err, group = static_cast<CContactGroup*>(iDb->ReadContactL(groupId)));
       
   229 	__ASSERT_ALWAYS(err == KErrNone, User::Leave(EFail));
       
   230 	CleanupStack::PushL(group);
       
   231 	const CContactIdArray* array = group->ItemsContained();
       
   232 
       
   233 	// Verify correct number of entries created for this phonebook
       
   234 	const TInt count = array->Count(); // for debugging
       
   235 	__ASSERT_ALWAYS(count == aExpectedCount, User::Leave(EFail));
       
   236 
       
   237 	// Read entry
       
   238 	TContactItemId id((*array)[0]);
       
   239 	CContactICCEntry* entry = static_cast<CContactICCEntry*>(iDb->ReadMinimalContactL(id));
       
   240 	CleanupStack::PushL(entry);
       
   241 	CheckFieldCountL(aPhonebook, entry); // Entry contains correct number of fields
       
   242 
       
   243 	CleanupStack::PopAndDestroy(2); // group & entry
       
   244 	}
       
   245 
       
   246 /** 
       
   247  * Add a contact to the ICC & database.
       
   248  * @param aName Name
       
   249  * @param aNumber Phone number
       
   250  * @param aPhonebook Phonebook UID (optional)
       
   251  * @param aEmail Email entry (optional)
       
   252  */
       
   253 void CPhbkIntegrationTestUtility::AddContactL(const TDesC& aName, const TDesC& aNumber, const TUid aPhonebook, const TDesC& aEmail)
       
   254 	{
       
   255 	TContactItemId templateId(iDb->ICCTemplateIdL(aPhonebook));
       
   256 	CContactItem* iccTemplate = iDb->ReadContactLC(templateId);
       
   257 	CContactICCEntry* entry = CContactICCEntry::NewL(*iccTemplate);
       
   258 	CleanupStack::PopAndDestroy(iccTemplate);
       
   259 	CleanupStack::PushL(entry);
       
   260 	//Set the phonebook field, if the field doesn't exist, it should be added
       
   261 	CContactItemFieldSet& fieldset = entry->CardFields();
       
   262 	TInt n = fieldset.Find(KUidContactFieldICCPhonebook);
       
   263 	if(n==KErrNotFound)
       
   264 		{
       
   265 		CContactItemField* field = CContactItemField::NewLC(KStorageTypeText,KUidContactFieldICCPhonebook);
       
   266 		entry->AddFieldL(*field);
       
   267 		CleanupStack::Pop(field);
       
   268 		CContactItemFieldSet& fieldset = entry->CardFields();
       
   269 		n = fieldset.Find(KUidContactFieldICCPhonebook);
       
   270 		__ASSERT_ALWAYS(n != KErrNotFound, User::Leave(EFail));
       
   271 		}
       
   272 	CContactItemField& field = fieldset[n];
       
   273 	CContactTextField* textField = field.TextStorage();
       
   274 	TBuf<128> buf;
       
   275 	TInt phonebookUidNum = aPhonebook.iUid;
       
   276 	buf.AppendNum(phonebookUidNum);
       
   277 	textField->SetTextL(buf);
       
   278 
       
   279 	AddTextFieldL(KUidContactFieldFamilyName,KUidContactFieldVCardMapUnusedN,aName,*entry);
       
   280 	AddTextFieldL(KUidContactFieldPhoneNumber,KUidContactFieldVCardMapTEL,aNumber,*entry);
       
   281 	if (aPhonebook == KUidUsimAppAdnPhonebook)
       
   282 		{
       
   283 		AddTextFieldL(KUidContactFieldEMail,KUidContactFieldVCardMapUnusedN,aEmail,*entry);
       
   284 		}
       
   285 	TContactItemId id(iDb->AddNewContactL(*entry)); 
       
   286 	CleanupStack::PopAndDestroy(entry);	
       
   287 	__ASSERT_ALWAYS(id != KNullContactId, User::Leave(EFail));
       
   288 	}
       
   289 
       
   290 /** 
       
   291  * Add a contact to the ICC & database.
       
   292  * @param aName Name
       
   293  * @param aNumber Phone number
       
   294  * @param aSlotNumber Slot number
       
   295  * @param aPhonebook Phonebook UID (optional)
       
   296  * @param aEmail Email entry (optional)
       
   297  */
       
   298 void CPhbkIntegrationTestUtility::AddContactL(const TDesC& aName, const TDesC& aNumber, const TDesC& aSlotNumber, const TUid aPhonebook, const TDesC& aEmail)
       
   299 	{
       
   300 	TContactItemId templateId(iDb->ICCTemplateIdL(aPhonebook));
       
   301 	CContactItem* iccTemplate = iDb->ReadContactLC(templateId);
       
   302 	CContactICCEntry* entry = CContactICCEntry::NewL(*iccTemplate);
       
   303 	CleanupStack::PopAndDestroy(iccTemplate);
       
   304 	CleanupStack::PushL(entry);
       
   305 	//Set the phonebook field, if the field doesn't exist, it should be added
       
   306 	CContactItemFieldSet& fieldset = entry->CardFields();
       
   307 	TInt n = fieldset.Find(KUidContactFieldICCPhonebook);
       
   308 	if(n==KErrNotFound)
       
   309 		{
       
   310 		CContactItemField* field = CContactItemField::NewLC(KStorageTypeText,KUidContactFieldICCPhonebook);
       
   311 		entry->AddFieldL(*field);
       
   312 		CleanupStack::Pop(field);
       
   313 		CContactItemFieldSet& fieldset = entry->CardFields();
       
   314 		n = fieldset.Find(KUidContactFieldICCPhonebook);
       
   315 		__ASSERT_ALWAYS(n != KErrNotFound, User::Leave(EFail));
       
   316 		}
       
   317 	CContactItemField& field = fieldset[n];
       
   318 	CContactTextField* textField = field.TextStorage();
       
   319 	TBuf<128> buf;
       
   320 	TInt phonebookUidNum = aPhonebook.iUid;
       
   321 	buf.AppendNum(phonebookUidNum);
       
   322 	textField->SetTextL(buf);
       
   323 
       
   324 	AddTextFieldL(KUidContactFieldFamilyName,KUidContactFieldVCardMapUnusedN,aName,*entry);
       
   325 	AddTextFieldL(KUidContactFieldPhoneNumber,KUidContactFieldVCardMapTEL,aNumber,*entry);
       
   326 	AddTextFieldL(KUidContactFieldICCSlot,KUidContactFieldVCardMapTEL,aSlotNumber,*entry);
       
   327 	if (aPhonebook == KUidUsimAppAdnPhonebook)
       
   328 		{
       
   329 		AddTextFieldL(KUidContactFieldEMail,KUidContactFieldVCardMapUnusedN,aEmail,*entry);
       
   330 		}
       
   331 	TContactItemId id(iDb->AddNewContactL(*entry)); 
       
   332 	CleanupStack::PopAndDestroy(entry);	
       
   333 	__ASSERT_ALWAYS(id != KNullContactId, User::Leave(EFail));
       
   334 	}
       
   335 
       
   336 /**
       
   337  * Add a new text field (aField) to the CContactICCEntry supplied by aIccEntry. 
       
   338  * @param aFieldType Field type
       
   339  * @param aMapping Mapping for the field's content type
       
   340  * @param aField Field data
       
   341  * @param aIccEntry CContactICCEntry item
       
   342  */ 
       
   343 void CPhbkIntegrationTestUtility::AddTextFieldL(TFieldType aFieldType, TUid aMapping, const TDesC& aField, CContactICCEntry& aIccEntry)
       
   344 	{
       
   345 	CContactItemFieldSet& fieldSet = aIccEntry.CardFields();
       
   346 	TInt pos = fieldSet.Find(aFieldType);
       
   347 	if (pos!=KErrNotFound)
       
   348 		{
       
   349 		CContactItemField& field=fieldSet[pos];
       
   350 		field.TextStorage()->SetTextL(aField);
       
   351 		}
       
   352 	else
       
   353 		{
       
   354 		CContactItemField* field=CContactItemField::NewLC(KStorageTypeText, aFieldType);
       
   355 		field->SetMapping(aMapping);
       
   356 		field->AddFieldTypeL(aFieldType); 
       
   357 		field->TextStorage()->SetTextL(aField);
       
   358 		aIccEntry.AddFieldL(*field);
       
   359 		CleanupStack::Pop(field); 
       
   360 		}
       
   361 	}
       
   362 
       
   363 /** Delete an ICC contact - normal case */
       
   364 void CPhbkIntegrationTestUtility::DeleteContactL(const TUid aPhonebook, TInt aIndex)
       
   365 	{
       
   366 	iDb->SetDbViewContactType(KUidContactICCEntry);
       
   367 	// get the unique groupId for the given phonebook
       
   368 	TContactItemId groupId(KNullContactId);
       
   369 	User::LeaveIfError(iSession.GetPhoneBookId(groupId, 
       
   370 						RPhoneBookSession::ESyncGroupId,
       
   371 						aPhonebook));
       
   372 	__ASSERT_ALWAYS(groupId != KNullContactId, User::Leave(EFail));
       
   373   
       
   374 	// based on the groupId, get items belonging to the phonebook
       
   375 	CContactGroup* group = NULL;
       
   376 	TRAPD(err, group = static_cast<CContactGroup*>(iDb->ReadContactL(groupId)));
       
   377 	__ASSERT_ALWAYS(err == KErrNone, User::Leave(EFail));
       
   378 	CleanupStack::PushL(group);
       
   379 	const CContactIdArray* array = group->ItemsContained();
       
   380 
       
   381 	// delete item
       
   382 	TInt count = array->Count();
       
   383 	__ASSERT_ALWAYS(count >= aIndex, User::Leave(EFail));
       
   384 	TContactItemId id = (*array)[aIndex];
       
   385 	iDb->DeleteContactL(id);
       
   386 
       
   387 	//check the item has been removed from the database
       
   388 	CContactItem* item=NULL; 
       
   389 	TRAP(err, item = iDb->ReadContactL(id)); 
       
   390 	__ASSERT_ALWAYS(err == KErrNotFound, User::Leave(EFail));
       
   391 	delete item;
       
   392 
       
   393 	CleanupStack::PopAndDestroy(); // group
       
   394 	}
       
   395 
       
   396 /** 
       
   397  * Find contact IDs that match aFindString in the field specified by aFieldToSearch.
       
   398  * @param aFindString Text to search for
       
   399  * @param aFieldToSearch Field to search
       
   400  * @param aExpectedMatches Expected number of matching contacts
       
   401  */
       
   402 void CPhbkIntegrationTestUtility::FindContactsL(const TDesC& aFindString, TFieldType aFieldToSearch, TInt aExpectedMatches)
       
   403 	{
       
   404 	CContactItemFieldDef* fieldDef=new(ELeave) CContactItemFieldDef;
       
   405 	CleanupStack::PushL(fieldDef);
       
   406 	fieldDef->AppendL(aFieldToSearch);
       
   407 	CContactIdArray* array = iDb->FindLC(aFindString,fieldDef);
       
   408 	__ASSERT_ALWAYS(array->Count() == aExpectedMatches, User::Leave(EFail));
       
   409 	CleanupStack::PopAndDestroy(2,fieldDef);
       
   410 	}
       
   411 
       
   412 /** 
       
   413  * Replace the current name field with another name
       
   414  * @param aItem Reference to CContactItem
       
   415  * @param aModifiedName New name to use
       
   416  */
       
   417 void CPhbkIntegrationTestUtility::ChangeNameFieldL(CContactItem& aItem, const TDesC& aModifiedName)
       
   418 	{
       
   419 	CContactItemFieldSet& fieldset = aItem.CardFields();
       
   420 	const TInt pos(fieldset.Find(KUidContactFieldFamilyName));	
       
   421 	CContactItemField& field = fieldset[pos];
       
   422 	CContactTextField* textfield = field.TextStorage();
       
   423 	textfield->SetTextL(aModifiedName);
       
   424 	}
       
   425 
       
   426 /** 
       
   427  * Replace the current name field with another name
       
   428  * @param aItem Reference to CContactItem
       
   429  * @param aModifiedNumber New number to use
       
   430  */
       
   431 void CPhbkIntegrationTestUtility::ChangeNumberFieldL(CContactItem& aItem, const TDesC& aModifiedNumber)
       
   432 	{
       
   433 	CContactItemFieldSet& fieldset = aItem.CardFields();
       
   434 	const TInt pos(fieldset.Find(KUidContactFieldPhoneNumber));
       
   435 	CContactItemField& field = fieldset[pos];
       
   436 	CContactTextField* textfield = field.TextStorage();
       
   437 	textfield->SetTextL(aModifiedNumber);
       
   438 	}
       
   439 
       
   440 /** Open an ICC contact for edit */
       
   441 void CPhbkIntegrationTestUtility::OpenContactL()
       
   442 	{
       
   443 	iDb->SetDbViewContactType(KUidContactICCEntry);
       
   444 	const CContactIdArray* sortedItems = iDb->SortedItemsL();
       
   445 	TContactItemId id = (*sortedItems)[0];
       
   446 	CContactICCEntry* entry = static_cast<CContactICCEntry*>(iDb->OpenContactLX(id));
       
   447 	CleanupStack::PushL(entry);
       
   448 	ChangeNameFieldL(*entry,KModifiedName);
       
   449 	iDb->CloseContactL(id);
       
   450 	CleanupStack::PopAndDestroy(2); //entry+lockrecord
       
   451 	}
       
   452 
       
   453 /** Edit an ICC contact */
       
   454 void CPhbkIntegrationTestUtility::EditContactL()
       
   455 	{
       
   456 	iDb->SetDbViewContactType(KUidContactICCEntry);
       
   457 	const CContactIdArray* sortedItems = iDb->SortedItemsL();
       
   458 	TContactItemId id = (*sortedItems)[0];
       
   459 	CContactICCEntry* entry = static_cast<CContactICCEntry*>(iDb->OpenContactLX(id));
       
   460 	CleanupStack::PushL(entry);
       
   461 	ChangeNameFieldL(*entry,KModifiedName);
       
   462 	iDb->CommitContactL(*entry);
       
   463 	CleanupStack::PopAndDestroy(2); //entry+lockrecord
       
   464 	}
       
   465