sl@0: /* sl@0: * Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * TTextView.cpp test file for UndoSystem classes sl@0: * sl@0: */ sl@0: sl@0: sl@0: #include sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: #include "form_and_etext_editor.h" sl@0: #include "UndoSystem.h" sl@0: #include "EditorUndo.h" sl@0: #include "FRMPAGE.H" sl@0: sl@0: _LIT(KHello, "hello world"); sl@0: const TInt KPaginatePriority = -100; sl@0: const TInt KGranularity = 10; sl@0: sl@0: using namespace UndoSystem; sl@0: sl@0: LOCAL_C TInt GetNumber(TInt aMin, TInt aMax) sl@0: { sl@0: __ASSERT_ALWAYS(aMin <= aMax, User::Invariant()); sl@0: sl@0: TInt64 seed = Math::Random(); sl@0: TReal randomReal = Math::FRand(seed); sl@0: sl@0: TReal maxReal = randomReal * ((aMax-aMin)+1); sl@0: TReal rounded = 0; sl@0: User::LeaveIfError(Math::Round(rounded, maxReal, 0)); sl@0: sl@0: TInt result = rounded + aMin; sl@0: sl@0: if(result> aMax) sl@0: { sl@0: return aMax; sl@0: } sl@0: return result; sl@0: } sl@0: sl@0: void ManipulateText(CTextView* aView, CRichText* aText) sl@0: { sl@0: _LIT(KStartText, "The quick brown fox jumped over the lazy dog."); sl@0: aText->InsertL(0, KStartText); sl@0: aView->HandleInsertDeleteL(TCursorSelection(0, KStartText().Length()), 0); sl@0: aText->InsertL(19, TChar(CEditableText::EParagraphDelimiter)); sl@0: aView->HandleCharEditL(); sl@0: TCharFormat format; sl@0: TCharFormatMask mask; sl@0: format.iFontSpec.iFontStyle.SetStrokeWeight(EStrokeWeightBold); sl@0: mask.ClearAll(); sl@0: mask.SetAttrib(EAttFontStrokeWeight); sl@0: aText->ApplyCharFormatL(format, mask, 41, 3); sl@0: aView->HandleRangeFormatChangeL(TCursorSelection(41, 44)); sl@0: aView->SetDocPosL(42); sl@0: TInt length = aText->DocumentLength(); sl@0: aText->DeleteL(0, length); sl@0: aView->HandleInsertDeleteL(TCursorSelection(0, 0), length); sl@0: } sl@0: sl@0: void ManipulateText1(CTextView* aView, CRichText* aText) sl@0: { sl@0: TInt testaYPos = 0; sl@0: _LIT(KText, "The weather is quite good today, but it's a bit too cold"); sl@0: aText->InsertL(0, KText); sl@0: aView->HandleInsertDeleteL(TCursorSelection(0, KText().Length()), 0); sl@0: aView->SetDocPosL(10); //56 is the position of the last character d sl@0: aView->SetViewLineAtTopL(1); sl@0: aView->SetViewL(50, testaYPos); sl@0: aView->HandleAdditionalCharactersAtEndL(); sl@0: } sl@0: sl@0: inline TBool IsSurrogate(TText16 aInt16) sl@0: /** sl@0: @return True, if aText16 is high surrogate or low surrogate; false, otherwise. sl@0: */ sl@0: { sl@0: return (aInt16 & 0xF800) == 0xD800; sl@0: } sl@0: sl@0: class CMyTestPicture : public CPicture sl@0: { sl@0: public: sl@0: static CMyTestPicture* NewL(TSize aSize); sl@0: void Draw(CGraphicsContext&,const TPoint&,const TRect&,MGraphicsDeviceMap*) const {} sl@0: void ExternalizeL(RWriteStream& /*aStream*/) const {} sl@0: void GetOriginalSizeInTwips(TSize& aSize) const {aSize=iSizeOfPicture;} sl@0: private: sl@0: CMyTestPicture(TSize aSize); sl@0: private: sl@0: TSize iSizeOfPicture; sl@0: }; sl@0: sl@0: CMyTestPicture* CMyTestPicture::NewL(TSize aSize) sl@0: { sl@0: return new(ELeave) CMyTestPicture(aSize); sl@0: } sl@0: sl@0: sl@0: CMyTestPicture::CMyTestPicture(TSize aSize):iSizeOfPicture(aSize) sl@0: {} sl@0: sl@0: sl@0: class CTextViewTest : public CBase sl@0: { sl@0: public: sl@0: CTextViewTest(CCoeEnv& aEnv) sl@0: : iEnv(aEnv), iWindowRect(10, 10, 110, 110), iWindow(aEnv.WsSession()), sl@0: test(_L("TTextView - Some tests for CTextView")) {} sl@0: void ConstructL(); sl@0: void InitializeL(); sl@0: void AddTextL(const TDesC&); sl@0: void Destroy(); sl@0: ~CTextViewTest(); sl@0: void TestL(); sl@0: void Test1L(); sl@0: void TestCancelSelectionL(); sl@0: void TestHandleAdditionalCharactersAtEndL(); sl@0: void TestFinishBackgroundFormattingL(); sl@0: void TestSetCursorVisibilityL(); sl@0: void TestSetSelectionVisibilityL(); sl@0: void TestEnablePictureFrameL(); sl@0: void TestSetCursorWidthTypeL(); sl@0: void TestParagraphRectL(); sl@0: void TestSetDocPosL(); sl@0: void TestSetViewLineAtTopL(); sl@0: void TestDrawL(); sl@0: void TestFormatTextL(); sl@0: void TestHandleCharEditL(); sl@0: void TestHandleRangeFormatChangeL(); sl@0: void TestHandleInsertDeleteL(); sl@0: void TestHandleGlobalChangeL(); sl@0: void TestHandleGlobalChangeNoRedrawL(); sl@0: void TestScrollDisplayL(); sl@0: void TestScrollDisplayPixelsL(); sl@0: void TestScrollDisplayPixelsNoLimitBordersL(TInt aOffset); sl@0: void TestForDEF142286BounceScrollingL(); sl@0: void TestScrollDisplayLinesL(); sl@0: void TestScrollDisplayParagraphsL(); sl@0: void TestSetViewL(); sl@0: void TestMoveCursorL(); sl@0: void TestSetSelectionL(); sl@0: void TestMatchCursorHeightL(); sl@0: void TestCalculateHorizontalExtremesL(); sl@0: void TestXyPosToDocPosL(); sl@0: // void TestDrawL1(); sl@0: void TestGetPictureRectangleL(); sl@0: void TestGetPictureRectangle1L(); sl@0: void TestSetDisplayContextL(); sl@0: void TestGetPictureRectangleDefectL(); sl@0: void TestGetLineRectL(); // Test for defect WEP-567K9C Form panics when picture sl@0: // inserted in CRichText and alignmnent is set to bottom sl@0: void TestForDEF003426L(); sl@0: void TestForDEF038488L(); sl@0: void InitializeDiffCharFormatL(); sl@0: void TestGetParaFormatL(); sl@0: // Function to test the Class TFormAndEtextEditor sl@0: void FormAndEtextTestL(); sl@0: void TestForINC092725L(); sl@0: void TestForPDEF108443L(); sl@0: void TestForPDEF113755L(); sl@0: void TestForPDEF115165L(); sl@0: void TestForPDEF118443L(); sl@0: void TestForPDEF121798L(); sl@0: void TestForPDEF120239L(); sl@0: void TestForDEF124989L(); sl@0: void TestForDEF124975L(); sl@0: sl@0: struct STestDataTInt4 sl@0: { sl@0: TInt iDoc1; sl@0: TInt iDoc2; sl@0: TInt iPos1; sl@0: TInt iPos2; sl@0: }; sl@0: sl@0: private: sl@0: CCoeEnv& iEnv; sl@0: TRect iWindowRect; sl@0: CParaFormatLayer* iParaLayer; sl@0: CCharFormatLayer* iCharLayer; sl@0: CRichText* iEtext; sl@0: CTextLayout* iLayout; sl@0: RWindow iWindow; sl@0: CTextView* iView; sl@0: RTest test; sl@0: TCursorSelection select; sl@0: TInt testDeltaY; sl@0: TInt testDeltaLines; sl@0: TInt testDeltaParas; sl@0: TInt testaYPos; sl@0: TCursorPosition::TMovementType testaMovement; sl@0: TFontSpec testaFontSpec; sl@0: TInt testaLeft; sl@0: TInt testaRight; sl@0: TPoint testaPoint; sl@0: TBool testaCanScaleOrCrop; sl@0: CBitmapContext* testaGc; sl@0: TPoint testaXyPos; sl@0: CBitmapDevice* testaGd; sl@0: RWindowGroup testaGroupWin; sl@0: RWsSession testaSession; sl@0: }; sl@0: sl@0: void CTextViewTest::ConstructL() sl@0: { sl@0: iWindow.Construct(iEnv.RootWin(), 12345); sl@0: iParaLayer = CParaFormatLayer::NewL(); sl@0: iCharLayer = CCharFormatLayer::NewL(); sl@0: test.Title(); sl@0: test.Start(_L("CTextView Tests:")); sl@0: } sl@0: sl@0: void CTextViewTest::InitializeL() sl@0: { sl@0: Destroy(); sl@0: iEtext = CRichText::NewL(iParaLayer, iCharLayer); sl@0: iLayout = CTextLayout::NewL(iEtext, iWindowRect.Width()); sl@0: iView = CTextView::NewL(iLayout, iWindowRect, iEnv.ScreenDevice(), sl@0: iEnv.SystemGc().Device(), &iWindow, &iEnv.RootWin(), &iEnv.WsSession()); sl@0: testaGd=(CBitmapDevice*) iEnv.SystemGc().Device(); sl@0: } sl@0: sl@0: void CTextViewTest::AddTextL(const TDesC& aText) sl@0: { sl@0: iEtext->InsertL(0, aText); sl@0: TCursorSelection s(0, aText.Length()); sl@0: iView->HandleInsertDeleteL(s, 0); sl@0: } sl@0: sl@0: void CTextViewTest::InitializeDiffCharFormatL() sl@0: { sl@0: Destroy(); sl@0: delete iCharLayer; sl@0: iCharLayer=0; sl@0: TCharFormat charFormat; sl@0: TCharFormatMask charFormatMask; sl@0: charFormat.iFontPresentation.iPictureAlignment=TFontPresentation::EAlignBottom; sl@0: charFormatMask.SetAttrib(EAttFontPictureAlignment); sl@0: iCharLayer = CCharFormatLayer::NewL(charFormat,charFormatMask); sl@0: iEtext = CRichText::NewL(iParaLayer, iCharLayer); sl@0: iLayout = CTextLayout::NewL(iEtext, iWindowRect.Width()); sl@0: iView = CTextView::NewL(iLayout, iWindowRect, iEnv.ScreenDevice(), sl@0: iEnv.SystemGc().Device(), &iWindow, &iEnv.RootWin(), &iEnv.WsSession()); sl@0: testaGd=(CBitmapDevice*) iEnv.SystemGc().Device(); sl@0: } sl@0: sl@0: void CTextViewTest::Destroy() sl@0: { sl@0: delete iView; sl@0: iView = 0; sl@0: delete iLayout; sl@0: iLayout = 0; sl@0: delete iEtext; sl@0: iEtext = 0; sl@0: } sl@0: sl@0: sl@0: void CTextViewTest::TestL() sl@0: { sl@0: // Test for fix to ASR-4UYHZX: ETEXT panic 12 (ECharPosBeyondDocument) when sl@0: // out of memory sl@0: InitializeL(); sl@0: ManipulateText(iView, iEtext); sl@0: Destroy(); sl@0: TInt consecutiveSuccesses = 0; sl@0: for (TInt i = 1; consecutiveSuccesses != 100; ++i) sl@0: { sl@0: __UHEAP_MARK; sl@0: InitializeL(); sl@0: __UHEAP_SETFAIL(RHeap::EDeterministic, i); sl@0: TRAPD(err, ManipulateText(iView, iEtext)); sl@0: Destroy(); sl@0: __UHEAP_SETFAIL(RHeap::ENone, 0); sl@0: __UHEAP_MARKENDC(0); sl@0: if (err == KErrNone) sl@0: ++consecutiveSuccesses; sl@0: else sl@0: consecutiveSuccesses = 0; sl@0: } sl@0: } sl@0: sl@0: sl@0: void CTextViewTest::Test1L() sl@0: { sl@0: // testing functions SetViewL, SetViewLineAtTopL, sl@0: // SetDocPosL & HandleAdditionalCharactersAtEndL sl@0: // - should work but need some kind sl@0: // of pre-settings and initialization before they can all be proved sl@0: // that there is no memory leak sl@0: InitializeL(); sl@0: ManipulateText1(iView, iEtext); //where all pre-settings have been done sl@0: Destroy(); sl@0: TInt consecutiveSuccesses = 0; sl@0: for (TInt i = 1; consecutiveSuccesses != 100; ++i) sl@0: { sl@0: __UHEAP_MARK; sl@0: InitializeL(); sl@0: __UHEAP_SETFAIL(RHeap::EDeterministic, i); sl@0: TRAPD(err, ManipulateText1(iView, iEtext)); sl@0: Destroy(); sl@0: __UHEAP_SETFAIL(RHeap::ENone, 0); sl@0: __UHEAP_MARKENDC(0); sl@0: if (err == KErrNone) sl@0: ++consecutiveSuccesses; sl@0: else sl@0: consecutiveSuccesses = 0; sl@0: } sl@0: } sl@0: sl@0: sl@0: void CTextViewTest::TestCancelSelectionL() sl@0: { sl@0: InitializeL(); sl@0: iView->CancelSelectionL(); sl@0: Destroy(); sl@0: TInt consecutiveSuccesses = 0; sl@0: for (TInt i = 1; consecutiveSuccesses != 100; ++i) sl@0: { sl@0: __UHEAP_MARK; sl@0: InitializeL(); sl@0: __UHEAP_SETFAIL(RHeap::EDeterministic, i); sl@0: TRAPD(err, iView->CancelSelectionL()); sl@0: Destroy(); sl@0: __UHEAP_SETFAIL(RHeap::ENone, 0); sl@0: __UHEAP_MARKENDC(0); sl@0: if (err == KErrNone) sl@0: ++consecutiveSuccesses; sl@0: else sl@0: consecutiveSuccesses = 0; sl@0: } sl@0: } sl@0: sl@0: sl@0: void CTextViewTest::TestFinishBackgroundFormattingL() sl@0: { sl@0: InitializeL(); sl@0: iView->FinishBackgroundFormattingL(); sl@0: Destroy(); sl@0: TInt consecutiveSuccesses = 0; sl@0: for (TInt i = 1; consecutiveSuccesses != 100; ++i) sl@0: { sl@0: __UHEAP_MARK; sl@0: InitializeL(); sl@0: __UHEAP_SETFAIL(RHeap::EDeterministic, i); sl@0: TRAPD(err, iView->FinishBackgroundFormattingL()); sl@0: Destroy(); sl@0: __UHEAP_SETFAIL(RHeap::ENone, 0); sl@0: __UHEAP_MARKENDC(0); sl@0: if (err == KErrNone) sl@0: ++consecutiveSuccesses; sl@0: else sl@0: consecutiveSuccesses = 0; sl@0: } sl@0: } sl@0: sl@0: sl@0: void CTextViewTest::TestFormatTextL() sl@0: { sl@0: InitializeL(); sl@0: iView->FormatTextL(); sl@0: Destroy(); sl@0: TInt consecutiveSuccesses = 0; sl@0: for (TInt i = 1; consecutiveSuccesses != 100; ++i) sl@0: { sl@0: __UHEAP_MARK; sl@0: InitializeL(); sl@0: __UHEAP_SETFAIL(RHeap::EDeterministic, i); sl@0: TRAPD(err, iView->FormatTextL()); sl@0: Destroy(); sl@0: __UHEAP_SETFAIL(RHeap::ENone, 0); sl@0: __UHEAP_MARKENDC(0); sl@0: if (err == KErrNone) sl@0: ++consecutiveSuccesses; sl@0: else sl@0: consecutiveSuccesses = 0; sl@0: } sl@0: } sl@0: sl@0: sl@0: void CTextViewTest::TestSetCursorVisibilityL() sl@0: { sl@0: InitializeL(); sl@0: iView->SetCursorVisibilityL(1,1); sl@0: Destroy(); sl@0: TInt consecutiveSuccesses = 0; sl@0: for (TInt i = 1; consecutiveSuccesses != 100; ++i) sl@0: { sl@0: __UHEAP_MARK; sl@0: InitializeL(); sl@0: __UHEAP_SETFAIL(RHeap::EDeterministic, i); sl@0: TRAPD(err, iView->SetCursorVisibilityL(1,1)); //TInt aLineCursor, TInt aTextCursor sl@0: Destroy(); sl@0: __UHEAP_SETFAIL(RHeap::ENone, 0); sl@0: __UHEAP_MARKENDC(0); sl@0: if (err == KErrNone) sl@0: ++consecutiveSuccesses; sl@0: else sl@0: consecutiveSuccesses = 0; sl@0: } sl@0: } sl@0: sl@0: sl@0: void CTextViewTest::TestSetSelectionVisibilityL() sl@0: { sl@0: InitializeL(); sl@0: iView->SetSelectionVisibilityL(1); sl@0: Destroy(); sl@0: TInt consecutiveSuccesses = 0; sl@0: for (TInt i = 1; consecutiveSuccesses != 100; ++i) sl@0: { sl@0: __UHEAP_MARK; sl@0: InitializeL(); sl@0: __UHEAP_SETFAIL(RHeap::EDeterministic, i); sl@0: TRAPD(err, iView->SetSelectionVisibilityL(1)); //TBool aSelectionVisible sl@0: Destroy(); sl@0: __UHEAP_SETFAIL(RHeap::ENone, 0); sl@0: __UHEAP_MARKENDC(0); sl@0: if (err == KErrNone) sl@0: ++consecutiveSuccesses; sl@0: else sl@0: consecutiveSuccesses = 0; sl@0: } sl@0: } sl@0: sl@0: sl@0: void CTextViewTest::TestEnablePictureFrameL() sl@0: { sl@0: InitializeL(); sl@0: iView->EnablePictureFrameL(1); sl@0: Destroy(); sl@0: TInt consecutiveSuccesses = 0; sl@0: for (TInt i = 1; consecutiveSuccesses != 100; ++i) sl@0: { sl@0: __UHEAP_MARK; sl@0: InitializeL(); sl@0: __UHEAP_SETFAIL(RHeap::EDeterministic, i); sl@0: TRAPD(err, iView->EnablePictureFrameL(1)); //TBool aEnabled sl@0: Destroy(); sl@0: __UHEAP_SETFAIL(RHeap::ENone, 0); sl@0: __UHEAP_MARKENDC(0); sl@0: if (err == KErrNone) sl@0: ++consecutiveSuccesses; sl@0: else sl@0: consecutiveSuccesses = 0; sl@0: } sl@0: } sl@0: sl@0: sl@0: void CTextViewTest::TestSetCursorWidthTypeL() sl@0: { sl@0: InitializeL(); sl@0: iView->SetCursorWidthTypeL(TTextCursor::ETypeRectangle,0); sl@0: Destroy(); sl@0: TInt consecutiveSuccesses = 0; sl@0: for (TInt i = 1; consecutiveSuccesses != 100; ++i) sl@0: { sl@0: __UHEAP_MARK; sl@0: InitializeL(); sl@0: __UHEAP_SETFAIL(RHeap::EDeterministic, i); sl@0: TRAPD(err, iView->SetCursorWidthTypeL(TTextCursor::ETypeRectangle,0)); //TTextCursor::EType aType, TInt aWidth=0 sl@0: Destroy(); sl@0: __UHEAP_SETFAIL(RHeap::ENone, 0); sl@0: __UHEAP_MARKENDC(0); sl@0: if (err == KErrNone) sl@0: ++consecutiveSuccesses; sl@0: else sl@0: consecutiveSuccesses = 0; sl@0: } sl@0: } sl@0: sl@0: sl@0: void CTextViewTest::TestParagraphRectL() sl@0: { sl@0: InitializeL(); sl@0: iView->ParagraphRectL(1); sl@0: Destroy(); sl@0: TInt consecutiveSuccesses = 0; sl@0: for (TInt i = 1; consecutiveSuccesses != 100; ++i) sl@0: { sl@0: __UHEAP_MARK; sl@0: InitializeL(); sl@0: __UHEAP_SETFAIL(RHeap::EDeterministic, i); sl@0: TRAPD(err, iView->ParagraphRectL(1)); //TInt aDocPos sl@0: Destroy(); sl@0: __UHEAP_SETFAIL(RHeap::ENone, 0); sl@0: __UHEAP_MARKENDC(0); sl@0: if (err == KErrNone) sl@0: ++consecutiveSuccesses; sl@0: else sl@0: consecutiveSuccesses = 0; sl@0: } sl@0: } sl@0: sl@0: sl@0: void CTextViewTest::TestDrawL() sl@0: { sl@0: InitializeL(); sl@0: iView->DrawL(iWindowRect); sl@0: Destroy(); sl@0: TInt consecutiveSuccesses = 0; sl@0: for (TInt i = 1; consecutiveSuccesses != 100; ++i) sl@0: { sl@0: __UHEAP_MARK; sl@0: InitializeL(); sl@0: __UHEAP_SETFAIL(RHeap::EDeterministic, i); sl@0: TRAPD(err, iView->DrawL(iWindowRect)); //TRect aRect sl@0: Destroy(); sl@0: __UHEAP_SETFAIL(RHeap::ENone, 0); sl@0: __UHEAP_MARKENDC(0); sl@0: if (err == KErrNone) sl@0: ++consecutiveSuccesses; sl@0: else sl@0: consecutiveSuccesses = 0; sl@0: } sl@0: } sl@0: sl@0: sl@0: void CTextViewTest::TestHandleRangeFormatChangeL() sl@0: { sl@0: InitializeL(); sl@0: iView->HandleRangeFormatChangeL(select, EFalse); sl@0: Destroy(); sl@0: TInt consecutiveSuccesses = 0; sl@0: for (TInt i = 1; consecutiveSuccesses != 100; ++i) sl@0: { sl@0: __UHEAP_MARK; sl@0: InitializeL(); sl@0: __UHEAP_SETFAIL(RHeap::EDeterministic, i); sl@0: TRAPD(err, iView->HandleRangeFormatChangeL(select, EFalse)); sl@0: Destroy(); sl@0: __UHEAP_SETFAIL(RHeap::ENone, 0); sl@0: __UHEAP_MARKENDC(0); sl@0: if (err == KErrNone) sl@0: ++consecutiveSuccesses; sl@0: else sl@0: consecutiveSuccesses = 0; sl@0: } sl@0: } sl@0: sl@0: sl@0: void CTextViewTest::TestHandleInsertDeleteL() sl@0: { sl@0: InitializeL(); sl@0: iView->HandleInsertDeleteL(select, 1, EFalse); sl@0: Destroy(); sl@0: TInt consecutiveSuccesses = 0; sl@0: for (TInt i = 1; consecutiveSuccesses != 100; ++i) sl@0: { sl@0: __UHEAP_MARK; sl@0: InitializeL(); sl@0: __UHEAP_SETFAIL(RHeap::EDeterministic, i); sl@0: TRAPD(err, iView->HandleInsertDeleteL(select, 1, EFalse)); sl@0: Destroy(); sl@0: __UHEAP_SETFAIL(RHeap::ENone, 0); sl@0: __UHEAP_MARKENDC(0); sl@0: if (err == KErrNone) sl@0: ++consecutiveSuccesses; sl@0: else sl@0: consecutiveSuccesses = 0; sl@0: } sl@0: } sl@0: sl@0: sl@0: void CTextViewTest::TestHandleGlobalChangeL() sl@0: { sl@0: InitializeL(); sl@0: iView->HandleGlobalChangeL(TViewYPosQualifier()); sl@0: Destroy(); sl@0: TInt consecutiveSuccesses = 0; sl@0: for (TInt i = 1; consecutiveSuccesses != 100; ++i) sl@0: { sl@0: __UHEAP_MARK; sl@0: InitializeL(); sl@0: __UHEAP_SETFAIL(RHeap::EDeterministic, i); sl@0: TRAPD(err, iView->HandleGlobalChangeL(TViewYPosQualifier())); sl@0: Destroy(); sl@0: __UHEAP_SETFAIL(RHeap::ENone, 0); sl@0: __UHEAP_MARKENDC(0); sl@0: if (err == KErrNone) sl@0: ++consecutiveSuccesses; sl@0: else sl@0: consecutiveSuccesses = 0; sl@0: } sl@0: } sl@0: sl@0: sl@0: void CTextViewTest::TestHandleGlobalChangeNoRedrawL() sl@0: { sl@0: InitializeL(); sl@0: iView->HandleGlobalChangeNoRedrawL(TViewYPosQualifier()); sl@0: Destroy(); sl@0: TInt consecutiveSuccesses = 0; sl@0: for (TInt i = 1; consecutiveSuccesses != 100; ++i) sl@0: { sl@0: __UHEAP_MARK; sl@0: InitializeL(); sl@0: __UHEAP_SETFAIL(RHeap::EDeterministic, i); sl@0: TRAPD(err, iView->HandleGlobalChangeNoRedrawL(TViewYPosQualifier())); sl@0: Destroy(); sl@0: __UHEAP_SETFAIL(RHeap::ENone, 0); sl@0: __UHEAP_MARKENDC(0); sl@0: if (err == KErrNone) sl@0: ++consecutiveSuccesses; sl@0: else sl@0: consecutiveSuccesses = 0; sl@0: } sl@0: } sl@0: sl@0: sl@0: void CTextViewTest::TestScrollDisplayL() sl@0: { sl@0: InitializeL(); sl@0: iView->ScrollDisplayL(TCursorPosition::EFLeft); sl@0: Destroy(); sl@0: TInt consecutiveSuccesses = 0; sl@0: for (TInt i = 1; consecutiveSuccesses != 100; ++i) sl@0: { sl@0: __UHEAP_MARK; sl@0: InitializeL(); sl@0: __UHEAP_SETFAIL(RHeap::EDeterministic, i); sl@0: TRAPD(err, iView->ScrollDisplayL(TCursorPosition::EFLeft)); sl@0: Destroy(); sl@0: __UHEAP_SETFAIL(RHeap::ENone, 0); sl@0: __UHEAP_MARKENDC(0); sl@0: if (err == KErrNone) sl@0: ++consecutiveSuccesses; sl@0: else sl@0: consecutiveSuccesses = 0; sl@0: } sl@0: } sl@0: sl@0: sl@0: void CTextViewTest::TestScrollDisplayPixelsL() sl@0: { sl@0: InitializeL(); sl@0: iView->ScrollDisplayPixelsL(testDeltaY); sl@0: Destroy(); sl@0: TInt consecutiveSuccesses = 0; sl@0: for (TInt i = 1; consecutiveSuccesses != 100; ++i) sl@0: { sl@0: __UHEAP_MARK; sl@0: InitializeL(); sl@0: __UHEAP_SETFAIL(RHeap::EDeterministic, i); sl@0: TRAPD(err, iView->ScrollDisplayPixelsL(testDeltaY)); sl@0: Destroy(); sl@0: __UHEAP_SETFAIL(RHeap::ENone, 0); sl@0: __UHEAP_MARKENDC(0); sl@0: if (err == KErrNone) sl@0: ++consecutiveSuccesses; sl@0: else sl@0: consecutiveSuccesses = 0; sl@0: } sl@0: } sl@0: sl@0: sl@0: void CTextViewTest::TestScrollDisplayPixelsNoLimitBordersL(TInt aOffset) sl@0: { sl@0: /* sl@0: * This test case is for new added function ScrollDisplayPixelsNoLimitBorderL() which support sl@0: * no limit scrolling, using this function text view can be scrolled beyond the top and bottom sl@0: * border. sl@0: * Text view will be firstly scrolled to border using ScrollDisplayPixelsL() which can't scroll sl@0: * text view beyond the top or bottom border. sl@0: * Then text view will be scrolled using ScrollDisplayPixelsNoLimitBorderL() to same direction. sl@0: * Code will test this step that if text view is really scrolled beyond the border by checking sl@0: * the iBandTop position before and after the scrolling operation.*/ sl@0: sl@0: InitializeL(); sl@0: _LIT(KTestParagraph, "This is a piece of text which is used to test the bounce scrolling feature made by s60."); sl@0: for (TInt i=0;i<=20;i++) sl@0: AddTextL(KTestParagraph); sl@0: sl@0: TInt firstBandTop, secondBandTop; sl@0: TInt offset = aOffset; sl@0: while( offset!=0 ) sl@0: { sl@0: iView->ScrollDisplayPixelsL(offset); sl@0: } sl@0: offset = aOffset; sl@0: firstBandTop = iLayout->PixelsAboveBand(); sl@0: iView->ScrollDisplayPixelsNoLimitBorderL(offset); sl@0: secondBandTop = iLayout->PixelsAboveBand(); sl@0: test(firstBandTop - secondBandTop == offset); sl@0: sl@0: offset = 0 - aOffset; sl@0: while( offset!=0 ) sl@0: { sl@0: iView->ScrollDisplayPixelsL(offset); sl@0: } sl@0: offset = 0 - aOffset; sl@0: firstBandTop = iLayout->PixelsAboveBand(); sl@0: iView->ScrollDisplayPixelsNoLimitBorderL(offset); sl@0: secondBandTop = iLayout->PixelsAboveBand(); sl@0: test(firstBandTop - secondBandTop == offset); sl@0: sl@0: Destroy(); sl@0: } sl@0: sl@0: sl@0: void CTextViewTest::TestScrollDisplayLinesL() sl@0: { sl@0: InitializeL(); sl@0: iView->ScrollDisplayLinesL(testDeltaLines); sl@0: Destroy(); sl@0: TInt consecutiveSuccesses = 0; sl@0: for (TInt i = 1; consecutiveSuccesses != 100; ++i) sl@0: { sl@0: __UHEAP_MARK; sl@0: InitializeL(); sl@0: __UHEAP_SETFAIL(RHeap::EDeterministic, i); sl@0: TRAPD(err, iView->ScrollDisplayLinesL(testDeltaLines)); sl@0: Destroy(); sl@0: __UHEAP_SETFAIL(RHeap::ENone, 0); sl@0: __UHEAP_MARKENDC(0); sl@0: if (err == KErrNone) sl@0: ++consecutiveSuccesses; sl@0: else sl@0: consecutiveSuccesses = 0; sl@0: } sl@0: } sl@0: sl@0: sl@0: void CTextViewTest::TestScrollDisplayParagraphsL() sl@0: { sl@0: InitializeL(); sl@0: AddTextL(KHello); sl@0: iView->ScrollDisplayParagraphsL(testDeltaParas); sl@0: Destroy(); sl@0: TInt consecutiveSuccesses = 0; sl@0: for (TInt i = 1; consecutiveSuccesses != 100; ++i) sl@0: { sl@0: __UHEAP_MARK; sl@0: InitializeL(); sl@0: AddTextL(KHello); sl@0: __UHEAP_SETFAIL(RHeap::EDeterministic, i); sl@0: TRAPD(err, iView->ScrollDisplayParagraphsL(testDeltaParas)); sl@0: Destroy(); sl@0: __UHEAP_SETFAIL(RHeap::ENone, 0); sl@0: __UHEAP_MARKENDC(0); sl@0: if (err == KErrNone) sl@0: ++consecutiveSuccesses; sl@0: else sl@0: consecutiveSuccesses = 0; sl@0: } sl@0: } sl@0: sl@0: sl@0: void CTextViewTest::TestSetViewL() sl@0: { sl@0: InitializeL(); sl@0: iView->SetViewL(1, testaYPos); sl@0: Destroy(); sl@0: TInt consecutiveSuccesses = 0; sl@0: for (TInt i = 1; consecutiveSuccesses != 100; ++i) sl@0: { sl@0: __UHEAP_MARK; sl@0: InitializeL(); sl@0: __UHEAP_SETFAIL(RHeap::EDeterministic, i); sl@0: TRAPD(err, iView->SetViewL(1, testaYPos)); sl@0: Destroy(); sl@0: __UHEAP_SETFAIL(RHeap::ENone, 0); sl@0: __UHEAP_MARKENDC(0); sl@0: if (err == KErrNone) sl@0: ++consecutiveSuccesses; sl@0: else sl@0: consecutiveSuccesses = 0; sl@0: } sl@0: } sl@0: sl@0: sl@0: void CTextViewTest::TestMoveCursorL() sl@0: { sl@0: InitializeL(); sl@0: AddTextL(KHello); sl@0: iView->MoveCursorL(testaMovement, EFalse); sl@0: Destroy(); sl@0: TInt consecutiveSuccesses = 0; sl@0: for (TInt i = 1; consecutiveSuccesses != 100; ++i) sl@0: { sl@0: __UHEAP_MARK; sl@0: InitializeL(); sl@0: AddTextL(KHello); sl@0: __UHEAP_SETFAIL(RHeap::EDeterministic, i); sl@0: TRAPD(err, iView->MoveCursorL(testaMovement, EFalse)); sl@0: Destroy(); sl@0: __UHEAP_SETFAIL(RHeap::ENone, 0); sl@0: __UHEAP_MARKENDC(0); sl@0: if (err == KErrNone) sl@0: ++consecutiveSuccesses; sl@0: else sl@0: consecutiveSuccesses = 0; sl@0: } sl@0: } sl@0: sl@0: sl@0: void CTextViewTest::TestSetSelectionL() sl@0: { sl@0: InitializeL(); sl@0: iView->SetSelectionL(select); sl@0: Destroy(); sl@0: TInt consecutiveSuccesses = 0; sl@0: for (TInt i = 1; consecutiveSuccesses != 100; ++i) sl@0: { sl@0: __UHEAP_MARK; sl@0: InitializeL(); sl@0: __UHEAP_SETFAIL(RHeap::EDeterministic, i); sl@0: TRAPD(err, iView->SetSelectionL(select)); sl@0: Destroy(); sl@0: __UHEAP_SETFAIL(RHeap::ENone, 0); sl@0: __UHEAP_MARKENDC(0); sl@0: if (err == KErrNone) sl@0: ++consecutiveSuccesses; sl@0: else sl@0: consecutiveSuccesses = 0; sl@0: } sl@0: } sl@0: sl@0: sl@0: void CTextViewTest::TestMatchCursorHeightL() sl@0: { sl@0: InitializeL(); sl@0: iView->MatchCursorHeightL(testaFontSpec); sl@0: Destroy(); sl@0: TInt consecutiveSuccesses = 0; sl@0: for (TInt i = 1; consecutiveSuccesses != 100; ++i) sl@0: { sl@0: __UHEAP_MARK; sl@0: InitializeL(); sl@0: __UHEAP_SETFAIL(RHeap::EDeterministic, i); sl@0: TRAPD(err, iView->MatchCursorHeightL(testaFontSpec)); sl@0: Destroy(); sl@0: __UHEAP_SETFAIL(RHeap::ENone, 0); sl@0: __UHEAP_MARKENDC(0); sl@0: if (err == KErrNone) sl@0: ++consecutiveSuccesses; sl@0: else sl@0: consecutiveSuccesses = 0; sl@0: } sl@0: } sl@0: sl@0: sl@0: void CTextViewTest::TestCalculateHorizontalExtremesL() sl@0: { sl@0: InitializeL(); sl@0: iView->CalculateHorizontalExtremesL(testaLeft, testaRight, EFalse); sl@0: Destroy(); sl@0: TInt consecutiveSuccesses = 0; sl@0: for (TInt i = 1; consecutiveSuccesses != 100; ++i) sl@0: { sl@0: __UHEAP_MARK; sl@0: InitializeL(); sl@0: __UHEAP_SETFAIL(RHeap::EDeterministic, i); sl@0: TRAPD(err, iView->CalculateHorizontalExtremesL(testaLeft, testaRight, EFalse)); sl@0: Destroy(); sl@0: __UHEAP_SETFAIL(RHeap::ENone, 0); sl@0: __UHEAP_MARKENDC(0); sl@0: if (err == KErrNone) sl@0: ++consecutiveSuccesses; sl@0: else sl@0: consecutiveSuccesses = 0; sl@0: } sl@0: } sl@0: sl@0: sl@0: void CTextViewTest::TestXyPosToDocPosL() sl@0: { sl@0: InitializeL(); sl@0: iView->XyPosToDocPosL(testaPoint); sl@0: Destroy(); sl@0: TInt consecutiveSuccesses = 0; sl@0: for (TInt i = 1; consecutiveSuccesses != 100; ++i) sl@0: { sl@0: __UHEAP_MARK; sl@0: InitializeL(); sl@0: __UHEAP_SETFAIL(RHeap::EDeterministic, i); sl@0: TRAPD(err, iView->XyPosToDocPosL(testaPoint)); sl@0: Destroy(); sl@0: __UHEAP_SETFAIL(RHeap::ENone, 0); sl@0: __UHEAP_MARKENDC(0); sl@0: if (err == KErrNone) sl@0: ++consecutiveSuccesses; sl@0: else sl@0: consecutiveSuccesses = 0; sl@0: } sl@0: } sl@0: sl@0: /* sl@0: void CTextViewTest::TestDrawL1() sl@0: { sl@0: InitializeL(); sl@0: iView->DrawL(iWindowRect, testaGc); sl@0: Destroy(); sl@0: TInt consecutiveSuccesses = 0; sl@0: for (TInt i = 1; consecutiveSuccesses != 100; ++i) sl@0: { sl@0: __UHEAP_MARK; sl@0: InitializeL(); sl@0: __UHEAP_SETFAIL(RHeap::EDeterministic, i); sl@0: TRAPD(err, iView->DrawL(iWindowRect, testaGc)); sl@0: Destroy(); sl@0: __UHEAP_SETFAIL(RHeap::ENone, 0); sl@0: __UHEAP_MARKENDC(0); sl@0: if (err == KErrNone) sl@0: ++consecutiveSuccesses; sl@0: else sl@0: consecutiveSuccesses = 0; sl@0: } sl@0: } sl@0: */ sl@0: sl@0: sl@0: void CTextViewTest::TestGetPictureRectangleL() sl@0: { sl@0: InitializeL(); sl@0: iView->GetPictureRectangleL(1, iWindowRect, &testaCanScaleOrCrop); sl@0: Destroy(); sl@0: TInt consecutiveSuccesses = 0; sl@0: for (TInt i = 1; consecutiveSuccesses != 100; ++i) sl@0: { sl@0: __UHEAP_MARK; sl@0: InitializeL(); sl@0: __UHEAP_SETFAIL(RHeap::EDeterministic, i); sl@0: TRAPD(err, iView->GetPictureRectangleL(1, iWindowRect, &testaCanScaleOrCrop)); sl@0: Destroy(); sl@0: __UHEAP_SETFAIL(RHeap::ENone, 0); sl@0: __UHEAP_MARKENDC(0); sl@0: if (err == KErrNone) sl@0: ++consecutiveSuccesses; sl@0: else sl@0: consecutiveSuccesses = 0; sl@0: } sl@0: } sl@0: sl@0: sl@0: void CTextViewTest::TestGetPictureRectangle1L() sl@0: { sl@0: InitializeL(); sl@0: iView->GetPictureRectangleL(testaXyPos, iWindowRect, &testaCanScaleOrCrop); sl@0: Destroy(); sl@0: TInt consecutiveSuccesses = 0; sl@0: for (TInt i = 1; consecutiveSuccesses != 100; ++i) sl@0: { sl@0: __UHEAP_MARK; sl@0: InitializeL(); sl@0: __UHEAP_SETFAIL(RHeap::EDeterministic, i); sl@0: TRAPD(err, iView->GetPictureRectangleL(testaXyPos, iWindowRect, &testaCanScaleOrCrop)); sl@0: Destroy(); sl@0: __UHEAP_SETFAIL(RHeap::ENone, 0); sl@0: __UHEAP_MARKENDC(0); sl@0: if (err == KErrNone) sl@0: ++consecutiveSuccesses; sl@0: else sl@0: consecutiveSuccesses = 0; sl@0: } sl@0: } sl@0: sl@0: sl@0: void CTextViewTest::TestSetDisplayContextL() sl@0: { sl@0: CBitmapContext* atestGc; sl@0: CBitmapContext* anotherGc; sl@0: InitializeL(); sl@0: iView->SetDisplayContextL(testaGd, &iWindow, &testaGroupWin, &testaSession); sl@0: Destroy(); sl@0: TInt consecutiveSuccesses = 0; sl@0: for (TInt i = 1; consecutiveSuccesses != 1; ++i) sl@0: { sl@0: __UHEAP_MARK; sl@0: InitializeL(); sl@0: __UHEAP_SETFAIL(RHeap::EDeterministic, i); sl@0: atestGc=iView->BitmapContext(); sl@0: TRAPD(err, iView->SetDisplayContextL(testaGd, &iWindow, &testaGroupWin, &testaSession)); sl@0: anotherGc=iView->BitmapContext(); sl@0: if (err) sl@0: { sl@0: test(atestGc==anotherGc); sl@0: } sl@0: else sl@0: { sl@0: test(atestGc!=anotherGc); sl@0: } sl@0: Destroy(); sl@0: __UHEAP_SETFAIL(RHeap::ENone, 0); sl@0: __UHEAP_MARKENDC(0); sl@0: if (err == KErrNone) sl@0: ++consecutiveSuccesses; sl@0: else sl@0: consecutiveSuccesses = 0; sl@0: } sl@0: } sl@0: sl@0: sl@0: void CTextViewTest::TestGetPictureRectangleDefectL() sl@0: { sl@0: /* sl@0: _LIT(KParagraphAverage,"Some text to test that the Picture returned is in the correct position. The size of this paragraph should be reasonable, not too long not too short."); sl@0: _LIT(KParagraphBigger,"Moulin Rouge: a film review. I don't know what I was expecting from Oulin Rouge, but what I got came as an even more of a surprise. The movie is a visual feast, a sing along extravaganza. The choices of songs is refreshing, with mix of Nirvan-Smells like teen spirit- to Madonna-Like a virgin-. Who knew that Ewan and Nicole could sing so well together."); sl@0: _LIT(KParagraphSmall,"CBusBase is an abstract base class for dynamic memory buffers. You can read or write bytes."); sl@0: InitializeL(); sl@0: TInt length; sl@0: iEtext->InsertL(0,KParagraphAverage); sl@0: iView->HandleInsertDeleteL(TCursorSelection(0, KParagraphAverage().Length()), 0); sl@0: iEtext->InsertL(KParagraphAverage().Length(),TChar(CEditableText::EParagraphDelimiter)); sl@0: iView->HandleCharEditL(); sl@0: sl@0: length=iEtext->LdDocumentLength(); sl@0: iEtext->InsertL(iEtext->LdDocumentLength(),KParagraphBigger); sl@0: iView->HandleInsertDeleteL(TCursorSelection(length,KParagraphBigger().Length()), 0); sl@0: sl@0: length=iEtext->LdDocumentLength(); sl@0: iEtext->InsertL(iEtext->LdDocumentLength(),KParagraphSmall); sl@0: iView->HandleInsertDeleteL(TCursorSelection(length,KParagraphSmall().Length()), 0); sl@0: sl@0: TSize size(100,100); sl@0: TPoint xypos; sl@0: CMyTestPicture* testpicture1 = CMyTestPicture::NewL(size); sl@0: CMyTestPicture* testpicture2 = CMyTestPicture::NewL(size); sl@0: CMyTestPicture* testpicture3 = CMyTestPicture::NewL(size); sl@0: size.SetSize(200,200); sl@0: CMyTestPicture* testpicture4 = CMyTestPicture::NewL(size); sl@0: CMyTestPicture* testpicture5 = CMyTestPicture::NewL(size); sl@0: CMyTestPicture* testpicture6 = CMyTestPicture::NewL(size); sl@0: TPictureHeader mypic; sl@0: TPictureHeader mypic2; sl@0: //mypic.iPictureType = KUidXzePictureType; sl@0: mypic.iPicture=testpicture1; sl@0: mypic2.iPicture=testpicture2; sl@0: // Testing the picture sl@0: sl@0: iEtext->InsertL(10,mypic2); sl@0: mypic2.iPicture=testpicture1; sl@0: iEtext->InsertL(40,mypic2); sl@0: iView->DocPosToXyPosL(200,xypos); sl@0: test.Printf(_L("The xy coords are %d & %d\n"),xypos.iX,xypos.iY); sl@0: xypos.SetXY(78,55); sl@0: TInt docpos; sl@0: docpos=iView->XyPosToDocPosL(xypos); sl@0: test.Printf(_L("The new docpos is %d\n"),docpos); sl@0: TRect rect; sl@0: TBool boo; sl@0: boo=iView->GetPictureRectangleL(40,rect); sl@0: test.Printf(_L("%d & %d \n"),rect.Size().iHeight,rect.Size().iWidth); sl@0: if (boo) sl@0: test.Printf(_L("Yes!")); sl@0: else sl@0: test.Printf(_L("Noo!")); sl@0: */ sl@0: } sl@0: sl@0: void CTextViewTest::TestGetLineRectL() sl@0: { sl@0: sl@0: _LIT(KSomeText,"Empty. Well this text has to now be something else. Maybe this will increase the height of the CTextLayout and if it does then"); sl@0: // calls the initializeDiffCharFormatL to set the new CharFormatLayer sl@0: // which sets the picture alignment to be Bottom. sl@0: InitializeDiffCharFormatL(); sl@0: // create test pictures to be inserted into the richtext object sl@0: TSize size(100,100); sl@0: CMyTestPicture* testpicture1 = CMyTestPicture::NewL(size); sl@0: TPictureHeader tPicHeader; sl@0: tPicHeader.iPictureType = KUidXzePictureType; sl@0: tPicHeader.iPicture = testpicture1; sl@0: test.Printf(_L("Created a picture\n")); sl@0: sl@0: // inserting some text & picture into the richtext object sl@0: iEtext->InsertL(0,KSomeText); sl@0: TInt startOfPicture; sl@0: startOfPicture=iEtext->DocumentLength(); sl@0: iEtext->InsertL(startOfPicture,tPicHeader); sl@0: test.Printf(_L("Inserted the picture in CRichText object \n")); sl@0: sl@0: //Call the guilty function sl@0: TRect resultingRect; sl@0: TInt endOfDocument = iEtext->DocumentLength(); sl@0: iView->FormatTextL(); sl@0: resultingRect=iLayout->GetLineRectL(startOfPicture,endOfDocument); sl@0: } sl@0: sl@0: void CTextViewTest::TestGetParaFormatL() sl@0: { sl@0: test.Next(_L("Starting GetParaFormatL test")); sl@0: _LIT(KSomeText,"Empty. Well this text has to now be something else. Maybe this will increase the height of the CTextLayout and if it does then"); sl@0: InitializeL(); sl@0: // create the CParaFormat & TparaFormatMask sl@0: // and set that in the iParaFormatLayer sl@0: CParaFormat* paraFormat = CParaFormat::NewL(); sl@0: TParaFormatMask paraFormatMask; sl@0: iParaLayer->SetL(paraFormat,paraFormatMask); sl@0: iEtext->SetGlobalParaFormat(iParaLayer); sl@0: iEtext->InsertL(0,KSomeText); sl@0: iView->FormatTextL(); sl@0: // Create another CParaFormat & TParaFormatMask and set sl@0: // some attributes to be different from the default. sl@0: CParaFormat* anotherParaFormat = CParaFormat::NewL(); sl@0: TParaFormatMask anotherParaFormatMask; sl@0: anotherParaFormat->iRightMarginInTwips=200; sl@0: anotherParaFormatMask.SetAttrib(EAttRightMargin); sl@0: anotherParaFormat->iLeftMarginInTwips=400; sl@0: anotherParaFormatMask.SetAttrib(EAttLeftMargin); sl@0: anotherParaFormat->iLineSpacingInTwips=300; sl@0: anotherParaFormatMask.SetAttrib(EAttLineSpacing); sl@0: anotherParaFormat->iHorizontalAlignment=CParaFormat::ERightAlign; sl@0: anotherParaFormatMask.SetAttrib(EAttAlignment); sl@0: sl@0: //Now call CRichText::GetParaFormat using anotherParaFormat * Mask sl@0: // and test that it is the same as paraFormat. sl@0: iEtext->GetParaFormatL(anotherParaFormat,anotherParaFormatMask,0,10); sl@0: sl@0: TInt result = anotherParaFormat->iRightMarginInTwips; sl@0: test (result==0); sl@0: sl@0: result = anotherParaFormat->iLeftMarginInTwips; sl@0: test (result==0); sl@0: result = anotherParaFormat->iLineSpacingInTwips; sl@0: test (result==200); // default value for iLineSpacingInTwips set in paraFormat is 200 sl@0: test (anotherParaFormat->iHorizontalAlignment == CParaFormat::ELeftAlign); sl@0: sl@0: TBool testresult; sl@0: testresult=anotherParaFormat->IsEqual(*paraFormat); sl@0: test(testresult); sl@0: sl@0: } sl@0: sl@0: sl@0: void CTextViewTest::TestForDEF003426L() sl@0: { sl@0: // Initialise CTextViewTest object for next test. sl@0: InitializeL(); sl@0: test.Next(_L("Verifying CTextView::XyPosToDosPosL() WRT DEF003426")); sl@0: sl@0: // Insert a one line paragraph into EText object and reformat view. sl@0: _LIT(KTestParagraph, "This is a piece of text to test the character positioning API based in X,Y cocordinates."); sl@0: iEtext->InsertL(0, KTestParagraph); sl@0: TCursorSelection sel(0, KTestParagraph().Length()); sl@0: (void) iView->HandleInsertDeleteL(sel, 0, EFalse); sl@0: sl@0: // Test XyPosToDocPosL() with coordinates beyond top left corner sl@0: TInt docPos = -1; sl@0: docPos = iView->XyPosToDocPosL(testaPoint); sl@0: test(docPos == 0); // Should give char position of 0 sl@0: sl@0: // Test XyPosToDocPosL() with coordinates beyond bottom right corner sl@0: TRect viewRect = iView->ViewRect(); sl@0: viewRect.iBr.iX += 300; sl@0: viewRect.iBr.iY += 111; sl@0: docPos = iView->XyPosToDocPosL(viewRect.iBr); sl@0: test(docPos != 0); // Should give char position of 88 sl@0: sl@0: // Clean up test object sl@0: Destroy(); sl@0: } sl@0: sl@0: /*** Test code for DEF038858 sl@0: " It isn't poss. to set via CTextView a TTmDocPos of iPos = 0; iLeadingEdge=false" sl@0: */ sl@0: void CTextViewTest::TestForDEF038488L() sl@0: { sl@0: // Initialise CTextViewTest object for next test. sl@0: InitializeL(); sl@0: test.Next(_L("Verifying CTextView::SetDocPosL() DEF038858")); sl@0: sl@0: _LIT(KText, "This is the test for DEF038488"); sl@0: iEtext->InsertL(0, KText); sl@0: iView->HandleInsertDeleteL(TCursorSelection(0, KText().Length()), 0); sl@0: sl@0: // Test SetDocPosL() with coordinates -1 sl@0: iView->SetDocPosL(-1); sl@0: sl@0: // check the value of iLeadingEdge sl@0: TTmDocPos RawDocPos; sl@0: iView->GetCursorPos(RawDocPos); sl@0: test(RawDocPos.iLeadingEdge == EFalse); sl@0: sl@0: } sl@0: sl@0: CTextViewTest::~CTextViewTest() sl@0: { sl@0: test.End(); sl@0: test.Close(); sl@0: delete iView; sl@0: iWindow.Close(); sl@0: delete iLayout; sl@0: delete iEtext; sl@0: delete iCharLayer; sl@0: delete iParaLayer; sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-FORM-UT-1888 sl@0: @SYMTestCaseDesc Testing the Class TFormAndEtextEditor sl@0: @SYMTestPriority Low sl@0: @SYMTestActions Tests the API's of TFormAndEtextEditor by inserting the text, applying specific format and style to the text, getting the text,format and style and also deleting the same(text,format and style) sl@0: @SYMTestExpectedResults Tests must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: void CTextViewTest::FormAndEtextTestL() sl@0: { sl@0: InitializeL(); sl@0: test.Next(_L(" @SYMTestCaseID:SYSLIB-FORM-UT-1888 Testing TFormAndEtextEditor ")); sl@0: TCharFormatMask charMask; sl@0: TCharFormat charFormat; sl@0: charFormat.iFontSpec.iTypeface.iName = _S("Arial"); sl@0: charFormat.iFontSpec.iHeight = 240; sl@0: charMask.SetAttrib(EAttFontTypeface); sl@0: charMask.SetAttrib(EAttFontHeight); sl@0: CCharFormatLayer* charFormatLayer = CCharFormatLayer::NewL(); sl@0: charFormatLayer->SetL(charFormat,charMask); sl@0: TParaFormatMask paraFormatMask; sl@0: CParaFormatLayer* paraFormatLayer=CParaFormatLayer::NewL((CParaFormat*)NULL,paraFormatMask); sl@0: CParagraphStyle* paraStyle = CParagraphStyle::NewL(*paraFormatLayer,*charFormatLayer); sl@0: CStyleList* styleList = CStyleList::NewL(); sl@0: RParagraphStyleInfo paraStyleInfo(paraStyle,paraStyle); sl@0: paraStyleInfo.iStyle->iName=_L("Arial"); sl@0: paraStyleInfo.iStyleForNextPara->iName=_L("Arial"); sl@0: // Appending the new style to stylelist sl@0: styleList->AppendL(¶StyleInfo); sl@0: sl@0: iEtext->SetStyleListExternallyOwned(*styleList); sl@0: iEtext->Reset(); sl@0: TFormAndEtextEditor newEditor(*iView,*iEtext); sl@0: sl@0: TTmCharFormatLayer charLayer; sl@0: TTmCharFormatLayer charLayer1; sl@0: TTmCharFormatMask charIMask; sl@0: TTmCharFormat charI; sl@0: RTmParFormatLayer parLayer; sl@0: RTmParFormatLayer parLayer1; sl@0: TTmParFormatMask parNMask; sl@0: charIMask.iFlags = TTmCharFormatMask::EItalic; sl@0: TOpenFontFaceAttribBase attrib; sl@0: attrib.SetBold(EFalse); sl@0: charI.iFontSpec.SetAttrib(attrib); sl@0: parNMask.iFlags = TTmParFormatMask::EKeepWithNext; sl@0: RTmParFormat parN; sl@0: parN.iFlags = RTmParFormat::EKeepWithNext; sl@0: charLayer.iMask = charIMask; sl@0: charLayer.iFormat = charI; sl@0: charLayer1=charLayer; sl@0: parLayer.iMask = parNMask; sl@0: sl@0: parLayer.iFormat.CopyL(parN); sl@0: TPtrC ptr1(_L("Arial")); sl@0: // Inserting the text and applying the style specified(Arial) sl@0: newEditor.InsertTextL(0, _L("Hello World"),&ptr1); sl@0: sl@0: // Setting the paragraph and character format explicitly sl@0: newEditor.SetParFormatL(0,11,parLayer); sl@0: newEditor.SetCharFormatL(0,11,charLayer); sl@0: sl@0: MUnifiedEditor::TFormatLevel level = MUnifiedEditor::EEffective; sl@0: TInt runLen=11; sl@0: // Getting the paragraph and character format sl@0: newEditor.GetParFormatL(0,level,parLayer1,runLen); sl@0: newEditor.GetCharFormat(0,level,charLayer1,runLen); sl@0: sl@0: // Deleting first 6 characters sl@0: newEditor.DeleteTextL(0,6); sl@0: // Deleting the paragraph and character format for the remaining text sl@0: newEditor.DeleteParFormatL(0,5); sl@0: newEditor.DeleteCharFormatL(0,5); sl@0: sl@0: TPtrC ptr; sl@0: // Get the text into ptr. A paragraph seperator(\x2029) gets appended at the end of text. sl@0: newEditor.GetText(0,ptr); sl@0: test(ptr==_L("World\x2029")); sl@0: sl@0: RTmStyle style1; sl@0: RParagraphStyleInfo paraStyleInfo1(paraStyle,paraStyle); sl@0: paraStyleInfo1.iStyle->iName=_L("NewStyle"); sl@0: paraStyleInfo1.iStyleForNextPara->iName=_L("NewStyle"); sl@0: style1.CopyL(paraStyleInfo1); sl@0: // Creating a new style and changing the current style to the new one. sl@0: newEditor.StyleSupport()->CreateStyleL(style1); sl@0: newEditor.StyleSupport()->ChangeStyleL(style1); sl@0: sl@0: RTmStyle style2; sl@0: // Get the style by Name sl@0: TInt retVal = newEditor.StyleSupport()->GetStyleByNameL(_L("Arial"),style2); sl@0: retVal = newEditor.StyleSupport()->GetStyleByNameL(_L("NewStyle"),style2); sl@0: // Get the style for a particular length of text sl@0: newEditor.StyleSupport()->GetStyle(0,ptr,runLen); sl@0: // Get the style by index sl@0: retVal = newEditor.StyleSupport()->GetStyleByIndexL(1,style1); sl@0: // Deleting the style sl@0: newEditor.StyleSupport()->DeleteStyleL(_L("NewStyle")); sl@0: retVal = newEditor.StyleCount(); sl@0: test(retVal==1); sl@0: style1.Close(); sl@0: style2.Close(); sl@0: delete charFormatLayer; sl@0: delete paraFormatLayer; sl@0: delete styleList; sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-FORM-UT-3347 sl@0: @SYMTestCaseDesc Testing the fix for INC092725: RF S60 3.2 Help: Touch and sl@0: scrolling a topic down closing the program sl@0: @SYMTestPriority High sl@0: @SYMTestActions Run affected APIs passing scroll values that would put the display sl@0: outside the formatted range. sl@0: @SYMTestExpectedResults First of all, the calls should not panic the process. sl@0: Secondly, that the calls leave with the correct error code. sl@0: @SYMDEF INC092725 sl@0: */ sl@0: void CTextViewTest::TestForINC092725L() sl@0: { sl@0: test.Next(_L(" @SYMTestCaseID:SYSLIB-FORM-UT-3347 Testing fix for INC092725 ")); sl@0: TInt err = KErrNone; sl@0: InitializeL(); sl@0: AddTextL(KHello); sl@0: sl@0: //Scroll up sl@0: iLayout->AdjustVerticalAlignment(CParaFormat::EAbsoluteRightAlign); sl@0: TRAP(err, iView->ScrollDisplayL(TCursorPosition::EFLineUp, CTextLayout::EFAllowScrollingBlankSpace)); sl@0: test(err==CTextLayout::EPosNotFormatted); sl@0: err=KErrNone; sl@0: sl@0: //Scroll down sl@0: iLayout->AdjustVerticalAlignment(CParaFormat::EAbsoluteLeftAlign); sl@0: TRAP(err, iView->ScrollDisplayL(TCursorPosition::EFLineDown, CTextLayout::EFAllowScrollingBlankSpace)); sl@0: test(err==CTextLayout::EPosNotFormatted); sl@0: err=KErrNone; sl@0: sl@0: //Line scroll up sl@0: TInt i = 105; sl@0: iLayout->AdjustVerticalAlignment(CParaFormat::EAbsoluteRightAlign); sl@0: TRAP(err, iView->ScrollDisplayLinesL(i, CTextLayout::EFAllowScrollingBlankSpace)); sl@0: test(err==CTextLayout::EPosNotFormatted); sl@0: err=KErrNone; sl@0: sl@0: //Line scroll down sl@0: i = -105; sl@0: iLayout->AdjustVerticalAlignment(CParaFormat::EAbsoluteLeftAlign); sl@0: TRAP(err, iView->ScrollDisplayLinesL(i, CTextLayout::EFAllowScrollingBlankSpace)); sl@0: test(err==CTextLayout::EPosNotFormatted); sl@0: err=KErrNone; sl@0: sl@0: //Paragraph scroll up sl@0: i = 105; sl@0: iLayout->AdjustVerticalAlignment(CParaFormat::EAbsoluteRightAlign); sl@0: TRAP(err, iView->ScrollDisplayParagraphsL(i, CTextLayout::EFAllowScrollingBlankSpace)); sl@0: test(err==CTextLayout::EPosNotFormatted); sl@0: err=KErrNone; sl@0: sl@0: //Paragraph scroll down sl@0: i = -105; sl@0: iLayout->AdjustVerticalAlignment(CParaFormat::EAbsoluteLeftAlign); sl@0: TRAP(err, iView->ScrollDisplayParagraphsL(i, CTextLayout::EFAllowScrollingBlankSpace)); sl@0: test(err==CTextLayout::EPosNotFormatted); sl@0: Destroy(); sl@0: } sl@0: sl@0: sl@0: class CTestScreenDevice : public CPrinterDevice sl@0: { sl@0: public: sl@0: CTestScreenDevice(CWsScreenDevice* aDevice,RDrawableWindow& aWin); sl@0: TDisplayMode DisplayMode() const {return iDevice->DisplayMode();} sl@0: TSize SizeInPixels() const {return iDevice->SizeInPixels();} sl@0: TSize SizeInTwips() const {return iDevice->SizeInTwips();} sl@0: TInt NumTypefaces() const {return iDevice->NumTypefaces();} sl@0: void TypefaceSupport(TTypefaceSupport& aTypefaceSupport,TInt aTypefaceIndex) const sl@0: {iDevice->TypefaceSupport(aTypefaceSupport,aTypefaceIndex);} sl@0: TInt FontHeightInTwips(TInt aTypefaceIndex,TInt aHeightIndex) const sl@0: {return iDevice->FontHeightInTwips(aTypefaceIndex,aHeightIndex);} sl@0: void PaletteAttributes(TBool& aModifiable,TInt& aNumEntries) const sl@0: {iDevice->PaletteAttributes(aModifiable,aNumEntries);} sl@0: void SetPalette(CPalette* aPalette) {iDevice->SetPalette(aPalette);} sl@0: TInt GetPalette(CPalette*& aPalette) const {return iDevice->GetPalette(aPalette);} sl@0: TInt CreateContext(CGraphicsContext *&aGc); sl@0: TInt HorizontalTwipsToPixels(TInt aTwips) const {return iDevice->HorizontalTwipsToPixels(aTwips);}; sl@0: TInt VerticalTwipsToPixels(TInt aTwips) const {return iDevice->VerticalTwipsToPixels(aTwips);}; sl@0: TInt HorizontalPixelsToTwips(TInt aPixels) const {return iDevice->HorizontalPixelsToTwips(aPixels);}; sl@0: TInt VerticalPixelsToTwips(TInt aPixels) const {return iDevice->VerticalPixelsToTwips(aPixels);}; sl@0: TInt GetNearestFontInTwips(CFont*& aFont,const TFontSpec& aFontSpec) {return iDevice->GetNearestFontInTwips(aFont,aFontSpec);}; sl@0: void ReleaseFont(CFont* aFont) {iDevice->ReleaseFont(aFont);}; sl@0: TPrinterModelName ModelName() const {return _L("");} sl@0: TUid ModelUid() const {TUid dummy; return dummy;} sl@0: void CreateControlL(CPrinterPort* /*aPrinterPort*/) {} sl@0: TPrinterModelEntry Model() const {return iModel;} sl@0: TInt SetModel(const TPrinterModelHeader& /*aModel*/,CStreamStore& /*aStore*/) {return KErrNone;} sl@0: TBool RequiresPrinterPort() {return EFalse;} sl@0: private: sl@0: RDrawableWindow& iWin; sl@0: CWsScreenDevice* iDevice; sl@0: TPrinterModelEntry iModel; sl@0: }; sl@0: sl@0: CTestScreenDevice::CTestScreenDevice(CWsScreenDevice* aDevice,RDrawableWindow& aWin): sl@0: iWin(aWin) sl@0: { sl@0: iDevice=aDevice; sl@0: iModel.iUid=TUid::Null(); sl@0: } sl@0: sl@0: TInt CTestScreenDevice::CreateContext(CGraphicsContext*& aGc) sl@0: { sl@0: sl@0: TInt ret=iDevice->CreateContext(aGc); sl@0: ((CWindowGc *) aGc)->Activate(iWin); sl@0: return ret; sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-FORM-UT-3496 sl@0: @SYMTestCaseDesc Testing the fix for PDEF108443: Two same content pages are printed when contact fields are exactly one page long sl@0: @SYMTestPriority Medium sl@0: @SYMTestActions Creates text paginators and tests resulting number of pages when there is text to 'full page - 1 line', full page and full page + 1 line of text. sl@0: @SYMTestExpectedResults Results should be 1 page, 1 page and 2 pages respectively. sl@0: @SYMDEF PDEF108443 sl@0: */ sl@0: void CTextViewTest::TestForPDEF108443L() sl@0: { sl@0: test.Next(_L(" @SYMTestCaseID:SYSLIB-FORM-UT-3496 Testing fix for PDEF108443 ")); sl@0: CTestScreenDevice* screenDevice = new(ELeave) CTestScreenDevice(iEnv.ScreenDevice(),iWindow); sl@0: sl@0: TMargins margins; sl@0: margins.iTop = 1440; sl@0: margins.iBottom = 1440; sl@0: margins.iLeft = 1440; sl@0: margins.iRight = 1440; sl@0: TSize s(11906,16838); sl@0: TPageSpec p(TPageSpec::EPortrait, s); sl@0: sl@0: CArrayFixFlat* charsPerPage1 = new(ELeave) CArrayFixFlat(KGranularity); sl@0: CTextPaginator* paginator1 = CTextPaginator::NewL(screenDevice, charsPerPage1, KPaginatePriority); sl@0: paginator1->SetPageMarginsInTwips(margins); sl@0: paginator1->SetPageSpecInTwips(p); sl@0: sl@0: CArrayFixFlat* charsPerPage2 = new(ELeave) CArrayFixFlat(KGranularity); sl@0: CTextPaginator* paginator2 = CTextPaginator::NewL(screenDevice, charsPerPage2, KPaginatePriority); sl@0: paginator2->SetPageMarginsInTwips(margins); sl@0: paginator2->SetPageSpecInTwips(p); sl@0: sl@0: CArrayFixFlat* charsPerPage3 = new(ELeave) CArrayFixFlat(KGranularity); sl@0: CTextPaginator* paginator3 = CTextPaginator::NewL(screenDevice, charsPerPage3, KPaginatePriority); sl@0: paginator3->SetPageMarginsInTwips(margins); sl@0: paginator3->SetPageSpecInTwips(p); sl@0: sl@0: sl@0: // We need to find out the height of lines and print area of the page. sl@0: // From this we determine how many lines *should* appear on the page. sl@0: // This differs between devices(ie. hw and winscw). sl@0: TRect textRect; sl@0: textRect.iTl.iX=margins.iLeft; sl@0: textRect.iTl.iY=margins.iTop; sl@0: textRect.iBr.iX=s.iWidth-margins.iRight; sl@0: textRect.iBr.iY=s.iHeight-margins.iBottom; sl@0: sl@0: textRect = screenDevice->TwipsToPixels(textRect); //defect 131765, call the same func as paginator sl@0: TInt pageHeight = textRect.Height(); sl@0: _LIT(KDummyString,"AAAAAA"); sl@0: InitializeL(); sl@0: AddTextL(KDummyString); sl@0: TInt lineHeight = 0; sl@0: CParaFormat* paraFormat = CParaFormat::NewL(); sl@0: iEtext->GetParagraphFormatL(paraFormat,0); sl@0: TBool pageBreakChar = EFalse; sl@0: TInt docPos = 0; sl@0: iLayout->FormatLineL(paraFormat,docPos,lineHeight,pageBreakChar); sl@0: sl@0: sl@0: TInt numLines = pageHeight/lineHeight; // Number of lines expected on a page with paginator settings defined above and line height = 21 sl@0: TChar simpleChar('A'); sl@0: TBuf<200> string1; sl@0: for (TInt i = 0; i < numLines-2; i++) // ...numlines - 1 sl@0: { sl@0: string1.Append(simpleChar); sl@0: string1.Append(CEditableText::EParagraphDelimiter); sl@0: } sl@0: string1.Append(simpleChar); // final line sl@0: TBuf<200> string2; sl@0: for (TInt i = 0; i < numLines-1; i++) // ...numlines sl@0: { sl@0: string2.Append(simpleChar); sl@0: string2.Append(CEditableText::EParagraphDelimiter); sl@0: } sl@0: string2.Append(simpleChar); // final line sl@0: TBuf<200> string3; sl@0: for (TInt i = 0; i < numLines; i++) // ...numlines + 1 sl@0: { sl@0: string3.Append(simpleChar); sl@0: string3.Append(CEditableText::EParagraphDelimiter); sl@0: } sl@0: string3.Append(simpleChar); // final line sl@0: sl@0: InitializeL(); sl@0: AddTextL(string1); sl@0: paginator1->SetDocumentL(iEtext); sl@0: docPos=0; sl@0: paginator1->AppendTextL(docPos); sl@0: TInt numPages=paginator1->PaginationCompletedL(); sl@0: test(numPages==1); sl@0: InitializeL(); sl@0: AddTextL(string2); sl@0: paginator2->SetDocumentL(iEtext); sl@0: docPos=0; sl@0: paginator2->AppendTextL(docPos); sl@0: numPages=paginator2->PaginationCompletedL(); sl@0: test(numPages==1); sl@0: InitializeL(); sl@0: AddTextL(string3); sl@0: paginator3->SetDocumentL(iEtext); sl@0: docPos=0; sl@0: paginator3->AppendTextL(docPos); sl@0: numPages=paginator3->PaginationCompletedL(); sl@0: test(numPages==2); sl@0: sl@0: delete charsPerPage1; sl@0: delete charsPerPage2; sl@0: delete charsPerPage3; sl@0: delete screenDevice; sl@0: delete paraFormat; sl@0: Destroy(); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-FORM-UT-4002 sl@0: @SYMTestCaseDesc Test to ensure the CTextView::SetSelectionVisibilityL will not panic when EFTextVisible sl@0: is set off. sl@0: @SYMTestPriority Normal sl@0: @SYMTestActions Create a CTextView instance with EFTextVisible set off. Call SetSelectionVisibilityL(ETrue) sl@0: and SetSelectionVisibilityL(EFalse). sl@0: @SYMTestExpectedResults Given conditions in test actions, calling SetSelectionVisibilityL should not panic. sl@0: @SYMDEF PDEF113755 sl@0: */ sl@0: void CTextViewTest::TestForPDEF113755L() sl@0: { sl@0: test.Next(_L(" @SYMTestCaseID:SYSLIB-FORM-UT-4002 Testing fix for PDEF113755 ")); sl@0: InitializeL(); sl@0: sl@0: TCursorSelection selection(0,8); // length of selection must be >0 sl@0: iView->SetSelectionL(selection); sl@0: sl@0: iView->MakeVisible(ETrue); //Test if the EFSelectionVisible flag is set correctly sl@0: iView->SetSelectionVisibilityL(ETrue); sl@0: test(iView->SelectionVisible()); sl@0: iView->SetSelectionVisibilityL(EFalse); sl@0: test(!iView->SelectionVisible()); sl@0: sl@0: iView->MakeVisible(EFalse); sl@0: iView->SetSelectionVisibilityL(ETrue); //Should never panic form::1200 here sl@0: iView->SetSelectionVisibilityL(EFalse); sl@0: sl@0: Destroy(); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-FORM-UT-4004 sl@0: @SYMTestCaseDesc Test for INC113143, to ensure CTextLayout::GetLineRectL returns the correct rectangle sl@0: regarding the writting direction of text. Depend on Platform: WINSCW/H4/H6(DEF131765). sl@0: @SYMTestPriority Normal sl@0: @SYMTestActions Tested 16 scenarios that the CTextLayout::GetLineRectL could be call, also tested for sl@0: edge cases such as 1 char, whole line, DocPos2 < DocPos1, etc.. sl@0: @SYMTestExpectedResults CTextLayout::GetLineRectL should return expected rectangles. sl@0: @SYMDEF PDEF115165 sl@0: */ sl@0: void CTextViewTest::TestForPDEF115165L() sl@0: { sl@0: test.Next(_L(" @SYMTestCaseID:SYSLIB-FORM-UT-4004 Testing fix for PDEF115165 ")); sl@0: InitializeL(); sl@0: sl@0: TCharFormat charFormat = TCharFormat(_L("Arial"),100); sl@0: TCharFormatMask charFormatMask; sl@0: charFormatMask.SetAll(); sl@0: iCharLayer->SetL(charFormat, charFormatMask); sl@0: iEtext->SetGlobalCharFormat(iCharLayer); sl@0: _LIT(KLtoRChar,"a"); sl@0: _LIT(KRtoLChar,"\x6B2"); sl@0: _LIT(KLtoRText,"aaa"); sl@0: _LIT(KRtoLText,"\x6B2\x6B2\x6B2"); sl@0: _LIT(KParaSep, "\x2029"); sl@0: sl@0: TRect rect; sl@0: sl@0: // Test for 16 scenarios of Bidi texts.. sl@0: // Sample text for test sl@0: // Doc_Pos: | 0| 1| 2| 5| 4| 3| 6| 7| 8|11|10| 9| sl@0: // X-Coords: |0| 5|10|15|20|25|30|35|40|45|50|55|60| in case w=5 sl@0: sl@0: iEtext->Reset(); sl@0: iEtext->InsertL(0,KLtoRText); sl@0: iEtext->InsertL(iEtext->DocumentLength(),KRtoLText); sl@0: iEtext->InsertL(iEtext->DocumentLength(),KLtoRText); sl@0: iEtext->InsertL(iEtext->DocumentLength(),KRtoLText); sl@0: iEtext->InsertL(iEtext->DocumentLength(),KParaSep); sl@0: iView->FormatTextL(); sl@0: sl@0: TPoint point1,point2; sl@0: iLayout->DocPosToXyPosL(0,point1); sl@0: iLayout->DocPosToXyPosL(1,point2); sl@0: sl@0: TInt wLTR = point2.iX - point1.iX; //It depends on platform. WINSCW/H4 w=5; H6 w=4 sl@0: sl@0: iLayout->DocPosToXyPosL(5,point1); sl@0: iLayout->DocPosToXyPosL(4,point2); sl@0: TInt wRTL = point2.iX - point1.iX; //It depends on platform. WINSCW/H4 w=5; H6 w=4 sl@0: RDebug::Print(_L("wLTR %d,wRTL %d"), wLTR,wRTL); sl@0: sl@0: // DocPos1 is LTR, DocPos1+1 is LTR, DocPos2 is LTR, DocPos2+1 is RTL sl@0: rect = iLayout->GetLineRectL(0,2); sl@0: RDebug::Print(_L("iTl.iX %d,iY %d, iBr.iX %d,iY %d"), rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY); sl@0: test(rect.iTl.iX == 0 && rect.iBr.iX == 3*wLTR); sl@0: sl@0: // DocPos1 is LTR, DocPos1+1 is LTR, DocPos2 is RTL, DocPos2+1 is RTL sl@0: rect = iLayout->GetLineRectL(0,4); sl@0: RDebug::Print(_L("iTl.iX %d,iY %d, iBr.iX %d,iY %d"), rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY); sl@0: test(rect.iTl.iX == 0 && rect.iBr.iX == 3*wLTR + 2*wRTL); sl@0: sl@0: // DocPos1 is LTR, DocPos1+1 is LTR, DocPos2 is RTL, DocPos2+1 is LTR sl@0: rect = iLayout->GetLineRectL(0,5); sl@0: RDebug::Print(_L("iTl.iX %d,iY %d, iBr.iX %d,iY %d"), rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY); sl@0: test(rect.iTl.iX == 0 && rect.iBr.iX == 3*wLTR + wRTL); sl@0: sl@0: // DocPos1 is LTR, DocPos1+1 is LTR, DocPos2 is LTR, DocPos2+1 is LTR sl@0: rect = iLayout->GetLineRectL(0,7); sl@0: RDebug::Print(_L("iTl.iX %d,iY %d, iBr.iX %d,iY %d"), rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY); sl@0: test(rect.iTl.iX == 0 && rect.iBr.iX == 3*wLTR + 3*wRTL + 2*wLTR); sl@0: sl@0: // DocPos1 is LTR, DocPos1+1 is RTL, DocPos2 is LTR, DocPos2+1 is LTR sl@0: rect = iLayout->GetLineRectL(2,7); sl@0: RDebug::Print(_L("iTl.iX %d,iY %d, iBr.iX %d,iY %d"), rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY); sl@0: test(rect.iTl.iX == 2*wLTR && rect.iBr.iX == 3*wLTR + 3*wRTL + 2*wLTR); sl@0: sl@0: // DocPos1 is LTR, DocPos1+1 is RTL, DocPos2 is LTR, DocPos2+1 is RTL sl@0: rect = iLayout->GetLineRectL(2,8); sl@0: RDebug::Print(_L("iTl.iX %d,iY %d, iBr.iX %d,iY %d"), rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY); sl@0: test(rect.iTl.iX == 2*wLTR && rect.iBr.iX == 3*wLTR + 3*wRTL + 3*wLTR); sl@0: sl@0: // DocPos1 is LTR, DocPos1+1 is RTL, DocPos2 is RTL, DocPos2+1 is LTR sl@0: rect = iLayout->GetLineRectL(2,5); sl@0: RDebug::Print(_L("iTl.iX %d,iY %d, iBr.iX %d,iY %d"), rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY); sl@0: test(rect.iTl.iX == 2*wLTR && rect.iBr.iX == 3*wLTR + wRTL); sl@0: sl@0: // DocPos1 is LTR, DocPos1+1 is RTL, DocPos2 is RTL, DocPos2+1 is RTL sl@0: rect = iLayout->GetLineRectL(2,4); sl@0: RDebug::Print(_L("iTl.iX %d,iY %d, iBr.iX %d,iY %d"), rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY); sl@0: test(rect.iTl.iX == 2*wLTR && rect.iBr.iX == 3*wLTR + 2*wRTL); sl@0: sl@0: // Sample text for test sl@0: // Doc_Pos: | 9|10|11| 8| 7| 6| 3| 4| 5| 2| 1| 0| sl@0: // X-Coords: |40|45|50|55|60|65|70|75|80|85|90|95|100| in case w=5 sl@0: sl@0: iEtext->Reset(); sl@0: iEtext->InsertL(0,KRtoLText); sl@0: iEtext->InsertL(iEtext->DocumentLength(),KLtoRText); sl@0: iEtext->InsertL(iEtext->DocumentLength(),KRtoLText); sl@0: iEtext->InsertL(iEtext->DocumentLength(),KLtoRText); sl@0: iEtext->InsertL(iEtext->DocumentLength(),KParaSep); sl@0: iView->FormatTextL(); sl@0: sl@0: // DocPos1 is RTL, DocPos1+1 is LTR, DocPos2 is LTR, DocPos2+1 is LTR sl@0: rect = iLayout->GetLineRectL(2,4); sl@0: RDebug::Print(_L("iTl.iX %d,iY %d, iBr.iX %d,iY %d"), rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY); sl@0: test(rect.iTl.iX == iWindowRect.Width() - 3*wRTL - 2*wLTR && rect.iBr.iX == iWindowRect.Width() - 2*wRTL); sl@0: sl@0: // DocPos1 is RTL, DocPos1+1 is LTR, DocPos2 is LTR, DocPos2+1 is RTL sl@0: rect = iLayout->GetLineRectL(2,5); sl@0: RDebug::Print(_L("iTl.iX %d,iY %d, iBr.iX %d,iY %d"), rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY); sl@0: test(rect.iTl.iX == iWindowRect.Width() - 3*wRTL - wLTR && rect.iBr.iX == iWindowRect.Width() - 2*wRTL); sl@0: sl@0: // DocPos1 is RTL, DocPos1+1 is LTR, DocPos2 is RTL, DocPos2+1 is LTR sl@0: rect = iLayout->GetLineRectL(2,8); sl@0: RDebug::Print(_L("iTl.iX %d,iY %d, iBr.iX %d,iY %d"), rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY); sl@0: test(rect.iTl.iX == iWindowRect.Width() - 3*wRTL - 3*wLTR - 3*wRTL && rect.iBr.iX == iWindowRect.Width() - 2*wRTL); sl@0: sl@0: // DocPos1 is RTL, DocPos1+1 is LTR, DocPos2 is RTL, DocPos2+1 is RTL sl@0: rect = iLayout->GetLineRectL(2,7); sl@0: RDebug::Print(_L("iTl.iX %d,iY %d, iBr.iX %d,iY %d"), rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY); sl@0: test(rect.iTl.iX == iWindowRect.Width() - 3*wRTL - 3*wLTR - 2*wRTL && rect.iBr.iX == iWindowRect.Width() - 2*wRTL); sl@0: sl@0: // DocPos1 is RTL, DocPos1+1 is RTL, DocPos2 is LTR, DocPos2+1 is LTR sl@0: rect = iLayout->GetLineRectL(0,4); sl@0: RDebug::Print(_L("iTl.iX %d,iY %d, iBr.iX %d,iY %d"), rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY); sl@0: test(rect.iTl.iX == iWindowRect.Width() - 3*wRTL - 2*wLTR && rect.iBr.iX == 100); sl@0: sl@0: // DocPos1 is RTL, DocPos1+1 is RTL, DocPos2 is LTR, DocPos2+1 is RTL sl@0: rect = iLayout->GetLineRectL(0,5); sl@0: RDebug::Print(_L("iTl.iX %d,iY %d, iBr.iX %d,iY %d"), rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY); sl@0: test(rect.iTl.iX == iWindowRect.Width() - 3*wRTL - wLTR && rect.iBr.iX == 100); sl@0: sl@0: // DocPos1 is RTL, DocPos1+1 is RTL, DocPos2 is RTL, DocPos2+1 is LTR sl@0: rect = iLayout->GetLineRectL(0,8); sl@0: RDebug::Print(_L("iTl.iX %d,iY %d, iBr.iX %d,iY %d"), rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY); sl@0: test(rect.iTl.iX == iWindowRect.Width() - 3*wRTL - 3*wLTR - 3*wRTL && rect.iBr.iX == 100); sl@0: sl@0: // DocPos1 is RTL, DocPos1+1 is RTL, DocPos2 is RTL, DocPos2+1 is RTL sl@0: rect = iLayout->GetLineRectL(0,7); sl@0: RDebug::Print(_L("iTl.iX %d,iY %d, iBr.iX %d,iY %d"), rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY); sl@0: test(rect.iTl.iX == iWindowRect.Width() - 3*wRTL - 3*wLTR - 2*wRTL && rect.iBr.iX == 100); sl@0: sl@0: sl@0: sl@0: // Edge case tests sl@0: // Sample text sl@0: // 1st Line: | 0| 1| 2| 3| 4| 5| 6| 7| 8| 9|10|11|19|18|17|16|15|14|13|12| sl@0: // X-Coords: | 0| 5|10|15|20|25|30|35|40|45|50|55|60|65|70|75|80|85|90|95|100| in case w=5 sl@0: // 2nd Line: |23|22|21|20| sl@0: sl@0: // Edge case tests sl@0: // Sample text sl@0: // 1st Line: | 0| 1| 2| 3| 4| 5| 6| 7| 8| 9|10|11|12|13|14|24|23|22|21|20|19|18|17|16|15| sl@0: // X-Coords: | 0| 4| 8|12|16|20|24|28|32|36|40|44|48|52|56|60|64|68|72|76|80|84|88|92|96|100| w=4 sl@0: // 2nd Line: |29|28|27|26|25|24|23|22|21|20| sl@0: sl@0: TInt LtoRLength = (iWindowRect.Width() - 5*wRTL)/wLTR; sl@0: TInt RtoLLength = 10; sl@0: TInt RtoLinLine1= (iWindowRect.Width() - LtoRLength * wLTR)/wRTL; sl@0: TInt Line2Start = LtoRLength + RtoLinLine1; sl@0: sl@0: iEtext->Reset(); sl@0: for(TInt i=0;iInsertL(iEtext->DocumentLength(),KLtoRChar); sl@0: } sl@0: sl@0: for(TInt i=0;iInsertL(iEtext->DocumentLength(),KRtoLChar); sl@0: } sl@0: iEtext->InsertL(iEtext->DocumentLength(),KParaSep); sl@0: iView->FormatTextL(); sl@0: sl@0: for(TInt i=0;iGetLineRectL(i,i+1); sl@0: RDebug::Print(_L("%d: iTl.iX %d,iY %d, iBr.iX %d,iY %d"), i,rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY); sl@0: } sl@0: sl@0: rect = iLayout->GetLineRectL(0,LtoRLength); sl@0: RDebug::Print(_L("iTl.iX %d,iY %d, iBr.iX %d,iY %d"), rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY); sl@0: test(rect.iTl.iX == 0 && rect.iBr.iX == LtoRLength*wLTR + RtoLinLine1*wRTL ); //Line 1 sl@0: sl@0: rect = iLayout->GetLineRectL(Line2Start, LtoRLength + RtoLLength); sl@0: RDebug::Print(_L("iTl.iX %d,iY %d, iBr.iX %d,iY %d"), rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY); sl@0: test(rect.iTl.iX == 0 && rect.iBr.iX == (RtoLLength - RtoLinLine1)*wRTL); //Line 2 sl@0: sl@0: rect = iLayout->GetLineRectL(0,0); sl@0: RDebug::Print(_L("iTl.iX %d,iY %d, iBr.iX %d,iY %d"), rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY); sl@0: test(rect.iTl.iX == 0 && rect.iBr.iX == wLTR); //first char sl@0: sl@0: //firt char of RTL sl@0: rect = iLayout->GetLineRectL(LtoRLength,LtoRLength); sl@0: RDebug::Print(_L("iTl.iX %d,iY %d, iBr.iX %d,iY %d"), rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY); sl@0: test(rect.iTl.iX == LtoRLength*wLTR + (RtoLinLine1-1)*wRTL && rect.iBr.iX == LtoRLength*wLTR + RtoLinLine1*wRTL); //end of line 1 sl@0: sl@0: //middle of L to R sl@0: rect = iLayout->GetLineRectL(LtoRLength/2,LtoRLength/2); sl@0: RDebug::Print(_L("iTl.iX %d,iY %d, iBr.iX %d,iY %d"), rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY); sl@0: test(rect.iTl.iX == LtoRLength/2 * wLTR && rect.iBr.iX == (LtoRLength/2+1) * wLTR); sl@0: sl@0: //middle of LTR to first of RTL sl@0: rect = iLayout->GetLineRectL(LtoRLength/2,LtoRLength); sl@0: RDebug::Print(_L("iTl.iX %d,iY %d, iBr.iX %d,iY %d"), rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY); sl@0: test(rect.iTl.iX == LtoRLength/2 * wLTR && rect.iBr.iX == LtoRLength*wLTR + RtoLinLine1*wRTL); sl@0: sl@0: //second of RTL to start of 2nd line ?? sl@0: rect = iLayout->GetLineRectL(LtoRLength+1,Line2Start); sl@0: RDebug::Print(_L("iTl.iX %d,iY %d, iBr.iX %d,iY %d"), rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY); sl@0: test(rect.iTl.iX == LtoRLength*wLTR + (RtoLinLine1-1)*wRTL && rect.iBr.iX == LtoRLength*wLTR + RtoLinLine1*wRTL); //end of line 1 sl@0: sl@0: //middle of L to R sl@0: rect = iLayout->GetLineRectL(LtoRLength/2,LtoRLength/2-1); sl@0: RDebug::Print(_L("iTl.iX %d,iY %d, iBr.iX %d,iY %d"), rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY); sl@0: test(rect.iTl.iX == LtoRLength/2 * wLTR && rect.iBr.iX == LtoRLength*wLTR + RtoLinLine1*wRTL); sl@0: sl@0: sl@0: // Test for edge cases while two lines are in different direction sl@0: // Sample text sl@0: // 1st Line: | 0| 1| 2| 3| 4| 5| 6| 7| 8| 9|10|11|12|13|14|15|16|17|18|19| sl@0: // X-Coords: | 0| 5|10|15|20|25|30|35|40|45|50|55|60|65|70|75|80|85|90|95|100| in case w=5 sl@0: // 2nd Line: |39|38|37|36|35|34|33|32|31|30|29|28|27|26|25|24|23|22|21|20| sl@0: sl@0: // Test for edge cases while two lines are in different direction sl@0: // Sample text sl@0: // 1st Line: | 0| 1| 2| 3| 4| 5| 6| 7| 8| 9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24| sl@0: // X-Coords: | 0| 4| 8| 12|16|20|24|28|32|36|40|44|48|52|56|60|64|68|72|76|80|84|88|92|96|100| w=4 sl@0: // 2nd Line: |49|48|47|46|45|44|43|42|41|40|39|38|37|36|35|34|33|32|31|30|29|28|27|26|25| sl@0: sl@0: LtoRLength = iWindowRect.Width()/wLTR; sl@0: RtoLLength = iWindowRect.Width()/wRTL; sl@0: sl@0: iEtext->Reset(); sl@0: for(TInt i=0;iInsertL(iEtext->DocumentLength(),KLtoRChar); sl@0: } sl@0: sl@0: for(TInt i=0;iInsertL(iEtext->DocumentLength(),KRtoLChar); sl@0: } sl@0: iEtext->InsertL(iEtext->DocumentLength(),KParaSep); sl@0: iView->FormatTextL(); sl@0: sl@0: for(TInt i=0;iGetLineRectL(i,i+1); sl@0: RDebug::Print(_L("%d: iTl.iX %d,iY %d, iBr.iX %d,iY %d"), i,rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY); sl@0: } sl@0: sl@0: sl@0: //1st line sl@0: rect = iLayout->GetLineRectL(3, LtoRLength-1); sl@0: RDebug::Print(_L("iTl.iX %d,iY %d, iBr.iX %d,iY %d"), rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY); sl@0: test(rect.iTl.iX == 3*wLTR && rect.iBr.iX == LtoRLength*wLTR); //Line 2 sl@0: sl@0: //2nd line sl@0: rect = iLayout->GetLineRectL(LtoRLength,LtoRLength + RtoLLength -2); sl@0: RDebug::Print(_L("iTl.iX %d,iY %d, iBr.iX %d,iY %d"), rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY); sl@0: test(rect.iTl.iX == wRTL && rect.iBr.iX == RtoLLength*wRTL); //Line 2 sl@0: sl@0: //end of 1st line sl@0: rect = iLayout->GetLineRectL(LtoRLength-1, LtoRLength-1); sl@0: RDebug::Print(_L("iTl.iX %d,iY %d, iBr.iX %d,iY %d"), rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY); sl@0: test(rect.iTl.iX == (LtoRLength-1)*wLTR && rect.iBr.iX == LtoRLength*wLTR); //Line 2 sl@0: sl@0: //start of 2nd line sl@0: rect = iLayout->GetLineRectL(LtoRLength, LtoRLength); sl@0: RDebug::Print(_L("iTl.iX %d,iY %d, iBr.iX %d,iY %d"), rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY); sl@0: test(rect.iTl.iX == (RtoLLength-1)*wRTL && rect.iBr.iX == RtoLLength*wRTL); //Line 2 sl@0: sl@0: //1st line to 2nd line sl@0: rect = iLayout->GetLineRectL(LtoRLength-1, LtoRLength); sl@0: RDebug::Print(_L("iTl.iX %d,iY %d, iBr.iX %d,iY %d"), rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY); sl@0: test(rect.iTl.iX == (LtoRLength-1)*wLTR && rect.iBr.iX == LtoRLength*wLTR); //Line 2 sl@0: sl@0: sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-FORM-UT-4007 sl@0: @SYMTestCaseDesc Test for PDEF118443 sl@0: @SYMTestPriority Normal sl@0: @SYMTestActions Use test cases in form of "text + ZWJ + non-text characters", format the line, sl@0: then use CTmTextLayout::FindAdjacentChunks() to find text Chunks surrounding sl@0: the ZWJ. then verify if the text is broken at the correct place. sl@0: @SYMTestExpectedResults CTmTextLayout::FindAdjacentChunks() should return: sl@0: - Left chunk = "text + ZWJ", sl@0: - Right chunk = "non-text characters". sl@0: @SYMDEF PDEF118443 sl@0: */ sl@0: void CTextViewTest::TestForPDEF118443L() sl@0: { sl@0: test.Next(_L(" @SYMTestCaseID:SYSLIB-FORM-UT-4007 Testing fix for PDEF118443 ")); sl@0: InitializeL(); sl@0: sl@0: TCharFormat charFormat = TCharFormat(_L("ClearlyU"),10); sl@0: TCharFormatMask charFormatMask; sl@0: charFormatMask.SetAll(); sl@0: iCharLayer->SetL(charFormat, charFormatMask); sl@0: iEtext->SetGlobalCharFormat(iCharLayer); sl@0: sl@0: // Note: a 'W' is added at the front to make the text chunk have side-bearings, so that it won't be amalgamated sl@0: // with the following chunk. This is to make the test case be as same as the original use case that caused the defect. sl@0: _LIT(KScriptEndWithZWJ,"W\x0931\x094d\x200d"); // Scripte end with ZWJ (a 'W' in the front) sl@0: _LIT(KTextTestCase0,"\x2029"); // Paragraph seperator (Bidi Category: B) sl@0: _LIT(KTextTestCase1,"0"); // Digit 0 (Bidi Category: EN) sl@0: _LIT(KTextTestCase2,"+"); // Plus sign (Bidi Category: ES) sl@0: _LIT(KTextTestCase3,"\u00A3"); // Pound symbol (Bidi Category: ET) sl@0: _LIT(KTextTestCase4,"."); // Period (Bidi Category: CS) sl@0: _LIT(KTextTestCase5,"\x0009"); // Tab (Bidi Category: S) sl@0: _LIT(KTextTestCase6,"\x0020"); // Space (Bidi Category: WS) sl@0: _LIT(KTextTestCase7,"\x000C"); // Form feed (Bidi Category: WS) sl@0: _LIT(KTextTestCase8,"\x2028"); // Line breaker (Bidi Category: WS) sl@0: sl@0: TTmDocPosSpec pos(4, TTmDocPosSpec::ETrailing); sl@0: CTmTextLayout::TTmChunkDescription left; sl@0: CTmTextLayout::TTmChunkDescription right; sl@0: sl@0: // Test case 0: ZWJ + Paragraph seperater sl@0: iEtext->Reset(); sl@0: iEtext->InsertL(0,KScriptEndWithZWJ); sl@0: iEtext->InsertL(iEtext->DocumentLength(),KTextTestCase0); sl@0: iView->FormatTextL(); sl@0: iLayout->TagmaTextLayout().FindAdjacentChunks(pos, left, right); sl@0: test(left.iStart == 0); sl@0: test(left.iEnd == 4); sl@0: test(left.iRightToLeft == EFalse); sl@0: test(right.iStart == 4); sl@0: test(right.iRightToLeft == EFalse); sl@0: sl@0: // Test case 1: ZWJ + Digit '0' sl@0: iEtext->Reset(); sl@0: iEtext->InsertL(0,KScriptEndWithZWJ); sl@0: iEtext->InsertL(iEtext->DocumentLength(),KTextTestCase1); sl@0: iView->FormatTextL(); sl@0: iLayout->TagmaTextLayout().FindAdjacentChunks(pos, left, right); sl@0: test(left.iStart == 0); sl@0: test(left.iEnd == 4); sl@0: test(left.iRightToLeft == EFalse); sl@0: test(right.iStart == 4); sl@0: test(right.iRightToLeft == EFalse); sl@0: sl@0: // Test case 2: ZWJ + Plus sign '+' sl@0: iEtext->Reset(); sl@0: iEtext->InsertL(0,KScriptEndWithZWJ); sl@0: iEtext->InsertL(iEtext->DocumentLength(),KTextTestCase2); sl@0: iView->FormatTextL(); sl@0: iLayout->TagmaTextLayout().FindAdjacentChunks(pos, left, right); sl@0: test(left.iStart == 0); sl@0: test(left.iEnd == 4); sl@0: test(left.iRightToLeft == EFalse); sl@0: test(right.iStart == 4); sl@0: test(right.iRightToLeft == EFalse); sl@0: sl@0: // Test case 3: ZWJ + Pound symbol '??' sl@0: iEtext->Reset(); sl@0: iEtext->InsertL(0,KScriptEndWithZWJ); sl@0: iEtext->InsertL(iEtext->DocumentLength(),KTextTestCase3); sl@0: iView->FormatTextL(); sl@0: iLayout->TagmaTextLayout().FindAdjacentChunks(pos, left, right); sl@0: test(left.iStart == 0); sl@0: test(left.iEnd == 4); sl@0: test(left.iRightToLeft == EFalse); sl@0: test(right.iStart == 4); sl@0: test(right.iRightToLeft == EFalse); sl@0: sl@0: // Test case 0: ZWJ + Period '.' sl@0: iEtext->Reset(); sl@0: iEtext->InsertL(0,KScriptEndWithZWJ); sl@0: iEtext->InsertL(iEtext->DocumentLength(),KTextTestCase4); sl@0: iView->FormatTextL(); sl@0: iLayout->TagmaTextLayout().FindAdjacentChunks(pos, left, right); sl@0: test(left.iStart == 0); sl@0: test(left.iEnd == 4); sl@0: test(left.iRightToLeft == EFalse); sl@0: test(right.iStart == 4); sl@0: test(right.iRightToLeft == EFalse); sl@0: sl@0: // Test case 0: ZWJ + Tab Character sl@0: iEtext->Reset(); sl@0: iEtext->InsertL(0,KScriptEndWithZWJ); sl@0: iEtext->InsertL(iEtext->DocumentLength(),KTextTestCase5); sl@0: iView->FormatTextL(); sl@0: iLayout->TagmaTextLayout().FindAdjacentChunks(pos, left, right); sl@0: test(left.iStart == 0); sl@0: test(left.iEnd == 4); sl@0: test(left.iRightToLeft == EFalse); sl@0: test(right.iStart == 4); sl@0: test(right.iRightToLeft == EFalse); sl@0: sl@0: // Test case 0: ZWJ + Space sl@0: iEtext->Reset(); sl@0: iEtext->InsertL(0,KScriptEndWithZWJ); sl@0: iEtext->InsertL(iEtext->DocumentLength(),KTextTestCase6); sl@0: iView->FormatTextL(); sl@0: iLayout->TagmaTextLayout().FindAdjacentChunks(pos, left, right); sl@0: test(left.iStart == 0); sl@0: test(left.iEnd == 4); sl@0: test(left.iRightToLeft == EFalse); sl@0: test(right.iStart == 4); sl@0: test(right.iRightToLeft == EFalse); sl@0: sl@0: // Test case 0: ZWJ + Form feed sl@0: iEtext->Reset(); sl@0: iEtext->InsertL(0,KScriptEndWithZWJ); sl@0: iEtext->InsertL(iEtext->DocumentLength(),KTextTestCase7); sl@0: iView->FormatTextL(); sl@0: iLayout->TagmaTextLayout().FindAdjacentChunks(pos, left, right); sl@0: test(left.iStart == 0); sl@0: test(left.iEnd == 4); sl@0: test(left.iRightToLeft == EFalse); sl@0: test(right.iStart == 4); sl@0: test(right.iRightToLeft == EFalse); sl@0: sl@0: // Test case 0: ZWJ + Line breaker sl@0: iEtext->Reset(); sl@0: iEtext->InsertL(0,KScriptEndWithZWJ); sl@0: iEtext->InsertL(iEtext->DocumentLength(),KTextTestCase8); sl@0: iView->FormatTextL(); sl@0: iLayout->TagmaTextLayout().FindAdjacentChunks(pos, left, right); sl@0: test(left.iStart == 0); sl@0: test(left.iEnd == 4); sl@0: test(left.iRightToLeft == EFalse); sl@0: test(right.iStart == 4); sl@0: test(right.iRightToLeft == EFalse); sl@0: sl@0: Destroy(); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-FORM-UT-4016 sl@0: @SYMTestCaseDesc Testing the fix for PDEF121798 Printing: Email is printed only two pages sl@0: @SYMTestPriority Medium sl@0: @SYMTestActions Paginates random amounts of text and checks whether the correct number of pages are returned from pagination. sl@0: @SYMTestExpectedResults The amount of pages produced by the paginator should match the expected number of pages based on lines of text, page size, etc. sl@0: @SYMDEF PDEF121798 sl@0: */ sl@0: void CTextViewTest::TestForPDEF121798L() sl@0: { sl@0: test.Next(_L("Testing fix for PDEF121798")); sl@0: CTestScreenDevice* screenDevice = new(ELeave) CTestScreenDevice(iEnv.ScreenDevice(),iWindow); sl@0: sl@0: TMargins margins; sl@0: margins.iTop = 1440; sl@0: margins.iBottom = 1440; sl@0: margins.iLeft = 1440; sl@0: margins.iRight = 1440; sl@0: TSize s(11906,16838); sl@0: TPageSpec p(TPageSpec::EPortrait, s); sl@0: sl@0: // We need to find out the height of lines and print area of the page. sl@0: // From this we determine how many lines *should* appear on the page. sl@0: // This differs between devices(ie. hw and winscw). sl@0: TInt pageHeight = screenDevice->VerticalTwipsToPixels(s.iHeight - margins.iTop - margins.iBottom); sl@0: _LIT(KDummyString,"this is used by dummy paginator to find out line height and page size"); sl@0: InitializeL(); sl@0: AddTextL(KDummyString); sl@0: TInt lineHeight = 0; sl@0: CParaFormat* paraFormat = CParaFormat::NewL(); sl@0: iEtext->GetParagraphFormatL(paraFormat,0); sl@0: TBool pageBreakChar = EFalse; sl@0: TInt docPos = 0; sl@0: iLayout->FormatLineL(paraFormat,docPos,lineHeight,pageBreakChar); sl@0: sl@0: CArrayFixFlat* charsPerPage = new(ELeave) CArrayFixFlat(KGranularity); sl@0: TInt numLines = pageHeight/lineHeight; // Number of lines expected on a page with paginator settings defined above and line height. sl@0: sl@0: sl@0: sl@0: // Perform 50 random pagination tests. sl@0: for(TInt numTests = 0; numTests < 50; numTests++) sl@0: { sl@0: // Generate the number of lines in this document. sl@0: TBuf<512> testString; sl@0: TInt randomNum = (Math::Random() % 512); sl@0: // Calculate the expected number of pages based on page size and line height sl@0: TInt expectedPages = randomNum/numLines; sl@0: // If it's not an exact fit there will be another page lost in the integer division. sl@0: if ((numLines * expectedPages != randomNum) || randomNum == 0) sl@0: { sl@0: ++expectedPages; sl@0: } sl@0: // Append the random number of lines to the test string sl@0: for (TInt i = 0; i < randomNum-1; i++) // randomNum -1 because we add a character after the loop. sl@0: { sl@0: // Empty lines will do. sl@0: testString.Append(CEditableText::EParagraphDelimiter); sl@0: } sl@0: // End the text with a character rather than a paragraph delim. sl@0: testString.Append(_L("A")); sl@0: sl@0: sl@0: InitializeL(); sl@0: AddTextL(testString); sl@0: // Set up the paginator. sl@0: CTextPaginator* paginator = CTextPaginator::NewL(screenDevice, charsPerPage, KPaginatePriority); sl@0: paginator->SetPageMarginsInTwips(margins); sl@0: paginator->SetPageSpecInTwips(p); sl@0: paginator->SetDocumentL(iEtext); sl@0: docPos=0; sl@0: paginator->AppendTextL(docPos); sl@0: TInt numPages=paginator->PaginationCompletedL(); sl@0: RDebug::Printf("%d lines: Expected %d pages, got %d pages", randomNum, expectedPages, numPages); sl@0: test(expectedPages == numPages); sl@0: delete paginator; sl@0: } sl@0: delete charsPerPage; sl@0: delete screenDevice; sl@0: delete paraFormat; sl@0: Destroy(); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-FORM-UT-4015 sl@0: @SYMTestCaseDesc Test for PDEF120239 sl@0: @SYMTestPriority Normal sl@0: @SYMTestActions Use text consist of "LTR text + ZWJ + RTL Text", format the line, then: sl@0: 1) use CTmTextLayout::FindAdjacentChunks() to find chunks around overlapped doc pos. sl@0: 2) use CTextView::MoveCursorL to move cursor through out the line. sl@0: @SYMTestExpectedResults 1) FindAdjacentChunks() returns correct chunks sl@0: 2) Cursor should moves Left to Right and Right to Left correctly sl@0: @SYMDEF PDEF120239 sl@0: */ sl@0: void CTextViewTest::TestForPDEF120239L() sl@0: { sl@0: test.Next(_L("Testing fix for PDEF120239L")); sl@0: InitializeL(); sl@0: sl@0: TCharFormat charFormat = TCharFormat(_L("NewTimes"),10); sl@0: TCharFormatMask charFormatMask; sl@0: charFormatMask.SetAll(); sl@0: iCharLayer->SetL(charFormat, charFormatMask); sl@0: iEtext->SetGlobalCharFormat(iCharLayer); sl@0: sl@0: _LIT(KTestScript,"\x0931\x094d\x200d\x684"); // Test script (LTR text + ZWJ + RTL Text) sl@0: sl@0: iEtext->Reset(); sl@0: iEtext->InsertL(0,KTestScript); sl@0: iView->FormatTextL(); sl@0: sl@0: // 1) use CTmTextLayout::FindAdjacentChunks() sl@0: CTmTextLayout::TTmChunkDescription left; sl@0: CTmTextLayout::TTmChunkDescription right; sl@0: sl@0: TTmDocPosSpec pos(3, TTmDocPosSpec::ETrailing); sl@0: sl@0: iLayout->TagmaTextLayout().FindAdjacentChunks(pos, left, right); sl@0: test(left.iStart == 0); sl@0: test(left.iEnd == 3); sl@0: test(!left.iRightToLeft); sl@0: test(right.iStart == 2); sl@0: test(right.iEnd == 4); sl@0: test(right.iRightToLeft); sl@0: sl@0: pos.iPos = 2; sl@0: pos.iType = TTmDocPosSpec::ELeading; sl@0: sl@0: iLayout->TagmaTextLayout().FindAdjacentChunks(pos, left, right); sl@0: test(left.iStart == 2); sl@0: test(left.iEnd == 4); sl@0: test(left.iRightToLeft); sl@0: test(right.iStart == 4); sl@0: test(right.iEnd == 5); sl@0: test(!right.iRightToLeft); sl@0: sl@0: // 2) use CTextView::MoveCursorL to move cursor sl@0: TTmDocPos cursorPos; sl@0: TTmDocPos targetPos1 (0, ETrue); sl@0: TTmDocPos targetPos2 (0, EFalse); sl@0: TCursorPosition::TMovementType move = TCursorPosition::EFRight; sl@0: sl@0: TCursorSelection selection(0,0); sl@0: iView->SetSelectionL(selection); sl@0: iView->GetCursorPos(cursorPos); sl@0: test(cursorPos == targetPos1 || cursorPos == targetPos2); sl@0: sl@0: targetPos1.iPos = 3; sl@0: targetPos1.iLeadingEdge = EFalse; sl@0: targetPos2.iPos = 4; sl@0: targetPos2.iLeadingEdge = EFalse; sl@0: iView->MoveCursorL(move, EFalse); sl@0: iView->GetCursorPos(cursorPos); sl@0: test(cursorPos == targetPos1 || cursorPos == targetPos2); sl@0: sl@0: targetPos1.iPos = 2; sl@0: targetPos1.iLeadingEdge = ETrue; sl@0: targetPos2.iPos = 4; sl@0: targetPos2.iLeadingEdge = ETrue; sl@0: iView->MoveCursorL(move, EFalse); sl@0: iView->GetCursorPos(cursorPos); sl@0: test(cursorPos == targetPos1 || cursorPos == targetPos2); sl@0: sl@0: move = TCursorPosition::EFLeft; sl@0: sl@0: targetPos1.iPos = 3; sl@0: targetPos1.iLeadingEdge = EFalse; sl@0: targetPos2.iPos = 4; sl@0: targetPos2.iLeadingEdge = EFalse; sl@0: iView->MoveCursorL(move, EFalse); sl@0: iView->GetCursorPos(cursorPos); sl@0: test(cursorPos == targetPos1 || cursorPos == targetPos2); sl@0: sl@0: targetPos1.iPos = 0; sl@0: targetPos1.iLeadingEdge = EFalse; sl@0: targetPos2.iPos = 0; sl@0: targetPos2.iLeadingEdge = ETrue; sl@0: iView->MoveCursorL(move, EFalse); sl@0: iView->GetCursorPos(cursorPos); sl@0: test(cursorPos == targetPos1 || cursorPos == targetPos2); sl@0: sl@0: Destroy(); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-FORM-UT-4021 sl@0: @SYMTestCaseDesc Test for DEF124989, to ensure TFormAndEtextEditor::SetStyleHelperL has no sl@0: NULL-dereference issue. sl@0: @SYMTestPriority Normal sl@0: @SYMTestActions Call TFormAndEtextEditor::InsertTextL and pass in a style name which could sl@0: not be found in styleList.Then a NULL is generated. sl@0: @SYMTestExpectedResults No panic(KERN-EXEC 3) raised from this case. sl@0: @SYMDEF DEF124989 sl@0: */ sl@0: void CTextViewTest::TestForDEF124989L() sl@0: { sl@0: // Initialise CTextViewTest object for next test. sl@0: InitializeL(); sl@0: test.Next(_L(" @SYMTestCaseID:SYSLIB-FORM-UT-4021 Testing fix for DEF124989 ")); sl@0: sl@0: // Insert a one line paragraph into EText object and reformat view. sl@0: _LIT(KTestParagraph, "This is a piece of text to test the character positioning API based in X,Y cocordinates."); sl@0: iEtext->InsertL(0, KTestParagraph); sl@0: sl@0: TFormAndEtextEditor newEditor(*iView,*iEtext); sl@0: sl@0: CStyleList* styleList = CStyleList::NewL(); sl@0: CleanupStack::PushL(styleList); sl@0: RParagraphStyleInfo paraStyleInfo(NULL,NULL); sl@0: sl@0: // Appending the new style to stylelist sl@0: styleList->AppendL(¶StyleInfo); sl@0: iEtext->SetStyleListExternallyOwned(*styleList); sl@0: sl@0: TPtrC ptr1(_L("Arial3")); sl@0: // Inserting the text and applying the style specified(Arial3) sl@0: // which is not in syleList. sl@0: newEditor.InsertTextL(0, _L("Hello World"),&ptr1); sl@0: sl@0: // Clean up test object sl@0: CleanupStack::PopAndDestroy(); sl@0: Destroy(); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-FORM-UT-4022 sl@0: @SYMTestCaseDesc Test for DEF124975 sl@0: @SYMTestPriority Normal sl@0: @SYMTestActions 1) Call CTextLayout::AdjustVerticalAlignment() when there is no content sl@0: 2) Add Some random text and then call CTextLayout::AdjustVerticalAlignment()@SYMTestExpectedResults There should be no panic during the process sl@0: @SYMDEF DEF124975 sl@0: */ sl@0: void CTextViewTest::TestForDEF124975L() sl@0: { sl@0: test.Next(_L(" @SYMTestCaseID: Testing fix for coverity DEF124975 ")); sl@0: InitializeL(); sl@0: sl@0: const TInt MaxTestCount = 50; sl@0: const TInt MaxStringCount = 100; sl@0: TInt TestCount = GetNumber(1, MaxTestCount); sl@0: TInt StringCount = GetNumber(1, MaxStringCount); sl@0: sl@0: for(TInt i=0; iAdjustVerticalAlignment(CParaFormat::ECustomAlign); sl@0: } sl@0: sl@0: for(TInt i=0; iAdjustVerticalAlignment(CParaFormat::ECustomAlign); sl@0: testString.Close(); sl@0: } sl@0: sl@0: Destroy(); sl@0: } sl@0: sl@0: void CTextViewTest::TestForDEF142286BounceScrollingL() sl@0: { sl@0: test.Next(_L(" Testing fix for DEF142286 which supports bounce scrolling feature ")); sl@0: TestScrollDisplayPixelsNoLimitBordersL(10); sl@0: TestScrollDisplayPixelsNoLimitBordersL(50); sl@0: TestScrollDisplayPixelsNoLimitBordersL(100); sl@0: } sl@0: sl@0: void RunTestsL(CCoeEnv& aEnv) sl@0: { sl@0: CTextViewTest* t = new(ELeave) CTextViewTest(aEnv); sl@0: CleanupStack::PushL(t); sl@0: t->ConstructL(); sl@0: t->TestL(); sl@0: t->Test1L(); sl@0: t->TestCancelSelectionL(); sl@0: t->TestFinishBackgroundFormattingL(); sl@0: t->TestSetCursorVisibilityL(); sl@0: t->TestSetSelectionVisibilityL(); sl@0: t->TestEnablePictureFrameL(); sl@0: t->TestSetCursorWidthTypeL(); sl@0: t->TestParagraphRectL(); sl@0: t->TestDrawL(); sl@0: t->TestFormatTextL(); sl@0: t->TestHandleRangeFormatChangeL(); sl@0: t->TestHandleInsertDeleteL(); sl@0: t->TestHandleGlobalChangeL(); sl@0: t->TestHandleGlobalChangeNoRedrawL(); sl@0: t->TestScrollDisplayL(); sl@0: t->TestScrollDisplayPixelsL(); sl@0: t->TestScrollDisplayLinesL(); sl@0: t->TestScrollDisplayParagraphsL(); sl@0: t->TestMoveCursorL(); sl@0: t->TestSetSelectionL(); sl@0: t->TestMatchCursorHeightL(); sl@0: t->TestCalculateHorizontalExtremesL(); sl@0: t->TestXyPosToDocPosL(); sl@0: t->TestGetPictureRectangleL(); sl@0: t->TestGetPictureRectangle1L(); sl@0: //t->TestGetPictureRectangleDefectL(); sl@0: t->TestSetDisplayContextL(); sl@0: t->TestGetParaFormatL(); sl@0: t->TestGetLineRectL(); sl@0: t->TestForDEF003426L(); sl@0: t->TestForDEF038488L(); sl@0: t->FormAndEtextTestL(); sl@0: t->TestForINC092725L(); sl@0: t->TestForPDEF108443L(); sl@0: t->TestForPDEF113755L(); sl@0: t->TestForPDEF115165L(); sl@0: t->TestForPDEF118443L(); sl@0: t->TestForPDEF121798L(); sl@0: t->TestForDEF124989L(); sl@0: t->TestForPDEF120239L(); sl@0: t->TestForDEF124975L(); sl@0: t->TestForDEF142286BounceScrollingL(); sl@0: CleanupStack::PopAndDestroy(t); sl@0: } sl@0: sl@0: TInt E32Main() sl@0: { sl@0: CCoeEnv* env=new CCoeEnv; sl@0: TRAPD(err, sl@0: env->ConstructL(); sl@0: RunTestsL(*env); sl@0: ); sl@0: return err; sl@0: } sl@0: sl@0: #if defined(__WINS__) sl@0: EXPORT_C TInt EntryPoint(TAny*) {return E32Main();} sl@0: #endif