textrendering/textformatting/test/src/TTextView.cpp
changeset 0 1fb32624e06b
child 16 748ec5531811
equal deleted inserted replaced
-1:000000000000 0:1fb32624e06b
       
     1 /*
       
     2 * Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 * TTextView.cpp test file for UndoSystem classes
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #include <e32test.h>
       
    21 
       
    22 #include <coemain.h>
       
    23 #include <frmtview.h>
       
    24 #include <txtrich.h>
       
    25 #include <conpics.h>
       
    26 #include <e32math.h>
       
    27 
       
    28 #include "form_and_etext_editor.h"
       
    29 #include "UndoSystem.h"
       
    30 #include "EditorUndo.h"
       
    31 #include "FRMPAGE.H"
       
    32 
       
    33 _LIT(KHello, "hello world");
       
    34 const TInt KPaginatePriority = -100;
       
    35 const TInt KGranularity = 10;
       
    36 
       
    37 using namespace UndoSystem;
       
    38 
       
    39 LOCAL_C TInt GetNumber(TInt aMin, TInt aMax)
       
    40 	{
       
    41 	__ASSERT_ALWAYS(aMin <= aMax, User::Invariant());
       
    42 
       
    43 	TInt64 seed = Math::Random();
       
    44 	TReal randomReal = Math::FRand(seed);
       
    45 
       
    46 	TReal maxReal = randomReal * ((aMax-aMin)+1);
       
    47 	TReal rounded = 0;
       
    48 	User::LeaveIfError(Math::Round(rounded, maxReal, 0));
       
    49 
       
    50 	TInt result = rounded + aMin;
       
    51 	
       
    52 	if(result> aMax)
       
    53 		{
       
    54 		return aMax;
       
    55 		}
       
    56 	return result;
       
    57 	}
       
    58 
       
    59 void ManipulateText(CTextView* aView, CRichText* aText)
       
    60 	{
       
    61 	_LIT(KStartText, "The quick brown fox jumped over the lazy dog.");
       
    62 	aText->InsertL(0, KStartText);
       
    63 	aView->HandleInsertDeleteL(TCursorSelection(0, KStartText().Length()), 0);
       
    64 	aText->InsertL(19, TChar(CEditableText::EParagraphDelimiter));
       
    65 	aView->HandleCharEditL();
       
    66 	TCharFormat format;
       
    67 	TCharFormatMask mask;
       
    68 	format.iFontSpec.iFontStyle.SetStrokeWeight(EStrokeWeightBold);
       
    69 	mask.ClearAll();
       
    70 	mask.SetAttrib(EAttFontStrokeWeight);
       
    71 	aText->ApplyCharFormatL(format, mask, 41, 3);
       
    72 	aView->HandleRangeFormatChangeL(TCursorSelection(41, 44));
       
    73 	aView->SetDocPosL(42);
       
    74 	TInt length = aText->DocumentLength();
       
    75 	aText->DeleteL(0, length);
       
    76 	aView->HandleInsertDeleteL(TCursorSelection(0, 0), length);
       
    77 	}
       
    78 
       
    79 void ManipulateText1(CTextView* aView, CRichText* aText)
       
    80 	{
       
    81 	TInt testaYPos = 0;
       
    82 	_LIT(KText, "The weather is quite good today, but it's a bit too cold");
       
    83 	aText->InsertL(0, KText);
       
    84 	aView->HandleInsertDeleteL(TCursorSelection(0, KText().Length()), 0);
       
    85 	aView->SetDocPosL(10); //56 is the position of the last character d
       
    86 	aView->SetViewLineAtTopL(1);
       
    87 	aView->SetViewL(50, testaYPos);
       
    88 	aView->HandleAdditionalCharactersAtEndL();
       
    89 	}
       
    90 
       
    91 inline TBool IsSurrogate(TText16 aInt16)
       
    92 /**
       
    93 @return True, if aText16 is high surrogate or low surrogate; false, otherwise.
       
    94 */
       
    95 	{
       
    96 	return (aInt16 & 0xF800) == 0xD800;
       
    97 	}
       
    98 
       
    99 class CMyTestPicture : public CPicture
       
   100 	{
       
   101 public:
       
   102 	static CMyTestPicture* NewL(TSize aSize);
       
   103 	void Draw(CGraphicsContext&,const TPoint&,const TRect&,MGraphicsDeviceMap*) const {}
       
   104 	void ExternalizeL(RWriteStream& /*aStream*/) const {}
       
   105 	void GetOriginalSizeInTwips(TSize& aSize) const {aSize=iSizeOfPicture;}
       
   106 private:
       
   107 	CMyTestPicture(TSize aSize);
       
   108 private:
       
   109 	TSize iSizeOfPicture;
       
   110 	};
       
   111 
       
   112 CMyTestPicture* CMyTestPicture::NewL(TSize aSize)
       
   113 	{
       
   114 	return new(ELeave) CMyTestPicture(aSize);
       
   115 	}
       
   116 
       
   117 
       
   118 CMyTestPicture::CMyTestPicture(TSize aSize):iSizeOfPicture(aSize)
       
   119 	{}
       
   120 
       
   121 
       
   122 class CTextViewTest : public CBase
       
   123 	{
       
   124 public:
       
   125 	CTextViewTest(CCoeEnv& aEnv)
       
   126 		: iEnv(aEnv), 	iWindowRect(10, 10, 110, 110), iWindow(aEnv.WsSession()),
       
   127 		test(_L("TTextView - Some tests for CTextView")) {}
       
   128 	void ConstructL();
       
   129 	void InitializeL();
       
   130 	void AddTextL(const TDesC&);
       
   131 	void Destroy();
       
   132 	~CTextViewTest();
       
   133 	void TestL();
       
   134 	void Test1L();
       
   135 	void TestCancelSelectionL();
       
   136 	void TestHandleAdditionalCharactersAtEndL();
       
   137 	void TestFinishBackgroundFormattingL();
       
   138 	void TestSetCursorVisibilityL();
       
   139 	void TestSetSelectionVisibilityL();
       
   140 	void TestEnablePictureFrameL();
       
   141 	void TestSetCursorWidthTypeL();
       
   142 	void TestParagraphRectL();
       
   143 	void TestSetDocPosL();
       
   144 	void TestSetViewLineAtTopL();
       
   145 	void TestDrawL();
       
   146 	void TestFormatTextL();
       
   147 	void TestHandleCharEditL();
       
   148 	void TestHandleRangeFormatChangeL();
       
   149 	void TestHandleInsertDeleteL();
       
   150 	void TestHandleGlobalChangeL();
       
   151 	void TestHandleGlobalChangeNoRedrawL();
       
   152 	void TestScrollDisplayL();
       
   153     void TestScrollDisplayPixelsL();
       
   154     void TestScrollDisplayPixelsNoLimitBordersL(TInt aOffset);
       
   155     void TestForDEF142286BounceScrollingL();
       
   156 	void TestScrollDisplayLinesL();
       
   157 	void TestScrollDisplayParagraphsL();
       
   158 	void TestSetViewL();
       
   159 	void TestMoveCursorL();
       
   160 	void TestSetSelectionL();
       
   161 	void TestMatchCursorHeightL();
       
   162 	void TestCalculateHorizontalExtremesL();
       
   163 	void TestXyPosToDocPosL();
       
   164 //	void TestDrawL1();
       
   165 	void TestGetPictureRectangleL();
       
   166 	void TestGetPictureRectangle1L();
       
   167 	void TestSetDisplayContextL();
       
   168 	void TestGetPictureRectangleDefectL();
       
   169 	void TestGetLineRectL(); // Test for defect WEP-567K9C Form panics when picture
       
   170 							 // inserted in CRichText and alignmnent is set to bottom
       
   171 	void TestForDEF003426L();
       
   172 	void TestForDEF038488L();
       
   173 	void InitializeDiffCharFormatL();
       
   174 	void TestGetParaFormatL();
       
   175 	// Function to test the Class TFormAndEtextEditor
       
   176 	void FormAndEtextTestL();
       
   177 	void TestForINC092725L();
       
   178 	void TestForPDEF108443L();
       
   179 	void TestForPDEF113755L();
       
   180 	void TestForPDEF115165L();
       
   181 	void TestForPDEF118443L();
       
   182 	void TestForPDEF121798L();
       
   183 	void TestForPDEF120239L();
       
   184 	void TestForDEF124989L();
       
   185 	void TestForDEF124975L();
       
   186 	
       
   187 	struct STestDataTInt4
       
   188 		{
       
   189 		TInt iDoc1;
       
   190 		TInt iDoc2; 
       
   191 		TInt iPos1;
       
   192 		TInt iPos2;		
       
   193 		};
       
   194 	
       
   195 private:
       
   196 	CCoeEnv& iEnv;
       
   197 	TRect iWindowRect;
       
   198 	CParaFormatLayer* iParaLayer;
       
   199 	CCharFormatLayer* iCharLayer;
       
   200 	CRichText* iEtext;
       
   201 	CTextLayout* iLayout;
       
   202 	RWindow iWindow;
       
   203 	CTextView* iView;
       
   204 	RTest test;
       
   205 	TCursorSelection select;
       
   206 	TInt testDeltaY;
       
   207 	TInt testDeltaLines;
       
   208 	TInt testDeltaParas;
       
   209 	TInt testaYPos;
       
   210 	TCursorPosition::TMovementType testaMovement;
       
   211 	TFontSpec testaFontSpec;
       
   212 	TInt testaLeft;
       
   213 	TInt testaRight;
       
   214 	TPoint testaPoint;
       
   215 	TBool testaCanScaleOrCrop;
       
   216 	CBitmapContext* testaGc;
       
   217 	TPoint testaXyPos;
       
   218 	CBitmapDevice* testaGd;
       
   219 	RWindowGroup testaGroupWin;
       
   220 	RWsSession testaSession;
       
   221 	};
       
   222 
       
   223 void CTextViewTest::ConstructL()
       
   224 	{
       
   225 	iWindow.Construct(iEnv.RootWin(), 12345);
       
   226 	iParaLayer = CParaFormatLayer::NewL();
       
   227 	iCharLayer = CCharFormatLayer::NewL();
       
   228 	test.Title();
       
   229 	test.Start(_L("CTextView Tests:"));
       
   230 	}
       
   231 
       
   232 void CTextViewTest::InitializeL()
       
   233 	{
       
   234 	Destroy();
       
   235 	iEtext = CRichText::NewL(iParaLayer, iCharLayer);
       
   236 	iLayout = CTextLayout::NewL(iEtext, iWindowRect.Width());
       
   237 	iView = CTextView::NewL(iLayout, iWindowRect, iEnv.ScreenDevice(),
       
   238 		iEnv.SystemGc().Device(), &iWindow, &iEnv.RootWin(), &iEnv.WsSession());
       
   239 	testaGd=(CBitmapDevice*) iEnv.SystemGc().Device();
       
   240 	}
       
   241 
       
   242 void CTextViewTest::AddTextL(const TDesC& aText)
       
   243 	{
       
   244 	iEtext->InsertL(0, aText);
       
   245 	TCursorSelection s(0, aText.Length());
       
   246 	iView->HandleInsertDeleteL(s, 0);
       
   247 	}
       
   248 
       
   249 void CTextViewTest::InitializeDiffCharFormatL()
       
   250 	{
       
   251 	Destroy();
       
   252 	delete iCharLayer;
       
   253 	iCharLayer=0;
       
   254 	TCharFormat charFormat;
       
   255 	TCharFormatMask charFormatMask;
       
   256 	charFormat.iFontPresentation.iPictureAlignment=TFontPresentation::EAlignBottom;
       
   257 	charFormatMask.SetAttrib(EAttFontPictureAlignment);
       
   258 	iCharLayer = CCharFormatLayer::NewL(charFormat,charFormatMask);
       
   259 	iEtext = CRichText::NewL(iParaLayer, iCharLayer);
       
   260 	iLayout = CTextLayout::NewL(iEtext, iWindowRect.Width());
       
   261 	iView = CTextView::NewL(iLayout, iWindowRect, iEnv.ScreenDevice(),
       
   262 		iEnv.SystemGc().Device(), &iWindow, &iEnv.RootWin(), &iEnv.WsSession());
       
   263 	testaGd=(CBitmapDevice*) iEnv.SystemGc().Device();
       
   264 	}
       
   265 
       
   266 void CTextViewTest::Destroy()
       
   267 	{
       
   268 	delete iView;
       
   269 	iView = 0;
       
   270 	delete iLayout;
       
   271 	iLayout = 0;
       
   272 	delete iEtext;
       
   273 	iEtext = 0;
       
   274 	}
       
   275 
       
   276 
       
   277 void CTextViewTest::TestL()
       
   278 	{
       
   279 	// Test for fix to ASR-4UYHZX: ETEXT panic 12 (ECharPosBeyondDocument) when
       
   280 	// out of memory
       
   281 	InitializeL();
       
   282 	ManipulateText(iView, iEtext);
       
   283 	Destroy();
       
   284 	TInt consecutiveSuccesses = 0;
       
   285 	for (TInt i = 1; consecutiveSuccesses != 100; ++i)
       
   286 		{
       
   287 		__UHEAP_MARK;
       
   288 		InitializeL();
       
   289 		__UHEAP_SETFAIL(RHeap::EDeterministic, i);
       
   290 		TRAPD(err, ManipulateText(iView, iEtext));
       
   291 		Destroy();
       
   292 		__UHEAP_SETFAIL(RHeap::ENone, 0);
       
   293 		__UHEAP_MARKENDC(0);
       
   294 		if (err == KErrNone)
       
   295 			++consecutiveSuccesses;
       
   296 		else
       
   297 			consecutiveSuccesses = 0;
       
   298 		}
       
   299 	}
       
   300 
       
   301 
       
   302 void CTextViewTest::Test1L()
       
   303 	{
       
   304 	// testing functions SetViewL, SetViewLineAtTopL,
       
   305 	// SetDocPosL & HandleAdditionalCharactersAtEndL
       
   306 	// - should work but need some kind
       
   307 	// of pre-settings and initialization before they can all be proved
       
   308 	// that there is no memory leak
       
   309 	InitializeL();
       
   310 	ManipulateText1(iView, iEtext); //where all pre-settings have been done
       
   311 	Destroy();
       
   312 	TInt consecutiveSuccesses = 0;
       
   313 	for (TInt i = 1; consecutiveSuccesses != 100; ++i)
       
   314 		{
       
   315 		__UHEAP_MARK;
       
   316 		InitializeL();
       
   317 		__UHEAP_SETFAIL(RHeap::EDeterministic, i);
       
   318 		TRAPD(err, ManipulateText1(iView, iEtext));
       
   319 		Destroy();
       
   320 		__UHEAP_SETFAIL(RHeap::ENone, 0);
       
   321 		__UHEAP_MARKENDC(0);
       
   322 		if (err == KErrNone)
       
   323 			++consecutiveSuccesses;
       
   324 		else
       
   325 			consecutiveSuccesses = 0;
       
   326 		}
       
   327 	}
       
   328 
       
   329 
       
   330 void CTextViewTest::TestCancelSelectionL()
       
   331 	{
       
   332 	InitializeL();
       
   333 	iView->CancelSelectionL();
       
   334 	Destroy();
       
   335 	TInt consecutiveSuccesses = 0;
       
   336 	for (TInt i = 1; consecutiveSuccesses != 100; ++i)
       
   337 		{
       
   338 		__UHEAP_MARK;
       
   339 		InitializeL();
       
   340 		__UHEAP_SETFAIL(RHeap::EDeterministic, i);
       
   341 		TRAPD(err, iView->CancelSelectionL());
       
   342 		Destroy();
       
   343 		__UHEAP_SETFAIL(RHeap::ENone, 0);
       
   344 		__UHEAP_MARKENDC(0);
       
   345 		if (err == KErrNone)
       
   346 			++consecutiveSuccesses;
       
   347 		else
       
   348 			consecutiveSuccesses = 0;
       
   349 		}
       
   350 	}
       
   351 
       
   352 
       
   353 void CTextViewTest::TestFinishBackgroundFormattingL()
       
   354 	{
       
   355 	InitializeL();
       
   356 	iView->FinishBackgroundFormattingL();
       
   357 	Destroy();
       
   358 	TInt consecutiveSuccesses = 0;
       
   359 	for (TInt i = 1; consecutiveSuccesses != 100; ++i)
       
   360 		{
       
   361 		__UHEAP_MARK;
       
   362 		InitializeL();
       
   363 		__UHEAP_SETFAIL(RHeap::EDeterministic, i);
       
   364 		TRAPD(err, iView->FinishBackgroundFormattingL());
       
   365 		Destroy();
       
   366 		__UHEAP_SETFAIL(RHeap::ENone, 0);
       
   367 		__UHEAP_MARKENDC(0);
       
   368 		if (err == KErrNone)
       
   369 			++consecutiveSuccesses;
       
   370 		else
       
   371 			consecutiveSuccesses = 0;
       
   372 		}
       
   373 	}
       
   374 
       
   375 
       
   376 void CTextViewTest::TestFormatTextL()
       
   377 	{
       
   378 	InitializeL();
       
   379 	iView->FormatTextL();
       
   380 	Destroy();
       
   381 	TInt consecutiveSuccesses = 0;
       
   382 	for (TInt i = 1; consecutiveSuccesses != 100; ++i)
       
   383 		{
       
   384 		__UHEAP_MARK;
       
   385 		InitializeL();
       
   386 		__UHEAP_SETFAIL(RHeap::EDeterministic, i);
       
   387 		TRAPD(err, iView->FormatTextL());
       
   388 		Destroy();
       
   389 		__UHEAP_SETFAIL(RHeap::ENone, 0);
       
   390 		__UHEAP_MARKENDC(0);
       
   391 		if (err == KErrNone)
       
   392 			++consecutiveSuccesses;
       
   393 		else
       
   394 			consecutiveSuccesses = 0;
       
   395 		}
       
   396 	}
       
   397 
       
   398 
       
   399 void CTextViewTest::TestSetCursorVisibilityL()
       
   400 	{
       
   401 	InitializeL();
       
   402 	iView->SetCursorVisibilityL(1,1);
       
   403 	Destroy();
       
   404 	TInt consecutiveSuccesses = 0;
       
   405 	for (TInt i = 1; consecutiveSuccesses != 100; ++i)
       
   406 		{
       
   407 		__UHEAP_MARK;
       
   408 		InitializeL();
       
   409 		__UHEAP_SETFAIL(RHeap::EDeterministic, i);
       
   410 		TRAPD(err, iView->SetCursorVisibilityL(1,1)); //TInt aLineCursor, TInt aTextCursor
       
   411 		Destroy();
       
   412 		__UHEAP_SETFAIL(RHeap::ENone, 0);
       
   413 		__UHEAP_MARKENDC(0);
       
   414 		if (err == KErrNone)
       
   415 			++consecutiveSuccesses;
       
   416 		else
       
   417 			consecutiveSuccesses = 0;
       
   418 		}
       
   419 	}
       
   420 
       
   421 
       
   422 void CTextViewTest::TestSetSelectionVisibilityL()
       
   423 	{
       
   424 	InitializeL();
       
   425 	iView->SetSelectionVisibilityL(1);
       
   426 	Destroy();
       
   427 	TInt consecutiveSuccesses = 0;
       
   428 	for (TInt i = 1; consecutiveSuccesses != 100; ++i)
       
   429 		{
       
   430 		__UHEAP_MARK;
       
   431 		InitializeL();
       
   432 		__UHEAP_SETFAIL(RHeap::EDeterministic, i);
       
   433 		TRAPD(err, iView->SetSelectionVisibilityL(1)); //TBool aSelectionVisible
       
   434 		Destroy();
       
   435 		__UHEAP_SETFAIL(RHeap::ENone, 0);
       
   436 		__UHEAP_MARKENDC(0);
       
   437 		if (err == KErrNone)
       
   438 			++consecutiveSuccesses;
       
   439 		else
       
   440 			consecutiveSuccesses = 0;
       
   441 		}
       
   442 	}
       
   443 
       
   444 
       
   445 void CTextViewTest::TestEnablePictureFrameL()
       
   446 	{
       
   447 	InitializeL();
       
   448 	iView->EnablePictureFrameL(1);
       
   449 	Destroy();
       
   450 	TInt consecutiveSuccesses = 0;
       
   451 	for (TInt i = 1; consecutiveSuccesses != 100; ++i)
       
   452 		{
       
   453 		__UHEAP_MARK;
       
   454 		InitializeL();
       
   455 		__UHEAP_SETFAIL(RHeap::EDeterministic, i);
       
   456 		TRAPD(err, iView->EnablePictureFrameL(1)); //TBool aEnabled
       
   457 		Destroy();
       
   458 		__UHEAP_SETFAIL(RHeap::ENone, 0);
       
   459 		__UHEAP_MARKENDC(0);
       
   460 		if (err == KErrNone)
       
   461 			++consecutiveSuccesses;
       
   462 		else
       
   463 			consecutiveSuccesses = 0;
       
   464 		}
       
   465 	}
       
   466 
       
   467 
       
   468 void CTextViewTest::TestSetCursorWidthTypeL()
       
   469 	{
       
   470 	InitializeL();
       
   471 	iView->SetCursorWidthTypeL(TTextCursor::ETypeRectangle,0);
       
   472 	Destroy();
       
   473 	TInt consecutiveSuccesses = 0;
       
   474 	for (TInt i = 1; consecutiveSuccesses != 100; ++i)
       
   475 		{
       
   476 		__UHEAP_MARK;
       
   477 		InitializeL();
       
   478 		__UHEAP_SETFAIL(RHeap::EDeterministic, i);
       
   479 		TRAPD(err, iView->SetCursorWidthTypeL(TTextCursor::ETypeRectangle,0)); //TTextCursor::EType aType, TInt aWidth=0
       
   480 		Destroy();
       
   481 		__UHEAP_SETFAIL(RHeap::ENone, 0);
       
   482 		__UHEAP_MARKENDC(0);
       
   483 		if (err == KErrNone)
       
   484 			++consecutiveSuccesses;
       
   485 		else
       
   486 			consecutiveSuccesses = 0;
       
   487 		}
       
   488 	}
       
   489 
       
   490 
       
   491 void CTextViewTest::TestParagraphRectL()
       
   492 	{
       
   493 	InitializeL();
       
   494 	iView->ParagraphRectL(1);
       
   495 	Destroy();
       
   496 	TInt consecutiveSuccesses = 0;
       
   497 	for (TInt i = 1; consecutiveSuccesses != 100; ++i)
       
   498 		{
       
   499 		__UHEAP_MARK;
       
   500 		InitializeL();
       
   501 		__UHEAP_SETFAIL(RHeap::EDeterministic, i);
       
   502 		TRAPD(err, iView->ParagraphRectL(1)); //TInt aDocPos
       
   503 		Destroy();
       
   504 		__UHEAP_SETFAIL(RHeap::ENone, 0);
       
   505 		__UHEAP_MARKENDC(0);
       
   506 		if (err == KErrNone)
       
   507 			++consecutiveSuccesses;
       
   508 		else
       
   509 			consecutiveSuccesses = 0;
       
   510 		}
       
   511 	}
       
   512 
       
   513 
       
   514 void CTextViewTest::TestDrawL()
       
   515 	{
       
   516 	InitializeL();
       
   517 	iView->DrawL(iWindowRect);
       
   518 	Destroy();
       
   519 	TInt consecutiveSuccesses = 0;
       
   520 	for (TInt i = 1; consecutiveSuccesses != 100; ++i)
       
   521 		{
       
   522 		__UHEAP_MARK;
       
   523 		InitializeL();
       
   524 		__UHEAP_SETFAIL(RHeap::EDeterministic, i);
       
   525 		TRAPD(err, iView->DrawL(iWindowRect)); //TRect aRect
       
   526 		Destroy();
       
   527 		__UHEAP_SETFAIL(RHeap::ENone, 0);
       
   528 		__UHEAP_MARKENDC(0);
       
   529 		if (err == KErrNone)
       
   530 			++consecutiveSuccesses;
       
   531 		else
       
   532 			consecutiveSuccesses = 0;
       
   533 		}
       
   534 	}
       
   535 
       
   536 
       
   537 void CTextViewTest::TestHandleRangeFormatChangeL()
       
   538 	{
       
   539 	InitializeL();
       
   540 	iView->HandleRangeFormatChangeL(select, EFalse);
       
   541 	Destroy();
       
   542 	TInt consecutiveSuccesses = 0;
       
   543 	for (TInt i = 1; consecutiveSuccesses != 100; ++i)
       
   544 		{
       
   545 		__UHEAP_MARK;
       
   546 		InitializeL();
       
   547 		__UHEAP_SETFAIL(RHeap::EDeterministic, i);
       
   548 		TRAPD(err, iView->HandleRangeFormatChangeL(select, EFalse));
       
   549 		Destroy();
       
   550 		__UHEAP_SETFAIL(RHeap::ENone, 0);
       
   551 		__UHEAP_MARKENDC(0);
       
   552 		if (err == KErrNone)
       
   553 			++consecutiveSuccesses;
       
   554 		else
       
   555 			consecutiveSuccesses = 0;
       
   556 		}
       
   557 	}
       
   558 
       
   559 
       
   560 void CTextViewTest::TestHandleInsertDeleteL()
       
   561 	{
       
   562 	InitializeL();
       
   563 	iView->HandleInsertDeleteL(select, 1, EFalse);
       
   564 	Destroy();
       
   565 	TInt consecutiveSuccesses = 0;
       
   566 	for (TInt i = 1; consecutiveSuccesses != 100; ++i)
       
   567 		{
       
   568 		__UHEAP_MARK;
       
   569 		InitializeL();
       
   570 		__UHEAP_SETFAIL(RHeap::EDeterministic, i);
       
   571 		TRAPD(err, iView->HandleInsertDeleteL(select, 1, EFalse));
       
   572 		Destroy();
       
   573 		__UHEAP_SETFAIL(RHeap::ENone, 0);
       
   574 		__UHEAP_MARKENDC(0);
       
   575 		if (err == KErrNone)
       
   576 			++consecutiveSuccesses;
       
   577 		else
       
   578 			consecutiveSuccesses = 0;
       
   579 		}
       
   580 	}
       
   581 
       
   582 
       
   583 void CTextViewTest::TestHandleGlobalChangeL()
       
   584 	{
       
   585 	InitializeL();
       
   586 	iView->HandleGlobalChangeL(TViewYPosQualifier());
       
   587 	Destroy();
       
   588 	TInt consecutiveSuccesses = 0;
       
   589 	for (TInt i = 1; consecutiveSuccesses != 100; ++i)
       
   590 		{
       
   591 		__UHEAP_MARK;
       
   592 		InitializeL();
       
   593 		__UHEAP_SETFAIL(RHeap::EDeterministic, i);
       
   594 		TRAPD(err, iView->HandleGlobalChangeL(TViewYPosQualifier()));
       
   595 		Destroy();
       
   596 		__UHEAP_SETFAIL(RHeap::ENone, 0);
       
   597 		__UHEAP_MARKENDC(0);
       
   598 		if (err == KErrNone)
       
   599 			++consecutiveSuccesses;
       
   600 		else
       
   601 			consecutiveSuccesses = 0;
       
   602 		}
       
   603 	}
       
   604 
       
   605 
       
   606 void CTextViewTest::TestHandleGlobalChangeNoRedrawL()
       
   607 	{
       
   608 	InitializeL();
       
   609 	iView->HandleGlobalChangeNoRedrawL(TViewYPosQualifier());
       
   610 	Destroy();
       
   611 	TInt consecutiveSuccesses = 0;
       
   612 	for (TInt i = 1; consecutiveSuccesses != 100; ++i)
       
   613 		{
       
   614 		__UHEAP_MARK;
       
   615 		InitializeL();
       
   616 		__UHEAP_SETFAIL(RHeap::EDeterministic, i);
       
   617 		TRAPD(err, iView->HandleGlobalChangeNoRedrawL(TViewYPosQualifier()));
       
   618 		Destroy();
       
   619 		__UHEAP_SETFAIL(RHeap::ENone, 0);
       
   620 		__UHEAP_MARKENDC(0);
       
   621 		if (err == KErrNone)
       
   622 			++consecutiveSuccesses;
       
   623 		else
       
   624 			consecutiveSuccesses = 0;
       
   625 		}
       
   626 	}
       
   627 
       
   628 
       
   629 void CTextViewTest::TestScrollDisplayL()
       
   630 	{
       
   631 	InitializeL();
       
   632 	iView->ScrollDisplayL(TCursorPosition::EFLeft);
       
   633 	Destroy();
       
   634 	TInt consecutiveSuccesses = 0;
       
   635 	for (TInt i = 1; consecutiveSuccesses != 100; ++i)
       
   636 		{
       
   637 		__UHEAP_MARK;
       
   638 		InitializeL();
       
   639 		__UHEAP_SETFAIL(RHeap::EDeterministic, i);
       
   640 		TRAPD(err, iView->ScrollDisplayL(TCursorPosition::EFLeft));
       
   641 		Destroy();
       
   642 		__UHEAP_SETFAIL(RHeap::ENone, 0);
       
   643 		__UHEAP_MARKENDC(0);
       
   644 		if (err == KErrNone)
       
   645 			++consecutiveSuccesses;
       
   646 		else
       
   647 			consecutiveSuccesses = 0;
       
   648 		}
       
   649 	}
       
   650 
       
   651 
       
   652 void CTextViewTest::TestScrollDisplayPixelsL()
       
   653 	{
       
   654 	InitializeL();
       
   655 	iView->ScrollDisplayPixelsL(testDeltaY);
       
   656 	Destroy();
       
   657 	TInt consecutiveSuccesses = 0;
       
   658 	for (TInt i = 1; consecutiveSuccesses != 100; ++i)
       
   659 		{
       
   660 		__UHEAP_MARK;
       
   661 		InitializeL();
       
   662 		__UHEAP_SETFAIL(RHeap::EDeterministic, i);
       
   663 		TRAPD(err, iView->ScrollDisplayPixelsL(testDeltaY));
       
   664 		Destroy();
       
   665 		__UHEAP_SETFAIL(RHeap::ENone, 0);
       
   666 		__UHEAP_MARKENDC(0);
       
   667 		if (err == KErrNone)
       
   668 			++consecutiveSuccesses;
       
   669 		else
       
   670 			consecutiveSuccesses = 0;
       
   671 		}
       
   672 	}
       
   673 
       
   674 
       
   675 void CTextViewTest::TestScrollDisplayPixelsNoLimitBordersL(TInt aOffset)
       
   676     { 
       
   677     /*
       
   678      * This test case is for new added function ScrollDisplayPixelsNoLimitBorderL() which support
       
   679      * no limit scrolling, using this function text view can be scrolled beyond the top and bottom 
       
   680      * border.
       
   681      * Text view will be firstly scrolled to border using ScrollDisplayPixelsL() which can't scroll
       
   682      * text view beyond the top or bottom border.
       
   683      * Then text view will be scrolled using ScrollDisplayPixelsNoLimitBorderL() to same direction.
       
   684      * Code will test this step that if text view is really scrolled beyond the border by checking 
       
   685      * the iBandTop position before and after the scrolling operation.*/
       
   686     
       
   687     InitializeL();
       
   688     _LIT(KTestParagraph, "This is a piece of text which is used to test the bounce scrolling feature made by s60.");
       
   689     for (TInt i=0;i<=20;i++)
       
   690         AddTextL(KTestParagraph);
       
   691     
       
   692     TInt firstBandTop, secondBandTop;
       
   693     TInt offset = aOffset;
       
   694     while( offset!=0 )
       
   695         {
       
   696         iView->ScrollDisplayPixelsL(offset);
       
   697         }
       
   698     offset = aOffset;
       
   699     firstBandTop = iLayout->PixelsAboveBand();
       
   700     iView->ScrollDisplayPixelsNoLimitBorderL(offset);
       
   701     secondBandTop = iLayout->PixelsAboveBand();
       
   702     test(firstBandTop - secondBandTop == offset);
       
   703 
       
   704     offset = 0 - aOffset;
       
   705     while( offset!=0 )
       
   706         {
       
   707         iView->ScrollDisplayPixelsL(offset);
       
   708         }
       
   709     offset = 0 - aOffset;
       
   710     firstBandTop = iLayout->PixelsAboveBand();
       
   711     iView->ScrollDisplayPixelsNoLimitBorderL(offset);
       
   712     secondBandTop = iLayout->PixelsAboveBand();
       
   713     test(firstBandTop - secondBandTop == offset);
       
   714     
       
   715     Destroy();
       
   716     }
       
   717 
       
   718 
       
   719 void CTextViewTest::TestScrollDisplayLinesL()
       
   720 	{
       
   721 	InitializeL();
       
   722 	iView->ScrollDisplayLinesL(testDeltaLines);
       
   723 	Destroy();
       
   724 	TInt consecutiveSuccesses = 0;
       
   725 	for (TInt i = 1; consecutiveSuccesses != 100; ++i)
       
   726 		{
       
   727 		__UHEAP_MARK;
       
   728 		InitializeL();
       
   729 		__UHEAP_SETFAIL(RHeap::EDeterministic, i);
       
   730 		TRAPD(err, iView->ScrollDisplayLinesL(testDeltaLines));
       
   731 		Destroy();
       
   732 		__UHEAP_SETFAIL(RHeap::ENone, 0);
       
   733 		__UHEAP_MARKENDC(0);
       
   734 		if (err == KErrNone)
       
   735 			++consecutiveSuccesses;
       
   736 		else
       
   737 			consecutiveSuccesses = 0;
       
   738 		}
       
   739 	}
       
   740 
       
   741 
       
   742 void CTextViewTest::TestScrollDisplayParagraphsL()
       
   743 	{
       
   744 	InitializeL();
       
   745 	AddTextL(KHello);
       
   746 	iView->ScrollDisplayParagraphsL(testDeltaParas);
       
   747 	Destroy();
       
   748 	TInt consecutiveSuccesses = 0;
       
   749 	for (TInt i = 1; consecutiveSuccesses != 100; ++i)
       
   750 		{
       
   751 		__UHEAP_MARK;
       
   752 		InitializeL();
       
   753 		AddTextL(KHello);
       
   754 		__UHEAP_SETFAIL(RHeap::EDeterministic, i);
       
   755 		TRAPD(err, iView->ScrollDisplayParagraphsL(testDeltaParas));
       
   756 		Destroy();
       
   757 		__UHEAP_SETFAIL(RHeap::ENone, 0);
       
   758 		__UHEAP_MARKENDC(0);
       
   759 		if (err == KErrNone)
       
   760 			++consecutiveSuccesses;
       
   761 		else
       
   762 			consecutiveSuccesses = 0;
       
   763 		}
       
   764 	}
       
   765 
       
   766 
       
   767 void CTextViewTest::TestSetViewL()
       
   768 	{
       
   769 	InitializeL();
       
   770 	iView->SetViewL(1, testaYPos);
       
   771 	Destroy();
       
   772 	TInt consecutiveSuccesses = 0;
       
   773 	for (TInt i = 1; consecutiveSuccesses != 100; ++i)
       
   774 		{
       
   775 		__UHEAP_MARK;
       
   776 		InitializeL();
       
   777 		__UHEAP_SETFAIL(RHeap::EDeterministic, i);
       
   778 		TRAPD(err, iView->SetViewL(1, testaYPos));
       
   779 		Destroy();
       
   780 		__UHEAP_SETFAIL(RHeap::ENone, 0);
       
   781 		__UHEAP_MARKENDC(0);
       
   782 		if (err == KErrNone)
       
   783 			++consecutiveSuccesses;
       
   784 		else
       
   785 			consecutiveSuccesses = 0;
       
   786 		}
       
   787 	}
       
   788 
       
   789 
       
   790 void CTextViewTest::TestMoveCursorL()
       
   791 	{
       
   792 	InitializeL();
       
   793 	AddTextL(KHello);
       
   794 	iView->MoveCursorL(testaMovement, EFalse);
       
   795 	Destroy();
       
   796 	TInt consecutiveSuccesses = 0;
       
   797 	for (TInt i = 1; consecutiveSuccesses != 100; ++i)
       
   798 		{
       
   799 		__UHEAP_MARK;
       
   800 		InitializeL();
       
   801 		AddTextL(KHello);
       
   802 		__UHEAP_SETFAIL(RHeap::EDeterministic, i);
       
   803 		TRAPD(err, iView->MoveCursorL(testaMovement, EFalse));
       
   804 		Destroy();
       
   805 		__UHEAP_SETFAIL(RHeap::ENone, 0);
       
   806 		__UHEAP_MARKENDC(0);
       
   807 		if (err == KErrNone)
       
   808 			++consecutiveSuccesses;
       
   809 		else
       
   810 			consecutiveSuccesses = 0;
       
   811 		}
       
   812 	}
       
   813 
       
   814 
       
   815 void CTextViewTest::TestSetSelectionL()
       
   816 	{
       
   817 	InitializeL();
       
   818 	iView->SetSelectionL(select);
       
   819 	Destroy();
       
   820 	TInt consecutiveSuccesses = 0;
       
   821 	for (TInt i = 1; consecutiveSuccesses != 100; ++i)
       
   822 		{
       
   823 		__UHEAP_MARK;
       
   824 		InitializeL();
       
   825 		__UHEAP_SETFAIL(RHeap::EDeterministic, i);
       
   826 		TRAPD(err, iView->SetSelectionL(select));
       
   827 		Destroy();
       
   828 		__UHEAP_SETFAIL(RHeap::ENone, 0);
       
   829 		__UHEAP_MARKENDC(0);
       
   830 		if (err == KErrNone)
       
   831 			++consecutiveSuccesses;
       
   832 		else
       
   833 			consecutiveSuccesses = 0;
       
   834 		}
       
   835 	}
       
   836 
       
   837 
       
   838 void CTextViewTest::TestMatchCursorHeightL()
       
   839 	{
       
   840 	InitializeL();
       
   841 	iView->MatchCursorHeightL(testaFontSpec);
       
   842 	Destroy();
       
   843 	TInt consecutiveSuccesses = 0;
       
   844 	for (TInt i = 1; consecutiveSuccesses != 100; ++i)
       
   845 		{
       
   846 		__UHEAP_MARK;
       
   847 		InitializeL();
       
   848 		__UHEAP_SETFAIL(RHeap::EDeterministic, i);
       
   849 		TRAPD(err, iView->MatchCursorHeightL(testaFontSpec));
       
   850 		Destroy();
       
   851 		__UHEAP_SETFAIL(RHeap::ENone, 0);
       
   852 		__UHEAP_MARKENDC(0);
       
   853 		if (err == KErrNone)
       
   854 			++consecutiveSuccesses;
       
   855 		else
       
   856 			consecutiveSuccesses = 0;
       
   857 		}
       
   858 	}
       
   859 
       
   860 
       
   861 void CTextViewTest::TestCalculateHorizontalExtremesL()
       
   862 	{
       
   863 	InitializeL();
       
   864 	iView->CalculateHorizontalExtremesL(testaLeft, testaRight, EFalse);
       
   865 	Destroy();
       
   866 	TInt consecutiveSuccesses = 0;
       
   867 	for (TInt i = 1; consecutiveSuccesses != 100; ++i)
       
   868 		{
       
   869 		__UHEAP_MARK;
       
   870 		InitializeL();
       
   871 		__UHEAP_SETFAIL(RHeap::EDeterministic, i);
       
   872 		TRAPD(err, iView->CalculateHorizontalExtremesL(testaLeft, testaRight, EFalse));
       
   873 		Destroy();
       
   874 		__UHEAP_SETFAIL(RHeap::ENone, 0);
       
   875 		__UHEAP_MARKENDC(0);
       
   876 		if (err == KErrNone)
       
   877 			++consecutiveSuccesses;
       
   878 		else
       
   879 			consecutiveSuccesses = 0;
       
   880 		}
       
   881 	}
       
   882 
       
   883 
       
   884 void CTextViewTest::TestXyPosToDocPosL()
       
   885 	{
       
   886 	InitializeL();
       
   887 	iView->XyPosToDocPosL(testaPoint);
       
   888 	Destroy();
       
   889 	TInt consecutiveSuccesses = 0;
       
   890 	for (TInt i = 1; consecutiveSuccesses != 100; ++i)
       
   891 		{
       
   892 		__UHEAP_MARK;
       
   893 		InitializeL();
       
   894 		__UHEAP_SETFAIL(RHeap::EDeterministic, i);
       
   895 		TRAPD(err, iView->XyPosToDocPosL(testaPoint));
       
   896 		Destroy();
       
   897 		__UHEAP_SETFAIL(RHeap::ENone, 0);
       
   898 		__UHEAP_MARKENDC(0);
       
   899 		if (err == KErrNone)
       
   900 			++consecutiveSuccesses;
       
   901 		else
       
   902 			consecutiveSuccesses = 0;
       
   903 		}
       
   904 	}
       
   905 
       
   906 /*
       
   907 void CTextViewTest::TestDrawL1()
       
   908 	{
       
   909 	InitializeL();
       
   910 	iView->DrawL(iWindowRect, testaGc);
       
   911 	Destroy();
       
   912 	TInt consecutiveSuccesses = 0;
       
   913 	for (TInt i = 1; consecutiveSuccesses != 100; ++i)
       
   914 		{
       
   915 		__UHEAP_MARK;
       
   916 		InitializeL();
       
   917 		__UHEAP_SETFAIL(RHeap::EDeterministic, i);
       
   918 		TRAPD(err, iView->DrawL(iWindowRect, testaGc));
       
   919 		Destroy();
       
   920 		__UHEAP_SETFAIL(RHeap::ENone, 0);
       
   921 		__UHEAP_MARKENDC(0);
       
   922 		if (err == KErrNone)
       
   923 			++consecutiveSuccesses;
       
   924 		else
       
   925 			consecutiveSuccesses = 0;
       
   926 		}
       
   927 	}
       
   928 */
       
   929 
       
   930 
       
   931 void CTextViewTest::TestGetPictureRectangleL()
       
   932 	{
       
   933 	InitializeL();
       
   934 	iView->GetPictureRectangleL(1, iWindowRect, &testaCanScaleOrCrop);
       
   935 	Destroy();
       
   936 	TInt consecutiveSuccesses = 0;
       
   937 	for (TInt i = 1; consecutiveSuccesses != 100; ++i)
       
   938 		{
       
   939 		__UHEAP_MARK;
       
   940 		InitializeL();
       
   941 		__UHEAP_SETFAIL(RHeap::EDeterministic, i);
       
   942 		TRAPD(err, iView->GetPictureRectangleL(1, iWindowRect, &testaCanScaleOrCrop));
       
   943 		Destroy();
       
   944 		__UHEAP_SETFAIL(RHeap::ENone, 0);
       
   945 		__UHEAP_MARKENDC(0);
       
   946 		if (err == KErrNone)
       
   947 			++consecutiveSuccesses;
       
   948 		else
       
   949 			consecutiveSuccesses = 0;
       
   950 		}
       
   951 	}
       
   952 
       
   953 
       
   954 void CTextViewTest::TestGetPictureRectangle1L()
       
   955 	{
       
   956 	InitializeL();
       
   957 	iView->GetPictureRectangleL(testaXyPos, iWindowRect, &testaCanScaleOrCrop);
       
   958 	Destroy();
       
   959 	TInt consecutiveSuccesses = 0;
       
   960 	for (TInt i = 1; consecutiveSuccesses != 100; ++i)
       
   961 		{
       
   962 		__UHEAP_MARK;
       
   963 		InitializeL();
       
   964 		__UHEAP_SETFAIL(RHeap::EDeterministic, i);
       
   965 		TRAPD(err, iView->GetPictureRectangleL(testaXyPos, iWindowRect, &testaCanScaleOrCrop));
       
   966 		Destroy();
       
   967 		__UHEAP_SETFAIL(RHeap::ENone, 0);
       
   968 		__UHEAP_MARKENDC(0);
       
   969 		if (err == KErrNone)
       
   970 			++consecutiveSuccesses;
       
   971 		else
       
   972 			consecutiveSuccesses = 0;
       
   973 		}
       
   974 	}
       
   975 
       
   976 
       
   977 void CTextViewTest::TestSetDisplayContextL()
       
   978 	{
       
   979 	CBitmapContext* atestGc;
       
   980 	CBitmapContext* anotherGc;
       
   981 	InitializeL();
       
   982 	iView->SetDisplayContextL(testaGd, &iWindow, &testaGroupWin, &testaSession);
       
   983 	Destroy();
       
   984 	TInt consecutiveSuccesses = 0;
       
   985 	for (TInt i = 1; consecutiveSuccesses != 1; ++i)
       
   986 		{
       
   987 		__UHEAP_MARK;
       
   988 		InitializeL();
       
   989 		__UHEAP_SETFAIL(RHeap::EDeterministic, i);
       
   990 		atestGc=iView->BitmapContext();
       
   991 		TRAPD(err, iView->SetDisplayContextL(testaGd, &iWindow, &testaGroupWin, &testaSession));
       
   992 		anotherGc=iView->BitmapContext();
       
   993 		if (err)
       
   994 			{
       
   995 			test(atestGc==anotherGc);
       
   996 			}
       
   997 		else
       
   998 			{
       
   999 			test(atestGc!=anotherGc);
       
  1000 			}
       
  1001 		Destroy();
       
  1002 		__UHEAP_SETFAIL(RHeap::ENone, 0);
       
  1003 		__UHEAP_MARKENDC(0);
       
  1004 		if (err == KErrNone)
       
  1005 			++consecutiveSuccesses;
       
  1006 		else
       
  1007 			consecutiveSuccesses = 0;
       
  1008 		}
       
  1009 	}
       
  1010 
       
  1011 
       
  1012 void CTextViewTest::TestGetPictureRectangleDefectL()
       
  1013 	{
       
  1014 	/*
       
  1015 	_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.");
       
  1016 	_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.");
       
  1017 	_LIT(KParagraphSmall,"CBusBase is an abstract base class for dynamic memory buffers. You can read or write bytes.");
       
  1018 	InitializeL();
       
  1019 	TInt length;
       
  1020 	iEtext->InsertL(0,KParagraphAverage);
       
  1021 	iView->HandleInsertDeleteL(TCursorSelection(0, KParagraphAverage().Length()), 0);
       
  1022 	iEtext->InsertL(KParagraphAverage().Length(),TChar(CEditableText::EParagraphDelimiter));
       
  1023 	iView->HandleCharEditL();
       
  1024 
       
  1025 	length=iEtext->LdDocumentLength();
       
  1026 	iEtext->InsertL(iEtext->LdDocumentLength(),KParagraphBigger);
       
  1027 	iView->HandleInsertDeleteL(TCursorSelection(length,KParagraphBigger().Length()), 0);
       
  1028 
       
  1029 	length=iEtext->LdDocumentLength();
       
  1030 	iEtext->InsertL(iEtext->LdDocumentLength(),KParagraphSmall);
       
  1031 	iView->HandleInsertDeleteL(TCursorSelection(length,KParagraphSmall().Length()), 0);
       
  1032 
       
  1033 	TSize size(100,100);
       
  1034 	TPoint xypos;
       
  1035 	CMyTestPicture* testpicture1 = CMyTestPicture::NewL(size);
       
  1036 	CMyTestPicture* testpicture2 = CMyTestPicture::NewL(size);
       
  1037 	CMyTestPicture* testpicture3 = CMyTestPicture::NewL(size);
       
  1038 	size.SetSize(200,200);
       
  1039 	CMyTestPicture* testpicture4 = CMyTestPicture::NewL(size);
       
  1040 	CMyTestPicture* testpicture5 = CMyTestPicture::NewL(size);
       
  1041 	CMyTestPicture* testpicture6 = CMyTestPicture::NewL(size);
       
  1042 	TPictureHeader mypic;
       
  1043 	TPictureHeader mypic2;
       
  1044 	//mypic.iPictureType = KUidXzePictureType;
       
  1045 	mypic.iPicture=testpicture1;
       
  1046 	mypic2.iPicture=testpicture2;
       
  1047 	// Testing the picture
       
  1048 
       
  1049 	iEtext->InsertL(10,mypic2);
       
  1050 	mypic2.iPicture=testpicture1;
       
  1051 	iEtext->InsertL(40,mypic2);
       
  1052 	iView->DocPosToXyPosL(200,xypos);
       
  1053 	test.Printf(_L("The xy coords are %d & %d\n"),xypos.iX,xypos.iY);
       
  1054 	xypos.SetXY(78,55);
       
  1055 	TInt docpos;
       
  1056 	docpos=iView->XyPosToDocPosL(xypos);
       
  1057 	test.Printf(_L("The new docpos is %d\n"),docpos);
       
  1058 	TRect rect;
       
  1059 	TBool boo;
       
  1060 	boo=iView->GetPictureRectangleL(40,rect);
       
  1061 	test.Printf(_L("%d & %d \n"),rect.Size().iHeight,rect.Size().iWidth);
       
  1062 	if (boo)
       
  1063 		test.Printf(_L("Yes!"));
       
  1064 	else
       
  1065 		test.Printf(_L("Noo!"));
       
  1066 	*/
       
  1067 	}
       
  1068 
       
  1069 void CTextViewTest::TestGetLineRectL()
       
  1070 	{
       
  1071 
       
  1072 	_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");
       
  1073 	// calls the initializeDiffCharFormatL to set the new CharFormatLayer
       
  1074 	// which sets the picture alignment to be Bottom.
       
  1075 	InitializeDiffCharFormatL();
       
  1076 	// create test pictures to be inserted into the richtext object
       
  1077 	TSize size(100,100);
       
  1078 	CMyTestPicture* testpicture1 = CMyTestPicture::NewL(size);
       
  1079 	TPictureHeader tPicHeader;
       
  1080 	tPicHeader.iPictureType = KUidXzePictureType;
       
  1081 	tPicHeader.iPicture = testpicture1;
       
  1082 	test.Printf(_L("Created a picture\n"));
       
  1083 
       
  1084 	// inserting some text & picture into the richtext object
       
  1085 	iEtext->InsertL(0,KSomeText);
       
  1086 	TInt startOfPicture;
       
  1087 	startOfPicture=iEtext->DocumentLength();
       
  1088 	iEtext->InsertL(startOfPicture,tPicHeader);
       
  1089 	test.Printf(_L("Inserted the picture in CRichText object \n"));
       
  1090 
       
  1091 	//Call the guilty function
       
  1092 	TRect resultingRect;
       
  1093 	TInt endOfDocument = iEtext->DocumentLength();
       
  1094 	iView->FormatTextL();
       
  1095 	resultingRect=iLayout->GetLineRectL(startOfPicture,endOfDocument);
       
  1096 	}
       
  1097 
       
  1098 void CTextViewTest::TestGetParaFormatL()
       
  1099 	{
       
  1100 	test.Next(_L("Starting GetParaFormatL test"));
       
  1101 	_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");
       
  1102 	InitializeL();
       
  1103 	// create the CParaFormat & TparaFormatMask
       
  1104 	// and set that in the iParaFormatLayer
       
  1105 	CParaFormat* paraFormat = CParaFormat::NewL();
       
  1106 	TParaFormatMask paraFormatMask;
       
  1107 	iParaLayer->SetL(paraFormat,paraFormatMask);
       
  1108 	iEtext->SetGlobalParaFormat(iParaLayer);
       
  1109 	iEtext->InsertL(0,KSomeText);
       
  1110 	iView->FormatTextL();
       
  1111 	// Create another CParaFormat & TParaFormatMask and set
       
  1112 	// some attributes to be different from the default.
       
  1113 	CParaFormat* anotherParaFormat = CParaFormat::NewL();
       
  1114 	TParaFormatMask anotherParaFormatMask;
       
  1115 	anotherParaFormat->iRightMarginInTwips=200;
       
  1116 	anotherParaFormatMask.SetAttrib(EAttRightMargin);
       
  1117 	anotherParaFormat->iLeftMarginInTwips=400;
       
  1118 	anotherParaFormatMask.SetAttrib(EAttLeftMargin);
       
  1119 	anotherParaFormat->iLineSpacingInTwips=300;
       
  1120 	anotherParaFormatMask.SetAttrib(EAttLineSpacing);
       
  1121 	anotherParaFormat->iHorizontalAlignment=CParaFormat::ERightAlign;
       
  1122 	anotherParaFormatMask.SetAttrib(EAttAlignment);
       
  1123 
       
  1124 	//Now call CRichText::GetParaFormat using anotherParaFormat * Mask
       
  1125 	// and test that it is the same as paraFormat.
       
  1126  	iEtext->GetParaFormatL(anotherParaFormat,anotherParaFormatMask,0,10);
       
  1127 
       
  1128 	TInt result = anotherParaFormat->iRightMarginInTwips;
       
  1129 	test (result==0);
       
  1130 
       
  1131 	result = anotherParaFormat->iLeftMarginInTwips;
       
  1132 	test (result==0);
       
  1133 	result = anotherParaFormat->iLineSpacingInTwips;
       
  1134 	test (result==200); // default value for iLineSpacingInTwips set in paraFormat is 200
       
  1135 	test (anotherParaFormat->iHorizontalAlignment == CParaFormat::ELeftAlign);
       
  1136 
       
  1137 	TBool testresult;
       
  1138 	testresult=anotherParaFormat->IsEqual(*paraFormat);
       
  1139 	test(testresult);
       
  1140 
       
  1141 	}
       
  1142 
       
  1143 
       
  1144 void CTextViewTest::TestForDEF003426L()
       
  1145 	{
       
  1146 	// Initialise CTextViewTest object for next test.
       
  1147 	InitializeL();
       
  1148 	test.Next(_L("Verifying CTextView::XyPosToDosPosL() WRT DEF003426"));
       
  1149 
       
  1150 	// Insert a one line paragraph into EText object and reformat view.
       
  1151 	_LIT(KTestParagraph, "This is a piece of text to test the character positioning API based in X,Y cocordinates.");
       
  1152 	iEtext->InsertL(0, KTestParagraph);
       
  1153 	TCursorSelection sel(0, KTestParagraph().Length());
       
  1154 	(void) iView->HandleInsertDeleteL(sel, 0, EFalse);
       
  1155 
       
  1156 	// Test XyPosToDocPosL() with coordinates beyond top left corner
       
  1157 	TInt docPos = -1;
       
  1158 	docPos = iView->XyPosToDocPosL(testaPoint);
       
  1159 	test(docPos == 0); // Should give char position of 0
       
  1160 
       
  1161 	// Test XyPosToDocPosL() with coordinates beyond bottom right corner
       
  1162 	TRect viewRect = iView->ViewRect();
       
  1163 	viewRect.iBr.iX += 300;
       
  1164 	viewRect.iBr.iY += 111;
       
  1165     docPos = iView->XyPosToDocPosL(viewRect.iBr);
       
  1166 	test(docPos != 0); // Should give char position of 88
       
  1167 
       
  1168 	// Clean up test object
       
  1169 	Destroy();
       
  1170 	}
       
  1171 
       
  1172 /*** Test code for DEF038858
       
  1173 	 " It isn't poss. to set via CTextView a TTmDocPos of iPos = 0; iLeadingEdge=false"
       
  1174  */
       
  1175 void CTextViewTest::TestForDEF038488L()
       
  1176 	{
       
  1177 	// Initialise CTextViewTest object for next test.
       
  1178 	InitializeL();
       
  1179 	test.Next(_L("Verifying CTextView::SetDocPosL() DEF038858"));
       
  1180 
       
  1181 	_LIT(KText, "This is the test for DEF038488");
       
  1182 	iEtext->InsertL(0, KText);
       
  1183 	iView->HandleInsertDeleteL(TCursorSelection(0, KText().Length()), 0);
       
  1184 
       
  1185 	// Test SetDocPosL() with coordinates -1
       
  1186 	iView->SetDocPosL(-1);
       
  1187 
       
  1188 	// check the value of iLeadingEdge
       
  1189 	TTmDocPos RawDocPos;
       
  1190 	iView->GetCursorPos(RawDocPos);
       
  1191 	test(RawDocPos.iLeadingEdge == EFalse);
       
  1192 
       
  1193 	}
       
  1194 
       
  1195 CTextViewTest::~CTextViewTest()
       
  1196 	{
       
  1197 	test.End();
       
  1198 	test.Close();
       
  1199 	delete iView;
       
  1200 	iWindow.Close();
       
  1201 	delete iLayout;
       
  1202 	delete iEtext;
       
  1203 	delete iCharLayer;
       
  1204 	delete iParaLayer;
       
  1205 	}
       
  1206 
       
  1207 /**
       
  1208 @SYMTestCaseID          SYSLIB-FORM-UT-1888
       
  1209 @SYMTestCaseDesc        Testing the Class TFormAndEtextEditor
       
  1210 @SYMTestPriority        Low
       
  1211 @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)
       
  1212 @SYMTestExpectedResults Tests must not fail
       
  1213 @SYMREQ                 REQ0000
       
  1214 */
       
  1215 void CTextViewTest::FormAndEtextTestL()
       
  1216 	{
       
  1217 	InitializeL();
       
  1218 	test.Next(_L(" @SYMTestCaseID:SYSLIB-FORM-UT-1888 Testing TFormAndEtextEditor "));
       
  1219 	TCharFormatMask charMask;
       
  1220     TCharFormat charFormat;
       
  1221 	charFormat.iFontSpec.iTypeface.iName = _S("Arial");
       
  1222     charFormat.iFontSpec.iHeight = 240;
       
  1223     charMask.SetAttrib(EAttFontTypeface);
       
  1224     charMask.SetAttrib(EAttFontHeight);
       
  1225     CCharFormatLayer* charFormatLayer = CCharFormatLayer::NewL();
       
  1226     charFormatLayer->SetL(charFormat,charMask);
       
  1227 	TParaFormatMask paraFormatMask;
       
  1228     CParaFormatLayer* paraFormatLayer=CParaFormatLayer::NewL((CParaFormat*)NULL,paraFormatMask);
       
  1229     CParagraphStyle* paraStyle = CParagraphStyle::NewL(*paraFormatLayer,*charFormatLayer);
       
  1230     CStyleList* styleList = CStyleList::NewL();
       
  1231     RParagraphStyleInfo paraStyleInfo(paraStyle,paraStyle);
       
  1232     paraStyleInfo.iStyle->iName=_L("Arial");
       
  1233     paraStyleInfo.iStyleForNextPara->iName=_L("Arial");
       
  1234     // Appending the new style to stylelist
       
  1235     styleList->AppendL(&paraStyleInfo);
       
  1236 
       
  1237 	iEtext->SetStyleListExternallyOwned(*styleList);
       
  1238 	iEtext->Reset();
       
  1239 	TFormAndEtextEditor newEditor(*iView,*iEtext);
       
  1240 
       
  1241 	TTmCharFormatLayer charLayer;
       
  1242 	TTmCharFormatLayer charLayer1;
       
  1243 	TTmCharFormatMask charIMask;
       
  1244 	TTmCharFormat charI;
       
  1245 	RTmParFormatLayer parLayer;
       
  1246 	RTmParFormatLayer parLayer1;
       
  1247 	TTmParFormatMask parNMask;
       
  1248 	charIMask.iFlags = TTmCharFormatMask::EItalic;
       
  1249 	TOpenFontFaceAttribBase attrib;
       
  1250 	attrib.SetBold(EFalse);
       
  1251 	charI.iFontSpec.SetAttrib(attrib);
       
  1252 	parNMask.iFlags = TTmParFormatMask::EKeepWithNext;
       
  1253 	RTmParFormat parN;
       
  1254 	parN.iFlags = RTmParFormat::EKeepWithNext;
       
  1255 	charLayer.iMask = charIMask;
       
  1256 	charLayer.iFormat = charI;
       
  1257 	charLayer1=charLayer;
       
  1258 	parLayer.iMask = parNMask;
       
  1259 
       
  1260 	parLayer.iFormat.CopyL(parN);
       
  1261 	TPtrC ptr1(_L("Arial"));
       
  1262 	// Inserting the text and applying the style specified(Arial)
       
  1263 	newEditor.InsertTextL(0, _L("Hello World"),&ptr1);
       
  1264 
       
  1265 	// Setting the paragraph and character format explicitly
       
  1266 	newEditor.SetParFormatL(0,11,parLayer);
       
  1267 	newEditor.SetCharFormatL(0,11,charLayer);
       
  1268 
       
  1269 	MUnifiedEditor::TFormatLevel level = MUnifiedEditor::EEffective;
       
  1270 	TInt runLen=11;
       
  1271 	// Getting the paragraph and character format
       
  1272 	newEditor.GetParFormatL(0,level,parLayer1,runLen);
       
  1273 	newEditor.GetCharFormat(0,level,charLayer1,runLen);
       
  1274 
       
  1275 	// Deleting first 6 characters
       
  1276 	newEditor.DeleteTextL(0,6);
       
  1277 	// Deleting the paragraph and character format for the remaining text
       
  1278 	newEditor.DeleteParFormatL(0,5);
       
  1279 	newEditor.DeleteCharFormatL(0,5);
       
  1280 
       
  1281 	TPtrC ptr;
       
  1282 	// Get the text into ptr. A paragraph seperator(\x2029) gets appended at the end of text.
       
  1283 	newEditor.GetText(0,ptr);
       
  1284 	test(ptr==_L("World\x2029"));
       
  1285 
       
  1286 	RTmStyle style1;
       
  1287 	RParagraphStyleInfo paraStyleInfo1(paraStyle,paraStyle);
       
  1288 	paraStyleInfo1.iStyle->iName=_L("NewStyle");
       
  1289 	paraStyleInfo1.iStyleForNextPara->iName=_L("NewStyle");
       
  1290 	style1.CopyL(paraStyleInfo1);
       
  1291 	// Creating a new style and changing the current style to the new one.
       
  1292 	newEditor.StyleSupport()->CreateStyleL(style1);
       
  1293 	newEditor.StyleSupport()->ChangeStyleL(style1);
       
  1294 
       
  1295 	RTmStyle style2;
       
  1296 	// Get the style by Name
       
  1297 	TInt retVal = newEditor.StyleSupport()->GetStyleByNameL(_L("Arial"),style2);
       
  1298 	retVal = newEditor.StyleSupport()->GetStyleByNameL(_L("NewStyle"),style2);
       
  1299 	// Get the style for a particular length of text
       
  1300 	newEditor.StyleSupport()->GetStyle(0,ptr,runLen);
       
  1301 	// Get the style by index
       
  1302 	retVal = newEditor.StyleSupport()->GetStyleByIndexL(1,style1);
       
  1303 	// Deleting the style
       
  1304 	newEditor.StyleSupport()->DeleteStyleL(_L("NewStyle"));
       
  1305 	retVal = newEditor.StyleCount();
       
  1306 	test(retVal==1);
       
  1307 	style1.Close();
       
  1308 	style2.Close();
       
  1309 	delete charFormatLayer;
       
  1310     delete paraFormatLayer;
       
  1311     delete styleList;
       
  1312 	}
       
  1313 
       
  1314 /**
       
  1315 @SYMTestCaseID          SYSLIB-FORM-UT-3347
       
  1316 @SYMTestCaseDesc        Testing the fix for INC092725: RF S60 3.2 Help: Touch and
       
  1317 						scrolling a topic down closing the program
       
  1318 @SYMTestPriority        High
       
  1319 @SYMTestActions         Run affected APIs passing scroll values that would put the display
       
  1320 						outside the formatted range.
       
  1321 @SYMTestExpectedResults First of all, the calls should not panic the process.
       
  1322 						Secondly, that the calls leave with the correct error code.
       
  1323 @SYMDEF                 INC092725
       
  1324 */
       
  1325 void CTextViewTest::TestForINC092725L()
       
  1326 	{
       
  1327 	test.Next(_L(" @SYMTestCaseID:SYSLIB-FORM-UT-3347 Testing fix for INC092725 "));
       
  1328 	TInt err = KErrNone;
       
  1329 	InitializeL();
       
  1330 	AddTextL(KHello);
       
  1331 
       
  1332 	//Scroll up
       
  1333 	iLayout->AdjustVerticalAlignment(CParaFormat::EAbsoluteRightAlign);
       
  1334 	TRAP(err, iView->ScrollDisplayL(TCursorPosition::EFLineUp, CTextLayout::EFAllowScrollingBlankSpace));
       
  1335 	test(err==CTextLayout::EPosNotFormatted);
       
  1336 	err=KErrNone;
       
  1337 
       
  1338 	//Scroll down
       
  1339 	iLayout->AdjustVerticalAlignment(CParaFormat::EAbsoluteLeftAlign);
       
  1340 	TRAP(err, iView->ScrollDisplayL(TCursorPosition::EFLineDown, CTextLayout::EFAllowScrollingBlankSpace));
       
  1341 	test(err==CTextLayout::EPosNotFormatted);
       
  1342 	err=KErrNone;
       
  1343 
       
  1344 	//Line scroll up
       
  1345 	TInt i = 105;
       
  1346 	iLayout->AdjustVerticalAlignment(CParaFormat::EAbsoluteRightAlign);
       
  1347 	TRAP(err, iView->ScrollDisplayLinesL(i, CTextLayout::EFAllowScrollingBlankSpace));
       
  1348 	test(err==CTextLayout::EPosNotFormatted);
       
  1349 	err=KErrNone;
       
  1350 
       
  1351 	//Line scroll down
       
  1352 	i = -105;
       
  1353 	iLayout->AdjustVerticalAlignment(CParaFormat::EAbsoluteLeftAlign);
       
  1354 	TRAP(err, iView->ScrollDisplayLinesL(i, CTextLayout::EFAllowScrollingBlankSpace));
       
  1355 	test(err==CTextLayout::EPosNotFormatted);
       
  1356 	err=KErrNone;
       
  1357 
       
  1358 	//Paragraph scroll up
       
  1359 	i = 105;
       
  1360 	iLayout->AdjustVerticalAlignment(CParaFormat::EAbsoluteRightAlign);
       
  1361 	TRAP(err, iView->ScrollDisplayParagraphsL(i, CTextLayout::EFAllowScrollingBlankSpace));
       
  1362 	test(err==CTextLayout::EPosNotFormatted);
       
  1363 	err=KErrNone;
       
  1364 
       
  1365 	//Paragraph scroll down
       
  1366 	i = -105;
       
  1367 	iLayout->AdjustVerticalAlignment(CParaFormat::EAbsoluteLeftAlign);
       
  1368 	TRAP(err, iView->ScrollDisplayParagraphsL(i, CTextLayout::EFAllowScrollingBlankSpace));
       
  1369 	test(err==CTextLayout::EPosNotFormatted);
       
  1370 	Destroy();
       
  1371 	}
       
  1372 
       
  1373 
       
  1374 class CTestScreenDevice : public CPrinterDevice
       
  1375 	{
       
  1376 public:
       
  1377     CTestScreenDevice(CWsScreenDevice* aDevice,RDrawableWindow& aWin);
       
  1378 	TDisplayMode DisplayMode() const {return iDevice->DisplayMode();}
       
  1379 	TSize SizeInPixels() const {return iDevice->SizeInPixels();}
       
  1380 	TSize SizeInTwips() const {return iDevice->SizeInTwips();}
       
  1381     TInt NumTypefaces() const {return iDevice->NumTypefaces();}
       
  1382     void TypefaceSupport(TTypefaceSupport& aTypefaceSupport,TInt aTypefaceIndex) const
       
  1383 										{iDevice->TypefaceSupport(aTypefaceSupport,aTypefaceIndex);}
       
  1384 	TInt FontHeightInTwips(TInt aTypefaceIndex,TInt aHeightIndex) const
       
  1385 									{return iDevice->FontHeightInTwips(aTypefaceIndex,aHeightIndex);}
       
  1386 	void PaletteAttributes(TBool& aModifiable,TInt& aNumEntries) const
       
  1387 												{iDevice->PaletteAttributes(aModifiable,aNumEntries);}
       
  1388 	void SetPalette(CPalette* aPalette) {iDevice->SetPalette(aPalette);}
       
  1389 	TInt GetPalette(CPalette*& aPalette) const {return iDevice->GetPalette(aPalette);}
       
  1390  	TInt CreateContext(CGraphicsContext *&aGc);
       
  1391 	TInt HorizontalTwipsToPixels(TInt aTwips) const {return iDevice->HorizontalTwipsToPixels(aTwips);};
       
  1392 	TInt VerticalTwipsToPixels(TInt aTwips) const {return iDevice->VerticalTwipsToPixels(aTwips);};
       
  1393 	TInt HorizontalPixelsToTwips(TInt aPixels) const {return iDevice->HorizontalPixelsToTwips(aPixels);};
       
  1394 	TInt VerticalPixelsToTwips(TInt aPixels) const {return iDevice->VerticalPixelsToTwips(aPixels);};
       
  1395 	TInt GetNearestFontInTwips(CFont*& aFont,const TFontSpec& aFontSpec) {return iDevice->GetNearestFontInTwips(aFont,aFontSpec);};
       
  1396 	void ReleaseFont(CFont* aFont) {iDevice->ReleaseFont(aFont);};
       
  1397 	TPrinterModelName ModelName() const {return _L("");}
       
  1398 	TUid ModelUid() const {TUid dummy; return dummy;}
       
  1399 	void CreateControlL(CPrinterPort* /*aPrinterPort*/) {}
       
  1400 	TPrinterModelEntry Model() const {return iModel;}
       
  1401 	TInt SetModel(const TPrinterModelHeader& /*aModel*/,CStreamStore& /*aStore*/) {return KErrNone;}
       
  1402 	TBool RequiresPrinterPort() {return EFalse;}
       
  1403 private:
       
  1404 	RDrawableWindow& iWin;
       
  1405 	CWsScreenDevice* iDevice;
       
  1406 	TPrinterModelEntry iModel;
       
  1407 	};
       
  1408 
       
  1409 CTestScreenDevice::CTestScreenDevice(CWsScreenDevice* aDevice,RDrawableWindow& aWin):
       
  1410 	iWin(aWin)
       
  1411 	{
       
  1412 	iDevice=aDevice;
       
  1413 	iModel.iUid=TUid::Null();
       
  1414 	}
       
  1415 
       
  1416 TInt CTestScreenDevice::CreateContext(CGraphicsContext*& aGc)
       
  1417 	{
       
  1418 
       
  1419 	TInt ret=iDevice->CreateContext(aGc);
       
  1420 	((CWindowGc *) aGc)->Activate(iWin);
       
  1421 	return ret;
       
  1422 	}
       
  1423 
       
  1424 /**
       
  1425 @SYMTestCaseID          SYSLIB-FORM-UT-3496
       
  1426 @SYMTestCaseDesc        Testing the fix for PDEF108443: Two same content pages are printed when contact fields are exactly one page long
       
  1427 @SYMTestPriority        Medium
       
  1428 @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.
       
  1429 @SYMTestExpectedResults Results should be 1 page, 1 page and 2 pages respectively.
       
  1430 @SYMDEF                 PDEF108443
       
  1431 */
       
  1432 void CTextViewTest::TestForPDEF108443L()
       
  1433 	{
       
  1434 	test.Next(_L(" @SYMTestCaseID:SYSLIB-FORM-UT-3496 Testing fix for PDEF108443 "));
       
  1435 	CTestScreenDevice* screenDevice = new(ELeave) CTestScreenDevice(iEnv.ScreenDevice(),iWindow);
       
  1436 
       
  1437 	TMargins margins;
       
  1438 	margins.iTop = 1440;
       
  1439 	margins.iBottom = 1440;
       
  1440 	margins.iLeft = 1440;
       
  1441 	margins.iRight = 1440;
       
  1442 	TSize s(11906,16838);
       
  1443 	TPageSpec p(TPageSpec::EPortrait, s);
       
  1444 
       
  1445 	CArrayFixFlat<TInt>* charsPerPage1 = new(ELeave) CArrayFixFlat<TInt>(KGranularity);
       
  1446 	CTextPaginator* paginator1 = CTextPaginator::NewL(screenDevice, charsPerPage1, KPaginatePriority);
       
  1447 	paginator1->SetPageMarginsInTwips(margins);
       
  1448 	paginator1->SetPageSpecInTwips(p);
       
  1449 
       
  1450 	CArrayFixFlat<TInt>* charsPerPage2 = new(ELeave) CArrayFixFlat<TInt>(KGranularity);
       
  1451 	CTextPaginator* paginator2 = CTextPaginator::NewL(screenDevice, charsPerPage2, KPaginatePriority);
       
  1452 	paginator2->SetPageMarginsInTwips(margins);
       
  1453 	paginator2->SetPageSpecInTwips(p);
       
  1454 
       
  1455 	CArrayFixFlat<TInt>* charsPerPage3 = new(ELeave) CArrayFixFlat<TInt>(KGranularity);
       
  1456 	CTextPaginator* paginator3 = CTextPaginator::NewL(screenDevice, charsPerPage3, KPaginatePriority);
       
  1457 	paginator3->SetPageMarginsInTwips(margins);
       
  1458 	paginator3->SetPageSpecInTwips(p);
       
  1459 
       
  1460 
       
  1461 	// We need to find out the height of lines and print area of the page.
       
  1462 	// From this we determine how many lines *should* appear on the page.
       
  1463 	// This differs between devices(ie. hw and winscw).
       
  1464 	TRect textRect;
       
  1465 	textRect.iTl.iX=margins.iLeft;
       
  1466 	textRect.iTl.iY=margins.iTop;
       
  1467 	textRect.iBr.iX=s.iWidth-margins.iRight;
       
  1468 	textRect.iBr.iY=s.iHeight-margins.iBottom;
       
  1469 	
       
  1470 	textRect = screenDevice->TwipsToPixels(textRect);  //defect 131765, call the same func as paginator
       
  1471 	TInt pageHeight =  textRect.Height();
       
  1472 	_LIT(KDummyString,"AAAAAA");
       
  1473 	InitializeL();
       
  1474 	AddTextL(KDummyString);
       
  1475 	TInt lineHeight = 0;
       
  1476 	CParaFormat* paraFormat = CParaFormat::NewL();
       
  1477 	iEtext->GetParagraphFormatL(paraFormat,0);
       
  1478 	TBool pageBreakChar = EFalse;
       
  1479 	TInt docPos = 0;
       
  1480 	iLayout->FormatLineL(paraFormat,docPos,lineHeight,pageBreakChar);
       
  1481 
       
  1482 
       
  1483 	TInt numLines = pageHeight/lineHeight; // Number of lines expected on a page with paginator settings defined above and line height = 21
       
  1484 	TChar simpleChar('A');
       
  1485 	TBuf<200> string1;
       
  1486 	for (TInt i = 0; i < numLines-2; i++) // ...numlines - 1
       
  1487 		{
       
  1488 		string1.Append(simpleChar);
       
  1489 		string1.Append(CEditableText::EParagraphDelimiter);
       
  1490 		}
       
  1491 		string1.Append(simpleChar); // final line
       
  1492 	TBuf<200> string2;
       
  1493 	for (TInt i = 0; i < numLines-1; i++) // ...numlines
       
  1494 		{
       
  1495 		string2.Append(simpleChar);
       
  1496 		string2.Append(CEditableText::EParagraphDelimiter);
       
  1497 		}
       
  1498 		string2.Append(simpleChar); // final line
       
  1499 	TBuf<200> string3;
       
  1500 	for (TInt i = 0; i < numLines; i++) // ...numlines + 1
       
  1501 		{
       
  1502 		string3.Append(simpleChar);
       
  1503 		string3.Append(CEditableText::EParagraphDelimiter);
       
  1504 		}
       
  1505 		string3.Append(simpleChar); // final line
       
  1506 
       
  1507 	InitializeL();
       
  1508 	AddTextL(string1);
       
  1509 	paginator1->SetDocumentL(iEtext);
       
  1510 	docPos=0;
       
  1511 	paginator1->AppendTextL(docPos);
       
  1512 	TInt numPages=paginator1->PaginationCompletedL();
       
  1513 	test(numPages==1);
       
  1514 	InitializeL();
       
  1515 	AddTextL(string2);
       
  1516 	paginator2->SetDocumentL(iEtext);
       
  1517 	docPos=0;
       
  1518 	paginator2->AppendTextL(docPos);
       
  1519 	numPages=paginator2->PaginationCompletedL();
       
  1520 	test(numPages==1);
       
  1521 	InitializeL();
       
  1522 	AddTextL(string3);
       
  1523 	paginator3->SetDocumentL(iEtext);
       
  1524 	docPos=0;
       
  1525 	paginator3->AppendTextL(docPos);
       
  1526 	numPages=paginator3->PaginationCompletedL();
       
  1527 	test(numPages==2);
       
  1528 
       
  1529 	delete charsPerPage1;
       
  1530 	delete charsPerPage2;
       
  1531 	delete charsPerPage3;
       
  1532 	delete screenDevice;
       
  1533 	delete paraFormat;
       
  1534 	Destroy();
       
  1535 	}
       
  1536 
       
  1537 /**
       
  1538 @SYMTestCaseID          SYSLIB-FORM-UT-4002
       
  1539 @SYMTestCaseDesc	    Test to ensure the CTextView::SetSelectionVisibilityL will not panic when EFTextVisible
       
  1540 						is set off.
       
  1541 @SYMTestPriority 	    Normal
       
  1542 @SYMTestActions  	    Create a CTextView instance with EFTextVisible set off. Call SetSelectionVisibilityL(ETrue)
       
  1543 						and SetSelectionVisibilityL(EFalse).
       
  1544 @SYMTestExpectedResults	Given conditions in test actions, calling SetSelectionVisibilityL should not panic.
       
  1545 @SYMDEF                 PDEF113755
       
  1546 */
       
  1547 void CTextViewTest::TestForPDEF113755L()
       
  1548 	{
       
  1549 	test.Next(_L(" @SYMTestCaseID:SYSLIB-FORM-UT-4002 Testing fix for PDEF113755 "));
       
  1550 	InitializeL();
       
  1551 
       
  1552 	TCursorSelection selection(0,8); // length of selection must be >0
       
  1553 	iView->SetSelectionL(selection);
       
  1554 
       
  1555 	iView->MakeVisible(ETrue);	//Test if the EFSelectionVisible flag is set correctly
       
  1556 	iView->SetSelectionVisibilityL(ETrue);
       
  1557 	test(iView->SelectionVisible());
       
  1558 	iView->SetSelectionVisibilityL(EFalse);
       
  1559 	test(!iView->SelectionVisible());
       
  1560 
       
  1561 	iView->MakeVisible(EFalse);
       
  1562 	iView->SetSelectionVisibilityL(ETrue); //Should never panic form::1200 here
       
  1563 	iView->SetSelectionVisibilityL(EFalse);
       
  1564 
       
  1565 	Destroy();
       
  1566 	}
       
  1567 
       
  1568 /**
       
  1569 @SYMTestCaseID          SYSLIB-FORM-UT-4004
       
  1570 @SYMTestCaseDesc	    Test for INC113143, to ensure CTextLayout::GetLineRectL returns the correct rectangle
       
  1571 						regarding the writting direction of text. Depend on Platform: WINSCW/H4/H6(DEF131765).
       
  1572 @SYMTestPriority 	    Normal
       
  1573 @SYMTestActions  	    Tested 16 scenarios that the CTextLayout::GetLineRectL could be call, also tested for
       
  1574 						edge cases such as 1 char, whole line, DocPos2 < DocPos1, etc..
       
  1575 @SYMTestExpectedResults CTextLayout::GetLineRectL should return expected rectangles.
       
  1576 @SYMDEF                 PDEF115165
       
  1577 */
       
  1578 void CTextViewTest::TestForPDEF115165L()
       
  1579 	{
       
  1580 	test.Next(_L(" @SYMTestCaseID:SYSLIB-FORM-UT-4004 Testing fix for PDEF115165 "));
       
  1581 	InitializeL();
       
  1582 
       
  1583 	TCharFormat charFormat = TCharFormat(_L("Arial"),100);
       
  1584 	TCharFormatMask charFormatMask;
       
  1585 	charFormatMask.SetAll();
       
  1586 	iCharLayer->SetL(charFormat, charFormatMask);
       
  1587 	iEtext->SetGlobalCharFormat(iCharLayer);
       
  1588 
       
  1589 	_LIT(KLtoRText,"aaa");
       
  1590 	_LIT(KRtoLText,"\x6B2\x6B2\x6B2");
       
  1591 	_LIT(KLtoRTextLong,"aaaaaaaaaaaa");
       
  1592 	_LIT(KLtoRTextLong2,"aaaaaaaaaaaaaaa");
       
  1593 	_LIT(KRtoLTextLong,"\x6B2\x6B2\x6B2\x6B2\x6B2\x6B2\x6B2\x6B2\x6B2\x6B2\x6B2\x6B2"); //12 char
       
  1594 	_LIT(KRtoLTextLong2,"\x6B2\x6B2\x6B2\x6B2\x6B2\x6B2\x6B2\x6B2\x6B2\x6B2\x6B2\x6B2\x6B2\x6B2\x6B2"); //15 char
       
  1595 	_LIT(KLtoRTextVeryLong,"aaaaaaaaaaaaaaaaaaaa"); // 20 characters
       
  1596 	_LIT(KLtoRTextVeryLong2,"aaaaaaaaaaaaaaaaaaaaaaaaa"); // 25 characters
       
  1597 	_LIT(KRtoLTextVeryLong,"\x6B2\x6B2\x6B2\x6B2\x6B2\x6B2\x6B2\x6B2\x6B2\x6B2\x6B2\x6B2\x6B2\x6B2\x6B2\x6B2\x6B2\x6B2\x6B2\x6B2"); //20 char
       
  1598 	_LIT(KRtoLTextVeryLong2,"\x6B2\x6B2\x6B2\x6B2\x6B2\x6B2\x6B2\x6B2\x6B2\x6B2\x6B2\x6B2\x6B2\x6B2\x6B2\x6B2\x6B2\x6B2\x6B2\x6B2\x6B2\x6B2\x6B2\x6B2\x6B2"); //25 char
       
  1599 	_LIT(KParaSep, "\x2029");
       
  1600 
       
  1601 	TRect rect;
       
  1602 
       
  1603 //  Test for 16 scenarios of Bidi texts..
       
  1604 //	Sample text for test
       
  1605 //	Doc_Pos:    | 0| 1| 2| 5| 4| 3| 6| 7| 8|11|10| 9|
       
  1606 //	X-Coords:  |0| 5|10|15|20|25|30|35|40|45|50|55|60|  in case w=5
       
  1607 
       
  1608 	iEtext->Reset();
       
  1609 	iEtext->InsertL(0,KLtoRText);
       
  1610 	iEtext->InsertL(iEtext->DocumentLength(),KRtoLText);
       
  1611 	iEtext->InsertL(iEtext->DocumentLength(),KLtoRText);
       
  1612 	iEtext->InsertL(iEtext->DocumentLength(),KRtoLText);
       
  1613 	iEtext->InsertL(iEtext->DocumentLength(),KParaSep);
       
  1614 	iView->FormatTextL();
       
  1615 
       
  1616 	TPoint point1,point2;
       
  1617 	iLayout->DocPosToXyPosL(0,point1);
       
  1618 	iLayout->DocPosToXyPosL(1,point2);
       
  1619 	
       
  1620 	TInt w = point2.iX - point1.iX;		//It depends on platform. WINSCW/H4 w=5; H6 w=4
       
  1621 	
       
  1622 //	DocPos1 is LTR, DocPos1+1 is LTR, DocPos2 is LTR, DocPos2+1 is LTR
       
  1623 	rect = iLayout->GetLineRectL(0,7);
       
  1624 	test(rect.iTl.iX == 0 && rect.iBr.iX == 8*w);
       
  1625 
       
  1626 //	DocPos1 is LTR, DocPos1+1 is LTR, DocPos2 is LTR, DocPos2+1 is RTL
       
  1627 	rect = iLayout->GetLineRectL(0,2);
       
  1628 	test(rect.iTl.iX == 0 && rect.iBr.iX == 3*w);
       
  1629 
       
  1630 //	DocPos1 is LTR, DocPos1+1 is LTR, DocPos2 is RTL, DocPos2+1 is LTR
       
  1631 	rect = iLayout->GetLineRectL(0,5);
       
  1632 	test(rect.iTl.iX == 0 && rect.iBr.iX == 4*w);
       
  1633 
       
  1634 //	DocPos1 is LTR, DocPos1+1 is LTR, DocPos2 is RTL, DocPos2+1 is RTL
       
  1635 	rect = iLayout->GetLineRectL(0,4);
       
  1636 	test(rect.iTl.iX == 0 && rect.iBr.iX == 5*w);
       
  1637 
       
  1638 //	DocPos1 is LTR, DocPos1+1 is RTL, DocPos2 is LTR, DocPos2+1 is LTR
       
  1639 	rect = iLayout->GetLineRectL(2,7);
       
  1640 	test(rect.iTl.iX == 2*w && rect.iBr.iX == 8*w);
       
  1641 
       
  1642 //	DocPos1 is LTR, DocPos1+1 is RTL, DocPos2 is LTR, DocPos2+1 is RTL
       
  1643 	rect = iLayout->GetLineRectL(2,8);
       
  1644 	test(rect.iTl.iX == 2*w && rect.iBr.iX == 9*w);
       
  1645 
       
  1646 //	DocPos1 is LTR, DocPos1+1 is RTL, DocPos2 is RTL, DocPos2+1 is LTR
       
  1647 	rect = iLayout->GetLineRectL(2,5);
       
  1648 	test(rect.iTl.iX == 2*w && rect.iBr.iX == 4*w);
       
  1649 
       
  1650 //	DocPos1 is LTR, DocPos1+1 is RTL, DocPos2 is RTL, DocPos2+1 is RTL
       
  1651 	rect = iLayout->GetLineRectL(2,4);
       
  1652 	test(rect.iTl.iX == 2*w && rect.iBr.iX == 5*w);
       
  1653 
       
  1654 //	Sample text for test
       
  1655 //	Doc_Pos:     | 9|10|11| 8| 7| 6| 3| 4| 5| 2| 1| 0|
       
  1656 //	X-Coords:  |40|45|50|55|60|65|70|75|80|85|90|95|100|     in case w=5
       
  1657 
       
  1658 	iEtext->Reset();
       
  1659 	iEtext->InsertL(0,KRtoLText);
       
  1660 	iEtext->InsertL(iEtext->DocumentLength(),KLtoRText);
       
  1661 	iEtext->InsertL(iEtext->DocumentLength(),KRtoLText);
       
  1662 	iEtext->InsertL(iEtext->DocumentLength(),KLtoRText);
       
  1663 	iEtext->InsertL(iEtext->DocumentLength(),KParaSep);
       
  1664 	iView->FormatTextL();
       
  1665 	
       
  1666 //	DocPos1 is RTL, DocPos1+1 is LTR, DocPos2 is LTR, DocPos2+1 is LTR
       
  1667 	rect = iLayout->GetLineRectL(2,4);
       
  1668 	test(rect.iTl.iX == (75/5-20)*w+100 && rect.iBr.iX == (90/5-20)*w+100);
       
  1669 			
       
  1670 //	DocPos1 is RTL, DocPos1+1 is LTR, DocPos2 is LTR, DocPos2+1 is RTL
       
  1671 	rect = iLayout->GetLineRectL(2,5);
       
  1672 	test(rect.iTl.iX == (80/5-20)*w+100 && rect.iBr.iX == (90/5-20)*w+100);
       
  1673 
       
  1674 //	DocPos1 is RTL, DocPos1+1 is LTR, DocPos2 is RTL, DocPos2+1 is LTR
       
  1675 	rect = iLayout->GetLineRectL(2,8);
       
  1676 	test(rect.iTl.iX == (55/5-20)*w+100 && rect.iBr.iX == (90/5-20)*w+100);
       
  1677 
       
  1678 //	DocPos1 is RTL, DocPos1+1 is LTR, DocPos2 is RTL, DocPos2+1 is RTL
       
  1679 	rect = iLayout->GetLineRectL(2,7);
       
  1680 	test(rect.iTl.iX == (60/5-20)*w+100 && rect.iBr.iX == (90/5-20)*w+100);
       
  1681 
       
  1682 //	DocPos1 is RTL, DocPos1+1 is RTL, DocPos2 is LTR, DocPos2+1 is LTR
       
  1683 	rect = iLayout->GetLineRectL(0,4);
       
  1684 	test(rect.iTl.iX == (75/5-20)*w+100 && rect.iBr.iX == 100);
       
  1685 
       
  1686 //	DocPos1 is RTL, DocPos1+1 is RTL, DocPos2 is LTR, DocPos2+1 is RTL
       
  1687 	rect = iLayout->GetLineRectL(0,5);
       
  1688 	test(rect.iTl.iX == (80/5-20)*w+100 && rect.iBr.iX == 100);
       
  1689 
       
  1690 //	DocPos1 is RTL, DocPos1+1 is RTL, DocPos2 is RTL, DocPos2+1 is LTR
       
  1691 	rect = iLayout->GetLineRectL(0,8);
       
  1692 	test(rect.iTl.iX == (55/5-20)*w+100 && rect.iBr.iX == 100);
       
  1693 
       
  1694 //	DocPos1 is RTL, DocPos1+1 is RTL, DocPos2 is RTL, DocPos2+1 is RTL
       
  1695 	rect = iLayout->GetLineRectL(0,7);
       
  1696 	test(rect.iTl.iX == (60/5-20)*w+100 && rect.iBr.iX == 100);
       
  1697 	
       
  1698 	STestDataTInt4 DataEmH4[] = {
       
  1699 			{0,12,0,100 },{20,24,0,20},{0,0,0,5},{12,12,95,100},{7,7,35,40},
       
  1700 			{7,12,35,100},{13,20,95,100},{10,9,50,100},
       
  1701 			{3,19,15,100},{20,38,5,100},{19,19,95,100},{20,20,95,100},{19,20,95,100},
       
  1702 	};
       
  1703 	STestDataTInt4 DataH6[] = {
       
  1704 			{0,15,0,100}, {25,30,0,20},{0,0,0,4},{15,15,96,100},{7,7,28,32},
       
  1705 			{7,15,28,100},{16,25,96,100},{10,9,40,100},
       
  1706 			{3,24,12,100},{25,48,4,100}, {24,24,96,100},{25,25,96,100},{24,25,96,100},
       
  1707 	};
       
  1708 	
       
  1709 	test(sizeof(DataEmH4)/sizeof(STestDataTInt4) == sizeof(DataH6)/sizeof(STestDataTInt4));
       
  1710 	
       
  1711 	STestDataTInt4 *testdata;
       
  1712 	TPtrC pLtoRTextLong;
       
  1713 	TPtrC pRtoLTextLong;
       
  1714 	TPtrC pLtoRTextVeryLong;
       
  1715 	TPtrC pRtoLTextVeryLong;
       
  1716 	
       
  1717 	if(w == 5)// for WINSCW(Em) and H4
       
  1718 		{
       
  1719 		testdata = DataEmH4;
       
  1720 		pLtoRTextLong.Set(KLtoRTextLong);
       
  1721 		pRtoLTextLong.Set(KRtoLTextLong);
       
  1722 		pLtoRTextVeryLong.Set(KLtoRTextVeryLong);
       
  1723 		pRtoLTextVeryLong.Set(KRtoLTextVeryLong);
       
  1724 		}
       
  1725 	else if (w == 4)  // for H6
       
  1726 		{
       
  1727 		testdata = DataH6;
       
  1728 		pLtoRTextLong.Set(KLtoRTextLong2);
       
  1729 		pRtoLTextLong.Set(KRtoLTextLong2);
       
  1730 		pLtoRTextVeryLong.Set(KLtoRTextVeryLong2);
       
  1731 		pRtoLTextVeryLong.Set(KRtoLTextVeryLong2);
       
  1732 		}
       
  1733 	else
       
  1734 		{
       
  1735 		test(0);
       
  1736 		Destroy();
       
  1737 		return;
       
  1738 		}
       
  1739 	
       
  1740 //	Edge case tests
       
  1741 //	Sample text
       
  1742 //	1st Line:    | 0| 1| 2| 3| 4| 5| 6| 7| 8| 9|10|11|19|18|17|16|15|14|13|12|
       
  1743 //	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
       
  1744 //	2nd Line:    |23|22|21|20|
       
  1745 	
       
  1746 //	Edge case tests
       
  1747 //	Sample text
       
  1748 //	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|
       
  1749 //	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
       
  1750 //	2nd Line:    |29|28|27|26|25|24|23|22|21|20|
       
  1751 	
       
  1752 	iEtext->Reset();
       
  1753 	iEtext->InsertL(0,pLtoRTextLong);
       
  1754 	iEtext->InsertL(iEtext->DocumentLength(),pRtoLTextLong);	
       
  1755 	iEtext->InsertL(iEtext->DocumentLength(),KParaSep);
       
  1756 	iView->FormatTextL();
       
  1757 
       
  1758 	for (TInt i = 0; i < 8;i++)
       
  1759 		{
       
  1760 		//	Test for whole line i=0 to 1
       
  1761 		//	Test for one char   i=2 to 4
       
  1762 		//	Test for DocPos2 at the end of line  i=5
       
  1763 		//	Test for DocPos2 at a different line i=6
       
  1764 		//	Test for DocPos2 < DocPos1			 i=7
       
  1765 		rect = iLayout->GetLineRectL(testdata[i].iDoc1,testdata[i].iDoc2);
       
  1766 		test.Printf(_L("GetLineRect edge test i=%d \n"),i);
       
  1767 		test(rect.iTl.iX == testdata[i].iPos1 && rect.iBr.iX == testdata[i].iPos2); //Line 1
       
  1768 		}
       
  1769 			
       
  1770 //	Test for edge cases while two lines are in different direction
       
  1771 //	Sample text
       
  1772 //	1st Line:    | 0| 1| 2| 3| 4| 5| 6| 7| 8| 9|10|11|12|13|14|15|16|17|18|19|
       
  1773 //	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
       
  1774 //	2nd Line:    |39|38|37|36|35|34|33|32|31|30|29|28|27|26|25|24|23|22|21|20|
       
  1775 		
       
  1776 //	Test for edge cases while two lines are in different direction
       
  1777 //  Sample text
       
  1778 //	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|
       
  1779 //	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
       
  1780 //	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|
       
  1781 	iEtext->Reset();
       
  1782 	iEtext->InsertL(0,pLtoRTextVeryLong);
       
  1783 	iEtext->InsertL(iEtext->DocumentLength(),pRtoLTextVeryLong);
       
  1784 	iEtext->InsertL(iEtext->DocumentLength(),KParaSep);
       
  1785 	iView->FormatTextL();
       
  1786 
       
  1787 	for (TInt i = 8; i < 13; i++)
       
  1788 		{
       
  1789 		rect = iLayout->GetLineRectL(testdata[i].iDoc1,testdata[i].iDoc2);
       
  1790 		test.Printf(_L("GetLineRect edge test i=%d \n"),i);
       
  1791 		test(rect.iTl.iX == testdata[i].iPos1 && rect.iBr.iX == testdata[i].iPos2); //Line 1
       
  1792 		}	
       
  1793 	Destroy();
       
  1794 	}
       
  1795 
       
  1796 /**
       
  1797 @SYMTestCaseID          SYSLIB-FORM-UT-4007
       
  1798 @SYMTestCaseDesc	    Test for PDEF118443
       
  1799 @SYMTestPriority 	    Normal
       
  1800 @SYMTestActions			Use test cases in form of "text + ZWJ + non-text characters", format the line,
       
  1801  						then use CTmTextLayout::FindAdjacentChunks() to find text Chunks surrounding
       
  1802  						the ZWJ. then verify if the text is broken at the correct place.
       
  1803 @SYMTestExpectedResults CTmTextLayout::FindAdjacentChunks() should return:
       
  1804 						- Left chunk = "text + ZWJ",
       
  1805 						- Right chunk = "non-text characters".
       
  1806 @SYMDEF                 PDEF118443
       
  1807 */
       
  1808 void CTextViewTest::TestForPDEF118443L()
       
  1809 	{
       
  1810 	test.Next(_L(" @SYMTestCaseID:SYSLIB-FORM-UT-4007 Testing fix for PDEF118443 "));
       
  1811 	InitializeL();
       
  1812 
       
  1813 	TCharFormat charFormat = TCharFormat(_L("ClearlyU"),10);
       
  1814 	TCharFormatMask charFormatMask;
       
  1815 	charFormatMask.SetAll();
       
  1816 	iCharLayer->SetL(charFormat, charFormatMask);
       
  1817 	iEtext->SetGlobalCharFormat(iCharLayer);
       
  1818 
       
  1819 	// Note: a 'W' is added at the front to make the text chunk have side-bearings, so that it won't be amalgamated
       
  1820 	// with the following chunk. This is to make the test case be as same as the original use case that caused the defect.
       
  1821 	_LIT(KScriptEndWithZWJ,"W\x0931\x094d\x200d");	// Scripte end with ZWJ (a 'W' in the front)
       
  1822 	_LIT(KTextTestCase0,"\x2029");	// Paragraph seperator (Bidi Category: B)
       
  1823 	_LIT(KTextTestCase1,"0");		// Digit 0 (Bidi Category: EN)
       
  1824 	_LIT(KTextTestCase2,"+");		// Plus sign (Bidi Category: ES)
       
  1825 	_LIT(KTextTestCase3,"\u00A3");		// Pound symbol (Bidi Category: ET)
       
  1826 	_LIT(KTextTestCase4,".");		// Period (Bidi Category: CS)
       
  1827 	_LIT(KTextTestCase5,"\x0009");	// Tab (Bidi Category: S)
       
  1828 	_LIT(KTextTestCase6,"\x0020");	// Space (Bidi Category: WS)
       
  1829 	_LIT(KTextTestCase7,"\x000C");	// Form feed (Bidi Category: WS)
       
  1830 	_LIT(KTextTestCase8,"\x2028");	// Line breaker (Bidi Category: WS)
       
  1831 
       
  1832 	TTmDocPosSpec pos(4, TTmDocPosSpec::ETrailing);
       
  1833 	CTmTextLayout::TTmChunkDescription left;
       
  1834 	CTmTextLayout::TTmChunkDescription right;
       
  1835 
       
  1836 	// Test case 0: ZWJ + Paragraph seperater
       
  1837 	iEtext->Reset();
       
  1838 	iEtext->InsertL(0,KScriptEndWithZWJ);
       
  1839 	iEtext->InsertL(iEtext->DocumentLength(),KTextTestCase0);
       
  1840 	iView->FormatTextL();
       
  1841 	iLayout->TagmaTextLayout().FindAdjacentChunks(pos, left, right);
       
  1842 	test(left.iStart == 0);
       
  1843 	test(left.iEnd == 4);
       
  1844 	test(left.iRightToLeft == EFalse);
       
  1845 	test(right.iStart == 4);
       
  1846 	test(right.iRightToLeft == EFalse);
       
  1847 
       
  1848 	// Test case 1: ZWJ + Digit '0'
       
  1849 	iEtext->Reset();
       
  1850 	iEtext->InsertL(0,KScriptEndWithZWJ);
       
  1851 	iEtext->InsertL(iEtext->DocumentLength(),KTextTestCase1);
       
  1852 	iView->FormatTextL();
       
  1853 	iLayout->TagmaTextLayout().FindAdjacentChunks(pos, left, right);
       
  1854 	test(left.iStart == 0);
       
  1855 	test(left.iEnd == 4);
       
  1856 	test(left.iRightToLeft == EFalse);
       
  1857 	test(right.iStart == 4);
       
  1858 	test(right.iRightToLeft == EFalse);
       
  1859 
       
  1860 	// Test case 2: ZWJ + Plus sign '+'
       
  1861 	iEtext->Reset();
       
  1862 	iEtext->InsertL(0,KScriptEndWithZWJ);
       
  1863 	iEtext->InsertL(iEtext->DocumentLength(),KTextTestCase2);
       
  1864 	iView->FormatTextL();
       
  1865 	iLayout->TagmaTextLayout().FindAdjacentChunks(pos, left, right);
       
  1866 	test(left.iStart == 0);
       
  1867 	test(left.iEnd == 4);
       
  1868 	test(left.iRightToLeft == EFalse);
       
  1869 	test(right.iStart == 4);
       
  1870 	test(right.iRightToLeft == EFalse);
       
  1871 
       
  1872 	// Test case 3: ZWJ + Pound symbol '??'
       
  1873 	iEtext->Reset();
       
  1874 	iEtext->InsertL(0,KScriptEndWithZWJ);
       
  1875 	iEtext->InsertL(iEtext->DocumentLength(),KTextTestCase3);
       
  1876 	iView->FormatTextL();
       
  1877 	iLayout->TagmaTextLayout().FindAdjacentChunks(pos, left, right);
       
  1878 	test(left.iStart == 0);
       
  1879 	test(left.iEnd == 4);
       
  1880 	test(left.iRightToLeft == EFalse);
       
  1881 	test(right.iStart == 4);
       
  1882 	test(right.iRightToLeft == EFalse);
       
  1883 
       
  1884 	// Test case 0: ZWJ + Period '.'
       
  1885 	iEtext->Reset();
       
  1886 	iEtext->InsertL(0,KScriptEndWithZWJ);
       
  1887 	iEtext->InsertL(iEtext->DocumentLength(),KTextTestCase4);
       
  1888 	iView->FormatTextL();
       
  1889 	iLayout->TagmaTextLayout().FindAdjacentChunks(pos, left, right);
       
  1890 	test(left.iStart == 0);
       
  1891 	test(left.iEnd == 4);
       
  1892 	test(left.iRightToLeft == EFalse);
       
  1893 	test(right.iStart == 4);
       
  1894 	test(right.iRightToLeft == EFalse);
       
  1895 
       
  1896 	// Test case 0: ZWJ + Tab Character
       
  1897 	iEtext->Reset();
       
  1898 	iEtext->InsertL(0,KScriptEndWithZWJ);
       
  1899 	iEtext->InsertL(iEtext->DocumentLength(),KTextTestCase5);
       
  1900 	iView->FormatTextL();
       
  1901 	iLayout->TagmaTextLayout().FindAdjacentChunks(pos, left, right);
       
  1902 	test(left.iStart == 0);
       
  1903 	test(left.iEnd == 4);
       
  1904 	test(left.iRightToLeft == EFalse);
       
  1905 	test(right.iStart == 4);
       
  1906 	test(right.iRightToLeft == EFalse);
       
  1907 
       
  1908 	// Test case 0: ZWJ + Space
       
  1909 	iEtext->Reset();
       
  1910 	iEtext->InsertL(0,KScriptEndWithZWJ);
       
  1911 	iEtext->InsertL(iEtext->DocumentLength(),KTextTestCase6);
       
  1912 	iView->FormatTextL();
       
  1913 	iLayout->TagmaTextLayout().FindAdjacentChunks(pos, left, right);
       
  1914 	test(left.iStart == 0);
       
  1915 	test(left.iEnd == 4);
       
  1916 	test(left.iRightToLeft == EFalse);
       
  1917 	test(right.iStart == 4);
       
  1918 	test(right.iRightToLeft == EFalse);
       
  1919 
       
  1920 	// Test case 0: ZWJ + Form feed
       
  1921 	iEtext->Reset();
       
  1922 	iEtext->InsertL(0,KScriptEndWithZWJ);
       
  1923 	iEtext->InsertL(iEtext->DocumentLength(),KTextTestCase7);
       
  1924 	iView->FormatTextL();
       
  1925 	iLayout->TagmaTextLayout().FindAdjacentChunks(pos, left, right);
       
  1926 	test(left.iStart == 0);
       
  1927 	test(left.iEnd == 4);
       
  1928 	test(left.iRightToLeft == EFalse);
       
  1929 	test(right.iStart == 4);
       
  1930 	test(right.iRightToLeft == EFalse);
       
  1931 
       
  1932 	// Test case 0: ZWJ + Line breaker
       
  1933 	iEtext->Reset();
       
  1934 	iEtext->InsertL(0,KScriptEndWithZWJ);
       
  1935 	iEtext->InsertL(iEtext->DocumentLength(),KTextTestCase8);
       
  1936 	iView->FormatTextL();
       
  1937 	iLayout->TagmaTextLayout().FindAdjacentChunks(pos, left, right);
       
  1938 	test(left.iStart == 0);
       
  1939 	test(left.iEnd == 4);
       
  1940 	test(left.iRightToLeft == EFalse);
       
  1941 	test(right.iStart == 4);
       
  1942 	test(right.iRightToLeft == EFalse);
       
  1943 
       
  1944 	Destroy();
       
  1945 	}
       
  1946 
       
  1947 /**
       
  1948 @SYMTestCaseID          SYSLIB-FORM-UT-4016
       
  1949 @SYMTestCaseDesc        Testing the fix for PDEF121798 Printing: Email is printed only two pages 
       
  1950 @SYMTestPriority        Medium
       
  1951 @SYMTestActions         Paginates random amounts of text and checks whether the correct number of pages are returned from pagination.
       
  1952 @SYMTestExpectedResults The amount of pages produced by the paginator should match the expected number of pages based on lines of text, page size, etc.
       
  1953 @SYMDEF                 PDEF121798
       
  1954 */
       
  1955 void CTextViewTest::TestForPDEF121798L()
       
  1956 	{
       
  1957 	test.Next(_L("Testing fix for PDEF121798"));
       
  1958 	CTestScreenDevice* screenDevice = new(ELeave) CTestScreenDevice(iEnv.ScreenDevice(),iWindow);
       
  1959 		
       
  1960 	TMargins margins;
       
  1961 	margins.iTop = 1440;
       
  1962 	margins.iBottom = 1440;
       
  1963 	margins.iLeft = 1440;
       
  1964 	margins.iRight = 1440;
       
  1965 	TSize s(11906,16838);
       
  1966 	TPageSpec p(TPageSpec::EPortrait, s);
       
  1967 		
       
  1968 	// We need to find out the height of lines and print area of the page.
       
  1969 	// From this we determine how many lines *should* appear on the page.
       
  1970 	// This differs between devices(ie. hw and winscw).
       
  1971 	TInt pageHeight = screenDevice->VerticalTwipsToPixels(s.iHeight - margins.iTop - margins.iBottom);
       
  1972 	_LIT(KDummyString,"this is used by dummy paginator to find out line height and page size");
       
  1973 	InitializeL();
       
  1974 	AddTextL(KDummyString);
       
  1975 	TInt lineHeight = 0;	
       
  1976 	CParaFormat* paraFormat = CParaFormat::NewL();
       
  1977 	iEtext->GetParagraphFormatL(paraFormat,0);
       
  1978 	TBool pageBreakChar = EFalse;
       
  1979 	TInt docPos = 0;
       
  1980 	iLayout->FormatLineL(paraFormat,docPos,lineHeight,pageBreakChar);
       
  1981 	
       
  1982 	CArrayFixFlat<TInt>* charsPerPage = new(ELeave) CArrayFixFlat<TInt>(KGranularity);
       
  1983 	TInt numLines = pageHeight/lineHeight; // Number of lines expected on a page with paginator settings defined above and line height.
       
  1984 	
       
  1985 	
       
  1986 	
       
  1987 	// Perform 50 random pagination tests.
       
  1988 	for(TInt numTests = 0; numTests < 50; numTests++)
       
  1989 		{
       
  1990 		// Generate the number of lines in this document.
       
  1991 		TBuf<512> testString;
       
  1992 		TInt randomNum = (Math::Random() % 512);
       
  1993 		// Calculate the expected number of pages based on page size and line height
       
  1994 		TInt expectedPages = randomNum/numLines;
       
  1995 		// If it's not an exact fit there will be another page lost in the integer division.
       
  1996 		if ((numLines * expectedPages != randomNum) || randomNum == 0)
       
  1997 			{
       
  1998 			++expectedPages;
       
  1999 			}
       
  2000 		// Append the random number of lines to the test string
       
  2001 		for (TInt i = 0; i < randomNum-1; i++) // randomNum -1 because we add a character after the loop.
       
  2002 			{
       
  2003 			// Empty lines will do.
       
  2004 			testString.Append(CEditableText::EParagraphDelimiter);
       
  2005 			}
       
  2006 		// End the text with a character rather than a paragraph delim.
       
  2007 		testString.Append(_L("A"));
       
  2008 		
       
  2009 		
       
  2010 		InitializeL();
       
  2011 		AddTextL(testString);
       
  2012 		// Set up the paginator.
       
  2013 		CTextPaginator* paginator = CTextPaginator::NewL(screenDevice, charsPerPage, KPaginatePriority);
       
  2014 		paginator->SetPageMarginsInTwips(margins);
       
  2015 		paginator->SetPageSpecInTwips(p);
       
  2016 		paginator->SetDocumentL(iEtext);
       
  2017 		docPos=0;
       
  2018 		paginator->AppendTextL(docPos);
       
  2019 		TInt numPages=paginator->PaginationCompletedL();
       
  2020 		RDebug::Printf("%d lines: Expected %d pages, got %d pages", randomNum, expectedPages, numPages);
       
  2021 		test(expectedPages == numPages);
       
  2022 		delete paginator;
       
  2023 		}
       
  2024 	delete charsPerPage;
       
  2025 	delete screenDevice;
       
  2026 	delete paraFormat;
       
  2027 	Destroy();
       
  2028 	}
       
  2029 
       
  2030 /**
       
  2031 @SYMTestCaseID          SYSLIB-FORM-UT-4015
       
  2032 @SYMTestCaseDesc	    Test for PDEF120239
       
  2033 @SYMTestPriority 	    Normal
       
  2034 @SYMTestActions			Use text consist of "LTR text + ZWJ + RTL Text", format the line, then:
       
  2035 						1) use CTmTextLayout::FindAdjacentChunks() to find chunks around overlapped doc pos.
       
  2036 						2) use CTextView::MoveCursorL to move cursor through out the line.
       
  2037 @SYMTestExpectedResults 1) FindAdjacentChunks() returns correct chunks
       
  2038 						2) Cursor should moves Left to Right and Right to Left correctly
       
  2039 @SYMDEF                 PDEF120239
       
  2040 */
       
  2041 void CTextViewTest::TestForPDEF120239L()
       
  2042 	{
       
  2043 	test.Next(_L("Testing fix for PDEF120239L"));
       
  2044 	InitializeL();
       
  2045 	
       
  2046 	TCharFormat charFormat = TCharFormat(_L("NewTimes"),10);
       
  2047 	TCharFormatMask charFormatMask;
       
  2048 	charFormatMask.SetAll();
       
  2049 	iCharLayer->SetL(charFormat, charFormatMask);
       
  2050 	iEtext->SetGlobalCharFormat(iCharLayer);
       
  2051  	
       
  2052 	_LIT(KTestScript,"\x0931\x094d\x200d\x684");	// Test script (LTR text + ZWJ + RTL Text)
       
  2053 	
       
  2054 	iEtext->Reset();
       
  2055 	iEtext->InsertL(0,KTestScript);
       
  2056 	iView->FormatTextL();
       
  2057 	
       
  2058 	// 1) use CTmTextLayout::FindAdjacentChunks()
       
  2059 	CTmTextLayout::TTmChunkDescription left;
       
  2060 	CTmTextLayout::TTmChunkDescription right;
       
  2061 	
       
  2062 	TTmDocPosSpec pos(3, TTmDocPosSpec::ETrailing);
       
  2063 
       
  2064 	iLayout->TagmaTextLayout().FindAdjacentChunks(pos, left, right);
       
  2065 	test(left.iStart == 0);
       
  2066 	test(left.iEnd == 3);
       
  2067 	test(!left.iRightToLeft);
       
  2068 	test(right.iStart == 2);
       
  2069 	test(right.iEnd == 4);
       
  2070 	test(right.iRightToLeft);
       
  2071 	
       
  2072 	pos.iPos = 2;
       
  2073 	pos.iType = TTmDocPosSpec::ELeading;
       
  2074 	
       
  2075 	iLayout->TagmaTextLayout().FindAdjacentChunks(pos, left, right);
       
  2076 	test(left.iStart == 2);
       
  2077 	test(left.iEnd == 4);
       
  2078 	test(left.iRightToLeft);
       
  2079 	test(right.iStart == 4);
       
  2080 	test(right.iEnd == 5);
       
  2081 	test(!right.iRightToLeft);
       
  2082 	
       
  2083 	// 2) use CTextView::MoveCursorL to move cursor
       
  2084 	TTmDocPos cursorPos;
       
  2085 	TTmDocPos targetPos1 (0, ETrue);
       
  2086 	TTmDocPos targetPos2 (0, EFalse);
       
  2087 	TCursorPosition::TMovementType move = TCursorPosition::EFRight;
       
  2088 	
       
  2089 	TCursorSelection selection(0,0);
       
  2090 	iView->SetSelectionL(selection);
       
  2091 	iView->GetCursorPos(cursorPos);
       
  2092 	test(cursorPos == targetPos1 || cursorPos == targetPos2);
       
  2093 	
       
  2094 	targetPos1.iPos = 3;
       
  2095 	targetPos1.iLeadingEdge = EFalse;
       
  2096 	targetPos2.iPos = 4;
       
  2097 	targetPos2.iLeadingEdge = EFalse;
       
  2098 	iView->MoveCursorL(move, EFalse);
       
  2099 	iView->GetCursorPos(cursorPos);
       
  2100 	test(cursorPos == targetPos1 || cursorPos == targetPos2);
       
  2101 	
       
  2102 	targetPos1.iPos = 2;
       
  2103 	targetPos1.iLeadingEdge = ETrue;
       
  2104 	targetPos2.iPos = 4;
       
  2105 	targetPos2.iLeadingEdge = ETrue;
       
  2106 	iView->MoveCursorL(move, EFalse);
       
  2107 	iView->GetCursorPos(cursorPos);
       
  2108 	test(cursorPos == targetPos1 || cursorPos == targetPos2);
       
  2109 	
       
  2110 	move = TCursorPosition::EFLeft;
       
  2111 	
       
  2112 	targetPos1.iPos = 3;
       
  2113 	targetPos1.iLeadingEdge = EFalse;
       
  2114 	targetPos2.iPos = 4;
       
  2115 	targetPos2.iLeadingEdge = EFalse;
       
  2116 	iView->MoveCursorL(move, EFalse);
       
  2117 	iView->GetCursorPos(cursorPos);
       
  2118 	test(cursorPos == targetPos1 || cursorPos == targetPos2);
       
  2119 	
       
  2120 	targetPos1.iPos = 0;
       
  2121 	targetPos1.iLeadingEdge = EFalse;
       
  2122 	targetPos2.iPos = 0;
       
  2123 	targetPos2.iLeadingEdge = ETrue;
       
  2124 	iView->MoveCursorL(move, EFalse);
       
  2125 	iView->GetCursorPos(cursorPos);
       
  2126 	test(cursorPos == targetPos1 || cursorPos == targetPos2);
       
  2127 
       
  2128 	Destroy();
       
  2129 	}
       
  2130 
       
  2131 /**
       
  2132 @SYMTestCaseID          SYSLIB-FORM-UT-4021
       
  2133 @SYMTestCaseDesc	    Test for DEF124989, to ensure TFormAndEtextEditor::SetStyleHelperL has no 
       
  2134                         NULL-dereference issue.
       
  2135 @SYMTestPriority 	    Normal
       
  2136 @SYMTestActions  	    Call TFormAndEtextEditor::InsertTextL and pass in a style name which could 
       
  2137 						not be found in styleList.Then a NULL is generated.
       
  2138 @SYMTestExpectedResults No panic(KERN-EXEC 3) raised from this case.
       
  2139 @SYMDEF                 DEF124989
       
  2140 */
       
  2141 void CTextViewTest::TestForDEF124989L()
       
  2142 	{
       
  2143 	// Initialise CTextViewTest object for next test.
       
  2144 	InitializeL();
       
  2145 	test.Next(_L(" @SYMTestCaseID:SYSLIB-FORM-UT-4021 Testing fix for DEF124989 "));
       
  2146 
       
  2147 	// Insert a one line paragraph into EText object and reformat view.
       
  2148 	_LIT(KTestParagraph, "This is a piece of text to test the character positioning API based in X,Y cocordinates.");
       
  2149 	iEtext->InsertL(0, KTestParagraph);
       
  2150 	
       
  2151 	TFormAndEtextEditor newEditor(*iView,*iEtext);
       
  2152 	
       
  2153 	CStyleList* styleList = CStyleList::NewL();
       
  2154 	CleanupStack::PushL(styleList);
       
  2155 	RParagraphStyleInfo paraStyleInfo(NULL,NULL);
       
  2156 
       
  2157 	// Appending the new style to stylelist
       
  2158 	styleList->AppendL(&paraStyleInfo);
       
  2159 	iEtext->SetStyleListExternallyOwned(*styleList);
       
  2160 	
       
  2161 	TPtrC ptr1(_L("Arial3"));
       
  2162 	// Inserting the text and applying the style specified(Arial3) 
       
  2163 	// which is not in syleList.  
       
  2164 	newEditor.InsertTextL(0, _L("Hello World"),&ptr1);
       
  2165 	
       
  2166 	// Clean up test object
       
  2167 	CleanupStack::PopAndDestroy();
       
  2168 	Destroy();
       
  2169 	}
       
  2170 
       
  2171 /**
       
  2172 @SYMTestCaseID                      SYSLIB-FORM-UT-4022
       
  2173 @SYMTestCaseDesc	    Test for DEF124975
       
  2174 @SYMTestPriority                       Normal
       
  2175 @SYMTestActions                      1) Call CTextLayout::AdjustVerticalAlignment() when there is no content
       
  2176                                                    2) Add Some random text and then call CTextLayout::AdjustVerticalAlignment()@SYMTestExpectedResults       There should be no panic during the process
       
  2177 @SYMDEF                                 DEF124975
       
  2178 */
       
  2179 void CTextViewTest::TestForDEF124975L()
       
  2180 	{
       
  2181 	test.Next(_L(" @SYMTestCaseID: Testing fix for coverity DEF124975 "));
       
  2182 	InitializeL();
       
  2183 	
       
  2184 	const TInt MaxTestCount = 50;
       
  2185 	const TInt MaxStringCount = 100;
       
  2186 	TInt TestCount = GetNumber(1, MaxTestCount);
       
  2187 	TInt StringCount = GetNumber(1, MaxStringCount);
       
  2188 	
       
  2189 	for(TInt i=0; i<TestCount; i++)
       
  2190 		{
       
  2191 		iLayout->AdjustVerticalAlignment(CParaFormat::ECustomAlign);
       
  2192 		}
       
  2193 	
       
  2194 	for(TInt i=0; i<TestCount; i++)
       
  2195 		{
       
  2196 		RBuf testString;
       
  2197 		testString.Create(StringCount);
       
  2198 		for(int i=0; i<testString.MaxLength(); i++)
       
  2199 			{
       
  2200 			TInt c = GetNumber(0, 0xffff);
       
  2201 			while ( IsSurrogate(c) )
       
  2202 			    c = GetNumber(0, 0xffff);
       
  2203 			testString.Append( c );
       
  2204 			}
       
  2205 		AddTextL(testString);
       
  2206 		iLayout->AdjustVerticalAlignment(CParaFormat::ECustomAlign);
       
  2207 		testString.Close();
       
  2208 		}
       
  2209 	
       
  2210 	Destroy();
       
  2211 	}
       
  2212 
       
  2213 void CTextViewTest::TestForDEF142286BounceScrollingL()
       
  2214     {
       
  2215     test.Next(_L(" Testing fix for DEF142286 which supports bounce scrolling feature "));
       
  2216     TestScrollDisplayPixelsNoLimitBordersL(10);
       
  2217     TestScrollDisplayPixelsNoLimitBordersL(50);
       
  2218     TestScrollDisplayPixelsNoLimitBordersL(100);
       
  2219     }
       
  2220 
       
  2221 void RunTestsL(CCoeEnv& aEnv)
       
  2222 	{
       
  2223 	CTextViewTest* t = new(ELeave) CTextViewTest(aEnv);
       
  2224 	CleanupStack::PushL(t);
       
  2225 	t->ConstructL();
       
  2226 	t->TestL();
       
  2227 	t->Test1L();
       
  2228 	t->TestCancelSelectionL();
       
  2229 	t->TestFinishBackgroundFormattingL();
       
  2230 	t->TestSetCursorVisibilityL();
       
  2231 	t->TestSetSelectionVisibilityL();
       
  2232 	t->TestEnablePictureFrameL();
       
  2233 	t->TestSetCursorWidthTypeL();
       
  2234 	t->TestParagraphRectL();
       
  2235 	t->TestDrawL();
       
  2236 	t->TestFormatTextL();
       
  2237 	t->TestHandleRangeFormatChangeL();
       
  2238 	t->TestHandleInsertDeleteL();
       
  2239 	t->TestHandleGlobalChangeL();
       
  2240 	t->TestHandleGlobalChangeNoRedrawL();
       
  2241 	t->TestScrollDisplayL();
       
  2242 	t->TestScrollDisplayPixelsL();
       
  2243 	t->TestScrollDisplayLinesL();
       
  2244 	t->TestScrollDisplayParagraphsL();
       
  2245 	t->TestMoveCursorL();
       
  2246 	t->TestSetSelectionL();
       
  2247 	t->TestMatchCursorHeightL();
       
  2248 	t->TestCalculateHorizontalExtremesL();
       
  2249 	t->TestXyPosToDocPosL();
       
  2250 	t->TestGetPictureRectangleL();
       
  2251 	t->TestGetPictureRectangle1L();
       
  2252 	//t->TestGetPictureRectangleDefectL();
       
  2253 	t->TestSetDisplayContextL();
       
  2254 	t->TestGetParaFormatL();
       
  2255 	t->TestGetLineRectL();
       
  2256 	t->TestForDEF003426L();
       
  2257 	t->TestForDEF038488L();
       
  2258 	t->FormAndEtextTestL();
       
  2259 	t->TestForINC092725L();
       
  2260 	t->TestForPDEF108443L();
       
  2261 	t->TestForPDEF113755L();
       
  2262 	t->TestForPDEF115165L();
       
  2263 	t->TestForPDEF118443L();
       
  2264 	t->TestForPDEF121798L();
       
  2265 	t->TestForDEF124989L();
       
  2266 	t->TestForPDEF120239L();
       
  2267 	t->TestForDEF124975L();
       
  2268     t->TestForDEF142286BounceScrollingL();
       
  2269 	CleanupStack::PopAndDestroy(t);
       
  2270 }
       
  2271 
       
  2272 TInt E32Main()
       
  2273 	{
       
  2274 	CCoeEnv* env=new CCoeEnv;
       
  2275 	TRAPD(err,
       
  2276 		env->ConstructL();
       
  2277 		RunTestsL(*env);
       
  2278 		);
       
  2279 	return err;
       
  2280 	}
       
  2281 
       
  2282 #if defined(__WINS__)
       
  2283 EXPORT_C TInt EntryPoint(TAny*) {return E32Main();}
       
  2284 #endif