diff -r 748ec5531811 -r 336bee5c2d35 textrendering/textformatting/test/src/TCustomCharMapping.cpp --- a/textrendering/textformatting/test/src/TCustomCharMapping.cpp Tue Aug 31 17:01:26 2010 +0300 +++ b/textrendering/textformatting/test/src/TCustomCharMapping.cpp Wed Sep 01 12:39:40 2010 +0100 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2005-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" @@ -15,6 +15,8 @@ * */ + +#include "TGraphicsContext.h" #include #include #include @@ -23,11 +25,26 @@ #include #include #include -#include "TGraphicsContext.h" -#include "tcustomcharmapping.h" + +namespace LocalToFile +{ + +_LIT(KTCustomCharMapping, "TCustomCharMapping"); +const TInt KDisplayWidth = 202; +const TInt KDisplayHeight = 100; +const TInt KPictureCharacter = 0xFFFC; +RTest test(KTCustomCharMapping); -namespace LocalToTCustomCharMapping -{ +enum TTestNum + { + EDefaultBehaviourInvisible = 0, + EDefaultBehaviourVisible = 1, + ECustomRemappingInvisible = 2, + ECustomRemappingVisible = 3, + ENewTest = 4 //Test remapping with no custom remapper and some flags explicitly set to invisible + }; + + class CPinkSquare : public CPicture { public: @@ -134,7 +151,7 @@ CParaFormat* iParagraphFormat; }; } -using namespace LocalToTCustomCharMapping; +using namespace LocalToFile; class CTestTextView // slightly naughty { @@ -248,18 +265,18 @@ { } -void CTCustomCharMappingStep::DoTestL(TDes& aText, CTextLayout* /*aLayout*/, CTestGraphicsDevice* aDevice, CTextView* aView, TTestNum aTestNum) +void DoTestL(TDes& aText, CTextLayout* /*aLayout*/, CTestGraphicsDevice* aDevice, CTextView* aView, TTestNum aTestNum) { aText = KTestStrings[aTestNum][0]; aDevice->LineArray().ResetLineArray(); aView->HandleGlobalChangeL(); const TTestGCDisplayLine* line1 = &(aDevice->LineArray().Line(0)); const TTestGCDisplayLine* line2 = aDevice->LineArray().Find(KTestStrings[aTestNum][1]); - TEST(0 != line1); - TEST(0 != line2); + test(0 != line1); + test(0 != line2); // Can't always do a direct comparison of lines because same string // may appear in more than one line, so compare contents - TEST(line1->iLineData.Compare(line2->iLineData) == 0); + test(line1->iLineData.Compare(line2->iLineData) == 0); } @@ -271,12 +288,12 @@ @SYMTestExpectedResults The test must not fail. @SYMPREQ 1128 Placeholders for invisible characers in rich text shall be customizable */ -void CTCustomCharMappingStep::RunInstallationTestsL() +void RunInstallationTestsL() { // Note: If you need to move these heap checks any further "in" to focus // on a specific test then you will have to move all the setup code in as // well - and still preserve the two different display widths in use - INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-FORM-CT-0147 ")); + test.Next(_L(" @SYMTestCaseID:SYSLIB-FORM-CT-0147 ")); __UHEAP_MARK; CActiveScheduler* scheduler = new(ELeave) CActiveScheduler; CleanupStack::PushL(scheduler); @@ -300,21 +317,21 @@ MFormCustomInvisibleCharacterRemapper* remapper; // read what the ptr is set to - check it is null remapper = layout->GetCustomInvisibleCharacterRemapper(); - INFO_PRINTF1(_L("Test uninstalled")); - TEST(remapper == NULL); + test.Next(_L("Test uninstalled")); + test(remapper == NULL); // install a custom remapper - get the ptr - check it is set MFormCustomInvisibleCharacterRemapper* customRemapper = CCustomRemapper::NewL(); layout->SetCustomInvisibleCharacterRemapper(customRemapper); remapper = layout->GetCustomInvisibleCharacterRemapper(); - INFO_PRINTF1(_L("Test installed")); - TEST(remapper == customRemapper); + test.Next(_L("Test installed")); + test(remapper == customRemapper); // set the ptr back to null (deinstall) - get the ptr - check it is null layout->SetCustomInvisibleCharacterRemapper(NULL); remapper = layout->GetCustomInvisibleCharacterRemapper(); - INFO_PRINTF1(_L("Test uninstalled again")); - TEST(remapper == NULL); + test.Next(_L("Test uninstalled again")); + test(remapper == NULL); delete customRemapper; @@ -335,9 +352,9 @@ @SYMTestExpectedResults The test must not fail. @SYMPREQ 1128 Placeholders for invisible characers in rich text shall be customizable */ -void CTCustomCharMappingStep::RunDefaultBehaviourTestsL() +void RunDefaultBehaviourTestsL() { - INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-FORM-CT-0148 ")); + test.Next(_L(" @SYMTestCaseID:SYSLIB-FORM-CT-0148 ")); CActiveScheduler* scheduler = new(ELeave) CActiveScheduler; CleanupStack::PushL(scheduler); CActiveScheduler::Install(scheduler); @@ -359,7 +376,7 @@ // Start by making sure no custom remapper is installed MFormCustomInvisibleCharacterRemapper* remapper; remapper = layout->GetCustomInvisibleCharacterRemapper(); - TEST(remapper == NULL); + test(remapper == NULL); // Set all invisible characters to be invisible TNonPrintingCharVisibility visibility; @@ -367,7 +384,7 @@ layout->SetNonPrintingCharsVisibility(visibility); // Test remapping with no custom remapper and flags set to invisible - INFO_PRINTF1(_L("Test uninstalled behaviour - flags invisible")); + test.Next(_L("Test uninstalled behaviour - flags invisible")); DoTestL(text, layout, device, view, EDefaultBehaviourInvisible); // Now set all invisible characters to be visible @@ -375,11 +392,11 @@ layout->SetNonPrintingCharsVisibility(visibility); // Test remapping with no custom remapper and flags set to visible - INFO_PRINTF1(_L("Test uninstalled behaviour - flags visible")); + test.Next(_L("Test uninstalled behaviour - flags visible")); DoTestL(text, layout, device, view, EDefaultBehaviourVisible); // Test remapping with no custom remapper and some flags explicitly set to invisible - INFO_PRINTF1(_L("Test uninstalled behaviour - some flags invisible")); + test.Next(_L("Test uninstalled behaviour - some flags invisible")); //Set all invisible characters to be visible visibility.SetAllVisible(); //Set some attributes explicitly to be invisible @@ -411,12 +428,12 @@ @SYMTestExpectedResults The test must not fail. @SYMPREQ 1128 Placeholders for invisible characers in rich text shall be customizable */ -void CTCustomCharMappingStep::RunCustomBehaviourTestsL() +void RunCustomBehaviourTestsL() { // Note: If you need to move these heap checks any further "in" to focus // on a specific test then you will have to move all the setup code in as // well - and still preserve the two different display widths in use - INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-FORM-CT-0149 ")); + test.Next(_L(" @SYMTestCaseID:SYSLIB-FORM-CT-0149 ")); __UHEAP_MARK; CActiveScheduler* scheduler = new(ELeave) CActiveScheduler; CleanupStack::PushL(scheduler); @@ -441,7 +458,7 @@ MFormCustomInvisibleCharacterRemapper* customRemapper = CCustomRemapper::NewL(); layout->SetCustomInvisibleCharacterRemapper(customRemapper); remapper = layout->GetCustomInvisibleCharacterRemapper(); - TEST(remapper == customRemapper); + test(remapper == customRemapper); // Set all invisible characters to be invisible TNonPrintingCharVisibility visibility; @@ -449,7 +466,7 @@ layout->SetNonPrintingCharsVisibility(visibility); // Test remapping with custom remapper and flags set to invisible - INFO_PRINTF1(_L("Test installed behaviour - flags invisible")); + test.Next(_L("Test installed behaviour - flags invisible")); DoTestL(text, layout, device, view, ECustomRemappingInvisible); // Now set all invisible characters to be visible @@ -457,13 +474,13 @@ layout->SetNonPrintingCharsVisibility(visibility); // Test remapping with custom remapper and flags set to visible - INFO_PRINTF1(_L("Test installed behaviour - flags visible")); + test.Next(_L("Test installed behaviour - flags visible")); DoTestL(text, layout, device, view, ECustomRemappingVisible); // Now we are finished deinstall and delete it layout->SetCustomInvisibleCharacterRemapper(NULL); remapper = layout->GetCustomInvisibleCharacterRemapper(); - TEST(remapper == NULL); + test(remapper == NULL); delete customRemapper; CleanupStack::PopAndDestroy(offScreenContext); @@ -474,30 +491,39 @@ __UHEAP_MARKEND; } -CTCustomCharMappingStep::CTCustomCharMappingStep() - { - - } -TVerdict CTCustomCharMappingStep::doTestStepL() - { - SetTestStepResult(EPass); - INFO_PRINTF1(_L("Test installation/deinstallatiion")); - TInt error = RFbsSession::Connect(); - if (error == KErrNotFound) - { - FbsStartup(); - error = RFbsSession::Connect(); - } - TEST(error == KErrNone); - TRAP(error, RunInstallationTestsL()); - TEST(error == KErrNone); - INFO_PRINTF1(_L("Test uninstalled behaviour")); - TRAP(error, RunDefaultBehaviourTestsL()); - TEST(error == KErrNone); - INFO_PRINTF1(_L("Test behaviour with custom remapper installed")); - TRAP(error, RunCustomBehaviourTestsL()); - TEST(error == KErrNone); - RFbsSession::Disconnect(); - return TestStepResult(); - } +TInt E32Main() + { + __UHEAP_MARK; + test.Title(); + static CTrapCleanup* TrapCleanup = CTrapCleanup::New(); + test.Start(_L("Test installation/deinstallatiion")); + TInt error = RFbsSession::Connect(); + if (error == KErrNotFound) + { + FbsStartup(); + error = RFbsSession::Connect(); + } + test(error == KErrNone); + TRAP(error, RunInstallationTestsL()); + test(error == KErrNone); + test.Next(_L("Test uninstalled behaviour")); + TRAP(error, RunDefaultBehaviourTestsL()); + test(error == KErrNone); + test.Next(_L("Test behaviour with custom remapper installed")); + TRAP(error, RunCustomBehaviourTestsL()); + test(error == KErrNone); + RFbsSession::Disconnect(); + test.End(); + delete TrapCleanup; + test.Close(); + __UHEAP_MARKEND; + User::Heap().Check(); + return error; + } + + +#if defined(__WINS__) +EXPORT_C TInt EntryPoint(TAny*) {return E32Main();} +#endif +