pimappsupport/vcardandvcal/tsrc/tPerformance.cpp
changeset 0 f979ecb2b13e
equal deleted inserted replaced
-1:000000000000 0:f979ecb2b13e
       
     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 //
       
    15 
       
    16 #define __PROFILING__
       
    17 
       
    18 // System includes
       
    19 #include <e32std.h>
       
    20 #include <e32base.h>
       
    21 #include <e32test.h>
       
    22 #include <s32mem.h>
       
    23 
       
    24 // User includes
       
    25 #include <versit.h>
       
    26 #include <vcal.h>
       
    27 #include <vcard.h>
       
    28 #include <vtoken.h>
       
    29 
       
    30 // Globals
       
    31 _LIT(KTestName,"Performance Test");
       
    32 _LIT(KTestDirInput,"Z:\\TPerFormance\\inputFile\\");
       
    33 _LIT(KTestDirOutput,"c:\\TPerFormance\\outputFile\\");
       
    34 _LIT(KTestDirResult,"c:\\TPerFormance\\resultFile\\");
       
    35 _LIT(KTestFileNameExt,".TXT");
       
    36 
       
    37 _LIT8(KVersitTokenAGENDAENTRYTYPE,		"AGENDAENTRYTYPE");
       
    38 _LIT8(KVersitTokenNICKNAME,				"NICKNAME");
       
    39 _LIT8(KVersitTokenXWABGENDER,				"X-WAB-GENDER");
       
    40 
       
    41 LOCAL_D RTest TheTest(KTestName);
       
    42 
       
    43 class SRHeapCopy 
       
    44 	{// dummy heap which is a copy RHeapCopy butmake iAllocCount public
       
    45 public:
       
    46 	//enum TAllocFail {ERandom,ETrueRandom,EDeterministic,ENone,EFailNext};
       
    47 public:
       
    48 	TBool iTestCodeRunning;	
       
    49 	TInt iTestNestingLevel;
       
    50 	TInt iTestNumAllocCells;
       
    51 	TUint iTestAddress;
       
    52 	TInt iTestSize;
       
    53 	TInt iTestAllocCount;
       
    54 public:
       
    55 	struct SDebugCell {TInt len;TInt nestingLevel;TInt allocCount;};
       
    56 private:
       
    57 	TInt iNestingLevel;
       
    58 public:
       
    59 	TInt iAllocCount;
       
    60 private:
       
    61 	TInt iLevelNumAllocCells;
       
    62 	SDebugCell* iPtrDebugCell;
       
    63 	RHeap::TAllocFail iFailType;
       
    64 	TInt iFailRate;
       
    65 	TBool iFailed;
       
    66 	TInt iFailAllocCount;
       
    67 	TInt iRand;
       
    68 	};
       
    69 
       
    70 class CTests : public CBase
       
    71 	{
       
    72 public:
       
    73 	static void DoTestsL();
       
    74 private:
       
    75 	enum TDataType
       
    76 		{
       
    77 		ETvCardFile,
       
    78 		ETvCalFile,
       
    79 		ETvCardLine,
       
    80 		ETvCalLine,
       
    81 		};
       
    82 
       
    83 	struct SPrintResult
       
    84 		{
       
    85 		TInt TimeInt;				//internalising time
       
    86 		TInt TimeExt;				//externalising time
       
    87 		TInt IncreasedCells;		//net increase in heap cells
       
    88 		TInt IncreasedSizeInBytes;	//net increase in heap size
       
    89 		TInt NumAlloInt;			//overall number of allocations when internalising
       
    90 		TInt NumAlloExt;			//overall number of allocations when externalising
       
    91 		};
       
    92 
       
    93 	~CTests();
       
    94 	void ConstructL();
       
    95 	void AllTestsL();
       
    96 	void TestIntExtFileL(TDataType aDataType);
       
    97 	void TestVCalMemoryUsageByAddingEntitiesL(TInt aNumOfEntry,SPrintResult& aResult);
       
    98 	void TestVCardMemoryUsageWithDiffCharsetsL(SPrintResult& aResult,const TDesC& aFileName, Versit::TVersitCharSet aCharset=Versit::EUSAsciiCharSet);
       
    99 	void TestVCardMemoryUsageL();
       
   100 	void TestVCalMemoryUsageL();
       
   101 	void CreateEntityEventEntryL(CParserVCalEntity& aEntity);
       
   102 	void CreateEntityTodoEntryL(CParserVCalEntity& aEntity);
       
   103 	void PrintOutResult(const TDesC& aFilename, RFile& aFile, SPrintResult aResult);
       
   104 	void PrintOutResult(RFile& aFile, TInt aNumOfEntries, SPrintResult aResult);
       
   105 	void CreateAparserLC(TDataType aDataType,CVersitParser*& aParser);
       
   106 	void ExternaliseFileL(CVersitParser& aParser,const TDesC& aFileName);
       
   107 	void InternaliseFileL(CVersitParser& aParser,const TDesC& aFileName);
       
   108 private:
       
   109 	RFs iFsSession;
       
   110 	TBool iSessionConnected;
       
   111 	CVersitParser* iParser;		//This is to keep the Static Utilities around
       
   112 	CFileMan* iFm;
       
   113 	};
       
   114 
       
   115 void CTests::DoTestsL()
       
   116 	{
       
   117 	CTests* self=new(ELeave) CTests;
       
   118 	CleanupStack::PushL(self);
       
   119 	self->ConstructL();
       
   120 	self->AllTestsL();
       
   121 	CleanupStack::PopAndDestroy(self);
       
   122 	}
       
   123 
       
   124 void CTests::ConstructL()
       
   125 	{
       
   126 	TheTest.Printf(_L("About to connect to file session\r\n"));
       
   127 	User::LeaveIfError(iFsSession.Connect());
       
   128 	iSessionConnected=ETrue;
       
   129 	iFm = CFileMan::NewL(iFsSession);
       
   130 	iParser=new(ELeave) CVersitParser(CVersitParser::ENoVersionProperty);
       
   131 	iParser->ConstructL();
       
   132 	}
       
   133 
       
   134 CTests::~CTests()
       
   135 	{
       
   136 	delete iParser;
       
   137 	if(iFm)
       
   138 		{
       
   139 		iFm->RmDir(KTestDirOutput);
       
   140 		iFm->RmDir(KTestDirResult);
       
   141 		iFm->RmDir(_L("c:\\TPerFormance\\"));
       
   142 		delete iFm;
       
   143 		}
       
   144 	if (iSessionConnected)
       
   145 		iFsSession.Close();
       
   146 	}
       
   147 
       
   148 void CTests::ExternaliseFileL(CVersitParser& aParser,const TDesC& aFileName)
       
   149 	{
       
   150 	RFile file;
       
   151 	User::LeaveIfError(file.Replace(iFsSession, aFileName, EFileWrite));
       
   152 	CleanupClosePushL(file);
       
   153 	aParser.ExternalizeL(file);
       
   154 	CleanupStack::PopAndDestroy(&file);
       
   155 	}
       
   156 
       
   157 void CTests::InternaliseFileL(CVersitParser& aParser,const TDesC& aFileName)
       
   158 	{
       
   159 	RFile file;
       
   160 	User::LeaveIfError(file.Open(iFsSession, aFileName, EFileRead));
       
   161 	CleanupClosePushL(file);
       
   162 	TInt start=0;
       
   163 	aParser.InternalizeL(file, start);
       
   164 	CleanupStack::PopAndDestroy(&file);
       
   165 	}
       
   166 
       
   167 void CTests::CreateAparserLC(TDataType aDataType,CVersitParser*& aParser)
       
   168 	{
       
   169 	if ((aDataType==ETvCardFile)||(aDataType==ETvCardLine))
       
   170 		aParser = CParserVCard::NewL();
       
   171 	else
       
   172 		aParser = CParserVCal::NewL();
       
   173 	CleanupStack::PushL(aParser);
       
   174 	}
       
   175 
       
   176 void CTests::PrintOutResult(RFile& aFile,TInt aNumOfEntries, SPrintResult aResult)
       
   177 	{
       
   178 	TBuf<200> resultBuf;
       
   179 	resultBuf.Format(_L("\t%d\t\t%d\t\t%d\t\t%d\x0d\x0a"),aNumOfEntries,aResult.IncreasedSizeInBytes,aResult.IncreasedCells,aResult.NumAlloExt);
       
   180 	TheTest.Printf(resultBuf);
       
   181 	TBuf8<100> resultBuf8;
       
   182 	resultBuf8.Copy(resultBuf);
       
   183 	aFile.Write(resultBuf8);
       
   184 	}
       
   185 
       
   186 void CTests::PrintOutResult(const TDesC& aDescription, RFile& file, SPrintResult aResult)
       
   187 	{
       
   188 	//output result
       
   189 	TBuf<200> resultBuf;
       
   190 	if (aResult.TimeInt==0)
       
   191 		resultBuf.Format(_L("%-23S\t%d\t\t%d\t\t%d\x0d\x0a"),&aDescription, aResult.IncreasedSizeInBytes,aResult.IncreasedCells,aResult.NumAlloExt);
       
   192 	else
       
   193 		resultBuf.Format(_L("%-23S\t%d\t\t%d\t\t%d\t\t%d\t\t%d\t\t%d\t\t%d\x0d\x0a"),&aDescription, aResult.TimeInt, aResult.TimeExt, aResult.TimeInt+aResult.TimeExt,aResult.IncreasedCells,aResult.IncreasedSizeInBytes,aResult.NumAlloInt,aResult.NumAlloExt);
       
   194 	TheTest.Printf(resultBuf);
       
   195 	TBuf8<100> resultBuf8;
       
   196 	resultBuf8.Copy(resultBuf);
       
   197 	file.Write(resultBuf8);
       
   198 	}
       
   199 
       
   200 void CTests::AllTestsL()
       
   201 	{
       
   202 	TInt err;
       
   203 	err=iFsSession.MkDirAll(KTestDirOutput());
       
   204 	if((err!=KErrAlreadyExists) && (err!=KErrNone))
       
   205 		{
       
   206 		TheTest.Printf(_L("Directory failed to created err=%d\r\n"),err);
       
   207 		TheTest.Getch();
       
   208 		User::Leave(err);
       
   209 		}
       
   210 	err=iFsSession.MkDirAll(KTestDirResult());
       
   211 	if((err!=KErrAlreadyExists) && (err!=KErrNone))
       
   212 		User::Leave(err);
       
   213 
       
   214 	_LIT(KTest1,"Int & Ext vCards\n");
       
   215 	TheTest.Printf(KTest1);
       
   216 	TestIntExtFileL(ETvCardFile);
       
   217 
       
   218 	_LIT(KTest2,"\n\nInt & Ext vCals\n");
       
   219   	TheTest.Printf(KTest2);
       
   220   	TestIntExtFileL(ETvCalFile);
       
   221   
       
   222  	_LIT(KTest3,"\n\nInt & Ext vCards with single line\n");
       
   223   	TheTest.Printf(KTest3);
       
   224   	TestIntExtFileL(ETvCardLine);
       
   225   
       
   226   	_LIT(KTest4,"\n\nInt & Ext vCal with single line\n");
       
   227   	TheTest.Printf(KTest4);
       
   228   	TestIntExtFileL(ETvCalLine);
       
   229 
       
   230 	_LIT(KTest5,"\n\nVCal Test with added entities\n");
       
   231 	TheTest.Printf(KTest5);
       
   232 	TestVCalMemoryUsageL();
       
   233 	
       
   234 	_LIT(KTest6, "\n\nCreate a vCard by Adding Properties\n\n");
       
   235 	TheTest.Printf(KTest6);
       
   236 	TestVCardMemoryUsageL(); 
       
   237 	}
       
   238 
       
   239 void CTests::TestVCalMemoryUsageL()
       
   240 	{
       
   241 	_LIT(KResultWithAddingEntities,"vCalAddingEntriesResult");
       
   242 	TFileName resultFile;
       
   243 	resultFile=KTestDirResult;
       
   244 	resultFile.Append(KResultWithAddingEntities);
       
   245 	resultFile.Append(KTestFileNameExt);
       
   246 	RFile file;
       
   247 	User::LeaveIfError(file.Replace(iFsSession, resultFile,EFileWrite+EFileShareAny+EFileStreamText));
       
   248 	CleanupClosePushL(file);//file
       
   249 
       
   250 	TBuf<200> title;
       
   251 	title.Format(_L("num entries\theap size\tnum obj \tnum. Alloc\x0d\x0a"));
       
   252 	TheTest.Printf(title);
       
   253 	TBuf8<200> title8;
       
   254 	title8.Copy(title);
       
   255 	file.Write(title8);
       
   256 
       
   257 	for(TInt i=5;i<41;i=i+5)
       
   258 		{
       
   259 		SPrintResult result;
       
   260 		TestVCalMemoryUsageByAddingEntitiesL(i,result);
       
   261 		PrintOutResult(file,i,result);
       
   262 		}
       
   263 
       
   264 	CleanupStack::PopAndDestroy(&file);
       
   265 	}
       
   266 
       
   267 void CTests::TestVCardMemoryUsageL()
       
   268 	{
       
   269 	_LIT(KvCardResult,"vCardAddingPropertyResult");
       
   270 	TFileName resultFile;
       
   271 	resultFile=KTestDirResult;
       
   272 	resultFile.Append(KvCardResult);
       
   273 	resultFile.Append(KTestFileNameExt);
       
   274 	RFile file;
       
   275 	User::LeaveIfError(file.Replace(iFsSession, resultFile,EFileWrite+EFileShareAny+EFileStreamText));
       
   276 	CleanupClosePushL(file);//file
       
   277 
       
   278 	TBuf<200> title;
       
   279 	title.Format(_L("file Name\t\t\theap size\tnum obj \tnum. Alloc\x0d\x0a"));
       
   280 	TheTest.Printf(title);
       
   281 	TBuf8<200> title8;
       
   282 	title8.Copy(title);
       
   283 	file.Write(title8);
       
   284 	SPrintResult result;
       
   285 	result.TimeInt=0;
       
   286 	Versit::TVersitCharSet charset;
       
   287 
       
   288 	_LIT(KVCardTestFile1, "vCardAddedProAscii");
       
   289 	TestVCardMemoryUsageWithDiffCharsetsL(result,KVCardTestFile1);
       
   290 	PrintOutResult(KVCardTestFile1,file,result);
       
   291 
       
   292 	_LIT(KVCardTestFile2, "vCardAddedProGBK");
       
   293 	charset=Versit::EGBKCharSet;
       
   294 	TestVCardMemoryUsageWithDiffCharsetsL(result,KVCardTestFile2,charset);
       
   295 	PrintOutResult(KVCardTestFile2,file,result);
       
   296 
       
   297 	_LIT(KVCardTestFile3, "vCardAddedProShifJis");
       
   298 	charset=Versit::EShiftJISCharSet;
       
   299 	TestVCardMemoryUsageWithDiffCharsetsL(result,KVCardTestFile3,charset);
       
   300 	PrintOutResult(KVCardTestFile3,file,result);
       
   301 
       
   302 	_LIT(KVCardTestFile4,"vCardAddedProUtf7");
       
   303 	charset=Versit::EUTF7CharSet;
       
   304 	TestVCardMemoryUsageWithDiffCharsetsL(result,KVCardTestFile4,charset);
       
   305 	PrintOutResult(KVCardTestFile4,file,result);
       
   306 
       
   307 	_LIT(KVCardTestFile5,"vCardAddedProJis");
       
   308 	charset=Versit::EJISCharSet;
       
   309 	TestVCardMemoryUsageWithDiffCharsetsL(result,KVCardTestFile5,charset);
       
   310 	PrintOutResult(KVCardTestFile5,file,result);
       
   311 
       
   312 	CleanupStack::PopAndDestroy(&file);
       
   313 	}
       
   314 
       
   315 void CTests::TestVCardMemoryUsageWithDiffCharsetsL(SPrintResult& aResult, const TDesC& aFileName,Versit::TVersitCharSet aCharset)
       
   316 	{
       
   317 	TInt numCellsBefore, numCellsAfter, sizeInBytesBefore, sizeInBytesAfter, numAllocBefore, numAllocAfter;
       
   318 	RHeap& heap = User::Heap();
       
   319 	SRHeapCopy& myHeap = REINTERPRET_CAST(SRHeapCopy&, heap);
       
   320 	numCellsBefore = heap.AllocSize(sizeInBytesBefore);
       
   321 	numAllocBefore = myHeap.iAllocCount; 
       
   322 	
       
   323 	CParserVCard* vCardParser = CParserVCard::NewL();
       
   324 	CleanupStack::PushL(vCardParser);
       
   325 
       
   326 	_LIT8(KHOME, "HOME");
       
   327 	_LIT8(KVOICE, "VOICE");
       
   328 	_LIT8(KCELL, "CELL");
       
   329 	_LIT8(KFAX, "FAX");
       
   330 	_LIT8(KPOSTAL, "POSTAL");
       
   331 	_LIT8(KPREF, "PREF");
       
   332 	_LIT8(KWORK, "WORK");
       
   333 
       
   334 	_LIT(KSurname, "Example");
       
   335 	_LIT(KFirstname, "A");
       
   336 	_LIT(KMiddlename, "N");
       
   337 	_LIT(KFullname, "A N Example");
       
   338 	_LIT(KTIME, "20010419T103325Z");
       
   339 	_LIT(KEMAIL, "symbian.foundation@exp.example.test");
       
   340 	_LIT(KTELNUM, "01-6329-60000");
       
   341 	_LIT(KORG, "Symbian Foundation Center");
       
   342 	_LIT(KDR, "DR");
       
   343 	_LIT(KLONGNOTE, "This is a long note to test This is a long note to testThis is a long note to test This is a long note to test This is a long note to test This is a long note to test");
       
   344 	_LIT(KADSFIELD1, "Example 1");
       
   345 	_LIT(KADSFIELD2, "Example City Ø");
       
   346 	_LIT(KADSFIELD3, "ZZ99 EXP");
       
   347 	_LIT(KLONGLAB, "long label to test ong label to test ong label to test ong label to test ong label to test ong label to test ong label to test");
       
   348 	_LIT(KNUM, "2");
       
   349 	_LIT(KADSINTER, "http://www.symbianfoundation.example");
       
   350 	_LIT(KDATE, "19520607");
       
   351 
       
   352 	//property 1
       
   353 	CDesCArrayFlat* desArray1 = new (ELeave) CDesCArrayFlat(3);
       
   354 	CleanupStack::PushL(desArray1);
       
   355 	desArray1->AppendL(KSurname);  
       
   356 	desArray1->AppendL(KFirstname);
       
   357 	desArray1->AppendL(KMiddlename); 
       
   358 	CParserPropertyValue* valueN=new (ELeave) CParserPropertyValueCDesCArray(desArray1);
       
   359   	CleanupStack::Pop(desArray1);
       
   360 	CleanupStack::PushL(valueN);
       
   361 	CParserGroupedProperty* propertyN = CParserGroupedProperty::NewL(*valueN, KVersitTokenN, NULL, NULL);
       
   362 	CleanupStack::Pop(valueN);
       
   363 	CleanupStack::PushL(propertyN);
       
   364 	vCardParser->AddPropertyL(propertyN);
       
   365 	CleanupStack::Pop(propertyN);
       
   366 
       
   367 	//property 2
       
   368 	CParserPropertyValue* valueFN = CParserPropertyValueHBufC::NewL(KFullname);
       
   369 	CleanupStack::PushL(valueFN);
       
   370 	CParserGroupedProperty* propertyFN = CParserGroupedProperty::NewL(*valueFN, KVersitTokenFN, NULL, NULL);
       
   371 	CleanupStack::Pop(valueFN);
       
   372 	CleanupStack::PushL(propertyFN);
       
   373 	vCardParser->AddPropertyL(propertyFN);
       
   374 	CleanupStack::Pop(propertyFN);
       
   375 
       
   376 	//property 3
       
   377 	CParserPropertyValue* valueNN = CParserPropertyValueHBufC::NewL(KFullname);
       
   378 	CleanupStack::PushL(valueNN);
       
   379 	CParserGroupedProperty* propertyNN = CParserGroupedProperty::NewL(*valueNN, KVersitTokenNICKNAME, NULL, NULL);
       
   380 	CleanupStack::Pop(valueNN);
       
   381 	CleanupStack::PushL(propertyNN);
       
   382 	vCardParser->AddPropertyL(propertyNN);
       
   383 	CleanupStack::Pop(propertyNN);
       
   384 
       
   385 	//property 4
       
   386 	CParserPropertyValue* value4 = CParserPropertyValueHBufC::NewL(KORG);
       
   387 	CleanupStack::PushL(value4);
       
   388 	CParserGroupedProperty* property4 = CParserGroupedProperty::NewL(*value4, KVersitTokenORG, NULL, NULL);
       
   389 	CleanupStack::Pop(value4);
       
   390 	CleanupStack::PushL(property4);
       
   391 	vCardParser->AddPropertyL(property4);
       
   392 	CleanupStack::Pop(property4);
       
   393 
       
   394 	//property 5
       
   395 	CParserPropertyValue* value5 = CParserPropertyValueHBufC::NewL(KDR);
       
   396 	CleanupStack::PushL(value5);
       
   397 	CParserGroupedProperty* property5 = CParserGroupedProperty::NewL(*value5, KVersitTokenTITLE, NULL, NULL);
       
   398 	CleanupStack::Pop(value5);
       
   399 	CleanupStack::PushL(property5);
       
   400 	vCardParser->AddPropertyL(property5);
       
   401 	CleanupStack::Pop(property5);
       
   402 
       
   403 	//property 6
       
   404 	CParserPropertyValue* value6 = CParserPropertyValueHBufC::NewL(KLONGNOTE);
       
   405 	CleanupStack::PushL(value6);
       
   406 	CParserGroupedProperty* property6 = CParserGroupedProperty::NewL(*value6, KVersitTokenNOTE, NULL, NULL);
       
   407 	CleanupStack::Pop(value6);
       
   408 	CleanupStack::PushL(property6);
       
   409 	vCardParser->AddPropertyL(property6);
       
   410 	CleanupStack::Pop(property6);
       
   411 
       
   412 	//property 7
       
   413 	CArrayPtr<CParserParam>* arrayOfParams = new(ELeave) CArrayPtrFlat<CParserParam>(2);
       
   414 	CParserParam* parserParam1 = CParserParam::NewL(KWORK, KNullDesC8);
       
   415 	CleanupStack::PushL(parserParam1);
       
   416 	arrayOfParams->AppendL(parserParam1);
       
   417 	CleanupStack::Pop(parserParam1);
       
   418 
       
   419 	CParserParam* parserParam2= CParserParam::NewL(KVOICE, KNullDesC8);
       
   420 	CleanupStack::PushL(parserParam2);
       
   421 	arrayOfParams->AppendL(parserParam2);
       
   422 	CleanupStack::Pop(parserParam2);
       
   423 	CParserPropertyValue* value7 = CParserPropertyValueHBufC::NewL(KTELNUM);
       
   424 	CleanupStack::PushL(value7);
       
   425 	CParserGroupedProperty* property7 = CParserGroupedProperty::NewL(*value7, KVersitTokenTEL, NULL, arrayOfParams);
       
   426 	CleanupStack::Pop(value7);
       
   427 	CleanupStack::PushL(property7);
       
   428 	vCardParser->AddPropertyL(property7);
       
   429 	CleanupStack::Pop(property7);
       
   430 
       
   431 	//property 8
       
   432 	CArrayPtr<CParserParam>* arrayOfParams8 = new(ELeave) CArrayPtrFlat<CParserParam>(2);
       
   433 	CParserParam* parserParam8A = CParserParam::NewL(KHOME, KNullDesC8);
       
   434 	CleanupStack::PushL(parserParam8A);
       
   435 	arrayOfParams8->AppendL(parserParam8A);
       
   436 	CleanupStack::Pop(parserParam8A);
       
   437 	CParserParam* parserParam8B = CParserParam::NewL(KHOME, KNullDesC8);
       
   438 	CleanupStack::PushL(parserParam8B);
       
   439 	arrayOfParams8->AppendL(parserParam8B);
       
   440 	CleanupStack::Pop(parserParam8B);
       
   441 	CParserPropertyValue* value8 = CParserPropertyValueHBufC::NewL(KTELNUM);
       
   442 	CleanupStack::PushL(value8);
       
   443 	CParserGroupedProperty* property8 = CParserGroupedProperty::NewL(*value8, KVersitTokenTEL, NULL, arrayOfParams8);
       
   444 	CleanupStack::Pop(value8);
       
   445 	CleanupStack::PushL(property8);
       
   446 	vCardParser->AddPropertyL(property8);
       
   447 	CleanupStack::Pop(property8);
       
   448 
       
   449 	//property 9
       
   450 	CArrayPtr<CParserParam>* arrayOfParams9 = new(ELeave) CArrayPtrFlat<CParserParam>(2);
       
   451 	CParserParam* parserParam9A = CParserParam::NewL(KCELL, KNullDesC8);
       
   452 	CleanupStack::PushL(parserParam9A);
       
   453 	arrayOfParams9->AppendL(parserParam9A);
       
   454 	CleanupStack::Pop(parserParam9A);
       
   455 	CParserParam* parserParam9B = CParserParam::NewL(KVOICE, KNullDesC8);
       
   456 	CleanupStack::PushL(parserParam9B);
       
   457 	arrayOfParams9->AppendL(parserParam9B);
       
   458 	CleanupStack::Pop(parserParam9B);
       
   459 	CParserPropertyValue* value9 = CParserPropertyValueHBufC::NewL(KTELNUM);
       
   460 	CleanupStack::PushL(value9);
       
   461 	CParserGroupedProperty* property9 = CParserGroupedProperty::NewL(*value9, KVersitTokenTEL, NULL, arrayOfParams9);
       
   462 	CleanupStack::Pop(value9);
       
   463 	CleanupStack::PushL(property9);
       
   464 	vCardParser->AddPropertyL(property9);
       
   465 	CleanupStack::Pop(property9);
       
   466 
       
   467 	//property 10
       
   468 	CArrayPtr<CParserParam>* arrayOfParams10 = new(ELeave) CArrayPtrFlat<CParserParam>(2);
       
   469 	CParserParam* parserParam10A = CParserParam::NewL(KWORK, KNullDesC8);
       
   470 	CleanupStack::PushL(parserParam10A);
       
   471 	arrayOfParams10->AppendL(parserParam10A);
       
   472 	CleanupStack::Pop(parserParam10A);
       
   473 	CParserParam* parserParam10B = CParserParam::NewL(KFAX, KNullDesC8);
       
   474 	CleanupStack::PushL(parserParam10B);
       
   475 	arrayOfParams10->AppendL(parserParam10B);
       
   476 	CleanupStack::Pop(parserParam10B);
       
   477 	CParserPropertyValue* value10 = CParserPropertyValueHBufC::NewL(KTELNUM);
       
   478 	CleanupStack::PushL(value10);
       
   479 	CParserGroupedProperty* property10 = CParserGroupedProperty::NewL(*value10, KVersitTokenTEL, NULL, arrayOfParams10);
       
   480 	CleanupStack::Pop(value10);
       
   481 	CleanupStack::PushL(property10);
       
   482 	vCardParser->AddPropertyL(property10);
       
   483 	CleanupStack::Pop(property10);
       
   484 
       
   485 	//property 11
       
   486 
       
   487 	CArrayPtr<CParserParam>* arrayOfParams11 = new(ELeave) CArrayPtrFlat<CParserParam>(2);
       
   488 	CParserParam* parserParam11A = CParserParam::NewL(KPOSTAL, KNullDesC8);
       
   489 	CleanupStack::PushL(parserParam11A);
       
   490 	arrayOfParams11->AppendL(parserParam11A);
       
   491 	CleanupStack::Pop(parserParam11A);
       
   492 	CParserParam* parserParam11B = CParserParam::NewL(KWORK, KNullDesC8);
       
   493 	CleanupStack::PushL(parserParam11B);
       
   494 	arrayOfParams11->AppendL(parserParam11B);
       
   495 	CleanupStack::Pop(parserParam11B);
       
   496 	CDesCArrayFlat* desArrayAdr = new (ELeave) CDesCArrayFlat(3);
       
   497 	CleanupStack::PushL(desArrayAdr);
       
   498 	desArrayAdr->AppendL(KNullDesC);  
       
   499 	desArrayAdr->AppendL(KADSFIELD1);  
       
   500 	desArrayAdr->AppendL(KADSFIELD2);
       
   501 	desArrayAdr->AppendL(KNullDesC);  
       
   502 	desArrayAdr->AppendL(KADSFIELD3); 
       
   503 	CParserPropertyValue* valueAdr=new (ELeave) CParserPropertyValueCDesCArray(desArrayAdr);
       
   504   	CleanupStack::Pop(desArrayAdr);
       
   505 	CleanupStack::PushL(valueAdr);
       
   506 	CParserGroupedProperty* property11 = CParserGroupedProperty::NewL(*valueAdr, KVersitTokenADR, NULL, arrayOfParams11);
       
   507 	CleanupStack::Pop(valueAdr);
       
   508 	CleanupStack::PushL(property11);
       
   509 	vCardParser->AddPropertyL(property11);
       
   510 	CleanupStack::Pop(property11);
       
   511 
       
   512 	//property 12
       
   513 	CArrayPtr<CParserParam>* arrayOfParams12 = new(ELeave) CArrayPtrFlat<CParserParam>(2);
       
   514 	CParserParam* parserParam12 = CParserParam::NewL(KWORK, KNullDesC8);
       
   515 	CleanupStack::PushL(parserParam12);
       
   516 	arrayOfParams12->AppendL(parserParam12);
       
   517 	CleanupStack::Pop(parserParam12);
       
   518 	CParserPropertyValue* value12 = CParserPropertyValueHBufC::NewL(KLONGLAB);
       
   519 	CleanupStack::PushL(value12);
       
   520 	CParserGroupedProperty* property12 = CParserGroupedProperty::NewL(*value12, KVersitTokenLABEL, NULL, arrayOfParams12);
       
   521 	CleanupStack::Pop(value12);
       
   522 	CleanupStack::PushL(property12);
       
   523 	vCardParser->AddPropertyL(property12);
       
   524 	CleanupStack::Pop(property12);
       
   525 
       
   526 	//property 13
       
   527 
       
   528 	CArrayPtr<CParserParam>* arrayOfParams13 = new(ELeave) CArrayPtrFlat<CParserParam>(3);
       
   529 	CParserParam* parserParam13A = CParserParam::NewL(KPOSTAL, KNullDesC8);
       
   530 	CleanupStack::PushL(parserParam13A);
       
   531 	arrayOfParams13->AppendL(parserParam13A);
       
   532 	CleanupStack::Pop(parserParam13A);
       
   533 	CParserParam* parserParam13B = CParserParam::NewL(KHOME, KNullDesC8);
       
   534 	CleanupStack::PushL(parserParam13B);
       
   535 	arrayOfParams13->AppendL(parserParam13B);
       
   536 	CleanupStack::Pop(parserParam13B);
       
   537 	CDesCArrayFlat* desArrayAdr1 = new (ELeave) CDesCArrayFlat(3);
       
   538 	CleanupStack::PushL(desArrayAdr1);
       
   539 	desArrayAdr1->AppendL(KNullDesC);  
       
   540 	desArrayAdr1->AppendL(KADSFIELD1);  
       
   541 	desArrayAdr1->AppendL(KADSFIELD2);
       
   542 	desArrayAdr1->AppendL(KNullDesC);  
       
   543 	desArrayAdr1->AppendL(KADSFIELD3); 
       
   544 	CParserPropertyValue* valueAdr1=new (ELeave) CParserPropertyValueCDesCArray(desArrayAdr1);
       
   545   	CleanupStack::Pop(desArrayAdr1);
       
   546 	CleanupStack::PushL(valueAdr1);
       
   547 	CParserGroupedProperty* property13 = CParserGroupedProperty::NewL(*valueAdr1, KVersitTokenADR, NULL, arrayOfParams13);
       
   548 	CleanupStack::Pop(valueAdr1);
       
   549 	CleanupStack::PushL(property13);
       
   550 	vCardParser->AddPropertyL(property13);
       
   551 	CleanupStack::Pop(property13);
       
   552 
       
   553 	//property 14
       
   554 	CArrayPtr<CParserParam>* arrayOfParams14 = new(ELeave) CArrayPtrFlat<CParserParam>(2);
       
   555 	CParserParam* parserParam14 = CParserParam::NewL(KHOME, KNullDesC8);
       
   556 	CleanupStack::PushL(parserParam14);
       
   557 	arrayOfParams14->AppendL(parserParam14);
       
   558 	CleanupStack::Pop(parserParam14);
       
   559 	CParserPropertyValue* value14 = CParserPropertyValueHBufC::NewL(KLONGLAB);
       
   560 	CleanupStack::PushL(value14);
       
   561 	CParserGroupedProperty* property14 = CParserGroupedProperty::NewL(*value14, KVersitTokenLABEL, NULL, arrayOfParams14);
       
   562 	CleanupStack::Pop(value14);
       
   563 	CleanupStack::PushL(property14);
       
   564 	vCardParser->AddPropertyL(property14);
       
   565 	CleanupStack::Pop(property14);
       
   566 
       
   567 	//property 15
       
   568 	CParserPropertyValue* value15 = CParserPropertyValueHBufC::NewL(KNUM);
       
   569 	CleanupStack::PushL(value15);
       
   570 	CParserGroupedProperty* property15 = CParserGroupedProperty::NewL(*value15, KVersitTokenXWABGENDER, NULL, NULL);
       
   571 	CleanupStack::Pop(value15);
       
   572 	CleanupStack::PushL(property15);
       
   573 	vCardParser->AddPropertyL(property15);
       
   574 	CleanupStack::Pop(property15);
       
   575 
       
   576 	//property 16
       
   577 	CParserPropertyValue* value16 = CParserPropertyValueHBufC::NewL(KVersitTokenEmpty);
       
   578 	CleanupStack::PushL(value16);
       
   579 	CParserGroupedProperty* property16 = CParserGroupedProperty::NewL(*value16, KVersitTokenURL, NULL, NULL);
       
   580 	CleanupStack::Pop(value16);
       
   581 	CleanupStack::PushL(property16);
       
   582 	vCardParser->AddPropertyL(property16);
       
   583 	CleanupStack::Pop(property16);
       
   584 
       
   585 	//property 17
       
   586 	CParserPropertyValue* value17 = CParserPropertyValueHBufC::NewL(KADSINTER);
       
   587 	CleanupStack::PushL(value17);
       
   588 	CParserGroupedProperty* property17 = CParserGroupedProperty::NewL(*value17, KVersitTokenURL, NULL, NULL);
       
   589 	CleanupStack::Pop(value17);
       
   590 	CleanupStack::PushL(property17);
       
   591 	vCardParser->AddPropertyL(property17);
       
   592 	CleanupStack::Pop(property17);
       
   593 
       
   594 	//property 18
       
   595 	CParserPropertyValue* value18 = CParserPropertyValueHBufC::NewL(KDATE);
       
   596 	CleanupStack::PushL(value18);
       
   597 	CParserGroupedProperty* property18 = CParserGroupedProperty::NewL(*value18, KVersitTokenBDAY, NULL, NULL);
       
   598 	CleanupStack::Pop(value18);
       
   599 	CleanupStack::PushL(property18);
       
   600 	vCardParser->AddPropertyL(property18);
       
   601 	CleanupStack::Pop(property18);
       
   602 
       
   603 	//property 19
       
   604 	CArrayPtr<CParserParam>* arrayOfParams19 = new(ELeave) CArrayPtrFlat<CParserParam>(2);
       
   605 	CParserParam* parserParam19A = CParserParam::NewL(KPREF, KNullDesC8);
       
   606 	CleanupStack::PushL(parserParam19A);
       
   607 	arrayOfParams19->AppendL(parserParam19A);
       
   608 	CleanupStack::Pop(parserParam19A);
       
   609 	CParserParam* parserParam19B= CParserParam::NewL(KVersitTokenINTERNET, KNullDesC8);
       
   610 	CleanupStack::PushL(parserParam19B);
       
   611 	arrayOfParams19->AppendL(parserParam19B);
       
   612 	CleanupStack::Pop(parserParam19B);
       
   613 	CParserPropertyValue* value19 = CParserPropertyValueHBufC::NewL(KEMAIL);
       
   614 	CleanupStack::PushL(value19);
       
   615 	CParserGroupedProperty* property19 = CParserGroupedProperty::NewL(*value19, KVersitTokenEMAIL, NULL, arrayOfParams19);
       
   616 	CleanupStack::Pop(value19);
       
   617 	CleanupStack::PushL(property19);
       
   618 	vCardParser->AddPropertyL(property19);
       
   619 	CleanupStack::Pop(property19);
       
   620 
       
   621 	//property 20
       
   622 	CArrayPtr<CParserParam>* arrayOfParams20 = new(ELeave) CArrayPtrFlat<CParserParam>(1);
       
   623 	CParserParam* parserParam20= CParserParam::NewL(KVersitTokenINTERNET, KNullDesC8);
       
   624 	CleanupStack::PushL(parserParam20);
       
   625 	arrayOfParams20->AppendL(parserParam20);
       
   626 	CleanupStack::Pop(parserParam20);
       
   627 	CParserPropertyValue* value20 = CParserPropertyValueHBufC::NewL(KEMAIL);
       
   628 	CleanupStack::PushL(value20);
       
   629 	CParserGroupedProperty* property20 = CParserGroupedProperty::NewL(*value20, KVersitTokenEMAIL, NULL, arrayOfParams20);
       
   630 	CleanupStack::Pop(value20);
       
   631 	CleanupStack::PushL(property20);
       
   632 	vCardParser->AddPropertyL(property20);
       
   633 	CleanupStack::Pop(property20);
       
   634 
       
   635 	//property 21
       
   636 	CParserPropertyValue* value21 = CParserPropertyValueHBufC::NewL(KTIME);
       
   637 	CleanupStack::PushL(value21);
       
   638 	CParserGroupedProperty* property21 = CParserGroupedProperty::NewL(*value21, KVersitTokenREV, NULL, NULL);
       
   639 	CleanupStack::Pop(value21);
       
   640 	CleanupStack::PushL(property21);
       
   641 	vCardParser->AddPropertyL(property21);
       
   642 	CleanupStack::Pop(property21);
       
   643 
       
   644 	_LIT(KvCard,".VCF");
       
   645 
       
   646 	TFileName fullNameFile;
       
   647 	fullNameFile=KTestDirOutput;
       
   648 	fullNameFile.Append(aFileName);
       
   649 	fullNameFile.Append(KvCard);
       
   650 	vCardParser->SetDefaultCharSet(aCharset);
       
   651 	ExternaliseFileL(*vCardParser, fullNameFile);
       
   652 
       
   653 	numAllocAfter = myHeap.iAllocCount;
       
   654 	numCellsAfter = heap.AllocSize(sizeInBytesAfter);
       
   655 	aResult.NumAlloExt = numAllocAfter - numAllocBefore;
       
   656 	aResult.IncreasedCells = numCellsAfter - numCellsBefore;
       
   657 	aResult.IncreasedSizeInBytes = sizeInBytesAfter - sizeInBytesBefore;
       
   658 	CleanupStack::PopAndDestroy(vCardParser);
       
   659 	}
       
   660 
       
   661 void CTests::TestVCalMemoryUsageByAddingEntitiesL(TInt aNumOfEntry,SPrintResult& aResult)
       
   662 	{
       
   663 	_LIT(KVCalTestFile, "VCalWithAddedEntries");
       
   664 	_LIT(KvCal,".VCS");
       
   665 
       
   666 	TInt numCellsBefore, numCellsAfter, sizeInBytesBefore, sizeInBytesAfter, numAllocBefore, numAllocAfter;
       
   667 	RHeap& heap = User::Heap();
       
   668 	SRHeapCopy& myHeap = REINTERPRET_CAST(SRHeapCopy&, heap);
       
   669 	numCellsBefore = heap.AllocSize(sizeInBytesBefore);
       
   670 	numAllocBefore = myHeap.iAllocCount; 
       
   671 
       
   672 	CParserVCal* vCalParser = CParserVCal::NewL();
       
   673 	CleanupStack::PushL(vCalParser);
       
   674 	for(TInt i=0;i<aNumOfEntry/2;i++)
       
   675 		{
       
   676 		CParserVCalEntity* entityEvent = CParserVCalEntity::NewL();
       
   677 		CleanupStack::PushL(entityEvent);
       
   678 		CreateEntityEventEntryL(*entityEvent);
       
   679 		CleanupStack::Pop(entityEvent);
       
   680 		vCalParser->AddEntityL(entityEvent);
       
   681 		}
       
   682 	TInt mumTodo=aNumOfEntry/2+aNumOfEntry%2;
       
   683 	for(TInt j=0;j<mumTodo;j++)
       
   684 		{
       
   685 		CParserVCalEntity* entityTodo = CParserVCalEntity::NewL();
       
   686 		CleanupStack::PushL(entityTodo);
       
   687 		CreateEntityTodoEntryL(*entityTodo);
       
   688 		CleanupStack::Pop(entityTodo);
       
   689 		vCalParser->AddEntityL(entityTodo);
       
   690 		}
       
   691 
       
   692 	//creating an output file and externalise all the data (properties)
       
   693 	//that have just been created
       
   694 	TBuf<2> numString;
       
   695 	numString.Num(aNumOfEntry);
       
   696 	TFileName fullNameFile;
       
   697 	fullNameFile=KTestDirOutput;
       
   698 	fullNameFile.Append(KVCalTestFile);
       
   699 	fullNameFile.Append(numString);
       
   700 	fullNameFile.Append(KvCal);
       
   701 	RFile file;
       
   702 	CleanupClosePushL(file);//file
       
   703 	ExternaliseFileL(*vCalParser, fullNameFile);
       
   704 
       
   705 	numAllocAfter = myHeap.iAllocCount;
       
   706 	numCellsAfter = heap.AllocSize(sizeInBytesAfter);
       
   707 	aResult.NumAlloExt = numAllocAfter - numAllocBefore;
       
   708 	aResult.IncreasedCells = numCellsAfter - numCellsBefore;
       
   709 	aResult.IncreasedSizeInBytes = sizeInBytesAfter - sizeInBytesBefore;
       
   710  	CleanupStack::PopAndDestroy(2,vCalParser);
       
   711 	}
       
   712 
       
   713 void CTests::CreateEntityEventEntryL(CParserVCalEntity& aEntity)
       
   714 	{
       
   715 	_LIT(KTIME, "19991101T000000Z");
       
   716 
       
   717 	aEntity.SetEntityNameL(KVersitVarTokenVEVENT);
       
   718 
       
   719 	//property 1 within same entity
       
   720 	CParserPropertyValue* value1 = CParserPropertyValueHBufC::NewL(_L("APPOINTMENT"));
       
   721 	CleanupStack::PushL(value1);
       
   722 	CParserProperty* property1 = CParserProperty::NewL(*value1, KVersitTokenAGENDAENTRYTYPE, NULL);
       
   723 	CleanupStack::Pop(value1);
       
   724 	CleanupStack::PushL(property1);
       
   725 	aEntity.AddPropertyL(property1);
       
   726 	CleanupStack::Pop(property1);
       
   727 	
       
   728 	//property 2 within same entity
       
   729 	CParserPropertyValue* value2 = CParserPropertyValueHBufC::NewL(_L("app engines weekly meeting APPOINTMENT"));
       
   730 	CleanupStack::PushL(value2);
       
   731 	CParserProperty* property2 = CParserProperty::NewL(*value2, KVersitTokenDESCRIPTION, NULL);
       
   732 	CleanupStack::Pop(value2);
       
   733 	CleanupStack::PushL(property2);
       
   734 	aEntity.AddPropertyL(property2);
       
   735 	CleanupStack::Pop(property2);
       
   736 
       
   737 	//property 3 within same entity
       
   738 	CParserPropertyValue* value3 = CParserPropertyValueHBufC::NewL(_L("2"));
       
   739 	CleanupStack::PushL(value3);
       
   740 	CParserProperty* property3 = CParserProperty::NewL(*value3, KVersitTokenUID, NULL);
       
   741 	CleanupStack::Pop(value3);
       
   742 	CleanupStack::PushL(property3);
       
   743 	aEntity.AddPropertyL(property3);
       
   744 	CleanupStack::Pop(property3);
       
   745 
       
   746 	CArrayPtr<CParserParam>* arrayOfParams4 = new(ELeave) CArrayPtrFlat<CParserParam>(1);
       
   747 	CParserParam* parserParam4 = CParserParam::NewL(KVersitTokenSOUND, KNullDesC8);
       
   748 	CleanupStack::PushL(parserParam4);
       
   749 	arrayOfParams4->AppendL(parserParam4);
       
   750 	CleanupStack::Pop(parserParam4);
       
   751 
       
   752 	TDateTime date(2001,ENovember,1,0,15,0,0);
       
   753 	TVersitDateTime* runtime = new(ELeave) TVersitDateTime(date, TVersitDateTime::EIsMachineLocal);
       
   754 	CleanupStack::PushL(runtime);
       
   755 	CVersitAlarm* value4 = CVersitAlarm::NewL(runtime,0,0,_L("Fanfare"),KNullDesC);
       
   756 	CleanupStack::Pop(runtime);
       
   757 	CleanupStack::PushL(value4);
       
   758 
       
   759 	CParserPropertyValueAlarm* alarmValue4 = new(ELeave) CParserPropertyValueAlarm(value4);
       
   760 	CleanupStack::Pop(value4);
       
   761 	CleanupStack::PushL(alarmValue4);
       
   762 	CParserProperty* property4 = CParserProperty::NewL(*alarmValue4, KVersitTokenAALARM, arrayOfParams4);
       
   763 	CleanupStack::Pop(alarmValue4);
       
   764 	CleanupStack::PushL(property4);
       
   765 	aEntity.AddPropertyL(property4);
       
   766 	CleanupStack::Pop(property4);
       
   767 
       
   768 	//property 5 within same entity
       
   769 	CParserPropertyValue* value5 = CParserPropertyValueHBufC::NewL(_L("PUBLIC"));
       
   770 	CleanupStack::PushL(value5);
       
   771 	CParserProperty* property5 = CParserProperty::NewL(*value5, KVersitTokenCLASS, NULL);
       
   772 	CleanupStack::Pop(value5);
       
   773 	CleanupStack::PushL(property5);
       
   774 	aEntity.AddPropertyL(property5);
       
   775 	CleanupStack::Pop(property5);
       
   776 
       
   777 	//property 6 within same entity
       
   778 	CParserPropertyValue* value6 = CParserPropertyValueHBufC::NewL(_L("19991101T000000Z"));
       
   779 	CleanupStack::PushL(value6);
       
   780 	CParserProperty* property6 = CParserProperty::NewL(*value6, KVersitTokenDCREATED, NULL);
       
   781 	CleanupStack::Pop(value6);
       
   782 	CleanupStack::PushL(property6);
       
   783 	aEntity.AddPropertyL(property6);
       
   784 	CleanupStack::Pop(property6);
       
   785 
       
   786 	//property 7 within same entity
       
   787 	CParserPropertyValue* value7 = CParserPropertyValueHBufC::NewL(KTIME);
       
   788 	CleanupStack::PushL(value7);
       
   789 	CParserProperty* property7 = CParserProperty::NewL(*value7, KVersitTokenLASTMODIFIED, NULL);
       
   790 	CleanupStack::Pop(value7);
       
   791 	CleanupStack::PushL(property7);
       
   792 	aEntity.AddPropertyL(property7);
       
   793 	CleanupStack::Pop(property7);
       
   794 
       
   795 	//property 8 within same entity
       
   796 	CParserPropertyValue* value8 = CParserPropertyValueHBufC::NewL(KTIME);
       
   797 	CleanupStack::PushL(value8);
       
   798 	CParserProperty* property8 = CParserProperty::NewL(*value8, KVersitTokenDTSTART, NULL);
       
   799 	CleanupStack::Pop(value8);
       
   800 	CleanupStack::PushL(property8);
       
   801 	aEntity.AddPropertyL(property8);
       
   802 	CleanupStack::Pop(property8);
       
   803 
       
   804 	//property 9 within same entity
       
   805 	CParserPropertyValue* value9 = CParserPropertyValueHBufC::NewL(KTIME);
       
   806 	CleanupStack::PushL(value9);
       
   807 	CParserProperty* property9 = CParserProperty::NewL(*value9, KVersitTokenDTEND, NULL);
       
   808 	CleanupStack::Pop(value9);
       
   809 	CleanupStack::PushL(property9);
       
   810 	aEntity.AddPropertyL(property9);
       
   811 	CleanupStack::Pop(property9);
       
   812 	}
       
   813 
       
   814 
       
   815 void CTests::CreateEntityTodoEntryL(CParserVCalEntity& aEntity)
       
   816 	{
       
   817 	aEntity.SetEntityNameL(KVersitVarTokenVTODO);
       
   818 	
       
   819 	//property 1 within same entity
       
   820 	CParserPropertyValue* value1 = CParserPropertyValueHBufC::NewL(_L("APPOINTMENT"));
       
   821 	CleanupStack::PushL(value1);
       
   822 	CParserProperty* property1 = CParserProperty::NewL(*value1, KVersitTokenAGENDAENTRYTYPE, NULL);
       
   823 	CleanupStack::Pop(value1);
       
   824 	CleanupStack::PushL(property1);
       
   825 	aEntity.AddPropertyL(property1);
       
   826 	CleanupStack::Pop(property1);
       
   827 
       
   828 	//property 2 within same entity
       
   829 	CParserPropertyValue* value2= CParserPropertyValueHBufC::NewL(_L("meeting with Nokia APPOINTMENT"));
       
   830 	CleanupStack::PushL(value2);
       
   831 	CParserProperty* property2 = CParserProperty::NewL(*value2, KVersitTokenDESCRIPTION, NULL);
       
   832 	CleanupStack::Pop(value2);
       
   833 	CleanupStack::PushL(property2);
       
   834 	aEntity.AddPropertyL(property2);
       
   835 	CleanupStack::Pop(property2);
       
   836 
       
   837 	//property 3 within same entity
       
   838 	CParserPropertyValue* value3 = CParserPropertyValueHBufC::NewL(_L("3"));
       
   839 	CleanupStack::PushL(value3);
       
   840 	CParserProperty* property3 = CParserProperty::NewL(*value3, KVersitTokenUID, NULL);
       
   841 	CleanupStack::Pop(value3);
       
   842 	CleanupStack::PushL(property3);
       
   843 	aEntity.AddPropertyL(property3);
       
   844 	CleanupStack::Pop(property3);
       
   845 
       
   846 	//property 4 within same entity
       
   847 	CParserPropertyValue* value4 = CParserPropertyValueHBufC::NewL(_L("PUBLIC"));
       
   848 	CleanupStack::PushL(value4);
       
   849 	CParserProperty* property4 = CParserProperty::NewL(*value4, KVersitTokenCLASS, NULL);
       
   850 	CleanupStack::Pop(value4);
       
   851 	CleanupStack::PushL(property4);
       
   852 	aEntity.AddPropertyL(property4);
       
   853 	CleanupStack::Pop(property4);
       
   854 
       
   855 	//property 5 within same entity
       
   856 	CParserPropertyValue* value5 = CParserPropertyValueHBufC::NewL(_L("19991101T000000Z"));
       
   857 	CleanupStack::PushL(value5);
       
   858 	CParserProperty* property5 = CParserProperty::NewL(*value5, KVersitTokenDCREATED, NULL);
       
   859 	CleanupStack::Pop(value5);
       
   860 	CleanupStack::PushL(property5);
       
   861 	aEntity.AddPropertyL(property5);
       
   862 	CleanupStack::Pop(property5);
       
   863 
       
   864 	//property 6 within same entity
       
   865 	CParserPropertyValue* value6 = CParserPropertyValueHBufC::NewL(_L("19991101T130400Z"));
       
   866 	CleanupStack::PushL(value6);
       
   867 	CParserProperty* property6 = CParserProperty::NewL(*value6, KVersitTokenLASTMODIFIED, NULL);
       
   868 	CleanupStack::Pop(value6);
       
   869 	CleanupStack::PushL(property6);
       
   870 	aEntity.AddPropertyL(property6);
       
   871 	CleanupStack::Pop(property6);
       
   872 
       
   873 
       
   874 	//property 7 within same entity
       
   875 	CParserPropertyValue* value7 = CParserPropertyValueHBufC::NewL(_L("19991101T100000Z"));
       
   876 	CleanupStack::PushL(value7);
       
   877 	CParserProperty* property7 = CParserProperty::NewL(*value7, KVersitTokenDTSTART, NULL);
       
   878 	CleanupStack::Pop(value7);
       
   879 	CleanupStack::PushL(property7);
       
   880 	aEntity.AddPropertyL(property7);
       
   881 	CleanupStack::Pop(property7);
       
   882 
       
   883 	//property 8 within same entity
       
   884 	CParserPropertyValue* value8 = CParserPropertyValueHBufC::NewL(_L("19991001T113000Z"));
       
   885 	CleanupStack::PushL(value8);
       
   886 	CParserProperty* property8 = CParserProperty::NewL(*value8, KVersitTokenDTEND, NULL);
       
   887 	CleanupStack::Pop(value8);
       
   888 	CleanupStack::PushL(property8);
       
   889 	aEntity.AddPropertyL(property8);
       
   890 	CleanupStack::Pop(property8);
       
   891 	}
       
   892 
       
   893 void CTests::TestIntExtFileL(TDataType aDataType)
       
   894 	{
       
   895 	//wild cards for searching testing files and store the profiling result in different files
       
   896 	_LIT(KvCardFile,"File*.vcf");
       
   897 	_LIT(KvCalFile,"File*.vcs");
       
   898 	_LIT(KvCardLine,"Line*.vcf");
       
   899 	_LIT(KvCalLine,"Line*.vcs");
       
   900 	_LIT(KvCardResultFile,"Int&Ext_vCardFile_com");
       
   901 	_LIT(KvCalResultFile,"Int&Ext_vCalFile_com");
       
   902 	_LIT(KvCardResultLine,"Int&Ext_vCardLine_com");
       
   903 	_LIT(KvCalResultLine,"Int&Ext_vCalLine_com");
       
   904 
       
   905 	TFileName dataFile;
       
   906 	TFileName resultFile;
       
   907 	resultFile=KTestDirResult;
       
   908 	switch (aDataType)
       
   909 		{
       
   910 		case ETvCardFile:
       
   911 			dataFile=KvCardFile;
       
   912 			resultFile.Append(KvCardResultFile);
       
   913 			break;
       
   914 		case ETvCalFile:
       
   915 			dataFile=KvCalFile;
       
   916 			resultFile.Append(KvCalResultFile);
       
   917 			break;
       
   918 		case ETvCardLine:
       
   919 			dataFile=KvCardLine;
       
   920 			resultFile.Append(KvCardResultLine);
       
   921 			break;
       
   922 		case ETvCalLine:
       
   923 			dataFile=KvCalLine;
       
   924 			resultFile.Append(KvCalResultLine);
       
   925 			break;
       
   926 		}
       
   927 	resultFile.Append(KTestFileNameExt);
       
   928 
       
   929 	TFindFile* findFile = new(ELeave) TFindFile(iFsSession);
       
   930 	CleanupStack::PushL(findFile);//findFile
       
   931 	CDir* directory=NULL;
       
   932 
       
   933 	User::LeaveIfError(findFile->FindWildByDir(dataFile,KTestDirInput,directory));
       
   934 	CleanupStack::PopAndDestroy(findFile);//findFile
       
   935 	CleanupStack::PushL(directory);//directory
       
   936 	RFile file;
       
   937 	User::LeaveIfError(file.Replace(iFsSession, resultFile,EFileWrite+EFileShareAny+EFileStreamText));
       
   938 	CleanupClosePushL(file);//file
       
   939 
       
   940 	TBuf<200> title;
       
   941 	title.Format(_L("file name\tinternalize\texternalize\ttotal time\tnum of obj\theap size\tnum. Alloc int\tnum. Alloc ext\x0d\x0a"));
       
   942 	TheTest.Printf(title);
       
   943 	TBuf8<200> title8;
       
   944 	title8.Copy(title);
       
   945 	file.Write(title8);
       
   946 
       
   947 	TInt numberOfFiles=directory->Count();
       
   948 	CleanupStack::PopAndDestroy(2,directory);
       
   949 	}
       
   950 
       
   951 //@SYMTestCaseID PIM-TPERFOMANCE-0001
       
   952 	
       
   953 GLDEF_C TInt E32Main()
       
   954 	{
       
   955 	
       
   956 	TTime startTime;
       
   957 	startTime.UniversalTime();
       
   958 	
       
   959 	__UHEAP_MARK;
       
   960 	CTrapCleanup* cleanup = CTrapCleanup::New();
       
   961 	if	(!cleanup)
       
   962 		return KErrNoMemory;
       
   963 	TheTest.Start(_L("@SYMTestCaseID PIM-TPERFOMANCE-0001 Performance Test"));
       
   964 	
       
   965 	TRAPD(err,CTests::DoTestsL());
       
   966 #if !defined(__WINS__)
       
   967 	if (err!=KErrNone)
       
   968 		{
       
   969 		_LIT(KError,"Test left with error %d\r\n");
       
   970 		TheTest.Printf(KError,err);
       
   971 		TheTest.Getch();
       
   972 		}
       
   973 #endif
       
   974 	TheTest(err == KErrNone);
       
   975 	TheTest.Printf(_L("Test complete\r\n"));
       
   976 	User::After(3000000);
       
   977 	TheTest.End();
       
   978 	TheTest.Close();
       
   979 
       
   980 	delete cleanup;
       
   981 	__UHEAP_MARKEND;
       
   982 	
       
   983 	TTime finishTime;
       
   984 	finishTime.UniversalTime();
       
   985 	TReal elapsed = (TReal)finishTime.MicroSecondsFrom(startTime).Int64();
       
   986 	TheTest.Printf(_L("Elapsed time: %.4f\n"), elapsed/1000000);
       
   987 	
       
   988 	return (KErrNone);
       
   989 	}