diff -r 601ab138ba0b -r a7c938434754 textrendering/texthandling/ttext/T_CONVS.CPP --- a/textrendering/texthandling/ttext/T_CONVS.CPP Tue Jul 06 16:23:19 2010 +0300 +++ b/textrendering/texthandling/ttext/T_CONVS.CPP Wed Aug 18 11:34:25 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 1997-2010 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" @@ -21,21 +21,31 @@ #include #include #include -#include #include #include #include +#include "T_CONVS.h" + +#define test(cond) \ + { \ + TBool __bb = (cond); \ + TEST(__bb); \ + if (!__bb) \ + { \ + ERR_PRINTF1(_L("ERROR: Test Failed")); \ + User::Leave(1); \ + } \ + } const TInt KTestCleanupStack=0x20; const TInt KTestExpandSize=0x20; LOCAL_D CTrapCleanup* TheTrapCleanup; -LOCAL_D RTest test(_L("T_CONVS - EditableText Persistence")); LOCAL_D TPtrC bigBuf(_L("This is a very big buffer indeed, containing text and special characters,\ big enough to fill a segment of an editable text component that employs segmented storage")); //////////////////////////////////////////////////////////////////////////////////////////// -class TTestFieldFactory : public MTextFieldFactory +class TTestFieldFactoryCONVS : public MTextFieldFactory { public: // from MTextFieldFactory @@ -44,7 +54,7 @@ // Returns NULL if it does not recognise/support the field type }; -CTextField* TTestFieldFactory::NewFieldL(TUid aFieldType) +CTextField* TTestFieldFactoryCONVS::NewFieldL(TUid aFieldType) // Creates a field (in aHeader) of the type specified in aHeader // { @@ -56,14 +66,14 @@ ///////////////////////////////////////////////////////////////////////////////////////////// template -void testCopy(T &aCopy,const T &anOriginal) +void CT_CONVS::testCopy(T &aCopy,const T &anOriginal) // // Copy anOriginal to aCopy using memory-based streams. // { CBufSeg *buf=CBufSeg::NewL(KTestExpandSize); if (buf==NULL) - test.Panic(_L("Allocating buffer")); + User::Panic(_L("Allocating buffer"), 1234); // Write anOriginal out to the buffer. RBufWriteStream out(*buf); @@ -71,7 +81,7 @@ test(r==KErrNone); TRAP(r,out.CommitL()); if (r!=KErrNone) - test.Panic(_L("Committing write stream")); + User::Panic(_L("Committing write stream"), 1234); // Read anOriginal in from the buffer. RBufReadStream in(*buf); @@ -87,7 +97,7 @@ _LIT(KOutputFile, "c:\\etext\\t_convs.tst"); template -void testStoreRestoreL(T& aCopy,const T& aOriginal) +void CT_CONVS::testStoreRestoreL(T& aCopy,const T& aOriginal) // Test document persistance. // { @@ -117,14 +127,14 @@ template -void testCopyChain(T &aCopy,const T &anOriginal,TInt aExcludeCount,const CFormatLayer* aBase) +void CT_CONVS::testCopyChain(T &aCopy,const T &anOriginal,TInt aExcludeCount,const CFormatLayer* aBase) // // Copy anOriginal to aCopy using memory-based streams. // { CBufSeg *buf=CBufSeg::NewL(KTestExpandSize); if (buf==NULL) - test.Panic(_L("Allocating buffer")); + User::Panic(_L("Allocating buffer"), 1234); // Write anOriginal out to the buffer. RBufWriteStream out(*buf); @@ -132,7 +142,7 @@ test(r==KErrNone); TRAP(r,out.CommitL()); if (r!=KErrNone) - test.Panic(_L("Committing write stream")); + User::Panic(_L("Committing write stream"), 1234); // Read anOriginal in from the buffer. RBufReadStream in(*buf); @@ -147,7 +157,7 @@ } -LOCAL_C TInt IsEqual(const CPlainText* aCopy,const CPlainText* aOriginal) +TInt CT_CONVS::IsEqual(const CPlainText* aCopy,const CPlainText* aOriginal) // // Returns true if aCopy contents matches aOriginal contents. // Takes account of multiple segments of a segmented text component. @@ -174,35 +184,35 @@ } -void testPlainTextL(CEditableText::TDocumentStorage aStorage) +void CT_CONVS::testPlainTextL(CEditableText::TDocumentStorage aStorage) // // Test streaming CPlainText. // {// Create the plain text components. - test.Start(_L("Streaming CPlainText")); + INFO_PRINTF1(_L("Streaming CPlainText")); CPlainText* copy=CPlainText::NewL(aStorage); CPlainText* testDoc=CPlainText::NewL(aStorage); // // Set the original - empty - test.Start(_L("empty.")); + INFO_PRINTF1(_L("empty.")); testStoreRestoreL(*copy,*testDoc); test(IsEqual(copy,testDoc)); // - test.Next(_L("paragraph delimiter")); + INFO_PRINTF1(_L("paragraph delimiter")); TRAPD(r,testDoc->InsertL(0,CEditableText::EParagraphDelimiter)); test(r==KErrNone); testStoreRestoreL(*copy,*testDoc); test(IsEqual(copy,testDoc)); // // Next test with tons of text guaranteed to force segment break when using segmented storage. - test.Next(_L("big text component")); + INFO_PRINTF1(_L("big text component")); testDoc->InsertL(0,bigBuf); testStoreRestoreL(*copy,*testDoc); test(IsEqual(copy,testDoc)); // // Now test with field components. - test.Next(_L("big text doc with field components.")); - TTestFieldFactory factory; + INFO_PRINTF1(_L("big text doc with field components.")); + TTestFieldFactoryCONVS factory; testDoc->SetFieldFactory(&factory); copy->SetFieldFactory(&factory); CTextField* field=NULL; @@ -216,18 +226,17 @@ test(IsEqual(copy,testDoc)); // // - test.End(); delete copy; delete testDoc; } -void testGlobalTextL(CEditableText::TDocumentStorage aStorage) +void CT_CONVS::testGlobalTextL(CEditableText::TDocumentStorage aStorage) // // Test streaming CGlobalText. // {// Create the plain text components. - test.Next(_L("Streaming CGlobalText")); + INFO_PRINTF1(_L("Streaming CGlobalText")); CParaFormatLayer* paraLayer=CParaFormatLayer::NewL(); CCharFormatLayer* charLayer=CCharFormatLayer::NewL(); // Set something interesting in the layers: @@ -244,24 +253,22 @@ CGlobalText* testDoc=CGlobalText::NewL(paraLayer,charLayer,aStorage); // Set the original - empty - test.Start(_L("empty.")); + INFO_PRINTF1(_L("empty.")); testStoreRestoreL(*copy,*testDoc); test(IsEqual(copy,testDoc)); // - test.Next(_L("paragraph delimiter")); + INFO_PRINTF1(_L("paragraph delimiter")); TRAPD(r,testDoc->InsertL(0,CEditableText::EParagraphDelimiter)); test(r==KErrNone); testStoreRestoreL(*copy,*testDoc); test(IsEqual(copy,testDoc)); // Next test with tons of text guaranteed to force segment break when using segmented storage. - test.Next(_L("big text component")); + INFO_PRINTF1(_L("big text component")); testDoc->InsertL(0,bigBuf); testStoreRestoreL(*copy,*testDoc); test(IsEqual(copy,testDoc)); - test.End(); - test.End(); delete copy; delete testDoc; delete paraLayer; @@ -270,7 +277,7 @@ } -LOCAL_C TInt LayerIsEqual(const CParaFormatLayer* aRestored,const CParaFormatLayer* aOriginal) +TInt CT_CONVS::LayerIsEqual(const CParaFormatLayer* aRestored,const CParaFormatLayer* aOriginal) // // Returns true if aRestored contents matches aOriginal contents. // @@ -291,7 +298,7 @@ } -LOCAL_C TInt LayerIsEqual(const CCharFormatLayer* aRestored,const CCharFormatLayer* aOriginal) +TInt CT_CONVS::LayerIsEqual(const CCharFormatLayer* aRestored,const CCharFormatLayer* aOriginal) // // Returns true if aRestored contents matches aOriginal contents. // @@ -308,12 +315,12 @@ } -void testFmtLayerStoreL() +void CT_CONVS::testFmtLayerStoreL() // // Test the format layer StoreL(). // { - test.Start(_L("CParaFormatLayer")); + INFO_PRINTF1(_L("CParaFormatLayer")); // Create test layers. CParaFormatLayer* pfl1=NULL; CParaFormatLayer* restored=NULL; @@ -327,13 +334,13 @@ TParaFormatMask pm1; pm1.SetAll(); // Sets all but the compound attributes. // TEST ONE DEFAULT CASES - test.Start(_L("Default paragraph format values.")); + INFO_PRINTF1(_L("Default paragraph format values.")); TRAP(r,pfl1->SetL(pf1,pm1)); test(r==KErrNone); testCopy(*restored,*pfl1); test(LayerIsEqual(restored,pfl1)); test(restored->SenseBase()==pfl1->SenseBase()); // Both should default to based on NULL // TEST TWO - test.Next(_L("Setting all attributes")); + INFO_PRINTF1(_L("Setting all attributes")); pf1->iLeftMarginInTwips=5000; pm1.ClearAll(); pm1.SetAttrib(EAttLeftMargin); pf1->iRightMarginInTwips=5001; pm1.SetAttrib(EAttRightMargin); pf1->iIndentInTwips=5002;pm1.SetAttrib(EAttIndent); @@ -399,7 +406,6 @@ testCopy(*restored,*pfl1); test(LayerIsEqual(restored,pfl1)); test(restored->SenseBase()==pfl1->SenseBase()); // Both should default to based on NULL - test.End(); // delete pf1; delete pfl1; @@ -407,9 +413,9 @@ // // Now the CCharFormatLayer Store/Restore // - test.Next(_L("CCharFormatLayer")); + INFO_PRINTF1(_L("CCharFormatLayer")); // - test.Start(_L("Setting all attributes")); + INFO_PRINTF1(_L("Setting all attributes")); // Create test layers. CCharFormatLayer* cfl1=NULL; CCharFormatLayer* cRestored=NULL; @@ -451,11 +457,10 @@ // delete cfl1; delete cRestored; - test.End(); } -LOCAL_C TInt ChainIsEqual(const CParaFormatLayer* aCopy,const CParaFormatLayer* aOriginal) +TInt CT_CONVS::ChainIsEqual(const CParaFormatLayer* aCopy,const CParaFormatLayer* aOriginal) // // Tests that the restored chain is identical to the original chain. // @@ -479,7 +484,7 @@ } -LOCAL_C TInt ChainIsEqual(const CCharFormatLayer* aCopy,const CCharFormatLayer* aOriginal) +TInt CT_CONVS::ChainIsEqual(const CCharFormatLayer* aCopy,const CCharFormatLayer* aOriginal) // // Tests that the restored chain is identical to the original chain. // @@ -503,13 +508,13 @@ } -void DoParaChainL() +void CT_CONVS::DoParaChainL() // // Tests the streaming of a chain of format layers // { - test.Next(_L("Re/StoreChainL()")); - test.Start(_L("CParaFormatLayer")); + INFO_PRINTF1(_L("Re/StoreChainL()")); + INFO_PRINTF1(_L("CParaFormatLayer")); // Create the chain of para format layers. CParaFormatLayer* l1=CParaFormatLayer::NewL(); CParaFormatLayer* l2=CParaFormatLayer::NewL(); @@ -585,12 +590,12 @@ } -void DoCharChainL() +void CT_CONVS::DoCharChainL() // // // { - test.Next(_L("CCharFormatLayer")); + INFO_PRINTF1(_L("CCharFormatLayer")); // Create the chain of character format layers. CCharFormatLayer* cl1=CCharFormatLayer::NewL(); CCharFormatLayer* cl2=CCharFormatLayer::NewL(); @@ -630,7 +635,7 @@ charMask.SetAttrib(EAttFontTypeface); cl4->SetL(charFormat,charMask); // NOW DO IT - test.Start(_L("Chain 4 layers deep, terminating on a based on NULL")); + INFO_PRINTF1(_L("Chain 4 layers deep, terminating on a based on NULL")); testCopyChain(*rChar,*cl1,0,(const CFormatLayer*)NULL); TInt restoredChainCount=rChar->ChainCount(); test(ChainIsEqual(rChar,cl1)); @@ -651,7 +656,7 @@ } -void DoCharChainVariant1() +void CT_CONVS::DoCharChainVariant1() // // Case 2: Where the chain does not terminate at a NULL link. // @@ -695,7 +700,7 @@ charMask.SetAttrib(EAttFontTypeface); cl4->SetL(charFormat,charMask); // NOW DO IT - test.Next(_L("Chain 3 layers deep, terminating on a non-NULL based-on")); + INFO_PRINTF1(_L("Chain 3 layers deep, terminating on a non-NULL based-on")); testCopyChain(*rChar,*cl1,1,(const CFormatLayer*)cl4); TInt restoredChainCount=rChar->ChainCount(); test(ChainIsEqual(rChar,cl1)); @@ -713,14 +718,10 @@ delete cl2; delete cl3; delete cl4; - - test.End(); - test.End(); - test.End(); } -void testFmtLayerStoreChainL() +void CT_CONVS::testFmtLayerStoreChainL() // // Controls the testing of the chainig stuff. // @@ -733,7 +734,7 @@ } -void testFmtLayerL() +void CT_CONVS::testFmtLayerL() // // Tests the streaming of format layers. // @@ -743,7 +744,7 @@ } -LOCAL_C void setupCleanup() +void CT_CONVS::setupCleanup() // // Initialise the cleanup stack. // @@ -760,7 +761,7 @@ } -LOCAL_C void DeleteDataFile(const TDesC& aFullName) +void CT_CONVS::DeleteDataFile(const TDesC& aFullName) { RFs fsSession; TInt err = fsSession.Connect(); @@ -789,40 +790,38 @@ } } -GLDEF_C TInt E32Main() -// -// Test streaming conversions. -// +CT_CONVS::CT_CONVS() { - setupCleanup(); - test.Title(); - __UHEAP_MARK; - - test.Start(_L(" @SYMTestCaseID:SYSLIB-ETEXT-LEGACY-T_CONVS-0001 EText components using Flat Storage ")); - TRAPD(r,testPlainTextL(CEditableText::EFlatStorage)); - test(r==KErrNone); - TRAP(r,testGlobalTextL(CEditableText::EFlatStorage)); - test(r==KErrNone); - -// - test.Next(_L("EText components using Segmented storage")); - TRAP(r,testPlainTextL(CEditableText::ESegmentedStorage)); - test(r==KErrNone); - TRAP(r,testGlobalTextL(CEditableText::ESegmentedStorage)); - test(r==KErrNone); - - test.Next(_L("Format Layer components")); - TRAP(r,testFmtLayerL()); - test(r==KErrNone); - -// test.End(); - __UHEAP_MARKEND; - - ::DeleteDataFile(KOutputFile); //deletion of data files must be before call to End() - DEF047652 - test.End(); - test.Close(); - delete TheTrapCleanup; - - return 0; + SetTestStepName(KTestStep_T_CONVS); } +TVerdict CT_CONVS::doTestStepL() + { + SetTestStepResult(EFail); + + INFO_PRINTF1(_L("T_CONVS - EditableText Persistence")); + setupCleanup(); + __UHEAP_MARK; + + INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-ETEXT-LEGACY-T_CONVS-0001 EText components using Flat Storage ")); + TRAPD(error1, testPlainTextL(CEditableText::EFlatStorage)); + TRAPD(error2, testGlobalTextL(CEditableText::EFlatStorage)); + + INFO_PRINTF1(_L("EText components using Segmented storage")); + TRAPD(error3, testPlainTextL(CEditableText::ESegmentedStorage)); + TRAPD(error4, testGlobalTextL(CEditableText::ESegmentedStorage)); + + INFO_PRINTF1(_L("Format Layer components")); + TRAPD(error5, testFmtLayerL()); + + __UHEAP_MARKEND; + DeleteDataFile(KOutputFile); //deletion of data files must be before call to End() - DEF047652 + delete TheTrapCleanup; + + if(error1 == KErrNone && error2 == KErrNone && error3 == KErrNone && error4 == KErrNone && error5 == KErrNone) + { + SetTestStepResult(EPass); + } + + return TestStepResult(); + }