phonebookengines/contactsmodel/tsrc/t_cntvcard.cpp
changeset 37 fd64c38c277d
parent 24 0ba2181d7c28
equal deleted inserted replaced
31:2a11b5b00470 37:fd64c38c277d
    28 #include <cntfldst.h>
    28 #include <cntfldst.h>
    29 #include <e32def.h>
    29 #include <e32def.h>
    30 #include "t_utils2.h"
    30 #include "t_utils2.h"
    31 #include "t_rndutils.h"
    31 #include "t_rndutils.h"
    32 #include <coreappstest/testserver.h>
    32 #include <coreappstest/testserver.h>
       
    33 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
       
    34 #include "cntdb_internal.h"
       
    35 #endif
    33 
    36 
    34 _LIT(KTestName,"T_CNTVCARD");
    37 _LIT(KTestName,"T_CNTVCARD");
    35 
    38 
    36 
    39 
    37 
    40 
   105 							);
   108 							);
   106 
   109 
   107 _LIT8(KMultiParam,"BEGIN:VCARD\r\n"
   110 _LIT8(KMultiParam,"BEGIN:VCARD\r\n"
   108 				"VERSION:2.1\r\n"
   111 				"VERSION:2.1\r\n"
   109 				"N:;Neo;;Mr.;\r\n"
   112 				"N:;Neo;;Mr.;\r\n"
   110 				"FN:Mr. Anderson\r\n"
   113 				"FN:Mr. TestName\r\n"
   111 				"TEL;TYPE=HOME;TYPE=VOICE;TYPE=CELL:123\r\n"
   114 				"TEL;TYPE=HOME;TYPE=VOICE;TYPE=CELL:123\r\n"
   112 				"END:VCARD\r\n"
   115 				"END:VCARD\r\n"
   113 				);
   116 				);
   114 _LIT8(KTelExport, "TEL;HOME;VOICE;CELL:123\r\n");
   117 _LIT8(KTelExport, "TEL;HOME;VOICE;CELL:123\r\n");
   115 
   118 
   226 					"REV:20060821T131829Z\r\n"
   229 					"REV:20060821T131829Z\r\n"
   227 					"UID:f356da00bfd5320f-00e0f93a015eb46d-20\r\n"
   230 					"UID:f356da00bfd5320f-00e0f93a015eb46d-20\r\n"
   228 					"N:Cccc;Pekka;;;\r\n"
   231 					"N:Cccc;Pekka;;;\r\n"
   229 					"END:VCARD\r\n"
   232 					"END:VCARD\r\n"
   230 );
   233 );
       
   234  
       
   235 _LIT8(KPartialVCard,"BEGIN:VCARD\r\n"
       
   236         "\r"
       
   237 );
       
   238 
   231 const TAny* GNames[]  = {&KFirstName, &KFirstNamePrn, &KSurName, &KSurNamePrn, &KOrgName, &KOrgNamePrn};
   239 const TAny* GNames[]  = {&KFirstName, &KFirstNamePrn, &KSurName, &KSurNamePrn, &KOrgName, &KOrgNamePrn};
   232 const TAny* GLabels[]  = {&KFirstNameLabel, &KFirstNamePrnLabel, &KSurNameLabel, &KSurNamePrnLabel, &KOrgNameLabel, &KOrgNamePrnLabel};
   240 const TAny* GLabels[]  = {&KFirstNameLabel, &KFirstNamePrnLabel, &KSurNameLabel, &KSurNamePrnLabel, &KOrgNameLabel, &KOrgNamePrnLabel};
   233 
   241 
   234 const TInt KNumberOfExtendedFieldNames=6;
   242 const TInt KNumberOfExtendedFieldNames=6;
   235 
   243 
   801 	CleanupStack::PopAndDestroy(TheIds); 
   809 	CleanupStack::PopAndDestroy(TheIds); 
   802 	test.Next(_L("Emptying database"));
   810 	test.Next(_L("Emptying database"));
   803 	EmptyDatabase();
   811 	EmptyDatabase();
   804 	}
   812 	}
   805 
   813 
   806 ///////////////////////////////////////////////////////////////////////////////
   814 //
   807 /* Test Function Implementations                                             */
   815 /* Test Function Implementations                                             */
   808 ///////////////////////////////////////////////////////////////////////////////
   816 //
   809 TContactItemId AddContactL (CContactDatabase& aDatabase)
   817 TContactItemId AddContactL (CContactDatabase& aDatabase)
   810 	{
   818 	{
   811 	TInt bit = 0;
   819 	TInt bit = 0;
   812 	TContactItemId retval;
   820 	TContactItemId retval;
   813 	CRandomContactGenerator* generator = NULL;
   821 	CRandomContactGenerator* generator = NULL;
  1088 	//Use the same contact id as before
  1096 	//Use the same contact id as before
  1089 	CContactItem* updatedContact = CntTest->Db()->ReadContactLC(contactId);
  1097 	CContactItem* updatedContact = CntTest->Db()->ReadContactLC(contactId);
  1090 	CContactItemFieldSet& updatedContactFieldSet = updatedContact->CardFields();
  1098 	CContactItemFieldSet& updatedContactFieldSet = updatedContact->CardFields();
  1091 
  1099 
  1092 	test.Next(_L("Check Updated Mobile Number 1"));
  1100 	test.Next(_L("Check Updated Mobile Number 1"));
  1093 	TEST_CONDITION(FieldCheck(updatedContactFieldSet,5,_L("07905001")));
  1101 	TEST_CONDITION(FieldCheck(updatedContactFieldSet,5,_L("7700900329")));
  1094 		
  1102 		
  1095 	test.Next(_L("Check Updated Mobile Number 2"));
  1103 	test.Next(_L("Check Updated Mobile Number 2"));
  1096 	TEST_CONDITION(FieldCheck(updatedContactFieldSet,6,_L("07906002")));
  1104 	TEST_CONDITION(FieldCheck(updatedContactFieldSet,6,_L("07700900529")));
  1097 
  1105 
  1098 	test.Next(_L("Check Updated Work Number 1"));
  1106 	test.Next(_L("Check Updated Work Number 1"));
  1099 	TEST_CONDITION(FieldCheck(updatedContactFieldSet,29,_L("1234567890")));
  1107 	TEST_CONDITION(FieldCheck(updatedContactFieldSet,29,_L("7700900999")));
  1100 
  1108 
  1101 	test.Next(_L("Check Updated Work Number 2"));
  1109 	test.Next(_L("Check Updated Work Number 2"));
  1102 	TEST_CONDITION(FieldCheck(updatedContactFieldSet,30,_L("2345678901")));
  1110 	TEST_CONDITION(FieldCheck(updatedContactFieldSet,30,_L("7700900888")));
  1103 
  1111 
  1104 	test.Next(_L("Check Updated Work Number 3"));
  1112 	test.Next(_L("Check Updated Work Number 3"));
  1105 	TEST_CONDITION(FieldCheck(updatedContactFieldSet,31,_L("3456789012")));
  1113 	TEST_CONDITION(FieldCheck(updatedContactFieldSet,31,_L("7700900777")));
  1106 
  1114 
  1107 	test.Next(_L("Check Updated Work Number 4"));
  1115 	test.Next(_L("Check Updated Work Number 4"));
  1108 	TEST_CONDITION(FieldCheck(updatedContactFieldSet,32,_L("4567890123")));
  1116 	TEST_CONDITION(FieldCheck(updatedContactFieldSet,32,_L("7700900666")));
  1109 
  1117 
  1110 	test.Next(_L("Check Updated Work Number 5"));
  1118 	test.Next(_L("Check Updated Work Number 5"));
  1111 	TEST_CONDITION(FieldCheck(updatedContactFieldSet,33,_L("5678901234")));
  1119 	TEST_CONDITION(FieldCheck(updatedContactFieldSet,33,_L("7700900555")));
  1112  
  1120  
  1113 	//cleanup
  1121 	//cleanup
  1114 	CleanupStack::PopAndDestroy(updatedContact);
  1122 	CleanupStack::PopAndDestroy(updatedContact);
  1115 	CleanupStack::PopAndDestroy(&readStream);
  1123 	CleanupStack::PopAndDestroy(&readStream);
  1116 	CleanupStack::PopAndDestroy(idArray);
  1124 	CleanupStack::PopAndDestroy(idArray);
  2012 	test.Printf(_L("Export of large binary property completed successfully"));		
  2020 	test.Printf(_L("Export of large binary property completed successfully"));		
  2013 
  2021 
  2014 }
  2022 }
  2015 
  2023 
  2016 /**
  2024 /**
       
  2025 @SYMTestCaseID PIM-T-CNTVCARD-PDEF140328-0001
       
  2026 @SYMTestType UT
       
  2027 @SYMTestPriority High
       
  2028 @SYMTestCaseDesc Partial vCard's should be processed without any panics
       
  2029 
       
  2030 @SYMTestActions
       
  2031 1.Import a partial vCard.
       
  2032 
       
  2033 @SYMTestExpectedResults For the above tests:
       
  2034 1.There should be no panics while import is happening.
       
  2035 */
       
  2036  void TestImportingPartialOrEmptyVCardsL()
       
  2037 {
       
  2038     test.Next(_L("Test import of partial vCard"));
       
  2039     CArrayPtr<CContactItem>* contactItems = NULL;
       
  2040     RDesReadStream vcard(KPartialVCard());
       
  2041     CleanupClosePushL(vcard);
       
  2042     TInt success = EFalse;
       
  2043     CContactDatabase* db = CntTest->CreateDatabaseL();
       
  2044     contactItems = db->ImportContactsL(TUid::Uid(KUidVCardConvDefaultImpl), vcard, success, CContactDatabase::EImportSingleContact);
       
  2045     CleanupStack::PushL( TCleanupItem( CleanUpResetAndDestroy, contactItems ) );
       
  2046     CleanupStack::PopAndDestroy(contactItems);
       
  2047     CleanupStack::PopAndDestroy(&vcard);
       
  2048     test.Printf(_L("Import of partial vCard completed successfully"));
       
  2049 }
       
  2050 
       
  2051 
       
  2052 /**
  2017 
  2053 
  2018 @SYMTestCaseID     PIM-T-CNTVCARD-0001
  2054 @SYMTestCaseID     PIM-T-CNTVCARD-0001
  2019 
  2055 
  2020 */
  2056 */
  2021 
  2057 
  2033 	TempFiles->RegisterL(KImpTypeVcardName);
  2069 	TempFiles->RegisterL(KImpTypeVcardName);
  2034 	TempFiles->RegisterL(KImpNoTypeVcardName);	
  2070 	TempFiles->RegisterL(KImpNoTypeVcardName);	
  2035 	TempFiles->RegisterL(KVCardFile5);
  2071 	TempFiles->RegisterL(KVCardFile5);
  2036 	TempFiles->RegisterL(KVCardFile6);
  2072 	TempFiles->RegisterL(KVCardFile6);
  2037 
  2073 
       
  2074 	//without the fix this test will cause User 21 panic in versit 
       
  2075 	TestImportingPartialOrEmptyVCardsL();
  2038 	VCardEmailTestL();
  2076 	VCardEmailTestL();
  2039 	AccessCountTestsL();			
  2077 	AccessCountTestsL();			
  2040 	DefaultVoiceParamTestsL();
  2078 	DefaultVoiceParamTestsL();
  2041 	ExportContactTestL();
  2079 	ExportContactTestL();
  2042 	ExportNamelessContactTestL();
  2080 	ExportNamelessContactTestL();