phonebookengines/contactsmodel/tsrc/t_cntvcard.cpp
changeset 37 fd64c38c277d
parent 24 0ba2181d7c28
--- a/phonebookengines/contactsmodel/tsrc/t_cntvcard.cpp	Fri May 14 15:42:23 2010 +0300
+++ b/phonebookengines/contactsmodel/tsrc/t_cntvcard.cpp	Thu May 27 12:45:19 2010 +0300
@@ -30,6 +30,9 @@
 #include "t_utils2.h"
 #include "t_rndutils.h"
 #include <coreappstest/testserver.h>
+#ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
+#include "cntdb_internal.h"
+#endif
 
 _LIT(KTestName,"T_CNTVCARD");
 
@@ -107,7 +110,7 @@
 _LIT8(KMultiParam,"BEGIN:VCARD\r\n"
 				"VERSION:2.1\r\n"
 				"N:;Neo;;Mr.;\r\n"
-				"FN:Mr. Anderson\r\n"
+				"FN:Mr. TestName\r\n"
 				"TEL;TYPE=HOME;TYPE=VOICE;TYPE=CELL:123\r\n"
 				"END:VCARD\r\n"
 				);
@@ -228,6 +231,11 @@
 					"N:Cccc;Pekka;;;\r\n"
 					"END:VCARD\r\n"
 );
+ 
+_LIT8(KPartialVCard,"BEGIN:VCARD\r\n"
+        "\r"
+);
+
 const TAny* GNames[]  = {&KFirstName, &KFirstNamePrn, &KSurName, &KSurNamePrn, &KOrgName, &KOrgNamePrn};
 const TAny* GLabels[]  = {&KFirstNameLabel, &KFirstNamePrnLabel, &KSurNameLabel, &KSurNamePrnLabel, &KOrgNameLabel, &KOrgNamePrnLabel};
 
@@ -803,9 +811,9 @@
 	EmptyDatabase();
 	}
 
-///////////////////////////////////////////////////////////////////////////////
+//
 /* Test Function Implementations                                             */
-///////////////////////////////////////////////////////////////////////////////
+//
 TContactItemId AddContactL (CContactDatabase& aDatabase)
 	{
 	TInt bit = 0;
@@ -1090,25 +1098,25 @@
 	CContactItemFieldSet& updatedContactFieldSet = updatedContact->CardFields();
 
 	test.Next(_L("Check Updated Mobile Number 1"));
-	TEST_CONDITION(FieldCheck(updatedContactFieldSet,5,_L("07905001")));
+	TEST_CONDITION(FieldCheck(updatedContactFieldSet,5,_L("7700900329")));
 		
 	test.Next(_L("Check Updated Mobile Number 2"));
-	TEST_CONDITION(FieldCheck(updatedContactFieldSet,6,_L("07906002")));
+	TEST_CONDITION(FieldCheck(updatedContactFieldSet,6,_L("07700900529")));
 
 	test.Next(_L("Check Updated Work Number 1"));
-	TEST_CONDITION(FieldCheck(updatedContactFieldSet,29,_L("1234567890")));
+	TEST_CONDITION(FieldCheck(updatedContactFieldSet,29,_L("7700900999")));
 
 	test.Next(_L("Check Updated Work Number 2"));
-	TEST_CONDITION(FieldCheck(updatedContactFieldSet,30,_L("2345678901")));
+	TEST_CONDITION(FieldCheck(updatedContactFieldSet,30,_L("7700900888")));
 
 	test.Next(_L("Check Updated Work Number 3"));
-	TEST_CONDITION(FieldCheck(updatedContactFieldSet,31,_L("3456789012")));
+	TEST_CONDITION(FieldCheck(updatedContactFieldSet,31,_L("7700900777")));
 
 	test.Next(_L("Check Updated Work Number 4"));
-	TEST_CONDITION(FieldCheck(updatedContactFieldSet,32,_L("4567890123")));
+	TEST_CONDITION(FieldCheck(updatedContactFieldSet,32,_L("7700900666")));
 
 	test.Next(_L("Check Updated Work Number 5"));
-	TEST_CONDITION(FieldCheck(updatedContactFieldSet,33,_L("5678901234")));
+	TEST_CONDITION(FieldCheck(updatedContactFieldSet,33,_L("7700900555")));
  
 	//cleanup
 	CleanupStack::PopAndDestroy(updatedContact);
@@ -2014,6 +2022,34 @@
 }
 
 /**
+@SYMTestCaseID PIM-T-CNTVCARD-PDEF140328-0001
+@SYMTestType UT
+@SYMTestPriority High
+@SYMTestCaseDesc Partial vCard's should be processed without any panics
+
+@SYMTestActions
+1.Import a partial vCard.
+
+@SYMTestExpectedResults For the above tests:
+1.There should be no panics while import is happening.
+*/
+ void TestImportingPartialOrEmptyVCardsL()
+{
+    test.Next(_L("Test import of partial vCard"));
+    CArrayPtr<CContactItem>* contactItems = NULL;
+    RDesReadStream vcard(KPartialVCard());
+    CleanupClosePushL(vcard);
+    TInt success = EFalse;
+    CContactDatabase* db = CntTest->CreateDatabaseL();
+    contactItems = db->ImportContactsL(TUid::Uid(KUidVCardConvDefaultImpl), vcard, success, CContactDatabase::EImportSingleContact);
+    CleanupStack::PushL( TCleanupItem( CleanUpResetAndDestroy, contactItems ) );
+    CleanupStack::PopAndDestroy(contactItems);
+    CleanupStack::PopAndDestroy(&vcard);
+    test.Printf(_L("Import of partial vCard completed successfully"));
+}
+
+
+/**
 
 @SYMTestCaseID     PIM-T-CNTVCARD-0001
 
@@ -2035,6 +2071,8 @@
 	TempFiles->RegisterL(KVCardFile5);
 	TempFiles->RegisterL(KVCardFile6);
 
+	//without the fix this test will cause User 21 panic in versit 
+	TestImportingPartialOrEmptyVCardsL();
 	VCardEmailTestL();
 	AccessCountTestsL();			
 	DefaultVoiceParamTestsL();