diff -r 748ec5531811 -r 336bee5c2d35 textrendering/texthandling/ttext/T_CONVS1.CPP --- a/textrendering/texthandling/ttext/T_CONVS1.CPP Tue Aug 31 17:01:26 2010 +0300 +++ b/textrendering/texthandling/ttext/T_CONVS1.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" @@ -20,30 +20,20 @@ #include #include #include +#include #include #include -#include "T_CONVS1.h" - -#define test(cond) \ - { \ - TBool __bb = (cond); \ - TEST(__bb); \ - if (!__bb) \ - { \ - ERR_PRINTF1(_L("ERROR: Test Failed")); \ - User::Leave(1); \ - } \ - } const TInt KTestCleanupStack=0x20; LOCAL_D CTrapCleanup* TheTrapCleanup; +LOCAL_D RTest test(_L("T_CONVS1 - GlobalText 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 TTestFieldFactoryCONVS1 : public MTextFieldFactory +class TTestFieldFactory : public MTextFieldFactory { public: // from MTextFieldFactory @@ -52,7 +42,7 @@ // Returns NULL if it does not recognise/support the field type }; -CTextField* TTestFieldFactoryCONVS1::NewFieldL(TUid aFieldType) +CTextField* TTestFieldFactory::NewFieldL(TUid aFieldType) // Creates a field (in aHeader) of the type specified in aHeader // { @@ -65,7 +55,7 @@ _LIT(KOutputFile, "c:\\etext\\t_convs1.tst"); template -void CT_CONVS1::testStoreRestoreL(T& aCopy,const T& aOriginal) +void testStoreRestoreL(T& aCopy,const T& aOriginal) // Test document persistance. // { @@ -93,7 +83,7 @@ theFs.Close(); } -TInt CT_CONVS1::IsEqual(const CPlainText* aCopy,const CPlainText* aOriginal) +LOCAL_C TInt IsEqual(const CPlainText* aCopy,const CPlainText* aOriginal) // // Tests for equality of plain text components. // Takes account of multiple segments of a segmented text component. @@ -115,7 +105,7 @@ lengthRead+=orig.Length(); } test(lengthRead==lengthOfOriginal+1); - INFO_PRINTF1(_L("Restored plain text component matches original")); + test.Next(_L("Restored plain text component matches original")); TInt copyFieldCount=aCopy->FieldCount(); TInt origFieldCount=aOriginal->FieldCount(); test(copyFieldCount==origFieldCount); @@ -123,7 +113,7 @@ } -TInt CT_CONVS1::DocsEqual(const CGlobalText* aCopy,const CGlobalText* aOrig) +LOCAL_C TInt DocsEqual(const CGlobalText* aCopy,const CGlobalText* aOrig) // // // @@ -133,7 +123,7 @@ } -void CT_CONVS1::GenerateGlobalTextL() +void GenerateGlobalTextL() // // Create a global text documnet. // @@ -170,7 +160,7 @@ TParaFormatMask nn; r1->SetL((CParaFormat*)NULL,nn); CGlobalText* restoredDoc=CGlobalText::NewL(r1,cr1,CEditableText::ESegmentedStorage); // Store a text field in the global text. - TTestFieldFactoryCONVS1 factory; + TTestFieldFactory factory; globalDoc->SetFieldFactory(&factory); restoredDoc->SetFieldFactory(&factory); CTextField* field=NULL; @@ -181,10 +171,11 @@ globalDoc->InsertFieldL(0,field,KDateTimeFieldUid)); test(ret==KErrNone); // And do the streaming/restore. - INFO_PRINTF1(_L("Storing global text with field record")); - INFO_PRINTF1(_L("Restoring global text")); + test.Start(_L("Storing global text with field record")); + test.Next(_L("Restoring global text")); testStoreRestoreL(*restoredDoc,*globalDoc); test(DocsEqual(restoredDoc,globalDoc)); + test.End(); // Now clean up. TInt restoredCharChain=cr1->ChainCount(); TInt restoredParaChain=r1->ChainCount(); @@ -214,7 +205,7 @@ } -void CT_CONVS1::setupCleanup() +LOCAL_C void setupCleanup() // // Initialise the cleanup stack. // @@ -231,7 +222,7 @@ } -void CT_CONVS1::DeleteDataFile(const TDesC& aFullName) +LOCAL_C void DeleteDataFile(const TDesC& aFullName) { RFs fsSession; TInt err = fsSession.Connect(); @@ -260,31 +251,29 @@ } } -CT_CONVS1::CT_CONVS1() +GLDEF_C TInt E32Main() +// +// Test streaming conversions. +// { - SetTestStepName(KTestStep_T_CONVS1); + setupCleanup(); + test.Title(); + __UHEAP_MARK; + + test.Start(_L("Generate global text")); + test.Next(_L(" @SYMTestCaseID:SYSLIB-ETEXT-LEGACY-T_CONVS1-0001 ")); + TRAPD(r,GenerateGlobalTextL()); + test(r==KErrNone); + + __UHEAP_MARKEND; + + ::DeleteDataFile(KOutputFile); //deletion of data files must be before call to End() - DEF047652 + test.End(); + test.Close(); + delete TheTrapCleanup; + + + + return 0; } -TVerdict CT_CONVS1::doTestStepL() - { - SetTestStepResult(EFail); - - setupCleanup(); - __UHEAP_MARK; - - INFO_PRINTF1(_L("T_CONVS1 - GlobalText Persistence")); - INFO_PRINTF1(_L("Generate global text")); - INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-ETEXT-LEGACY-T_CONVS1-0001 ")); - TRAPD(error1, GenerateGlobalTextL()); - - __UHEAP_MARKEND; - DeleteDataFile(KOutputFile); //deletion of data files must be before call to End() - DEF047652 - delete TheTrapCleanup; - - if(error1 == KErrNone) - { - SetTestStepResult(EPass); - } - - return TestStepResult(); - }