textrendering/texthandling/ttext/TRTCUSTM.CPP
branchRCL_3
changeset 55 336bee5c2d35
parent 54 748ec5531811
equal deleted inserted replaced
54:748ec5531811 55:336bee5c2d35
     1 /*
     1 /*
     2 * Copyright (c) 1997-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    17 
    17 
    18 
    18 
    19 #include <txtrich.h>
    19 #include <txtrich.h>
    20 #include <txtstyle.h>
    20 #include <txtstyle.h>
    21 #include "TXTMRTSR.H"
    21 #include "TXTMRTSR.H"
       
    22 #include <e32test.h>
    22 #include <gdi.h>
    23 #include <gdi.h>
    23 #include <conpics.h>											   						 
    24 #include <conpics.h>											   						 
    24 #include <s32mem.h>
    25 #include <s32mem.h>
    25 #include <s32file.h>
    26 #include <s32file.h>
    26 #include <flddef.h>
    27 #include <flddef.h>
    27 #include <fldbltin.h>
    28 #include <fldbltin.h>
    28 #include <fldset.h>
    29 #include <fldset.h>
    29 #include "TRTCUSTM.h"
    30 
    30 
    31 GLDEF_C RTest test(_L("TRTCUSTM"));
    31 #define test(cond)											\
       
    32 	{														\
       
    33 	TBool __bb = (cond);									\
       
    34 	TEST(__bb);												\
       
    35 	if (!__bb)												\
       
    36 		{													\
       
    37 		ERR_PRINTF1(_L("ERROR: Test Failed"));				\
       
    38 		User::Leave(1);										\
       
    39 		}													\
       
    40 	}
       
    41 
       
    42 LOCAL_D RFs theFs;
    32 LOCAL_D RFs theFs;
    43 LOCAL_D CFileStore* TheStore;
    33 LOCAL_D CFileStore* TheStore;
    44 LOCAL_D CParaFormatLayer* GlobalParaFormatLayer;
    34 LOCAL_D CParaFormatLayer* GlobalParaFormatLayer;
    45 LOCAL_D CCharFormatLayer* GlobalCharFormatLayer;
    35 LOCAL_D CCharFormatLayer* GlobalCharFormatLayer;
    46 LOCAL_D CTrapCleanup* TheTrapCleanup;
    36 LOCAL_D CTrapCleanup* TheTrapCleanup;
    55 	CStreamStore* iStore;
    45 	CStreamStore* iStore;
    56 	};
    46 	};
    57 
    47 
    58 
    48 
    59 ////////////////////////////////////////////////////////////////////////////////////////////
    49 ////////////////////////////////////////////////////////////////////////////////////////////
    60 class TTestFieldFactoryTRTCUSTM : public MTextFieldFactory
    50 class TTestFieldFactory : public MTextFieldFactory
    61 	{
    51 	{
    62 public:
    52 public:
    63 	// from MTextFieldFactory
    53 	// from MTextFieldFactory
    64 	virtual CTextField* NewFieldL(TUid aFieldType); 
    54 	virtual CTextField* NewFieldL(TUid aFieldType); 
    65 	// Creates a field of the type specified
    55 	// Creates a field of the type specified
    66 	// Returns NULL if it does not recognise/support the field type
    56 	// Returns NULL if it does not recognise/support the field type
    67 	};
    57 	};
    68 
    58 
    69 CTextField* TTestFieldFactoryTRTCUSTM::NewFieldL(TUid aFieldType)
    59 CTextField* TTestFieldFactory::NewFieldL(TUid aFieldType)
    70 // Creates a field (in aHeader) of the type specified in aHeader
    60 // Creates a field (in aHeader) of the type specified in aHeader
    71 // 
    61 // 
    72 	{
    62 	{
    73 	CTextField* field=NULL;
    63 	CTextField* field=NULL;
    74 	if (aFieldType==KDateTimeFieldUid)
    64 	if (aFieldType==KDateTimeFieldUid)
    75 		field = (CTextField*)new(ELeave) CDateTimeField();
    65 		field = (CTextField*)new(ELeave) CDateTimeField();
    76 	return field;
    66 	return field;
    77 	}
    67 	}
    78 /////////////////////////////////////////////////////////////////////////////////////////////
    68 /////////////////////////////////////////////////////////////////////////////////////////////
    79 
    69 
    80 void CT_TRTCUSTM::WriteInlineL(RWriteStream& aStream,CRichText* aRichText)
    70 LOCAL_D void WriteInlineL(RWriteStream& aStream,CRichText* aRichText)
    81 	{
    71 	{
    82 	aRichText->CancelInsertCharFormat();
    72 	aRichText->CancelInsertCharFormat();
    83 	aRichText->ExternalizeFieldDataL(aStream);
    73 	aRichText->ExternalizeFieldDataL(aStream);
    84 	aRichText->ExternalizeStyleDataL(aStream);
    74 	aRichText->ExternalizeStyleDataL(aStream);
    85 	TBool hasMarkupData=aRichText->HasMarkupData();
    75 	TBool hasMarkupData=aRichText->HasMarkupData();
    87 	if (hasMarkupData)
    77 	if (hasMarkupData)
    88 		aRichText->ExternalizeMarkupDataL(aStream);	
    78 		aRichText->ExternalizeMarkupDataL(aStream);	
    89 	aRichText->ExternalizePlainTextL(aStream);
    79 	aRichText->ExternalizePlainTextL(aStream);
    90 	}
    80 	}
    91 
    81 
    92 void CT_TRTCUSTM::ReadInlineL(RReadStream& aStream,CRichText* aRichText)
    82 LOCAL_D void ReadInlineL(RReadStream& aStream,CRichText* aRichText)
    93 	{
    83 	{
    94 	aRichText->InternalizeFieldDataL(aStream);
    84 	aRichText->InternalizeFieldDataL(aStream);
    95 	aRichText->InternalizeStyleDataL(aStream);
    85 	aRichText->InternalizeStyleDataL(aStream);
    96 	TBool hasMarkupData=(TBool)aStream.ReadUint8L();
    86 	TBool hasMarkupData=(TBool)aStream.ReadUint8L();
    97 	if (hasMarkupData)
    87 	if (hasMarkupData)
    98 		aRichText->InternalizeMarkupDataL(aStream);	
    88 		aRichText->InternalizeMarkupDataL(aStream);	
    99 	aRichText->InternalizePlainTextL(aStream);
    89 	aRichText->InternalizePlainTextL(aStream);
   100 	}
    90 	}
   101 
    91 
   102 
    92 
   103 TStreamId CT_TRTCUSTM::PerformSaveL(CRichText* aRichText)
    93 LOCAL_D TStreamId PerformSaveL(CRichText* aRichText)
   104 //
    94 //
   105 	{
    95 	{
   106 	RStoreWriteStream out;
    96 	RStoreWriteStream out;
   107 	TStreamId id1=out.CreateLC(*TheStore);
    97 	TStreamId id1=out.CreateLC(*TheStore);
   108 	WriteInlineL(out,aRichText);
    98 	WriteInlineL(out,aRichText);
   112 	TheStore->CommitL();
   102 	TheStore->CommitL();
   113 	return id1;
   103 	return id1;
   114 	}
   104 	}
   115 
   105 
   116 
   106 
   117 CRichText* CT_TRTCUSTM::PerformLoadL(TStreamId aId)
   107 LOCAL_C CRichText* PerformLoadL(TStreamId aId)
   118 //
   108 //
   119 	{
   109 	{
   120 	CRichText* text=CRichText::NewL(GlobalParaFormatLayer,GlobalCharFormatLayer);
   110 	CRichText* text=CRichText::NewL(GlobalParaFormatLayer,GlobalCharFormatLayer);
   121 	RStoreReadStream in;
   111 	RStoreReadStream in;
   122 	in.OpenLC(*TheStore,aId);
   112 	in.OpenLC(*TheStore,aId);
   126 	CleanupStack::PopAndDestroy();  // in
   116 	CleanupStack::PopAndDestroy();  // in
   127 	return text;
   117 	return text;
   128 	}
   118 	}
   129 
   119 
   130 
   120 
   131 CStyleList* CT_TRTCUSTM::CreatePopulatedStyleList()
   121 LOCAL_C CStyleList* CreatePopulatedStyleList()
   132 //
   122 //
   133 	{
   123 	{
   134 	//
   124 	//
   135 	// Create style aswell.
   125 	// Create style aswell.
   136 	CStyleList* list=CStyleList::NewL();
   126 	CStyleList* list=CStyleList::NewL();
   146 	return list;
   136 	return list;
   147 	}
   137 	}
   148 
   138 
   149 _LIT(KTRtCustOutputFile,"c:\\etext\\TRTCUSTM.DAT");
   139 _LIT(KTRtCustOutputFile,"c:\\etext\\TRTCUSTM.DAT");
   150 
   140 
   151 void CT_TRTCUSTM::CustomLoadSave()
   141 LOCAL_C void CustomLoadSave()
   152 	{
   142 	{
   153 // Set up the framework
   143 // Set up the framework
   154 	theFs.Delete(KTRtCustOutputFile);
   144 	theFs.Delete(KTRtCustOutputFile);
   155 	theFs.MkDirAll(KTRtCustOutputFile);
   145 	theFs.MkDirAll(KTRtCustOutputFile);
   156 	TheStore=CPermanentFileStore::CreateLC(theFs,KTRtCustOutputFile,EFileRead|EFileWrite);
   146 	TheStore=CPermanentFileStore::CreateLC(theFs,KTRtCustOutputFile,EFileRead|EFileWrite);
   157 	TheStore->SetTypeL(TheStore->Layout());
   147 	TheStore->SetTypeL(TheStore->Layout());
   158 
   148 
   159 //
   149 //
   160 // Case (1) Rich text with owned style list. - no markup data
   150 // Case (1) Rich text with owned style list. - no markup data
   161 //
   151 //
   162 	INFO_PRINTF1(_L("RT + no markup + style list owned"));
   152 	test.Start(_L("RT + no markup + style list owned"));
   163 	//
   153 	//
   164 	// Setup the rich text
   154 	// Setup the rich text
   165 	CStyleList* list=CreatePopulatedStyleList();
   155 	CStyleList* list=CreatePopulatedStyleList();
   166 	CRichText* richText1=CRichText::NewL(GlobalParaFormatLayer,GlobalCharFormatLayer,*list);
   156 	CRichText* richText1=CRichText::NewL(GlobalParaFormatLayer,GlobalCharFormatLayer,*list);
   167 	TBool hasMarkupData=richText1->HasMarkupData();
   157 	TBool hasMarkupData=richText1->HasMarkupData();
   183 	delete empty;
   173 	delete empty;
   184 	empty=NULL;
   174 	empty=NULL;
   185 //
   175 //
   186 // Case (2) Rich text with referenced style list. - no markup data
   176 // Case (2) Rich text with referenced style list. - no markup data
   187 //
   177 //
   188 	INFO_PRINTF1(_L("RT + no markup + style list externally owned"));
   178 	test.Next(_L("RT + no markup + style list externally owned"));
   189 	//
   179 	//
   190 	// Setup the rich text
   180 	// Setup the rich text
   191 	list=CreatePopulatedStyleList();
   181 	list=CreatePopulatedStyleList();
   192 	richText1=CRichText::NewL(GlobalParaFormatLayer,GlobalCharFormatLayer,*list,CEditableText::ESegmentedStorage,2);
   182 	richText1=CRichText::NewL(GlobalParaFormatLayer,GlobalCharFormatLayer,*list,CEditableText::ESegmentedStorage,2);
   193 	richText1->SetStyleListExternallyOwned(ETrue);
   183 	richText1->SetStyleListExternallyOwned(ETrue);
   215 	delete list;
   205 	delete list;
   216 	empty=NULL;
   206 	empty=NULL;
   217 //
   207 //
   218 // Case (3) Rich text with referenced style list. - with markup
   208 // Case (3) Rich text with referenced style list. - with markup
   219 //
   209 //
   220 	INFO_PRINTF1(_L("RT + markup + style list externally owned"));
   210 	test.Next(_L("RT + markup + style list externally owned"));
   221 	// Setup the rich text
   211 	// Setup the rich text
   222 	list=CreatePopulatedStyleList();
   212 	list=CreatePopulatedStyleList();
   223 	richText1=CRichText::NewL(GlobalParaFormatLayer,GlobalCharFormatLayer,*list);
   213 	richText1=CRichText::NewL(GlobalParaFormatLayer,GlobalCharFormatLayer,*list);
   224 	richText1->SetStyleListExternallyOwned(ETrue);
   214 	richText1->SetStyleListExternallyOwned(ETrue);
   225 	hasMarkupData=richText1->HasMarkupData();
   215 	hasMarkupData=richText1->HasMarkupData();
   252 	delete list;
   242 	delete list;
   253 	empty=NULL;
   243 	empty=NULL;
   254 //
   244 //
   255 // Case (4) Rich text with no style list. - no effective markup
   245 // Case (4) Rich text with no style list. - no effective markup
   256 //
   246 //
   257 	INFO_PRINTF1(_L("RT + delete picture + no style list"));
   247 	test.Next(_L("RT + delete picture + no style list"));
   258 	// Setup the rich text
   248 	// Setup the rich text
   259 	richText1=CRichText::NewL(GlobalParaFormatLayer,GlobalCharFormatLayer);
   249 	richText1=CRichText::NewL(GlobalParaFormatLayer,GlobalCharFormatLayer);
   260 	hasMarkupData=richText1->HasMarkupData();
   250 	hasMarkupData=richText1->HasMarkupData();
   261 	test(!hasMarkupData);
   251 	test(!hasMarkupData);
   262 	richText1->InsertL(0,_L("hello"));
   252 	richText1->InsertL(0,_L("hello"));
   291 	delete empty;
   281 	delete empty;
   292 	empty=NULL;
   282 	empty=NULL;
   293 //
   283 //
   294 // Case (5) Rich text with SetInsertCharFormat()
   284 // Case (5) Rich text with SetInsertCharFormat()
   295 //
   285 //
   296 	INFO_PRINTF1(_L("RT + SetInsertCharFormatL()"));
   286 	test.Next(_L("RT + SetInsertCharFormatL()"));
   297 	// Setup the rich text
   287 	// Setup the rich text
   298 	richText1=CRichText::NewL(GlobalParaFormatLayer,GlobalCharFormatLayer);
   288 	richText1=CRichText::NewL(GlobalParaFormatLayer,GlobalCharFormatLayer);
   299 	hasMarkupData=richText1->HasMarkupData();
   289 	hasMarkupData=richText1->HasMarkupData();
   300 	test(!hasMarkupData);
   290 	test(!hasMarkupData);
   301 	richText1->InsertL(0,_L("hello"));
   291 	richText1->InsertL(0,_L("hello"));
   323 	empty=NULL;
   313 	empty=NULL;
   324 //
   314 //
   325 // Case (6) Rich text with components - default re/store used.
   315 // Case (6) Rich text with components - default re/store used.
   326 //
   316 //
   327 
   317 
   328 	INFO_PRINTF1(_L("RT + components"));
   318 	test.Next(_L("RT + components"));
   329 	// Setup the rich text
   319 	// Setup the rich text
   330 	richText1=CRichText::NewL(GlobalParaFormatLayer,GlobalCharFormatLayer);
   320 	richText1=CRichText::NewL(GlobalParaFormatLayer,GlobalCharFormatLayer);
   331 	hasMarkupData=richText1->HasMarkupData();
   321 	hasMarkupData=richText1->HasMarkupData();
   332 	test(!hasMarkupData);
   322 	test(!hasMarkupData);
   333 	richText1->InsertL(0,_L("hello"));
   323 	richText1->InsertL(0,_L("hello"));
   334 	richText1->InsertL(richText1->DocumentLength(),CEditableText::EParagraphDelimiter);
   324 	richText1->InsertL(richText1->DocumentLength(),CEditableText::EParagraphDelimiter);
   335 	richText1->InsertL(richText1->DocumentLength(),_L("there"));
   325 	richText1->InsertL(richText1->DocumentLength(),_L("there"));
   336 	richText1->InsertL(richText1->DocumentLength(),CEditableText::EParagraphDelimiter);
   326 	richText1->InsertL(richText1->DocumentLength(),CEditableText::EParagraphDelimiter);
   337 	//
   327 	//
   338 	// Create & insert some fields
   328 	// Create & insert some fields
   339 	TTestFieldFactoryTRTCUSTM factory;
   329 	TTestFieldFactory factory;
   340 	richText1->SetFieldFactory(&factory);
   330 	richText1->SetFieldFactory(&factory);
   341 	CTextField* field=NULL;
   331 	CTextField* field=NULL;
   342 	CTextField* field2=NULL;
   332 	CTextField* field2=NULL;
   343 	TRAP(ret,
   333 	TRAP(ret,
   344 	field=factory.NewFieldL(KDateTimeFieldUid));	test(ret==KErrNone);
   334 	field=factory.NewFieldL(KDateTimeFieldUid));	test(ret==KErrNone);
   392 	empty=NULL;
   382 	empty=NULL;
   393 	delete pictureFactory;
   383 	delete pictureFactory;
   394 //
   384 //
   395 // Case (7) Rich text with fields with referenced style list with markup
   385 // Case (7) Rich text with fields with referenced style list with markup
   396 //
   386 //
   397 	INFO_PRINTF1(_L("RT + fields + markup + style list"));
   387 	test.Next(_L("RT + fields + markup + style list"));
   398 	// Setup the rich text
   388 	// Setup the rich text
   399 	list=CreatePopulatedStyleList();
   389 	list=CreatePopulatedStyleList();
   400 	richText1=CRichText::NewL(GlobalParaFormatLayer,GlobalCharFormatLayer,*list);
   390 	richText1=CRichText::NewL(GlobalParaFormatLayer,GlobalCharFormatLayer,*list);
   401 	hasMarkupData=richText1->HasMarkupData();
   391 	hasMarkupData=richText1->HasMarkupData();
   402 	test(hasMarkupData);
   392 	test(hasMarkupData);
   473 	delete empty;
   463 	delete empty;
   474 	empty=NULL;
   464 	empty=NULL;
   475 //
   465 //
   476 // Case (8) Rich text with fields with referenced style list with markup - default store
   466 // Case (8) Rich text with fields with referenced style list with markup - default store
   477 //
   467 //
   478 	INFO_PRINTF1(_L("RT + fields + markup + style list - default store"));
   468 	test.Next(_L("RT + fields + markup + style list - default store"));
   479 	// Setup the rich text
   469 	// Setup the rich text
   480 	list=CreatePopulatedStyleList();
   470 	list=CreatePopulatedStyleList();
   481 	richText1=CRichText::NewL(GlobalParaFormatLayer,GlobalCharFormatLayer,*list);
   471 	richText1=CRichText::NewL(GlobalParaFormatLayer,GlobalCharFormatLayer,*list);
   482 	hasMarkupData=richText1->HasMarkupData();
   472 	hasMarkupData=richText1->HasMarkupData();
   483 	test(hasMarkupData);
   473 	test(hasMarkupData);
   526 	delete empty;
   516 	delete empty;
   527 	empty=NULL;	//
   517 	empty=NULL;	//
   528 //
   518 //
   529 // Case (9) Rich text with no components whatsoever - default store
   519 // Case (9) Rich text with no components whatsoever - default store
   530 //
   520 //
   531 	INFO_PRINTF1(_L("RT + no markup whatsoever - default store"));
   521 	test.Next(_L("RT + no markup whatsoever - default store"));
   532 	richText1=CRichText::NewL(GlobalParaFormatLayer,GlobalCharFormatLayer);
   522 	richText1=CRichText::NewL(GlobalParaFormatLayer,GlobalCharFormatLayer);
   533 	hasMarkupData=richText1->HasMarkupData();
   523 	hasMarkupData=richText1->HasMarkupData();
   534 	test(!hasMarkupData);
   524 	test(!hasMarkupData);
   535 	richText1->InsertL(0,_L("hello"));
   525 	richText1->InsertL(0,_L("hello"));
   536 	richText1->InsertL(richText1->DocumentLength(),CEditableText::EParagraphDelimiter);
   526 	richText1->InsertL(richText1->DocumentLength(),CEditableText::EParagraphDelimiter);
   556 	delete empty;
   546 	delete empty;
   557 	empty=NULL;
   547 	empty=NULL;
   558 	//
   548 	//
   559 	//
   549 	//
   560 	CleanupStack::PopAndDestroy();  // TheStore
   550 	CleanupStack::PopAndDestroy();  // TheStore
       
   551 	test.End();
   561 	}
   552 	}
   562 	
   553 	
   563 /**
   554 /**
   564 @SYMTestCaseID 			SYSLIB-ETEXT-CT-3380
   555 @SYMTestCaseID 			SYSLIB-ETEXT-CT-3380
   565 @SYMTestCaseDesc  		Inserting and deleting rich text and verify behaviours of DeleteParagraph(), Delete() and NotifyDelete(); 
   556 @SYMTestCaseDesc  		Inserting and deleting rich text and verify behaviours of DeleteParagraph(), Delete() and NotifyDelete(); 
   574 						7. Insert plain text in between two fields to rich text object then delete plain text to merge two fields
   565 						7. Insert plain text in between two fields to rich text object then delete plain text to merge two fields
   575 @SYMTestExpectedResults	CTextFieldSet, CPlainText, CRichText's APIs for performing various types of deletion function properly when 
   566 @SYMTestExpectedResults	CTextFieldSet, CPlainText, CRichText's APIs for performing various types of deletion function properly when 
   576   dealing with paragraph delimiter and hidden characters in a paragraph
   567   dealing with paragraph delimiter and hidden characters in a paragraph
   577 @SYMDEF					PDEF101757
   568 @SYMDEF					PDEF101757
   578 */
   569 */
   579 void CT_TRTCUSTM::TestDEF101757()
   570 LOCAL_C void TestDEF101757()
   580 	{	
   571 	{	
   581 	TFindFieldInfo info;
   572 	TFindFieldInfo info;
   582 	TTestFieldFactoryTRTCUSTM factory;
   573 	TTestFieldFactory factory;
   583 	CTextField* field=NULL;
   574 	CTextField* field=NULL;
   584 	CTextField* field1=NULL;
   575 	CTextField* field1=NULL;
   585 	CTextField* field2=NULL;
   576 	CTextField* field2=NULL;
   586 	CTextField* field3=NULL;
   577 	CTextField* field3=NULL;
   587 	CTextField* field4=NULL;
   578 	CTextField* field4=NULL;
   588 	
   579 	
   589 	_LIT(KSample1, "Hello"); // length:5
   580 	_LIT(KSample1, "Hello"); // length:5
   590 	_LIT(KSample2, "How are you"); // length:11
   581 	_LIT(KSample2, "How are you"); // length:11
   591 	
   582 	
   592 	INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-ETEXT-CT-3380 Insertion and deletion to rich text object "));
   583 	test.Start(_L(" @SYMTestCaseID:SYSLIB-ETEXT-CT-3380 Insertion and deletion to rich text object "));
   593 	
   584 	
   594 	CRichText* richText=CRichText::NewL(GlobalParaFormatLayer,GlobalCharFormatLayer);
   585 	CRichText* richText=CRichText::NewL(GlobalParaFormatLayer,GlobalCharFormatLayer);
   595 	CleanupStack::PushL(richText);
   586 	CleanupStack::PushL(richText);
   596 	
   587 	
   597 	// Case1
   588 	// Case1
   704 	test(info.iFirstFieldLen==10);
   695 	test(info.iFirstFieldLen==10);
   705 	test(info.iFirstFieldPos==10);
   696 	test(info.iFirstFieldPos==10);
   706 	test(richText->FieldCount()==2);
   697 	test(richText->FieldCount()==2);
   707 	
   698 	
   708 	CleanupStack::PopAndDestroy(richText);
   699 	CleanupStack::PopAndDestroy(richText);
       
   700 	test.End();
   709 	}
   701 	}
   710 	
   702 	
   711 
   703 
   712 //Testcode for INC054540
   704 //Testcode for INC054540
   713 void CT_TRTCUSTM::TestINC054540()
   705 LOCAL_C void TestINC054540()
   714 	{
   706 	{
   715 	theFs.Delete(KTRtCustOutputFile);
   707 	theFs.Delete(KTRtCustOutputFile);
   716 	theFs.MkDirAll(KTRtCustOutputFile);
   708 	theFs.MkDirAll(KTRtCustOutputFile);
   717 	TheStore=CPermanentFileStore::CreateLC(theFs,KTRtCustOutputFile,EFileRead|EFileWrite);
   709 	TheStore=CPermanentFileStore::CreateLC(theFs,KTRtCustOutputFile,EFileRead|EFileWrite);
   718 	TheStore->SetTypeL(TheStore->Layout());
   710 	TheStore->SetTypeL(TheStore->Layout());
   719 //
   711 //
   720 //test 1: Test INC054540 fix for 255 fields
   712 //test 1: Test INC054540 fix for 255 fields
   721 //	
   713 //	
   722 	INFO_PRINTF1(_L("test"));
   714 	test.Start(_L("test"));
   723 	
   715 	
   724 	CRichText* richText1=CRichText::NewL(GlobalParaFormatLayer,GlobalCharFormatLayer);
   716 	CRichText* richText1=CRichText::NewL(GlobalParaFormatLayer,GlobalCharFormatLayer);
   725 	//
   717 	//
   726 	// Now add a text field to this.
   718 	// Now add a text field to this.
   727 	TTestFieldFactoryTRTCUSTM factory;
   719 	TTestFieldFactory factory;
   728 	richText1->SetFieldFactory(&factory);
   720 	richText1->SetFieldFactory(&factory);
   729 	CTextField* field=NULL;
   721 	CTextField* field=NULL;
   730 	TInt x=0;
   722 	TInt x=0;
   731 	//add 255 fields
   723 	//add 255 fields
   732 	while(x<255)
   724 	while(x<255)
   770 	empty=NULL;
   762 	empty=NULL;
   771 	
   763 	
   772 //
   764 //
   773 //test 2: Test INC054540 fix for more than 255 fields
   765 //test 2: Test INC054540 fix for more than 255 fields
   774 //	
   766 //	
   775 	INFO_PRINTF1(_L("test for more than 255 fields"));
   767 	test.Next(_L("test for more than 255 fields"));
   776 	richText1=CRichText::NewL(GlobalParaFormatLayer,GlobalCharFormatLayer);
   768 	richText1=CRichText::NewL(GlobalParaFormatLayer,GlobalCharFormatLayer);
   777 	// Add the text fields
   769 	// Add the text fields
   778 	richText1->SetFieldFactory(&factory);
   770 	richText1->SetFieldFactory(&factory);
   779 	field=NULL;
   771 	field=NULL;
   780 	x=0;
   772 	x=0;
   818 	delete empty;
   810 	delete empty;
   819 	empty=NULL;
   811 	empty=NULL;
   820 	//
   812 	//
   821 	//
   813 	//
   822 	CleanupStack::PopAndDestroy();  // TheStore
   814 	CleanupStack::PopAndDestroy();  // TheStore
   823 	}
   815 	test.End();
   824 
   816 	}
   825 
   817 
   826 void CT_TRTCUSTM::doMainL()
   818 
       
   819 LOCAL_C void doMainL()
   827 	{
   820 	{
   828 	GlobalParaFormatLayer=CParaFormatLayer::NewL();
   821 	GlobalParaFormatLayer=CParaFormatLayer::NewL();
   829 	GlobalCharFormatLayer=CCharFormatLayer::NewL();
   822 	GlobalCharFormatLayer=CCharFormatLayer::NewL();
   830 	theFs.Connect();
   823 	theFs.Connect();
   831 	//
   824 	//
   837 	delete GlobalCharFormatLayer;
   830 	delete GlobalCharFormatLayer;
   838 	theFs.Close();
   831 	theFs.Close();
   839 	}
   832 	}
   840 
   833 
   841 
   834 
   842 void CT_TRTCUSTM::setupCleanup()
   835 LOCAL_C void setupCleanup()
   843 //
   836 //
   844 // Initialise the cleanup stack.
   837 // Initialise the cleanup stack.
   845 //
   838 //
   846     {
   839     {
   847 	TheTrapCleanup=CTrapCleanup::New();
   840 	TheTrapCleanup=CTrapCleanup::New();
   854 		});
   847 		});
   855 	test(r==KErrNone);
   848 	test(r==KErrNone);
   856 	}
   849 	}
   857 
   850 
   858 
   851 
   859 void CT_TRTCUSTM::DeleteDataFile(const TDesC& aFullName)
   852 LOCAL_C void DeleteDataFile(const TDesC& aFullName)
   860 	{
   853 	{
   861 	RFs fsSession;
   854 	RFs fsSession;
   862 	TInt err = fsSession.Connect();
   855 	TInt err = fsSession.Connect();
   863 	if(err == KErrNone)
   856 	if(err == KErrNone)
   864 		{
   857 		{
   883 		{
   876 		{
   884 		RDebug::Print(_L("Error %d connecting file session. File: %S.\n"), err, &aFullName);
   877 		RDebug::Print(_L("Error %d connecting file session. File: %S.\n"), err, &aFullName);
   885 		}
   878 		}
   886 	}
   879 	}
   887 
   880 
   888 
   881 GLDEF_C TInt E32Main()
   889 CT_TRTCUSTM::CT_TRTCUSTM()
   882 //
       
   883 // Test permanent file TheStore.
       
   884 //
   890     {
   885     {
   891     SetTestStepName(KTestStep_T_TRTCUSTM);
   886 	test.Title();
       
   887 	setupCleanup();
       
   888 	__UHEAP_MARK;
       
   889 //
       
   890 	test.Start(_L("Testing custom save/load optimization"));
       
   891 	TRAPD(ret,doMainL());	
       
   892 	test(ret==KErrNone);
       
   893 	
       
   894 	::DeleteDataFile(KTRtCustOutputFile); 	//deletion of data files must be before call to End() - DEF047652
       
   895 	test.End();
       
   896 //
       
   897 	__UHEAP_MARKEND;
       
   898 	delete TheTrapCleanup;
       
   899 	test.Close();
       
   900 
       
   901 	return KErrNone;
   892     }
   902     }
   893 
   903 
   894 TVerdict CT_TRTCUSTM::doTestStepL()
       
   895     {
       
   896     SetTestStepResult(EFail);
       
   897 
       
   898     setupCleanup();
       
   899     __UHEAP_MARK;
       
   900     
       
   901     INFO_PRINTF1(_L("TRTCUSTM"));
       
   902     INFO_PRINTF1(_L("Testing custom save/load optimization"));
       
   903     TRAPD(error1, doMainL());
       
   904     DeleteDataFile(KTRtCustOutputFile);   //deletion of data files must be before call to End() - DEF047652
       
   905 
       
   906     __UHEAP_MARKEND;
       
   907     delete TheTrapCleanup;
       
   908 
       
   909     if(error1 == KErrNone)
       
   910         {
       
   911         SetTestStepResult(EPass);
       
   912         }
       
   913 
       
   914     return TestStepResult();
       
   915     }