First public contribution.
2 * Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
15 * TTextView.cpp test file for UndoSystem classes
28 #include "form_and_etext_editor.h"
29 #include "UndoSystem.h"
30 #include "EditorUndo.h"
33 _LIT(KHello, "hello world");
34 const TInt KPaginatePriority = -100;
35 const TInt KGranularity = 10;
37 using namespace UndoSystem;
39 LOCAL_C TInt GetNumber(TInt aMin, TInt aMax)
41 __ASSERT_ALWAYS(aMin <= aMax, User::Invariant());
43 TInt64 seed = Math::Random();
44 TReal randomReal = Math::FRand(seed);
46 TReal maxReal = randomReal * ((aMax-aMin)+1);
48 User::LeaveIfError(Math::Round(rounded, maxReal, 0));
50 TInt result = rounded + aMin;
59 void ManipulateText(CTextView* aView, CRichText* aText)
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();
68 format.iFontSpec.iFontStyle.SetStrokeWeight(EStrokeWeightBold);
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);
79 void ManipulateText1(CTextView* aView, CRichText* aText)
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();
91 inline TBool IsSurrogate(TText16 aInt16)
93 @return True, if aText16 is high surrogate or low surrogate; false, otherwise.
96 return (aInt16 & 0xF800) == 0xD800;
99 class CMyTestPicture : public CPicture
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;}
107 CMyTestPicture(TSize aSize);
109 TSize iSizeOfPicture;
112 CMyTestPicture* CMyTestPicture::NewL(TSize aSize)
114 return new(ELeave) CMyTestPicture(aSize);
118 CMyTestPicture::CMyTestPicture(TSize aSize):iSizeOfPicture(aSize)
122 class CTextViewTest : public CBase
125 CTextViewTest(CCoeEnv& aEnv)
126 : iEnv(aEnv), iWindowRect(10, 10, 110, 110), iWindow(aEnv.WsSession()),
127 test(_L("TTextView - Some tests for CTextView")) {}
130 void AddTextL(const TDesC&);
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();
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();
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();
187 struct STestDataTInt4
198 CParaFormatLayer* iParaLayer;
199 CCharFormatLayer* iCharLayer;
201 CTextLayout* iLayout;
205 TCursorSelection select;
210 TCursorPosition::TMovementType testaMovement;
211 TFontSpec testaFontSpec;
215 TBool testaCanScaleOrCrop;
216 CBitmapContext* testaGc;
218 CBitmapDevice* testaGd;
219 RWindowGroup testaGroupWin;
220 RWsSession testaSession;
223 void CTextViewTest::ConstructL()
225 iWindow.Construct(iEnv.RootWin(), 12345);
226 iParaLayer = CParaFormatLayer::NewL();
227 iCharLayer = CCharFormatLayer::NewL();
229 test.Start(_L("CTextView Tests:"));
232 void CTextViewTest::InitializeL()
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();
242 void CTextViewTest::AddTextL(const TDesC& aText)
244 iEtext->InsertL(0, aText);
245 TCursorSelection s(0, aText.Length());
246 iView->HandleInsertDeleteL(s, 0);
249 void CTextViewTest::InitializeDiffCharFormatL()
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();
266 void CTextViewTest::Destroy()
277 void CTextViewTest::TestL()
279 // Test for fix to ASR-4UYHZX: ETEXT panic 12 (ECharPosBeyondDocument) when
282 ManipulateText(iView, iEtext);
284 TInt consecutiveSuccesses = 0;
285 for (TInt i = 1; consecutiveSuccesses != 100; ++i)
289 __UHEAP_SETFAIL(RHeap::EDeterministic, i);
290 TRAPD(err, ManipulateText(iView, iEtext));
292 __UHEAP_SETFAIL(RHeap::ENone, 0);
295 ++consecutiveSuccesses;
297 consecutiveSuccesses = 0;
302 void CTextViewTest::Test1L()
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
310 ManipulateText1(iView, iEtext); //where all pre-settings have been done
312 TInt consecutiveSuccesses = 0;
313 for (TInt i = 1; consecutiveSuccesses != 100; ++i)
317 __UHEAP_SETFAIL(RHeap::EDeterministic, i);
318 TRAPD(err, ManipulateText1(iView, iEtext));
320 __UHEAP_SETFAIL(RHeap::ENone, 0);
323 ++consecutiveSuccesses;
325 consecutiveSuccesses = 0;
330 void CTextViewTest::TestCancelSelectionL()
333 iView->CancelSelectionL();
335 TInt consecutiveSuccesses = 0;
336 for (TInt i = 1; consecutiveSuccesses != 100; ++i)
340 __UHEAP_SETFAIL(RHeap::EDeterministic, i);
341 TRAPD(err, iView->CancelSelectionL());
343 __UHEAP_SETFAIL(RHeap::ENone, 0);
346 ++consecutiveSuccesses;
348 consecutiveSuccesses = 0;
353 void CTextViewTest::TestFinishBackgroundFormattingL()
356 iView->FinishBackgroundFormattingL();
358 TInt consecutiveSuccesses = 0;
359 for (TInt i = 1; consecutiveSuccesses != 100; ++i)
363 __UHEAP_SETFAIL(RHeap::EDeterministic, i);
364 TRAPD(err, iView->FinishBackgroundFormattingL());
366 __UHEAP_SETFAIL(RHeap::ENone, 0);
369 ++consecutiveSuccesses;
371 consecutiveSuccesses = 0;
376 void CTextViewTest::TestFormatTextL()
379 iView->FormatTextL();
381 TInt consecutiveSuccesses = 0;
382 for (TInt i = 1; consecutiveSuccesses != 100; ++i)
386 __UHEAP_SETFAIL(RHeap::EDeterministic, i);
387 TRAPD(err, iView->FormatTextL());
389 __UHEAP_SETFAIL(RHeap::ENone, 0);
392 ++consecutiveSuccesses;
394 consecutiveSuccesses = 0;
399 void CTextViewTest::TestSetCursorVisibilityL()
402 iView->SetCursorVisibilityL(1,1);
404 TInt consecutiveSuccesses = 0;
405 for (TInt i = 1; consecutiveSuccesses != 100; ++i)
409 __UHEAP_SETFAIL(RHeap::EDeterministic, i);
410 TRAPD(err, iView->SetCursorVisibilityL(1,1)); //TInt aLineCursor, TInt aTextCursor
412 __UHEAP_SETFAIL(RHeap::ENone, 0);
415 ++consecutiveSuccesses;
417 consecutiveSuccesses = 0;
422 void CTextViewTest::TestSetSelectionVisibilityL()
425 iView->SetSelectionVisibilityL(1);
427 TInt consecutiveSuccesses = 0;
428 for (TInt i = 1; consecutiveSuccesses != 100; ++i)
432 __UHEAP_SETFAIL(RHeap::EDeterministic, i);
433 TRAPD(err, iView->SetSelectionVisibilityL(1)); //TBool aSelectionVisible
435 __UHEAP_SETFAIL(RHeap::ENone, 0);
438 ++consecutiveSuccesses;
440 consecutiveSuccesses = 0;
445 void CTextViewTest::TestEnablePictureFrameL()
448 iView->EnablePictureFrameL(1);
450 TInt consecutiveSuccesses = 0;
451 for (TInt i = 1; consecutiveSuccesses != 100; ++i)
455 __UHEAP_SETFAIL(RHeap::EDeterministic, i);
456 TRAPD(err, iView->EnablePictureFrameL(1)); //TBool aEnabled
458 __UHEAP_SETFAIL(RHeap::ENone, 0);
461 ++consecutiveSuccesses;
463 consecutiveSuccesses = 0;
468 void CTextViewTest::TestSetCursorWidthTypeL()
471 iView->SetCursorWidthTypeL(TTextCursor::ETypeRectangle,0);
473 TInt consecutiveSuccesses = 0;
474 for (TInt i = 1; consecutiveSuccesses != 100; ++i)
478 __UHEAP_SETFAIL(RHeap::EDeterministic, i);
479 TRAPD(err, iView->SetCursorWidthTypeL(TTextCursor::ETypeRectangle,0)); //TTextCursor::EType aType, TInt aWidth=0
481 __UHEAP_SETFAIL(RHeap::ENone, 0);
484 ++consecutiveSuccesses;
486 consecutiveSuccesses = 0;
491 void CTextViewTest::TestParagraphRectL()
494 iView->ParagraphRectL(1);
496 TInt consecutiveSuccesses = 0;
497 for (TInt i = 1; consecutiveSuccesses != 100; ++i)
501 __UHEAP_SETFAIL(RHeap::EDeterministic, i);
502 TRAPD(err, iView->ParagraphRectL(1)); //TInt aDocPos
504 __UHEAP_SETFAIL(RHeap::ENone, 0);
507 ++consecutiveSuccesses;
509 consecutiveSuccesses = 0;
514 void CTextViewTest::TestDrawL()
517 iView->DrawL(iWindowRect);
519 TInt consecutiveSuccesses = 0;
520 for (TInt i = 1; consecutiveSuccesses != 100; ++i)
524 __UHEAP_SETFAIL(RHeap::EDeterministic, i);
525 TRAPD(err, iView->DrawL(iWindowRect)); //TRect aRect
527 __UHEAP_SETFAIL(RHeap::ENone, 0);
530 ++consecutiveSuccesses;
532 consecutiveSuccesses = 0;
537 void CTextViewTest::TestHandleRangeFormatChangeL()
540 iView->HandleRangeFormatChangeL(select, EFalse);
542 TInt consecutiveSuccesses = 0;
543 for (TInt i = 1; consecutiveSuccesses != 100; ++i)
547 __UHEAP_SETFAIL(RHeap::EDeterministic, i);
548 TRAPD(err, iView->HandleRangeFormatChangeL(select, EFalse));
550 __UHEAP_SETFAIL(RHeap::ENone, 0);
553 ++consecutiveSuccesses;
555 consecutiveSuccesses = 0;
560 void CTextViewTest::TestHandleInsertDeleteL()
563 iView->HandleInsertDeleteL(select, 1, EFalse);
565 TInt consecutiveSuccesses = 0;
566 for (TInt i = 1; consecutiveSuccesses != 100; ++i)
570 __UHEAP_SETFAIL(RHeap::EDeterministic, i);
571 TRAPD(err, iView->HandleInsertDeleteL(select, 1, EFalse));
573 __UHEAP_SETFAIL(RHeap::ENone, 0);
576 ++consecutiveSuccesses;
578 consecutiveSuccesses = 0;
583 void CTextViewTest::TestHandleGlobalChangeL()
586 iView->HandleGlobalChangeL(TViewYPosQualifier());
588 TInt consecutiveSuccesses = 0;
589 for (TInt i = 1; consecutiveSuccesses != 100; ++i)
593 __UHEAP_SETFAIL(RHeap::EDeterministic, i);
594 TRAPD(err, iView->HandleGlobalChangeL(TViewYPosQualifier()));
596 __UHEAP_SETFAIL(RHeap::ENone, 0);
599 ++consecutiveSuccesses;
601 consecutiveSuccesses = 0;
606 void CTextViewTest::TestHandleGlobalChangeNoRedrawL()
609 iView->HandleGlobalChangeNoRedrawL(TViewYPosQualifier());
611 TInt consecutiveSuccesses = 0;
612 for (TInt i = 1; consecutiveSuccesses != 100; ++i)
616 __UHEAP_SETFAIL(RHeap::EDeterministic, i);
617 TRAPD(err, iView->HandleGlobalChangeNoRedrawL(TViewYPosQualifier()));
619 __UHEAP_SETFAIL(RHeap::ENone, 0);
622 ++consecutiveSuccesses;
624 consecutiveSuccesses = 0;
629 void CTextViewTest::TestScrollDisplayL()
632 iView->ScrollDisplayL(TCursorPosition::EFLeft);
634 TInt consecutiveSuccesses = 0;
635 for (TInt i = 1; consecutiveSuccesses != 100; ++i)
639 __UHEAP_SETFAIL(RHeap::EDeterministic, i);
640 TRAPD(err, iView->ScrollDisplayL(TCursorPosition::EFLeft));
642 __UHEAP_SETFAIL(RHeap::ENone, 0);
645 ++consecutiveSuccesses;
647 consecutiveSuccesses = 0;
652 void CTextViewTest::TestScrollDisplayPixelsL()
655 iView->ScrollDisplayPixelsL(testDeltaY);
657 TInt consecutiveSuccesses = 0;
658 for (TInt i = 1; consecutiveSuccesses != 100; ++i)
662 __UHEAP_SETFAIL(RHeap::EDeterministic, i);
663 TRAPD(err, iView->ScrollDisplayPixelsL(testDeltaY));
665 __UHEAP_SETFAIL(RHeap::ENone, 0);
668 ++consecutiveSuccesses;
670 consecutiveSuccesses = 0;
675 void CTextViewTest::TestScrollDisplayPixelsNoLimitBordersL(TInt aOffset)
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
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.*/
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);
692 TInt firstBandTop, secondBandTop;
693 TInt offset = aOffset;
696 iView->ScrollDisplayPixelsL(offset);
699 firstBandTop = iLayout->PixelsAboveBand();
700 iView->ScrollDisplayPixelsNoLimitBorderL(offset);
701 secondBandTop = iLayout->PixelsAboveBand();
702 test(firstBandTop - secondBandTop == offset);
704 offset = 0 - aOffset;
707 iView->ScrollDisplayPixelsL(offset);
709 offset = 0 - aOffset;
710 firstBandTop = iLayout->PixelsAboveBand();
711 iView->ScrollDisplayPixelsNoLimitBorderL(offset);
712 secondBandTop = iLayout->PixelsAboveBand();
713 test(firstBandTop - secondBandTop == offset);
719 void CTextViewTest::TestScrollDisplayLinesL()
722 iView->ScrollDisplayLinesL(testDeltaLines);
724 TInt consecutiveSuccesses = 0;
725 for (TInt i = 1; consecutiveSuccesses != 100; ++i)
729 __UHEAP_SETFAIL(RHeap::EDeterministic, i);
730 TRAPD(err, iView->ScrollDisplayLinesL(testDeltaLines));
732 __UHEAP_SETFAIL(RHeap::ENone, 0);
735 ++consecutiveSuccesses;
737 consecutiveSuccesses = 0;
742 void CTextViewTest::TestScrollDisplayParagraphsL()
746 iView->ScrollDisplayParagraphsL(testDeltaParas);
748 TInt consecutiveSuccesses = 0;
749 for (TInt i = 1; consecutiveSuccesses != 100; ++i)
754 __UHEAP_SETFAIL(RHeap::EDeterministic, i);
755 TRAPD(err, iView->ScrollDisplayParagraphsL(testDeltaParas));
757 __UHEAP_SETFAIL(RHeap::ENone, 0);
760 ++consecutiveSuccesses;
762 consecutiveSuccesses = 0;
767 void CTextViewTest::TestSetViewL()
770 iView->SetViewL(1, testaYPos);
772 TInt consecutiveSuccesses = 0;
773 for (TInt i = 1; consecutiveSuccesses != 100; ++i)
777 __UHEAP_SETFAIL(RHeap::EDeterministic, i);
778 TRAPD(err, iView->SetViewL(1, testaYPos));
780 __UHEAP_SETFAIL(RHeap::ENone, 0);
783 ++consecutiveSuccesses;
785 consecutiveSuccesses = 0;
790 void CTextViewTest::TestMoveCursorL()
794 iView->MoveCursorL(testaMovement, EFalse);
796 TInt consecutiveSuccesses = 0;
797 for (TInt i = 1; consecutiveSuccesses != 100; ++i)
802 __UHEAP_SETFAIL(RHeap::EDeterministic, i);
803 TRAPD(err, iView->MoveCursorL(testaMovement, EFalse));
805 __UHEAP_SETFAIL(RHeap::ENone, 0);
808 ++consecutiveSuccesses;
810 consecutiveSuccesses = 0;
815 void CTextViewTest::TestSetSelectionL()
818 iView->SetSelectionL(select);
820 TInt consecutiveSuccesses = 0;
821 for (TInt i = 1; consecutiveSuccesses != 100; ++i)
825 __UHEAP_SETFAIL(RHeap::EDeterministic, i);
826 TRAPD(err, iView->SetSelectionL(select));
828 __UHEAP_SETFAIL(RHeap::ENone, 0);
831 ++consecutiveSuccesses;
833 consecutiveSuccesses = 0;
838 void CTextViewTest::TestMatchCursorHeightL()
841 iView->MatchCursorHeightL(testaFontSpec);
843 TInt consecutiveSuccesses = 0;
844 for (TInt i = 1; consecutiveSuccesses != 100; ++i)
848 __UHEAP_SETFAIL(RHeap::EDeterministic, i);
849 TRAPD(err, iView->MatchCursorHeightL(testaFontSpec));
851 __UHEAP_SETFAIL(RHeap::ENone, 0);
854 ++consecutiveSuccesses;
856 consecutiveSuccesses = 0;
861 void CTextViewTest::TestCalculateHorizontalExtremesL()
864 iView->CalculateHorizontalExtremesL(testaLeft, testaRight, EFalse);
866 TInt consecutiveSuccesses = 0;
867 for (TInt i = 1; consecutiveSuccesses != 100; ++i)
871 __UHEAP_SETFAIL(RHeap::EDeterministic, i);
872 TRAPD(err, iView->CalculateHorizontalExtremesL(testaLeft, testaRight, EFalse));
874 __UHEAP_SETFAIL(RHeap::ENone, 0);
877 ++consecutiveSuccesses;
879 consecutiveSuccesses = 0;
884 void CTextViewTest::TestXyPosToDocPosL()
887 iView->XyPosToDocPosL(testaPoint);
889 TInt consecutiveSuccesses = 0;
890 for (TInt i = 1; consecutiveSuccesses != 100; ++i)
894 __UHEAP_SETFAIL(RHeap::EDeterministic, i);
895 TRAPD(err, iView->XyPosToDocPosL(testaPoint));
897 __UHEAP_SETFAIL(RHeap::ENone, 0);
900 ++consecutiveSuccesses;
902 consecutiveSuccesses = 0;
907 void CTextViewTest::TestDrawL1()
910 iView->DrawL(iWindowRect, testaGc);
912 TInt consecutiveSuccesses = 0;
913 for (TInt i = 1; consecutiveSuccesses != 100; ++i)
917 __UHEAP_SETFAIL(RHeap::EDeterministic, i);
918 TRAPD(err, iView->DrawL(iWindowRect, testaGc));
920 __UHEAP_SETFAIL(RHeap::ENone, 0);
923 ++consecutiveSuccesses;
925 consecutiveSuccesses = 0;
931 void CTextViewTest::TestGetPictureRectangleL()
934 iView->GetPictureRectangleL(1, iWindowRect, &testaCanScaleOrCrop);
936 TInt consecutiveSuccesses = 0;
937 for (TInt i = 1; consecutiveSuccesses != 100; ++i)
941 __UHEAP_SETFAIL(RHeap::EDeterministic, i);
942 TRAPD(err, iView->GetPictureRectangleL(1, iWindowRect, &testaCanScaleOrCrop));
944 __UHEAP_SETFAIL(RHeap::ENone, 0);
947 ++consecutiveSuccesses;
949 consecutiveSuccesses = 0;
954 void CTextViewTest::TestGetPictureRectangle1L()
957 iView->GetPictureRectangleL(testaXyPos, iWindowRect, &testaCanScaleOrCrop);
959 TInt consecutiveSuccesses = 0;
960 for (TInt i = 1; consecutiveSuccesses != 100; ++i)
964 __UHEAP_SETFAIL(RHeap::EDeterministic, i);
965 TRAPD(err, iView->GetPictureRectangleL(testaXyPos, iWindowRect, &testaCanScaleOrCrop));
967 __UHEAP_SETFAIL(RHeap::ENone, 0);
970 ++consecutiveSuccesses;
972 consecutiveSuccesses = 0;
977 void CTextViewTest::TestSetDisplayContextL()
979 CBitmapContext* atestGc;
980 CBitmapContext* anotherGc;
982 iView->SetDisplayContextL(testaGd, &iWindow, &testaGroupWin, &testaSession);
984 TInt consecutiveSuccesses = 0;
985 for (TInt i = 1; consecutiveSuccesses != 1; ++i)
989 __UHEAP_SETFAIL(RHeap::EDeterministic, i);
990 atestGc=iView->BitmapContext();
991 TRAPD(err, iView->SetDisplayContextL(testaGd, &iWindow, &testaGroupWin, &testaSession));
992 anotherGc=iView->BitmapContext();
995 test(atestGc==anotherGc);
999 test(atestGc!=anotherGc);
1002 __UHEAP_SETFAIL(RHeap::ENone, 0);
1003 __UHEAP_MARKENDC(0);
1004 if (err == KErrNone)
1005 ++consecutiveSuccesses;
1007 consecutiveSuccesses = 0;
1012 void CTextViewTest::TestGetPictureRectangleDefectL()
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.");
1020 iEtext->InsertL(0,KParagraphAverage);
1021 iView->HandleInsertDeleteL(TCursorSelection(0, KParagraphAverage().Length()), 0);
1022 iEtext->InsertL(KParagraphAverage().Length(),TChar(CEditableText::EParagraphDelimiter));
1023 iView->HandleCharEditL();
1025 length=iEtext->LdDocumentLength();
1026 iEtext->InsertL(iEtext->LdDocumentLength(),KParagraphBigger);
1027 iView->HandleInsertDeleteL(TCursorSelection(length,KParagraphBigger().Length()), 0);
1029 length=iEtext->LdDocumentLength();
1030 iEtext->InsertL(iEtext->LdDocumentLength(),KParagraphSmall);
1031 iView->HandleInsertDeleteL(TCursorSelection(length,KParagraphSmall().Length()), 0);
1033 TSize size(100,100);
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
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);
1056 docpos=iView->XyPosToDocPosL(xypos);
1057 test.Printf(_L("The new docpos is %d\n"),docpos);
1060 boo=iView->GetPictureRectangleL(40,rect);
1061 test.Printf(_L("%d & %d \n"),rect.Size().iHeight,rect.Size().iWidth);
1063 test.Printf(_L("Yes!"));
1065 test.Printf(_L("Noo!"));
1069 void CTextViewTest::TestGetLineRectL()
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"));
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"));
1091 //Call the guilty function
1092 TRect resultingRect;
1093 TInt endOfDocument = iEtext->DocumentLength();
1094 iView->FormatTextL();
1095 resultingRect=iLayout->GetLineRectL(startOfPicture,endOfDocument);
1098 void CTextViewTest::TestGetParaFormatL()
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");
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);
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);
1128 TInt result = anotherParaFormat->iRightMarginInTwips;
1131 result = anotherParaFormat->iLeftMarginInTwips;
1133 result = anotherParaFormat->iLineSpacingInTwips;
1134 test (result==200); // default value for iLineSpacingInTwips set in paraFormat is 200
1135 test (anotherParaFormat->iHorizontalAlignment == CParaFormat::ELeftAlign);
1138 testresult=anotherParaFormat->IsEqual(*paraFormat);
1144 void CTextViewTest::TestForDEF003426L()
1146 // Initialise CTextViewTest object for next test.
1148 test.Next(_L("Verifying CTextView::XyPosToDosPosL() WRT DEF003426"));
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);
1156 // Test XyPosToDocPosL() with coordinates beyond top left corner
1158 docPos = iView->XyPosToDocPosL(testaPoint);
1159 test(docPos == 0); // Should give char position of 0
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
1168 // Clean up test object
1172 /*** Test code for DEF038858
1173 " It isn't poss. to set via CTextView a TTmDocPos of iPos = 0; iLeadingEdge=false"
1175 void CTextViewTest::TestForDEF038488L()
1177 // Initialise CTextViewTest object for next test.
1179 test.Next(_L("Verifying CTextView::SetDocPosL() DEF038858"));
1181 _LIT(KText, "This is the test for DEF038488");
1182 iEtext->InsertL(0, KText);
1183 iView->HandleInsertDeleteL(TCursorSelection(0, KText().Length()), 0);
1185 // Test SetDocPosL() with coordinates -1
1186 iView->SetDocPosL(-1);
1188 // check the value of iLeadingEdge
1189 TTmDocPos RawDocPos;
1190 iView->GetCursorPos(RawDocPos);
1191 test(RawDocPos.iLeadingEdge == EFalse);
1195 CTextViewTest::~CTextViewTest()
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
1215 void CTextViewTest::FormAndEtextTestL()
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(¶StyleInfo);
1237 iEtext->SetStyleListExternallyOwned(*styleList);
1239 TFormAndEtextEditor newEditor(*iView,*iEtext);
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;
1254 parN.iFlags = RTmParFormat::EKeepWithNext;
1255 charLayer.iMask = charIMask;
1256 charLayer.iFormat = charI;
1257 charLayer1=charLayer;
1258 parLayer.iMask = parNMask;
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);
1265 // Setting the paragraph and character format explicitly
1266 newEditor.SetParFormatL(0,11,parLayer);
1267 newEditor.SetCharFormatL(0,11,charLayer);
1269 MUnifiedEditor::TFormatLevel level = MUnifiedEditor::EEffective;
1271 // Getting the paragraph and character format
1272 newEditor.GetParFormatL(0,level,parLayer1,runLen);
1273 newEditor.GetCharFormat(0,level,charLayer1,runLen);
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);
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"));
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);
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();
1309 delete charFormatLayer;
1310 delete paraFormatLayer;
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.
1325 void CTextViewTest::TestForINC092725L()
1327 test.Next(_L(" @SYMTestCaseID:SYSLIB-FORM-UT-3347 Testing fix for INC092725 "));
1328 TInt err = KErrNone;
1333 iLayout->AdjustVerticalAlignment(CParaFormat::EAbsoluteRightAlign);
1334 TRAP(err, iView->ScrollDisplayL(TCursorPosition::EFLineUp, CTextLayout::EFAllowScrollingBlankSpace));
1335 test(err==CTextLayout::EPosNotFormatted);
1339 iLayout->AdjustVerticalAlignment(CParaFormat::EAbsoluteLeftAlign);
1340 TRAP(err, iView->ScrollDisplayL(TCursorPosition::EFLineDown, CTextLayout::EFAllowScrollingBlankSpace));
1341 test(err==CTextLayout::EPosNotFormatted);
1346 iLayout->AdjustVerticalAlignment(CParaFormat::EAbsoluteRightAlign);
1347 TRAP(err, iView->ScrollDisplayLinesL(i, CTextLayout::EFAllowScrollingBlankSpace));
1348 test(err==CTextLayout::EPosNotFormatted);
1353 iLayout->AdjustVerticalAlignment(CParaFormat::EAbsoluteLeftAlign);
1354 TRAP(err, iView->ScrollDisplayLinesL(i, CTextLayout::EFAllowScrollingBlankSpace));
1355 test(err==CTextLayout::EPosNotFormatted);
1358 //Paragraph scroll up
1360 iLayout->AdjustVerticalAlignment(CParaFormat::EAbsoluteRightAlign);
1361 TRAP(err, iView->ScrollDisplayParagraphsL(i, CTextLayout::EFAllowScrollingBlankSpace));
1362 test(err==CTextLayout::EPosNotFormatted);
1365 //Paragraph scroll down
1367 iLayout->AdjustVerticalAlignment(CParaFormat::EAbsoluteLeftAlign);
1368 TRAP(err, iView->ScrollDisplayParagraphsL(i, CTextLayout::EFAllowScrollingBlankSpace));
1369 test(err==CTextLayout::EPosNotFormatted);
1374 class CTestScreenDevice : public CPrinterDevice
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;}
1404 RDrawableWindow& iWin;
1405 CWsScreenDevice* iDevice;
1406 TPrinterModelEntry iModel;
1409 CTestScreenDevice::CTestScreenDevice(CWsScreenDevice* aDevice,RDrawableWindow& aWin):
1413 iModel.iUid=TUid::Null();
1416 TInt CTestScreenDevice::CreateContext(CGraphicsContext*& aGc)
1419 TInt ret=iDevice->CreateContext(aGc);
1420 ((CWindowGc *) aGc)->Activate(iWin);
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.
1432 void CTextViewTest::TestForPDEF108443L()
1434 test.Next(_L(" @SYMTestCaseID:SYSLIB-FORM-UT-3496 Testing fix for PDEF108443 "));
1435 CTestScreenDevice* screenDevice = new(ELeave) CTestScreenDevice(iEnv.ScreenDevice(),iWindow);
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);
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);
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);
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);
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).
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;
1470 textRect = screenDevice->TwipsToPixels(textRect); //defect 131765, call the same func as paginator
1471 TInt pageHeight = textRect.Height();
1472 _LIT(KDummyString,"AAAAAA");
1474 AddTextL(KDummyString);
1475 TInt lineHeight = 0;
1476 CParaFormat* paraFormat = CParaFormat::NewL();
1477 iEtext->GetParagraphFormatL(paraFormat,0);
1478 TBool pageBreakChar = EFalse;
1480 iLayout->FormatLineL(paraFormat,docPos,lineHeight,pageBreakChar);
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');
1486 for (TInt i = 0; i < numLines-2; i++) // ...numlines - 1
1488 string1.Append(simpleChar);
1489 string1.Append(CEditableText::EParagraphDelimiter);
1491 string1.Append(simpleChar); // final line
1493 for (TInt i = 0; i < numLines-1; i++) // ...numlines
1495 string2.Append(simpleChar);
1496 string2.Append(CEditableText::EParagraphDelimiter);
1498 string2.Append(simpleChar); // final line
1500 for (TInt i = 0; i < numLines; i++) // ...numlines + 1
1502 string3.Append(simpleChar);
1503 string3.Append(CEditableText::EParagraphDelimiter);
1505 string3.Append(simpleChar); // final line
1509 paginator1->SetDocumentL(iEtext);
1511 paginator1->AppendTextL(docPos);
1512 TInt numPages=paginator1->PaginationCompletedL();
1516 paginator2->SetDocumentL(iEtext);
1518 paginator2->AppendTextL(docPos);
1519 numPages=paginator2->PaginationCompletedL();
1523 paginator3->SetDocumentL(iEtext);
1525 paginator3->AppendTextL(docPos);
1526 numPages=paginator3->PaginationCompletedL();
1529 delete charsPerPage1;
1530 delete charsPerPage2;
1531 delete charsPerPage3;
1532 delete screenDevice;
1538 @SYMTestCaseID SYSLIB-FORM-UT-4002
1539 @SYMTestCaseDesc Test to ensure the CTextView::SetSelectionVisibilityL will not panic when EFTextVisible
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.
1547 void CTextViewTest::TestForPDEF113755L()
1549 test.Next(_L(" @SYMTestCaseID:SYSLIB-FORM-UT-4002 Testing fix for PDEF113755 "));
1552 TCursorSelection selection(0,8); // length of selection must be >0
1553 iView->SetSelectionL(selection);
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());
1561 iView->MakeVisible(EFalse);
1562 iView->SetSelectionVisibilityL(ETrue); //Should never panic form::1200 here
1563 iView->SetSelectionVisibilityL(EFalse);
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.
1578 void CTextViewTest::TestForPDEF115165L()
1580 test.Next(_L(" @SYMTestCaseID:SYSLIB-FORM-UT-4004 Testing fix for PDEF115165 "));
1583 TCharFormat charFormat = TCharFormat(_L("Arial"),100);
1584 TCharFormatMask charFormatMask;
1585 charFormatMask.SetAll();
1586 iCharLayer->SetL(charFormat, charFormatMask);
1587 iEtext->SetGlobalCharFormat(iCharLayer);
1588 _LIT(KLtoRChar,"a");
1589 _LIT(KRtoLChar,"\x6B2");
1590 _LIT(KLtoRText,"aaa");
1591 _LIT(KRtoLText,"\x6B2\x6B2\x6B2");
1592 _LIT(KParaSep, "\x2029");
1596 // Test for 16 scenarios of Bidi texts..
1597 // Sample text for test
1598 // Doc_Pos: | 0| 1| 2| 5| 4| 3| 6| 7| 8|11|10| 9|
1599 // X-Coords: |0| 5|10|15|20|25|30|35|40|45|50|55|60| in case w=5
1602 iEtext->InsertL(0,KLtoRText);
1603 iEtext->InsertL(iEtext->DocumentLength(),KRtoLText);
1604 iEtext->InsertL(iEtext->DocumentLength(),KLtoRText);
1605 iEtext->InsertL(iEtext->DocumentLength(),KRtoLText);
1606 iEtext->InsertL(iEtext->DocumentLength(),KParaSep);
1607 iView->FormatTextL();
1609 TPoint point1,point2;
1610 iLayout->DocPosToXyPosL(0,point1);
1611 iLayout->DocPosToXyPosL(1,point2);
1613 TInt wLTR = point2.iX - point1.iX; //It depends on platform. WINSCW/H4 w=5; H6 w=4
1615 iLayout->DocPosToXyPosL(5,point1);
1616 iLayout->DocPosToXyPosL(4,point2);
1617 TInt wRTL = point2.iX - point1.iX; //It depends on platform. WINSCW/H4 w=5; H6 w=4
1618 RDebug::Print(_L("wLTR %d,wRTL %d"), wLTR,wRTL);
1620 // DocPos1 is LTR, DocPos1+1 is LTR, DocPos2 is LTR, DocPos2+1 is RTL
1621 rect = iLayout->GetLineRectL(0,2);
1622 RDebug::Print(_L("iTl.iX %d,iY %d, iBr.iX %d,iY %d"), rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY);
1623 test(rect.iTl.iX == 0 && rect.iBr.iX == 3*wLTR);
1625 // DocPos1 is LTR, DocPos1+1 is LTR, DocPos2 is RTL, DocPos2+1 is RTL
1626 rect = iLayout->GetLineRectL(0,4);
1627 RDebug::Print(_L("iTl.iX %d,iY %d, iBr.iX %d,iY %d"), rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY);
1628 test(rect.iTl.iX == 0 && rect.iBr.iX == 3*wLTR + 2*wRTL);
1630 // DocPos1 is LTR, DocPos1+1 is LTR, DocPos2 is RTL, DocPos2+1 is LTR
1631 rect = iLayout->GetLineRectL(0,5);
1632 RDebug::Print(_L("iTl.iX %d,iY %d, iBr.iX %d,iY %d"), rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY);
1633 test(rect.iTl.iX == 0 && rect.iBr.iX == 3*wLTR + wRTL);
1635 // DocPos1 is LTR, DocPos1+1 is LTR, DocPos2 is LTR, DocPos2+1 is LTR
1636 rect = iLayout->GetLineRectL(0,7);
1637 RDebug::Print(_L("iTl.iX %d,iY %d, iBr.iX %d,iY %d"), rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY);
1638 test(rect.iTl.iX == 0 && rect.iBr.iX == 3*wLTR + 3*wRTL + 2*wLTR);
1640 // DocPos1 is LTR, DocPos1+1 is RTL, DocPos2 is LTR, DocPos2+1 is LTR
1641 rect = iLayout->GetLineRectL(2,7);
1642 RDebug::Print(_L("iTl.iX %d,iY %d, iBr.iX %d,iY %d"), rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY);
1643 test(rect.iTl.iX == 2*wLTR && rect.iBr.iX == 3*wLTR + 3*wRTL + 2*wLTR);
1645 // DocPos1 is LTR, DocPos1+1 is RTL, DocPos2 is LTR, DocPos2+1 is RTL
1646 rect = iLayout->GetLineRectL(2,8);
1647 RDebug::Print(_L("iTl.iX %d,iY %d, iBr.iX %d,iY %d"), rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY);
1648 test(rect.iTl.iX == 2*wLTR && rect.iBr.iX == 3*wLTR + 3*wRTL + 3*wLTR);
1650 // DocPos1 is LTR, DocPos1+1 is RTL, DocPos2 is RTL, DocPos2+1 is LTR
1651 rect = iLayout->GetLineRectL(2,5);
1652 RDebug::Print(_L("iTl.iX %d,iY %d, iBr.iX %d,iY %d"), rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY);
1653 test(rect.iTl.iX == 2*wLTR && rect.iBr.iX == 3*wLTR + wRTL);
1655 // DocPos1 is LTR, DocPos1+1 is RTL, DocPos2 is RTL, DocPos2+1 is RTL
1656 rect = iLayout->GetLineRectL(2,4);
1657 RDebug::Print(_L("iTl.iX %d,iY %d, iBr.iX %d,iY %d"), rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY);
1658 test(rect.iTl.iX == 2*wLTR && rect.iBr.iX == 3*wLTR + 2*wRTL);
1660 // Sample text for test
1661 // Doc_Pos: | 9|10|11| 8| 7| 6| 3| 4| 5| 2| 1| 0|
1662 // X-Coords: |40|45|50|55|60|65|70|75|80|85|90|95|100| in case w=5
1665 iEtext->InsertL(0,KRtoLText);
1666 iEtext->InsertL(iEtext->DocumentLength(),KLtoRText);
1667 iEtext->InsertL(iEtext->DocumentLength(),KRtoLText);
1668 iEtext->InsertL(iEtext->DocumentLength(),KLtoRText);
1669 iEtext->InsertL(iEtext->DocumentLength(),KParaSep);
1670 iView->FormatTextL();
1672 // DocPos1 is RTL, DocPos1+1 is LTR, DocPos2 is LTR, DocPos2+1 is LTR
1673 rect = iLayout->GetLineRectL(2,4);
1674 RDebug::Print(_L("iTl.iX %d,iY %d, iBr.iX %d,iY %d"), rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY);
1675 test(rect.iTl.iX == iWindowRect.Width() - 3*wRTL - 2*wLTR && rect.iBr.iX == iWindowRect.Width() - 2*wRTL);
1677 // DocPos1 is RTL, DocPos1+1 is LTR, DocPos2 is LTR, DocPos2+1 is RTL
1678 rect = iLayout->GetLineRectL(2,5);
1679 RDebug::Print(_L("iTl.iX %d,iY %d, iBr.iX %d,iY %d"), rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY);
1680 test(rect.iTl.iX == iWindowRect.Width() - 3*wRTL - wLTR && rect.iBr.iX == iWindowRect.Width() - 2*wRTL);
1682 // DocPos1 is RTL, DocPos1+1 is LTR, DocPos2 is RTL, DocPos2+1 is LTR
1683 rect = iLayout->GetLineRectL(2,8);
1684 RDebug::Print(_L("iTl.iX %d,iY %d, iBr.iX %d,iY %d"), rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY);
1685 test(rect.iTl.iX == iWindowRect.Width() - 3*wRTL - 3*wLTR - 3*wRTL && rect.iBr.iX == iWindowRect.Width() - 2*wRTL);
1687 // DocPos1 is RTL, DocPos1+1 is LTR, DocPos2 is RTL, DocPos2+1 is RTL
1688 rect = iLayout->GetLineRectL(2,7);
1689 RDebug::Print(_L("iTl.iX %d,iY %d, iBr.iX %d,iY %d"), rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY);
1690 test(rect.iTl.iX == iWindowRect.Width() - 3*wRTL - 3*wLTR - 2*wRTL && rect.iBr.iX == iWindowRect.Width() - 2*wRTL);
1692 // DocPos1 is RTL, DocPos1+1 is RTL, DocPos2 is LTR, DocPos2+1 is LTR
1693 rect = iLayout->GetLineRectL(0,4);
1694 RDebug::Print(_L("iTl.iX %d,iY %d, iBr.iX %d,iY %d"), rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY);
1695 test(rect.iTl.iX == iWindowRect.Width() - 3*wRTL - 2*wLTR && rect.iBr.iX == 100);
1697 // DocPos1 is RTL, DocPos1+1 is RTL, DocPos2 is LTR, DocPos2+1 is RTL
1698 rect = iLayout->GetLineRectL(0,5);
1699 RDebug::Print(_L("iTl.iX %d,iY %d, iBr.iX %d,iY %d"), rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY);
1700 test(rect.iTl.iX == iWindowRect.Width() - 3*wRTL - wLTR && rect.iBr.iX == 100);
1702 // DocPos1 is RTL, DocPos1+1 is RTL, DocPos2 is RTL, DocPos2+1 is LTR
1703 rect = iLayout->GetLineRectL(0,8);
1704 RDebug::Print(_L("iTl.iX %d,iY %d, iBr.iX %d,iY %d"), rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY);
1705 test(rect.iTl.iX == iWindowRect.Width() - 3*wRTL - 3*wLTR - 3*wRTL && rect.iBr.iX == 100);
1707 // DocPos1 is RTL, DocPos1+1 is RTL, DocPos2 is RTL, DocPos2+1 is RTL
1708 rect = iLayout->GetLineRectL(0,7);
1709 RDebug::Print(_L("iTl.iX %d,iY %d, iBr.iX %d,iY %d"), rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY);
1710 test(rect.iTl.iX == iWindowRect.Width() - 3*wRTL - 3*wLTR - 2*wRTL && rect.iBr.iX == 100);
1716 // 1st Line: | 0| 1| 2| 3| 4| 5| 6| 7| 8| 9|10|11|19|18|17|16|15|14|13|12|
1717 // 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
1718 // 2nd Line: |23|22|21|20|
1722 // 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|
1723 // 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
1724 // 2nd Line: |29|28|27|26|25|24|23|22|21|20|
1726 TInt LtoRLength = (iWindowRect.Width() - 5*wRTL)/wLTR;
1727 TInt RtoLLength = 10;
1728 TInt RtoLinLine1= (iWindowRect.Width() - LtoRLength * wLTR)/wRTL;
1729 TInt Line2Start = LtoRLength + RtoLinLine1;
1732 for(TInt i=0;i<LtoRLength;i++)
1734 iEtext->InsertL(iEtext->DocumentLength(),KLtoRChar);
1737 for(TInt i=0;i<RtoLLength;i++)
1739 iEtext->InsertL(iEtext->DocumentLength(),KRtoLChar);
1741 iEtext->InsertL(iEtext->DocumentLength(),KParaSep);
1742 iView->FormatTextL();
1744 for(TInt i=0;i<LtoRLength + RtoLLength;i++)
1746 rect = iLayout->GetLineRectL(i,i+1);
1747 RDebug::Print(_L("%d: iTl.iX %d,iY %d, iBr.iX %d,iY %d"), i,rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY);
1750 rect = iLayout->GetLineRectL(0,LtoRLength);
1751 RDebug::Print(_L("iTl.iX %d,iY %d, iBr.iX %d,iY %d"), rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY);
1752 test(rect.iTl.iX == 0 && rect.iBr.iX == LtoRLength*wLTR + RtoLinLine1*wRTL ); //Line 1
1754 rect = iLayout->GetLineRectL(Line2Start, LtoRLength + RtoLLength);
1755 RDebug::Print(_L("iTl.iX %d,iY %d, iBr.iX %d,iY %d"), rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY);
1756 test(rect.iTl.iX == 0 && rect.iBr.iX == (RtoLLength - RtoLinLine1)*wRTL); //Line 2
1758 rect = iLayout->GetLineRectL(0,0);
1759 RDebug::Print(_L("iTl.iX %d,iY %d, iBr.iX %d,iY %d"), rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY);
1760 test(rect.iTl.iX == 0 && rect.iBr.iX == wLTR); //first char
1763 rect = iLayout->GetLineRectL(LtoRLength,LtoRLength);
1764 RDebug::Print(_L("iTl.iX %d,iY %d, iBr.iX %d,iY %d"), rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY);
1765 test(rect.iTl.iX == LtoRLength*wLTR + (RtoLinLine1-1)*wRTL && rect.iBr.iX == LtoRLength*wLTR + RtoLinLine1*wRTL); //end of line 1
1768 rect = iLayout->GetLineRectL(LtoRLength/2,LtoRLength/2);
1769 RDebug::Print(_L("iTl.iX %d,iY %d, iBr.iX %d,iY %d"), rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY);
1770 test(rect.iTl.iX == LtoRLength/2 * wLTR && rect.iBr.iX == (LtoRLength/2+1) * wLTR);
1772 //middle of LTR to first of RTL
1773 rect = iLayout->GetLineRectL(LtoRLength/2,LtoRLength);
1774 RDebug::Print(_L("iTl.iX %d,iY %d, iBr.iX %d,iY %d"), rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY);
1775 test(rect.iTl.iX == LtoRLength/2 * wLTR && rect.iBr.iX == LtoRLength*wLTR + RtoLinLine1*wRTL);
1777 //second of RTL to start of 2nd line ??
1778 rect = iLayout->GetLineRectL(LtoRLength+1,Line2Start);
1779 RDebug::Print(_L("iTl.iX %d,iY %d, iBr.iX %d,iY %d"), rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY);
1780 test(rect.iTl.iX == LtoRLength*wLTR + (RtoLinLine1-1)*wRTL && rect.iBr.iX == LtoRLength*wLTR + RtoLinLine1*wRTL); //end of line 1
1783 rect = iLayout->GetLineRectL(LtoRLength/2,LtoRLength/2-1);
1784 RDebug::Print(_L("iTl.iX %d,iY %d, iBr.iX %d,iY %d"), rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY);
1785 test(rect.iTl.iX == LtoRLength/2 * wLTR && rect.iBr.iX == LtoRLength*wLTR + RtoLinLine1*wRTL);
1788 // Test for edge cases while two lines are in different direction
1790 // 1st Line: | 0| 1| 2| 3| 4| 5| 6| 7| 8| 9|10|11|12|13|14|15|16|17|18|19|
1791 // 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
1792 // 2nd Line: |39|38|37|36|35|34|33|32|31|30|29|28|27|26|25|24|23|22|21|20|
1794 // Test for edge cases while two lines are in different direction
1796 // 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|
1797 // 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
1798 // 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|
1800 LtoRLength = iWindowRect.Width()/wLTR;
1801 RtoLLength = iWindowRect.Width()/wRTL;
1804 for(TInt i=0;i<LtoRLength;i++)
1806 iEtext->InsertL(iEtext->DocumentLength(),KLtoRChar);
1809 for(TInt i=0;i<RtoLLength;i++)
1811 iEtext->InsertL(iEtext->DocumentLength(),KRtoLChar);
1813 iEtext->InsertL(iEtext->DocumentLength(),KParaSep);
1814 iView->FormatTextL();
1816 for(TInt i=0;i<LtoRLength + RtoLLength;i++)
1818 rect = iLayout->GetLineRectL(i,i+1);
1819 RDebug::Print(_L("%d: iTl.iX %d,iY %d, iBr.iX %d,iY %d"), i,rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY);
1824 rect = iLayout->GetLineRectL(3, LtoRLength-1);
1825 RDebug::Print(_L("iTl.iX %d,iY %d, iBr.iX %d,iY %d"), rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY);
1826 test(rect.iTl.iX == 3*wLTR && rect.iBr.iX == LtoRLength*wLTR); //Line 2
1829 rect = iLayout->GetLineRectL(LtoRLength,LtoRLength + RtoLLength -2);
1830 RDebug::Print(_L("iTl.iX %d,iY %d, iBr.iX %d,iY %d"), rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY);
1831 test(rect.iTl.iX == wRTL && rect.iBr.iX == RtoLLength*wRTL); //Line 2
1834 rect = iLayout->GetLineRectL(LtoRLength-1, LtoRLength-1);
1835 RDebug::Print(_L("iTl.iX %d,iY %d, iBr.iX %d,iY %d"), rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY);
1836 test(rect.iTl.iX == (LtoRLength-1)*wLTR && rect.iBr.iX == LtoRLength*wLTR); //Line 2
1839 rect = iLayout->GetLineRectL(LtoRLength, LtoRLength);
1840 RDebug::Print(_L("iTl.iX %d,iY %d, iBr.iX %d,iY %d"), rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY);
1841 test(rect.iTl.iX == (RtoLLength-1)*wRTL && rect.iBr.iX == RtoLLength*wRTL); //Line 2
1843 //1st line to 2nd line
1844 rect = iLayout->GetLineRectL(LtoRLength-1, LtoRLength);
1845 RDebug::Print(_L("iTl.iX %d,iY %d, iBr.iX %d,iY %d"), rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY);
1846 test(rect.iTl.iX == (LtoRLength-1)*wLTR && rect.iBr.iX == LtoRLength*wLTR); //Line 2
1852 @SYMTestCaseID SYSLIB-FORM-UT-4007
1853 @SYMTestCaseDesc Test for PDEF118443
1854 @SYMTestPriority Normal
1855 @SYMTestActions Use test cases in form of "text + ZWJ + non-text characters", format the line,
1856 then use CTmTextLayout::FindAdjacentChunks() to find text Chunks surrounding
1857 the ZWJ. then verify if the text is broken at the correct place.
1858 @SYMTestExpectedResults CTmTextLayout::FindAdjacentChunks() should return:
1859 - Left chunk = "text + ZWJ",
1860 - Right chunk = "non-text characters".
1863 void CTextViewTest::TestForPDEF118443L()
1865 test.Next(_L(" @SYMTestCaseID:SYSLIB-FORM-UT-4007 Testing fix for PDEF118443 "));
1868 TCharFormat charFormat = TCharFormat(_L("ClearlyU"),10);
1869 TCharFormatMask charFormatMask;
1870 charFormatMask.SetAll();
1871 iCharLayer->SetL(charFormat, charFormatMask);
1872 iEtext->SetGlobalCharFormat(iCharLayer);
1874 // Note: a 'W' is added at the front to make the text chunk have side-bearings, so that it won't be amalgamated
1875 // with the following chunk. This is to make the test case be as same as the original use case that caused the defect.
1876 _LIT(KScriptEndWithZWJ,"W\x0931\x094d\x200d"); // Scripte end with ZWJ (a 'W' in the front)
1877 _LIT(KTextTestCase0,"\x2029"); // Paragraph seperator (Bidi Category: B)
1878 _LIT(KTextTestCase1,"0"); // Digit 0 (Bidi Category: EN)
1879 _LIT(KTextTestCase2,"+"); // Plus sign (Bidi Category: ES)
1880 _LIT(KTextTestCase3,"\u00A3"); // Pound symbol (Bidi Category: ET)
1881 _LIT(KTextTestCase4,"."); // Period (Bidi Category: CS)
1882 _LIT(KTextTestCase5,"\x0009"); // Tab (Bidi Category: S)
1883 _LIT(KTextTestCase6,"\x0020"); // Space (Bidi Category: WS)
1884 _LIT(KTextTestCase7,"\x000C"); // Form feed (Bidi Category: WS)
1885 _LIT(KTextTestCase8,"\x2028"); // Line breaker (Bidi Category: WS)
1887 TTmDocPosSpec pos(4, TTmDocPosSpec::ETrailing);
1888 CTmTextLayout::TTmChunkDescription left;
1889 CTmTextLayout::TTmChunkDescription right;
1891 // Test case 0: ZWJ + Paragraph seperater
1893 iEtext->InsertL(0,KScriptEndWithZWJ);
1894 iEtext->InsertL(iEtext->DocumentLength(),KTextTestCase0);
1895 iView->FormatTextL();
1896 iLayout->TagmaTextLayout().FindAdjacentChunks(pos, left, right);
1897 test(left.iStart == 0);
1898 test(left.iEnd == 4);
1899 test(left.iRightToLeft == EFalse);
1900 test(right.iStart == 4);
1901 test(right.iRightToLeft == EFalse);
1903 // Test case 1: ZWJ + Digit '0'
1905 iEtext->InsertL(0,KScriptEndWithZWJ);
1906 iEtext->InsertL(iEtext->DocumentLength(),KTextTestCase1);
1907 iView->FormatTextL();
1908 iLayout->TagmaTextLayout().FindAdjacentChunks(pos, left, right);
1909 test(left.iStart == 0);
1910 test(left.iEnd == 4);
1911 test(left.iRightToLeft == EFalse);
1912 test(right.iStart == 4);
1913 test(right.iRightToLeft == EFalse);
1915 // Test case 2: ZWJ + Plus sign '+'
1917 iEtext->InsertL(0,KScriptEndWithZWJ);
1918 iEtext->InsertL(iEtext->DocumentLength(),KTextTestCase2);
1919 iView->FormatTextL();
1920 iLayout->TagmaTextLayout().FindAdjacentChunks(pos, left, right);
1921 test(left.iStart == 0);
1922 test(left.iEnd == 4);
1923 test(left.iRightToLeft == EFalse);
1924 test(right.iStart == 4);
1925 test(right.iRightToLeft == EFalse);
1927 // Test case 3: ZWJ + Pound symbol '??'
1929 iEtext->InsertL(0,KScriptEndWithZWJ);
1930 iEtext->InsertL(iEtext->DocumentLength(),KTextTestCase3);
1931 iView->FormatTextL();
1932 iLayout->TagmaTextLayout().FindAdjacentChunks(pos, left, right);
1933 test(left.iStart == 0);
1934 test(left.iEnd == 4);
1935 test(left.iRightToLeft == EFalse);
1936 test(right.iStart == 4);
1937 test(right.iRightToLeft == EFalse);
1939 // Test case 0: ZWJ + Period '.'
1941 iEtext->InsertL(0,KScriptEndWithZWJ);
1942 iEtext->InsertL(iEtext->DocumentLength(),KTextTestCase4);
1943 iView->FormatTextL();
1944 iLayout->TagmaTextLayout().FindAdjacentChunks(pos, left, right);
1945 test(left.iStart == 0);
1946 test(left.iEnd == 4);
1947 test(left.iRightToLeft == EFalse);
1948 test(right.iStart == 4);
1949 test(right.iRightToLeft == EFalse);
1951 // Test case 0: ZWJ + Tab Character
1953 iEtext->InsertL(0,KScriptEndWithZWJ);
1954 iEtext->InsertL(iEtext->DocumentLength(),KTextTestCase5);
1955 iView->FormatTextL();
1956 iLayout->TagmaTextLayout().FindAdjacentChunks(pos, left, right);
1957 test(left.iStart == 0);
1958 test(left.iEnd == 4);
1959 test(left.iRightToLeft == EFalse);
1960 test(right.iStart == 4);
1961 test(right.iRightToLeft == EFalse);
1963 // Test case 0: ZWJ + Space
1965 iEtext->InsertL(0,KScriptEndWithZWJ);
1966 iEtext->InsertL(iEtext->DocumentLength(),KTextTestCase6);
1967 iView->FormatTextL();
1968 iLayout->TagmaTextLayout().FindAdjacentChunks(pos, left, right);
1969 test(left.iStart == 0);
1970 test(left.iEnd == 4);
1971 test(left.iRightToLeft == EFalse);
1972 test(right.iStart == 4);
1973 test(right.iRightToLeft == EFalse);
1975 // Test case 0: ZWJ + Form feed
1977 iEtext->InsertL(0,KScriptEndWithZWJ);
1978 iEtext->InsertL(iEtext->DocumentLength(),KTextTestCase7);
1979 iView->FormatTextL();
1980 iLayout->TagmaTextLayout().FindAdjacentChunks(pos, left, right);
1981 test(left.iStart == 0);
1982 test(left.iEnd == 4);
1983 test(left.iRightToLeft == EFalse);
1984 test(right.iStart == 4);
1985 test(right.iRightToLeft == EFalse);
1987 // Test case 0: ZWJ + Line breaker
1989 iEtext->InsertL(0,KScriptEndWithZWJ);
1990 iEtext->InsertL(iEtext->DocumentLength(),KTextTestCase8);
1991 iView->FormatTextL();
1992 iLayout->TagmaTextLayout().FindAdjacentChunks(pos, left, right);
1993 test(left.iStart == 0);
1994 test(left.iEnd == 4);
1995 test(left.iRightToLeft == EFalse);
1996 test(right.iStart == 4);
1997 test(right.iRightToLeft == EFalse);
2003 @SYMTestCaseID SYSLIB-FORM-UT-4016
2004 @SYMTestCaseDesc Testing the fix for PDEF121798 Printing: Email is printed only two pages
2005 @SYMTestPriority Medium
2006 @SYMTestActions Paginates random amounts of text and checks whether the correct number of pages are returned from pagination.
2007 @SYMTestExpectedResults The amount of pages produced by the paginator should match the expected number of pages based on lines of text, page size, etc.
2010 void CTextViewTest::TestForPDEF121798L()
2012 test.Next(_L("Testing fix for PDEF121798"));
2013 CTestScreenDevice* screenDevice = new(ELeave) CTestScreenDevice(iEnv.ScreenDevice(),iWindow);
2016 margins.iTop = 1440;
2017 margins.iBottom = 1440;
2018 margins.iLeft = 1440;
2019 margins.iRight = 1440;
2020 TSize s(11906,16838);
2021 TPageSpec p(TPageSpec::EPortrait, s);
2023 // We need to find out the height of lines and print area of the page.
2024 // From this we determine how many lines *should* appear on the page.
2025 // This differs between devices(ie. hw and winscw).
2026 TInt pageHeight = screenDevice->VerticalTwipsToPixels(s.iHeight - margins.iTop - margins.iBottom);
2027 _LIT(KDummyString,"this is used by dummy paginator to find out line height and page size");
2029 AddTextL(KDummyString);
2030 TInt lineHeight = 0;
2031 CParaFormat* paraFormat = CParaFormat::NewL();
2032 iEtext->GetParagraphFormatL(paraFormat,0);
2033 TBool pageBreakChar = EFalse;
2035 iLayout->FormatLineL(paraFormat,docPos,lineHeight,pageBreakChar);
2037 CArrayFixFlat<TInt>* charsPerPage = new(ELeave) CArrayFixFlat<TInt>(KGranularity);
2038 TInt numLines = pageHeight/lineHeight; // Number of lines expected on a page with paginator settings defined above and line height.
2042 // Perform 50 random pagination tests.
2043 for(TInt numTests = 0; numTests < 50; numTests++)
2045 // Generate the number of lines in this document.
2046 TBuf<512> testString;
2047 TInt randomNum = (Math::Random() % 512);
2048 // Calculate the expected number of pages based on page size and line height
2049 TInt expectedPages = randomNum/numLines;
2050 // If it's not an exact fit there will be another page lost in the integer division.
2051 if ((numLines * expectedPages != randomNum) || randomNum == 0)
2055 // Append the random number of lines to the test string
2056 for (TInt i = 0; i < randomNum-1; i++) // randomNum -1 because we add a character after the loop.
2058 // Empty lines will do.
2059 testString.Append(CEditableText::EParagraphDelimiter);
2061 // End the text with a character rather than a paragraph delim.
2062 testString.Append(_L("A"));
2066 AddTextL(testString);
2067 // Set up the paginator.
2068 CTextPaginator* paginator = CTextPaginator::NewL(screenDevice, charsPerPage, KPaginatePriority);
2069 paginator->SetPageMarginsInTwips(margins);
2070 paginator->SetPageSpecInTwips(p);
2071 paginator->SetDocumentL(iEtext);
2073 paginator->AppendTextL(docPos);
2074 TInt numPages=paginator->PaginationCompletedL();
2075 RDebug::Printf("%d lines: Expected %d pages, got %d pages", randomNum, expectedPages, numPages);
2076 test(expectedPages == numPages);
2079 delete charsPerPage;
2080 delete screenDevice;
2086 @SYMTestCaseID SYSLIB-FORM-UT-4015
2087 @SYMTestCaseDesc Test for PDEF120239
2088 @SYMTestPriority Normal
2089 @SYMTestActions Use text consist of "LTR text + ZWJ + RTL Text", format the line, then:
2090 1) use CTmTextLayout::FindAdjacentChunks() to find chunks around overlapped doc pos.
2091 2) use CTextView::MoveCursorL to move cursor through out the line.
2092 @SYMTestExpectedResults 1) FindAdjacentChunks() returns correct chunks
2093 2) Cursor should moves Left to Right and Right to Left correctly
2096 void CTextViewTest::TestForPDEF120239L()
2098 test.Next(_L("Testing fix for PDEF120239L"));
2101 TCharFormat charFormat = TCharFormat(_L("NewTimes"),10);
2102 TCharFormatMask charFormatMask;
2103 charFormatMask.SetAll();
2104 iCharLayer->SetL(charFormat, charFormatMask);
2105 iEtext->SetGlobalCharFormat(iCharLayer);
2107 _LIT(KTestScript,"\x0931\x094d\x200d\x684"); // Test script (LTR text + ZWJ + RTL Text)
2110 iEtext->InsertL(0,KTestScript);
2111 iView->FormatTextL();
2113 // 1) use CTmTextLayout::FindAdjacentChunks()
2114 CTmTextLayout::TTmChunkDescription left;
2115 CTmTextLayout::TTmChunkDescription right;
2117 TTmDocPosSpec pos(3, TTmDocPosSpec::ETrailing);
2119 iLayout->TagmaTextLayout().FindAdjacentChunks(pos, left, right);
2120 test(left.iStart == 0);
2121 test(left.iEnd == 3);
2122 test(!left.iRightToLeft);
2123 test(right.iStart == 2);
2124 test(right.iEnd == 4);
2125 test(right.iRightToLeft);
2128 pos.iType = TTmDocPosSpec::ELeading;
2130 iLayout->TagmaTextLayout().FindAdjacentChunks(pos, left, right);
2131 test(left.iStart == 2);
2132 test(left.iEnd == 4);
2133 test(left.iRightToLeft);
2134 test(right.iStart == 4);
2135 test(right.iEnd == 5);
2136 test(!right.iRightToLeft);
2138 // 2) use CTextView::MoveCursorL to move cursor
2139 TTmDocPos cursorPos;
2140 TTmDocPos targetPos1 (0, ETrue);
2141 TTmDocPos targetPos2 (0, EFalse);
2142 TCursorPosition::TMovementType move = TCursorPosition::EFRight;
2144 TCursorSelection selection(0,0);
2145 iView->SetSelectionL(selection);
2146 iView->GetCursorPos(cursorPos);
2147 test(cursorPos == targetPos1 || cursorPos == targetPos2);
2149 targetPos1.iPos = 3;
2150 targetPos1.iLeadingEdge = EFalse;
2151 targetPos2.iPos = 4;
2152 targetPos2.iLeadingEdge = EFalse;
2153 iView->MoveCursorL(move, EFalse);
2154 iView->GetCursorPos(cursorPos);
2155 test(cursorPos == targetPos1 || cursorPos == targetPos2);
2157 targetPos1.iPos = 2;
2158 targetPos1.iLeadingEdge = ETrue;
2159 targetPos2.iPos = 4;
2160 targetPos2.iLeadingEdge = ETrue;
2161 iView->MoveCursorL(move, EFalse);
2162 iView->GetCursorPos(cursorPos);
2163 test(cursorPos == targetPos1 || cursorPos == targetPos2);
2165 move = TCursorPosition::EFLeft;
2167 targetPos1.iPos = 3;
2168 targetPos1.iLeadingEdge = EFalse;
2169 targetPos2.iPos = 4;
2170 targetPos2.iLeadingEdge = EFalse;
2171 iView->MoveCursorL(move, EFalse);
2172 iView->GetCursorPos(cursorPos);
2173 test(cursorPos == targetPos1 || cursorPos == targetPos2);
2175 targetPos1.iPos = 0;
2176 targetPos1.iLeadingEdge = EFalse;
2177 targetPos2.iPos = 0;
2178 targetPos2.iLeadingEdge = ETrue;
2179 iView->MoveCursorL(move, EFalse);
2180 iView->GetCursorPos(cursorPos);
2181 test(cursorPos == targetPos1 || cursorPos == targetPos2);
2187 @SYMTestCaseID SYSLIB-FORM-UT-4021
2188 @SYMTestCaseDesc Test for DEF124989, to ensure TFormAndEtextEditor::SetStyleHelperL has no
2189 NULL-dereference issue.
2190 @SYMTestPriority Normal
2191 @SYMTestActions Call TFormAndEtextEditor::InsertTextL and pass in a style name which could
2192 not be found in styleList.Then a NULL is generated.
2193 @SYMTestExpectedResults No panic(KERN-EXEC 3) raised from this case.
2196 void CTextViewTest::TestForDEF124989L()
2198 // Initialise CTextViewTest object for next test.
2200 test.Next(_L(" @SYMTestCaseID:SYSLIB-FORM-UT-4021 Testing fix for DEF124989 "));
2202 // Insert a one line paragraph into EText object and reformat view.
2203 _LIT(KTestParagraph, "This is a piece of text to test the character positioning API based in X,Y cocordinates.");
2204 iEtext->InsertL(0, KTestParagraph);
2206 TFormAndEtextEditor newEditor(*iView,*iEtext);
2208 CStyleList* styleList = CStyleList::NewL();
2209 CleanupStack::PushL(styleList);
2210 RParagraphStyleInfo paraStyleInfo(NULL,NULL);
2212 // Appending the new style to stylelist
2213 styleList->AppendL(¶StyleInfo);
2214 iEtext->SetStyleListExternallyOwned(*styleList);
2216 TPtrC ptr1(_L("Arial3"));
2217 // Inserting the text and applying the style specified(Arial3)
2218 // which is not in syleList.
2219 newEditor.InsertTextL(0, _L("Hello World"),&ptr1);
2221 // Clean up test object
2222 CleanupStack::PopAndDestroy();
2227 @SYMTestCaseID SYSLIB-FORM-UT-4022
2228 @SYMTestCaseDesc Test for DEF124975
2229 @SYMTestPriority Normal
2230 @SYMTestActions 1) Call CTextLayout::AdjustVerticalAlignment() when there is no content
2231 2) Add Some random text and then call CTextLayout::AdjustVerticalAlignment()@SYMTestExpectedResults There should be no panic during the process
2234 void CTextViewTest::TestForDEF124975L()
2236 test.Next(_L(" @SYMTestCaseID: Testing fix for coverity DEF124975 "));
2239 const TInt MaxTestCount = 50;
2240 const TInt MaxStringCount = 100;
2241 TInt TestCount = GetNumber(1, MaxTestCount);
2242 TInt StringCount = GetNumber(1, MaxStringCount);
2244 for(TInt i=0; i<TestCount; i++)
2246 iLayout->AdjustVerticalAlignment(CParaFormat::ECustomAlign);
2249 for(TInt i=0; i<TestCount; i++)
2252 testString.Create(StringCount);
2253 for(int i=0; i<testString.MaxLength(); i++)
2255 TInt c = GetNumber(0, 0xffff);
2256 while ( IsSurrogate(c) )
2257 c = GetNumber(0, 0xffff);
2258 testString.Append( c );
2260 AddTextL(testString);
2261 iLayout->AdjustVerticalAlignment(CParaFormat::ECustomAlign);
2268 void CTextViewTest::TestForDEF142286BounceScrollingL()
2270 test.Next(_L(" Testing fix for DEF142286 which supports bounce scrolling feature "));
2271 TestScrollDisplayPixelsNoLimitBordersL(10);
2272 TestScrollDisplayPixelsNoLimitBordersL(50);
2273 TestScrollDisplayPixelsNoLimitBordersL(100);
2276 void RunTestsL(CCoeEnv& aEnv)
2278 CTextViewTest* t = new(ELeave) CTextViewTest(aEnv);
2279 CleanupStack::PushL(t);
2283 t->TestCancelSelectionL();
2284 t->TestFinishBackgroundFormattingL();
2285 t->TestSetCursorVisibilityL();
2286 t->TestSetSelectionVisibilityL();
2287 t->TestEnablePictureFrameL();
2288 t->TestSetCursorWidthTypeL();
2289 t->TestParagraphRectL();
2291 t->TestFormatTextL();
2292 t->TestHandleRangeFormatChangeL();
2293 t->TestHandleInsertDeleteL();
2294 t->TestHandleGlobalChangeL();
2295 t->TestHandleGlobalChangeNoRedrawL();
2296 t->TestScrollDisplayL();
2297 t->TestScrollDisplayPixelsL();
2298 t->TestScrollDisplayLinesL();
2299 t->TestScrollDisplayParagraphsL();
2300 t->TestMoveCursorL();
2301 t->TestSetSelectionL();
2302 t->TestMatchCursorHeightL();
2303 t->TestCalculateHorizontalExtremesL();
2304 t->TestXyPosToDocPosL();
2305 t->TestGetPictureRectangleL();
2306 t->TestGetPictureRectangle1L();
2307 //t->TestGetPictureRectangleDefectL();
2308 t->TestSetDisplayContextL();
2309 t->TestGetParaFormatL();
2310 t->TestGetLineRectL();
2311 t->TestForDEF003426L();
2312 t->TestForDEF038488L();
2313 t->FormAndEtextTestL();
2314 t->TestForINC092725L();
2315 t->TestForPDEF108443L();
2316 t->TestForPDEF113755L();
2317 t->TestForPDEF115165L();
2318 t->TestForPDEF118443L();
2319 t->TestForPDEF121798L();
2320 t->TestForDEF124989L();
2321 t->TestForPDEF120239L();
2322 t->TestForDEF124975L();
2323 t->TestForDEF142286BounceScrollingL();
2324 CleanupStack::PopAndDestroy(t);
2329 CCoeEnv* env=new CCoeEnv;
2337 #if defined(__WINS__)
2338 EXPORT_C TInt EntryPoint(TAny*) {return E32Main();}