pimprotocols/phonebooksync/Test/TE_cntsync/te_cntsyncadd.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 <e32test.h>
       
    17 
       
    18 #include "te_cntsyncbase.h"
       
    19 #include "te_cntsyncadd.h"
       
    20 #include <phbksync.h>
       
    21 #include <exterror.h>
       
    22 
       
    23 _LIT(KTestEmpty,"");
       
    24 _LIT(KBoundaryTestName,"B");
       
    25 _LIT(KBoundaryTestNumber,"2");
       
    26 _LIT(KTestCompany,"Company A");
       
    27 _LIT(KTestNumberWithDTMF,"020788p98w8548");
       
    28 _LIT(KTestAddNumber,"12345678");
       
    29 
       
    30 
       
    31 /** 
       
    32  * Factory construction method.
       
    33  * @return Pointer to CPhbkAddICCContactTest object
       
    34  */
       
    35 CPhbkAddICCContactTest* CPhbkAddICCContactTest::NewL()
       
    36 	{
       
    37 	CPhbkAddICCContactTest* self = new(ELeave) CPhbkAddICCContactTest();
       
    38 	return self;
       
    39 	}
       
    40 
       
    41 /**
       
    42  *  Default constructor.  Each test step initialises it's own name.
       
    43  */
       
    44 CPhbkAddICCContactTest::CPhbkAddICCContactTest()
       
    45 	{
       
    46 	SetTestStepName(_L("AddICCContactTest"));
       
    47 	}
       
    48 
       
    49 /** Add an ICC entry to each of the supported phonebooks - normal case */
       
    50 enum TVerdict CPhbkAddICCContactTest::doTestStepL()
       
    51 	{
       
    52 	SetSyncModeL(RPhoneBookSession::EManual);
       
    53 	CheckSyncModeL(RPhoneBookSession::EManual);
       
    54 	SetSimTsyTestNumberL(19);
       
    55 	DoSyncL();
       
    56 
       
    57 	AddContactL(KTestName,KTestNumber,KUidIccGlobalAdnPhonebook,KTestEMail);
       
    58 	AddContactL(KTestName,KTestNumber,KUidIccGlobalSdnPhonebook);
       
    59 	AddContactL(KTestName,KTestNumber,KUidIccGlobalLndPhonebook);
       
    60 	AddContactL(KTestName,KTestNumber,KUidUsimAppAdnPhonebook,KTestEMail);
       
    61 	AddContactL(KTestName,KTestNumber,KUidIccGlobalFdnPhonebook);
       
    62 
       
    63 	return TestStepResult();
       
    64 	}
       
    65 
       
    66 
       
    67 /** 
       
    68  * Factory construction method.
       
    69  * @return Pointer to CPhbkAddEntryEmptyNameTest object
       
    70  */
       
    71 CPhbkAddEntryEmptyNameTest* CPhbkAddEntryEmptyNameTest::NewL()
       
    72 	{
       
    73 	CPhbkAddEntryEmptyNameTest* self = new(ELeave) CPhbkAddEntryEmptyNameTest();
       
    74 	return self;
       
    75 	}
       
    76 
       
    77 /**
       
    78  *  Default constructor.  Each test step initialises it's own name.
       
    79  */
       
    80 CPhbkAddEntryEmptyNameTest::CPhbkAddEntryEmptyNameTest()
       
    81 	{
       
    82 	SetTestStepName(_L("AddEntryEmptyNameTest"));
       
    83 	}
       
    84 
       
    85 /** Add an ICC entry to each of the supported phonebooks - name field is empty */
       
    86 enum TVerdict CPhbkAddEntryEmptyNameTest::doTestStepL()
       
    87 	{
       
    88 	SetSimTsyTestNumberL(19);
       
    89 	DoSyncL();
       
    90 
       
    91 	TRAPD(err, AddContactL(KTestEmpty,KTestNumber,KUidIccGlobalAdnPhonebook));
       
    92 	TESTCHECKL(err, KErrNone); 
       
    93 
       
    94 	TRAP(err, AddContactL(KTestEmpty,KTestNumber,KUidIccGlobalSdnPhonebook));
       
    95 	TESTCHECKL(err, KErrNone); 
       
    96 
       
    97 	TRAP(err, AddContactL(KTestEmpty,KTestNumber,KUidIccGlobalLndPhonebook));
       
    98 	TESTCHECKL(err, KErrNone); 
       
    99 
       
   100 	TRAP(err, AddContactL(KTestEmpty,KTestNumber,KUidUsimAppAdnPhonebook,KTestEMail));
       
   101 	TESTCHECKL(err, KErrNone); 
       
   102 
       
   103 	TRAP(err, AddContactL(KTestEmpty,KTestNumber,KUidIccGlobalFdnPhonebook));
       
   104 	TESTCHECKL(err, KErrNone); 
       
   105 
       
   106 	return TestStepResult();
       
   107 	}
       
   108 
       
   109 
       
   110 /** 
       
   111  * Factory construction method.
       
   112  * @return Pointer to CPhbkAddEntryEmptyNumberTest object
       
   113  */
       
   114 CPhbkAddEntryEmptyNumberTest* CPhbkAddEntryEmptyNumberTest::NewL()
       
   115 	{
       
   116 	CPhbkAddEntryEmptyNumberTest* self = new(ELeave) CPhbkAddEntryEmptyNumberTest();
       
   117 	return self;
       
   118 	}
       
   119 
       
   120 /**
       
   121  *  Default constructor.  Each test step initialises it's own name.
       
   122  */
       
   123 CPhbkAddEntryEmptyNumberTest::CPhbkAddEntryEmptyNumberTest()
       
   124 	{
       
   125 	SetTestStepName(_L("AddEntryEmptyNumberTest"));
       
   126 	}
       
   127 
       
   128 /** Add an ICC entry to each of the supported phonebooks - number field is empty */
       
   129 enum TVerdict CPhbkAddEntryEmptyNumberTest::doTestStepL()
       
   130 	{
       
   131 	SetSimTsyTestNumberL(19);
       
   132 	DoSyncL();
       
   133 
       
   134 	TRAPD(err, AddContactL(KTestName,KTestEmpty,KUidIccGlobalAdnPhonebook));
       
   135 	TESTCHECKL(err, KErrNone); 
       
   136 
       
   137 	TRAP(err, AddContactL(KTestName,KTestEmpty,KUidIccGlobalSdnPhonebook));
       
   138 	TESTCHECKL(err, KErrNone); 
       
   139 
       
   140 	TRAP(err, AddContactL(KTestName,KTestEmpty,KUidIccGlobalLndPhonebook));
       
   141 	TESTCHECKL(err, KErrNone); 
       
   142 
       
   143 	TRAP(err, AddContactL(KTestName,KTestEmpty,KUidUsimAppAdnPhonebook,KTestEMail));
       
   144 	TESTCHECKL(err, KErrNone); 
       
   145 
       
   146 	TRAP(err, AddContactL(KTestName,KTestEmpty,KUidIccGlobalFdnPhonebook));
       
   147 	TESTCHECKL(err, KErrNone); 
       
   148 
       
   149 	return TestStepResult();
       
   150 	}
       
   151 
       
   152 /** 
       
   153  * Factory construction method.
       
   154  * @return Pointer to CPhbkAddEntryEmptyEmailTest object
       
   155  */
       
   156 CPhbkAddEntryEmptyEmailTest* CPhbkAddEntryEmptyEmailTest::NewL()
       
   157 	{
       
   158 	CPhbkAddEntryEmptyEmailTest* self = new(ELeave) CPhbkAddEntryEmptyEmailTest();
       
   159 	return self;
       
   160 	}
       
   161 
       
   162 /**
       
   163  *  Default constructor.  Each test step initialises it's own name.
       
   164  */
       
   165 CPhbkAddEntryEmptyEmailTest::CPhbkAddEntryEmptyEmailTest()
       
   166 	{
       
   167 	SetTestStepName(_L("AddEntryEmptyEmailTest"));
       
   168 	}
       
   169 
       
   170 /** Add an ICC entry to each of the supported phonebooks - first email field is empty, second one is valid */
       
   171 enum TVerdict CPhbkAddEntryEmptyEmailTest::doTestStepL()
       
   172 	{
       
   173 	SetSyncModeL(RPhoneBookSession::EManual);
       
   174 	CheckSyncModeL(RPhoneBookSession::EManual);
       
   175 
       
   176 	TRequestStatus status;
       
   177 
       
   178 	// Loading a bunch of entries from the SIM (one of them contains the dodgy entry)
       
   179 	SetSimTsyTestNumberL(27);
       
   180 
       
   181 	// Sync
       
   182 	iSession.DoSynchronisation(status, KUidUsimAppAdnPhonebook);
       
   183 	User::WaitForRequest(status);
       
   184 	TESTCHECKL(status.Int(), KErrNone);
       
   185 
       
   186 	// Resetting the phone 
       
   187 	SetSimTsyTestNumberL(28);
       
   188 
       
   189 	// Sync again
       
   190 	iSession.DoSynchronisation(status, KUidUsimAppAdnPhonebook);
       
   191 	User::WaitForRequest(status);
       
   192 	TESTCHECKL(status.Int(), KErrNone);
       
   193 
       
   194 	// look for contact in the synchronised database
       
   195 	CContactItemFieldDef* fieldDef = new(ELeave) CContactItemFieldDef;
       
   196 	CleanupStack::PushL(fieldDef);
       
   197 	fieldDef->AppendL(KUidContactFieldEMail); // define subset of fields to search
       
   198 	CContactIdArray* array = iDb->FindLC(KTestEMail,fieldDef);
       
   199 	TESTCHECKL(array->Count(),1); 
       
   200 	TContactItemId entryId = (*array)[0];
       
   201 
       
   202 	// now read it back
       
   203 	CContactItem* entryItem = iDb->ReadContactLC(entryId);
       
   204 	CContactICCEntry* newEntry = CContactICCEntry::NewL(*entryItem);
       
   205 	CleanupStack::PushL(newEntry);
       
   206 	
       
   207 	// now checking the entry
       
   208 	CContactItemFieldSet& fieldset = newEntry->CardFields();
       
   209 	CheckEmptyEmailFieldContentL(fieldset,KUidContactFieldEMail,KTestEMail);
       
   210 	
       
   211 	CleanupStack::PopAndDestroy(newEntry);
       
   212 	CleanupStack::PopAndDestroy(entryItem);
       
   213 	CleanupStack::PopAndDestroy(array);
       
   214 	CleanupStack::PopAndDestroy(fieldDef);
       
   215 
       
   216 	return TestStepResult();
       
   217 	}
       
   218 
       
   219 /** 
       
   220  * Check that the field of type aFieldType has the same content as 
       
   221  * aExpectedContent
       
   222  * @param aFieldset Contact item fieldset
       
   223  * @param aFieldType Field type to test
       
   224  * @param aExpectedContent Expected data
       
   225  */
       
   226 void CPhbkAddIntegrationTestBase::CheckEmptyEmailFieldContentL(CContactItemFieldSet& aFieldset, TFieldType aFieldType, const TDesC& aExpectedContent)
       
   227 	{
       
   228 	// Look for up to two entries with that label
       
   229 	TInt pos1 = aFieldset.FindNext(aFieldType,KContactFieldSetSearchAll);
       
   230 	TInt pos2 = aFieldset.FindNext(aFieldType,pos1+1);
       
   231 	
       
   232 	TBool match1 = EFalse;
       
   233 	TBool match2 = EFalse;
       
   234 
       
   235 	// There must be exactly two email fields 
       
   236 	TESTCHECKCONDITION((pos1!=KErrNotFound)&&(pos2!=KErrNotFound));
       
   237 
       
   238 	// Checking the value of the first match
       
   239 	if(pos1 != KErrNotFound)
       
   240 		{
       
   241 		CContactItemField& field1 = aFieldset[pos1];		
       
   242 		CContactTextField* textField1 = field1.TextStorage();
       
   243 		if(textField1 != NULL)
       
   244 			{
       
   245 			match1 = (textField1->Text() == aExpectedContent); // Flips to ETrue
       
   246 			}
       
   247 		}
       
   248 
       
   249 	// Checking the value of the second match
       
   250 	if(pos2 != KErrNotFound)
       
   251 		{
       
   252 		CContactItemField& field2 = aFieldset[pos2];		
       
   253 		CContactTextField* textField2 = field2.TextStorage();
       
   254 		if(textField2 != NULL)
       
   255 			{
       
   256 			match2 = (textField2->Text() == aExpectedContent); // Flips to ETrue
       
   257 			}
       
   258 		}
       
   259 
       
   260 	// One (and only one) of the entries must match the expected value
       
   261 	TESTCHECKCONDITIONL( (match1 && !match2) || (!match1 && match2) );
       
   262 	}
       
   263 
       
   264 /** 
       
   265  * Factory construction method.
       
   266  * @return Pointer to CPhbkAddPhonebookFullTest object
       
   267  */
       
   268 CPhbkAddPhonebookFullTest* CPhbkAddPhonebookFullTest::NewL()
       
   269 	{
       
   270 	CPhbkAddPhonebookFullTest* self = new(ELeave) CPhbkAddPhonebookFullTest();
       
   271 	return self;
       
   272 	}
       
   273 
       
   274 /**
       
   275  *  Default constructor.  Each test step initialises it's own name.
       
   276  */
       
   277 CPhbkAddPhonebookFullTest::CPhbkAddPhonebookFullTest()
       
   278 	{
       
   279 	SetTestStepName(_L("AddPhonebookFullTest"));
       
   280 	}
       
   281 
       
   282 /** Add an ICC entry to each of the supported phonebooks - fails because phonebook is full */
       
   283 enum TVerdict CPhbkAddPhonebookFullTest::doTestStepL()
       
   284 	{
       
   285 	SetSimTsyTestNumberL(16);
       
   286 	DoSyncL();
       
   287 
       
   288 	TRAPD(error,AddContactL(KTestName,KTestNumber,KUidIccGlobalAdnPhonebook)); 
       
   289 	TESTCHECKL(error, KErrNoMemory); // TSY reports "no free slots as KErrNoMemory"
       
   290 
       
   291 	TRAP(error,AddContactL(KTestName,KTestNumber,KUidIccGlobalSdnPhonebook)); 
       
   292 	TESTCHECKL(error, KErrNoMemory); // TSY reports "no free slots as KErrNoMemory"
       
   293 
       
   294 	TRAP(error,AddContactL(KTestName,KTestNumber,KUidIccGlobalLndPhonebook)); 
       
   295 	TESTCHECKL(error, KErrNoMemory); // TSY reports "no free slots as KErrNoMemory"
       
   296 
       
   297 	TRAP(error,AddContactL(KTestName,KTestNumber,KUidUsimAppAdnPhonebook,KTestEMail)); 
       
   298 	TESTCHECKL(error, KErrNoMemory); // TSY reports "no free slots as KErrNoMemory"
       
   299 
       
   300 	TRAP(error,AddContactL(KTestName,KTestNumber,KUidIccGlobalFdnPhonebook)); 
       
   301 	TESTCHECKL(error, KErrNoMemory); // TSY reports "no free slots as KErrNoMemory"
       
   302 
       
   303 	return TestStepResult();
       
   304 	}
       
   305 
       
   306 
       
   307 /** 
       
   308  * Factory construction method.
       
   309  * @return Pointer to CPhbkAddBoundaryConditionsTest object
       
   310  */
       
   311 CPhbkAddBoundaryConditionsTest* CPhbkAddBoundaryConditionsTest::NewL()
       
   312 	{
       
   313 	CPhbkAddBoundaryConditionsTest* self = new(ELeave) CPhbkAddBoundaryConditionsTest();
       
   314 	return self;
       
   315 	}
       
   316 
       
   317 /**
       
   318  *  Default constructor.  Each test step initialises it's own name.
       
   319  */
       
   320 CPhbkAddBoundaryConditionsTest::CPhbkAddBoundaryConditionsTest()
       
   321 	{
       
   322 	SetTestStepName(_L("AddBoundaryConditionsTest"));
       
   323 	}
       
   324 
       
   325 /* Add an ICC entry to each of the supported phonebooks - boundary conditions met */
       
   326 enum TVerdict CPhbkAddBoundaryConditionsTest::doTestStepL()
       
   327 	{
       
   328 	SetSimTsyTestNumberL(19);
       
   329 	DoSyncL();
       
   330 	RPhoneBookSession::TContactFieldsV1 fields;
       
   331 	RPhoneBookSession::TContactFieldsV1Pckg fieldsPckg(fields);
       
   332 	iSession.GetContactFormat(fieldsPckg);
       
   333 
       
   334 	TInt i(0);
       
   335 
       
   336 	TBuf16<KMaxPhBkNameSize> name;
       
   337 	TBuf16<RMobilePhone::KMaxMobileTelNumberSize> number;
       
   338 
       
   339 	// Check Condition when length of fields are less than max length defined in config
       
   340 	name.Format(KBoundaryTestName);
       
   341 	number.Format(KBoundaryTestNumber);
       
   342 
       
   343 	// value of i=2 because name field already contains 1 char
       
   344 	for(i=2; i<fields.iNameField.iLength; i++)
       
   345 		name.Append(KBoundaryTestName);
       
   346 
       
   347 	TESTCHECKL(fields.iNameField.iCount, 1);
       
   348 	TESTCHECKCONDITION(fields.iNameField.iDisplayed);
       
   349 	
       
   350 	// value of i=2 because number field already contains 1 char
       
   351 	for(i=2; i<fields.iNumberField.iLength; i++)
       
   352 		number.Append(KBoundaryTestNumber);
       
   353 
       
   354 	TESTCHECK(fields.iNumberField.iCount, 1);
       
   355 	TESTCHECKCONDITION(fields.iNumberField.iDisplayed);
       
   356 	TESTCHECK(fields.iIccSlotField.iLength, -1);
       
   357 	TESTCHECK(fields.iIccSlotField.iCount, 1);
       
   358 	TESTCHECKCONDITION(fields.iIccSlotField.iDisplayed);
       
   359 
       
   360 	// Now try to add these fields that test boundary conditions 
       
   361 	TRAPD(err, AddContactL(name,number,KUidIccGlobalAdnPhonebook));
       
   362 	TESTCHECKL(err, KErrNone);
       
   363 
       
   364 	TRAP(err, AddContactL(name,number,KUidIccGlobalSdnPhonebook));
       
   365 	TESTCHECKL(err, KErrNone);
       
   366 
       
   367 	TRAP(err, AddContactL(name,number,KUidIccGlobalLndPhonebook));
       
   368 	TESTCHECKL(err, KErrNone);
       
   369 
       
   370 	TRAP(err, AddContactL(name,number,KUidUsimAppAdnPhonebook,KTestEMail));
       
   371 	TESTCHECKL(err, KErrNone);
       
   372 
       
   373 	TRAP(err, AddContactL(name,number,KUidIccGlobalFdnPhonebook));
       
   374 	TESTCHECKL(err, KErrNone);
       
   375 
       
   376 	// Check Condition when length of fields are equal to max length defined in config
       
   377 	name.Format(KBoundaryTestName);
       
   378 	number.Format(KBoundaryTestNumber);
       
   379 
       
   380 	// value of i=2 because name field already contains 1 char
       
   381 	for(i=2; i<fields.iNameField.iLength+1; i++)
       
   382 		name.Append(KBoundaryTestName);
       
   383 
       
   384 	TESTCHECKL(fields.iNameField.iCount, 1);
       
   385 	TESTCHECKCONDITION(fields.iNameField.iDisplayed);
       
   386 	
       
   387 	// value of i=2 because number field already contains 1 char
       
   388 	for(i=2; i<fields.iNumberField.iLength+1; i++)
       
   389 		number.Append(KBoundaryTestNumber);
       
   390 
       
   391 	TESTCHECK(fields.iNumberField.iCount, 1);
       
   392 	TESTCHECKCONDITION(fields.iNumberField.iDisplayed);
       
   393 	TESTCHECK(fields.iIccSlotField.iLength, -1);
       
   394 	TESTCHECK(fields.iIccSlotField.iCount, 1);
       
   395 	TESTCHECKCONDITION(fields.iIccSlotField.iDisplayed);
       
   396 
       
   397 	// Now try to add these fields that test boundary conditions 
       
   398 	TRAP(err, AddContactL(name,number,KUidIccGlobalAdnPhonebook));
       
   399 	TESTCHECKL(err, KErrNone);
       
   400 
       
   401 	TRAP(err, AddContactL(name,number,KUidIccGlobalSdnPhonebook));
       
   402 	TESTCHECKL(err, KErrNone);
       
   403 
       
   404 	TRAP(err, AddContactL(name,number,KUidIccGlobalLndPhonebook));
       
   405 	TESTCHECKL(err, KErrNone);
       
   406 
       
   407 	TRAP(err, AddContactL(name,number,KUidUsimAppAdnPhonebook,KTestEMail));
       
   408 	TESTCHECKL(err, KErrNone);
       
   409 
       
   410 	TRAP(err, AddContactL(name,number,KUidIccGlobalFdnPhonebook));
       
   411 	TESTCHECKL(err, KErrNone);
       
   412 
       
   413 	// Check Condition when length of name field is greater than max length defined in config
       
   414 	name.Format(KBoundaryTestName);
       
   415 	number.Format(KBoundaryTestNumber);
       
   416 
       
   417 	// value of i=2 because name field already contains 1 char
       
   418 	for(i=2; i<fields.iNameField.iLength+2; i++)
       
   419 		name.Append(KBoundaryTestName);
       
   420 
       
   421 	TESTCHECKL(fields.iNameField.iCount, 1);
       
   422 	TESTCHECKCONDITION(fields.iNameField.iDisplayed);
       
   423 
       
   424 	// value of i=2 because number field already contains 1 char
       
   425 	for(i=2; i<fields.iNumberField.iLength+1; i++)
       
   426 		number.Append(KBoundaryTestNumber);
       
   427 
       
   428 	TESTCHECK(fields.iNumberField.iCount, 1);
       
   429 	TESTCHECKCONDITION(fields.iNumberField.iDisplayed);
       
   430 	TESTCHECK(fields.iIccSlotField.iLength, -1);
       
   431 	TESTCHECK(fields.iIccSlotField.iCount, 1);
       
   432 	TESTCHECKCONDITION(fields.iIccSlotField.iDisplayed);
       
   433 
       
   434 	// Now try to add these fields that exceed boundary conditions 
       
   435 	TRAP(err, AddContactL(name,number,KUidIccGlobalAdnPhonebook));
       
   436 	TESTCHECKL(err, KErrPhonebookTextOverflow);
       
   437 
       
   438 	TRAP(err, AddContactL(name,number,KUidIccGlobalSdnPhonebook));
       
   439 	TESTCHECKL(err, KErrPhonebookTextOverflow);
       
   440 
       
   441 	TRAP(err, AddContactL(name,number,KUidIccGlobalLndPhonebook));
       
   442 	TESTCHECKL(err, KErrPhonebookTextOverflow);
       
   443 
       
   444 	TRAP(err, AddContactL(name,number,KUidUsimAppAdnPhonebook,KTestEMail));
       
   445 	TESTCHECKL(err, KErrPhonebookTextOverflow);
       
   446 
       
   447 	TRAP(err, AddContactL(name,number,KUidIccGlobalFdnPhonebook));
       
   448 	TESTCHECKL(err, KErrPhonebookTextOverflow);
       
   449 
       
   450 	// Check Condition when length of tel number field is greater than max length defined in config
       
   451 	name.Format(KBoundaryTestName);
       
   452 	number.Format(KBoundaryTestNumber);
       
   453 
       
   454 	// value of i=2 because name field already contains 1 char
       
   455 	for(i=2; i<fields.iNameField.iLength+1; i++)
       
   456 		name.Append(KBoundaryTestName);
       
   457 
       
   458 	TESTCHECKL(fields.iNameField.iCount, 1);
       
   459 	TESTCHECKCONDITION(fields.iNameField.iDisplayed);
       
   460 
       
   461 	// value of i=2 because number field already contains 1 char
       
   462 	for(i=2; i<fields.iNumberField.iLength+2; i++)
       
   463 		number.Append(KBoundaryTestNumber);
       
   464 
       
   465 	TESTCHECK(fields.iNumberField.iCount, 1);
       
   466 	TESTCHECKCONDITION(fields.iNumberField.iDisplayed);
       
   467 	TESTCHECK(fields.iIccSlotField.iLength, -1);
       
   468 	TESTCHECK(fields.iIccSlotField.iCount, 1);
       
   469 	TESTCHECKCONDITION(fields.iIccSlotField.iDisplayed);
       
   470 
       
   471 	// Now try to add these fields that exceed boundary conditions 
       
   472 	TRAP(err, AddContactL(name,number,KUidIccGlobalAdnPhonebook));
       
   473 	TESTCHECKL(err, KErrPhonebookNumberOverflow);
       
   474 
       
   475 	TRAP(err, AddContactL(name,number,KUidIccGlobalSdnPhonebook));
       
   476 	TESTCHECKL(err, KErrPhonebookNumberOverflow);
       
   477 
       
   478 	TRAP(err, AddContactL(name,number,KUidIccGlobalLndPhonebook));
       
   479 	TESTCHECKL(err, KErrPhonebookNumberOverflow);
       
   480 
       
   481 	TRAP(err, AddContactL(name,number,KUidUsimAppAdnPhonebook,KTestEMail));
       
   482 	TESTCHECKL(err, KErrPhonebookNumberOverflow);
       
   483 
       
   484 	TRAP(err, AddContactL(name,number,KUidIccGlobalFdnPhonebook));
       
   485 	TESTCHECKL(err, KErrPhonebookNumberOverflow);
       
   486 	
       
   487 	return TestStepResult();
       
   488 	}
       
   489 
       
   490 /** 
       
   491  * Factory construction method.
       
   492  * @return Pointer to CPhbkAddNameBoundaryExceededTest object
       
   493  */
       
   494 CPhbkAddNameBoundaryExceededTest* CPhbkAddNameBoundaryExceededTest::NewL()
       
   495 	{
       
   496 	CPhbkAddNameBoundaryExceededTest* self = new(ELeave) CPhbkAddNameBoundaryExceededTest();
       
   497 	return self;
       
   498 	}
       
   499 
       
   500 /**
       
   501  *  Default constructor.  Each test step initialises it's own name.
       
   502  */
       
   503 CPhbkAddNameBoundaryExceededTest::CPhbkAddNameBoundaryExceededTest()
       
   504 	{
       
   505 	SetTestStepName(_L("AddNameBoundaryExceededTest"));
       
   506 	}
       
   507 
       
   508 /* Add an ICC entry to each of the supported phonebooks - name boundary conditions exceeded */
       
   509 enum TVerdict CPhbkAddNameBoundaryExceededTest::doTestStepL()
       
   510 	{
       
   511 	RPhoneBookSession::TContactFieldsV1 fields;
       
   512 	RPhoneBookSession::TContactFieldsV1Pckg fieldsPckg(fields);
       
   513 	iSession.GetContactFormat(fieldsPckg);
       
   514 	
       
   515 	TBuf16<KMaxPhBkNameSize> name;
       
   516 	name.Format(KBoundaryTestName);
       
   517 	TBuf16<RMobilePhone::KMaxMobileTelNumberSize> number;
       
   518 	number.Format(KBoundaryTestNumber);
       
   519 
       
   520 	TInt i(0);
       
   521 	for(i=0; i<(fields.iNameField.iLength+10); i++)
       
   522 		name.Append(KBoundaryTestName); // name boundary exceeded by 10 characters
       
   523 
       
   524 	TESTCHECKL(fields.iNameField.iCount, 1);
       
   525 	TESTCHECKCONDITIONL(fields.iNameField.iDisplayed);
       
   526 	
       
   527 	for(i=1; i<fields.iNumberField.iLength+3; i++)
       
   528 		number.Append(KBoundaryTestNumber);
       
   529 
       
   530 	TESTCHECKL(fields.iNumberField.iCount, 1);
       
   531 	TESTCHECKCONDITIONL(fields.iNumberField.iDisplayed);
       
   532 	TESTCHECKL(fields.iIccSlotField.iLength, -1);
       
   533 	TESTCHECKL(fields.iIccSlotField.iCount, 1);
       
   534 	TESTCHECKCONDITIONL(fields.iIccSlotField.iDisplayed);
       
   535 
       
   536 	// move to another SIM TSY configuration where the phonebook is full
       
   537 
       
   538 	TRAPD(err, AddContactL(name,number,KUidIccGlobalAdnPhonebook));
       
   539 	TESTCHECKL(err, KErrOverflow);
       
   540 	TRAP(err, AddContactL(name,number,KUidIccGlobalSdnPhonebook));
       
   541 	TESTCHECKL(err, KErrOverflow);
       
   542 	TRAP(err, AddContactL(name,number,KUidIccGlobalLndPhonebook));
       
   543 	TESTCHECKL(err, KErrOverflow);
       
   544 	TRAP(err, AddContactL(name,number,KUidUsimAppAdnPhonebook,KTestEMail));
       
   545 	TESTCHECKL(err, KErrOverflow);
       
   546 	TRAP(err, AddContactL(name,number,KUidIccGlobalFdnPhonebook));
       
   547 	TESTCHECKL(err, KErrOverflow);
       
   548 
       
   549 	return TestStepResult();
       
   550 	}
       
   551 
       
   552 
       
   553 /** 
       
   554  * Factory construction method.
       
   555  * @return Pointer to CPhbkAddNumberBoundaryExceededTest object
       
   556  */
       
   557 CPhbkAddNumberBoundaryExceededTest* CPhbkAddNumberBoundaryExceededTest::NewL()
       
   558 	{
       
   559 	CPhbkAddNumberBoundaryExceededTest* self = new(ELeave) CPhbkAddNumberBoundaryExceededTest();
       
   560 	return self;
       
   561 	}
       
   562 
       
   563 /**
       
   564  *  Default constructor.  Each test step initialises it's own name.
       
   565  */
       
   566 CPhbkAddNumberBoundaryExceededTest::CPhbkAddNumberBoundaryExceededTest()
       
   567 	{
       
   568 	SetTestStepName(_L("AddNumberBoundaryExceededTest"));
       
   569 	}
       
   570 
       
   571 /* Add an ICC entry to each of the supported phonebooks - number boundary conditions exceeded */
       
   572 enum TVerdict CPhbkAddNumberBoundaryExceededTest::doTestStepL()
       
   573 	{
       
   574 	RPhoneBookSession::TContactFieldsV1 fields;
       
   575 	RPhoneBookSession::TContactFieldsV1Pckg fieldsPckg(fields);
       
   576 	iSession.GetContactFormat(fieldsPckg);
       
   577 	TBuf16<KMaxPhBkNameSize> name;
       
   578 	name.Format(KBoundaryTestName);
       
   579 	TBuf16<RMobilePhone::KMaxMobileTelNumberSize> number;
       
   580 	number.Format(KBoundaryTestNumber);
       
   581 
       
   582 	TInt i(0);
       
   583 	for(i=1; i<fields.iNameField.iLength+1; i++)
       
   584 		name.Append(KBoundaryTestName); 
       
   585 
       
   586 	TESTCHECKL(fields.iNameField.iCount, 1);
       
   587 	TESTCHECKCONDITIONL(fields.iNameField.iDisplayed);
       
   588 	
       
   589 	for(i=0; i<fields.iNumberField.iLength+1; i++)
       
   590 		number.Append(KBoundaryTestNumber); // number boundary exceeded by 1 character
       
   591 
       
   592 	TESTCHECKL(fields.iNumberField.iCount, 1);
       
   593 	TESTCHECKCONDITIONL(fields.iNumberField.iDisplayed);
       
   594 	TESTCHECKL(fields.iIccSlotField.iLength, -1);
       
   595 	TESTCHECKL(fields.iIccSlotField.iCount, 1);
       
   596 	TESTCHECKCONDITIONL(fields.iIccSlotField.iDisplayed);
       
   597 
       
   598 	// move to another SIM TSY configuration where the phonebook is full
       
   599 
       
   600 	TRAPD(err, AddContactL(name,number,KUidIccGlobalAdnPhonebook));
       
   601 	TESTCHECKL(err, KErrOverflow);
       
   602 	TRAP(err, AddContactL(name,number,KUidIccGlobalSdnPhonebook));
       
   603 	TESTCHECKL(err, KErrOverflow);
       
   604 	TRAP(err, AddContactL(name,number,KUidIccGlobalLndPhonebook));
       
   605 	TESTCHECKL(err, KErrOverflow);
       
   606 	TRAP(err, AddContactL(name,number,KUidUsimAppAdnPhonebook,KTestEMail));
       
   607 	TESTCHECKL(err, KErrOverflow);
       
   608 	TRAP(err, AddContactL(name,number,KUidIccGlobalFdnPhonebook));
       
   609 	TESTCHECKL(err, KErrOverflow);
       
   610 
       
   611 	return TestStepResult();
       
   612 	}
       
   613 
       
   614 
       
   615 /** 
       
   616  * Factory construction method.
       
   617  * @return Pointer to CPhbkAddSequenceOfEntriesTest object
       
   618  */
       
   619 CPhbkAddSequenceOfEntriesTest* CPhbkAddSequenceOfEntriesTest::NewL()
       
   620 	{
       
   621 	CPhbkAddSequenceOfEntriesTest* self = new(ELeave) CPhbkAddSequenceOfEntriesTest();
       
   622 	return self;
       
   623 	}
       
   624 
       
   625 /**
       
   626  *  Default constructor.  Each test step initialises it's own name.
       
   627  */
       
   628 CPhbkAddSequenceOfEntriesTest::CPhbkAddSequenceOfEntriesTest()
       
   629 	{
       
   630 	SetTestStepName(_L("AddSequenceOfEntriesTest"));
       
   631 	}
       
   632 
       
   633 /* Add sequence of ICC entries - Fill ICC */
       
   634 enum TVerdict CPhbkAddSequenceOfEntriesTest::doTestStepL()
       
   635 	{
       
   636 	SetSimTsyTestNumberL(19);
       
   637 	DoSyncL();
       
   638 	for(TInt i=1; i<(KMaxICCSlotsTest6+10);++i)
       
   639 		{
       
   640 		TRAPD(err1, AddContactL(KTestName, KTestNumber, KUidIccGlobalAdnPhonebook)); // Keep adding entries to all phonebooks
       
   641 		TRAPD(err2, AddContactL(KTestName, KTestNumber, KUidIccGlobalSdnPhonebook));
       
   642 		TRAPD(err3, AddContactL(KTestName, KTestNumber, KUidIccGlobalLndPhonebook));
       
   643 		TRAPD(err4, AddContactL(KTestName, KTestNumber, KUidUsimAppAdnPhonebook, KTestEMail));
       
   644 		TRAPD(err5, AddContactL(KTestName, KTestNumber, KUidIccGlobalFdnPhonebook));
       
   645 		if(i < (KMaxICCSlotsTest6 - KNumOfUsedSlotstest6 + 1))
       
   646 			{			
       
   647 			TESTCHECKL(err1, KErrNone);
       
   648 			TESTCHECKL(err2, KErrNone);
       
   649 			TESTCHECKL(err3, KErrNone);
       
   650 			TESTCHECKL(err4, KErrNone);
       
   651 			TESTCHECKL(err5, KErrNone);
       
   652 			}
       
   653 		else
       
   654 			{
       
   655 			TESTCHECKL(err1, KErrNoMemory);
       
   656 			TESTCHECKL(err2, KErrNoMemory);
       
   657 			TESTCHECKL(err3, KErrNoMemory);
       
   658 			TESTCHECKL(err4, KErrNoMemory);
       
   659 			TESTCHECKL(err5, KErrNoMemory);
       
   660 			}
       
   661 		}
       
   662 
       
   663 	return TestStepResult();
       
   664 	}
       
   665 
       
   666 
       
   667 /** 
       
   668  * Factory construction method.
       
   669  * @return Pointer to CPhbkAddEntryICCLockedTest object
       
   670  */
       
   671 CPhbkAddEntryICCLockedTest* CPhbkAddEntryICCLockedTest::NewL()
       
   672 	{
       
   673 	CPhbkAddEntryICCLockedTest* self = new(ELeave) CPhbkAddEntryICCLockedTest();
       
   674 	return self;
       
   675 	}
       
   676 
       
   677 /**
       
   678  *  Default constructor.  Each test step initialises it's own name.
       
   679  */
       
   680 CPhbkAddEntryICCLockedTest::CPhbkAddEntryICCLockedTest()
       
   681 	{
       
   682 	SetTestStepName(_L("AddEntryICCLockedTest"));
       
   683 	}
       
   684 
       
   685 /* Add an ICC entry to each of the supported phonebooks - ICC locked */
       
   686 enum TVerdict CPhbkAddEntryICCLockedTest::doTestStepL()
       
   687 	{
       
   688 	SetSimTsyTestNumberL(18);
       
   689 	DoSyncL();
       
   690 	TInt err1(KErrNone), err2(KErrNone), err3(KErrNone), err4(KErrNone), err5(KErrNone);
       
   691 	while(err1==KErrNone && err2==KErrNone && err3==KErrNone && err4==KErrNone) // Wait for ICC to become locked
       
   692 		{
       
   693 		TRAP(err1,AddContactL(KTestName,KTestNumber,KUidIccGlobalAdnPhonebook));
       
   694 		TRAP(err2,AddContactL(KTestName,KTestNumber,KUidIccGlobalSdnPhonebook));
       
   695 		TRAP(err3,AddContactL(KTestName,KTestNumber,KUidIccGlobalLndPhonebook));
       
   696 		TRAP(err4,AddContactL(KTestName,KTestNumber,KUidUsimAppAdnPhonebook,KTestEMail));
       
   697 		TRAP(err5,AddContactL(KTestName,KTestNumber,KUidIccGlobalFdnPhonebook));
       
   698 		User::After(2000000);	// Wait a second and try again.
       
   699 		}
       
   700 	TRAP(err1,AddContactL(KTestName,KTestNumber,KUidIccGlobalAdnPhonebook));
       
   701 	TRAP(err2,AddContactL(KTestName,KTestNumber,KUidIccGlobalSdnPhonebook));
       
   702 	TRAP(err3,AddContactL(KTestName,KTestNumber,KUidIccGlobalLndPhonebook));
       
   703 	TRAP(err4,AddContactL(KTestName,KTestNumber,KUidUsimAppAdnPhonebook,KTestEMail));
       
   704 	TRAP(err5,AddContactL(KTestName,KTestNumber,KUidIccGlobalFdnPhonebook));
       
   705 	TESTCHECK(err1, KErrAccessDenied);
       
   706 	TESTCHECK(err2, KErrAccessDenied);
       
   707 	TESTCHECK(err3, KErrAccessDenied);
       
   708 	TESTCHECK(err4, KErrAccessDenied);
       
   709 	TESTCHECK(err5, KErrAccessDenied);
       
   710 	User::After(10000000); // Wait for ICC to become unlocked
       
   711 
       
   712 	return TestStepResult();
       
   713 	}
       
   714 
       
   715 
       
   716 /** 
       
   717  * Factory construction method.
       
   718  * @return Pointer to CPhbkAddEntryICCWriteFailsTest object
       
   719  */
       
   720 CPhbkAddEntryICCWriteFailsTest* CPhbkAddEntryICCWriteFailsTest::NewL()
       
   721 	{
       
   722 	CPhbkAddEntryICCWriteFailsTest* self = new(ELeave) CPhbkAddEntryICCWriteFailsTest();
       
   723 	return self;
       
   724 	}
       
   725 
       
   726 /**
       
   727  *  Default constructor.  Each test step initialises it's own name.
       
   728  */
       
   729 CPhbkAddEntryICCWriteFailsTest::CPhbkAddEntryICCWriteFailsTest()
       
   730 	{
       
   731 	SetTestStepName(_L("AddEntryICCWriteFailsTest"));
       
   732 	}
       
   733 
       
   734 /* Add an ICC entry to each of the supported phonebooks - ICC write fails */
       
   735 enum TVerdict CPhbkAddEntryICCWriteFailsTest::doTestStepL()
       
   736 	{
       
   737 	SetSimTsyTestNumberL(5);
       
   738 	DoSyncL();
       
   739 	TRAPD(err,AddContactL(KTestName,KTestNumber,KUidIccGlobalAdnPhonebook)); 
       
   740 	TESTCHECKL(err, KErrBadHandle);
       
   741 	TRAP(err,AddContactL(KTestName,KTestNumber,KUidIccGlobalSdnPhonebook)); 
       
   742 	TESTCHECKL(err, KErrBadHandle);
       
   743 	TRAP(err,AddContactL(KTestName,KTestNumber,KUidIccGlobalLndPhonebook)); 
       
   744 	TESTCHECKL(err, KErrBadHandle);
       
   745 	TRAP(err,AddContactL(KTestName,KTestNumber,KUidUsimAppAdnPhonebook,KTestEMail)); 
       
   746 	TESTCHECKL(err, KErrBadHandle);
       
   747 	TRAP(err,AddContactL(KTestName,KTestNumber,KUidIccGlobalFdnPhonebook)); 
       
   748 	TESTCHECKL(err, KErrBadHandle);
       
   749 
       
   750 	return TestStepResult();
       
   751 	}
       
   752 
       
   753 
       
   754 /** 
       
   755  * Factory construction method.
       
   756  * @return Pointer to CPhbkAddEntryInvalidFieldTest object
       
   757  */
       
   758 CPhbkAddEntryInvalidFieldTest* CPhbkAddEntryInvalidFieldTest::NewL()
       
   759 	{
       
   760 	CPhbkAddEntryInvalidFieldTest* self = new(ELeave) CPhbkAddEntryInvalidFieldTest();
       
   761 	return self;
       
   762 	}
       
   763 
       
   764 /**
       
   765  *  Default constructor.  Each test step initialises it's own name.
       
   766  */
       
   767 CPhbkAddEntryInvalidFieldTest::CPhbkAddEntryInvalidFieldTest()
       
   768 	{
       
   769 	SetTestStepName(_L("AddEntryInvalidFieldTest"));
       
   770 	}
       
   771 
       
   772 /* Add an ICC entry to each of the supported phonebooks - invalid field included */
       
   773 enum TVerdict CPhbkAddEntryInvalidFieldTest::doTestStepL()
       
   774 	{
       
   775 	SetSimTsyTestNumberL(17);
       
   776 	DoSyncL();
       
   777 
       
   778 	DoAddEntryInvalidFieldL(KUidIccGlobalAdnPhonebook);
       
   779 	DoAddEntryInvalidFieldL(KUidIccGlobalSdnPhonebook);
       
   780 	DoAddEntryInvalidFieldL(KUidIccGlobalLndPhonebook);
       
   781 	DoAddEntryInvalidFieldL(KUidUsimAppAdnPhonebook);
       
   782 	DoAddEntryInvalidFieldL(KUidIccGlobalFdnPhonebook);
       
   783 
       
   784 	return TestStepResult();
       
   785 	}
       
   786 
       
   787 
       
   788 /* Add an ICC entry to phonebook aPhonebook - invalid field included */
       
   789 void CPhbkAddIntegrationTestBase::DoAddEntryInvalidFieldL(const TUid aPhonebook)
       
   790 	{
       
   791 	TContactItemId templateId = iDb->ICCTemplateIdL(aPhonebook);
       
   792 	CContactItem* iccTemplate = iDb->ReadContactLC(templateId);
       
   793 	CContactICCEntry* entry = CContactICCEntry::NewL(*iccTemplate);
       
   794 	CleanupStack::PopAndDestroy(iccTemplate);
       
   795 	CleanupStack::PushL(entry);
       
   796 
       
   797 	AddTextFieldL(KUidContactFieldFamilyName,KUidContactFieldVCardMapUnusedN, KTestName, *entry);
       
   798 	AddTextFieldL(KUidContactFieldPhoneNumber,KUidContactFieldVCardMapTEL, KTestNumber, *entry);
       
   799 	AddTextFieldL(KUidContactFieldCompanyName,KUidContactFieldVCardMapUnusedN, KTestCompany, *entry); // invalid field 
       
   800 	TContactItemId id(KNullContactId);
       
   801 	TRAPD(err, id=iDb->AddNewContactL(*entry));
       
   802 	CleanupStack::PopAndDestroy(entry);	
       
   803 	TESTCHECKL(id, KNullContactId);
       
   804 	TESTCHECKL(err, KErrNotSupported); 
       
   805 	}
       
   806 
       
   807 /** 
       
   808  * Factory construction method.
       
   809  * @return Pointer to CPhbkAddEntryNumberWithDTMFTest object
       
   810  */
       
   811 CPhbkAddEntryNumberWithDTMFTest* CPhbkAddEntryNumberWithDTMFTest::NewL()
       
   812 	{
       
   813 	CPhbkAddEntryNumberWithDTMFTest* self = new(ELeave) CPhbkAddEntryNumberWithDTMFTest();
       
   814 	return self;
       
   815 	}
       
   816 
       
   817 /**
       
   818  *  Default constructor.  Each test step initialises it's own name.
       
   819  */
       
   820 CPhbkAddEntryNumberWithDTMFTest::CPhbkAddEntryNumberWithDTMFTest()
       
   821 	{
       
   822 	SetTestStepName(_L("AddEntryNumberWithDTMFTest"));
       
   823 	}
       
   824 
       
   825 /* Add sequence of ICC entries - Fill ICC */
       
   826 enum TVerdict CPhbkAddEntryNumberWithDTMFTest::doTestStepL()
       
   827 	{
       
   828 	SetSimTsyTestNumberL(19);
       
   829 	DoSyncL();
       
   830 	TRAPD(err,AddContactL(KTestName,KTestNumberWithDTMF,KUidIccGlobalAdnPhonebook)); 
       
   831 	TESTCHECKL(err, KErrNone); 
       
   832 	TRAP(err,AddContactL(KTestName,KTestNumberWithDTMF,KUidIccGlobalSdnPhonebook)); 
       
   833 	TESTCHECKL(err, KErrNone); 
       
   834 	TRAP(err,AddContactL(KTestName,KTestNumberWithDTMF,KUidIccGlobalLndPhonebook)); 
       
   835 	TESTCHECKL(err, KErrNone); 
       
   836 	TRAP(err,AddContactL(KTestName,KTestNumberWithDTMF,KUidUsimAppAdnPhonebook,KTestEMail)); 
       
   837 	TESTCHECKL(err, KErrNone); 
       
   838 	TRAP(err,AddContactL(KTestName,KTestNumberWithDTMF,KUidIccGlobalFdnPhonebook)); 
       
   839 	TESTCHECKL(err, KErrNone); 
       
   840 
       
   841 	return TestStepResult();
       
   842 	}
       
   843 
       
   844 
       
   845 /** 
       
   846  * Factory construction method.
       
   847  * @return Pointer to CPhbkAddEntryReadOnlyAccessTest object
       
   848  */
       
   849 CPhbkAddEntryReadOnlyAccessTest* CPhbkAddEntryReadOnlyAccessTest::NewL()
       
   850 	{
       
   851 	CPhbkAddEntryReadOnlyAccessTest* self = new(ELeave) CPhbkAddEntryReadOnlyAccessTest();
       
   852 	return self;
       
   853 	}
       
   854 
       
   855 /**
       
   856  *  Default constructor.  Each test step initialises it's own name.
       
   857  */
       
   858 CPhbkAddEntryReadOnlyAccessTest::CPhbkAddEntryReadOnlyAccessTest()
       
   859 	{
       
   860 	SetTestStepName(_L("AddEntryReadOnlyAccessTest"));
       
   861 	}
       
   862 
       
   863 /* Add an ICC entry to each of the supported phonebooks - read-only phonebook */
       
   864 enum TVerdict CPhbkAddEntryReadOnlyAccessTest::doTestStepL()
       
   865 	{
       
   866 	SetSimTsyTestNumberL(20);
       
   867 	DoSyncL();
       
   868 	TRAPD(err,AddContactL(KTestName,KTestNumber,KUidIccGlobalAdnPhonebook)); // valid fields
       
   869 	TESTCHECKL(err, KErrAccessDenied); // read-only access 
       
   870 	TRAP(err,AddContactL(KTestName,KTestNumber,KUidIccGlobalSdnPhonebook)); // valid fields
       
   871 	TESTCHECKL(err, KErrAccessDenied); // read-only access 
       
   872 	TRAP(err,AddContactL(KTestName,KTestNumber,KUidIccGlobalLndPhonebook)); // valid fields
       
   873 	TESTCHECKL(err, KErrAccessDenied); // read-only access 
       
   874 	TRAP(err,AddContactL(KTestName,KTestNumber,KUidUsimAppAdnPhonebook,KTestEMail)); // valid fields
       
   875 	TESTCHECKL(err, KErrAccessDenied); // read-only access 
       
   876 	TRAP(err,AddContactL(KTestName,KTestNumber,KUidIccGlobalFdnPhonebook)); // valid fields
       
   877 	TESTCHECKL(err, KErrAccessDenied); // read-only access 
       
   878 
       
   879 	return TestStepResult();
       
   880 	}
       
   881 
       
   882 
       
   883 /** 
       
   884  * Add a contact to the ICC & database.
       
   885  * @param aName Name
       
   886  * @param aNumber Phone number
       
   887  * @param aPhonebook Phonebook
       
   888  * @param aEMail Email address - only added to Usim phonebook
       
   889  */
       
   890 void CPhbkAddIntegrationTestBase::AddContactL(const TDesC& aName, const TDesC& aNumber, const TUid aPhonebook, const TDesC& aEMail)
       
   891 	{
       
   892 	TContactItemId templateId(iDb->ICCTemplateIdL(aPhonebook));
       
   893 	CContactItem* iccTemplate = iDb->ReadContactLC(templateId);
       
   894 	CContactICCEntry* entry = CContactICCEntry::NewL(*iccTemplate);
       
   895 	CleanupStack::PopAndDestroy(iccTemplate);
       
   896 	CleanupStack::PushL(entry);
       
   897 	AddTextFieldL(KUidContactFieldFamilyName,KUidContactFieldVCardMapUnusedN,aName,*entry);
       
   898 	AddTextFieldL(KUidContactFieldPhoneNumber,KUidContactFieldVCardMapTEL,aNumber,*entry);
       
   899 	if ((aPhonebook == KUidUsimAppAdnPhonebook) || (aPhonebook == KUidIccGlobalAdnPhonebook))
       
   900 		{
       
   901 		AddTextFieldL(KUidContactFieldEMail,KUidContactFieldVCardMapUnusedN,aEMail,*entry);
       
   902 		}
       
   903 	TContactItemId id(iDb->AddNewContactL(*entry)); 
       
   904 	CleanupStack::PopAndDestroy(entry);	
       
   905 	TESTCHECKCONDITIONL(id != KNullContactId);
       
   906 	}
       
   907 
       
   908 /**
       
   909  * Add a new text field (aField) to the CContactICCEntry supplied by aIccEntry. 
       
   910  * @param aFieldType Field type
       
   911  * @param aMapping Mapping for the field's content type
       
   912  * @param aField Field data
       
   913  * @param aIccEntry CContactICCEntry item
       
   914  */ 
       
   915 void CPhbkAddIntegrationTestBase::AddTextFieldL(TFieldType aFieldType, TUid aMapping, const TDesC& aField, CContactICCEntry& aIccEntry)
       
   916 	{
       
   917 	CContactItemFieldSet& fieldSet = aIccEntry.CardFields();
       
   918 	TInt pos = fieldSet.Find(aFieldType);
       
   919 	if (pos!=KErrNotFound)
       
   920 		{
       
   921 		CContactItemField& field=fieldSet[pos];
       
   922 		field.TextStorage()->SetTextL(aField);
       
   923 		}
       
   924 	else
       
   925 		{
       
   926 		CContactItemField* field=CContactItemField::NewLC(KStorageTypeText, aFieldType);
       
   927 		field->SetMapping(aMapping);
       
   928 		field->AddFieldTypeL(aFieldType); 
       
   929 		field->TextStorage()->SetTextL(aField);
       
   930 		aIccEntry.AddFieldL(*field);
       
   931 		CleanupStack::Pop(field); 
       
   932 		}
       
   933 	}
       
   934 
       
   935 /** 
       
   936  * Factory construction method.
       
   937  * @return Pointer to CPhbkAddAdditionalNumWithTagTest object
       
   938  */
       
   939 CPhbkAddAdditionalNumWithTagTest* CPhbkAddAdditionalNumWithTagTest::NewL()
       
   940 	{
       
   941 	CPhbkAddAdditionalNumWithTagTest* self = new(ELeave) CPhbkAddAdditionalNumWithTagTest();
       
   942 	return self;
       
   943 	}
       
   944 
       
   945 /**
       
   946  *  Default constructor.  Each test step initialises it's own name.
       
   947  */
       
   948 CPhbkAddAdditionalNumWithTagTest::CPhbkAddAdditionalNumWithTagTest()
       
   949 	{
       
   950 	SetTestStepName(_L("AddAdditionalNumWithTagTest"));
       
   951 	}
       
   952 
       
   953 /** 
       
   954  * Add contacts to the ICC & database with additional number plus alpha tag.
       
   955  */
       
   956 enum TVerdict CPhbkAddAdditionalNumWithTagTest::doTestStepL()
       
   957 	{
       
   958 	SetSimTsyTestNumberL(22);
       
   959 	DoSyncL();
       
   960 
       
   961 	// add additional entry for each type of number alpha tag
       
   962 	AddAdditionalNumEntryL(KTestAddNumber, KUidContactFieldVCardMapMSG);
       
   963 	AddAdditionalNumEntryL(KTestAddNumber, KUidContactFieldVCardMapVOICE);
       
   964 	AddAdditionalNumEntryL(KTestAddNumber, KUidContactFieldVCardMapFAX);
       
   965 	AddAdditionalNumEntryL(KTestAddNumber, KUidContactFieldVCardMapPREF);
       
   966 	AddAdditionalNumEntryL(KTestAddNumber, KUidContactFieldVCardMapCELL);
       
   967 	AddAdditionalNumEntryL(KTestAddNumber, KUidContactFieldVCardMapPAGER);
       
   968 	AddAdditionalNumEntryL(KTestAddNumber, KUidContactFieldVCardMapBBS);
       
   969 	AddAdditionalNumEntryL(KTestAddNumber, KUidContactFieldVCardMapMODEM);
       
   970 	AddAdditionalNumEntryL(KTestAddNumber, KUidContactFieldVCardMapCAR);
       
   971 	AddAdditionalNumEntryL(KTestAddNumber, KUidContactFieldVCardMapISDN);
       
   972 	AddAdditionalNumEntryL(KTestAddNumber, KUidContactFieldVCardMapVIDEO);
       
   973 
       
   974 	return TestStepResult();
       
   975 	}
       
   976 
       
   977 
       
   978 /** 
       
   979  * Add a contact with additional number plus alpha tag.
       
   980  */
       
   981 void CPhbkAddIntegrationTestBase::AddAdditionalNumEntryL(const TDesC& aFieldNum, const TUid aFieldType)
       
   982 	{
       
   983 	TContactItemId templateId(iDb->ICCTemplateIdL(KUidUsimAppAdnPhonebook));
       
   984 	CContactItem* iccTemplate = iDb->ReadContactLC(templateId);
       
   985 	CContactICCEntry* entry = CContactICCEntry::NewL(*iccTemplate);
       
   986 	CleanupStack::PopAndDestroy(iccTemplate);
       
   987 	CleanupStack::PushL(entry);
       
   988 
       
   989 	// create typical USIM App entry
       
   990 	AddTextFieldL(KUidContactFieldFamilyName, KUidContactFieldVCardMapUnusedN, KTestName, *entry);
       
   991 	AddTextFieldL(KUidContactFieldPhoneNumber, KUidContactFieldVCardMapTEL, KTestNumber, *entry);
       
   992 	AddTextFieldL(KUidContactFieldEMail, KUidContactFieldVCardMapUnusedN, KTestEMail, *entry);
       
   993 
       
   994 	// add additional number with alpha tag
       
   995 	CContactItemField* field=CContactItemField::NewLC(KStorageTypeText, KUidContactFieldPhoneNumber);
       
   996 	field->SetMapping(KUidContactFieldVCardMapTEL);
       
   997 	field->AddFieldTypeL(KUidContactFieldPhoneNumber); 
       
   998 	field->TextStorage()->SetTextL(aFieldNum);
       
   999 	field->AddFieldTypeL(aFieldType); 
       
  1000 	entry->AddFieldL(*field);
       
  1001 	CleanupStack::Pop(field); 
       
  1002 
       
  1003 	TContactItemId id(iDb->AddNewContactL(*entry)); 
       
  1004 	CleanupStack::PopAndDestroy(entry);	
       
  1005 	TESTCHECKCONDITIONL(id != KNullContactId);
       
  1006 
       
  1007 	// check additional entry has the additional number
       
  1008 	CContactItem* newEntry = static_cast <CContactICCEntry*> (iDb->ReadContactLC(id));
       
  1009 	TESTCHECKCONDITIONL(newEntry != NULL);
       
  1010 	CContactItemFieldSet& fieldSet = newEntry->CardFields();
       
  1011 	TInt pos = fieldSet.Find(aFieldType);
       
  1012 	TESTCHECKCONDITIONL(pos != KErrNotFound);
       
  1013 	CleanupStack::PopAndDestroy(newEntry);	
       
  1014 
       
  1015 	}
       
  1016 
       
  1017 
       
  1018 /** 
       
  1019  * Factory construction method.
       
  1020  * @return Pointer to CPhbkAddEntryWithNoTemplateTest object
       
  1021  */
       
  1022 CPhbkAddEntryWithNoTemplateTest* CPhbkAddEntryWithNoTemplateTest::NewL()
       
  1023 	{
       
  1024 	CPhbkAddEntryWithNoTemplateTest* self = new(ELeave) CPhbkAddEntryWithNoTemplateTest();
       
  1025 	return self;
       
  1026 	}
       
  1027 
       
  1028 /**
       
  1029  *  Default constructor.  Each test step initialises its own name.
       
  1030  */
       
  1031 CPhbkAddEntryWithNoTemplateTest::CPhbkAddEntryWithNoTemplateTest()
       
  1032 	{
       
  1033 	SetTestStepName(_L("AddEntryWithNoTemplateTest"));
       
  1034 	}
       
  1035 
       
  1036 /** 
       
  1037  *  Create contact group with zero as template ID, and add a contact to it.
       
  1038  */
       
  1039 enum TVerdict CPhbkAddEntryWithNoTemplateTest::doTestStepL()
       
  1040 	{
       
  1041 
       
  1042 	//
       
  1043 	// delete ini file
       
  1044 	//
       
  1045 	
       
  1046 	INFO_PRINTF1(_L("Deleting phonefile"));
       
  1047 	_LIT(KPhbkSyncIniFile,"C:\\Private\\102030A1\\Phbksync.ini");
       
  1048 	RFs fs;
       
  1049 	TInt err = fs.Connect();
       
  1050 	TESTCHECKL(err, KErrNone);
       
  1051 	err=fs.Delete(KPhbkSyncIniFile);
       
  1052 	fs.Close();	
       
  1053 
       
  1054 	//
       
  1055 	// add a new contact to a group with template id zero
       
  1056 	//
       
  1057 	CContactItem* group = iDb->CreateContactGroupLC();
       
  1058 	group->SetTemplateRefId(0);
       
  1059 
       
  1060 	CContactICCEntry* contact = NULL;
       
  1061 	CreateContactLC(contact, KUidIccGlobalAdnPhonebook,KTestName,KTestNumber, KTestEMail);
       
  1062 
       
  1063 	iDb->AddContactToGroupL(*contact,*group);
       
  1064 
       
  1065 	CleanupStack::PopAndDestroy(2,group);
       
  1066 
       
  1067 	//
       
  1068 	// force a creation of the phonebooks (including a call to CSyncEngineServer::CreateGroupIdL)
       
  1069 	//
       
  1070 	ConfigurePhbkSyncToIdleL();
       
  1071 	ConfigurePhbkSyncToFullL();
       
  1072 
       
  1073 	return TestStepResult();
       
  1074 }
       
  1075  
       
  1076 void CPhbkAddIntegrationTestBase::CreateContactLC(CContactICCEntry*& aEntry, const TUid aPhonebook, const TDesC& aName, const TDesC& aNumber, const TDesC& aEmail)
       
  1077 	{
       
  1078 	TContactItemId templateId(iDb->ICCTemplateIdL(aPhonebook));
       
  1079 	CContactItem* iccTemplate = iDb->ReadContactLC(templateId);
       
  1080 	aEntry = CContactICCEntry::NewL(*iccTemplate);
       
  1081 	CleanupStack::PopAndDestroy(iccTemplate);
       
  1082 	CleanupStack::PushL(aEntry);
       
  1083 
       
  1084 	AddTextFieldL(KUidContactFieldFamilyName,KUidContactFieldVCardMapUnusedN,aName,*aEntry);
       
  1085 	AddTextFieldL(KUidContactFieldPhoneNumber,KUidContactFieldVCardMapTEL,aNumber,*aEntry);
       
  1086 	if ((aPhonebook == KUidUsimAppAdnPhonebook) || (aPhonebook == KUidIccGlobalAdnPhonebook))
       
  1087 		{
       
  1088 		AddTextFieldL(KUidContactFieldEMail,KUidContactFieldVCardMapUnusedN,aEmail,*aEntry);
       
  1089 		}
       
  1090 	}