pimprotocols/phonebooksync/Test/TE_cntsync/te_cntsyncread.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 
       
    18 #include "te_cntsyncbase.h"
       
    19 #include "te_cntsyncread.h"
       
    20 
       
    21 
       
    22 /** 
       
    23  * Factory construction method.
       
    24  * @return Pointer to CPhbkSyncReadICCContactTest object
       
    25  */
       
    26 CPhbkSyncReadICCContactTest* CPhbkSyncReadICCContactTest::NewL()
       
    27 	{
       
    28 	CPhbkSyncReadICCContactTest* self = new(ELeave) CPhbkSyncReadICCContactTest();
       
    29 	return self;
       
    30 	}
       
    31 
       
    32 /**
       
    33  *  Default constructor.  Each test step initialises its own name.
       
    34  */
       
    35 CPhbkSyncReadICCContactTest::CPhbkSyncReadICCContactTest()
       
    36 	{
       
    37 	SetTestStepName(_L("ReadICCContactTest"));
       
    38 	}
       
    39 
       
    40 /** 
       
    41  * Read an ICC entry - normal case.
       
    42  * Check group membership is correct and relevant number of fields have
       
    43  * been created.
       
    44  */
       
    45 enum TVerdict CPhbkSyncReadICCContactTest::doTestStepL()
       
    46 	{
       
    47 	SetSyncModeL(RPhoneBookSession::EManual);
       
    48 	CheckSyncModeL(RPhoneBookSession::EManual);
       
    49 
       
    50 	SetSimTsyTestNumberL(9);
       
    51 	DoSyncL();
       
    52 
       
    53 	// We're NOT trying to read all phonebook content, only a single entry
       
    54 	// from each phonebook, hence EFalse
       
    55 	ReadContactL(KUidIccGlobalAdnPhonebook, KTest9ICCSlotsADN, EFalse); 
       
    56 	ReadContactL(KUidIccGlobalSdnPhonebook, KTest9ICCSlotsSDN, EFalse); 
       
    57 	ReadContactL(KUidIccGlobalLndPhonebook, KTest9ICCSlotsLND, EFalse); 
       
    58 	ReadContactL(KUidUsimAppAdnPhonebook, KTest9ICCSlotsUsim, EFalse); 
       
    59 	ReadContactL(KUidIccGlobalFdnPhonebook, KTest9ICCSlotsFDN, EFalse); 
       
    60 
       
    61 	return TestStepResult();
       
    62 	}
       
    63 
       
    64 /** 
       
    65  * Factory construction method.
       
    66  * @return Pointer to CPhbkSyncReadSequenceOfICCEntriesTest object
       
    67  */
       
    68 CPhbkSyncReadSequenceOfICCEntriesTest* CPhbkSyncReadSequenceOfICCEntriesTest::NewL()
       
    69 	{
       
    70 	CPhbkSyncReadSequenceOfICCEntriesTest* self = new(ELeave) CPhbkSyncReadSequenceOfICCEntriesTest();
       
    71 	return self;
       
    72 	}
       
    73 
       
    74 /**
       
    75  *  Default constructor.  Each test step initialises it's own name.
       
    76  */
       
    77 CPhbkSyncReadSequenceOfICCEntriesTest::CPhbkSyncReadSequenceOfICCEntriesTest()
       
    78 	{
       
    79 	SetTestStepName(_L("ReadSequenceOfICCEntriesTest"));
       
    80 	}
       
    81 
       
    82 /** 
       
    83  * Read a sequence of ICC entries - full phonebook case 
       
    84  */
       
    85 enum TVerdict CPhbkSyncReadSequenceOfICCEntriesTest::doTestStepL()
       
    86 	{
       
    87 	// Load a data set with full slots on each phonebook
       
    88 	SetSimTsyTestNumberL(1);
       
    89 	DoSyncL();
       
    90 
       
    91 	// We shall try to read the whole of each phonebook, hence ETrue
       
    92 	ReadContactL(KUidIccGlobalAdnPhonebook, KTest1ICCSlotsADN, ETrue);
       
    93 	ReadContactL(KUidIccGlobalSdnPhonebook, KTest1ICCSlotsSDN, ETrue);
       
    94 	ReadContactL(KUidIccGlobalLndPhonebook, KTest1ICCSlotsLND, ETrue);
       
    95 	ReadContactL(KUidUsimAppAdnPhonebook, KTest1ICCSlotsUsim, ETrue);
       
    96 	ReadContactL(KUidIccGlobalFdnPhonebook, KTest1ICCSlotsFDN, ETrue);
       
    97 
       
    98 	return TestStepResult();
       
    99 	}
       
   100 
       
   101 
       
   102 /** 
       
   103  * Factory construction method.
       
   104  * @return Pointer to CPhbkSyncReadContactInvalidUIDTest object
       
   105  */
       
   106 CPhbkSyncReadContactInvalidUIDTest* CPhbkSyncReadContactInvalidUIDTest::NewL()
       
   107 	{
       
   108 	CPhbkSyncReadContactInvalidUIDTest* self = new(ELeave) CPhbkSyncReadContactInvalidUIDTest();
       
   109 	return self;
       
   110 	}
       
   111 
       
   112 /**
       
   113  *  Default constructor.  Each test step initialises it's own name.
       
   114  */
       
   115 CPhbkSyncReadContactInvalidUIDTest::CPhbkSyncReadContactInvalidUIDTest()
       
   116 	{
       
   117 	SetTestStepName(_L("ReadContactInvalidUIDTest"));
       
   118 	}
       
   119 
       
   120 /** 
       
   121  * Read a number of ICC entries - invalid UID.
       
   122  */
       
   123 enum TVerdict CPhbkSyncReadContactInvalidUIDTest::doTestStepL()
       
   124 	{
       
   125 	// Load a data set with full slots on each phonebook
       
   126 	SetSimTsyTestNumberL(1);
       
   127 	DoSyncL();
       
   128 	
       
   129 	iDb->SetDbViewContactType(KUidContactICCEntry);
       
   130 	const CContactIdArray* sortedItems = iDb->SortedItemsL();
       
   131 	TInt count(sortedItems->Count());
       
   132 	TESTCHECK(count, KTest1MaxSlots);
       
   133 
       
   134 	TContactItemId invalidUid(-2);
       
   135 	CContactICCEntry* entry = NULL;
       
   136 	TRAPD(err, entry = static_cast<CContactICCEntry*>(iDb->ReadContactL(invalidUid)));
       
   137 	TESTCHECK(err, KErrNotFound);
       
   138 	delete entry;
       
   139 
       
   140 	invalidUid=-786;
       
   141 	TRAP(err, entry = static_cast<CContactICCEntry*>(iDb->ReadContactL(invalidUid)));
       
   142 	TESTCHECK(err, KErrNotFound);
       
   143 	delete entry;
       
   144 
       
   145 	invalidUid=999;
       
   146 	TRAP(err, entry = static_cast<CContactICCEntry*>(iDb->ReadContactL(invalidUid)));
       
   147 	TESTCHECK(err, KErrNotFound);
       
   148 	delete entry;
       
   149 
       
   150 	return TestStepResult();
       
   151 	}
       
   152 
       
   153 
       
   154 /** 
       
   155  * Factory construction method.
       
   156  * @return Pointer to CPhbkSyncReadContactsEmptyFieldTest object
       
   157  */
       
   158 CPhbkSyncReadContactsEmptyFieldTest* CPhbkSyncReadContactsEmptyFieldTest::NewL()
       
   159 	{
       
   160 	CPhbkSyncReadContactsEmptyFieldTest* self = new(ELeave) CPhbkSyncReadContactsEmptyFieldTest();
       
   161 	return self;
       
   162 	}
       
   163 
       
   164 /**
       
   165  *  Default constructor.  Each test step initialises it's own name.
       
   166  */
       
   167 CPhbkSyncReadContactsEmptyFieldTest::CPhbkSyncReadContactsEmptyFieldTest()
       
   168 	{
       
   169 	SetTestStepName(_L("ReadContactsEmptyFieldTest"));
       
   170 	}
       
   171 
       
   172 /** 
       
   173  * Read a sequence of ICC entries - empty field case. 
       
   174  * Name, number or email fields are empty.
       
   175  * Check group membership is correct and relevant number of fields have
       
   176  * been created.
       
   177  */
       
   178 enum TVerdict CPhbkSyncReadContactsEmptyFieldTest::doTestStepL()
       
   179 	{
       
   180 	// This test employs data with empty fields
       
   181 	SetSimTsyTestNumberL(6);
       
   182 	DoSyncL();
       
   183 
       
   184 	ReadAllContactContentL(KUidIccGlobalAdnPhonebook, KTest6ICCSlotsADN);
       
   185 	ReadAllContactContentL(KUidIccGlobalSdnPhonebook, KTest6ICCSlotsSDN);
       
   186 	ReadAllContactContentL(KUidIccGlobalLndPhonebook, KTest6ICCSlotsLND);
       
   187 	ReadAllContactContentL(KUidUsimAppAdnPhonebook, KTest6ICCSlotsUsim);
       
   188 	ReadAllContactContentL(KUidIccGlobalFdnPhonebook, KTest6ICCSlotsFDN);
       
   189 
       
   190 	return TestStepResult();
       
   191 	}
       
   192 
       
   193 
       
   194 /** 
       
   195  * Factory construction method.
       
   196  * @return Pointer to CPhbkSyncReadContactFullViewICCLockedTest object
       
   197  */
       
   198 CPhbkSyncReadContactFullViewICCLockedTest* CPhbkSyncReadContactFullViewICCLockedTest::NewL()
       
   199 	{
       
   200 	CPhbkSyncReadContactFullViewICCLockedTest* self = new(ELeave) CPhbkSyncReadContactFullViewICCLockedTest();
       
   201 	return self;
       
   202 	}
       
   203 
       
   204 /**
       
   205  *  Default constructor.  Each test step initialises it's own name.
       
   206  */
       
   207 CPhbkSyncReadContactFullViewICCLockedTest::CPhbkSyncReadContactFullViewICCLockedTest()
       
   208 	{
       
   209 	SetTestStepName(_L("ReadContactFullViewICCLockedTest"));
       
   210 	}
       
   211 
       
   212 /** 
       
   213  * Read ICC entry - entry not available as the ICC becomes locked.
       
   214  */
       
   215 enum TVerdict CPhbkSyncReadContactFullViewICCLockedTest::doTestStepL()
       
   216 	{
       
   217 	// ADN Entry
       
   218 	SetSimTsyTestNumberL(2);
       
   219 	DoSyncL();
       
   220 	ReadFullContactLockedL(KUidIccGlobalAdnPhonebook, KTest2ICCSlotsADN);
       
   221 
       
   222 	// SDN Entry
       
   223 	SetSimTsyTestNumberL(2);
       
   224 	DoSyncL();
       
   225 	ReadFullContactLockedL(KUidIccGlobalSdnPhonebook, KTest2ICCSlotsSDN);
       
   226 
       
   227 	// LND Entry
       
   228 	SetSimTsyTestNumberL(2);
       
   229 	DoSyncL();
       
   230 	ReadFullContactLockedL(KUidIccGlobalLndPhonebook, KTest2ICCSlotsLND);
       
   231 
       
   232 	// Usim App Entry
       
   233 	SetSimTsyTestNumberL(2);
       
   234 	DoSyncL();
       
   235 	ReadFullContactLockedL(KUidUsimAppAdnPhonebook, KTest2ICCSlotsUsim);
       
   236 
       
   237 	// FDN Entry
       
   238 	SetSimTsyTestNumberL(2);
       
   239 	DoSyncL();
       
   240 	ReadFullContactLockedL(KUidIccGlobalFdnPhonebook, KTest2ICCSlotsFDN);
       
   241 
       
   242 	return TestStepResult();
       
   243 	}
       
   244 
       
   245 
       
   246 /** 
       
   247  * Factory construction method.
       
   248  * @return Pointer to CPhbkSyncReadContactDiffViewsTest object
       
   249  */
       
   250 CPhbkSyncReadContactDiffViewsTest* CPhbkSyncReadContactDiffViewsTest::NewL()
       
   251 	{
       
   252 	CPhbkSyncReadContactDiffViewsTest* self = new(ELeave) CPhbkSyncReadContactDiffViewsTest();
       
   253 	return self;
       
   254 	}
       
   255 
       
   256 /**
       
   257  *  Default constructor.  Each test step initialises it's own name.
       
   258  */
       
   259 CPhbkSyncReadContactDiffViewsTest::CPhbkSyncReadContactDiffViewsTest()
       
   260 	{
       
   261 	SetTestStepName(_L("ReadContactDiffViewsTest"));
       
   262 	}
       
   263 
       
   264 /** 
       
   265  * Read an ICC entry - specify full view, full view for non-existent entry, name, number 
       
   266  * and invalid view
       
   267  */
       
   268 enum TVerdict CPhbkSyncReadContactDiffViewsTest::doTestStepL()
       
   269 	{
       
   270 	// ADN Entry
       
   271 	SetSimTsyTestNumberL(2);
       
   272 	DoSyncL();
       
   273 	ReadContactViewsL(KUidIccGlobalAdnPhonebook, KTest2ICCSlotsADN);
       
   274 
       
   275 	// SDN Entry
       
   276 	SetSimTsyTestNumberL(2);
       
   277 	DoSyncL();
       
   278 	ReadContactViewsL(KUidIccGlobalSdnPhonebook, KTest2ICCSlotsSDN);
       
   279 
       
   280 	// LND Entry
       
   281 	SetSimTsyTestNumberL(2);
       
   282 	DoSyncL();
       
   283 	ReadContactViewsL(KUidIccGlobalLndPhonebook, KTest2ICCSlotsLND);
       
   284 
       
   285 	// Usim App Entry
       
   286 	SetSimTsyTestNumberL(2);
       
   287 	DoSyncL();
       
   288 	ReadContactViewsL(KUidUsimAppAdnPhonebook, KTest2ICCSlotsUsim);
       
   289 
       
   290 	// FDN Entry
       
   291 	SetSimTsyTestNumberL(2);
       
   292 	DoSyncL();
       
   293 	ReadContactViewsL(KUidIccGlobalFdnPhonebook, KTest2ICCSlotsFDN);
       
   294 
       
   295 	return TestStepResult();
       
   296 	}
       
   297 
       
   298 
       
   299 /** 
       
   300  * Factory construction method.
       
   301  * @return Pointer to CPhbkSyncReadICCMinimalContactTest object
       
   302  */
       
   303 CPhbkSyncReadICCMinimalContactTest* CPhbkSyncReadICCMinimalContactTest::NewL()
       
   304 	{
       
   305 	CPhbkSyncReadICCMinimalContactTest* self = new(ELeave) CPhbkSyncReadICCMinimalContactTest();
       
   306 	return self;
       
   307 	}
       
   308 
       
   309 /**
       
   310  *  Default constructor.  Each test step initialises it's own name.
       
   311  */
       
   312 CPhbkSyncReadICCMinimalContactTest::CPhbkSyncReadICCMinimalContactTest()
       
   313 	{
       
   314 	SetTestStepName(_L("ReadICCMinimalContactTest"));
       
   315 	}
       
   316 
       
   317 /**
       
   318  * Read an ICC entry - minimal read operation.
       
   319  */
       
   320 enum TVerdict CPhbkSyncReadICCMinimalContactTest::doTestStepL()
       
   321 	{
       
   322 	SetSimTsyTestNumberL(1);
       
   323 	DoSyncL();
       
   324 
       
   325 	ReadMinimalContactL(KUidIccGlobalAdnPhonebook, KTest1ICCSlotsADN);
       
   326 	ReadMinimalContactL(KUidIccGlobalSdnPhonebook, KTest1ICCSlotsSDN);
       
   327 	ReadMinimalContactL(KUidIccGlobalLndPhonebook, KTest1ICCSlotsLND);
       
   328 	ReadMinimalContactL(KUidUsimAppAdnPhonebook, KTest1ICCSlotsUsim);
       
   329 	ReadMinimalContactL(KUidIccGlobalFdnPhonebook, KTest1ICCSlotsFDN);
       
   330 
       
   331 	return TestStepResult();
       
   332 	}
       
   333 
       
   334 
       
   335 /** 
       
   336  * Factory construction method.
       
   337  * @return Pointer to CPhbkSyncReadMinimalContactInvalidUIDTest object
       
   338  */
       
   339 CPhbkSyncReadMinimalContactInvalidUIDTest* CPhbkSyncReadMinimalContactInvalidUIDTest::NewL()
       
   340 	{
       
   341 	CPhbkSyncReadMinimalContactInvalidUIDTest* self = new(ELeave) CPhbkSyncReadMinimalContactInvalidUIDTest();
       
   342 	return self;
       
   343 	}
       
   344 
       
   345 /**
       
   346  *  Default constructor.  Each test step initialises it's own name.
       
   347  */
       
   348 CPhbkSyncReadMinimalContactInvalidUIDTest::CPhbkSyncReadMinimalContactInvalidUIDTest()
       
   349 	{
       
   350 	SetTestStepName(_L("ReadMinimalContactInvalidUIDTest"));
       
   351 	}
       
   352 
       
   353 enum TVerdict CPhbkSyncReadMinimalContactInvalidUIDTest::doTestStepL()
       
   354 	{
       
   355 	SetSimTsyTestNumberL(1);
       
   356 	DoSyncL();
       
   357 
       
   358 	iDb->SetDbViewContactType(KUidContactICCEntry);
       
   359 	const CContactIdArray* sortedItems = iDb->SortedItemsL();
       
   360 	TInt count = sortedItems->Count(); // for debugging
       
   361 	TESTCHECK(count, KTest1MaxSlots);
       
   362 
       
   363 	TContactItemId invalidUID(1500);
       
   364 	TRAPD(err,iDb->ReadMinimalContactL(invalidUID));
       
   365 	TESTCHECK(err, KErrNotFound);
       
   366 
       
   367 	return TestStepResult();
       
   368 	}
       
   369 
       
   370 
       
   371 /** 
       
   372  * Factory construction method.
       
   373  * @return Pointer to CPhbkSyncReadMinimalContactEmptyFieldTest object
       
   374  */
       
   375 CPhbkSyncReadMinimalContactEmptyFieldTest* CPhbkSyncReadMinimalContactEmptyFieldTest::NewL()
       
   376 	{
       
   377 	CPhbkSyncReadMinimalContactEmptyFieldTest* self = new(ELeave) CPhbkSyncReadMinimalContactEmptyFieldTest();
       
   378 	return self;
       
   379 	}
       
   380 
       
   381 /**
       
   382  *  Default constructor.  Each test step initialises it's own name.
       
   383  */
       
   384 CPhbkSyncReadMinimalContactEmptyFieldTest::CPhbkSyncReadMinimalContactEmptyFieldTest()
       
   385 	{
       
   386 	SetTestStepName(_L("ReadMinimalContactEmptyFieldTest"));
       
   387 	}
       
   388 
       
   389 /** 
       
   390  * Read a sequence of ICC entries - minimal read with missing fields. 
       
   391  * Name, number or email fields are empty.
       
   392  */
       
   393 enum TVerdict CPhbkSyncReadMinimalContactEmptyFieldTest::doTestStepL()
       
   394 	{
       
   395 	// This test employs data with empty fields
       
   396 	SetSimTsyTestNumberL(6);
       
   397 	DoSyncL();
       
   398 	
       
   399 	ReadMinimalContactL(KUidIccGlobalAdnPhonebook, KTest6ICCSlotsADN);
       
   400 	ReadMinimalContactL(KUidIccGlobalSdnPhonebook, KTest6ICCSlotsSDN);
       
   401 	ReadMinimalContactL(KUidIccGlobalLndPhonebook, KTest6ICCSlotsLND);
       
   402 	ReadMinimalContactL(KUidUsimAppAdnPhonebook, KTest6ICCSlotsUsim);
       
   403 	ReadMinimalContactL(KUidIccGlobalFdnPhonebook, KTest6ICCSlotsFDN);
       
   404 
       
   405 	return TestStepResult();
       
   406 	}
       
   407 
       
   408 
       
   409 /** 
       
   410  * Factory construction method.
       
   411  * @return Pointer to CPhbkSyncReadMinimalContactICCLockedTest object
       
   412  */
       
   413 CPhbkSyncReadMinimalContactICCLockedTest* CPhbkSyncReadMinimalContactICCLockedTest::NewL()
       
   414 	{
       
   415 	CPhbkSyncReadMinimalContactICCLockedTest* self = new(ELeave) CPhbkSyncReadMinimalContactICCLockedTest();
       
   416 	return self;
       
   417 	}
       
   418 
       
   419 /**
       
   420  *  Default constructor.  Each test step initialises it's own name.
       
   421  */
       
   422 CPhbkSyncReadMinimalContactICCLockedTest::CPhbkSyncReadMinimalContactICCLockedTest()
       
   423 	{
       
   424 	SetTestStepName(_L("ReadMinimalContactICCLockedTest"));
       
   425 	}
       
   426 
       
   427 /** 
       
   428  * Read a number of ICC entries - minimal read, entry not available as the ICC becomes locked.
       
   429  */
       
   430 enum TVerdict CPhbkSyncReadMinimalContactICCLockedTest::doTestStepL()
       
   431 	{
       
   432 	// ADN Entry
       
   433 	SetSimTsyTestNumberL(2);
       
   434 	DoSyncL();
       
   435 	ReadMinimalContactLockedL(KUidIccGlobalAdnPhonebook, KTest2ICCSlotsADN);
       
   436 
       
   437 	// SDN Entry
       
   438 	SetSimTsyTestNumberL(2);
       
   439 	DoSyncL();
       
   440 	ReadMinimalContactLockedL(KUidIccGlobalSdnPhonebook, KTest2ICCSlotsSDN);
       
   441 
       
   442 	// LND Entry
       
   443 	SetSimTsyTestNumberL(2);
       
   444 	DoSyncL();
       
   445 	ReadMinimalContactLockedL(KUidIccGlobalLndPhonebook, KTest2ICCSlotsLND);
       
   446 
       
   447 	// Usim App Entry
       
   448 	SetSimTsyTestNumberL(2);
       
   449 	DoSyncL();
       
   450 	ReadMinimalContactLockedL(KUidUsimAppAdnPhonebook, KTest2ICCSlotsUsim);
       
   451 
       
   452 	// FDN Entry
       
   453 	SetSimTsyTestNumberL(2);
       
   454 	DoSyncL();
       
   455 	ReadMinimalContactLockedL(KUidIccGlobalFdnPhonebook, KTest2ICCSlotsFDN);
       
   456 
       
   457 	return TestStepResult();
       
   458 	}
       
   459 
       
   460 
       
   461 /** 
       
   462  * Factory construction method.
       
   463  * @return Pointer to CPhbkSyncReadContactTextDefFullViewTest object
       
   464  */
       
   465 CPhbkSyncReadContactTextDefFullViewTest* CPhbkSyncReadContactTextDefFullViewTest::NewL()
       
   466 	{
       
   467 	CPhbkSyncReadContactTextDefFullViewTest* self = new(ELeave) CPhbkSyncReadContactTextDefFullViewTest();
       
   468 	return self;
       
   469 	}
       
   470 
       
   471 /**
       
   472  *  Default constructor.  Each test step initialises it's own name.
       
   473  */
       
   474 CPhbkSyncReadContactTextDefFullViewTest::CPhbkSyncReadContactTextDefFullViewTest()
       
   475 	{
       
   476 	SetTestStepName(_L("ReadContactTextDefFullViewTest"));
       
   477 	}
       
   478 
       
   479 /** 
       
   480  * Read an ICC entry - create string from contact info (full view).
       
   481  */
       
   482 enum TVerdict CPhbkSyncReadContactTextDefFullViewTest::doTestStepL()
       
   483 	{
       
   484 	// NOT trying to read all phonebook, hence EFalse
       
   485 
       
   486 	SetSimTsyTestNumberL(2);
       
   487 	DoSyncL();
       
   488 
       
   489 	ReadFullContactTextDefL(KUidIccGlobalAdnPhonebook, KTest2ICCSlotsADN, EFalse);
       
   490 	ReadFullContactTextDefL(KUidIccGlobalSdnPhonebook, KTest2ICCSlotsSDN, EFalse);
       
   491 	ReadFullContactTextDefL(KUidIccGlobalLndPhonebook, KTest2ICCSlotsLND, EFalse);
       
   492 	ReadFullContactTextDefL(KUidUsimAppAdnPhonebook, KTest2ICCSlotsUsim, EFalse);
       
   493 	ReadFullContactTextDefL(KUidIccGlobalFdnPhonebook, KTest2ICCSlotsFDN, EFalse);
       
   494 
       
   495 	return TestStepResult();
       
   496 	}
       
   497 
       
   498 
       
   499 /** 
       
   500  * Factory construction method.
       
   501  * @return Pointer to CPhbkSyncReadContactNumberTextDefTest object
       
   502  */
       
   503 CPhbkSyncReadContactNumberTextDefTest* CPhbkSyncReadContactNumberTextDefTest::NewL()
       
   504 	{
       
   505 	CPhbkSyncReadContactNumberTextDefTest* self = new(ELeave) CPhbkSyncReadContactNumberTextDefTest();
       
   506 	return self;
       
   507 	}
       
   508 
       
   509 /**
       
   510  *  Default constructor.  Each test step initialises it's own name.
       
   511  */
       
   512 CPhbkSyncReadContactNumberTextDefTest::CPhbkSyncReadContactNumberTextDefTest()
       
   513 	{
       
   514 	SetTestStepName(_L("ReadContactNumberTextDefTest"));
       
   515 	}
       
   516 
       
   517 /** 
       
   518  * Read an ICC entry - create number string from contact info.
       
   519  */
       
   520 enum TVerdict CPhbkSyncReadContactNumberTextDefTest::doTestStepL()
       
   521 	{
       
   522 	// NOT trying to read all phonebook, hence EFalse
       
   523 
       
   524 	SetSimTsyTestNumberL(2);
       
   525 	DoSyncL();
       
   526 
       
   527 	ReadNumberContactTextDefL(KUidIccGlobalAdnPhonebook, KTest2ICCSlotsADN, EFalse);
       
   528 	ReadNumberContactTextDefL(KUidIccGlobalSdnPhonebook, KTest2ICCSlotsSDN, EFalse);
       
   529 	ReadNumberContactTextDefL(KUidIccGlobalLndPhonebook, KTest2ICCSlotsLND, EFalse);
       
   530 	ReadNumberContactTextDefL(KUidUsimAppAdnPhonebook, KTest2ICCSlotsUsim, EFalse);
       
   531 	ReadNumberContactTextDefL(KUidIccGlobalFdnPhonebook, KTest2ICCSlotsFDN, EFalse);
       
   532 
       
   533 	return TestStepResult();
       
   534 	}
       
   535 
       
   536 
       
   537 /** 
       
   538  * Factory construction method.
       
   539  * @return Pointer to CPhbkSyncReadContactNameTextDefTest object
       
   540  */
       
   541 CPhbkSyncReadContactNameTextDefTest* CPhbkSyncReadContactNameTextDefTest::NewL()
       
   542 	{
       
   543 	CPhbkSyncReadContactNameTextDefTest* self = new(ELeave) CPhbkSyncReadContactNameTextDefTest();
       
   544 	return self;
       
   545 	}
       
   546 
       
   547 /**
       
   548  *  Default constructor.  Each test step initialises it's own name.
       
   549  */
       
   550 CPhbkSyncReadContactNameTextDefTest::CPhbkSyncReadContactNameTextDefTest()
       
   551 	{
       
   552 	SetTestStepName(_L("ReadContactNameTextDefTest"));
       
   553 	}
       
   554 
       
   555 /** 
       
   556  * Read an ICC entry - create name string from contact info.
       
   557  */
       
   558 enum TVerdict CPhbkSyncReadContactNameTextDefTest::doTestStepL()
       
   559 	{
       
   560 	// NOT trying to read all phonebook, hence EFalse
       
   561 
       
   562 	SetSimTsyTestNumberL(2);
       
   563 	DoSyncL();
       
   564 
       
   565 	ReadNameContactTextDefL(KUidIccGlobalAdnPhonebook, KTest2ICCSlotsADN, EFalse);
       
   566 	ReadNameContactTextDefL(KUidIccGlobalSdnPhonebook, KTest2ICCSlotsSDN, EFalse);
       
   567 	ReadNameContactTextDefL(KUidIccGlobalLndPhonebook, KTest2ICCSlotsLND, EFalse);
       
   568 	ReadNameContactTextDefL(KUidUsimAppAdnPhonebook, KTest2ICCSlotsUsim, EFalse);
       
   569 	ReadNameContactTextDefL(KUidIccGlobalFdnPhonebook, KTest2ICCSlotsFDN, EFalse);
       
   570 
       
   571 	return TestStepResult();
       
   572 	}
       
   573 
       
   574 
       
   575 /** 
       
   576  * Factory construction method.
       
   577  * @return Pointer to CPhbkSyncReadContactInvalidTextDefTest object
       
   578  */
       
   579 CPhbkSyncReadContactInvalidTextDefTest* CPhbkSyncReadContactInvalidTextDefTest::NewL()
       
   580 	{
       
   581 	CPhbkSyncReadContactInvalidTextDefTest* self = new(ELeave) CPhbkSyncReadContactInvalidTextDefTest();
       
   582 	return self;
       
   583 	}
       
   584 
       
   585 /**
       
   586  *  Default constructor.  Each test step initialises it's own name.
       
   587  */
       
   588 CPhbkSyncReadContactInvalidTextDefTest::CPhbkSyncReadContactInvalidTextDefTest()
       
   589 	{
       
   590 	SetTestStepName(_L("ReadContactInvalidTextDefTest"));
       
   591 	}
       
   592 
       
   593 /** 
       
   594  * Read an ICC entry - invalid string specification.
       
   595  */
       
   596 enum TVerdict CPhbkSyncReadContactInvalidTextDefTest::doTestStepL()
       
   597 	{
       
   598 	SetSimTsyTestNumberL(2);
       
   599 	DoSyncL();
       
   600 
       
   601 	ReadInvalidContactTextDefL(KUidIccGlobalAdnPhonebook, KTest2ICCSlotsADN);
       
   602 	ReadInvalidContactTextDefL(KUidIccGlobalSdnPhonebook, KTest2ICCSlotsSDN);
       
   603 	ReadInvalidContactTextDefL(KUidIccGlobalLndPhonebook, KTest2ICCSlotsLND);
       
   604 	ReadInvalidContactTextDefL(KUidUsimAppAdnPhonebook, KTest2ICCSlotsUsim);
       
   605 	ReadInvalidContactTextDefL(KUidIccGlobalFdnPhonebook, KTest2ICCSlotsFDN);
       
   606 
       
   607 	return TestStepResult();
       
   608 	}
       
   609 
       
   610 
       
   611 /** 
       
   612  * Factory construction method.
       
   613  * @return Pointer to CPhbkSyncReadContactICCLockedTest object
       
   614  */
       
   615 CPhbkSyncReadContactICCLockedTest* CPhbkSyncReadContactICCLockedTest::NewL()
       
   616 	{
       
   617 	CPhbkSyncReadContactICCLockedTest* self = new(ELeave) CPhbkSyncReadContactICCLockedTest();
       
   618 	return self;
       
   619 	}
       
   620 
       
   621 /**
       
   622  *  Default constructor.  Each test step initialises it's own name.
       
   623  */
       
   624 CPhbkSyncReadContactICCLockedTest::CPhbkSyncReadContactICCLockedTest()
       
   625 	{
       
   626 	SetTestStepName(_L("ReadContactICCLockedTest"));
       
   627 	}
       
   628 
       
   629 /** 
       
   630  * Read an ICC entry using text definition when ICC is locked.
       
   631  */
       
   632 enum TVerdict CPhbkSyncReadContactICCLockedTest::doTestStepL()
       
   633 	{
       
   634 	// ADN Entry
       
   635 	SetSimTsyTestNumberL(2);
       
   636 	DoSyncL();
       
   637 	ReadLockedContactTextDefL(KUidIccGlobalAdnPhonebook, KTest2ICCSlotsADN);
       
   638 
       
   639 	// SDN Entry
       
   640 	SetSimTsyTestNumberL(2);
       
   641 	DoSyncL();
       
   642 	ReadLockedContactTextDefL(KUidIccGlobalSdnPhonebook, KTest2ICCSlotsSDN);
       
   643 
       
   644 	// LND Entry
       
   645 	SetSimTsyTestNumberL(2);
       
   646 	DoSyncL();
       
   647 	ReadLockedContactTextDefL(KUidIccGlobalLndPhonebook, KTest2ICCSlotsLND);
       
   648 
       
   649 	// Usim App Entry
       
   650 	SetSimTsyTestNumberL(2);
       
   651 	DoSyncL();
       
   652 	ReadLockedContactTextDefL(KUidUsimAppAdnPhonebook, KTest2ICCSlotsUsim);
       
   653 
       
   654 	// FDN Entry
       
   655 	SetSimTsyTestNumberL(2);
       
   656 	DoSyncL();
       
   657 	ReadLockedContactTextDefL(KUidIccGlobalFdnPhonebook, KTest2ICCSlotsFDN);
       
   658 
       
   659 	return TestStepResult();
       
   660 	}
       
   661 
       
   662 
       
   663 /************************ STRESS TESTS *****************************/
       
   664 
       
   665 /** 
       
   666  * Factory construction method.
       
   667  * @return Pointer to CPhbkSyncReadFullICCNameViewTest object
       
   668  */
       
   669 CPhbkSyncReadFullICCNameViewTest* CPhbkSyncReadFullICCNameViewTest::NewL()
       
   670 	{
       
   671 	CPhbkSyncReadFullICCNameViewTest* self = new(ELeave) CPhbkSyncReadFullICCNameViewTest();
       
   672 	return self;
       
   673 	}
       
   674 
       
   675 /**
       
   676  *  Default constructor.  Each test step initialises it's own name.
       
   677  */
       
   678 CPhbkSyncReadFullICCNameViewTest::CPhbkSyncReadFullICCNameViewTest()
       
   679 	{
       
   680 	SetTestStepName(_L("ReadFullICCNameViewTest"));
       
   681 	}
       
   682 
       
   683 /** 
       
   684  * Read operation stress test.
       
   685  *
       
   686  * Read a full phonebook with the name view.
       
   687  */
       
   688 enum TVerdict CPhbkSyncReadFullICCNameViewTest::doTestStepL()
       
   689 	{
       
   690 	// ensure contact database entries are removed because this test demands that 
       
   691 	// the order of new entry IDs corresponds to the order of the test data entries
       
   692 	delete iDb;
       
   693 	iDb=NULL;
       
   694 	User::After(1000000); //1 second wait for contact to shut down
       
   695 	iSession.Close();
       
   696 	ConfigurePhbkSyncToIdleL();
       
   697 	TRAP_IGNORE(CContactDatabase::DeleteDefaultFileL());	
       
   698 	ConfigurePhbkSyncToFullL();
       
   699 	iDb = OpenOrCreateContactDatabaseL();
       
   700 	User::After(1000000); //1 second wait for contact to start the phbk server
       
   701 	User::LeaveIfError(iSession.Connect());
       
   702 	User::After(3000000); //3 second wait for server to create phbktable
       
   703 
       
   704 	// Test data for this scenario is divided into individual phonebooks because
       
   705 	// SIMTSY cannot handle maximum entries for all phonebooks in a single set.
       
   706 	// Data provided is not necessarily the maximum possible for each phonebook
       
   707 	// due to inability to predict stack usage at the point of testing.
       
   708 	TRequestStatus status; 
       
   709 
       
   710 	// Global ADN
       
   711 	SetSimTsyTestNumberL(131);
       
   712 	iSession.DoSynchronisation(status);
       
   713 	User::WaitForRequest(status);
       
   714 	TESTCHECKL(status.Int(), KErrNone);
       
   715 	ReadAllContactNameViewL(KUidIccGlobalAdnPhonebook, KTest13ICCSlotsADN);
       
   716 
       
   717 	// Global SDN
       
   718 	SetSimTsyTestNumberL(132);
       
   719 	iSession.DoSynchronisation(status, KUidIccGlobalSdnPhonebook);
       
   720 	User::WaitForRequest(status);
       
   721 	TESTCHECKL(status.Int(), KErrNone);
       
   722 	ReadAllContactNameViewL(KUidIccGlobalSdnPhonebook, KTest13ICCSlotsSDN);
       
   723 
       
   724 	// Global LND
       
   725 	SetSimTsyTestNumberL(133);
       
   726 	iSession.DoSynchronisation(status, KUidIccGlobalLndPhonebook);
       
   727 	User::WaitForRequest(status);
       
   728 	TESTCHECKL(status.Int(), KErrNone);
       
   729 	ReadAllContactNameViewL(KUidIccGlobalLndPhonebook, KTest13ICCSlotsLND);
       
   730 
       
   731 	// USIM App
       
   732 	SetSimTsyTestNumberL(134);
       
   733 	iSession.DoSynchronisation(status, KUidUsimAppAdnPhonebook);
       
   734 	User::WaitForRequest(status);
       
   735 	TESTCHECKL(status.Int(), KErrNone);
       
   736 	ReadAllContactNameViewL(KUidUsimAppAdnPhonebook, KTest13ICCSlotsUsim);
       
   737 
       
   738 	// Global FDN
       
   739 	SetSimTsyTestNumberL(135);
       
   740 	iSession.DoSynchronisation(status, KUidIccGlobalFdnPhonebook);
       
   741 	User::WaitForRequest(status);
       
   742 	TESTCHECKL(status.Int(), KErrNone);
       
   743 	ReadAllContactNameViewL(KUidIccGlobalFdnPhonebook, KTest13ICCSlotsFDN);
       
   744 
       
   745 	return TestStepResult();
       
   746 	}
       
   747 
       
   748 
       
   749 /** 
       
   750  * Factory construction method.
       
   751  * @return Pointer to CPhbkSyncReadFullICCNumberViewTest object
       
   752  */
       
   753 CPhbkSyncReadFullICCNumberViewTest* CPhbkSyncReadFullICCNumberViewTest::NewL()
       
   754 	{
       
   755 	CPhbkSyncReadFullICCNumberViewTest* self = new(ELeave) CPhbkSyncReadFullICCNumberViewTest();
       
   756 	return self;
       
   757 	}
       
   758 
       
   759 /**
       
   760  *  Default constructor.  Each test step initialises it's own name.
       
   761  */
       
   762 CPhbkSyncReadFullICCNumberViewTest::CPhbkSyncReadFullICCNumberViewTest()
       
   763 	{
       
   764 	SetTestStepName(_L("ReadFullICCNumberViewTest"));
       
   765 	}
       
   766 
       
   767 /** 
       
   768  * Read operation stress test.
       
   769  *
       
   770  * Read a full phonebook with the number view. It is also necessary to view the Contacts DB 
       
   771  * using the development UI to ensure that these test cases pass.
       
   772  */
       
   773 enum TVerdict CPhbkSyncReadFullICCNumberViewTest::doTestStepL()
       
   774 	{
       
   775 	// Test data for this scenario is divided into individual phonebooks because
       
   776 	// SIMTSY cannot handle maximum entries for all phonebooks in a single set.
       
   777 	// Data provided is not necessarily the maximum possible for each phonebook
       
   778 	// due to inability to predict stack usage at the point of testing.
       
   779 	TRequestStatus status; 
       
   780 
       
   781 	// Global ADN
       
   782 	SetSimTsyTestNumberL(131);
       
   783 	iSession.DoSynchronisation(status);
       
   784 	User::WaitForRequest(status);
       
   785 	TESTCHECKL(status.Int(), KErrNone);
       
   786 	ReadAllContactNumberViewL(KUidIccGlobalAdnPhonebook, KTest13ICCSlotsADN);
       
   787 
       
   788 	// Global SDN
       
   789 	SetSimTsyTestNumberL(132);
       
   790 	iSession.DoSynchronisation(status, KUidIccGlobalSdnPhonebook);
       
   791 	User::WaitForRequest(status);
       
   792 	TESTCHECKL(status.Int(), KErrNone);
       
   793 	ReadAllContactNumberViewL(KUidIccGlobalSdnPhonebook, KTest13ICCSlotsSDN);
       
   794 
       
   795 	// Global LND
       
   796 	SetSimTsyTestNumberL(133);
       
   797 	iSession.DoSynchronisation(status, KUidIccGlobalLndPhonebook);
       
   798 	User::WaitForRequest(status);
       
   799 	TESTCHECKL(status.Int(), KErrNone);
       
   800 	ReadAllContactNumberViewL(KUidIccGlobalLndPhonebook, KTest13ICCSlotsLND);
       
   801 
       
   802 	// USIM App
       
   803 	SetSimTsyTestNumberL(134);
       
   804 	iSession.DoSynchronisation(status, KUidUsimAppAdnPhonebook);
       
   805 	User::WaitForRequest(status);
       
   806 	TESTCHECKL(status.Int(), KErrNone);
       
   807 	ReadAllContactNumberViewL(KUidUsimAppAdnPhonebook, KTest13ICCSlotsUsim);
       
   808 
       
   809 	// Global FDN
       
   810 	SetSimTsyTestNumberL(135);
       
   811 	iSession.DoSynchronisation(status, KUidIccGlobalFdnPhonebook);
       
   812 	User::WaitForRequest(status);
       
   813 	TESTCHECKL(status.Int(), KErrNone);
       
   814 	ReadAllContactNumberViewL(KUidIccGlobalFdnPhonebook, KTest13ICCSlotsFDN);
       
   815 
       
   816 	return TestStepResult();
       
   817 	}
       
   818 
       
   819 
       
   820 /** 
       
   821  * Factory construction method.
       
   822  * @return Pointer to CPhbkSyncReadFullICCFullViewTest object
       
   823  */
       
   824 CPhbkSyncReadFullICCFullViewTest* CPhbkSyncReadFullICCFullViewTest::NewL()
       
   825 	{
       
   826 	CPhbkSyncReadFullICCFullViewTest* self = new(ELeave) CPhbkSyncReadFullICCFullViewTest();
       
   827 	return self;
       
   828 	}
       
   829 
       
   830 /**
       
   831  *  Default constructor.  Each test step initialises it's own name.
       
   832  */
       
   833 CPhbkSyncReadFullICCFullViewTest::CPhbkSyncReadFullICCFullViewTest()
       
   834 	{
       
   835 	SetTestStepName(_L("ReadFullICCFullViewTest"));
       
   836 	}
       
   837 
       
   838 /** 
       
   839  * Read a full phonebook with the full view.
       
   840  */
       
   841 enum TVerdict CPhbkSyncReadFullICCFullViewTest::doTestStepL()
       
   842 	{
       
   843 	// Test data for this scenario is divided into individual phonebooks because
       
   844 	// SIMTSY cannot handle maximum entries for all phonebooks in a single set.
       
   845 	// Data provided is not necessarily the maximum possible for each phonebook
       
   846 	// due to inability to predict stack usage at the point of testing.
       
   847 	TRequestStatus status; 
       
   848 
       
   849 	// Global ADN
       
   850 	SetSimTsyTestNumberL(131);
       
   851 	iSession.DoSynchronisation(status);
       
   852 	User::WaitForRequest(status);
       
   853 	TESTCHECKL(status.Int(), KErrNone);
       
   854 	ReadAllContactFullViewL(KUidIccGlobalAdnPhonebook, KTest13ICCSlotsADN);
       
   855 
       
   856 	// Global SDN
       
   857 	SetSimTsyTestNumberL(132);
       
   858 	iSession.DoSynchronisation(status, KUidIccGlobalSdnPhonebook);
       
   859 	User::WaitForRequest(status);
       
   860 	TESTCHECKL(status.Int(), KErrNone);
       
   861 	ReadAllContactFullViewL(KUidIccGlobalSdnPhonebook, KTest13ICCSlotsSDN);
       
   862 
       
   863 	// Global LND
       
   864 	SetSimTsyTestNumberL(133);
       
   865 	iSession.DoSynchronisation(status, KUidIccGlobalLndPhonebook);
       
   866 	User::WaitForRequest(status);
       
   867 	TESTCHECKL(status.Int(), KErrNone);
       
   868 	ReadAllContactFullViewL(KUidIccGlobalLndPhonebook, KTest13ICCSlotsLND);
       
   869 
       
   870 	// USIM App
       
   871 	SetSimTsyTestNumberL(134);
       
   872 	iSession.DoSynchronisation(status, KUidUsimAppAdnPhonebook);
       
   873 	User::WaitForRequest(status);
       
   874 	TESTCHECKL(status.Int(), KErrNone);
       
   875 	ReadAllContactFullViewL(KUidUsimAppAdnPhonebook, KTest13ICCSlotsUsim);
       
   876 
       
   877 	// Global FDN
       
   878 	SetSimTsyTestNumberL(135);
       
   879 	iSession.DoSynchronisation(status, KUidIccGlobalFdnPhonebook);
       
   880 	User::WaitForRequest(status);
       
   881 	TESTCHECKL(status.Int(), KErrNone);
       
   882 	ReadAllContactFullViewL(KUidIccGlobalFdnPhonebook, KTest13ICCSlotsFDN);
       
   883 
       
   884 	return TestStepResult();
       
   885 	}
       
   886 
       
   887 
       
   888 /** 
       
   889  * Factory construction method.
       
   890  * @return Pointer to CPhbkSyncReadFullICCNameTextDefTest object
       
   891  */
       
   892 CPhbkSyncReadFullICCNameTextDefTest* CPhbkSyncReadFullICCNameTextDefTest::NewL()
       
   893 	{
       
   894 	CPhbkSyncReadFullICCNameTextDefTest* self = new(ELeave) CPhbkSyncReadFullICCNameTextDefTest();
       
   895 	return self;
       
   896 	}
       
   897 
       
   898 /**
       
   899  *  Default constructor.  Each test step initialises it's own name.
       
   900  */
       
   901 CPhbkSyncReadFullICCNameTextDefTest::CPhbkSyncReadFullICCNameTextDefTest()
       
   902 	{
       
   903 	SetTestStepName(_L("ReadFullICCNameTextDefTest"));
       
   904 	}
       
   905 
       
   906 /** 
       
   907  * Read a full phonebook - create name string from contact info.
       
   908  */
       
   909 enum TVerdict CPhbkSyncReadFullICCNameTextDefTest::doTestStepL()
       
   910 	{
       
   911 	// Test data for this scenario is divided into individual phonebooks because
       
   912 	// SIMTSY cannot handle maximum entries for all phonebooks in a single set.
       
   913 	// Data provided is not necessarily the maximum possible for each phonebook
       
   914 	// due to inability to predict stack usage at the point of testing.
       
   915 	TRequestStatus status; 
       
   916 
       
   917 	// Global ADN
       
   918 	SetSimTsyTestNumberL(131);
       
   919 	iSession.DoSynchronisation(status);
       
   920 	User::WaitForRequest(status);
       
   921 	TESTCHECKL(status.Int(), KErrNone);
       
   922 	ReadNameContactTextDefL(KUidIccGlobalAdnPhonebook, KTest13ICCSlotsADN, ETrue);
       
   923 
       
   924 	// Global SDN
       
   925 	SetSimTsyTestNumberL(132);
       
   926 	iSession.DoSynchronisation(status, KUidIccGlobalSdnPhonebook);
       
   927 	User::WaitForRequest(status);
       
   928 	TESTCHECKL(status.Int(), KErrNone);
       
   929 	ReadNameContactTextDefL(KUidIccGlobalSdnPhonebook, KTest13ICCSlotsSDN, ETrue);
       
   930 
       
   931 	// Global LND
       
   932 	SetSimTsyTestNumberL(133);
       
   933 	iSession.DoSynchronisation(status, KUidIccGlobalLndPhonebook);
       
   934 	User::WaitForRequest(status);
       
   935 	TESTCHECKL(status.Int(), KErrNone);
       
   936 	ReadNameContactTextDefL(KUidIccGlobalLndPhonebook, KTest13ICCSlotsLND, ETrue);
       
   937 
       
   938 	// USIM App
       
   939 	SetSimTsyTestNumberL(134);
       
   940 	iSession.DoSynchronisation(status, KUidUsimAppAdnPhonebook);
       
   941 	User::WaitForRequest(status);
       
   942 	TESTCHECKL(status.Int(), KErrNone);
       
   943 	ReadNameContactTextDefL(KUidUsimAppAdnPhonebook, KTest13ICCSlotsUsim, ETrue);
       
   944 
       
   945 	// Global FDN
       
   946 	SetSimTsyTestNumberL(135);
       
   947 	iSession.DoSynchronisation(status, KUidIccGlobalFdnPhonebook);
       
   948 	User::WaitForRequest(status);
       
   949 	TESTCHECKL(status.Int(), KErrNone);
       
   950 	ReadNameContactTextDefL(KUidIccGlobalFdnPhonebook, KTest13ICCSlotsFDN, ETrue);
       
   951 
       
   952 	return TestStepResult();
       
   953 	}
       
   954 
       
   955 
       
   956 /** 
       
   957  * Factory construction method.
       
   958  * @return Pointer to CPhbkSyncReadFullICCNumberTextDefTest object
       
   959  */
       
   960 CPhbkSyncReadFullICCNumberTextDefTest* CPhbkSyncReadFullICCNumberTextDefTest::NewL()
       
   961 	{
       
   962 	CPhbkSyncReadFullICCNumberTextDefTest* self = new(ELeave) CPhbkSyncReadFullICCNumberTextDefTest();
       
   963 	return self;
       
   964 	}
       
   965 
       
   966 /**
       
   967  *  Default constructor.  Each test step initialises it's own name.
       
   968  */
       
   969 CPhbkSyncReadFullICCNumberTextDefTest::CPhbkSyncReadFullICCNumberTextDefTest()
       
   970 	{
       
   971 	SetTestStepName(_L("ReadFullICCNumberTextDefTest"));
       
   972 	}
       
   973 
       
   974 /** 
       
   975  * Read a full phonebook - create number string from contact info.
       
   976  */
       
   977 enum TVerdict CPhbkSyncReadFullICCNumberTextDefTest::doTestStepL()
       
   978 	{
       
   979 	// Test data for this scenario is divided into individual phonebooks because
       
   980 	// SIMTSY cannot handle maximum entries for all phonebooks in a single set.
       
   981 	// Data provided is not necessarily the maximum possible for each phonebook
       
   982 	// due to inability to predict stack usage at the point of testing.
       
   983 	TRequestStatus status; 
       
   984 
       
   985 	// Global ADN
       
   986 	SetSimTsyTestNumberL(131);
       
   987 	iSession.DoSynchronisation(status);
       
   988 	User::WaitForRequest(status);
       
   989 	TESTCHECKL(status.Int(), KErrNone);
       
   990 	ReadNumberContactTextDefL(KUidIccGlobalAdnPhonebook, KTest13ICCSlotsADN, ETrue);
       
   991 
       
   992 	// Global SDN
       
   993 	SetSimTsyTestNumberL(132);
       
   994 	iSession.DoSynchronisation(status, KUidIccGlobalSdnPhonebook);
       
   995 	User::WaitForRequest(status);
       
   996 	TESTCHECKL(status.Int(), KErrNone);
       
   997 	ReadNumberContactTextDefL(KUidIccGlobalSdnPhonebook, KTest13ICCSlotsSDN, ETrue);
       
   998 
       
   999 	// Global LND
       
  1000 	SetSimTsyTestNumberL(133);
       
  1001 	iSession.DoSynchronisation(status, KUidIccGlobalLndPhonebook);
       
  1002 	User::WaitForRequest(status);
       
  1003 	TESTCHECKL(status.Int(), KErrNone);
       
  1004 	ReadNumberContactTextDefL(KUidIccGlobalLndPhonebook, KTest13ICCSlotsLND, ETrue);
       
  1005 
       
  1006 	// USIM App
       
  1007 	SetSimTsyTestNumberL(134);
       
  1008 	iSession.DoSynchronisation(status, KUidUsimAppAdnPhonebook);
       
  1009 	User::WaitForRequest(status);
       
  1010 	TESTCHECKL(status.Int(), KErrNone);
       
  1011 	ReadNumberContactTextDefL(KUidUsimAppAdnPhonebook, KTest13ICCSlotsUsim, ETrue);
       
  1012 
       
  1013 	// Global FDN
       
  1014 	SetSimTsyTestNumberL(135);
       
  1015 	iSession.DoSynchronisation(status, KUidIccGlobalFdnPhonebook);
       
  1016 	User::WaitForRequest(status);
       
  1017 	TESTCHECKL(status.Int(), KErrNone);
       
  1018 	ReadNumberContactTextDefL(KUidIccGlobalFdnPhonebook, KTest13ICCSlotsFDN, ETrue);
       
  1019 
       
  1020 	return TestStepResult();
       
  1021 	}
       
  1022 
       
  1023 
       
  1024 /** 
       
  1025  * Factory construction method.
       
  1026  * @return Pointer to CPhbkSyncReadFullICCFullViewTextDefTest object
       
  1027  */
       
  1028 CPhbkSyncReadFullICCFullViewTextDefTest* CPhbkSyncReadFullICCFullViewTextDefTest::NewL()
       
  1029 	{
       
  1030 	CPhbkSyncReadFullICCFullViewTextDefTest* self = new(ELeave) CPhbkSyncReadFullICCFullViewTextDefTest();
       
  1031 	return self;
       
  1032 	}
       
  1033 
       
  1034 /**
       
  1035  *  Default constructor.  Each test step initialises it's own name.
       
  1036  */
       
  1037 CPhbkSyncReadFullICCFullViewTextDefTest::CPhbkSyncReadFullICCFullViewTextDefTest()
       
  1038 	{
       
  1039 	SetTestStepName(_L("ReadFullICCFullViewTextDefTest"));
       
  1040 	}
       
  1041 
       
  1042 /** 
       
  1043  * Read a full phonebook - create string from contact info (full view).
       
  1044  */
       
  1045 enum TVerdict CPhbkSyncReadFullICCFullViewTextDefTest::doTestStepL()
       
  1046 	{
       
  1047 	// Test data for this scenario is divided into individual phonebooks because
       
  1048 	// SIMTSY cannot handle maximum entries for all phonebooks in a single set.
       
  1049 	// Data provided is not necessarily the maximum possible for each phonebook
       
  1050 	// due to inability to predict stack usage at the point of testing.
       
  1051 	TRequestStatus status; 
       
  1052 
       
  1053 	// Global ADN
       
  1054 	SetSimTsyTestNumberL(131);
       
  1055 	iSession.DoSynchronisation(status);
       
  1056 	User::WaitForRequest(status);
       
  1057 	TESTCHECKL(status.Int(), KErrNone);
       
  1058 	ReadFullContactTextDefL(KUidIccGlobalAdnPhonebook, KTest13ICCSlotsADN, ETrue);
       
  1059 
       
  1060 	// Global SDN
       
  1061 	SetSimTsyTestNumberL(132);
       
  1062 	iSession.DoSynchronisation(status, KUidIccGlobalSdnPhonebook);
       
  1063 	User::WaitForRequest(status);
       
  1064 	TESTCHECKL(status.Int(), KErrNone);
       
  1065 	ReadFullContactTextDefL(KUidIccGlobalSdnPhonebook, KTest13ICCSlotsSDN, ETrue);
       
  1066 
       
  1067 	// Global LND
       
  1068 	SetSimTsyTestNumberL(133);
       
  1069 	iSession.DoSynchronisation(status, KUidIccGlobalLndPhonebook);
       
  1070 	User::WaitForRequest(status);
       
  1071 	TESTCHECKL(status.Int(), KErrNone);
       
  1072 	ReadFullContactTextDefL(KUidIccGlobalLndPhonebook, KTest13ICCSlotsLND, ETrue);
       
  1073 
       
  1074 	// USIM App
       
  1075 	SetSimTsyTestNumberL(134);
       
  1076 	iSession.DoSynchronisation(status, KUidUsimAppAdnPhonebook);
       
  1077 	User::WaitForRequest(status);
       
  1078 	TESTCHECKL(status.Int(), KErrNone);
       
  1079 	ReadFullContactTextDefL(KUidUsimAppAdnPhonebook, KTest13ICCSlotsUsim, ETrue);
       
  1080 
       
  1081 	// Global FDN
       
  1082 	SetSimTsyTestNumberL(135);
       
  1083 	iSession.DoSynchronisation(status, KUidIccGlobalFdnPhonebook);
       
  1084 	User::WaitForRequest(status);
       
  1085 	TESTCHECKL(status.Int(), KErrNone);
       
  1086 	ReadFullContactTextDefL(KUidIccGlobalFdnPhonebook, KTest13ICCSlotsFDN, ETrue);
       
  1087 
       
  1088 	return TestStepResult();
       
  1089 	}
       
  1090 
       
  1091 
       
  1092 /** 
       
  1093  * Check group membership.
       
  1094  * All ICC entries synchronised should belong to a single group. This group 
       
  1095  * should contain all the ADN phonebook entries
       
  1096  *
       
  1097  * @param aItem             ICC entry 
       
  1098  * @param aExpectedMembers  Expected number of members of the ADN phonebook
       
  1099  */
       
  1100 void CPhbkReadIntegrationTestBase::CheckGroupMembershipL(CContactICCEntry& aItem, TInt aExpectedMembers)
       
  1101 	{
       
  1102 	const CContactIdArray* owned = aItem.GroupsJoined();	
       
  1103 	TESTCHECKCONDITIONL(owned != NULL);
       
  1104 	TESTCHECKL(owned->Count(), 1);
       
  1105 	TContactItemId groupId = (*owned)[0];
       
  1106 
       
  1107 	CContactGroup* group = static_cast<CContactGroup*>(iDb->ReadContactL(groupId));
       
  1108 	CleanupStack::PushL(group);	
       
  1109 	const CContactIdArray* itemsContained = group->ItemsContained();
       
  1110 	TESTCHECKL(itemsContained->Count(), aExpectedMembers);
       
  1111 	CleanupStack::PopAndDestroy(group);	
       
  1112 	}
       
  1113 
       
  1114 /** 
       
  1115  * Check that the field of type aFieldType has the same content as 
       
  1116  * aExpectedContent
       
  1117  * @param aFieldset Contact item fieldset
       
  1118  * @param aFieldType Field type to test
       
  1119  * @param aExpectedContent Expected data
       
  1120  */
       
  1121 void CPhbkReadIntegrationTestBase::CheckFieldContentL(CContactItemFieldSet& aFieldset, TFieldType aFieldType, const TDesC& aExpectedContent)
       
  1122 	{
       
  1123 	TInt pos = aFieldset.Find(aFieldType);
       
  1124 	CContactItemField& field = aFieldset[pos];
       
  1125 	CContactTextField* textField = field.TextStorage();
       
  1126 	TESTCHECKCONDITION(textField != NULL);
       
  1127 	TESTCHECKCONDITIONL(textField->Text() == aExpectedContent);
       
  1128 	}
       
  1129 
       
  1130 
       
  1131 /** 
       
  1132  * Check that the field of type aFieldType has the same content as 
       
  1133  * aExpectedContent.  This method is an overload of 
       
  1134  * CPhbkReadIntegrationTestBase::CheckFieldContentL(CContactItemFieldSet& aFieldset, TFieldType aFieldType, const TDesC& aExpectedContent)
       
  1135  * and allows the user to check the field content of a field when there
       
  1136  * are multiple instances of the field in the CContactItemfieldSet array 
       
  1137  * specified.  This can be done by specifying the position in the array
       
  1138  * to start searching from.
       
  1139  *
       
  1140  * @param aFieldset Contact item fieldset
       
  1141  * @param aFieldType Field type to test
       
  1142  * @param aSearchFromPos The index in aFieldSet to start searching from
       
  1143  * @param aExpectedContent Expected data
       
  1144  */
       
  1145 void CPhbkReadIntegrationTestBase::CheckFieldContentL(CContactItemFieldSet& aFieldset, TFieldType aFieldType, TInt aSearchFromPos, const TDesC& aExpectedContent)
       
  1146 	{
       
  1147 	TInt pos = aFieldset.FindNext(aFieldType, aSearchFromPos);
       
  1148 	CContactItemField& field = aFieldset[pos];
       
  1149 	CContactTextField* textField = field.TextStorage();
       
  1150 	TESTCHECKCONDITION(textField != NULL);
       
  1151 	TESTCHECKCONDITIONL(textField->Text() == aExpectedContent);
       
  1152 	}
       
  1153 	
       
  1154 /** 
       
  1155  * Check that aEntry contains correct number of fields.
       
  1156  *
       
  1157  * @param aPhonebook  ICC Phonebook to check.
       
  1158  * @param aEntry      Contact ICC Entry
       
  1159  */
       
  1160 void CPhbkReadIntegrationTestBase::CheckFieldCountL(const TUid aPhonebook, CContactICCEntry* aEntry)
       
  1161 	{
       
  1162 	CContactItemFieldSet& fieldset = aEntry->CardFields();
       
  1163 	const TInt fieldsetCount = fieldset.Count(); //for debugging
       
  1164 	if (aPhonebook == KUidUsimAppAdnPhonebook)
       
  1165 		{
       
  1166 		TESTCHECKCONDITION(fieldsetCount >= 6); //Name,Number,email,ICC slot, phonebook
       
  1167 		}
       
  1168 	else
       
  1169 		{
       
  1170 		TESTCHECKCONDITION(fieldsetCount >= 5); //Name,Number,ICC slot, phonebook
       
  1171 		}
       
  1172 	}
       
  1173 
       
  1174 /** 
       
  1175  * Check that aEntry contains correct number of fields for minimal contact item.
       
  1176  *
       
  1177  * @param aPhonebook  ICC Phonebook to check.
       
  1178  * @param aEntry      Contact ICC Entry
       
  1179  */
       
  1180 void CPhbkReadIntegrationTestBase::CheckMinimalFieldCountL(const TUid aPhonebook, CContactICCEntry* aEntry)
       
  1181 	{
       
  1182 	CContactItemFieldSet& fieldset = aEntry->CardFields();
       
  1183 	const TInt fieldsetCount = fieldset.Count(); //for debugging
       
  1184 	if (aPhonebook == KUidUsimAppAdnPhonebook)
       
  1185 		{
       
  1186 		TESTCHECKCONDITION(fieldsetCount >= 5); //Name,Number,email,ICC slot, phonebook
       
  1187 		}
       
  1188 	else
       
  1189 		{
       
  1190 		TESTCHECKCONDITION(fieldsetCount >= 4); //Name,Number,ICC slot, phonebook
       
  1191 		}
       
  1192 	}
       
  1193 
       
  1194 /** 
       
  1195  * Check that the field data stored on the SIM is identical to the
       
  1196  * data stored in Contacts model.
       
  1197  * @param aPhonebook type of phonebook
       
  1198  * @param aItem ICC item to test
       
  1199  * @param aSlotNumber Slot number 
       
  1200  */
       
  1201 void CPhbkReadIntegrationTestBase::CheckFieldsL(const TUid aPhonebook, CContactICCEntry* aItem, TInt aSlotNumber)
       
  1202 	{
       
  1203 	TBuf<20> buf;
       
  1204 	CContactItemFieldSet& fieldset = aItem->CardFields();
       
  1205 	if(aPhonebook == KUidIccGlobalAdnPhonebook)
       
  1206 		{
       
  1207 		buf.Format(KNameFormat, 'A', aSlotNumber);
       
  1208 		}
       
  1209 	else if(aPhonebook == KUidIccGlobalSdnPhonebook)
       
  1210 		{
       
  1211 		buf.Format(KNameFormat, 'B', aSlotNumber);
       
  1212 		}
       
  1213 	else if(aPhonebook == KUidIccGlobalLndPhonebook)
       
  1214 		{
       
  1215 		buf.Format(KNameFormat, 'C', aSlotNumber);
       
  1216 		}
       
  1217 	else if(aPhonebook == KUidUsimAppAdnPhonebook)
       
  1218 		{
       
  1219 		buf.Format(KNameFormat, 'D', aSlotNumber);
       
  1220 		}
       
  1221 	else if(aPhonebook == KUidIccGlobalFdnPhonebook)
       
  1222 		{
       
  1223 		buf.Format(KNameFormat, 'E', aSlotNumber);
       
  1224 		}
       
  1225 	CheckFieldContentL(fieldset,KUidContactFieldFamilyName,buf);
       
  1226 	buf.Format(KNumberFormat,aSlotNumber);
       
  1227 	CheckFieldContentL(fieldset,KUidContactFieldPhoneNumber,buf);
       
  1228 	if(aPhonebook == KUidUsimAppAdnPhonebook)
       
  1229 		{
       
  1230 		buf.Format(KEmailFormat,aSlotNumber);
       
  1231 		CheckFieldContentL(fieldset,KUidContactFieldEMail,buf);
       
  1232 		}
       
  1233 	}
       
  1234 
       
  1235 /** 
       
  1236  * Read all ICC entry - normal case.
       
  1237  * Check group membership is correct and relevant number of fields have
       
  1238  * been created.
       
  1239  */
       
  1240 void CPhbkReadIntegrationTestBase::ReadContactL(const TUid aPhonebook, TInt aExpectedCount, TBool aReadAll)
       
  1241 	{
       
  1242 	iDb->SetDbViewContactType(KUidContactICCEntry);
       
  1243 	// get the unique groupId for the given phonebook
       
  1244 	TContactItemId groupId(KNullContactId);
       
  1245 	User::LeaveIfError(iSession.GetPhoneBookId(groupId, 
       
  1246 						RPhoneBookSession::ESyncGroupId,
       
  1247 						aPhonebook));
       
  1248 	TESTCHECKCONDITIONL(groupId != KNullContactId);
       
  1249   
       
  1250 	// based on the groupId, get items belonging to the phonebook
       
  1251 	CContactGroup* group = NULL;
       
  1252 	TRAPD(err, group = static_cast<CContactGroup*>(iDb->ReadContactL(groupId)));
       
  1253 	TESTCHECKL(err, KErrNone);
       
  1254 	CleanupStack::PushL(group);
       
  1255 	const CContactIdArray* array = group->ItemsContained();
       
  1256 
       
  1257 	// Verify correct number of entries created for this phonebook
       
  1258 	TInt count = array->Count(); // for debugging
       
  1259 	TESTCHECKL(count, aExpectedCount);
       
  1260 
       
  1261   	// Read all items or only first?
       
  1262   	if (!aReadAll)
       
  1263   		count = 1;
       
  1264   	
       
  1265 	for (TInt i=0; i<count; ++i)
       
  1266 		{
       
  1267 		TContactItemId id = (*array)[i];
       
  1268 		CContactICCEntry* entry = NULL;
       
  1269 		TRAP(err, entry = static_cast<CContactICCEntry*>(iDb->ReadContactL(id)));
       
  1270 		TESTCHECKL(err, KErrNone);
       
  1271 		CleanupStack::PushL(entry);
       
  1272 		// Verify correct number of fields created for entry
       
  1273 		CheckFieldCountL(aPhonebook, entry);
       
  1274 		CleanupStack::PopAndDestroy(); // entry
       
  1275 		}
       
  1276 
       
  1277 	CleanupStack::PopAndDestroy(); // group
       
  1278 	}
       
  1279 
       
  1280 /** 
       
  1281  * Read a sequence of ICC entries - normal case.
       
  1282  * Check group membership is correct and check field content
       
  1283  */
       
  1284 void CPhbkReadIntegrationTestBase::ReadAllContactContentL(const TUid aPhonebook, TInt aExpectedCount)
       
  1285 	{
       
  1286 	iDb->SetDbViewContactType(KUidContactICCEntry);
       
  1287 	// get the unique groupId for the given phonebook
       
  1288 	TContactItemId groupId(KNullContactId);
       
  1289 	User::LeaveIfError(iSession.GetPhoneBookId(groupId, 
       
  1290 						RPhoneBookSession::ESyncGroupId,
       
  1291 						aPhonebook));
       
  1292 	TESTCHECKCONDITIONL(groupId != KNullContactId);
       
  1293   
       
  1294 	// based on the groupId, get items belonging to the phonebook
       
  1295 	CContactGroup* group = NULL;
       
  1296 	TRAPD(err, group = static_cast<CContactGroup*>(iDb->ReadContactL(groupId)));
       
  1297 	TESTCHECKL(err, KErrNone);
       
  1298 	CleanupStack::PushL(group);
       
  1299 	const CContactIdArray* array = group->ItemsContained();
       
  1300 
       
  1301 	// Verify correct number of entries created for this phonebook
       
  1302 	const TInt count = array->Count(); // for debugging
       
  1303 	TESTCHECKL(count, aExpectedCount);
       
  1304 
       
  1305 	// Read each item
       
  1306 	for (TInt i=0; i<count; ++i)
       
  1307 		{
       
  1308 		TContactItemId id = (*array)[i];
       
  1309 		CContactICCEntry* entry = NULL;
       
  1310 		TRAP(err, entry = static_cast<CContactICCEntry*>(iDb->ReadContactL(id)));
       
  1311 		TESTCHECKL(err, KErrNone);
       
  1312 		delete entry;
       
  1313 		}
       
  1314 
       
  1315 	CleanupStack::PopAndDestroy(); // group
       
  1316 	}
       
  1317 
       
  1318 /** 
       
  1319  * Read a ICC entry - entry not available as the ICC becomes locked.
       
  1320  */
       
  1321 void CPhbkReadIntegrationTestBase::ReadFullContactLockedL(const TUid aPhonebook, TInt aExpectedCount)
       
  1322 	{
       
  1323 	iDb->SetDbViewContactType(KUidContactICCEntry);
       
  1324 	// get the unique groupId for the given phonebook
       
  1325 	TContactItemId groupId(KNullContactId);
       
  1326 	User::LeaveIfError(iSession.GetPhoneBookId(groupId, 
       
  1327 						RPhoneBookSession::ESyncGroupId,
       
  1328 						aPhonebook));
       
  1329 	TESTCHECKCONDITIONL(groupId != KNullContactId);
       
  1330   
       
  1331 	// based on the groupId, get items belonging to the phonebook
       
  1332 	CContactGroup* group = NULL;
       
  1333 	TRAPD(err, group = static_cast<CContactGroup*>(iDb->ReadContactL(groupId)));
       
  1334 	TESTCHECKL(err, KErrNone);
       
  1335 	CleanupStack::PushL(group);
       
  1336 	const CContactIdArray* array = group->ItemsContained();
       
  1337 	SignalSimTsyToReduceTimersL();
       
  1338 
       
  1339 	// Access ICC and wait for it to become locked
       
  1340 	TContactItemId id = (*array)[0]; 
       
  1341 	while(err==KErrNone) 
       
  1342 		{
       
  1343 		User::After(1000000);	// Wait a second and try again.
       
  1344 		CContactICCEntry* failEntry=NULL;
       
  1345 		TRAP(err, failEntry = (CContactICCEntry*)iDb->ReadContactL(id, *iDb->AllFieldsView())); // Entry unavailable due to ICC being locked
       
  1346 		delete failEntry;
       
  1347 		}
       
  1348 	TESTCHECKL(err, KErrAccessDenied);
       
  1349 	SignalSimTsyToReduceTimersL();
       
  1350 
       
  1351 	// Wait for ICC to become unlocked again
       
  1352 	while(err==KErrAccessDenied) 
       
  1353 		{
       
  1354 		User::After(1000000);	// Wait a second and try again.
       
  1355 		CContactICCEntry* failEntry=NULL;
       
  1356 		TRAP(err, failEntry = (CContactICCEntry*)iDb->ReadContactL(id, *iDb->AllFieldsView())); // Entry unavailable due to ICC being locked
       
  1357 		delete failEntry;
       
  1358 		}
       
  1359 
       
  1360 	WaitForSyncToCompleteL();
       
  1361 
       
  1362 	// Read the item again
       
  1363 	CContactICCEntry* entry = NULL;
       
  1364 	TRAP(err, entry = static_cast<CContactICCEntry*>(iDb->ReadContactL(id, *iDb->AllFieldsView())));
       
  1365 	TESTCHECKL(err, KErrNone);
       
  1366 	CleanupStack::PushL(entry);
       
  1367 
       
  1368 	// Verify correct number of entries created for this phonebook
       
  1369 	const TInt count = array->Count(); // for debugging
       
  1370 	TESTCHECKL(count, aExpectedCount);
       
  1371 
       
  1372 	// Verify correct number of fields created for entry
       
  1373 	CheckFieldCountL(aPhonebook, entry);
       
  1374 
       
  1375 	CleanupStack::PopAndDestroy(2); // group and entry
       
  1376 	}
       
  1377 
       
  1378 /** 
       
  1379  * Read ICC entry - specify full view, full view for non-existent entry, name, number 
       
  1380  * and invalid view
       
  1381  */
       
  1382 void CPhbkReadIntegrationTestBase::ReadContactViewsL(const TUid aPhonebook, TInt aExpectedCount)
       
  1383 	{
       
  1384 	iDb->SetDbViewContactType(KUidContactICCEntry);
       
  1385 	// get the unique groupId for the given phonebook
       
  1386 	TContactItemId groupId(KNullContactId);
       
  1387 	User::LeaveIfError(iSession.GetPhoneBookId(groupId, 
       
  1388 						RPhoneBookSession::ESyncGroupId,
       
  1389 						aPhonebook));
       
  1390 	TESTCHECKCONDITIONL(groupId != KNullContactId);
       
  1391   
       
  1392 	// based on the groupId, get items belonging to the phonebook
       
  1393 	CContactGroup* group = NULL;
       
  1394 	TRAPD(err, group = static_cast<CContactGroup*>(iDb->ReadContactL(groupId)));
       
  1395 	TESTCHECKL(err, KErrNone);
       
  1396 	CleanupStack::PushL(group);
       
  1397 	const CContactIdArray* array = group->ItemsContained();
       
  1398 
       
  1399 	// Verify correct number of entries created for this phonebook
       
  1400 	const TInt count = array->Count(); // for debugging
       
  1401 	TESTCHECKL(count, aExpectedCount);
       
  1402 
       
  1403 	TContactItemId id = (*array)[0];
       
  1404 
       
  1405 	// Full view 
       
  1406 	CContactICCEntry* entry = NULL;
       
  1407 	TRAP(err, entry = static_cast<CContactICCEntry*>(iDb->ReadContactL(id, *iDb->AllFieldsView())));
       
  1408 	TESTCHECKL(err, KErrNone);
       
  1409 	CleanupStack::PushL(entry);
       
  1410 	CheckGroupMembershipL(*entry,aExpectedCount);
       
  1411 	CheckFieldCountL(aPhonebook, entry); // Entry contains correct number of fields
       
  1412 	CleanupStack::PopAndDestroy();
       
  1413 
       
  1414 	// Full view non-existent entry
       
  1415 	TContactItemId invalidUID(9877); 
       
  1416 	TRAP(err,entry = static_cast<CContactICCEntry*>(iDb->ReadContactL(invalidUID, *iDb->AllFieldsView())));
       
  1417 	TESTCHECKL(err, KErrNotFound);
       
  1418 
       
  1419 	// Number view 
       
  1420 	CContactItemViewDef* numberView=CContactItemViewDef::NewL(CContactItemViewDef::EIncludeFields,CContactItemViewDef::EMaskHiddenFields);
       
  1421 	CleanupStack::PushL(numberView);
       
  1422 	numberView->AddL(KUidContactFieldPhoneNumber); 
       
  1423 	TESTCHECKL(numberView->Count(), 1);
       
  1424 	TRAP(err, entry = static_cast<CContactICCEntry*>(iDb->ReadContactL(id, *numberView))); 
       
  1425 	TESTCHECKL(err, KErrNone);
       
  1426 	CleanupStack::PushL(entry);
       
  1427 	CheckGroupMembershipL(*entry,aExpectedCount);
       
  1428 	CheckFieldCountL(aPhonebook, entry); // Entry contains correct number of fields
       
  1429 	CleanupStack::PopAndDestroy();
       
  1430 	CleanupStack::PopAndDestroy();
       
  1431 
       
  1432 	// Name view 
       
  1433 	CContactItemViewDef* nameView = CContactItemViewDef::NewL(CContactItemViewDef::EIncludeFields,CContactItemViewDef::EMaskHiddenFields);
       
  1434 	CleanupStack::PushL(nameView);
       
  1435 	nameView->AddL(KUidContactFieldFamilyName); 
       
  1436 	TESTCHECKL(nameView->Count(), 1);
       
  1437 	TRAP(err, entry = static_cast<CContactICCEntry*>(iDb->ReadContactL(id, *nameView)));
       
  1438 	TESTCHECKL(err, KErrNone);
       
  1439 	CleanupStack::PushL(entry);
       
  1440 	CheckGroupMembershipL(*entry,aExpectedCount);
       
  1441 	CheckFieldCountL(aPhonebook, entry); // Entry contains correct number of fields
       
  1442 	CleanupStack::PopAndDestroy();
       
  1443 	CleanupStack::PopAndDestroy();
       
  1444 
       
  1445 	// Invalid view 
       
  1446 	TUid invalidUid = {-2};
       
  1447 	CContactICCEntry* failEntry = NULL;
       
  1448 	CContactItemViewDef* invalidView=CContactItemViewDef::NewL(CContactItemViewDef::EMaskFields,CContactItemViewDef::EMaskHiddenFields);
       
  1449 	CleanupStack::PushL(invalidView);
       
  1450 	invalidView->AddL(invalidUid); 
       
  1451 	TESTCHECKL(invalidView->Count(), 1);
       
  1452 	TRAP(err, failEntry = (CContactICCEntry*)(iDb->ReadContactL(id, *invalidView)));
       
  1453 	TESTCHECKL(err, KErrNone); // valid id 
       
  1454 	CleanupStack::PushL(failEntry);
       
  1455 	CContactItemFieldSet& fieldset = failEntry->CardFields();
       
  1456 	const TInt pos(fieldset.Find(KUidContactFieldFamilyName));	
       
  1457 	CContactItemField& field = fieldset[pos];
       
  1458 	CContactTextField* textfield = field.TextStorage();
       
  1459 	TESTCHECKCONDITIONL(textfield->IsFull());
       
  1460 	CleanupStack::PopAndDestroy();
       
  1461 	CleanupStack::PopAndDestroy();
       
  1462 	SignalSimTsyToReduceTimersL();
       
  1463 
       
  1464 	// Full view entry not available
       
  1465 	while(err==KErrNone) // Wait for ICC to become locked
       
  1466 		{
       
  1467 		CContactICCEntry* entry = NULL;
       
  1468 		User::After(1000000);
       
  1469 		TRAP(err, entry = (CContactICCEntry*)iDb->ReadContactL(id, *iDb->AllFieldsView()));
       
  1470 		if (!err)
       
  1471 			delete entry;
       
  1472 		}
       
  1473 	TESTCHECKL(err, KErrAccessDenied);
       
  1474 
       
  1475 	CleanupStack::PopAndDestroy(group);	// group
       
  1476 	}
       
  1477 
       
  1478 /**
       
  1479  * Read an ICC contact - minimal read operation.
       
  1480  */
       
  1481 void CPhbkReadIntegrationTestBase::ReadMinimalContactL(const TUid aPhonebook, TInt aExpectedCount)
       
  1482 	{
       
  1483 	iDb->SetDbViewContactType(KUidContactICCEntry);
       
  1484 	// get the unique groupId for the given phonebook
       
  1485 	TContactItemId groupId(KNullContactId);
       
  1486 	User::LeaveIfError(iSession.GetPhoneBookId(groupId, 
       
  1487 						RPhoneBookSession::ESyncGroupId,
       
  1488 						aPhonebook));
       
  1489 	TESTCHECKCONDITIONL(groupId != KNullContactId);
       
  1490   
       
  1491 	// based on the groupId, get items belonging to the phonebook
       
  1492 	CContactGroup* group = NULL;
       
  1493 	TRAPD(err, group = static_cast<CContactGroup*>(iDb->ReadContactL(groupId)));
       
  1494 	TESTCHECKL(err, KErrNone);
       
  1495 	CleanupStack::PushL(group);
       
  1496 	const CContactIdArray* array = group->ItemsContained();
       
  1497 
       
  1498 	// Verify correct number of entries created for this phonebook
       
  1499 	const TInt count = array->Count(); // for debugging
       
  1500 	TESTCHECKL(count, aExpectedCount);
       
  1501 
       
  1502 	// Read entry
       
  1503 	TContactItemId id = (*array)[0];
       
  1504 	CContactICCEntry* entry = NULL;
       
  1505 	TRAP(err, entry = static_cast<CContactICCEntry*>(iDb->ReadMinimalContactL(id)));
       
  1506 	TESTCHECKL(err, KErrNone);
       
  1507 	CleanupStack::PushL(entry);
       
  1508 	CheckMinimalFieldCountL(aPhonebook, entry); // Entry contains correct number of fields
       
  1509 
       
  1510 	CleanupStack::PopAndDestroy(2); // group & entry
       
  1511 	}
       
  1512 
       
  1513 /** 
       
  1514  * Read minimal ICC entry - normal case.
       
  1515  * Check group membership is correct and relevant number of fields have
       
  1516  * been created.
       
  1517  */
       
  1518 void CPhbkReadIntegrationTestBase::ReadAllMinimalContactL(const TUid aPhonebook, TInt aExpectedCount)
       
  1519 	{
       
  1520 	iDb->SetDbViewContactType(KUidContactICCEntry);
       
  1521 	// get the unique groupId for the given phonebook
       
  1522 	TContactItemId groupId(KNullContactId);
       
  1523 	User::LeaveIfError(iSession.GetPhoneBookId(groupId, 
       
  1524 						RPhoneBookSession::ESyncGroupId,
       
  1525 						aPhonebook));
       
  1526 	TESTCHECKCONDITIONL(groupId != KNullContactId);
       
  1527   
       
  1528 	// based on the groupId, get items belonging to the phonebook
       
  1529 	CContactGroup* group = NULL;
       
  1530 	TRAPD(err, group = static_cast<CContactGroup*>(iDb->ReadContactL(groupId)));
       
  1531 	TESTCHECKL(err, KErrNone);
       
  1532 	CleanupStack::PushL(group);
       
  1533 	const CContactIdArray* array = group->ItemsContained();
       
  1534 
       
  1535 	// Verify correct number of entries created for this phonebook
       
  1536 	const TInt count = array->Count(); // for debugging
       
  1537 	TESTCHECKL(count, aExpectedCount);
       
  1538 
       
  1539 	// Read each item
       
  1540 	for (TInt i=0; i<count; ++i)
       
  1541 		{
       
  1542 		TContactItemId id = (*array)[i];
       
  1543 		CContactICCEntry* entry = NULL;
       
  1544 		TRAP(err, entry = static_cast<CContactICCEntry*>(iDb->ReadMinimalContactL(id)));
       
  1545 		TESTCHECKL(err, KErrNone);
       
  1546 		CleanupStack::PushL(entry);
       
  1547 		// Verify correct number of fields created for entry
       
  1548 		CheckMinimalFieldCountL(aPhonebook, entry);
       
  1549 		CleanupStack::PopAndDestroy(); // entry
       
  1550 		}
       
  1551 
       
  1552 	CleanupStack::PopAndDestroy(); // group
       
  1553 	}
       
  1554 
       
  1555 /** 
       
  1556  * Read minimal ICC entry - entry not available as the ICC becomes locked.
       
  1557  */
       
  1558 void CPhbkReadIntegrationTestBase::ReadMinimalContactLockedL(const TUid aPhonebook, TInt aExpectedCount)
       
  1559 	{
       
  1560 	iDb->SetDbViewContactType(KUidContactICCEntry);
       
  1561 	// get the unique groupId for the given phonebook
       
  1562 	TContactItemId groupId(KNullContactId);
       
  1563 	User::LeaveIfError(iSession.GetPhoneBookId(groupId, 
       
  1564 						RPhoneBookSession::ESyncGroupId,
       
  1565 						aPhonebook));
       
  1566 	TESTCHECKCONDITIONL(groupId != KNullContactId);
       
  1567   
       
  1568 	// based on the groupId, get items belonging to the phonebook
       
  1569 	CContactGroup* group = NULL;
       
  1570 	TRAPD(err, group = static_cast<CContactGroup*>(iDb->ReadContactL(groupId)));
       
  1571 	TESTCHECKL(err, KErrNone);
       
  1572 	CleanupStack::PushL(group);
       
  1573 	const CContactIdArray* array = group->ItemsContained();
       
  1574 	SignalSimTsyToReduceTimersL();
       
  1575 
       
  1576 	// Access ICC and wait for it to become locked
       
  1577 	TContactItemId id = (*array)[0]; 
       
  1578 	while(err==KErrNone) 
       
  1579 		{
       
  1580 		User::After(1000000);	// Wait a second and try again.
       
  1581 		CContactICCEntry* failEntry=NULL;
       
  1582 		TRAP(err, failEntry = (CContactICCEntry*)iDb->ReadMinimalContactL(id)); // Entry unavailable due to ICC being locked
       
  1583 		delete failEntry;
       
  1584 		}
       
  1585 	TESTCHECKL(err, KErrAccessDenied);
       
  1586 	SignalSimTsyToReduceTimersL();
       
  1587 
       
  1588 	// Wait for ICC to become unlocked again
       
  1589 	while(err==KErrAccessDenied) 
       
  1590 		{
       
  1591 		User::After(1000000);	// Wait a second and try again.
       
  1592 		CContactICCEntry* failEntry=NULL;
       
  1593 		TRAP(err, failEntry = (CContactICCEntry*)iDb->ReadMinimalContactL(id)); // Entry unavailable due to ICC being locked
       
  1594 		delete failEntry;
       
  1595 		}
       
  1596 		
       
  1597 	WaitForSyncToCompleteL();
       
  1598 
       
  1599 	// Read the item again
       
  1600 	CContactICCEntry* entry = NULL;
       
  1601 	TRAP(err, entry = static_cast<CContactICCEntry*>(iDb->ReadMinimalContactL(id)));
       
  1602 	TESTCHECKL(err, KErrNone);
       
  1603 	CleanupStack::PushL(entry);
       
  1604 
       
  1605 	// Verify correct number of entries created for this phonebook
       
  1606 	const TInt count = array->Count(); // for debugging
       
  1607 	TESTCHECKL(count, aExpectedCount);
       
  1608 
       
  1609 	// Verify correct number of fields created for entry
       
  1610 	CheckMinimalFieldCountL(aPhonebook, entry);
       
  1611 
       
  1612 	CleanupStack::PopAndDestroy(2); // group and entry
       
  1613 	}
       
  1614 
       
  1615 /** 
       
  1616  * Read an ICC entry -  - create string from contact info (full view)
       
  1617  */
       
  1618 void CPhbkReadIntegrationTestBase::ReadFullContactTextDefL(const TUid aPhonebook, TInt aExpectedCount, TBool aReadAll)
       
  1619 	{
       
  1620 	iDb->SetDbViewContactType(KUidContactICCEntry);
       
  1621 	// get the unique groupId for the given phonebook
       
  1622 	TContactItemId groupId(KNullContactId);
       
  1623 	User::LeaveIfError(iSession.GetPhoneBookId(groupId, 
       
  1624 						RPhoneBookSession::ESyncGroupId,
       
  1625 						aPhonebook));
       
  1626 	TESTCHECKCONDITIONL(groupId != KNullContactId);
       
  1627   
       
  1628 	// based on the groupId, get items belonging to the phonebook
       
  1629 	CContactGroup* group = NULL;
       
  1630 	TRAPD(err, group = static_cast<CContactGroup*>(iDb->ReadContactL(groupId)));
       
  1631 	TESTCHECKL(err, KErrNone);
       
  1632 	CleanupStack::PushL(group);
       
  1633 	const CContactIdArray* array = group->ItemsContained();
       
  1634 
       
  1635 	// Verify correct number of entries created for this phonebook
       
  1636 	TInt count = array->Count(); // for debugging
       
  1637 	TESTCHECKL(count, aExpectedCount);
       
  1638 
       
  1639 	// Read all items or only the first?
       
  1640 	if (!aReadAll)
       
  1641 		count = 1;
       
  1642 		
       
  1643 	for(TInt i=0; i<count; ++i)
       
  1644 		{
       
  1645 		TContactItemId id = (*array)[i];
       
  1646 		TBuf<RMobilePhone::KMaxMobileTelNumberSize> buf;
       
  1647 		TRAPD(err, iDb->ReadContactTextDefL(id,buf,NULL)); // Pass NULL as text definition - Contacts model will construct descriptor from the first fields that match
       
  1648 		TESTCHECKL(err, KErrNone);
       
  1649 		TESTCHECKCONDITIONL(buf.Length() != 0);
       
  1650 		}
       
  1651 
       
  1652 	CleanupStack::PopAndDestroy(); // group
       
  1653 	}
       
  1654 
       
  1655 /** 
       
  1656  * Read an ICC entry -  - create number string from contact info
       
  1657  */
       
  1658 void CPhbkReadIntegrationTestBase::ReadNumberContactTextDefL(const TUid aPhonebook, TInt aExpectedCount, TBool aReadAll)
       
  1659 	{
       
  1660 	iDb->SetDbViewContactType(KUidContactICCEntry);
       
  1661 	// get the unique groupId for the given phonebook
       
  1662 	TContactItemId groupId(KNullContactId);
       
  1663 	User::LeaveIfError(iSession.GetPhoneBookId(groupId, 
       
  1664 						RPhoneBookSession::ESyncGroupId,
       
  1665 						aPhonebook));
       
  1666 	TESTCHECKCONDITIONL(groupId != KNullContactId);
       
  1667   
       
  1668 	// based on the groupId, get items belonging to the phonebook
       
  1669 	CContactGroup* group = NULL;
       
  1670 	TRAPD(err, group = static_cast<CContactGroup*>(iDb->ReadContactL(groupId)));
       
  1671 	TESTCHECKL(err, KErrNone);
       
  1672 	CleanupStack::PushL(group);
       
  1673 	const CContactIdArray* array = group->ItemsContained();
       
  1674 
       
  1675 	// Verify correct number of entries created for this phonebook
       
  1676 	TInt count = array->Count(); // for debugging
       
  1677 	TESTCHECKL(count, aExpectedCount);
       
  1678 
       
  1679 	// Read all items or only the first?
       
  1680 	if (!aReadAll)
       
  1681 		count = 1;
       
  1682 		
       
  1683 	for(TInt i=0; i<count; ++i)
       
  1684 		{
       
  1685 		TContactItemId id = (*array)[i];
       
  1686 		CContactTextDef *textDef=CContactTextDef::NewL();
       
  1687 		CleanupStack::PushL(textDef);
       
  1688 		textDef->AppendL(TContactTextDefItem(KUidContactFieldPhoneNumber,_L("==")));
       
  1689 		TBuf<RMobilePhone::KMaxMobileTelNumberSize> buf;
       
  1690 		TRAPD(err, iDb->ReadContactTextDefL(id,buf,textDef));
       
  1691 		TESTCHECKL(err, KErrNone);
       
  1692 		TESTCHECKCONDITIONL(buf.Length() != 0);
       
  1693 		CleanupStack::PopAndDestroy(textDef);
       
  1694 		}
       
  1695 
       
  1696 	CleanupStack::PopAndDestroy(); // group
       
  1697 	}
       
  1698 
       
  1699 /** 
       
  1700  * Read an ICC entry - create name string from contact info
       
  1701  */
       
  1702 void CPhbkReadIntegrationTestBase::ReadNameContactTextDefL(const TUid aPhonebook, TInt aExpectedCount, TBool aReadAll)
       
  1703 	{
       
  1704 	iDb->SetDbViewContactType(KUidContactICCEntry);
       
  1705 	// get the unique groupId for the given phonebook
       
  1706 	TContactItemId groupId(KNullContactId);
       
  1707 	User::LeaveIfError(iSession.GetPhoneBookId(groupId, 
       
  1708 						RPhoneBookSession::ESyncGroupId,
       
  1709 						aPhonebook));
       
  1710 	TESTCHECKCONDITIONL(groupId != KNullContactId);
       
  1711   
       
  1712 	// based on the groupId, get items belonging to the phonebook
       
  1713 	CContactGroup* group = NULL;
       
  1714 	TRAPD(err, group = static_cast<CContactGroup*>(iDb->ReadContactL(groupId)));
       
  1715 	TESTCHECKL(err, KErrNone);
       
  1716 	CleanupStack::PushL(group);
       
  1717 	const CContactIdArray* array = group->ItemsContained();
       
  1718 
       
  1719 	// Verify correct number of entries created for this phonebook
       
  1720 	TInt count = array->Count(); // for debugging
       
  1721 	TESTCHECKL(count, aExpectedCount);
       
  1722 
       
  1723 	// Read all items or only the first?
       
  1724 	if (!aReadAll)
       
  1725 		count = 1;
       
  1726 		
       
  1727 	for(TInt i=0; i<count; ++i)
       
  1728 		{
       
  1729 		TContactItemId id = (*array)[i];
       
  1730 		CContactTextDef *textDef=CContactTextDef::NewL();
       
  1731 		CleanupStack::PushL(textDef);
       
  1732 		textDef->AppendL(TContactTextDefItem(KUidContactFieldFamilyName,_L("==")));
       
  1733 		TBuf<KMaxPhBkNameSize> buf;
       
  1734 		TRAPD(err, iDb->ReadContactTextDefL(id,buf,textDef));
       
  1735 		TESTCHECKL(err, KErrNone);
       
  1736 		TESTCHECKCONDITIONL(buf.Length() != 0);
       
  1737 		CleanupStack::PopAndDestroy(textDef);
       
  1738 		}
       
  1739 
       
  1740 	CleanupStack::PopAndDestroy(); // group
       
  1741 	}
       
  1742 
       
  1743 /** 
       
  1744  * Read an ICC entry - invalid string specification
       
  1745  */
       
  1746 void CPhbkReadIntegrationTestBase::ReadInvalidContactTextDefL(const TUid aPhonebook, TInt aExpectedCount)
       
  1747 	{
       
  1748 	iDb->SetDbViewContactType(KUidContactICCEntry);
       
  1749 	// get the unique groupId for the given phonebook
       
  1750 	TContactItemId groupId(KNullContactId);
       
  1751 	User::LeaveIfError(iSession.GetPhoneBookId(groupId, 
       
  1752 						RPhoneBookSession::ESyncGroupId,
       
  1753 						aPhonebook));
       
  1754 	TESTCHECKCONDITIONL(groupId != KNullContactId);
       
  1755   
       
  1756 	// based on the groupId, get items belonging to the phonebook
       
  1757 	CContactGroup* group = NULL;
       
  1758 	TRAPD(err, group = static_cast<CContactGroup*>(iDb->ReadContactL(groupId)));
       
  1759 	TESTCHECKL(err, KErrNone);
       
  1760 	CleanupStack::PushL(group);
       
  1761 	const CContactIdArray* array = group->ItemsContained();
       
  1762 
       
  1763 	// Verify correct number of entries created for this phonebook
       
  1764 	const TInt count = array->Count(); // for debugging
       
  1765 	TESTCHECKL(count, aExpectedCount);
       
  1766 
       
  1767 	// Read the first item
       
  1768 	TContactItemId id = (*array)[0];
       
  1769 	CContactTextDef *textDef=CContactTextDef::NewL();
       
  1770 	CleanupStack::PushL(textDef);
       
  1771 	textDef->SetExactMatchOnly(ETrue);
       
  1772 	textDef->AppendL(TContactTextDefItem(KUidContactFieldCompanyName,_L("==")));
       
  1773 	TBuf<KMaxPhBkNameSize> buf;
       
  1774 	TRAP(err, iDb->ReadContactTextDefL(id,buf,textDef));
       
  1775 	TESTCHECKL(err, KErrNone); // contact ID being read is valid and 
       
  1776 							   // the ICC contact can be read (ie. read validation was ok).
       
  1777 	TESTCHECKL(buf.Length(), 0); // field in the text definition does not 
       
  1778 								 // exist in an ICC contact so buf is empty 
       
  1779 	CleanupStack::PopAndDestroy(2); // group & textDef
       
  1780 	}
       
  1781 
       
  1782 /** 
       
  1783  * Read a locked ICC entry - create name string from contact info
       
  1784  */
       
  1785 void CPhbkReadIntegrationTestBase::ReadLockedContactTextDefL(const TUid aPhonebook, TInt aExpectedCount)
       
  1786 	{
       
  1787 	iDb->SetDbViewContactType(KUidContactICCEntry);
       
  1788 	// get the unique groupId for the given phonebook
       
  1789 	TContactItemId groupId(KNullContactId);
       
  1790 	User::LeaveIfError(iSession.GetPhoneBookId(groupId, 
       
  1791 						RPhoneBookSession::ESyncGroupId,
       
  1792 						aPhonebook));
       
  1793 	TESTCHECKCONDITIONL(groupId != KNullContactId);
       
  1794   
       
  1795 	// based on the groupId, get items belonging to the phonebook
       
  1796 	CContactGroup* group = NULL;
       
  1797 	TRAPD(err, group = static_cast<CContactGroup*>(iDb->ReadContactL(groupId)));
       
  1798 	TESTCHECKL(err, KErrNone);
       
  1799 	CleanupStack::PushL(group);
       
  1800 	const CContactIdArray* array = group->ItemsContained();
       
  1801 
       
  1802 	// Verify correct number of entries created for this phonebook
       
  1803 	const TInt count = array->Count(); // for debugging
       
  1804 	TESTCHECKL(count, aExpectedCount);
       
  1805 
       
  1806 	// Read the first item
       
  1807 	TContactItemId id = (*array)[0];
       
  1808 	CContactTextDef *textDef=CContactTextDef::NewLC();
       
  1809 	textDef->AppendL(TContactTextDefItem(KUidContactFieldFamilyName,_L("==")));
       
  1810 	TBuf<KMaxPhBkNameSize> buf;
       
  1811 	SignalSimTsyToReduceTimersL();
       
  1812 	while(err==KErrNone) // Wait for ICC to become locked
       
  1813 		{
       
  1814 		User::After(5000);
       
  1815 		TRAP(err, iDb->ReadContactTextDefL(id,buf,textDef));
       
  1816 		}
       
  1817 	TESTCHECKL(err, KErrAccessDenied);
       
  1818 
       
  1819 	CleanupStack::PopAndDestroy(2); // group & textDef
       
  1820 	}
       
  1821 
       
  1822 
       
  1823 /** 
       
  1824  * Read all ICC entry - full view.
       
  1825  * Check group membership is correct and relevant number of fields have
       
  1826  * been created.
       
  1827  */
       
  1828 void CPhbkReadIntegrationTestBase::ReadAllContactFullViewL(const TUid aPhonebook, TInt aExpectedCount)
       
  1829 	{
       
  1830 	iDb->SetDbViewContactType(KUidContactICCEntry);
       
  1831 	// get the unique groupId for the given phonebook
       
  1832 	TContactItemId groupId(KNullContactId);
       
  1833 	User::LeaveIfError(iSession.GetPhoneBookId(groupId, 
       
  1834 						RPhoneBookSession::ESyncGroupId,
       
  1835 						aPhonebook));
       
  1836 	TESTCHECKCONDITIONL(groupId != KNullContactId);
       
  1837   
       
  1838 	// based on the groupId, get items belonging to the phonebook
       
  1839 	CContactGroup* group = NULL;
       
  1840 	TRAPD(err, group = static_cast<CContactGroup*>(iDb->ReadContactL(groupId)));
       
  1841 	TESTCHECKL(err, KErrNone);
       
  1842 	CleanupStack::PushL(group);
       
  1843 	const CContactIdArray* array = group->ItemsContained();
       
  1844 
       
  1845 	// Verify correct number of entries created for this phonebook
       
  1846 	const TInt count = array->Count(); // for debugging
       
  1847 	TESTCHECKL(count, aExpectedCount);
       
  1848 
       
  1849 	for(TInt i=0; i<count; ++i)
       
  1850 		{
       
  1851 		// Full view 
       
  1852 		TContactItemId id = (*array)[i];
       
  1853 		CContactICCEntry* entry = static_cast<CContactICCEntry*>(iDb->ReadContactL(id, *iDb->AllFieldsView())); // specify full view
       
  1854 		CleanupStack::PushL(entry);
       
  1855 		CheckFieldCountL(aPhonebook, entry); // Entry contains correct number of fields
       
  1856 		CheckFieldsL(aPhonebook, entry, i + 1); // Entry contains correct content
       
  1857 		CleanupStack::PopAndDestroy(entry);
       
  1858 		}
       
  1859 
       
  1860 	CleanupStack::PopAndDestroy(); // group
       
  1861 	}
       
  1862 
       
  1863 /** 
       
  1864  * Read all ICC entry - name view.
       
  1865  * Check group membership is correct and relevant number of fields have
       
  1866  * been created.
       
  1867  */
       
  1868 void CPhbkReadIntegrationTestBase::ReadAllContactNameViewL(const TUid aPhonebook, TInt aExpectedCount)
       
  1869 	{
       
  1870 	iDb->SetDbViewContactType(KUidContactICCEntry);
       
  1871 	// get the unique groupId for the given phonebook
       
  1872 	TContactItemId groupId(KNullContactId);
       
  1873 	User::LeaveIfError(iSession.GetPhoneBookId(groupId, 
       
  1874 						RPhoneBookSession::ESyncGroupId,
       
  1875 						aPhonebook));
       
  1876 	TESTCHECKCONDITIONL(groupId != KNullContactId);
       
  1877   
       
  1878 	// based on the groupId, get items belonging to the phonebook
       
  1879 	CContactGroup* group = NULL;
       
  1880 	TRAPD(err, group = static_cast<CContactGroup*>(iDb->ReadContactL(groupId)));
       
  1881 	TESTCHECKL(err, KErrNone);
       
  1882 	CleanupStack::PushL(group);
       
  1883 	const CContactIdArray* array = group->ItemsContained();
       
  1884 
       
  1885 	// Verify correct number of entries created for this phonebook
       
  1886 	const TInt count = array->Count(); // for debugging
       
  1887 	TESTCHECKL(count, aExpectedCount);
       
  1888 
       
  1889 	for(TInt i=0; i<count; ++i)
       
  1890 		{
       
  1891 		// Name view 
       
  1892 		TContactItemId id = (*array)[i];
       
  1893 		CContactItemViewDef* view = CContactItemViewDef::NewLC(CContactItemViewDef::EIncludeFields,CContactItemViewDef::EMaskHiddenFields);
       
  1894 		view->AddL(KUidContactFieldFamilyName); 
       
  1895 		TESTCHECKL(view->Count(), 1);
       
  1896 		CContactICCEntry* entry = static_cast<CContactICCEntry*>(iDb->ReadContactL(id, *view));
       
  1897 		CleanupStack::PushL(entry);
       
  1898 		CheckFieldCountL(aPhonebook, entry); // Entry contains correct number of fields
       
  1899 		CleanupStack::PopAndDestroy(entry);
       
  1900 		CleanupStack::PopAndDestroy();	// view	
       
  1901 		}
       
  1902 
       
  1903 	CleanupStack::PopAndDestroy(); // group
       
  1904 	}
       
  1905 
       
  1906 /** 
       
  1907  * Read all ICC entry - number view.
       
  1908  * Check group membership is correct and relevant number of fields have
       
  1909  * been created.
       
  1910  */
       
  1911 void CPhbkReadIntegrationTestBase::ReadAllContactNumberViewL(const TUid aPhonebook, TInt aExpectedCount)
       
  1912 	{
       
  1913 	iDb->SetDbViewContactType(KUidContactICCEntry);
       
  1914 	// get the unique groupId for the given phonebook
       
  1915 	TContactItemId groupId(KNullContactId);
       
  1916 	User::LeaveIfError(iSession.GetPhoneBookId(groupId, 
       
  1917 						RPhoneBookSession::ESyncGroupId,
       
  1918 						aPhonebook));
       
  1919 	TESTCHECKCONDITIONL(groupId != KNullContactId);
       
  1920   
       
  1921 	// based on the groupId, get items belonging to the phonebook
       
  1922 	CContactGroup* group = NULL;
       
  1923 	TRAPD(err, group = static_cast<CContactGroup*>(iDb->ReadContactL(groupId)));
       
  1924 	TESTCHECKL(err, KErrNone);
       
  1925 	CleanupStack::PushL(group);
       
  1926 	const CContactIdArray* array = group->ItemsContained();
       
  1927 
       
  1928 	// Verify correct number of entries created for this phonebook
       
  1929 	const TInt count = array->Count(); // for debugging
       
  1930 	TESTCHECKL(count, aExpectedCount);
       
  1931 
       
  1932 	for(TInt i=0; i<count; ++i)
       
  1933 		{
       
  1934 		// Number view 
       
  1935 		TContactItemId id = (*array)[i];
       
  1936 		CContactItemViewDef* view = CContactItemViewDef::NewLC(CContactItemViewDef::EIncludeFields,CContactItemViewDef::EMaskHiddenFields);
       
  1937 		view->AddL(KUidContactFieldPhoneNumber); 
       
  1938 		TESTCHECKL(view->Count(), 1);
       
  1939 		CContactICCEntry* entry = static_cast<CContactICCEntry*>(iDb->ReadContactL(id, *view));
       
  1940 		CleanupStack::PushL(entry);
       
  1941 		CheckFieldCountL(aPhonebook, entry); // Entry contains correct number of fields
       
  1942 		CleanupStack::PopAndDestroy(entry);
       
  1943 		CleanupStack::PopAndDestroy();	// view	
       
  1944 		}
       
  1945 
       
  1946 	CleanupStack::PopAndDestroy(); // group
       
  1947 	}
       
  1948 
       
  1949 
       
  1950 /** 
       
  1951  * Factory construction method.
       
  1952  * @return Pointer to CPhbkSyncReadAdditionalNumTagsTest object
       
  1953  */
       
  1954 CPhbkSyncReadAdditionalNumTagsTest* CPhbkSyncReadAdditionalNumTagsTest::NewL()
       
  1955 	{
       
  1956 	CPhbkSyncReadAdditionalNumTagsTest* self = new(ELeave) CPhbkSyncReadAdditionalNumTagsTest();
       
  1957 	return self;
       
  1958 	}
       
  1959 
       
  1960 /**
       
  1961  *  Default constructor.  Each test step initialises it's own name.
       
  1962  */
       
  1963 CPhbkSyncReadAdditionalNumTagsTest::CPhbkSyncReadAdditionalNumTagsTest()
       
  1964 	{
       
  1965 	SetTestStepName(_L("ReadAdditionalNumTagsTest"));
       
  1966 	}
       
  1967 
       
  1968 /** 
       
  1969  * Read ICC entries with additional numbers and alpha tags
       
  1970  */
       
  1971 enum TVerdict CPhbkSyncReadAdditionalNumTagsTest::doTestStepL()
       
  1972 	{
       
  1973 	// ensure contact database entries are removed because this test demands that 
       
  1974 	// the order of new entry IDs corresponds to the order of the test data entries
       
  1975 	delete iDb;
       
  1976 	iDb=NULL;
       
  1977 	User::After(1000000); //1 second wait for contact to shut down
       
  1978 	
       
  1979 	iSession.Close();
       
  1980 	ConfigurePhbkSyncToIdleL();
       
  1981 	TRAP_IGNORE(CContactDatabase::DeleteDefaultFileL());	
       
  1982 	ConfigurePhbkSyncToFullL();
       
  1983 	iDb = OpenOrCreateContactDatabaseL();
       
  1984 	User::After(1000000); //1 second wait for contact to start the phbk server
       
  1985 	User::LeaveIfError(iSession.Connect());
       
  1986 	User::After(3000000); //3 second wait for server to create phbktable
       
  1987 
       
  1988 	SetSimTsyTestNumberL(22);
       
  1989 	DoSyncL();
       
  1990 
       
  1991 	iDb->SetDbViewContactType(KUidContactICCEntry);
       
  1992 	// get the unique groupId for the USIM App phonebook
       
  1993 	TContactItemId groupId(KNullContactId);
       
  1994 	User::LeaveIfError(iSession.GetPhoneBookId(groupId, 
       
  1995 						RPhoneBookSession::ESyncGroupId,
       
  1996 						KUidUsimAppAdnPhonebook));
       
  1997 	TESTCHECKCONDITIONL(groupId != KNullContactId);
       
  1998   
       
  1999 	// based on the groupId, get items belonging to the phonebook
       
  2000 	CContactGroup* group = NULL;
       
  2001 	TRAPD(err, group = static_cast<CContactGroup*>(iDb->ReadContactL(groupId)));
       
  2002 	TESTCHECKL(err, KErrNone);
       
  2003 	CleanupStack::PushL(group);
       
  2004 	const CContactIdArray* array = group->ItemsContained();
       
  2005 
       
  2006 	const TInt count = array->Count(); // for debugging
       
  2007 	for(TInt i=0; i<count; ++i)
       
  2008 		{
       
  2009 		TContactItemId id = (*array)[i];
       
  2010 		CContactICCEntry* entry = static_cast<CContactICCEntry*>(iDb->ReadContactL(id));
       
  2011 		CleanupStack::PushL(entry);
       
  2012 		CContactItemFieldSet& fieldset = entry->CardFields();
       
  2013 		TInt pos(KErrNotFound);
       
  2014 		switch (i)
       
  2015 		{
       
  2016 		case 0:
       
  2017 			pos = fieldset.Find(KUidContactFieldVCardMapMSG);
       
  2018 			break;
       
  2019 		case 1:
       
  2020 			pos = fieldset.Find(KUidContactFieldVCardMapVOICE);
       
  2021 			break;
       
  2022 		case 2:
       
  2023 			pos = fieldset.Find(KUidContactFieldVCardMapFAX);
       
  2024 			break;
       
  2025 		case 3:
       
  2026 			pos = fieldset.Find(KUidContactFieldVCardMapPREF);
       
  2027 			break;
       
  2028 		case 4:
       
  2029 			pos = fieldset.Find(KUidContactFieldVCardMapCELL);
       
  2030 			break;
       
  2031 		case 5:
       
  2032 			pos = fieldset.Find(KUidContactFieldVCardMapPAGER);
       
  2033 			break;
       
  2034 		case 6:
       
  2035 			pos = fieldset.Find(KUidContactFieldVCardMapBBS);
       
  2036 			break;
       
  2037 		case 7:
       
  2038 			pos = fieldset.Find(KUidContactFieldVCardMapMODEM);
       
  2039 			break;
       
  2040 		case 8:
       
  2041 			pos = fieldset.Find(KUidContactFieldVCardMapCAR);
       
  2042 			break;
       
  2043 		case 9:
       
  2044 			pos = fieldset.Find(KUidContactFieldVCardMapISDN);
       
  2045 			break;
       
  2046 		case 10:
       
  2047 			pos = fieldset.Find(KUidContactFieldVCardMapVIDEO);
       
  2048 			break;
       
  2049 
       
  2050 		default:
       
  2051 			break;
       
  2052 		}
       
  2053 		TESTCHECKCONDITIONL(pos != KErrNotFound);
       
  2054 		CleanupStack::PopAndDestroy(entry);
       
  2055 		}
       
  2056 
       
  2057 	CleanupStack::PopAndDestroy(); // group
       
  2058 	return TestStepResult();
       
  2059 	}
       
  2060 	
       
  2061 /** 
       
  2062  * Factory construction method.
       
  2063  * @return Pointer to CPhbkSyncReadInternationalNumberTest object
       
  2064  */
       
  2065 CPhbkSyncReadInternationalNumberTest* CPhbkSyncReadInternationalNumberTest::NewL()
       
  2066 	{
       
  2067 	CPhbkSyncReadInternationalNumberTest* self = new(ELeave) CPhbkSyncReadInternationalNumberTest();
       
  2068 	return self;
       
  2069 	}
       
  2070 
       
  2071 /**
       
  2072  *  Default constructor.  Each test step initialises it's own name.
       
  2073  */
       
  2074 CPhbkSyncReadInternationalNumberTest::CPhbkSyncReadInternationalNumberTest()
       
  2075 	{
       
  2076 	SetTestStepName(_L("ReadInternationalNumberTest"));
       
  2077 	}
       
  2078 
       
  2079 /** 
       
  2080  * Read ICC entries with international numbers.
       
  2081  */
       
  2082 enum TVerdict CPhbkSyncReadInternationalNumberTest::doTestStepL()
       
  2083 	{
       
  2084 	// Clear out the Contacts Database to start from afresh for this test.
       
  2085 	delete iDb;
       
  2086 	iDb=NULL;
       
  2087 	User::After(1000000); //1 second wait for contact to shut down
       
  2088 	
       
  2089 	iSession.Close();
       
  2090 	ConfigurePhbkSyncToIdleL();
       
  2091 	TRAP_IGNORE(CContactDatabase::DeleteDefaultFileL());	
       
  2092 	ConfigurePhbkSyncToFullL();
       
  2093 	iDb = OpenOrCreateContactDatabaseL();
       
  2094 	User::After(1000000); //1 second wait for contact to start the phbk server
       
  2095 	User::LeaveIfError(iSession.Connect());
       
  2096 	User::After(3000000); //3 second wait for server to create phbktable
       
  2097 
       
  2098 	SetSimTsyTestNumberL(136);
       
  2099 	
       
  2100 	// Sync the USIM App ADN Phonebook
       
  2101 	TRequestStatus status = KErrNone;
       
  2102 	iSession.DoSynchronisation(status, KUidUsimAppAdnPhonebook);
       
  2103 	User::WaitForRequest(status);
       
  2104 	TESTCHECKL(status.Int(), KErrNone);
       
  2105 		
       
  2106 	iDb->SetDbViewContactType(KUidContactICCEntry);	
       
  2107 	
       
  2108 	// Search for a particular contact in the database
       
  2109 	
       
  2110 	// Specify which fields to search
       
  2111 	CContactItemFieldDef* fieldDef = new(ELeave) CContactItemFieldDef;
       
  2112 	CleanupStack::PushL(fieldDef);
       
  2113 	fieldDef->AppendL(KUidContactFieldFamilyName); 
       
  2114 	
       
  2115 	// Get the contact item ID of the contact we are looking for
       
  2116 	CContactIdArray* array = iDb->FindLC(KTestPersonWithInternationalNumber, fieldDef);
       
  2117 	TESTCHECKL(array->Count(),1);
       
  2118   	
       
  2119   	TContactItemId contactItemId = (*array)[0];
       
  2120   	
       
  2121   	CleanupStack::PopAndDestroy(2, fieldDef); // array, fieldDef
       
  2122   	
       
  2123   	// Get the contact item
       
  2124 	CContactItem* contactItem = iDb->ReadContactL(contactItemId);
       
  2125 	CleanupStack::PushL(contactItem);
       
  2126 	
       
  2127 	CContactItemFieldSet& fieldset = contactItem->CardFields();
       
  2128 	
       
  2129 	// Compare the international numbers with what is expected
       
  2130 	// index stores the field position to search from since all
       
  2131 	// the numbers are stored in multiple instances of the same field type.	
       
  2132 	TInt index = fieldset.Find(KUidContactFieldPhoneNumber);
       
  2133 	CheckFieldContentL(fieldset, KUidContactFieldPhoneNumber, KTestInternationalNumber1);
       
  2134 
       
  2135 	index = fieldset.FindNext(KUidContactFieldPhoneNumber, index+1);
       
  2136 	CheckFieldContentL(fieldset, KUidContactFieldPhoneNumber, index, KTestInternationalNumber2);
       
  2137 
       
  2138 	index = fieldset.FindNext(KUidContactFieldPhoneNumber, index+1);
       
  2139 	CheckFieldContentL(fieldset, KUidContactFieldPhoneNumber, index, KTestInternationalNumber1);
       
  2140 
       
  2141 	CleanupStack::PopAndDestroy(contactItem);
       
  2142 	
       
  2143 	return TestStepResult();
       
  2144 	}
       
  2145 
       
  2146 
       
  2147 /** 
       
  2148  *  Tests that an ICC contact can be read without starting PhBkSync first.
       
  2149  * 
       
  2150  *  @return EPass if the successful was successful.
       
  2151  */
       
  2152 TVerdict CPhbkSyncReadWithOutOpeningPhBkSyncFirstTest::doTestStepL()
       
  2153 	{
       
  2154 	//
       
  2155 	// Setup SIMTSY so some contacts exist on the SIM and sync them...
       
  2156 	//
       
  2157 	SetSyncModeL(RPhoneBookSession::EManual);
       
  2158 	CheckSyncModeL(RPhoneBookSession::EManual);
       
  2159 	SetSimTsyTestNumberL(0);
       
  2160 	DoSyncL();
       
  2161 
       
  2162 	//
       
  2163 	// Close the Contacts Database as may have a handle to Phonebook Sync...
       
  2164 	//
       
  2165     delete iDb;
       
  2166 	iDb=NULL;
       
  2167 
       
  2168 	//
       
  2169 	// Close the Phonebook Sync handle and tell the server to shutdown and
       
  2170 	// unload. This is required for this test to work and for security
       
  2171 	// reasons is only possible with a debug server.
       
  2172 	//
       
  2173 #if _DEBUG
       
  2174 	iSession.ShutdownServer(ETrue);
       
  2175 	iSession.Close();
       
  2176 	User::After(1); // To ensure the close / server shutdown is processed.
       
  2177 #else
       
  2178 	INFO_PRINTF1(_L("<font color=Orange>This test is only valid in UDEB!</font>"));
       
  2179 	iSession.Close();
       
  2180 #endif
       
  2181 
       
  2182 	//
       
  2183 	// Now open Contacts Database (Phonebook Sync will not be automatically
       
  2184 	// opened)...
       
  2185 	//
       
  2186 	iDb = OpenOrCreateContactDatabaseL();
       
  2187 
       
  2188 	//
       
  2189 	// Find an ICC contact ID to read...
       
  2190 	//
       
  2191 	iDb->SetDbViewContactType(KUidContactICCEntry);
       
  2192 
       
  2193 	TContactIter  iter(*iDb);
       
  2194     TContactItemId  contactId = iter.FirstL();
       
  2195     
       
  2196     TESTCHECKCONDITIONL(contactId != KNullContactId);
       
  2197     
       
  2198     //
       
  2199     // Try and read the contact...
       
  2200     //
       
  2201 	CContactItem*  item = NULL;
       
  2202 
       
  2203 	TRAPD(err, item = iDb->ReadContactL(contactId));
       
  2204 #if _DEBUG
       
  2205 	TESTCHECK(err, KErrNotFound);
       
  2206 #else
       
  2207 	TESTCHECK(err, KErrNone);
       
  2208 	TESTCHECKCONDITION(item != NULL);
       
  2209 #endif
       
  2210 	delete item;
       
  2211 	item = NULL;
       
  2212 	
       
  2213 	//
       
  2214 	// Ensuring Phonebook Sync is running and synchronised...
       
  2215 	//
       
  2216 	TInt  ret = iSession.Connect();
       
  2217 	TESTCHECKL(ret, KErrNone);
       
  2218 
       
  2219 	ConfigurePhbkSyncToFullL();
       
  2220 	DoSyncL();
       
  2221 
       
  2222 	//
       
  2223     // Now repeat the test...
       
  2224     //
       
  2225 	TRAP(err, item = iDb->ReadContactL(contactId));
       
  2226 	TESTCHECK(err, KErrNone);
       
  2227 	TESTCHECKCONDITION(item != NULL);
       
  2228 	delete item;
       
  2229 	item = NULL;
       
  2230 
       
  2231 	return TestStepResult();
       
  2232 	} // CPhbkSyncReadWithOutOpeningPhBkSyncFirstTest::doTestStepL
       
  2233