telephonyserverplugins/multimodetsy/test/Te_PhBk/Te_PhBk.cpp
changeset 0 3553901f7fa8
equal deleted inserted replaced
-1:000000000000 0:3553901f7fa8
       
     1 // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 /**
       
    17  @file
       
    18 */
       
    19 
       
    20 #include <e32test.h>
       
    21 #include <c32comm.h>
       
    22 #include <etelmm.h>
       
    23 #include <mmretrieve.h>
       
    24 #include <mpbutil.h>
       
    25 
       
    26 #include "Te_PhBk.h"
       
    27 
       
    28 //------------------------------------------------------------------
       
    29 //			** TEST PhBk STEPS ***
       
    30 //------------------------------------------------------------------
       
    31 
       
    32 CTestPhoneInfo::CTestPhoneInfo()
       
    33 /** Each test step initialises it's own name
       
    34 */
       
    35 	{
       
    36 	// store the name of this test case
       
    37 	// this is the name that is used by the script file
       
    38 	SetTestStepName(_L("TestPhoneInfo"));
       
    39 	}
       
    40 //------------------------------------------------------------------
       
    41 
       
    42 TVerdict CTestPhoneInfo::doTestStepL( void )
       
    43 /**
       
    44  * This function gets information about the phone: the Phone Manufacturer's Id, the
       
    45  * Model and Revision ID, the Serial number and the number of phone books supported,
       
    46  * as well as information associated with each supported phone book.
       
    47  * The functions are called on a RBasicGsmPhone object.
       
    48  */
       
    49 	{
       
    50 	RMobilePhone::TMobilePhoneIdentityV1 aPhoneId;
       
    51 	TRequestStatus status;
       
    52 	RMobilePhoneStore::TMobilePhoneStoreInfoV1 aPhoneStoreInfo;
       
    53 	RMobilePhoneStore::TMobilePhoneStoreInfoV1Pckg aPhoneStoreInfoPckg(aPhoneStoreInfo);
       
    54 
       
    55 	iPhone.GetPhoneId(status, aPhoneId);
       
    56 	User::WaitForRequest(status);
       
    57 	CHECKPOINT(status, KErrNone, _L("*** Failed RMobilePhone::GetPhoneId() ***")) ;
       
    58 
       
    59 	INFO_PRINTF2(TRefByValue<const TDesC>(_L("Manufacturer ID : %S")), &aPhoneId.iManufacturer);
       
    60 	INFO_PRINTF2(TRefByValue<const TDesC>(_L("Model ID : %S")), &aPhoneId.iModel);
       
    61 	INFO_PRINTF2(TRefByValue<const TDesC>(_L("Revision ID : %S")), &aPhoneId.iRevision);
       
    62 	INFO_PRINTF2(TRefByValue<const TDesC>(_L("Serial number : %S")), &aPhoneId.iSerialNumber);
       
    63 	User::After(4000000L);	// Give user time to see the test results
       
    64 
       
    65 	iPhone.GetPhoneStoreInfo(status, aPhoneStoreInfoPckg, KETelMeDialledPhoneBook);
       
    66 	User::WaitForRequest(status);
       
    67 	INFO_PRINTF2(TRefByValue<const TDesC>(_L("Testing \"DIALLED_CALLS\" returned %d")), status.Int());
       
    68 	if(status.Int() == KErrNone)
       
    69 	    {
       
    70 		aPhoneStoreInfo = aPhoneStoreInfoPckg();
       
    71 		checkPhoneBookInfoL(aPhoneStoreInfo);
       
    72 	    }
       
    73 	else
       
    74 	    {
       
    75 		INFO_PRINTF1(_L("*** Phone Book \"DIALLED_CALLS\" not supported by this phone ***"));
       
    76 	    }
       
    77 
       
    78 
       
    79 	iPhone.GetPhoneStoreInfo(status, aPhoneStoreInfoPckg, KETelMeMissedPhoneBook);
       
    80 	User::WaitForRequest(status);
       
    81 	INFO_PRINTF2(TRefByValue<const TDesC>(_L("Testing \"MISSED_CALLS\" returned %d")), status.Int());
       
    82 	if(status.Int() == KErrNone)
       
    83 	    {
       
    84 		aPhoneStoreInfo = aPhoneStoreInfoPckg();
       
    85 		checkPhoneBookInfoL(aPhoneStoreInfo);
       
    86 	    }
       
    87 	else
       
    88 	    {
       
    89 		INFO_PRINTF1(_L("*** Phone Book \"MISSED_CALLS\" not supported by this phone ***"));
       
    90 	    }
       
    91 
       
    92 
       
    93 	iPhone.GetPhoneStoreInfo(status, aPhoneStoreInfoPckg, KETelMeReceivedPhoneBook);
       
    94 	User::WaitForRequest(status);
       
    95 	INFO_PRINTF2(TRefByValue<const TDesC>(_L("Testing \"RECEIVED_CALLS\" returned %d")), status.Int());
       
    96 	if(status.Int() == KErrNone)
       
    97 	    {
       
    98 		aPhoneStoreInfo = aPhoneStoreInfoPckg();
       
    99 		checkPhoneBookInfoL(aPhoneStoreInfo);
       
   100 	    }
       
   101 	else
       
   102 	    {
       
   103 		INFO_PRINTF1(_L("*** Phone Book \"RECEIVED_CALLS\" not supported by this phone ***"));
       
   104 	    }
       
   105 
       
   106 	iPhone.GetPhoneStoreInfo(status, aPhoneStoreInfoPckg, KETelMeAdnPhoneBook);
       
   107 	User::WaitForRequest(status);
       
   108 	INFO_PRINTF2(TRefByValue<const TDesC>(_L("Testing \"ME_PHONEBOOK\" returned %d")), status.Int());
       
   109 	if(status.Int() == KErrNone)
       
   110 	    {
       
   111 		aPhoneStoreInfo = aPhoneStoreInfoPckg();
       
   112 		checkPhoneBookInfoL(aPhoneStoreInfo);
       
   113 	    }
       
   114 	else
       
   115 	    {
       
   116 		INFO_PRINTF1(_L("*** Phone Book \"ME_PHONEBOOK\" not supported by this phone ***"));
       
   117 	    }
       
   118 
       
   119 	iPhone.GetPhoneStoreInfo(status, aPhoneStoreInfoPckg, KETelIccVoiceMailBox);
       
   120 	User::WaitForRequest(status);
       
   121 	INFO_PRINTF2(TRefByValue<const TDesC>(_L("Testing \"VOICE_MAILBOX\" returned %d")), status.Int());
       
   122 	if(status.Int() == KErrNone)
       
   123 	    {
       
   124 		aPhoneStoreInfo = aPhoneStoreInfoPckg();
       
   125 		checkPhoneBookInfoL(aPhoneStoreInfo);
       
   126 	    }
       
   127 	else
       
   128 	    {
       
   129 		INFO_PRINTF1(_L("*** Phone Book \"VOICE_MAILBOX\" not supported by this phone ***"));
       
   130 	    }
       
   131 
       
   132 	iPhone.GetPhoneStoreInfo(status, aPhoneStoreInfoPckg, KETelIccAdnPhoneBook);
       
   133 	User::WaitForRequest(status);
       
   134 	INFO_PRINTF2(TRefByValue<const TDesC>(_L("Testing \"SIM_PHONEBOOK\" returned %d")), status.Int());
       
   135 	if(status.Int() == KErrNone)
       
   136 	    {
       
   137 		aPhoneStoreInfo = aPhoneStoreInfoPckg();
       
   138 		checkPhoneBookInfoL(aPhoneStoreInfo);
       
   139 	    }
       
   140 	else
       
   141 	    {
       
   142 		INFO_PRINTF1(_L("*** Phone Book \"SIM_PHONEBOOK\" not supported by this phone ***"));
       
   143 	    }
       
   144 
       
   145 	iPhone.GetPhoneStoreInfo(status, aPhoneStoreInfoPckg, KETelCombinedAdnPhoneBook);
       
   146 	User::WaitForRequest(status);
       
   147 	INFO_PRINTF2(TRefByValue<const TDesC>(_L("Testing \"COMBINED_SIM_ME\" returned %d")), status.Int());
       
   148 	if(status.Int() == KErrNone)
       
   149 	    {
       
   150 		aPhoneStoreInfo = aPhoneStoreInfoPckg();
       
   151 		checkPhoneBookInfoL(aPhoneStoreInfo);
       
   152 	    }
       
   153 	else
       
   154 	    {
       
   155 		INFO_PRINTF1(_L("*** Phone Book \"COMBINED_SIM_ME\" not supported by this phone ***"));
       
   156 	    }
       
   157 
       
   158 	iPhone.GetPhoneStoreInfo(status, aPhoneStoreInfoPckg, KETelIccFdnPhoneBook);
       
   159 	User::WaitForRequest(status);
       
   160 	INFO_PRINTF2(TRefByValue<const TDesC>(_L("Testing \"FIXED_DIAL_NUM\" returned %d")), status.Int());
       
   161 	if(status.Int() == KErrNone)
       
   162 	    {
       
   163 		aPhoneStoreInfo = aPhoneStoreInfoPckg();
       
   164 		checkPhoneBookInfoL(aPhoneStoreInfo);
       
   165 	    }
       
   166 	else
       
   167 	    {
       
   168 		INFO_PRINTF1(_L("*** Phone Book \"FIXED_DIAL_NUM\" not supported by this phone ***"));
       
   169 	    }
       
   170 
       
   171 	iPhone.GetPhoneStoreInfo(status, aPhoneStoreInfoPckg, KETelIccSdnPhoneBook);
       
   172 	User::WaitForRequest(status);
       
   173 	INFO_PRINTF2(TRefByValue<const TDesC>(_L("Testing \"SERV_DIAL_NUM\" returned %d")), status.Int());
       
   174 	if(status.Int() == KErrNone)
       
   175 	    {
       
   176 		aPhoneStoreInfo = aPhoneStoreInfoPckg();
       
   177 		checkPhoneBookInfoL(aPhoneStoreInfo);
       
   178 	    }
       
   179 	else
       
   180 	    {
       
   181 		INFO_PRINTF1(_L("*** Phone Book \"SERV_DIAL_NUM\" not supported by this phone ***"));
       
   182 	    }
       
   183 
       
   184 	iPhone.GetPhoneStoreInfo(status, aPhoneStoreInfoPckg, KETelIccBdnPhoneBook);
       
   185 	User::WaitForRequest(status);
       
   186 	INFO_PRINTF2(TRefByValue<const TDesC>(_L("Testing \"BARRED_DIAL_NUM\" returned %d")), status.Int());
       
   187 	if(status.Int() == KErrNone)
       
   188 	    {
       
   189 		aPhoneStoreInfo = aPhoneStoreInfoPckg();
       
   190 		checkPhoneBookInfoL(aPhoneStoreInfo);
       
   191 	    }
       
   192 	else
       
   193 	    {
       
   194 		INFO_PRINTF1(_L("*** Phone Book \"BARRED_DIAL_NUM\" not supported by this phone ***"));
       
   195 	    }
       
   196 	    
       
   197 	// RAM phonebook
       
   198 	TEST( CheckPhoneStoreInfo(iPhone, KETelMeAdnPhoneBook, KEtelGsmPhoneBookType, _L("RAM phonebook")) == KErrNone );
       
   199 	// Dialled numbers phonebook
       
   200 	TEST( CheckPhoneStoreInfo(iPhone, KETelMeDialledPhoneBook, KEtelGsmPhoneBookType, _L("Dialled numbers phonebook")) == KErrNone );
       
   201 	// Missed calls phonebook
       
   202 	TEST( CheckPhoneStoreInfo(iPhone, KETelMeMissedPhoneBook, KEtelGsmPhoneBookType, _L("Missed calls phonebook")) == KErrNone );
       
   203 	// Received calls phonebook
       
   204 	TEST( CheckPhoneStoreInfo(iPhone, KETelMeReceivedPhoneBook, KEtelGsmPhoneBookType, _L("Received calls phonebook")) == KErrNone );
       
   205 	// SIM phonebook
       
   206 	TEST( CheckPhoneStoreInfo(iPhone, KETelIccAdnPhoneBook, KEtelGsmPhoneBookType, _L("SIM phonebook")) == KErrNone );
       
   207 	// Fixed dialling numbers phonebook
       
   208 	TEST( CheckPhoneStoreInfo(iPhone, KETelIccFdnPhoneBook, KEtelGsmPhoneBookType, _L("Fixed dialling numbers phonebook")) == KErrNone );
       
   209 	// Service dialling numbers phonebook
       
   210 	TEST( CheckPhoneStoreInfo(iPhone, KETelIccSdnPhoneBook, KEtelGsmPhoneBookType, _L("Service dialling numbers phonebook")) == KErrNone );
       
   211 	// Own number phonebook
       
   212 	TEST( CheckPhoneStoreInfo(iPhone, KETelOwnNumberStore, KEtelGsmPhoneBookType, _L("Own number phonebook")) == KErrNone );
       
   213 	// Emergency number phonebook
       
   214 	TEST( CheckPhoneStoreInfo(iPhone, KETelEmergencyNumberStore, KEtelGsmPhoneBookType, _L("Emergency number phonebook")) == KErrNone );
       
   215 	// SIM dialled numbers phonebook
       
   216 	TEST( CheckPhoneStoreInfo(iPhone, KETelIccLndPhoneBook, KEtelGsmPhoneBookType, _L("SIM dialled numbers phonebook")) == KErrNone );
       
   217 	// Voice mail
       
   218 	TEST( CheckPhoneStoreInfo(iPhone, KETelIccVoiceMailBox, KEtelGsmPhoneBookType, _L("Voice mail")) == KErrNone );
       
   219 	// ICC SMS Store
       
   220 	TEST( CheckPhoneStoreInfo(iPhone, KETelIccSmsStore, KEtelGsmPhoneBookType, _L("ICC SMS Store")) == KErrNone );
       
   221 	
       
   222 	INFO_PRINTF1(_L("\n\nTest using RMobilePhone::GetPhoneStoreInfo() with CDMA mode specified\n"));
       
   223 	
       
   224 	// RAM phonebook
       
   225 	TEST( CheckPhoneStoreInfo(iPhone, KETelMeAdnPhoneBook, KEtelCdmaPhoneBookType, _L("RAM phonebook")) == KErrNone );
       
   226 	// Dialled numbers phonebook
       
   227 	TEST( CheckPhoneStoreInfo(iPhone, KETelMeDialledPhoneBook, KEtelCdmaPhoneBookType, _L("Dialled numbers phonebook")) == KErrNone );
       
   228 	// Missed calls phonebook
       
   229 	TEST( CheckPhoneStoreInfo(iPhone, KETelMeMissedPhoneBook, KEtelCdmaPhoneBookType, _L("Missed calls phonebook")) == KErrNone );
       
   230 	// Received calls phonebook
       
   231 	TEST( CheckPhoneStoreInfo(iPhone, KETelMeReceivedPhoneBook, KEtelCdmaPhoneBookType, _L("Received calls phonebook")) == KErrNone );
       
   232 	// SIM phonebook
       
   233 	TEST( CheckPhoneStoreInfo(iPhone, KETelIccAdnPhoneBook, KEtelCdmaPhoneBookType, _L("SIM phonebook")) == KErrNone );
       
   234 	// Fixed dialling numbers phonebook
       
   235 	TEST( CheckPhoneStoreInfo(iPhone, KETelIccFdnPhoneBook, KEtelCdmaPhoneBookType, _L("Fixed dialling numbers phonebook")) == KErrNone );
       
   236 	// Service dialling numbers phonebook
       
   237 	TEST( CheckPhoneStoreInfo(iPhone, KETelIccSdnPhoneBook, KEtelCdmaPhoneBookType, _L("Service dialling numbers phonebook")) == KErrNone );
       
   238 	// Own number phonebook
       
   239 	TEST( CheckPhoneStoreInfo(iPhone, KETelOwnNumberStore, KEtelCdmaPhoneBookType, _L("Own number phonebook")) == KErrNone );
       
   240 	// Emergency number phonebook
       
   241 	TEST( CheckPhoneStoreInfo(iPhone, KETelEmergencyNumberStore, KEtelCdmaPhoneBookType, _L("Emergency number phonebook")) == KErrNone );
       
   242 	// SIM dialled numbers phonebook
       
   243 	TEST( CheckPhoneStoreInfo(iPhone, KETelIccLndPhoneBook, KEtelCdmaPhoneBookType, _L("SIM dialled numbers phonebook")) == KErrNone );
       
   244 	// Voice mail
       
   245 	TEST( CheckPhoneStoreInfo(iPhone, KETelIccVoiceMailBox, KEtelCdmaPhoneBookType, _L("Voice mail")) == KErrNone );
       
   246 	// ICC SMS Store
       
   247 	TEST( CheckPhoneStoreInfo(iPhone, KETelIccSmsStore, KEtelCdmaPhoneBookType, _L("ICC SMS Store")) == KErrNone );
       
   248 	
       
   249 	INFO_PRINTF1(_L("\n\nTest using RMobilePhone::GetPhoneStoreInfo() with USIM mode specified\n"));
       
   250 	
       
   251 	// RAM phonebook
       
   252 	TEST( CheckPhoneStoreInfo(iPhone, KETelMeAdnPhoneBook, KEtelUSimPhoneBookType, _L("RAM phonebook")) == KErrNone );
       
   253 	// Dialled numbers phonebook
       
   254 	TEST( CheckPhoneStoreInfo(iPhone, KETelMeDialledPhoneBook, KEtelUSimPhoneBookType, _L("Dialled numbers phonebook")) == KErrNone );
       
   255 	// Missed calls phonebook
       
   256 	TEST( CheckPhoneStoreInfo(iPhone, KETelMeMissedPhoneBook, KEtelUSimPhoneBookType, _L("Missed calls phonebook")) == KErrNone );
       
   257 	// Received calls phonebook
       
   258 	TEST( CheckPhoneStoreInfo(iPhone, KETelMeReceivedPhoneBook, KEtelUSimPhoneBookType, _L("Received calls phonebook")) == KErrNone );
       
   259 	// SIM phonebook
       
   260 	TEST( CheckPhoneStoreInfo(iPhone, KETelIccAdnPhoneBook, KEtelUSimPhoneBookType, _L("SIM phonebook")) == KErrNone );
       
   261 	// Fixed dialling numbers phonebook
       
   262 	TEST( CheckPhoneStoreInfo(iPhone, KETelIccFdnPhoneBook, KEtelUSimPhoneBookType, _L("Fixed dialling numbers phonebook")) == KErrNone );
       
   263 	// Service dialling numbers phonebook
       
   264 	TEST( CheckPhoneStoreInfo(iPhone, KETelIccSdnPhoneBook, KEtelUSimPhoneBookType, _L("Service dialling numbers phonebook")) == KErrNone );
       
   265 	// Own number phonebook
       
   266 	TEST( CheckPhoneStoreInfo(iPhone, KETelOwnNumberStore, KEtelUSimPhoneBookType, _L("Own number phonebook")) == KErrNone );
       
   267 	// Emergency number phonebook
       
   268 	TEST( CheckPhoneStoreInfo(iPhone, KETelEmergencyNumberStore, KEtelUSimPhoneBookType, _L("Emergency number phonebook")) == KErrNone );
       
   269 	// SIM dialled numbers phonebook
       
   270 	TEST( CheckPhoneStoreInfo(iPhone, KETelIccLndPhoneBook, KEtelUSimPhoneBookType, _L("SIM dialled numbers phonebook")) == KErrNone );
       
   271 	// Voice mail
       
   272 	TEST( CheckPhoneStoreInfo(iPhone, KETelIccVoiceMailBox, KEtelUSimPhoneBookType, _L("Voice mail")) == KErrNone );
       
   273 	// ICC SMS Store
       
   274 	TEST( CheckPhoneStoreInfo(iPhone, KETelIccSmsStore, KEtelUSimPhoneBookType, _L("ICC SMS Store")) == KErrNone );
       
   275 	    
       
   276 	return TestStepResult();
       
   277 	}
       
   278 	
       
   279 //------------------------------------------------------------------
       
   280 
       
   281 CTestGetCapsAndInfo::CTestGetCapsAndInfo()
       
   282 /** Each test step initialises it's own name
       
   283 */
       
   284 	{
       
   285 	// store the name of this test case
       
   286 	// this is the name that is used by the script file
       
   287 	SetTestStepName(_L("TestGetCapsAndInfo"));
       
   288 	}
       
   289 //------------------------------------------------------------------
       
   290 
       
   291 TVerdict CTestGetCapsAndInfo::doTestStepL( void )
       
   292 /**
       
   293  * This function gets the SIM phone book's static capabilities (as well as the ME &
       
   294  * MT phone books, if supported), and information associated with the phone book.
       
   295  * It also validates the obtained information.
       
   296  * @test GT83-TPHBK-001.06 Test opening an ICC-based phonebook of abbreviated dialling numbers
       
   297  * @test GT83-TPHBK-002.06 Test closing an ICC-based phonebook of abbreviated dialling numbers
       
   298  * @test GT83-TPHBK-003.04 Test retrieval of the phone book store info and capabilities of an ME-based phonebook of abbreviated dialling numbers.
       
   299  * @test GT83-TPHBK-003.06 Test retrieval of the phone book store info and capabilities of an ICC-based phonebook of abbreviated dialling numbers
       
   300  * @test GT83-TPHBK-003.11 Test retrieval of the phone book store info and capabilities of a combination of the ADN stored in ME and ICC
       
   301  * @test GT83-TPHBK-003.13 Test cancelling a request to retrieve phone book store info and capabilities
       
   302  */
       
   303 	{
       
   304 	TInt ret=KErrNone;
       
   305 	TRequestStatus status;
       
   306 	RMobilePhoneBookStore::TMobilePhoneBookInfoV1 aInfo;
       
   307 	RMobilePhoneBookStore::TMobilePhoneBookInfoV1Pckg aInfoPckg(aInfo);
       
   308 	RMobilePhoneBookStore::TMobilePhoneBookInfoV1 *aInfob;
       
   309 
       
   310 	// SIM phone book - mandatory
       
   311 	RMobilePhoneBookStore simPhBk;
       
   312 	ret=simPhBk.Open(iPhone,  KETelIccAdnPhoneBook);
       
   313 	TEST_CHECKL(ret, KErrNone, _L("*** Failed to open ICC ADN Phonebook!! ***"));
       
   314 	simPhBk.GetInfo(status, aInfoPckg);
       
   315 	User::WaitForRequest(status);
       
   316 	CHECKPOINT(status.Int(), KErrNone, _L("GT83-TPHBK-003.06 - *** Failed RMobilePhoneBookStore::GetInfo() ***")) ;
       
   317 	aInfob = &aInfoPckg();
       
   318 	TEST(aInfob->iCaps & RMobilePhoneStore::KCapsWriteAccess);
       
   319 	TEST(!aInfob->iName.Compare(KETelIccAdnPhoneBook()));
       
   320 	simPhBk.Close();
       
   321 
       
   322 	// ME phone book - optional support by the phones
       
   323 	RMobilePhoneBookStore mePhBk;
       
   324 	ret=mePhBk.Open(iPhone,  KETelMeAdnPhoneBook());
       
   325 	if (ret==KErrNone)
       
   326 		{
       
   327 		INFO_PRINTF1(_L("ME phonebook supported"));
       
   328 		mePhBk.GetInfo(status, aInfoPckg);
       
   329 		User::WaitForRequest(status);
       
   330 		CHECKPOINT(status.Int(), KErrNone, _L("GT83-TPHBK-003.04 - *** Failed RMobilePhoneBookStore::GetInfo() ***")) ;
       
   331 		aInfob = &aInfoPckg();
       
   332 		TEST(aInfob->iCaps & RMobilePhoneStore::KCapsWriteAccess);
       
   333 		TEST(!aInfob->iName.Compare(KETelMeAdnPhoneBook()));
       
   334 		}
       
   335 	else
       
   336 		INFO_PRINTF1(_L("*** Failed to open ME ADN Phonebook, Phonebook may not be supported by phone ***"));
       
   337 
       
   338 	mePhBk.Close();
       
   339 
       
   340 	// Combined ME and SIM phone book - optional support by the phones
       
   341 	RMobilePhoneBookStore combPhBk;
       
   342 	ret=combPhBk.Open(iPhone,  KETelCombinedAdnPhoneBook());
       
   343 	if (ret==KErrNone)
       
   344 		{
       
   345 		INFO_PRINTF1(_L("Combined ME & SIM phonebook supported"));
       
   346 
       
   347 		combPhBk.GetInfo(status, aInfoPckg);
       
   348 		User::WaitForRequest(status);
       
   349 		CHECKPOINT(status.Int(), KErrNone, _L("GT83-TPHBK-003.11 - *** Failed RMobilePhoneBookStore::GetInfo() ***")) ;
       
   350 
       
   351 		aInfob = &aInfoPckg();
       
   352 
       
   353 		TEST(aInfob->iCaps && RMobilePhoneStore::KCapsWriteAccess);
       
   354 		TEST(!aInfob->iName.Compare(KETelCombinedAdnPhoneBook()));
       
   355 		}
       
   356 	combPhBk.Close();
       
   357 
       
   358 		// Combined ME and SIM phone book
       
   359 	ret=combPhBk.Open(iPhone,  KETelCombinedAdnPhoneBook());
       
   360 	if(ret==KErrNone)
       
   361 		{
       
   362 		combPhBk.GetInfo(status, aInfoPckg);
       
   363 		User::WaitForRequest(status);
       
   364 		CHECKPOINT(status.Int(), KErrNone, _L("GT83-TPHBK-003.11 - *** Failed RMobilePhoneBookStore::GetInfo() ***")) ;
       
   365 
       
   366 		aInfob = &aInfoPckg();
       
   367 
       
   368 		TEST(aInfob->iMaxNumLength >0);
       
   369 		TEST(aInfob->iMaxTextLength >=0);
       
   370 		TEST(!aInfob->iName.Compare(KETelCombinedAdnPhoneBook()));
       
   371 
       
   372 		#ifdef __TEST_CANCEL__
       
   373 		combPhBk.GetInfo(status, aInfoPckg);
       
   374 		combPhBk.CancelAsyncRequest(EMobilePhoneStoreGetInfo);
       
   375 		User::WaitForRequest(status);
       
   376 		INFO_PRINTF2(_L("Async MT PhoneBook GetInfo Cancel Status = %d"),status);
       
   377 		CHECKPOINT_EXPR((status==KErrCancel || status==KErrNone), _L("GT83-TPHBK-003.13 - *** Failed CancelAsyncRequest(EMobilePhoneStoreGetInfo) ***"));
       
   378 		#endif
       
   379 		}
       
   380 	combPhBk.Close();
       
   381 	return TestStepResult();
       
   382 	}
       
   383 //------------------------------------------------------------------
       
   384 
       
   385 CTestReadAndWrite::CTestReadAndWrite()
       
   386 /** Each test step initialises it's own name
       
   387 */
       
   388 	{
       
   389 	// store the name of this test case
       
   390 	// this is the name that is used by the script file
       
   391 	SetTestStepName(_L("TestReadAndWrite"));
       
   392 	}
       
   393 
       
   394 //------------------------------------------------------------------
       
   395 
       
   396 void CTestReadAndWrite::WriteToMEPhBkL()
       
   397 /**
       
   398  * This function is called from the testReadAndWrite() function. Writes to the 1st 4
       
   399  * locations in the ME PhoneBook. Any existing entries in these locations will be overwritten.
       
   400  * @test GT83-TPHBK-001.04 Test opening a ME-based phonebook of abbreviated dialling numbers.
       
   401  * @test GT83-TPHBK-007.04 "Test writing a single phonebook entry to a specified location in a ME-based phonebook of abbreviated dialling numbers, where the location is empty"
       
   402 */
       
   403 	{
       
   404 	const TInt KEntries=4;
       
   405 	RMobilePhoneBookStore mePhBk;
       
   406 	TRequestStatus status;
       
   407 	TInt ret(KErrNone);
       
   408 	
       
   409 	ret=mePhBk.Open(iPhone,  KETelMeAdnPhoneBook);
       
   410 	if(ret==KErrNone)
       
   411 		{
       
   412 		INFO_PRINTF1(_L("Write to the ME PhoneBook..."));
       
   413 
       
   414 		TBuf8<KPBDataClientBuf> pbData; // Client reserved space for phonebook data
       
   415 
       
   416 		_LIT16(KTel,"123456%03d");
       
   417 		_LIT16(KText,"TelNo %03d");
       
   418 		TBuf16<13> text(KTel), number(KText);
       
   419 
       
   420 		CPhoneBookBuffer* pbBuffer = new(ELeave) CPhoneBookBuffer(); // used to write phonebook data
       
   421 		pbBuffer->Set(&pbData); // Set it to point to the Client buffer
       
   422 
       
   423 		for(TInt index=1;index<=KEntries;++index)
       
   424 			{
       
   425 			// First specify starting index and set iNumofEntries to 1, since it is only
       
   426 			// possible to write one entry at a time
       
   427 
       
   428 			number.FillZ(); // Reset previous values
       
   429 			number.Zero();
       
   430 			text.FillZ();
       
   431 			text.Zero();
       
   432 			pbData.FillZ();
       
   433 			pbData.Zero();
       
   434 
       
   435 			// convert number into TLV format and append it to allocated buffer
       
   436 			number.Format(KTel(), index);
       
   437 			ret=pbBuffer->PutTagAndValue(RMobilePhoneBookStore::ETagPBNumber, number);
       
   438 			TESTL(ret == KErrNone) ;
       
   439 
       
   440 			// convert number type into TLV format and append it to allocated buffer
       
   441 			TUint8 tonNpi=KTypeOfNumber; 
       
   442 			ret=pbBuffer->PutTagAndValue(RMobilePhoneBookStore::ETagPBTonNpi, tonNpi);
       
   443 			TESTL(ret == KErrNone);
       
   444 
       
   445 			text.Format(KText(), index);
       
   446 			INFO_PRINTF2(_L("Writing \'%S\'"),&text);
       
   447 
       
   448 			// convert text into TLV format and append it to allocated buffer
       
   449 			ret=pbBuffer->PutTagAndValue(RMobilePhoneBookStore::ETagPBText, text);
       
   450 			TESTL(ret == KErrNone);
       
   451 
       
   452 			mePhBk.Write(status, pbData, index);
       
   453 			User::WaitForRequest(status);
       
   454 			TEST_CHECKL(status.Int(), KErrNone, _L("GT83-TPHBK-007.04 - *** Failed to Write to the ME Phonebook! ***"));
       
   455 			}
       
   456 		delete pbBuffer;
       
   457 		}
       
   458 
       
   459 	else
       
   460 		INFO_PRINTF1(_L("*** Failed to open ME ADN Phonebook! ***"));
       
   461 
       
   462 	mePhBk.Close();
       
   463 	}
       
   464 
       
   465 //------------------------------------------------------------------
       
   466 
       
   467 TVerdict CTestReadAndWrite::doTestStepL( void )
       
   468 /**
       
   469  * This function creates an array of names and telephone numbers which are to be used as
       
   470  * phone book entries. It then writes these entries synchronously to the SIM phone book
       
   471  * and reads them back. If the Combined Phone book is supported, entries are first written
       
   472  * to the ME phonebook and then read from the Combined Phone book. This is because the MT
       
   473  * (SIM + ME) phonebook does not have write access.
       
   474  * @test GT83-TPHBK-001.06 Test opening an ICC-based phonebook of abbreviated dialling numbers
       
   475  * @test GT83-TPHBK-002.06 Test closing an ICC-based phonebook of abbreviated dialling numbers
       
   476  * @test GT83-TPHBK-001.11 Test opening a combination of the ADN stored in ME and ICC
       
   477  * @test GT83-TPHBK-002.11 Test closing a combination of the ADN stored in ME and ICC
       
   478  * @test GT83-TPHBK-006.06 Test retrieval of entries in an ICC-based phonebook of abbreviated dialling numbers
       
   479  * @test GT83-TPHBK-006.11 Test retrieval of entries in a combination of the ADN stored in ME and ICC
       
   480  * @test GT83-TPHBK-007.06 Test writing a single phonebook entry to a specified location in an ICC-based phonebook containing voice mailbox numbers, where the location is empty
       
   481  * @test GT83-TPHBK-007.11 Test writing a single phonebook entry to a specified location in an ICC-based phonebook containing the fixed dialling numbers list, when the phone is in a mode that allows editing the fixed dialling numbers, where the location is empty
       
   482 */
       
   483 	{
       
   484 	TInt ret=KErrNone;
       
   485 	TRequestStatus status;
       
   486 	RMobilePhoneBookStore simPhBk;
       
   487 
       
   488 	TBuf8<KPBDataClientBuf> pbData, pbReadData1, pbReadData2, pbReadEmpty; // Client reserved space for phonebook data
       
   489 	TInt requestedIndex(0);
       
   490 
       
   491 	// Create array of names and numbers
       
   492 	const TText16* names[]={(TText16*)KAnnText.iBuf, (TText16*)KMattSText.iBuf, (TText16*)KAndyText.iBuf,
       
   493 						  (TText16*)KMattMText.iBuf,(TText16*)KPaulText.iBuf, (TText16*)KMumAndDadText.iBuf,
       
   494 						  (TText16*)KSymbolText.iBuf,(TText16*)KTextTooLong.iBuf};
       
   495 
       
   496 	const TText16* numbers[]={(TText16*)KAnnPhoneNum.iBuf, (TText16*)KMattSPhoneNum.iBuf, (TText16*)KAndyPhoneNum.iBuf,
       
   497 							(TText16*)KMattMPhoneNum.iBuf, (TText16*)KPaulPhoneNum.iBuf, (TText16*)KMumAndDadPhoneNum.iBuf,
       
   498 							(TText16*)KSymbolPhoneNum.iBuf,(TText16*)KNumberTooLong.iBuf};
       
   499 
       
   500 
       
   501 	TBuf16<KBufSize> entryNumber(numbers[0]);
       
   502 	TBuf16<KBufSize> entryName(names[0]);
       
   503 	// Motorola T260 requires a pause otherwise it does not respond to the 
       
   504 	// next AT command.
       
   505 	User::After(500000);
       
   506 	CPhoneBookBuffer* pbBuffer = new(ELeave) CPhoneBookBuffer();
       
   507 	pbBuffer->Set(&pbData); // Set it to point to the Client buffer
       
   508 
       
   509 	// Write the entries to the SIM Phone Book
       
   510 	TInt writeIndex(0);
       
   511 	TInt i(0), size(KPPBEntriesNum);
       
   512 
       
   513 	TUint8 tagValue(0);
       
   514 	CPhoneBookBuffer::TPhBkTagType aDataType;
       
   515 
       
   516 
       
   517 	/* Read the entries back */
       
   518 	TUint16 index;
       
   519 	TUint8  tonNpi(0);
       
   520 	TPtrC16 number(NULL,0);
       
   521 	TPtrC16 text(NULL,0);
       
   522 
       
   523 
       
   524 
       
   525 	ret=simPhBk.Open(iPhone,  KETelIccAdnPhoneBook());
       
   526 	CHECKPOINT(ret, KErrNone, _L("*** Failed to open ICC ADN Phonebook ***"));
       
   527 	if(ret==KErrNone)
       
   528 		{
       
   529 		RMobilePhoneBookStore::TMobilePhoneBookInfoV1Pckg dummyInfoPckg(iDummyInfo);
       
   530 		for (i=1; i<=size; ++i)
       
   531 			{
       
   532 			simPhBk.GetInfo(status, dummyInfoPckg);		// Recommended by EtelMM API documentation
       
   533 			User::WaitForRequest(status);
       
   534 
       
   535 			//first reset the following three local buffers to delete any existing data
       
   536 			entryNumber.Zero();
       
   537 			entryName.Zero();
       
   538 			pbData.Zero();
       
   539 
       
   540 			entryNumber=numbers[i-1];
       
   541 			entryName=names[i-1];
       
   542 
       
   543 			// First specify starting index and set iNumofEntries to 1, since it is only
       
   544 			// possible to write one entry at a time
       
   545 
       
   546 			writeIndex = i; // Note that TSY will overwrite any existing data. It is up to
       
   547 							// the Sync to check whether it is the first available entry
       
   548 
       
   549 			// convert number into TLV format and append it to allocated buffer
       
   550 			ret=pbBuffer->PutTagAndValue(RMobilePhoneBookStore::ETagPBNumber, entryNumber);
       
   551 			TEST(ret == KErrNone) ;
       
   552 
       
   553 			// convert type into TLV format and append it to allocated buffer
       
   554 			TUint8 tonNpi=KTypeOfNumber; 
       
   555 			ret=pbBuffer->PutTagAndValue(RMobilePhoneBookStore::ETagPBTonNpi, tonNpi);
       
   556 			TEST(ret == KErrNone) ;
       
   557 
       
   558 			// convert text into TLV format and append it to allocated buffer
       
   559 			ret=pbBuffer->PutTagAndValue(RMobilePhoneBookStore::ETagPBText, entryName);
       
   560 			TEST(ret == KErrNone) ;
       
   561 
       
   562 			simPhBk.Write(status, pbData, writeIndex);
       
   563 			User::WaitForRequest(status);
       
   564 			CHECKPOINT(status.Int(), KErrNone, _L("GT83-TPHBK-007.06 - *** Failed to write to the ICC ADN Phonebook ***"));
       
   565 			}
       
   566 
       
   567 		/* Reads Forwads and it reads all entries individually */
       
   568 		for(i=1; i<=size; ++i)
       
   569 			{
       
   570 			//first reset the following three local buffers to delete any existing data
       
   571 			entryNumber.Zero();
       
   572 			entryName.Zero();
       
   573 			pbData.Zero();
       
   574 
       
   575 			// reset all loop variables
       
   576 			index = 0;
       
   577 			tonNpi = 0;
       
   578 			tagValue = 0;
       
   579 
       
   580 			requestedIndex = i;
       
   581 			simPhBk.Read(status, requestedIndex, 1, pbReadData1);
       
   582 			User::WaitForRequest(status);
       
   583 			CHECKPOINT(status.Int(), KErrNone, _L("GT83-TPHBK-006.06 - *** Failed to read from ICC ADN Phonebook ***")) ;
       
   584 
       
   585 			entryNumber=numbers[i-1];
       
   586 			entryName=names[i-1];
       
   587 
       
   588 			// now decode PB data received in TLV format
       
   589 			pbBuffer->Set(&pbReadData1); // Set pbBuffer to point to received phonebook data
       
   590 			pbBuffer->StartRead();       // Start reading received phonebook data
       
   591 
       
   592 			while (pbBuffer->GetTagAndType(tagValue, aDataType)==KErrNone)
       
   593 				{
       
   594 				switch (tagValue)
       
   595 					{
       
   596 				case RMobilePhoneBookStore::ETagPBAdnIndex:
       
   597 					pbBuffer->GetValue(index);			
       
   598 					break;
       
   599 				case RMobilePhoneBookStore::ETagPBTonNpi:
       
   600 					pbBuffer->GetValue(tonNpi);			
       
   601 					break;
       
   602 				case RMobilePhoneBookStore::ETagPBText:
       
   603 					pbBuffer->GetValue(text);			
       
   604 					break;
       
   605 				case RMobilePhoneBookStore::ETagPBNumber:
       
   606 					pbBuffer->GetValue(number);			
       
   607 					break;
       
   608 				default:
       
   609 					// An unsupported field type - just skip this value
       
   610 					pbBuffer->SkipValue(aDataType);
       
   611 					break;
       
   612 					}
       
   613 			}; // end while
       
   614 
       
   615 			TEST(tonNpi==KTypeOfNumber);
       
   616 			TEST(number.Compare(entryNumber)==KErrNone);
       
   617 			TEST(text.Compare(entryName)==KErrNone);
       
   618 			TEST(index == i) ;
       
   619 		} // end for
       
   620 
       
   621 		// Try to read an empty entry - find out which one is empty first
       
   622 		RMobilePhoneBookStore::TMobilePhoneBookInfoV1 info;
       
   623 		RMobilePhoneBookStore::TMobilePhoneBookInfoV1Pckg infoPckg(info);
       
   624 		simPhBk.GetInfo(status,infoPckg);
       
   625 		User::WaitForRequest(status);
       
   626 		CHECKPOINT(status.Int(), KErrNone, _L("GT83-TPHBK-006.06 - *** Failed RMobilePhoneBookStore::GetInfo() ***")) ;
       
   627 
       
   628 		// If used entry information not available, use total entries and guess
       
   629 		// last one is not used.
       
   630 
       
   631 		requestedIndex = (info.iUsedEntries>=0) ? info.iUsedEntries+1 : info.iTotalEntries;
       
   632 
       
   633 		simPhBk.Read(status, requestedIndex, 1, pbReadEmpty);
       
   634 		User::WaitForRequest(status);
       
   635 		CHECKPOINT(status.Int(), KErrNotFound, _L("GT83-TPHBK-006.06")) ; // If asked to read an empty entry, TSY will return KErrNotFound
       
   636 								 // It is now clients responsibility to ensure a valid index is supplied
       
   637 
       
   638 		// Read Backwards, one by one
       
   639 		for(i=size; i>0; --i)
       
   640 			{
       
   641 			//first reset the following three local buffers to delete any existing data
       
   642 			entryNumber.Zero();
       
   643 			entryName.Zero();
       
   644 			pbData.Zero();
       
   645 
       
   646 			requestedIndex = i;
       
   647 			simPhBk.Read(status, requestedIndex, 1, pbReadData2);
       
   648 			User::WaitForRequest(status);
       
   649 			CHECKPOINT(status.Int(), KErrNone, _L("GT83-TPHBK-006.06")) ;
       
   650 
       
   651 			entryNumber=numbers[i-1];
       
   652 			entryName=names[i-1];
       
   653 
       
   654 			// reset all loop variables
       
   655 			index = 0;
       
   656 			tagValue = 0;
       
   657 
       
   658 			// now decode PB data received in TLV format
       
   659 			pbBuffer->Set(&pbReadData2); // Set pbBuffer to point to received phonebook data
       
   660 			pbBuffer->StartRead();       // Start reading received phonebook data
       
   661 			while (pbBuffer->GetTagAndType(tagValue, aDataType)==KErrNone)
       
   662 				{
       
   663 				switch (tagValue)
       
   664 					{
       
   665 				case RMobilePhoneBookStore::ETagPBAdnIndex:
       
   666 					pbBuffer->GetValue(index);			
       
   667 					break;
       
   668 				case RMobilePhoneBookStore::ETagPBTonNpi:
       
   669 					pbBuffer->GetValue(tonNpi);			
       
   670 					break;
       
   671 				case RMobilePhoneBookStore::ETagPBText:
       
   672 					pbBuffer->GetValue(text);			
       
   673 					break;
       
   674 				case RMobilePhoneBookStore::ETagPBNumber:
       
   675 					pbBuffer->GetValue(number);			
       
   676 					break;
       
   677 				default:
       
   678 					// An unsupported field type - just skip this value
       
   679 					pbBuffer->SkipValue(aDataType);
       
   680 					break;
       
   681 					}
       
   682 			} // end while
       
   683 
       
   684 			TEST(tonNpi==KTypeOfNumber);
       
   685 			TEST(number.Compare(entryNumber)==KErrNone);
       
   686 			TEST(text.Compare(entryName)==KErrNone);
       
   687 			TEST(index == i) ;
       
   688 			} // end for
       
   689 		} //end if
       
   690 
       
   691 	simPhBk.Close();
       
   692 
       
   693 // From Combined phone book
       
   694 
       
   695 	//
       
   696 	// This part of the test reads the 1st few entries in the combined Phone Book (ME+
       
   697 	// SIM). As the Combined Phonebook does not (should not) have 'WriteAccess', some
       
   698 	// entries will first be written to the ME phone book. The SIM phone book
       
   699 	// already contains the entries written above.
       
   700 	//
       
   701 	WriteToMEPhBkL();
       
   702 
       
   703 	RMobilePhoneBookStore combPhBk;
       
   704 	ret=combPhBk.Open(iPhone,  KETelCombinedAdnPhoneBook);
       
   705 	if(ret==KErrNone)
       
   706 		{
       
   707 		RMobilePhoneBookStore::TMobilePhoneBookInfoV1Pckg dummyInfoPckg(iDummyInfo);
       
   708 		combPhBk.GetInfo(status, dummyInfoPckg);		// Recommended by EtelMM API documentation
       
   709 		User::WaitForRequest(status);
       
   710 
       
   711 		const TInt KEntries=4;		// Same value in WriteToMEPhBk()
       
   712 		const TInt KBufSize=20;
       
   713 
       
   714 		// Read index locations 1 to KEntries
       
   715 		for(TUint16 index=1;index<=KEntries;++index)
       
   716 			{
       
   717 			combPhBk.Read(status, index, 1, pbReadData2);
       
   718 			User::WaitForRequest(status);
       
   719 			CHECKPOINT(status.Int(), KErrNone, _L("GT83-TPHBK-006.11 - *** Failed to read from Combined Phonebook ***")) ;
       
   720 
       
   721 			// now decode PB data received in TLV format
       
   722 			TPtrC16 telNumPtr;
       
   723 			TPtrC16 textPtr;
       
   724 
       
   725 			pbBuffer->Set(&pbReadData2); // Set pbBuffer to point to received phonebook data
       
   726 			pbBuffer->StartRead();       // Start reading received phonebook data
       
   727 
       
   728 			while (pbBuffer->GetTagAndType(tagValue, aDataType)==KErrNone)
       
   729 				{
       
   730 				switch (tagValue)
       
   731 					{
       
   732 				case RMobilePhoneBookStore::ETagPBText:
       
   733 					pbBuffer->GetValue(textPtr);			
       
   734 					break;
       
   735 				case RMobilePhoneBookStore::ETagPBNumber:
       
   736 					pbBuffer->GetValue(telNumPtr);			
       
   737 					break;
       
   738 				default:
       
   739 					// An unsupported field type - just skip this value
       
   740 					pbBuffer->SkipValue(aDataType);
       
   741 					break;
       
   742 					}
       
   743 				} 
       
   744 
       
   745 			//
       
   746 			// Assemble the data we expect to have read
       
   747 			_LIT16(KTel,"123456%03d");
       
   748 			_LIT16(KText,"TelNo %03d");
       
   749 			TBuf16<KBufSize> telNumExpected;
       
   750 			TBuf16<KBufSize> textExpected;
       
   751 			telNumExpected.Format(KTel,index);
       
   752 			textExpected.Format(KText,index);
       
   753 						
       
   754 			//
       
   755 			// Check the data we actually read with what we expected to read
       
   756 			TEST(telNumPtr.Compare(telNumExpected)==0);
       
   757 			TEST(textPtr.Compare(textExpected)==0);
       
   758 			} 
       
   759 
       
   760 		// Entry to write - this should be read only...
       
   761 		requestedIndex = 5;
       
   762 
       
   763 		// convert number into TLV format and append it to allocated buffer
       
   764 		ret=pbBuffer->PutTagAndValue(RMobilePhoneBookStore::ETagPBNumber, KAnnPhoneNum);
       
   765 		TEST(ret == KErrNone) ;
       
   766 
       
   767 		// convert number type into TLV format and append it to allocated buffer
       
   768 		tonNpi=KTypeOfNumber;
       
   769 		ret=pbBuffer->PutTagAndValue(RMobilePhoneBookStore::ETagPBTonNpi, tonNpi);
       
   770 		TEST(ret == KErrNone) ;
       
   771 
       
   772 		// convert text into TLV format and append it to allocated buffer
       
   773 		ret=pbBuffer->PutTagAndValue((TUint8)RMobilePhoneBookStore::ETagPBText, KAnnText);
       
   774 		TEST(ret == KErrNone) ;
       
   775 		}
       
   776 	combPhBk.Close();
       
   777 	delete pbBuffer;
       
   778 	return TestStepResult();
       
   779 	}
       
   780 //------------------------------------------------------------------
       
   781 
       
   782 CTestDelete::CTestDelete()
       
   783 /** Each test step initialises it's own name
       
   784 */
       
   785 	{
       
   786 	// store the name of this test case
       
   787 	// this is the name that is used by the script file
       
   788 	SetTestStepName(_L("TestDelete"));
       
   789 	}
       
   790 //------------------------------------------------------------------
       
   791 
       
   792 TVerdict CTestDelete::doTestStepL( void )
       
   793 /**
       
   794  * This function deletes the first 7 entries from the SIM phone book
       
   795  * @test GT83-TPHBK-001.06 Test opening an ICC-based phonebook of abbreviated dialling numbers
       
   796  * @test GT83-TPHBK-002.06 Test closing an ICC-based phonebook of abbreviated dialling numbers
       
   797  * @test GT83-TPHBK-006.	06 Test retrieval of the first entry in an ICC-based phonebook of abbreviated dialling numbers
       
   798  * @test GT83-TPHBK-008.06 Test deleting an individual phonebook entry from an ICC-based phonebook of abbreviated dialling numbers
       
   799  */
       
   800 	{
       
   801 	TRequestStatus status;
       
   802 	RMobilePhoneBookStore simPhBk;
       
   803 	TBuf8<KPBDataClientBuf> pbData; // Client reserved space for phonebook data
       
   804 	TInt ret(KErrNone);
       
   805 	
       
   806 	ret=simPhBk.Open(iPhone,  KETelIccAdnPhoneBook);
       
   807 	CHECKPOINT(ret, KErrNone, _L("*** Failed to open ICC ADN Phonebook! ***"));
       
   808 	if(ret==KErrNone)
       
   809 		{
       
   810 		RMobilePhoneBookStore::TMobilePhoneBookInfoV1 info;
       
   811 		RMobilePhoneBookStore::TMobilePhoneBookInfoV1Pckg infoPckg(info);
       
   812 		simPhBk.GetInfo(status, infoPckg);		// Recommended by EtelMM API documentation
       
   813 		User::WaitForRequest(status);
       
   814 
       
   815 		for(TInt i=1; i<=KPPBEntriesNum; ++i)
       
   816 			{
       
   817 			simPhBk.Delete(status, i);
       
   818 			User::WaitForRequest(status);
       
   819 			CHECKPOINT(status.Int(), KErrNone, _L("GT83-TPHBK-008.06 - ***Failed RMobilePhoneBookStore::Delete()")) ;
       
   820 			}
       
   821 
       
   822 		// now try to read first (empty) entry
       
   823 		simPhBk.Read(status, 1, 1, pbData);
       
   824 		User::WaitForRequest(status); 
       
   825 		CHECKPOINT(status.Int(), KErrNotFound, _L("GT83-TPHBK-006.06")) ;
       
   826 		// If asked to read an emptry entry, TSY will not return an error
       
   827 		// It is now client's responsibility to ensure a valid index is supplied
       
   828 		}
       
   829 	simPhBk.Close();
       
   830 	return TestStepResult();
       
   831 	}
       
   832 //------------------------------------------------------------------
       
   833 
       
   834 CTestNotifications::CTestNotifications()
       
   835 /** Each test step initialises it's own name
       
   836 */
       
   837 	{
       
   838 	// store the name of this test case
       
   839 	// this is the name that is used by the script file
       
   840 	SetTestStepName(_L("TestNotifications"));
       
   841 	}
       
   842 //------------------------------------------------------------------
       
   843 
       
   844 TVerdict CTestNotifications::doTestStepL( void )
       
   845 /**
       
   846  * This function opens the SIM and MT (if supported) phonebooks and posts a request for
       
   847  * notification. Since this notification is not supported by any phonebook it should receive
       
   848  * KErrNotSupported.
       
   849  * @test GT83-TPHBK-001.06 Test opening an ICC-based phonebook of abbreviated dialling numbers
       
   850  * @test GT83-TPHBK-002.06 Test closing an ICC-based phonebook of abbreviated dialling numbers
       
   851  * @test GT83-TPHBK-007.06 "Test writing a single phonebook entry to a specified location in an ICC-based phonebook containing voice mailbox numbers, where the location is empty"
       
   852  * @test GT83-TPHBK-008.06 Test deleting an individual phonebook entry from an ICC-based phonebook of abbreviated dialling numbers
       
   853  * @test GT83-TPHBK-008.16 Test cancelling deleting individual phonebook entries from a phonebook
       
   854  */
       
   855 	{
       
   856 	TRequestStatus status;
       
   857 	RMobilePhoneBookStore simPhBk, combPhBk;
       
   858 	TBuf8<KPBDataClientBuf> pbData; // Client reserved space for phonebook data
       
   859 	TInt index(0), ret(0);
       
   860 
       
   861 	CPhoneBookBuffer* pbBuffer=new(ELeave) CPhoneBookBuffer(); // used to read/write phonebook entries
       
   862 	pbBuffer->Set(&pbData); // Set it to point to the Client buffer
       
   863 
       
   864 	ret=simPhBk.Open(iPhone,  KETelIccAdnPhoneBook);
       
   865 	CHECKPOINT(ret, KErrNone, _L("*** Failed to open ICC ADN Phonebook! ***"));
       
   866 	if(ret==KErrNone)
       
   867 		{
       
   868 		RMobilePhoneBookStore::TMobilePhoneBookInfoV1 info;
       
   869 		RMobilePhoneBookStore::TMobilePhoneBookInfoV1Pckg infoPckg(info);
       
   870 		simPhBk.GetInfo(status, infoPckg);		// Recommended by EtelMM API documentation
       
   871 		User::WaitForRequest(status);
       
   872 
       
   873 		ret=combPhBk.Open(iPhone,  KETelCombinedAdnPhoneBook);
       
   874 		if(ret==KErrNone)
       
   875 			{
       
   876 			combPhBk.GetInfo(status, infoPckg);		// Recommended by EtelMM API documentation
       
   877 			User::WaitForRequest(status);
       
   878 
       
   879 			TRequestStatus status1, status2;
       
   880 			TInt index1 = 0;
       
   881 			TInt index2 = 0;
       
   882 			TUint32 eventToReturn;
       
   883 
       
   884 			simPhBk.NotifyStoreEvent(status1, eventToReturn,index1);	// Will Notify if an entry is added
       
   885 			TEST(status1.Int() == KRequestPending) ;
       
   886 
       
   887 			combPhBk.NotifyStoreEvent(status2, eventToReturn, index2); // Same here ;-)
       
   888 			TEST(status2.Int() == KRequestPending) ;
       
   889 
       
   890 			index = 1; // write to the first slot
       
   891 			// convert number into TLV format and append it to allocated buffer
       
   892 			ret=pbBuffer->PutTagAndValue(RMobilePhoneBookStore::ETagPBNumber, KAnnPhoneNum);
       
   893 			TEST(ret == KErrNone) ;
       
   894 
       
   895 			// convert number type into TLV format and append it to allocated buffer
       
   896 			TUint8 tonNpi=KTypeOfNumber;
       
   897 			ret=pbBuffer->PutTagAndValue(RMobilePhoneBookStore::ETagPBTonNpi, tonNpi);
       
   898 			TEST(ret == KErrNone) ;
       
   899 
       
   900 			// convert text into TLV format and append it to allocated buffer
       
   901 			ret=pbBuffer->PutTagAndValue(RMobilePhoneBookStore::ETagPBText, KAnnText);
       
   902 			TEST(ret == KErrNone) ;
       
   903 
       
   904 			simPhBk.Write(status, pbData, index);
       
   905 			User::WaitForRequest(status); // Write request
       
   906 			CHECKPOINT(status.Int(), KErrNone, _L("GT83-TPHBK-007.06 - *** Failed RMobilePhoneBookStore::Write() ***")) ;
       
   907 
       
   908 			User::WaitForRequest(status1); // Notification
       
   909 			if (status1==KErrNotSupported)
       
   910 				{
       
   911 				// Notification is not supported by phonebook store - as expected
       
   912 				INFO_PRINTF1(_L("Phonebook Store Write Notification is NOT Supported"));
       
   913 				}
       
   914 			else
       
   915 				{
       
   916 				// This should not happen since this notification is not supported by phonebook store
       
   917 				INFO_PRINTF1(_L("Phonebook Store Write Notification IS Supported - failed"));
       
   918 				SetTestStepResult(EFail);
       
   919 				}
       
   920 
       
   921 			User::WaitForRequest(status2);
       
   922 			if (status2==KErrNotSupported)
       
   923 				{
       
   924 				// Notification is not supported by phonebook store - as expected
       
   925 				INFO_PRINTF1(_L("Phonebook Store Write Notification is NOT Supported"));
       
   926 				}
       
   927 			else
       
   928 				{
       
   929 				// This should not happen since this notification is not supported by phonebook store
       
   930 				INFO_PRINTF1(_L("Phonebook Store Write Notification IS Supported - failed"));
       
   931 				SetTestStepResult(EFail);
       
   932 				}
       
   933 
       
   934 			status1= KErrNone; // reset status variable
       
   935 			simPhBk.NotifyStoreEvent(status1, eventToReturn, index1);
       
   936 
       
   937 			combPhBk.NotifyStoreEvent(status2, eventToReturn, index2);
       
   938 
       
   939 			// Now delete that entry
       
   940 			simPhBk.Delete(status, 1);
       
   941 			User::WaitForRequest(status);
       
   942 			CHECKPOINT(status.Int(), KErrNone, _L("GT83-TPHBK-008.06 - *** Failed RMobilePhoneBookStore::Delete() ***")) ;
       
   943 
       
   944 			User::WaitForRequest(status1);
       
   945 			if (status1==KErrNotSupported)
       
   946 				{
       
   947 				// Notification is not supported by phonebook store - as expected
       
   948 				INFO_PRINTF1(_L("Phonebook Store Delete Notification is NOT Supported"));
       
   949 				}
       
   950 			else
       
   951 				{
       
   952 				// This should not happen since this notification is not supported by phonebook store
       
   953 				INFO_PRINTF1(_L("Phonebook Store Delete Notification IS Supported - failed"));
       
   954 				SetTestStepResult(EFail);
       
   955 				}
       
   956 
       
   957 			User::WaitForRequest(status2);
       
   958 			if (status2==KErrNotSupported)
       
   959 				{
       
   960 				// Notification is not supported by phonebook store - as expected
       
   961 				INFO_PRINTF1(_L("Phonebook Store Delete Notification is NOT Supported"));
       
   962 				}
       
   963 			else
       
   964 				{
       
   965 				// This should not happen since this notification is not supported by phonebook store
       
   966 				INFO_PRINTF1(_L("Phonebook Store Delete Notification IS Supported - failed"));
       
   967 				SetTestStepResult(EFail);
       
   968 				}
       
   969 
       
   970 			// EntryChangedNotificationCancel Request
       
   971 			status1= KErrNone; // reset status variable
       
   972 			simPhBk.NotifyStoreEvent(status1, eventToReturn, index1);
       
   973 			simPhBk.CancelAsyncRequest(EMobilePhoneStoreNotifyStoreEvent);
       
   974 			User::WaitForRequest(status1);
       
   975 			// Isn't supported
       
   976 			// TEST_CHECKL(status1.Int(), KErrNone, _L("GT83-TPHBK-008.16")) ;
       
   977 
       
   978 			if (status1==KErrNotSupported)
       
   979 				{
       
   980 				// Notification is not supported by phonebook store - as expected
       
   981 				INFO_PRINTF1(_L("Phonebook Store Notification is NOT Supported"));
       
   982 				}
       
   983 			else
       
   984 				{
       
   985 				// This should not happen since this notification is not supported by phonebook store
       
   986 				INFO_PRINTF1(_L("Phonebook Store Notification cancelled"));
       
   987 				SetTestStepResult(EFail);
       
   988 				}
       
   989 
       
   990 			// Cancel Notification Request after 2 seconds
       
   991 			status1= KErrNone; // reset status variable
       
   992 			simPhBk.NotifyStoreEvent(status1, eventToReturn, index1);
       
   993 
       
   994 			// Now write the same entry again
       
   995 			simPhBk.Write(status, pbData, index);		
       
   996 			User::WaitForRequest(status);
       
   997 			CHECKPOINT(status.Int(), KErrNone, _L("*** Failed RMobilePhoneBookStore::Write() ***")) ;
       
   998 
       
   999 			User::After(2000000L);
       
  1000 			simPhBk.CancelAsyncRequest(EMobilePhoneStoreNotifyStoreEvent);
       
  1001 			User::WaitForRequest(status1);
       
  1002 
       
  1003 			INFO_PRINTF2(TRefByValue<const TDesC>(_L("Cancel Status = %d")), status1.Int());
       
  1004 
       
  1005 			TEST(status1==KErrCancel || status1==KErrNotSupported);
       
  1006 
       
  1007 			simPhBk.Delete(status, 1); // Deleting the last added entry so that the test ends "clean".
       
  1008 			User::WaitForRequest(status);
       
  1009 			}
       
  1010 		combPhBk.Close();
       
  1011 		}
       
  1012 	simPhBk.Close();
       
  1013 	delete pbBuffer;
       
  1014 	return TestStepResult();
       
  1015 
       
  1016 	}
       
  1017 //------------------------------------------------------------------
       
  1018 
       
  1019 CTestInvalidOps::CTestInvalidOps()
       
  1020 /** Each test step initialises it's own name
       
  1021 */
       
  1022 	{
       
  1023 	// store the name of this test case
       
  1024 	// this is the name that is used by the script file
       
  1025 	SetTestStepName(_L("TestInvalidOps"));
       
  1026 	}
       
  1027 //------------------------------------------------------------------
       
  1028 
       
  1029 TVerdict CTestInvalidOps::doTestStepL( void )
       
  1030 /**
       
  1031  * Stress test. Tries to perform invalid operations on the phonebook to make sure the
       
  1032  * phone errors these operations accordingly.
       
  1033  * @test GT83-TPHBK-001.06 Test opening an ICC-based phonebook of abbreviated dialling numbers
       
  1034  * @test GT83-TPHBK-002.06 Test closing an ICC-based phonebook of abbreviated dialling numbers
       
  1035  * @test GT83-TPHBK-003.06 Test retrieval of the phone book store info and capabilities of an ICC-based phonebook of abbreviated dialling numbers
       
  1036  */
       
  1037 	{
       
  1038 	RMobilePhoneBookStore simPhBk;
       
  1039 	RMobilePhoneBookStore::TMobilePhoneBookInfoV1	info;
       
  1040 	TRequestStatus status;
       
  1041 
       
  1042 	TBuf8<KPBDataClientBuf> pbData; // Client reserved space for phonebook data
       
  1043 	TInt index(0); 
       
  1044 	TInt numEntries(1);
       
  1045 	TInt ret(KErrNone);
       
  1046 
       
  1047 	ret=simPhBk.Open(iPhone,  KETelIccAdnPhoneBook);
       
  1048 	TEST_CHECKL(ret, KErrNone, _L("*** Failed to open ICC ADN PhoneBook ***"));
       
  1049 	if(ret==KErrNone)
       
  1050 		{
       
  1051 		CPhoneBookBuffer* pbBuffer=new(ELeave) CPhoneBookBuffer(); // used to read/write phonebook entries
       
  1052 		pbBuffer->Set(&pbData); // Set it to point to the Client buffer
       
  1053 
       
  1054 		// Read and write past the end of phone book - First ask the phone what is the maximum number of
       
  1055 		// entries, then tries to write past the max index!
       
  1056 		RMobilePhoneBookStore::TMobilePhoneBookInfoV1Pckg infoPckg(info);
       
  1057 		simPhBk.GetInfo(status, infoPckg);
       
  1058 		User::WaitForRequest(status);
       
  1059 		CHECKPOINT(status.Int(), KErrNone, _L("GT83-TPHBK-003.06 - ***Failed RMobilePhoneBookStore::GetInfo() ***")) ;
       
  1060 
       
  1061 		TInt maxNumber = info.iTotalEntries;
       
  1062 
       
  1063 		// Write an entry beyond the returned phonebook limit
       
  1064 		index = maxNumber + 1;
       
  1065 
       
  1066 		// convert number into TLV format and append it to allocated buffer
       
  1067 		ret=pbBuffer->PutTagAndValue(RMobilePhoneBookStore::ETagPBNumber, KAnnPhoneNum);
       
  1068 		TEST(ret == KErrNone) ;
       
  1069 
       
  1070 		// convert number type into TLV format and append it to allocated buffer
       
  1071 		TUint8 tonNpi=KTypeOfNumber;
       
  1072 		ret=pbBuffer->PutTagAndValue(RMobilePhoneBookStore::ETagPBTonNpi,tonNpi);
       
  1073 		TEST(ret == KErrNone) ;
       
  1074 
       
  1075 		// convert text into TLV format and append it to allocated buffer
       
  1076 		ret=pbBuffer->PutTagAndValue(RMobilePhoneBookStore::ETagPBText, KAnnText);
       
  1077 		TEST(ret == KErrNone) ;
       
  1078 
       
  1079 		simPhBk.Write(status, pbData, index);
       
  1080 		User::WaitForRequest(status); // Write request
       
  1081 		TEST(status!=KErrNone) ;  // Should not accept Phone book entry maxNumber + 1
       
  1082 
       
  1083 		pbData.Zero(); // Clear buffer
       
  1084 
       
  1085 		// Read that entry
       
  1086 		simPhBk.Read(status, index, numEntries, pbData);
       
  1087 		User::WaitForRequest(status);
       
  1088 		TEST(status!=KErrNone); // There should be no entry written
       
  1089 
       
  1090 		// Delete an entry beyond the returned phonebook limit
       
  1091 		simPhBk.Delete(status, index); // Testing to delete an impossible indexed entry
       
  1092 		User::WaitForRequest(status);
       
  1093 		TEST(status!=KErrNone); // There should be no entry deleted
       
  1094 
       
  1095 		// Write text field too long - assume 30 characters is too long!
       
  1096 		index = 1;
       
  1097 
       
  1098 		// convert number into TLV format and append it to allocated buffer
       
  1099 		ret=pbBuffer->PutTagAndValue(RMobilePhoneBookStore::ETagPBNumber, KAnnPhoneNum);
       
  1100 		TEST(ret == KErrNone) ;
       
  1101 
       
  1102 		// convert number type into TLV format and append it to allocated buffer
       
  1103 		ret=pbBuffer->PutTagAndValue(RMobilePhoneBookStore::ETagPBTonNpi, tonNpi);
       
  1104 		TEST(ret == KErrNone) ;
       
  1105 
       
  1106 		// convert text into TLV format and append it to allocated buffer
       
  1107 		ret=pbBuffer->PutTagAndValue(RMobilePhoneBookStore::ETagPBText, KTextTooLong);
       
  1108 		TEST(ret == KErrNone) ;
       
  1109 
       
  1110 		simPhBk.Write(status, pbData, index);
       
  1111 		User::WaitForRequest(status); // Write request
       
  1112 		if (status==KErrNone)
       
  1113 			{
       
  1114 			INFO_PRINTF1(_L("Phone book does not error writing a too long name tag!"));
       
  1115 			simPhBk.Delete(status, index);
       
  1116 			User::WaitForRequest(status);
       
  1117 			TEST(status == KErrNone) ;
       
  1118 			}
       
  1119 		else
       
  1120 			{
       
  1121 			TEST(status == KErrGeneral) ;
       
  1122 			}
       
  1123 
       
  1124 		// Write number field too long - assume 30 characters is too long!
       
  1125 		index = 1;
       
  1126 		// convert number into TLV format and append it to allocated buffer
       
  1127 		ret=pbBuffer->PutTagAndValue(RMobilePhoneBookStore::ETagPBNumber, KNumberTooLong);
       
  1128 		TEST(ret == KErrNone) ;
       
  1129 
       
  1130 		// convert number type into TLV format and append it to allocated buffer
       
  1131 		ret=pbBuffer->PutTagAndValue(RMobilePhoneBookStore::ETagPBTonNpi,tonNpi);
       
  1132 		TEST(ret == KErrNone) ;
       
  1133 
       
  1134 		// convert text into TLV format and append it to allocated buffer
       
  1135 		ret=pbBuffer->PutTagAndValue(RMobilePhoneBookStore::ETagPBText, KAnnText);
       
  1136 		TEST(ret == KErrNone) ;
       
  1137 
       
  1138 		simPhBk.Write(status, pbData, index);
       
  1139 		User::WaitForRequest(status); // Write request
       
  1140 		if (status==KErrNone)
       
  1141 			{
       
  1142 			INFO_PRINTF1(_L("Phone book does not error writing a too long number field!"));
       
  1143 			simPhBk.Delete(status, index);
       
  1144 			User::WaitForRequest(status);
       
  1145 			TEST(status == KErrNone) ;
       
  1146 			}
       
  1147 		else
       
  1148 			{
       
  1149 			TEST(status == KErrGeneral) ;
       
  1150 			}
       
  1151 		delete pbBuffer;
       
  1152 		}
       
  1153 	simPhBk.Close();
       
  1154 	return TestStepResult();
       
  1155 	}
       
  1156 //------------------------------------------------------------------
       
  1157 
       
  1158 CTestAdvancedPhBk::CTestAdvancedPhBk()
       
  1159 /** Each test step initialises it's own name
       
  1160 */
       
  1161 	{
       
  1162 	// store the name of this test case
       
  1163 	// this is the name that is used by the script file
       
  1164 	SetTestStepName(_L("TestAdvancedPhBk"));
       
  1165 	}
       
  1166 //------------------------------------------------------------------
       
  1167 
       
  1168 TVerdict CTestAdvancedPhBk::doTestStepL( void )
       
  1169 /**
       
  1170  * This function opens an Advanced Gsm SIM PhoneBook, then proceeds to write and then
       
  1171  * delete 'KFillTo' entries from the phone book.
       
  1172  * @test GT83-TPHBK-001.06 Test opening an ICC-based phonebook of abbreviated dialling numbers
       
  1173  * @test GT83-TPHBK-002.06 Test closing an ICC-based phonebook of abbreviated dialling numbers
       
  1174  * @test GT83-TPHBK-003.06 Test retrieval of the phone book store info and capabilities of an ICC-based phonebook of abbreviated dialling numbers
       
  1175  * @test GT83-TPHBK-007.06 "Test writing a single phonebook entry to a specified location in an ICC-based phonebook containing voice mailbox numbers, where the location is empty"
       
  1176  * @test GT83-TPHBK-008.06 Test deleting an individual phonebook entry from an ICC-based phonebook of abbreviated dialling numbers
       
  1177  */
       
  1178 	{
       
  1179 	const TInt KFillTo=30;
       
  1180 
       
  1181 	TInt ret=KErrNone;
       
  1182 	TRequestStatus status;
       
  1183 	RMobilePhoneBookStore::TMobilePhoneBookInfoV1 aPhoneStoreInfob;
       
  1184 	RMobilePhoneBookStore::TMobilePhoneBookInfoV1Pckg aPhoneStoreInfoPckgb(aPhoneStoreInfob);
       
  1185 	RMobilePhoneBookStore simPhBk;
       
  1186 
       
  1187 	TBuf8<KPBDataClientBuf> pbData; // Client reserved space for phonebook data
       
  1188 
       
  1189 	_LIT16(KTel,"1632960000%02d");
       
  1190 	_LIT16(KText,"Tel %02d");
       
  1191 	TBuf16<15> text(KTel), number(KText);
       
  1192 
       
  1193 	TInt index(1);
       
  1194 	ret=simPhBk.Open(iPhone,  KETelIccAdnPhoneBook);
       
  1195 	TEST_CHECKL(ret, KErrNone, _L("*** Failed to open ICC ADN PhoneBook ***"));
       
  1196 	if(ret==KErrNone)
       
  1197 		{
       
  1198 		// Write the entries
       
  1199 		INFO_PRINTF1(_L("Fill the 1st 30 locations in the SIM phonebook..."));
       
  1200 		simPhBk.GetInfo(status, aPhoneStoreInfoPckgb);
       
  1201 		User::WaitForRequest(status);
       
  1202 		TEST_CHECKL(status.Int(), KErrNone, _L("GT83-TPHBK-003.06")) ;
       
  1203 		aPhoneStoreInfob = aPhoneStoreInfoPckgb();
       
  1204 		TInt used=aPhoneStoreInfob.iUsedEntries ;
       
  1205 
       
  1206 		CPhoneBookBuffer* pbBuffer = new(ELeave) CPhoneBookBuffer(); // used to write phonebook data
       
  1207 		pbBuffer->Set(&pbData); // Set it to point to the Client buffer
       
  1208 
       
  1209 		// Fields supported by this phonebook are returned to client as capabilities
       
  1210 		// in aPhoneStoreInfoPckgb. It is assumed that all GSM phonebook fields (index, tel num,
       
  1211 		// type and name) are supported even though that part of the code has to be tested as well.
       
  1212 
       
  1213 		while (used<KFillTo)
       
  1214 			{
       
  1215 			// First specify starting index and set iNumofEntries to 1, since it is only
       
  1216 			// possible to write one entry at a time
       
  1217 
       
  1218 			number.FillZ(); // Reset previous values
       
  1219 			number.Zero();
       
  1220 			text.FillZ();
       
  1221 			text.Zero();
       
  1222 			pbData.FillZ();
       
  1223 			pbData.Zero();
       
  1224 
       
  1225 			// convert number into TLV format and append it to allocated buffer
       
  1226 			number.Format(KTel(), index);
       
  1227 			ret=pbBuffer->PutTagAndValue(RMobilePhoneBookStore::ETagPBNumber, number);
       
  1228 			TEST(ret == KErrNone) ;
       
  1229 
       
  1230 			// convert number type into TLV format and append it to allocated buffer
       
  1231 			TUint8 tonNpi=KTypeOfNumber; 
       
  1232 			ret=pbBuffer->PutTagAndValue(RMobilePhoneBookStore::ETagPBTonNpi, tonNpi);
       
  1233 			TEST(ret == KErrNone) ;
       
  1234 
       
  1235 			text.Format(KText(), index);
       
  1236 			INFO_PRINTF2(_L("Writing \'%S\'"),&text);
       
  1237 			// convert text into TLV format and append it to allocated buffer
       
  1238 			ret=pbBuffer->PutTagAndValue(RMobilePhoneBookStore::ETagPBText, text);
       
  1239 			TEST(ret == KErrNone) ;
       
  1240 
       
  1241 			simPhBk.Write(status, pbData, index);
       
  1242 			User::WaitForRequest(status);
       
  1243 			CHECKPOINT(status.Int(), KErrNone, _L("GT83-TPHBK-007.06 - *** Failed RMobilePhoneBookStore::Write() *** "));
       
  1244 			used++;
       
  1245 			index++;
       
  1246 			} // end while
       
  1247 		delete pbBuffer;
       
  1248 		}
       
  1249 	simPhBk.Close();
       
  1250 
       
  1251 	// Delete the entries //
       
  1252 	INFO_PRINTF1(_L("Re-opening phonebook..."));
       
  1253 	ret=simPhBk.Open(iPhone,  KETelIccAdnPhoneBook);
       
  1254 	TEST_CHECKL(ret, KErrNone, _L("*** Failed to open ICC ADN PhoneBook ***"));
       
  1255 	if(ret==KErrNone)
       
  1256 		{
       
  1257 		simPhBk.GetInfo(status, aPhoneStoreInfoPckgb);
       
  1258 		User::WaitForRequest(status);
       
  1259 		CHECKPOINT(status.Int(), KErrNone, _L("GT83-TPHBK-003.06 - *** Failed RMobilePhoneBookStore::GetInfo() ***")) ;
       
  1260 		aPhoneStoreInfob = aPhoneStoreInfoPckgb();
       
  1261 		INFO_PRINTF1(_L("Deleting the entries..."));
       
  1262 		for (int iy=1;iy<=KFillTo;++iy)
       
  1263 			{
       
  1264 			INFO_PRINTF2(_L("Deleting %03d"),iy);
       
  1265 			simPhBk.Delete(status, iy);
       
  1266 			User::WaitForRequest(status);
       
  1267 			CHECKPOINT(status.Int(), KErrNone, _L("GT83-TPHBK-008.06 - *** Failed RMobilePhoneBookStore::Delete() ***"));
       
  1268 			}
       
  1269 		}
       
  1270 	simPhBk.Close();
       
  1271 	return TestStepResult();
       
  1272 	}
       
  1273 //------------------------------------------------------------------
       
  1274 
       
  1275 CRetrievalOfWholePhoneBook::CRetrievalOfWholePhoneBook()
       
  1276 /** Each test step initialises it's own name
       
  1277 */
       
  1278 	{
       
  1279 	// store the name of this test case
       
  1280 	// this is the name that is used by the script file
       
  1281 	SetTestStepName(_L("RetrievalOfWholePhoneBook"));
       
  1282 	}
       
  1283 //------------------------------------------------------------------
       
  1284 
       
  1285 TVerdict CRetrievalOfWholePhoneBook::doTestStepL( void )
       
  1286 /**
       
  1287  * Detected Network test. This function gets the number of available networks
       
  1288  * and information on these networks. Also tests some Cancel Requests.
       
  1289  * @test GT83-TPHBK-001.06 Test opening an ICC-based phonebook of abbreviated dialling numbers
       
  1290  * @test GT83-TPHBK-002.06 Test closing an ICC-based phonebook of abbreviated dialling numbers
       
  1291  * @test GT83-TPHBK-003.06 Test retrieval of the phone book store info and capabilities of an ICC-based phonebook of abbreviated dialling numbers
       
  1292  * @test GT83-TPHBK-004.06 "Obtain total number of slots and number of slots used, using GetInfo method. Test  retrieval of the whole list of phone book entries from an ICC-based phonebook of abbreviated dialling numbers"
       
  1293  */
       
  1294 	{
       
  1295 	INFO_PRINTF1(_L("==============================="));
       
  1296 	INFO_PRINTF1(_L(" Test retrieval of a Phonebook "));
       
  1297 	INFO_PRINTF1(_L("==============================="));
       
  1298 	// First write 15 entries to the phone
       
  1299 	INFO_PRINTF1(_L("Writing 15 entries to the phone"));
       
  1300 	WriteBatchOfEntriesToThePhoneL();
       
  1301 
       
  1302 	CPhoneBookBuffer* pbBuffer=new(ELeave) CPhoneBookBuffer(); // used to read phonebook data
       
  1303 	TBuf8<KPBDataClientBuf> pbReadData1; // Client reserved space for phonebook data
       
  1304 	TRequestStatus status;
       
  1305 
       
  1306 	TUint16 index(0);
       
  1307 	TUint8 tonNpi;
       
  1308 	TPtrC16 number(NULL,0);
       
  1309 	TPtrC16 text(NULL,0);
       
  1310 
       
  1311 	TUint8 tagValue(0);
       
  1312 	CPhoneBookBuffer::TPhBkTagType aDataType;
       
  1313 
       
  1314 	RMobilePhoneBookStore simPhBk;
       
  1315 	TInt ret=simPhBk.Open(iPhone,  KETelIccAdnPhoneBook);
       
  1316 	TEST_CHECKL(ret, KErrNone, _L("*** Failed to open ICC ADN PhoneBook ***"));
       
  1317 	if(ret==KErrNone)
       
  1318 		{	
       
  1319 		// Get total number of phonebook entires
       
  1320 		RMobilePhoneBookStore::TMobilePhoneBookInfoV1 aInfo;
       
  1321 		RMobilePhoneBookStore::TMobilePhoneBookInfoV1Pckg aInfoPckg(aInfo);
       
  1322 		simPhBk.GetInfo(status, aInfoPckg);
       
  1323 		User::WaitForRequest(status);
       
  1324 		TEST_CHECKL(status.Int(), KErrNone, _L("GT83-TPHBK-003.06")) ;
       
  1325 
       
  1326 		INFO_PRINTF2(_L("Start retrieving %d phonebook entries"), aInfo.iTotalEntries);
       
  1327 
       
  1328 		simPhBk.Read(status, 1, aInfo.iTotalEntries, pbReadData1);
       
  1329 		User::WaitForRequest(status);
       
  1330 		CHECKPOINT(status.Int(), KErrNone, _L("GT83-TPHBK-004.06 - *** Failed RMobilePhoneBookStore::Read() ***")) ;
       
  1331 
       
  1332 		// pbReadData1 will contain a batch of retrieved entries, so start by parsing through its
       
  1333 		// data to retrieve individual entries
       
  1334 		pbBuffer->Set(&pbReadData1); // Set pbBuffer to point to received phonebook data
       
  1335 		pbBuffer->StartRead();       // Start reading received phonebook data
       
  1336 		TInt entryCount=0;
       
  1337 		while (pbBuffer->GetTagAndType(tagValue, aDataType)==KErrNone)
       
  1338 			{
       
  1339 			switch (tagValue)
       
  1340 				{
       
  1341 			case RMobilePhoneBookStore::ETagPBAdnIndex:
       
  1342 				entryCount++;
       
  1343 				pbBuffer->GetValue(index);			
       
  1344 				break;
       
  1345 			case RMobilePhoneBookStore::ETagPBTonNpi:
       
  1346 				pbBuffer->GetValue(tonNpi);			
       
  1347 				break;
       
  1348 			case RMobilePhoneBookStore::ETagPBText:
       
  1349 				pbBuffer->GetValue(text);			
       
  1350 				break;
       
  1351 			case RMobilePhoneBookStore::ETagPBNumber:
       
  1352 				pbBuffer->GetValue(number);			
       
  1353 				break;
       
  1354 			default:
       
  1355 				// An unsupported field type - just skip this value
       
  1356 				pbBuffer->SkipValue(aDataType);
       
  1357 				break;
       
  1358 				}
       
  1359 
       
  1360 			// Print each individual entry
       
  1361 			if((tagValue == RMobilePhoneBookStore::ETagPBNewEntry) && (entryCount>1)) // Only print if all fields retrieved
       
  1362 				{
       
  1363 				INFO_PRINTF4(_L("%d = >%S<  >%S<"), index, &text, &number); // It is not displaying data corectly on the console
       
  1364 				}
       
  1365 			} // end while
       
  1366 		}
       
  1367 	simPhBk.Close();
       
  1368 	delete pbBuffer;
       
  1369 	INFO_PRINTF1(_L("Deleting the entries "));
       
  1370 	clearPhoneBookL(KETelIccAdnPhoneBook());
       
  1371 	return TestStepResult();
       
  1372 	}
       
  1373 //------------------------------------------------------------------
       
  1374 
       
  1375 CRetrievalOfBatchOfPhoneBookEntries::CRetrievalOfBatchOfPhoneBookEntries()
       
  1376 /** Each test step initialises it's own name
       
  1377 */
       
  1378 	{
       
  1379 	// store the name of this test case
       
  1380 	// this is the name that is used by the script file
       
  1381 	SetTestStepName(_L("RetrievalOfBatchOfPhoneBookEntries"));
       
  1382 	}
       
  1383 //------------------------------------------------------------------
       
  1384 
       
  1385 TVerdict CRetrievalOfBatchOfPhoneBookEntries::doTestStepL( void )
       
  1386 /**
       
  1387  * Test of retrieval of a batch of phonebook entries. This method is mainly used to test
       
  1388  * removal of partially populated phonebook entries by the MMTSY.
       
  1389  * @test GT83-TPHBK-001.06 Test opening an ICC-based phonebook of abbreviated dialling numbers
       
  1390  * @test GT83-TPHBK-002.06 Test closing an ICC-based phonebook of abbreviated dialling numbers
       
  1391  * @test GT83-TPHBK-005.06 Test retieval of half of the entries from an ICC-based phonebook of abbreviated dialling numbers
       
  1392  */
       
  1393 	{
       
  1394 	INFO_PRINTF1(_L("================================================"));
       
  1395 	INFO_PRINTF1(_L(" Test retrieval of a Batch of Phonebook Entries "));
       
  1396 	INFO_PRINTF1(_L("================================================"));
       
  1397 	// First write 15 entries to the phone
       
  1398 	INFO_PRINTF1(_L("Writing 15 entries to the phone"));
       
  1399 	WriteBatchOfEntriesToThePhoneL();
       
  1400 
       
  1401 	RMobilePhoneBookStore simPhBk;
       
  1402 	TRequestStatus status;
       
  1403 	TBuf8<KPBDataClientSmallBuf> pbReadData1; // Client reserved space for phonebook data
       
  1404 	CPhoneBookBuffer* pbBuffer=new(ELeave) CPhoneBookBuffer(); // used to read phonebook data
       
  1405 
       
  1406 	TInt ret=simPhBk.Open(iPhone,  KETelIccAdnPhoneBook);
       
  1407 	TEST_CHECKL(ret, KErrNone, _L("*** Failed to open ICC ADN PhoneBook ***"));
       
  1408 	if(ret==KErrNone)
       
  1409 		{
       
  1410 		RMobilePhoneBookStore::TMobilePhoneBookInfoV1Pckg dummyInfoPckg(iDummyInfo);
       
  1411 		simPhBk.GetInfo(status, dummyInfoPckg);		// Recommended by EtelMM API documentation
       
  1412 		User::WaitForRequest(status);
       
  1413 		TEST_CHECKL(status.Int(), KErrNone, _L("*** Failed RMobilePhoneBookStore::GetInfo() ***")) ;
       
  1414 
       
  1415 		INFO_PRINTF1(_L("This test can take up to a minute to complete..."));
       
  1416 		TInt startIndex = 3; // Where to start in the phonebook
       
  1417 		TInt batchSize = 4; // How many entries to get.
       
  1418 
       
  1419 		INFO_PRINTF3(_L("Start retrieving a batch of %d phonebook entries with starting index %d"), batchSize, startIndex);
       
  1420 
       
  1421 		simPhBk.Read(status, startIndex, batchSize, pbReadData1);
       
  1422 		User::WaitForRequest(status);
       
  1423 		CHECKPOINT(status.Int(), KErrNone, _L("GT83-TPHBK-005.06 - *** Failed RMobilePhoneBookStore::Read() ***")) ;
       
  1424 
       
  1425 		TUint16 index(0);
       
  1426 		TUint8 tonNpi;
       
  1427 		TPtrC16 number(NULL,0);
       
  1428 		TPtrC16 text(NULL,0);
       
  1429 
       
  1430 		TUint8 tagValue(0);
       
  1431 		CPhoneBookBuffer::TPhBkTagType aDataType;
       
  1432 
       
  1433 		// pbReadData1 will contain a batch of retrieved entries, so start by parsing through its
       
  1434 		// data to retrieve/decode individual entries
       
  1435 		pbBuffer->Set(&pbReadData1); // Set pbBuffer to point to received phonebook data
       
  1436 		pbBuffer->StartRead();       // Start reading received phonebook data
       
  1437 		TInt entryCount=0;
       
  1438 		while (pbBuffer->GetTagAndType(tagValue, aDataType)==KErrNone)
       
  1439 			{
       
  1440 			switch (tagValue)
       
  1441 				{
       
  1442 			case RMobilePhoneBookStore::ETagPBAdnIndex:
       
  1443 				entryCount++;
       
  1444 				pbBuffer->GetValue(index);			
       
  1445 				break;
       
  1446 			case RMobilePhoneBookStore::ETagPBTonNpi:
       
  1447 				pbBuffer->GetValue(tonNpi);			
       
  1448 				break;
       
  1449 			case RMobilePhoneBookStore::ETagPBText:
       
  1450 				pbBuffer->GetValue(text);			
       
  1451 				break;
       
  1452 			case RMobilePhoneBookStore::ETagPBNumber:
       
  1453 				pbBuffer->GetValue(number);			
       
  1454 				break;
       
  1455 			default:
       
  1456 				// An unsupported field type - just skip this value
       
  1457 				pbBuffer->SkipValue(aDataType);
       
  1458 				break;
       
  1459 				}
       
  1460 
       
  1461 			// Print each individual entry
       
  1462 			if((tagValue == RMobilePhoneBookStore::ETagPBNewEntry) && (entryCount>1)) // Only print if all fields retrieved
       
  1463 				{
       
  1464 				INFO_PRINTF4(_L("%d = >%S<  >%S<"), index, &text, &number); // It is not displaying data corectly on the console
       
  1465 				}
       
  1466 			} // end while
       
  1467 		}
       
  1468 	simPhBk.Close();
       
  1469 	delete pbBuffer;
       
  1470 
       
  1471 	INFO_PRINTF1(_L("Deleting the entries "));
       
  1472 	clearPhoneBookL(KETelIccAdnPhoneBook());
       
  1473 	return TestStepResult();
       
  1474 	}
       
  1475 //------------------------------------------------------------------
       
  1476 
       
  1477 CRetrievalOfHalfOfPhoneBookEntries::CRetrievalOfHalfOfPhoneBookEntries()
       
  1478 /** Each test step initialises it's own name
       
  1479 */
       
  1480 	{
       
  1481 	// store the name of this test case
       
  1482 	// this is the name that is used by the script file
       
  1483 	SetTestStepName(_L("RetrievalOfHalfOfPhoneBookEntries"));
       
  1484 	}
       
  1485 //------------------------------------------------------------------
       
  1486 
       
  1487 TVerdict CRetrievalOfHalfOfPhoneBookEntries::doTestStepL( void )
       
  1488 /**
       
  1489  * Test of retrieval of a half of phonebook entries. This method is mainly used to test
       
  1490  * removal of partially populated phonebook entries by the MMTSY.
       
  1491  * @test GT83-TPHBK-001.06 Test opening an ICC-based phonebook of abbreviated dialling numbers
       
  1492  * @test GT83-TPHBK-002.06 Test closing an ICC-based phonebook of abbreviated dialling numbers
       
  1493  * @test GT83-TPHBK-003.06 Test retrieval of the phone book store info and capabilities of an ICC-based phonebook of abbreviated dialling numbers
       
  1494  * @test GT83-TPHBK-005.06 Test retieval of half of the entries from an ICC-based phonebook of abbreviated dialling numbers
       
  1495  */
       
  1496 	{
       
  1497 	RMobilePhoneBookStore::TMobilePhoneBookInfoV1 aPhoneStoreInfob;
       
  1498 	RMobilePhoneBookStore::TMobilePhoneBookInfoV1Pckg aPhoneStoreInfoPckgb(aPhoneStoreInfob);
       
  1499 
       
  1500 	INFO_PRINTF1(_L("================================================"));
       
  1501 	INFO_PRINTF1(_L(" Test retrieval of a Batch of Phonebook Entries "));
       
  1502 	INFO_PRINTF1(_L("================================================"));
       
  1503 	// First write 15 entries to the phone
       
  1504 	INFO_PRINTF1(_L("Writing 15 entries to the phone"));
       
  1505 	WriteBatchOfEntriesToThePhoneL();
       
  1506 
       
  1507 	RMobilePhoneBookStore simPhBk;
       
  1508 	TRequestStatus status;
       
  1509 	TBuf8<KPBDataClientBuf> pbReadData1; // Client reserved space for phonebook data
       
  1510 	CPhoneBookBuffer* pbBuffer=new(ELeave) CPhoneBookBuffer(); // used to read phonebook data
       
  1511 
       
  1512 	TInt ret=simPhBk.Open(iPhone,  KETelIccAdnPhoneBook);
       
  1513 	TEST_CHECKL(ret, KErrNone, _L("*** Failed to open ICC ADN PhoneBook ***"));
       
  1514 	if(ret==KErrNone)
       
  1515 		{
       
  1516 		INFO_PRINTF1(_L("This test can take up to a minute to complete..."));
       
  1517 
       
  1518 		simPhBk.GetInfo(status, aPhoneStoreInfoPckgb);
       
  1519 		User::WaitForRequest(status);
       
  1520 		TEST_CHECKL(status.Int(), KErrNone, _L("GT83-TPHBK-003.06 - *** Failed RMobilePhoneBookStore::GetInfo() ***")) ;
       
  1521 
       
  1522 		aPhoneStoreInfob = aPhoneStoreInfoPckgb() ;
       
  1523 		TInt batchSize = (aPhoneStoreInfob.iTotalEntries)/2; //50%
       
  1524 
       
  1525 		INFO_PRINTF2(_L("Start retrieving a batch of %d phonebook entries with starting index 1"), batchSize);
       
  1526 
       
  1527 		simPhBk.Read(status, 1, batchSize, pbReadData1);
       
  1528 		User::WaitForRequest(status);
       
  1529 		CHECKPOINT(status.Int(), KErrNone, _L("GT83-TPHBK-005.06 - *** Failed RMobilePhoneBookStore::Read() ***")) ;
       
  1530 
       
  1531 		TUint16 index(0);
       
  1532 		TUint8 tonNpi;
       
  1533 		TPtrC16 number(NULL,0);
       
  1534 		TPtrC16 text(NULL,0);
       
  1535 
       
  1536 		TUint8 tagValue(0);
       
  1537 		CPhoneBookBuffer::TPhBkTagType aDataType;
       
  1538 
       
  1539 		// pbReadData1 will contain a batch of retrieved entries, so start by parsing through its
       
  1540 		// data to retrieve/decode individual entries
       
  1541 		pbBuffer->Set(&pbReadData1); // Set pbBuffer to point to received phonebook data
       
  1542 		pbBuffer->StartRead();       // Start reading received phonebook data
       
  1543 		TInt entryCount=0;
       
  1544 		while (pbBuffer->GetTagAndType(tagValue, aDataType)==KErrNone)
       
  1545 			{
       
  1546 			switch (tagValue)
       
  1547 				{
       
  1548 			case RMobilePhoneBookStore::ETagPBAdnIndex:
       
  1549 				entryCount++;
       
  1550 				pbBuffer->GetValue(index);			
       
  1551 				break;
       
  1552 			case RMobilePhoneBookStore::ETagPBTonNpi:
       
  1553 				pbBuffer->GetValue(tonNpi);			
       
  1554 				break;
       
  1555 			case RMobilePhoneBookStore::ETagPBText:
       
  1556 				pbBuffer->GetValue(text);			
       
  1557 				break;
       
  1558 			case RMobilePhoneBookStore::ETagPBNumber:
       
  1559 				pbBuffer->GetValue(number);			
       
  1560 				break;
       
  1561 			default:
       
  1562 				// An unsupported field type - just skip this value
       
  1563 				pbBuffer->SkipValue(aDataType);
       
  1564 				break;
       
  1565 				}
       
  1566 
       
  1567 			// Print each individual entry
       
  1568 			if((tagValue == RMobilePhoneBookStore::ETagPBNewEntry) && (entryCount>1)) // Only print if all fields retrieved
       
  1569 				{
       
  1570 				INFO_PRINTF4(_L("%d = >%S<  >%S<"), index, &text, &number); // It is not displaying data corectly on the console
       
  1571 				}
       
  1572 			} // end while
       
  1573 		}
       
  1574 	simPhBk.Close();
       
  1575 	delete pbBuffer;
       
  1576 
       
  1577 	INFO_PRINTF1(_L("Deleting the entries "));
       
  1578 	clearPhoneBookL(KETelIccAdnPhoneBook());
       
  1579 	return TestStepResult();
       
  1580 	}