Update contrib.
2 * Copyright (c) 2002-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.
21 #include "TCustomWrap.h"
22 #include "TGraphicsContext.h"
23 #include "TBitmapDoc.h"
24 #include "TestPicture.h"
33 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
34 #include "TAGMA_INTERNAL.H"
37 namespace LocalToFile {
39 _LIT(KTTextView2, "TTextView2");
40 const TInt KDisplayWidth = 100;
41 const TInt KDisplayHeight = 100;
42 const TInt KAleph = 0x5D0;
43 const TInt KPictureCharacter = 0xFFFC;
44 const TInt KRightToLeftMarker = 0x200F;
45 const TInt KZeroWidthNonJoiner = 0x200C;
46 RTest test(KTTextView2);
48 /** Simple test picture. */
49 class CPinkSquare : public CPicture
52 // Size of square in twips.
53 // 600 is 15 pixels using the standard test graphics device at
54 // its default resolution.
55 enum { KWidth = 600, KHeight = 600 };
57 void Draw(CGraphicsContext& aGc, const TPoint& aTopLeft,
58 const TRect& aClipRect, MGraphicsDeviceMap* aMap) const
60 // This picture is a magenta square
61 TPoint size(KWidth, KHeight);
63 size = aMap->TwipsToPixels(size);
64 TRect rect(aTopLeft, aTopLeft + size);
65 aGc.SetClippingRect(aClipRect);
66 aGc.SetDrawMode(CGraphicsContext::EDrawModePEN);
67 aGc.SetPenColor(KRgbMagenta);
68 aGc.SetBrushStyle(CGraphicsContext::ESolidBrush);
69 aGc.SetBrushColor(KRgbMagenta);
72 void ExternalizeL(RWriteStream&) const {}
73 void GetOriginalSizeInTwips(TSize& a) const
75 a.iWidth = CPinkSquare::KWidth;
76 a.iHeight = CPinkSquare::KHeight;
81 /** Lightweight test document model. */
82 class TDocModel : public MLayDoc
85 TDocModel(const TDesC& aDes)
86 : iDes(&aDes), iParagraphFormat(0), iBreakPos(0) {}
87 void SetParagraphFormat(CParaFormat* a)
91 /** Sets the segmentation of the buffer to cut at this point.
92 aParam a 0 means no break at all. */
93 void SetBreakPos(TInt a)
98 TInt LdDocumentLength() const { return iDes->Length(); }
99 TInt LdToParagraphStart(TInt& a) const
102 if (a < LdDocumentLength())
104 a = iDes->Left(a).LocateReverse(0x2029);
105 a = a < 0? 0 : a + 1;
109 void GetParagraphFormatL(CParaFormat* aFormat, TInt) const
111 if (iParagraphFormat)
113 aFormat->CopyL(*iParagraphFormat);
118 tabStop.iTwipsPosition = 1000;
119 tabStop.iType = TTabStop::ELeftTab;
120 aFormat->StoreTabL(tabStop);
122 void GetChars(TPtrC& aView,TCharFormat& aFormat, TInt aStartPos)const
126 TInt docLength = LdDocumentLength();
127 if (aStartPos < iBreakPos && iBreakPos < docLength)
128 aView.Set(iDes->Mid(aStartPos, iBreakPos - aStartPos));
129 else if (aStartPos == docLength)
132 aView.Set(iDes->Mid(aStartPos));
134 TInt GetPictureSizeInTwips(TSize& aSize, TInt aPos) const
136 if ((*iDes)[aPos] != KPictureCharacter)
138 aSize.iWidth = CPinkSquare::KWidth;
139 aSize.iHeight = CPinkSquare::KHeight;
142 CPicture* PictureHandleL(TInt aPos, TForcePictureLoad) const
144 if ((*iDes)[aPos] != KPictureCharacter)
146 return new(ELeave) CPinkSquare;
148 TBool EnquirePageBreak(TInt aPos, TInt aLength)const
150 return iDes->Mid(aPos, aLength).Locate(0x000C) < 0?
153 TBool SelectParagraphLabel(TInt) { return EFalse; }
154 void CancelSelectLabel() {}
157 CParaFormat* iParagraphFormat;
162 // Remaps whatever character is used in construction to the letter 'E'
163 class TTestCustomRemap : public MFormCustomInvisibleCharacterRemapper
166 TTestCustomRemap(TUint aChar)
170 TUint Remap(TUint aChar, const TNonPrintingCharVisibility aNonPrintingCharVisibility,
171 const TLayDocTextSource& aLayDoc)
179 return DefaultMapping(aChar, aNonPrintingCharVisibility, aLayDoc);
187 // Remaps all break characters to the letter 'E'
188 class TTestCustomRemapper : public MFormCustomInvisibleCharacterRemapper
191 TUint Remap(TUint aChar, const TNonPrintingCharVisibility aNonPrintingCharVisibility,
192 const TLayDocTextSource& aLayDoc)
196 case CEditableText::ELineBreak:
197 case CEditableText::EParagraphDelimiter:
198 case CEditableText::EPageBreak:
205 return DefaultMapping(aChar, aNonPrintingCharVisibility, aLayDoc);
209 using namespace LocalToFile;
214 static void SetOffScreenContext(CTextView* aView, CBitmapContext* aContext)
216 aView->iOffScreenContext = aContext;
218 static TRect GetInvalidRect(CTextView* aView)
220 return aView->iDisplay.ClippingRect();
222 static int GetFormattedHeight(CTextView* aView)
224 return aView->iFormattedUpTo;
226 static void TestMemberOffsetsL()
228 // The members of these classes must not move due to inline method offsets.
229 // Any of the following tests failing will indicate a BC break.
230 test(_FOFF(CTextView, iLayout)==64);
231 test(_FOFF(CTextView, iCursorPos)==192);
232 test(_FOFF(CTextView, iFlags)==240);
233 test(_FOFF(CTextView, iObserver)==264);
237 class CTestTextLayout
240 static void TestMemberOffsetsL()
242 // The members of these classes must not move due to inline method offsets.
243 // Any of the following tests failing will indicate a BC break.
244 test(_FOFF(CTextLayout, iText)==4);
245 test(_FOFF(CTextLayout, iBandTop)==104);
246 test(_FOFF(CTextLayout, iScrollFlags)==116);
247 test(_FOFF(CTextLayout, iHighlightExtensions)==128);
251 // Test for TET-5D7MCV: Sound object focus indicators flickering
252 _LIT(KPicture, "\xFFFC");
253 _LIT(KInitialText, "xy");
255 void SetViewRect1(CTextView *aView)
257 TRect view(0, 0, 100, 100);
258 aView->SetViewRect(view);
261 void SetViewRect2(CTextView *aView)
263 TRect view(10, 15, 60, 65);
264 aView->SetViewRect(view);
267 void TET_5D7MCV_L(TDes& aText, CTestGraphicsDevice* aDevice, CTextView* aView,
268 CTextLayout* aLayout)
270 // This is supposed to test flicker-free redraw, but that is very difficult
271 // to test properly, so we do what we can:
272 // 1) If flicker-free redraw is disabled and there is no off-screen context set,
273 // there should be drawing to the real device
274 // 2) If there is an off-screen context set, there should be drawing to the
275 // off-screen context, and not the real device
276 // 3) If flicker-free redraw is enabled and there is no off-screen context set,
277 // there should be no drawing to the real device.
278 // We are not testing that the correct thing is drawn to the internal off-screen
279 // bitmap when flicker-free redraw is enabled. This is bad, but I can't work
280 // out a good way round it. As the off-screen context uses much of the same
281 // machinery as flicker-free redraw, it tests maybe 80% of it.
283 CTestGraphicsDevice* offScreenDevice = CTestGraphicsDevice::NewL(aDevice->SizeInPixels(), 0);
284 CleanupStack::PushL(offScreenDevice);
285 CWindowGc* offScreenContext;
286 User::LeaveIfError(offScreenDevice->CreateContext(offScreenContext));
287 CleanupStack::PushL(offScreenContext);
289 CTestTextView::SetOffScreenContext(aView, 0);
290 aView->DisableFlickerFreeRedraw();
292 aText.Append(KInitialText);
293 aView->HandleInsertDeleteL(TCursorSelection(0,KInitialText().Length()), 0, EFalse);
294 aText.Insert(1, KPicture);
295 aView->HandleInsertDeleteL(TCursorSelection(1,2), 0, ETrue);
296 aView->SetCursorVisibilityL(TCursor::EFCursorVisible, TCursor::EFCursorVisible);
297 aView->SetSelectionVisibilityL(ETrue);
298 aView->EnablePictureFrameL(ETrue);
299 TRect* pictureRectPtr;
301 aView->SetXyPosL(TPoint(11, 1), EFalse, pictureRectPtr, frameEdges);
302 test(pictureRectPtr != 0);
303 aDevice->ClearAreaDrawnWithCondition();
304 offScreenDevice->ClearAreaDrawnWithCondition();
305 aView->DrawL(TRect(0, 0, CPinkSquare::KWidth, CPinkSquare::KHeight));
306 test(!aDevice->AreaDrawnWithCondition().IsEmpty());
307 test(offScreenDevice->AreaDrawnWithCondition().IsEmpty());
308 aDevice->ClearAreaDrawnWithCondition();
309 offScreenDevice->ClearAreaDrawnWithCondition();
311 CTestTextView::SetOffScreenContext(aView, offScreenContext);
312 aView->EnableFlickerFreeRedraw();
314 aView->DrawL(TRect(0, 0, CPinkSquare::KWidth, CPinkSquare::KHeight));
315 test(aDevice->AreaDrawnWithCondition().IsEmpty());
316 TRect xoredArea = offScreenDevice->AreaDrawnWithCondition();
317 test(!xoredArea.IsEmpty());
318 offScreenDevice->ClearAreaDrawnWithCondition();
320 const TRect &viewRect = aView->ViewRect();
321 aView->DrawL(viewRect);
322 test(aDevice->AreaDrawnWithCondition().IsEmpty());
323 test(offScreenDevice->AreaDrawnWithCondition() == xoredArea);
325 // We need a CFbsDevice -- this will supply fonts that can be drawn to the
326 // offscreen bitmap created by the flicker-free redraw code.
327 CFbsBitmap* bm = new CFbsBitmap;
328 CleanupStack::PushL(bm);
329 bm->Create(TSize(1,1), EGray2);
330 CFbsBitmapDevice* bitmapDevice = CFbsBitmapDevice::NewL(bm);
331 CleanupStack::PushL(bitmapDevice);
332 aLayout->SetImageDeviceMap(bitmapDevice);
333 CTestTextView::SetOffScreenContext(aView, 0);
334 aView->EnableFlickerFreeRedraw();
336 aView->DrawL(TRect(0, 0, CPinkSquare::KWidth, CPinkSquare::KHeight));
337 test(aDevice->AreaDrawnWithCondition().IsEmpty());
338 xoredArea = offScreenDevice->AreaDrawnWithCondition();
339 test(!xoredArea.IsEmpty());
340 offScreenDevice->ClearAreaDrawnWithCondition();
342 aView->DrawL(viewRect);
343 test(aDevice->AreaDrawnWithCondition().IsEmpty());
345 aLayout->SetImageDeviceMap(aDevice);
346 CleanupStack::PopAndDestroy(bitmapDevice);
347 CleanupStack::PopAndDestroy(bm);
348 CTestTextView::SetOffScreenContext(aView, 0);
349 aView->DisableFlickerFreeRedraw();
351 aDevice->ClearAreaDrawnWithCondition();
352 offScreenDevice->ClearAreaDrawnWithCondition();
353 aView->DrawL(viewRect);
354 test(offScreenDevice->AreaDrawnWithCondition().IsEmpty());
355 xoredArea.Move(viewRect.iTl);
356 test(aDevice->AreaDrawnWithCondition() == xoredArea);
358 CleanupStack::PopAndDestroy(offScreenContext);
359 CleanupStack::PopAndDestroy(offScreenDevice);
362 @SYMTestCaseID SYSLIB-FORM-CT-4014
363 @SYMTestCaseDesc Tests CTextView::IsPictureFrameSelected doesn't panic with EFNoPictureFrame
364 @SYMTestPriority High
366 @SYMTestExpectedResults Resulting document position are where expected and frame drawn correctly.
367 In this case picture frame is not drawn as we set the selection visibility to "off"
370 void RunPDEF118831TestL()
372 //create editor/bitmap
373 CTestBitmapFile* bitMap = CTestBitmapFile::NewLC(TRect(0, 0, 140, 185));
375 //create the picture to insert (this one is a red box)
376 CTestPicture* pic = new(ELeave)CTestPicture();
377 CleanupStack::PushL(pic);
378 pic->SetSizeInTwips(TSize(400,400));
380 //add some text before the pictures
381 bitMap->AppendL(_L("A"));
385 for (pos=0;pos<2;pos++)
386 bitMap->AppendL(pic);
388 //add some text after the pictures
389 bitMap->AppendL(_L("A"));
390 bitMap->View()->HandleGlobalChangeL();
392 //As a result we have
394 //with cursor pos: 01 1 2 2 3 4
396 //SetSelectionVisibility to false
397 bitMap->View()->SetSelectionVisibilityL(EFalse);
399 // Place the cursor at the end of the last picture added and start moving the cursor left.
400 TCursorPosition::TMovementType type = TCursorPosition::EFLeft;
402 // Docuemnt position is already at the end, but it is Trailing. Make it Leading and set it.
403 TTmDocPosSpec::TType docPosType = TTmDocPosSpec::ELeading;
406 TTmDocPosSpec docPos;
408 docPos.iType = docPosType;
411 TBool selectionIsPictureFrame;
413 // Cursor on last letter "A"
414 bitMap->View()->SetDocPosL(docPos);
415 bitMap->View()->GetCursorPos(thisPos);
416 selectionIsPictureFrame
417 = bitMap->View()->IsPictureFrameSelected(dummyRect, dummyPos);
418 test(thisPos.iPos == 4 && type == TCursorPosition::EFLeft);
419 test(selectionIsPictureFrame == 0);
422 // Cursor moved to first (from the right) picture but picture frame not selected
423 bitMap->View()->MoveCursorL(type, EFalse);
424 bitMap->View()->GetCursorPos(thisPos);
425 selectionIsPictureFrame
426 = bitMap->View()->IsPictureFrameSelected(dummyRect, dummyPos);
427 test(thisPos.iPos == 3 && type == TCursorPosition::EFLeft);
428 test(selectionIsPictureFrame == 0);
432 // Cursor still on first picture and now picture frame has been selected
433 bitMap->View()->MoveCursorL(type, EFalse);
434 bitMap->View()->GetCursorPos(thisPos);
435 selectionIsPictureFrame
436 = bitMap->View()->IsPictureFrameSelected(dummyRect, dummyPos);
437 test(thisPos.iPos == 2 && type == TCursorPosition::EFLeft);
438 test(selectionIsPictureFrame == 1);
441 // Cursor on second picture and picture frame not selected
442 bitMap->View()->MoveCursorL(type, EFalse);
443 bitMap->View()->GetCursorPos(thisPos);
444 selectionIsPictureFrame
445 = bitMap->View()->IsPictureFrameSelected(dummyRect, dummyPos);
446 test(thisPos.iPos == 2 && type == TCursorPosition::EFLeft);
447 test(selectionIsPictureFrame == 0);
451 // Cusror still on second picture and picture frame has been selected
452 bitMap->View()->MoveCursorL(type, EFalse);
453 bitMap->View()->GetCursorPos(thisPos);
454 selectionIsPictureFrame
455 = bitMap->View()->IsPictureFrameSelected(dummyRect, dummyPos);
456 test(thisPos.iPos == 1 && type == TCursorPosition::EFLeft);
457 test(selectionIsPictureFrame == 1);
460 // Cursor moved to second letter "A"
461 bitMap->View()->MoveCursorL(type, EFalse);
462 bitMap->View()->GetCursorPos(thisPos);
463 selectionIsPictureFrame
464 = bitMap->View()->IsPictureFrameSelected(dummyRect, dummyPos);
465 test(thisPos.iPos == 1 && type == TCursorPosition::EFLeft);
466 test(selectionIsPictureFrame == 0);
470 bitMap->View()->MoveCursorL(type, EFalse);
471 bitMap->View()->GetCursorPos(thisPos);
472 selectionIsPictureFrame
473 = bitMap->View()->IsPictureFrameSelected(dummyRect, dummyPos);
474 test(thisPos.iPos == 0 && type == TCursorPosition::EFLeft);
475 test(selectionIsPictureFrame == 0);
478 CleanupStack::Pop(pic);
479 CleanupStack::PopAndDestroy(1);
482 Test for defect INC020746: Visual cursor position update incorrect at end of
485 void INC020746_L(TDes& aText, CTextView* aView)
489 aText.Append(0x5D0); // Aleph
491 aView->DisableFlickerFreeRedraw();
492 aView->HandleGlobalChangeL();
493 TTmDocPosSpec pos(2, TTmDocPosSpec::ELeading);
494 aView->SetDocPosL(pos);
496 aView->GetCursorPos(posOut);
497 test(posOut.iPos == 2);
498 test(posOut.iLeadingEdge);
499 pos.iType = TTmDocPosSpec::ETrailing;
500 aView->SetDocPosL(pos);
501 aView->GetCursorPos(posOut);
502 test(posOut.iPos == 2);
503 test(!posOut.iLeadingEdge);
507 @SYMTestCaseID SYSLIB-FORM-UT-1653
508 @SYMTestCaseDesc Test to make sure an ordinary hyphen is returned when a potential hyphen is inserted.
509 @SYMTestPriority Critical.
510 @SYMTestActions Insets a potential hyphen into some text and then check the output once it has passed
511 through MTmCustom::Map.
512 @SYMTestExpectedResults The test must not fail.
513 @SYMDEF INC080603: Soft Hyphen is not replaced by Ordinary Hyphen in Tagma
516 // Test code had to be changed because of a problem in BullseyeCoverage, which does not like
517 // dealing with certain hexadecimal character combinations in string literals.
518 void INC080603L(TDes& aText, CTestGraphicsDevice* aDevice,CTextLayout* aLayout, CTextView* aView)
520 _LIT(KInputText, "ABCDEFABCDEF");
521 const TUint16 Hyphen = 0x00ad;
523 aDevice->LineArray().ResetLineArray();
524 aDevice->LineArray().Enable();
528 aText.Insert(6, (TPtrC(&Hyphen,1)));
531 aLayout->SetWrapWidth(aView->ViewRect().Width());
532 aLayout->ForceNoWrapping(CTextLayout::EFParagraphsWrappedByDefault);
534 aView->HandleGlobalChangeL();
536 TBuf<3> des2 (aDevice->LineArray().Line(1).LineData()); //Hyphen should be on this line
537 TInt pos = des2.Find(_L("-"));
538 test (pos != KErrNotFound);
540 aDevice->LineArray().Disable();
544 DEF035472 - Non-printable char detection api does not report correct result
546 void DEF035472_L(TDes& aText, CTextView* aView)
548 const TChar leftToRightMarker(0x200E);
550 aText.Append(leftToRightMarker);
551 aText.Append(leftToRightMarker);
552 aText.Append(leftToRightMarker);
554 aText.Append(leftToRightMarker);
555 aText.Append(leftToRightMarker);
556 aText.Append(leftToRightMarker);
557 aView->HandleGlobalChangeL();
558 TTmDocPosSpec position(3, TTmDocPosSpec::ELeading);
559 aView->SetDocPosL(position);
560 TCursorSelection selection = aView->GetBackwardDeletePositionL();
561 test(selection.LowerPos() == 0);
562 test(selection.HigherPos() == 3);
563 position.iType = TTmDocPosSpec::ETrailing;
564 aView->SetDocPosL(position);
565 selection = aView->GetBackwardDeletePositionL();
566 test(selection.LowerPos() == 0);
567 test(selection.HigherPos() == 3);
569 aView->SetDocPosL(position);
570 selection = aView->GetForwardDeletePositionL();
571 test(selection.LowerPos() == 4);
572 test(selection.HigherPos() == 7);
573 position.iType = TTmDocPosSpec::ELeading;
574 aView->SetDocPosL(position);
575 selection = aView->GetForwardDeletePositionL();
576 test(selection.LowerPos() == 4);
577 test(selection.HigherPos() == 7);
581 INC036005 - Word--difficult to place focus on an object in word.
582 This defect is caused by a defect in Form in which when finding a position
583 by x-y coordinate, the trailing edge is never found, always the leading edge.
584 This means that the trailing edge of the picture is incorrectly identified as
585 the leading edge of the following character and the picture is not highlighted.
586 This test tests that the trailing edge of characters is found correctly.
588 void INC036005_L(TDes& aText, CTextView* aView)
595 aView->DisableFlickerFreeRedraw();
596 aView->HandleGlobalChangeL();
597 aView->SetLeftTextMargin(0);
598 aView->SetViewLineAtTopL(1);
600 test(1 == aView->XyPosToDocPosL(pt));
602 test(1 == aView->XyPosToDocPosL(pt));
607 aView->HandleGlobalChangeL();
608 aView->SetLeftTextMargin(0);
609 aView->SetViewLineAtTopL(1);
611 test(1 == aView->XyPosToDocPosL(pt));
613 test(1 == aView->XyPosToDocPosL(pt));
615 // Test with real picture
618 aText.Append(KPictureCharacter);
620 aView->HandleGlobalChangeL();
621 aView->SetLeftTextMargin(0);
622 aView->SetViewLineAtTopL(1);
626 aView->SetXyPosL(pt, EFalse, rect, edges);
627 TCursorSelection sel = aView->Selection();
628 test(sel.LowerPos() == 1 && sel.HigherPos() == 2);
629 aView->SetDocPosL(0, EFalse);
631 aView->SetXyPosL(pt, EFalse, rect, edges);
632 sel = aView->Selection();
633 test(sel.LowerPos() == 1 && sel.HigherPos() == 2);
635 // Test with real picture and potentially confusing ambiguities
638 aText.Append(KRightToLeftMarker);
639 aText.Append(KPictureCharacter);
640 aText.Append(KRightToLeftMarker);
642 aView->HandleGlobalChangeL();
643 aView->SetLeftTextMargin(0);
644 aView->SetViewLineAtTopL(1);
646 aView->SetXyPosL(pt, EFalse, rect, edges);
647 sel = aView->Selection();
648 test(sel.LowerPos() == 2 && sel.HigherPos() == 3);
649 aView->SetDocPosL(0, EFalse);
651 aView->SetXyPosL(pt, EFalse, rect, edges);
652 sel = aView->Selection();
653 test(sel.LowerPos() == 2 && sel.HigherPos() == 3);
657 // INC085809: CSHelp - Scrolling doesn't work properly, length of the bar changes weirdly
658 // With the fix in PosRangeInBand, the output in this case will be one pixel larger than before
659 void INC085809_L(CTextLayout* aLayout, CTextView* aView)
662 TRect view(0, 0, 102, 26);
663 aView->SetViewRect(view);
664 TInt output = aLayout->PosRangeInBand(input);
668 // Utility functions to show contents of test data using test.Printf
670 _LIT(KAddressMarker, "> ");
672 _LIT(KLength, ", Length of Data = %d 16-bit words\r\n");
675 _LIT(KSingleString, "%s\r\n");
678 void PrintTestData (const TDesC& aTitle , const TDesC16& aData)
685 TInt length = aData.Length();
690 buffer.Append(aTitle);
691 buffer.Append(KLength);
693 test.Printf(buffer, length);
695 for (i = 0 ; i < length ; i += 8)
698 buffer.AppendNumFixedWidth(i, EHex, 8);
699 buffer += KAddressMarker;
701 end = ((length-i) >= 8) ? i+8 : length;
703 for (j = i ; j < end ; ++j)
705 buffer.AppendNumFixedWidth(aData[j], EHex, 4);
708 buffer += TPtrC(KSpaces().Ptr(), ((8-(j-i))*5)+4);
710 for (j = i ; j < end ; ++j)
714 buffer.Append(aData[j]);
721 buffer.ZeroTerminate();
722 test.Printf(KSingleString, buffer.Ptr());
727 void PrintTestData(const TDesC& aTitle, const TText16* aDataBuffer, const TInt aSize)
729 PrintTestData(aTitle, TPtrC16(aDataBuffer, aSize));
733 _LIT(KTavSequence, "\x05ea\x05ea\x05ea\x05ea\x05ea\x05ea\x05ea\x05ea\x05ea\x05ea");
735 _LIT(KMixedSequence, "\x05d1\x05d2\x05d3\x05d4\x05d5\x05d6\x05d7\x05d8\x05d9 JCDEFGHIJ "
736 L"\x05da\x05db\x05dc\x05dd\x05de\x05df\x05e0\x05e1\x05e2 KLMNOPQRS ");
738 static const TInt KChunksPerTest = 9;
739 static const TInt KDirectionalityTests = 5;
741 static const TPtrC16 KDirectionalityResults[KDirectionalityTests][KChunksPerTest] =
744 _S("\xffff\x0020\xffff"),
745 _S("\xffff\x05d9\x05d8\x05d7\x05d6\x05d5\x05d4\x05d3\x05d2\x05d1\x05d0\xffff"),
746 _S("\xffff\x0020\xffff"),
747 _S("\xffff\x004a\x0043\x0044\x0045\x0046\x0047\x0048\x0049\x004a\xffff"),
748 _S("\xffff\x0020\xffff"),
749 _S("\xffff\x05e2\x05e1\x05e0\x05df\x05de\x05dd\x05dc\x05db\x05da\xffff"),
750 _S("\xffff\xffff\xffff"),
751 _S("\xffff\x0020\xffff"),
752 _S("\xffff\x004b\x004c\x004d\x004e\x004f\x0050\x0051\x0052\x0053\xffff")
755 _S("\xffff\x0020\xffff"),
756 _S("\xffff\x05d9\x05d8\x05d7\x05d6\x05d5\x05d4\x05d3\x05d2\x05d1\xffff"),
757 _S("\xffff\x0020\xffff"),
758 _S("\xffff\x004a\x0043\x0044\x0045\x0046\x0047\x0048\x0049\x004a\xffff"),
759 _S("\xffff\x0020\xffff"),
760 _S("\xffff\x05e2\x05e1\x05e0\x05df\x05de\x05dd\x05dc\x05db\x05da\xffff"),
761 _S("\xffff\xffff\xffff"),
762 _S("\xffff\x0020\xffff"),
763 _S("\xffff\x004b\x004c\x004d\x004e\x004f\x0050\x0051\x0052\x0053\xffff"),
766 _S("\xffff\x0049\xffff"),
767 _S("\xffff\x05d9\x05d8\x05d7\x05d6\x05d5\x05d4\x05d3\x05d2\x05d1\xffff"),
768 _S("\xffff\x0020\xffff"),
769 _S("\xffff\x004a\x0043\x0044\x0045\x0046\x0047\x0048\x0049\x004a\xffff"),
770 _S("\xffff\x0020\xffff"),
771 _S("\xffff\x05e2\x05e1\x05e0\x05df\x05de\x05dd\x05dc\x05db\x05da\xffff"),
772 _S("\xffff\x0020\xffff"),
773 _S("\xffff\x004b\x004c\x004d\x004e\x004f\x0050\x0051\x0052\x0053\x0020\xffff\xffff"),
774 _S("\xffff\xffff\xffff"),
777 _S("\xffff\x0020\xffff"),
778 _S("\xffff\x05d9\x05d8\x05d7\x05d6\x05d5\x05d4\x05d3\x05d2\x05d1\xffff"),
779 _S("\xffff\x0020\xffff"),
780 _S("\xffff\x004a\x0043\x0044\x0045\x0046\x0047\x0048\x0049\x004a\xffff"),
781 _S("\xffff\x0020\xffff"),
782 _S("\xffff\x05e2\x05e1\x05e0\x05df\x05de\x05dd\x05dc\x05db\x05da\xffff"),
783 _S("\xffff\xffff\xffff"),
784 _S("\xffff\x0020\xffff"),
785 _S("\xffff\x004b\x004c\x004d\x004e\x004f\x0050\x0051\x0052\x0053\xffff"),
788 _S("\xffff\x0020\xffff"),
789 _S("\xffff\x05d9\x05d8\x05d7\x05d6\x05d5\x05d4\x05d3\x05d2\x05d1\x05d0\xffff"),
790 _S("\xffff\x0020\xffff"),
791 _S("\xffff\x004a\x0043\x0044\x0045\x0046\x0047\x0048\x0049\x004a\xffff"),
792 _S("\xffff\x0020\xffff"),
793 _S("\xffff\x05e2\x05e1\x05e0\x05df\x05de\x05dd\x05dc\x05db\x05da\xffff"),
794 _S("\xffff\xffff\xffff"),
795 _S("\xffff\x0020\xffff"),
796 _S("\xffff\x004b\x004c\x004d\x004e\x004f\x0050\x0051\x0052\x0053\xffff"),
800 _LIT(KTitle1, "Initial format (RtoL)");
801 _LIT(KTitle2, "Deleting first character , still RtoL");
802 _LIT(KTitle3, "Inserting a first character, now LtoR");
803 _LIT(KTitle4, "Deleting first character , becoming RtoL");
804 _LIT(KTitle5, "Inserting a first character, still RToL");
805 _LIT(KPassed, "passed\r\n");
806 _LIT(KFailed, "failed\r\n");
807 _LIT(KExpected, "Expected");
809 _LIT(KCase, "Test case %d, testing chunk %d\r\n");
813 const TUint16 KUnicodeLetterA = 'I';
814 const TUint16 KUnicodeLetterHebrewAlef = 0x05d0;
816 TPtrC KLUnicodeLetterA(&KUnicodeLetterA,1);
817 TPtrC KLUnicodeLetterHebrewAlef(&KUnicodeLetterHebrewAlef,1);
819 void DirectionalityTestL(TDes& aText, CTestGraphicsDevice* aDevice, CTextLayout* aLayout, CTextView* aView)
821 test.Next(_L("Testing paragraph directionality of editable text"));
822 CTestGraphicsDevice* offScreenDevice = CTestGraphicsDevice::NewL(aDevice->SizeInPixels(), 0);
823 CleanupStack::PushL(offScreenDevice);
824 offScreenDevice->SetLineArray(aDevice->LineArray());
825 CWindowGc* offScreenContext;
826 User::LeaveIfError(offScreenDevice->CreateContext(offScreenContext));
827 CleanupStack::PushL(offScreenContext);
828 CTestTextView::SetOffScreenContext(aView, offScreenContext);
829 aView->EnableFlickerFreeRedraw();
834 TBool allPassed = ETrue;
835 TInt chunksInThisTest;
836 for (TInt testCase = 0 ; testCase < KDirectionalityTests ; ++testCase)
838 test.Printf(_L("Directionality test case %d\r\n"), testCase+1);
840 aDevice->LineArray().ResetLineArray();
841 chunksInThisTest = KChunksPerTest;
846 aLayout->SetAmountToFormat(CTextLayout::EFFormatAllText);
848 aDevice->LineArray().ResetLineArray();
849 aText.Append(KUnicodeLetterHebrewAlef); //first strong character is right-to-left
850 aText.Append(KMixedSequence); //rest of test data is constant
851 aView->HandleGlobalChangeL();
852 aView->FinishBackgroundFormattingL();
856 aView->SetDocPosL(0,EFalse);
857 aDevice->LineArray().ResetLineArray();
858 aText.Delete(0,1); //delete the first character
859 aView->HandleGlobalChangeL();
863 aView->SetDocPosL(0,EFalse);
864 aDevice->LineArray().ResetLineArray();
865 aText.Insert(0,KLUnicodeLetterA); //replace first character with a left-to-right one
866 aView->HandleGlobalChangeL();
867 chunksInThisTest = KChunksPerTest - 1;
871 aView->SetDocPosL(0,EFalse);
872 aDevice->LineArray().ResetLineArray();
873 aText.Delete(0,1); //delete the first character
874 aView->HandleGlobalChangeL();
878 aView->SetDocPosL(0,EFalse);
879 aDevice->LineArray().ResetLineArray();
880 aText.Insert(0,KLUnicodeLetterHebrewAlef); //replace first character with a right-to-left one again
881 aView->HandleGlobalChangeL();
884 test.Printf(_L("Directionality test %d undefined\r\n"), testCase);
888 for (i = 0; i < chunksInThisTest ; ++i)
890 const TDesC16& des1 = KDirectionalityResults[testCase][i];
891 const TDesC16& des2 = aDevice->LineArray().Line(i).LineData();
892 match = (des1.Compare(des2) == 0);
895 test.Printf(KCase, testCase, i);
896 PrintTestData(KExpected, KDirectionalityResults[testCase][i]);
897 PrintTestData(KGot, aDevice->LineArray().Line(i).LineData());
899 passed = passed && match;
903 test.Printf(KPassed);
908 test.Printf(KFailed);
912 CTestTextView::SetOffScreenContext(aView, 0);
913 CleanupStack::PopAndDestroy(offScreenContext);
914 CleanupStack::PopAndDestroy(offScreenDevice);
917 // Test for defect DEF021603: Visual cursor position update incorrect when insert a LTR char after
919 void DEF021603_L(TDes& aText, CTestGraphicsDevice* aDevice, CTextView* aView)
921 CTestGraphicsDevice* offScreenDevice = CTestGraphicsDevice::NewL(aDevice->SizeInPixels(), 0);
922 CleanupStack::PushL(offScreenDevice);
923 CWindowGc* offScreenContext;
924 User::LeaveIfError(offScreenDevice->CreateContext(offScreenContext));
925 CleanupStack::PushL(offScreenContext);
926 CTestTextView::SetOffScreenContext(aView, offScreenContext);
930 aText.Append(KLUnicodeLetterHebrewAlef);
931 aText.Append(KLUnicodeLetterHebrewAlef);
932 aText.Append(KLUnicodeLetterA);
933 aView->HandleCharEditL(CTextLayout::EFCharacterInsert, EFalse);
934 aView->GetCursorPos(posOut);
935 test(!posOut.iLeadingEdge); // should be on trailing edge (rhs)
937 CleanupStack::PopAndDestroy(offScreenContext);
938 CleanupStack::PopAndDestroy(offScreenDevice);
942 _LIT(KText_022229, "ABCDEFGHIJABCDEFGHIJABCDEFGHIJABCABCDEFGHIJABCDEFGHIJABCDEFGHIJ");
945 Test for defect DEF022229: Form: Cursor sent to 'home' position on Page up/down
948 void DEF022229_L(TDes& aText, CTestGraphicsDevice* aDevice, CTextView* aView)
951 CTestGraphicsDevice* offScreenDevice = CTestGraphicsDevice::NewL(aDevice->SizeInPixels(), 0);
952 CleanupStack::PushL(offScreenDevice);
953 CWindowGc* offScreenContext;
954 User::LeaveIfError(offScreenDevice->CreateContext(offScreenContext));
955 CleanupStack::PushL(offScreenContext);
956 CTestTextView::SetOffScreenContext(aView, offScreenContext);
959 aText = KText_022229;
960 aView->SetDocPosL(0);
961 test(cursorPos.iPos==0);
964 TCursorPosition::TMovementType lineDown = TCursorPosition::EFLineDown;
965 aView->MoveCursorL(lineDown, EFalse);
966 aView->GetCursorPos(cursorPos);
967 TInt compare = cursorPos.iPos;
970 TCursorPosition::TMovementType pageDown = TCursorPosition::EFPageDown;
971 aView->MoveCursorL(pageDown, EFalse);
972 aView->GetCursorPos(cursorPos);
973 test(cursorPos.iPos!=0);
976 TCursorPosition::TMovementType pageUp = TCursorPosition::EFPageUp;
977 aView->MoveCursorL(pageUp, EFalse);
978 aView->GetCursorPos(cursorPos);
979 test(cursorPos.iPos==compare);
981 CTestTextView::SetOffScreenContext(aView, 0);
982 CleanupStack::PopAndDestroy(offScreenContext);
983 CleanupStack::PopAndDestroy(offScreenDevice);
987 Tests that CTextView::XyPosToDocPosL returns the correct positions in the case
988 where the point passed in is beyond the horizontal bounds of the line.
990 void TestCTextView_XyPosToDocPosL_ReturnsCorrectLine(
991 TDes& aText, CTextView* aView)
993 aText = _L("abcdef ghijkl\x2029zyxwvu.");
994 aView->HandleGlobalChangeL();
996 TInt pos = aView->XyPosToDocPosL(pt);
999 pos = aView->XyPosToDocPosL(pt);
1000 test(pos == 6 || pos == 5);
1002 pos = aView->XyPosToDocPosL(pt);
1005 pos = aView->XyPosToDocPosL(pt);
1008 pos = aView->XyPosToDocPosL(pt);
1011 pos = aView->XyPosToDocPosL(pt);
1012 test(pos == 20 || pos == 21);
1015 void INC036809_L(TDes& aText, CTextView* aView)
1018 aView->HandleGlobalChangeL();
1019 TTmPosInfo2 posInfo;
1020 TTmDocPosSpec pos(1, TTmDocPosSpec::ELeading);
1021 TBool result = aView->FindDocPosL(pos, posInfo);
1023 test(posInfo.iDocPos.iPos == 1);
1024 test(posInfo.iDocPos.iLeadingEdge);
1025 test(posInfo.iEdge.iX = 30);
1027 pos.iType = TTmDocPosSpec::ETrailing;
1028 result = aView->FindDocPosL(pos, posInfo);
1030 test(posInfo.iDocPos.iPos == 2);
1031 test(!posInfo.iDocPos.iLeadingEdge);
1032 test(posInfo.iEdge.iX = 45);
1033 pos.iType = TTmDocPosSpec::ELeading;
1034 result = aView->FindDocPosL(pos, posInfo);
1036 test(posInfo.iDocPos.iPos == 2);
1037 test(posInfo.iDocPos.iLeadingEdge);
1038 test(posInfo.iEdge.iX = 45);
1041 void DEF037255_L(TDes& aText, CTextView* aView)
1043 // 0x2004 = 3-per-em space: 3 pixels in the test font
1044 // 0x2029 = Paragraph delimiter
1045 // 0xFFFC = object replacement character
1046 aText = _L("\x2004\x2004Y\x2029\xFFFC\x2029\x2004\x2004W");
1047 aView->EnablePictureFrameL(ETrue);
1048 aView->HandleGlobalChangeL();
1049 TTmDocPos pos(1, EFalse);
1050 aView->SetDocPosL(pos);
1051 const TCursorPosition::TMovementType down = TCursorPosition::EFLineDown;
1052 TCursorPosition::TMovementType m = down;
1053 aView->MoveCursorL(m, EFalse);
1054 TCursorSelection sel = aView->Selection();
1055 test(sel.LowerPos() == 4);
1056 test(sel.HigherPos() == 5);
1058 aView->MoveCursorL(m, EFalse);
1059 sel = aView->Selection();
1060 test(sel.LowerPos() == 7);
1061 test(sel.HigherPos() == 7);
1064 /** Tests that the horizontal scroll position is within acceptable bounds.
1066 void TestCursorPosition(const CTextView* aView)
1068 TInt hsj = aView->HorizontalScrollJump();
1069 TInt width = aView->ViewRect().Width();
1070 TInt buffer = width / 10;
1073 aView->Layout()->CalculateHorizontalExtremesL(left, right, ETrue, EFalse);
1074 TInt minCursorX = 0;
1075 TInt maxCursorX = width;
1078 left -= hsj + buffer;
1079 minCursorX = buffer;
1083 right += hsj + buffer;
1084 maxCursorX = width - buffer;
1086 TInt ltm = aView->LeftTextMargin();
1088 aView->GetCursorPos(docPos);
1089 TTmPosInfo2 posInfo;
1090 TTmLineInfo lineInfo;
1091 TBool docPosFormatted = aView->Layout()
1092 ->FindDocPos(docPos, posInfo, &lineInfo);
1093 TBool cursorIsOutsideBounds = posInfo.iEdge.iX < lineInfo.iInnerRect.iTl.iX
1094 || lineInfo.iInnerRect.iBr.iX <= posInfo.iEdge.iX? ETrue : EFalse;
1095 TInt cursorX = posInfo.iEdge.iX - ltm;
1096 test(docPosFormatted);
1097 test((left <= ltm && ltm + width <= right)
1098 || cursorIsOutsideBounds);
1099 test((minCursorX <= cursorX && cursorX <= maxCursorX)
1100 || cursorIsOutsideBounds);
1103 void INC037293_L(TDes& aText, CTextView* aView, CTextLayout* aLayout)
1105 aView->EnablePictureFrameL(EFalse);
1106 aLayout->ForceNoWrapping(CTextLayout::EFAllParagraphsNotWrapped);
1107 aLayout->SetWrapWidth(aView->ViewRect().Width());
1109 aView->HandleGlobalChangeL();
1110 TestCursorPosition(aView);
1111 TCursorPosition::TMovementType move;
1112 for (TInt i0 = 0; i0 != 20; ++i0)
1114 aText.Append('a' + i0);
1115 TCursorSelection sel(i0, i0 + 1);
1116 aView->HandleInsertDeleteL(sel, 0, EFalse);
1117 TestCursorPosition(aView);
1119 move = TCursorPosition::EFLineBeg;
1120 aView->MoveCursorL(move, EFalse);
1121 TestCursorPosition(aView);
1122 move = TCursorPosition::EFLineEnd;
1123 aView->MoveCursorL(move, EFalse);
1124 TestCursorPosition(aView);
1125 for (TInt i1 = 0; i1 != 20; ++i1)
1127 move = TCursorPosition::EFLeft;
1128 aView->MoveCursorL(move, EFalse);
1129 TestCursorPosition(aView);
1131 for (TInt i2 = 0; i2 != 20; ++i2)
1133 move = TCursorPosition::EFRight;
1134 aView->MoveCursorL(move, EFalse);
1135 TestCursorPosition(aView);
1138 aView->HandleGlobalChangeL();
1139 TestCursorPosition(aView);
1140 for (TInt i3 = 0; i3 != 20; ++i3)
1142 aText.Append(KAleph);
1143 TCursorSelection sel(i3, i3 + 1);
1144 aView->HandleInsertDeleteL(sel, 0, EFalse);
1145 TestCursorPosition(aView);
1147 move = TCursorPosition::EFLineBeg;
1148 aView->MoveCursorL(move, EFalse);
1149 TestCursorPosition(aView);
1150 move = TCursorPosition::EFLineEnd;
1151 aView->MoveCursorL(move, EFalse);
1152 TestCursorPosition(aView);
1153 for (TInt i4 = 0; i4 != 20; ++i4)
1155 move = TCursorPosition::EFRight;
1156 aView->MoveCursorL(move, EFalse);
1157 TestCursorPosition(aView);
1159 for (TInt i5 = 0; i5 != 20; ++i5)
1161 move = TCursorPosition::EFLeft;
1162 aView->MoveCursorL(move, EFalse);
1163 TestCursorPosition(aView);
1167 aLayout->ForceNoWrapping(CTextLayout::EFParagraphsWrappedByDefault);
1168 aView->HandleGlobalChangeL();
1169 TestCursorPosition(aView);
1170 for (TInt i6 = 0; i6 != 10; ++i6)
1172 aText.Append('a' + i6);
1174 TCursorSelection sel(i6 * 2, i6 * 2 + 2);
1175 aView->HandleInsertDeleteL(sel, 0, EFalse);
1176 TestCursorPosition(aView);
1178 for (TInt i7 = 0; i7 != 30; ++i7)
1180 move = TCursorPosition::EFLeft;
1181 aView->MoveCursorL(move, EFalse);
1182 TestCursorPosition(aView);
1184 for (TInt i8 = 0; i8 != 30; ++i8)
1186 move = TCursorPosition::EFRight;
1187 aView->MoveCursorL(move, EFalse);
1188 TestCursorPosition(aView);
1192 aView->HandleGlobalChangeL();
1193 TestCursorPosition(aView);
1194 for (TInt i9 = 0; i9 != 10; ++i9)
1196 aText.Append(KAleph);
1198 TCursorSelection sel(i9 * 2, i9 * 2 + 2);
1199 aView->HandleInsertDeleteL(sel, 0, EFalse);
1200 TestCursorPosition(aView);
1202 for (TInt ia = 0; ia != 30; ++ia)
1204 move = TCursorPosition::EFRight;
1205 aView->MoveCursorL(move, EFalse);
1206 TestCursorPosition(aView);
1208 for (TInt ib = 0; ib != 30; ++ib)
1210 move = TCursorPosition::EFLeft;
1211 aView->MoveCursorL(move, EFalse);
1212 TestCursorPosition(aView);
1216 /** Tests that the text specified has been drawn by the device and returns
1217 its x-coordinate. */
1218 TInt XCoordinateOfText(const TDesC& aText, CTestGraphicsDevice* aDevice)
1220 const TTestGCDisplayLine* line = aDevice->LineArray().Find(aText);
1222 return line->Position().iX;
1226 INC038282 - Right-to-Left text in CSHLPCMP toolchain + Form is not formatted
1229 Tests that when the text directionality is resolved implicitly the indents,
1230 margins and bullets are on the correct sides.
1233 void INC038282_L(TDes& aText, CTestGraphicsDevice* aDevice,
1234 CTextLayout* aLayout, CTextView* aView,
1235 CParaFormat* aParagraphFormat)
1237 SetViewRect2(aView);
1238 // Gentle first test: set margins, left-to-right text, no bullets, leading alignment.
1240 aParagraphFormat->iLeftMarginInTwips = 200; // 5 pixels
1241 aParagraphFormat->iRightMarginInTwips = 600; // 15 pixels
1242 aParagraphFormat->iIndentInTwips = 280; // 7 pixels
1243 aParagraphFormat->iHorizontalAlignment = CParaFormat::ELeftAlign;
1244 aLayout->SetWrapWidth(aView->ViewRect().Width());
1245 TCursorSelection selection(0, 0);
1246 aView->SetPendingSelection(selection);
1247 aDevice->LineArray().ResetLineArray();
1248 aView->HandleGlobalChangeL();
1249 TInt x = XCoordinateOfText(_L("F"), aDevice);
1251 x = XCoordinateOfText(_L("s."), aDevice);
1253 // Now right aligned
1254 aParagraphFormat->iHorizontalAlignment = CParaFormat::ERightAlign;
1255 aView->SetPendingSelection(selection);
1256 aDevice->LineArray().ResetLineArray();
1257 aView->HandleGlobalChangeL();
1258 x = XCoordinateOfText(_L("F"), aDevice);
1260 x = XCoordinateOfText(_L("s."), aDevice);
1262 // Now Hebrew left aligned (with ERightAlign set, because really
1263 // that means "trailing")
1264 aText = _L("\x5D0 \x5D1");
1265 aView->SetPendingSelection(selection);
1266 aDevice->LineArray().ResetLineArray();
1267 aView->HandleGlobalChangeL();
1268 x = XCoordinateOfText(_L("\x5D0"), aDevice);
1270 x = XCoordinateOfText(_L("\x5D1"), aDevice);
1272 // Now right aligned (== leading == ELeftAlign).
1273 aParagraphFormat->iHorizontalAlignment = CParaFormat::ELeftAlign;
1274 aView->SetPendingSelection(selection);
1275 aDevice->LineArray().ResetLineArray();
1276 aView->HandleGlobalChangeL();
1277 x = XCoordinateOfText(_L("\x5D0"), aDevice);
1279 x = XCoordinateOfText(_L("\x5D1"), aDevice);
1281 // Now with a bullet.
1282 aParagraphFormat->iIndentInTwips = 440; // 11 pixels
1283 aParagraphFormat->iBullet = new(ELeave) TBullet;
1284 aParagraphFormat->iBullet->iHangingIndent = EFalse;
1285 aParagraphFormat->iBullet->iCharacterCode = 0x2022;
1286 aView->SetPendingSelection(selection);
1287 aDevice->LineArray().ResetLineArray();
1288 aView->HandleGlobalChangeL();
1289 x = XCoordinateOfText(_L("\x5D0"), aDevice);
1291 x = XCoordinateOfText(_L("\x5D1"), aDevice);
1293 x = XCoordinateOfText(_L("\x2022"), aDevice);
1295 // Trailing (left) align
1296 aParagraphFormat->iHorizontalAlignment = CParaFormat::ERightAlign;
1297 aView->SetPendingSelection(selection);
1298 aDevice->LineArray().ResetLineArray();
1299 aView->HandleGlobalChangeL();
1300 x = XCoordinateOfText(_L("\x5D0"), aDevice);
1302 x = XCoordinateOfText(_L("\x5D1"), aDevice);
1304 x = XCoordinateOfText(_L("\x2022"), aDevice);
1306 // Latin text, right aligned.
1308 aView->SetPendingSelection(selection);
1309 aDevice->LineArray().ResetLineArray();
1310 aView->HandleGlobalChangeL();
1311 x = XCoordinateOfText(_L("F"), aDevice);
1313 x = XCoordinateOfText(_L("s."), aDevice);
1315 x = XCoordinateOfText(_L("\x2022"), aDevice);
1318 aParagraphFormat->iHorizontalAlignment = CParaFormat::ELeftAlign;
1319 aView->SetPendingSelection(selection);
1320 aDevice->LineArray().ResetLineArray();
1321 aView->HandleGlobalChangeL();
1322 x = XCoordinateOfText(_L("F"), aDevice);
1324 x = XCoordinateOfText(_L("s"), aDevice);
1326 x = XCoordinateOfText(_L("\x2022"), aDevice);
1328 // Now bullet with hanging indent (Latin text, leading alignment)
1329 aParagraphFormat->iBullet->iHangingIndent = ETrue;
1330 aView->SetPendingSelection(selection);
1331 aDevice->LineArray().ResetLineArray();
1332 aView->HandleGlobalChangeL();
1333 x = XCoordinateOfText(_L("F"), aDevice);
1335 x = XCoordinateOfText(_L("s"), aDevice);
1337 x = XCoordinateOfText(_L("\x2022"), aDevice);
1339 // Trailing alignment
1340 aParagraphFormat->iHorizontalAlignment = CParaFormat::ERightAlign;
1341 aView->SetPendingSelection(selection);
1342 aDevice->LineArray().ResetLineArray();
1343 aView->HandleGlobalChangeL();
1344 x = XCoordinateOfText(_L("F"), aDevice);
1346 x = XCoordinateOfText(_L("s"), aDevice);
1348 x = XCoordinateOfText(_L("\x2022"), aDevice);
1350 // Hebrew, trailing, hanging indent
1351 aText = _L("\x5D0 \x5D1");
1352 aView->SetPendingSelection(selection);
1353 aDevice->LineArray().ResetLineArray();
1354 aView->HandleGlobalChangeL();
1355 x = XCoordinateOfText(_L("\x5D0"), aDevice);
1357 x = XCoordinateOfText(_L("\x5D1"), aDevice);
1359 x = XCoordinateOfText(_L("\x2022"), aDevice);
1361 // Leading alignment
1362 aParagraphFormat->iHorizontalAlignment = CParaFormat::ELeftAlign;
1363 aView->SetPendingSelection(selection);
1364 aDevice->LineArray().ResetLineArray();
1365 aView->HandleGlobalChangeL();
1366 x = XCoordinateOfText(_L("\x5D0"), aDevice);
1368 x = XCoordinateOfText(_L("\x5D1"), aDevice);
1370 x = XCoordinateOfText(_L("\x2022"), aDevice);
1373 aParagraphFormat->Reset();
1377 @SYMTestCaseID SYSLIB-FORM-UT-1663
1378 @SYMTestCaseDesc Tests to make sure when non-solid border has been set for the paragraph more than 1 line,
1379 there's no border been drawn between the lines in the paragraph.
1380 @SYMTestPriority High
1381 @SYMTestActions Insert a paragraph of text, which contains at least 3 lines. Draw non-solid borders
1382 for the paragraph. Check the area between line 1 and line 2 to see if there's any border
1383 been drawn incorrectly.
1384 @SYMTestExpectedResults Test must not fail
1387 const TInt KBorderThicknessInTwips=40;
1389 void DEF073913L(TDes& aText, CTestGraphicsDevice* aDevice, CTextView* aView, CParaFormat* aParagraphFormat)
1391 SetViewRect1(aView);
1393 aText = _L("abcdefghijklmnopqrstuvwxyz");
1395 // set borders' attribute
1400 top.iThickness=KBorderThicknessInTwips;
1401 bottom.iThickness=KBorderThicknessInTwips;
1402 left.iThickness=KBorderThicknessInTwips;
1403 right.iThickness=KBorderThicknessInTwips;
1405 // make it non-solid for the defect testing
1406 top.iLineStyle=TParaBorder::EDotted;
1407 bottom.iLineStyle=TParaBorder::EDotted;
1408 left.iLineStyle=TParaBorder::EDotted;
1409 right.iLineStyle=TParaBorder::EDotted;
1411 TParaFormatMask aParaMask;
1412 aParaMask.SetAttrib(EAttTopBorder);
1413 aParaMask.SetAttrib(EAttBottomBorder);
1414 aParaMask.SetAttrib(EAttLeftBorder);
1415 aParaMask.SetAttrib(EAttRightBorder);
1417 aParagraphFormat->SetParaBorderL(CParaFormat::EParaBorderTop,top);
1418 aParagraphFormat->SetParaBorderL(CParaFormat::EParaBorderBottom,bottom);
1419 aParagraphFormat->SetParaBorderL(CParaFormat::EParaBorderLeft,left);
1420 aParagraphFormat->SetParaBorderL(CParaFormat::EParaBorderRight,right);
1422 TCursorSelection selection(0, 0);
1423 aView->SetPendingSelection(selection);
1425 // set testing area: border area between text line 1 and line 2
1426 TRect forbiddenArea(1, 13, 49, 13);
1427 aDevice->SetTestingArea(forbiddenArea);
1428 aDevice->LineArray().ResetLineArray();
1429 aView->HandleGlobalChangeL();
1431 // check there have enough lines in the paragraph
1432 TInt lines = aDevice->LineArray().LinesPresent();
1435 // check the drawing result,
1436 // expected: no line has been drawn on the testing area
1437 test(aDevice->HasDrawnOnTestingArea() == EFalse);
1439 aParagraphFormat->Reset();
1443 INC039567 - Zero-width Non-joiner character does not work in editors
1445 Tests that Arabic letters separated by ZWNJ (U+200C) are either rendered in
1446 separate calls or remain separated in their strings by ZWNJ.
1449 void INC039567_L(TDes& aText, CTestGraphicsDevice* aDevice, CTextView* aView)
1451 aText = _L("\x628\x200C\x62D\x200C\x633");
1452 aDevice->LineArray().ResetLineArray();
1453 aView->HandleGlobalChangeL();
1454 for (TInt i = 0; i < aText.Length(); i += 2)
1456 const TTestGCDisplayLine *line = aDevice->LineArray().Find(
1458 // Check that the line actually was drawn
1460 const TDesC& displayed = line->iLineData;
1461 TInt pos = displayed.Locate(aText[i]);
1462 // Check that the line contains the text we expect. Failure here indicates
1463 // a failure of the test code.
1465 // Check that the character is followed by a ZWNJ, if anything at all.
1466 // 0xFFFF intervening is OK
1467 for (TInt j = pos + 1;
1468 j != displayed.Length() && displayed[j] != KZeroWidthNonJoiner;
1470 test(displayed[j] == 0xFFFF);
1471 // Check that the character is preceded by a ZWNJ, if anything at all.
1472 // 0xFFFF intervening is OK
1474 0 != k && displayed[k - 1] != KZeroWidthNonJoiner; --k)
1475 test(displayed[k - 1] == 0xFFFF);
1479 /** Erroneous Cursor movement on top two lines
1481 Tests that when the cursor is moved up to the top of the document and then up
1482 one more to the start of the document, that the latent X position moves to the
1483 start of the line as well.
1486 void DEF061143_L(TDes& aText, CTextLayout* aLayout, CTextView* aView)
1488 SetViewRect1(aView);
1489 aLayout->ForceNoWrapping(CTextLayout::EFParagraphsWrappedByDefault);
1490 aLayout->SetWrapWidth(aView->ViewRect().Width());
1491 aText = _L("First Line Second.");
1492 aView->HandleGlobalChangeL();
1493 TTmDocPos pos(15, ETrue);
1494 aView->SetDocPosL(pos);
1495 TCursorPosition::TMovementType move = TCursorPosition::EFLineUp;
1496 aView->MoveCursorL(move, EFalse);
1497 move = TCursorPosition::EFLineUp;
1498 aView->MoveCursorL(move, EFalse);
1499 aView->GetCursorPos(pos);
1500 test(pos.iPos == 0);
1501 move = TCursorPosition::EFLineDown;
1502 aView->MoveCursorL(move, EFalse);
1503 aView->GetCursorPos(pos);
1504 test(pos.iPos == 11);
1507 /** Page Down from last line moves the cursor to the start of the line. */
1508 void DEF063340_L(TDes& aText, CTextLayout* aLayout, CTextView* aView)
1510 SetViewRect1(aView);
1511 aLayout->ForceNoWrapping(CTextLayout::EFParagraphsWrappedByDefault);
1512 aLayout->SetWrapWidth(aView->ViewRect().Width());
1514 aView->HandleGlobalChangeL();
1515 TTmDocPos pos(1, EFalse);
1516 aView->SetDocPosL(pos);
1517 TCursorPosition::TMovementType move = TCursorPosition::EFPageDown;
1518 aView->MoveCursorL(move, EFalse);
1519 aView->GetCursorPos(pos);
1520 test(pos.iPos == 1);
1521 test(move == TCursorPosition::EFLineEnd);
1524 TBool LineIsEqual(CLineArray& aLineArray, TInt aLineNumber,
1525 const TDesC& aCandidate)
1528 line.Set( aLineArray.Line(aLineNumber).LineData() );
1529 while (1 < line.Length() && line[0] == 0xFFFF)
1530 line.Set( line.Mid(1) );
1531 while (1 < line.Length() && line[line.Length() - 1] == 0xFFFF)
1532 line.Set( line.Left(line.Length() - 1) );
1533 return 0 == aCandidate.Compare(line);
1536 _LIT(KClusterBreakTest1, "\xE01\xE33");
1537 _LIT(KClusterBreakTest2, "citta\x300");
1538 _LIT(KClusterBreakTest3, "\x928\x94d\x928");
1539 /** @SYMTestCaseID SYSLIB-FORM-UT-1533
1541 Test that clusters are not broken by segmented storage.
1542 @SYMTestPriority High
1544 Format some Devanagari with a text model that deliberately
1545 refuses to supply Form with whole syllables. Check that whole
1546 syllables are rendered.
1547 @SYMTestExpectedResults No panics.
1549 void TestClusterBreaks(TDes& aText, CTestGraphicsDevice* aDevice,
1550 CTextLayout* aLayout, CTextView* aView, TDocModel* aDocModel)
1552 SetViewRect1(aView);
1553 aLayout->ForceNoWrapping(CTextLayout::EFParagraphsWrappedByDefault);
1554 aLayout->SetWrapWidth(aView->ViewRect().Width());
1555 aDevice->LineArray().Enable();
1558 aText = KClusterBreakTest1();
1559 aDocModel->SetBreakPos(1);
1560 // Check TDocModel is actually doing the test correctly
1561 aDocModel->GetChars(text, dummy, 0);
1562 test(text.Length() == 1);
1563 aDevice->LineArray().ResetLineArray();
1564 aView->HandleGlobalChangeL();
1565 test(LineIsEqual(aDevice->LineArray(), 0, KClusterBreakTest1));
1567 aText = KClusterBreakTest2();
1568 aDocModel->SetBreakPos(5);
1569 aDocModel->GetChars(text, dummy, 0);
1570 test(text.Length() == 5);
1571 aDevice->LineArray().ResetLineArray();
1572 aView->HandleGlobalChangeL();
1573 test(LineIsEqual(aDevice->LineArray(), 0, KClusterBreakTest2));
1575 aText = KClusterBreakTest3();
1576 aDocModel->SetBreakPos(2);
1577 aDocModel->GetChars(text, dummy, 0);
1578 test(text.Length() == 2);
1579 aDevice->LineArray().ResetLineArray();
1580 aView->HandleGlobalChangeL();
1581 test(LineIsEqual(aDevice->LineArray(), 0, KClusterBreakTest3));
1583 aDocModel->SetBreakPos(0);
1586 /** DEF065322: Inconsistent parameter values in MFormCustomDraw::DrawBackground() */
1587 const TInt KDEF065322_CharSize = 13; // height of char
1588 const TInt KDEF065322_MaxCount = 3;
1589 const TInt KDEF065322_RectSize = 100; // view is 100 by 100
1591 class DEF065322_CustomDraw : public MFormCustomDraw
1594 void DrawBackground(const TParam &aParam, const TRgb &aBackground, TRect &aDrawn) const
1596 TRgb ignore(aBackground);
1597 aDrawn = aParam.iDrawRect;
1599 // Test that there are 3 calls to this method and that the expected results are returned.
1600 test(count < KDEF065322_MaxCount);
1602 test(aDrawn.iTl.iX == 0);
1603 test(aDrawn.iTl.iY == count*KDEF065322_CharSize);
1604 test(aDrawn.iBr.iX == KDEF065322_RectSize);
1606 if(count < KDEF065322_MaxCount-1)
1608 test(aDrawn.iBr.iY == (1+count)*KDEF065322_CharSize);
1612 test(aDrawn.iBr.iY == KDEF065322_RectSize);
1620 TInt DEF065322_CustomDraw::count = 0;
1622 void DEF065322_L(TDes& aText, CTextLayout* aLayout, CTextView* aView)
1624 // This text results in 3 calls to the DEF065322_CustomDraw::DrawBackground()
1625 // 1 call for each line of text (2) and 1 for remainder of the text view.
1626 aText = _L("12345678901234567890");
1627 TRect displayRect(0, 0, 100, 100);
1630 DEF065322_CustomDraw customDraw;
1631 aLayout->SetCustomDraw(&customDraw);
1633 // create screen context
1634 CTestGraphicsDevice* device = CTestGraphicsDevice::NewL(displayRect.Size(), 0);
1635 CleanupStack::PushL(device);
1636 CTestGraphicsDevice* screenDevice = CTestGraphicsDevice::NewL(device->SizeInPixels(), 0);
1637 CleanupStack::PushL(screenDevice);
1638 screenDevice->SetLineArray(device->LineArray());
1639 CWindowGc* screenContext;
1640 User::LeaveIfError(screenDevice->CreateContext(screenContext));
1641 CleanupStack::PushL(screenContext);
1642 CTestTextView::SetOffScreenContext(aView, screenContext);
1644 // enable flicker free redraw
1645 aView->EnableFlickerFreeRedraw();
1647 // Cause DEF065322_CustomDraw::DrawBackground() to be executed 3 times
1648 aView->HandleGlobalChangeL();
1651 DEF065322_CustomDraw::count = 0;
1653 // disable flicker free redraw
1654 aView->DisableFlickerFreeRedraw();
1656 // Cause DEF065322_CustomDraw::DrawBackground() to be executed 3 times
1657 aView->HandleGlobalChangeL();
1659 // remove custom draw
1660 aLayout->SetCustomDraw(NULL);
1663 CTestTextView::SetOffScreenContext(aView, 0);
1664 CleanupStack::PopAndDestroy(screenContext);
1665 CleanupStack::PopAndDestroy(screenDevice);
1666 CleanupStack::PopAndDestroy(device);
1669 // Side-bearings at the ends of chunks are now taken into account.
1670 void INC078304_L(TDes& aText, CTextView* aView)
1672 // W has side-bearings of 1 pixel extending on each side.
1673 // Waw (U+0648) has a left side-bearing of -5
1674 // Therefore "WWW" has total width 1+10+10+10+1 == 32
1675 // WawWaw has total width 5+10+10 == 25
1676 SetViewRect1(aView);
1677 aText = _L("WWW\x648\x648WWW\x2029\xff0f\xff0f\xff0f\x2029///");
1678 aView->HandleGlobalChangeL();
1680 TTmPosInfo2 posInfo;
1681 TTmDocPosSpec posSpec(1, TTmDocPosSpec::ETrailing);
1682 aView->FindDocPosL(posSpec, posInfo, &line);
1683 test(line.iInnerRect.iTl.iX == 0);
1684 test(line.iInnerRect.iBr.iX == 89);
1685 test(posInfo.iEdge.iX == 11);
1687 aView->FindDocPosL(posSpec, posInfo, 0);
1688 test(posInfo.iEdge.iX == 21);
1690 aView->FindDocPosL(posSpec, posInfo, 0);
1691 test(posInfo.iEdge.iX == 32);
1692 posSpec.iType = TTmDocPosSpec::ELeading;
1693 aView->FindDocPosL(posSpec, posInfo, 0);
1694 test(posInfo.iEdge.iX == 57);
1696 posSpec.iType = TTmDocPosSpec::ETrailing;
1697 aView->FindDocPosL(posSpec, posInfo, 0);
1698 test(posInfo.iEdge.iX == 47);
1700 aView->FindDocPosL(posSpec, posInfo, 0);
1701 test(posInfo.iEdge.iX == 32);
1702 posSpec.iType = TTmDocPosSpec::ELeading;
1703 aView->FindDocPosL(posSpec, posInfo, 0);
1704 test(posInfo.iEdge.iX == 57);
1706 posSpec.iType = TTmDocPosSpec::ETrailing;
1707 aView->FindDocPosL(posSpec, posInfo, 0);
1708 test(posInfo.iEdge.iX == 68);
1710 aView->FindDocPosL(posSpec, posInfo, 0);
1711 test(posInfo.iEdge.iX == 78);
1713 aView->FindDocPosL(posSpec, posInfo, 0);
1714 test(posInfo.iEdge.iX == 89);
1716 // Test fullwidth solidus -- has a right side-bearing in our font
1717 // It is best if this goes 10, 20, 31
1718 // but it is acceptable for it to go 11, 22, 33
1720 aView->FindDocPosL(posSpec, posInfo, 0);
1721 TInt x1 = posInfo.iEdge.iX;
1722 test(x1 == 10 || x1 == 11);
1724 aView->FindDocPosL(posSpec, posInfo, 0);
1725 TInt x2 = posInfo.iEdge.iX;
1726 test(x2 - x1 == 10 || x2 - x1 == 11);
1728 aView->FindDocPosL(posSpec, posInfo, 0);
1729 test(posInfo.iEdge.iX - x2 == 11);
1731 // Test "///" -- / has a left side-bearing in our font
1732 // It is best if this goes 11, 21, 31
1733 // but it is acceptable for it to go 11, 22, 33
1735 aView->FindDocPosL(posSpec, posInfo, 0);
1736 test(posInfo.iEdge.iX == 11);
1738 aView->FindDocPosL(posSpec, posInfo, 0);
1739 x1 = posInfo.iEdge.iX;
1740 test(x1 == 21 || x1 == 22);
1742 aView->FindDocPosL(posSpec, posInfo, 0);
1743 x2 = posInfo.iEdge.iX;
1744 test(x2 - x1 == 10 || x2 - x1 == 11);
1747 // Pen position now taken into account in bounds calculation/check.
1748 void INC086257_L(TDes& aText, CTextLayout* aLayout, CTextView* aView)
1749 // Conditions setup to simulate the unwanted horiz scroll pre-fix
1750 // Fix will cause line-break instead
1753 aText = _L("DDDDDDDDDD");
1754 aView->HandleGlobalChangeL();
1756 aView->DocPosToXyPosL(aLayout->TagmaTextLayout().EndChar()-1,cursorPoint);
1757 test(cursorPoint.iX==11); //break happened - cursor is one character from left margin
1758 test(cursorPoint.iY==23); //and on the next line
1760 aText = KTavSequence; // right-to-left characters
1761 aView->HandleGlobalChangeL();
1762 aView->DocPosToXyPosL(aLayout->TagmaTextLayout().EndChar()-1,cursorPoint);
1763 test(cursorPoint.iX==89); //break happened - cursor is one character from right margin
1764 test(cursorPoint.iY==23); //and on the next line
1767 // Remapped linebreak characters now conditionally taken into account in bounds calculation/check.
1768 void INC087637_test(TDes& aText, CTextLayout* aLayout, CTextView* aView,
1769 TPoint& cursorPoint, TBool aLeft2Right, TUint aAppendChar=0)
1770 // Set up conditions placed in subroutine to guarantee consistency
1774 aText = _L("DDDDDDDDDD");
1778 aText = KTavSequence; // right-to-left characters
1782 aText.Append(aAppendChar);
1783 aView->HandleGlobalChangeL();
1784 aView->DocPosToXyPosL(aLayout->TagmaTextLayout().EndChar()-2,cursorPoint);
1788 aView->HandleGlobalChangeL();
1789 aView->DocPosToXyPosL(aLayout->TagmaTextLayout().EndChar()-1,cursorPoint);
1792 void INC087637_L(TDes& aText, CTextLayout* aLayout, CTextView* aView)
1793 // Conditions setup to simulate the linebreak character overhanging margin
1794 // Fix will cause wrap conditional upon flag set in layout object
1796 TTestCustomRemap paradelim(CEditableText::EParagraphDelimiter);
1797 TTestCustomRemap linebreak(CEditableText::ELineBreak);
1798 TTestCustomRemap pagebreak(CEditableText::EPageBreak);
1799 TTestCustomRemapper allbreaks;
1800 TRect view(0, 0, 200, 200);
1801 aView->SetViewRect(view);
1802 aLayout->SetWrapWidth(102); // allow a couple of pixels to allow for linebreak char start
1804 const TBool Left2Right = ETrue;
1805 const TBool Right2Left = EFalse;
1806 TTestCustomWrap customWrap;
1810 // First test status quo to show difference
1811 INC087637_test(aText,aLayout,aView,cursorPoint,Left2Right);
1812 test(cursorPoint.iX==101); //cursor is near right margin
1813 test(cursorPoint.iY==10); //and on the first line
1814 INC087637_test(aText,aLayout,aView,cursorPoint,Left2Right,CEditableText::ELineBreak);
1815 test(cursorPoint.iX==101); //cursor is near right margin
1816 test(cursorPoint.iY==10); //and on the first line
1817 INC087637_test(aText,aLayout,aView,cursorPoint,Left2Right,CEditableText::EPageBreak);
1818 test(cursorPoint.iX==101); //cursor is near right margin
1819 test(cursorPoint.iY==10); //and on the first line
1820 // Remap paragraph delimiter - still no difference because no custom wrap set
1821 aLayout->SetCustomInvisibleCharacterRemapper(¶delim);
1822 INC087637_test(aText,aLayout,aView,cursorPoint,Left2Right);
1823 test(cursorPoint.iX==101); //cursor is near right margin
1824 test(cursorPoint.iY==10); //and on the first line
1825 INC087637_test(aText,aLayout,aView,cursorPoint,Left2Right,CEditableText::ELineBreak);
1826 test(cursorPoint.iX==101); //cursor is near right margin
1827 test(cursorPoint.iY==10); //and on the first line
1828 INC087637_test(aText,aLayout,aView,cursorPoint,Left2Right,CEditableText::EPageBreak);
1829 test(cursorPoint.iX==101); //cursor is near right margin
1830 test(cursorPoint.iY==10); //and on the first line
1831 // Set custom wrap - paragraph delimiter, and only paragraph delimiter breaks to a new line
1832 aLayout->SetCustomWrap(&customWrap);
1833 INC087637_test(aText,aLayout,aView,cursorPoint,Left2Right);
1834 test(cursorPoint.iX==0); //cursor is at left margin
1835 test(cursorPoint.iY==23); //and on the second line
1836 INC087637_test(aText,aLayout,aView,cursorPoint,Left2Right,CEditableText::ELineBreak);
1837 test(cursorPoint.iX==101); //cursor is near right margin
1838 test(cursorPoint.iY==10); //and on the first line
1839 INC087637_test(aText,aLayout,aView,cursorPoint,Left2Right,CEditableText::EPageBreak);
1840 test(cursorPoint.iX==101); //cursor is near right margin
1841 test(cursorPoint.iY==10); //and on the first line
1842 // Remap linebreak character - linebreak character, and only linebreak character breaks to a new line
1843 aLayout->SetCustomInvisibleCharacterRemapper(&linebreak);
1844 INC087637_test(aText,aLayout,aView,cursorPoint,Left2Right);
1845 test(cursorPoint.iX==101); //cursor is near right margin
1846 test(cursorPoint.iY==10); //and on the first line
1847 INC087637_test(aText,aLayout,aView,cursorPoint,Left2Right,CEditableText::ELineBreak);
1848 test(cursorPoint.iX==0); //cursor is at left margin
1849 test(cursorPoint.iY==23); //and on the second line
1850 INC087637_test(aText,aLayout,aView,cursorPoint,Left2Right,CEditableText::EPageBreak);
1851 test(cursorPoint.iX==101); //cursor is near right margin
1852 test(cursorPoint.iY==10); //and on the first line
1853 // Remap pagebreak character - pagebreak character, and only pagebreak character breaks to a new line
1854 aLayout->SetCustomInvisibleCharacterRemapper(&pagebreak);
1855 INC087637_test(aText,aLayout,aView,cursorPoint,Left2Right);
1856 test(cursorPoint.iX==101); //cursor is near right margin
1857 test(cursorPoint.iY==10); //and on the first line
1858 INC087637_test(aText,aLayout,aView,cursorPoint,Left2Right,CEditableText::ELineBreak);
1859 test(cursorPoint.iX==101); //cursor is near right margin
1860 test(cursorPoint.iY==10); //and on the first line
1861 INC087637_test(aText,aLayout,aView,cursorPoint,Left2Right,CEditableText::EPageBreak);
1862 test(cursorPoint.iX==0); //cursor is at left margin
1863 test(cursorPoint.iY==23); //and on the second line
1864 // Remap all linebreak characters - all test break to a new line
1865 aLayout->SetCustomInvisibleCharacterRemapper(&allbreaks);
1866 INC087637_test(aText,aLayout,aView,cursorPoint,Left2Right);
1867 test(cursorPoint.iX==0); //cursor is at left margin
1868 test(cursorPoint.iY==23); //and on the second line
1869 INC087637_test(aText,aLayout,aView,cursorPoint,Left2Right,CEditableText::ELineBreak);
1870 test(cursorPoint.iX==0); //cursor is at left margin
1871 test(cursorPoint.iY==23); //and on the second line
1872 INC087637_test(aText,aLayout,aView,cursorPoint,Left2Right,CEditableText::EPageBreak);
1873 test(cursorPoint.iX==0); //cursor is at left margin
1874 test(cursorPoint.iY==23); //and on the second line
1875 // With all linebreak characters remapped, reset custom wrap - no breaks occur
1876 aLayout->SetCustomWrap(NULL);
1877 INC087637_test(aText,aLayout,aView,cursorPoint,Left2Right);
1878 test(cursorPoint.iX==101); //cursor is near right margin
1879 test(cursorPoint.iY==10); //and on the first line
1880 INC087637_test(aText,aLayout,aView,cursorPoint,Left2Right,CEditableText::ELineBreak);
1881 test(cursorPoint.iX==101); //cursor is near right margin
1882 test(cursorPoint.iY==10); //and on the first line
1883 INC087637_test(aText,aLayout,aView,cursorPoint,Left2Right,CEditableText::EPageBreak);
1884 test(cursorPoint.iX==101); //cursor is near right margin
1885 test(cursorPoint.iY==10); //and on the first line
1889 // First test status quo to show difference
1890 aLayout->SetCustomInvisibleCharacterRemapper(NULL);// switch off character remapping
1891 INC087637_test(aText,aLayout,aView,cursorPoint,Right2Left);
1892 test(cursorPoint.iX==1); //cursor is near left margin
1893 test(cursorPoint.iY==10); //and on the first line
1894 INC087637_test(aText,aLayout,aView,cursorPoint,Right2Left,CEditableText::ELineBreak);
1895 test(cursorPoint.iX==1); //cursor is near left margin
1896 test(cursorPoint.iY==10); //and on the first line
1897 INC087637_test(aText,aLayout,aView,cursorPoint,Right2Left,CEditableText::EPageBreak);
1898 test(cursorPoint.iX==1); //cursor is near left margin
1899 test(cursorPoint.iY==10); //and on the first line
1900 // Remap paragraph delimiter - still no difference because no custom wrap set
1901 aLayout->SetCustomInvisibleCharacterRemapper(¶delim);
1902 INC087637_test(aText,aLayout,aView,cursorPoint,Right2Left);
1903 test(cursorPoint.iX==1); //cursor is near left margin
1904 test(cursorPoint.iY==10); //and on the first line
1905 INC087637_test(aText,aLayout,aView,cursorPoint,Right2Left,CEditableText::ELineBreak);
1906 test(cursorPoint.iX==1); //cursor is near left margin
1907 test(cursorPoint.iY==10); //and on the first line
1908 INC087637_test(aText,aLayout,aView,cursorPoint,Right2Left,CEditableText::EPageBreak);
1909 test(cursorPoint.iX==1); //cursor is near left margin
1910 test(cursorPoint.iY==10); //and on the first line
1911 // Set custom wrap - paragraph delimiter, and only paragraph delimiter breaks to a new line
1912 aLayout->SetCustomWrap(&customWrap);
1913 INC087637_test(aText,aLayout,aView,cursorPoint,Right2Left);
1914 test(cursorPoint.iX==102); //cursor is at right margin
1915 test(cursorPoint.iY==23); //and on the second line
1916 INC087637_test(aText,aLayout,aView,cursorPoint,Right2Left,CEditableText::ELineBreak);
1917 test(cursorPoint.iX==1); //cursor is near left margin
1918 test(cursorPoint.iY==10); //and on the first line
1919 INC087637_test(aText,aLayout,aView,cursorPoint,Right2Left,CEditableText::EPageBreak);
1920 test(cursorPoint.iX==1); //cursor is near left margin
1921 test(cursorPoint.iY==10); //and on the first line
1922 // Remap linebreak character - linebreak character, and only linebreak character breaks to a new line
1923 aLayout->SetCustomInvisibleCharacterRemapper(&linebreak);
1924 INC087637_test(aText,aLayout,aView,cursorPoint,Right2Left);
1925 test(cursorPoint.iX==1); //cursor is near left margin
1926 test(cursorPoint.iY==10); //and on the first line
1927 INC087637_test(aText,aLayout,aView,cursorPoint,Right2Left,CEditableText::ELineBreak);
1928 test(cursorPoint.iX==102); //cursor is at right margin
1929 test(cursorPoint.iY==23); //but on the second line
1930 INC087637_test(aText,aLayout,aView,cursorPoint,Right2Left,CEditableText::EPageBreak);
1931 test(cursorPoint.iX==1); //cursor is near left margin
1932 test(cursorPoint.iY==10); //and on the first line
1933 // Remap pagebreak character - pagebreak character, and only pagebreak character breaks to a new line
1934 aLayout->SetCustomInvisibleCharacterRemapper(&pagebreak);
1935 INC087637_test(aText,aLayout,aView,cursorPoint,Right2Left);
1936 test(cursorPoint.iX==1); //cursor is near left margin
1937 test(cursorPoint.iY==10); //and on the first line
1938 INC087637_test(aText,aLayout,aView,cursorPoint,Right2Left,CEditableText::ELineBreak);
1939 test(cursorPoint.iX==1); //cursor is near left margin
1940 test(cursorPoint.iY==10); //and on the first line
1941 INC087637_test(aText,aLayout,aView,cursorPoint,Right2Left,CEditableText::EPageBreak);
1942 test(cursorPoint.iX==102); //cursor is at right margin
1943 test(cursorPoint.iY==23); //but on the second line
1944 // Remap all linebreak characters - all test break to a new line
1945 aLayout->SetCustomInvisibleCharacterRemapper(&allbreaks);
1946 INC087637_test(aText,aLayout,aView,cursorPoint,Right2Left);
1947 test(cursorPoint.iX==102); //cursor is at right margin
1948 test(cursorPoint.iY==23); //but on the second line
1949 INC087637_test(aText,aLayout,aView,cursorPoint,Right2Left,CEditableText::ELineBreak);
1950 test(cursorPoint.iX==102); //cursor is at right margin
1951 test(cursorPoint.iY==23); //but on the second line
1952 INC087637_test(aText,aLayout,aView,cursorPoint,Right2Left,CEditableText::EPageBreak);
1953 test(cursorPoint.iX==102); //cursor is at right margin
1954 test(cursorPoint.iY==23); //but on the second line
1955 // With all linebreak characters remapped, reset custom wrap - no breaks occur
1956 aLayout->SetCustomWrap(NULL);
1957 INC087637_test(aText,aLayout,aView,cursorPoint,Right2Left);
1958 test(cursorPoint.iX==1); //cursor is near left margin
1959 test(cursorPoint.iY==10); //and on the first line
1960 INC087637_test(aText,aLayout,aView,cursorPoint,Right2Left,CEditableText::ELineBreak);
1961 test(cursorPoint.iX==1); //cursor is near left margin
1962 test(cursorPoint.iY==10); //and on the first line
1963 INC087637_test(aText,aLayout,aView,cursorPoint,Right2Left,CEditableText::EPageBreak);
1964 test(cursorPoint.iX==1); //cursor is near left margin
1965 test(cursorPoint.iY==10); //and on the first line
1967 // reset for next test
1968 aLayout->SetWrapWidth(100);
1969 aLayout->SetCustomInvisibleCharacterRemapper(NULL);
1972 // No Memory mode entered twice on a certain leave unwinding
1973 void DEF078967_L(TDes& aText, CTestGraphicsDevice* aDevice, CTextView* aView)
1975 SetViewRect1(aView);
1976 aText = _L("some text is bigger than others");
1977 aView->HandleGlobalChangeL();
1978 TSize size(100, 100);
1979 CTestGraphicsDevice* offScreenDevice = CTestGraphicsDevice::NewL(size, 0);
1980 CleanupStack::PushL(offScreenDevice);
1981 CWindowGc* offScreenContext;
1982 User::LeaveIfError(offScreenDevice->CreateContext(offScreenContext));
1983 CleanupStack::PushL(offScreenContext);
1984 CTestTextView::SetOffScreenContext(aView, offScreenContext);
1985 aView->EnableFlickerFreeRedraw();
1988 User::LeaveIfError(aDevice->CreateBitmapContext(bc));
1989 CleanupStack::PushL(bc);
1990 // Form can eat leaves, so we'll want a clear run of
1991 // (say) three before we'll stop testing.
1993 for (TInt i = 1; ok < 3; ++i)
1995 __UHEAP_FAILNEXT(i);
1996 TRAPD(error, aView->DrawL(rect, *bc));
1997 if (error == KErrNone)
2003 CleanupStack::PopAndDestroy(bc);
2004 CleanupStack::PopAndDestroy(offScreenContext);
2005 CleanupStack::PopAndDestroy(offScreenDevice);
2006 aView->DisableFlickerFreeRedraw();
2009 void INC092568_L(TDes& aText, CTextLayout* aLayout, CTextView* aView)
2011 //fill up text buffer/ view
2012 aText = _L("1234567890123456789012345678901234567890123456789012");
2013 aText.Append(_L("34567890123456789012345678901234567890123456789"));
2014 aView->HandleGlobalChangeL();
2016 //set up test variable
2017 TInt end = aText.Length();
2018 TPoint viewableWindowTopLeft(0,0);
2019 TCursorSelection selectTop(0,0);
2020 TCursorSelection selectBottom(end,end);
2021 TTmPosInfo2 posInfo;
2023 //restrict viewable window so that scrolling is necessary
2024 aLayout->SetBandHeight(70);
2026 //test scrolling *without* SetPendingSelection
2027 aView->SetDocPosL(0); //scroll text down to top of document
2028 aView->FindXyPosL(viewableWindowTopLeft, posInfo, NULL);
2029 test(posInfo.iDocPos.iPos == 0);
2030 aView->HandleInsertDeleteL(selectBottom,0,ETrue);
2031 aView->FindXyPosL(viewableWindowTopLeft, posInfo, NULL);
2032 test(posInfo.iDocPos.iPos == 40); //text has scrolled up
2033 aView->SetDocPosL(0); //scroll text down to top of document
2034 aView->FindXyPosL(viewableWindowTopLeft, posInfo, NULL);
2035 test(posInfo.iDocPos.iPos == 0); //text has scrolled down
2036 aView->HandleRangeFormatChangeL(selectBottom,ETrue);
2037 aView->FindXyPosL(viewableWindowTopLeft, posInfo, NULL);
2038 test(posInfo.iDocPos.iPos == 40); //text has scrolled up
2040 //test *no* scrolling with SetPendingSelection
2041 //and selection reset by Handle.. methods
2042 aView->SetDocPosL(0);//scroll text down to top of document
2043 aView->FindXyPosL(viewableWindowTopLeft, posInfo, NULL);
2044 test(posInfo.iDocPos.iPos == 0);
2045 aView->SetPendingSelection(selectTop);
2046 aView->HandleInsertDeleteL(selectBottom,0,ETrue);
2047 aView->FindXyPosL(viewableWindowTopLeft, posInfo, NULL);
2048 test(posInfo.iDocPos.iPos == 0); //text has not scrolled
2049 aView->HandleRangeFormatChangeL(selectBottom,ETrue);
2050 aView->FindXyPosL(viewableWindowTopLeft, posInfo, NULL);
2051 test(posInfo.iDocPos.iPos == 40); //text has scrolled up due to reset
2052 aView->SetDocPosL(0); //scroll text down to top of document
2053 aView->FindXyPosL(viewableWindowTopLeft, posInfo, NULL);
2054 test(posInfo.iDocPos.iPos == 0);
2055 aView->SetPendingSelection(selectTop);
2056 aView->HandleRangeFormatChangeL(selectBottom,ETrue);
2057 aView->FindXyPosL(viewableWindowTopLeft, posInfo, NULL);
2058 test(posInfo.iDocPos.iPos == 0); //text has not scrolled
2059 aView->HandleInsertDeleteL(selectBottom,0,ETrue);
2060 aView->FindXyPosL(viewableWindowTopLeft, posInfo, NULL);
2061 test(posInfo.iDocPos.iPos == 40); //text has scrolled up due to reset
2063 //test *scrolling* with SetPendingSelection
2064 aView->SetDocPosL(0);//scroll text down to top of document
2065 aView->FindXyPosL(viewableWindowTopLeft, posInfo, NULL);
2066 test(posInfo.iDocPos.iPos == 0);
2067 aView->SetPendingSelection(selectBottom);
2068 aView->HandleInsertDeleteL(selectTop,0,ETrue);
2069 aView->FindXyPosL(viewableWindowTopLeft, posInfo, NULL);
2070 test(posInfo.iDocPos.iPos == 40); //text has scrolled up due to selectpending
2071 aView->SetDocPosL(0); //scroll text down to top of document
2072 aView->FindXyPosL(viewableWindowTopLeft, posInfo, NULL);
2073 test(posInfo.iDocPos.iPos == 0);
2074 aView->SetPendingSelection(selectBottom);
2075 aView->HandleRangeFormatChangeL(selectTop,ETrue);
2076 aView->FindXyPosL(viewableWindowTopLeft, posInfo, NULL);
2077 test(posInfo.iDocPos.iPos == 40); //text has scrolled up due to selectpending
2079 //reset for next test
2080 aView->SetDocPosL(0);
2083 void INC092257L(TDes& aText,CTextView* aView)
2086 aView->HandleGlobalChangeL();
2087 aView->GetForwardDeletePositionL();
2088 aView->GetBackwardDeletePositionL();
2092 @SYMTestCaseID SYSLIB-FORM-CT-3422
2093 @SYMTestCaseDesc "Scrolling works weirdly when replying to email". This was a particular
2094 sequence of API calls under certain conditions that was causing an
2095 unexpected downward line scroll.
2096 @SYMTestPriority High
2097 @SYMTestActions Recreate the defect's pre-conditions and then call the API sequence.
2098 @SYMTestExpectedResults At the end of the sequence, no downward line scroll should have occurred.
2101 void PDEF109450_L(TDes& aText, CTextLayout* aLayout, CTextView* aView)
2103 // Text buffer/ view should be filled up and should include
2104 // a paragraph break after a few characters
2105 aText = _L("12345");
2106 aText.Append(_L("\x2029")); // para delim
2107 aText.Append(_L("6789012345678901234567890123456789012345678901"));
2108 aText.Append(_L("2345678901234567890123456789012345678901234567"));
2109 aView->HandleGlobalChangeL();
2111 // Set up defect preconditions
2112 TViewYPosQualifier viewYPosQualifier;
2113 viewYPosQualifier.SetFillScreen();
2114 viewYPosQualifier.SetMakeLineFullyVisible();
2115 aLayout->SetBandHeight(50); //restrict viewable window so that scrolling is necessary
2116 aLayout->SetAmountToFormat(CTextLayout::EFFormatBand);//set visible height to band height
2117 aView->SetDocPosL(0);//scroll to top of document
2118 TCursorPosition::TMovementType cursorMovement = TCursorPosition::EFLineDown;
2119 aView->MoveCursorL(cursorMovement,0);//move the cursor down one line from the top
2121 aView->GetCursorPos(docPos);
2122 aText.Insert(docPos.iPos, _L("\x2029"));//insert a 2nd para break right after the 1st
2124 // Call the API sequence
2125 aView->SetPendingSelection(TCursorSelection(docPos.iPos,docPos.iPos));
2126 aView->HandleInsertDeleteL(TCursorSelection(docPos.iPos+1,docPos.iPos),1);
2127 aView->HandleGlobalChangeNoRedrawL(viewYPosQualifier);
2128 aView->HandleCharEditL(CTextLayout::EFParagraphDelimiter);
2130 // Test to ensure no scroll has occurred
2131 TPoint viewableWindowTopLeft(0,0);
2132 TTmPosInfo2 posInfo;
2133 aView->FindXyPosL(viewableWindowTopLeft, posInfo, NULL);
2134 test(posInfo.iDocPos.iPos == 0);//viewableWindowTopLeft should still be at doc start
2136 //reset for next test
2137 aView->SetDocPosL(0);
2140 void VerifyLineBreak(CTextView* aView,TInt aLines, TInt *aLineEnds)
2142 CTextView::TTagmaForwarder forwarder;
2143 forwarder.InitL(aView);
2145 //force reformatting of text
2146 aView->HandleGlobalChangeL();
2148 //get the number of lines in the text
2149 TInt lines = forwarder.Lines();
2150 test(lines == aLines);
2152 //verify that the lines are broken in the correct places
2154 for(TInt index = 0;index < aLines;index++)
2156 forwarder.LineNumberToLine(index,info);
2157 test(info.iEnd == aLineEnds[index]);
2161 @SYMTestCaseID SYSLIB-FORM-CT-3478
2162 @SYMTestCaseDesc Tests to ensure the correct line breaking behaviour when wrapping tabs
2163 @SYMTestPriority High
2164 @SYMTestActions Formats a series of strings using a variety of custom wrapping rules and verifies that
2165 strings with tabs are broken correctly
2166 @SYMTestExpectedResults All strings should be broken as specified by the line breaking rules
2169 void PDEF107440_L(TDes& aText, CTextLayout* aLayout, CTextView* aView)
2171 //This array defines the positions in the string where the lines should end
2172 TInt lineEnds[2] = {10,17};
2174 _LIT(KTestString1,"gggggg ggg\taaaaa");
2175 _LIT(KTestString2,"gggggggggg\taaaaa");
2176 _LIT(KTestString3,"gggggggggg\t aaaa");
2177 _LIT(KTestString4,"gggggggggg \taaaa");
2179 //Set the text string - the length of this string (actually the position
2180 //of the tab within the string) is set so that the tab character should not
2181 //fit properly into a single line
2182 aText = KTestString1;
2184 //This custom wrapper will allow breaking before the tab character
2185 TTestCustomWrap2 customWrap2;
2186 aLayout->SetCustomWrap(&customWrap2);
2188 //Check that the line is broken before the tab
2189 VerifyLineBreak(aView, 2, lineEnds);
2191 //This custom wrapper will allow the tab to hang
2192 TTestCustomWrap3 customWrap3;
2193 aLayout->SetCustomWrap(&customWrap3);
2195 aText = KTestString1;
2197 //Check that the line is broken after the tab
2199 VerifyLineBreak(aView, 2, lineEnds);
2201 //This custom wrapper will treat the tab as a space line breaking class
2202 TTestCustomWrap4 customWrap4;
2203 aLayout->SetCustomWrap(&customWrap4);
2205 //Check that the line is broken after the tab
2207 VerifyLineBreak(aView, 2, lineEnds);
2209 //Now change the text so that the tab is followed by a space character
2210 aText = KTestString3;
2212 //Verify that the line is broken after the space - as the space and tab are allowed to hang
2214 VerifyLineBreak(aView, 2, lineEnds);
2216 //Now change the text so that the tab follows a space character
2217 aText = KTestString4;
2219 //Verify that the line is broken after the tab - as the space and tab are allowed to hang
2220 VerifyLineBreak(aView, 2, lineEnds);
2222 //reset to the default wrapper - this will not allow breaking
2223 //before the tab and will not allow the tab to hang
2224 aLayout->SetCustomWrap(NULL);
2226 //Set back to the original string
2227 aText = KTestString1;
2229 //Verify that the line is broken after the space as the string cannot
2230 // be legally broken before or after the tab
2232 VerifyLineBreak(aView, 2, lineEnds);
2234 //Now change the text so that the line cannot be broken legally
2235 //at the space character
2236 aText = KTestString2;
2238 //Verify that the line is broken before the tab - this is a forced break
2240 VerifyLineBreak(aView, 2, lineEnds);
2242 //Now change the text so that the tab is followed by a space character
2243 aText = KTestString3;
2245 //Verify that the line is broken before the tab as the tab is not allowed to hang
2246 //this is a forced break
2248 VerifyLineBreak(aView, 2, lineEnds);
2250 //Now change the text so that the tab follows a space character
2251 aText = KTestString4;
2253 //Verify that the line is broken before the tab as space is allowed to hang
2255 VerifyLineBreak(aView, 2, lineEnds);
2259 @SYMTestCaseID SYSLIB-FORM-UT-3521
2260 @SYMTestCaseDesc Testing the fix for INC108075: Marathi Input : Fallback rendered characters appears suddenly when we are insert
2261 @SYMTestPriority Medium
2262 @SYMTestActions Check that cverlapping characters in the text do not affect the line breaking
2263 @SYMTestExpectedResults Lines should be broken at correct positions with ZWJ.
2266 void INC108075_L(TDes& aText, CTextLayout* aLayout, CTextView* aView)
2268 // Ra+Virama(Halant)+ZWJ = Eyelash Ra
2269 _LIT(KTestString1,"\x0930\x094D\x200D Hello, 12 abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz");
2270 // Same as above, but replacing a space with Arabic letter Feh, this should cause an overlap of chunks
2272 _LIT(KTestString2,"\x0930\x094D\x200D\x0641Hello, 12 abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz");
2273 aLayout->SetWrapWidth(533);
2274 aText = KTestString1;
2275 //This array defines the positions in the string where the lines should end
2276 TInt lineEnds[2] = {14,67};
2277 //Verify that the line is broken in the correct places
2278 VerifyLineBreak(aView, 2, lineEnds);
2279 aText = KTestString2;
2280 //Verify that the line is broken in the correct places
2281 VerifyLineBreak(aView, 2, lineEnds);
2284 void TestTextViewL(TDes& aText, CTestGraphicsDevice* aDevice,
2285 CTextLayout* aLayout, CTextView* aView, TDocModel* aDocModel)
2287 test.Start(_L("Test fix for defect TET_5D7MCV"));
2288 TET_5D7MCV_L(aText, aDevice, aView, aLayout);
2289 test.Next(_L("Test fix for defect INC020746"));
2290 INC020746_L(aText, aView);
2291 test.Next(_L("Test fix for defect DEF021603"));
2292 DEF021603_L(aText, aDevice, aView);
2293 test.Next(_L("Test fix for defect DEF022229"));
2294 DEF022229_L(aText, aDevice, aView);
2295 test.Next(_L("Test fix for defect DEF035472"));
2296 DEF035472_L(aText, aView);
2297 test.Next(_L("Test fix for defect INC036005"));
2298 INC036005_L(aText, aView);
2299 test.Next(_L("Test XyPosToDocPosL outside horizontal bounds"));
2300 TestCTextView_XyPosToDocPosL_ReturnsCorrectLine(aText, aView);
2301 test.Next(_L("Test fix for defect INC036809"));
2302 INC036809_L(aText, aView);
2303 test.Next(_L("Test fix for defect DEF037255"));
2304 DEF037255_L(aText, aView);
2305 test.Next(_L("Test fix for defect INC037293"));
2306 INC037293_L(aText, aView, aLayout);
2307 test.Next(_L("Test fix for defect INC039567"));
2308 INC039567_L(aText, aDevice, aView);
2309 test.Next(_L("Test fix for defect DEF061143"));
2310 DEF061143_L(aText, aLayout, aView);
2311 test.Next(_L("Test fix for defect DEF063340"));
2312 DEF063340_L(aText, aLayout, aView);
2313 test.Next(_L(" @SYMTestCaseID:SYSLIB-FORM-UT-1533 Test clusters are not broken "));
2314 TestClusterBreaks(aText, aDevice, aLayout, aView, aDocModel);
2315 test.Next(_L("Test fix for defect DEF065322"));
2316 DEF065322_L(aText, aLayout, aView);
2317 test.Next(_L("Test fix for defect DEF078967"));
2318 DEF078967_L(aText, aDevice, aView);
2319 test.Next(_L("Test fix for defect INC078304"));
2320 INC078304_L(aText, aView);
2321 test.Next(_L(" @SYMTestCaseID:SYSLIB-FORM-UT-1653 Test fix for defect INC080603 "));
2322 INC080603L(aText, aDevice, aLayout, aView);
2323 test.Next(_L("Test fix for defect INC086257"));
2324 INC086257_L(aText, aLayout, aView);
2325 test.Next(_L("Test fix for defect INC085809"));
2326 INC085809_L(aLayout, aView);
2327 test.Next(_L("Test fix for defect INC092568"));
2328 INC092568_L(aText, aLayout, aView);
2329 test.Next(_L("Test fix for defect INC087637"));
2330 INC087637_L(aText, aLayout, aView);
2331 test.Next(_L("Test fix for defect INC092557/DEF094709"));
2332 INC092257L(aText,aView);
2333 test.Next(_L(" @SYMTestCaseID:SYSLIB-FORM-CT-3422 Test fix for defect PDEF109450 "));
2334 PDEF109450_L(aText, aLayout, aView);
2335 test.Next(_L(" @SYMTestCaseID:SYSLIB-FORM-CT-3478 Test fix for defect PDEF107440 "));
2336 PDEF107440_L(aText, aLayout, aView);
2337 test.Next(_L(" @SYMTestCaseID:SYSLIB-FORM-UT-3521 Test fix for defect INC108075 "));
2338 INC108075_L(aText, aLayout, aView);
2342 void DEF047281L(TDes& aText,CTextLayout* aLayout)
2344 _LIT(KText, "ThisIsTheTestForDEF047281");
2350 aLayout->GetMinimumSizeL(200, aSize);
2351 test(aSize.iHeight == KHeight); // height of 1 line
2352 aLayout->GetMinimumSizeL(200, ETrue, aSize);
2353 test(aSize.iHeight == KHeight); // height of 1 line
2354 aLayout->GetMinimumSizeL(200, EFalse, aSize);
2355 test(aSize.iHeight == KHeight*2); // height of 2 lines
2359 void TestTextViewParagraphL(TDes& aText, CTestGraphicsDevice* aDevice,
2360 CTextLayout* aLayout, CTextView* aView, CParaFormat* aParagraphFormat)
2362 test.Start(_L("Test fix for defect INC038282"));
2363 INC038282_L(aText, aDevice, aLayout, aView, aParagraphFormat);
2364 test.Next(_L(" @SYMTestCaseID:SYSLIB-FORM-UT-1663 Test fix for defect DEF073913 "));
2365 DEF073913L(aText, aDevice, aView, aParagraphFormat);
2366 test.Next(_L("Test fix for defect DEF047281"));
2367 DEF047281L(aText, aLayout);
2372 void RunTestTextViewL()
2375 TDocModel docModel(text);
2376 TRect displayRect(0, 0, KDisplayWidth, KDisplayHeight);
2377 CTextLayout* layout = CTextLayout::NewL(&docModel, displayRect.Width());
2378 CleanupStack::PushL(layout);
2379 CTestGraphicsDevice* device = CTestGraphicsDevice::NewL(displayRect.Size(), 0);
2380 CleanupStack::PushL(device);
2381 CTextView* view = CTextView::NewL(layout, displayRect,
2382 device, device, 0, 0, 0);
2383 CleanupStack::PushL(view);
2384 TestTextViewL(text, device, layout, view, &docModel);
2385 CParaFormat* paragraph = CParaFormat::NewLC();
2386 docModel.SetParagraphFormat(paragraph);
2387 TestTextViewParagraphL(text, device, layout, view, paragraph);
2388 CleanupStack::PopAndDestroy(paragraph);
2389 CleanupStack::PopAndDestroy(view);
2390 CleanupStack::PopAndDestroy(device);
2391 CleanupStack::PopAndDestroy(layout);
2394 void RunDirectionalityTestL()
2397 TDocModel docModel(text);
2398 TRect displayRect(0, 0, KDisplayWidth, KDisplayHeight);
2399 CTextLayout* layout = CTextLayout::NewL(&docModel, displayRect.Width());
2400 CleanupStack::PushL(layout);
2401 CTestGraphicsDevice* device = CTestGraphicsDevice::NewL(displayRect.Size(), 0);
2402 CleanupStack::PushL(device);
2403 CTextView* view = CTextView::NewL(layout, displayRect,
2404 device, device, 0, 0, 0);
2405 CleanupStack::PushL(view);
2406 DirectionalityTestL(text, device, layout, view);
2407 CleanupStack::PopAndDestroy(view);
2408 CleanupStack::PopAndDestroy(device);
2409 CleanupStack::PopAndDestroy(layout);
2412 _LIT(KText_020329, "ABCDEFGHIJ ABCDEFGHIJ ABCDEFGHIJ ABC\x2029 ABCDEFGHIJ ABCDEFGHIJ ABCDEFGHIJ \x2029 ABCDEFGHIJ ABCDEFGHIJ ABCDEFGHIJ \x2029 ABCDEFGHIJ ABCDEFGHIJ ABCDEFGHIJ \x2029");
2414 void INC020329TestL(TDes& aText, CTestGraphicsDevice* /*aDevice*/, CTextLayout* aLayout, CTextView* aView)
2416 TSize smallSize(100, 40);
2417 CTestGraphicsDevice* offScreenDevice = CTestGraphicsDevice::NewL(smallSize, 0);
2418 CleanupStack::PushL(offScreenDevice);
2419 CWindowGc* offScreenContext;
2420 User::LeaveIfError(offScreenDevice->CreateContext(offScreenContext));
2421 CleanupStack::PushL(offScreenContext);
2422 CTestTextView::SetOffScreenContext(aView, offScreenContext);
2423 aView->EnableFlickerFreeRedraw();
2425 // This test procedure checks for the presence of defect INC020329.
2426 // To do this we need a small view (100x40) and two paragraphs where
2427 // the first is 3.5 lines long. The defect results in the cursor
2428 // being unable to move down a line to the second paragraph from
2429 // the last half line of paragraph one. The cursor first jumps to end
2430 // of paragraph (end of line 4) and then no further. This defect occurs
2431 // when band formatting is configured.
2433 TTestCustomWrap wrapAnywhere;
2434 TCursorPosition::TMovementType moveDown = TCursorPosition::EFLineDown;
2436 TTmDocPos cursorPos;
2438 // Setup view/layout state appropriate for the 1st part of test.
2439 // Insert text, setup wrapping on any character
2440 // Cursor doc pos is 0, formatting is EFFormatAllText not band
2442 aText = KText_020329;
2443 aLayout->SetCustomWrap(&wrapAnywhere);
2444 aLayout->DiscardFormat();
2445 aView->HandleGlobalChangeL();
2447 // TEST: Cursor movement with WHOLE text formatting
2449 scrollBy = aView->SetDocPosL(0); // =(0,10)
2451 scrollBy = aView->SetDocPosL(22); // =(0,0)
2453 scrollBy = aView->MoveCursorL(moveDown, EFalse); // =(0,-12), EFLineDown
2454 test(moveDown==TCursorPosition::EFLineDown);
2455 aView->GetCursorPos(cursorPos); // (32,1)
2456 test(cursorPos.iPos==32);
2458 scrollBy = aView->MoveCursorL(moveDown, EFalse); // =(0,-13), EFLineDown
2459 test(moveDown==TCursorPosition::EFLineDown);
2460 aView->GetCursorPos(cursorPos); // (39,1)
2461 test(cursorPos.iPos==39);
2463 scrollBy = aView->MoveCursorL(moveDown, EFalse); // =(0,-13), EFLineDown
2464 test(moveDown==TCursorPosition::EFLineDown);
2465 aView->GetCursorPos(cursorPos); // (49,1)
2466 test(cursorPos.iPos==49);
2468 // Setup view/layout state appropriate for the 2nd part of test.
2469 // Loose all formatting data from previous test
2470 // Cursor doc pos is 0, formatting is EFFormatBand only
2472 aLayout->DiscardFormat();
2473 aLayout->SetAmountToFormat(CTextLayout::EFFormatBand);
2474 test(aLayout->IsFormattingBand());
2475 aView->HandleGlobalChangeL();
2477 // TEST: Same cursor movement above BUT with Band formatting
2479 scrollBy = aView->SetDocPosL(0);
2481 scrollBy = aView->SetDocPosL(22);
2483 scrollBy = aView->MoveCursorL(moveDown, EFalse);
2484 test(moveDown==TCursorPosition::EFLineDown);
2485 aView->GetCursorPos(cursorPos); // (32,1)
2486 test(cursorPos.iPos==32);
2488 scrollBy = aView->MoveCursorL(moveDown, EFalse); // Defect: =(0,0), EFLineEnd!
2489 test(moveDown==TCursorPosition::EFLineDown);
2490 aView->GetCursorPos(cursorPos); // Defect: (36,1)
2491 test(cursorPos.iPos==39);
2493 scrollBy = aView->MoveCursorL(moveDown, EFalse); // Defect: =(0,0), EFNoMovement!
2494 test(moveDown==TCursorPosition::EFLineDown);
2495 aView->GetCursorPos(cursorPos); // Defect: (36,1)
2496 test(cursorPos.iPos==49);
2499 aLayout->SetCustomWrap(0);
2500 aText.Delete(0, aText.Length());
2502 CTestTextView::SetOffScreenContext(aView, 0);
2503 CleanupStack::PopAndDestroy(offScreenContext);
2504 CleanupStack::PopAndDestroy(offScreenDevice);
2507 void RunTestINC020329L()
2510 TDocModel docModel(text);
2511 TRect displayRect(0, 0, 100, 40);
2512 CTextLayout* layout = CTextLayout::NewL(&docModel, displayRect.Width());
2513 CleanupStack::PushL(layout);
2514 CTestGraphicsDevice* device = CTestGraphicsDevice::NewL(displayRect.Size(), 0);
2515 CleanupStack::PushL(device);
2516 CTextView* view = CTextView::NewL(layout, displayRect,
2517 device, device, 0, 0, 0);
2518 CleanupStack::PushL(view);
2520 INC020329TestL(text, device, layout, view);
2522 CleanupStack::PopAndDestroy(view);
2523 CleanupStack::PopAndDestroy(device);
2524 CleanupStack::PopAndDestroy(layout);
2528 @SYMTestCaseID SYSLIB-FORM-CT-1861
2529 @SYMTestCaseDesc Tests to ensure the correct operation of highlight extensions.
2530 @SYMTestPriority High
2531 @SYMTestActions Insert a paragraph of text, which contains at least 3 lines. Highlight different
2532 sections with different highlight extension settings and compare resulting
2533 screen with pre-defined bitmaps.
2534 @SYMTestExpectedResults Screen and bitmaps should match
2537 void RunTestPDEF085280L()
2539 //create editor/bitmap
2540 CTestBitmapFile* bitMap = CTestBitmapFile::NewLC(TRect(0, 0, 360, 94));
2542 //open the zipfile containing the comparison bitmaps
2543 CTestBitmapZipFileExtractor* extract = CTestBitmapZipFileExtractor::NewLC(
2544 _L("Z:\\test\\app-framework\\form\\input\\bitmaps.zip"));
2547 bitMap->AppendL(_L("the quick brown fox jumped over the lazy dog. 1234567890?!*"));
2548 bitMap->View()->HandleGlobalChangeL();
2550 /*********************************************************
2551 Note:- The commented "SaveFileL" code below was used to originally
2552 generate the baseline test data. It has been left in and commented
2553 so that if the data needs to be changed in the future, it will just
2554 be case of temporarily moving the commenter from the "SaveFileL"
2556 *********************************************************/
2558 //Base-line test - no highlight extensions
2559 bitMap->View()->SetDocPosL(27);
2560 bitMap->View()->SetDocPosL(31,ETrue);
2561 // bitMap->SaveFileL(_L("c:\\SetHighlightExtensions(0,0,0,0).bmp"));
2562 test(bitMap->CompareL(extract->BitmapFileL(_L("SetHighlightExtensions(0,0,0,0).bmp"))));
2564 //Shift highlight north-west
2565 bitMap->View()->SetDocPosL(27);
2566 bitMap->View()->SetHighlightExtensions(25,-25,12,-12);
2567 bitMap->View()->SetDocPosL(31,ETrue);
2568 // bitMap->SaveFileL(_L("c:\\SetHighlightExtensions(25,-25,12,-12).bmp"));
2569 test(bitMap->CompareL(extract->BitmapFileL(_L("SetHighlightExtensions(25,-25,12,-12).bmp"))));
2571 //Shift highlight south-east
2572 bitMap->View()->SetDocPosL(27);
2573 bitMap->View()->SetHighlightExtensions(-25,25,-12,12);
2574 bitMap->View()->SetDocPosL(31,ETrue);
2575 // bitMap->SaveFileL(_L("c:\\SetHighlightExtensions(-25,25,-12,12).bmp"));
2576 test(bitMap->CompareL(extract->BitmapFileL(_L("SetHighlightExtensions(-25,25,-12,12).bmp"))));
2578 //Shift highlight north-east
2579 bitMap->View()->SetDocPosL(27);
2580 bitMap->View()->SetHighlightExtensions(-25,25,12,-12);
2581 bitMap->View()->SetDocPosL(31,ETrue);
2582 // bitMap->SaveFileL(_L("c:\\SetHighlightExtensions(-25,25,12,-12).bmp"));
2583 test(bitMap->CompareL(extract->BitmapFileL(_L("SetHighlightExtensions(-25,25,12,-12).bmp"))));
2585 //Shift highlight south-west
2586 bitMap->View()->SetDocPosL(27);
2587 bitMap->View()->SetHighlightExtensions(25,-25,-12,12);
2588 bitMap->View()->SetDocPosL(31,ETrue);
2589 // bitMap->SaveFileL(_L("c:\\SetHighlightExtensions(25,-25,-12,12).bmp"));
2590 test(bitMap->CompareL(extract->BitmapFileL(_L("SetHighlightExtensions(25,-25,-12,12).bmp"))));
2592 //Make extensions huge and highlight one character - highlight blobs over nearly whole screen
2593 bitMap->View()->SetDocPosL(29);
2594 bitMap->View()->SetHighlightExtensions(120,100,15,15);
2595 bitMap->View()->SetDocPosL(30,ETrue);
2596 // bitMap->SaveFileL(_L("c:\\SetHighlightExtensions(120,100,15,15).bmp"));
2597 test(bitMap->CompareL(extract->BitmapFileL(_L("SetHighlightExtensions(120,100,15,15).bmp"))));
2599 //Precursor to highlight overlap - skinny highlight through text
2600 bitMap->View()->SetDocPosL(8);
2601 bitMap->View()->SetHighlightExtensions(0,0,-5,-5);
2602 bitMap->View()->SetDocPosL(31,ETrue);
2603 // bitMap->SaveFileL(_L("c:\\SetHighlightExtensions(0,0,-5,-5).bmp"));
2604 test(bitMap->CompareL(extract->BitmapFileL(_L("SetHighlightExtensions(0,0,-5,-5).bmp"))));
2606 //Highlight overlap - extension top and bottom overlaps between lines
2607 bitMap->View()->SetDocPosL(8);
2608 bitMap->View()->SetHighlightExtensions(0,0,10,10);
2609 bitMap->View()->SetDocPosL(31,ETrue);
2610 // bitMap->SaveFileL(_L("c:\\SetHighlightExtensions(0,0,10,10).bmp"));
2611 test(bitMap->CompareL(extract->BitmapFileL(_L("SetHighlightExtensions(0,0,10,10).bmp"))));
2613 CleanupStack::PopAndDestroy(2,bitMap);
2616 void PDEF097387TestL(CRichText* aRichText, CTextView* aTextView)
2618 _LIT(KTest,"0123456789");
2619 TPtrC text1(KTest().Ptr(), KTest().Length());
2620 CTextLayout* layout = const_cast<CTextLayout*>(aTextView->Layout());
2622 aRichText->InsertL(0, text1);
2624 // set line ascent and descent so baseline will be outside line rect
2625 aTextView->SetExcessHeightRequired(3);
2626 layout->SetMinimumLineDescent(0);
2627 aTextView->FormatTextL();
2629 // scroll through the document and test that the cursor goes to the right position
2630 // none of these tests should fail.
2631 TTmDocPos pos(9, ETrue);
2632 aTextView->SetDocPosL(pos);
2633 TCursorPosition::TMovementType move = TCursorPosition::EFLeft;
2634 aTextView->MoveCursorL(move, EFalse);
2635 aTextView->GetCursorPos(pos);
2636 test(pos.iPos == 8);
2637 aTextView->MoveCursorL(move, EFalse);
2638 aTextView->GetCursorPos(pos);
2639 test(pos.iPos == 7);
2640 aTextView->MoveCursorL(move, EFalse);
2641 aTextView->GetCursorPos(pos);
2642 test(pos.iPos == 6);
2643 move = TCursorPosition::EFLeft;
2644 aTextView->MoveCursorL(move, EFalse);
2645 aTextView->GetCursorPos(pos);
2646 test(pos.iPos == 5);
2647 move = TCursorPosition::EFLeft;
2648 aTextView->MoveCursorL(move, EFalse);
2649 aTextView->GetCursorPos(pos);
2650 test(pos.iPos == 4);
2651 move = TCursorPosition::EFLeft;
2652 aTextView->MoveCursorL(move, EFalse);
2653 aTextView->GetCursorPos(pos);
2654 test(pos.iPos == 3);
2655 move = TCursorPosition::EFLeft;
2656 aTextView->MoveCursorL(move, EFalse);
2657 aTextView->GetCursorPos(pos);
2658 test(pos.iPos == 2);
2659 move = TCursorPosition::EFLeft;
2660 aTextView->MoveCursorL(move, EFalse);
2661 aTextView->GetCursorPos(pos);
2662 test(pos.iPos == 1);
2663 move = TCursorPosition::EFLeft;
2664 aTextView->MoveCursorL(move, EFalse);
2665 aTextView->GetCursorPos(pos);
2666 test(pos.iPos == 0);
2670 void RunPDEF097387TestL(CFbsScreenDevice* aDevice)
2672 CParaFormat* paraFormat = CParaFormat::NewLC();
2673 TParaFormatMask paraFormatMask;
2674 // set up paragraph propeties
2675 paraFormat->iHorizontalAlignment=CParaFormat::ELeftAlign;
2676 paraFormatMask.SetAttrib(EAttAlignment);
2677 paraFormat->iLineSpacingInTwips=21;
2678 paraFormatMask.SetAttrib(EAttLineSpacing);
2679 paraFormat->iLineSpacingControl=CParaFormat::ELineSpacingExactlyInPixels;
2680 paraFormatMask.SetAttrib(EAttLineSpacingControl);
2681 CParaFormatLayer* paraFormatLayer = CParaFormatLayer::NewL(paraFormat,paraFormatMask);
2682 CleanupStack::PushL(paraFormatLayer);
2683 CCharFormatLayer* charFormat = CCharFormatLayer::NewL();
2684 CleanupStack::PushL(charFormat);
2685 CRichText* text = CRichText::NewL(paraFormatLayer, charFormat);
2686 CleanupStack::PushL(text);
2687 TRect displayRect(0, 0, 70, 42);
2688 CTextLayout* layout = CTextLayout::NewL(text, displayRect.Width());
2689 CleanupStack::PushL(layout);
2690 CTextView* view = CTextView::NewL(layout, displayRect,
2691 aDevice, aDevice, 0, 0, 0);
2692 CleanupStack::PushL(view);
2694 PDEF097387TestL(text, view);
2695 CleanupStack::PopAndDestroy(view);
2696 CleanupStack::PopAndDestroy(layout);
2697 CleanupStack::PopAndDestroy(text);
2698 CleanupStack::PopAndDestroy(charFormat);
2699 CleanupStack::PopAndDestroy(paraFormatLayer);
2700 CleanupStack::PopAndDestroy(paraFormat);
2704 @SYMTestCaseID SYSLIB-FORM-UT-3162
2705 @SYMTestCaseDesc Tests to ensure the correct cursor position is maintained when scrolling through a document
2706 @SYMTestPriority High
2707 @SYMTestActions Creates a view and layout whose will have baselines outside the rect. of the line.
2708 It then tests that when scrolling through the document that the correct cursor position is maintained
2709 @SYMTestExpectedResults Cursor position should be maintained correctly when scrolling through document.
2712 _LIT(KTestFont, "ClearlyU");
2713 void SetupAndRunPDEF097387TestL()
2716 CFbsScreenDevice* screenDevice = 0;
2717 TRAP(error, screenDevice = CFbsScreenDevice::NewL(0,EColor16M));
2718 if (error == KErrNotSupported)
2719 TRAP(error, screenDevice = CFbsScreenDevice::NewL(0,EColor16MA));
2720 if (error == KErrNotSupported)
2721 TRAP(error, screenDevice = CFbsScreenDevice::NewL(0,EColor16MU));
2722 if (error == KErrNotSupported)
2723 TRAP(error, screenDevice = CFbsScreenDevice::NewL(0,EColor64K));
2724 if (error == KErrNotSupported)
2725 TRAP(error, screenDevice = CFbsScreenDevice::NewL(0,EColor4K));
2726 if (error == KErrNotSupported)
2727 TRAP(error, screenDevice = CFbsScreenDevice::NewL(0,EColor256));
2728 if (error == KErrNotSupported)
2729 TRAP(error, screenDevice = CFbsScreenDevice::NewL(0,EColor16));
2730 if (error == KErrNotSupported)
2731 TRAP(error, screenDevice = CFbsScreenDevice::NewL(0,EGray256));
2732 if (error == KErrNotSupported)
2733 TRAP(error, screenDevice = CFbsScreenDevice::NewL(0,EGray16));
2734 if (error == KErrNotSupported)
2735 TRAP(error, screenDevice = CFbsScreenDevice::NewL(0,EGray4));
2736 if (error == KErrNotSupported)
2737 screenDevice = CFbsScreenDevice::NewL(0,EGray2);
2739 CleanupStack::PushL(screenDevice);
2740 screenDevice->ChangeScreenDevice(0);
2741 screenDevice->SetAutoUpdate(ETrue);
2742 CGraphicsContext* gc;
2743 User::LeaveIfError(screenDevice->CreateContext(gc));
2744 CleanupStack::PushL(gc);
2745 TFontSpec fs(KTestFont, 20);
2747 User::LeaveIfError(screenDevice->GetNearestFontInPixels(font, fs));
2748 TFontSpec fontSpec = font->FontSpecInTwips();
2749 if(0 != fontSpec.iTypeface.iName.Compare(KTestFont))
2751 // Test font not found.
2752 User::Leave(KErrNotFound);
2754 TRAP(error, RunPDEF097387TestL(screenDevice));
2755 CleanupStack::PopAndDestroy(gc);
2756 CleanupStack::PopAndDestroy(screenDevice);
2757 User::LeaveIfError(error);
2761 @SYMTestCaseID SYSLIB-FORM-UT-3241
2762 @SYMTestCaseDesc Test to ensure that invalid rectangle of the text view is being set
2763 correctly after removing of a line of text
2764 @SYMTestPriority High
2765 @SYMTestActions Creates a text document and view and layout objects for it.
2766 Then appends text to the document one character at a
2767 time until text starts to wrap to the second line. At this point
2768 the last character is being deleted, so that the text fits into
2769 one line once again. Then we get the invalid rectangle of the view
2770 and check that this rectangle includes the area where the second line
2772 @SYMTestExpectedResults The location of the second line of text should be included into
2776 void RunPDEF098569TestL()
2778 //create editor/bitmap
2779 CTestBitmapFile* bitMap = CTestBitmapFile::NewLC();
2781 bitMap->AppendL(_L("a")); //insert first character to calculate first line's height
2782 bitMap->View()->HandleCharEditL();
2783 TInt FirstLineBottom = CTestTextView::GetFormattedHeight(bitMap->View());
2784 //perform appending loop
2787 bitMap->AppendL(_L("a"));
2788 bitMap->View()->HandleCharEditL();
2790 while (CTestTextView::GetFormattedHeight(bitMap->View())==FirstLineBottom );
2791 TInt SecondLineBottom = CTestTextView::GetFormattedHeight(bitMap->View());
2793 //delete last character
2794 TInt last = bitMap->Layout()->DocumentLength() - 1;
2795 TCursorSelection selection=TCursorSelection(last,last);
2796 bitMap->DocModel()->DelSetInsertCharFormatL(selection.LowerPos(),1);
2797 bitMap->View()->HandleCharEditL(CTextLayout::EFLeftDelete,EFalse);
2799 //get the invalid area of the view object
2800 TRect invalid_rect = CTestTextView::GetInvalidRect(bitMap->View());
2801 //check that entire rectangle of the second line lies within the invalid area
2802 test(invalid_rect.iTl.iY<=FirstLineBottom && invalid_rect.iBr.iY>=SecondLineBottom);
2804 CleanupStack::PopAndDestroy(bitMap);
2808 @SYMTestCaseID SYSLIB-FORM-UT-3345
2809 @SYMTestCaseDesc Test to ensure that implicit redraw is disabled until an external
2811 @SYMTestPriority High
2812 @SYMTestActions Create a view and layout object.
2813 Check BeginDraw() and EndDraw() are disabled.
2815 Check BeginDraw() and EndDraw() are enabled.
2816 @SYMTestExpectedResults Implicit redraw should be disabled until external draw
2820 void RunINC099424TestL()
2823 TDocModel docModel(text);
2824 TRect displayRect(0, 0, KDisplayWidth, KDisplayHeight);
2825 CTextLayout* layout = CTextLayout::NewL(&docModel, displayRect.Width());
2826 CleanupStack::PushL(layout);
2827 CTestGraphicsDevice* device = CTestGraphicsDevice::NewL(displayRect.Size(), 0);
2828 CleanupStack::PushL(device);
2829 CTextView* view = CTextView::NewL(layout, displayRect,
2830 device, device, 0, 0, 0);
2831 CleanupStack::PushL(view);
2833 // This test uses CTextLayout::BeginRedrawCalled() to determine whether or not
2834 // CTextLayout::BeginRedraw() and CTextLayout::EndRedraw() are enabled.
2835 // CTextLayout::BeginRedrawCalled() returns ETrue if CTextLayout::iBeginRedrawCount
2836 // is greater than 0. Otherwise EFalse.
2837 // CTextLayout::BeginRedraw() and CTextLayout::EndRedraw() increments or
2838 // decrements iBeginRedrawCount respectively if they are enabled.
2840 TRect rect(0,0,0,0);
2842 // Check iBeginRedrawCount is 0 initially.
2843 // If next line is successful then iBeginRedrawCount must be 0
2844 // because it is initialised to this on construction.
2845 test(layout->BeginRedrawCalled() == EFalse);
2847 // Check begin and end functions are disabled
2848 layout->BeginRedraw(rect);
2849 test(layout->BeginRedrawCalled() == EFalse);
2850 // Doing this many times in case enabled and the CTextLayout::iBeginRedrawCount
2851 // was already negative.
2852 for(TInt i = 0; i < 20; i++)
2853 layout->EndRedraw();
2854 test(layout->BeginRedrawCalled() == EFalse);
2856 // Enable begin and end functions with external draw.
2857 // BeginRedrawCalled returns EFalse because DrawL call both begin and end
2858 // which increments then decrements iBeginRedrawCount
2860 test(layout->BeginRedrawCalled() == EFalse);
2862 // Test begin and end functions are enabled individually
2863 layout->BeginRedraw(rect);
2864 test(layout->BeginRedrawCalled() != EFalse);
2865 layout->EndRedraw();
2866 test(layout->BeginRedrawCalled() == EFalse);
2869 CleanupStack::PopAndDestroy(view);
2870 CleanupStack::PopAndDestroy(device);
2871 CleanupStack::PopAndDestroy(layout);
2875 @SYMTestCaseID SYSLIB-FORM-CT-3754
2876 @SYMTestCaseDesc A further test to ensure the correct operation of highlight extensions.
2877 @SYMTestPriority High
2878 @SYMTestActions Fill viewable area with multiple short lines of text. The next line
2879 to scroll into view should be a longer line of text followed by more
2880 short lines. Ensure highlighting and band formatting are on. Select
2881 the text from the beginning of the document until after the short line
2882 directly following the long line.
2883 @SYMTestExpectedResults Screen and bitmaps should match - the whole of the long line should be
2887 void RunINC109995TestL()
2889 //create editor/bitmap
2890 CTestBitmapFile* bitMap = CTestBitmapFile::NewLC();
2892 //open the zipfile containing the comparison bitmaps
2893 CTestBitmapZipFileExtractor* extract = CTestBitmapZipFileExtractor::NewLC(
2894 _L("Z:\\test\\app-framework\\form\\input\\bitmaps.zip"));
2896 //set up test conditions
2897 bitMap->Layout()->SetAmountToFormat();
2898 bitMap->Layout()->SetHighlightExtensions(0,0,-1,-1);
2900 // the offscreen bitmap. This looks like an unexpected feature in its' own right. The visual
2901 // effect, in this case, is that out of the three visible lines, only the
2902 // second line gets updated when scrolling with highlighting on.
2903 bitMap->View()->DisableFlickerFreeRedraw();
2906 bitMap->AppendL(_L("11111\x2029"));
2907 bitMap->AppendL(_L("22222\x2029"));
2908 bitMap->AppendL(_L("33333\x2029"));
2909 bitMap->AppendL(_L("aaaaaaaaaaaaaaaaa\x2029"));
2910 bitMap->AppendL(_L("44444\x2029"));
2911 bitMap->AppendL(_L("55555\x2029"));
2912 bitMap->View()->HandleGlobalChangeL();
2914 //highlight the text
2915 TCursorPosition::TMovementType lineDown = TCursorPosition::EFLineDown;
2916 bitMap->View()->SetDocPosL(0);
2917 bitMap->View()->MoveCursorL(lineDown,ETrue);
2918 bitMap->View()->MoveCursorL(lineDown,ETrue);
2919 bitMap->View()->MoveCursorL(lineDown,ETrue);
2920 bitMap->View()->MoveCursorL(lineDown,ETrue);
2921 bitMap->View()->MoveCursorL(lineDown,ETrue);
2923 // bitMap->SaveFileL(_L("c:\\ScrolledHighlight.bmp"));
2924 test(bitMap->CompareL(extract->BitmapFileL(_L("ScrolledHighlight.bmp"))));
2926 CleanupStack::PopAndDestroy(2,bitMap);
2930 @SYMTestCaseID SYSLIB-FORM-CT-4003
2931 @SYMTestCaseDesc Test to ensure correct cursor movement between 2 lines containing a pictures.
2932 @SYMTestPriority High
2933 @SYMTestActions Inserts pictures until the line breaks, then moves the cursor leftwards for
2934 LTR text, and rightwards for RTL text, starting from the end of the 2nd line,
2935 testing the MovementType that has taken place and the position of the cursor
2936 after the movement, especially when the cursor moves to the first line.
2937 @SYMTestExpectedResults Resulting document position are where expected.
2940 void RunPDEF112004TestL()
2943 //create editor/bitmap
2944 CTestBitmapFile* bitMap = CTestBitmapFile::NewLC(TRect(0, 0, 140, 185));
2946 //create the picture to insert (this one is a red box)
2947 CTestPicture* pic = new(ELeave)CTestPicture();
2948 CleanupStack::PushL(pic);
2949 pic->SetSizeInTwips(TSize(400,400));
2951 //Add lots of pictures until we get a line break, and then format the view
2952 // Just to be sure, add one picture after we get a line break.
2959 bitMap->AppendL(pic);
2960 numLines = bitMap->View()->Layout()->NumFormattedLines();
2963 bitMap->View()->HandleGlobalChangeL();
2965 // Place the cursor at the end of the last picture added and start moving the cursor left.
2967 bitMap->View()->GetCursorPos(thisPos);
2968 TCursorPosition::TMovementType type = TCursorPosition::EFLeft;
2970 // Docuemnt position is already at the end, but it is Trailing. Make it Leading and set it.
2971 TTmDocPosSpec::TType docPosType = TTmDocPosSpec::ELeading;
2972 TTmDocPosSpec docPos;
2973 docPos.iPos = pos;//thisPos.iPos;
2974 docPos.iType = docPosType;
2976 bitMap->View()->SetDocPosL(docPos);
2977 bitMap->View()->GetCursorPos(thisPos);
2978 test(thisPos.iPos == 4);
2979 // Move the cursor and test if it has moved
2980 bitMap->View()->MoveCursorL(type, EFalse);
2981 bitMap->View()->GetCursorPos(thisPos);
2983 test(thisPos.iPos == 3 && type == TCursorPosition::EFLeft);
2984 // Move the cursor and test if it has moved
2985 bitMap->View()->MoveCursorL(type, EFalse);
2986 bitMap->View()->GetCursorPos(thisPos);
2987 test(thisPos.iPos == 3 && type == TCursorPosition::EFLeft);
2988 // Move the cursor and test if it has moved
2989 bitMap->View()->MoveCursorL(type, EFalse);
2990 bitMap->View()->GetCursorPos(thisPos);
2991 test(thisPos.iPos == 2 && type == TCursorPosition::EFLeft);
2992 // Move the cursor and test if it has moved
2993 bitMap->View()->MoveCursorL(type, EFalse);
2994 bitMap->View()->GetCursorPos(thisPos);
2995 test(thisPos.iPos == 1 && type == TCursorPosition::EFLeft);
2996 // Move the cursor and test if it has moved
2997 bitMap->View()->MoveCursorL(type, EFalse);
2998 bitMap->View()->GetCursorPos(thisPos);
2999 test(thisPos.iPos == 1 && type == TCursorPosition::EFLeft);
3001 /** Now test the same for pictures in a RTL paragraph.
3002 Put some RTL text so that the paragraph changes to a RTL paragraph.
3003 Then move the cursor right, through the pictures */
3004 bitMap->AppendL(_L("\x630"));
3005 bitMap->View()->HandleGlobalChangeL();
3007 docPos.iPos = bitMap->View()->Layout()->DocumentLength();
3008 docPos.iType = TTmDocPosSpec::ELeading;
3009 bitMap->View()->SetDocPosL(docPos);
3010 bitMap->View()->GetCursorPos(thisPos);
3011 test(thisPos.iPos == 5);
3013 type = TCursorPosition::EFRight;
3014 // Move the cursor and test if it has moved
3015 bitMap->View()->MoveCursorL(type, EFalse);
3016 bitMap->View()->GetCursorPos(thisPos);
3018 test(thisPos.iPos == 4 && type == TCursorPosition::EFRight);
3019 // Move the cursor and test if it has moved
3020 bitMap->View()->MoveCursorL(type, EFalse);
3021 bitMap->View()->GetCursorPos(thisPos);
3023 test(thisPos.iPos == 3 && type == TCursorPosition::EFRight);
3024 // Move the cursor and test if it has moved
3025 bitMap->View()->MoveCursorL(type, EFalse);
3026 bitMap->View()->GetCursorPos(thisPos);
3028 test(thisPos.iPos == 3 && type == TCursorPosition::EFRight);
3029 // Move the cursor and test if it has moved
3030 bitMap->View()->MoveCursorL(type, EFalse);
3031 bitMap->View()->GetCursorPos(thisPos);
3033 test(thisPos.iPos == 2 && type == TCursorPosition::EFRight);
3034 // Move the cursor and test if it has moved
3035 bitMap->View()->MoveCursorL(type, EFalse);
3036 bitMap->View()->GetCursorPos(thisPos);
3038 test(thisPos.iPos == 1 && type == TCursorPosition::EFRight);
3040 CleanupStack::Pop(pic);
3041 CleanupStack::PopAndDestroy(1);
3046 @SYMTestCaseID SYSLIB-FORM-CT-4001
3047 @SYMTestCaseDesc Test to ensure correct picture selection and cursor movement in
3048 line of text containing a picture.
3049 @SYMTestPriority High
3050 @SYMTestActions Writes text wrapping to five lines and inserts pictures in the
3051 middle three lines and sets picture text alignment other than
3052 baseline, then tests that various cursor movements result in the
3053 correct doc positions. Also checks that a frame is drawn around the
3054 centre picture when expected.
3055 @SYMTestExpectedResults Resulting document position are where expected; frame drawn correctly
3058 void RunINC112423TestVariantsL(const TDesC& aComparisonFileName, const TDesC& aText,
3059 TFontPresentation::TAlignment aAlignment, TCursorPosition::TMovementType aMove)
3061 //open the zipfile containing the comparison bitmaps
3062 CTestBitmapZipFileExtractor* extract = CTestBitmapZipFileExtractor::NewLC(
3063 _L("Z:\\test\\app-framework\\form\\input\\bitmaps.zip"));
3065 //create editor/bitmap
3066 CTestBitmapFile* bitMap = CTestBitmapFile::NewLC(TRect(0, 0, 160, 185), TCharFormat(_L("ClearlyU"),1));
3068 //create the picture to insert (this one is a red box)
3069 CTestPicture* pic = new(ELeave)CTestPicture();
3070 CleanupStack::PushL(pic);
3071 pic->SetSizeInTwips(TSize(400,400)); //pic needs to be higher than text height to catch all aligments
3073 //insert mixture of text and pictures
3074 bitMap->AppendL(aText);
3075 bitMap->AppendL(aText);
3076 bitMap->AppendL(aText);
3077 TInt firstPicPos = bitMap->DocModel()->DocumentLength(); //get cursor pos of first picture
3078 bitMap->AppendL(pic);
3079 bitMap->View()->HandleGlobalChangeL();
3081 //change picture alignment
3082 TInt docLength = bitMap->DocModel()->DocumentLength();
3083 TCursorSelection selection(docLength, docLength-1);
3084 bitMap->View()->SetSelectionL(selection);
3086 format.iFontPresentation.iPictureAlignment = aAlignment;
3087 TCharFormatMask mask;
3088 mask.SetAttrib(EAttFontPictureAlignment);
3089 bitMap->DocModel()->ApplyCharFormatL(format, mask, selection.LowerPos(), 1);
3090 bitMap->View()->HandleRangeFormatChangeL(selection,EFalse);
3091 bitMap->View()->CancelSelectionL();
3093 //insert more text and pictures
3094 bitMap->AppendL(aText);
3095 bitMap->AppendL(aText);
3096 TInt secondPicPos = bitMap->DocModel()->DocumentLength(); //get cursor pos of second picture
3097 bitMap->AppendL(pic);
3098 bitMap->AppendL(aText);
3099 bitMap->AppendL(aText);
3100 TInt thirdPicPos = bitMap->DocModel()->DocumentLength(); //get cursor pos of third picture
3101 bitMap->AppendL(pic);
3102 bitMap->AppendL(aText);
3103 bitMap->AppendL(aText);
3104 bitMap->AppendL(aText);
3105 bitMap->View()->HandleGlobalChangeL();
3107 //now move cursor over each picture and test for correct selection
3109 bitMap->View()->SetDocPosL(firstPicPos);
3110 bitMap->View()->MoveCursorL(aMove, EFalse);
3111 bitMap->View()->GetCursorPos(thisPos);
3112 test(thisPos.iPos == firstPicPos); //cursor should be over the first picture
3113 bitMap->View()->SetDocPosL(secondPicPos);
3114 bitMap->View()->MoveCursorL(aMove, EFalse);
3115 bitMap->View()->GetCursorPos(thisPos);
3116 test(thisPos.iPos == secondPicPos); //cursor should be over the second picture
3117 // bitMap->SaveFileL(aComparisonFileName); //and a frame should be drawn over it
3118 test(bitMap->CompareL(extract->BitmapFileL(aComparisonFileName)));
3119 bitMap->View()->SetDocPosL(thirdPicPos);
3120 bitMap->View()->MoveCursorL(aMove, EFalse);
3121 bitMap->View()->GetCursorPos(thisPos);
3122 test(thisPos.iPos == thirdPicPos); //cursor should be over the third picture
3124 //Test up/down cursor movement
3126 TBool leadingEdge = aMove == TCursorPosition::EFRight;
3127 TCursorPosition::TMovementType move = TCursorPosition::EFLineDown;
3128 bitMap->View()->SetDocPosL(0); //go to top of document
3129 bitMap->View()->GetCursorPos(thisPos);
3131 TTmDocPos firstLineHome(thisPos.iPos, leadingEdge);
3132 bitMap->View()->MoveCursorL(move, EFalse);
3133 bitMap->View()->GetCursorPos(thisPos);
3134 test(thisPos.iPos > lastPos.iPos); //cursor should have moved down
3135 TTmDocPos secondLineHome = lastPos = thisPos;
3136 TTmDocPos firstLineEnd(secondLineHome.iPos - 1, leadingEdge);
3137 bitMap->View()->MoveCursorL(move, EFalse);
3138 bitMap->View()->GetCursorPos(thisPos);
3139 test(thisPos.iPos > lastPos.iPos); //cursor should have moved down again
3140 TTmDocPos thirdLineHome = lastPos = thisPos;
3141 TTmDocPos secondLineEnd(thirdLineHome.iPos - 1, leadingEdge);
3142 bitMap->View()->MoveCursorL(move, EFalse);
3143 bitMap->View()->GetCursorPos(thisPos);
3144 test(thisPos.iPos > lastPos.iPos); //cursor should have moved down again
3145 TTmDocPos fourthLineHome = lastPos = thisPos;
3146 TTmDocPos thirdLineEnd(fourthLineHome.iPos - 1, leadingEdge);
3147 bitMap->View()->MoveCursorL(move, EFalse);
3148 bitMap->View()->GetCursorPos(thisPos);
3149 test(thisPos.iPos > lastPos.iPos); //cursor should have moved down again
3150 TTmDocPos fifthLineHome = lastPos = thisPos;
3151 TTmDocPos fourthLineEnd(fifthLineHome.iPos - 1, leadingEdge);
3152 bitMap->View()->SetDocPosL(bitMap->DocModel()->DocumentLength()); //go to end of document
3153 bitMap->View()->GetCursorPos(thisPos);
3155 TTmDocPos fifthLineEnd(thisPos.iPos, leadingEdge);
3156 bitMap->View()->MoveCursorL(move = TCursorPosition::EFLineUp, EFalse);
3157 bitMap->View()->GetCursorPos(thisPos);
3158 test(thisPos.iPos < lastPos.iPos); //cursor should have moved up
3160 bitMap->View()->MoveCursorL(move, EFalse);
3161 bitMap->View()->GetCursorPos(thisPos);
3162 test(thisPos.iPos < lastPos.iPos); //cursor should have moved up again
3164 bitMap->View()->MoveCursorL(move, EFalse);
3165 bitMap->View()->GetCursorPos(thisPos);
3166 test(thisPos.iPos < lastPos.iPos); //cursor should have moved up again
3168 bitMap->View()->MoveCursorL(move, EFalse);
3169 bitMap->View()->GetCursorPos(thisPos);
3170 test(thisPos.iPos < lastPos.iPos); //cursor should have moved up again
3172 //Test home/end cursor movement
3173 bitMap->View()->MoveCursorL(move = TCursorPosition::EFLineBeg, EFalse);
3174 bitMap->View()->GetCursorPos(thisPos);
3175 test(thisPos == firstLineHome);
3176 bitMap->View()->MoveCursorL(move = TCursorPosition::EFLineEnd, EFalse);
3177 bitMap->View()->GetCursorPos(thisPos);
3178 test(thisPos == firstLineEnd);
3179 bitMap->View()->MoveCursorL(move = TCursorPosition::EFLineDown, EFalse);
3180 bitMap->View()->MoveCursorL(move = TCursorPosition::EFLineBeg, EFalse);
3181 bitMap->View()->GetCursorPos(thisPos);
3182 test(thisPos == secondLineHome);
3183 bitMap->View()->MoveCursorL(move = TCursorPosition::EFLineEnd, EFalse);
3184 bitMap->View()->GetCursorPos(thisPos);
3185 test(thisPos == secondLineEnd);
3186 bitMap->View()->MoveCursorL(move = TCursorPosition::EFLineDown, EFalse);
3187 bitMap->View()->MoveCursorL(move = TCursorPosition::EFLineBeg, EFalse);
3188 bitMap->View()->GetCursorPos(thisPos);
3189 test(thisPos == thirdLineHome);
3190 bitMap->View()->MoveCursorL(move = TCursorPosition::EFLineEnd, EFalse);
3191 bitMap->View()->GetCursorPos(thisPos);
3192 test(thisPos == thirdLineEnd);
3193 bitMap->View()->MoveCursorL(move = TCursorPosition::EFLineDown, EFalse);
3194 bitMap->View()->MoveCursorL(move = TCursorPosition::EFLineBeg, EFalse);
3195 bitMap->View()->GetCursorPos(thisPos);
3196 test(thisPos == fourthLineHome);
3197 bitMap->View()->MoveCursorL(move = TCursorPosition::EFLineEnd, EFalse);
3198 bitMap->View()->GetCursorPos(thisPos);
3199 test(thisPos == fourthLineEnd);
3200 bitMap->View()->MoveCursorL(move = TCursorPosition::EFLineDown, EFalse);
3201 bitMap->View()->MoveCursorL(move = TCursorPosition::EFLineBeg, EFalse);
3202 bitMap->View()->GetCursorPos(thisPos);
3203 test(thisPos == fifthLineHome);
3204 bitMap->View()->MoveCursorL(move = TCursorPosition::EFLineEnd, EFalse);
3205 bitMap->View()->GetCursorPos(thisPos);
3206 test(thisPos == fifthLineEnd);
3208 //Test at line extremes cursor movement left/right wraps to next/previous line
3209 move = aMove == TCursorPosition::EFRight? TCursorPosition::EFLeft : TCursorPosition::EFRight;
3210 bitMap->View()->SetDocPosL(firstLineEnd);
3211 bitMap->View()->MoveCursorL(aMove, EFalse);
3212 bitMap->View()->GetCursorPos(thisPos);
3213 test(thisPos == secondLineHome);
3214 bitMap->View()->MoveCursorL(move, EFalse);
3215 bitMap->View()->GetCursorPos(thisPos);
3216 test(thisPos == firstLineEnd);
3217 bitMap->View()->SetDocPosL(secondLineEnd);
3218 bitMap->View()->MoveCursorL(aMove, EFalse);
3219 bitMap->View()->GetCursorPos(thisPos);
3220 test(thisPos == thirdLineHome);
3221 bitMap->View()->MoveCursorL(move, EFalse);
3222 bitMap->View()->GetCursorPos(thisPos);
3223 test(thisPos == secondLineEnd);
3224 bitMap->View()->SetDocPosL(thirdLineEnd);
3225 bitMap->View()->MoveCursorL(aMove, EFalse);
3226 bitMap->View()->GetCursorPos(thisPos);
3227 test(thisPos == fourthLineHome);
3228 bitMap->View()->MoveCursorL(move, EFalse);
3229 bitMap->View()->GetCursorPos(thisPos);
3230 test(thisPos == thirdLineEnd);
3231 bitMap->View()->SetDocPosL(fourthLineEnd);
3232 bitMap->View()->MoveCursorL(aMove, EFalse);
3233 bitMap->View()->GetCursorPos(thisPos);
3234 test(thisPos == fifthLineHome);
3235 bitMap->View()->MoveCursorL(move, EFalse);
3236 bitMap->View()->GetCursorPos(thisPos);
3237 test(thisPos == fourthLineEnd);
3239 //Test pageup/pagedown
3240 bitMap->View()->MoveCursorL(move = TCursorPosition::EFPageUp, EFalse);
3241 bitMap->View()->MoveCursorL(move = TCursorPosition::EFPageUp, EFalse);
3242 bitMap->View()->GetCursorPos(thisPos);
3243 test(thisPos.iPos == firstLineHome.iPos);
3244 bitMap->View()->MoveCursorL(move = TCursorPosition::EFPageDown, EFalse);
3245 bitMap->View()->MoveCursorL(move = TCursorPosition::EFPageDown, EFalse);
3246 bitMap->View()->GetCursorPos(thisPos);
3247 test(thisPos.iPos == fifthLineEnd.iPos);
3249 CleanupStack::Pop(pic);
3250 CleanupStack::PopAndDestroy(2, extract);
3252 void RunINC112423TestL()
3254 RunINC112423TestVariantsL(_L("alignArabicBot.bmp"), _L("\x630\x630\x630\x630\x630\x630\x630\x630 "),
3255 TFontPresentation::EAlignBottom, TCursorPosition::EFLeft);
3256 RunINC112423TestVariantsL(_L("alignArabicCen.bmp"), _L("\x630\x630\x630\x630\x630\x630\x630\x630 "),
3257 TFontPresentation::EAlignCentered, TCursorPosition::EFLeft);
3258 RunINC112423TestVariantsL(_L("alignArabicTop.bmp"), _L("\x630\x630\x630\x630\x630\x630\x630\x630 "),
3259 TFontPresentation::EAlignTop, TCursorPosition::EFLeft);
3260 RunINC112423TestVariantsL(_L("alignLatinBot.bmp"), _L("aaaaaaaa "),
3261 TFontPresentation::EAlignBottom, TCursorPosition::EFRight);
3262 RunINC112423TestVariantsL(_L("alignLatinCen.bmp"), _L("aaaaaaaa "),
3263 TFontPresentation::EAlignCentered, TCursorPosition::EFRight);
3264 RunINC112423TestVariantsL(_L("alignLatinTop.bmp"), _L("aaaaaaaa "),
3265 TFontPresentation::EAlignTop, TCursorPosition::EFRight);
3269 @SYMTestCaseID SYSLIB-FORM-CT-4005
3270 @SYMTestCaseDesc Given the usecase condition, test to ensure there is no highlighted
3271 character following CTextView::CancelSelectionL();
3272 @SYMTestPriority High
3273 @SYMTestActions Create an empty document and append one character to it. Select this
3274 character in the document and then cancel the selection.
3275 @SYMTestExpectedResults Screen and bitmap should match - the character should not be highlighted.
3278 void RunPDEF114862TestL()
3280 //create editor/bitmap
3281 CTestBitmapFile* bitMap = CTestBitmapFile::NewLC();
3283 //open the zipfile containing the comparison bitmaps
3284 CTestBitmapZipFileExtractor* extract = CTestBitmapZipFileExtractor::NewLC(
3285 _L("Z:\\test\\app-framework\\form\\input\\bitmaps.zip"));
3287 //set up test conditions
3288 bitMap->AppendL(_L("@"));
3289 bitMap->View()->SetSelectionL(TCursorSelection(1,0));
3290 bitMap->View()->CancelSelectionL();
3292 // bitMap->SaveFileL(_L("c:\\MailboxWizard.bmp"));
3293 test(bitMap->CompareL(extract->BitmapFileL(_L("MailboxWizard.bmp"))));
3295 CleanupStack::PopAndDestroy(2, bitMap);
3300 @SYMTestCaseID SYSLIB-FORM-CT-4008
3301 @SYMTestCaseDesc Make sure any highlighting is properly canceled when moving
3302 the cursor without drag.
3303 @SYMTestPriority High
3304 @SYMTestActions Write some text to an empty document, highlight part of the text
3305 and then move the cursor without selecting text.
3306 @SYMTestExpectedResults No text should be highlighted following cursor move.
3309 void RunINC116681TestL()
3311 //open the zipfile containing the comparison bitmaps
3312 CTestBitmapZipFileExtractor* extract = CTestBitmapZipFileExtractor::NewLC(
3313 _L("Z:\\test\\app-framework\\form\\input\\bitmaps.zip"));
3315 //create editor/bitmap
3316 CTestBitmapFile* bitMap = CTestBitmapFile::NewLC();
3318 //setup test conditions
3319 bitMap->AppendL(_L("SomeText")); // enter some text
3320 bitMap->View()->SetSelectionL(TCursorSelection(5,1)); //highlight some of it
3321 TCursorPosition::TMovementType moveRight = TCursorPosition::EFRight;
3322 bitMap->View()->MoveCursorL(moveRight, EFalse); //move cursor with drag off
3323 // bitMap->SaveFileL(_L("c:\\INC116681.bmp"));
3324 test(bitMap->CompareL(extract->BitmapFileL(_L("INC116681.bmp"))));
3326 CleanupStack::PopAndDestroy(2);
3330 @SYMTestCaseID SYSLIB-FORM-UT-4018
3331 @SYMTestCaseDesc Performance test for formatting document with many pictures and test.
3332 @SYMTestPriority Medium
3333 @SYMTestActions Add a lot pictures separated by commas and time the operation.
3334 @SYMTestExpectedResults The formatting should not take longer than the specified timeout.
3337 void RunPDEF123018TestL()
3339 // define a time unit for the performance test timeout
3340 const TInt KOneSecond = 1000000;
3341 //create editor/bitmap
3342 CTestBitmapFile* bitMap = CTestBitmapFile::NewLC(TRect(0, 0, 140, 185));
3344 //create any old picture to insert
3345 CTestPicture* pic = new(ELeave)CTestPicture();
3346 CleanupStack::PushL(pic);
3347 pic->SetSizeInTwips(TSize(400,400));
3349 // Add some text and pictures, and time it.
3350 // Appending a picture will invoke the formatting.
3351 // Many calls should cause a lot of reformatting which will show the performance.
3353 startTime.HomeTime();
3354 for (TInt i = 0; i < 50; i++)
3356 bitMap->AppendL(pic);
3357 bitMap->AppendL(_L(","));
3361 TTimeIntervalMicroSeconds diff = endTime.MicroSecondsFrom(startTime);
3363 // Different performance timeouts for emulator / hardware.
3365 #if defined __WINS__ || defined __WINSCW__
3366 buf.Format( _L("Testing on emulator: Timeout = 3 seconds; finished in %d microseconds"), diff.Int64() );
3367 RDebug::Print( buf );
3368 test(diff < 3*KOneSecond);
3369 #elif defined __ARMCC__
3370 // for naviengine SMP, the timeout should be 150% time needed compare with H4, 25m for H4, 38m for naviengine
3371 buf.Format( _L("Testing on hardware: Timeout = 38 seconds; finished in %d microseconds"), diff.Int64() );
3372 RDebug::Print( buf );
3373 test(diff < 38*KOneSecond);
3377 CleanupStack::Pop(pic);
3378 CleanupStack::PopAndDestroy(1);
3382 @SYMTestCaseID SYSLIB-FORM-CT-4019
3383 @SYMTestCaseDesc When a line in a document is filled with nothing but pictures
3384 and the picture alignment is set to anything other than baseline
3385 then the cursor should be correctly placed on that line.
3386 @SYMTestPriority Medium
3387 @SYMTestActions Fill a line up with pictures so that it wraps, place the cursor
3388 at the beginning of that line and measure the line metrics.
3389 @SYMTestExpectedResults The line metrics should be correct in order to place the cursor
3390 in the expected position.
3393 void RunDEF122198_1TestL() //picture is taller than font height
3395 CTestBitmapFile* bitMap = CTestBitmapFile::NewLC(TRect(0, 0, 160, 80));
3397 //create the picture to insert (this one is a red box)
3398 CTestPicture* pic = new(ELeave)CTestPicture();
3399 CleanupStack::PushL(pic);
3400 pic->SetSizeInTwips(TSize(400,400));
3402 //insert line of pictures
3403 bitMap->AppendL(pic);
3404 bitMap->AppendL(pic);
3405 bitMap->AppendL(pic);
3406 bitMap->AppendL(pic);
3407 bitMap->AppendL(pic);
3408 bitMap->View()->HandleGlobalChangeL();
3410 //change picture alignment
3411 TCursorSelection selection(0, bitMap->DocModel()->DocumentLength());
3412 bitMap->View()->SetSelectionL(selection);
3414 format.iFontPresentation.iPictureAlignment = TFontPresentation::EAlignBottom;
3415 TCharFormatMask mask;
3416 mask.SetAttrib(EAttFontPictureAlignment);
3417 bitMap->DocModel()->ApplyCharFormatL(format, mask, selection.LowerPos(), selection.Length());
3418 bitMap->View()->HandleRangeFormatChangeL(selection,EFalse);
3419 bitMap->View()->CancelSelectionL();
3421 // I could find no way of getting a bitmap screenshot which showed the cursor.
3422 // All attempts - including rewriting bitmapDoc to use Wserv - failed.
3423 // Therefore, the best I can do is test the resulting line information against
3424 // which the position of the cursor is drawn.
3425 TTmPosInfo2 posInfo;
3426 TTmLineInfo currentLineInfo;
3428 bitMap->View()->SetDocPosL(0,EFalse);
3429 bitMap->View()->GetCursorPos(docPos);
3430 bitMap->Layout()->FindDocPos(docPos, posInfo, ¤tLineInfo);
3432 test(posInfo.iEdge.iY==33);
3433 test(currentLineInfo.iBaseline==33);
3435 //change picture alignment and test again
3436 format.iFontPresentation.iPictureAlignment = TFontPresentation::EAlignCentered;
3437 bitMap->View()->SetSelectionL(selection);
3438 bitMap->DocModel()->ApplyCharFormatL(format, mask, selection.LowerPos(), selection.Length());
3439 bitMap->View()->HandleRangeFormatChangeL(selection,EFalse);
3440 bitMap->View()->CancelSelectionL();
3441 bitMap->Layout()->FindDocPos(docPos, posInfo, ¤tLineInfo);
3443 test(posInfo.iEdge.iY==29);
3444 test(currentLineInfo.iBaseline==29);
3446 //change picture alignment and test again
3447 format.iFontPresentation.iPictureAlignment = TFontPresentation::EAlignTop;
3448 bitMap->View()->SetSelectionL(selection);
3449 bitMap->DocModel()->ApplyCharFormatL(format, mask, selection.LowerPos(), selection.Length());
3450 bitMap->View()->HandleRangeFormatChangeL(selection,EFalse);
3451 bitMap->View()->CancelSelectionL();
3452 bitMap->Layout()->FindDocPos(docPos, posInfo, ¤tLineInfo);
3454 test(posInfo.iEdge.iY==25);
3455 test(currentLineInfo.iBaseline==25);
3457 CleanupStack::PopAndDestroy(2);
3460 void RunDEF122198_2TestL() //picture is shorter than font height
3462 CTestBitmapFile* bitMap = CTestBitmapFile::NewLC(TRect(0, 0, 160, 80));
3464 //create the picture to insert (this one is a red box)
3465 CTestPicture* pic = new(ELeave)CTestPicture();
3466 CleanupStack::PushL(pic);
3467 pic->SetSizeInTwips(TSize(400,200));
3469 //insert line of pictures
3470 bitMap->AppendL(pic);
3471 bitMap->AppendL(pic);
3472 bitMap->AppendL(pic);
3473 bitMap->AppendL(pic);
3474 bitMap->AppendL(pic);
3475 bitMap->View()->HandleGlobalChangeL();
3477 //change picture alignment
3478 TCursorSelection selection(0, bitMap->DocModel()->DocumentLength());
3479 bitMap->View()->SetSelectionL(selection);
3481 format.iFontPresentation.iPictureAlignment = TFontPresentation::EAlignBottom;
3482 TCharFormatMask mask;
3483 mask.SetAttrib(EAttFontPictureAlignment);
3484 bitMap->DocModel()->ApplyCharFormatL(format, mask, selection.LowerPos(), selection.Length());
3485 bitMap->View()->HandleRangeFormatChangeL(selection,EFalse);
3486 bitMap->View()->CancelSelectionL();
3488 // I could find no way of getting a bitmap screenshot which showed the cursor.
3489 // All attempts - including rewriting bitmapDoc to use Wserv - failed.
3490 // Therefore, the best I can do is test the resulting line information against
3491 // which the position of the cursor is drawn.
3492 TTmPosInfo2 posInfo;
3493 TTmLineInfo currentLineInfo;
3495 bitMap->View()->SetDocPosL(0,EFalse);
3496 bitMap->View()->GetCursorPos(docPos);
3497 bitMap->Layout()->FindDocPos(docPos, posInfo, ¤tLineInfo);
3498 test(posInfo.iEdge.iY==25);
3499 test(currentLineInfo.iBaseline==25);
3501 CleanupStack::PopAndDestroy(2);
3505 @SYMTestCaseID SYSLIB-FORM-CT-4020
3506 @SYMTestCaseDesc When a zero-width character precedes the current doc position,
3507 pressing backspace should not delete everything back to the
3508 beginning of the document.
3509 @SYMTestPriority Medium
3510 @SYMTestActions Recreate the reported usecase and test for the correct action,
3511 then perform a similar test for every zero-width character.
3512 @SYMTestExpectedResults The selection anchor point should be at the correct position
3516 void RunINC123427TestL()
3518 // *** First test actual defect usecase ***
3519 CTestBitmapFile* bitMap = CTestBitmapFile::NewLC();
3520 bitMap->AppendL(_L("a meeting\x2029"));
3521 bitMap->AppendL(_L("\x200E\x0038:00 am - 8:00 am 18/06/2008\x2029"));
3522 bitMap->AppendL(_L("\x200Ehere\x2029"));
3523 bitMap->AppendL(_L("\x2029"));
3524 bitMap->AppendL(_L("\x200ERepeats daily:\x2029"));
3525 bitMap->AppendL(_L("\x200E\x0046rom 17/06/2008\x2029"));
3526 bitMap->View()->HandleGlobalChangeL();
3528 bitMap->View()->SetDocPosL(48);
3529 TCursorSelection selection = bitMap->View()->GetBackwardDeletePositionL();
3530 test(selection.iAnchorPos==46);
3532 // *** Now reset the doc and test for all zero-width characters ***
3533 bitMap->DocModel()->Reset();
3534 bitMap->AppendL(_L("->")); //something valid to start
3536 TUint stringIndex=0;
3539 // create a continuous line containing every zero width character:
3540 // add C0, C1 controls
3541 for (charVal=0x1; charVal<0x9; charVal++)
3543 string[stringIndex++] = charVal;
3545 string[stringIndex++] = 0xB;
3546 for (charVal=0xD; charVal<0x20; charVal++)
3548 string[stringIndex++] = charVal;
3550 string[stringIndex++] = 0x7F;
3551 string[stringIndex++] = 0x81;
3552 string[stringIndex++] = 0x8F;
3553 string[stringIndex++] = 0x90;
3555 // add layout controls & invisible operators
3556 for (charVal=0x200B; charVal<0x2010; charVal++)
3558 string[stringIndex++] = charVal;
3560 // U+205F is not zero width
3561 for (charVal=0x2060; charVal<0x2065; charVal++)
3563 string[stringIndex++] = charVal;
3565 for (charVal=0x206A; charVal<0x2070; charVal++)
3567 string[stringIndex++] = charVal;
3571 for (charVal=0xFFF9; charVal<0xFFFD; charVal++)
3573 string[stringIndex++] = charVal;
3576 string[stringIndex] = 0; // zero terminate
3579 TTmCharFormat temp2;
3580 bitMap->AppendL(TBuf<70>(string));
3581 bitMap->AppendL(_L("<"));
3582 bitMap->View()->HandleGlobalChangeL();
3584 // cycle through the doc at each zerowidth char and test correct backward
3585 // delete position. This test would have passed without the fix
3587 for (TUint i=startpos; i<stringIndex+startpos; i++)
3589 bitMap->View()->SetDocPosL(i);
3590 selection = bitMap->View()->GetBackwardDeletePositionL();
3591 test(selection.iAnchorPos==1);
3594 // same test again but with no valid characters at the start.
3595 // This test would have passed without the fix
3596 bitMap->DocModel()->Reset();
3597 bitMap->AppendL(TBuf<70>(string));
3598 bitMap->View()->HandleGlobalChangeL();
3599 for (TUint i=0; i<stringIndex; i++)
3601 bitMap->View()->SetDocPosL(i);
3602 selection = bitMap->View()->GetBackwardDeletePositionL();
3603 test(selection.iAnchorPos==0);
3606 // same test again but with a complete line of visible characters before the
3607 // line of invisible ones. This test would *not* have passed without the fix
3608 bitMap->DocModel()->Reset();
3609 bitMap->AppendL(_L("0123456789\x2029"));
3610 bitMap->AppendL(_L("0123456789\x2029"));
3611 bitMap->AppendL(TBuf<70>(string));
3612 bitMap->View()->HandleGlobalChangeL();
3614 for (TUint i=startpos; i<stringIndex+startpos-1; i++)
3616 bitMap->View()->SetDocPosL(i);
3617 selection = bitMap->View()->GetBackwardDeletePositionL();
3618 test(selection.iAnchorPos==21);
3621 CleanupStack::PopAndDestroy();
3627 static CTrapCleanup* TrapCleanup = CTrapCleanup::New();
3628 TInt error = RFbsSession::Connect();
3629 if (error == KErrNotFound)
3632 error = RFbsSession::Connect();
3634 CActiveScheduler* scheduler = new(ELeave) CActiveScheduler;
3635 CActiveScheduler::Install(scheduler);
3636 test(error == KErrNone);
3637 test.Start(_L("CTextView tests"));
3638 TRAP(error, RunTestTextViewL());
3639 test(error == KErrNone);
3640 test.Next(_L(" @SYMTestCaseID:SYSLIB-FORM-CT-4014 RunPDEF118831TestL "));
3641 TRAP(error, RunPDEF118831TestL());
3642 test(error == KErrNone);
3643 test.Next(_L("Directionality tests"));
3644 TRAP(error, RunDirectionalityTestL());
3645 test(error == KErrNone);
3646 test.Next(_L("Inline offsets test"));
3647 TRAP(error, CTestTextView::TestMemberOffsetsL());
3648 test(error == KErrNone);
3649 TRAP(error, CTestTextLayout::TestMemberOffsetsL());
3650 test(error == KErrNone);
3651 test.Next(_L("Test fix for defect INC020329"));
3652 TRAP(error, RunTestINC020329L());
3653 test(error == KErrNone);
3654 test.Next(_L(" @SYMTestCaseID:SYSLIB-FORM-CT-1861 Test fix for defect PDEF085280 "));
3655 TRAP(error, RunTestPDEF085280L());
3656 test(error == KErrNone);
3657 test.Next(_L(" @SYMTestCaseID:SYSLIB-FORM-UT-3162 Test fix for defect PDEF097387 "));
3658 TRAP(error, SetupAndRunPDEF097387TestL());
3659 test(error == KErrNone);
3660 test.Next(_L(" @SYMTestCaseID:SYSLIB-FORM-UT-3241 Test fix for defect PDEF098569 "));
3661 TRAP(error, RunPDEF098569TestL());
3662 test(error == KErrNone);
3663 test.Next(_L(" @SYMTestCaseID:SYSLIB-FORM-UT-3345 Test fix for defect INC099424 "));
3664 TRAP(error, RunINC099424TestL());
3665 test(error == KErrNone);
3666 test.Next(_L(" @SYMTestCaseID:SYSLIB-FORM-CT-3754 Test fix for defect INC109995 & DEF118277 "));
3667 TRAP(error, RunINC109995TestL());
3668 test(error == KErrNone);
3669 test.Next(_L(" @SYMTestCaseID:SYSLIB-FORM-CT-4003 Test fix for defect PDEF112004 "));
3670 TRAP(error, RunPDEF112004TestL());
3671 test(error == KErrNone);
3672 test.Next(_L(" @SYMTestCaseID:SYSLIB-FORM-CT-4001 Test fix for defect INC112423 "));
3673 TRAP(error, RunINC112423TestL());
3674 test(error == KErrNone);
3675 test.Next(_L(" @SYMTestCaseID:SYSLIB-FORM-CT-4005 Test fix for defect PDEF114862 "));
3676 TRAP(error, RunPDEF114862TestL());
3677 test(error == KErrNone);
3678 test.Next(_L(" @SYMTestCaseID:SYSLIB-FORM-CT-4008 Test fix for defect INC116681 "));
3679 TRAP(error, RunINC116681TestL());
3680 test(error == KErrNone);
3681 test.Next(_L(" @SYMTestCaseID:SYSLIB-FORM-CT-4019 Test fix for defect DEF122198 "));
3682 TRAP(error, RunDEF122198_1TestL());
3683 test(error == KErrNone);
3684 TRAP(error, RunDEF122198_2TestL());
3685 test(error == KErrNone);
3686 test.Next(_L(" @SYMTestCaseID:SYSLIB-FORM-CT-4020 Test fix for defect INC123427 "));
3687 TRAP(error, RunINC123427TestL());
3688 test(error == KErrNone);
3689 test.Next(_L(" @SYMTestCaseID:SYSLIB-FORM-UT-4018 Test fix for defect PDEF123018"));
3690 TRAP(error, RunPDEF123018TestL());
3691 test(error == KErrNone);
3693 RFbsSession::Disconnect();