os/textandloc/textrendering/textformatting/test/src/TCustomCharMapping.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/textandloc/textrendering/textformatting/test/src/TCustomCharMapping.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,503 @@
     1.4 +/*
     1.5 +* Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies).
     1.6 +* All rights reserved.
     1.7 +* This component and the accompanying materials are made available
     1.8 +* under the terms of "Eclipse Public License v1.0"
     1.9 +* which accompanies this distribution, and is available
    1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.11 +*
    1.12 +* Initial Contributors:
    1.13 +* Nokia Corporation - initial contribution.
    1.14 +*
    1.15 +* Contributors:
    1.16 +*
    1.17 +* Description: 
    1.18 +*
    1.19 +*/
    1.20 +
    1.21 +#include <e32std.h>
    1.22 +#include <e32test.h>
    1.23 +#include <frmtlay.h>
    1.24 +#include <frmtview.h>
    1.25 +#include <frmconst.h>
    1.26 +#include <txtlaydc.h>
    1.27 +#include <txtetext.h>
    1.28 +#include <w32std.h>
    1.29 +#include "TGraphicsContext.h"
    1.30 +#include "tcustomcharmapping.h"
    1.31 +
    1.32 +namespace LocalToTCustomCharMapping
    1.33 +{
    1.34 +class CPinkSquare : public CPicture
    1.35 +	{
    1.36 +public:
    1.37 +	// Size of square in twips.
    1.38 +	// 600 is 15 pixels using the standard test graphics device at
    1.39 +	// its default resolution.
    1.40 +	enum { KWidth = 600, KHeight = 600 };
    1.41 +	CPinkSquare()
    1.42 +		{}
    1.43 +	void Draw(CGraphicsContext& aGc, const TPoint& aTopLeft, const TRect& aClipRect, MGraphicsDeviceMap* aMap) const
    1.44 +		{
    1.45 +		// This picture is a magenta square
    1.46 +		TPoint size(KWidth, KHeight);
    1.47 +		if (aMap)
    1.48 +			size = aMap->TwipsToPixels(size);
    1.49 +		TRect rect(aTopLeft, aTopLeft + size);
    1.50 +		aGc.SetClippingRect(aClipRect);
    1.51 +		aGc.SetDrawMode(CGraphicsContext::EDrawModePEN);
    1.52 +		aGc.SetPenColor(KRgbMagenta);
    1.53 +		aGc.SetBrushStyle(CGraphicsContext::ESolidBrush);
    1.54 +		aGc.SetBrushColor(KRgbMagenta);
    1.55 +		aGc.DrawRect(rect);
    1.56 +		}
    1.57 +	void ExternalizeL(RWriteStream&) const
    1.58 +		{}
    1.59 +	void GetOriginalSizeInTwips(TSize& a) const
    1.60 +		{
    1.61 +		a.iWidth = CPinkSquare::KWidth;
    1.62 +		a.iHeight = CPinkSquare::KHeight;
    1.63 +		}
    1.64 +	};
    1.65 +
    1.66 +_LIT(KEnd, "\x2029");
    1.67 +class TDocModel : public MLayDoc
    1.68 +	{
    1.69 +public:
    1.70 +	TDocModel(const TDesC& aDes)
    1.71 +	 :	iDes(&aDes), iParagraphFormat(0)
    1.72 +		{}
    1.73 +	void SetParagraphFormat(CParaFormat* a)
    1.74 +		{
    1.75 +		iParagraphFormat = a;
    1.76 +		}
    1.77 +	// From MLayDoc
    1.78 +	TInt LdDocumentLength() const
    1.79 +		{ return iDes->Length(); }
    1.80 +	TInt LdToParagraphStart(TInt& a) const
    1.81 +		{
    1.82 +		TInt curr = a;
    1.83 +		if (a < LdDocumentLength())
    1.84 +			{
    1.85 +			a = iDes->Left(a).LocateReverse(0x2029);
    1.86 +			a = a < 0? 0 : a + 1;
    1.87 +			}
    1.88 +		return curr - a;
    1.89 +		}
    1.90 +	void GetParagraphFormatL(CParaFormat* aFormat, TInt) const
    1.91 +		{
    1.92 +		if (iParagraphFormat)
    1.93 +			{
    1.94 +			aFormat->CopyL(*iParagraphFormat);
    1.95 +			return;
    1.96 +			}
    1.97 +		aFormat->Reset();
    1.98 +		TTabStop tabStop;
    1.99 +		tabStop.iTwipsPosition = 1000;
   1.100 +		tabStop.iType = TTabStop::ELeftTab;
   1.101 +		aFormat->StoreTabL(tabStop);
   1.102 +		}
   1.103 +	void GetChars(TPtrC& aView,TCharFormat& aFormat, TInt aStartPos)const
   1.104 +		{
   1.105 +		TCharFormat cf;
   1.106 +		aFormat = cf;
   1.107 +		if (aStartPos == LdDocumentLength())
   1.108 +			aView.Set(KEnd);
   1.109 +		else
   1.110 +			aView.Set(iDes->Mid(aStartPos));
   1.111 +		}
   1.112 +	TInt GetPictureSizeInTwips(TSize& aSize, TInt aPos) const
   1.113 +		{
   1.114 +		if ((*iDes)[aPos] != KPictureCharacter)
   1.115 +			return KErrNotFound;
   1.116 +		aSize.iWidth = CPinkSquare::KWidth;
   1.117 +		aSize.iHeight = CPinkSquare::KHeight;
   1.118 +		return KErrNone;
   1.119 +		}
   1.120 +	CPicture* PictureHandleL(TInt aPos, TForcePictureLoad) const
   1.121 +		{
   1.122 +		if ((*iDes)[aPos] != KPictureCharacter)
   1.123 +			return 0;
   1.124 +		return new(ELeave) CPinkSquare;
   1.125 +		}
   1.126 +	TBool EnquirePageBreak(TInt aPos, TInt aLength)const
   1.127 +		{
   1.128 +		return iDes->Mid(aPos, aLength).Locate(0x000C) < 0?
   1.129 +			EFalse : ETrue;
   1.130 +		}
   1.131 +	TBool SelectParagraphLabel(TInt)
   1.132 +		{ return EFalse; }
   1.133 +	void CancelSelectLabel()
   1.134 +		{}
   1.135 +private:
   1.136 +	const TDesC* iDes;
   1.137 +	CParaFormat* iParagraphFormat;
   1.138 +	};
   1.139 +}
   1.140 +using namespace LocalToTCustomCharMapping;
   1.141 +
   1.142 +class CTestTextView	// slightly naughty
   1.143 +	{
   1.144 +public:
   1.145 +	static void SetContextForFlickerFreeRedraw(CTextView* aView, CBitmapContext* aContext)
   1.146 +		{
   1.147 +		aView->iOffScreenContext = aContext;
   1.148 +		}
   1.149 +	};
   1.150 +
   1.151 +
   1.152 +static const TInt KTestCases = 5;
   1.153 +static const TInt KVariants = 2;
   1.154 +
   1.155 +// For tests 0 to 3 the source string consists of:
   1.156 +// 'Y' <hard space> 'Z' <normal space> <non-breaking hyphen> <zero width space>
   1.157 +static const TPtrC KTestStrings[KTestCases][KVariants] =
   1.158 +	{
   1.159 +		{	// Test remapping with no custom remapper and flags set to invisible
   1.160 +			// The non-breaking hyphen is turned into a normal hyphen
   1.161 +			// The zero width space disappears (0xFFFF) and the hard space becomes a normal space
   1.162 +			// All done by MTmCustom::Map()
   1.163 +		_S("\x0059\x00A0\x005A\x0020\x2011\x200B"),
   1.164 +		_S("\xFFFF\x0059\x0020\x005A\x0020\x002D\xFFFF\xFFFF"),
   1.165 +		},
   1.166 +		{	// Test remapping with no custom remapper and flags set to visible
   1.167 +			// The non-breaking hyphen becomes a tilde
   1.168 +			// The normal space and the zero width space become visible middle dots
   1.169 +			// The hard (non-breaking) space becomes a degree sign
   1.170 +			// The paragraph sign becomes a pilcrow
   1.171 +			// All done by MTmCustom::Map()
   1.172 +		_S("\x0059\x00A0\x005A\x0020\x2011\x200B"),
   1.173 +		_S("\xFFFF\x0059\x00B0\x005A\x00B7\x007E\x00B7\x00B6\xFFFF"),
   1.174 +		},
   1.175 +		{	// Test remapping with custom remapper and flags set to invisible
   1.176 +			// The non-breaking hyphen is turned into a normal hyphen
   1.177 +			// The zero width space disappears (0xFFFF) and the hard space becomes a normal space
   1.178 +			// All done by MTmCustom::Map()
   1.179 +			// The hard (non-breaking) space becomes a caret
   1.180 +			// This is done by the custom remapper
   1.181 +		_S("\x0059\x00A0\x005A\x0020\x2011\x200B"),
   1.182 +		_S("\xFFFF\x0059\x005E\x005A\x0020\x002D\xFFFF\xFFFF"),
   1.183 +		},
   1.184 +		{	// Test remapping with custom remapper and flags set to visible
   1.185 +			// The non-breaking hyphen becomes a tilde
   1.186 +			// The zero width space become visible middle dots
   1.187 +			// All done by MTmCustom::Map()
   1.188 +			// The normal space remains a normal (invisible) space because default behaviour is overidden
   1.189 +			// The hard (non-breaking) space becomes a caret
   1.190 +			// The paragraph sign becomes a capital P
   1.191 +			// All done by the custom remapper
   1.192 +		_S("\x0059\x00A0\x005A\x0020\x2011\x200B"),
   1.193 +		_S("\xFFFF\x0059\x005E\x005A\x0020\x007E\x00B7\x0050\xFFFF"),
   1.194 +		},
   1.195 +		{
   1.196 +			// Test remapping with no custom remapper and some flags explicitly set to invisible
   1.197 +			// The non-breaking hyphen is turned into a normal hyphen
   1.198 +			// The zero width space disappears (0xFFFF) and the hard space becomes a normal space
   1.199 +			// All done by MTmCustom::Map()
   1.200 +		_S("\x0059\x00A0\x005A\x0020\x2011\x200B"),
   1.201 +		_S("\xFFFF\x0059\x0020\x005A\x0020\x002D\xFFFF\xFFFF"),
   1.202 +		}
   1.203 +	};
   1.204 +
   1.205 +
   1.206 +class CCustomRemapper : public MFormCustomInvisibleCharacterRemapper
   1.207 +	{
   1.208 +public:
   1.209 +	static CCustomRemapper* NewL();
   1.210 +	~CCustomRemapper();
   1.211 +	TUint Remap(TUint aChar, const TNonPrintingCharVisibility aNonPrintingCharVisibility, const TLayDocTextSource& aLayDoc);
   1.212 +private:
   1.213 +	CCustomRemapper();
   1.214 +	};
   1.215 +
   1.216 +	CCustomRemapper* CCustomRemapper::NewL()
   1.217 +		{
   1.218 +		CCustomRemapper* me = new(ELeave) CCustomRemapper;
   1.219 +		return me;
   1.220 +		}
   1.221 +
   1.222 +	CCustomRemapper::~CCustomRemapper()
   1.223 +		{
   1.224 +		}
   1.225 +
   1.226 +	TUint CCustomRemapper::Remap(TUint aChar, const TNonPrintingCharVisibility aNonPrintingCharVisibility, const TLayDocTextSource& aLayDoc)
   1.227 +		{
   1.228 +		switch (aChar)
   1.229 +			{
   1.230 +			case CEditableText::EParagraphDelimiter:
   1.231 +				if (aNonPrintingCharVisibility.ParagraphDelimitersVisible())
   1.232 +					return 0x0050; // capital P - override when visible
   1.233 +				break;
   1.234 +
   1.235 +			case CEditableText::ESpace:
   1.236 +				return aChar; // don't remap but don't pass it on - override default
   1.237 +				// break statement was removed.
   1.238 +
   1.239 +			case CEditableText::ENonBreakingSpace:
   1.240 +				return 0x005E; // Caret - override always - visible or not
   1.241 +				// break statement was removed.
   1.242 +			default:
   1.243 +				break; // do nothing
   1.244 +			}
   1.245 +
   1.246 +		// If not mapping special characters, or not mapping this particular character, use the default mapping.
   1.247 +		return DefaultMapping(aChar, aNonPrintingCharVisibility, aLayDoc);
   1.248 +		}
   1.249 +
   1.250 +	CCustomRemapper::CCustomRemapper()
   1.251 +		{
   1.252 +		}
   1.253 +
   1.254 +void CTCustomCharMappingStep::DoTestL(TDes& aText, CTextLayout* /*aLayout*/, CTestGraphicsDevice* aDevice, CTextView* aView, TTestNum aTestNum)
   1.255 +	{
   1.256 +	aText = KTestStrings[aTestNum][0];
   1.257 +	aDevice->LineArray().ResetLineArray();
   1.258 +	aView->HandleGlobalChangeL();
   1.259 +	const TTestGCDisplayLine* line1 = &(aDevice->LineArray().Line(0));
   1.260 +	const TTestGCDisplayLine* line2 = aDevice->LineArray().Find(KTestStrings[aTestNum][1]);
   1.261 +	TEST(0 != line1);
   1.262 +	TEST(0 != line2);
   1.263 +	// Can't always do a direct comparison of lines because same string
   1.264 +	// may appear in more than one line, so compare contents
   1.265 +	TEST(line1->iLineData.Compare(line2->iLineData) == 0);
   1.266 +	}
   1.267 +
   1.268 +
   1.269 +/**
   1.270 +@SYMTestCaseID SYSLIB-FORM-CT-0147
   1.271 +@SYMTestCaseDesc Test installation and deinstallation of custom remapper
   1.272 +@SYMTestPriority High
   1.273 +@SYMTestActions  Test installation and deinstallation of custom remapper
   1.274 +@SYMTestExpectedResults The test must not fail.
   1.275 +@SYMPREQ 1128 Placeholders for invisible characers in rich text shall be customizable
   1.276 +*/
   1.277 +void CTCustomCharMappingStep::RunInstallationTestsL()
   1.278 +	{
   1.279 +	// Note: If you need to move these heap checks any further "in" to focus
   1.280 +	// on a specific test then you will have to move all the setup code in as
   1.281 +	// well - and still preserve the two different display widths in use
   1.282 +    INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-FORM-CT-0147 "));
   1.283 +	__UHEAP_MARK;
   1.284 +	CActiveScheduler* scheduler = new(ELeave) CActiveScheduler;
   1.285 +	CleanupStack::PushL(scheduler);
   1.286 +	CActiveScheduler::Install(scheduler);
   1.287 +	TBuf<100> text;
   1.288 +	TDocModel docModel(text);
   1.289 +	TRect displayRect(0, 0, KDisplayWidth, KDisplayHeight);
   1.290 +	CTextLayout* layout = CTextLayout::NewL(&docModel, displayRect.Width());
   1.291 +	CleanupStack::PushL(layout);
   1.292 +	CTestGraphicsDevice* device = CTestGraphicsDevice::NewL(displayRect.Size(), 0);
   1.293 +	CleanupStack::PushL(device);
   1.294 +	CTextView* view = CTextView::NewL(layout, displayRect, device, device, 0, 0, 0);
   1.295 +	CleanupStack::PushL(view);
   1.296 +	// This is used to force the use of CTestGraphicsContext instead of a normal one
   1.297 +	CWindowGc* offScreenContext;
   1.298 +	User::LeaveIfError(device->CreateContext(offScreenContext));
   1.299 +	CleanupStack::PushL(offScreenContext);
   1.300 +	CTestTextView::SetContextForFlickerFreeRedraw(view, offScreenContext);
   1.301 +
   1.302 +	// OK, let's get down to testing
   1.303 +	MFormCustomInvisibleCharacterRemapper* remapper;
   1.304 +	// read what the ptr is set to - check it is null
   1.305 +	remapper = layout->GetCustomInvisibleCharacterRemapper();
   1.306 +	INFO_PRINTF1(_L("Test uninstalled"));
   1.307 +	TEST(remapper == NULL);
   1.308 +
   1.309 +	// install a custom remapper - get the ptr - check it is set
   1.310 +	MFormCustomInvisibleCharacterRemapper* customRemapper = CCustomRemapper::NewL();
   1.311 +	layout->SetCustomInvisibleCharacterRemapper(customRemapper);
   1.312 +	remapper = layout->GetCustomInvisibleCharacterRemapper();
   1.313 +	INFO_PRINTF1(_L("Test installed"));
   1.314 +	TEST(remapper == customRemapper);
   1.315 +
   1.316 +	// set the ptr back to null (deinstall) - get the ptr - check it is null
   1.317 +	layout->SetCustomInvisibleCharacterRemapper(NULL);
   1.318 +	remapper = layout->GetCustomInvisibleCharacterRemapper();
   1.319 +	INFO_PRINTF1(_L("Test uninstalled again"));
   1.320 +	TEST(remapper == NULL);
   1.321 +
   1.322 +	delete customRemapper;
   1.323 +
   1.324 +	CleanupStack::PopAndDestroy(offScreenContext);
   1.325 +	CleanupStack::PopAndDestroy(view);
   1.326 +	CleanupStack::PopAndDestroy(device);
   1.327 +	CleanupStack::PopAndDestroy(layout);
   1.328 +	CleanupStack::PopAndDestroy(scheduler);
   1.329 +	__UHEAP_MARKEND;
   1.330 +	}
   1.331 +
   1.332 +
   1.333 +/**
   1.334 +@SYMTestCaseID SYSLIB-FORM-CT-0148
   1.335 +@SYMTestCaseDesc Test behaviour without custom remapper installed
   1.336 +@SYMTestPriority High
   1.337 +@SYMTestActions  Test behaviour without custom remapper installed
   1.338 +@SYMTestExpectedResults The test must not fail.
   1.339 +@SYMPREQ 1128 Placeholders for invisible characers in rich text shall be customizable
   1.340 +*/
   1.341 +void CTCustomCharMappingStep::RunDefaultBehaviourTestsL()
   1.342 +	{
   1.343 +    INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-FORM-CT-0148 "));
   1.344 +	CActiveScheduler* scheduler = new(ELeave) CActiveScheduler;
   1.345 +	CleanupStack::PushL(scheduler);
   1.346 +	CActiveScheduler::Install(scheduler);
   1.347 +	TBuf<100> text;
   1.348 +	TDocModel docModel(text);
   1.349 +	TRect displayRect(0, 0, KDisplayWidth, KDisplayHeight);
   1.350 +	CTextLayout* layout = CTextLayout::NewL(&docModel, displayRect.Width());
   1.351 +	CleanupStack::PushL(layout);
   1.352 +	CTestGraphicsDevice* device = CTestGraphicsDevice::NewL(displayRect.Size(), 0);
   1.353 +	CleanupStack::PushL(device);
   1.354 +	CTextView* view = CTextView::NewL(layout, displayRect, device, device, 0, 0, 0);
   1.355 +	CleanupStack::PushL(view);
   1.356 +	// This is used to force the use of CTestGraphicsContext instead of a normal one
   1.357 +	CWindowGc* offScreenContext;
   1.358 +	User::LeaveIfError(device->CreateContext(offScreenContext));
   1.359 +	CleanupStack::PushL(offScreenContext);
   1.360 +	CTestTextView::SetContextForFlickerFreeRedraw(view, offScreenContext);
   1.361 +
   1.362 +	// Start by making sure no custom remapper is installed
   1.363 +	MFormCustomInvisibleCharacterRemapper* remapper;
   1.364 +	remapper = layout->GetCustomInvisibleCharacterRemapper();
   1.365 +	TEST(remapper == NULL);
   1.366 +
   1.367 +	// Set all invisible characters to be invisible
   1.368 +	TNonPrintingCharVisibility visibility;
   1.369 +	visibility.SetNoneVisible();
   1.370 +	layout->SetNonPrintingCharsVisibility(visibility);
   1.371 +
   1.372 +	// Test remapping with no custom remapper and flags set to invisible
   1.373 +	INFO_PRINTF1(_L("Test uninstalled behaviour - flags invisible"));
   1.374 +	DoTestL(text, layout, device, view, EDefaultBehaviourInvisible);
   1.375 +
   1.376 +	// Now set all invisible characters to be visible
   1.377 +	visibility.SetAllVisible();
   1.378 +	layout->SetNonPrintingCharsVisibility(visibility);
   1.379 +
   1.380 +	// Test remapping with no custom remapper and flags set to visible
   1.381 +	INFO_PRINTF1(_L("Test uninstalled behaviour - flags visible"));
   1.382 +	DoTestL(text, layout, device, view, EDefaultBehaviourVisible);
   1.383 +
   1.384 +	// Test remapping with no custom remapper and some flags explicitly set to invisible
   1.385 +	INFO_PRINTF1(_L("Test uninstalled behaviour - some flags invisible"));
   1.386 +	//Set all invisible characters to be visible
   1.387 +	visibility.SetAllVisible();
   1.388 +	//Set some attributes explicitly to be invisible
   1.389 +	visibility.SetSpacesVisible(EFalse);
   1.390 +	visibility.SetTabsVisible(EFalse);
   1.391 +	visibility.SetPotentialHyphensVisible(EFalse);
   1.392 +	visibility.SetParagraphDelimitersVisible(EFalse);
   1.393 +	visibility.SetPageBreaksVisible(EFalse);
   1.394 +	visibility.SetNonBreakingSpacesVisible(EFalse);
   1.395 +	visibility.SetNonBreakingHyphensVisible(EFalse);
   1.396 +	visibility.SetLineBreaksVisible(EFalse);
   1.397 +	layout->SetNonPrintingCharsVisibility(visibility);
   1.398 +	//Test if the visibility is set accordingly
   1.399 +	DoTestL(text, layout, device, view, ENewTest);
   1.400 +
   1.401 +	CleanupStack::PopAndDestroy(offScreenContext);
   1.402 +	CleanupStack::PopAndDestroy(view);
   1.403 +	CleanupStack::PopAndDestroy(device);
   1.404 +	CleanupStack::PopAndDestroy(layout);
   1.405 +	CleanupStack::PopAndDestroy(scheduler);
   1.406 +	}
   1.407 +
   1.408 +
   1.409 +/**
   1.410 +@SYMTestCaseID SYSLIB-FORM-CT-0149
   1.411 +@SYMTestCaseDesc Test behaviour with custom remapper installed
   1.412 +@SYMTestPriority High
   1.413 +@SYMTestActions  Test behaviour with custom remapper installed
   1.414 +@SYMTestExpectedResults The test must not fail.
   1.415 +@SYMPREQ 1128 Placeholders for invisible characers in rich text shall be customizable
   1.416 +*/
   1.417 +void CTCustomCharMappingStep::RunCustomBehaviourTestsL()
   1.418 +	{
   1.419 +	// Note: If you need to move these heap checks any further "in" to focus
   1.420 +	// on a specific test then you will have to move all the setup code in as
   1.421 +	// well - and still preserve the two different display widths in use
   1.422 +    INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-FORM-CT-0149 "));
   1.423 +	__UHEAP_MARK;
   1.424 +	CActiveScheduler* scheduler = new(ELeave) CActiveScheduler;
   1.425 +	CleanupStack::PushL(scheduler);
   1.426 +	CActiveScheduler::Install(scheduler);
   1.427 +	TBuf<100> text;
   1.428 +	TDocModel docModel(text);
   1.429 +	TRect displayRect(0, 0, KDisplayWidth, KDisplayHeight);
   1.430 +	CTextLayout* layout = CTextLayout::NewL(&docModel, displayRect.Width());
   1.431 +	CleanupStack::PushL(layout);
   1.432 +	CTestGraphicsDevice* device = CTestGraphicsDevice::NewL(displayRect.Size(), 0);
   1.433 +	CleanupStack::PushL(device);
   1.434 +	CTextView* view = CTextView::NewL(layout, displayRect, device, device, 0, 0, 0);
   1.435 +	CleanupStack::PushL(view);
   1.436 +	// This is used to force the use of CTestGraphicsContext instead of a normal one
   1.437 +	CWindowGc* offScreenContext;
   1.438 +	User::LeaveIfError(device->CreateContext(offScreenContext));
   1.439 +	CleanupStack::PushL(offScreenContext);
   1.440 +	CTestTextView::SetContextForFlickerFreeRedraw(view, offScreenContext);
   1.441 +
   1.442 +	// We need to install a custom remapper
   1.443 +	MFormCustomInvisibleCharacterRemapper* remapper;
   1.444 +	MFormCustomInvisibleCharacterRemapper* customRemapper = CCustomRemapper::NewL();
   1.445 +	layout->SetCustomInvisibleCharacterRemapper(customRemapper);
   1.446 +	remapper = layout->GetCustomInvisibleCharacterRemapper();
   1.447 +	TEST(remapper == customRemapper);
   1.448 +
   1.449 +	// Set all invisible characters to be invisible
   1.450 +	TNonPrintingCharVisibility visibility;
   1.451 +	visibility.SetNoneVisible();
   1.452 +	layout->SetNonPrintingCharsVisibility(visibility);
   1.453 +
   1.454 +	// Test remapping with custom remapper and flags set to invisible
   1.455 +	INFO_PRINTF1(_L("Test installed behaviour - flags invisible"));
   1.456 +	DoTestL(text, layout, device, view, ECustomRemappingInvisible);
   1.457 +
   1.458 +	// Now set all invisible characters to be visible
   1.459 +	visibility.SetAllVisible();
   1.460 +	layout->SetNonPrintingCharsVisibility(visibility);
   1.461 +
   1.462 +	// Test remapping with custom remapper and flags set to visible
   1.463 +	INFO_PRINTF1(_L("Test installed behaviour - flags visible"));
   1.464 +	DoTestL(text, layout, device, view, ECustomRemappingVisible);
   1.465 +
   1.466 +	// Now we are finished deinstall and delete it
   1.467 +	layout->SetCustomInvisibleCharacterRemapper(NULL);
   1.468 +	remapper = layout->GetCustomInvisibleCharacterRemapper();
   1.469 +	TEST(remapper == NULL);
   1.470 +	delete customRemapper;
   1.471 +
   1.472 +	CleanupStack::PopAndDestroy(offScreenContext);
   1.473 +	CleanupStack::PopAndDestroy(view);
   1.474 +	CleanupStack::PopAndDestroy(device);
   1.475 +	CleanupStack::PopAndDestroy(layout);
   1.476 +	CleanupStack::PopAndDestroy(scheduler);
   1.477 +	__UHEAP_MARKEND;
   1.478 +	}
   1.479 +
   1.480 +CTCustomCharMappingStep::CTCustomCharMappingStep()
   1.481 +    {
   1.482 +    
   1.483 +    }
   1.484 +
   1.485 +TVerdict CTCustomCharMappingStep::doTestStepL()
   1.486 +    {
   1.487 +    SetTestStepResult(EPass);
   1.488 +    INFO_PRINTF1(_L("Test installation/deinstallatiion"));
   1.489 +    TInt error = RFbsSession::Connect();
   1.490 +    if (error == KErrNotFound)
   1.491 +        {
   1.492 +        FbsStartup();
   1.493 +        error = RFbsSession::Connect();
   1.494 +        }
   1.495 +    TEST(error == KErrNone);
   1.496 +    TRAP(error, RunInstallationTestsL());
   1.497 +    TEST(error == KErrNone);
   1.498 +    INFO_PRINTF1(_L("Test uninstalled behaviour"));
   1.499 +    TRAP(error, RunDefaultBehaviourTestsL());
   1.500 +    TEST(error == KErrNone);
   1.501 +    INFO_PRINTF1(_L("Test behaviour with custom remapper installed"));
   1.502 +    TRAP(error, RunCustomBehaviourTestsL());
   1.503 +    TEST(error == KErrNone);
   1.504 +    RFbsSession::Disconnect();
   1.505 +    return TestStepResult();
   1.506 +    }