os/textandloc/textrendering/texthandling/ttext/T_RICH1A.CPP
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/textandloc/textrendering/texthandling/ttext/T_RICH1A.CPP	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,1082 @@
     1.4 +/*
     1.5 +* Copyright (c) 1997-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 +
    1.22 +#include <txtrich.h>
    1.23 +#include <gdi.h>
    1.24 +#include <conpics.h>
    1.25 +#include <s32stor.h>
    1.26 +#include "../incp/T_PMLPAR.H"
    1.27 +#include "T_RICH1A.h"
    1.28 +
    1.29 +LOCAL_D CTestStep *pTestStep = NULL;
    1.30 +#define test(cond)											\
    1.31 +	{														\
    1.32 +	TBool __bb = (cond);									\
    1.33 +	pTestStep->TEST(__bb);									\
    1.34 +	if (!__bb)												\
    1.35 +		{													\
    1.36 +		pTestStep->ERR_PRINTF1(_L("ERROR: Test Failed"));	\
    1.37 +		User::Leave(1);										\
    1.38 +		}													\
    1.39 +	}
    1.40 +#undef INFO_PRINTF1
    1.41 +#undef INFO_PRINTF2
    1.42 +// copy from tefexportconst.h
    1.43 +#define INFO_PRINTF1(p1)        pTestStep->Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrInfo, (p1))
    1.44 +#define INFO_PRINTF2(p1, p2)    pTestStep->Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrInfo, (p1), (p2))
    1.45 +
    1.46 +
    1.47 +#define UNUSED_VAR(a) a = a
    1.48 +
    1.49 +LOCAL_D CTrapCleanup* TheTrapCleanup;
    1.50 +LOCAL_D const TInt KTestCleanupStack=0x200;
    1.51 +
    1.52 +class MAtomicTest
    1.53 +	{
    1.54 +public:
    1.55 +	/** Test that the object is correctly set at stage aStage, then advance it
    1.56 +	to stage aStage+1 with an atomic (with respect to leaving) operation.
    1.57 +
    1.58 +	The test at each stage should test that the previous stage really happened
    1.59 +	and that no part of the new stage has happened.
    1.60 +
    1.61 +	RunAtomicTest will test that each of these operations really is atomic.
    1.62 +	@param aStage The stage to test this object is at.
    1.63 +	@return
    1.64 +		ETrue if this object was successfully advanced to the next stage.
    1.65 +		EFalse if there were no more stages to be advanced to.
    1.66 +	*/
    1.67 +	virtual TBool TestAndRunStageL(TInt aStage) = 0;
    1.68 +	/** Tests that the leave reported in aError is suitable as an error code
    1.69 +	from aStage. Panics if not.
    1.70 +
    1.71 +	@param aError Code that TestAndRunStageL(aStage) left with.
    1.72 +	@param aStage Stage at which the leave occurred. */
    1.73 +	virtual void TestErrorCondition(TInt aStage, TInt aError) = 0;
    1.74 +	void RunAtomicTest();
    1.75 +	};
    1.76 +
    1.77 +/** Runs TestAndRunStage repeatedly with different out-of-memory test
    1.78 +conditions.
    1.79 +
    1.80 +It checks that the operations defined at each stage either leave and leave this
    1.81 +object in the same condition, or return successfully and leave the object in
    1.82 +the next stage. */
    1.83 +void MAtomicTest::RunAtomicTest()
    1.84 +	{
    1.85 +	TInt stage = 0;
    1.86 +	TInt failRate = 1;
    1.87 +	TBool more = ETrue;
    1.88 +	while (more)
    1.89 +		{
    1.90 +		__UHEAP_SETFAIL(RHeap::EDeterministic, failRate);
    1.91 +		TRAPD(err, more = TestAndRunStageL(stage));
    1.92 +		if (err == KErrNone)
    1.93 +			{
    1.94 +			failRate = 1;
    1.95 +			++stage;
    1.96 +			}
    1.97 +		else
    1.98 +			{
    1.99 +			TestErrorCondition(stage, err);
   1.100 +			++failRate;
   1.101 +			}
   1.102 +		}
   1.103 +	__UHEAP_RESET;
   1.104 +	}
   1.105 +
   1.106 +template<class S,class T,CEditableText::TDocumentStorage D>
   1.107 +class CRichTest : public CRichText, public MAtomicTest
   1.108 +	{
   1.109 +public:
   1.110 +	static CRichTest* NewL(CParaFormatLayer* aPara,CCharFormatLayer* aChar);
   1.111 +
   1.112 +	void DoFlatTests();
   1.113 +	void RegisterMethodsL();
   1.114 +	void InsertWithDelimsL();
   1.115 +	void TestResetL();
   1.116 +	void TestDelete1L();
   1.117 +	void TestDelete2L();
   1.118 +    void TestApplyRemoveCharFormat();
   1.119 +	void TestRemSpecParaFmtL();
   1.120 +	void DoPML();
   1.121 +	void TestForDefectTET5DHEWWL();
   1.122 +	void TestForDefectINC010183L();
   1.123 +	void TestForDefectINC064162L();
   1.124 +	void TestForDefectINC109323L();
   1.125 +	// Tests SetInsertCharFormat and friends for atomicity.
   1.126 +	TBool TestAndRunStageL(TInt aStage);
   1.127 +	void TestErrorCondition(TInt aStage, TInt aError);
   1.128 +protected:
   1.129 +	CRichTest(CParaFormatLayer* aPara,CCharFormatLayer* aChar);
   1.130 +	};
   1.131 +
   1.132 +template<class S, class T,CEditableText::TDocumentStorage D>
   1.133 +CRichTest<S,T,D>* CRichTest<S,T,D>::NewL(CParaFormatLayer* aPara,CCharFormatLayer* aChar)
   1.134 +	{
   1.135 +	CRichTest<S,T,D>* tmp=new(ELeave)CRichTest<S,T,D>(aPara,aChar);
   1.136 +	tmp->ConstructL(D,EDefaultTextGranularity,EMultiPara);
   1.137 +	return tmp;
   1.138 +	}
   1.139 +
   1.140 +
   1.141 +template<class S, class T,CEditableText::TDocumentStorage D>
   1.142 +CRichTest<S,T,D>::CRichTest(CParaFormatLayer* aPara,CCharFormatLayer* aChar)
   1.143 +	:CRichText(aPara,aChar)
   1.144 +	{}
   1.145 +
   1.146 +
   1.147 +template<class S, class T,CEditableText::TDocumentStorage D>
   1.148 +void CRichTest<S,T,D>::DoFlatTests()
   1.149 +	{
   1.150 +	INFO_PRINTF1(_L("Registering all methods"));
   1.151 +	RegisterMethodsL();
   1.152 +	INFO_PRINTF1(_L("Inserting with embedded paragraph delimiters"));
   1.153 +	InsertWithDelimsL();
   1.154 +	
   1.155 +	}
   1.156 +
   1.157 +
   1.158 +template<class S, class T,CEditableText::TDocumentStorage D>
   1.159 +void CRichTest<S,T,D>::InsertWithDelimsL()
   1.160 +	{
   1.161 +	INFO_PRINTF1(_L("Inserting into shared para"));
   1.162 +
   1.163 +	Reset();
   1.164 +	TBuf<512> testbuf(_L("a"));
   1.165 +	for (TInt ii=0;ii<8;ii++)
   1.166 +		{
   1.167 +		testbuf.Append('a');
   1.168 +		testbuf.Append(CEditableText::EParagraphDelimiter);
   1.169 +		}
   1.170 +	InsertL(0,testbuf);
   1.171 +	test(DocumentLength()==17);
   1.172 +	test(ParagraphCount()==9);
   1.173 +
   1.174 +	Reset();
   1.175 +	TBufC<512> bufC;
   1.176 +	InsertL(0,bufC);
   1.177 +		
   1.178 +	Reset();
   1.179 +	TBuf<512> buf(_L("Herewith"));
   1.180 +	InsertL(0,buf);
   1.181 +
   1.182 +	InsertL(4,CEditableText::EParagraphDelimiter);
   1.183 +	// THE ABOVE IS TEMPORARY ONLY _ REMOVE IT AS SOON AS YOUVE DONE.
   1.184 +	
   1.185 +	Reset();
   1.186 +//	TBuf<512> buf(_L("Herewith"));
   1.187 +	buf.Append(EParagraphDelimiter);
   1.188 +	InsertL(0,buf);
   1.189 +
   1.190 +	buf.Append(_L("Is para one"));
   1.191 +	buf.Append(EParagraphDelimiter);
   1.192 +	InsertL(4,buf);
   1.193 +
   1.194 +	buf.Append(_L(" trailing text"));
   1.195 +	InsertL(DocumentLength()-1,buf);
   1.196 +	//////////////////////////////////
   1.197 +	// Pathalogical case (1)
   1.198 +	// Inserting text with delimiters between 2 adjacent pictures.
   1.199 +	INFO_PRINTF1(_L("Inserting text with delimiters between 2 adjacent pictures."));
   1.200 +	//
   1.201 +	Reset();
   1.202 +	CXzePicture* picA=CXzePicture::NewL('Z');
   1.203 +	TPictureHeader hdrA;
   1.204 +	hdrA.iPictureType=KUidXzePictureType;
   1.205 +	hdrA.iPicture=picA;
   1.206 +	//
   1.207 +	CXzePicture* picB=CXzePicture::NewL('X');
   1.208 +	TPictureHeader hdrB;
   1.209 +	hdrB.iPictureType=KUidXzePictureType;
   1.210 +	hdrB.iPicture=picB;
   1.211 +	//
   1.212 +	InsertL(0,hdrA);
   1.213 +	InsertL(DocumentLength(),hdrB);
   1.214 +	buf.SetLength(0);
   1.215 +	buf.Append(_L("some"));
   1.216 +	buf.Append(CEditableText::EParagraphDelimiter);
   1.217 +	buf.Append(_L("trailing text"));
   1.218 +	InsertL(1,buf);
   1.219 +	//
   1.220 +	Reset();  // Destroys all pictures.
   1.221 +	picA=CXzePicture::NewL('Z');
   1.222 +	hdrA.iPictureType=KUidXzePictureType;
   1.223 +	hdrA.iPicture=picA;
   1.224 +	picB=CXzePicture::NewL('X');
   1.225 +	hdrB.iPictureType=KUidXzePictureType;
   1.226 +	hdrB.iPicture=picB;
   1.227 +	InsertL(0,hdrA);
   1.228 +	InsertL(DocumentLength(),hdrB);
   1.229 +	buf.SetLength(5);  // A single para delimiter, with no trailing text.
   1.230 +	InsertL(1,buf);
   1.231 +	////////////////////////////////
   1.232 +	// Pathalogical case (2)
   1.233 +	// Insert text with delimiters after a picture
   1.234 +	INFO_PRINTF1(_L("Insert text with delimiters after a picture"));
   1.235 +	//
   1.236 +	Reset();  // Destroys all pictures.
   1.237 +	picA=CXzePicture::NewL('Z');
   1.238 +	hdrA.iPictureType=KUidXzePictureType;
   1.239 +	hdrA.iPicture=picA;
   1.240 +	InsertL(0,hdrA);
   1.241 +	buf.SetLength(7);
   1.242 +	InsertL(1,buf);
   1.243 +
   1.244 +	////////////////////////////////
   1.245 +	// Pathalogical case (3)
   1.246 +	// Insert text with delimiters before a picture
   1.247 +	INFO_PRINTF1(_L("Insert text with delimiters before a picture"));
   1.248 +	//
   1.249 +	Reset();  // Destroys all pictures.
   1.250 +	picA=CXzePicture::NewL('Z');
   1.251 +	hdrA.iPictureType=KUidXzePictureType;
   1.252 +	hdrA.iPicture=picA;
   1.253 +	InsertL(0,hdrA);
   1.254 +	buf.SetLength(7);
   1.255 +	InsertL(0,buf);
   1.256 +	//	
   1.257 +	Reset();
   1.258 +	
   1.259 +	}
   1.260 +
   1.261 +
   1.262 +template<class S, class T,CEditableText::TDocumentStorage D>
   1.263 +void CRichTest<S,T,D>::RegisterMethodsL()
   1.264 +//
   1.265 +// 1st part of testing, involves all methods being called to ensure that all
   1.266 +// methods exist and run without panicking.
   1.267 +//
   1.268 +	{
   1.269 +	INFO_PRINTF1(_L("CRichText::NewL()"));
   1.270 +
   1.271 +	// InsertL()
   1.272 +	INFO_PRINTF1(_L("InsertL()"));
   1.273 +	TPtrC buf(_L("Herewith"));
   1.274 +	InsertL(0,buf);
   1.275 +
   1.276 +//	11.3.97 DavidA defect test 
   1.277 +	TCharFormat charFormat;
   1.278 +	TCharFormatMask charFormatMask;
   1.279 +	TInt lastChar=DocumentLength();
   1.280 +	ApplyCharFormatL(charFormat,charFormatMask,lastChar,1);
   1.281 +//	end of addition.
   1.282 +
   1.283 +
   1.284 +	TPtrC buf2(_L("Hello"));
   1.285 +	InsertL(0,buf2);
   1.286 +
   1.287 +	DeleteL(3,7);
   1.288 +
   1.289 +	// SetInsertCharFormatL()
   1.290 +	INFO_PRINTF1(_L("SetInsertCharFormatL()"));
   1.291 +	TCharFormat format; TCharFormatMask mask;
   1.292 +	format.iFontSpec.iFontStyle.SetStrokeWeight(EStrokeWeightBold);
   1.293 +	mask.SetAttrib(EAttFontStrokeWeight);
   1.294 +	SetInsertCharFormatL(format,mask,3);
   1.295 +	// Test for alloc heaven when doing multiple simultaneous SetInsertCharFormat()s.
   1.296 +	format.iFontSpec.iFontStyle.SetPosture(EPostureItalic);
   1.297 +	mask.SetAttrib(EAttFontPosture);
   1.298 +	SetInsertCharFormatL(format,mask,3);
   1.299 +	//
   1.300 +	TPtrC buf3(_L(" is bold."));
   1.301 +	InsertL(3,buf3);
   1.302 +	CancelInsertCharFormat();
   1.303 +
   1.304 +	// Inserting new paragraph
   1.305 +	INFO_PRINTF1(_L("Inserting paragraph delimiter (Insert(TChar))"));
   1.306 +	InsertL(4,CEditableText::EParagraphDelimiter);
   1.307 +
   1.308 +	// Delete()
   1.309 +	INFO_PRINTF1(_L("DeleteL()"));
   1.310 +	DeleteL(5,1);
   1.311 +
   1.312 +	// Sensing character format over a specified range.
   1.313 +	INFO_PRINTF1(_L("GetCharFormat()"));
   1.314 +	TCharFormat charFormat1; TCharFormatMask undeterminedMask;
   1.315 +	GetCharFormat(charFormat1,undeterminedMask,0,4);
   1.316 +
   1.317 +	// Sensing paragraph format over a specified range.
   1.318 +	INFO_PRINTF1(_L("SenseParagraphFormatL()"));
   1.319 +	CParaFormat* pParaFormat=NULL;
   1.320 +	TRAPD(r,pParaFormat=CParaFormat::NewL());
   1.321 +	test(r==KErrNone);
   1.322 +	TParaFormatMask undeterminedParaMask;
   1.323 +	GetParaFormatL(pParaFormat,undeterminedParaMask,0,DocumentLength());
   1.324 +	delete pParaFormat;
   1.325 +	
   1.326 +	// DelSetInsertCharFormatL()
   1.327 +	INFO_PRINTF1(_L("DelSetInsertCharFormatL()"));
   1.328 +	TPtrC buf4(_L("This is para 2."));
   1.329 +	InsertL(0,buf4);
   1.330 +	SetInsertCharFormatL(format,mask,15);
   1.331 +	TPtrC buf5(_L("In italic."));
   1.332 +	InsertL(15,buf5);
   1.333 +	DelSetInsertCharFormatL(4,5);
   1.334 +	
   1.335 +	// CancelInsertCharFormat()
   1.336 +	INFO_PRINTF1(_L("CancelInsertCharFormat()"));
   1.337 +	CancelInsertCharFormat();
   1.338 +	
   1.339 +	// ApplyParaFormatL()
   1.340 +	INFO_PRINTF1(_L("ApplyParaFormatL()"));
   1.341 +	CParaFormat* paraFormat=CParaFormat::NewL(); TParaFormatMask paraMask;
   1.342 +	paraFormat->iHorizontalAlignment=CParaFormat::ECenterAlign;
   1.343 +	paraMask.SetAttrib(EAttAlignment);
   1.344 +	ApplyParaFormatL(paraFormat,paraMask,0,DocumentLength());
   1.345 +
   1.346 +	// ApplyCharFormatL()
   1.347 +	INFO_PRINTF1(_L("ApplyCharFormatL()"));
   1.348 +	format.iFontSpec.iFontStyle.SetPosture(EPostureItalic); mask.SetAttrib(EAttFontPosture);
   1.349 +	format.iFontPresentation.iStrikethrough=EStrikethroughOn; mask.SetAttrib(EAttFontStrikethrough);
   1.350 +	ApplyCharFormatL(format,mask,0,DocumentLength());
   1.351 +
   1.352 +	// SenseParaFormatL()
   1.353 +	INFO_PRINTF1(_L("SenseParaFormatL()"));
   1.354 +	GetParagraphFormatL(paraFormat,DocumentLength()-1);
   1.355 +
   1.356 +	// CountParas()
   1.357 +	INFO_PRINTF1(_L("ParagraphCount()"));
   1.358 +	ParagraphCount();
   1.359 +
   1.360 +	// ParagraphStart()
   1.361 +	INFO_PRINTF1(_L("ParagraphStart()"));
   1.362 +	TInt aPos=0;
   1.363 +	ToParagraphStart(aPos);
   1.364 +
   1.365 +	// Reset
   1.366 +	Reset();
   1.367 +
   1.368 +	delete paraFormat;
   1.369 +
   1.370 +	
   1.371 +	}
   1.372 +
   1.373 +/**
   1.374 +@SYMTestCaseID 			SYSLIB-ETEXT-UT-3548
   1.375 +@SYMTestCaseDesc  		Testing behaviour of function ApplyCharFormatL() when called at end of document
   1.376 +						that contains plain text. Applied formatting should work on subsequent text
   1.377 +@SYMTestPriority  		High
   1.378 +@SYMTestActions 		1. Insert text1
   1.379 +						2. Switch on bold formatting
   1.380 +						3. Insert text2
   1.381 +						4. Test that first char of text1 is not bold and a character of text 2 is bold. 
   1.382 +@SYMTestExpectedResults	ApplyCharFormatL() applies formatting from end of doc to subsequent character.
   1.383 +@SYMDEF					INC109323
   1.384 +*/
   1.385 +template<class S, class T,CEditableText::TDocumentStorage D>
   1.386 +void CRichTest<S,T,D>::TestForDefectINC109323L()
   1.387 +	{
   1.388 +	__UHEAP_MARK;
   1.389 +	INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-ETEXT-UT-3548 Test ApplyCharFormatL() for bold at end positions of text "));	
   1.390 +	_LIT(KText1, "Testing Bold format");
   1.391 +	_LIT(KText2, "bold");	
   1.392 +
   1.393 +	CParaFormatLayer* paraLayer = CParaFormatLayer::NewL();
   1.394 +	CleanupStack::PushL(paraLayer);
   1.395 +	CCharFormatLayer* charLayer = CCharFormatLayer::NewL();
   1.396 +	CleanupStack::PushL(charLayer);
   1.397 +	CRichText* doc = CRichText::NewL(paraLayer,charLayer,D);
   1.398 +	CleanupStack::PushL(doc);
   1.399 +	TCharFormat format1;
   1.400 +	TCharFormat fmtCheck1;
   1.401 +	format1.iFontPresentation.iUnderline = EUnderlineOff;
   1.402 +	// initilizing format attributes
   1.403 +	TCharFormatMask mask1;
   1.404 +	TCharFormatMask mask2;	
   1.405 +	fmtCheck1.iFontPresentation.iUnderline = EUnderlineOff;	
   1.406 +	//Test document containing test string and cursor positioned at end of doc.
   1.407 +	//Turn on bold formatting and subsequent characters are in bold format.
   1.408 +	doc->InsertL(0, KText1);
   1.409 +	format1.iFontSpec.iFontStyle.SetStrokeWeight(EStrokeWeightBold);
   1.410 +	mask1.SetAttrib(EAttFontStrokeWeight);//Set Bold
   1.411 +	doc->ApplyCharFormatL(format1, mask1, doc->DocumentLength(),0);//Apply Bold	
   1.412 +	doc->InsertL(19, KText2);//These should be in bold
   1.413 +	mask1.ClearAttrib(EAttFontStrokeWeight);//Remove bold formatting
   1.414 +	doc->GetCharFormat(format1, mask1, 0, 1);//Get format of characters at position 0
   1.415 +	doc->GetCharFormat(fmtCheck1, mask2, 22, 1);//Get format of characters at position 22
   1.416 +	test(format1.iFontSpec.iFontStyle.StrokeWeight()!=EStrokeWeightBold);
   1.417 +	test(fmtCheck1.iFontSpec.iFontStyle.StrokeWeight()==EStrokeWeightBold);	
   1.418 +	//tidyup
   1.419 +	CleanupStack::PopAndDestroy(doc);
   1.420 +	CleanupStack::PopAndDestroy(charLayer);
   1.421 +	CleanupStack::PopAndDestroy(paraLayer);	
   1.422 +	__UHEAP_MARKEND;
   1.423 +	}
   1.424 +
   1.425 +template<class S, class T,CEditableText::TDocumentStorage D>
   1.426 +void CRichTest<S,T,D>::TestRemSpecParaFmtL()
   1.427 +//
   1.428 +// Test the RemoveSpecificParaFormatL() method of CRichText.
   1.429 +//
   1.430 +	{
   1.431 +	__UHEAP_MARK;
   1.432 +	INFO_PRINTF1(_L("RemoveSpecificParaFormatL()"));
   1.433 +	CParaFormat* globalParaFormat=CParaFormat::NewLC();
   1.434 +	TParaFormatMask globalParaMask;
   1.435 +	globalParaFormat->iHorizontalAlignment=CParaFormat::ECenterAlign;
   1.436 +	globalParaMask.SetAttrib(EAttAlignment);
   1.437 +	CParaFormatLayer* paraLayer=CParaFormatLayer::NewL(globalParaFormat,globalParaMask);
   1.438 +	CCharFormatLayer* charLayer=CCharFormatLayer::NewL();
   1.439 +	CRichText* doc=NULL;
   1.440 +	TRAPD(ret,doc=CRichText::NewL(paraLayer,charLayer,D));
   1.441 +	if (ret!=KErrNone)
   1.442 +		{
   1.443 +		test(doc==NULL);
   1.444 +		User::Leave(ret);
   1.445 +		}
   1.446 +	TPtrC buf1(_L("Here is paragraph one text."));
   1.447 +	doc->InsertL(0,buf1);
   1.448 +	//
   1.449 +	// Apply specific paragraph format
   1.450 +	CParaFormat* format=CParaFormat::NewLC();
   1.451 +	TParaFormatMask mask;
   1.452 +	format->iHorizontalAlignment=CParaFormat::ERightAlign;
   1.453 +	mask.SetAttrib(EAttAlignment);
   1.454 +	doc->ApplyParaFormatL(format,mask,1,1);
   1.455 +	CParaFormat* sensedFormat=CParaFormat::NewLC();
   1.456 +	doc->GetParagraphFormatL(sensedFormat,0);
   1.457 +	test(sensedFormat->iHorizontalAlignment==CParaFormat::ERightAlign);
   1.458 +	//
   1.459 +	// Remove specific para format and test
   1.460 +	doc->RemoveSpecificParaFormatL(0,1);
   1.461 +	doc->GetParagraphFormatL(sensedFormat,0);
   1.462 +	test(sensedFormat->iHorizontalAlignment==CParaFormat::ECenterAlign);
   1.463 +	//
   1.464 +	CleanupStack::PopAndDestroy(3); // the 2 para formats.
   1.465 +	delete doc;
   1.466 +	delete paraLayer;
   1.467 +	delete charLayer;
   1.468 +
   1.469 +	__UHEAP_MARKEND;
   1.470 +	}
   1.471 +
   1.472 +
   1.473 +template<class S, class T,CEditableText::TDocumentStorage D>
   1.474 +void CRichTest<S,T,D>::TestDelete1L()
   1.475 +//
   1.476 +// Test the DeleteL() method of CRichText.
   1.477 +//
   1.478 +	{
   1.479 +	__UHEAP_MARK;
   1.480 +	INFO_PRINTF1(_L("DeleteL()"));
   1.481 +	CParaFormatLayer* paraLayer=CParaFormatLayer::NewL();
   1.482 +	CCharFormatLayer* charLayer=CCharFormatLayer::NewL();
   1.483 +	CRichText* doc=NULL;
   1.484 +	TRAPD(ret,doc=CRichText::NewL(paraLayer,charLayer,D));
   1.485 +	if (ret!=KErrNone)
   1.486 +		{
   1.487 +		test(doc==NULL);
   1.488 +		User::Leave(ret);
   1.489 +		}
   1.490 +	TPtrC buf1(_L("Here is paragraph one text."));
   1.491 +	TPtrC buf2(_L("Here is paragraph one text."));
   1.492 +	doc->InsertL(0,buf1);
   1.493 +	doc->InsertL(doc->DocumentLength(),EParagraphDelimiter);
   1.494 +	doc->InsertL(doc->DocumentLength(),buf2);
   1.495 +	//
   1.496 +	// Apply formatting
   1.497 +	TCharFormat applyFormat;
   1.498 +	TCharFormatMask applyMask;
   1.499 +	applyFormat.iFontSpec.iFontStyle.SetStrokeWeight(EStrokeWeightBold);
   1.500 +	applyMask.SetAttrib(EAttFontStrokeWeight);
   1.501 +	doc->ApplyCharFormatL(applyFormat,applyMask,8,28);
   1.502 +	//
   1.503 +	// Now try the delete - should end up with a single shared paragraph!!!
   1.504 +	doc->DeleteL(8,28);
   1.505 +	TInt documentLength=doc->DocumentLength();
   1.506 +	test(documentLength==27);
   1.507 +	//
   1.508 +	delete doc;
   1.509 +	delete paraLayer;
   1.510 +	delete charLayer;
   1.511 +
   1.512 +	__UHEAP_MARKEND;
   1.513 +	}
   1.514 +
   1.515 +
   1.516 +template<class S, class T,CEditableText::TDocumentStorage D>
   1.517 +void CRichTest<S,T,D>::TestDelete2L()
   1.518 +//
   1.519 +// Test the DeleteL() method of CRichText.
   1.520 +// Deleting the paragraph delimiter between 2 paras of constant character format, but of varying
   1.521 +// paragraph formats.
   1.522 +//
   1.523 +	{
   1.524 +	__UHEAP_MARK;
   1.525 +	INFO_PRINTF1(_L("DeleteL()"));
   1.526 +	CParaFormatLayer* paraLayer=CParaFormatLayer::NewL();
   1.527 +	CCharFormatLayer* charLayer=CCharFormatLayer::NewL();
   1.528 +	CRichText* doc=NULL;
   1.529 +	TRAPD(ret,doc=CRichText::NewL(paraLayer,charLayer,D));
   1.530 +	if (ret!=KErrNone)
   1.531 +		{
   1.532 +		test(doc==NULL);
   1.533 +		User::Leave(ret);
   1.534 +		}
   1.535 +	TPtrC buf1(_L("A"));
   1.536 +	TPtrC buf2(_L("B"));
   1.537 +	TPtrC buf3(_L("C"));
   1.538 +	doc->InsertL(0,buf1);
   1.539 +	doc->InsertL(doc->DocumentLength(),EParagraphDelimiter);
   1.540 +	doc->InsertL(doc->DocumentLength(),buf2);
   1.541 +	doc->InsertL(doc->DocumentLength(),EParagraphDelimiter);
   1.542 +	doc->InsertL(doc->DocumentLength(),buf3);
   1.543 +	//
   1.544 +	// Apply formatting
   1.545 +	CParaFormat* applyFormat=CParaFormat::NewLC();
   1.546 +	TParaFormatMask applyMask;
   1.547 +	applyFormat->iHorizontalAlignment=CParaFormat::ERightAlign;
   1.548 +	applyMask.SetAttrib(EAttAlignment);
   1.549 +	//
   1.550 +	// Make 1st & 3rd para the same para format, different to para 2.
   1.551 +	
   1.552 +	doc->ApplyParaFormatL(applyFormat,applyMask,1,1);
   1.553 +	doc->ApplyParaFormatL(applyFormat,applyMask,5,1);
   1.554 +	CleanupStack::PopAndDestroy();  // para format
   1.555 +	//
   1.556 +	// Now try the delete - should end up with a single shared paragraph!!!
   1.557 +	/*TBool parasMerged=*/doc->DeleteL(3,1);  // delete para 2 delimiter
   1.558 +	TInt documentLength=doc->DocumentLength();
   1.559 +	test(documentLength==4);
   1.560 +	//
   1.561 +	delete doc;
   1.562 +	delete paraLayer;
   1.563 +	delete charLayer;
   1.564 +
   1.565 +	__UHEAP_MARKEND;
   1.566 +	}
   1.567 +
   1.568 +
   1.569 +/**
   1.570 +@SYMTestCaseID             SYSLIB-ETEXT-UT-3431
   1.571 +@SYMTestCaseDesc          Testing behaviour of functions ApplyCharFormatL() and RemoveSpecificFormatL();
   1.572 +    formatting of text including end of document character
   1.573 +@SYMTestPriority          High
   1.574 +@SYMTestActions         1. format text and compare attribute values for equality
   1.575 +                        2. testing for fix of INC097216 whether EOD also formatted
   1.576 +                        3. remove formatting of text and compare attribute values for equality
   1.577 +                        4. testing for fix of DEF104149 whether EOD also has formatting removed
   1.578 +@SYMTestExpectedResults    ApplyCharFormatL() and RemoveSpecificFormatL() apply and remove formatting from
   1.579 +    specified range of text including end of document character
   1.580 +@SYMDEF                    DEF104149
   1.581 +*/
   1.582 +template<class S, class T,CEditableText::TDocumentStorage D>
   1.583 +void CRichTest<S,T,D>::TestApplyRemoveCharFormat()
   1.584 +    {
   1.585 +    __UHEAP_MARK;
   1.586 +    INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-ETEXT-UT-3431 Test ApplyCharFormatL() & RemoveSpecificCharFormat() "));	
   1.587 +    CParaFormatLayer* paraLayer = CParaFormatLayer::NewL();
   1.588 +    CleanupStack::PushL(paraLayer);
   1.589 +    CCharFormatLayer* charLayer = CCharFormatLayer::NewL();
   1.590 +    CleanupStack::PushL(charLayer);
   1.591 +    CRichText* doc = CRichText::NewL(paraLayer,charLayer,D);
   1.592 +    CleanupStack::PushL(doc);
   1.593 +    _LIT(KText1, "Hello there!");
   1.594 +    doc->InsertL(0, KText1);
   1.595 +    test(doc->DocumentLength()==12);
   1.596 +   
   1.597 +    // initilizing format (ie.underline) values
   1.598 +    TCharFormat formatCheck;
   1.599 +    formatCheck.iFontPresentation.iUnderline = EUnderlineOff;
   1.600 +    TCharFormat fmatCheck;
   1.601 +    formatCheck.iFontPresentation.iUnderline = EUnderlineOff;
   1.602 +    TCharFormat format;
   1.603 +    format.iFontPresentation.iUnderline = EUnderlineOn;
   1.604 +    TCharFormat formatNone;
   1.605 +    formatCheck.iFontPresentation.iUnderline = EUnderlineOff;
   1.606 +
   1.607 +    // initilizing format attributes
   1.608 +    TCharFormatMask maskCheck;   
   1.609 +    TCharFormatMask mask;
   1.610 +    mask.SetAttrib(EAttFontUnderline);
   1.611 +   
   1.612 +    // underline KText1 and compare its attribute values with EUnderlineOn for equality
   1.613 +    doc->ApplyCharFormatL(format, mask, 0, 12);   
   1.614 +    doc->GetCharFormat(formatCheck, maskCheck, 0, 12);
   1.615 +    // testing for fix of INC097216 whether EOD also formatted
   1.616 +    doc->GetCharFormat(fmatCheck, maskCheck, 12, 1);
   1.617 +    test(format.IsEqual(formatCheck));
   1.618 +    test(format.IsEqual(fmatCheck));
   1.619 +
   1.620 +    // remove underlining of KText1 and compare its attribute values with EUnderlineOff for equality
   1.621 +    doc->RemoveSpecificCharFormatL(0, 12);
   1.622 +    doc->GetCharFormat(formatCheck, maskCheck, 0, 12);
   1.623 +    // testing for fix of INC104149 whether EOD also has formatting removed
   1.624 +    doc->GetCharFormat(fmatCheck, maskCheck, 12, 1);
   1.625 +    test(formatCheck.IsEqual(formatNone));
   1.626 +    test(fmatCheck.IsEqual(formatNone));
   1.627 +   
   1.628 +    CleanupStack::PopAndDestroy(doc);
   1.629 +    CleanupStack::PopAndDestroy(charLayer);
   1.630 +    CleanupStack::PopAndDestroy(paraLayer);   
   1.631 +    __UHEAP_MARKEND;
   1.632 +    }
   1.633 +
   1.634 +
   1.635 +template<class S, class T,CEditableText::TDocumentStorage D>
   1.636 +void CRichTest<S,T,D>::TestResetL()
   1.637 +//
   1.638 +// Test the Reset() method of CRichText.
   1.639 +//
   1.640 +	{
   1.641 +	__UHEAP_MARK;
   1.642 +	INFO_PRINTF1(_L("Reset()"));
   1.643 +	CParaFormatLayer* paraLayer=CParaFormatLayer::NewL();
   1.644 +	CCharFormatLayer* charLayer=CCharFormatLayer::NewL();
   1.645 +	CRichText* doc=NULL;
   1.646 +	TRAPD(ret,doc=CRichText::NewL(paraLayer,charLayer,D));
   1.647 +	if (ret!=KErrNone)
   1.648 +		{
   1.649 +		test(doc==NULL);
   1.650 +		User::Leave(ret);
   1.651 +		}
   1.652 +	TPtrC buf1(_L("Here is paragraph one text."));
   1.653 +	TPtrC buf2(_L("And here is that of the second paragraph"));
   1.654 +	doc->InsertL(0,buf1);
   1.655 +	doc->InsertL(doc->DocumentLength(),EParagraphDelimiter);
   1.656 +	doc->InsertL(doc->DocumentLength(),buf2);
   1.657 +	//
   1.658 +	doc->Reset();
   1.659 +	test(doc->ParagraphCount()==1);
   1.660 +	doc->Reset();
   1.661 +	test(doc->ParagraphCount()==1);
   1.662 +	doc->Reset();
   1.663 +	test(doc->ParagraphCount()==1);
   1.664 +	delete doc;
   1.665 +	delete paraLayer;
   1.666 +	delete charLayer;
   1.667 +
   1.668 +	__UHEAP_MARKEND;
   1.669 +	}
   1.670 +	
   1.671 +
   1.672 +template<class S, class T,CEditableText::TDocumentStorage D>
   1.673 +void CRichTest<S,T,D>::DoPML()
   1.674 +//
   1.675 +// Use PML source translator to produce a RichText component.
   1.676 +//
   1.677 +	{
   1.678 + 	__UHEAP_MARK;
   1.679 +	INFO_PRINTF1(_L("Checking PML sourced RichText Component"));
   1.680 + 	// set filename
   1.681 +	TFileName theFileName=_L("z:\\test\\app-framework\\etext\\t_rich1a.pml");
   1.682 +	// Parse PML
   1.683 +	CParser* myParser=NULL;
   1.684 +	CRichText* richTextDoc=NULL;
   1.685 +	TRAPD(ret, myParser=CParser::NewL());
   1.686 +	CleanupStack::PushL(myParser);
   1.687 +	TRAP(ret, richTextDoc=myParser->ParseL(theFileName));
   1.688 +	CleanupStack::PushL(richTextDoc);
   1.689 +	CParaFormatLayer* pl = const_cast<CParaFormatLayer*>(
   1.690 +		richTextDoc->GlobalParaFormatLayer());
   1.691 +	CleanupStack::PushL(pl);
   1.692 +	CCharFormatLayer* cl = const_cast<CCharFormatLayer*>(
   1.693 +		richTextDoc->GlobalCharFormatLayer());
   1.694 +	CleanupStack::PushL(cl);
   1.695 +	
   1.696 +	TInt paraCount=richTextDoc->ParagraphCount();
   1.697 +	test(paraCount==2);
   1.698 +	TBool hasMarkupData=richTextDoc->HasMarkupData();
   1.699 +	test(hasMarkupData==EFalse);
   1.700 +
   1.701 +	// Testing overloaded senseChars - looking at the indeterminate mask.
   1.702 +//	TCharFormat charFormat;	TCharFormatMask charFormatMask;
   1.703 +//	richTextDoc->GetCharFormat(0,17,charFormat,charFormatMask);
   1.704 +//	test(charFormatMask==0);
   1.705 +
   1.706 +//	richTextDoc->GetCharFormat(17,10,charFormat,charFormatMask);
   1.707 +
   1.708 +	CParaFormat* paraFormat = 0;
   1.709 +	paraFormat=CParaFormat::NewLC();
   1.710 +	TParaFormatMask paraFormatMask;
   1.711 +	richTextDoc->GetParaFormatL(paraFormat,paraFormatMask,0,2);
   1.712 +	richTextDoc->GetParaFormatL(paraFormat,paraFormatMask,17,3);  // All para 2 and just para1
   1.713 +
   1.714 +	CleanupStack::PopAndDestroy(paraFormat);
   1.715 +	CleanupStack::PopAndDestroy(cl);
   1.716 +	CleanupStack::PopAndDestroy(pl);
   1.717 +	CleanupStack::PopAndDestroy(richTextDoc);
   1.718 +	CleanupStack::PopAndDestroy(myParser);
   1.719 +	__UHEAP_MARKEND;
   1.720 +	}
   1.721 +
   1.722 +template<class S, class T,CEditableText::TDocumentStorage D>
   1.723 +void CRichTest<S,T,D>::TestForDefectTET5DHEWWL()
   1.724 +//
   1.725 +// Test the CRichTextIndex::InsertL() for defect TET-5DHEWW which 
   1.726 +// should not be present from 15/10/02.
   1.727 +//
   1.728 +	{
   1.729 +	__UHEAP_MARK;
   1.730 +
   1.731 +	INFO_PRINTF1(_L("Testing for the presence of defect TET-5DHEWW"));
   1.732 +
   1.733 +	CParaFormatLayer* paraLayer = CParaFormatLayer::NewL();
   1.734 +	CCharFormatLayer* charLayer = CCharFormatLayer::NewL();
   1.735 +
   1.736 +	CRichText* doc = NULL;
   1.737 +	TRAPD(ret, doc = CRichText::NewL(paraLayer,charLayer,D));
   1.738 +	if (ret!=KErrNone)
   1.739 +		{
   1.740 +		test(doc==NULL);
   1.741 +		User::Leave(ret);
   1.742 +		}
   1.743 +
   1.744 +	TPtrC buf1(_L("sometext "));
   1.745 +	doc->InsertL(0, buf1);
   1.746 +
   1.747 +	TCharFormat charFormat12(_L("Times New Roman"), 240);
   1.748 +	TCharFormatMask charMask12;
   1.749 +	charMask12.SetAttrib(EAttFontHeight);
   1.750 +	doc->SetInsertCharFormatL(charFormat12, charMask12, doc->DocumentLength());
   1.751 +
   1.752 +	TPtrC buf2(_L("sometext "));
   1.753 +	doc->InsertL(doc->DocumentLength(), buf2);
   1.754 +
   1.755 +	doc->SetInsertCharFormatL(charFormat12, charMask12, doc->DocumentLength());
   1.756 +	doc->InsertL(doc->DocumentLength(), EParagraphDelimiter);
   1.757 +
   1.758 +	// Defect present in CRichTextIndex if test executable crashes/panics on the 
   1.759 +	// previous line on a debug build. Should this test method return normally then 
   1.760 +	// the EText library used does not contain the defect.
   1.761 +
   1.762 +	TInt docLen = doc->DocumentLength();
   1.763 +	test(docLen==19);
   1.764 +
   1.765 +	INFO_PRINTF1(_L("RTEST:                        Test PASSED - defect not present!\n"));
   1.766 +
   1.767 +	delete doc;
   1.768 +	delete paraLayer;
   1.769 +	delete charLayer;
   1.770 +
   1.771 +	__UHEAP_MARKEND;
   1.772 +	}
   1.773 +
   1.774 +// CRichTextIndex::GetParaFormatL doesn't set TParaFormatMask correctly
   1.775 +template<class S, class T,CEditableText::TDocumentStorage D>
   1.776 +void CRichTest<S,T,D>::TestForDefectINC010183L()
   1.777 +	{
   1.778 +	__UHEAP_MARK;
   1.779 +
   1.780 +	INFO_PRINTF1(_L("Testing for the presence of defect INC010183"));
   1.781 +
   1.782 +	CParaFormatLayer* paraLayer = CParaFormatLayer::NewL();
   1.783 +	CleanupStack::PushL(paraLayer);
   1.784 +	CCharFormatLayer* charLayer = CCharFormatLayer::NewL();
   1.785 +	CleanupStack::PushL(charLayer);
   1.786 +
   1.787 +	CRichText* doc = CRichText::NewL(paraLayer,charLayer,D);
   1.788 +	CleanupStack::PushL(doc);
   1.789 +
   1.790 +	TPtrC buf1(_L("para1\x2029para2\x2029para3"));
   1.791 +	doc->InsertL(0, buf1);
   1.792 +
   1.793 +	CParaFormat* pFormat = CParaFormat::NewLC();
   1.794 +	pFormat->iBullet = new(ELeave) TBullet;
   1.795 +	pFormat->iBullet->iHeightInTwips = 1;
   1.796 +	TParaFormatMask pMask;
   1.797 +	pMask.SetAttrib(EAttBullet);
   1.798 +
   1.799 +	doc->ApplyParaFormatL(pFormat, pMask, 8, 1);
   1.800 +	doc->GetParaFormatL(pFormat, pMask, 0, 14);
   1.801 +
   1.802 +	// test that the bullet's "varies" flag is set.
   1.803 +	test(pMask.AttribIsSet(EAttBullet));
   1.804 +
   1.805 +	doc->GetParaFormatL(pFormat, pMask, 7, 6);
   1.806 +
   1.807 +	// test that the bullet's "varies" flag is set.
   1.808 +	test(pMask.AttribIsSet(EAttBullet));
   1.809 +
   1.810 +	CleanupStack::PopAndDestroy(pFormat);
   1.811 +	CleanupStack::PopAndDestroy(doc);
   1.812 +	CleanupStack::PopAndDestroy(charLayer);
   1.813 +	CleanupStack::PopAndDestroy(paraLayer);
   1.814 +
   1.815 +	__UHEAP_MARKEND;
   1.816 +	}
   1.817 +
   1.818 +
   1.819 +// CRichTextIndex::InsertL, Insertion of zero-length text should not cancel the pending new TCharFormat.
   1.820 +// This test sets the Strikethrough option on and applies it to a zero length section of text before checking
   1.821 +// the format has been applied correctly. Then it inputs 3 characters and checks to see if the format of these
   1.822 +// characters also has the character format applied to them.  
   1.823 +template<class S, class T,CEditableText::TDocumentStorage D>
   1.824 +void CRichTest<S,T,D>::TestForDefectINC064162L()
   1.825 +	{
   1.826 +	__UHEAP_MARK;
   1.827 +	
   1.828 +	INFO_PRINTF1(_L("INC064162 - Testing insertion of zero-length text doesn't cancel the pending TCharFormat"));
   1.829 +	
   1.830 +	TInt length = 3;	
   1.831 +	TPtrC bufPtrLetterNone(_L(""));
   1.832 +	TPtrC bufPtrLettersABC(_L("ABC"));
   1.833 +	
   1.834 +	CParaFormatLayer* paraLayer = CParaFormatLayer::NewL();
   1.835 +	CleanupStack::PushL(paraLayer);
   1.836 +	CCharFormatLayer* charLayer = CCharFormatLayer::NewL();
   1.837 +	CleanupStack::PushL(charLayer);
   1.838 +
   1.839 +	CRichText* doc = CRichText::NewL(paraLayer,charLayer,D);
   1.840 +	CleanupStack::PushL(doc);
   1.841 +
   1.842 +	TCharFormat cFormatCheck;
   1.843 +	cFormatCheck.iFontPresentation.iStrikethrough = EStrikethroughOff;
   1.844 +	
   1.845 +	TCharFormat cFormat;
   1.846 +	cFormat.iFontPresentation.iStrikethrough = EStrikethroughOn;
   1.847 +
   1.848 +	TCharFormatMask cMaskCheck;
   1.849 +	
   1.850 +	TCharFormatMask cMask;
   1.851 +	cMask.SetAttrib(EAttFontStrikethrough);
   1.852 +	
   1.853 +	// Applying the strikethrough format on a zero length section of text.
   1.854 +	doc->ApplyCharFormatL(cFormat,cMask,0,0);	
   1.855 +
   1.856 +	doc->InsertL(0, bufPtrLetterNone);
   1.857 +	
   1.858 +	doc->GetCharFormat(cFormatCheck, cMaskCheck,0,0);
   1.859 +
   1.860 +	// testing the format of the empty buf
   1.861 +	test(cFormat.IsEqual(cFormatCheck));
   1.862 +
   1.863 +	doc->InsertL(0, bufPtrLettersABC);	
   1.864 +	doc->GetCharFormat(cFormatCheck, cMaskCheck,0,length);
   1.865 +	
   1.866 +	// testing the format of the 3 characters
   1.867 +	test(cFormat.IsEqual(cFormatCheck));
   1.868 + 
   1.869 +	CleanupStack::PopAndDestroy(doc);
   1.870 +	CleanupStack::PopAndDestroy(charLayer);
   1.871 +	CleanupStack::PopAndDestroy(paraLayer);
   1.872 +
   1.873 +	__UHEAP_MARKEND;
   1.874 +	}
   1.875 +
   1.876 +
   1.877 +
   1.878 +template<class S, class T,CEditableText::TDocumentStorage D>
   1.879 +TBool CRichTest<S,T,D>::TestAndRunStageL(TInt aStage)
   1.880 +	{
   1.881 +	_LIT(KSomeText, "Text\x2029par ");
   1.882 +	_LIT(KSomeTextPlus3, "Text\x2029par \x2029z ");
   1.883 +	TCharFormat format;
   1.884 +	TCharFormatMask mask;
   1.885 +	TCharFormatMask varies;
   1.886 +	switch (aStage)
   1.887 +		{
   1.888 +	case 0:
   1.889 +		Reset();
   1.890 +		return ETrue;
   1.891 +	case 1:
   1.892 +		test(DocumentLength() == 0);
   1.893 +		InsertL(0, KSomeText);
   1.894 +		return ETrue;
   1.895 +	case 2:
   1.896 +			{
   1.897 +			TBuf<100> buf;
   1.898 +			test(DocumentLength() == KSomeText().Length());
   1.899 +			Extract(buf, 0, KSomeText().Length());
   1.900 +			test(0 == buf.Compare(KSomeText));
   1.901 +			TCharFormat format0;
   1.902 +			GetCharFormat(format, varies, 0, KSomeText().Length());
   1.903 +			test(varies.IsNull());		// format should not vary
   1.904 +			test(format.IsEqual(format0));
   1.905 +			}
   1.906 +		// Set an insert char format for font height 100
   1.907 +		mask.SetAttrib(EAttFontHeight);
   1.908 +		format.iFontSpec.iHeight = 100;
   1.909 +		SetInsertCharFormatL(format, mask, 9);
   1.910 +		return ETrue;
   1.911 +	case 3:
   1.912 +		test(DocumentLength() == KSomeText().Length());
   1.913 +		// Insert a carriage return and cancel the insert char format.
   1.914 +		// This stands in place of moving the cursor away from the
   1.915 +		// insertion point and back again.
   1.916 +		InsertL(9, 0x2029);
   1.917 +		return ETrue;
   1.918 +	case 4:
   1.919 +		test(DocumentLength() == KSomeText().Length() + 1);
   1.920 +		CancelInsertCharFormat();
   1.921 +		return ETrue;
   1.922 +	case 5:
   1.923 +		test(DocumentLength() == KSomeText().Length() + 1);
   1.924 +		GetCharFormat(format, varies, 0, 9);
   1.925 +			{
   1.926 +			TCharFormat format0;
   1.927 +			test(format.IsEqual(format0));
   1.928 +			test(varies.IsNull());
   1.929 +			}
   1.930 +		GetCharFormat(format, varies, 9, 1);
   1.931 +		test(varies.IsNull());
   1.932 +		test(format.iFontSpec.iHeight == 100);
   1.933 +		// Insert a character after the new carriage return. It should
   1.934 +		// have height 100. This is what the defect INC038479 is
   1.935 +		// complaining about. In fact it is a long-standing problem,
   1.936 +		// long assumed to be too difficult to solve in a reasonable
   1.937 +		// time.
   1.938 +		InsertL(10, 'z');
   1.939 +		return ETrue;
   1.940 +	case 6:
   1.941 +		test(DocumentLength() == KSomeText().Length() + 2);
   1.942 +		GetCharFormat(format, varies, 9, 2);
   1.943 +		test(varies.IsNull());
   1.944 +		test(format.iFontSpec.iHeight == 100);
   1.945 +		// Insert a space. This prepares us for checking for a regression
   1.946 +		// that was introduced then fixed in the fix for INC038479.
   1.947 +		InsertL(11, ' ');
   1.948 +		return ETrue;
   1.949 +	case 7:
   1.950 +			{
   1.951 +			TBuf<100> buf;
   1.952 +			test(DocumentLength() == KSomeTextPlus3().Length());
   1.953 +			Extract(buf, 0, KSomeTextPlus3().Length());
   1.954 +			test(0 == buf.Compare(KSomeTextPlus3));
   1.955 +			TCharFormat format0;
   1.956 +			GetCharFormat(format, varies, 0, KSomeText().Length());
   1.957 +			test(varies.IsNull());		// format should not vary across the original bit
   1.958 +			test(format.IsEqual(format0));
   1.959 +			GetCharFormat(format, varies, KSomeText().Length(), 3);
   1.960 +			test(format.iFontSpec.iHeight == 100);
   1.961 +			test(varies.IsNull());
   1.962 +			}
   1.963 +		// Set a new insert character format for bold
   1.964 +		mask.SetAttrib(EAttFontStrokeWeight);
   1.965 +		format.iFontSpec.iFontStyle.SetStrokeWeight(EStrokeWeightBold);
   1.966 +		SetInsertCharFormatL(format, mask, 9);
   1.967 +		return ETrue;
   1.968 +	case 8:
   1.969 +		// and unset the insert character format again
   1.970 +		mask.SetAttrib(EAttFontStrokeWeight);
   1.971 +		format.iFontSpec.iFontStyle.SetStrokeWeight(EStrokeWeightNormal);
   1.972 +		SetInsertCharFormatL(format, mask, 9);
   1.973 +		return ETrue;
   1.974 +	case 9:
   1.975 +		test(DocumentLength() == KSomeTextPlus3().Length());
   1.976 +		// Add a carriage return.
   1.977 +		InsertL(12, 0x2029);
   1.978 +		return ETrue;
   1.979 +	case 10:
   1.980 +		test(DocumentLength() == KSomeTextPlus3().Length() + 1);
   1.981 +		GetCharFormat(format, varies, KSomeTextPlus3().Length(), 1);
   1.982 +		test(varies.IsNull());
   1.983 +		test(format.iFontSpec.iFontStyle.StrokeWeight() == EStrokeWeightNormal);
   1.984 +		return EFalse;
   1.985 +	default:
   1.986 +		return ETrue;
   1.987 +		}
   1.988 +	}
   1.989 +
   1.990 +template<class S, class T,CEditableText::TDocumentStorage D>
   1.991 +void CRichTest<S,T,D>::TestErrorCondition(TInt aStage, TInt aError)
   1.992 +	{
   1.993 +	// No leaves possible except NoMemory.
   1.994 +	test(aError == KErrNoMemory);
   1.995 +	// Stage 4 should not leave at all.
   1.996 +	test(aStage != 4);
   1.997 +	}
   1.998 +
   1.999 +
  1.1000 +template<class S, class T, CEditableText::TDocumentStorage D>
  1.1001 +void TestClassesL()
  1.1002 +	{
  1.1003 +	__UHEAP_MARK;
  1.1004 +
  1.1005 +	CParaFormatLayer* paraLayer = CParaFormatLayer::NewL();
  1.1006 +	CleanupStack::PushL(paraLayer);
  1.1007 +	CCharFormatLayer* charLayer = CCharFormatLayer::NewL();
  1.1008 +	CleanupStack::PushL(charLayer);
  1.1009 +	CRichTest<S, T, D>* doc = CRichTest<S, T, D>::NewL(paraLayer, charLayer);
  1.1010 +	CleanupStack::PushL(doc);
  1.1011 +
  1.1012 +	doc->DoFlatTests();
  1.1013 +	doc->TestResetL();
  1.1014 +	doc->TestDelete1L();
  1.1015 +	doc->TestDelete2L();
  1.1016 +	doc->TestApplyRemoveCharFormat();
  1.1017 +	doc->TestRemSpecParaFmtL();
  1.1018 +	doc->DoPML();
  1.1019 +	doc->TestForDefectTET5DHEWWL();
  1.1020 +	doc->TestForDefectINC010183L();
  1.1021 +	doc->TestForDefectINC064162L();
  1.1022 +	doc->TestForDefectINC109323L();
  1.1023 +	INFO_PRINTF1(_L("INC038479 - Email editor: font settings made at doc end can be lost and returned to default"));
  1.1024 +	// Also tests SetInsetCharFormat more thoroughly.
  1.1025 +	doc->RunAtomicTest();
  1.1026 +
  1.1027 +	CleanupStack::PopAndDestroy(doc);
  1.1028 +	CleanupStack::PopAndDestroy(charLayer);
  1.1029 +	CleanupStack::PopAndDestroy(paraLayer);
  1.1030 +
  1.1031 +	__UHEAP_MARKEND;
  1.1032 +	}
  1.1033 +
  1.1034 +void DoTestsL()
  1.1035 +	{
  1.1036 +	INFO_PRINTF1(_L("CRichText - Flat"));
  1.1037 +	TestClassesL<TText,TPtrC,CEditableText::EFlatStorage>();
  1.1038 +	INFO_PRINTF1(_L("CRichText - Segmented"));
  1.1039 +	TestClassesL<TText,TPtrC,CEditableText::ESegmentedStorage>();
  1.1040 +	
  1.1041 +	}
  1.1042 +
  1.1043 +	
  1.1044 +LOCAL_C void setupCleanup()
  1.1045 +//
  1.1046 +// Initialise the cleanup stack.
  1.1047 +//
  1.1048 +	{
  1.1049 +
  1.1050 +	TheTrapCleanup=CTrapCleanup::New();
  1.1051 +	TRAPD(r,\
  1.1052 +		{\
  1.1053 +		for (TInt i=KTestCleanupStack;i>0;i--)\
  1.1054 +			CleanupStack::PushL((TAny*)1);\
  1.1055 +		test(r==KErrNone);\
  1.1056 +		CleanupStack::Pop(KTestCleanupStack);\
  1.1057 +		});
  1.1058 +	}
  1.1059 +
  1.1060 +CT_RICH1A::CT_RICH1A()
  1.1061 +    {
  1.1062 +    SetTestStepName(KTestStep_T_RICH1A);
  1.1063 +    pTestStep = this;
  1.1064 +    }
  1.1065 +
  1.1066 +TVerdict CT_RICH1A::doTestStepL()
  1.1067 +    {
  1.1068 +    SetTestStepResult(EFail);
  1.1069 +
  1.1070 +    setupCleanup();
  1.1071 +    INFO_PRINTF1(_L("CRichText Document"));
  1.1072 +    __UHEAP_MARK;
  1.1073 +    
  1.1074 +    TRAPD(ret,DoTestsL());
  1.1075 +    
  1.1076 +    __UHEAP_MARKEND;
  1.1077 +    delete TheTrapCleanup;
  1.1078 +    
  1.1079 +    if (ret == KErrNone)
  1.1080 +        {
  1.1081 +        SetTestStepResult(EPass);
  1.1082 +        }
  1.1083 +
  1.1084 +    return TestStepResult();
  1.1085 +    }