os/textandloc/textrendering/textformatting/test/src/TTextView.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/TTextView.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,2339 @@
     1.4 +/*
     1.5 +* Copyright (c) 2000-2009 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 +* TTextView.cpp test file for UndoSystem classes
    1.19 +*
    1.20 +*/
    1.21 +
    1.22 +
    1.23 +#include <e32test.h>
    1.24 +
    1.25 +#include <coemain.h>
    1.26 +#include <frmtview.h>
    1.27 +#include <txtrich.h>
    1.28 +#include <conpics.h>
    1.29 +#include <e32math.h>
    1.30 +
    1.31 +#include "form_and_etext_editor.h"
    1.32 +#include "UndoSystem.h"
    1.33 +#include "EditorUndo.h"
    1.34 +#include "FRMPAGE.H"
    1.35 +
    1.36 +_LIT(KHello, "hello world");
    1.37 +const TInt KPaginatePriority = -100;
    1.38 +const TInt KGranularity = 10;
    1.39 +
    1.40 +using namespace UndoSystem;
    1.41 +
    1.42 +LOCAL_C TInt GetNumber(TInt aMin, TInt aMax)
    1.43 +	{
    1.44 +	__ASSERT_ALWAYS(aMin <= aMax, User::Invariant());
    1.45 +
    1.46 +	TInt64 seed = Math::Random();
    1.47 +	TReal randomReal = Math::FRand(seed);
    1.48 +
    1.49 +	TReal maxReal = randomReal * ((aMax-aMin)+1);
    1.50 +	TReal rounded = 0;
    1.51 +	User::LeaveIfError(Math::Round(rounded, maxReal, 0));
    1.52 +
    1.53 +	TInt result = rounded + aMin;
    1.54 +	
    1.55 +	if(result> aMax)
    1.56 +		{
    1.57 +		return aMax;
    1.58 +		}
    1.59 +	return result;
    1.60 +	}
    1.61 +
    1.62 +void ManipulateText(CTextView* aView, CRichText* aText)
    1.63 +	{
    1.64 +	_LIT(KStartText, "The quick brown fox jumped over the lazy dog.");
    1.65 +	aText->InsertL(0, KStartText);
    1.66 +	aView->HandleInsertDeleteL(TCursorSelection(0, KStartText().Length()), 0);
    1.67 +	aText->InsertL(19, TChar(CEditableText::EParagraphDelimiter));
    1.68 +	aView->HandleCharEditL();
    1.69 +	TCharFormat format;
    1.70 +	TCharFormatMask mask;
    1.71 +	format.iFontSpec.iFontStyle.SetStrokeWeight(EStrokeWeightBold);
    1.72 +	mask.ClearAll();
    1.73 +	mask.SetAttrib(EAttFontStrokeWeight);
    1.74 +	aText->ApplyCharFormatL(format, mask, 41, 3);
    1.75 +	aView->HandleRangeFormatChangeL(TCursorSelection(41, 44));
    1.76 +	aView->SetDocPosL(42);
    1.77 +	TInt length = aText->DocumentLength();
    1.78 +	aText->DeleteL(0, length);
    1.79 +	aView->HandleInsertDeleteL(TCursorSelection(0, 0), length);
    1.80 +	}
    1.81 +
    1.82 +void ManipulateText1(CTextView* aView, CRichText* aText)
    1.83 +	{
    1.84 +	TInt testaYPos = 0;
    1.85 +	_LIT(KText, "The weather is quite good today, but it's a bit too cold");
    1.86 +	aText->InsertL(0, KText);
    1.87 +	aView->HandleInsertDeleteL(TCursorSelection(0, KText().Length()), 0);
    1.88 +	aView->SetDocPosL(10); //56 is the position of the last character d
    1.89 +	aView->SetViewLineAtTopL(1);
    1.90 +	aView->SetViewL(50, testaYPos);
    1.91 +	aView->HandleAdditionalCharactersAtEndL();
    1.92 +	}
    1.93 +
    1.94 +inline TBool IsSurrogate(TText16 aInt16)
    1.95 +/**
    1.96 +@return True, if aText16 is high surrogate or low surrogate; false, otherwise.
    1.97 +*/
    1.98 +	{
    1.99 +	return (aInt16 & 0xF800) == 0xD800;
   1.100 +	}
   1.101 +
   1.102 +class CMyTestPicture : public CPicture
   1.103 +	{
   1.104 +public:
   1.105 +	static CMyTestPicture* NewL(TSize aSize);
   1.106 +	void Draw(CGraphicsContext&,const TPoint&,const TRect&,MGraphicsDeviceMap*) const {}
   1.107 +	void ExternalizeL(RWriteStream& /*aStream*/) const {}
   1.108 +	void GetOriginalSizeInTwips(TSize& aSize) const {aSize=iSizeOfPicture;}
   1.109 +private:
   1.110 +	CMyTestPicture(TSize aSize);
   1.111 +private:
   1.112 +	TSize iSizeOfPicture;
   1.113 +	};
   1.114 +
   1.115 +CMyTestPicture* CMyTestPicture::NewL(TSize aSize)
   1.116 +	{
   1.117 +	return new(ELeave) CMyTestPicture(aSize);
   1.118 +	}
   1.119 +
   1.120 +
   1.121 +CMyTestPicture::CMyTestPicture(TSize aSize):iSizeOfPicture(aSize)
   1.122 +	{}
   1.123 +
   1.124 +
   1.125 +class CTextViewTest : public CBase
   1.126 +	{
   1.127 +public:
   1.128 +	CTextViewTest(CCoeEnv& aEnv)
   1.129 +		: iEnv(aEnv), 	iWindowRect(10, 10, 110, 110), iWindow(aEnv.WsSession()),
   1.130 +		test(_L("TTextView - Some tests for CTextView")) {}
   1.131 +	void ConstructL();
   1.132 +	void InitializeL();
   1.133 +	void AddTextL(const TDesC&);
   1.134 +	void Destroy();
   1.135 +	~CTextViewTest();
   1.136 +	void TestL();
   1.137 +	void Test1L();
   1.138 +	void TestCancelSelectionL();
   1.139 +	void TestHandleAdditionalCharactersAtEndL();
   1.140 +	void TestFinishBackgroundFormattingL();
   1.141 +	void TestSetCursorVisibilityL();
   1.142 +	void TestSetSelectionVisibilityL();
   1.143 +	void TestEnablePictureFrameL();
   1.144 +	void TestSetCursorWidthTypeL();
   1.145 +	void TestParagraphRectL();
   1.146 +	void TestSetDocPosL();
   1.147 +	void TestSetViewLineAtTopL();
   1.148 +	void TestDrawL();
   1.149 +	void TestFormatTextL();
   1.150 +	void TestHandleCharEditL();
   1.151 +	void TestHandleRangeFormatChangeL();
   1.152 +	void TestHandleInsertDeleteL();
   1.153 +	void TestHandleGlobalChangeL();
   1.154 +	void TestHandleGlobalChangeNoRedrawL();
   1.155 +	void TestScrollDisplayL();
   1.156 +    void TestScrollDisplayPixelsL();
   1.157 +    void TestScrollDisplayPixelsNoLimitBordersL(TInt aOffset);
   1.158 +    void TestForDEF142286BounceScrollingL();
   1.159 +	void TestScrollDisplayLinesL();
   1.160 +	void TestScrollDisplayParagraphsL();
   1.161 +	void TestSetViewL();
   1.162 +	void TestMoveCursorL();
   1.163 +	void TestSetSelectionL();
   1.164 +	void TestMatchCursorHeightL();
   1.165 +	void TestCalculateHorizontalExtremesL();
   1.166 +	void TestXyPosToDocPosL();
   1.167 +//	void TestDrawL1();
   1.168 +	void TestGetPictureRectangleL();
   1.169 +	void TestGetPictureRectangle1L();
   1.170 +	void TestSetDisplayContextL();
   1.171 +	void TestGetPictureRectangleDefectL();
   1.172 +	void TestGetLineRectL(); // Test for defect WEP-567K9C Form panics when picture
   1.173 +							 // inserted in CRichText and alignmnent is set to bottom
   1.174 +	void TestForDEF003426L();
   1.175 +	void TestForDEF038488L();
   1.176 +	void InitializeDiffCharFormatL();
   1.177 +	void TestGetParaFormatL();
   1.178 +	// Function to test the Class TFormAndEtextEditor
   1.179 +	void FormAndEtextTestL();
   1.180 +	void TestForINC092725L();
   1.181 +	void TestForPDEF108443L();
   1.182 +	void TestForPDEF113755L();
   1.183 +	void TestForPDEF115165L();
   1.184 +	void TestForPDEF118443L();
   1.185 +	void TestForPDEF121798L();
   1.186 +	void TestForPDEF120239L();
   1.187 +	void TestForDEF124989L();
   1.188 +	void TestForDEF124975L();
   1.189 +	
   1.190 +	struct STestDataTInt4
   1.191 +		{
   1.192 +		TInt iDoc1;
   1.193 +		TInt iDoc2; 
   1.194 +		TInt iPos1;
   1.195 +		TInt iPos2;		
   1.196 +		};
   1.197 +	
   1.198 +private:
   1.199 +	CCoeEnv& iEnv;
   1.200 +	TRect iWindowRect;
   1.201 +	CParaFormatLayer* iParaLayer;
   1.202 +	CCharFormatLayer* iCharLayer;
   1.203 +	CRichText* iEtext;
   1.204 +	CTextLayout* iLayout;
   1.205 +	RWindow iWindow;
   1.206 +	CTextView* iView;
   1.207 +	RTest test;
   1.208 +	TCursorSelection select;
   1.209 +	TInt testDeltaY;
   1.210 +	TInt testDeltaLines;
   1.211 +	TInt testDeltaParas;
   1.212 +	TInt testaYPos;
   1.213 +	TCursorPosition::TMovementType testaMovement;
   1.214 +	TFontSpec testaFontSpec;
   1.215 +	TInt testaLeft;
   1.216 +	TInt testaRight;
   1.217 +	TPoint testaPoint;
   1.218 +	TBool testaCanScaleOrCrop;
   1.219 +	CBitmapContext* testaGc;
   1.220 +	TPoint testaXyPos;
   1.221 +	CBitmapDevice* testaGd;
   1.222 +	RWindowGroup testaGroupWin;
   1.223 +	RWsSession testaSession;
   1.224 +	};
   1.225 +
   1.226 +void CTextViewTest::ConstructL()
   1.227 +	{
   1.228 +	iWindow.Construct(iEnv.RootWin(), 12345);
   1.229 +	iParaLayer = CParaFormatLayer::NewL();
   1.230 +	iCharLayer = CCharFormatLayer::NewL();
   1.231 +	test.Title();
   1.232 +	test.Start(_L("CTextView Tests:"));
   1.233 +	}
   1.234 +
   1.235 +void CTextViewTest::InitializeL()
   1.236 +	{
   1.237 +	Destroy();
   1.238 +	iEtext = CRichText::NewL(iParaLayer, iCharLayer);
   1.239 +	iLayout = CTextLayout::NewL(iEtext, iWindowRect.Width());
   1.240 +	iView = CTextView::NewL(iLayout, iWindowRect, iEnv.ScreenDevice(),
   1.241 +		iEnv.SystemGc().Device(), &iWindow, &iEnv.RootWin(), &iEnv.WsSession());
   1.242 +	testaGd=(CBitmapDevice*) iEnv.SystemGc().Device();
   1.243 +	}
   1.244 +
   1.245 +void CTextViewTest::AddTextL(const TDesC& aText)
   1.246 +	{
   1.247 +	iEtext->InsertL(0, aText);
   1.248 +	TCursorSelection s(0, aText.Length());
   1.249 +	iView->HandleInsertDeleteL(s, 0);
   1.250 +	}
   1.251 +
   1.252 +void CTextViewTest::InitializeDiffCharFormatL()
   1.253 +	{
   1.254 +	Destroy();
   1.255 +	delete iCharLayer;
   1.256 +	iCharLayer=0;
   1.257 +	TCharFormat charFormat;
   1.258 +	TCharFormatMask charFormatMask;
   1.259 +	charFormat.iFontPresentation.iPictureAlignment=TFontPresentation::EAlignBottom;
   1.260 +	charFormatMask.SetAttrib(EAttFontPictureAlignment);
   1.261 +	iCharLayer = CCharFormatLayer::NewL(charFormat,charFormatMask);
   1.262 +	iEtext = CRichText::NewL(iParaLayer, iCharLayer);
   1.263 +	iLayout = CTextLayout::NewL(iEtext, iWindowRect.Width());
   1.264 +	iView = CTextView::NewL(iLayout, iWindowRect, iEnv.ScreenDevice(),
   1.265 +		iEnv.SystemGc().Device(), &iWindow, &iEnv.RootWin(), &iEnv.WsSession());
   1.266 +	testaGd=(CBitmapDevice*) iEnv.SystemGc().Device();
   1.267 +	}
   1.268 +
   1.269 +void CTextViewTest::Destroy()
   1.270 +	{
   1.271 +	delete iView;
   1.272 +	iView = 0;
   1.273 +	delete iLayout;
   1.274 +	iLayout = 0;
   1.275 +	delete iEtext;
   1.276 +	iEtext = 0;
   1.277 +	}
   1.278 +
   1.279 +
   1.280 +void CTextViewTest::TestL()
   1.281 +	{
   1.282 +	// Test for fix to ASR-4UYHZX: ETEXT panic 12 (ECharPosBeyondDocument) when
   1.283 +	// out of memory
   1.284 +	InitializeL();
   1.285 +	ManipulateText(iView, iEtext);
   1.286 +	Destroy();
   1.287 +	TInt consecutiveSuccesses = 0;
   1.288 +	for (TInt i = 1; consecutiveSuccesses != 100; ++i)
   1.289 +		{
   1.290 +		__UHEAP_MARK;
   1.291 +		InitializeL();
   1.292 +		__UHEAP_SETFAIL(RHeap::EDeterministic, i);
   1.293 +		TRAPD(err, ManipulateText(iView, iEtext));
   1.294 +		Destroy();
   1.295 +		__UHEAP_SETFAIL(RHeap::ENone, 0);
   1.296 +		__UHEAP_MARKENDC(0);
   1.297 +		if (err == KErrNone)
   1.298 +			++consecutiveSuccesses;
   1.299 +		else
   1.300 +			consecutiveSuccesses = 0;
   1.301 +		}
   1.302 +	}
   1.303 +
   1.304 +
   1.305 +void CTextViewTest::Test1L()
   1.306 +	{
   1.307 +	// testing functions SetViewL, SetViewLineAtTopL,
   1.308 +	// SetDocPosL & HandleAdditionalCharactersAtEndL
   1.309 +	// - should work but need some kind
   1.310 +	// of pre-settings and initialization before they can all be proved
   1.311 +	// that there is no memory leak
   1.312 +	InitializeL();
   1.313 +	ManipulateText1(iView, iEtext); //where all pre-settings have been done
   1.314 +	Destroy();
   1.315 +	TInt consecutiveSuccesses = 0;
   1.316 +	for (TInt i = 1; consecutiveSuccesses != 100; ++i)
   1.317 +		{
   1.318 +		__UHEAP_MARK;
   1.319 +		InitializeL();
   1.320 +		__UHEAP_SETFAIL(RHeap::EDeterministic, i);
   1.321 +		TRAPD(err, ManipulateText1(iView, iEtext));
   1.322 +		Destroy();
   1.323 +		__UHEAP_SETFAIL(RHeap::ENone, 0);
   1.324 +		__UHEAP_MARKENDC(0);
   1.325 +		if (err == KErrNone)
   1.326 +			++consecutiveSuccesses;
   1.327 +		else
   1.328 +			consecutiveSuccesses = 0;
   1.329 +		}
   1.330 +	}
   1.331 +
   1.332 +
   1.333 +void CTextViewTest::TestCancelSelectionL()
   1.334 +	{
   1.335 +	InitializeL();
   1.336 +	iView->CancelSelectionL();
   1.337 +	Destroy();
   1.338 +	TInt consecutiveSuccesses = 0;
   1.339 +	for (TInt i = 1; consecutiveSuccesses != 100; ++i)
   1.340 +		{
   1.341 +		__UHEAP_MARK;
   1.342 +		InitializeL();
   1.343 +		__UHEAP_SETFAIL(RHeap::EDeterministic, i);
   1.344 +		TRAPD(err, iView->CancelSelectionL());
   1.345 +		Destroy();
   1.346 +		__UHEAP_SETFAIL(RHeap::ENone, 0);
   1.347 +		__UHEAP_MARKENDC(0);
   1.348 +		if (err == KErrNone)
   1.349 +			++consecutiveSuccesses;
   1.350 +		else
   1.351 +			consecutiveSuccesses = 0;
   1.352 +		}
   1.353 +	}
   1.354 +
   1.355 +
   1.356 +void CTextViewTest::TestFinishBackgroundFormattingL()
   1.357 +	{
   1.358 +	InitializeL();
   1.359 +	iView->FinishBackgroundFormattingL();
   1.360 +	Destroy();
   1.361 +	TInt consecutiveSuccesses = 0;
   1.362 +	for (TInt i = 1; consecutiveSuccesses != 100; ++i)
   1.363 +		{
   1.364 +		__UHEAP_MARK;
   1.365 +		InitializeL();
   1.366 +		__UHEAP_SETFAIL(RHeap::EDeterministic, i);
   1.367 +		TRAPD(err, iView->FinishBackgroundFormattingL());
   1.368 +		Destroy();
   1.369 +		__UHEAP_SETFAIL(RHeap::ENone, 0);
   1.370 +		__UHEAP_MARKENDC(0);
   1.371 +		if (err == KErrNone)
   1.372 +			++consecutiveSuccesses;
   1.373 +		else
   1.374 +			consecutiveSuccesses = 0;
   1.375 +		}
   1.376 +	}
   1.377 +
   1.378 +
   1.379 +void CTextViewTest::TestFormatTextL()
   1.380 +	{
   1.381 +	InitializeL();
   1.382 +	iView->FormatTextL();
   1.383 +	Destroy();
   1.384 +	TInt consecutiveSuccesses = 0;
   1.385 +	for (TInt i = 1; consecutiveSuccesses != 100; ++i)
   1.386 +		{
   1.387 +		__UHEAP_MARK;
   1.388 +		InitializeL();
   1.389 +		__UHEAP_SETFAIL(RHeap::EDeterministic, i);
   1.390 +		TRAPD(err, iView->FormatTextL());
   1.391 +		Destroy();
   1.392 +		__UHEAP_SETFAIL(RHeap::ENone, 0);
   1.393 +		__UHEAP_MARKENDC(0);
   1.394 +		if (err == KErrNone)
   1.395 +			++consecutiveSuccesses;
   1.396 +		else
   1.397 +			consecutiveSuccesses = 0;
   1.398 +		}
   1.399 +	}
   1.400 +
   1.401 +
   1.402 +void CTextViewTest::TestSetCursorVisibilityL()
   1.403 +	{
   1.404 +	InitializeL();
   1.405 +	iView->SetCursorVisibilityL(1,1);
   1.406 +	Destroy();
   1.407 +	TInt consecutiveSuccesses = 0;
   1.408 +	for (TInt i = 1; consecutiveSuccesses != 100; ++i)
   1.409 +		{
   1.410 +		__UHEAP_MARK;
   1.411 +		InitializeL();
   1.412 +		__UHEAP_SETFAIL(RHeap::EDeterministic, i);
   1.413 +		TRAPD(err, iView->SetCursorVisibilityL(1,1)); //TInt aLineCursor, TInt aTextCursor
   1.414 +		Destroy();
   1.415 +		__UHEAP_SETFAIL(RHeap::ENone, 0);
   1.416 +		__UHEAP_MARKENDC(0);
   1.417 +		if (err == KErrNone)
   1.418 +			++consecutiveSuccesses;
   1.419 +		else
   1.420 +			consecutiveSuccesses = 0;
   1.421 +		}
   1.422 +	}
   1.423 +
   1.424 +
   1.425 +void CTextViewTest::TestSetSelectionVisibilityL()
   1.426 +	{
   1.427 +	InitializeL();
   1.428 +	iView->SetSelectionVisibilityL(1);
   1.429 +	Destroy();
   1.430 +	TInt consecutiveSuccesses = 0;
   1.431 +	for (TInt i = 1; consecutiveSuccesses != 100; ++i)
   1.432 +		{
   1.433 +		__UHEAP_MARK;
   1.434 +		InitializeL();
   1.435 +		__UHEAP_SETFAIL(RHeap::EDeterministic, i);
   1.436 +		TRAPD(err, iView->SetSelectionVisibilityL(1)); //TBool aSelectionVisible
   1.437 +		Destroy();
   1.438 +		__UHEAP_SETFAIL(RHeap::ENone, 0);
   1.439 +		__UHEAP_MARKENDC(0);
   1.440 +		if (err == KErrNone)
   1.441 +			++consecutiveSuccesses;
   1.442 +		else
   1.443 +			consecutiveSuccesses = 0;
   1.444 +		}
   1.445 +	}
   1.446 +
   1.447 +
   1.448 +void CTextViewTest::TestEnablePictureFrameL()
   1.449 +	{
   1.450 +	InitializeL();
   1.451 +	iView->EnablePictureFrameL(1);
   1.452 +	Destroy();
   1.453 +	TInt consecutiveSuccesses = 0;
   1.454 +	for (TInt i = 1; consecutiveSuccesses != 100; ++i)
   1.455 +		{
   1.456 +		__UHEAP_MARK;
   1.457 +		InitializeL();
   1.458 +		__UHEAP_SETFAIL(RHeap::EDeterministic, i);
   1.459 +		TRAPD(err, iView->EnablePictureFrameL(1)); //TBool aEnabled
   1.460 +		Destroy();
   1.461 +		__UHEAP_SETFAIL(RHeap::ENone, 0);
   1.462 +		__UHEAP_MARKENDC(0);
   1.463 +		if (err == KErrNone)
   1.464 +			++consecutiveSuccesses;
   1.465 +		else
   1.466 +			consecutiveSuccesses = 0;
   1.467 +		}
   1.468 +	}
   1.469 +
   1.470 +
   1.471 +void CTextViewTest::TestSetCursorWidthTypeL()
   1.472 +	{
   1.473 +	InitializeL();
   1.474 +	iView->SetCursorWidthTypeL(TTextCursor::ETypeRectangle,0);
   1.475 +	Destroy();
   1.476 +	TInt consecutiveSuccesses = 0;
   1.477 +	for (TInt i = 1; consecutiveSuccesses != 100; ++i)
   1.478 +		{
   1.479 +		__UHEAP_MARK;
   1.480 +		InitializeL();
   1.481 +		__UHEAP_SETFAIL(RHeap::EDeterministic, i);
   1.482 +		TRAPD(err, iView->SetCursorWidthTypeL(TTextCursor::ETypeRectangle,0)); //TTextCursor::EType aType, TInt aWidth=0
   1.483 +		Destroy();
   1.484 +		__UHEAP_SETFAIL(RHeap::ENone, 0);
   1.485 +		__UHEAP_MARKENDC(0);
   1.486 +		if (err == KErrNone)
   1.487 +			++consecutiveSuccesses;
   1.488 +		else
   1.489 +			consecutiveSuccesses = 0;
   1.490 +		}
   1.491 +	}
   1.492 +
   1.493 +
   1.494 +void CTextViewTest::TestParagraphRectL()
   1.495 +	{
   1.496 +	InitializeL();
   1.497 +	iView->ParagraphRectL(1);
   1.498 +	Destroy();
   1.499 +	TInt consecutiveSuccesses = 0;
   1.500 +	for (TInt i = 1; consecutiveSuccesses != 100; ++i)
   1.501 +		{
   1.502 +		__UHEAP_MARK;
   1.503 +		InitializeL();
   1.504 +		__UHEAP_SETFAIL(RHeap::EDeterministic, i);
   1.505 +		TRAPD(err, iView->ParagraphRectL(1)); //TInt aDocPos
   1.506 +		Destroy();
   1.507 +		__UHEAP_SETFAIL(RHeap::ENone, 0);
   1.508 +		__UHEAP_MARKENDC(0);
   1.509 +		if (err == KErrNone)
   1.510 +			++consecutiveSuccesses;
   1.511 +		else
   1.512 +			consecutiveSuccesses = 0;
   1.513 +		}
   1.514 +	}
   1.515 +
   1.516 +
   1.517 +void CTextViewTest::TestDrawL()
   1.518 +	{
   1.519 +	InitializeL();
   1.520 +	iView->DrawL(iWindowRect);
   1.521 +	Destroy();
   1.522 +	TInt consecutiveSuccesses = 0;
   1.523 +	for (TInt i = 1; consecutiveSuccesses != 100; ++i)
   1.524 +		{
   1.525 +		__UHEAP_MARK;
   1.526 +		InitializeL();
   1.527 +		__UHEAP_SETFAIL(RHeap::EDeterministic, i);
   1.528 +		TRAPD(err, iView->DrawL(iWindowRect)); //TRect aRect
   1.529 +		Destroy();
   1.530 +		__UHEAP_SETFAIL(RHeap::ENone, 0);
   1.531 +		__UHEAP_MARKENDC(0);
   1.532 +		if (err == KErrNone)
   1.533 +			++consecutiveSuccesses;
   1.534 +		else
   1.535 +			consecutiveSuccesses = 0;
   1.536 +		}
   1.537 +	}
   1.538 +
   1.539 +
   1.540 +void CTextViewTest::TestHandleRangeFormatChangeL()
   1.541 +	{
   1.542 +	InitializeL();
   1.543 +	iView->HandleRangeFormatChangeL(select, EFalse);
   1.544 +	Destroy();
   1.545 +	TInt consecutiveSuccesses = 0;
   1.546 +	for (TInt i = 1; consecutiveSuccesses != 100; ++i)
   1.547 +		{
   1.548 +		__UHEAP_MARK;
   1.549 +		InitializeL();
   1.550 +		__UHEAP_SETFAIL(RHeap::EDeterministic, i);
   1.551 +		TRAPD(err, iView->HandleRangeFormatChangeL(select, EFalse));
   1.552 +		Destroy();
   1.553 +		__UHEAP_SETFAIL(RHeap::ENone, 0);
   1.554 +		__UHEAP_MARKENDC(0);
   1.555 +		if (err == KErrNone)
   1.556 +			++consecutiveSuccesses;
   1.557 +		else
   1.558 +			consecutiveSuccesses = 0;
   1.559 +		}
   1.560 +	}
   1.561 +
   1.562 +
   1.563 +void CTextViewTest::TestHandleInsertDeleteL()
   1.564 +	{
   1.565 +	InitializeL();
   1.566 +	iView->HandleInsertDeleteL(select, 1, EFalse);
   1.567 +	Destroy();
   1.568 +	TInt consecutiveSuccesses = 0;
   1.569 +	for (TInt i = 1; consecutiveSuccesses != 100; ++i)
   1.570 +		{
   1.571 +		__UHEAP_MARK;
   1.572 +		InitializeL();
   1.573 +		__UHEAP_SETFAIL(RHeap::EDeterministic, i);
   1.574 +		TRAPD(err, iView->HandleInsertDeleteL(select, 1, EFalse));
   1.575 +		Destroy();
   1.576 +		__UHEAP_SETFAIL(RHeap::ENone, 0);
   1.577 +		__UHEAP_MARKENDC(0);
   1.578 +		if (err == KErrNone)
   1.579 +			++consecutiveSuccesses;
   1.580 +		else
   1.581 +			consecutiveSuccesses = 0;
   1.582 +		}
   1.583 +	}
   1.584 +
   1.585 +
   1.586 +void CTextViewTest::TestHandleGlobalChangeL()
   1.587 +	{
   1.588 +	InitializeL();
   1.589 +	iView->HandleGlobalChangeL(TViewYPosQualifier());
   1.590 +	Destroy();
   1.591 +	TInt consecutiveSuccesses = 0;
   1.592 +	for (TInt i = 1; consecutiveSuccesses != 100; ++i)
   1.593 +		{
   1.594 +		__UHEAP_MARK;
   1.595 +		InitializeL();
   1.596 +		__UHEAP_SETFAIL(RHeap::EDeterministic, i);
   1.597 +		TRAPD(err, iView->HandleGlobalChangeL(TViewYPosQualifier()));
   1.598 +		Destroy();
   1.599 +		__UHEAP_SETFAIL(RHeap::ENone, 0);
   1.600 +		__UHEAP_MARKENDC(0);
   1.601 +		if (err == KErrNone)
   1.602 +			++consecutiveSuccesses;
   1.603 +		else
   1.604 +			consecutiveSuccesses = 0;
   1.605 +		}
   1.606 +	}
   1.607 +
   1.608 +
   1.609 +void CTextViewTest::TestHandleGlobalChangeNoRedrawL()
   1.610 +	{
   1.611 +	InitializeL();
   1.612 +	iView->HandleGlobalChangeNoRedrawL(TViewYPosQualifier());
   1.613 +	Destroy();
   1.614 +	TInt consecutiveSuccesses = 0;
   1.615 +	for (TInt i = 1; consecutiveSuccesses != 100; ++i)
   1.616 +		{
   1.617 +		__UHEAP_MARK;
   1.618 +		InitializeL();
   1.619 +		__UHEAP_SETFAIL(RHeap::EDeterministic, i);
   1.620 +		TRAPD(err, iView->HandleGlobalChangeNoRedrawL(TViewYPosQualifier()));
   1.621 +		Destroy();
   1.622 +		__UHEAP_SETFAIL(RHeap::ENone, 0);
   1.623 +		__UHEAP_MARKENDC(0);
   1.624 +		if (err == KErrNone)
   1.625 +			++consecutiveSuccesses;
   1.626 +		else
   1.627 +			consecutiveSuccesses = 0;
   1.628 +		}
   1.629 +	}
   1.630 +
   1.631 +
   1.632 +void CTextViewTest::TestScrollDisplayL()
   1.633 +	{
   1.634 +	InitializeL();
   1.635 +	iView->ScrollDisplayL(TCursorPosition::EFLeft);
   1.636 +	Destroy();
   1.637 +	TInt consecutiveSuccesses = 0;
   1.638 +	for (TInt i = 1; consecutiveSuccesses != 100; ++i)
   1.639 +		{
   1.640 +		__UHEAP_MARK;
   1.641 +		InitializeL();
   1.642 +		__UHEAP_SETFAIL(RHeap::EDeterministic, i);
   1.643 +		TRAPD(err, iView->ScrollDisplayL(TCursorPosition::EFLeft));
   1.644 +		Destroy();
   1.645 +		__UHEAP_SETFAIL(RHeap::ENone, 0);
   1.646 +		__UHEAP_MARKENDC(0);
   1.647 +		if (err == KErrNone)
   1.648 +			++consecutiveSuccesses;
   1.649 +		else
   1.650 +			consecutiveSuccesses = 0;
   1.651 +		}
   1.652 +	}
   1.653 +
   1.654 +
   1.655 +void CTextViewTest::TestScrollDisplayPixelsL()
   1.656 +	{
   1.657 +	InitializeL();
   1.658 +	iView->ScrollDisplayPixelsL(testDeltaY);
   1.659 +	Destroy();
   1.660 +	TInt consecutiveSuccesses = 0;
   1.661 +	for (TInt i = 1; consecutiveSuccesses != 100; ++i)
   1.662 +		{
   1.663 +		__UHEAP_MARK;
   1.664 +		InitializeL();
   1.665 +		__UHEAP_SETFAIL(RHeap::EDeterministic, i);
   1.666 +		TRAPD(err, iView->ScrollDisplayPixelsL(testDeltaY));
   1.667 +		Destroy();
   1.668 +		__UHEAP_SETFAIL(RHeap::ENone, 0);
   1.669 +		__UHEAP_MARKENDC(0);
   1.670 +		if (err == KErrNone)
   1.671 +			++consecutiveSuccesses;
   1.672 +		else
   1.673 +			consecutiveSuccesses = 0;
   1.674 +		}
   1.675 +	}
   1.676 +
   1.677 +
   1.678 +void CTextViewTest::TestScrollDisplayPixelsNoLimitBordersL(TInt aOffset)
   1.679 +    { 
   1.680 +    /*
   1.681 +     * This test case is for new added function ScrollDisplayPixelsNoLimitBorderL() which support
   1.682 +     * no limit scrolling, using this function text view can be scrolled beyond the top and bottom 
   1.683 +     * border.
   1.684 +     * Text view will be firstly scrolled to border using ScrollDisplayPixelsL() which can't scroll
   1.685 +     * text view beyond the top or bottom border.
   1.686 +     * Then text view will be scrolled using ScrollDisplayPixelsNoLimitBorderL() to same direction.
   1.687 +     * Code will test this step that if text view is really scrolled beyond the border by checking 
   1.688 +     * the iBandTop position before and after the scrolling operation.*/
   1.689 +    
   1.690 +    InitializeL();
   1.691 +    _LIT(KTestParagraph, "This is a piece of text which is used to test the bounce scrolling feature made by s60.");
   1.692 +    for (TInt i=0;i<=20;i++)
   1.693 +        AddTextL(KTestParagraph);
   1.694 +    
   1.695 +    TInt firstBandTop, secondBandTop;
   1.696 +    TInt offset = aOffset;
   1.697 +    while( offset!=0 )
   1.698 +        {
   1.699 +        iView->ScrollDisplayPixelsL(offset);
   1.700 +        }
   1.701 +    offset = aOffset;
   1.702 +    firstBandTop = iLayout->PixelsAboveBand();
   1.703 +    iView->ScrollDisplayPixelsNoLimitBorderL(offset);
   1.704 +    secondBandTop = iLayout->PixelsAboveBand();
   1.705 +    test(firstBandTop - secondBandTop == offset);
   1.706 +
   1.707 +    offset = 0 - aOffset;
   1.708 +    while( offset!=0 )
   1.709 +        {
   1.710 +        iView->ScrollDisplayPixelsL(offset);
   1.711 +        }
   1.712 +    offset = 0 - aOffset;
   1.713 +    firstBandTop = iLayout->PixelsAboveBand();
   1.714 +    iView->ScrollDisplayPixelsNoLimitBorderL(offset);
   1.715 +    secondBandTop = iLayout->PixelsAboveBand();
   1.716 +    test(firstBandTop - secondBandTop == offset);
   1.717 +    
   1.718 +    Destroy();
   1.719 +    }
   1.720 +
   1.721 +
   1.722 +void CTextViewTest::TestScrollDisplayLinesL()
   1.723 +	{
   1.724 +	InitializeL();
   1.725 +	iView->ScrollDisplayLinesL(testDeltaLines);
   1.726 +	Destroy();
   1.727 +	TInt consecutiveSuccesses = 0;
   1.728 +	for (TInt i = 1; consecutiveSuccesses != 100; ++i)
   1.729 +		{
   1.730 +		__UHEAP_MARK;
   1.731 +		InitializeL();
   1.732 +		__UHEAP_SETFAIL(RHeap::EDeterministic, i);
   1.733 +		TRAPD(err, iView->ScrollDisplayLinesL(testDeltaLines));
   1.734 +		Destroy();
   1.735 +		__UHEAP_SETFAIL(RHeap::ENone, 0);
   1.736 +		__UHEAP_MARKENDC(0);
   1.737 +		if (err == KErrNone)
   1.738 +			++consecutiveSuccesses;
   1.739 +		else
   1.740 +			consecutiveSuccesses = 0;
   1.741 +		}
   1.742 +	}
   1.743 +
   1.744 +
   1.745 +void CTextViewTest::TestScrollDisplayParagraphsL()
   1.746 +	{
   1.747 +	InitializeL();
   1.748 +	AddTextL(KHello);
   1.749 +	iView->ScrollDisplayParagraphsL(testDeltaParas);
   1.750 +	Destroy();
   1.751 +	TInt consecutiveSuccesses = 0;
   1.752 +	for (TInt i = 1; consecutiveSuccesses != 100; ++i)
   1.753 +		{
   1.754 +		__UHEAP_MARK;
   1.755 +		InitializeL();
   1.756 +		AddTextL(KHello);
   1.757 +		__UHEAP_SETFAIL(RHeap::EDeterministic, i);
   1.758 +		TRAPD(err, iView->ScrollDisplayParagraphsL(testDeltaParas));
   1.759 +		Destroy();
   1.760 +		__UHEAP_SETFAIL(RHeap::ENone, 0);
   1.761 +		__UHEAP_MARKENDC(0);
   1.762 +		if (err == KErrNone)
   1.763 +			++consecutiveSuccesses;
   1.764 +		else
   1.765 +			consecutiveSuccesses = 0;
   1.766 +		}
   1.767 +	}
   1.768 +
   1.769 +
   1.770 +void CTextViewTest::TestSetViewL()
   1.771 +	{
   1.772 +	InitializeL();
   1.773 +	iView->SetViewL(1, testaYPos);
   1.774 +	Destroy();
   1.775 +	TInt consecutiveSuccesses = 0;
   1.776 +	for (TInt i = 1; consecutiveSuccesses != 100; ++i)
   1.777 +		{
   1.778 +		__UHEAP_MARK;
   1.779 +		InitializeL();
   1.780 +		__UHEAP_SETFAIL(RHeap::EDeterministic, i);
   1.781 +		TRAPD(err, iView->SetViewL(1, testaYPos));
   1.782 +		Destroy();
   1.783 +		__UHEAP_SETFAIL(RHeap::ENone, 0);
   1.784 +		__UHEAP_MARKENDC(0);
   1.785 +		if (err == KErrNone)
   1.786 +			++consecutiveSuccesses;
   1.787 +		else
   1.788 +			consecutiveSuccesses = 0;
   1.789 +		}
   1.790 +	}
   1.791 +
   1.792 +
   1.793 +void CTextViewTest::TestMoveCursorL()
   1.794 +	{
   1.795 +	InitializeL();
   1.796 +	AddTextL(KHello);
   1.797 +	iView->MoveCursorL(testaMovement, EFalse);
   1.798 +	Destroy();
   1.799 +	TInt consecutiveSuccesses = 0;
   1.800 +	for (TInt i = 1; consecutiveSuccesses != 100; ++i)
   1.801 +		{
   1.802 +		__UHEAP_MARK;
   1.803 +		InitializeL();
   1.804 +		AddTextL(KHello);
   1.805 +		__UHEAP_SETFAIL(RHeap::EDeterministic, i);
   1.806 +		TRAPD(err, iView->MoveCursorL(testaMovement, EFalse));
   1.807 +		Destroy();
   1.808 +		__UHEAP_SETFAIL(RHeap::ENone, 0);
   1.809 +		__UHEAP_MARKENDC(0);
   1.810 +		if (err == KErrNone)
   1.811 +			++consecutiveSuccesses;
   1.812 +		else
   1.813 +			consecutiveSuccesses = 0;
   1.814 +		}
   1.815 +	}
   1.816 +
   1.817 +
   1.818 +void CTextViewTest::TestSetSelectionL()
   1.819 +	{
   1.820 +	InitializeL();
   1.821 +	iView->SetSelectionL(select);
   1.822 +	Destroy();
   1.823 +	TInt consecutiveSuccesses = 0;
   1.824 +	for (TInt i = 1; consecutiveSuccesses != 100; ++i)
   1.825 +		{
   1.826 +		__UHEAP_MARK;
   1.827 +		InitializeL();
   1.828 +		__UHEAP_SETFAIL(RHeap::EDeterministic, i);
   1.829 +		TRAPD(err, iView->SetSelectionL(select));
   1.830 +		Destroy();
   1.831 +		__UHEAP_SETFAIL(RHeap::ENone, 0);
   1.832 +		__UHEAP_MARKENDC(0);
   1.833 +		if (err == KErrNone)
   1.834 +			++consecutiveSuccesses;
   1.835 +		else
   1.836 +			consecutiveSuccesses = 0;
   1.837 +		}
   1.838 +	}
   1.839 +
   1.840 +
   1.841 +void CTextViewTest::TestMatchCursorHeightL()
   1.842 +	{
   1.843 +	InitializeL();
   1.844 +	iView->MatchCursorHeightL(testaFontSpec);
   1.845 +	Destroy();
   1.846 +	TInt consecutiveSuccesses = 0;
   1.847 +	for (TInt i = 1; consecutiveSuccesses != 100; ++i)
   1.848 +		{
   1.849 +		__UHEAP_MARK;
   1.850 +		InitializeL();
   1.851 +		__UHEAP_SETFAIL(RHeap::EDeterministic, i);
   1.852 +		TRAPD(err, iView->MatchCursorHeightL(testaFontSpec));
   1.853 +		Destroy();
   1.854 +		__UHEAP_SETFAIL(RHeap::ENone, 0);
   1.855 +		__UHEAP_MARKENDC(0);
   1.856 +		if (err == KErrNone)
   1.857 +			++consecutiveSuccesses;
   1.858 +		else
   1.859 +			consecutiveSuccesses = 0;
   1.860 +		}
   1.861 +	}
   1.862 +
   1.863 +
   1.864 +void CTextViewTest::TestCalculateHorizontalExtremesL()
   1.865 +	{
   1.866 +	InitializeL();
   1.867 +	iView->CalculateHorizontalExtremesL(testaLeft, testaRight, EFalse);
   1.868 +	Destroy();
   1.869 +	TInt consecutiveSuccesses = 0;
   1.870 +	for (TInt i = 1; consecutiveSuccesses != 100; ++i)
   1.871 +		{
   1.872 +		__UHEAP_MARK;
   1.873 +		InitializeL();
   1.874 +		__UHEAP_SETFAIL(RHeap::EDeterministic, i);
   1.875 +		TRAPD(err, iView->CalculateHorizontalExtremesL(testaLeft, testaRight, EFalse));
   1.876 +		Destroy();
   1.877 +		__UHEAP_SETFAIL(RHeap::ENone, 0);
   1.878 +		__UHEAP_MARKENDC(0);
   1.879 +		if (err == KErrNone)
   1.880 +			++consecutiveSuccesses;
   1.881 +		else
   1.882 +			consecutiveSuccesses = 0;
   1.883 +		}
   1.884 +	}
   1.885 +
   1.886 +
   1.887 +void CTextViewTest::TestXyPosToDocPosL()
   1.888 +	{
   1.889 +	InitializeL();
   1.890 +	iView->XyPosToDocPosL(testaPoint);
   1.891 +	Destroy();
   1.892 +	TInt consecutiveSuccesses = 0;
   1.893 +	for (TInt i = 1; consecutiveSuccesses != 100; ++i)
   1.894 +		{
   1.895 +		__UHEAP_MARK;
   1.896 +		InitializeL();
   1.897 +		__UHEAP_SETFAIL(RHeap::EDeterministic, i);
   1.898 +		TRAPD(err, iView->XyPosToDocPosL(testaPoint));
   1.899 +		Destroy();
   1.900 +		__UHEAP_SETFAIL(RHeap::ENone, 0);
   1.901 +		__UHEAP_MARKENDC(0);
   1.902 +		if (err == KErrNone)
   1.903 +			++consecutiveSuccesses;
   1.904 +		else
   1.905 +			consecutiveSuccesses = 0;
   1.906 +		}
   1.907 +	}
   1.908 +
   1.909 +/*
   1.910 +void CTextViewTest::TestDrawL1()
   1.911 +	{
   1.912 +	InitializeL();
   1.913 +	iView->DrawL(iWindowRect, testaGc);
   1.914 +	Destroy();
   1.915 +	TInt consecutiveSuccesses = 0;
   1.916 +	for (TInt i = 1; consecutiveSuccesses != 100; ++i)
   1.917 +		{
   1.918 +		__UHEAP_MARK;
   1.919 +		InitializeL();
   1.920 +		__UHEAP_SETFAIL(RHeap::EDeterministic, i);
   1.921 +		TRAPD(err, iView->DrawL(iWindowRect, testaGc));
   1.922 +		Destroy();
   1.923 +		__UHEAP_SETFAIL(RHeap::ENone, 0);
   1.924 +		__UHEAP_MARKENDC(0);
   1.925 +		if (err == KErrNone)
   1.926 +			++consecutiveSuccesses;
   1.927 +		else
   1.928 +			consecutiveSuccesses = 0;
   1.929 +		}
   1.930 +	}
   1.931 +*/
   1.932 +
   1.933 +
   1.934 +void CTextViewTest::TestGetPictureRectangleL()
   1.935 +	{
   1.936 +	InitializeL();
   1.937 +	iView->GetPictureRectangleL(1, iWindowRect, &testaCanScaleOrCrop);
   1.938 +	Destroy();
   1.939 +	TInt consecutiveSuccesses = 0;
   1.940 +	for (TInt i = 1; consecutiveSuccesses != 100; ++i)
   1.941 +		{
   1.942 +		__UHEAP_MARK;
   1.943 +		InitializeL();
   1.944 +		__UHEAP_SETFAIL(RHeap::EDeterministic, i);
   1.945 +		TRAPD(err, iView->GetPictureRectangleL(1, iWindowRect, &testaCanScaleOrCrop));
   1.946 +		Destroy();
   1.947 +		__UHEAP_SETFAIL(RHeap::ENone, 0);
   1.948 +		__UHEAP_MARKENDC(0);
   1.949 +		if (err == KErrNone)
   1.950 +			++consecutiveSuccesses;
   1.951 +		else
   1.952 +			consecutiveSuccesses = 0;
   1.953 +		}
   1.954 +	}
   1.955 +
   1.956 +
   1.957 +void CTextViewTest::TestGetPictureRectangle1L()
   1.958 +	{
   1.959 +	InitializeL();
   1.960 +	iView->GetPictureRectangleL(testaXyPos, iWindowRect, &testaCanScaleOrCrop);
   1.961 +	Destroy();
   1.962 +	TInt consecutiveSuccesses = 0;
   1.963 +	for (TInt i = 1; consecutiveSuccesses != 100; ++i)
   1.964 +		{
   1.965 +		__UHEAP_MARK;
   1.966 +		InitializeL();
   1.967 +		__UHEAP_SETFAIL(RHeap::EDeterministic, i);
   1.968 +		TRAPD(err, iView->GetPictureRectangleL(testaXyPos, iWindowRect, &testaCanScaleOrCrop));
   1.969 +		Destroy();
   1.970 +		__UHEAP_SETFAIL(RHeap::ENone, 0);
   1.971 +		__UHEAP_MARKENDC(0);
   1.972 +		if (err == KErrNone)
   1.973 +			++consecutiveSuccesses;
   1.974 +		else
   1.975 +			consecutiveSuccesses = 0;
   1.976 +		}
   1.977 +	}
   1.978 +
   1.979 +
   1.980 +void CTextViewTest::TestSetDisplayContextL()
   1.981 +	{
   1.982 +	CBitmapContext* atestGc;
   1.983 +	CBitmapContext* anotherGc;
   1.984 +	InitializeL();
   1.985 +	iView->SetDisplayContextL(testaGd, &iWindow, &testaGroupWin, &testaSession);
   1.986 +	Destroy();
   1.987 +	TInt consecutiveSuccesses = 0;
   1.988 +	for (TInt i = 1; consecutiveSuccesses != 1; ++i)
   1.989 +		{
   1.990 +		__UHEAP_MARK;
   1.991 +		InitializeL();
   1.992 +		__UHEAP_SETFAIL(RHeap::EDeterministic, i);
   1.993 +		atestGc=iView->BitmapContext();
   1.994 +		TRAPD(err, iView->SetDisplayContextL(testaGd, &iWindow, &testaGroupWin, &testaSession));
   1.995 +		anotherGc=iView->BitmapContext();
   1.996 +		if (err)
   1.997 +			{
   1.998 +			test(atestGc==anotherGc);
   1.999 +			}
  1.1000 +		else
  1.1001 +			{
  1.1002 +			test(atestGc!=anotherGc);
  1.1003 +			}
  1.1004 +		Destroy();
  1.1005 +		__UHEAP_SETFAIL(RHeap::ENone, 0);
  1.1006 +		__UHEAP_MARKENDC(0);
  1.1007 +		if (err == KErrNone)
  1.1008 +			++consecutiveSuccesses;
  1.1009 +		else
  1.1010 +			consecutiveSuccesses = 0;
  1.1011 +		}
  1.1012 +	}
  1.1013 +
  1.1014 +
  1.1015 +void CTextViewTest::TestGetPictureRectangleDefectL()
  1.1016 +	{
  1.1017 +	/*
  1.1018 +	_LIT(KParagraphAverage,"Some text to test that the Picture returned is in the correct position. The size of this paragraph should be reasonable, not too long not too short.");
  1.1019 +	_LIT(KParagraphBigger,"Moulin Rouge: a film review. I don't know what I was expecting from Oulin Rouge, but what I got came as an even more of a surprise. The movie is a visual feast, a sing along extravaganza. The choices of songs is refreshing, with mix of Nirvan-Smells like teen spirit- to Madonna-Like a virgin-. Who knew that Ewan and Nicole could sing so well together.");
  1.1020 +	_LIT(KParagraphSmall,"CBusBase is an abstract base class for dynamic memory buffers. You can read or write bytes.");
  1.1021 +	InitializeL();
  1.1022 +	TInt length;
  1.1023 +	iEtext->InsertL(0,KParagraphAverage);
  1.1024 +	iView->HandleInsertDeleteL(TCursorSelection(0, KParagraphAverage().Length()), 0);
  1.1025 +	iEtext->InsertL(KParagraphAverage().Length(),TChar(CEditableText::EParagraphDelimiter));
  1.1026 +	iView->HandleCharEditL();
  1.1027 +
  1.1028 +	length=iEtext->LdDocumentLength();
  1.1029 +	iEtext->InsertL(iEtext->LdDocumentLength(),KParagraphBigger);
  1.1030 +	iView->HandleInsertDeleteL(TCursorSelection(length,KParagraphBigger().Length()), 0);
  1.1031 +
  1.1032 +	length=iEtext->LdDocumentLength();
  1.1033 +	iEtext->InsertL(iEtext->LdDocumentLength(),KParagraphSmall);
  1.1034 +	iView->HandleInsertDeleteL(TCursorSelection(length,KParagraphSmall().Length()), 0);
  1.1035 +
  1.1036 +	TSize size(100,100);
  1.1037 +	TPoint xypos;
  1.1038 +	CMyTestPicture* testpicture1 = CMyTestPicture::NewL(size);
  1.1039 +	CMyTestPicture* testpicture2 = CMyTestPicture::NewL(size);
  1.1040 +	CMyTestPicture* testpicture3 = CMyTestPicture::NewL(size);
  1.1041 +	size.SetSize(200,200);
  1.1042 +	CMyTestPicture* testpicture4 = CMyTestPicture::NewL(size);
  1.1043 +	CMyTestPicture* testpicture5 = CMyTestPicture::NewL(size);
  1.1044 +	CMyTestPicture* testpicture6 = CMyTestPicture::NewL(size);
  1.1045 +	TPictureHeader mypic;
  1.1046 +	TPictureHeader mypic2;
  1.1047 +	//mypic.iPictureType = KUidXzePictureType;
  1.1048 +	mypic.iPicture=testpicture1;
  1.1049 +	mypic2.iPicture=testpicture2;
  1.1050 +	// Testing the picture
  1.1051 +
  1.1052 +	iEtext->InsertL(10,mypic2);
  1.1053 +	mypic2.iPicture=testpicture1;
  1.1054 +	iEtext->InsertL(40,mypic2);
  1.1055 +	iView->DocPosToXyPosL(200,xypos);
  1.1056 +	test.Printf(_L("The xy coords are %d & %d\n"),xypos.iX,xypos.iY);
  1.1057 +	xypos.SetXY(78,55);
  1.1058 +	TInt docpos;
  1.1059 +	docpos=iView->XyPosToDocPosL(xypos);
  1.1060 +	test.Printf(_L("The new docpos is %d\n"),docpos);
  1.1061 +	TRect rect;
  1.1062 +	TBool boo;
  1.1063 +	boo=iView->GetPictureRectangleL(40,rect);
  1.1064 +	test.Printf(_L("%d & %d \n"),rect.Size().iHeight,rect.Size().iWidth);
  1.1065 +	if (boo)
  1.1066 +		test.Printf(_L("Yes!"));
  1.1067 +	else
  1.1068 +		test.Printf(_L("Noo!"));
  1.1069 +	*/
  1.1070 +	}
  1.1071 +
  1.1072 +void CTextViewTest::TestGetLineRectL()
  1.1073 +	{
  1.1074 +
  1.1075 +	_LIT(KSomeText,"Empty. Well this text has to now be something else. Maybe this will increase the height of the CTextLayout and if it does then");
  1.1076 +	// calls the initializeDiffCharFormatL to set the new CharFormatLayer
  1.1077 +	// which sets the picture alignment to be Bottom.
  1.1078 +	InitializeDiffCharFormatL();
  1.1079 +	// create test pictures to be inserted into the richtext object
  1.1080 +	TSize size(100,100);
  1.1081 +	CMyTestPicture* testpicture1 = CMyTestPicture::NewL(size);
  1.1082 +	TPictureHeader tPicHeader;
  1.1083 +	tPicHeader.iPictureType = KUidXzePictureType;
  1.1084 +	tPicHeader.iPicture = testpicture1;
  1.1085 +	test.Printf(_L("Created a picture\n"));
  1.1086 +
  1.1087 +	// inserting some text & picture into the richtext object
  1.1088 +	iEtext->InsertL(0,KSomeText);
  1.1089 +	TInt startOfPicture;
  1.1090 +	startOfPicture=iEtext->DocumentLength();
  1.1091 +	iEtext->InsertL(startOfPicture,tPicHeader);
  1.1092 +	test.Printf(_L("Inserted the picture in CRichText object \n"));
  1.1093 +
  1.1094 +	//Call the guilty function
  1.1095 +	TRect resultingRect;
  1.1096 +	TInt endOfDocument = iEtext->DocumentLength();
  1.1097 +	iView->FormatTextL();
  1.1098 +	resultingRect=iLayout->GetLineRectL(startOfPicture,endOfDocument);
  1.1099 +	}
  1.1100 +
  1.1101 +void CTextViewTest::TestGetParaFormatL()
  1.1102 +	{
  1.1103 +	test.Next(_L("Starting GetParaFormatL test"));
  1.1104 +	_LIT(KSomeText,"Empty. Well this text has to now be something else. Maybe this will increase the height of the CTextLayout and if it does then");
  1.1105 +	InitializeL();
  1.1106 +	// create the CParaFormat & TparaFormatMask
  1.1107 +	// and set that in the iParaFormatLayer
  1.1108 +	CParaFormat* paraFormat = CParaFormat::NewL();
  1.1109 +	TParaFormatMask paraFormatMask;
  1.1110 +	iParaLayer->SetL(paraFormat,paraFormatMask);
  1.1111 +	iEtext->SetGlobalParaFormat(iParaLayer);
  1.1112 +	iEtext->InsertL(0,KSomeText);
  1.1113 +	iView->FormatTextL();
  1.1114 +	// Create another CParaFormat & TParaFormatMask and set
  1.1115 +	// some attributes to be different from the default.
  1.1116 +	CParaFormat* anotherParaFormat = CParaFormat::NewL();
  1.1117 +	TParaFormatMask anotherParaFormatMask;
  1.1118 +	anotherParaFormat->iRightMarginInTwips=200;
  1.1119 +	anotherParaFormatMask.SetAttrib(EAttRightMargin);
  1.1120 +	anotherParaFormat->iLeftMarginInTwips=400;
  1.1121 +	anotherParaFormatMask.SetAttrib(EAttLeftMargin);
  1.1122 +	anotherParaFormat->iLineSpacingInTwips=300;
  1.1123 +	anotherParaFormatMask.SetAttrib(EAttLineSpacing);
  1.1124 +	anotherParaFormat->iHorizontalAlignment=CParaFormat::ERightAlign;
  1.1125 +	anotherParaFormatMask.SetAttrib(EAttAlignment);
  1.1126 +
  1.1127 +	//Now call CRichText::GetParaFormat using anotherParaFormat * Mask
  1.1128 +	// and test that it is the same as paraFormat.
  1.1129 + 	iEtext->GetParaFormatL(anotherParaFormat,anotherParaFormatMask,0,10);
  1.1130 +
  1.1131 +	TInt result = anotherParaFormat->iRightMarginInTwips;
  1.1132 +	test (result==0);
  1.1133 +
  1.1134 +	result = anotherParaFormat->iLeftMarginInTwips;
  1.1135 +	test (result==0);
  1.1136 +	result = anotherParaFormat->iLineSpacingInTwips;
  1.1137 +	test (result==200); // default value for iLineSpacingInTwips set in paraFormat is 200
  1.1138 +	test (anotherParaFormat->iHorizontalAlignment == CParaFormat::ELeftAlign);
  1.1139 +
  1.1140 +	TBool testresult;
  1.1141 +	testresult=anotherParaFormat->IsEqual(*paraFormat);
  1.1142 +	test(testresult);
  1.1143 +
  1.1144 +	}
  1.1145 +
  1.1146 +
  1.1147 +void CTextViewTest::TestForDEF003426L()
  1.1148 +	{
  1.1149 +	// Initialise CTextViewTest object for next test.
  1.1150 +	InitializeL();
  1.1151 +	test.Next(_L("Verifying CTextView::XyPosToDosPosL() WRT DEF003426"));
  1.1152 +
  1.1153 +	// Insert a one line paragraph into EText object and reformat view.
  1.1154 +	_LIT(KTestParagraph, "This is a piece of text to test the character positioning API based in X,Y cocordinates.");
  1.1155 +	iEtext->InsertL(0, KTestParagraph);
  1.1156 +	TCursorSelection sel(0, KTestParagraph().Length());
  1.1157 +	(void) iView->HandleInsertDeleteL(sel, 0, EFalse);
  1.1158 +
  1.1159 +	// Test XyPosToDocPosL() with coordinates beyond top left corner
  1.1160 +	TInt docPos = -1;
  1.1161 +	docPos = iView->XyPosToDocPosL(testaPoint);
  1.1162 +	test(docPos == 0); // Should give char position of 0
  1.1163 +
  1.1164 +	// Test XyPosToDocPosL() with coordinates beyond bottom right corner
  1.1165 +	TRect viewRect = iView->ViewRect();
  1.1166 +	viewRect.iBr.iX += 300;
  1.1167 +	viewRect.iBr.iY += 111;
  1.1168 +    docPos = iView->XyPosToDocPosL(viewRect.iBr);
  1.1169 +	test(docPos != 0); // Should give char position of 88
  1.1170 +
  1.1171 +	// Clean up test object
  1.1172 +	Destroy();
  1.1173 +	}
  1.1174 +
  1.1175 +/*** Test code for DEF038858
  1.1176 +	 " It isn't poss. to set via CTextView a TTmDocPos of iPos = 0; iLeadingEdge=false"
  1.1177 + */
  1.1178 +void CTextViewTest::TestForDEF038488L()
  1.1179 +	{
  1.1180 +	// Initialise CTextViewTest object for next test.
  1.1181 +	InitializeL();
  1.1182 +	test.Next(_L("Verifying CTextView::SetDocPosL() DEF038858"));
  1.1183 +
  1.1184 +	_LIT(KText, "This is the test for DEF038488");
  1.1185 +	iEtext->InsertL(0, KText);
  1.1186 +	iView->HandleInsertDeleteL(TCursorSelection(0, KText().Length()), 0);
  1.1187 +
  1.1188 +	// Test SetDocPosL() with coordinates -1
  1.1189 +	iView->SetDocPosL(-1);
  1.1190 +
  1.1191 +	// check the value of iLeadingEdge
  1.1192 +	TTmDocPos RawDocPos;
  1.1193 +	iView->GetCursorPos(RawDocPos);
  1.1194 +	test(RawDocPos.iLeadingEdge == EFalse);
  1.1195 +
  1.1196 +	}
  1.1197 +
  1.1198 +CTextViewTest::~CTextViewTest()
  1.1199 +	{
  1.1200 +	test.End();
  1.1201 +	test.Close();
  1.1202 +	delete iView;
  1.1203 +	iWindow.Close();
  1.1204 +	delete iLayout;
  1.1205 +	delete iEtext;
  1.1206 +	delete iCharLayer;
  1.1207 +	delete iParaLayer;
  1.1208 +	}
  1.1209 +
  1.1210 +/**
  1.1211 +@SYMTestCaseID          SYSLIB-FORM-UT-1888
  1.1212 +@SYMTestCaseDesc        Testing the Class TFormAndEtextEditor
  1.1213 +@SYMTestPriority        Low
  1.1214 +@SYMTestActions         Tests the API's of TFormAndEtextEditor by inserting the text, applying specific format and style to the text, getting the text,format and style and also deleting the same(text,format and style)
  1.1215 +@SYMTestExpectedResults Tests must not fail
  1.1216 +@SYMREQ                 REQ0000
  1.1217 +*/
  1.1218 +void CTextViewTest::FormAndEtextTestL()
  1.1219 +	{
  1.1220 +	InitializeL();
  1.1221 +	test.Next(_L(" @SYMTestCaseID:SYSLIB-FORM-UT-1888 Testing TFormAndEtextEditor "));
  1.1222 +	TCharFormatMask charMask;
  1.1223 +    TCharFormat charFormat;
  1.1224 +	charFormat.iFontSpec.iTypeface.iName = _S("Arial");
  1.1225 +    charFormat.iFontSpec.iHeight = 240;
  1.1226 +    charMask.SetAttrib(EAttFontTypeface);
  1.1227 +    charMask.SetAttrib(EAttFontHeight);
  1.1228 +    CCharFormatLayer* charFormatLayer = CCharFormatLayer::NewL();
  1.1229 +    charFormatLayer->SetL(charFormat,charMask);
  1.1230 +	TParaFormatMask paraFormatMask;
  1.1231 +    CParaFormatLayer* paraFormatLayer=CParaFormatLayer::NewL((CParaFormat*)NULL,paraFormatMask);
  1.1232 +    CParagraphStyle* paraStyle = CParagraphStyle::NewL(*paraFormatLayer,*charFormatLayer);
  1.1233 +    CStyleList* styleList = CStyleList::NewL();
  1.1234 +    RParagraphStyleInfo paraStyleInfo(paraStyle,paraStyle);
  1.1235 +    paraStyleInfo.iStyle->iName=_L("Arial");
  1.1236 +    paraStyleInfo.iStyleForNextPara->iName=_L("Arial");
  1.1237 +    // Appending the new style to stylelist
  1.1238 +    styleList->AppendL(&paraStyleInfo);
  1.1239 +
  1.1240 +	iEtext->SetStyleListExternallyOwned(*styleList);
  1.1241 +	iEtext->Reset();
  1.1242 +	TFormAndEtextEditor newEditor(*iView,*iEtext);
  1.1243 +
  1.1244 +	TTmCharFormatLayer charLayer;
  1.1245 +	TTmCharFormatLayer charLayer1;
  1.1246 +	TTmCharFormatMask charIMask;
  1.1247 +	TTmCharFormat charI;
  1.1248 +	RTmParFormatLayer parLayer;
  1.1249 +	RTmParFormatLayer parLayer1;
  1.1250 +	TTmParFormatMask parNMask;
  1.1251 +	charIMask.iFlags = TTmCharFormatMask::EItalic;
  1.1252 +	TOpenFontFaceAttribBase attrib;
  1.1253 +	attrib.SetBold(EFalse);
  1.1254 +	charI.iFontSpec.SetAttrib(attrib);
  1.1255 +	parNMask.iFlags = TTmParFormatMask::EKeepWithNext;
  1.1256 +	RTmParFormat parN;
  1.1257 +	parN.iFlags = RTmParFormat::EKeepWithNext;
  1.1258 +	charLayer.iMask = charIMask;
  1.1259 +	charLayer.iFormat = charI;
  1.1260 +	charLayer1=charLayer;
  1.1261 +	parLayer.iMask = parNMask;
  1.1262 +
  1.1263 +	parLayer.iFormat.CopyL(parN);
  1.1264 +	TPtrC ptr1(_L("Arial"));
  1.1265 +	// Inserting the text and applying the style specified(Arial)
  1.1266 +	newEditor.InsertTextL(0, _L("Hello World"),&ptr1);
  1.1267 +
  1.1268 +	// Setting the paragraph and character format explicitly
  1.1269 +	newEditor.SetParFormatL(0,11,parLayer);
  1.1270 +	newEditor.SetCharFormatL(0,11,charLayer);
  1.1271 +
  1.1272 +	MUnifiedEditor::TFormatLevel level = MUnifiedEditor::EEffective;
  1.1273 +	TInt runLen=11;
  1.1274 +	// Getting the paragraph and character format
  1.1275 +	newEditor.GetParFormatL(0,level,parLayer1,runLen);
  1.1276 +	newEditor.GetCharFormat(0,level,charLayer1,runLen);
  1.1277 +
  1.1278 +	// Deleting first 6 characters
  1.1279 +	newEditor.DeleteTextL(0,6);
  1.1280 +	// Deleting the paragraph and character format for the remaining text
  1.1281 +	newEditor.DeleteParFormatL(0,5);
  1.1282 +	newEditor.DeleteCharFormatL(0,5);
  1.1283 +
  1.1284 +	TPtrC ptr;
  1.1285 +	// Get the text into ptr. A paragraph seperator(\x2029) gets appended at the end of text.
  1.1286 +	newEditor.GetText(0,ptr);
  1.1287 +	test(ptr==_L("World\x2029"));
  1.1288 +
  1.1289 +	RTmStyle style1;
  1.1290 +	RParagraphStyleInfo paraStyleInfo1(paraStyle,paraStyle);
  1.1291 +	paraStyleInfo1.iStyle->iName=_L("NewStyle");
  1.1292 +	paraStyleInfo1.iStyleForNextPara->iName=_L("NewStyle");
  1.1293 +	style1.CopyL(paraStyleInfo1);
  1.1294 +	// Creating a new style and changing the current style to the new one.
  1.1295 +	newEditor.StyleSupport()->CreateStyleL(style1);
  1.1296 +	newEditor.StyleSupport()->ChangeStyleL(style1);
  1.1297 +
  1.1298 +	RTmStyle style2;
  1.1299 +	// Get the style by Name
  1.1300 +	TInt retVal = newEditor.StyleSupport()->GetStyleByNameL(_L("Arial"),style2);
  1.1301 +	retVal = newEditor.StyleSupport()->GetStyleByNameL(_L("NewStyle"),style2);
  1.1302 +	// Get the style for a particular length of text
  1.1303 +	newEditor.StyleSupport()->GetStyle(0,ptr,runLen);
  1.1304 +	// Get the style by index
  1.1305 +	retVal = newEditor.StyleSupport()->GetStyleByIndexL(1,style1);
  1.1306 +	// Deleting the style
  1.1307 +	newEditor.StyleSupport()->DeleteStyleL(_L("NewStyle"));
  1.1308 +	retVal = newEditor.StyleCount();
  1.1309 +	test(retVal==1);
  1.1310 +	style1.Close();
  1.1311 +	style2.Close();
  1.1312 +	delete charFormatLayer;
  1.1313 +    delete paraFormatLayer;
  1.1314 +    delete styleList;
  1.1315 +	}
  1.1316 +
  1.1317 +/**
  1.1318 +@SYMTestCaseID          SYSLIB-FORM-UT-3347
  1.1319 +@SYMTestCaseDesc        Testing the fix for INC092725: RF S60 3.2 Help: Touch and
  1.1320 +						scrolling a topic down closing the program
  1.1321 +@SYMTestPriority        High
  1.1322 +@SYMTestActions         Run affected APIs passing scroll values that would put the display
  1.1323 +						outside the formatted range.
  1.1324 +@SYMTestExpectedResults First of all, the calls should not panic the process.
  1.1325 +						Secondly, that the calls leave with the correct error code.
  1.1326 +@SYMDEF                 INC092725
  1.1327 +*/
  1.1328 +void CTextViewTest::TestForINC092725L()
  1.1329 +	{
  1.1330 +	test.Next(_L(" @SYMTestCaseID:SYSLIB-FORM-UT-3347 Testing fix for INC092725 "));
  1.1331 +	TInt err = KErrNone;
  1.1332 +	InitializeL();
  1.1333 +	AddTextL(KHello);
  1.1334 +
  1.1335 +	//Scroll up
  1.1336 +	iLayout->AdjustVerticalAlignment(CParaFormat::EAbsoluteRightAlign);
  1.1337 +	TRAP(err, iView->ScrollDisplayL(TCursorPosition::EFLineUp, CTextLayout::EFAllowScrollingBlankSpace));
  1.1338 +	test(err==CTextLayout::EPosNotFormatted);
  1.1339 +	err=KErrNone;
  1.1340 +
  1.1341 +	//Scroll down
  1.1342 +	iLayout->AdjustVerticalAlignment(CParaFormat::EAbsoluteLeftAlign);
  1.1343 +	TRAP(err, iView->ScrollDisplayL(TCursorPosition::EFLineDown, CTextLayout::EFAllowScrollingBlankSpace));
  1.1344 +	test(err==CTextLayout::EPosNotFormatted);
  1.1345 +	err=KErrNone;
  1.1346 +
  1.1347 +	//Line scroll up
  1.1348 +	TInt i = 105;
  1.1349 +	iLayout->AdjustVerticalAlignment(CParaFormat::EAbsoluteRightAlign);
  1.1350 +	TRAP(err, iView->ScrollDisplayLinesL(i, CTextLayout::EFAllowScrollingBlankSpace));
  1.1351 +	test(err==CTextLayout::EPosNotFormatted);
  1.1352 +	err=KErrNone;
  1.1353 +
  1.1354 +	//Line scroll down
  1.1355 +	i = -105;
  1.1356 +	iLayout->AdjustVerticalAlignment(CParaFormat::EAbsoluteLeftAlign);
  1.1357 +	TRAP(err, iView->ScrollDisplayLinesL(i, CTextLayout::EFAllowScrollingBlankSpace));
  1.1358 +	test(err==CTextLayout::EPosNotFormatted);
  1.1359 +	err=KErrNone;
  1.1360 +
  1.1361 +	//Paragraph scroll up
  1.1362 +	i = 105;
  1.1363 +	iLayout->AdjustVerticalAlignment(CParaFormat::EAbsoluteRightAlign);
  1.1364 +	TRAP(err, iView->ScrollDisplayParagraphsL(i, CTextLayout::EFAllowScrollingBlankSpace));
  1.1365 +	test(err==CTextLayout::EPosNotFormatted);
  1.1366 +	err=KErrNone;
  1.1367 +
  1.1368 +	//Paragraph scroll down
  1.1369 +	i = -105;
  1.1370 +	iLayout->AdjustVerticalAlignment(CParaFormat::EAbsoluteLeftAlign);
  1.1371 +	TRAP(err, iView->ScrollDisplayParagraphsL(i, CTextLayout::EFAllowScrollingBlankSpace));
  1.1372 +	test(err==CTextLayout::EPosNotFormatted);
  1.1373 +	Destroy();
  1.1374 +	}
  1.1375 +
  1.1376 +
  1.1377 +class CTestScreenDevice : public CPrinterDevice
  1.1378 +	{
  1.1379 +public:
  1.1380 +    CTestScreenDevice(CWsScreenDevice* aDevice,RDrawableWindow& aWin);
  1.1381 +	TDisplayMode DisplayMode() const {return iDevice->DisplayMode();}
  1.1382 +	TSize SizeInPixels() const {return iDevice->SizeInPixels();}
  1.1383 +	TSize SizeInTwips() const {return iDevice->SizeInTwips();}
  1.1384 +    TInt NumTypefaces() const {return iDevice->NumTypefaces();}
  1.1385 +    void TypefaceSupport(TTypefaceSupport& aTypefaceSupport,TInt aTypefaceIndex) const
  1.1386 +										{iDevice->TypefaceSupport(aTypefaceSupport,aTypefaceIndex);}
  1.1387 +	TInt FontHeightInTwips(TInt aTypefaceIndex,TInt aHeightIndex) const
  1.1388 +									{return iDevice->FontHeightInTwips(aTypefaceIndex,aHeightIndex);}
  1.1389 +	void PaletteAttributes(TBool& aModifiable,TInt& aNumEntries) const
  1.1390 +												{iDevice->PaletteAttributes(aModifiable,aNumEntries);}
  1.1391 +	void SetPalette(CPalette* aPalette) {iDevice->SetPalette(aPalette);}
  1.1392 +	TInt GetPalette(CPalette*& aPalette) const {return iDevice->GetPalette(aPalette);}
  1.1393 + 	TInt CreateContext(CGraphicsContext *&aGc);
  1.1394 +	TInt HorizontalTwipsToPixels(TInt aTwips) const {return iDevice->HorizontalTwipsToPixels(aTwips);};
  1.1395 +	TInt VerticalTwipsToPixels(TInt aTwips) const {return iDevice->VerticalTwipsToPixels(aTwips);};
  1.1396 +	TInt HorizontalPixelsToTwips(TInt aPixels) const {return iDevice->HorizontalPixelsToTwips(aPixels);};
  1.1397 +	TInt VerticalPixelsToTwips(TInt aPixels) const {return iDevice->VerticalPixelsToTwips(aPixels);};
  1.1398 +	TInt GetNearestFontInTwips(CFont*& aFont,const TFontSpec& aFontSpec) {return iDevice->GetNearestFontInTwips(aFont,aFontSpec);};
  1.1399 +	void ReleaseFont(CFont* aFont) {iDevice->ReleaseFont(aFont);};
  1.1400 +	TPrinterModelName ModelName() const {return _L("");}
  1.1401 +	TUid ModelUid() const {TUid dummy; return dummy;}
  1.1402 +	void CreateControlL(CPrinterPort* /*aPrinterPort*/) {}
  1.1403 +	TPrinterModelEntry Model() const {return iModel;}
  1.1404 +	TInt SetModel(const TPrinterModelHeader& /*aModel*/,CStreamStore& /*aStore*/) {return KErrNone;}
  1.1405 +	TBool RequiresPrinterPort() {return EFalse;}
  1.1406 +private:
  1.1407 +	RDrawableWindow& iWin;
  1.1408 +	CWsScreenDevice* iDevice;
  1.1409 +	TPrinterModelEntry iModel;
  1.1410 +	};
  1.1411 +
  1.1412 +CTestScreenDevice::CTestScreenDevice(CWsScreenDevice* aDevice,RDrawableWindow& aWin):
  1.1413 +	iWin(aWin)
  1.1414 +	{
  1.1415 +	iDevice=aDevice;
  1.1416 +	iModel.iUid=TUid::Null();
  1.1417 +	}
  1.1418 +
  1.1419 +TInt CTestScreenDevice::CreateContext(CGraphicsContext*& aGc)
  1.1420 +	{
  1.1421 +
  1.1422 +	TInt ret=iDevice->CreateContext(aGc);
  1.1423 +	((CWindowGc *) aGc)->Activate(iWin);
  1.1424 +	return ret;
  1.1425 +	}
  1.1426 +
  1.1427 +/**
  1.1428 +@SYMTestCaseID          SYSLIB-FORM-UT-3496
  1.1429 +@SYMTestCaseDesc        Testing the fix for PDEF108443: Two same content pages are printed when contact fields are exactly one page long
  1.1430 +@SYMTestPriority        Medium
  1.1431 +@SYMTestActions         Creates text paginators and tests resulting number of pages when there is text to 'full page - 1 line', full page and full page + 1 line of text.
  1.1432 +@SYMTestExpectedResults Results should be 1 page, 1 page and 2 pages respectively.
  1.1433 +@SYMDEF                 PDEF108443
  1.1434 +*/
  1.1435 +void CTextViewTest::TestForPDEF108443L()
  1.1436 +	{
  1.1437 +	test.Next(_L(" @SYMTestCaseID:SYSLIB-FORM-UT-3496 Testing fix for PDEF108443 "));
  1.1438 +	CTestScreenDevice* screenDevice = new(ELeave) CTestScreenDevice(iEnv.ScreenDevice(),iWindow);
  1.1439 +
  1.1440 +	TMargins margins;
  1.1441 +	margins.iTop = 1440;
  1.1442 +	margins.iBottom = 1440;
  1.1443 +	margins.iLeft = 1440;
  1.1444 +	margins.iRight = 1440;
  1.1445 +	TSize s(11906,16838);
  1.1446 +	TPageSpec p(TPageSpec::EPortrait, s);
  1.1447 +
  1.1448 +	CArrayFixFlat<TInt>* charsPerPage1 = new(ELeave) CArrayFixFlat<TInt>(KGranularity);
  1.1449 +	CTextPaginator* paginator1 = CTextPaginator::NewL(screenDevice, charsPerPage1, KPaginatePriority);
  1.1450 +	paginator1->SetPageMarginsInTwips(margins);
  1.1451 +	paginator1->SetPageSpecInTwips(p);
  1.1452 +
  1.1453 +	CArrayFixFlat<TInt>* charsPerPage2 = new(ELeave) CArrayFixFlat<TInt>(KGranularity);
  1.1454 +	CTextPaginator* paginator2 = CTextPaginator::NewL(screenDevice, charsPerPage2, KPaginatePriority);
  1.1455 +	paginator2->SetPageMarginsInTwips(margins);
  1.1456 +	paginator2->SetPageSpecInTwips(p);
  1.1457 +
  1.1458 +	CArrayFixFlat<TInt>* charsPerPage3 = new(ELeave) CArrayFixFlat<TInt>(KGranularity);
  1.1459 +	CTextPaginator* paginator3 = CTextPaginator::NewL(screenDevice, charsPerPage3, KPaginatePriority);
  1.1460 +	paginator3->SetPageMarginsInTwips(margins);
  1.1461 +	paginator3->SetPageSpecInTwips(p);
  1.1462 +
  1.1463 +
  1.1464 +	// We need to find out the height of lines and print area of the page.
  1.1465 +	// From this we determine how many lines *should* appear on the page.
  1.1466 +	// This differs between devices(ie. hw and winscw).
  1.1467 +	TRect textRect;
  1.1468 +	textRect.iTl.iX=margins.iLeft;
  1.1469 +	textRect.iTl.iY=margins.iTop;
  1.1470 +	textRect.iBr.iX=s.iWidth-margins.iRight;
  1.1471 +	textRect.iBr.iY=s.iHeight-margins.iBottom;
  1.1472 +	
  1.1473 +	textRect = screenDevice->TwipsToPixels(textRect);  //defect 131765, call the same func as paginator
  1.1474 +	TInt pageHeight =  textRect.Height();
  1.1475 +	_LIT(KDummyString,"AAAAAA");
  1.1476 +	InitializeL();
  1.1477 +	AddTextL(KDummyString);
  1.1478 +	TInt lineHeight = 0;
  1.1479 +	CParaFormat* paraFormat = CParaFormat::NewL();
  1.1480 +	iEtext->GetParagraphFormatL(paraFormat,0);
  1.1481 +	TBool pageBreakChar = EFalse;
  1.1482 +	TInt docPos = 0;
  1.1483 +	iLayout->FormatLineL(paraFormat,docPos,lineHeight,pageBreakChar);
  1.1484 +
  1.1485 +
  1.1486 +	TInt numLines = pageHeight/lineHeight; // Number of lines expected on a page with paginator settings defined above and line height = 21
  1.1487 +	TChar simpleChar('A');
  1.1488 +	TBuf<200> string1;
  1.1489 +	for (TInt i = 0; i < numLines-2; i++) // ...numlines - 1
  1.1490 +		{
  1.1491 +		string1.Append(simpleChar);
  1.1492 +		string1.Append(CEditableText::EParagraphDelimiter);
  1.1493 +		}
  1.1494 +		string1.Append(simpleChar); // final line
  1.1495 +	TBuf<200> string2;
  1.1496 +	for (TInt i = 0; i < numLines-1; i++) // ...numlines
  1.1497 +		{
  1.1498 +		string2.Append(simpleChar);
  1.1499 +		string2.Append(CEditableText::EParagraphDelimiter);
  1.1500 +		}
  1.1501 +		string2.Append(simpleChar); // final line
  1.1502 +	TBuf<200> string3;
  1.1503 +	for (TInt i = 0; i < numLines; i++) // ...numlines + 1
  1.1504 +		{
  1.1505 +		string3.Append(simpleChar);
  1.1506 +		string3.Append(CEditableText::EParagraphDelimiter);
  1.1507 +		}
  1.1508 +		string3.Append(simpleChar); // final line
  1.1509 +
  1.1510 +	InitializeL();
  1.1511 +	AddTextL(string1);
  1.1512 +	paginator1->SetDocumentL(iEtext);
  1.1513 +	docPos=0;
  1.1514 +	paginator1->AppendTextL(docPos);
  1.1515 +	TInt numPages=paginator1->PaginationCompletedL();
  1.1516 +	test(numPages==1);
  1.1517 +	InitializeL();
  1.1518 +	AddTextL(string2);
  1.1519 +	paginator2->SetDocumentL(iEtext);
  1.1520 +	docPos=0;
  1.1521 +	paginator2->AppendTextL(docPos);
  1.1522 +	numPages=paginator2->PaginationCompletedL();
  1.1523 +	test(numPages==1);
  1.1524 +	InitializeL();
  1.1525 +	AddTextL(string3);
  1.1526 +	paginator3->SetDocumentL(iEtext);
  1.1527 +	docPos=0;
  1.1528 +	paginator3->AppendTextL(docPos);
  1.1529 +	numPages=paginator3->PaginationCompletedL();
  1.1530 +	test(numPages==2);
  1.1531 +
  1.1532 +	delete charsPerPage1;
  1.1533 +	delete charsPerPage2;
  1.1534 +	delete charsPerPage3;
  1.1535 +	delete screenDevice;
  1.1536 +	delete paraFormat;
  1.1537 +	Destroy();
  1.1538 +	}
  1.1539 +
  1.1540 +/**
  1.1541 +@SYMTestCaseID          SYSLIB-FORM-UT-4002
  1.1542 +@SYMTestCaseDesc	    Test to ensure the CTextView::SetSelectionVisibilityL will not panic when EFTextVisible
  1.1543 +						is set off.
  1.1544 +@SYMTestPriority 	    Normal
  1.1545 +@SYMTestActions  	    Create a CTextView instance with EFTextVisible set off. Call SetSelectionVisibilityL(ETrue)
  1.1546 +						and SetSelectionVisibilityL(EFalse).
  1.1547 +@SYMTestExpectedResults	Given conditions in test actions, calling SetSelectionVisibilityL should not panic.
  1.1548 +@SYMDEF                 PDEF113755
  1.1549 +*/
  1.1550 +void CTextViewTest::TestForPDEF113755L()
  1.1551 +	{
  1.1552 +	test.Next(_L(" @SYMTestCaseID:SYSLIB-FORM-UT-4002 Testing fix for PDEF113755 "));
  1.1553 +	InitializeL();
  1.1554 +
  1.1555 +	TCursorSelection selection(0,8); // length of selection must be >0
  1.1556 +	iView->SetSelectionL(selection);
  1.1557 +
  1.1558 +	iView->MakeVisible(ETrue);	//Test if the EFSelectionVisible flag is set correctly
  1.1559 +	iView->SetSelectionVisibilityL(ETrue);
  1.1560 +	test(iView->SelectionVisible());
  1.1561 +	iView->SetSelectionVisibilityL(EFalse);
  1.1562 +	test(!iView->SelectionVisible());
  1.1563 +
  1.1564 +	iView->MakeVisible(EFalse);
  1.1565 +	iView->SetSelectionVisibilityL(ETrue); //Should never panic form::1200 here
  1.1566 +	iView->SetSelectionVisibilityL(EFalse);
  1.1567 +
  1.1568 +	Destroy();
  1.1569 +	}
  1.1570 +
  1.1571 +/**
  1.1572 +@SYMTestCaseID          SYSLIB-FORM-UT-4004
  1.1573 +@SYMTestCaseDesc	    Test for INC113143, to ensure CTextLayout::GetLineRectL returns the correct rectangle
  1.1574 +						regarding the writting direction of text. Depend on Platform: WINSCW/H4/H6(DEF131765).
  1.1575 +@SYMTestPriority 	    Normal
  1.1576 +@SYMTestActions  	    Tested 16 scenarios that the CTextLayout::GetLineRectL could be call, also tested for
  1.1577 +						edge cases such as 1 char, whole line, DocPos2 < DocPos1, etc..
  1.1578 +@SYMTestExpectedResults CTextLayout::GetLineRectL should return expected rectangles.
  1.1579 +@SYMDEF                 PDEF115165
  1.1580 +*/
  1.1581 +void CTextViewTest::TestForPDEF115165L()
  1.1582 +	{
  1.1583 +	test.Next(_L(" @SYMTestCaseID:SYSLIB-FORM-UT-4004 Testing fix for PDEF115165 "));
  1.1584 +	InitializeL();
  1.1585 +
  1.1586 +	TCharFormat charFormat = TCharFormat(_L("Arial"),100);
  1.1587 +	TCharFormatMask charFormatMask;
  1.1588 +	charFormatMask.SetAll();
  1.1589 +	iCharLayer->SetL(charFormat, charFormatMask);
  1.1590 +	iEtext->SetGlobalCharFormat(iCharLayer);
  1.1591 +	_LIT(KLtoRChar,"a");
  1.1592 +	_LIT(KRtoLChar,"\x6B2");
  1.1593 +	_LIT(KLtoRText,"aaa");
  1.1594 +	_LIT(KRtoLText,"\x6B2\x6B2\x6B2");
  1.1595 +	_LIT(KParaSep, "\x2029");
  1.1596 +
  1.1597 +	TRect rect;
  1.1598 +
  1.1599 +//  Test for 16 scenarios of Bidi texts..
  1.1600 +//	Sample text for test
  1.1601 +//	Doc_Pos:    | 0| 1| 2| 5| 4| 3| 6| 7| 8|11|10| 9|
  1.1602 +//	X-Coords:  |0| 5|10|15|20|25|30|35|40|45|50|55|60|  in case w=5
  1.1603 +
  1.1604 +	iEtext->Reset();
  1.1605 +	iEtext->InsertL(0,KLtoRText);
  1.1606 +	iEtext->InsertL(iEtext->DocumentLength(),KRtoLText);
  1.1607 +	iEtext->InsertL(iEtext->DocumentLength(),KLtoRText);
  1.1608 +	iEtext->InsertL(iEtext->DocumentLength(),KRtoLText);
  1.1609 +	iEtext->InsertL(iEtext->DocumentLength(),KParaSep);
  1.1610 +	iView->FormatTextL();
  1.1611 +
  1.1612 +	TPoint point1,point2;
  1.1613 +	iLayout->DocPosToXyPosL(0,point1);
  1.1614 +	iLayout->DocPosToXyPosL(1,point2);
  1.1615 +
  1.1616 +	TInt wLTR = point2.iX - point1.iX;		//It depends on platform. WINSCW/H4 w=5; H6 w=4
  1.1617 +	
  1.1618 +	iLayout->DocPosToXyPosL(5,point1);
  1.1619 +	iLayout->DocPosToXyPosL(4,point2);
  1.1620 +	TInt wRTL = point2.iX - point1.iX;        //It depends on platform. WINSCW/H4 w=5; H6 w=4
  1.1621 +	RDebug::Print(_L("wLTR %d,wRTL %d"), wLTR,wRTL);
  1.1622 +
  1.1623 +	//  DocPos1 is LTR, DocPos1+1 is LTR, DocPos2 is LTR, DocPos2+1 is RTL
  1.1624 +    rect = iLayout->GetLineRectL(0,2);
  1.1625 +    RDebug::Print(_L("iTl.iX %d,iY %d, iBr.iX %d,iY %d"), rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY);
  1.1626 +    test(rect.iTl.iX == 0 && rect.iBr.iX == 3*wLTR);
  1.1627 +
  1.1628 +    //  DocPos1 is LTR, DocPos1+1 is LTR, DocPos2 is RTL, DocPos2+1 is RTL
  1.1629 +    rect = iLayout->GetLineRectL(0,4);
  1.1630 +    RDebug::Print(_L("iTl.iX %d,iY %d, iBr.iX %d,iY %d"), rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY);
  1.1631 +    test(rect.iTl.iX == 0 && rect.iBr.iX == 3*wLTR + 2*wRTL);
  1.1632 +
  1.1633 +    //  DocPos1 is LTR, DocPos1+1 is LTR, DocPos2 is RTL, DocPos2+1 is LTR
  1.1634 +    rect = iLayout->GetLineRectL(0,5);
  1.1635 +    RDebug::Print(_L("iTl.iX %d,iY %d, iBr.iX %d,iY %d"), rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY);
  1.1636 +    test(rect.iTl.iX == 0 && rect.iBr.iX == 3*wLTR + wRTL);
  1.1637 +    
  1.1638 +    //	DocPos1 is LTR, DocPos1+1 is LTR, DocPos2 is LTR, DocPos2+1 is LTR
  1.1639 +	rect = iLayout->GetLineRectL(0,7);
  1.1640 +    RDebug::Print(_L("iTl.iX %d,iY %d, iBr.iX %d,iY %d"), rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY);
  1.1641 +	test(rect.iTl.iX == 0 && rect.iBr.iX == 3*wLTR + 3*wRTL + 2*wLTR);
  1.1642 +	
  1.1643 +//	DocPos1 is LTR, DocPos1+1 is RTL, DocPos2 is LTR, DocPos2+1 is LTR
  1.1644 +	rect = iLayout->GetLineRectL(2,7);
  1.1645 +	RDebug::Print(_L("iTl.iX %d,iY %d, iBr.iX %d,iY %d"), rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY);
  1.1646 +	test(rect.iTl.iX == 2*wLTR && rect.iBr.iX == 3*wLTR + 3*wRTL + 2*wLTR);
  1.1647 +
  1.1648 +//	DocPos1 is LTR, DocPos1+1 is RTL, DocPos2 is LTR, DocPos2+1 is RTL
  1.1649 +	rect = iLayout->GetLineRectL(2,8);
  1.1650 +	RDebug::Print(_L("iTl.iX %d,iY %d, iBr.iX %d,iY %d"), rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY);
  1.1651 +	test(rect.iTl.iX == 2*wLTR && rect.iBr.iX == 3*wLTR + 3*wRTL + 3*wLTR);
  1.1652 +
  1.1653 +//	DocPos1 is LTR, DocPos1+1 is RTL, DocPos2 is RTL, DocPos2+1 is LTR
  1.1654 +	rect = iLayout->GetLineRectL(2,5);
  1.1655 +	RDebug::Print(_L("iTl.iX %d,iY %d, iBr.iX %d,iY %d"), rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY);
  1.1656 +	test(rect.iTl.iX == 2*wLTR && rect.iBr.iX == 3*wLTR + wRTL);
  1.1657 +
  1.1658 +//	DocPos1 is LTR, DocPos1+1 is RTL, DocPos2 is RTL, DocPos2+1 is RTL
  1.1659 +	rect = iLayout->GetLineRectL(2,4);
  1.1660 +	RDebug::Print(_L("iTl.iX %d,iY %d, iBr.iX %d,iY %d"), rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY);
  1.1661 +	test(rect.iTl.iX == 2*wLTR && rect.iBr.iX == 3*wLTR + 2*wRTL);
  1.1662 +
  1.1663 +//	Sample text for test
  1.1664 +//	Doc_Pos:     | 9|10|11| 8| 7| 6| 3| 4| 5| 2| 1| 0|
  1.1665 +//	X-Coords:  |40|45|50|55|60|65|70|75|80|85|90|95|100|     in case w=5
  1.1666 +
  1.1667 +	iEtext->Reset();
  1.1668 +	iEtext->InsertL(0,KRtoLText);
  1.1669 +	iEtext->InsertL(iEtext->DocumentLength(),KLtoRText);
  1.1670 +	iEtext->InsertL(iEtext->DocumentLength(),KRtoLText);
  1.1671 +	iEtext->InsertL(iEtext->DocumentLength(),KLtoRText);
  1.1672 +	iEtext->InsertL(iEtext->DocumentLength(),KParaSep);
  1.1673 +	iView->FormatTextL();
  1.1674 +	
  1.1675 +//	DocPos1 is RTL, DocPos1+1 is LTR, DocPos2 is LTR, DocPos2+1 is LTR
  1.1676 +	rect = iLayout->GetLineRectL(2,4);
  1.1677 +	RDebug::Print(_L("iTl.iX %d,iY %d, iBr.iX %d,iY %d"), rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY);	
  1.1678 +	test(rect.iTl.iX == iWindowRect.Width() - 3*wRTL - 2*wLTR && rect.iBr.iX == iWindowRect.Width() - 2*wRTL);
  1.1679 +			
  1.1680 +//	DocPos1 is RTL, DocPos1+1 is LTR, DocPos2 is LTR, DocPos2+1 is RTL
  1.1681 +	rect = iLayout->GetLineRectL(2,5);
  1.1682 +	RDebug::Print(_L("iTl.iX %d,iY %d, iBr.iX %d,iY %d"), rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY);	
  1.1683 +	test(rect.iTl.iX == iWindowRect.Width() - 3*wRTL - wLTR && rect.iBr.iX == iWindowRect.Width() - 2*wRTL);
  1.1684 +
  1.1685 +//	DocPos1 is RTL, DocPos1+1 is LTR, DocPos2 is RTL, DocPos2+1 is LTR
  1.1686 +	rect = iLayout->GetLineRectL(2,8);
  1.1687 +	RDebug::Print(_L("iTl.iX %d,iY %d, iBr.iX %d,iY %d"), rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY);	
  1.1688 +	test(rect.iTl.iX == iWindowRect.Width() - 3*wRTL - 3*wLTR - 3*wRTL && rect.iBr.iX == iWindowRect.Width() - 2*wRTL);
  1.1689 +
  1.1690 +//	DocPos1 is RTL, DocPos1+1 is LTR, DocPos2 is RTL, DocPos2+1 is RTL
  1.1691 +	rect = iLayout->GetLineRectL(2,7);
  1.1692 +	RDebug::Print(_L("iTl.iX %d,iY %d, iBr.iX %d,iY %d"), rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY);
  1.1693 +	test(rect.iTl.iX == iWindowRect.Width() - 3*wRTL - 3*wLTR - 2*wRTL && rect.iBr.iX == iWindowRect.Width() - 2*wRTL);
  1.1694 +
  1.1695 +//	DocPos1 is RTL, DocPos1+1 is RTL, DocPos2 is LTR, DocPos2+1 is LTR
  1.1696 +	rect = iLayout->GetLineRectL(0,4);
  1.1697 +	RDebug::Print(_L("iTl.iX %d,iY %d, iBr.iX %d,iY %d"), rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY);	
  1.1698 +	test(rect.iTl.iX == iWindowRect.Width() - 3*wRTL - 2*wLTR && rect.iBr.iX == 100);
  1.1699 +
  1.1700 +//	DocPos1 is RTL, DocPos1+1 is RTL, DocPos2 is LTR, DocPos2+1 is RTL
  1.1701 +	rect = iLayout->GetLineRectL(0,5);
  1.1702 +	RDebug::Print(_L("iTl.iX %d,iY %d, iBr.iX %d,iY %d"), rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY);
  1.1703 +	test(rect.iTl.iX == iWindowRect.Width() - 3*wRTL - wLTR && rect.iBr.iX == 100);
  1.1704 +
  1.1705 +//	DocPos1 is RTL, DocPos1+1 is RTL, DocPos2 is RTL, DocPos2+1 is LTR
  1.1706 +	rect = iLayout->GetLineRectL(0,8);
  1.1707 +	RDebug::Print(_L("iTl.iX %d,iY %d, iBr.iX %d,iY %d"), rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY);	
  1.1708 +	test(rect.iTl.iX == iWindowRect.Width() - 3*wRTL - 3*wLTR - 3*wRTL && rect.iBr.iX == 100);
  1.1709 +
  1.1710 +//	DocPos1 is RTL, DocPos1+1 is RTL, DocPos2 is RTL, DocPos2+1 is RTL
  1.1711 +	rect = iLayout->GetLineRectL(0,7);
  1.1712 +	RDebug::Print(_L("iTl.iX %d,iY %d, iBr.iX %d,iY %d"), rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY);	
  1.1713 +	test(rect.iTl.iX == iWindowRect.Width() - 3*wRTL - 3*wLTR - 2*wRTL && rect.iBr.iX == 100);
  1.1714 +	
  1.1715 +
  1.1716 +	
  1.1717 +//	Edge case tests
  1.1718 +//	Sample text
  1.1719 +//	1st Line:    | 0| 1| 2| 3| 4| 5| 6| 7| 8| 9|10|11|19|18|17|16|15|14|13|12|
  1.1720 +//	X-Coords:  | 0| 5|10|15|20|25|30|35|40|45|50|55|60|65|70|75|80|85|90|95|100|   in case w=5
  1.1721 +//	2nd Line:    |23|22|21|20|
  1.1722 +	
  1.1723 +//	Edge case tests
  1.1724 +//	Sample text
  1.1725 +//	1st Line:    | 0| 1| 2| 3| 4| 5| 6| 7| 8| 9|10|11|12|13|14|24|23|22|21|20|19|18|17|16|15|
  1.1726 +//	X-Coords:  | 0| 4| 8|12|16|20|24|28|32|36|40|44|48|52|56|60|64|68|72|76|80|84|88|92|96|100|  w=4
  1.1727 +//	2nd Line:    |29|28|27|26|25|24|23|22|21|20|
  1.1728 +	
  1.1729 +	TInt LtoRLength = (iWindowRect.Width() - 5*wRTL)/wLTR;
  1.1730 +	TInt RtoLLength = 10;
  1.1731 +	TInt RtoLinLine1= (iWindowRect.Width() - LtoRLength * wLTR)/wRTL;
  1.1732 +	TInt Line2Start = LtoRLength + RtoLinLine1;
  1.1733 +	
  1.1734 +	iEtext->Reset();
  1.1735 +	for(TInt i=0;i<LtoRLength;i++)
  1.1736 +        {
  1.1737 +        iEtext->InsertL(iEtext->DocumentLength(),KLtoRChar);
  1.1738 +        }
  1.1739 +	
  1.1740 +	for(TInt i=0;i<RtoLLength;i++)
  1.1741 +	    {
  1.1742 +	    iEtext->InsertL(iEtext->DocumentLength(),KRtoLChar);
  1.1743 +	    }	
  1.1744 +	iEtext->InsertL(iEtext->DocumentLength(),KParaSep);
  1.1745 +	iView->FormatTextL();
  1.1746 +
  1.1747 +    for(TInt i=0;i<LtoRLength + RtoLLength;i++)
  1.1748 +    {
  1.1749 +        rect = iLayout->GetLineRectL(i,i+1);
  1.1750 +        RDebug::Print(_L("%d: iTl.iX %d,iY %d, iBr.iX %d,iY %d"), i,rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY);
  1.1751 +    }          
  1.1752 +    
  1.1753 +    rect = iLayout->GetLineRectL(0,LtoRLength);
  1.1754 +    RDebug::Print(_L("iTl.iX %d,iY %d, iBr.iX %d,iY %d"), rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY);    
  1.1755 +    test(rect.iTl.iX == 0 && rect.iBr.iX == LtoRLength*wLTR + RtoLinLine1*wRTL ); //Line 1
  1.1756 +  
  1.1757 +    rect = iLayout->GetLineRectL(Line2Start, LtoRLength + RtoLLength);
  1.1758 +    RDebug::Print(_L("iTl.iX %d,iY %d, iBr.iX %d,iY %d"), rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY);
  1.1759 +    test(rect.iTl.iX == 0 && rect.iBr.iX == (RtoLLength - RtoLinLine1)*wRTL); //Line 2
  1.1760 +
  1.1761 +    rect = iLayout->GetLineRectL(0,0);
  1.1762 +    RDebug::Print(_L("iTl.iX %d,iY %d, iBr.iX %d,iY %d"), rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY);    
  1.1763 +    test(rect.iTl.iX == 0 && rect.iBr.iX == wLTR); //first char
  1.1764 +    
  1.1765 +    //firt char of RTL
  1.1766 +    rect = iLayout->GetLineRectL(LtoRLength,LtoRLength);
  1.1767 +    RDebug::Print(_L("iTl.iX %d,iY %d, iBr.iX %d,iY %d"), rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY);    
  1.1768 +    test(rect.iTl.iX == LtoRLength*wLTR + (RtoLinLine1-1)*wRTL && rect.iBr.iX == LtoRLength*wLTR + RtoLinLine1*wRTL); //end of line 1
  1.1769 +
  1.1770 +    //middle of L to R
  1.1771 +    rect = iLayout->GetLineRectL(LtoRLength/2,LtoRLength/2);
  1.1772 +    RDebug::Print(_L("iTl.iX %d,iY %d, iBr.iX %d,iY %d"), rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY);    
  1.1773 +    test(rect.iTl.iX == LtoRLength/2 * wLTR && rect.iBr.iX == (LtoRLength/2+1) * wLTR);
  1.1774 +      
  1.1775 +    //middle of LTR to first of RTL
  1.1776 +    rect = iLayout->GetLineRectL(LtoRLength/2,LtoRLength);
  1.1777 +    RDebug::Print(_L("iTl.iX %d,iY %d, iBr.iX %d,iY %d"), rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY);    
  1.1778 +    test(rect.iTl.iX == LtoRLength/2 * wLTR && rect.iBr.iX == LtoRLength*wLTR + RtoLinLine1*wRTL);
  1.1779 + 
  1.1780 +    //second of RTL to start of 2nd line ??
  1.1781 +    rect = iLayout->GetLineRectL(LtoRLength+1,Line2Start);
  1.1782 +    RDebug::Print(_L("iTl.iX %d,iY %d, iBr.iX %d,iY %d"), rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY);    
  1.1783 +    test(rect.iTl.iX == LtoRLength*wLTR + (RtoLinLine1-1)*wRTL && rect.iBr.iX == LtoRLength*wLTR + RtoLinLine1*wRTL); //end of line 1
  1.1784 +  
  1.1785 +    //middle of L to R
  1.1786 +    rect = iLayout->GetLineRectL(LtoRLength/2,LtoRLength/2-1);
  1.1787 +    RDebug::Print(_L("iTl.iX %d,iY %d, iBr.iX %d,iY %d"), rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY);    
  1.1788 +    test(rect.iTl.iX == LtoRLength/2 * wLTR && rect.iBr.iX == LtoRLength*wLTR + RtoLinLine1*wRTL);
  1.1789 +    
  1.1790 +		
  1.1791 +//	Test for edge cases while two lines are in different direction
  1.1792 +//	Sample text
  1.1793 +//	1st Line:    | 0| 1| 2| 3| 4| 5| 6| 7| 8| 9|10|11|12|13|14|15|16|17|18|19|
  1.1794 +//	X-Coords:  | 0| 5|10|15|20|25|30|35|40|45|50|55|60|65|70|75|80|85|90|95|100|  in case w=5
  1.1795 +//	2nd Line:    |39|38|37|36|35|34|33|32|31|30|29|28|27|26|25|24|23|22|21|20|
  1.1796 +		
  1.1797 +//	Test for edge cases while two lines are in different direction
  1.1798 +//  Sample text
  1.1799 +//	1st Line:    | 0| 1| 2| 3| 4| 5| 6| 7| 8| 9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|
  1.1800 +//	X-Coords:  | 0| 4| 8| 12|16|20|24|28|32|36|40|44|48|52|56|60|64|68|72|76|80|84|88|92|96|100|  w=4
  1.1801 +//	2nd Line:    |49|48|47|46|45|44|43|42|41|40|39|38|37|36|35|34|33|32|31|30|29|28|27|26|25|
  1.1802 +    
  1.1803 +    LtoRLength = iWindowRect.Width()/wLTR;
  1.1804 +    RtoLLength = iWindowRect.Width()/wRTL;
  1.1805 +        
  1.1806 +    iEtext->Reset();
  1.1807 +    for(TInt i=0;i<LtoRLength;i++)
  1.1808 +        {
  1.1809 +        iEtext->InsertL(iEtext->DocumentLength(),KLtoRChar);
  1.1810 +        }
  1.1811 +    
  1.1812 +    for(TInt i=0;i<RtoLLength;i++)
  1.1813 +        {
  1.1814 +        iEtext->InsertL(iEtext->DocumentLength(),KRtoLChar);
  1.1815 +        }       
  1.1816 +	iEtext->InsertL(iEtext->DocumentLength(),KParaSep);
  1.1817 +	iView->FormatTextL();
  1.1818 +
  1.1819 +    for(TInt i=0;i<LtoRLength + RtoLLength;i++)
  1.1820 +    {
  1.1821 +        rect = iLayout->GetLineRectL(i,i+1);
  1.1822 +        RDebug::Print(_L("%d: iTl.iX %d,iY %d, iBr.iX %d,iY %d"), i,rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY);
  1.1823 +    }  
  1.1824 + 
  1.1825 +    
  1.1826 +    //1st line
  1.1827 +    rect = iLayout->GetLineRectL(3, LtoRLength-1);
  1.1828 +    RDebug::Print(_L("iTl.iX %d,iY %d, iBr.iX %d,iY %d"), rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY);
  1.1829 +    test(rect.iTl.iX == 3*wLTR && rect.iBr.iX == LtoRLength*wLTR); //Line 2
  1.1830 +
  1.1831 +    //2nd line
  1.1832 +    rect = iLayout->GetLineRectL(LtoRLength,LtoRLength + RtoLLength -2);
  1.1833 +    RDebug::Print(_L("iTl.iX %d,iY %d, iBr.iX %d,iY %d"), rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY);
  1.1834 +    test(rect.iTl.iX == wRTL && rect.iBr.iX == RtoLLength*wRTL); //Line 2
  1.1835 +
  1.1836 +    //end of 1st line
  1.1837 +    rect = iLayout->GetLineRectL(LtoRLength-1, LtoRLength-1);
  1.1838 +    RDebug::Print(_L("iTl.iX %d,iY %d, iBr.iX %d,iY %d"), rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY);
  1.1839 +    test(rect.iTl.iX == (LtoRLength-1)*wLTR && rect.iBr.iX == LtoRLength*wLTR); //Line 2
  1.1840 +
  1.1841 +    //start of 2nd line
  1.1842 +    rect = iLayout->GetLineRectL(LtoRLength, LtoRLength);
  1.1843 +    RDebug::Print(_L("iTl.iX %d,iY %d, iBr.iX %d,iY %d"), rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY);
  1.1844 +    test(rect.iTl.iX == (RtoLLength-1)*wRTL && rect.iBr.iX == RtoLLength*wRTL); //Line 2
  1.1845 +
  1.1846 +     //1st line to 2nd line
  1.1847 +     rect = iLayout->GetLineRectL(LtoRLength-1, LtoRLength);
  1.1848 +     RDebug::Print(_L("iTl.iX %d,iY %d, iBr.iX %d,iY %d"), rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY);
  1.1849 +     test(rect.iTl.iX == (LtoRLength-1)*wLTR && rect.iBr.iX == LtoRLength*wLTR); //Line 2
  1.1850 +
  1.1851 +
  1.1852 +	}
  1.1853 +
  1.1854 +/**
  1.1855 +@SYMTestCaseID          SYSLIB-FORM-UT-4007
  1.1856 +@SYMTestCaseDesc	    Test for PDEF118443
  1.1857 +@SYMTestPriority 	    Normal
  1.1858 +@SYMTestActions			Use test cases in form of "text + ZWJ + non-text characters", format the line,
  1.1859 + 						then use CTmTextLayout::FindAdjacentChunks() to find text Chunks surrounding
  1.1860 + 						the ZWJ. then verify if the text is broken at the correct place.
  1.1861 +@SYMTestExpectedResults CTmTextLayout::FindAdjacentChunks() should return:
  1.1862 +						- Left chunk = "text + ZWJ",
  1.1863 +						- Right chunk = "non-text characters".
  1.1864 +@SYMDEF                 PDEF118443
  1.1865 +*/
  1.1866 +void CTextViewTest::TestForPDEF118443L()
  1.1867 +	{
  1.1868 +	test.Next(_L(" @SYMTestCaseID:SYSLIB-FORM-UT-4007 Testing fix for PDEF118443 "));
  1.1869 +	InitializeL();
  1.1870 +
  1.1871 +	TCharFormat charFormat = TCharFormat(_L("ClearlyU"),10);
  1.1872 +	TCharFormatMask charFormatMask;
  1.1873 +	charFormatMask.SetAll();
  1.1874 +	iCharLayer->SetL(charFormat, charFormatMask);
  1.1875 +	iEtext->SetGlobalCharFormat(iCharLayer);
  1.1876 +
  1.1877 +	// Note: a 'W' is added at the front to make the text chunk have side-bearings, so that it won't be amalgamated
  1.1878 +	// with the following chunk. This is to make the test case be as same as the original use case that caused the defect.
  1.1879 +	_LIT(KScriptEndWithZWJ,"W\x0931\x094d\x200d");	// Scripte end with ZWJ (a 'W' in the front)
  1.1880 +	_LIT(KTextTestCase0,"\x2029");	// Paragraph seperator (Bidi Category: B)
  1.1881 +	_LIT(KTextTestCase1,"0");		// Digit 0 (Bidi Category: EN)
  1.1882 +	_LIT(KTextTestCase2,"+");		// Plus sign (Bidi Category: ES)
  1.1883 +	_LIT(KTextTestCase3,"\u00A3");		// Pound symbol (Bidi Category: ET)
  1.1884 +	_LIT(KTextTestCase4,".");		// Period (Bidi Category: CS)
  1.1885 +	_LIT(KTextTestCase5,"\x0009");	// Tab (Bidi Category: S)
  1.1886 +	_LIT(KTextTestCase6,"\x0020");	// Space (Bidi Category: WS)
  1.1887 +	_LIT(KTextTestCase7,"\x000C");	// Form feed (Bidi Category: WS)
  1.1888 +	_LIT(KTextTestCase8,"\x2028");	// Line breaker (Bidi Category: WS)
  1.1889 +
  1.1890 +	TTmDocPosSpec pos(4, TTmDocPosSpec::ETrailing);
  1.1891 +	CTmTextLayout::TTmChunkDescription left;
  1.1892 +	CTmTextLayout::TTmChunkDescription right;
  1.1893 +
  1.1894 +	// Test case 0: ZWJ + Paragraph seperater
  1.1895 +	iEtext->Reset();
  1.1896 +	iEtext->InsertL(0,KScriptEndWithZWJ);
  1.1897 +	iEtext->InsertL(iEtext->DocumentLength(),KTextTestCase0);
  1.1898 +	iView->FormatTextL();
  1.1899 +	iLayout->TagmaTextLayout().FindAdjacentChunks(pos, left, right);
  1.1900 +	test(left.iStart == 0);
  1.1901 +	test(left.iEnd == 4);
  1.1902 +	test(left.iRightToLeft == EFalse);
  1.1903 +	test(right.iStart == 4);
  1.1904 +	test(right.iRightToLeft == EFalse);
  1.1905 +
  1.1906 +	// Test case 1: ZWJ + Digit '0'
  1.1907 +	iEtext->Reset();
  1.1908 +	iEtext->InsertL(0,KScriptEndWithZWJ);
  1.1909 +	iEtext->InsertL(iEtext->DocumentLength(),KTextTestCase1);
  1.1910 +	iView->FormatTextL();
  1.1911 +	iLayout->TagmaTextLayout().FindAdjacentChunks(pos, left, right);
  1.1912 +	test(left.iStart == 0);
  1.1913 +	test(left.iEnd == 4);
  1.1914 +	test(left.iRightToLeft == EFalse);
  1.1915 +	test(right.iStart == 4);
  1.1916 +	test(right.iRightToLeft == EFalse);
  1.1917 +
  1.1918 +	// Test case 2: ZWJ + Plus sign '+'
  1.1919 +	iEtext->Reset();
  1.1920 +	iEtext->InsertL(0,KScriptEndWithZWJ);
  1.1921 +	iEtext->InsertL(iEtext->DocumentLength(),KTextTestCase2);
  1.1922 +	iView->FormatTextL();
  1.1923 +	iLayout->TagmaTextLayout().FindAdjacentChunks(pos, left, right);
  1.1924 +	test(left.iStart == 0);
  1.1925 +	test(left.iEnd == 4);
  1.1926 +	test(left.iRightToLeft == EFalse);
  1.1927 +	test(right.iStart == 4);
  1.1928 +	test(right.iRightToLeft == EFalse);
  1.1929 +
  1.1930 +	// Test case 3: ZWJ + Pound symbol '??'
  1.1931 +	iEtext->Reset();
  1.1932 +	iEtext->InsertL(0,KScriptEndWithZWJ);
  1.1933 +	iEtext->InsertL(iEtext->DocumentLength(),KTextTestCase3);
  1.1934 +	iView->FormatTextL();
  1.1935 +	iLayout->TagmaTextLayout().FindAdjacentChunks(pos, left, right);
  1.1936 +	test(left.iStart == 0);
  1.1937 +	test(left.iEnd == 4);
  1.1938 +	test(left.iRightToLeft == EFalse);
  1.1939 +	test(right.iStart == 4);
  1.1940 +	test(right.iRightToLeft == EFalse);
  1.1941 +
  1.1942 +	// Test case 0: ZWJ + Period '.'
  1.1943 +	iEtext->Reset();
  1.1944 +	iEtext->InsertL(0,KScriptEndWithZWJ);
  1.1945 +	iEtext->InsertL(iEtext->DocumentLength(),KTextTestCase4);
  1.1946 +	iView->FormatTextL();
  1.1947 +	iLayout->TagmaTextLayout().FindAdjacentChunks(pos, left, right);
  1.1948 +	test(left.iStart == 0);
  1.1949 +	test(left.iEnd == 4);
  1.1950 +	test(left.iRightToLeft == EFalse);
  1.1951 +	test(right.iStart == 4);
  1.1952 +	test(right.iRightToLeft == EFalse);
  1.1953 +
  1.1954 +	// Test case 0: ZWJ + Tab Character
  1.1955 +	iEtext->Reset();
  1.1956 +	iEtext->InsertL(0,KScriptEndWithZWJ);
  1.1957 +	iEtext->InsertL(iEtext->DocumentLength(),KTextTestCase5);
  1.1958 +	iView->FormatTextL();
  1.1959 +	iLayout->TagmaTextLayout().FindAdjacentChunks(pos, left, right);
  1.1960 +	test(left.iStart == 0);
  1.1961 +	test(left.iEnd == 4);
  1.1962 +	test(left.iRightToLeft == EFalse);
  1.1963 +	test(right.iStart == 4);
  1.1964 +	test(right.iRightToLeft == EFalse);
  1.1965 +
  1.1966 +	// Test case 0: ZWJ + Space
  1.1967 +	iEtext->Reset();
  1.1968 +	iEtext->InsertL(0,KScriptEndWithZWJ);
  1.1969 +	iEtext->InsertL(iEtext->DocumentLength(),KTextTestCase6);
  1.1970 +	iView->FormatTextL();
  1.1971 +	iLayout->TagmaTextLayout().FindAdjacentChunks(pos, left, right);
  1.1972 +	test(left.iStart == 0);
  1.1973 +	test(left.iEnd == 4);
  1.1974 +	test(left.iRightToLeft == EFalse);
  1.1975 +	test(right.iStart == 4);
  1.1976 +	test(right.iRightToLeft == EFalse);
  1.1977 +
  1.1978 +	// Test case 0: ZWJ + Form feed
  1.1979 +	iEtext->Reset();
  1.1980 +	iEtext->InsertL(0,KScriptEndWithZWJ);
  1.1981 +	iEtext->InsertL(iEtext->DocumentLength(),KTextTestCase7);
  1.1982 +	iView->FormatTextL();
  1.1983 +	iLayout->TagmaTextLayout().FindAdjacentChunks(pos, left, right);
  1.1984 +	test(left.iStart == 0);
  1.1985 +	test(left.iEnd == 4);
  1.1986 +	test(left.iRightToLeft == EFalse);
  1.1987 +	test(right.iStart == 4);
  1.1988 +	test(right.iRightToLeft == EFalse);
  1.1989 +
  1.1990 +	// Test case 0: ZWJ + Line breaker
  1.1991 +	iEtext->Reset();
  1.1992 +	iEtext->InsertL(0,KScriptEndWithZWJ);
  1.1993 +	iEtext->InsertL(iEtext->DocumentLength(),KTextTestCase8);
  1.1994 +	iView->FormatTextL();
  1.1995 +	iLayout->TagmaTextLayout().FindAdjacentChunks(pos, left, right);
  1.1996 +	test(left.iStart == 0);
  1.1997 +	test(left.iEnd == 4);
  1.1998 +	test(left.iRightToLeft == EFalse);
  1.1999 +	test(right.iStart == 4);
  1.2000 +	test(right.iRightToLeft == EFalse);
  1.2001 +
  1.2002 +	Destroy();
  1.2003 +	}
  1.2004 +
  1.2005 +/**
  1.2006 +@SYMTestCaseID          SYSLIB-FORM-UT-4016
  1.2007 +@SYMTestCaseDesc        Testing the fix for PDEF121798 Printing: Email is printed only two pages 
  1.2008 +@SYMTestPriority        Medium
  1.2009 +@SYMTestActions         Paginates random amounts of text and checks whether the correct number of pages are returned from pagination.
  1.2010 +@SYMTestExpectedResults The amount of pages produced by the paginator should match the expected number of pages based on lines of text, page size, etc.
  1.2011 +@SYMDEF                 PDEF121798
  1.2012 +*/
  1.2013 +void CTextViewTest::TestForPDEF121798L()
  1.2014 +	{
  1.2015 +	test.Next(_L("Testing fix for PDEF121798"));
  1.2016 +	CTestScreenDevice* screenDevice = new(ELeave) CTestScreenDevice(iEnv.ScreenDevice(),iWindow);
  1.2017 +		
  1.2018 +	TMargins margins;
  1.2019 +	margins.iTop = 1440;
  1.2020 +	margins.iBottom = 1440;
  1.2021 +	margins.iLeft = 1440;
  1.2022 +	margins.iRight = 1440;
  1.2023 +	TSize s(11906,16838);
  1.2024 +	TPageSpec p(TPageSpec::EPortrait, s);
  1.2025 +		
  1.2026 +	// We need to find out the height of lines and print area of the page.
  1.2027 +	// From this we determine how many lines *should* appear on the page.
  1.2028 +	// This differs between devices(ie. hw and winscw).
  1.2029 +	TInt pageHeight = screenDevice->VerticalTwipsToPixels(s.iHeight - margins.iTop - margins.iBottom);
  1.2030 +	_LIT(KDummyString,"this is used by dummy paginator to find out line height and page size");
  1.2031 +	InitializeL();
  1.2032 +	AddTextL(KDummyString);
  1.2033 +	TInt lineHeight = 0;	
  1.2034 +	CParaFormat* paraFormat = CParaFormat::NewL();
  1.2035 +	iEtext->GetParagraphFormatL(paraFormat,0);
  1.2036 +	TBool pageBreakChar = EFalse;
  1.2037 +	TInt docPos = 0;
  1.2038 +	iLayout->FormatLineL(paraFormat,docPos,lineHeight,pageBreakChar);
  1.2039 +	
  1.2040 +	CArrayFixFlat<TInt>* charsPerPage = new(ELeave) CArrayFixFlat<TInt>(KGranularity);
  1.2041 +	TInt numLines = pageHeight/lineHeight; // Number of lines expected on a page with paginator settings defined above and line height.
  1.2042 +	
  1.2043 +	
  1.2044 +	
  1.2045 +	// Perform 50 random pagination tests.
  1.2046 +	for(TInt numTests = 0; numTests < 50; numTests++)
  1.2047 +		{
  1.2048 +		// Generate the number of lines in this document.
  1.2049 +		TBuf<512> testString;
  1.2050 +		TInt randomNum = (Math::Random() % 512);
  1.2051 +		// Calculate the expected number of pages based on page size and line height
  1.2052 +		TInt expectedPages = randomNum/numLines;
  1.2053 +		// If it's not an exact fit there will be another page lost in the integer division.
  1.2054 +		if ((numLines * expectedPages != randomNum) || randomNum == 0)
  1.2055 +			{
  1.2056 +			++expectedPages;
  1.2057 +			}
  1.2058 +		// Append the random number of lines to the test string
  1.2059 +		for (TInt i = 0; i < randomNum-1; i++) // randomNum -1 because we add a character after the loop.
  1.2060 +			{
  1.2061 +			// Empty lines will do.
  1.2062 +			testString.Append(CEditableText::EParagraphDelimiter);
  1.2063 +			}
  1.2064 +		// End the text with a character rather than a paragraph delim.
  1.2065 +		testString.Append(_L("A"));
  1.2066 +		
  1.2067 +		
  1.2068 +		InitializeL();
  1.2069 +		AddTextL(testString);
  1.2070 +		// Set up the paginator.
  1.2071 +		CTextPaginator* paginator = CTextPaginator::NewL(screenDevice, charsPerPage, KPaginatePriority);
  1.2072 +		paginator->SetPageMarginsInTwips(margins);
  1.2073 +		paginator->SetPageSpecInTwips(p);
  1.2074 +		paginator->SetDocumentL(iEtext);
  1.2075 +		docPos=0;
  1.2076 +		paginator->AppendTextL(docPos);
  1.2077 +		TInt numPages=paginator->PaginationCompletedL();
  1.2078 +		RDebug::Printf("%d lines: Expected %d pages, got %d pages", randomNum, expectedPages, numPages);
  1.2079 +		test(expectedPages == numPages);
  1.2080 +		delete paginator;
  1.2081 +		}
  1.2082 +	delete charsPerPage;
  1.2083 +	delete screenDevice;
  1.2084 +	delete paraFormat;
  1.2085 +	Destroy();
  1.2086 +	}
  1.2087 +
  1.2088 +/**
  1.2089 +@SYMTestCaseID          SYSLIB-FORM-UT-4015
  1.2090 +@SYMTestCaseDesc	    Test for PDEF120239
  1.2091 +@SYMTestPriority 	    Normal
  1.2092 +@SYMTestActions			Use text consist of "LTR text + ZWJ + RTL Text", format the line, then:
  1.2093 +						1) use CTmTextLayout::FindAdjacentChunks() to find chunks around overlapped doc pos.
  1.2094 +						2) use CTextView::MoveCursorL to move cursor through out the line.
  1.2095 +@SYMTestExpectedResults 1) FindAdjacentChunks() returns correct chunks
  1.2096 +						2) Cursor should moves Left to Right and Right to Left correctly
  1.2097 +@SYMDEF                 PDEF120239
  1.2098 +*/
  1.2099 +void CTextViewTest::TestForPDEF120239L()
  1.2100 +	{
  1.2101 +	test.Next(_L("Testing fix for PDEF120239L"));
  1.2102 +	InitializeL();
  1.2103 +	
  1.2104 +	TCharFormat charFormat = TCharFormat(_L("NewTimes"),10);
  1.2105 +	TCharFormatMask charFormatMask;
  1.2106 +	charFormatMask.SetAll();
  1.2107 +	iCharLayer->SetL(charFormat, charFormatMask);
  1.2108 +	iEtext->SetGlobalCharFormat(iCharLayer);
  1.2109 + 	
  1.2110 +	_LIT(KTestScript,"\x0931\x094d\x200d\x684");	// Test script (LTR text + ZWJ + RTL Text)
  1.2111 +	
  1.2112 +	iEtext->Reset();
  1.2113 +	iEtext->InsertL(0,KTestScript);
  1.2114 +	iView->FormatTextL();
  1.2115 +	
  1.2116 +	// 1) use CTmTextLayout::FindAdjacentChunks()
  1.2117 +	CTmTextLayout::TTmChunkDescription left;
  1.2118 +	CTmTextLayout::TTmChunkDescription right;
  1.2119 +	
  1.2120 +	TTmDocPosSpec pos(3, TTmDocPosSpec::ETrailing);
  1.2121 +
  1.2122 +	iLayout->TagmaTextLayout().FindAdjacentChunks(pos, left, right);
  1.2123 +	test(left.iStart == 0);
  1.2124 +	test(left.iEnd == 3);
  1.2125 +	test(!left.iRightToLeft);
  1.2126 +	test(right.iStart == 2);
  1.2127 +	test(right.iEnd == 4);
  1.2128 +	test(right.iRightToLeft);
  1.2129 +	
  1.2130 +	pos.iPos = 2;
  1.2131 +	pos.iType = TTmDocPosSpec::ELeading;
  1.2132 +	
  1.2133 +	iLayout->TagmaTextLayout().FindAdjacentChunks(pos, left, right);
  1.2134 +	test(left.iStart == 2);
  1.2135 +	test(left.iEnd == 4);
  1.2136 +	test(left.iRightToLeft);
  1.2137 +	test(right.iStart == 4);
  1.2138 +	test(right.iEnd == 5);
  1.2139 +	test(!right.iRightToLeft);
  1.2140 +	
  1.2141 +	// 2) use CTextView::MoveCursorL to move cursor
  1.2142 +	TTmDocPos cursorPos;
  1.2143 +	TTmDocPos targetPos1 (0, ETrue);
  1.2144 +	TTmDocPos targetPos2 (0, EFalse);
  1.2145 +	TCursorPosition::TMovementType move = TCursorPosition::EFRight;
  1.2146 +	
  1.2147 +	TCursorSelection selection(0,0);
  1.2148 +	iView->SetSelectionL(selection);
  1.2149 +	iView->GetCursorPos(cursorPos);
  1.2150 +	test(cursorPos == targetPos1 || cursorPos == targetPos2);
  1.2151 +	
  1.2152 +	targetPos1.iPos = 3;
  1.2153 +	targetPos1.iLeadingEdge = EFalse;
  1.2154 +	targetPos2.iPos = 4;
  1.2155 +	targetPos2.iLeadingEdge = EFalse;
  1.2156 +	iView->MoveCursorL(move, EFalse);
  1.2157 +	iView->GetCursorPos(cursorPos);
  1.2158 +	test(cursorPos == targetPos1 || cursorPos == targetPos2);
  1.2159 +	
  1.2160 +	targetPos1.iPos = 2;
  1.2161 +	targetPos1.iLeadingEdge = ETrue;
  1.2162 +	targetPos2.iPos = 4;
  1.2163 +	targetPos2.iLeadingEdge = ETrue;
  1.2164 +	iView->MoveCursorL(move, EFalse);
  1.2165 +	iView->GetCursorPos(cursorPos);
  1.2166 +	test(cursorPos == targetPos1 || cursorPos == targetPos2);
  1.2167 +	
  1.2168 +	move = TCursorPosition::EFLeft;
  1.2169 +	
  1.2170 +	targetPos1.iPos = 3;
  1.2171 +	targetPos1.iLeadingEdge = EFalse;
  1.2172 +	targetPos2.iPos = 4;
  1.2173 +	targetPos2.iLeadingEdge = EFalse;
  1.2174 +	iView->MoveCursorL(move, EFalse);
  1.2175 +	iView->GetCursorPos(cursorPos);
  1.2176 +	test(cursorPos == targetPos1 || cursorPos == targetPos2);
  1.2177 +	
  1.2178 +	targetPos1.iPos = 0;
  1.2179 +	targetPos1.iLeadingEdge = EFalse;
  1.2180 +	targetPos2.iPos = 0;
  1.2181 +	targetPos2.iLeadingEdge = ETrue;
  1.2182 +	iView->MoveCursorL(move, EFalse);
  1.2183 +	iView->GetCursorPos(cursorPos);
  1.2184 +	test(cursorPos == targetPos1 || cursorPos == targetPos2);
  1.2185 +
  1.2186 +	Destroy();
  1.2187 +	}
  1.2188 +
  1.2189 +/**
  1.2190 +@SYMTestCaseID          SYSLIB-FORM-UT-4021
  1.2191 +@SYMTestCaseDesc	    Test for DEF124989, to ensure TFormAndEtextEditor::SetStyleHelperL has no 
  1.2192 +                        NULL-dereference issue.
  1.2193 +@SYMTestPriority 	    Normal
  1.2194 +@SYMTestActions  	    Call TFormAndEtextEditor::InsertTextL and pass in a style name which could 
  1.2195 +						not be found in styleList.Then a NULL is generated.
  1.2196 +@SYMTestExpectedResults No panic(KERN-EXEC 3) raised from this case.
  1.2197 +@SYMDEF                 DEF124989
  1.2198 +*/
  1.2199 +void CTextViewTest::TestForDEF124989L()
  1.2200 +	{
  1.2201 +	// Initialise CTextViewTest object for next test.
  1.2202 +	InitializeL();
  1.2203 +	test.Next(_L(" @SYMTestCaseID:SYSLIB-FORM-UT-4021 Testing fix for DEF124989 "));
  1.2204 +
  1.2205 +	// Insert a one line paragraph into EText object and reformat view.
  1.2206 +	_LIT(KTestParagraph, "This is a piece of text to test the character positioning API based in X,Y cocordinates.");
  1.2207 +	iEtext->InsertL(0, KTestParagraph);
  1.2208 +	
  1.2209 +	TFormAndEtextEditor newEditor(*iView,*iEtext);
  1.2210 +	
  1.2211 +	CStyleList* styleList = CStyleList::NewL();
  1.2212 +	CleanupStack::PushL(styleList);
  1.2213 +	RParagraphStyleInfo paraStyleInfo(NULL,NULL);
  1.2214 +
  1.2215 +	// Appending the new style to stylelist
  1.2216 +	styleList->AppendL(&paraStyleInfo);
  1.2217 +	iEtext->SetStyleListExternallyOwned(*styleList);
  1.2218 +	
  1.2219 +	TPtrC ptr1(_L("Arial3"));
  1.2220 +	// Inserting the text and applying the style specified(Arial3) 
  1.2221 +	// which is not in syleList.  
  1.2222 +	newEditor.InsertTextL(0, _L("Hello World"),&ptr1);
  1.2223 +	
  1.2224 +	// Clean up test object
  1.2225 +	CleanupStack::PopAndDestroy();
  1.2226 +	Destroy();
  1.2227 +	}
  1.2228 +
  1.2229 +/**
  1.2230 +@SYMTestCaseID                      SYSLIB-FORM-UT-4022
  1.2231 +@SYMTestCaseDesc	    Test for DEF124975
  1.2232 +@SYMTestPriority                       Normal
  1.2233 +@SYMTestActions                      1) Call CTextLayout::AdjustVerticalAlignment() when there is no content
  1.2234 +                                                   2) Add Some random text and then call CTextLayout::AdjustVerticalAlignment()@SYMTestExpectedResults       There should be no panic during the process
  1.2235 +@SYMDEF                                 DEF124975
  1.2236 +*/
  1.2237 +void CTextViewTest::TestForDEF124975L()
  1.2238 +	{
  1.2239 +	test.Next(_L(" @SYMTestCaseID: Testing fix for coverity DEF124975 "));
  1.2240 +	InitializeL();
  1.2241 +	
  1.2242 +	const TInt MaxTestCount = 50;
  1.2243 +	const TInt MaxStringCount = 100;
  1.2244 +	TInt TestCount = GetNumber(1, MaxTestCount);
  1.2245 +	TInt StringCount = GetNumber(1, MaxStringCount);
  1.2246 +	
  1.2247 +	for(TInt i=0; i<TestCount; i++)
  1.2248 +		{
  1.2249 +		iLayout->AdjustVerticalAlignment(CParaFormat::ECustomAlign);
  1.2250 +		}
  1.2251 +	
  1.2252 +	for(TInt i=0; i<TestCount; i++)
  1.2253 +		{
  1.2254 +		RBuf testString;
  1.2255 +		testString.Create(StringCount);
  1.2256 +		for(int i=0; i<testString.MaxLength(); i++)
  1.2257 +			{
  1.2258 +			TInt c = GetNumber(0, 0xffff);
  1.2259 +			while ( IsSurrogate(c) )
  1.2260 +			    c = GetNumber(0, 0xffff);
  1.2261 +			testString.Append( c );
  1.2262 +			}
  1.2263 +		AddTextL(testString);
  1.2264 +		iLayout->AdjustVerticalAlignment(CParaFormat::ECustomAlign);
  1.2265 +		testString.Close();
  1.2266 +		}
  1.2267 +	
  1.2268 +	Destroy();
  1.2269 +	}
  1.2270 +
  1.2271 +void CTextViewTest::TestForDEF142286BounceScrollingL()
  1.2272 +    {
  1.2273 +    test.Next(_L(" Testing fix for DEF142286 which supports bounce scrolling feature "));
  1.2274 +    TestScrollDisplayPixelsNoLimitBordersL(10);
  1.2275 +    TestScrollDisplayPixelsNoLimitBordersL(50);
  1.2276 +    TestScrollDisplayPixelsNoLimitBordersL(100);
  1.2277 +    }
  1.2278 +
  1.2279 +void RunTestsL(CCoeEnv& aEnv)
  1.2280 +	{
  1.2281 +	CTextViewTest* t = new(ELeave) CTextViewTest(aEnv);
  1.2282 +	CleanupStack::PushL(t);
  1.2283 +	t->ConstructL();
  1.2284 +	t->TestL();
  1.2285 +	t->Test1L();
  1.2286 +	t->TestCancelSelectionL();
  1.2287 +	t->TestFinishBackgroundFormattingL();
  1.2288 +	t->TestSetCursorVisibilityL();
  1.2289 +	t->TestSetSelectionVisibilityL();
  1.2290 +	t->TestEnablePictureFrameL();
  1.2291 +	t->TestSetCursorWidthTypeL();
  1.2292 +	t->TestParagraphRectL();
  1.2293 +	t->TestDrawL();
  1.2294 +	t->TestFormatTextL();
  1.2295 +	t->TestHandleRangeFormatChangeL();
  1.2296 +	t->TestHandleInsertDeleteL();
  1.2297 +	t->TestHandleGlobalChangeL();
  1.2298 +	t->TestHandleGlobalChangeNoRedrawL();
  1.2299 +	t->TestScrollDisplayL();
  1.2300 +	t->TestScrollDisplayPixelsL();
  1.2301 +	t->TestScrollDisplayLinesL();
  1.2302 +	t->TestScrollDisplayParagraphsL();
  1.2303 +	t->TestMoveCursorL();
  1.2304 +	t->TestSetSelectionL();
  1.2305 +	t->TestMatchCursorHeightL();
  1.2306 +	t->TestCalculateHorizontalExtremesL();
  1.2307 +	t->TestXyPosToDocPosL();
  1.2308 +	t->TestGetPictureRectangleL();
  1.2309 +	t->TestGetPictureRectangle1L();
  1.2310 +	//t->TestGetPictureRectangleDefectL();
  1.2311 +	t->TestSetDisplayContextL();
  1.2312 +	t->TestGetParaFormatL();
  1.2313 +	t->TestGetLineRectL();
  1.2314 +	t->TestForDEF003426L();
  1.2315 +	t->TestForDEF038488L();
  1.2316 +	t->FormAndEtextTestL();
  1.2317 +	t->TestForINC092725L();
  1.2318 +	t->TestForPDEF108443L();
  1.2319 +	t->TestForPDEF113755L();
  1.2320 +	t->TestForPDEF115165L();
  1.2321 +	t->TestForPDEF118443L();
  1.2322 +	t->TestForPDEF121798L();
  1.2323 +	t->TestForDEF124989L();
  1.2324 +	t->TestForPDEF120239L();
  1.2325 +	t->TestForDEF124975L();
  1.2326 +    t->TestForDEF142286BounceScrollingL();
  1.2327 +	CleanupStack::PopAndDestroy(t);
  1.2328 +}
  1.2329 +
  1.2330 +TInt E32Main()
  1.2331 +	{
  1.2332 +	CCoeEnv* env=new CCoeEnv;
  1.2333 +	TRAPD(err,
  1.2334 +		env->ConstructL();
  1.2335 +		RunTestsL(*env);
  1.2336 +		);
  1.2337 +	return err;
  1.2338 +	}
  1.2339 +
  1.2340 +#if defined(__WINS__)
  1.2341 +EXPORT_C TInt EntryPoint(TAny*) {return E32Main();}
  1.2342 +#endif