uiservicetab/vimpststorage/tsrc/vimpststorage_ut/src/vimpststorage_testBlocks.cpp
branchRCL_3
changeset 23 9a48e301e94b
parent 0 5e5d6b214f4f
equal deleted inserted replaced
22:3104fc151679 23:9a48e301e94b
       
     1 /*
       
     2 * Copyright (c) 2002 - 2007 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  
       
    15 :                
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 // [INCLUDE FILES] - do not remove
       
    23 #include <e32svr.h>
       
    24 #include <StifParser.h>
       
    25 #include <Stiftestinterface.h>
       
    26 #include <cntdb.h>
       
    27 #include <cntitem.h>
       
    28 //#include <cntmodel.h>
       
    29 #include <cntfldst.h>
       
    30 #include <cntfield.h>
       
    31 //#include <cvpbkcontactmanager.h> 
       
    32 
       
    33 #include "vimpststorage_test.h"
       
    34 
       
    35 #include "cvimpststoragemanager.h"
       
    36 #include "cvimpststoragemanagerfactory.h"
       
    37 #include "mvimpststoragecontacts.h"
       
    38 #include "mvimpststorageitemmodel.h"
       
    39 #include "cvimpststoragecontact.h"
       
    40 #include "cvimpststoragecontactlist.h"
       
    41 #include "bamdesca.h"
       
    42 #include "cvimpststoragevpbkstorehandler.h"
       
    43 #include "CVIMPSTStorageViewId.h"
       
    44 #include "CVIMPSTStorageContactSorter.h"
       
    45 #include "MVIMPSTStorageContact.h"
       
    46 
       
    47 #include "s_MVPbkContactLinkstub.h"
       
    48 #include <CVPbkContactStoreUriArray.h>
       
    49 #include <CVPbkContactManager.h>
       
    50 #include "CVPbkStoreContactStub.h"
       
    51 #include "CVPbkContactOperationBaseStub.h"
       
    52 
       
    53 _LIT( KIMContactListId,"IMContacts" );
       
    54 //_LIT( KVPContactListId,"VPContacts" );
       
    55 _LIT( KStoreName, "TestStore.cdb" );
       
    56 _LIT( KServiceName, "TestService" )	;
       
    57 _LIT( KDisplayname, "my contact list" );
       
    58 //_LIT( KVPDisplayname, "Voip list" );
       
    59 _LIT( KUserId, "id3@dummydomain.com" );
       
    60 const TUint32 serviceId(3);
       
    61 
       
    62 const TInt KNumberGranularity( 12 );
       
    63 
       
    64 const TInt ProcessInterval = 10000000; //10 seconds
       
    65 
       
    66 //extern
       
    67 extern TInt gGiveFieldCount;
       
    68 extern TBool gBestMatchingFieldType;
       
    69 
       
    70 extern CVPbkContactOperationBaseStub* gOperationStub;
       
    71 
       
    72 // ============================ MEMBER FUNCTIONS ===============================
       
    73 
       
    74 // -----------------------------------------------------------------------------
       
    75 // Cvimpststorage_test::Delete
       
    76 // Delete here all resources allocated and opened from test methods. 
       
    77 // Called from destructor. 
       
    78 // -----------------------------------------------------------------------------
       
    79 //
       
    80 void Cvimpststorage_test::Delete() 
       
    81     {
       
    82 
       
    83     }
       
    84 
       
    85 // -----------------------------------------------------------------------------
       
    86 // Cvimpststorage_test::RunMethodL
       
    87 // Run specified method. Contains also table of test mothods and their names.
       
    88 // -----------------------------------------------------------------------------
       
    89 //
       
    90 TInt Cvimpststorage_test::RunMethodL( 
       
    91     CStifItemParser& aItem ) 
       
    92     {
       
    93 
       
    94 	//first of all create database.
       
    95     static TStifFunctionInfo const KFunctions[] =
       
    96         {  
       
    97         // Copy this line for every implemented function.
       
    98         // First string is the function name used in TestScripter script file.
       
    99         // Second is the actual implementation member function. 
       
   100         ENTRY( "InitialiseLibraryTest", Cvimpststorage_test::InitialiseLibraryTestL ),
       
   101         ENTRY( "InitialiseViewTest", Cvimpststorage_test::InitialiseViewTestL ),
       
   102         ENTRY( "CVIMPSTStorageContactTestCase1L", Cvimpststorage_test::CVIMPSTStorageContactTestCase1L ),
       
   103         ENTRY( "CVIMPSTStorageContactTestCase2L", Cvimpststorage_test::CVIMPSTStorageContactTestCase2L ),
       
   104         ENTRY( "CVIMPSTStorageContactTestCase3L", Cvimpststorage_test::CVIMPSTStorageContactTestCase3L ),
       
   105         ENTRY( "CVIMPSTStorageContactTestCase4L", Cvimpststorage_test::CVIMPSTStorageContactTestCase4L ),        
       
   106         ENTRY( "CVIMPSTStorageContactTestCase6L", Cvimpststorage_test::CVIMPSTStorageContactTestCase6L ),
       
   107         ENTRY( "CVIMPSTStorageContactTestCase7L", Cvimpststorage_test::CVIMPSTStorageContactTestCase7L ),
       
   108         ENTRY( "CVIMPSTStorageContactTestCase8L", Cvimpststorage_test::CVIMPSTStorageContactTestCase8L ),
       
   109         ENTRY( "CVIMPSTStorageContactTestCase9L", Cvimpststorage_test::CVIMPSTStorageContactTestCase9L ),
       
   110         ENTRY( "CVIMPSTStorageContactTestCase10L", Cvimpststorage_test::CVIMPSTStorageContactTestCase10L ),
       
   111         
       
   112         ENTRY( "CVIMPSTStorageContactTestCase11L", Cvimpststorage_test::CVIMPSTStorageContactTestCase11L ),
       
   113         ENTRY( "CVIMPSTStorageContactTestCase12L", Cvimpststorage_test::CVIMPSTStorageContactTestCase12L ),
       
   114         ENTRY( "CVIMPSTStorageContactTestCase13L", Cvimpststorage_test::CVIMPSTStorageContactTestCase13L ),
       
   115         ENTRY( "CVIMPSTStorageContactTestCase14L", Cvimpststorage_test::CVIMPSTStorageContactTestCase14L ),
       
   116         ENTRY( "CVIMPSTStorageContactTestCase15L", Cvimpststorage_test::CVIMPSTStorageContactTestCase15L ),
       
   117         
       
   118         ENTRY( "CVIMPSTStorageContactListTestCase16L", Cvimpststorage_test::CVIMPSTStorageContactListTestCase16L ),
       
   119         ENTRY( "CVIMPSTStorageContactListTestCase17L", Cvimpststorage_test::CVIMPSTStorageContactListTestCase17L ),
       
   120         ENTRY( "CVIMPSTStorageContactListTestCase18L", Cvimpststorage_test::CVIMPSTStorageContactListTestCase18L ),
       
   121         ENTRY( "CVIMPSTStorageContactListTestCase19L", Cvimpststorage_test::CVIMPSTStorageContactListTestCase19L ),
       
   122         ENTRY( "CVIMPSTStorageContactListTestCase20L", Cvimpststorage_test::CVIMPSTStorageContactListTestCase20L ),
       
   123         ENTRY( "CVIMPSTStorageContactListTestCase21L", Cvimpststorage_test::CVIMPSTStorageContactListTestCase21L ),
       
   124         
       
   125         ENTRY( "CVIMPSTStorageXSPStoreHandlerTestCase01L", Cvimpststorage_test::CVIMPSTStorageXSPStoreHandlerTestCase01L ),
       
   126         
       
   127         
       
   128         
       
   129                        
       
   130          
       
   131                 
       
   132         //ADD NEW ENTRY HERE
       
   133         // [test cases entries] - Do not remove
       
   134 
       
   135         };
       
   136 
       
   137     const TInt count = sizeof( KFunctions ) / 
       
   138                         sizeof( TStifFunctionInfo );
       
   139 
       
   140     return RunInternalL( KFunctions, count, aItem );
       
   141 
       
   142     }
       
   143     
       
   144 /**
       
   145  * Called when a contact is deleted.
       
   146  * @param aId The ID of the deleted contact
       
   147  * @param aFromPEC, ETrue, if event is coming from PEC
       
   148  */
       
   149  void Cvimpststorage_test::HandleContactDeleteL( const TDesC& /*aContactId*/ )
       
   150 	 {
       
   151 	 iObserverReceivedNotification = ETrue;	
       
   152 	 }
       
   153  
       
   154 
       
   155 /**
       
   156  * Called when a contact is added.
       
   157  * @param aList. List for contact that was added.
       
   158  * @param aContact The contact which was added
       
   159  * @param aFromPEC, ETrue, if event is coming from PEC
       
   160  */
       
   161  void Cvimpststorage_test::HandleAdditionL( MVIMPSTStorageContactList& /*aList*/, MVIMPSTStorageContact& /*aContact*/ )
       
   162  	 {
       
   163 	 iObserverReceivedNotification = ETrue;	
       
   164 	 }
       
   165 
       
   166 
       
   167 /**
       
   168  * Called when a contact or list is about to change, or has been changed.
       
   169  * @param aList List that is changed. Can be NULL if contact is changed.
       
   170  * @param aContact Contact that is changed. Can be NULL if list is changed
       
   171  * @param aEventType The type of event: EStorageEventPreChange before
       
   172  * the change (contact still has the old information), or
       
   173  * EStorageEventPostChange after the change took place 
       
   174  * (contact has new information)
       
   175  */
       
   176  void Cvimpststorage_test::HandleChangeL( MVIMPSTStorageContactList* /*aList*/, MVIMPSTStorageContact* /*aContact*/,
       
   177         TVIMPSTEnums::TCAObserverEventType /*aEventType*/,
       
   178         TBool /*aUserIdChanged*/ )
       
   179 	 {
       
   180 	 iObserverReceivedNotification = ETrue;	
       
   181 	 }
       
   182 
       
   183 // -----------------------------------------------------------------------------
       
   184 // Cvimpststorage_test::InitialiseLibraryTestL
       
   185 // -----------------------------------------------------------------------------
       
   186 //
       
   187 
       
   188 TInt Cvimpststorage_test::InitialiseLibraryTestL( CStifItemParser& /*aItem*/  )
       
   189 	{
       
   190 	_LIT( KState, "State" );
       
   191     _LIT( KResult, "Initialisation successful" );   
       
   192 /*
       
   193 	CVIMPSTStorageManagerFactory::InitialiseLibraryL();	
       
   194 	CVIMPSTStorageManagerFactory::Release();
       
   195 */
       
   196     // Test case passed    
       
   197     TestModuleIf().Printf( 1, KState, KResult );  
       
   198 	    
       
   199     // Case was executed
       
   200     return KErrNone;
       
   201 	}
       
   202 
       
   203 
       
   204 
       
   205 
       
   206 // -----------------------------------------------------------------------------
       
   207 // Cvimpststorage_test::InitialiseViewTestL
       
   208 // -----------------------------------------------------------------------------
       
   209 //
       
   210 TInt  Cvimpststorage_test::InitialiseViewTestL( CStifItemParser& /*aItem*/  )
       
   211 	{
       
   212 	/*CVIMPSTStorageManagerFactory::InitialiseLibraryL();
       
   213 		
       
   214 	CVIMPSTStorageManagerFactory::InitialiseViewL(serviceId,KStoreName, KServiceName);	
       
   215 
       
   216 	CVIMPSTStorageManagerFactory::Release();	
       
   217 	  */  
       
   218     // Case was executed
       
   219     return KErrNone;		
       
   220 	}
       
   221 	
       
   222 	
       
   223 TInt Cvimpststorage_test::CVIMPSTStorageContactTestCase1L()
       
   224 	{
       
   225 	
       
   226 	
       
   227 	CVIMPSTStorageContact* contact = CVIMPSTStorageContact::NewL( NULL,
       
   228                                  NULL,
       
   229                                  NULL,                                 
       
   230                                  NULL,                                                                  
       
   231                                  NULL);
       
   232 
       
   233 	if (contact)
       
   234 		{		
       
   235 		delete contact;
       
   236 		return KErrNone ;
       
   237 		}
       
   238 	
       
   239 	return KErrGeneral;	
       
   240 	}
       
   241 
       
   242 
       
   243 TInt Cvimpststorage_test::CVIMPSTStorageContactTestCase2L()
       
   244 	{
       
   245 	//Ownership of contactLink is transferred to CVIMPSTStorageContact
       
   246 	//hence dont delete
       
   247 	MVPbkContactLink* contactLink = new (ELeave) CVPbkContactLinkStub();
       
   248 	CVPbkContactStoreUriArray* uriArray = CVPbkContactStoreUriArray::NewL();
       
   249 	CVPbkContactManager* contactMgr = CVPbkContactManager::NewL(*uriArray);
       
   250 							
       
   251 								
       
   252 	CVIMPSTStorageContact* contact = CVIMPSTStorageContact::NewL( NULL,
       
   253                                  contactLink,
       
   254                                  NULL,                                 
       
   255                                  contactMgr,                                                                  
       
   256                                  NULL);
       
   257 
       
   258 	if (contact)
       
   259 		{
       
   260 		if (contactLink == contact->ContactLink())
       
   261 			{
       
   262 			delete contact;
       
   263 			delete contactMgr;
       
   264 			delete uriArray;		
       
   265 			return KErrNone ;
       
   266 			}
       
   267 		}
       
   268 	
       
   269 	delete contactMgr;
       
   270 	delete uriArray;
       
   271 	delete contactLink;
       
   272 	return KErrGeneral;	
       
   273 	}
       
   274 	
       
   275 TInt Cvimpststorage_test::CVIMPSTStorageContactTestCase3L()
       
   276 	{
       
   277 	//Ownership of contactLink is transferred to CVIMPSTStorageContact
       
   278 	//hence dont delete
       
   279 	MVPbkContactLink* contactLink = new (ELeave) CVPbkContactLinkStub();
       
   280 							
       
   281 								
       
   282 	CVIMPSTStorageContact* contact = CVIMPSTStorageContact::NewL( NULL,
       
   283                                  contactLink,
       
   284                                  NULL,                                 
       
   285                                  NULL,                                                                  
       
   286                                  NULL);
       
   287 
       
   288 	if (contact)
       
   289 		{	
       
   290 		delete contact;
       
   291 		return KErrNone ;
       
   292 		}
       
   293 	
       
   294 	delete contactLink;
       
   295 	return KErrGeneral;	
       
   296 	}	
       
   297 		
       
   298 		
       
   299 TInt Cvimpststorage_test::CVIMPSTStorageContactTestCase4L()
       
   300 	{	
       
   301 	//TestCase for when there is no service field for a contact
       
   302 	gGiveFieldCount = 0;							
       
   303 	CVIMPSTStorageContact* contact = CVIMPSTStorageContact::NewL( NULL,
       
   304                                  NULL,
       
   305                                  NULL,                                 
       
   306                                  NULL,                                                                  
       
   307                                  NULL);
       
   308 
       
   309 	if (contact)
       
   310 		{
       
   311 		CVPbkStoreContactStub* storedContact = new (ELeave) CVPbkStoreContactStub();
       
   312 		CleanupStack::PushL( storedContact );
       
   313 		
       
   314 		// Read all necessary data from contact and store to 
       
   315 	    // own type
       
   316 	    CDesCArray* arrayForService = new (ELeave) CDesCArrayFlat( 
       
   317 	        KNumberGranularity );
       
   318 	    CleanupStack::PushL( arrayForService );
       
   319 
       
   320 		TInt err = contact->GetServiceFieldsL(storedContact, *arrayForService);
       
   321 		
       
   322 		contact->SetServiceFieldsL(*arrayForService);
       
   323 		
       
   324 		RPointerArray<HBufC> serviceDetails = contact->ServiceDetails();
       
   325 			
       
   326 		CleanupStack::PopAndDestroy(2); //storedContact, arrayForService	
       
   327 		
       
   328 		if ((err == KErrNotFound) && (0 == serviceDetails.Count()))
       
   329 			{
       
   330 			delete contact;
       
   331 			return KErrNone ;
       
   332 			}
       
   333 		
       
   334 		}	
       
   335 	delete contact;
       
   336 	return KErrGeneral;	
       
   337 	}			
       
   338 
       
   339 		
       
   340 TInt Cvimpststorage_test::CVIMPSTStorageContactTestCase6L()
       
   341 	{	
       
   342 	//TestCase for when there are some service field for a contact
       
   343 	//but the BestMatchingFieldType() function returns NULL
       
   344 	//Our code should not crash as this returns a Ptr value
       
   345 	gGiveFieldCount = 4;
       
   346 	gBestMatchingFieldType = EFalse;							
       
   347 	CVIMPSTStorageContact* contact = CVIMPSTStorageContact::NewL( NULL,
       
   348                                  NULL,
       
   349                                  NULL,                                 
       
   350                                  NULL,                                                                  
       
   351                                  NULL);
       
   352 
       
   353 	if (contact)
       
   354 		{
       
   355 		CVPbkStoreContactStub* storedContact = new (ELeave) CVPbkStoreContactStub();
       
   356 		CleanupStack::PushL( storedContact );
       
   357 		
       
   358 		// Read all necessary data from contact and store to 
       
   359 	    // own type
       
   360 	    CDesCArray* arrayForService = new (ELeave) CDesCArrayFlat( 
       
   361 	        KNumberGranularity );
       
   362 	    CleanupStack::PushL( arrayForService );
       
   363 
       
   364 		TInt err = contact->GetServiceFieldsL(storedContact, *arrayForService);		
       
   365 		contact->SetServiceFieldsL(*arrayForService);
       
   366 		
       
   367 		RPointerArray<HBufC> serviceDetails = contact->ServiceDetails();
       
   368 		
       
   369 		
       
   370 		if ((0 == arrayForService->MdcaCount()) && (arrayForService->MdcaCount() == serviceDetails.Count()))
       
   371 			{
       
   372 			delete contact;
       
   373 			CleanupStack::PopAndDestroy(2); //storedContact, arrayForService
       
   374 			return KErrNone ;	
       
   375 			}
       
   376 		
       
   377 		CleanupStack::PopAndDestroy(2); //storedContact, arrayForService
       
   378 		}	
       
   379 	delete contact;
       
   380 	return KErrGeneral;	
       
   381 	}
       
   382 	
       
   383 	
       
   384 TInt Cvimpststorage_test::CVIMPSTStorageContactTestCase7L()
       
   385 	{
       
   386 	_LIT(KTestCaseUserId, "testUser");									
       
   387 	CVIMPSTStorageContact* contact = CVIMPSTStorageContact::NewL( NULL,
       
   388                                  NULL,
       
   389                                  NULL,                                 
       
   390                                  NULL,                                                                  
       
   391                                  NULL);
       
   392 
       
   393 	if (contact)
       
   394 		{
       
   395 		contact->SetUserIdL(KTestCaseUserId());
       
   396 		
       
   397 		if (0 == KTestCaseUserId().Compare(contact->UserId()))
       
   398 			{
       
   399 			delete contact;
       
   400 			return KErrNone;	
       
   401 			}
       
   402 		}	
       
   403 	
       
   404 	delete contact;
       
   405 	return KErrGeneral;	
       
   406 	}			
       
   407 	
       
   408 
       
   409 TInt Cvimpststorage_test::CVIMPSTStorageContactTestCase8L()
       
   410 	{
       
   411 	_LIT(KTestCaseUserId, "testUser");									
       
   412 	
       
   413 	iObserverReceivedNotification = EFalse;
       
   414 	
       
   415 	CVIMPSTStorageContact* contact = CVIMPSTStorageContact::NewL( this,
       
   416                                  NULL,
       
   417                                  NULL,                                 
       
   418                                  NULL,                                                                  
       
   419                                  NULL);
       
   420 
       
   421 	if (contact)
       
   422 		{
       
   423 		//Initial Presence
       
   424 		if (TVIMPSTEnums::EOffline != contact->OnlineStatus())
       
   425 			{
       
   426 			delete contact;
       
   427 			return KErrGeneral;	
       
   428 			}
       
   429 		
       
   430 		contact->SignalChanges();
       
   431 		//Set the presence
       
   432 		contact->SetOnlineStatus(TVIMPSTEnums::EOnline);
       
   433 		if (TVIMPSTEnums::EOnline != contact->OnlineStatus())
       
   434 			{
       
   435 			delete contact;								
       
   436 			return KErrGeneral;	
       
   437 			}	
       
   438 		contact->SignalChanges();
       
   439 		contact->SetOnlineStatus(TVIMPSTEnums::EOnline);
       
   440 		if (TVIMPSTEnums::EOnline != contact->OnlineStatus())
       
   441 			{
       
   442 			delete contact;			
       
   443 			return KErrGeneral;	
       
   444 			}	
       
   445 		
       
   446 		contact->SignalChanges();
       
   447 		delete contact;
       
   448 		
       
   449 		if (!iObserverReceivedNotification)
       
   450 			{
       
   451 			return KErrGeneral;		
       
   452 			}
       
   453 
       
   454 		return KErrNone;
       
   455 		}	
       
   456 	
       
   457 	delete contact;
       
   458 	return KErrGeneral;	
       
   459 	}		
       
   460 
       
   461 TInt Cvimpststorage_test::CVIMPSTStorageContactTestCase9L()
       
   462 	{
       
   463 	_LIT(KTestCaseStatusTestId, "status");									
       
   464 	CVIMPSTStorageContact* contact = CVIMPSTStorageContact::NewL( NULL,
       
   465                                  NULL,
       
   466                                  NULL,                                 
       
   467                                  NULL,                                                                  
       
   468                                  NULL);
       
   469 
       
   470 	if (contact)
       
   471 		{
       
   472 		if (contact->StatusText().Length())
       
   473 			{
       
   474 			delete contact;
       
   475 			return KErrGeneral;	
       
   476 			}
       
   477 		
       
   478 		contact->SetStatusTextL(KTestCaseStatusTestId());
       
   479 		
       
   480 		if (0 == KTestCaseStatusTestId().Compare(contact->StatusText()))
       
   481 			{
       
   482 			delete contact;
       
   483 			return KErrNone;	
       
   484 			}
       
   485 		}	
       
   486 	
       
   487 	delete contact;
       
   488 	return KErrGeneral;	
       
   489 	}			
       
   490 
       
   491 
       
   492 TInt Cvimpststorage_test::CVIMPSTStorageContactTestCase10L()
       
   493 	{
       
   494 	_LIT8(KTestCaseAvatarId, "avatar");	
       
   495 	iObserverReceivedNotification = EFalse;								
       
   496 	CVIMPSTStorageContact* contact = CVIMPSTStorageContact::NewL( this,
       
   497 	                             NULL,
       
   498 	                             NULL,                                 
       
   499 	                             NULL,                                                                  
       
   500 	                             NULL);
       
   501 
       
   502 	if (contact)
       
   503 		{
       
   504 		if (!contact->AvatarContent().Length())
       
   505 			{
       
   506 			
       
   507 			contact->SetAvatarIndex(3);
       
   508 			
       
   509 			if (3 == contact->AvatarIndex())
       
   510 				{
       
   511 				contact->iAvatarContent = KTestCaseAvatarId().AllocL();
       
   512 				if (0 == KTestCaseAvatarId().Compare(contact->AvatarContent()))
       
   513 					{
       
   514 					contact->SignalAvatarChange();
       
   515 					if (iObserverReceivedNotification)
       
   516 						{
       
   517 						delete contact;
       
   518 						return KErrNone;					
       
   519 						}
       
   520 					}
       
   521 				}
       
   522 			}
       
   523 		}
       
   524 		
       
   525 	delete contact;
       
   526 	return KErrGeneral;		
       
   527 	}
       
   528 
       
   529 TInt Cvimpststorage_test::CVIMPSTStorageContactTestCase11L()
       
   530 	{
       
   531 	iObserverReceivedNotification = EFalse;
       
   532 	CVIMPSTStorageContact* contact = CVIMPSTStorageContact::NewL( this,
       
   533 	                             NULL,
       
   534 	                             NULL,                                 
       
   535 	                             NULL,                                                                  
       
   536 	                             NULL);
       
   537 	CVPbkStoreContactStub* storedContact = new (ELeave) CVPbkStoreContactStub();
       
   538 	CleanupStack::PushL( storedContact );
       
   539 	CVPbkContactOperationBaseStub* operationBaseStub = NULL;
       
   540 	if (contact)
       
   541 		{
       
   542 		TRAPD(err,contact->VPbkSingleContactOperationComplete(*operationBaseStub, storedContact));
       
   543 		
       
   544 		if ((KErrNone == err) && (storedContact==contact->VPbkStoreContact()))
       
   545 			{
       
   546 			CleanupStack::PopAndDestroy(); //storedContact
       
   547 			delete contact;	
       
   548 			return KErrNone;
       
   549 			}
       
   550 		}
       
   551 	CleanupStack::PopAndDestroy(); //storedContact	
       
   552 	delete contact;
       
   553 	return KErrGeneral;		
       
   554 	}
       
   555 
       
   556 
       
   557 TInt Cvimpststorage_test::CVIMPSTStorageContactTestCase12L()
       
   558 	{
       
   559 	iObserverReceivedNotification = EFalse;
       
   560 	CVIMPSTStorageContact* contact = CVIMPSTStorageContact::NewL( this,
       
   561 	                             NULL,
       
   562 	                             NULL,                                 
       
   563 	                             NULL,                                                                  
       
   564 	                             this);
       
   565 	
       
   566 	CVPbkStoreContactStub* storedContact = new (ELeave) CVPbkStoreContactStub();
       
   567 	CleanupStack::PushL( storedContact );
       
   568 		
       
   569 	if (contact)
       
   570 		{
       
   571 		TRAPD(err,contact->DoHandleVPbkSingleContactOperationCompleteL(storedContact));
       
   572 		
       
   573 		if (KErrNone == err)
       
   574 			{
       
   575 			CleanupStack::PopAndDestroy(); //storedContact
       
   576 			delete contact;	
       
   577 			return KErrNone;
       
   578 			}
       
   579 		}
       
   580 	
       
   581 	CleanupStack::PopAndDestroy(); //storedContact	
       
   582 	delete contact;
       
   583 	return KErrGeneral;		
       
   584 	}
       
   585 
       
   586 
       
   587 TInt Cvimpststorage_test::CVIMPSTStorageContactTestCase13L()
       
   588 	{
       
   589 	iObserverReceivedNotification = EFalse;
       
   590 	CVPbkStoreContactStub* storedContact = new (ELeave) CVPbkStoreContactStub();	
       
   591 	CVIMPSTStorageContact* contact = CVIMPSTStorageContact::NewL( this,
       
   592 	                             NULL,
       
   593 	                             storedContact,                                 
       
   594 	                             NULL,                                                                  
       
   595 	                             this);
       
   596 	if (contact)
       
   597 		{
       
   598 		contact->Commit();	
       
   599 		
       
   600 		TContactOpResult opResult;
       
   601 		opResult.iOpCode = EContactCommit;
       
   602 		opResult.iStoreContact = storedContact;
       
   603 		opResult.iExtension = NULL;	
       
   604 		
       
   605 		contact->ContactOperationCompleted(opResult);
       
   606 		
       
   607 		opResult.iOpCode = EContactLock;
       
   608 		contact->ContactOperationCompleted(opResult);		
       
   609 		contact->ContactOperationFailed( 
       
   610     				opResult.iOpCode, KErrArgument, EFalse );
       
   611 		
       
   612 		contact->Commit(this, this);
       
   613 		contact->ContactOperationCompleted(opResult);		
       
   614 		contact->ContactOperationFailed( 
       
   615     				opResult.iOpCode, KErrArgument, EFalse );
       
   616 		
       
   617 		}
       
   618 	
       
   619 	
       
   620 	delete contact;
       
   621 	return KErrNone;		
       
   622 	}
       
   623 
       
   624 
       
   625 
       
   626 TInt Cvimpststorage_test::CVIMPSTStorageContactTestCase14L()
       
   627 	{
       
   628 	iObserverReceivedNotification = EFalse;
       
   629 	CVPbkStoreContactStub* storedContact = new (ELeave) CVPbkStoreContactStub();	
       
   630 	MVPbkContactLink* contactLink = new (ELeave) CVPbkContactLinkStub();
       
   631 	CVPbkContactStoreUriArray* uriArray = CVPbkContactStoreUriArray::NewL();
       
   632 	CVPbkContactManager* contactMgr = CVPbkContactManager::NewL(*uriArray);
       
   633 	CVIMPSTStorageContact* contact = CVIMPSTStorageContact::NewL( this,
       
   634 	                             contactLink,
       
   635 	                             storedContact,                                 
       
   636 	                             contactMgr,                                                                  
       
   637 	                             this);
       
   638 	if (contact)
       
   639 		{
       
   640 		contact->Commit();	
       
   641 		
       
   642 		TContactOpResult opResult;
       
   643 		opResult.iOpCode = EContactCommit;
       
   644 		opResult.iStoreContact = storedContact;
       
   645 		opResult.iExtension = NULL;	
       
   646 		
       
   647 		contact->ContactOperationCompleted(opResult);
       
   648 		
       
   649 		opResult.iOpCode = EContactLock;
       
   650 		contact->ContactOperationCompleted(opResult);		
       
   651 		contact->ContactOperationFailed( 
       
   652     				opResult.iOpCode, KErrArgument, EFalse );
       
   653 		
       
   654 		contact->Commit(this, this);
       
   655 		contact->ContactOperationCompleted(opResult);		
       
   656 		contact->ContactOperationFailed( 
       
   657     				opResult.iOpCode, KErrArgument, EFalse );
       
   658 		
       
   659 		}
       
   660 	delete uriArray;
       
   661 	delete contactMgr;	
       
   662 	delete contact;
       
   663 	return KErrNone;		
       
   664 	}
       
   665 	    								
       
   666 
       
   667 TInt Cvimpststorage_test::CVIMPSTStorageContactTestCase15L()
       
   668 	{
       
   669 	
       
   670 	CVPbkStoreContactStub* storedContact = new (ELeave) CVPbkStoreContactStub();	
       
   671 	MVPbkContactLink* contactLink = new (ELeave) CVPbkContactLinkStub();
       
   672 	CVPbkContactStoreUriArray* uriArray = CVPbkContactStoreUriArray::NewL();
       
   673 	CVPbkContactManager* contactMgr = CVPbkContactManager::NewL(*uriArray);
       
   674 	CVIMPSTStorageContact* contact = CVIMPSTStorageContact::NewL( this,
       
   675 	                             contactLink,
       
   676 	                             storedContact,                                 
       
   677 	                             contactMgr,                                                                  
       
   678 	                             this);	
       
   679 	                             
       
   680 	CVPbkContactOperationBaseStub* operationBaseStub = NULL;	                             
       
   681 	if (contact)
       
   682 		{
       
   683 		
       
   684 		contact->VPbkSingleContactOperationFailed(*operationBaseStub, KErrArgument);
       
   685 		
       
   686 		contact->iContactOperationObserver = this;		
       
   687 		
       
   688 		contact->VPbkSingleContactOperationFailed(*gOperationStub, KErrArgument);
       
   689 		
       
   690 		}
       
   691 	delete uriArray;
       
   692 	delete contactMgr;	
       
   693 	delete contact;
       
   694 	return KErrNone;		
       
   695 	}
       
   696  	    								
       
   697 
       
   698 TInt Cvimpststorage_test::CVIMPSTStorageContactListTestCase16L()
       
   699 	{	
       
   700 	_LIT(KContactListId, "listid");
       
   701 	_LIT(KContactListName, "listName");
       
   702 	_LIT(KContactName, "contact");	
       
   703 	_LIT(KContactName1, "contact1");
       
   704 	_LIT(KContactName2, "contact2");
       
   705 	_LIT(KContactName3, "contact3");
       
   706 	_LIT(KContactNotFound, "contactNotFound");	
       
   707 		
       
   708 	CVIMPSTStorageContact* contact = CVIMPSTStorageContact::NewL( NULL,
       
   709 	                             NULL,
       
   710 	                             NULL,                                 
       
   711 	                             NULL,                                                                  
       
   712 	                             NULL);	
       
   713 	contact->SetUserIdL(KContactName());	                             	
       
   714 	
       
   715 	
       
   716 	CVIMPSTStorageContact* contact1 = CVIMPSTStorageContact::NewL( NULL,
       
   717 	                             NULL,
       
   718 	                             NULL,                                 
       
   719 	                             NULL,                                                                  
       
   720 	                             NULL);	
       
   721 	contact1->SetUserIdL(KContactName1());	                             		
       
   722 	
       
   723 	CVIMPSTStorageContact* contact2 = CVIMPSTStorageContact::NewL( NULL,
       
   724 	                             NULL,
       
   725 	                             NULL,                                 
       
   726 	                             NULL,                                                                  
       
   727 	                             NULL);	
       
   728 	contact2->SetUserIdL(KContactName2());	                             		                             
       
   729 	
       
   730 	CVIMPSTStorageContactSorter* sorter = CVIMPSTStorageContactSorter::NewL() ;
       
   731 	CleanupStack::PushL(sorter);
       
   732 	
       
   733 	sorter->SetSortAlgorithm(MVIMPSTStorageContact::ECompareAlphabetically);
       
   734 	CVIMPSTStorageContactList* list = CVIMPSTStorageContactList::NewL( *this,
       
   735                                       *sorter,
       
   736                                       KContactListId(), 
       
   737                                       KContactListName() );	                                                     	                             
       
   738 	if (list)
       
   739 		{
       
   740 		MVIMPSTStorageContact* cnt = NULL;		
       
   741 		cnt = list->AddContactL(contact);
       
   742 		if (cnt)
       
   743 			{			
       
   744 			//add same contact 
       
   745 			cnt = list->AddContactL(contact)	;				
       
   746 			if (cnt == contact)
       
   747 				{
       
   748 				cnt = list->AddContactL(contact1);					
       
   749 				cnt = list->AddContactL(contact2);									
       
   750 				
       
   751 				//search for contacts based on Id
       
   752 				cnt = list->FindContact(KContactName());
       
   753 				MVIMPSTStorageContact* cnt1(list->FindContact(KContactName1()));
       
   754 				MVIMPSTStorageContact* cnt2(list->FindContact(KContactName2()));
       
   755 				MVIMPSTStorageContact* cnt3(list->FindContact(KContactNotFound()));
       
   756 				
       
   757 				sorter->SetSortAlgorithm(MVIMPSTStorageContact::ECompareByPresence);
       
   758 				
       
   759 				if ( (cnt == contact) && 
       
   760 					(cnt1 == contact1) &&
       
   761 					(cnt2 == contact2) &&
       
   762 					(NULL == cnt3) )
       
   763 					{
       
   764 					TInt err = list->RemoveContact(KContactNotFound());
       
   765 					TInt err1 = list->RemoveContact(KContactName2());
       
   766 					TInt err2 = list->RemoveContact(KContactName1());
       
   767 					TInt err3 = list->RemoveContact(KContactName());
       
   768 					
       
   769 					if ( (KErrNotFound == err) &&
       
   770 						(KErrNone == err1) &&
       
   771 						(KErrNone == err2) &&
       
   772 						(KErrNone == err3)
       
   773 						)
       
   774 						{
       
   775 						delete list;
       
   776 						CleanupStack::PopAndDestroy(1);	
       
   777 						return KErrNone;						
       
   778 						}
       
   779 											
       
   780 					}
       
   781 				}
       
   782 			
       
   783 			}
       
   784 		}
       
   785 	CleanupStack::PopAndDestroy(1);	
       
   786 	return KErrGeneral;		
       
   787 	}
       
   788 	
       
   789 	
       
   790 TInt Cvimpststorage_test::CVIMPSTStorageContactListTestCase17L()
       
   791 	{	
       
   792 	_LIT(KContactListId, "listid");
       
   793 	_LIT(KContactListName, "listName");
       
   794 	_LIT(KContactName, "contact");	
       
   795 	_LIT(KContactName1, "contact1");
       
   796 	_LIT(KContactName2, "contact2");
       
   797 	_LIT(KContactName3, "contact3");
       
   798 	_LIT(KContactNotFound, "contactNotFound");
       
   799 	
       
   800 	MVPbkContactLink* contactLink = new (ELeave) CVPbkContactLinkStub();	
       
   801 	CVIMPSTStorageContact* contact = CVIMPSTStorageContact::NewL( NULL,
       
   802 	                             contactLink,
       
   803 	                             NULL,                                 
       
   804 	                             NULL,                                                                  
       
   805 	                             NULL);	
       
   806 	contact->SetUserIdL(KContactName());	                             	
       
   807 	
       
   808 	MVPbkContactLink* contactLink1 = new (ELeave) CVPbkContactLinkStub();	
       
   809 	CVIMPSTStorageContact* contact1 = CVIMPSTStorageContact::NewL( NULL,
       
   810 	                             contactLink1,
       
   811 	                             NULL,                                 
       
   812 	                             NULL,                                                                  
       
   813 	                             NULL);	
       
   814 	contact1->SetUserIdL(KContactName1());	                             	
       
   815 	
       
   816 	MVPbkContactLink* contactLink2 = new (ELeave) CVPbkContactLinkStub();	
       
   817 	CVIMPSTStorageContact* contact2 = CVIMPSTStorageContact::NewL( NULL,
       
   818 	                             contactLink2,
       
   819 	                             NULL,                                 
       
   820 	                             NULL,                                                                  
       
   821 	                             NULL);	
       
   822 	contact2->SetUserIdL(KContactName2());	                             		                             
       
   823 	
       
   824 	CVIMPSTStorageContactSorter* sorter = CVIMPSTStorageContactSorter::NewL() ;
       
   825 	CleanupStack::PushL(sorter);
       
   826 	
       
   827 	MVPbkContactLink* contactLinkNotFound = new (ELeave) CVPbkContactLinkStub();
       
   828 	
       
   829 	CVIMPSTStorageContactList* list = CVIMPSTStorageContactList::NewL( *this,
       
   830                                       *sorter,
       
   831                                       KContactListId(), 
       
   832                                       KContactListName() );	                                                     	                             
       
   833 	if (list)
       
   834 		{
       
   835 		MVIMPSTStorageContact* cnt = NULL;		
       
   836 		cnt = list->AddContactL(contact);
       
   837 		if (cnt)
       
   838 			{			
       
   839 			//add same contact 
       
   840 			cnt = list->AddContactL(contact)	;				
       
   841 			if (cnt == contact)
       
   842 				{
       
   843 				cnt = list->AddContactL(contact1);					
       
   844 				cnt = list->AddContactL(contact2);									
       
   845 				
       
   846 				//search for contacts based on Id
       
   847 				cnt = list->FindContact(*contactLink);
       
   848 				MVIMPSTStorageContact* cnt1(list->FindContact(*contactLink1));
       
   849 				MVIMPSTStorageContact* cnt2(list->FindContact(*contactLink2));
       
   850 				MVIMPSTStorageContact* cnt3(list->FindContact(*contactLinkNotFound));
       
   851 				
       
   852 				if ( (cnt == contact) && 
       
   853 					(cnt1 == contact1) &&
       
   854 					(cnt2 == contact2) &&
       
   855 					(NULL == cnt3) )
       
   856 					{
       
   857 					TInt err = list->RemoveContact(*contactLinkNotFound);
       
   858 					TInt err1 = list->RemoveContact(*contactLink2);
       
   859 					TInt err2 = list->RemoveContact(*contactLink1);
       
   860 					TInt err3 = list->RemoveContact(*contactLink);
       
   861 					
       
   862 					if ( (KErrNotFound == err) &&
       
   863 						(KErrNone == err1) &&
       
   864 						(KErrNone == err2) &&
       
   865 						(KErrNone == err3)
       
   866 						)
       
   867 						{
       
   868 						delete list;
       
   869 						CleanupStack::PopAndDestroy(1);	
       
   870 						return KErrNone;						
       
   871 						}
       
   872 											
       
   873 					}
       
   874 				}
       
   875 			
       
   876 			}
       
   877 		}
       
   878 	CleanupStack::PopAndDestroy(1);	
       
   879 	return KErrGeneral;		
       
   880 	}	
       
   881 
       
   882 
       
   883 TInt Cvimpststorage_test::CVIMPSTStorageContactListTestCase18L()
       
   884 	{	
       
   885 	_LIT(KContactListId, "listid");
       
   886 	_LIT(KContactListName, "listName");
       
   887 	_LIT(KContactName, "contact");	
       
   888 	_LIT(KContactName1, "contact1");
       
   889 	_LIT(KContactName2, "contact2");
       
   890 	_LIT(KContactName3, "contact3");
       
   891 	_LIT(KContactNotFound, "contactNotFound");
       
   892 	
       
   893 	MVPbkContactLink* contactLink = new (ELeave) CVPbkContactLinkStub();	
       
   894 	CVIMPSTStorageContact* contact = CVIMPSTStorageContact::NewL( NULL,
       
   895 	                             contactLink,
       
   896 	                             NULL,                                 
       
   897 	                             NULL,                                                                  
       
   898 	                             NULL);		
       
   899 	
       
   900 	CVIMPSTStorageContactSorter* sorter = CVIMPSTStorageContactSorter::NewL() ;
       
   901 	CleanupStack::PushL(sorter);
       
   902 	
       
   903 	MVPbkContactLink* contactLinkNotFound = new (ELeave) CVPbkContactLinkStub();
       
   904 	
       
   905 	CVIMPSTStorageContactList* list = CVIMPSTStorageContactList::NewL( *this,
       
   906                                       *sorter,
       
   907                                       KContactListId(), 
       
   908                                       KContactListName() );	                                                     	                             
       
   909 	if (list)
       
   910 		{
       
   911 		MVIMPSTStorageContact* cnt = NULL;		
       
   912 		cnt = list->AddContactL(contact);
       
   913 		if (cnt)
       
   914 			{			
       
   915 			//Pop the contact 
       
   916 			cnt = list->PopContact(*contactLink)	;				
       
   917 			if (cnt == contact)
       
   918 				{								
       
   919 				MVIMPSTStorageContact* cnt3(list->PopContact(*contactLinkNotFound));
       
   920 				
       
   921 				if ( (cnt == contact) && 					
       
   922 					(NULL == cnt3) )
       
   923 					{
       
   924 					delete list;
       
   925 					delete contact;
       
   926 					CleanupStack::PopAndDestroy(1);
       
   927 					return KErrNone;																	
       
   928 					}
       
   929 				}
       
   930 			
       
   931 			}
       
   932 		}
       
   933 	CleanupStack::PopAndDestroy(1);	
       
   934 	return KErrGeneral;		
       
   935 	}
       
   936 	
       
   937 	
       
   938 TInt Cvimpststorage_test::CVIMPSTStorageContactListTestCase19L()
       
   939 	{	
       
   940 	_LIT(KContactListId, "listid");
       
   941 	_LIT(KContactListName, "listName");
       
   942 	_LIT(KContactName, "contact");	
       
   943 	_LIT(KContactName1, "contact1");
       
   944 	_LIT(KContactName2, "contact2");
       
   945 	_LIT(KContactName3, "contact3");
       
   946 	_LIT(KContactNotFound, "contactNotFound");
       
   947 	
       
   948 	MVPbkContactLink* contactLink = new (ELeave) CVPbkContactLinkStub();	
       
   949 	CVIMPSTStorageContact* contact = CVIMPSTStorageContact::NewL( NULL,
       
   950 	                             contactLink,
       
   951 	                             NULL,                                 
       
   952 	                             NULL,                                                                  
       
   953 	                             NULL);	
       
   954 	contact->SetUserIdL(KContactName());	                             	
       
   955 	contact->SetOnlineStatus(TVIMPSTEnums::EOnline);
       
   956 	
       
   957 	MVPbkContactLink* contactLink1 = new (ELeave) CVPbkContactLinkStub();	
       
   958 	CVIMPSTStorageContact* contact1 = CVIMPSTStorageContact::NewL( NULL,
       
   959 	                             contactLink1,
       
   960 	                             NULL,                                 
       
   961 	                             NULL,                                                                  
       
   962 	                             NULL);	
       
   963 	contact1->SetUserIdL(KContactName1());	                             	
       
   964 	contact1->SetOnlineStatus(TVIMPSTEnums::EOffline);
       
   965 	
       
   966 	MVPbkContactLink* contactLink2 = new (ELeave) CVPbkContactLinkStub();	
       
   967 	CVIMPSTStorageContact* contact2 = CVIMPSTStorageContact::NewL( NULL,
       
   968 	                             contactLink2,
       
   969 	                             NULL,                                 
       
   970 	                             NULL,                                                                  
       
   971 	                             NULL);	
       
   972 	contact2->SetUserIdL(KContactName2());	                             		                             
       
   973 	contact2->SetOnlineStatus(TVIMPSTEnums::EBusy);
       
   974 	
       
   975 	MVPbkContactLink* contactLink3 = new (ELeave) CVPbkContactLinkStub();	
       
   976 	CVIMPSTStorageContact* contact3 = CVIMPSTStorageContact::NewL( NULL,
       
   977 	                             contactLink3,
       
   978 	                             NULL,                                 
       
   979 	                             NULL,                                                                  
       
   980 	                             NULL);	
       
   981 	contact3->SetUserIdL(KContactName3());	                             		                             
       
   982 	contact3->SetOnlineStatus(TVIMPSTEnums::EAway);
       
   983 	
       
   984 	CVIMPSTStorageContactSorter* sorter = CVIMPSTStorageContactSorter::NewL() ;
       
   985 	CleanupStack::PushL(sorter);
       
   986 	
       
   987 	MVPbkContactLink* contactLinkNotFound = new (ELeave) CVPbkContactLinkStub();
       
   988 	
       
   989 	CVIMPSTStorageContactList* list = CVIMPSTStorageContactList::NewL( *this,
       
   990                                       *sorter,
       
   991                                       KContactListId(), 
       
   992                                       KContactListName() );	                                                     	                             
       
   993 	if (list)
       
   994 		{
       
   995 			
       
   996 		list->AddContactL(contact);
       
   997 		list->AddContactL(contact1);
       
   998 		list->AddContactL(contact2);
       
   999 		list->AddContactL(contact3);;
       
  1000 		
       
  1001 		MVIMPSTStorageContact* test = &list->operator[](0);
       
  1002 		if ( test && list->Count() == 4)
       
  1003 			{
       
  1004 			if (list->OnlineCount() == 3)					
       
  1005 				{
       
  1006 				delete list;
       
  1007 				CleanupStack::PopAndDestroy(1);
       
  1008 				return KErrNone;					
       
  1009 				}
       
  1010 			}
       
  1011 		}
       
  1012 	CleanupStack::PopAndDestroy(1);	
       
  1013 	return KErrGeneral;		
       
  1014 	}	
       
  1015 
       
  1016 
       
  1017 TInt Cvimpststorage_test::CVIMPSTStorageContactListTestCase20L()
       
  1018 	{	
       
  1019 	_LIT(KContactListId, "listid");
       
  1020 	_LIT(KContactListName, "listName");
       
  1021 	_LIT(KTestCase20ListId, "meco");
       
  1022 	_LIT(KTestCase20ListName, "Meco display");
       
  1023 	CVIMPSTStorageContactSorter* sorter = CVIMPSTStorageContactSorter::NewL() ;
       
  1024 	CleanupStack::PushL(sorter);
       
  1025 	
       
  1026 	CVIMPSTStorageContactList* list = CVIMPSTStorageContactList::NewL( *this,
       
  1027                                       *sorter,
       
  1028                                       KContactListId(), 
       
  1029                                       KContactListName() );	                                                     	                             
       
  1030 	if (list)
       
  1031 		{
       
  1032 		
       
  1033 		if (0 == KContactListId().Compare(list->ListId()))
       
  1034 			{
       
  1035 			if (0 == KContactListName().Compare(list->DisplayName()))
       
  1036 				{
       
  1037 				
       
  1038 				list->SetDisplayNameL(KTestCase20ListName());
       
  1039 				list->SetListIdL(KTestCase20ListId());
       
  1040 				
       
  1041 				if ( (0 == KTestCase20ListId().Compare(list->ListId())) &&
       
  1042 					(0 == KTestCase20ListName().Compare(list->DisplayName())) )
       
  1043 					{
       
  1044 					CleanupStack::PopAndDestroy(1);	
       
  1045 					delete list;
       
  1046 					return KErrNone;						
       
  1047 					}
       
  1048 				}
       
  1049 			}
       
  1050 		}
       
  1051 	CleanupStack::PopAndDestroy(1);	
       
  1052 	return KErrGeneral;		
       
  1053 	}
       
  1054 
       
  1055 
       
  1056 TInt Cvimpststorage_test::CVIMPSTStorageContactListTestCase21L()
       
  1057 	{	
       
  1058 	_LIT(KContactListId, "listid");
       
  1059 	_LIT(KContactListName, "listName");
       
  1060 	_LIT(KContactName, "contact");	
       
  1061 	_LIT(KContactName1, "contact1");
       
  1062 	_LIT(KContactName2, "contact2");
       
  1063 	_LIT(KContactName3, "contact3");
       
  1064 	_LIT(KContactNotFound, "contactNotFound");
       
  1065 	
       
  1066 	MVPbkContactLink* contactLink = new (ELeave) CVPbkContactLinkStub();	
       
  1067 	CVIMPSTStorageContact* contact = CVIMPSTStorageContact::NewL( NULL,
       
  1068 	                             contactLink,
       
  1069 	                             NULL,                                 
       
  1070 	                             NULL,                                                                  
       
  1071 	                             NULL);	
       
  1072 	contact->SetUserIdL(KContactName());	                             	
       
  1073 	contact->SetOnlineStatus(TVIMPSTEnums::EOnline);
       
  1074 	
       
  1075 	MVPbkContactLink* contactLink1 = new (ELeave) CVPbkContactLinkStub();	
       
  1076 	CVIMPSTStorageContact* contact1 = CVIMPSTStorageContact::NewL( NULL,
       
  1077 	                             contactLink1,
       
  1078 	                             NULL,                                 
       
  1079 	                             NULL,                                                                  
       
  1080 	                             NULL);	
       
  1081 	contact1->SetUserIdL(KContactName1());	                             	
       
  1082 	contact1->SetOnlineStatus(TVIMPSTEnums::EOffline);
       
  1083 	
       
  1084 	MVPbkContactLink* contactLink2 = new (ELeave) CVPbkContactLinkStub();	
       
  1085 	CVIMPSTStorageContact* contact2 = CVIMPSTStorageContact::NewL( NULL,
       
  1086 	                             contactLink2,
       
  1087 	                             NULL,                                 
       
  1088 	                             NULL,                                                                  
       
  1089 	                             NULL);	
       
  1090 	contact2->SetUserIdL(KContactName2());	                             		                             
       
  1091 	contact2->SetOnlineStatus(TVIMPSTEnums::EBusy);
       
  1092 	
       
  1093 	MVPbkContactLink* contactLink3 = new (ELeave) CVPbkContactLinkStub();	
       
  1094 	CVIMPSTStorageContact* contact3 = CVIMPSTStorageContact::NewL( NULL,
       
  1095 	                             contactLink3,
       
  1096 	                             NULL,                                 
       
  1097 	                             NULL,                                                                  
       
  1098 	                             NULL);	
       
  1099 	contact3->SetUserIdL(KContactName3());	                             		                             
       
  1100 	contact3->SetOnlineStatus(TVIMPSTEnums::EAway);
       
  1101 	
       
  1102 	CVIMPSTStorageContactSorter* sorter = CVIMPSTStorageContactSorter::NewL() ;
       
  1103 	CleanupStack::PushL(sorter);
       
  1104 	
       
  1105 	MVPbkContactLink* contactLinkNotFound = new (ELeave) CVPbkContactLinkStub();
       
  1106 	
       
  1107 	CVIMPSTStorageContactList* list = CVIMPSTStorageContactList::NewL( *this,
       
  1108                                       *sorter,
       
  1109                                       KContactListId(), 
       
  1110                                       KContactListName() );	                                                     	                             
       
  1111 	if (list)
       
  1112 		{
       
  1113 			
       
  1114 		list->AddContactL(contact);
       
  1115 		list->AddContactL(contact1);
       
  1116 		list->AddContactL(contact2);	
       
  1117 		
       
  1118 		list->Sort();
       
  1119 		contact1->SetOnlineStatus(TVIMPSTEnums::EOnline);
       
  1120 		list->ResortContact(contact1);	
       
  1121 		contact1->SetOnlineStatus(TVIMPSTEnums::EAway);	
       
  1122 		list->ResortUnKnownContact(contact1);
       
  1123 		
       
  1124 		MVIMPSTStorageContact* cnt = &(list->OnlineContact( 1 ));
       
  1125 		TInt index = list->FindIndexOfContact( cnt, TVIMPSTEnums::EFilterAll );
       
  1126 				
       
  1127 		if (index == 1)
       
  1128 			{
       
  1129 			delete list;		
       
  1130 			CleanupStack::PopAndDestroy(1);	
       
  1131 			return KErrNone;				
       
  1132 			}
       
  1133 		}
       
  1134 	delete list;		
       
  1135 	CleanupStack::PopAndDestroy(1);	
       
  1136 	return KErrGeneral;		
       
  1137 	}	
       
  1138 
       
  1139 
       
  1140 
       
  1141 TInt Cvimpststorage_test::CVIMPSTStorageXSPStoreHandlerTestCase01L()
       
  1142 	{	
       
  1143 	_LIT(KStoreName, "MecoStore");
       
  1144 	_LIT(KServiceName, "MecoService");
       
  1145 	
       
  1146 	CVIMPSTStorageViewId* store = CVIMPSTStorageViewId::NewL(1,
       
  1147 										KStoreName(),
       
  1148 										KServiceName());
       
  1149 	//Create XSP Store Handler
       
  1150     CVIMPSTStorageVPbkStoreHandler*	contactStoreHandler = 
       
  1151     			CVIMPSTStorageVPbkStoreHandler::NewL(
       
  1152     						KStoreName(), KIMContactListId, 1, KServiceName(),
       
  1153     						*store);
       
  1154                                                	                             
       
  1155 	if (contactStoreHandler)
       
  1156 		{
       
  1157 		
       
  1158 		delete contactStoreHandler;
       
  1159 		delete store;
       
  1160 		return KErrNone;
       
  1161 		}
       
  1162 	delete contactStoreHandler;		
       
  1163 	delete store;
       
  1164 	return KErrGeneral;		
       
  1165 	}	
       
  1166 
       
  1167 
       
  1168 
       
  1169 	    								
       
  1170 /**
       
  1171  * Called when all the contacts are fetched
       
  1172  */
       
  1173 void Cvimpststorage_test::HandleContactAddedL(RPointerArray<HBufC>& /*aServiceDetails*/)
       
  1174 	{
       
  1175 		
       
  1176 	}
       
  1177 
       
  1178 /**
       
  1179  * Called when all the contacts are fetched
       
  1180  */
       
  1181 void Cvimpststorage_test::HandleContactDeletedL(RPointerArray<HBufC>& /*aServiceDetails*/)
       
  1182 	{
       
  1183 		
       
  1184 	}
       
  1185 
       
  1186 
       
  1187 
       
  1188 void Cvimpststorage_test::HandleContactOperationCompleteL( MVIMPSTStorageContact& /*aContact*/, TInt /*aError = KErrNone*/ )
       
  1189 	{
       
  1190 		
       
  1191 	}
       
  1192 				
       
  1193 /**
       
  1194  * From  MVPbkContactObserver
       
  1195  */
       
  1196 void Cvimpststorage_test::ContactOperationCompleted(TContactOpResult /*aResult*/)
       
  1197 	{
       
  1198 		
       
  1199 	}
       
  1200 
       
  1201 /**
       
  1202  * From MVPbkContactObserver
       
  1203  */
       
  1204 void Cvimpststorage_test::ContactOperationFailed
       
  1205     (TContactOp /*aOpCode*/, TInt /*aErrorCode*/, TBool /*aErrorNotified*/)
       
  1206     {
       
  1207     	
       
  1208     }
       
  1209 
       
  1210 		
       
  1211 		
       
  1212 //  [End of File] - Do not remove
       
  1213 
       
  1214 
       
  1215