pimprotocols/phonebooksync/Test/TE_PhBkSync/TestDoSynchronisationSteps.cpp
changeset 0 e686773b3f54
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 // Copyright (c) 2001-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 // This contains PhbkSync API DoSynchronisation() related Unit Test Steps
       
    15 // 
       
    16 //
       
    17 
       
    18 
       
    19 #include "TE_PhBkSyncBase.h"
       
    20 #include "TestDoSynchronisationSteps.h"
       
    21 
       
    22 
       
    23 /** 
       
    24  * Test synchronisation with a partially full Global/GSM ADN phonebook.
       
    25  *
       
    26  * It is assumed that server been connected/started by Open step.
       
    27  */
       
    28 //
       
    29 //    Test step1 -- Test#10 in Unit Test Spec. Doc. //
       
    30 //
       
    31 CPhbkSyncDoSynchronisationTest_01::CPhbkSyncDoSynchronisationTest_01()
       
    32 	{
       
    33 	// store the name of this test step
       
    34 	SetTestStepName(_L("PhbkSyncDoSynchronisationTest_01"));
       
    35 	}
       
    36 
       
    37 CPhbkSyncDoSynchronisationTest_01::~CPhbkSyncDoSynchronisationTest_01()
       
    38 	{
       
    39 	}
       
    40 
       
    41 TVerdict CPhbkSyncDoSynchronisationTest_01::doTestStepL( )
       
    42 	{
       
    43 	// 1. destroy the default .ini file if it exists
       
    44 	DestroyDefaultIniFileL();
       
    45 
       
    46 	// 2. load the partially full Global/GSM ADN phonebook from cfg file
       
    47 	SetSimTsyTestNumberL(10); // see [test10] in configuration file
       
    48 
       
    49 	// 3. set mode as EManual for the tested phonebook only.
       
    50 	//    If the current is EManual, then override it anyway.
       
    51 	User::LeaveIfError(iSession.SetSyncMode(RPhoneBookSession::EManual, KUidIccGlobalAdnPhonebook)); 
       
    52 	CheckSyncModeL(RPhoneBookSession::EManual, KUidIccGlobalAdnPhonebook);
       
    53 
       
    54 	CheckCacheStateInvalidL(KUidIccGlobalAdnPhonebook); 
       
    55 
       
    56 	// 4. do synchronisation
       
    57 	DoSyncL(KUidIccGlobalAdnPhonebook, KErrNone);
       
    58 
       
    59 	// 5. check the expected behaviour
       
    60 	CheckCacheStateValidL(KUidIccGlobalAdnPhonebook); 
       
    61 
       
    62 	return TestStepResult();
       
    63 	}
       
    64 
       
    65 /** 
       
    66  * Test synchronisation with a partially full USIM ADN phonebook.
       
    67  *
       
    68  * It is assumed that server been connected/started by Open step.
       
    69  */
       
    70 //
       
    71 //    Test step2 -- Test#11 in Unit Test Spec. Doc. //
       
    72 //
       
    73 CPhbkSyncDoSynchronisationTest_02::CPhbkSyncDoSynchronisationTest_02()
       
    74 	{
       
    75 	// store the name of this test step
       
    76 	SetTestStepName(_L("PhbkSyncDoSynchronisationTest_02"));
       
    77 	}
       
    78 
       
    79 CPhbkSyncDoSynchronisationTest_02::~CPhbkSyncDoSynchronisationTest_02()
       
    80 	{
       
    81 	}
       
    82 
       
    83 TVerdict CPhbkSyncDoSynchronisationTest_02::doTestStepL( )
       
    84 	{
       
    85 	// 1. load the partially full USIM ADN phonebook from cfg file
       
    86 	SetSimTsyTestNumberL(11); // see [test11] in configuration file
       
    87 
       
    88 	// 2. set mode as EManual for the tested phonebook only
       
    89 	User::LeaveIfError(iSession.SetSyncMode(RPhoneBookSession::EManual, KUidUsimAppAdnPhonebook)); 
       
    90 	CheckSyncModeL(RPhoneBookSession::EManual, KUidUsimAppAdnPhonebook);
       
    91 
       
    92 	// 3. do synchronisation
       
    93 	DoSyncL(KUidUsimAppAdnPhonebook, KErrNone);
       
    94 
       
    95 	// 4. check the expected behaviour
       
    96 	CheckCacheStateValidL(KUidUsimAppAdnPhonebook); 
       
    97 
       
    98 	return TestStepResult();
       
    99 	}
       
   100 
       
   101 /** 
       
   102  * Test synchronisation with a partially full Global/GSM SDN phonebook.
       
   103  *
       
   104  * It is assumed that server been connected/started by Open step.
       
   105  */
       
   106 //
       
   107 //    Test step3 -- Test#12 in Unit Test Spec. Doc.  //
       
   108 //
       
   109 CPhbkSyncDoSynchronisationTest_03::CPhbkSyncDoSynchronisationTest_03()
       
   110 	{
       
   111 	// store the name of this test step
       
   112 	SetTestStepName(_L("PhbkSyncDoSynchronisationTest_03"));
       
   113 	}
       
   114 
       
   115 CPhbkSyncDoSynchronisationTest_03::~CPhbkSyncDoSynchronisationTest_03()
       
   116 	{
       
   117 	}
       
   118 
       
   119 TVerdict CPhbkSyncDoSynchronisationTest_03::doTestStepL( )
       
   120 	{
       
   121 	// 1. load the partially full Global/GSM SDN phonebook from cfg file
       
   122 	SetSimTsyTestNumberL(12); // see [test12] in configuration file
       
   123 
       
   124 	// 2. set mode as EManual for the tested phonebook only
       
   125 	User::LeaveIfError(iSession.SetSyncMode(RPhoneBookSession::EManual, KUidIccGlobalSdnPhonebook)); 
       
   126 	CheckSyncModeL(RPhoneBookSession::EManual, KUidIccGlobalSdnPhonebook);
       
   127 
       
   128 	// 3. do synchronisation
       
   129 	DoSyncL(KUidIccGlobalSdnPhonebook, KErrNone);
       
   130 
       
   131 	// 4. check the expected behaviour
       
   132 
       
   133 	return TestStepResult();
       
   134 	}
       
   135 
       
   136 /** 
       
   137  * Test synchronisation with a partially full Global/GSM LND phonebook.
       
   138  *
       
   139  * It is assumed that server been connected/started by Open step.
       
   140  */
       
   141 //
       
   142 //    Test step4 -- Test#13 in Unit Test Spec. Doc.  //
       
   143 //
       
   144 CPhbkSyncDoSynchronisationTest_04::CPhbkSyncDoSynchronisationTest_04()
       
   145 	{
       
   146 	// store the name of this test step
       
   147 	SetTestStepName(_L("PhbkSyncDoSynchronisationTest_04"));
       
   148 	}
       
   149 
       
   150 CPhbkSyncDoSynchronisationTest_04::~CPhbkSyncDoSynchronisationTest_04()
       
   151 	{
       
   152 	}
       
   153 
       
   154 TVerdict CPhbkSyncDoSynchronisationTest_04::doTestStepL( )
       
   155 	{
       
   156 	// 1. load the partially full Global/GSM LND phonebook from cfg file
       
   157 	SetSimTsyTestNumberL(13); // see [test13] in configuration file
       
   158 
       
   159 	// 2. set mode as EManual for the tested phonebook only
       
   160 	User::LeaveIfError(iSession.SetSyncMode(RPhoneBookSession::EManual, KUidIccGlobalLndPhonebook)); 
       
   161 	CheckSyncModeL(RPhoneBookSession::EManual, KUidIccGlobalLndPhonebook);
       
   162 
       
   163 	// 3. do synchronisation
       
   164 	DoSyncL(KUidIccGlobalLndPhonebook, KErrNone); 
       
   165 
       
   166 	// 4. check the expected behaviour
       
   167 	CheckCacheStateValidL(KUidIccGlobalLndPhonebook); 
       
   168 
       
   169 	return TestStepResult();
       
   170 	}
       
   171 
       
   172 /** 
       
   173  * Test synchronisation with a full Global/GSM ADN phonebook.
       
   174  *
       
   175  * It is assumed that server been connected/started by Open step.
       
   176  */
       
   177 //
       
   178 //    Test step5 -- Test#14 in Unit Test Spec. Doc. //
       
   179 //
       
   180 CPhbkSyncDoSynchronisationTest_05::CPhbkSyncDoSynchronisationTest_05()
       
   181 	{
       
   182 	// store the name of this test step
       
   183 	SetTestStepName(_L("PhbkSyncDoSynchronisationTest_05"));
       
   184 	}
       
   185 
       
   186 CPhbkSyncDoSynchronisationTest_05::~CPhbkSyncDoSynchronisationTest_05()
       
   187 	{
       
   188 	}
       
   189 
       
   190 TVerdict CPhbkSyncDoSynchronisationTest_05::doTestStepL( )
       
   191 	{
       
   192 	// 1. load the full Global/GSM ADN phonebook from cfg file
       
   193 	SetSimTsyTestNumberL(14); // see [test14] in configuration file
       
   194 
       
   195 	// 2. set mode as EManual for the tested phonebook only
       
   196 	User::LeaveIfError(iSession.SetSyncMode(RPhoneBookSession::EManual, KUidIccGlobalAdnPhonebook)); 
       
   197 	CheckSyncModeL(RPhoneBookSession::EManual, KUidIccGlobalAdnPhonebook);
       
   198 
       
   199 	// 3. do synchronisation
       
   200 	DoSyncL(KUidIccGlobalAdnPhonebook, KErrNone);
       
   201 
       
   202 	// 4. check the expected behaviour
       
   203 	CheckCacheStateValidL(KUidIccGlobalAdnPhonebook); 
       
   204 
       
   205 	return TestStepResult();
       
   206 	}
       
   207 
       
   208 /** 
       
   209  * Test synchronisation with a full USIM ADN phonebook.
       
   210  *
       
   211  * It is assumed that server been connected/started by Open step.
       
   212  */
       
   213 //
       
   214 //    Test step6 -- Test#15 in Unit Test Spec. Doc.  //
       
   215 //
       
   216 CPhbkSyncDoSynchronisationTest_06::CPhbkSyncDoSynchronisationTest_06()
       
   217 	{
       
   218 	// store the name of this test step
       
   219 	SetTestStepName(_L("PhbkSyncDoSynchronisationTest_06"));
       
   220 	}
       
   221 
       
   222 CPhbkSyncDoSynchronisationTest_06::~CPhbkSyncDoSynchronisationTest_06()
       
   223 	{
       
   224 	}
       
   225 
       
   226 TVerdict CPhbkSyncDoSynchronisationTest_06::doTestStepL( )
       
   227 	{
       
   228 	// 1. load the full USIM ADN phonebook from cfg file
       
   229 	SetSimTsyTestNumberL(15); // see [test15] in configuration file
       
   230 
       
   231 	// 2. set mode as EManual for the tested phonebook only
       
   232 	User::LeaveIfError(iSession.SetSyncMode(RPhoneBookSession::EManual, KUidUsimAppAdnPhonebook)); 
       
   233 	CheckSyncModeL(RPhoneBookSession::EManual, KUidUsimAppAdnPhonebook);
       
   234 
       
   235 	// 3. do synchronisation
       
   236 	DoSyncL(KUidUsimAppAdnPhonebook, KErrNone);
       
   237 
       
   238 	// 4. check the expected behaviour
       
   239 	CheckCacheStateValidL(KUidUsimAppAdnPhonebook); 
       
   240 
       
   241 	return TestStepResult();
       
   242 	}
       
   243 
       
   244 /** 
       
   245  * Test synchronisation with a full SDN phonebook.
       
   246  *
       
   247  * It is assumed that server been connected/started by Open step.
       
   248  */
       
   249 //
       
   250 //    Test step7 -- Test#16 in Unit Test Spec. Doc.  //
       
   251 //
       
   252 CPhbkSyncDoSynchronisationTest_07::CPhbkSyncDoSynchronisationTest_07()
       
   253 	{
       
   254 	// store the name of this test step
       
   255 	SetTestStepName(_L("PhbkSyncDoSynchronisationTest_07"));
       
   256 	}
       
   257 
       
   258 CPhbkSyncDoSynchronisationTest_07::~CPhbkSyncDoSynchronisationTest_07()
       
   259 	{
       
   260 	}
       
   261 
       
   262 TVerdict CPhbkSyncDoSynchronisationTest_07::doTestStepL( )
       
   263 	{
       
   264 	// 1. load the full SDN phonebook from cfg file
       
   265 	SetSimTsyTestNumberL(16); // see [test16] in configuration file
       
   266 
       
   267 	// 2. set mode as EManual for the tested phonebook only
       
   268 	User::LeaveIfError(iSession.SetSyncMode(RPhoneBookSession::EManual, KUidIccGlobalSdnPhonebook)); 
       
   269 	CheckSyncModeL(RPhoneBookSession::EManual, KUidIccGlobalSdnPhonebook);
       
   270 
       
   271 	// 3. do synchronisation
       
   272 	DoSyncL(KUidIccGlobalSdnPhonebook, KErrNone);
       
   273 
       
   274 	// 4. check the expected behaviour
       
   275 	CheckCacheStateValidL(KUidIccGlobalSdnPhonebook); 
       
   276 
       
   277 	return TestStepResult();
       
   278 	}
       
   279 
       
   280 /** 
       
   281  * Test synchronisation with a full LND phonebook.
       
   282  *
       
   283  * It is assumed that server been connected/started by Open step.
       
   284  */
       
   285 //
       
   286 //    Test step8 -- Test#17 in Unit Test Spec. Doc.  //
       
   287 //
       
   288 CPhbkSyncDoSynchronisationTest_08::CPhbkSyncDoSynchronisationTest_08()
       
   289 	{
       
   290 	// store the name of this test step
       
   291 	SetTestStepName(_L("PhbkSyncDoSynchronisationTest_08"));
       
   292 	}
       
   293 
       
   294 CPhbkSyncDoSynchronisationTest_08::~CPhbkSyncDoSynchronisationTest_08()
       
   295 	{
       
   296 	}
       
   297 
       
   298 TVerdict CPhbkSyncDoSynchronisationTest_08::doTestStepL( )
       
   299 	{
       
   300 	// 1. load the full LND phonebook from cfg file
       
   301 	SetSimTsyTestNumberL(17); // see [test17] in configuration file
       
   302 
       
   303 	// 2. set mode as EManual for the tested phonebook only
       
   304 	User::LeaveIfError(iSession.SetSyncMode(RPhoneBookSession::EManual, KUidIccGlobalLndPhonebook)); 
       
   305 	CheckSyncModeL(RPhoneBookSession::EManual, KUidIccGlobalLndPhonebook);
       
   306 
       
   307 	// 3. do synchronisation
       
   308 	DoSyncL(KUidIccGlobalLndPhonebook, KErrNone);
       
   309 
       
   310 	// 4. check the expected behaviour
       
   311 	CheckCacheStateValidL(KUidIccGlobalLndPhonebook); 
       
   312 
       
   313 	return TestStepResult();
       
   314 	}
       
   315 
       
   316 /** 
       
   317  * Test synchronisation with all full supported phonebooks.
       
   318  *
       
   319  * It is assumed that server been connected/started by Open step.
       
   320  */
       
   321 //
       
   322 //    Test step9 -- Test#18 in Unit Test Spec. Doc.  //
       
   323 //
       
   324 CPhbkSyncDoSynchronisationTest_09::CPhbkSyncDoSynchronisationTest_09()
       
   325 	{
       
   326 	// store the name of this test step
       
   327 	SetTestStepName(_L("PhbkSyncDoSynchronisationTest_09"));
       
   328 	}
       
   329 
       
   330 CPhbkSyncDoSynchronisationTest_09::~CPhbkSyncDoSynchronisationTest_09()
       
   331 	{
       
   332 	}
       
   333 
       
   334 TVerdict CPhbkSyncDoSynchronisationTest_09::doTestStepL( )
       
   335 	{
       
   336 	// 1. load the full LND phonebook from cfg file
       
   337 	SetSimTsyTestNumberL(18); // see [test18] in configuration file
       
   338 
       
   339 	// 2. set mode as EManual for all supported phonebooks
       
   340 	TInt i(0);
       
   341 	for (i=0; i<KTotalNumberOfPhoneBook; i++) 
       
   342 		{ 
       
   343 		User::LeaveIfError(iSession.SetSyncMode(RPhoneBookSession::EManual, iPhoneBook[i]));
       
   344 		CheckSyncModeL(RPhoneBookSession::EManual, iPhoneBook[i]);
       
   345 		}
       
   346 
       
   347 	// 3. do synchronisation
       
   348 	for (i=0; i<KTotalNumberOfPhoneBook; i++) { 
       
   349 	DoSyncL(iPhoneBook[i], KErrNone);
       
   350 	}
       
   351 
       
   352 	// 4. check the expected behaviour
       
   353 	for (i=0; i<KTotalNumberOfPhoneBook; i++) 
       
   354 		{ 
       
   355 		CheckCacheStateValidL(iPhoneBook[i]);
       
   356 		}
       
   357 
       
   358 	return TestStepResult();
       
   359 	}
       
   360 
       
   361 /** 
       
   362  * Test synchronisation of all supported phonebooks, when
       
   363  * synchronisation of one of them fails.
       
   364  *
       
   365  * It is assumed that server been connected/started by Open step.
       
   366  */
       
   367 //
       
   368 //    Test step10 -- Test#19 in Unit Test Spec. Doc.  //
       
   369 //
       
   370 CPhbkSyncDoSynchronisationTest_10::CPhbkSyncDoSynchronisationTest_10()
       
   371 	{
       
   372 	// store the name of this test step
       
   373 	SetTestStepName(_L("PhbkSyncDoSynchronisationTest_10"));
       
   374 	}
       
   375 
       
   376 CPhbkSyncDoSynchronisationTest_10::~CPhbkSyncDoSynchronisationTest_10()
       
   377 	{
       
   378 	}
       
   379 
       
   380 TVerdict CPhbkSyncDoSynchronisationTest_10::doTestStepL( )
       
   381 	{
       
   382 	// 1. load all (partially full) phonebooks from cfg file
       
   383 	SetSimTsyTestNumberL(19); // see [test19] in configuration file
       
   384 
       
   385 	// 2. set mode as EManual for all supported phonebooks
       
   386 	TInt i(0);
       
   387 	for (i=0; i<KTotalNumberOfPhoneBook; i++) 
       
   388 		{ 
       
   389 		User::LeaveIfError(iSession.SetSyncMode(RPhoneBookSession::EManual, iPhoneBook[i]));
       
   390 		CheckSyncModeL(RPhoneBookSession::EManual, iPhoneBook[i]);
       
   391 		}
       
   392 
       
   393 	// 3. do synchronisation and LND will fail (see cfg. file)
       
   394 	for (i=0; i<KTotalNumberOfPhoneBook; i++) 
       
   395 		{
       
   396 		if (iPhoneBook[i] != KUidIccGlobalLndPhonebook) 
       
   397 			{
       
   398 			DoSyncL(iPhoneBook[i], KErrNone);
       
   399 			}
       
   400 		}
       
   401 
       
   402 	// To simply ignore the error generated by DoSynchronisation 
       
   403 	// since we cannot guarantee the phonebook synchroniser server 
       
   404 	// will give us the error KErrBadHandle defined in the cfg. file.
       
   405 	// However, we do know the error code != KErrNone
       
   406 	DoSyncL(KUidIccGlobalLndPhonebook, KErrBadHandle, ETrue); // ignore LND fail
       
   407 
       
   408 	// 4. check the expected behaviour
       
   409 	for (i=0; i<KTotalNumberOfPhoneBook; i++) 
       
   410 		{
       
   411 		if (iPhoneBook[i] == KUidIccGlobalLndPhonebook) 
       
   412 			{
       
   413 			RPhoneBookSession::TSyncState state;
       
   414 			iSession.GetPhoneBookCacheState(state, iPhoneBook[i]);
       
   415 			TESTCHECK(state, RPhoneBookSession::EErrorDuringSync);
       
   416 			}
       
   417 		else 
       
   418 			{ 
       
   419 			CheckCacheStateValidL(iPhoneBook[i]);
       
   420 			}
       
   421 		}
       
   422 
       
   423 	return TestStepResult();
       
   424 	}
       
   425 
       
   426 /** 
       
   427  * Test synchronisation of a Global/GSM ADN phonebook that
       
   428  * contains an entry whose size >512 characters which will
       
   429  * lead to overflow when phbksync is doing the batch reading.
       
   430  *
       
   431  * Following are the limits imposed by TSY:
       
   432  * 1.   100 -- max. number of digits/characters allowed for phonenumber
       
   433  * 2.   241 -- max. number of characters/digits allowed for name
       
   434  *
       
   435  * Following is the limit imposed by PhBkSync:
       
   436  * 1.   512 -- the max. size of the buffer used when doing batch read
       
   437  *
       
   438  * It is assumed that server been connected/started by Open step.
       
   439  */
       
   440 //
       
   441 //    Test step11 -- Test#20 in Unit Test Spec. Doc.  //
       
   442 //
       
   443 CPhbkSyncDoSynchronisationTest_11::CPhbkSyncDoSynchronisationTest_11()
       
   444 	{
       
   445 	// store the name of this test step
       
   446 	SetTestStepName(_L("PhbkSyncDoSynchronisationTest_11"));
       
   447 	}
       
   448 
       
   449 CPhbkSyncDoSynchronisationTest_11::~CPhbkSyncDoSynchronisationTest_11()
       
   450 	{
       
   451 	}
       
   452 
       
   453 TVerdict CPhbkSyncDoSynchronisationTest_11::doTestStepL( )
       
   454 	{
       
   455 	// 1. load Global/GSM ADN phonebook which has one entry > 512
       
   456 	SetSimTsyTestNumberL(20); // see [test20] in configuration file
       
   457 
       
   458 	// 2. set mode as EManual for all supported phonebooks
       
   459 	User::LeaveIfError(iSession.SetSyncMode(RPhoneBookSession::EManual, KUidIccGlobalAdnPhonebook));
       
   460 	CheckSyncModeL(RPhoneBookSession::EManual, KUidIccGlobalAdnPhonebook);
       
   461 
       
   462 	// 3. do synchronisation
       
   463 //	DoSyncL(KUidIccGlobalAdnPhonebook, KErrOverflow); // synchronisation fails
       
   464 
       
   465 	// there is a bug in TSY which returns KErrArgumnet rather than KErrOverflow
       
   466 	DoSyncL(KUidIccGlobalAdnPhonebook, KErrArgument); // synchronisation fails
       
   467 
       
   468 	// 4. check the expected behaviour
       
   469 	CheckCacheStateErrorL(KUidIccGlobalAdnPhonebook);
       
   470 
       
   471 	return TestStepResult();
       
   472 	}
       
   473 
       
   474 /** 
       
   475  * This test is similar to Test#20.
       
   476  * The difference is that the overflow is caused by large phone number 
       
   477  * and additional numbers rather than by names in Test#20.
       
   478  *
       
   479  * It is assumed that server been connected/started by Open step.
       
   480  */
       
   481 //
       
   482 //    Test step12 -- Test#21 in Unit Test Spec. Doc.//
       
   483 //
       
   484 CPhbkSyncDoSynchronisationTest_12::CPhbkSyncDoSynchronisationTest_12()
       
   485 	{
       
   486 	// store the name of this test step
       
   487 	SetTestStepName(_L("PhbkSyncDoSynchronisationTest_12"));
       
   488 	}
       
   489 
       
   490 CPhbkSyncDoSynchronisationTest_12::~CPhbkSyncDoSynchronisationTest_12()
       
   491 	{
       
   492 	}
       
   493 
       
   494 TVerdict CPhbkSyncDoSynchronisationTest_12::doTestStepL( )
       
   495 	{
       
   496 	// 1. load USIM App ADN phonebook which has ane entry whose tel number field > 255
       
   497 	SetSimTsyTestNumberL(21); // see [test21] in configuration file
       
   498 
       
   499 	// 2. set mode as EManual for all supported phonebooks
       
   500 	User::LeaveIfError(iSession.SetSyncMode(RPhoneBookSession::EManual, KUidUsimAppAdnPhonebook));
       
   501 	CheckSyncModeL(RPhoneBookSession::EManual, KUidUsimAppAdnPhonebook);
       
   502 
       
   503 	// 3. do synchronisation
       
   504 //	DoSyncL(KUidUsimAppAdnPhonebook, KErrOverflow); // synchronisation fails
       
   505 
       
   506 	// there is a bug in TSY which returns KErrArgumnet rather than KErrOverflow
       
   507 	DoSyncL(KUidUsimAppAdnPhonebook, KErrArgument); // synchronisation fails
       
   508 
       
   509 	// 4. check the expected behaviour
       
   510 	CheckCacheStateErrorL(KUidUsimAppAdnPhonebook);
       
   511 
       
   512 	return TestStepResult();
       
   513 	}
       
   514 
       
   515 /** 
       
   516  * Test synchronisation with a corrupted USIM.
       
   517  *
       
   518  * It is assumed that server been connected/started by Open step.
       
   519  */
       
   520 //
       
   521 //    Test step13 -- Test#22 in Unit Test Spec. Doc.  //
       
   522 //
       
   523 CPhbkSyncDoSynchronisationTest_13::CPhbkSyncDoSynchronisationTest_13()
       
   524 	{
       
   525 	// store the name of this test step
       
   526 	SetTestStepName(_L("PhbkSyncDoSynchronisationTest_13"));
       
   527 	}
       
   528 
       
   529 CPhbkSyncDoSynchronisationTest_13::~CPhbkSyncDoSynchronisationTest_13()
       
   530 	{
       
   531 	}
       
   532 
       
   533 TVerdict CPhbkSyncDoSynchronisationTest_13::doTestStepL( )
       
   534 	{
       
   535 	// 1. load the currupted USIM App ADN phonebook
       
   536 	SetSimTsyTestNumberL(22); // see [test22] in configuration file
       
   537 
       
   538 	// 2. set mode as EManual for all supported phonebooks
       
   539 	User::LeaveIfError(iSession.SetSyncMode(RPhoneBookSession::EManual, KUidUsimAppAdnPhonebook));
       
   540 	CheckSyncModeL(RPhoneBookSession::EManual, KUidUsimAppAdnPhonebook);
       
   541 
       
   542 	// 3. do synchronisation
       
   543 	// To simply ignore the error generated by DoSynchronisation since
       
   544 	// we cannot guarantee the phonebook synchroniser server will give
       
   545 	// us the error KErrBadHandle defined in the cfg. file.
       
   546 	// However, we do know the error code != KErrNone
       
   547 	DoSyncL(KUidUsimAppAdnPhonebook, KErrBadHandle, ETrue); // ignore the result
       
   548 
       
   549 	// 4. check the expected behaviour
       
   550 	CheckCacheStateErrorL(KUidUsimAppAdnPhonebook);
       
   551 
       
   552 	return TestStepResult();
       
   553 	}
       
   554 
       
   555 /**
       
   556  * Test synchronisation of a phonebook containing entries
       
   557  * that are "read-only".
       
   558  * Note that SDN and LND phonebooks are read-only by default.
       
   559  */
       
   560 //
       
   561 //    Test step14 -- Test#23 in Unit Test Spec. Doc.  //
       
   562 //
       
   563 CPhbkSyncDoSynchronisationTest_14::CPhbkSyncDoSynchronisationTest_14()
       
   564 	{
       
   565 	// store the name of this test step
       
   566 	SetTestStepName(_L("PhbkSyncDoSynchronisationTest_14"));
       
   567 	}
       
   568 
       
   569 CPhbkSyncDoSynchronisationTest_14::~CPhbkSyncDoSynchronisationTest_14()
       
   570 	{
       
   571 	}
       
   572 
       
   573 TVerdict CPhbkSyncDoSynchronisationTest_14::doTestStepL( )
       
   574 	{
       
   575 	// 1. change the mode as EManual for all phonebooks anc check it.
       
   576 	TInt i(0);
       
   577 	for (i=0; i<KTotalNumberOfPhoneBook; i++) 
       
   578 		{ 
       
   579 		ChangeSyncModeL(RPhoneBookSession::EManual, iPhoneBook[i]);
       
   580 		CheckSyncModeL(RPhoneBookSession::EManual, iPhoneBook[i]);    
       
   581 		}
       
   582 
       
   583 	// 2. load the dummy ICC which contains all phonebooks
       
   584 	SetSimTsyTestNumberL(0); // no synchronisation should happen
       
   585 
       
   586 	// 3. do synchronisation for read-only phonebooks (SDN and LND)
       
   587 	DoSyncL(KUidIccGlobalSdnPhonebook, KErrNone);
       
   588 	DoSyncL(KUidIccGlobalLndPhonebook, KErrNone);
       
   589 
       
   590 	// 4. check the expected behaviour
       
   591 	CheckCacheStateValidL(KUidIccGlobalSdnPhonebook);
       
   592 	CheckCacheStateValidL(KUidIccGlobalLndPhonebook);
       
   593 
       
   594 	return TestStepResult();
       
   595 	}
       
   596 
       
   597 /**
       
   598  * Test synchronisation when a UICC is not present
       
   599  */
       
   600 //
       
   601 //    Test step15 -- Test#24 in Unit Test Spec. Doc.  //
       
   602 //
       
   603 CPhbkSyncDoSynchronisationTest_15::CPhbkSyncDoSynchronisationTest_15()
       
   604 	{
       
   605 	// store the name of this test step
       
   606 	SetTestStepName(_L("PhbkSyncDoSynchronisationTest_15"));
       
   607 	}
       
   608 
       
   609 CPhbkSyncDoSynchronisationTest_15::~CPhbkSyncDoSynchronisationTest_15()
       
   610 	{
       
   611 	}
       
   612 
       
   613 TVerdict CPhbkSyncDoSynchronisationTest_15::doTestStepL( )
       
   614 	{
       
   615 	// 1. change the mode as EManual for all phonebooks anc check it.
       
   616 	TInt i(0);
       
   617 	for (i=0; i<KTotalNumberOfPhoneBook; i++) 
       
   618 		{ 
       
   619 		ChangeSyncModeL(RPhoneBookSession::EManual, iPhoneBook[i]);
       
   620 		CheckSyncModeL(RPhoneBookSession::EManual, iPhoneBook[i]);    
       
   621 		}
       
   622 
       
   623 	// 2. load the phonebooks prepared
       
   624 	SetSimTsyTestNumberL(24);
       
   625 
       
   626 	// 3. do synchronisation and failed
       
   627 	// To simply ignore the error generated by DoSynchronisation 
       
   628 	// since we cannot guarantee the phonebook synchroniser server 
       
   629 	// will give us the error KErrNotReady defined in the cfg. file.
       
   630 	// However, we do know the error code != KErrNone
       
   631 	DoSyncL(KUidIccGlobalAdnPhonebook, KErrNotReady); // ignore sync failure 
       
   632 	DoSyncL(KUidUsimAppAdnPhonebook, KErrNotReady);   // ignore sync failure
       
   633 	DoSyncL(KUidIccGlobalFdnPhonebook, KErrNotReady); // ignore sync failure 
       
   634 
       
   635 	// 4. check the expected behaviour
       
   636 	CheckCacheStateErrorL(KUidIccGlobalAdnPhonebook);
       
   637 	CheckCacheStateErrorL(KUidUsimAppAdnPhonebook);
       
   638 	CheckCacheStateErrorL(KUidIccGlobalFdnPhonebook);
       
   639 
       
   640 	return TestStepResult();
       
   641 	}
       
   642 
       
   643 /**
       
   644  * Test synchrnisation when UICC is "not ready"
       
   645  */
       
   646 //
       
   647 //    Test step16 -- Test#25 in Unit Test Spec. Doc.  //
       
   648 //
       
   649 CPhbkSyncDoSynchronisationTest_16::CPhbkSyncDoSynchronisationTest_16()
       
   650 	{
       
   651 	// store the name of this test step
       
   652 	SetTestStepName(_L("PhbkSyncDoSynchronisationTest_16"));
       
   653 	}
       
   654 
       
   655 CPhbkSyncDoSynchronisationTest_16::~CPhbkSyncDoSynchronisationTest_16()
       
   656 	{
       
   657 	}
       
   658 
       
   659 TVerdict CPhbkSyncDoSynchronisationTest_16::doTestStepL( )
       
   660 	{
       
   661 	// It is not clear how to simulate that UICC is "not ready" ???
       
   662 
       
   663 	return TestStepResult();
       
   664 	}
       
   665 
       
   666 
       
   667 /**
       
   668  * Test synchronisation when the UICC is "blocked"
       
   669  */
       
   670 //
       
   671 //    Test step17 -- Test#26 in Unit Test Spec. Doc.  //
       
   672 //
       
   673 CPhbkSyncDoSynchronisationTest_17::CPhbkSyncDoSynchronisationTest_17()
       
   674 	{
       
   675 	// store the name of this test step
       
   676 	SetTestStepName(_L("PhbkSyncDoSynchronisationTest_17"));
       
   677 	}
       
   678 
       
   679 CPhbkSyncDoSynchronisationTest_17::~CPhbkSyncDoSynchronisationTest_17()
       
   680 	{
       
   681 	}
       
   682 
       
   683 TVerdict CPhbkSyncDoSynchronisationTest_17::doTestStepL( )
       
   684 	{
       
   685 	// 1. change the mode as EManual for all phonebooks anc check it.
       
   686 	TInt i(0);
       
   687 	for (i=0; i<KTotalNumberOfPhoneBook; i++) 
       
   688 		{ 
       
   689 		ChangeSyncModeL(RPhoneBookSession::EManual, iPhoneBook[i]);
       
   690 		CheckSyncModeL(RPhoneBookSession::EManual, iPhoneBook[i]);    
       
   691 		}
       
   692 
       
   693 	// 2. load the test which contains all phonebooks, but they are locked
       
   694 	SetSimTsyTestNumberL(27);
       
   695 
       
   696 	// 3. do synchronisation and failed
       
   697 	DoSyncL(KUidIccGlobalAdnPhonebook, KErrAccessDenied);
       
   698 	DoSyncL(KUidUsimAppAdnPhonebook, KErrAccessDenied);
       
   699 	DoSyncL(KUidIccGlobalFdnPhonebook, KErrAccessDenied);
       
   700 
       
   701 	// 4. check the expected behaviour
       
   702 	CheckCacheStateErrorL(KUidIccGlobalAdnPhonebook);
       
   703 	CheckCacheStateErrorL(KUidUsimAppAdnPhonebook);
       
   704 	CheckCacheStateErrorL(KUidIccGlobalFdnPhonebook);
       
   705 
       
   706 	return TestStepResult();
       
   707 	}
       
   708 
       
   709 /**
       
   710  * Test synchronisation when the UICC is "PIN protected"
       
   711  */
       
   712 //
       
   713 //    Test step18 -- Test#27 in Unit Test Spec. Doc.  //
       
   714 //
       
   715 CPhbkSyncDoSynchronisationTest_18::CPhbkSyncDoSynchronisationTest_18()
       
   716 {
       
   717   // store the name of this test step
       
   718   SetTestStepName(_L("PhbkSyncDoSynchronisationTest_18"));
       
   719 }
       
   720 
       
   721 CPhbkSyncDoSynchronisationTest_18::~CPhbkSyncDoSynchronisationTest_18()
       
   722 	{
       
   723 	}
       
   724 
       
   725 TVerdict CPhbkSyncDoSynchronisationTest_18::doTestStepL( )
       
   726 	{
       
   727 	// 1. change the mode as EManual for all phonebooks anc check it.
       
   728 	TInt i(0);
       
   729 	for (i=0; i<KTotalNumberOfPhoneBook; i++) 
       
   730 		{ 
       
   731 		ChangeSyncModeL(RPhoneBookSession::EManual, iPhoneBook[i]);
       
   732 		CheckSyncModeL(RPhoneBookSession::EManual, iPhoneBook[i]);    
       
   733 		}
       
   734 
       
   735 	// 2. load the Global ADN and Usim ADN phonebooks prepared
       
   736 	SetSimTsyTestNumberL(27); // no synchronisation should happen
       
   737 
       
   738 	// 3. do synchronisation for the PIN protected phonebooks
       
   739 	DoSyncL(KUidIccGlobalAdnPhonebook, KErrAccessDenied); // should fail
       
   740 	DoSyncL(KUidUsimAppAdnPhonebook, KErrAccessDenied);   // should fail
       
   741 	DoSyncL(KUidIccGlobalFdnPhonebook, KErrAccessDenied); // should fail
       
   742 
       
   743 	// 4. check the expected behaviour
       
   744 	CheckCacheStateErrorL(KUidIccGlobalAdnPhonebook);
       
   745 	CheckCacheStateErrorL(KUidUsimAppAdnPhonebook);
       
   746 	CheckCacheStateErrorL(KUidIccGlobalFdnPhonebook);
       
   747 
       
   748 	return TestStepResult();
       
   749 	}
       
   750 
       
   751 /**
       
   752  * Test synchronisation of a phonebook that contains entries with
       
   753  * Name field set and Number fiedl blank
       
   754  */
       
   755 //
       
   756 //    Test step19 -- Test#28 in Unit Test Spec. Doc.  //
       
   757 //
       
   758 CPhbkSyncDoSynchronisationTest_19::CPhbkSyncDoSynchronisationTest_19()
       
   759 	{
       
   760 	// store the name of this test step
       
   761 	SetTestStepName(_L("PhbkSyncDoSynchronisationTest_19"));
       
   762 	}
       
   763 
       
   764 CPhbkSyncDoSynchronisationTest_19::~CPhbkSyncDoSynchronisationTest_19()
       
   765 	{
       
   766 	}
       
   767 
       
   768 TVerdict CPhbkSyncDoSynchronisationTest_19::doTestStepL( )
       
   769 	{
       
   770 	// 1. load the SDN phonebook prepared for this test
       
   771 	SetSimTsyTestNumberL(28); // see [test28] in configuration file
       
   772 
       
   773 	// 2. set mode as EManual, anyway.
       
   774 	User::LeaveIfError(iSession.SetSyncMode(RPhoneBookSession::EManual, KUidIccGlobalSdnPhonebook)); 
       
   775 	CheckSyncModeL(RPhoneBookSession::EManual, KUidIccGlobalSdnPhonebook);
       
   776 
       
   777 	// 3. do synchronisation
       
   778 	DoSyncL(KUidIccGlobalSdnPhonebook, KErrNone);
       
   779 
       
   780 	// 4. check the expected behaviour
       
   781 	CheckCacheStateValidL(KUidIccGlobalSdnPhonebook); 
       
   782 
       
   783 	return TestStepResult();
       
   784 	}
       
   785 
       
   786 /**
       
   787  * Test synchronisatin of a phonebook that contains entries
       
   788  * with Number field set and Name field blank.
       
   789  */
       
   790 //
       
   791 //    Test step20 -- Test#29 in Unit Test Spec. Doc.  //
       
   792 //
       
   793 CPhbkSyncDoSynchronisationTest_20::CPhbkSyncDoSynchronisationTest_20()
       
   794 	{
       
   795 	// store the name of this test step
       
   796 	SetTestStepName(_L("PhbkSyncDoSynchronisationTest_20"));
       
   797 	}
       
   798 
       
   799 CPhbkSyncDoSynchronisationTest_20::~CPhbkSyncDoSynchronisationTest_20()
       
   800 	{
       
   801 	}
       
   802 
       
   803 TVerdict CPhbkSyncDoSynchronisationTest_20::doTestStepL( )
       
   804 	{
       
   805 	// 1. load the SDN phonebook prepared for this test
       
   806 	SetSimTsyTestNumberL(29); // see [test29] in configuration file
       
   807 
       
   808 	// 2. set mode as EManual, anyway.
       
   809 	User::LeaveIfError(iSession.SetSyncMode(RPhoneBookSession::EManual, KUidIccGlobalSdnPhonebook)); 
       
   810 	CheckSyncModeL(RPhoneBookSession::EManual, KUidIccGlobalSdnPhonebook);
       
   811 
       
   812 	// 3. do synchronisation
       
   813 	DoSyncL(KUidIccGlobalSdnPhonebook, KErrNone);
       
   814 
       
   815 	// 4. check the expected behaviour
       
   816 	CheckCacheStateValidL(KUidIccGlobalSdnPhonebook); 
       
   817 
       
   818 	return TestStepResult();
       
   819 	}
       
   820 
       
   821 /**
       
   822  * Test synchronisation of a phonebook that contains entries 
       
   823  * that have letters in the phone number field.
       
   824  */ 
       
   825 //
       
   826 //    Test step21 -- Test#30 in Unit Test Spec. Doc.  //
       
   827 //
       
   828 CPhbkSyncDoSynchronisationTest_21::CPhbkSyncDoSynchronisationTest_21()
       
   829 	{
       
   830 	// store the name of this test step
       
   831 	SetTestStepName(_L("PhbkSyncDoSynchronisationTest_21"));
       
   832 	}
       
   833 
       
   834 CPhbkSyncDoSynchronisationTest_21::~CPhbkSyncDoSynchronisationTest_21()
       
   835 	{
       
   836 	}
       
   837 
       
   838 TVerdict CPhbkSyncDoSynchronisationTest_21::doTestStepL( )
       
   839 	{
       
   840 	// 1. load the SDN phonebook prepared for this test
       
   841 	SetSimTsyTestNumberL(30); // see [test30] in configuration file
       
   842 
       
   843 	// 2. set mode as EManual, anyway.
       
   844 	User::LeaveIfError(iSession.SetSyncMode(RPhoneBookSession::EManual, KUidIccGlobalSdnPhonebook)); 
       
   845 	CheckSyncModeL(RPhoneBookSession::EManual, KUidIccGlobalSdnPhonebook);
       
   846 
       
   847 	// 3. do synchronisation
       
   848 	DoSyncL(KUidIccGlobalSdnPhonebook, KErrNone);
       
   849 
       
   850 	// 4. check the expected behaviour
       
   851 	CheckCacheStateValidL(KUidIccGlobalSdnPhonebook); 
       
   852 
       
   853 	return TestStepResult();
       
   854 	}
       
   855 
       
   856 /**
       
   857  * Test synchronisation of a phonebook that contains entries
       
   858  * with "+", "p", and "w" in th phone number field.
       
   859  */
       
   860 //
       
   861 //    Test step22 -- Test#31 in Unit Test Spec. Doc.  //
       
   862 //
       
   863 CPhbkSyncDoSynchronisationTest_22::CPhbkSyncDoSynchronisationTest_22()
       
   864 	{
       
   865 	// store the name of this test step
       
   866 	SetTestStepName(_L("PhbkSyncDoSynchronisationTest_22"));
       
   867 	}
       
   868 
       
   869 CPhbkSyncDoSynchronisationTest_22::~CPhbkSyncDoSynchronisationTest_22()
       
   870 	{
       
   871 	}
       
   872 
       
   873 TVerdict CPhbkSyncDoSynchronisationTest_22::doTestStepL( )
       
   874 	{
       
   875 	// 1. load the SDN phonebook prepared for this test
       
   876 	SetSimTsyTestNumberL(31); // see [test31] in configuration file
       
   877 
       
   878 	// 2. set mode as EManual, anyway.
       
   879 	User::LeaveIfError(iSession.SetSyncMode(RPhoneBookSession::EManual, KUidIccGlobalSdnPhonebook)); 
       
   880 	CheckSyncModeL(RPhoneBookSession::EManual, KUidIccGlobalSdnPhonebook);
       
   881 
       
   882 	// 3. do synchronisation
       
   883 	DoSyncL(KUidIccGlobalSdnPhonebook, KErrNone);
       
   884 
       
   885 	// 4. check the expected behaviour
       
   886 	CheckCacheStateValidL(KUidIccGlobalSdnPhonebook); 
       
   887 
       
   888 	return TestStepResult();
       
   889 	}
       
   890 
       
   891 /**
       
   892  * Test synchronisation of a phonebook that has an entry
       
   893  * with the location number "0".
       
   894  */
       
   895 //
       
   896 //    Test step23 -- Test#32 in Unit Test Spec. Doc.  //
       
   897 //
       
   898 CPhbkSyncDoSynchronisationTest_23::CPhbkSyncDoSynchronisationTest_23()
       
   899 	{
       
   900 	// store the name of this test step
       
   901 	SetTestStepName(_L("PhbkSyncDoSynchronisationTest_23"));
       
   902 	}
       
   903 
       
   904 CPhbkSyncDoSynchronisationTest_23::~CPhbkSyncDoSynchronisationTest_23()
       
   905 	{
       
   906 	}
       
   907 
       
   908 TVerdict CPhbkSyncDoSynchronisationTest_23::doTestStepL( )
       
   909 	{
       
   910 	// 1. load the SDN phonebook prepared for this test
       
   911 	SetSimTsyTestNumberL(32); // see [test32] in configuration file
       
   912 
       
   913 	// 2. set mode as EManual, anyway.
       
   914 	User::LeaveIfError(iSession.SetSyncMode(RPhoneBookSession::EManual, KUidIccGlobalSdnPhonebook)); 
       
   915 	CheckSyncModeL(RPhoneBookSession::EManual, KUidIccGlobalSdnPhonebook);
       
   916 
       
   917 	// 3. do synchronisation
       
   918 	DoSyncL(KUidIccGlobalSdnPhonebook, KErrArgument);
       
   919 
       
   920 	// 4. check the expected behaviour
       
   921 	CheckCacheStateInvalidL(KUidIccGlobalSdnPhonebook); 
       
   922 
       
   923 	return TestStepResult();
       
   924 	}
       
   925 
       
   926 /**
       
   927  * Test synchronisation of a phonebook that has entries 
       
   928  * with negative location numbers
       
   929  */
       
   930 //
       
   931 //    Test step24 -- Test#33 in Unit Test Spec. Doc.  //
       
   932 //
       
   933 CPhbkSyncDoSynchronisationTest_24::CPhbkSyncDoSynchronisationTest_24()
       
   934 	{
       
   935 	// store the name of this test step
       
   936 	SetTestStepName(_L("PhbkSyncDoSynchronisationTest_24"));
       
   937 	}
       
   938 
       
   939 CPhbkSyncDoSynchronisationTest_24::~CPhbkSyncDoSynchronisationTest_24()
       
   940 	{
       
   941 	}
       
   942 
       
   943 TVerdict CPhbkSyncDoSynchronisationTest_24::doTestStepL( )
       
   944 	{
       
   945 	// 1. load the SDN phonebook prepared for this test
       
   946 	SetSimTsyTestNumberL(33); // see [test33] in configuration file
       
   947 
       
   948 	// 2. set mode as EManual, anyway.
       
   949 	User::LeaveIfError(iSession.SetSyncMode(RPhoneBookSession::EManual, KUidIccGlobalSdnPhonebook)); 
       
   950 	CheckSyncModeL(RPhoneBookSession::EManual, KUidIccGlobalSdnPhonebook);
       
   951 
       
   952 	// 3. do synchronisation
       
   953 	DoSyncL(KUidIccGlobalSdnPhonebook, KErrArgument);
       
   954 
       
   955 	// 4. check the expected behaviour
       
   956 	CheckCacheStateInvalidL(KUidIccGlobalSdnPhonebook); 
       
   957 
       
   958 	return TestStepResult();
       
   959 	}
       
   960 
       
   961 /**
       
   962  * Test synchronisation of multiple phonebooks by starting them 
       
   963  * sconsecutively.
       
   964  */
       
   965 //
       
   966 //    Test step25 -- Test#34 in Unit Test Spec. Doc.  //
       
   967 //
       
   968 CPhbkSyncDoSynchronisationTest_25::CPhbkSyncDoSynchronisationTest_25()
       
   969 	{
       
   970 	// store the name of this test step
       
   971 	SetTestStepName(_L("PhbkSyncDoSynchronisationTest_25"));
       
   972 	}
       
   973 
       
   974 CPhbkSyncDoSynchronisationTest_25::~CPhbkSyncDoSynchronisationTest_25()
       
   975 	{
       
   976 	}
       
   977 
       
   978 TVerdict CPhbkSyncDoSynchronisationTest_25::doTestStepL( )
       
   979 	{
       
   980 	// 1. load the dummy ICC which contains all phonebooks
       
   981 	//    server will be re-connected after loading the ICC
       
   982 	//    using the default .ini.
       
   983 	SetSimTsyTestNumberL(0); // see [test0] in configuration file
       
   984 
       
   985 	// 2. set mode as EManual and do initial synchronisation
       
   986 	TInt i(0);
       
   987 	for (i=0; i<KTotalNumberOfPhoneBook; i++) 
       
   988 		{ 
       
   989 		User::LeaveIfError(iSession.SetSyncMode(RPhoneBookSession::EManual, iPhoneBook[i]));
       
   990 		CheckSyncModeL(RPhoneBookSession::EManual, iPhoneBook[i]);
       
   991 		DoSyncL(iPhoneBook[i], KErrNone);
       
   992 		}
       
   993 
       
   994 	// 3. consecutively do sync according to the test purpose
       
   995 	RPhoneBookSession session;  // a NEW session handle
       
   996 	User::LeaveIfError(session.Connect()); // Second connection to the Server
       
   997 	TRequestStatus status1, status2, status3, status4;
       
   998 	for (i=0; i<KTotalNumberOfPhoneBook; i++) 
       
   999 		{ 
       
  1000 		iSession.DoSynchronisation(status1, iPhoneBook[i]); // Start first sync
       
  1001 		iSession.DoSynchronisation(status2, iPhoneBook[i]); // Start second sync
       
  1002 		iSession.DoSynchronisation(status3, iPhoneBook[i]); // Start third sync
       
  1003 		iSession.DoSynchronisation(status4, iPhoneBook[i]); // Start fourth sync
       
  1004 		User::WaitForRequest(status1);
       
  1005 		User::WaitForRequest(status2);
       
  1006 		User::WaitForRequest(status3);
       
  1007 		User::WaitForRequest(status4);
       
  1008 		TESTCHECK(status1.Int(), KErrNone);
       
  1009 		TESTCHECK(status2.Int(), KErrInUse);
       
  1010 		TESTCHECK(status3.Int(), KErrInUse);
       
  1011 		TESTCHECK(status4.Int(), KErrInUse);
       
  1012 		}
       
  1013 
       
  1014 	// 4. do another sync and it should be successful this time
       
  1015 	TRequestStatus status5;
       
  1016 	for (i=0; i<KTotalNumberOfPhoneBook; i++) 
       
  1017 		{ 
       
  1018 		session.DoSynchronisation(status5, iPhoneBook[i]);
       
  1019 		User::WaitForRequest(status5);
       
  1020 		TESTCHECK(status5.Int(), KErrNone);
       
  1021 		}
       
  1022 
       
  1023 	// 5. Close second connection to the server
       
  1024 	session.Close(); // Not the iSession used by every test step
       
  1025 
       
  1026 	return TestStepResult();
       
  1027 	}
       
  1028 
       
  1029 /**
       
  1030  * Test synchronisation of multiple phonebooks with hidden entries.
       
  1031  * 
       
  1032  * === Only applies to Global/GSM ADN and USIM App ADN phonebooks ===
       
  1033  */
       
  1034 //
       
  1035 //    Test step26 -- Test#35 in Unit Test Spec. Doc.  //
       
  1036 //
       
  1037 CPhbkSyncDoSynchronisationTest_26::CPhbkSyncDoSynchronisationTest_26()
       
  1038 	{
       
  1039 	// store the name of this test step
       
  1040 	SetTestStepName(_L("PhbkSyncDoSynchronisationTest_26"));
       
  1041 	}
       
  1042 
       
  1043 CPhbkSyncDoSynchronisationTest_26::~CPhbkSyncDoSynchronisationTest_26()
       
  1044 	{
       
  1045 	}
       
  1046 
       
  1047 TVerdict CPhbkSyncDoSynchronisationTest_26::doTestStepL( )
       
  1048 	{
       
  1049 	// 1. load all phonebooks, where Global/GSM ADN and USim App ADN
       
  1050 	// phonebooks contain hidden entries. The Global/GSM ADN and USim
       
  1051 	// App ADN are the phonebooks which are relevant to this test.
       
  1052 	SetSimTsyTestNumberL(37); // re-use phonebooks prepared for test37# 
       
  1053 
       
  1054 	// 2. set mode as EManual, anyway.
       
  1055 	User::LeaveIfError(iSession.SetSyncMode(RPhoneBookSession::EManual, KUidIccGlobalAdnPhonebook)); 
       
  1056 	CheckSyncModeL(RPhoneBookSession::EManual, KUidIccGlobalAdnPhonebook);
       
  1057 
       
  1058 	User::LeaveIfError(iSession.SetSyncMode(RPhoneBookSession::EManual, KUidUsimAppAdnPhonebook));
       
  1059 	CheckSyncModeL(RPhoneBookSession::EManual, KUidUsimAppAdnPhonebook);
       
  1060 
       
  1061 	// 3. do synchronisation
       
  1062 	DoSyncL(KUidIccGlobalAdnPhonebook, KErrNone);
       
  1063 	DoSyncL(KUidUsimAppAdnPhonebook, KErrNone);
       
  1064 
       
  1065 	// 4. check the expected behaviour
       
  1066 	// 4.1 Synchroniser synchronises all entries without any errors. 
       
  1067 	CheckCacheStateValidL(KUidIccGlobalAdnPhonebook); 
       
  1068 	CheckCacheStateValidL(KUidUsimAppAdnPhonebook);
       
  1069 
       
  1070 	// 4.2 Hidden entries are marked as such in the look-up table
       
  1071 	//     and not visible in the contacts database
       
  1072 
       
  1073 	// since there is no such an API from phbksync to get a valid
       
  1074 	// contact UID for the hidden entry, and also the hidden is not
       
  1075 	// put into the contact database, it is impossible to verify 
       
  1076 	// the expected behaviour.
       
  1077 
       
  1078 	return TestStepResult();
       
  1079 	}
       
  1080 
       
  1081 /**
       
  1082  * Test initial synchronisation is successful. Then test that a
       
  1083  * subsequent "SIM tookit refresh" notification leads to a second 
       
  1084  * synchronisation.
       
  1085  */
       
  1086 
       
  1087 
       
  1088 /** 
       
  1089  * Re-Synchronisation (SIM Toolkit initiated).
       
  1090  * SIM is OK. Synchronisation mode is "Auto Sync, Current ICC".
       
  1091  * Test initial synchronisation is successful. Then test that
       
  1092  * a subsequent "SIM toolkit refresh" notification leads to a 
       
  1093  * second synchronisation.
       
  1094  */
       
  1095 //
       
  1096 //    Test step27 -- Test#36 in Unit Test Spec. Doc.  //
       
  1097 //
       
  1098 CPhbkSyncDoSynchronisationTest_27::CPhbkSyncDoSynchronisationTest_27()
       
  1099 	{
       
  1100 	// store the name of this test step
       
  1101 	SetTestStepName(_L("PhbkSyncDoSynchronisationTest_27"));
       
  1102 	}
       
  1103 
       
  1104 CPhbkSyncDoSynchronisationTest_27::~CPhbkSyncDoSynchronisationTest_27()
       
  1105 	{
       
  1106 	}
       
  1107 
       
  1108 TVerdict CPhbkSyncDoSynchronisationTest_27::doTestStepL( )
       
  1109 	{
       
  1110 	TInt i(0);
       
  1111 	for (i=0; i<KTotalNumberOfPhoneBook; i++) 
       
  1112 		{ 
       
  1113 		User::LeaveIfError(iSession.SetSyncMode(RPhoneBookSession::EAutoCurrentIcc, iPhoneBook[i]));
       
  1114 		CheckSyncModeL(RPhoneBookSession::EAutoCurrentIcc, iPhoneBook[i]);
       
  1115 		}
       
  1116 
       
  1117 	// load the phonebook prepared for this particular test
       
  1118 	SetSimTsyTestNumberL(36);	// Switch to a SIM TSY configuration which sends a 
       
  1119 								// "refresh" notification at some point in the future
       
  1120 
       
  1121 	User::After(10000000); // Wait for refresh notification to trigger
       
  1122 	RPhoneBookSession::TSyncState state;
       
  1123 	for (i=0; i<KTotalNumberOfPhoneBook; i++) 
       
  1124 		{ 
       
  1125 		iSession.GetPhoneBookCacheState(state, iPhoneBook[i]); 
       
  1126 		while (state==RPhoneBookSession::EUnsynchronised) // Wait until cache becomes usable and for Synchronisation to be carried out 
       
  1127 			{
       
  1128 			iSession.GetPhoneBookCacheState(state, iPhoneBook[i]);
       
  1129 			User::After(1000000);
       
  1130 			}
       
  1131 		TESTCHECKL(state, RPhoneBookSession::ECacheValid); // Cache is now in valid state
       
  1132 		}
       
  1133 
       
  1134 	return TestStepResult();
       
  1135 	}
       
  1136 
       
  1137 /** 
       
  1138  * Test synchronisation with a partially full Global/GSM FDN phonebook.
       
  1139  *
       
  1140  * It is assumed that server been connected/started by Open step.
       
  1141  */
       
  1142 //
       
  1143 //    Test step28 --								//
       
  1144 //
       
  1145 CPhbkSyncDoSynchronisationTest_28::CPhbkSyncDoSynchronisationTest_28()
       
  1146 	{
       
  1147 	// store the name of this test step
       
  1148 	SetTestStepName(_L("PhbkSyncDoSynchronisationTest_28"));
       
  1149 	}
       
  1150 
       
  1151 CPhbkSyncDoSynchronisationTest_28::~CPhbkSyncDoSynchronisationTest_28()
       
  1152 	{
       
  1153 	}
       
  1154 
       
  1155 TVerdict CPhbkSyncDoSynchronisationTest_28::doTestStepL( )
       
  1156 	{
       
  1157 	// 1. set mode as EManual for the tested phonebook only
       
  1158 	User::LeaveIfError(iSession.SetSyncMode(RPhoneBookSession::EManual, KUidIccGlobalFdnPhonebook)); 
       
  1159 	CheckSyncModeL(RPhoneBookSession::EManual, KUidIccGlobalFdnPhonebook);
       
  1160 
       
  1161 	// 2. load the partially full Global/GSM FDN phonebook from cfg file
       
  1162 	SetSimTsyTestNumberL(39); // see [test39] in configuration file
       
  1163 
       
  1164 	// 3. do synchronisation
       
  1165 	DoSyncL(KUidIccGlobalFdnPhonebook, KErrNone);
       
  1166 
       
  1167 	// 4. check the expected behaviour
       
  1168 
       
  1169 	return TestStepResult();
       
  1170 	}
       
  1171 
       
  1172 /** 
       
  1173  * Test synchronisation with a full FDN phonebook.
       
  1174  *
       
  1175  * It is assumed that server been connected/started by Open step.
       
  1176  */
       
  1177 //
       
  1178 //    Test step29 --								//
       
  1179 //
       
  1180 CPhbkSyncDoSynchronisationTest_29::CPhbkSyncDoSynchronisationTest_29()
       
  1181 	{
       
  1182 	// store the name of this test step
       
  1183 	SetTestStepName(_L("PhbkSyncDoSynchronisationTest_29"));
       
  1184 	}
       
  1185 
       
  1186 CPhbkSyncDoSynchronisationTest_29::~CPhbkSyncDoSynchronisationTest_29()
       
  1187 	{
       
  1188 	}
       
  1189 
       
  1190 TVerdict CPhbkSyncDoSynchronisationTest_29::doTestStepL( )
       
  1191 	{
       
  1192 	// 1. load the full FDN phonebook from cfg file
       
  1193 	SetSimTsyTestNumberL(40); // see [test40] in configuration file
       
  1194 
       
  1195 	// 2. set mode as EManual for the tested phonebook only
       
  1196 	User::LeaveIfError(iSession.SetSyncMode(RPhoneBookSession::EManual, KUidIccGlobalFdnPhonebook)); 
       
  1197 	CheckSyncModeL(RPhoneBookSession::EManual, KUidIccGlobalFdnPhonebook);
       
  1198 
       
  1199 	// 3. do synchronisation
       
  1200 	DoSyncL(KUidIccGlobalFdnPhonebook, KErrNone);
       
  1201 
       
  1202 	// 4. check the expected behaviour
       
  1203 	CheckCacheStateValidL(KUidIccGlobalFdnPhonebook); 
       
  1204 
       
  1205 	return TestStepResult();
       
  1206 	}
       
  1207 
       
  1208 
       
  1209 /** 
       
  1210  *  Test booting the phone without PIN1 entered and then ensure that when the PIN
       
  1211  *  is entered that the phonebooks are synchronised.
       
  1212  */
       
  1213 TVerdict CPhbkSyncDoSynchronisationTest_30::doTestStepL()
       
  1214 	{
       
  1215 	//
       
  1216 	// Set half of the phonebooks to auto-sync and half to manual...
       
  1217 	//
       
  1218 	User::LeaveIfError(iSession.SetSyncMode(RPhoneBookSession::EAutoCurrentIcc, KUidIccGlobalAdnPhonebook)); 
       
  1219 	User::LeaveIfError(iSession.SetSyncMode(RPhoneBookSession::EAutoCurrentIcc, KUidIccGlobalSdnPhonebook)); 
       
  1220 	User::LeaveIfError(iSession.SetSyncMode(RPhoneBookSession::EAutoCurrentIcc, KUidIccGlobalLndPhonebook)); 
       
  1221 	User::LeaveIfError(iSession.SetSyncMode(RPhoneBookSession::EManual, KUidUsimAppAdnPhonebook)); 
       
  1222 	User::LeaveIfError(iSession.SetSyncMode(RPhoneBookSession::EManual, KUidIccGlobalFdnPhonebook)); 
       
  1223 
       
  1224 	//
       
  1225 	// Load a config were the ICC is PIN1 locked at the start...
       
  1226 	//
       
  1227 	SetSimTsyTestNumberL(101);
       
  1228 
       
  1229 	//
       
  1230 	// Check that the auto-sync phonebooks have failed and the others are unsynchronised.
       
  1231 	//
       
  1232 	CheckCacheStateErrorL(KUidIccGlobalAdnPhonebook); 
       
  1233 	CheckCacheStateErrorL(KUidIccGlobalSdnPhonebook); 
       
  1234 	CheckCacheStateErrorL(KUidIccGlobalLndPhonebook); 
       
  1235 	CheckCacheStateInvalidL(KUidUsimAppAdnPhonebook); 
       
  1236 	CheckCacheStateInvalidL(KUidIccGlobalFdnPhonebook); 
       
  1237 
       
  1238 	//
       
  1239 	// Move time forward and allow the PIN1 timer to trigger after being advanced,
       
  1240 	// so that the SIMTSY unlocks PIN1.
       
  1241 	//
       
  1242 	SignalSimTsyToReduceTimersL();
       
  1243 	User::After(5*1000000);
       
  1244 	
       
  1245 	//
       
  1246 	// Check that the auto-sync phonebooks have now sync'd and the others are unsynchronised.
       
  1247 	//
       
  1248 	CheckCacheStateValidL(KUidIccGlobalAdnPhonebook); 
       
  1249 	CheckCacheStateValidL(KUidIccGlobalSdnPhonebook); 
       
  1250 	CheckCacheStateValidL(KUidIccGlobalLndPhonebook); 
       
  1251 	CheckCacheStateInvalidL(KUidUsimAppAdnPhonebook); 
       
  1252 	CheckCacheStateInvalidL(KUidIccGlobalFdnPhonebook); 
       
  1253 
       
  1254 	return TestStepResult();
       
  1255 	} // CPhbkSyncDoSynchronisationTest_30::doTestStepL
       
  1256 
       
  1257 
       
  1258 //
       
  1259 //    OOM DoSynchronisation step1
       
  1260 //
       
  1261 CPhbkSyncOOMDoSynchronisationTest_01::CPhbkSyncOOMDoSynchronisationTest_01()
       
  1262 	{
       
  1263 	// store the name of this test step
       
  1264 	SetTestStepName(_L("PhbkSyncOOMDoSynchronisationTest_01"));
       
  1265 	}
       
  1266 
       
  1267 CPhbkSyncOOMDoSynchronisationTest_01::~CPhbkSyncOOMDoSynchronisationTest_01()
       
  1268 	{
       
  1269 	}
       
  1270 
       
  1271 TVerdict CPhbkSyncOOMDoSynchronisationTest_01::doTestStepL( )
       
  1272 	{
       
  1273 	// Note that only after session is connected, can Heap be marked
       
  1274 	DestroyDefaultIniFileL();
       
  1275 
       
  1276 	// load all phonebooks
       
  1277 	SetSimTsyTestNumberL(80);
       
  1278 
       
  1279 	// set mode as EManual for all supported phonebooks
       
  1280 	TInt i(0);
       
  1281 	for (i=0; i<KTotalNumberOfPhoneBook; i++) 
       
  1282 		{ 
       
  1283 		User::LeaveIfError(iSession.SetSyncMode(RPhoneBookSession::EManual, iPhoneBook[i]));
       
  1284 		CheckSyncModeL(RPhoneBookSession::EManual, iPhoneBook[i]);
       
  1285 		}
       
  1286 
       
  1287 	DoSyncL(KUidIccGlobalAdnPhonebook, KErrNone);
       
  1288 
       
  1289 	// do OOM test against synchronisation API
       
  1290 	RPhoneBookSession newSession;
       
  1291 	TRequestStatus status;
       
  1292 	TInt failure(1);
       
  1293 	iSession.__DbgMarkHeap();
       
  1294 	TInt err = newSession.Connect();
       
  1295 
       
  1296 	// connected OK
       
  1297 	INFO_PRINTF1(_L("This OOM test takes a bit longer due session closes/connects"));
       
  1298 
       
  1299 	do 
       
  1300 		{
       
  1301 		iSession.__DbgFailNext(failure++);
       
  1302 		newSession.DoSynchronisation(status, KUidIccGlobalAdnPhonebook);
       
  1303 		User::WaitForRequest(status);
       
  1304 		if ((err = status.Int()) != KErrNone)
       
  1305 			{
       
  1306 			newSession.Close();
       
  1307 			User::After(2000000); // 2 seconds
       
  1308 			iSession.__DbgCheckHeap(0);
       
  1309 			User::LeaveIfError(newSession.Connect());
       
  1310 			}
       
  1311 		} while (err != KErrNone);
       
  1312 
       
  1313 	User::After(5000000); // 5 seconds
       
  1314 	newSession.Close();
       
  1315 	iSession.__DbgCheckHeap(0);
       
  1316 	iSession.__DbgMarkEnd(0);
       
  1317 
       
  1318 	// OOM test OK
       
  1319 	INFO_PRINTF2(_L("DoSynchronisation becomes successful after %d FailNext calls"),failure);
       
  1320 
       
  1321 	// check the expected behaviour
       
  1322 	CheckCacheStateValidL(KUidIccGlobalAdnPhonebook);
       
  1323 
       
  1324 	// to ask the phbksync server to check the heap 
       
  1325 	iSession.Close();
       
  1326 
       
  1327 	// to ensure server has enough time to shut down
       
  1328 	User::After(3000000); 
       
  1329 	TInt ret(iSession.Connect());
       
  1330 	
       
  1331 	TESTCHECK(ret, KErrNone)
       
  1332 
       
  1333 	return TestStepResult();
       
  1334 	}
       
  1335 
       
  1336 //
       
  1337 //    SubscriberId test step1
       
  1338 //
       
  1339 CPhbkSyncSubscriberIdTest_01::CPhbkSyncSubscriberIdTest_01()
       
  1340 	{
       
  1341 	// store the name of this test step
       
  1342 	SetTestStepName(_L("PhbkSyncSubscriberIdTest_01"));
       
  1343 	}
       
  1344 
       
  1345 CPhbkSyncSubscriberIdTest_01::~CPhbkSyncSubscriberIdTest_01()
       
  1346 	{
       
  1347 	}
       
  1348 
       
  1349 TVerdict CPhbkSyncSubscriberIdTest_01::doTestStepL( )
       
  1350 	{
       
  1351 	// the purpose of this test is to test that DoSync request
       
  1352 	// is issued and is executed in server before the method
       
  1353 	// ::CompleteGetPhoneStoreInfo is called via the AO.
       
  1354 	// By doing that, we can trigger the condition "subscriberId"
       
  1355 	// is not retrived in ::DoSynchronisationL. 
       
  1356 
       
  1357 	DestroyDefaultIniFileL();
       
  1358 
       
  1359 	// load phonebooks and don't wait after connect
       
  1360 	//
       
  1361 	
       
  1362 	RProperty testNumberProperty;
       
  1363 	User::LeaveIfError(testNumberProperty.Attach(KUidPSSimTsyCategory, KPSSimTsyTestNumber));
       
  1364 	CleanupClosePushL(testNumberProperty);
       
  1365 	
       
  1366 	TRequestStatus status;
       
  1367 	testNumberProperty.Subscribe(status);
       
  1368 	User::LeaveIfError(testNumberProperty.Set(KUidPSSimTsyCategory,KPSSimTsyTestNumber,81));
       
  1369 	User::WaitForRequest(status);
       
  1370 	User::LeaveIfError(status.Int());
       
  1371 	TInt testNumberCheck;
       
  1372 	User::LeaveIfError(testNumberProperty.Get(testNumberCheck));
       
  1373 	if (81 != testNumberCheck)
       
  1374 	{
       
  1375 		User::Leave(KErrNotFound);		
       
  1376 	}
       
  1377 
       
  1378 	CleanupStack::PopAndDestroy(&testNumberProperty);
       
  1379 	
       
  1380 	iSession.Close();
       
  1381 	
       
  1382 	ConfigurePhbkSyncToIdleL();
       
  1383 	ConfigurePhbkSyncToFullL();
       
  1384 
       
  1385 	TInt ret = iSession.Connect();
       
  1386 	User::LeaveIfError(ret);
       
  1387 	
       
  1388 	User::LeaveIfError(iSession.SetSyncMode(RPhoneBookSession::EManual, 
       
  1389 						 KUidIccGlobalAdnPhonebook));
       
  1390 
       
  1391 	// Note that these is no delay after connect is done that will trigger
       
  1392 	// the execution sequence: ::DoSynchronisation followed by 
       
  1393 	// ::CompleteGetPhoneStoreInfo in phbksync.
       
  1394 	//
       
  1395 	DoSyncL(KUidIccGlobalAdnPhonebook, KErrNone);
       
  1396 
       
  1397 	// check the expected behaviour
       
  1398 	CheckCacheStateValidL(KUidIccGlobalAdnPhonebook);
       
  1399 
       
  1400 	return TestStepResult();
       
  1401 	}
       
  1402