textrendering/textformatting/test/src/TTagmaImp.cpp
branchRCL_3
changeset 55 336bee5c2d35
parent 54 748ec5531811
equal deleted inserted replaced
54:748ec5531811 55:336bee5c2d35
     1 /*
     1 /*
     2 * Copyright (c) 2001-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    27 #include "TMSTD.H"
    27 #include "TMSTD.H"
    28 #include "TmLayoutImp.h"
    28 #include "TmLayoutImp.h"
    29 #include "TMINTERP.H"
    29 #include "TMINTERP.H"
    30 #include "TmText.h"
    30 #include "TmText.h"
    31 #include "InlineText.h"
    31 #include "InlineText.h"
    32 #include "ttagmaimp.h"
    32 
    33 
    33 namespace LocalToFile
    34 namespace LocalToTTagmaImp
       
    35 {
    34 {
    36 enum TTagmaImpPanic { EAccessOutsideText = 1 };
    35 enum TTagmaImpPanic { EAccessOutsideText = 1 };
    37 void Panic(TTagmaImpPanic)
    36 void Panic(TTagmaImpPanic)
    38 	{
    37 	{
    39 	User::Panic(_L("TTagmaImp"), EAccessOutsideText);
    38 	User::Panic(_L("TTagmaImp"), EAccessOutsideText);
    40 	}
    39 	}
    41 
    40 RTest test(_L("Tagma internals tests"));
    42 CTTagmaImpStep* TestStep = NULL;
       
    43 #define TESTPOINT(p) TestStep->testpoint(p,(TText8*)__FILE__,__LINE__)
       
    44 #define TESTPRINT(p) TestStep->print(p,(TText8*)__FILE__,__LINE__)
       
    45 
    41 
    46 const TInt KPictureCharacter = 0xFFFC;
    42 const TInt KPictureCharacter = 0xFFFC;
    47 
    43 
    48 class CPinkSquare : public CPicture
    44 class CPinkSquare : public CPicture
    49 	{
    45 	{
   148 
   144 
   149 class THandleTester
   145 class THandleTester
   150 	{
   146 	{
   151 	TInt iProcessHandles;
   147 	TInt iProcessHandles;
   152 	TInt iThreadHandles;
   148 	TInt iThreadHandles;
       
   149 	RTest& iTest;
   153 public:
   150 public:
   154 	THandleTester()
   151 	THandleTester(RTest& rt) : iTest(rt)
   155 		{
   152 		{
   156 		RThread().HandleCount(iProcessHandles, iThreadHandles);
   153 		RThread().HandleCount(iProcessHandles, iThreadHandles);
   157 		}
   154 		}
   158 	~THandleTester()
   155 	~THandleTester()
   159 		{
   156 		{
   160 		TInt p;
   157 		TInt p;
   161 		TInt t;
   158 		TInt t;
   162 		RThread().HandleCount(p, t);
   159 		RThread().HandleCount(p, t);
   163 // this seems to break at random...
   160 // this seems to break at random...
   164 //		TestStep->test(p == iProcessHandles);
   161 //		iTest(p == iProcessHandles);
   165 		TESTPOINT(t == iThreadHandles);
   162 		iTest(t == iThreadHandles);
   166 		}
   163 		}
   167 	};
   164 	};
   168 
   165 
   169 class CFallableDeviceMap : public CBase, public MGraphicsDeviceMap
   166 class CFallableDeviceMap : public CBase, public MGraphicsDeviceMap
   170 	{
   167 	{
   283 		return 0;
   280 		return 0;
   284 		}
   281 		}
   285 	};
   282 	};
   286 
   283 
   287 }
   284 }
   288 using namespace LocalToTTagmaImp;
   285 using namespace LocalToFile;
   289 
   286 
   290 
   287 
   291 class CTagmaImpTest : public CBase
   288 class CTagmaImpTest : public CBase
   292 	{
   289 	{
   293 public:
   290 public:
   294 	CTagmaImpTest(CTTagmaImpStep* aStep) : iDevice(0), iGc(0)
   291 	CTagmaImpTest() : iDevice(0), iGc(0)
   295 		{
   292 		{
   296         TestStep = aStep;
       
   297 		}
   293 		}
   298 	void ConstructL()
   294 	void ConstructL()
   299 		{
   295 		{
   300 		TSize size(100, 100);
   296 		TSize size(100, 100);
   301 		iDevice = CTestGraphicsDevice::NewL(size, 0);
   297 		iDevice = CTestGraphicsDevice::NewL(size, 0);
   353 		{
   349 		{
   354 		TUint8 byte = reader.ReadByte();
   350 		TUint8 byte = reader.ReadByte();
   355 		TInt num = reader.ReadNumber();
   351 		TInt num = reader.ReadNumber();
   356 		TRect rect = reader.ReadRect();
   352 		TRect rect = reader.ReadRect();
   357 		TRect testRect(aStartValue + 2, aStartValue + 3, aStartValue + 4, aStartValue + 5);
   353 		TRect testRect(aStartValue + 2, aStartValue + 3, aStartValue + 4, aStartValue + 5);
   358 		TESTPOINT(byte == static_cast<TUint8>(aStartValue));
   354 		test(byte == static_cast<TUint8>(aStartValue));
   359 		TESTPOINT(num == aStartValue + 1);
   355 		test(num == aStartValue + 1);
   360 		TESTPOINT(rect == testRect);
   356 		test(rect == testRect);
   361 		}
   357 		}
   362 	return reader.CodePos();
   358 	return reader.CodePos();
   363 	}
   359 	}
   364 
   360 
   365 void CTagmaImpTest::AddSome1L(CTmCode& aCode, TInt aStartValue)
   361 void CTagmaImpTest::AddSome1L(CTmCode& aCode, TInt aStartValue)
   428 	CheckLots(*code, size1, 0, count4);
   424 	CheckLots(*code, size1, 0, count4);
   429 	CheckLots(*code, size1 + size4, 0, count2);
   425 	CheckLots(*code, size1 + size4, 0, count2);
   430 	code->Delete(size1, size4);
   426 	code->Delete(size1, size4);
   431 	CheckLots(*code, 0, 0, count1);
   427 	CheckLots(*code, 0, 0, count1);
   432 	CheckLots(*code, size1, 0, count2);
   428 	CheckLots(*code, size1, 0, count2);
   433 	TESTPOINT(code2->Size() == 0);
   429 	test(code2->Size() == 0);
   434 	CleanupStack::PopAndDestroy(code2);
   430 	CleanupStack::PopAndDestroy(code2);
   435 	CleanupStack::PopAndDestroy(code);
   431 	CleanupStack::PopAndDestroy(code);
   436 	}
   432 	}
   437 
   433 
   438 void CTagmaImpTest::CTmCodeOOML()
   434 void CTagmaImpTest::CTmCodeOOML()
   439 	{
   435 	{
   440 	ExerciseCTmCodeL();
   436 	ExerciseCTmCodeL();
   441 	TInt err;
   437 	TInt err;
   442 	TInt failAt = 1;
   438 	TInt failAt = 1;
   443 	do {
   439 	do {
   444 		THandleTester h();
   440 		THandleTester h(test);
   445 
   441 
   446 		__UHEAP_MARK;
   442 		__UHEAP_MARK;
   447 		__UHEAP_SETFAIL(RHeap::EDeterministic, failAt);
   443 		__UHEAP_SETFAIL(RHeap::EDeterministic, failAt);
   448 		TRAP(err, ExerciseCTmCodeL());
   444 		TRAP(err, ExerciseCTmCodeL());
   449 		__UHEAP_SETFAIL(RHeap::ENone, 0);
   445 		__UHEAP_SETFAIL(RHeap::ENone, 0);
   450 		__UHEAP_MARKENDC(0);
   446 		__UHEAP_MARKENDC(0);
   451 
   447 
   452 		++failAt;
   448 		++failAt;
   453 		} while (err == KErrNoMemory);
   449 		} while (err == KErrNoMemory);
   454 	TESTPOINT(err == KErrNone);
   450 	test(err == KErrNone);
   455 	}
   451 	}
   456 
   452 
   457 CTestSource* CTagmaImpTest::NewTestSourceLC()
   453 CTestSource* CTagmaImpTest::NewTestSourceLC()
   458 	{
   454 	{
   459 	_LIT(KTestText, "Some text for you to format for me.\x2029");
   455 	_LIT(KTestText, "Some text for you to format for me.\x2029");
   499 	// dry run- this will help the typeface store to settle down.
   495 	// dry run- this will help the typeface store to settle down.
   500 	ExerciseFormatL();
   496 	ExerciseFormatL();
   501 	TInt err;
   497 	TInt err;
   502 	TInt failAt = 1;
   498 	TInt failAt = 1;
   503 	do {
   499 	do {
   504 		THandleTester h();
   500 		THandleTester h(test);
   505 
   501 
   506 		__UHEAP_MARK;
   502 		__UHEAP_MARK;
   507 		__UHEAP_SETFAIL(RHeap::EDeterministic, failAt);
   503 		__UHEAP_SETFAIL(RHeap::EDeterministic, failAt);
   508 		TRAP(err, ExerciseFormatL());
   504 		TRAP(err, ExerciseFormatL());
   509 		__UHEAP_SETFAIL(RHeap::ENone, 0);
   505 		__UHEAP_SETFAIL(RHeap::ENone, 0);
   510 		__UHEAP_MARKENDC(0);
   506 		__UHEAP_MARKENDC(0);
   511 
   507 
   512 		++failAt;
   508 		++failAt;
   513 		} while (err == KErrNoMemory);
   509 		} while (err == KErrNoMemory);
   514 	TESTPOINT(err == KErrNone);
   510 	test(err == KErrNone);
   515 	}
   511 	}
   516 
   512 
   517 void CTagmaImpTest::ExerciseRTmTextCacheWidthL()
   513 void CTagmaImpTest::ExerciseRTmTextCacheWidthL()
   518 	{
   514 	{
   519 	_LIT(KOnions, "How easily happiness starts, slicing onions.\x2029");
   515 	_LIT(KOnions, "How easily happiness starts, slicing onions.\x2029");
   534 void CTagmaImpTest::RTmTextCacheWidthOOM()
   530 void CTagmaImpTest::RTmTextCacheWidthOOM()
   535 	{
   531 	{
   536 	TInt err;
   532 	TInt err;
   537 	TInt failAt = 1;
   533 	TInt failAt = 1;
   538 	do {
   534 	do {
   539 		THandleTester h();
   535 		THandleTester h(test);
   540 
   536 
   541 		__UHEAP_MARK;
   537 		__UHEAP_MARK;
   542 		__UHEAP_SETFAIL(RHeap::EDeterministic, failAt);
   538 		__UHEAP_SETFAIL(RHeap::EDeterministic, failAt);
   543 		TRAP(err, ExerciseRTmTextCacheWidthL());
   539 		TRAP(err, ExerciseRTmTextCacheWidthL());
   544 		__UHEAP_SETFAIL(RHeap::ENone, 0);
   540 		__UHEAP_SETFAIL(RHeap::ENone, 0);
   545 		__UHEAP_MARKENDC(0);
   541 		__UHEAP_MARKENDC(0);
   546 
   542 
   547 		++failAt;
   543 		++failAt;
   548 		} while (err == KErrNoMemory);
   544 		} while (err == KErrNoMemory);
   549 	TESTPOINT(err == KErrNone);
   545 	test(err == KErrNone);
   550 	}
   546 	}
   551 
   547 
   552 void CTagmaImpTest::ExerciseRTmGeneralInterpreterGetDisplayedTextL()
   548 void CTagmaImpTest::ExerciseRTmGeneralInterpreterGetDisplayedTextL()
   553 	{
   549 	{
   554 	CTestSource* source = NewTestSourceLC();
   550 	CTestSource* source = NewTestSourceLC();
   575 void CTagmaImpTest::RTmGeneralInterpreterGetDisplayedTextOOM()
   571 void CTagmaImpTest::RTmGeneralInterpreterGetDisplayedTextOOM()
   576 	{
   572 	{
   577 	TInt err;
   573 	TInt err;
   578 	TInt failAt = 1;
   574 	TInt failAt = 1;
   579 	do {
   575 	do {
   580 		THandleTester h();
   576 		THandleTester h(test);
   581 
   577 
   582 		__UHEAP_MARK;
   578 		__UHEAP_MARK;
   583 		__UHEAP_SETFAIL(RHeap::EDeterministic, failAt);
   579 		__UHEAP_SETFAIL(RHeap::EDeterministic, failAt);
   584 		TRAP(err, ExerciseRTmGeneralInterpreterGetDisplayedTextL());
   580 		TRAP(err, ExerciseRTmGeneralInterpreterGetDisplayedTextL());
   585 		__UHEAP_SETFAIL(RHeap::ENone, 0);
   581 		__UHEAP_SETFAIL(RHeap::ENone, 0);
   586 		__UHEAP_MARKENDC(0);
   582 		__UHEAP_MARKENDC(0);
   587 
   583 
   588 		++failAt;
   584 		++failAt;
   589 		} while (err == KErrNoMemory);
   585 		} while (err == KErrNoMemory);
   590 	TESTPOINT(err == KErrNone);
   586 	test(err == KErrNone);
   591 	}
   587 	}
   592 
   588 
   593 void CTagmaImpTest::WEP_55BHBF_DefectL()
   589 void CTagmaImpTest::WEP_55BHBF_DefectL()
   594 	{
   590 	{
   595 	__UHEAP_MARK;
   591 	__UHEAP_MARK;
   641 	CleanupStack::PushL(layout);
   637 	CleanupStack::PushL(layout);
   642 	CTmFormatContext::FormatL(*source, formatParam, *code, info, layout);
   638 	CTmFormatContext::FormatL(*source, formatParam, *code, info, layout);
   643 
   639 
   644 	// check that format has found the break at 11 characters
   640 	// check that format has found the break at 11 characters
   645 	// This is at the end of "this is a "
   641 	// This is at the end of "this is a "
   646 	TESTPOINT(info.iFirstLineEndChar == 11 );
   642 	test( info.iFirstLineEndChar == 11 );
   647 
   643 
   648 	// get the text that would be displayed into displayBuffer
   644 	// get the text that would be displayed into displayBuffer
   649 	TTmInterpreterParam interpreter_param(*code);
   645 	TTmInterpreterParam interpreter_param(*code);
   650 	interpreter_param.iCodeStart = 0;
   646 	interpreter_param.iCodeStart = 0;
   651 	interpreter_param.iCodeEnd = code->Size();
   647 	interpreter_param.iCodeEnd = code->Size();
   658 
   654 
   659 	// now check the content of the buffer returned
   655 	// now check the content of the buffer returned
   660 	// The defect caused this buffer to be missing the final 'a'
   656 	// The defect caused this buffer to be missing the final 'a'
   661 	// from "...this is a" at the end of the line
   657 	// from "...this is a" at the end of the line
   662 	// When this defect happens noCharsToDisplay != info.iFirstLineEndChar
   658 	// When this defect happens noCharsToDisplay != info.iFirstLineEndChar
   663 	TESTPOINT( info.iFirstLineEndChar == noCharsToDisplay );
   659 	test( info.iFirstLineEndChar == noCharsToDisplay );
   664 	TESTPOINT( displayBuffer[9] == 'a' );
   660 	test( displayBuffer[9] == 'a' );
   665 
   661 
   666 	interpreter.Close();
   662 	interpreter.Close();
   667 	CleanupStack::PopAndDestroy(layout);
   663 	CleanupStack::PopAndDestroy(layout);
   668 	CleanupStack::PopAndDestroy(code);   // code 
   664 	CleanupStack::PopAndDestroy(code);   // code 
   669 	CleanupStack::PopAndDestroy(source); // source
   665 	CleanupStack::PopAndDestroy(source); // source
   704 	CTmTextLayout* layout = new(ELeave) CTmTextLayout;
   700 	CTmTextLayout* layout = new(ELeave) CTmTextLayout;
   705 	CleanupStack::PushL(layout);
   701 	CleanupStack::PushL(layout);
   706 	CTmFormatContext::FormatL(*source1, formatParam1, *code, info1, layout);
   702 	CTmFormatContext::FormatL(*source1, formatParam1, *code, info1, layout);
   707 
   703 
   708 	// check that format didn't found any breaks
   704 	// check that format didn't found any breaks
   709 	TESTPOINT( info1.iFirstLineEndChar == KTest1().Length());
   705 	test( info1.iFirstLineEndChar == KTest1().Length());
   710 	TESTPOINT( info1.iLastLineStartChar == 0 );
   706 	test( info1.iLastLineStartChar == 0 );
   711 	TESTPOINT( info1.iHeight == 12 ); // just 1 line
   707 	test( info1.iHeight == 12 ); // just 1 line
   712 
   708 
   713 
   709 
   714 
   710 
   715 	// 2. now append more than one space and verify that the line is not broken
   711 	// 2. now append more than one space and verify that the line is not broken
   716 	CTestSource* source2 = NewTestSourceLC();
   712 	CTestSource* source2 = NewTestSourceLC();
   729 	formatParam2.iFlags = TTmFormatParam::EWrap;
   725 	formatParam2.iFlags = TTmFormatParam::EWrap;
   730 	formatParam2.iWrapWidth = 520;
   726 	formatParam2.iWrapWidth = 520;
   731 	CTmFormatContext::FormatL(*source2, formatParam2, *code, info2, layout);
   727 	CTmFormatContext::FormatL(*source2, formatParam2, *code, info2, layout);
   732 
   728 
   733 	// check that format didn't found any breaks
   729 	// check that format didn't found any breaks
   734 	TESTPOINT( info2.iFirstLineEndChar == KTest2().Length());
   730 	test( info2.iFirstLineEndChar == KTest2().Length());
   735 	TESTPOINT( info2.iLastLineStartChar == 0 );
   731 	test( info2.iLastLineStartChar == 0 );
   736 	TESTPOINT( info2.iHeight == 12 ); // just 1 line
   732 	test( info2.iHeight == 12 ); // just 1 line
   737 
   733 
   738 
   734 
   739 
   735 
   740 	// 3. now test with page breaks (0x000C) and line breaks (0x2028)
   736 	// 3. now test with page breaks (0x000C) and line breaks (0x2028)
   741 	CTestSource* source3 = NewTestSourceLC();
   737 	CTestSource* source3 = NewTestSourceLC();
   754 	formatParam3.iFlags = TTmFormatParam::EWrap;
   750 	formatParam3.iFlags = TTmFormatParam::EWrap;
   755 	formatParam3.iWrapWidth = 520;
   751 	formatParam3.iWrapWidth = 520;
   756 	CTmFormatContext::FormatL(*source3, formatParam3, *code, info3, layout);
   752 	CTmFormatContext::FormatL(*source3, formatParam3, *code, info3, layout);
   757 
   753 
   758 	// check that format didn't found any breaks
   754 	// check that format didn't found any breaks
   759 	TESTPOINT( info3.iFirstLineEndChar == 54 );
   755 	test( info3.iFirstLineEndChar == 54 );
   760 	TESTPOINT( info3.iLastLineStartChar == 108 );
   756 	test( info3.iLastLineStartChar == 108 );
   761 	TESTPOINT( info3.iHeight == 36 ); // 3 lines
   757 	test( info3.iHeight == 36 ); // 3 lines
   762 
   758 
   763 	CleanupStack::PopAndDestroy(source3);
   759 	CleanupStack::PopAndDestroy(source3);
   764 	CleanupStack::PopAndDestroy(source2);
   760 	CleanupStack::PopAndDestroy(source2);
   765 	CleanupStack::PopAndDestroy(layout); 
   761 	CleanupStack::PopAndDestroy(layout); 
   766 	CleanupStack::PopAndDestroy(source1);
   762 	CleanupStack::PopAndDestroy(source1);
   897 	RTmParFormat pft;
   893 	RTmParFormat pft;
   898 	CleanupClosePushL(pft);
   894 	CleanupClosePushL(pft);
   899 
   895 
   900 	text->GetText(0, testText, cft);
   896 	text->GetText(0, testText, cft);
   901 	text->GetParagraphFormatL(0, pft);
   897 	text->GetParagraphFormatL(0, pft);
   902 	TESTPOINT(testText.Length() == 14);
   898 	test(testText.Length() == 14);
   903 	TESTPOINT(testText.Compare(_L("first line\x2029sec")) == 0);
   899 	test(testText.Compare(_L("first line\x2029sec")) == 0);
   904 	TESTPOINT(cft == cf1);
   900 	test(cft == cf1);
   905 	TESTPOINT(pft == pf1);
   901 	test(pft == pf1);
   906 
   902 
   907 	text->GetText(11, testText, cft);
   903 	text->GetText(11, testText, cft);
   908 	text->GetParagraphFormatL(11, pft);
   904 	text->GetParagraphFormatL(11, pft);
   909 	TESTPOINT(testText.Length() == 3);
   905 	test(testText.Length() == 3);
   910 	TESTPOINT(testText.Compare(_L("sec")) == 0);
   906 	test(testText.Compare(_L("sec")) == 0);
   911 	TESTPOINT(cft == cf1);
   907 	test(cft == cf1);
   912 	TESTPOINT(pft == pf2);
   908 	test(pft == pf2);
   913 
   909 
   914 	text->GetText(14, testText, cft);
   910 	text->GetText(14, testText, cft);
   915 	text->GetParagraphFormatL(14, pft);
   911 	text->GetParagraphFormatL(14, pft);
   916 	TESTPOINT(testText.Length() == 3);
   912 	test(testText.Length() == 3);
   917 	TESTPOINT(testText.Compare(_L("t p")) == 0);
   913 	test(testText.Compare(_L("t p")) == 0);
   918 	TESTPOINT(cft == cf2);
   914 	test(cft == cf2);
   919 	TESTPOINT(pft == pf2);
   915 	test(pft == pf2);
   920 
   916 
   921 	text->GetText(17, testText, cft);
   917 	text->GetText(17, testText, cft);
   922 	text->GetParagraphFormatL(17, pft);
   918 	text->GetParagraphFormatL(17, pft);
   923 	TESTPOINT(cft == cf1);
   919 	test(cft == cf1);
   924 	TESTPOINT(pft == pf2);
   920 	test(pft == pf2);
   925 
   921 
   926 	text->GetText(21, testText, cft);
   922 	text->GetText(21, testText, cft);
   927 	text->GetParagraphFormatL(21, pft);
   923 	text->GetParagraphFormatL(21, pft);
   928 	TESTPOINT(pft == pf2);
   924 	test(pft == pf2);
   929 	CleanupStack::PopAndDestroy(&pft);
   925 	CleanupStack::PopAndDestroy(&pft);
   930 	CleanupStack::PopAndDestroy(&pf2);
   926 	CleanupStack::PopAndDestroy(&pf2);
   931 	CleanupStack::PopAndDestroy(&pf1);
   927 	CleanupStack::PopAndDestroy(&pf1);
   932 	CleanupStack::PopAndDestroy(text);
   928 	CleanupStack::PopAndDestroy(text);
   933 	}
   929 	}
   934 
   930 
   935 void CTagmaImpTest::GetIndices(TDes8& aBuf, const CTmTextImp::RRunArray& aRunArray)
   931 void CTagmaImpTest::GetIndices(TDes8& aBuf, const CTmTextImp::RRunArray& aRunArray)
   936 	{
   932 	{
   937     TESTPOINT(aRunArray.Index(0) == aRunArray.Index(1));
   933 	test(aRunArray.Index(0) == aRunArray.Index(1));
   938 	aBuf.Zero();
   934 	aBuf.Zero();
   939 	TInt index;
   935 	TInt index;
   940 	for (TInt i = 1; 0 <= (index = aRunArray.Index(i)); ++i)
   936 	for (TInt i = 1; 0 <= (index = aRunArray.Index(i)); ++i)
   941 		{
   937 		{
   942 		aBuf.Append('0' + index);
   938 		aBuf.Append('0' + index);
   964 	pf1.iSpaceAbove = 1;
   960 	pf1.iSpaceAbove = 1;
   965 	text->InsertL(0, _L("Some text"), &cf1, &pf1, 0, 0);
   961 	text->InsertL(0, _L("Some text"), &cf1, &pf1, 0, 0);
   966 
   962 
   967 	TInt memUsed = text->MemoryUsed();
   963 	TInt memUsed = text->MemoryUsed();
   968 	text->ChangeFormatL(formatParam);
   964 	text->ChangeFormatL(formatParam);
   969 	TESTPOINT(text->MemoryUsed()==memUsed);
   965 	test(text->MemoryUsed()==memUsed);
   970 
   966 
   971 	TTmFormatParam formatParam1;
   967 	TTmFormatParam formatParam1;
   972 	formatParam1.iStartChar = 0;
   968 	formatParam1.iStartChar = 0;
   973 	formatParam1.iEndChar = 15;
   969 	formatParam1.iEndChar = 15;
   974 	formatParam1.iLineInPar = 0;
   970 	formatParam1.iLineInPar = 0;
   977 	formatParam1.iMaxLines = KMaxTInt;
   973 	formatParam1.iMaxLines = KMaxTInt;
   978 	formatParam1.iFlags = TTmFormatParam::EWrap;
   974 	formatParam1.iFlags = TTmFormatParam::EWrap;
   979 	//Setting the format of the text
   975 	//Setting the format of the text
   980 	text->ChangeFormatL(formatParam1);
   976 	text->ChangeFormatL(formatParam1);
   981 	//After changing the format, memory used by the text differs from the initial value
   977 	//After changing the format, memory used by the text differs from the initial value
   982 	TESTPOINT(text->MemoryUsed()!=memUsed);
   978 	test(text->MemoryUsed()!=memUsed);
   983 	TRgb color1(100,10,20);
   979 	TRgb color1(100,10,20);
   984 	TRgb color2;
   980 	TRgb color2;
   985 	//Setting the system colour with an index representing the system background colour
   981 	//Setting the system colour with an index representing the system background colour
   986 	color2 = text->SystemColor(TLogicalRgb::ESystemBackgroundIndex,color1);
   982 	color2 = text->SystemColor(TLogicalRgb::ESystemBackgroundIndex,color1);
   987 	TESTPOINT(color2==color1);
   983 	test(color2==color1);
   988 
   984 
   989 	_LIT(KBody, "Body");
   985 	_LIT(KBody, "Body");
   990 	_LIT(KLabel, "Label, Longer than Body");
   986 	_LIT(KLabel, "Label, Longer than Body");
   991 	TTestParLabelSource sourceLabel(iDevice, KBody, KLabel);
   987 	TTestParLabelSource sourceLabel(iDevice, KBody, KLabel);
   992 	CTmTextLayout* iLayout = new (ELeave) CTmTextLayout;
   988 	CTmTextLayout* iLayout = new (ELeave) CTmTextLayout;
   994 	//Changing the custom formatting
   990 	//Changing the custom formatting
   995 	text->CustomizeL(iLayout->Source());
   991 	text->CustomizeL(iLayout->Source());
   996 
   992 
   997 	//Setting the system colour with an index representing the system foreground colour
   993 	//Setting the system colour with an index representing the system foreground colour
   998 	color2 = text->SystemColor(TLogicalRgb::ESystemSelectionForegroundIndex,color1);
   994 	color2 = text->SystemColor(TLogicalRgb::ESystemSelectionForegroundIndex,color1);
   999 	TESTPOINT(color2!=color1);
   995 	test(color2!=color1);
  1000 	CleanupStack::PopAndDestroy(&pf1);
   996 	CleanupStack::PopAndDestroy(&pf1);
  1001 	CleanupStack::PopAndDestroy(text);
   997 	CleanupStack::PopAndDestroy(text);
  1002 	}
   998 	}
  1003 
   999 
  1004 void CTagmaImpTest::CTmTextImp_RRunArrayL()
  1000 void CTagmaImpTest::CTmTextImp_RRunArrayL()
  1005 	{
  1001 	{
  1006 	TBuf8<50> indexBuf;
  1002 	TBuf8<50> indexBuf;
  1007 	CTmTextImp::RRunArray ra;
  1003 	CTmTextImp::RRunArray ra;
  1008 	CleanupClosePushL(ra);
  1004 	CleanupClosePushL(ra);
  1009 	GetIndices(indexBuf, ra);
  1005 	GetIndices(indexBuf, ra);
  1010 	TESTPOINT(0 == indexBuf.Compare(_L8("")));
  1006 	test(0 == indexBuf.Compare(_L8("")));
  1011 	ra.Insert(0, 10, 0);
  1007 	ra.Insert(0, 10, 0);
  1012 	GetIndices(indexBuf, ra);
  1008 	GetIndices(indexBuf, ra);
  1013 	TESTPOINT(0 == indexBuf.Compare(_L8("0000000000")));
  1009 	test(0 == indexBuf.Compare(_L8("0000000000")));
  1014 	ra.Insert(5, 10, 1);
  1010 	ra.Insert(5, 10, 1);
  1015 	GetIndices(indexBuf, ra);
  1011 	GetIndices(indexBuf, ra);
  1016 	TESTPOINT(0 == indexBuf.Compare(_L8("00000111111111100000")));
  1012 	test(0 == indexBuf.Compare(_L8("00000111111111100000")));
  1017 	ra.Delete(13, 4);
  1013 	ra.Delete(13, 4);
  1018 	GetIndices(indexBuf, ra);
  1014 	GetIndices(indexBuf, ra);
  1019 	TESTPOINT(0 == indexBuf.Compare(_L8("0000011111111000")));
  1015 	test(0 == indexBuf.Compare(_L8("0000011111111000")));
  1020 	ra.Delete(2, 12);
  1016 	ra.Delete(2, 12);
  1021 	GetIndices(indexBuf, ra);
  1017 	GetIndices(indexBuf, ra);
  1022 	TESTPOINT(0 == indexBuf.Compare(_L8("0000")));
  1018 	test(0 == indexBuf.Compare(_L8("0000")));
  1023 	ra.Delete(0, 4);
  1019 	ra.Delete(0, 4);
  1024 	GetIndices(indexBuf, ra);
  1020 	GetIndices(indexBuf, ra);
  1025 	TESTPOINT(0 == indexBuf.Compare(_L8("")));
  1021 	test(0 == indexBuf.Compare(_L8("")));
  1026 	ra.Insert(0, 20, 0);
  1022 	ra.Insert(0, 20, 0);
  1027 	ra.Set(5, 10, 1);
  1023 	ra.Set(5, 10, 1);
  1028 	GetIndices(indexBuf, ra);
  1024 	GetIndices(indexBuf, ra);
  1029 	TESTPOINT(0 == indexBuf.Compare(_L8("00000111111111100000")));
  1025 	test(0 == indexBuf.Compare(_L8("00000111111111100000")));
  1030 	ra.Set(6, 4, 2);
  1026 	ra.Set(6, 4, 2);
  1031 	GetIndices(indexBuf, ra);
  1027 	GetIndices(indexBuf, ra);
  1032 	TESTPOINT(0 == indexBuf.Compare(_L8("00000122221111100000")));
  1028 	test(0 == indexBuf.Compare(_L8("00000122221111100000")));
  1033 	ra.Set(10, 4, 3);
  1029 	ra.Set(10, 4, 3);
  1034 	GetIndices(indexBuf, ra);
  1030 	GetIndices(indexBuf, ra);
  1035 	TESTPOINT(0 == indexBuf.Compare(_L8("00000122223333100000")));
  1031 	test(0 == indexBuf.Compare(_L8("00000122223333100000")));
  1036 	ra.Set(9, 2, 1);
  1032 	ra.Set(9, 2, 1);
  1037 	GetIndices(indexBuf, ra);
  1033 	GetIndices(indexBuf, ra);
  1038 	TESTPOINT(0 == indexBuf.Compare(_L8("00000122211333100000")));
  1034 	test(0 == indexBuf.Compare(_L8("00000122211333100000")));
  1039 	ra.Set(6, 1, 1);
  1035 	ra.Set(6, 1, 1);
  1040 	GetIndices(indexBuf, ra);
  1036 	GetIndices(indexBuf, ra);
  1041 	TESTPOINT(0 == indexBuf.Compare(_L8("00000112211333100000")));
  1037 	test(0 == indexBuf.Compare(_L8("00000112211333100000")));
  1042 	ra.Set(8, 1, 1);
  1038 	ra.Set(8, 1, 1);
  1043 	GetIndices(indexBuf, ra);
  1039 	GetIndices(indexBuf, ra);
  1044 	TESTPOINT(0 == indexBuf.Compare(_L8("00000112111333100000")));
  1040 	test(0 == indexBuf.Compare(_L8("00000112111333100000")));
  1045 	ra.Set(7, 1, 1);
  1041 	ra.Set(7, 1, 1);
  1046 	GetIndices(indexBuf, ra);
  1042 	GetIndices(indexBuf, ra);
  1047 	TESTPOINT(0 == indexBuf.Compare(_L8("00000111111333100000")));
  1043 	test(0 == indexBuf.Compare(_L8("00000111111333100000")));
  1048 	ra.Set(7, 2, 2);
  1044 	ra.Set(7, 2, 2);
  1049 	GetIndices(indexBuf, ra);
  1045 	GetIndices(indexBuf, ra);
  1050 	TESTPOINT(0 == indexBuf.Compare(_L8("00000112211333100000")));
  1046 	test(0 == indexBuf.Compare(_L8("00000112211333100000")));
  1051 	ra.Set(1, 19, 1);
  1047 	ra.Set(1, 19, 1);
  1052 	GetIndices(indexBuf, ra);
  1048 	GetIndices(indexBuf, ra);
  1053 	TESTPOINT(0 == indexBuf.Compare(_L8("01111111111111111111")));
  1049 	test(0 == indexBuf.Compare(_L8("01111111111111111111")));
  1054 	CleanupStack::PopAndDestroy(&ra);
  1050 	CleanupStack::PopAndDestroy(&ra);
  1055 	}
  1051 	}
  1056 
  1052 
  1057 
  1053 
  1058 void CTagmaImpTest::CTmTextImp_BidirectionalAlignmentL()
  1054 void CTagmaImpTest::CTmTextImp_BidirectionalAlignmentL()
  1065 	{
  1061 	{
  1066 	CParaFormat* pF = CParaFormat::NewL();
  1062 	CParaFormat* pF = CParaFormat::NewL();
  1067 	CleanupStack::PushL(pF);
  1063 	CleanupStack::PushL(pF);
  1068 	RTmParFormat rPF;
  1064 	RTmParFormat rPF;
  1069 
  1065 
  1070 	TESTPOINT(RTmParFormat::EAlignNormalBidirectional == rPF.iAlignment);
  1066 	test(RTmParFormat::EAlignNormalBidirectional == rPF.iAlignment);
  1071 
  1067 
  1072 	rPF.CopyL(*pF);
  1068 	rPF.CopyL(*pF);
  1073 	TESTPOINT(RTmParFormat::EAlignNormal == rPF.iAlignment);
  1069 	test(RTmParFormat::EAlignNormal == rPF.iAlignment);
  1074 
  1070 
  1075 	pF->iHorizontalAlignment = CParaFormat::ELeftAlign;
  1071 	pF->iHorizontalAlignment = CParaFormat::ELeftAlign;
  1076 	rPF.CopyL(*pF);
  1072 	rPF.CopyL(*pF);
  1077 	TESTPOINT(RTmParFormat::EAlignNormal == rPF.iAlignment);
  1073 	test(RTmParFormat::EAlignNormal == rPF.iAlignment);
  1078 
  1074 
  1079 	pF->iHorizontalAlignment = CParaFormat::ECenterAlign;
  1075 	pF->iHorizontalAlignment = CParaFormat::ECenterAlign;
  1080 	rPF.CopyL(*pF);
  1076 	rPF.CopyL(*pF);
  1081 	TESTPOINT(RTmParFormat::EAlignCenter == rPF.iAlignment);
  1077 	test(RTmParFormat::EAlignCenter == rPF.iAlignment);
  1082 
  1078 
  1083 	pF->iHorizontalAlignment = CParaFormat::ERightAlign;
  1079 	pF->iHorizontalAlignment = CParaFormat::ERightAlign;
  1084 	rPF.CopyL(*pF);
  1080 	rPF.CopyL(*pF);
  1085 	TESTPOINT(RTmParFormat::EAlignReverse == rPF.iAlignment);
  1081 	test(RTmParFormat::EAlignReverse == rPF.iAlignment);
  1086 
  1082 
  1087 	pF->iHorizontalAlignment = CParaFormat::EJustifiedAlign;
  1083 	pF->iHorizontalAlignment = CParaFormat::EJustifiedAlign;
  1088 	rPF.CopyL(*pF);
  1084 	rPF.CopyL(*pF);
  1089 	TESTPOINT(RTmParFormat::EAlignJustify == rPF.iAlignment);
  1085 	test(RTmParFormat::EAlignJustify == rPF.iAlignment);
  1090 
  1086 
  1091 	pF->iHorizontalAlignment = CParaFormat::EAbsoluteLeftAlign;
  1087 	pF->iHorizontalAlignment = CParaFormat::EAbsoluteLeftAlign;
  1092 	rPF.CopyL(*pF);
  1088 	rPF.CopyL(*pF);
  1093 	TESTPOINT(RTmParFormat::EAlignAbsoluteLeft == rPF.iAlignment);
  1089 	test(RTmParFormat::EAlignAbsoluteLeft == rPF.iAlignment);
  1094 
  1090 
  1095 	pF->iHorizontalAlignment = CParaFormat::EAbsoluteRightAlign;
  1091 	pF->iHorizontalAlignment = CParaFormat::EAbsoluteRightAlign;
  1096 	rPF.CopyL(*pF);
  1092 	rPF.CopyL(*pF);
  1097 	TESTPOINT(RTmParFormat::EAlignAbsoluteRight == rPF.iAlignment);
  1093 	test(RTmParFormat::EAlignAbsoluteRight == rPF.iAlignment);
  1098 
  1094 
  1099 	rPF.Close();
  1095 	rPF.Close();
  1100 	CleanupStack::PopAndDestroy(); //pF
  1096 	CleanupStack::PopAndDestroy(); //pF
  1101 	}
  1097 	}
  1102 
  1098 
  1104 	{
  1100 	{
  1105 	CParaFormat* pF = CParaFormat::NewL();
  1101 	CParaFormat* pF = CParaFormat::NewL();
  1106 	CleanupStack::PushL(pF);
  1102 	CleanupStack::PushL(pF);
  1107 	RTmParFormat rPF;
  1103 	RTmParFormat rPF;
  1108 
  1104 
  1109 	TESTPOINT(pF->iHorizontalAlignment == CParaFormat::ELeftAlign);
  1105 	test(pF->iHorizontalAlignment == CParaFormat::ELeftAlign);
  1110 
  1106 
  1111 	rPF.iAlignment = RTmParFormat::EAlignNormal;
  1107 	rPF.iAlignment = RTmParFormat::EAlignNormal;
  1112 	rPF.GetCParaFormatL(*pF);
  1108 	rPF.GetCParaFormatL(*pF);
  1113 	TESTPOINT(CParaFormat::ELeftAlign == pF->iHorizontalAlignment);
  1109 	test(CParaFormat::ELeftAlign == pF->iHorizontalAlignment);
  1114 
  1110 
  1115 	rPF.iAlignment = RTmParFormat::EAlignCenter;
  1111 	rPF.iAlignment = RTmParFormat::EAlignCenter;
  1116 	rPF.GetCParaFormatL(*pF);
  1112 	rPF.GetCParaFormatL(*pF);
  1117 	TESTPOINT(CParaFormat::ECenterAlign == pF->iHorizontalAlignment);
  1113 	test(CParaFormat::ECenterAlign == pF->iHorizontalAlignment);
  1118 
  1114 
  1119 	rPF.iAlignment = RTmParFormat::EAlignReverse;
  1115 	rPF.iAlignment = RTmParFormat::EAlignReverse;
  1120 	rPF.GetCParaFormatL(*pF);
  1116 	rPF.GetCParaFormatL(*pF);
  1121 	TESTPOINT(CParaFormat::ERightAlign == pF->iHorizontalAlignment);
  1117 	test(CParaFormat::ERightAlign == pF->iHorizontalAlignment);
  1122 
  1118 
  1123 	rPF.iAlignment = RTmParFormat::EAlignJustify;
  1119 	rPF.iAlignment = RTmParFormat::EAlignJustify;
  1124 	rPF.GetCParaFormatL(*pF);
  1120 	rPF.GetCParaFormatL(*pF);
  1125 	TESTPOINT(CParaFormat::EJustifiedAlign == pF->iHorizontalAlignment);
  1121 	test(CParaFormat::EJustifiedAlign == pF->iHorizontalAlignment);
  1126 
  1122 
  1127 	rPF.iAlignment = RTmParFormat::EAlignAbsoluteLeft;
  1123 	rPF.iAlignment = RTmParFormat::EAlignAbsoluteLeft;
  1128 	rPF.GetCParaFormatL(*pF);
  1124 	rPF.GetCParaFormatL(*pF);
  1129 	TESTPOINT(CParaFormat::EAbsoluteLeftAlign == pF->iHorizontalAlignment);
  1125 	test(CParaFormat::EAbsoluteLeftAlign == pF->iHorizontalAlignment);
  1130 
  1126 
  1131 	rPF.iAlignment = RTmParFormat::EAlignAbsoluteRight;
  1127 	rPF.iAlignment = RTmParFormat::EAlignAbsoluteRight;
  1132 	rPF.GetCParaFormatL(*pF);
  1128 	rPF.GetCParaFormatL(*pF);
  1133 	TESTPOINT(CParaFormat::EAbsoluteRightAlign == pF->iHorizontalAlignment);
  1129 	test(CParaFormat::EAbsoluteRightAlign == pF->iHorizontalAlignment);
  1134 
  1130 
  1135 	rPF.Close();
  1131 	rPF.Close();
  1136 	CleanupStack::PopAndDestroy(); // pF
  1132 	CleanupStack::PopAndDestroy(); // pF
  1137 	}
  1133 	}
  1138 
  1134 
  1145 	TPtrC iNullText;
  1141 	TPtrC iNullText;
  1146 public:
  1142 public:
  1147 	TTestCustomFormattingSource(MGraphicsDeviceMap* aDevice,
  1143 	TTestCustomFormattingSource(MGraphicsDeviceMap* aDevice,
  1148 		const TDesC& aBody, TInt aCustomFormatType)
  1144 		const TDesC& aBody, TInt aCustomFormatType)
  1149 		: iDevice(aDevice)
  1145 		: iDevice(aDevice)
  1150         {
  1146 		{
  1151 		iCustomFormatType = aCustomFormatType;
  1147 		iCustomFormatType = aCustomFormatType;
  1152 		iBody.Set(aBody.Ptr(), aBody.Length());
  1148 		iBody.Set(aBody.Ptr(), aBody.Length());
  1153 		iCurrent = &iBody;
  1149 		iCurrent = &iBody;
  1154 		}
  1150 		}
  1155 	void Close()
  1151 	void Close()
  1223 				pos += from;
  1219 				pos += from;
  1224 				aNext.iPos = pos + 4; // Adjust by length of string "EPOC"
  1220 				aNext.iPos = pos + 4; // Adjust by length of string "EPOC"
  1225 				aNext.iLeadingEdge = EFalse;
  1221 				aNext.iLeadingEdge = EFalse;
  1226 				if (aNext.iPos - aFrom.iPos < aMaxLength + (aNext.iLeadingEdge ? 0 : 1))
  1222 				if (aNext.iPos - aFrom.iPos < aMaxLength + (aNext.iLeadingEdge ? 0 : 1))
  1227 					return KErrNotFound;
  1223 					return KErrNotFound;
  1228 				TBuf<256> buf;
  1224 	 test.Printf(_L("GetPos-InlineTextAt-%d %c-From-%d\n"), aNext.iPos, aNext.iLeadingEdge ? 'L' : 'T', aFrom.iPos);
  1229 				buf.AppendFormat(_L("GetPos-InlineTextAt-%d %c-From-%d\n"),aNext.iPos, aNext.iLeadingEdge ? 'L' : 'T', aFrom.iPos);
       
  1230 				TESTPRINT(buf);
       
  1231 				return KErrNone;
  1225 				return KErrNone;
  1232 				}
  1226 				}
  1233 			return KErrNotFound;
  1227 			return KErrNotFound;
  1234 			}
  1228 			}
  1235 		else if (iCustomFormatType == 2)
  1229 		else if (iCustomFormatType == 2)
  1250 					{ // search position is before the first break space
  1244 					{ // search position is before the first break space
  1251 					aNext.iPos = pos + 4; // adjust to position of first space
  1245 					aNext.iPos = pos + 4; // adjust to position of first space
  1252 					aNext.iLeadingEdge = ETrue;
  1246 					aNext.iLeadingEdge = ETrue;
  1253 					if (aNext.iPos - aFrom.iPos < aMaxLength + (aNext.iLeadingEdge ? 0 : 1))
  1247 					if (aNext.iPos - aFrom.iPos < aMaxLength + (aNext.iLeadingEdge ? 0 : 1))
  1254 						return KErrNotFound;
  1248 						return KErrNotFound;
  1255 					TBuf<256> buf;
  1249 	test.Printf(_L("GetPos-InlineTextAt-%d %c-From-%d\n"), aNext.iPos, aNext.iLeadingEdge ? 'L' : 'T', aFrom.iPos);
  1256 					buf.AppendFormat(_L("GetPos-InlineTextAt-%d %c-From-%d\n"), aNext.iPos, aNext.iLeadingEdge ? 'L' : 'T', aFrom.iPos);
       
  1257 					TESTPRINT(buf);
       
  1258 					return KErrNone;
  1250 					return KErrNone;
  1259 					}
  1251 					}
  1260 				// if it gets here search position is after the first break space
  1252 				// if it gets here search position is after the first break space
  1261 				if (pos + 7 >= aFrom.iPos)
  1253 				if (pos + 7 >= aFrom.iPos)
  1262 					{ // but before the second
  1254 					{ // but before the second
  1263 					aNext.iPos = pos + 7; // adjust to position of second space
  1255 					aNext.iPos = pos + 7; // adjust to position of second space
  1264 					aNext.iLeadingEdge = EFalse;
  1256 					aNext.iLeadingEdge = EFalse;
  1265 					if (aNext.iPos - aFrom.iPos < aMaxLength + (aNext.iLeadingEdge ? 0 : 1))
  1257 					if (aNext.iPos - aFrom.iPos < aMaxLength + (aNext.iLeadingEdge ? 0 : 1))
  1266 						return KErrNotFound;
  1258 						return KErrNotFound;
  1267 					TBuf<256> buf;
  1259 	test.Printf(_L("GetPos-InlineTextAt-%d %c-From-%d\n"), aNext.iPos, aNext.iLeadingEdge ? 'L' : 'T', aFrom.iPos);
  1268 					buf.AppendFormat(_L("GetPos-InlineTextAt-%d %c-From-%d\n"), aNext.iPos, aNext.iLeadingEdge ? 'L' : 'T', aFrom.iPos);
       
  1269 					TESTPRINT(buf);
       
  1270 					return KErrNone;
  1260 					return KErrNone;
  1271 					}
  1261 					}
  1272 				}
  1262 				}
  1273 			return KErrNotFound;
  1263 			return KErrNotFound;
  1274 			}
  1264 			}
  1275 		return KErrNotFound;
  1265 		return KErrNotFound;
  1276 		}
  1266 		}
  1277 	TPtrC GetInlineText(const TTmDocPos& aAt)
  1267 	TPtrC GetInlineText(const TTmDocPos& aAt)
  1278 		{
  1268 		{
  1279 	    TBuf<256> buf;
  1269 	test.Printf(_L("QueryTextAt-%d %c\n"), aAt.iPos, aAt.iLeadingEdge ? 'L' : 'T');
  1280 	    buf.AppendFormat(_L("QueryTextAt-%d %c\n"), aAt.iPos, aAt.iLeadingEdge ? 'L' : 'T');
       
  1281 	    TESTPRINT(buf);
       
  1282 		if (iCustomFormatType == 0)
  1270 		if (iCustomFormatType == 0)
  1283 			{
  1271 			{
  1284 			return iNullText;
  1272 			return iNullText;
  1285 			}
  1273 			}
  1286 		else if (iCustomFormatType == 1)
  1274 		else if (iCustomFormatType == 1)
  1297 				pos += at;
  1285 				pos += at;
  1298 				if ((pos + 4 == aAt.iPos) && !aAt.iLeadingEdge)
  1286 				if ((pos + 4 == aAt.iPos) && !aAt.iLeadingEdge)
  1299 					{
  1287 					{
  1300 					_LIT(KCFS3, "?");
  1288 					_LIT(KCFS3, "?");
  1301 					TPtrC tPtrC(KCFS3);
  1289 					TPtrC tPtrC(KCFS3);
  1302 					TBuf<256> buf;
  1290 	test.Printf(_L("GetText-QuestionMark-%d\n"), aAt.iPos);
  1303 					buf.AppendFormat(_L("GetText-QuestionMark-%d\n"), aAt.iPos);
       
  1304 					TESTPRINT(buf);
       
  1305 					return tPtrC;
  1291 					return tPtrC;
  1306 					}
  1292 					}
  1307 				}
  1293 				}
  1308 			return iNullText;
  1294 			return iNullText;
  1309 			}
  1295 			}
  1322 				if ((pos + 4 == aAt.iPos) && aAt.iLeadingEdge)
  1308 				if ((pos + 4 == aAt.iPos) && aAt.iLeadingEdge)
  1323 //				if ((pos + 4 == aAt.iPos) && !aAt.iLeadingEdge)
  1309 //				if ((pos + 4 == aAt.iPos) && !aAt.iLeadingEdge)
  1324 					{ // search position is on the first break space
  1310 					{ // search position is on the first break space
  1325 					_LIT(KCFS4, " ");
  1311 					_LIT(KCFS4, " ");
  1326 					TPtrC tPtrC(KCFS4);
  1312 					TPtrC tPtrC(KCFS4);
  1327 					
  1313 	test.Printf(_L("GetText-Space-%d-L\n"), aAt.iPos);
  1328                     TBuf<256> buf;
       
  1329                     buf.AppendFormat(_L("GetText-Space-%d-L\n"), aAt.iPos);
       
  1330                     TESTPRINT(buf);
       
  1331 					return tPtrC;
  1314 					return tPtrC;
  1332 					}
  1315 					}
  1333 				// if it gets here search position is not on the first break space
  1316 				// if it gets here search position is not on the first break space
  1334 				if ((pos + 7 == aAt.iPos) && !aAt.iLeadingEdge)
  1317 				if ((pos + 7 == aAt.iPos) && !aAt.iLeadingEdge)
  1335 					{ // but it is on the second
  1318 					{ // but it is on the second
  1336 					_LIT(KCFS4, " ");
  1319 					_LIT(KCFS4, " ");
  1337 					TPtrC tPtrC(KCFS4);
  1320 					TPtrC tPtrC(KCFS4);
  1338 					TBuf<256> buf;
  1321 	test.Printf(_L("GetText-Space-%d-T\n"), aAt.iPos);
  1339 					buf.AppendFormat(_L("GetText-Space-%d-T\n"), aAt.iPos);
       
  1340 					TESTPRINT(buf);
       
  1341 					return tPtrC;
  1322 					return tPtrC;
  1342 					}
  1323 					}
  1343 				}
  1324 				}
  1344 			return iNullText;
  1325 			return iNullText;
  1345 			}
  1326 			}
  1352 	// Test implementation of CustomFormatting
  1333 	// Test implementation of CustomFormatting
  1353 	// ========
  1334 	// ========
  1354 	// Test one
  1335 	// Test one
  1355 	// ========
  1336 	// ========
  1356 	// First test is where inline text is enabled but where there is none to insert
  1337 	// First test is where inline text is enabled but where there is none to insert
  1357 	_LIT(KBody0, "This is a bunch of boring plain text that doesn't get any inline text inserted.\x2029"); 
  1338 	_LIT(KBody0, "This is a bunch of boring plain text that doesn't get any inline text inserted.\x2029");
  1358 	TTestCustomFormattingSource s0(iDevice, KBody0, 0);	// No inline text
  1339 	TTestCustomFormattingSource s0(iDevice, KBody0, 0);	// No inline text
  1359 	CTmTextLayout* lay0 = new(ELeave) CTmTextLayout;
  1340 	CTmTextLayout* lay0 = new(ELeave) CTmTextLayout;
  1360 	TTmFormatParam fp0;
  1341 	TTmFormatParam fp0;
  1361 	fp0.iWrapWidth = 200;
  1342 	fp0.iWrapWidth = 200;
  1362 	fp0.iEndChar = KBody0().Length();
  1343 	fp0.iEndChar = KBody0().Length();
  1425 	//Test the sample text with ZWJ at the beginning of the string
  1406 	//Test the sample text with ZWJ at the beginning of the string
  1426 	text->InsertL(0,KLatinZWJ1);
  1407 	text->InsertL(0,KLatinZWJ1);
  1427 	text->GetDisplayedText(0,buffer,needed);
  1408 	text->GetDisplayedText(0,buffer,needed);
  1428 
  1409 
  1429 	//Verify that the text is formatted correctly
  1410 	//Verify that the text is formatted correctly
  1430 	TESTPOINT(buffer == KDisplayedLatinZWJ);
  1411 	test(buffer == KDisplayedLatinZWJ);
  1431 
  1412 
  1432 	//Verify that the length of the string is as expected
  1413 	//Verify that the length of the string is as expected
  1433 	textLength = (text->EndChar()) - (text->StartChar());
  1414 	textLength = (text->EndChar()) - (text->StartChar());
  1434 	TESTPOINT(textLength == KExpectedTextLength);
  1415 	test(textLength == KExpectedTextLength);
  1435 	text->Clear();
  1416 	text->Clear();
  1436 
  1417 
  1437 	//Test the sample text with ZWJ in the middle of the string
  1418 	//Test the sample text with ZWJ in the middle of the string
  1438 	text->InsertL(0,KLatinZWJ2);
  1419 	text->InsertL(0,KLatinZWJ2);
  1439 	text->GetDisplayedText(0,buffer,needed);
  1420 	text->GetDisplayedText(0,buffer,needed);
  1440 
  1421 
  1441 	//Verify that the text is formatted correctly
  1422 	//Verify that the text is formatted correctly
  1442 	TESTPOINT(buffer == KDisplayedLatinZWJ);
  1423 	test(buffer == KDisplayedLatinZWJ);
  1443 
  1424 
  1444 	//Verify that the length of the string is as expected
  1425 	//Verify that the length of the string is as expected
  1445 	textLength = (text->EndChar()) - (text->StartChar());
  1426 	textLength = (text->EndChar()) - (text->StartChar());
  1446 	TESTPOINT(textLength == KExpectedTextLength);
  1427 	test(textLength == KExpectedTextLength);
  1447 	text->Clear();
  1428 	text->Clear();
  1448 
  1429 
  1449 	//Test the sample text with ZWJ at the end of the string
  1430 	//Test the sample text with ZWJ at the end of the string
  1450 	text->InsertL(0,KLatinZWJ3);
  1431 	text->InsertL(0,KLatinZWJ3);
  1451 	text->GetDisplayedText(0,buffer,needed);
  1432 	text->GetDisplayedText(0,buffer,needed);
  1452 
  1433 
  1453 	//Verify that the text is formatted correctly
  1434 	//Verify that the text is formatted correctly
  1454 	TESTPOINT(buffer == KDisplayedLatinZWJ);
  1435 	test(buffer == KDisplayedLatinZWJ);
  1455 
  1436 
  1456 	//Verify that the length of the string is as expected
  1437 	//Verify that the length of the string is as expected
  1457 	textLength = (text->EndChar()) - (text->StartChar());
  1438 	textLength = (text->EndChar()) - (text->StartChar());
  1458 	TESTPOINT(textLength == KExpectedTextLength);
  1439 	test(textLength == KExpectedTextLength);
  1459 	text->Clear();
  1440 	text->Clear();
  1460 
  1441 
  1461 	CleanupStack::PopAndDestroy(); // text
  1442 	CleanupStack::PopAndDestroy(); // text
  1462 }
  1443 }
  1463 
  1444 
  1491 	//Test the sample text the Kananda and Tamil characters
  1472 	//Test the sample text the Kananda and Tamil characters
  1492 	text->InsertL(0,KKannadaTamil);
  1473 	text->InsertL(0,KKannadaTamil);
  1493 	text->GetDisplayedText(0,buffer,needed);
  1474 	text->GetDisplayedText(0,buffer,needed);
  1494 
  1475 
  1495 	//Verify that the text is formatted correctly
  1476 	//Verify that the text is formatted correctly
  1496 	TESTPOINT(buffer == KDisplayedKannadaTamil);
  1477 	test(buffer == KDisplayedKannadaTamil);
  1497 
  1478 
  1498 	//Verify that the length of the string is as expected
  1479 	//Verify that the length of the string is as expected
  1499 	textLength = (text->EndChar()) - (text->StartChar());
  1480 	textLength = (text->EndChar()) - (text->StartChar());
  1500 	TESTPOINT(textLength == KExpectedTextLength);
  1481 	test(textLength == KExpectedTextLength);
  1501 	text->Clear();
  1482 	text->Clear();
  1502 
  1483 
  1503 	CleanupStack::PopAndDestroy(); // text
  1484 	CleanupStack::PopAndDestroy(); // text
  1504 }
  1485 }
  1505 
  1486 
  1542 		CleanupStack::PushL(formatContext);
  1523 		CleanupStack::PushL(formatContext);
  1543 		
  1524 		
  1544 		chunk.SetL(*formatContext,0,0,10,533,0,chunkInfo);
  1525 		chunk.SetL(*formatContext,0,0,10,533,0,chunkInfo);
  1545 		TUint context = chunk.iContextCharInByteCode;
  1526 		TUint context = chunk.iContextCharInByteCode;
  1546 		// Test that the first chunk's context has been recognised as not needing supplied context.
  1527 		// Test that the first chunk's context has been recognised as not needing supplied context.
  1547 		TESTPOINT(0 == context);
  1528 		test(0 == context);
  1548 		chunk.SetL(*formatContext,3,0,10,533,0,chunkInfo);
  1529 		chunk.SetL(*formatContext,3,0,10,533,0,chunkInfo);
  1549 		context = chunk.iContextCharInByteCode;
  1530 		context = chunk.iContextCharInByteCode;
  1550 		// Test that the next chunk retains the Hindi context.
  1531 		// Test that the next chunk retains the Hindi context.
  1551 		TESTPOINT(2325 == context);
  1532 		test(2325 == context);
  1552 		chunk.SetL(*formatContext,4,0,10,533,0,chunkInfo);
  1533 		chunk.SetL(*formatContext,4,0,10,533,0,chunkInfo);
  1553 		context = chunk.iContextCharInByteCode;
  1534 		context = chunk.iContextCharInByteCode;
  1554 		// Test that the next chunk retains the Hindi context.
  1535 		// Test that the next chunk retains the Hindi context.
  1555 		TESTPOINT(2325 == context);
  1536 		test(2325 == context);
  1556 		chunk.SetL(*formatContext,5,0,10,533,0,chunkInfo);
  1537 		chunk.SetL(*formatContext,5,0,10,533,0,chunkInfo);
  1557 		context = chunk.iContextCharInByteCode;
  1538 		context = chunk.iContextCharInByteCode;
  1558 		// Test that the next chunk retains the Hindi context.
  1539 		// Test that the next chunk retains the Hindi context.
  1559 		TESTPOINT(2325 == context);
  1540 		test(2325 == context);
  1560 		chunk.SetL(*formatContext,6,0,10,533,0,chunkInfo);
  1541 		chunk.SetL(*formatContext,6,0,10,533,0,chunkInfo);
  1561 		context = chunk.iContextCharInByteCode;
  1542 		context = chunk.iContextCharInByteCode;
  1562 		// Test that the next chunk has been recognised as not needing supplied context.
  1543 		// Test that the next chunk has been recognised as not needing supplied context.
  1563 		TESTPOINT(0 == context);
  1544 		test(0 == context);
  1564 		chunk.SetL(*formatContext,9,0,10,533,0,chunkInfo);
  1545 		chunk.SetL(*formatContext,9,0,10,533,0,chunkInfo);
  1565 		context = chunk.iContextCharInByteCode;
  1546 		context = chunk.iContextCharInByteCode;
  1566 		// Test that the next chunk retains the Latin context.
  1547 		// Test that the next chunk retains the Latin context.
  1567 		TESTPOINT(99 == context);
  1548 		test(99 == context);
  1568 		
  1549 		
  1569 		
  1550 		
  1570 		CleanupStack::PopAndDestroy(formatContext); // formatContext
  1551 		CleanupStack::PopAndDestroy(formatContext); // formatContext
  1571 		CleanupStack::PopAndDestroy(layout); // layout
  1552 		CleanupStack::PopAndDestroy(layout); // layout
  1572 		CleanupStack::PopAndDestroy(code);   // code
  1553 		CleanupStack::PopAndDestroy(code);   // code
  1622 		// Iterate through lines in bytecode and check the context.
  1603 		// Iterate through lines in bytecode and check the context.
  1623 		while (interpreter.Next())
  1604 		while (interpreter.Next())
  1624 			{
  1605 			{
  1625 			if (interpreter.Op() == TTmInterpreter::EOpLine)
  1606 			if (interpreter.Op() == TTmInterpreter::EOpLine)
  1626 				{
  1607 				{
  1627 				TESTPOINT(interpreter.LineContextCharChar() == expectedResults[lines++]);
  1608 				test(interpreter.LineContextCharChar() == expectedResults[lines++]);
  1628 				}
  1609 				}
  1629 			interpreter.Skip();
  1610 			interpreter.Skip();
  1630 			}
  1611 			}
  1631 		
  1612 		
  1632 		// Test the correct amount of lines have been tested.
  1613 		// Test the correct amount of lines have been tested.
  1633 		TESTPOINT(4 == lines);
  1614 		test(4 == lines);
  1634 		
  1615 		
  1635 		// Close the interpreter and clean up the heap.
  1616 		// Close the interpreter and clean up the heap.
  1636 		interpreter.Close();
  1617 		interpreter.Close();
  1637 		CleanupStack::PopAndDestroy(layout); // layout
  1618 		CleanupStack::PopAndDestroy(layout); // layout
  1638 		CleanupStack::PopAndDestroy(code);   // code
  1619 		CleanupStack::PopAndDestroy(code);   // code
  1694 		while (interpreter.Next() && interpreter.Op() != TTmInterpreter::EOpLine)
  1675 		while (interpreter.Next() && interpreter.Op() != TTmInterpreter::EOpLine)
  1695 			{
  1676 			{
  1696 			TUint32 op = interpreter.Op();
  1677 			TUint32 op = interpreter.Op();
  1697 			if (interpreter.Op() == TTmInterpreter::EOpText || interpreter.Op() == TTmInterpreter::EOpSpecialChar)
  1678 			if (interpreter.Op() == TTmInterpreter::EOpText || interpreter.Op() == TTmInterpreter::EOpSpecialChar)
  1698 				{
  1679 				{
  1699 				TESTPOINT(expectedResults[chunks++] == interpreter.ContextCharChar());
  1680 				test(expectedResults[chunks++] == interpreter.ContextCharChar());
  1700 				}
  1681 				}
  1701 			else
  1682 			else
  1702 				{
  1683 				{
  1703 				interpreter.Skip();
  1684 				interpreter.Skip();
  1704 				}
  1685 				}
  1705 			}
  1686 			}
  1706 		
  1687 		
  1707 		// Test that the expected number of chunks were found in the bytecode.
  1688 		// Test that the expected number of chunks were found in the bytecode.
  1708 		TESTPOINT(3 == chunks);
  1689 		test(3 == chunks);
  1709 		
  1690 		
  1710 		// Close the interpreter and clean up the heap.
  1691 		// Close the interpreter and clean up the heap.
  1711 		interpreter.Close();
  1692 		interpreter.Close();
  1712 		CleanupStack::PopAndDestroy(layout); // layout
  1693 		CleanupStack::PopAndDestroy(layout); // layout
  1713 		CleanupStack::PopAndDestroy(code);   // code
  1694 		CleanupStack::PopAndDestroy(code);   // code
  1715 		}
  1696 		}
  1716 
  1697 
  1717 void CTagmaImpTest::TestL()
  1698 void CTagmaImpTest::TestL()
  1718 	{
  1699 	{
  1719 //	__UHEAP_MARK;
  1700 //	__UHEAP_MARK;
  1720     
  1701 
  1721 	TESTPRINT(_L("Regression test: DEF073838")); // Line break problem with WORD
  1702 	test.Start(_L("Regression test: DEF073838")); // Line break problem with WORD
  1722 	DEF_073838_DefectL();
  1703 	DEF_073838_DefectL();
  1723 
  1704 
  1724 	TESTPRINT(_L("Regression test: INC044969"));
  1705 	test.Next(_L("Regression test: INC044969"));
  1725 	INC_044969_DefectL();
  1706 	INC_044969_DefectL();
  1726 
  1707 
  1727 	TESTPRINT(_L("CTmTextImp::RRunArray tests"));
  1708 	test.Next(_L("CTmTextImp::RRunArray tests"));
  1728 	CTmTextImp_RRunArrayL();
  1709 	CTmTextImp_RRunArrayL();
  1729 
  1710 
  1730 	TESTPRINT(_L("Regression test: BUR-58FGE8"));
  1711 	test.Next(_L("Regression test: BUR-58FGE8"));
  1731 	BUR_58FGE8_DefectL();
  1712 	BUR_58FGE8_DefectL();
  1732 
  1713 
  1733 	TESTPRINT(_L("Regression test: WEP-55BHBF"));
  1714 	test.Next(_L("Regression test: WEP-55BHBF"));
  1734 	WEP_55BHBF_DefectL();
  1715 	WEP_55BHBF_DefectL();
  1735 
  1716 
  1736 	TESTPRINT(_L("Regression test: EXT-5ATF8D"));
  1717 	test.Next(_L("Regression test: EXT-5ATF8D"));
  1737 	EXT_5ATF8D_DefectL();
  1718 	EXT_5ATF8D_DefectL();
  1738 
  1719 
  1739 	TESTPRINT(_L(" @SYMTestCaseID:SYSLIB-FORM-UT-1886 Test for CTmTextImp API's "));
  1720 	test.Next(_L(" @SYMTestCaseID:SYSLIB-FORM-UT-1886 Test for CTmTextImp API's "));
  1740 	TestAPIL();
  1721 	TestAPIL();
  1741 
  1722 
  1742 	TESTPRINT(_L("CTmCode tests"));
  1723 	test.Next(_L("CTmCode tests"));
  1743 	CTmCodeOOML();
  1724 	CTmCodeOOML();
  1744 
  1725 
  1745 	TESTPRINT(_L("CTmFormatContext::FormatL tests"));
  1726 	test.Next(_L("CTmFormatContext::FormatL tests"));
  1746 	FormatOOML();
  1727 	FormatOOML();
  1747 
  1728 
  1748 	TESTPRINT(_L("RTmTextCache::Width tests"));
  1729 	test.Next(_L("RTmTextCache::Width tests"));
  1749 	RTmTextCacheWidthOOM();
  1730 	RTmTextCacheWidthOOM();
  1750 
  1731 
  1751 	TESTPRINT(_L("RTmGeneralInterpreter::GetDisplayedText tests"));
  1732 	test.Next(_L("RTmGeneralInterpreter::GetDisplayedText tests"));
  1752 	RTmGeneralInterpreterGetDisplayedTextOOM();
  1733 	RTmGeneralInterpreterGetDisplayedTextOOM();
  1753 
  1734 
  1754 	TESTPRINT(_L("Bidirectional alignment tests"));
  1735 	test.Next(_L("Bidirectional alignment tests"));
  1755 	CTmTextImp_BidirectionalAlignmentL();
  1736 	CTmTextImp_BidirectionalAlignmentL();
  1756 
  1737 
  1757 	TESTPRINT(_L("Custom formatting tests"));
  1738 	test.Next(_L("Custom formatting tests"));
  1758 	CustomFormattingL();
  1739 	CustomFormattingL();
  1759 
  1740 
  1760 	TESTPRINT(_L(" @SYMTestCaseID:SYSLIB-FORM-CT-3353 Regression test: PDEF101464 "));
  1741 	test.Next(_L(" @SYMTestCaseID:SYSLIB-FORM-CT-3353 Regression test: PDEF101464 "));
  1761 	PDEF_101464_DefectL();
  1742 	PDEF_101464_DefectL();
  1762 
  1743 
  1763 	TESTPRINT(_L(" @SYMTestCaseID:SYSLIB-FORM-CT-3398 Regression test: DEF101994 "));
  1744 	test.Next(_L(" @SYMTestCaseID:SYSLIB-FORM-CT-3398 Regression test: DEF101994 "));
  1764 	DEF101994_DefectL();
  1745 	DEF101994_DefectL();
  1765 	
  1746 	
  1766 	TESTPRINT(_L(" @SYMTestCaseID:SYSLIB-FORM-UT-4010 Drawing Text within context: Testing chunk context."));
  1747 	test.Next(_L(" @SYMTestCaseID:SYSLIB-FORM-UT-4010 Drawing Text within context: Testing chunk context."));
  1767 	TestChunkContext();
  1748 	TestChunkContext();
  1768 	
  1749 	
  1769 	TESTPRINT(_L(" @SYMTestCaseID:SYSLIB-FORM-UT-4011 Drawing Text within context: Testing line context within bytecode."));
  1750 	test.Next(_L(" @SYMTestCaseID:SYSLIB-FORM-UT-4011 Drawing Text within context: Testing line context within bytecode."));
  1770 	TestBytecodeLineContext();
  1751 	TestBytecodeLineContext();
  1771 	
  1752 	
  1772 	TESTPRINT(_L(" @SYMTestCaseID:SYSLIB-FORM-UT-4012 Drawing Text within context: Testing chunk context within bytecode."));
  1753 	test.Next(_L(" @SYMTestCaseID:SYSLIB-FORM-UT-4012 Drawing Text within context: Testing chunk context within bytecode."));
  1773 	TestBytecodeChunkContext();	
  1754 	TestBytecodeChunkContext();
       
  1755 	
       
  1756 	test.End(); 
  1774 	
  1757 	
  1775 //	__UHEAP_MARKEND;
  1758 //	__UHEAP_MARKEND;
  1776 	}
  1759 	}
  1777 
  1760 
  1778 CTTagmaImpStep::CTTagmaImpStep()
  1761 
  1779     {
  1762 void RunTestsL()
  1780     
  1763 	{
  1781     }
  1764 	CTagmaImpTest* t = new(ELeave) CTagmaImpTest();
  1782 
  1765 	CleanupStack::PushL(t);
  1783 TVerdict CTTagmaImpStep::doTestStepL()
  1766 	t->ConstructL();
  1784     {    
  1767 	t->TestL();
  1785     SetTestStepResult(EPass);
  1768 	CleanupStack::PopAndDestroy(t);
  1786     TestStep = this;
  1769 	}
  1787     
  1770 
  1788     TESTPRINT(_L("Tagma internals tests"));
  1771 TInt E32Main()
  1789     CTagmaImpTest* t = new(ELeave) CTagmaImpTest(this);
  1772 	{
  1790     CleanupStack::PushL(t);
  1773 	CTrapCleanup* theCleanup =CTrapCleanup::New();
  1791     t->ConstructL();
  1774 	test.Title();
  1792     t->TestL();
  1775 	TRAPD(err, RunTestsL());
  1793     CleanupStack::PopAndDestroy(t);
  1776 	test.Close();
  1794     
  1777 	delete theCleanup;
  1795     return TestStepResult();
  1778 	return err;
  1796     }
  1779 	}
  1797 
       
  1798