pimprotocols/phonebooksync/Test/TE_cntsync/te_cntsyncedit.cpp
changeset 0 e686773b3f54
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 // Copyright (c) 2004-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 #include <exterror.h>
       
    18 
       
    19 #include "te_cntsyncbase.h"
       
    20 #include "te_cntsyncedit.h"
       
    21 
       
    22 _LIT(KModifiedNameInADN,  "ADN Modified Name");
       
    23 _LIT(KModifiedNameInSDN,  "SDN Modified Name");
       
    24 _LIT(KModifiedNameInLND,  "LND Modified Name");
       
    25 _LIT(KModifiedNameInUsim, "Usim Modified Name");
       
    26 _LIT(KModifiedNameInFDN,  "FDN Modified Name");
       
    27 
       
    28 _LIT(KModifiedNumberInADN, "05050505050505");
       
    29 _LIT(KModifiedNumberInSDN, "15151515151515");
       
    30 _LIT(KModifiedNumberInLND, "25252525252525");
       
    31 _LIT(KModifiedNumberInUsim,"35353535353535");
       
    32 _LIT(KModifiedNumberInFDN, "45454545454545");
       
    33 
       
    34 _LIT(KModifiedEmailInUsim,"modEmail@moddomain");
       
    35 
       
    36 _LIT(KModifiedNameExceeded,"ABChfjdhfjhdfjhjfhjdhfjhfjhd");
       
    37 _LIT(KModifiedNumberExceeded,"02020300000222222222222222222222220000032232222222222222323");
       
    38  
       
    39 _LIT(KTestEmpty,"");
       
    40 
       
    41 _LIT(KModifiedEmptyNameInADN, "ADN Modified Empty");
       
    42 _LIT(KModifiedEmptyNameInSDN, "SDN Modified Empty");
       
    43 _LIT(KModifiedEmptyNameInLND, "LND Modified Empty");
       
    44 _LIT(KModifiedEmptyNameInUsim,"Usim Modified Empty");
       
    45 _LIT(KModifiedEmptyNameInFDN, "FDN Modified Empty");
       
    46 
       
    47 _LIT(KModifiedEmptyNumberInADN, "00000007878");
       
    48 _LIT(KModifiedEmptyNumberInSDN, "11111117878");
       
    49 _LIT(KModifiedEmptyNumberInLND, "22222227878");
       
    50 _LIT(KModifiedEmptyNumberInUsim,"33333337878");
       
    51 _LIT(KModifiedEmptyNumberInFDN, "44444447878");
       
    52 
       
    53 _LIT(KModifiedEmptyEmailInUsim,"modEmptyEmail@modEmptydomain");
       
    54 
       
    55 
       
    56 /** 
       
    57  * Factory construction method.
       
    58  * @return Pointer to CPhbkOpenICCContactTest object
       
    59  */
       
    60 CPhbkOpenICCContactTest* CPhbkOpenICCContactTest::NewL()
       
    61 	{
       
    62 	CPhbkOpenICCContactTest* self = new(ELeave) CPhbkOpenICCContactTest();
       
    63 	return self;
       
    64 	}
       
    65 
       
    66 /**
       
    67  *  Default constructor.  Each test step initialises it's own name.
       
    68  */
       
    69 CPhbkOpenICCContactTest::CPhbkOpenICCContactTest()
       
    70 	{
       
    71 	SetTestStepName(_L("OpenICCContactTest"));
       
    72 	}
       
    73 
       
    74 /** Open an ICC entry for edit - normal case */
       
    75 enum TVerdict CPhbkOpenICCContactTest::doTestStepL()
       
    76 	{
       
    77 	SetSimTsyTestNumberL(0);
       
    78 	DoSyncL();
       
    79 	// Edited fields are NOT committed to database, hence EFalse
       
    80 	OpenContactEditFieldsL(KUidIccGlobalAdnPhonebook, 0, EFalse, KModifiedNameInADN, KModifiedNumberInADN);
       
    81 	OpenContactEditFieldsL(KUidIccGlobalSdnPhonebook, 0, EFalse, KModifiedNameInSDN, KModifiedNumberInSDN);
       
    82 	OpenContactEditFieldsL(KUidIccGlobalLndPhonebook, 0, EFalse, KModifiedNameInLND, KModifiedNumberInLND);
       
    83 	OpenContactEditFieldsL(KUidUsimAppAdnPhonebook, 0, EFalse, KModifiedNameInUsim, KModifiedNumberInUsim, KModifiedEmailInUsim);
       
    84 	OpenContactEditFieldsL(KUidIccGlobalFdnPhonebook, 0, EFalse, KModifiedNameInFDN, KModifiedNumberInFDN);
       
    85 
       
    86 	return TestStepResult();
       
    87 	}
       
    88 
       
    89 
       
    90 /** 
       
    91  * Factory construction method.
       
    92  * @return Pointer to CPhbkOpenContactInvalidUIDTest object
       
    93  */
       
    94 CPhbkOpenContactInvalidUIDTest* CPhbkOpenContactInvalidUIDTest::NewL()
       
    95 	{
       
    96 	CPhbkOpenContactInvalidUIDTest* self = new(ELeave) CPhbkOpenContactInvalidUIDTest();
       
    97 	return self;
       
    98 	}
       
    99 
       
   100 /**
       
   101  *  Default constructor.  Each test step initialises it's own name.
       
   102  */
       
   103 CPhbkOpenContactInvalidUIDTest::CPhbkOpenContactInvalidUIDTest()
       
   104 	{
       
   105 	SetTestStepName(_L("OpenContactInvalidUIDTest"));
       
   106 	}
       
   107 
       
   108 /** Open an ICC entry for edit - invalid UID */
       
   109 enum TVerdict CPhbkOpenContactInvalidUIDTest::doTestStepL()
       
   110 	{
       
   111 	TContactItemId id(-7); // Negative UID
       
   112 	TRAPD(err, iDb->OpenContactLX(id));
       
   113 	TESTCHECKL(err, KErrNotFound);
       
   114 
       
   115 	return TestStepResult();
       
   116 	}
       
   117 
       
   118 
       
   119 /** 
       
   120  * Factory construction method.
       
   121  * @return Pointer to CPhbkEditICCContactTest object
       
   122  */
       
   123 CPhbkEditICCContactTest* CPhbkEditICCContactTest::NewL()
       
   124 	{
       
   125 	CPhbkEditICCContactTest* self = new(ELeave) CPhbkEditICCContactTest();
       
   126 	return self;
       
   127 	}
       
   128 
       
   129 /**
       
   130  *  Default constructor.  Each test step initialises it's own name.
       
   131  */
       
   132 CPhbkEditICCContactTest::CPhbkEditICCContactTest()
       
   133 	{
       
   134 	SetTestStepName(_L("EditICCContactTest"));
       
   135 	}
       
   136 
       
   137 /** Edit an ICC entry - normal case */
       
   138 enum TVerdict CPhbkEditICCContactTest::doTestStepL()
       
   139 	{
       
   140 	SetSimTsyTestNumberL(0);
       
   141 	DoSyncL();
       
   142 	// Edited fields are committed to database, hence ETrue
       
   143 	OpenContactEditFieldsL(KUidIccGlobalAdnPhonebook, 0, ETrue, KModifiedNameInADN, KModifiedNumberInADN);
       
   144 	OpenContactEditFieldsL(KUidIccGlobalSdnPhonebook, 0, ETrue, KModifiedNameInSDN, KModifiedNumberInSDN);
       
   145 	OpenContactEditFieldsL(KUidIccGlobalLndPhonebook, 0, ETrue, KModifiedNameInLND, KModifiedNumberInLND);
       
   146 	OpenContactEditFieldsL(KUidUsimAppAdnPhonebook, 0, ETrue, KModifiedNameInUsim, KModifiedNumberInUsim, KModifiedEmailInUsim);
       
   147 	OpenContactEditFieldsL(KUidIccGlobalFdnPhonebook, 0, ETrue, KModifiedNameInFDN, KModifiedNumberInFDN);
       
   148 
       
   149 	return TestStepResult();
       
   150 	}
       
   151 
       
   152 /** 
       
   153  * Factory construction method.
       
   154  * @return Pointer to CPhbkEditICCContactTwiceTest object
       
   155  */
       
   156 CPhbkEditICCContactTwiceTest* CPhbkEditICCContactTwiceTest::NewL()
       
   157 	{
       
   158 	CPhbkEditICCContactTwiceTest* self = new(ELeave) CPhbkEditICCContactTwiceTest();
       
   159 	return self;
       
   160 	}
       
   161 
       
   162 /**
       
   163  *  Default constructor.  Each test step initialises it's own name.
       
   164  */
       
   165 CPhbkEditICCContactTwiceTest::CPhbkEditICCContactTwiceTest()
       
   166 	{
       
   167 	SetTestStepName(_L("EditICCContactTwiceTest"));
       
   168 	}
       
   169 
       
   170 /** Edit an ICC entry twice */
       
   171 enum TVerdict CPhbkEditICCContactTwiceTest::doTestStepL()
       
   172 	{
       
   173 	// close existing phbksync session and contact database
       
   174 	delete iDb;
       
   175 	iDb=NULL;
       
   176 	iSession.Close();
       
   177 	ConfigurePhbkSyncToIdleL();
       
   178 	User::After(3000000); //3 second wait for contact to shut down
       
   179 
       
   180 	// Mark the heap before re-starting and performing two edits
       
   181 	__UHEAP_MARK;
       
   182 
       
   183 	ConfigurePhbkSyncToFullL();
       
   184 	User::LeaveIfError(iSession.Connect());
       
   185 	User::After(3000000); //3 second wait for server to start
       
   186 	iDb = OpenOrCreateContactDatabaseL();
       
   187 	User::After(3000000); //3 second wait for contact to start the phbk server
       
   188 	DoSyncL(); // synchronise
       
   189 
       
   190 	// Edit entry for each phonebook - note these are committed to database, hence ETrue
       
   191 	OpenContactEditFieldsL(KUidIccGlobalAdnPhonebook, 0, ETrue, KModifiedNameInADN, KModifiedNumberInADN);
       
   192 	OpenContactEditFieldsL(KUidIccGlobalSdnPhonebook, 0, ETrue, KModifiedNameInSDN, KModifiedNumberInSDN);
       
   193 	OpenContactEditFieldsL(KUidIccGlobalLndPhonebook, 0, ETrue, KModifiedNameInLND, KModifiedNumberInLND);
       
   194 	OpenContactEditFieldsL(KUidUsimAppAdnPhonebook, 0, ETrue, KModifiedNameInUsim, KModifiedNumberInUsim, KModifiedEmailInUsim);
       
   195 	OpenContactEditFieldsL(KUidIccGlobalFdnPhonebook, 0, ETrue, KModifiedNameInFDN, KModifiedNumberInFDN);
       
   196 
       
   197 	// Edit same entries again (using different name to ensure entry is changed)
       
   198 	OpenContactEditFieldsL(KUidIccGlobalAdnPhonebook, 0, ETrue, KModifiedEmptyNameInADN, KModifiedNumberInADN);
       
   199 	OpenContactEditFieldsL(KUidIccGlobalSdnPhonebook, 0, ETrue, KModifiedEmptyNameInSDN, KModifiedNumberInSDN);
       
   200 	OpenContactEditFieldsL(KUidIccGlobalLndPhonebook, 0, ETrue, KModifiedEmptyNameInLND, KModifiedNumberInLND);
       
   201 	OpenContactEditFieldsL(KUidUsimAppAdnPhonebook, 0, ETrue, KModifiedEmptyNameInUsim, KModifiedNumberInUsim, KModifiedEmailInUsim);
       
   202 	OpenContactEditFieldsL(KUidIccGlobalFdnPhonebook, 0, ETrue, KModifiedEmptyNameInFDN, KModifiedNumberInFDN);
       
   203 
       
   204 	// close existing phbksync session and contact database
       
   205 	delete iDb;
       
   206 	iDb=NULL;
       
   207 	iSession.Close();
       
   208 	ConfigurePhbkSyncToIdleL();
       
   209 	User::After(3000000); //3 second wait for contact to shut down
       
   210 
       
   211 	// Test the heap is okay
       
   212 	__UHEAP_MARKEND;
       
   213 	ConfigurePhbkSyncToFullL();
       
   214 	User::LeaveIfError(iSession.Connect());
       
   215 	User::After(3000000); //3 second wait for server to start
       
   216 
       
   217 	return TestStepResult();
       
   218 	}
       
   219 
       
   220 
       
   221 /** 
       
   222  * Factory construction method.
       
   223  * @return Pointer to CPhbkEditContactEmptyNameTest object
       
   224  */
       
   225 CPhbkEditContactEmptyNameTest* CPhbkEditContactEmptyNameTest::NewL()
       
   226 	{
       
   227 	CPhbkEditContactEmptyNameTest* self = new(ELeave) CPhbkEditContactEmptyNameTest();
       
   228 	return self;
       
   229 	}
       
   230 
       
   231 /**
       
   232  *  Default constructor.  Each test step initialises it's own name.
       
   233  */
       
   234 CPhbkEditContactEmptyNameTest::CPhbkEditContactEmptyNameTest()
       
   235 	{
       
   236 	SetTestStepName(_L("EditContactEmptyNameTest"));
       
   237 	}
       
   238 
       
   239 /** Edit an ICC entry - empty name field */
       
   240 enum TVerdict CPhbkEditContactEmptyNameTest::doTestStepL()
       
   241 	{
       
   242 	SetSimTsyTestNumberL(1);
       
   243 	DoSyncL();
       
   244 
       
   245 	// Edited fields are committed to database, hence ETrue
       
   246 	OpenContactEditFieldsL(KUidIccGlobalAdnPhonebook, 4, ETrue, KTestEmpty, KModifiedNumberInADN);
       
   247 	OpenContactEditFieldsL(KUidIccGlobalSdnPhonebook, 4, ETrue, KTestEmpty, KModifiedNumberInSDN);
       
   248 	OpenContactEditFieldsL(KUidIccGlobalLndPhonebook, 4, ETrue, KTestEmpty, KModifiedNumberInLND);
       
   249 	OpenContactEditFieldsL(KUidUsimAppAdnPhonebook, 4, ETrue, KTestEmpty, KModifiedNumberInUsim, KModifiedEmailInUsim);
       
   250 	OpenContactEditFieldsL(KUidIccGlobalFdnPhonebook, 4, ETrue, KTestEmpty, KModifiedNumberInFDN);
       
   251 
       
   252 	return TestStepResult();
       
   253 	}
       
   254 
       
   255 
       
   256 /** 
       
   257  * Factory construction method.
       
   258  * @return Pointer to CPhbkEditContactEmptyNumberTest object
       
   259  */
       
   260 CPhbkEditContactEmptyNumberTest* CPhbkEditContactEmptyNumberTest::NewL()
       
   261 	{
       
   262 	CPhbkEditContactEmptyNumberTest* self = new(ELeave) CPhbkEditContactEmptyNumberTest();
       
   263 	return self;
       
   264 	}
       
   265 
       
   266 /**
       
   267  *  Default constructor.  Each test step initialises it's own name.
       
   268  */
       
   269 CPhbkEditContactEmptyNumberTest::CPhbkEditContactEmptyNumberTest()
       
   270 	{
       
   271 	SetTestStepName(_L("EditContactEmptyNumberTest"));
       
   272 	}
       
   273 
       
   274 /** Edit an ICC entry - empty number field */
       
   275 enum TVerdict CPhbkEditContactEmptyNumberTest::doTestStepL()
       
   276 	{
       
   277 	SetSimTsyTestNumberL(1);
       
   278 	DoSyncL();
       
   279 
       
   280 	// Edited fields are committed to database, hence ETrue
       
   281 	OpenContactEditFieldsL(KUidIccGlobalAdnPhonebook, 3, ETrue, KModifiedNameInADN, KTestEmpty);
       
   282 	OpenContactEditFieldsL(KUidIccGlobalSdnPhonebook, 3, ETrue, KModifiedNameInSDN, KTestEmpty);
       
   283 	OpenContactEditFieldsL(KUidIccGlobalLndPhonebook, 3, ETrue, KModifiedNameInLND, KTestEmpty);
       
   284 	OpenContactEditFieldsL(KUidUsimAppAdnPhonebook, 3, ETrue, KModifiedNameInUsim, KTestEmpty, KModifiedEmailInUsim);
       
   285 	OpenContactEditFieldsL(KUidIccGlobalFdnPhonebook, 3, ETrue, KModifiedNameInFDN, KTestEmpty);
       
   286 
       
   287 	return TestStepResult();
       
   288 	}
       
   289 
       
   290 
       
   291 /** 
       
   292  * Factory construction method.
       
   293  * @return Pointer to CPhbkEditContactNameExceededTest object
       
   294  */
       
   295 CPhbkEditContactNameExceededTest* CPhbkEditContactNameExceededTest::NewL()
       
   296 	{
       
   297 	CPhbkEditContactNameExceededTest* self = new(ELeave) CPhbkEditContactNameExceededTest();
       
   298 	return self;
       
   299 	}
       
   300 
       
   301 /**
       
   302  *  Default constructor.  Each test step initialises it's own name.
       
   303  */
       
   304 CPhbkEditContactNameExceededTest::CPhbkEditContactNameExceededTest()
       
   305 	{
       
   306 	SetTestStepName(_L("EditContactNameExceededTest"));
       
   307 	}
       
   308 
       
   309 /** Edit an ICC entry - name boundary condition exceeded */
       
   310 enum TVerdict CPhbkEditContactNameExceededTest::doTestStepL()
       
   311 	{
       
   312 	SetSimTsyTestNumberL(0);
       
   313 	DoSyncL();
       
   314 	
       
   315 	// Edited fields are committed to database, hence ETrue
       
   316 	TRAPD(err, OpenContactEditFieldsL(KUidIccGlobalAdnPhonebook, 0, ETrue, KModifiedNameExceeded, KModifiedNumberInADN));
       
   317 	TESTCHECKL(err, KErrPhonebookTextOverflow);
       
   318 
       
   319 	TRAP(err, OpenContactEditFieldsL(KUidIccGlobalSdnPhonebook, 0, ETrue, KModifiedNameExceeded, KModifiedNumberInSDN));
       
   320 	TESTCHECKL(err, KErrPhonebookTextOverflow);
       
   321 
       
   322 	TRAP(err, OpenContactEditFieldsL(KUidIccGlobalLndPhonebook, 0, ETrue, KModifiedNameExceeded, KModifiedNumberInLND));
       
   323 	TESTCHECKL(err, KErrPhonebookTextOverflow);
       
   324 
       
   325 	TRAP(err, OpenContactEditFieldsL(KUidUsimAppAdnPhonebook, 0, ETrue, KModifiedNameExceeded, KModifiedNumberInUsim, KModifiedEmailInUsim));
       
   326 	TESTCHECKL(err, KErrPhonebookTextOverflow);
       
   327 
       
   328 	TRAP(err, OpenContactEditFieldsL(KUidIccGlobalFdnPhonebook, 0, ETrue, KModifiedNameExceeded, KModifiedNumberInFDN));
       
   329 	TESTCHECKL(err, KErrPhonebookTextOverflow);
       
   330 
       
   331 	return TestStepResult();
       
   332 	}
       
   333 
       
   334 
       
   335 /** 
       
   336  * Factory construction method.
       
   337  * @return Pointer to CPhbkEditContactNumberExceededTest object
       
   338  */
       
   339 CPhbkEditContactNumberExceededTest* CPhbkEditContactNumberExceededTest::NewL()
       
   340 	{
       
   341 	CPhbkEditContactNumberExceededTest* self = new(ELeave) CPhbkEditContactNumberExceededTest();
       
   342 	return self;
       
   343 	}
       
   344 
       
   345 /**
       
   346  *  Default constructor.  Each test step initialises it's own name.
       
   347  */
       
   348 CPhbkEditContactNumberExceededTest::CPhbkEditContactNumberExceededTest()
       
   349 	{
       
   350 	SetTestStepName(_L("EditContactNumberExceededTest"));
       
   351 	}
       
   352 
       
   353 /** Edit an ICC entry - number boundary condition exceeded */
       
   354 enum TVerdict CPhbkEditContactNumberExceededTest::doTestStepL()
       
   355 	{
       
   356 	SetSimTsyTestNumberL(0);
       
   357 	DoSyncL();
       
   358 	// Edited fields are committed to database, hence ETrue
       
   359 	TRAPD(err, OpenContactEditFieldsL(KUidIccGlobalAdnPhonebook, 0, ETrue, KModifiedNameInADN, KModifiedNumberExceeded));
       
   360 	TESTCHECKL(err, KErrPhonebookNumberOverflow);
       
   361 
       
   362 	TRAP(err, OpenContactEditFieldsL(KUidIccGlobalSdnPhonebook, 0, ETrue, KModifiedNameInSDN, KModifiedNumberExceeded));
       
   363 	TESTCHECKL(err, KErrPhonebookNumberOverflow);
       
   364 
       
   365 	TRAP(err, OpenContactEditFieldsL(KUidIccGlobalLndPhonebook, 0, ETrue, KModifiedNameInLND, KModifiedNumberExceeded));
       
   366 	TESTCHECKL(err, KErrPhonebookNumberOverflow);
       
   367 
       
   368 	TRAP(err, OpenContactEditFieldsL(KUidUsimAppAdnPhonebook, 0, ETrue, KModifiedNameInUsim, KModifiedNumberExceeded, KModifiedEmailInUsim));
       
   369 	TESTCHECKL(err, KErrPhonebookNumberOverflow);
       
   370 
       
   371 	TRAP(err, OpenContactEditFieldsL(KUidIccGlobalFdnPhonebook, 0, ETrue, KModifiedNameInFDN, KModifiedNumberExceeded));
       
   372 	TESTCHECKL(err, KErrPhonebookNumberOverflow);
       
   373 
       
   374 	return TestStepResult();
       
   375 	}
       
   376 
       
   377 
       
   378 /** 
       
   379  * Factory construction method.
       
   380  * @return Pointer to CPhbkEditContactICCLockedTest object
       
   381  */
       
   382 CPhbkEditContactICCLockedTest* CPhbkEditContactICCLockedTest::NewL()
       
   383 	{
       
   384 	CPhbkEditContactICCLockedTest* self = new(ELeave) CPhbkEditContactICCLockedTest();
       
   385 	return self;
       
   386 	}
       
   387 
       
   388 /**
       
   389  *  Default constructor.  Each test step initialises it's own name.
       
   390  */
       
   391 CPhbkEditContactICCLockedTest::CPhbkEditContactICCLockedTest()
       
   392 	{
       
   393 	SetTestStepName(_L("EditContactICCLockedTest"));
       
   394 	}
       
   395 
       
   396 /** Edit an ICC entry - ICC locked */
       
   397 enum TVerdict CPhbkEditContactICCLockedTest::doTestStepL()
       
   398 	{
       
   399 	SetSimTsyTestNumberL(2);
       
   400 	DoSyncL();
       
   401 
       
   402 	OpenContactEditLockedL(KUidIccGlobalAdnPhonebook, 4, KModifiedNumberInADN);
       
   403 	OpenContactEditLockedL(KUidIccGlobalSdnPhonebook, 4, KModifiedNumberInSDN);
       
   404 	OpenContactEditLockedL(KUidIccGlobalLndPhonebook, 4, KModifiedNumberInLND);
       
   405 	OpenContactEditLockedL(KUidUsimAppAdnPhonebook, 4, KModifiedNumberInUsim);
       
   406 
       
   407 	return TestStepResult();
       
   408 	}
       
   409 
       
   410 
       
   411 /** 
       
   412  * Factory construction method.
       
   413  * @return Pointer to CPhbkEditContactICCWriteFailsTest object
       
   414  */
       
   415 CPhbkEditContactICCWriteFailsTest* CPhbkEditContactICCWriteFailsTest::NewL()
       
   416 	{
       
   417 	CPhbkEditContactICCWriteFailsTest* self = new(ELeave) CPhbkEditContactICCWriteFailsTest();
       
   418 	return self;
       
   419 	}
       
   420 
       
   421 /**
       
   422  *  Default constructor.  Each test step initialises it's own name.
       
   423  */
       
   424 CPhbkEditContactICCWriteFailsTest::CPhbkEditContactICCWriteFailsTest()
       
   425 	{
       
   426 	SetTestStepName(_L("EditContactICCWriteFailsTest"));
       
   427 	}
       
   428 
       
   429 /** Edit an ICC entry - ICC write fails */
       
   430 enum TVerdict CPhbkEditContactICCWriteFailsTest::doTestStepL()
       
   431 	{
       
   432 	SetSimTsyTestNumberL(4);
       
   433 	DoSyncL();
       
   434 
       
   435 	// Edited fields are committed to database, hence ETrue
       
   436 	TRAPD(err, OpenContactEditFieldsL(KUidIccGlobalAdnPhonebook, 0, ETrue, KModifiedNameInADN, KModifiedNumberInADN));
       
   437 	TESTCHECKL(err, KErrBadHandle);
       
   438 
       
   439 	TRAP(err, OpenContactEditFieldsL(KUidIccGlobalSdnPhonebook, 0, ETrue, KModifiedNameInSDN, KModifiedNumberInSDN));
       
   440 	TESTCHECKL(err, KErrBadHandle);
       
   441 
       
   442 	TRAP(err, OpenContactEditFieldsL(KUidIccGlobalLndPhonebook, 0, ETrue, KModifiedNameInLND, KModifiedNumberInLND));
       
   443 	TESTCHECKL(err, KErrBadHandle);
       
   444 
       
   445 	TRAP(err, OpenContactEditFieldsL(KUidUsimAppAdnPhonebook, 0, ETrue, KModifiedNameInUsim, KModifiedNumberInUsim, KModifiedEmailInUsim));
       
   446 	TESTCHECKL(err, KErrBadHandle);
       
   447 
       
   448 	TRAP(err, OpenContactEditFieldsL(KUidIccGlobalFdnPhonebook, 0, ETrue, KModifiedNameInFDN, KModifiedNumberInFDN));
       
   449 	TESTCHECKL(err, KErrBadHandle);
       
   450 
       
   451 	return TestStepResult();
       
   452 	}
       
   453 
       
   454 
       
   455 /** 
       
   456  * Factory construction method.
       
   457  * @return Pointer to CPhbkEditContactEmptyFieldsTest object
       
   458  */
       
   459 CPhbkEditContactEmptyFieldsTest* CPhbkEditContactEmptyFieldsTest::NewL()
       
   460 	{
       
   461 	CPhbkEditContactEmptyFieldsTest* self = new(ELeave) CPhbkEditContactEmptyFieldsTest();
       
   462 	return self;
       
   463 	}
       
   464 
       
   465 /**
       
   466  *  Default constructor.  Each test step initialises it's own name.
       
   467  */
       
   468 CPhbkEditContactEmptyFieldsTest::CPhbkEditContactEmptyFieldsTest()
       
   469 	{
       
   470 	SetTestStepName(_L("EditContactEmptyFieldsTest"));
       
   471 	}
       
   472 
       
   473 /** Open and Edit an ICC entry - empty name and number fields */
       
   474 enum TVerdict CPhbkEditContactEmptyFieldsTest::doTestStepL()
       
   475 	{
       
   476 	SetSimTsyTestNumberL(6);
       
   477 	DoSyncL();
       
   478 
       
   479 	// *
       
   480 	// * MJH  - 12 Sept 2002
       
   481 	// * Assumptions for test data:
       
   482 	// * 
       
   483 	// * The fifth entry for each phonebook has no name
       
   484 	// * The sixth entry for each phonebook has no number
       
   485 	// * The sixth entry for Usim App ADN phonebook has no email
       
   486 	// * 
       
   487 
       
   488 	// Edited fields are NOT committed to database, hence EFalse
       
   489 	OpenContactEditFieldsL(KUidIccGlobalAdnPhonebook, 4, EFalse, KModifiedEmptyNameInADN, KModifiedEmptyNumberInADN);
       
   490 	OpenContactEditFieldsL(KUidIccGlobalSdnPhonebook, 4, EFalse, KModifiedEmptyNameInSDN, KModifiedEmptyNumberInSDN);
       
   491 	OpenContactEditFieldsL(KUidIccGlobalLndPhonebook, 4, EFalse, KModifiedEmptyNameInLND, KModifiedEmptyNumberInLND);
       
   492 	OpenContactEditFieldsL(KUidUsimAppAdnPhonebook, 4, EFalse, KModifiedEmptyNameInUsim, KModifiedEmptyNumberInUsim, KModifiedEmptyEmailInUsim);
       
   493 	OpenContactEditFieldsL(KUidIccGlobalFdnPhonebook, 4, EFalse, KModifiedEmptyNameInFDN, KModifiedEmptyNumberInFDN);
       
   494 
       
   495 	return TestStepResult();
       
   496 	}
       
   497 
       
   498 
       
   499 /** 
       
   500  * Factory construction method.
       
   501  * @return Pointer to CPhbkEditSlotWriteTest object
       
   502  */
       
   503 CPhbkEditSlotWriteTest* CPhbkEditSlotWriteTest::NewL()
       
   504 	{
       
   505 	CPhbkEditSlotWriteTest* self = new(ELeave) CPhbkEditSlotWriteTest();
       
   506 	return self;
       
   507 	}
       
   508 
       
   509 /**
       
   510  *  Default constructor.  Each test step initialises it's own name.
       
   511  */
       
   512 CPhbkEditSlotWriteTest::CPhbkEditSlotWriteTest()
       
   513 	{
       
   514 	SetTestStepName(_L("EditSlotWriteTest"));
       
   515 	}
       
   516 
       
   517 /** Edit entry based on slot number */
       
   518 enum TVerdict CPhbkEditSlotWriteTest::doTestStepL()
       
   519 	{
       
   520 	SetSimTsyTestNumberL(21);
       
   521 	DoSyncL();
       
   522 
       
   523 	CheckEditSlotWriteL(KUidIccGlobalAdnPhonebook);
       
   524 	CheckEditSlotWriteL(KUidIccGlobalSdnPhonebook);
       
   525 	CheckEditSlotWriteL(KUidIccGlobalLndPhonebook);
       
   526 	CheckEditSlotWriteL(KUidUsimAppAdnPhonebook);
       
   527 	CheckEditSlotWriteL(KUidIccGlobalFdnPhonebook);
       
   528 
       
   529 	return TestStepResult();
       
   530 	}
       
   531 
       
   532 
       
   533 /** 
       
   534  * Factory construction method.
       
   535  * @return Pointer to CPhbkOpenContactICCLockedTest object
       
   536  */
       
   537 CPhbkOpenContactICCLockedTest* CPhbkOpenContactICCLockedTest::NewL()
       
   538 	{
       
   539 	CPhbkOpenContactICCLockedTest* self = new(ELeave) CPhbkOpenContactICCLockedTest();
       
   540 	return self;
       
   541 	}
       
   542 
       
   543 /**
       
   544  *  Default constructor.  Each test step initialises it's own name.
       
   545  */
       
   546 CPhbkOpenContactICCLockedTest::CPhbkOpenContactICCLockedTest()
       
   547 	{
       
   548 	SetTestStepName(_L("OpenContactICCLockedTest"));
       
   549 	}
       
   550 
       
   551 /** Open an ICC entry - ICC locked */
       
   552 enum TVerdict CPhbkOpenContactICCLockedTest::doTestStepL()
       
   553 	{
       
   554 	SetSimTsyTestNumberL(2);
       
   555 	DoSyncL();
       
   556 
       
   557 	// Access ICC and wait for it to become locked
       
   558 	iDb->SetDbViewContactType(KUidContactICCEntry);
       
   559 	const CContactIdArray* sortedItems = iDb->SortedItemsL();
       
   560 	TContactItemId id = (*sortedItems)[0];
       
   561 	TInt err(KErrNone);
       
   562 	while(err==KErrNone) // Wait for ICC to become locked 
       
   563 		{
       
   564 		User::After(1000000);	// Wait a second and try again.
       
   565 		CContactICCEntry* failEntry=NULL;
       
   566 		TRAP(err, failEntry = (CContactICCEntry*)iDb->ReadContactL(id, *iDb->AllFieldsView())); // Entry unavailable due to ICC being locked
       
   567 		delete failEntry;
       
   568 		}
       
   569 	TESTCHECKL(err, KErrAccessDenied);
       
   570 
       
   571 	// *
       
   572 	// * MJH  - 12 Sept 2002
       
   573 	// * Assumptions for test data:
       
   574 	// * 
       
   575 	// * Each phonebook has at least five entries
       
   576 	// * 
       
   577 
       
   578 	// Edited fields are committed to database, hence ETrue
       
   579 	TRAP(err, OpenContactEditFieldsL(KUidIccGlobalAdnPhonebook, 4, ETrue, KModifiedNameInADN, KModifiedNumberInADN));
       
   580 	TESTCHECKL(err, KErrAccessDenied);
       
   581 
       
   582 	TRAP(err, OpenContactEditFieldsL(KUidIccGlobalSdnPhonebook, 4, ETrue, KModifiedNameInSDN, KModifiedNumberInSDN));
       
   583 	TESTCHECKL(err, KErrAccessDenied);
       
   584 
       
   585 	TRAP(err, OpenContactEditFieldsL(KUidIccGlobalLndPhonebook, 4, ETrue, KModifiedNameInLND, KModifiedNumberInLND));
       
   586 	TESTCHECKL(err, KErrAccessDenied);
       
   587 
       
   588 	TRAP(err, OpenContactEditFieldsL(KUidUsimAppAdnPhonebook, 4, ETrue, KModifiedNameInUsim, KModifiedNumberInUsim));
       
   589 	TESTCHECKL(err, KErrAccessDenied);
       
   590 
       
   591 	TRAP(err, OpenContactEditFieldsL(KUidIccGlobalFdnPhonebook, 4, ETrue, KModifiedNameInFDN, KModifiedNumberInFDN));
       
   592 	TESTCHECKL(err, KErrAccessDenied);
       
   593 
       
   594 	return TestStepResult();
       
   595 	}
       
   596 
       
   597 
       
   598 /** 
       
   599  * Factory construction method.
       
   600  * @return Pointer to CPhbkOpenEntryReadOnlyAccessTest object
       
   601  */
       
   602 CPhbkOpenEntryReadOnlyAccessTest* CPhbkOpenEntryReadOnlyAccessTest::NewL()
       
   603 	{
       
   604 	CPhbkOpenEntryReadOnlyAccessTest* self = new(ELeave) CPhbkOpenEntryReadOnlyAccessTest();
       
   605 	return self;
       
   606 	}
       
   607 
       
   608 /**
       
   609  *  Default constructor.  Each test step initialises it's own name.
       
   610  */
       
   611 CPhbkOpenEntryReadOnlyAccessTest::CPhbkOpenEntryReadOnlyAccessTest()
       
   612 	{
       
   613 	SetTestStepName(_L("OpenEntryReadOnlyAccessTest"));
       
   614 	}
       
   615 
       
   616 /* Open an ICC entry - read-only phonebook */
       
   617 enum TVerdict CPhbkOpenEntryReadOnlyAccessTest::doTestStepL()
       
   618 	{
       
   619 	SetSimTsyTestNumberL(12);
       
   620 	DoSyncL();
       
   621 
       
   622 	// *
       
   623 	// * MJH  - 12 Sept 2002
       
   624 	// * Assumptions for test data:
       
   625 	// * 
       
   626 	// * Each phonebook has at least two entries
       
   627 	// * 
       
   628 
       
   629 	// Edited fields are committed to database, hence ETrue
       
   630 	TRAPD(err, OpenContactEditFieldsL(KUidIccGlobalAdnPhonebook, 0, ETrue, KModifiedNameInADN, KModifiedNumberInADN));
       
   631 	TESTCHECKL(err, KErrAccessDenied);
       
   632 
       
   633 	TRAP(err, OpenContactEditFieldsL(KUidIccGlobalSdnPhonebook, 0, ETrue, KModifiedNameInSDN, KModifiedNumberInSDN));
       
   634 	TESTCHECKL(err, KErrAccessDenied);
       
   635 
       
   636 	TRAP(err, OpenContactEditFieldsL(KUidIccGlobalLndPhonebook, 0, ETrue, KModifiedNameInLND, KModifiedNumberInLND));
       
   637 	TESTCHECKL(err, KErrAccessDenied);
       
   638 
       
   639 	TRAP(err, OpenContactEditFieldsL(KUidUsimAppAdnPhonebook, 0, ETrue, KModifiedNameInUsim, KModifiedNumberInUsim));
       
   640 	TESTCHECKL(err, KErrAccessDenied);
       
   641 
       
   642 	TRAP(err, OpenContactEditFieldsL(KUidIccGlobalFdnPhonebook, 0, ETrue, KModifiedNameInFDN, KModifiedNumberInFDN));
       
   643 	TESTCHECKL(err, KErrAccessDenied);
       
   644 
       
   645 	return TestStepResult();
       
   646 	}
       
   647 
       
   648 
       
   649 /** 
       
   650  * Replace the current name field with another name
       
   651  * @param aItem Reference to CContactItem
       
   652  * @param aModifiedName New name to use
       
   653  */
       
   654 void CPhbkEditIntegrationTestBase::ChangeNameFieldL(CContactItem& aItem, const TDesC& aModifiedName)
       
   655 	{
       
   656 	CContactItemFieldSet& fieldset = aItem.CardFields();
       
   657 	const TInt pos(fieldset.Find(KUidContactFieldFamilyName));	
       
   658 	CContactItemField& field = fieldset[pos];
       
   659 	CContactTextField* textfield = field.TextStorage();
       
   660 	textfield->SetTextL(aModifiedName);
       
   661 	}
       
   662 
       
   663 /** 
       
   664  * Replace the current number field with another number
       
   665  * @param aItem Reference to CContactItem
       
   666  * @param aModifiedNumber New number to use
       
   667  */
       
   668 void CPhbkEditIntegrationTestBase::ChangeNumberFieldL(CContactItem& aItem, const TDesC& aModifiedNumber)
       
   669 	{
       
   670 	CContactItemFieldSet& fieldset = aItem.CardFields();
       
   671 	const TInt pos(fieldset.Find(KUidContactFieldPhoneNumber));
       
   672 	CContactItemField& field = fieldset[pos];
       
   673 	CContactTextField* textfield = field.TextStorage();
       
   674 	textfield->SetTextL(aModifiedNumber);
       
   675 	}
       
   676 
       
   677 /** 
       
   678  * Replace the current email field with another email
       
   679  * @param aItem Reference to CContactItem
       
   680  * @param aModifiedEmail New email to use
       
   681  */
       
   682 void CPhbkEditIntegrationTestBase::ChangeEmailFieldL(CContactItem& aItem, const TDesC& aModifiedEmail)
       
   683 	{
       
   684 	CContactItemFieldSet& fieldset = aItem.CardFields();
       
   685 	const TInt pos(fieldset.Find(KUidContactFieldEMail));
       
   686 	CContactItemField& field = fieldset[pos];
       
   687 	CContactTextField* textfield = field.TextStorage();
       
   688 	textfield->SetTextL(aModifiedEmail);
       
   689 	}
       
   690 
       
   691 /** Open an ICC contact for edit */
       
   692 void CPhbkEditIntegrationTestBase::OpenContactEditFieldsL(TUid aPhonebookUid, TInt aIndex, TBool aCommit, const TDesC& aModifiedName, const TDesC& aModifiedNumber, const TDesC& aModifiedEmail)
       
   693 	{
       
   694 	iDb->SetDbViewContactType(KUidContactICCEntry);
       
   695 	// get the unique groupId for the given phonebook
       
   696 	TContactItemId groupId(KNullContactId);
       
   697 	User::LeaveIfError(iSession.GetPhoneBookId(groupId, 
       
   698 						RPhoneBookSession::ESyncGroupId,
       
   699 						aPhonebookUid));
       
   700 	TESTCHECKCONDITIONL(groupId != KNullContactId);
       
   701   
       
   702 	// based on the groupId, get items belonging to the phonebook
       
   703 	CContactGroup* group = NULL;
       
   704 	TRAPD(err, group = static_cast<CContactGroup*>(iDb->ReadContactL(groupId)));
       
   705 	TESTCHECKL(err, KErrNone);
       
   706 	CleanupStack::PushL(group);
       
   707 	const CContactIdArray* array = group->ItemsContained();
       
   708 
       
   709 	// Obtain the UID for the indexed entry
       
   710 	TContactItemId id = (*array)[aIndex];
       
   711 
       
   712 	// Open the entry and attempt to edit
       
   713 	CContactICCEntry* entry = static_cast<CContactICCEntry*>(iDb->OpenContactLX(id));
       
   714 	CleanupStack::PushL(entry);
       
   715 	ChangeNumberFieldL(*entry,aModifiedNumber);
       
   716 	ChangeNameFieldL(*entry,aModifiedName);
       
   717 	if (aPhonebookUid == KUidUsimAppAdnPhonebook)
       
   718 		ChangeEmailFieldL(*entry,aModifiedEmail);
       
   719 
       
   720 	// Commit to database if required
       
   721 	if (aCommit)
       
   722 		iDb->CommitContactL(*entry);
       
   723 	else
       
   724 		iDb->CloseContactL(id);
       
   725 
       
   726 	CleanupStack::PopAndDestroy(3); // group, entry & lockrecord
       
   727 	}
       
   728 
       
   729 /** Open an ICC contact - edit is locked */
       
   730 void CPhbkEditIntegrationTestBase::OpenContactEditLockedL(TUid aPhonebookUid, TInt aIndex, const TDesC& aModifiedNumber)
       
   731 	{
       
   732 	iDb->SetDbViewContactType(KUidContactICCEntry);
       
   733 	// get the unique groupId for the given phonebook
       
   734 	TContactItemId groupId(KNullContactId);
       
   735 	User::LeaveIfError(iSession.GetPhoneBookId(groupId, 
       
   736 						RPhoneBookSession::ESyncGroupId,
       
   737 						aPhonebookUid));
       
   738 	TESTCHECKCONDITIONL(groupId != KNullContactId);
       
   739   
       
   740 	const CContactIdArray* sortedItems = iDb->SortedItemsL();
       
   741 	TContactItemId id = (*sortedItems)[0];
       
   742 	TInt error(KErrAccessDenied);
       
   743 	while (error==KErrAccessDenied  ||  error==KErrNotReady  ||  error==KErrNotFound) // Wait for ICC to become unlocked again
       
   744 		{
       
   745 		User::After(1000000);	// Wait a second and try again.
       
   746 		CContactICCEntry* failEntry=NULL;
       
   747 		TRAP(error, failEntry = (CContactICCEntry*)iDb->ReadContactL(id, *iDb->AllFieldsView())); // Entry unavailable due to ICC being locked
       
   748 		delete failEntry;
       
   749 		}
       
   750 	TESTCHECKL(error, KErrNone);
       
   751 
       
   752 	WaitForSyncToCompleteL();
       
   753 
       
   754 	// based on the groupId, get items belonging to the phonebook
       
   755 	CContactGroup* group = NULL;
       
   756 	TRAPD(err, group = static_cast<CContactGroup*>(iDb->ReadContactL(groupId)));
       
   757 	TESTCHECKL(err, KErrNone);
       
   758 	CleanupStack::PushL(group);
       
   759 	const CContactIdArray* array = group->ItemsContained();
       
   760 
       
   761 	// Obtain the UID for the indexed entry
       
   762 	TContactItemId id2 = (*array)[aIndex];
       
   763 
       
   764 	// Open the entry
       
   765 	CContactICCEntry* entry = static_cast<CContactICCEntry*>(iDb->OpenContactLX(id2));
       
   766 	CleanupStack::PushL(entry);
       
   767 	
       
   768 	while(error==KErrNone) // Wait for ICC to become locked again
       
   769 		{
       
   770 		User::After(1000000);	// Wait a second and try again.
       
   771 		CContactICCEntry* failEntry=NULL;
       
   772 		TRAP(error, failEntry = (CContactICCEntry*)iDb->ReadContactL(id, *iDb->AllFieldsView())); // Entry unavailable due to ICC being locked
       
   773 		delete failEntry;
       
   774 		}
       
   775 	TESTCHECKCONDITIONL(error==KErrAccessDenied  ||  error==KErrNotReady);
       
   776 
       
   777 	ChangeNumberFieldL(*entry, aModifiedNumber);
       
   778 	TRAP(err, iDb->CommitContactL(*entry));
       
   779 	TESTCHECKL(err, KErrAccessDenied);
       
   780 
       
   781 	CleanupStack::PopAndDestroy(3); // group, entry & lockrecord
       
   782 	}
       
   783 
       
   784 /** Check edit based on slot number */
       
   785 void CPhbkEditIntegrationTestBase::CheckEditSlotWriteL(const TUid aPhonebook)
       
   786 	{
       
   787 	TInt aSlot;
       
   788 	TContactItemId aId=KNullContactId;
       
   789 	CPhbkIntegrationTestUtility* add = CPhbkIntegrationTestUtility::NewL();
       
   790 	_LIT(Kslot17,"17");
       
   791 	_LIT(Kslot18,"18");
       
   792 
       
   793 	//test add new contact at specified slot
       
   794 	TInt matchingId;
       
   795 	aSlot=17;
       
   796 	TInt err = iSession.GetSlotId(aSlot, aId, aPhonebook);
       
   797 	TESTCHECKL(err, KErrNotFound);
       
   798 
       
   799 	add->AddContactL(KTestName,KTestNumber,Kslot17, aPhonebook, KTestEMail);
       
   800 	err = iSession.GetSlotId(aSlot, aId, aPhonebook);
       
   801 	TESTCHECKL(err, KErrNone);
       
   802 	matchingId=aId;
       
   803 
       
   804 	//edit slot number
       
   805 	iDb->SetDbViewContactType(KUidContactICCEntry);
       
   806 	CContactICCEntry* entry = static_cast<CContactICCEntry*>(iDb->OpenContactLX(aId));
       
   807 	CleanupStack::PushL(entry);
       
   808 
       
   809 	CContactItemFieldSet& fieldset = entry->CardFields();
       
   810 	const TInt pos(fieldset.Find(KUidContactFieldICCSlot));
       
   811 	CContactItemField& field = fieldset[pos];
       
   812 	CContactTextField* textfield = field.TextStorage();
       
   813 	textfield->SetTextL(Kslot18);
       
   814 	iDb->CommitContactL(*entry);
       
   815 	CleanupStack::PopAndDestroy(2);
       
   816 
       
   817 	//check slot 17 is empty
       
   818 	err = iSession.GetSlotId(aSlot, aId, aPhonebook);
       
   819 	TESTCHECKL(err, KErrNotFound);
       
   820 	
       
   821 	//check slot 18 is not empty
       
   822 	aSlot=18;
       
   823 	err = iSession.GetSlotId(aSlot, aId, aPhonebook);
       
   824 	TESTCHECKL(err, KErrNone);
       
   825 	TESTCHECKL(aId, matchingId);
       
   826 
       
   827 	delete add;
       
   828 	}
       
   829 
       
   830 /********************* STRESS TESTS ************************************/
       
   831 
       
   832 /** 
       
   833  * Factory construction method.
       
   834  * @return Pointer to CPhbkOpenFullICCTest object
       
   835  */
       
   836 CPhbkOpenFullICCTest* CPhbkOpenFullICCTest::NewL()
       
   837 	{
       
   838 	CPhbkOpenFullICCTest* self = new(ELeave) CPhbkOpenFullICCTest();
       
   839 	return self;
       
   840 	}
       
   841 
       
   842 /**
       
   843  *  Default constructor.  Each test step initialises it's own name.
       
   844  */
       
   845 CPhbkOpenFullICCTest::CPhbkOpenFullICCTest()
       
   846 	{
       
   847 	SetTestStepName(_L("OpenFullICCTest"));
       
   848 	}
       
   849 
       
   850 /** Open and close each ICC entry in a full phonebook */
       
   851 enum TVerdict CPhbkOpenFullICCTest::doTestStepL()
       
   852 	{
       
   853 	// Global ADN Phonebook
       
   854 	SetSimTsyTestNumberL(131);
       
   855 
       
   856 	TRequestStatus status; 
       
   857 	iSession.DoSynchronisation(status);
       
   858 	User::WaitForRequest(status);
       
   859 	TESTCHECKL(status.Int(), KErrNone);
       
   860 
       
   861 	iDb->SetDbViewContactType(KUidContactICCEntry);
       
   862 	// get the unique groupId for the given phonebook
       
   863 	TContactItemId groupId(KNullContactId);
       
   864 	User::LeaveIfError(iSession.GetPhoneBookId(groupId, 
       
   865 						RPhoneBookSession::ESyncGroupId,
       
   866 						KUidIccGlobalAdnPhonebook));
       
   867 	TESTCHECKCONDITIONL(groupId != KNullContactId);
       
   868   
       
   869 	// based on the groupId, get items belonging to the phonebook
       
   870 	CContactGroup* group = NULL;
       
   871 	TRAPD(err, group = static_cast<CContactGroup*>(iDb->ReadContactL(groupId)));
       
   872 	TESTCHECKL(err, KErrNone);
       
   873 	CleanupStack::PushL(group);
       
   874 	const CContactIdArray* array = group->ItemsContained();
       
   875 
       
   876 	TInt count(array->Count());
       
   877 	TESTCHECKL(count, KTest13ICCSlotsADN);
       
   878 	TInt i;
       
   879 
       
   880 	for(i=0; i<count; ++i)
       
   881 		{
       
   882 		TContactItemId id = (*array)[i];
       
   883 		CContactICCEntry* entry = static_cast<CContactICCEntry*>(iDb->OpenContactLX(id));
       
   884 		CleanupStack::PushL(entry);
       
   885 		ChangeNameFieldL(*entry,KModifiedName);
       
   886 		iDb->CloseContactL(id);
       
   887 		CleanupStack::PopAndDestroy(2); //entry+lockrecord
       
   888 		}
       
   889 	CleanupStack::PopAndDestroy(); // group
       
   890 
       
   891 	// Global SDN Phonebook
       
   892 	SetSimTsyTestNumberL(132);
       
   893 
       
   894 	iSession.DoSynchronisation(status, KUidIccGlobalSdnPhonebook);
       
   895 	User::WaitForRequest(status);
       
   896 	TESTCHECKL(status.Int(), KErrNone);
       
   897 
       
   898 	iDb->SetDbViewContactType(KUidContactICCEntry);
       
   899 	// get the unique groupId for the given phonebook
       
   900 	User::LeaveIfError(iSession.GetPhoneBookId(groupId, 
       
   901 						RPhoneBookSession::ESyncGroupId,
       
   902 						KUidIccGlobalSdnPhonebook));
       
   903 	TESTCHECKCONDITIONL(groupId != KNullContactId);
       
   904   
       
   905 	// based on the groupId, get items belonging to the phonebook
       
   906 	TRAP(err, group = static_cast<CContactGroup*>(iDb->ReadContactL(groupId)));
       
   907 	TESTCHECKL(err, KErrNone);
       
   908 	CleanupStack::PushL(group);
       
   909 	array = group->ItemsContained();
       
   910 
       
   911 	count = array->Count();
       
   912 	TESTCHECKL(count, KTest13ICCSlotsSDN);
       
   913 
       
   914 	for(i=0; i<count; ++i)
       
   915 		{
       
   916 		TContactItemId id = (*array)[i];
       
   917 		CContactICCEntry* entry = static_cast<CContactICCEntry*>(iDb->OpenContactLX(id));
       
   918 		CleanupStack::PushL(entry);
       
   919 		ChangeNameFieldL(*entry,KModifiedName);
       
   920 		iDb->CloseContactL(id);
       
   921 		CleanupStack::PopAndDestroy(2); //entry+lockrecord
       
   922 		}
       
   923 	CleanupStack::PopAndDestroy(); // group
       
   924 
       
   925 	// Global LND Phonebook
       
   926 	SetSimTsyTestNumberL(133);
       
   927 
       
   928 	iSession.DoSynchronisation(status, KUidIccGlobalLndPhonebook);
       
   929 	User::WaitForRequest(status);
       
   930 	TESTCHECKL(status.Int(), KErrNone);
       
   931 
       
   932 	iDb->SetDbViewContactType(KUidContactICCEntry);
       
   933 	// get the unique groupId for the given phonebook
       
   934 	User::LeaveIfError(iSession.GetPhoneBookId(groupId, 
       
   935 						RPhoneBookSession::ESyncGroupId,
       
   936 						KUidIccGlobalLndPhonebook));
       
   937 	TESTCHECKCONDITIONL(groupId != KNullContactId);
       
   938   
       
   939 	// based on the groupId, get items belonging to the phonebook
       
   940 	TRAP(err, group = static_cast<CContactGroup*>(iDb->ReadContactL(groupId)));
       
   941 	TESTCHECKL(err, KErrNone);
       
   942 	CleanupStack::PushL(group);
       
   943 	array = group->ItemsContained();
       
   944 
       
   945 	count = array->Count();
       
   946 	TESTCHECKL(count, KTest13ICCSlotsLND);
       
   947 
       
   948 	for(i=0; i<count; ++i)
       
   949 		{
       
   950 		TContactItemId id = (*array)[i];
       
   951 		CContactICCEntry* entry = static_cast<CContactICCEntry*>(iDb->OpenContactLX(id));
       
   952 		CleanupStack::PushL(entry);
       
   953 		ChangeNameFieldL(*entry,KModifiedName);
       
   954 		iDb->CloseContactL(id);
       
   955 		CleanupStack::PopAndDestroy(2); //entry+lockrecord
       
   956 		}
       
   957 	CleanupStack::PopAndDestroy(); // group
       
   958 
       
   959 	// Usim App Phonebook
       
   960 	SetSimTsyTestNumberL(134);
       
   961 
       
   962 	iSession.DoSynchronisation(status, KUidUsimAppAdnPhonebook);
       
   963 	User::WaitForRequest(status);
       
   964 	TESTCHECKL(status.Int(), KErrNone);
       
   965 
       
   966 	iDb->SetDbViewContactType(KUidContactICCEntry);
       
   967 	// get the unique groupId for the given phonebook
       
   968 	User::LeaveIfError(iSession.GetPhoneBookId(groupId, 
       
   969 						RPhoneBookSession::ESyncGroupId,
       
   970 						KUidUsimAppAdnPhonebook));
       
   971 	TESTCHECKCONDITIONL(groupId != KNullContactId);
       
   972   
       
   973 	// based on the groupId, get items belonging to the phonebook
       
   974 	TRAP(err, group = static_cast<CContactGroup*>(iDb->ReadContactL(groupId)));
       
   975 	TESTCHECKL(err, KErrNone);
       
   976 	CleanupStack::PushL(group);
       
   977 	array = group->ItemsContained();
       
   978 
       
   979 	count = array->Count();
       
   980 	TESTCHECKL(count, KTest13ICCSlotsUsim);
       
   981 
       
   982 	for(i=0; i<count; ++i)
       
   983 		{
       
   984 		TContactItemId id = (*array)[i];
       
   985 		CContactICCEntry* entry = static_cast<CContactICCEntry*>(iDb->OpenContactLX(id));
       
   986 		CleanupStack::PushL(entry);
       
   987 		ChangeNameFieldL(*entry,KModifiedName);
       
   988 		iDb->CloseContactL(id);
       
   989 		CleanupStack::PopAndDestroy(2); //entry+lockrecord
       
   990 		}
       
   991 	CleanupStack::PopAndDestroy(); // group
       
   992 
       
   993 	return TestStepResult();
       
   994 	}
       
   995