phonebookengines_old/contactsmodel/tsrc/t_iccStartup.cpp
changeset 40 b46a585f6909
equal deleted inserted replaced
37:fd64c38c277d 40:b46a585f6909
       
     1 // Copyright (c) 2006-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 test harness simulates aspects of the phbksync test plugin behaviour which
       
    15 // starts up the phbksync server if it is not running. The phbksync server configures itself
       
    16 // and needs to access the contacts DB. Accessing the contacts DB from within the contacts
       
    17 // server can cause deadlocks. The contacts client will load the test plugin and try to access
       
    18 // the contacts DB on first use only, this will avoid the problem of the server being deadlocked.
       
    19 // **This test only works with Contacts the test plugin and not the original phonebooksync plugin.**
       
    20 // winscw - DELETE phbksyncplugin.dll from %epocroot%/epoc32/release/winscw/udeb or similarly named directory
       
    21 // hardware - delete the line \"ECOM_PLUGIN(phbksyncplugin.dll,1020428C.rsc)\" from phbksync.iby
       
    22 // 
       
    23 //
       
    24 
       
    25 #include <e32test.h>
       
    26 #include "T_UTILS.H"
       
    27 #include "./TestSyncPlugIn/cnttestsynchroniser.h"
       
    28 
       
    29 _LIT(KICCStartupTest, "ICC Test plugin startup test");
       
    30 _LIT(KPhoneGroupId, "PhoneGroupId test");
       
    31 _LIT(KICCTemplateId, "ICCTemplateId test");
       
    32 _LIT(KIccStartupDB, "c:IccStartupDB");
       
    33 
       
    34 RTest test(KICCStartupTest);
       
    35 CCntTest* CntTestPtr;
       
    36 CContactSyncChecker* syncChecker;
       
    37 
       
    38 void DoPhoneGroupIdTest()
       
    39     {
       
    40     /*
       
    41 	get contacts database and get the contacts phone group id.
       
    42 	This should load the test plugin, which should make a call back
       
    43 	into the contacts DB
       
    44 	*/
       
    45 	CntTestPtr->CreateDatabaseL();	
       
    46 	CntTestPtr->OpenDatabaseL();
       
    47 	
       
    48 	
       
    49 	CContactDatabase& Db = *CntTestPtr->Db();
       
    50 	
       
    51 	Db.PhonebookGroupIdL(); 
       
    52 	
       
    53 	test (syncChecker->PluginLoadedCountL() == 2); //one for the client & one for server
       
    54 	
       
    55 	CntTestPtr->CloseDatabase();
       
    56 	CntTestPtr->DeleteDatabaseL(); //close & delete database at end of test
       
    57     }
       
    58 
       
    59 void DoICCTemplateIdTest()
       
    60     {
       
    61     /*
       
    62 	get contacts database and get the contacts ICCTemplate id.
       
    63 	This should load the test plugin, which should make a call back
       
    64 	into the contacts DB
       
    65 	*/
       
    66     CntTestPtr->CreateDatabaseL();	
       
    67 	CntTestPtr->OpenDatabaseL();
       
    68 	
       
    69 	
       
    70 	CContactDatabase& Db = *CntTestPtr->Db();
       
    71 	
       
    72 	Db.ICCTemplateIdL(); 
       
    73 	
       
    74 	test (syncChecker->PluginLoadedCountL() == 2); //one for the client & one for server
       
    75 	
       
    76 	CntTestPtr->CloseDatabase();
       
    77 	CntTestPtr->DeleteDatabaseL(); //close & delete database at end of test
       
    78 	
       
    79     }
       
    80 
       
    81 /**
       
    82 
       
    83 @SYMTestCaseID     PIM-T-ICCSTARTUP-0001
       
    84 
       
    85 */
       
    86  
       
    87 void DoTestsL()
       
    88     {
       
    89 	test.Start(_L("@SYMTESTCaseID:PIM-T-ICCSTARTUP-0001 ICC Test plugin startup test"));
       
    90 
       
    91 	syncChecker = new (ELeave) CContactSyncChecker;
       
    92 	syncChecker->ResetEverythingL(); //set the counters to zero
       
    93 	
       
    94 	test.Next(KPhoneGroupId);
       
    95 
       
    96 	DoPhoneGroupIdTest();
       
    97 	
       
    98 	
       
    99 	syncChecker->ResetEverythingL(); //set the counters to zero
       
   100 	test.Next(KICCTemplateId);
       
   101 
       
   102 	DoICCTemplateIdTest();
       
   103 	
       
   104 	
       
   105 	delete syncChecker;
       
   106     syncChecker = NULL;
       
   107 	
       
   108     }
       
   109 
       
   110 
       
   111 /** Standard E32Main method */
       
   112 
       
   113 GLDEF_C TInt E32Main()
       
   114 	{
       
   115 	__UHEAP_MARK;
       
   116 		
       
   117 	CntTestPtr=new(ELeave) CCntTest;
       
   118 	
       
   119 	CntTestPtr->ConstructL(test,KIccStartupDB); //KIccStartupDB defined in cnttestsynchroniser.h
       
   120 	
       
   121     TRAPD(err,DoTestsL()); 
       
   122     
       
   123 	CntTestPtr->EndTestLib(err); // is responsible for deleting the memory for itself 
       
   124 	
       
   125 	__UHEAP_MARKEND;
       
   126 	return KErrNone;
       
   127     }