diff -r 748ec5531811 -r 336bee5c2d35 textrendering/texthandling/ttext/TRTCUSTM.CPP --- a/textrendering/texthandling/ttext/TRTCUSTM.CPP Tue Aug 31 17:01:26 2010 +0300 +++ b/textrendering/texthandling/ttext/TRTCUSTM.CPP Wed Sep 01 12:39:40 2010 +0100 @@ -1,5 +1,5 @@ /* -* Copyright (c) 1997-2010 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of "Eclipse Public License v1.0" @@ -19,6 +19,7 @@ #include #include #include "TXTMRTSR.H" +#include #include #include #include @@ -26,19 +27,8 @@ #include #include #include -#include "TRTCUSTM.h" -#define test(cond) \ - { \ - TBool __bb = (cond); \ - TEST(__bb); \ - if (!__bb) \ - { \ - ERR_PRINTF1(_L("ERROR: Test Failed")); \ - User::Leave(1); \ - } \ - } - +GLDEF_C RTest test(_L("TRTCUSTM")); LOCAL_D RFs theFs; LOCAL_D CFileStore* TheStore; LOCAL_D CParaFormatLayer* GlobalParaFormatLayer; @@ -57,7 +47,7 @@ //////////////////////////////////////////////////////////////////////////////////////////// -class TTestFieldFactoryTRTCUSTM : public MTextFieldFactory +class TTestFieldFactory : public MTextFieldFactory { public: // from MTextFieldFactory @@ -66,7 +56,7 @@ // Returns NULL if it does not recognise/support the field type }; -CTextField* TTestFieldFactoryTRTCUSTM::NewFieldL(TUid aFieldType) +CTextField* TTestFieldFactory::NewFieldL(TUid aFieldType) // Creates a field (in aHeader) of the type specified in aHeader // { @@ -77,7 +67,7 @@ } ///////////////////////////////////////////////////////////////////////////////////////////// -void CT_TRTCUSTM::WriteInlineL(RWriteStream& aStream,CRichText* aRichText) +LOCAL_D void WriteInlineL(RWriteStream& aStream,CRichText* aRichText) { aRichText->CancelInsertCharFormat(); aRichText->ExternalizeFieldDataL(aStream); @@ -89,7 +79,7 @@ aRichText->ExternalizePlainTextL(aStream); } -void CT_TRTCUSTM::ReadInlineL(RReadStream& aStream,CRichText* aRichText) +LOCAL_D void ReadInlineL(RReadStream& aStream,CRichText* aRichText) { aRichText->InternalizeFieldDataL(aStream); aRichText->InternalizeStyleDataL(aStream); @@ -100,7 +90,7 @@ } -TStreamId CT_TRTCUSTM::PerformSaveL(CRichText* aRichText) +LOCAL_D TStreamId PerformSaveL(CRichText* aRichText) // { RStoreWriteStream out; @@ -114,7 +104,7 @@ } -CRichText* CT_TRTCUSTM::PerformLoadL(TStreamId aId) +LOCAL_C CRichText* PerformLoadL(TStreamId aId) // { CRichText* text=CRichText::NewL(GlobalParaFormatLayer,GlobalCharFormatLayer); @@ -128,7 +118,7 @@ } -CStyleList* CT_TRTCUSTM::CreatePopulatedStyleList() +LOCAL_C CStyleList* CreatePopulatedStyleList() // { // @@ -148,7 +138,7 @@ _LIT(KTRtCustOutputFile,"c:\\etext\\TRTCUSTM.DAT"); -void CT_TRTCUSTM::CustomLoadSave() +LOCAL_C void CustomLoadSave() { // Set up the framework theFs.Delete(KTRtCustOutputFile); @@ -159,7 +149,7 @@ // // Case (1) Rich text with owned style list. - no markup data // - INFO_PRINTF1(_L("RT + no markup + style list owned")); + test.Start(_L("RT + no markup + style list owned")); // // Setup the rich text CStyleList* list=CreatePopulatedStyleList(); @@ -185,7 +175,7 @@ // // Case (2) Rich text with referenced style list. - no markup data // - INFO_PRINTF1(_L("RT + no markup + style list externally owned")); + test.Next(_L("RT + no markup + style list externally owned")); // // Setup the rich text list=CreatePopulatedStyleList(); @@ -217,7 +207,7 @@ // // Case (3) Rich text with referenced style list. - with markup // - INFO_PRINTF1(_L("RT + markup + style list externally owned")); + test.Next(_L("RT + markup + style list externally owned")); // Setup the rich text list=CreatePopulatedStyleList(); richText1=CRichText::NewL(GlobalParaFormatLayer,GlobalCharFormatLayer,*list); @@ -254,7 +244,7 @@ // // Case (4) Rich text with no style list. - no effective markup // - INFO_PRINTF1(_L("RT + delete picture + no style list")); + test.Next(_L("RT + delete picture + no style list")); // Setup the rich text richText1=CRichText::NewL(GlobalParaFormatLayer,GlobalCharFormatLayer); hasMarkupData=richText1->HasMarkupData(); @@ -293,7 +283,7 @@ // // Case (5) Rich text with SetInsertCharFormat() // - INFO_PRINTF1(_L("RT + SetInsertCharFormatL()")); + test.Next(_L("RT + SetInsertCharFormatL()")); // Setup the rich text richText1=CRichText::NewL(GlobalParaFormatLayer,GlobalCharFormatLayer); hasMarkupData=richText1->HasMarkupData(); @@ -325,7 +315,7 @@ // Case (6) Rich text with components - default re/store used. // - INFO_PRINTF1(_L("RT + components")); + test.Next(_L("RT + components")); // Setup the rich text richText1=CRichText::NewL(GlobalParaFormatLayer,GlobalCharFormatLayer); hasMarkupData=richText1->HasMarkupData(); @@ -336,7 +326,7 @@ richText1->InsertL(richText1->DocumentLength(),CEditableText::EParagraphDelimiter); // // Create & insert some fields - TTestFieldFactoryTRTCUSTM factory; + TTestFieldFactory factory; richText1->SetFieldFactory(&factory); CTextField* field=NULL; CTextField* field2=NULL; @@ -394,7 +384,7 @@ // // Case (7) Rich text with fields with referenced style list with markup // - INFO_PRINTF1(_L("RT + fields + markup + style list")); + test.Next(_L("RT + fields + markup + style list")); // Setup the rich text list=CreatePopulatedStyleList(); richText1=CRichText::NewL(GlobalParaFormatLayer,GlobalCharFormatLayer,*list); @@ -475,7 +465,7 @@ // // Case (8) Rich text with fields with referenced style list with markup - default store // - INFO_PRINTF1(_L("RT + fields + markup + style list - default store")); + test.Next(_L("RT + fields + markup + style list - default store")); // Setup the rich text list=CreatePopulatedStyleList(); richText1=CRichText::NewL(GlobalParaFormatLayer,GlobalCharFormatLayer,*list); @@ -528,7 +518,7 @@ // // Case (9) Rich text with no components whatsoever - default store // - INFO_PRINTF1(_L("RT + no markup whatsoever - default store")); + test.Next(_L("RT + no markup whatsoever - default store")); richText1=CRichText::NewL(GlobalParaFormatLayer,GlobalCharFormatLayer); hasMarkupData=richText1->HasMarkupData(); test(!hasMarkupData); @@ -558,6 +548,7 @@ // // CleanupStack::PopAndDestroy(); // TheStore + test.End(); } /** @@ -576,10 +567,10 @@ dealing with paragraph delimiter and hidden characters in a paragraph @SYMDEF PDEF101757 */ -void CT_TRTCUSTM::TestDEF101757() +LOCAL_C void TestDEF101757() { TFindFieldInfo info; - TTestFieldFactoryTRTCUSTM factory; + TTestFieldFactory factory; CTextField* field=NULL; CTextField* field1=NULL; CTextField* field2=NULL; @@ -589,7 +580,7 @@ _LIT(KSample1, "Hello"); // length:5 _LIT(KSample2, "How are you"); // length:11 - INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-ETEXT-CT-3380 Insertion and deletion to rich text object ")); + test.Start(_L(" @SYMTestCaseID:SYSLIB-ETEXT-CT-3380 Insertion and deletion to rich text object ")); CRichText* richText=CRichText::NewL(GlobalParaFormatLayer,GlobalCharFormatLayer); CleanupStack::PushL(richText); @@ -706,11 +697,12 @@ test(richText->FieldCount()==2); CleanupStack::PopAndDestroy(richText); + test.End(); } //Testcode for INC054540 -void CT_TRTCUSTM::TestINC054540() +LOCAL_C void TestINC054540() { theFs.Delete(KTRtCustOutputFile); theFs.MkDirAll(KTRtCustOutputFile); @@ -719,12 +711,12 @@ // //test 1: Test INC054540 fix for 255 fields // - INFO_PRINTF1(_L("test")); + test.Start(_L("test")); CRichText* richText1=CRichText::NewL(GlobalParaFormatLayer,GlobalCharFormatLayer); // // Now add a text field to this. - TTestFieldFactoryTRTCUSTM factory; + TTestFieldFactory factory; richText1->SetFieldFactory(&factory); CTextField* field=NULL; TInt x=0; @@ -772,7 +764,7 @@ // //test 2: Test INC054540 fix for more than 255 fields // - INFO_PRINTF1(_L("test for more than 255 fields")); + test.Next(_L("test for more than 255 fields")); richText1=CRichText::NewL(GlobalParaFormatLayer,GlobalCharFormatLayer); // Add the text fields richText1->SetFieldFactory(&factory); @@ -820,10 +812,11 @@ // // CleanupStack::PopAndDestroy(); // TheStore + test.End(); } -void CT_TRTCUSTM::doMainL() +LOCAL_C void doMainL() { GlobalParaFormatLayer=CParaFormatLayer::NewL(); GlobalCharFormatLayer=CCharFormatLayer::NewL(); @@ -839,7 +832,7 @@ } -void CT_TRTCUSTM::setupCleanup() +LOCAL_C void setupCleanup() // // Initialise the cleanup stack. // @@ -856,7 +849,7 @@ } -void CT_TRTCUSTM::DeleteDataFile(const TDesC& aFullName) +LOCAL_C void DeleteDataFile(const TDesC& aFullName) { RFs fsSession; TInt err = fsSession.Connect(); @@ -885,31 +878,26 @@ } } +GLDEF_C TInt E32Main() +// +// Test permanent file TheStore. +// + { + test.Title(); + setupCleanup(); + __UHEAP_MARK; +// + test.Start(_L("Testing custom save/load optimization")); + TRAPD(ret,doMainL()); + test(ret==KErrNone); + + ::DeleteDataFile(KTRtCustOutputFile); //deletion of data files must be before call to End() - DEF047652 + test.End(); +// + __UHEAP_MARKEND; + delete TheTrapCleanup; + test.Close(); -CT_TRTCUSTM::CT_TRTCUSTM() - { - SetTestStepName(KTestStep_T_TRTCUSTM); + return KErrNone; } -TVerdict CT_TRTCUSTM::doTestStepL() - { - SetTestStepResult(EFail); - - setupCleanup(); - __UHEAP_MARK; - - INFO_PRINTF1(_L("TRTCUSTM")); - INFO_PRINTF1(_L("Testing custom save/load optimization")); - TRAPD(error1, doMainL()); - DeleteDataFile(KTRtCustOutputFile); //deletion of data files must be before call to End() - DEF047652 - - __UHEAP_MARKEND; - delete TheTrapCleanup; - - if(error1 == KErrNone) - { - SetTestStepResult(EPass); - } - - return TestStepResult(); - }