fontservices/textbase/tgdi/TBiDiDefect.cpp
changeset 45 662fa7de7023
equal deleted inserted replaced
41:ea44a32a96bc 45:662fa7de7023
       
     1 // Copyright (c) 2003-2010 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #include <biditext.h>
       
    17 #include <bidi.h>
       
    18 #include <bidivisual.h>
       
    19 #include "TGraphicsContext.h"
       
    20 #include "TBiDiDefect.h"
       
    21 
       
    22 class CTBiDiDefect : public CTGraphicsBase
       
    23 	{
       
    24 
       
    25 public:
       
    26 	CTBiDiDefect(CTestStep* aStep);
       
    27 	~CTBiDiDefect();
       
    28 
       
    29 protected:
       
    30 //from 	CTGraphicsStep
       
    31 	virtual void RunTestCaseL(TInt aCurTestCase);
       
    32 
       
    33 private:
       
    34 	void CreateTestGraphicsContextL();
       
    35 
       
    36 	void INC016328L(const TDesC& aTestText);
       
    37 	void INC016665L();
       
    38 	void INC017825L();
       
    39 	void INC017974L();
       
    40 	void INC017991L();
       
    41 	void DEF021227();
       
    42 	void INC023337();
       
    43 	void INC023917();
       
    44 	void DEF037928();
       
    45 	void DEF021347L();
       
    46 	void INC037549L();
       
    47 	void INC042422L();
       
    48 	void DEF059214L();
       
    49 
       
    50 	void TestDEF021347L(TUint16 aControlCharacter);
       
    51 	void TestDEF043720L();
       
    52 	
       
    53 	void TestPDEF117110L();
       
    54 
       
    55 private:
       
    56 	TBidirectionalState::TRunInfo* iRunInfoArray;
       
    57 	CTestFont* iTestFont;
       
    58 	TBidiText* iBidiText;
       
    59 	CTestGraphicsDevice* iTestGraphicsDevice;
       
    60 	CTestGraphicsContext* iTestGraphicsContext;
       
    61 	};
       
    62 
       
    63 
       
    64 CTBiDiDefect::CTBiDiDefect(CTestStep* aStep) :
       
    65 	CTGraphicsBase(aStep),
       
    66 	iRunInfoArray(NULL),
       
    67 	iTestFont(NULL),
       
    68 	iBidiText(NULL),
       
    69 	iTestGraphicsDevice(NULL),
       
    70 	iTestGraphicsContext(NULL)
       
    71 	{
       
    72 	}
       
    73 
       
    74 CTBiDiDefect::~CTBiDiDefect()
       
    75 	{
       
    76 	delete iTestGraphicsContext;
       
    77 	delete iTestGraphicsDevice;
       
    78 	delete iBidiText;
       
    79 	delete iTestFont;
       
    80 	delete [] iRunInfoArray;
       
    81 	}
       
    82 
       
    83 void CTBiDiDefect::RunTestCaseL(TInt aCurTestCase)
       
    84 	{
       
    85     ((CTBiDiDefectStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
       
    86 	switch(aCurTestCase)
       
    87 		{
       
    88 	case 1:
       
    89 		{
       
    90 /**
       
    91    @SYMTestCaseID          	GRAPHICS-GDI-BiDiDefect-0001
       
    92 */
       
    93 		((CTBiDiDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-GDI-BiDiDefect-0001"));
       
    94 		TBuf<32> testText(_L(".Test"));
       
    95 		INFO_PRINTF1(_L("INC016328"));
       
    96 		INC016328L(testText);
       
    97 		}
       
    98 		break;
       
    99 	case 2:
       
   100 /**
       
   101    @SYMTestCaseID          	GRAPHICS-GDI-BiDiDefect-0002
       
   102 */
       
   103 		((CTBiDiDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-GDI-BiDiDefect-0002"));
       
   104 		INFO_PRINTF1(_L("INC016665"));
       
   105 		INC016665L();
       
   106 		break;
       
   107 	case 3:
       
   108 /**
       
   109    @SYMTestCaseID          	GRAPHICS-GDI-BiDiDefect-0003
       
   110 */
       
   111 		((CTBiDiDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-GDI-BiDiDefect-0003"));
       
   112 		INFO_PRINTF1(_L("INC017825"));
       
   113 		INC017825L();
       
   114 		break;
       
   115 	case 4:
       
   116 /**
       
   117    @SYMTestCaseID          	GRAPHICS-GDI-BiDiDefect-0004
       
   118 */
       
   119 		((CTBiDiDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-GDI-BiDiDefect-0004"));
       
   120 		INFO_PRINTF1(_L("INC017974"));
       
   121 		INC017974L();
       
   122 		break;
       
   123 	case 5:
       
   124 /**
       
   125    @SYMTestCaseID          	GRAPHICS-GDI-BiDiDefect-0005
       
   126 */
       
   127 		((CTBiDiDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-GDI-BiDiDefect-0005"));
       
   128 		INFO_PRINTF1(_L("INC017991"));
       
   129 		INC017991L();
       
   130 		break;
       
   131 	case 6:
       
   132 /**
       
   133    @SYMTestCaseID          	GRAPHICS-GDI-BiDiDefect-0006
       
   134 */
       
   135 		((CTBiDiDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-GDI-BiDiDefect-0006"));
       
   136 		INFO_PRINTF1(_L("DEF021227"));
       
   137 		DEF021227();
       
   138 		break;
       
   139 	case 7:
       
   140 /**
       
   141    @SYMTestCaseID          	GRAPHICS-GDI-BiDiDefect-0007
       
   142 */
       
   143 		((CTBiDiDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-GDI-BiDiDefect-0007"));
       
   144 		INFO_PRINTF1(_L("DEF021347"));
       
   145 		DEF021347L();
       
   146 		break;
       
   147 	case 8:
       
   148 /**
       
   149    @SYMTestCaseID          	GRAPHICS-GDI-BiDiDefect-0008
       
   150 */
       
   151 		((CTBiDiDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-GDI-BiDiDefect-0008"));
       
   152 		INFO_PRINTF1(_L("INC023337"));
       
   153 		INC023337();
       
   154 		break;
       
   155 	case 9:
       
   156 /**
       
   157    @SYMTestCaseID          	GRAPHICS-GDI-BiDiDefect-0009
       
   158 */
       
   159 		((CTBiDiDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-GDI-BiDiDefect-0009"));
       
   160 		INFO_PRINTF1(_L("INC023917"));
       
   161 		INC023917();
       
   162 		break;
       
   163 	case 10:
       
   164 /**
       
   165    @SYMTestCaseID          	GRAPHICS-GDI-BiDiDefect-0010
       
   166 */
       
   167 		((CTBiDiDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-GDI-BiDiDefect-0010"));
       
   168 		INFO_PRINTF1(_L("DEF037928"));
       
   169 		DEF037928();
       
   170 		break;
       
   171 	case 11:
       
   172 /**
       
   173    @SYMTestCaseID          	GRAPHICS-GDI-BiDiDefect-0011
       
   174 */
       
   175 	//INC037549 TBidiText crashes if  <CR><LF> appear at the end of the text
       
   176 		((CTBiDiDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-GDI-BiDiDefect-0011"));
       
   177 		INFO_PRINTF1(_L("INC037549L"));
       
   178 		INC037549L();
       
   179 		break;
       
   180 	case 12:
       
   181 /**
       
   182    @SYMTestCaseID          	GRAPHICS-GDI-BiDiDefect-0012
       
   183 */
       
   184 	//INC042422 when calculated length in BidiCompact.cpp TRunInfoCompact::Reorder < 0
       
   185 		((CTBiDiDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-GDI-BiDiDefect-0012"));
       
   186 		INFO_PRINTF1(_L("INC042422L"));
       
   187 		INC042422L();
       
   188 		break;
       
   189 	case 13:
       
   190 /**
       
   191    @SYMTestCaseID          	GRAPHICS-GDI-BiDiDefect-0013
       
   192 */
       
   193 		((CTBiDiDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-GDI-BiDiDefect-0013"));
       
   194 		INFO_PRINTF1(_L("DEF043720"));
       
   195 		TestDEF043720L();
       
   196 		break;
       
   197 	case 14:
       
   198 /**
       
   199    @SYMTestCaseID          	GRAPHICS-GDI-BiDiDefect-0014
       
   200 */
       
   201 		((CTBiDiDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-GDI-BiDiDefect-0014"));
       
   202 		INFO_PRINTF1(_L("DEF059214: Erroneous caret cursor movements"));
       
   203 		DEF059214L();
       
   204 		break;
       
   205 	case 15:
       
   206 /**
       
   207    @SYMTestCaseID          	GRAPHICS-GDI-BiDiDefect-0015
       
   208 */
       
   209 		((CTBiDiDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-GDI-BiDiDefect-0015"));
       
   210 		INFO_PRINTF1(_L("PDEF117110"));
       
   211 		TestPDEF117110L();
       
   212 		break;
       
   213 	case 16:
       
   214 		((CTBiDiDefectStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
       
   215 		((CTBiDiDefectStep*)iStep)->CloseTMSGraphicsStep();
       
   216 		TestComplete();
       
   217 		break;
       
   218 		}
       
   219         ((CTBiDiDefectStep*)iStep)->RecordTestResultL();
       
   220 	}
       
   221 
       
   222 void CTBiDiDefect::CreateTestGraphicsContextL()
       
   223 	{
       
   224 	delete iTestGraphicsContext;
       
   225 	iTestGraphicsContext = NULL;
       
   226 	delete iTestGraphicsDevice;
       
   227 	iTestGraphicsDevice = NULL;
       
   228 	
       
   229 	TSize windowSize(400, 400);
       
   230 	iTestGraphicsDevice = CTestGraphicsDevice::NewL(windowSize);
       
   231 	CGraphicsContext* tContext = NULL;	
       
   232 	TEST(iTestGraphicsDevice->CreateContext(tContext) == KErrNone);
       
   233 	iTestGraphicsContext = static_cast<CTestGraphicsContext*>(tContext);
       
   234 	}
       
   235 
       
   236 //TBidiText crashes if the first character of the text is '.'.
       
   237 void CTBiDiDefect::INC016328L(const TDesC& aTestText)
       
   238 	{
       
   239 	TInt arraySize = TBidirectionalState::GenerateBdRunArray(aTestText.Ptr(), aTestText.Length(), 0, 0);
       
   240 	iRunInfoArray = new (ELeave) TBidirectionalState::TRunInfo[arraySize];
       
   241 	TBidirectionalState::GenerateBdRunArray(aTestText.Ptr(), aTestText.Length(), iRunInfoArray, arraySize);
       
   242 	TBidirectionalState state;
       
   243 	state.ReorderLine(iRunInfoArray, arraySize, ETrue, ETrue, EFalse, TChar::EOtherNeutral, TChar::EOtherNeutral);
       
   244 	TEST(iRunInfoArray->iLength > 0);
       
   245 	}
       
   246 
       
   247 //Truncation after space character in Bidirectional text classes.
       
   248 //Actually it doesn't prove missing space character but proves 
       
   249 //truncation at the middle of "text" word - yet another defect.
       
   250 void CTBiDiDefect::INC016665L()
       
   251 	{
       
   252 	iTestFont = new (ELeave) CTestFont;
       
   253 	iBidiText = TBidiText::NewL(_L("Truncated text"), 1);
       
   254 	iBidiText->WrapText(110, *iTestFont, NULL);//"Truncated " and "text"
       
   255 	TEST(iBidiText->DisplayText().Length() == 10);
       
   256 	TEST(iBidiText->DisplayText()[9] == 0x2026);
       
   257 	delete (iBidiText);
       
   258 
       
   259 	iBidiText = TBidiText::NewL(_L("Truncated     text"), 1);
       
   260 	iBidiText->WrapText(110, *iTestFont, NULL);//"Truncated " and "text"
       
   261 	TEST(iBidiText->DisplayText().Length() == 10);
       
   262 	TEST(iBidiText->DisplayText()[9] == 0x2026);
       
   263 	}
       
   264 
       
   265 //TBidiText crashes with length 0 descriptor.
       
   266 void CTBiDiDefect::INC017825L()
       
   267 	{
       
   268 	delete iTestGraphicsContext;
       
   269 	iTestGraphicsContext = NULL;
       
   270 	CreateTestGraphicsContextL();
       
   271 
       
   272 	delete iTestFont;
       
   273 	iTestFont = NULL;
       
   274 	iTestFont = new (ELeave) CTestFont;
       
   275 
       
   276 	delete iBidiText;
       
   277 	iBidiText = NULL;
       
   278 	iBidiText = TBidiText::NewL(KNullDesC(), 1);
       
   279 	iBidiText->WrapText(100, *iTestFont, NULL);
       
   280 
       
   281 	iBidiText->DrawText(*iTestGraphicsContext, TPoint(0, 20), 20, CGraphicsContext::ERight);
       
   282 	}
       
   283 
       
   284 //BidiText does not show 0x062A character correctly if it is a first character.
       
   285 void CTBiDiDefect::INC017974L()
       
   286 	{
       
   287 	_LIT(KTextWithLatinLettersFirstArabicLetter, "\x062A abcdef");
       
   288 	
       
   289 	delete iTestFont;
       
   290 	iTestFont = NULL;
       
   291 	iTestFont = new (ELeave) CTestFont;
       
   292 
       
   293 	delete iBidiText;
       
   294 	iBidiText = NULL;
       
   295 	iBidiText = TBidiText::NewL(KTextWithLatinLettersFirstArabicLetter, 1);
       
   296 	iBidiText->WrapText(100, *iTestFont, NULL);
       
   297 	const TText* text = iBidiText->DisplayText().Ptr();
       
   298 	TEST(text[7] == 0x062A);//the arabic character should be the first at the end.
       
   299 	}
       
   300 
       
   301 //TBidiText::DrawText draws out of the area if alignment is right.
       
   302 void CTBiDiDefect::INC017991L()
       
   303 	{
       
   304 	delete iTestGraphicsContext;
       
   305 	iTestGraphicsContext = NULL;
       
   306 	CreateTestGraphicsContextL();
       
   307 
       
   308 	_LIT(KTextWithLatinLetters, "abc def ghijk lmnop qrstuvw xyz 12.34.");
       
   309 	const TInt KTextWidth = 200;
       
   310 
       
   311 	delete iTestFont;
       
   312 	iTestFont = NULL;
       
   313 	iTestFont = new (ELeave) CTestFont;
       
   314 
       
   315 	delete iBidiText;
       
   316 	iBidiText = NULL;
       
   317 	iBidiText = TBidiText::NewL(KTextWithLatinLetters, 2);
       
   318 	iBidiText->WrapText(KTextWidth, *iTestFont, NULL);
       
   319 
       
   320 	iBidiText->DrawText(*iTestGraphicsContext, TPoint(0, 20), 20, CGraphicsContext::ERight);
       
   321 	const TTestGCDisplayLine& line1 = iTestGraphicsContext->DisplayLine(0);
       
   322 	const TDesC& text1 = line1.iLineData;
       
   323 	TInt width1 = iTestFont->TextWidthInPixels(text1);
       
   324 	TEST((width1 + line1.iLinePos.iX) <= KTextWidth);
       
   325 	const TTestGCDisplayLine& line2 = iTestGraphicsContext->DisplayLine(1);
       
   326 	const TDesC& text2 = line2.iLineData;
       
   327 	TInt width2 = iTestFont->TextWidthInPixels(text2);
       
   328 	TEST((width2 + line2.iLinePos.iX) <= KTextWidth);
       
   329 	}
       
   330 
       
   331 //TBidiLogicalToVisual seems to lose characters. 
       
   332 void CTBiDiDefect::DEF021227()
       
   333 	{
       
   334 	_LIT(KTestText, "Waitnote + D prompt ");
       
   335 // 	_LIT(KTestText, "Waitnote H D prompt ");
       
   336 	TBuf<100> visualText;
       
   337 	visualText.Fill(0xCDCD);
       
   338 	TBidirectionalState::TRunInfo runArray[6];
       
   339 
       
   340 	TBidiLogicalToVisual bidiConverter(KTestText, EFalse, runArray,
       
   341 		sizeof(runArray)/sizeof(runArray[0]));
       
   342 	bidiConverter.Reorder();
       
   343 	TDesC des = KTestText;
       
   344 	bidiConverter.GetVisualLine(visualText, 0, des.Length() - 1, 0xFFFF);
       
   345 	TInt len = visualText.Length();
       
   346 	TEST((des.Length() - 1) == len);
       
   347 	}
       
   348 
       
   349 //DrawText should not draw control codes (particularly Bidirectional ones)
       
   350 void CTBiDiDefect::DEF021347L()
       
   351 	{
       
   352 	TestDEF021347L(0x200C);
       
   353 	TestDEF021347L(0x200D);
       
   354 	TestDEF021347L(0x200E);
       
   355 	TestDEF021347L(0x200F);
       
   356 	TestDEF021347L(0x202A);
       
   357 	TestDEF021347L(0x202B);
       
   358 	TestDEF021347L(0x202C);
       
   359 	TestDEF021347L(0x202D);
       
   360 	TestDEF021347L(0x202E);
       
   361 	// Tested in TGLYPHSEL now following rewrite.
       
   362 	//TestDEF021347L(0xFFFF);
       
   363 	}
       
   364 
       
   365 void CTBiDiDefect::TestDEF021347L(TUint16 aControlCharacter)
       
   366 	{
       
   367 	const TInt KTestTextLen = 5;
       
   368 	TBuf<100> testText(KTestTextLen);
       
   369 	testText[0] = 'a';
       
   370 	testText[1] = 'b';
       
   371 	testText[2] = aControlCharacter;
       
   372 	testText[3] = 'c';
       
   373 	testText[4] = 'd';
       
   374 
       
   375 	delete iTestFont;
       
   376 	iTestFont = NULL;
       
   377 	iTestFont = new (ELeave) CTestFont;
       
   378 
       
   379 	CFont::TPositionParam param;
       
   380 	param.iDirection = 0;
       
   381 	param.iFlags = 1;
       
   382 	param.iText.Set(testText);
       
   383 	param.iPosInText = 0;
       
   384 	param.iPen.iX = 0;
       
   385 	param.iPen.iY = 0;
       
   386 	param.iPosInText = 2; //testText[2] = aControlCharacter
       
   387 	TBool r = iTestFont->GetCharacterPosition(param);
       
   388 
       
   389 	TEST(r && param.iPen.iX == 0 && param.iOutputGlyphs == 0);
       
   390 	}
       
   391 
       
   392 //TBidiLogicalToVisual::GetVisualLine() panics when aEnd == 0 
       
   393 void CTBiDiDefect::INC023337()
       
   394 	{
       
   395 	_LIT(KTestText, "");
       
   396 	TBuf<100> visualText;
       
   397 	visualText.Fill(0xCDCD);
       
   398 	TBidirectionalState::TRunInfo runArray[6];
       
   399 	TBidiLogicalToVisual bidiConverter(KTestText, EFalse, runArray, sizeof(runArray)/sizeof(runArray[0]));
       
   400 	bidiConverter.Reorder();
       
   401 
       
   402 	TDesC des = KTestText;
       
   403 	const TUint KEmptyChar = TUint(0xFFFF);
       
   404 	//The next statement will panics, if INC023337 is not fixed.
       
   405 	bidiConverter.GetVisualLine(visualText, 0, des.Length(), KEmptyChar);
       
   406 	}
       
   407 
       
   408 //TBidiLogicalToVisual indexes over the given text.
       
   409 void CTBiDiDefect::INC023917()
       
   410 	{
       
   411 	const TInt dest_buf_len = 10;
       
   412 	TBidirectionalState::TRunInfo runInfoArray[dest_buf_len];
       
   413 	const TInt src_buf_len = 4;
       
   414     TBuf<src_buf_len> logical;
       
   415     logical.Fill(0x0639, src_buf_len);
       
   416 
       
   417     _LIT(KArabicWord, "\x0631\x0641\x0636");
       
   418     logical = KArabicWord;
       
   419 
       
   420     TBidiLogicalToVisual bidiConverter(logical, runInfoArray, sizeof(runInfoArray)/sizeof(runInfoArray[0]));
       
   421     bidiConverter.Reorder();
       
   422 
       
   423     TBuf<dest_buf_len> visual;
       
   424     bidiConverter.GetVisualLine(visual, 0, logical.Length(), 0xFFFF);
       
   425 
       
   426 	TEST(visual[0] == 0x0636);
       
   427 	}
       
   428 
       
   429 // DEF037928 - TBidiLogicalToVisual::GetVisualLine does not work correctly for 0 length strings
       
   430 void CTBiDiDefect::DEF037928()
       
   431 	{
       
   432 	// Zero length string for testing
       
   433 	_LIT(KTestText, "");
       
   434 	TBuf<100> visualText;
       
   435 	visualText.Fill(0xCDCD);
       
   436 	visualText.SetMax();
       
   437 	
       
   438 	TBidirectionalState::TRunInfo runArray[6];
       
   439 	TBidiLogicalToVisual bidiConverter(KTestText, EFalse, runArray,
       
   440 		sizeof(runArray)/sizeof(runArray[0]));
       
   441 	bidiConverter.Reorder();
       
   442 
       
   443 	bidiConverter.GetVisualLine(visualText, 0, 1, 0xFFFF);
       
   444 	TEST( visualText.Length() == 0);
       
   445 	}
       
   446 	
       
   447 	
       
   448 // INC037549 - TBidiText crashes if  <CR><LF> appear at the end of the text
       
   449 void CTBiDiDefect::INC037549L()
       
   450 	{
       
   451 	// This crash occured when the final character is <cr>
       
   452 	// and following memory location is <lf>
       
   453 	// To test this testString has a length of 5, but sPtr has length 4
       
   454 	_LIT( testString, "123\r\n" ) ;
       
   455 	TBuf<5> string( testString ) ;
       
   456 	TPtrC sPtr( string.Ptr(), 4 ) ;
       
   457 	TBidiText* bText = TBidiText::NewL( sPtr, 1, TBidiText::ELeftToRight ) ;
       
   458 
       
   459 	delete bText;
       
   460 	}
       
   461 
       
   462 // INC042422 - when calculated length in BidiCompact.cpp TRunInfoCompact::Reorder < 0
       
   463 //
       
   464 // This defect causes an extra blank line to be added when text contains \r\n
       
   465 // This was caused by a miscalculation in Biditext.cpp SizeLineBreak().
       
   466 // this test case is modified due to change of TBidiText::DoWrapText for fixing PDEF117110
       
   467 void CTBiDiDefect::INC042422L()
       
   468 	{
       
   469 	_LIT( testString, "123\r\n" ) ;
       
   470 	TBidiText* bText = TBidiText::NewL( testString, 1, TBidiText::ELeftToRight ) ;
       
   471 	bText->WrapText(100,*iTestFont,0);
       
   472 	TPtrC text = bText->DisplayText(); 
       
   473 
       
   474 	// The defect caused text to contain an extra blank line
       
   475 	// So the length was 5 ( text contained:1,2,3, 0x2028, 0x2026)
       
   476 	// when the correct value is 4 (text should contain: 1,2,3, 0x2026)
       
   477 	// Note: Due to fix for PDEF117109, the correct value is 3 now (text contains: 1,2,3)
       
   478 	TEST(text.Length() == 3);
       
   479 	TEST(text[0] == '1');
       
   480 	TEST(text[1] == '2');
       
   481 	TEST(text[2] == '3');
       
   482 
       
   483 	delete bText;
       
   484 	}
       
   485 
       
   486 //DEF043720 - Assert fails in TBiDiText wrapping when more than one \n is present in the text 
       
   487 void CTBiDiDefect::TestDEF043720L()
       
   488 	{
       
   489 	delete iTestFont;
       
   490 	iTestFont = NULL;
       
   491 	iTestFont = new (ELeave) CTestFont;
       
   492 	
       
   493 	delete iBidiText;
       
   494 	iBidiText = NULL;
       
   495 	iBidiText = TBidiText::NewL(_L("\n\nAB\n\n\nCD\n"),10);
       
   496 	iBidiText->WrapText(10,*iTestFont,0);
       
   497 
       
   498 	//After wrapping text should look like "\x2028\x2028A\x2028B\x2028\x2028\x2028C\x2028D"
       
   499 	//where \x2028 is the line separator
       
   500 	TPtrC afterwrap(iBidiText->DisplayText());
       
   501 	TEST(afterwrap.Length()==11);
       
   502 	TEST(afterwrap[0]==0x2028);
       
   503 	TEST(afterwrap[1]==0x2028);
       
   504 	TEST(afterwrap[3]==0x2028);
       
   505 	TEST(afterwrap[5]==0x2028);
       
   506 	TEST(afterwrap[6]==0x2028);
       
   507 	TEST(afterwrap[7]==0x2028);
       
   508 	TEST(afterwrap[9]==0x2028);
       
   509 
       
   510 	INFO_PRINTF1(iBidiText->DisplayText());
       
   511 
       
   512 	delete iBidiText;
       
   513 	iBidiText = NULL;
       
   514 	delete iTestFont;
       
   515 	iTestFont = NULL;
       
   516 	}
       
   517 
       
   518 void CTBiDiDefect::DEF059214L()
       
   519 	{
       
   520 	TBidirectionalState::TRunInfo runs[4];
       
   521 	TBidirectionalState bs;
       
   522 	TBool ambig;
       
   523 
       
   524 	// entirely left to right paragraph is not ambiguous
       
   525 	ambig = 3000;
       
   526 	bs.Reset();
       
   527 	runs[0].iCategory = TChar::ELeftToRight;
       
   528 	runs[0].iStart = 0;
       
   529 	runs[0].iLength = 10;
       
   530 	bs.ReorderLine(runs, 1, ETrue, EFalse, EFalse, TChar::ELeftToRight,
       
   531 		TChar::ELeftToRight, ambig);
       
   532 
       
   533 	// entirely right to left paragraph is not ambiguous
       
   534 	ambig = 3000;
       
   535 	bs.Reset();
       
   536 	runs[0].iCategory = TChar::ERightToLeft;
       
   537 	runs[0].iStart = 0;
       
   538 	runs[0].iLength = 10;
       
   539 	bs.ReorderLine(runs, 1, ETrue, EFalse, ETrue, TChar::ERightToLeft,
       
   540 		TChar::ERightToLeft, ambig);
       
   541 	TEST(!ambig);
       
   542 
       
   543 	// right to left portion within left to right paragraph is ambiguous
       
   544 	ambig = 3000;
       
   545 	bs.Reset();
       
   546 	runs[0].iCategory = TChar::ERightToLeft;
       
   547 	runs[0].iStart = 0;
       
   548 	runs[0].iLength = 10;
       
   549 	bs.ReorderLine(runs, 1, ETrue, EFalse, EFalse, TChar::ERightToLeft,
       
   550 		TChar::ERightToLeft, ambig);
       
   551 	TEST(ambig && ambig != 3000);
       
   552 	ambig = 3000;
       
   553 	bs.Reset();
       
   554 	runs[0].iCategory = TChar::ERightToLeft;
       
   555 	runs[0].iStart = 0;
       
   556 	runs[0].iLength = 10;
       
   557 	bs.ReorderLine(runs, 1, ETrue, EFalse, EFalse, TChar::EOtherNeutral,
       
   558 		TChar::ERightToLeft, ambig);
       
   559 	TEST(ambig && ambig != 3000);
       
   560 
       
   561 	// left to right portion within right to left paragraph is ambiguous
       
   562 	ambig = 3000;
       
   563 	bs.Reset();
       
   564 	runs[0].iCategory = TChar::ELeftToRight;
       
   565 	runs[0].iStart = 0;
       
   566 	runs[0].iLength = 10;
       
   567 	bs.ReorderLine(runs, 1, ETrue, EFalse, ETrue, TChar::ELeftToRight,
       
   568 		TChar::ELeftToRight, ambig);
       
   569 	TEST(ambig && ambig != 3000);
       
   570 	ambig = 3000;
       
   571 	bs.Reset();
       
   572 	runs[0].iCategory = TChar::ELeftToRight;
       
   573 	runs[0].iStart = 0;
       
   574 	runs[0].iLength = 10;
       
   575 	bs.ReorderLine(runs, 1, ETrue, EFalse, ETrue, TChar::EOtherNeutral,
       
   576 		TChar::ELeftToRight, ambig);
       
   577 	TEST(ambig && ambig != 3000);
       
   578 
       
   579 	// right to left following on from left to right paragraph is ambiguous
       
   580 	ambig = 3000;
       
   581 	bs.Reset();
       
   582 	runs[0].iCategory = TChar::ELeftToRight;
       
   583 	runs[0].iStart = 0;
       
   584 	runs[0].iLength = 10;
       
   585 	bs.ReorderLine(runs, 1, ETrue, EFalse, EFalse, TChar::ERightToLeft,
       
   586 		TChar::ERightToLeft, ambig);
       
   587 	TEST(ambig && ambig != 3000);
       
   588 	ambig = 3000;
       
   589 	bs.Reset();
       
   590 	runs[0].iCategory = TChar::ELeftToRight;
       
   591 	runs[0].iStart = 0;
       
   592 	runs[0].iLength = 10;
       
   593 	bs.ReorderLine(runs, 1, ETrue, EFalse, EFalse, TChar::EOtherNeutral,
       
   594 		TChar::ERightToLeft, ambig);
       
   595 	TEST(ambig && ambig != 3000);
       
   596 
       
   597 	// left to right following on from right to left paragraph is ambiguous
       
   598 	ambig = 3000;
       
   599 	bs.Reset();
       
   600 	runs[0].iCategory = TChar::ERightToLeft;
       
   601 	runs[0].iStart = 0;
       
   602 	runs[0].iLength = 10;
       
   603 	bs.ReorderLine(runs, 1, ETrue, EFalse, ETrue, TChar::ELeftToRight,
       
   604 		TChar::ELeftToRight, ambig);
       
   605 	TEST(ambig && ambig != 3000);
       
   606 	ambig = 3000;
       
   607 	bs.Reset();
       
   608 	runs[0].iCategory = TChar::ERightToLeft;
       
   609 	runs[0].iStart = 0;
       
   610 	runs[0].iLength = 10;
       
   611 	bs.ReorderLine(runs, 1, ETrue, EFalse, ETrue, TChar::EOtherNeutral,
       
   612 		TChar::ELeftToRight, ambig);
       
   613 	TEST(ambig && ambig != 3000);
       
   614 	}
       
   615 
       
   616 void CTBiDiDefect::TestPDEF117110L()
       
   617 	{
       
   618 	TPtrC wrappedText;
       
   619 	TPtrC expectedText;
       
   620 		
       
   621 	delete iTestFont;
       
   622 	iTestFont = new (ELeave) CTestFont;
       
   623 		
       
   624 	delete iBidiText;
       
   625 	iBidiText = TBidiText::NewL(_L("Test Text\n"), 5);
       
   626 	iBidiText->WrapText(KMaxTInt, *iTestFont, NULL, 1);
       
   627 	wrappedText.Set(iBidiText->DisplayText());
       
   628 	expectedText.Set(_L("Test Text"));
       
   629 	TEST(expectedText.Compare(wrappedText) == 0);
       
   630 		
       
   631 	delete iBidiText;
       
   632 	iBidiText = TBidiText::NewL(_L("Test Text\r"), 5);
       
   633 	iBidiText->WrapText(KMaxTInt, *iTestFont, NULL, 1);
       
   634 	wrappedText.Set(iBidiText->DisplayText());
       
   635 	expectedText.Set(_L("Test Text"));
       
   636 	TEST(expectedText.Compare(wrappedText) == 0);
       
   637 		
       
   638 	delete iBidiText;
       
   639 	iBidiText = TBidiText::NewL(_L("Test Text\r\n"), 5);
       
   640 	iBidiText->WrapText(KMaxTInt, *iTestFont, NULL, 1);
       
   641 	wrappedText.Set(iBidiText->DisplayText());
       
   642 	expectedText.Set(_L("Test Text"));
       
   643 	TEST(expectedText.Compare(wrappedText) == 0);
       
   644 		
       
   645 	delete iBidiText;
       
   646 	iBidiText = TBidiText::NewL(_L("Test Text\x2028"), 5);
       
   647 	iBidiText->WrapText(KMaxTInt, *iTestFont, NULL, 1);
       
   648 	wrappedText.Set(iBidiText->DisplayText());
       
   649 	expectedText.Set(_L("Test Text"));
       
   650 	TEST(expectedText.Compare(wrappedText) == 0);
       
   651 		
       
   652 	delete iBidiText;
       
   653 	iBidiText = TBidiText::NewL(_L("Test Text\n\x2028"), 5);
       
   654 	iBidiText->WrapText(KMaxTInt, *iTestFont, NULL, 2);
       
   655 	wrappedText.Set(iBidiText->DisplayText());
       
   656 	expectedText.Set(_L("Test Text\x2028"));
       
   657 	TEST(expectedText.Compare(wrappedText) == 0);
       
   658 		
       
   659 	delete iBidiText;
       
   660 	iBidiText = TBidiText::NewL(_L("Test\nText\n"), 5);
       
   661 	iBidiText->WrapText(KMaxTInt, *iTestFont, NULL, 2);
       
   662 	wrappedText.Set(iBidiText->DisplayText());
       
   663 	expectedText.Set(_L("Test\x2028Text"));
       
   664 	TEST(expectedText.Compare(wrappedText) == 0);
       
   665 	
       
   666 	delete iBidiText;
       
   667 	iBidiText = TBidiText::NewL(_L("Test\nText\n"), 5);
       
   668 	iBidiText->WrapText(KMaxTInt, *iTestFont, NULL, 1);
       
   669 	wrappedText.Set(iBidiText->DisplayText());
       
   670 	expectedText.Set(_L("Test\x2026"));
       
   671 	TEST(expectedText.Compare(wrappedText) == 0);
       
   672 		
       
   673 	delete iBidiText;
       
   674 	iBidiText = TBidiText::NewL(_L("TestText\n"), 5);
       
   675 	iBidiText->WrapText(45, *iTestFont, NULL, 2);
       
   676 	wrappedText.Set(iBidiText->DisplayText());
       
   677 	expectedText.Set(_L("Test\x2028Text"));
       
   678 	TEST(expectedText.Compare(wrappedText) == 0);
       
   679 		
       
   680 	delete iBidiText;
       
   681 	iBidiText = TBidiText::NewL(_L("Test Text"), 5);
       
   682 	iBidiText->WrapText(KMaxTInt, *iTestFont, NULL, 1);
       
   683 	wrappedText.Set(iBidiText->DisplayText());
       
   684 	expectedText.Set(_L("Test Text"));
       
   685 	TEST(expectedText.Compare(wrappedText) == 0);
       
   686 		
       
   687 	delete iBidiText;
       
   688 	iBidiText = NULL;
       
   689 	delete iTestFont;
       
   690 	iTestFont = NULL;
       
   691 	}
       
   692 
       
   693 //--------------
       
   694 CTBiDiDefectStep::CTBiDiDefectStep()
       
   695 	{
       
   696 	SetTestStepName(KTBiDiDefectStep);
       
   697 	}
       
   698 
       
   699 CTGraphicsBase* CTBiDiDefectStep::CreateTestL()
       
   700 	{
       
   701 	return new (ELeave) CTBiDiDefect(this);
       
   702 	}