os/graphics/graphicsdeviceinterface/gdi/tgdi/TBiDiDefect.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/graphics/graphicsdeviceinterface/gdi/tgdi/TBiDiDefect.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,702 @@
     1.4 +// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +#include <biditext.h>
    1.20 +#include <bidi.h>
    1.21 +#include <bidivisual.h>
    1.22 +#include "TGraphicsContext.h"
    1.23 +#include "TBiDiDefect.h"
    1.24 +
    1.25 +class CTBiDiDefect : public CTGraphicsBase
    1.26 +	{
    1.27 +
    1.28 +public:
    1.29 +	CTBiDiDefect(CTestStep* aStep);
    1.30 +	~CTBiDiDefect();
    1.31 +
    1.32 +protected:
    1.33 +//from 	CTGraphicsStep
    1.34 +	virtual void RunTestCaseL(TInt aCurTestCase);
    1.35 +
    1.36 +private:
    1.37 +	void CreateTestGraphicsContextL();
    1.38 +
    1.39 +	void INC016328L(const TDesC& aTestText);
    1.40 +	void INC016665L();
    1.41 +	void INC017825L();
    1.42 +	void INC017974L();
    1.43 +	void INC017991L();
    1.44 +	void DEF021227();
    1.45 +	void INC023337();
    1.46 +	void INC023917();
    1.47 +	void DEF037928();
    1.48 +	void DEF021347L();
    1.49 +	void INC037549L();
    1.50 +	void INC042422L();
    1.51 +	void DEF059214L();
    1.52 +
    1.53 +	void TestDEF021347L(TUint16 aControlCharacter);
    1.54 +	void TestDEF043720L();
    1.55 +	
    1.56 +	void TestPDEF117110L();
    1.57 +
    1.58 +private:
    1.59 +	TBidirectionalState::TRunInfo* iRunInfoArray;
    1.60 +	CTestFont* iTestFont;
    1.61 +	TBidiText* iBidiText;
    1.62 +	CTestGraphicsDevice* iTestGraphicsDevice;
    1.63 +	CTestGraphicsContext* iTestGraphicsContext;
    1.64 +	};
    1.65 +
    1.66 +
    1.67 +CTBiDiDefect::CTBiDiDefect(CTestStep* aStep) :
    1.68 +	CTGraphicsBase(aStep),
    1.69 +	iRunInfoArray(NULL),
    1.70 +	iTestFont(NULL),
    1.71 +	iBidiText(NULL),
    1.72 +	iTestGraphicsDevice(NULL),
    1.73 +	iTestGraphicsContext(NULL)
    1.74 +	{
    1.75 +	}
    1.76 +
    1.77 +CTBiDiDefect::~CTBiDiDefect()
    1.78 +	{
    1.79 +	delete iTestGraphicsContext;
    1.80 +	delete iTestGraphicsDevice;
    1.81 +	delete iBidiText;
    1.82 +	delete iTestFont;
    1.83 +	delete [] iRunInfoArray;
    1.84 +	}
    1.85 +
    1.86 +void CTBiDiDefect::RunTestCaseL(TInt aCurTestCase)
    1.87 +	{
    1.88 +    ((CTBiDiDefectStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
    1.89 +	switch(aCurTestCase)
    1.90 +		{
    1.91 +	case 1:
    1.92 +		{
    1.93 +/**
    1.94 +   @SYMTestCaseID          	GRAPHICS-GDI-BiDiDefect-0001
    1.95 +*/
    1.96 +		((CTBiDiDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-GDI-BiDiDefect-0001"));
    1.97 +		TBuf<32> testText(_L(".Test"));
    1.98 +		INFO_PRINTF1(_L("INC016328"));
    1.99 +		INC016328L(testText);
   1.100 +		}
   1.101 +		break;
   1.102 +	case 2:
   1.103 +/**
   1.104 +   @SYMTestCaseID          	GRAPHICS-GDI-BiDiDefect-0002
   1.105 +*/
   1.106 +		((CTBiDiDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-GDI-BiDiDefect-0002"));
   1.107 +		INFO_PRINTF1(_L("INC016665"));
   1.108 +		INC016665L();
   1.109 +		break;
   1.110 +	case 3:
   1.111 +/**
   1.112 +   @SYMTestCaseID          	GRAPHICS-GDI-BiDiDefect-0003
   1.113 +*/
   1.114 +		((CTBiDiDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-GDI-BiDiDefect-0003"));
   1.115 +		INFO_PRINTF1(_L("INC017825"));
   1.116 +		INC017825L();
   1.117 +		break;
   1.118 +	case 4:
   1.119 +/**
   1.120 +   @SYMTestCaseID          	GRAPHICS-GDI-BiDiDefect-0004
   1.121 +*/
   1.122 +		((CTBiDiDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-GDI-BiDiDefect-0004"));
   1.123 +		INFO_PRINTF1(_L("INC017974"));
   1.124 +		INC017974L();
   1.125 +		break;
   1.126 +	case 5:
   1.127 +/**
   1.128 +   @SYMTestCaseID          	GRAPHICS-GDI-BiDiDefect-0005
   1.129 +*/
   1.130 +		((CTBiDiDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-GDI-BiDiDefect-0005"));
   1.131 +		INFO_PRINTF1(_L("INC017991"));
   1.132 +		INC017991L();
   1.133 +		break;
   1.134 +	case 6:
   1.135 +/**
   1.136 +   @SYMTestCaseID          	GRAPHICS-GDI-BiDiDefect-0006
   1.137 +*/
   1.138 +		((CTBiDiDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-GDI-BiDiDefect-0006"));
   1.139 +		INFO_PRINTF1(_L("DEF021227"));
   1.140 +		DEF021227();
   1.141 +		break;
   1.142 +	case 7:
   1.143 +/**
   1.144 +   @SYMTestCaseID          	GRAPHICS-GDI-BiDiDefect-0007
   1.145 +*/
   1.146 +		((CTBiDiDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-GDI-BiDiDefect-0007"));
   1.147 +		INFO_PRINTF1(_L("DEF021347"));
   1.148 +		DEF021347L();
   1.149 +		break;
   1.150 +	case 8:
   1.151 +/**
   1.152 +   @SYMTestCaseID          	GRAPHICS-GDI-BiDiDefect-0008
   1.153 +*/
   1.154 +		((CTBiDiDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-GDI-BiDiDefect-0008"));
   1.155 +		INFO_PRINTF1(_L("INC023337"));
   1.156 +		INC023337();
   1.157 +		break;
   1.158 +	case 9:
   1.159 +/**
   1.160 +   @SYMTestCaseID          	GRAPHICS-GDI-BiDiDefect-0009
   1.161 +*/
   1.162 +		((CTBiDiDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-GDI-BiDiDefect-0009"));
   1.163 +		INFO_PRINTF1(_L("INC023917"));
   1.164 +		INC023917();
   1.165 +		break;
   1.166 +	case 10:
   1.167 +/**
   1.168 +   @SYMTestCaseID          	GRAPHICS-GDI-BiDiDefect-0010
   1.169 +*/
   1.170 +		((CTBiDiDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-GDI-BiDiDefect-0010"));
   1.171 +		INFO_PRINTF1(_L("DEF037928"));
   1.172 +		DEF037928();
   1.173 +		break;
   1.174 +	case 11:
   1.175 +/**
   1.176 +   @SYMTestCaseID          	GRAPHICS-GDI-BiDiDefect-0011
   1.177 +*/
   1.178 +	//INC037549 TBidiText crashes if  <CR><LF> appear at the end of the text
   1.179 +		((CTBiDiDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-GDI-BiDiDefect-0011"));
   1.180 +		INFO_PRINTF1(_L("INC037549L"));
   1.181 +		INC037549L();
   1.182 +		break;
   1.183 +	case 12:
   1.184 +/**
   1.185 +   @SYMTestCaseID          	GRAPHICS-GDI-BiDiDefect-0012
   1.186 +*/
   1.187 +	//INC042422 when calculated length in BidiCompact.cpp TRunInfoCompact::Reorder < 0
   1.188 +		((CTBiDiDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-GDI-BiDiDefect-0012"));
   1.189 +		INFO_PRINTF1(_L("INC042422L"));
   1.190 +		INC042422L();
   1.191 +		break;
   1.192 +	case 13:
   1.193 +/**
   1.194 +   @SYMTestCaseID          	GRAPHICS-GDI-BiDiDefect-0013
   1.195 +*/
   1.196 +		((CTBiDiDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-GDI-BiDiDefect-0013"));
   1.197 +		INFO_PRINTF1(_L("DEF043720"));
   1.198 +		TestDEF043720L();
   1.199 +		break;
   1.200 +	case 14:
   1.201 +/**
   1.202 +   @SYMTestCaseID          	GRAPHICS-GDI-BiDiDefect-0014
   1.203 +*/
   1.204 +		((CTBiDiDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-GDI-BiDiDefect-0014"));
   1.205 +		INFO_PRINTF1(_L("DEF059214: Erroneous caret cursor movements"));
   1.206 +		DEF059214L();
   1.207 +		break;
   1.208 +	case 15:
   1.209 +/**
   1.210 +   @SYMTestCaseID          	GRAPHICS-GDI-BiDiDefect-0015
   1.211 +*/
   1.212 +		((CTBiDiDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-GDI-BiDiDefect-0015"));
   1.213 +		INFO_PRINTF1(_L("PDEF117110"));
   1.214 +		TestPDEF117110L();
   1.215 +		break;
   1.216 +	case 16:
   1.217 +		((CTBiDiDefectStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
   1.218 +		((CTBiDiDefectStep*)iStep)->CloseTMSGraphicsStep();
   1.219 +		TestComplete();
   1.220 +		break;
   1.221 +		}
   1.222 +        ((CTBiDiDefectStep*)iStep)->RecordTestResultL();
   1.223 +	}
   1.224 +
   1.225 +void CTBiDiDefect::CreateTestGraphicsContextL()
   1.226 +	{
   1.227 +	delete iTestGraphicsContext;
   1.228 +	iTestGraphicsContext = NULL;
   1.229 +	delete iTestGraphicsDevice;
   1.230 +	iTestGraphicsDevice = NULL;
   1.231 +	
   1.232 +	TSize windowSize(400, 400);
   1.233 +	iTestGraphicsDevice = CTestGraphicsDevice::NewL(windowSize);
   1.234 +	CGraphicsContext* tContext = NULL;	
   1.235 +	TEST(iTestGraphicsDevice->CreateContext(tContext) == KErrNone);
   1.236 +	iTestGraphicsContext = static_cast<CTestGraphicsContext*>(tContext);
   1.237 +	}
   1.238 +
   1.239 +//TBidiText crashes if the first character of the text is '.'.
   1.240 +void CTBiDiDefect::INC016328L(const TDesC& aTestText)
   1.241 +	{
   1.242 +	TInt arraySize = TBidirectionalState::GenerateBdRunArray(aTestText.Ptr(), aTestText.Length(), 0, 0);
   1.243 +	iRunInfoArray = new (ELeave) TBidirectionalState::TRunInfo[arraySize];
   1.244 +	TBidirectionalState::GenerateBdRunArray(aTestText.Ptr(), aTestText.Length(), iRunInfoArray, arraySize);
   1.245 +	TBidirectionalState state;
   1.246 +	state.ReorderLine(iRunInfoArray, arraySize, ETrue, ETrue, EFalse, TChar::EOtherNeutral, TChar::EOtherNeutral);
   1.247 +	TEST(iRunInfoArray->iLength > 0);
   1.248 +	}
   1.249 +
   1.250 +//Truncation after space character in Bidirectional text classes.
   1.251 +//Actually it doesn't prove missing space character but proves 
   1.252 +//truncation at the middle of "text" word - yet another defect.
   1.253 +void CTBiDiDefect::INC016665L()
   1.254 +	{
   1.255 +	iTestFont = new (ELeave) CTestFont;
   1.256 +	iBidiText = TBidiText::NewL(_L("Truncated text"), 1);
   1.257 +	iBidiText->WrapText(110, *iTestFont, NULL);//"Truncated " and "text"
   1.258 +	TEST(iBidiText->DisplayText().Length() == 10);
   1.259 +	TEST(iBidiText->DisplayText()[9] == 0x2026);
   1.260 +	delete (iBidiText);
   1.261 +
   1.262 +	iBidiText = TBidiText::NewL(_L("Truncated     text"), 1);
   1.263 +	iBidiText->WrapText(110, *iTestFont, NULL);//"Truncated " and "text"
   1.264 +	TEST(iBidiText->DisplayText().Length() == 10);
   1.265 +	TEST(iBidiText->DisplayText()[9] == 0x2026);
   1.266 +	}
   1.267 +
   1.268 +//TBidiText crashes with length 0 descriptor.
   1.269 +void CTBiDiDefect::INC017825L()
   1.270 +	{
   1.271 +	delete iTestGraphicsContext;
   1.272 +	iTestGraphicsContext = NULL;
   1.273 +	CreateTestGraphicsContextL();
   1.274 +
   1.275 +	delete iTestFont;
   1.276 +	iTestFont = NULL;
   1.277 +	iTestFont = new (ELeave) CTestFont;
   1.278 +
   1.279 +	delete iBidiText;
   1.280 +	iBidiText = NULL;
   1.281 +	iBidiText = TBidiText::NewL(KNullDesC(), 1);
   1.282 +	iBidiText->WrapText(100, *iTestFont, NULL);
   1.283 +
   1.284 +	iBidiText->DrawText(*iTestGraphicsContext, TPoint(0, 20), 20, CGraphicsContext::ERight);
   1.285 +	}
   1.286 +
   1.287 +//BidiText does not show 0x062A character correctly if it is a first character.
   1.288 +void CTBiDiDefect::INC017974L()
   1.289 +	{
   1.290 +	_LIT(KTextWithLatinLettersFirstArabicLetter, "\x062A abcdef");
   1.291 +	
   1.292 +	delete iTestFont;
   1.293 +	iTestFont = NULL;
   1.294 +	iTestFont = new (ELeave) CTestFont;
   1.295 +
   1.296 +	delete iBidiText;
   1.297 +	iBidiText = NULL;
   1.298 +	iBidiText = TBidiText::NewL(KTextWithLatinLettersFirstArabicLetter, 1);
   1.299 +	iBidiText->WrapText(100, *iTestFont, NULL);
   1.300 +	const TText* text = iBidiText->DisplayText().Ptr();
   1.301 +	TEST(text[7] == 0x062A);//the arabic character should be the first at the end.
   1.302 +	}
   1.303 +
   1.304 +//TBidiText::DrawText draws out of the area if alignment is right.
   1.305 +void CTBiDiDefect::INC017991L()
   1.306 +	{
   1.307 +	delete iTestGraphicsContext;
   1.308 +	iTestGraphicsContext = NULL;
   1.309 +	CreateTestGraphicsContextL();
   1.310 +
   1.311 +	_LIT(KTextWithLatinLetters, "abc def ghijk lmnop qrstuvw xyz 12.34.");
   1.312 +	const TInt KTextWidth = 200;
   1.313 +
   1.314 +	delete iTestFont;
   1.315 +	iTestFont = NULL;
   1.316 +	iTestFont = new (ELeave) CTestFont;
   1.317 +
   1.318 +	delete iBidiText;
   1.319 +	iBidiText = NULL;
   1.320 +	iBidiText = TBidiText::NewL(KTextWithLatinLetters, 2);
   1.321 +	iBidiText->WrapText(KTextWidth, *iTestFont, NULL);
   1.322 +
   1.323 +	iBidiText->DrawText(*iTestGraphicsContext, TPoint(0, 20), 20, CGraphicsContext::ERight);
   1.324 +	const TTestGCDisplayLine& line1 = iTestGraphicsContext->DisplayLine(0);
   1.325 +	const TDesC& text1 = line1.iLineData;
   1.326 +	TInt width1 = iTestFont->TextWidthInPixels(text1);
   1.327 +	TEST((width1 + line1.iLinePos.iX) <= KTextWidth);
   1.328 +	const TTestGCDisplayLine& line2 = iTestGraphicsContext->DisplayLine(1);
   1.329 +	const TDesC& text2 = line2.iLineData;
   1.330 +	TInt width2 = iTestFont->TextWidthInPixels(text2);
   1.331 +	TEST((width2 + line2.iLinePos.iX) <= KTextWidth);
   1.332 +	}
   1.333 +
   1.334 +//TBidiLogicalToVisual seems to lose characters. 
   1.335 +void CTBiDiDefect::DEF021227()
   1.336 +	{
   1.337 +	_LIT(KTestText, "Waitnote + D prompt ");
   1.338 +// 	_LIT(KTestText, "Waitnote H D prompt ");
   1.339 +	TBuf<100> visualText;
   1.340 +	visualText.Fill(0xCDCD);
   1.341 +	TBidirectionalState::TRunInfo runArray[6];
   1.342 +
   1.343 +	TBidiLogicalToVisual bidiConverter(KTestText, EFalse, runArray,
   1.344 +		sizeof(runArray)/sizeof(runArray[0]));
   1.345 +	bidiConverter.Reorder();
   1.346 +	TDesC des = KTestText;
   1.347 +	bidiConverter.GetVisualLine(visualText, 0, des.Length() - 1, 0xFFFF);
   1.348 +	TInt len = visualText.Length();
   1.349 +	TEST((des.Length() - 1) == len);
   1.350 +	}
   1.351 +
   1.352 +//DrawText should not draw control codes (particularly Bidirectional ones)
   1.353 +void CTBiDiDefect::DEF021347L()
   1.354 +	{
   1.355 +	TestDEF021347L(0x200C);
   1.356 +	TestDEF021347L(0x200D);
   1.357 +	TestDEF021347L(0x200E);
   1.358 +	TestDEF021347L(0x200F);
   1.359 +	TestDEF021347L(0x202A);
   1.360 +	TestDEF021347L(0x202B);
   1.361 +	TestDEF021347L(0x202C);
   1.362 +	TestDEF021347L(0x202D);
   1.363 +	TestDEF021347L(0x202E);
   1.364 +	// Tested in TGLYPHSEL now following rewrite.
   1.365 +	//TestDEF021347L(0xFFFF);
   1.366 +	}
   1.367 +
   1.368 +void CTBiDiDefect::TestDEF021347L(TUint16 aControlCharacter)
   1.369 +	{
   1.370 +	const TInt KTestTextLen = 5;
   1.371 +	TBuf<100> testText(KTestTextLen);
   1.372 +	testText[0] = 'a';
   1.373 +	testText[1] = 'b';
   1.374 +	testText[2] = aControlCharacter;
   1.375 +	testText[3] = 'c';
   1.376 +	testText[4] = 'd';
   1.377 +
   1.378 +	delete iTestFont;
   1.379 +	iTestFont = NULL;
   1.380 +	iTestFont = new (ELeave) CTestFont;
   1.381 +
   1.382 +	CFont::TPositionParam param;
   1.383 +	param.iDirection = 0;
   1.384 +	param.iFlags = 1;
   1.385 +	param.iText.Set(testText);
   1.386 +	param.iPosInText = 0;
   1.387 +	param.iPen.iX = 0;
   1.388 +	param.iPen.iY = 0;
   1.389 +	param.iPosInText = 2; //testText[2] = aControlCharacter
   1.390 +	TBool r = iTestFont->GetCharacterPosition(param);
   1.391 +
   1.392 +	TEST(r && param.iPen.iX == 0 && param.iOutputGlyphs == 0);
   1.393 +	}
   1.394 +
   1.395 +//TBidiLogicalToVisual::GetVisualLine() panics when aEnd == 0 
   1.396 +void CTBiDiDefect::INC023337()
   1.397 +	{
   1.398 +	_LIT(KTestText, "");
   1.399 +	TBuf<100> visualText;
   1.400 +	visualText.Fill(0xCDCD);
   1.401 +	TBidirectionalState::TRunInfo runArray[6];
   1.402 +	TBidiLogicalToVisual bidiConverter(KTestText, EFalse, runArray, sizeof(runArray)/sizeof(runArray[0]));
   1.403 +	bidiConverter.Reorder();
   1.404 +
   1.405 +	TDesC des = KTestText;
   1.406 +	const TUint KEmptyChar = TUint(0xFFFF);
   1.407 +	//The next statement will panics, if INC023337 is not fixed.
   1.408 +	bidiConverter.GetVisualLine(visualText, 0, des.Length(), KEmptyChar);
   1.409 +	}
   1.410 +
   1.411 +//TBidiLogicalToVisual indexes over the given text.
   1.412 +void CTBiDiDefect::INC023917()
   1.413 +	{
   1.414 +	const TInt dest_buf_len = 10;
   1.415 +	TBidirectionalState::TRunInfo runInfoArray[dest_buf_len];
   1.416 +	const TInt src_buf_len = 4;
   1.417 +    TBuf<src_buf_len> logical;
   1.418 +    logical.Fill(0x0639, src_buf_len);
   1.419 +
   1.420 +    _LIT(KArabicWord, "\x0631\x0641\x0636");
   1.421 +    logical = KArabicWord;
   1.422 +
   1.423 +    TBidiLogicalToVisual bidiConverter(logical, runInfoArray, sizeof(runInfoArray)/sizeof(runInfoArray[0]));
   1.424 +    bidiConverter.Reorder();
   1.425 +
   1.426 +    TBuf<dest_buf_len> visual;
   1.427 +    bidiConverter.GetVisualLine(visual, 0, logical.Length(), 0xFFFF);
   1.428 +
   1.429 +	TEST(visual[0] == 0x0636);
   1.430 +	}
   1.431 +
   1.432 +// DEF037928 - TBidiLogicalToVisual::GetVisualLine does not work correctly for 0 length strings
   1.433 +void CTBiDiDefect::DEF037928()
   1.434 +	{
   1.435 +	// Zero length string for testing
   1.436 +	_LIT(KTestText, "");
   1.437 +	TBuf<100> visualText;
   1.438 +	visualText.Fill(0xCDCD);
   1.439 +	visualText.SetMax();
   1.440 +	
   1.441 +	TBidirectionalState::TRunInfo runArray[6];
   1.442 +	TBidiLogicalToVisual bidiConverter(KTestText, EFalse, runArray,
   1.443 +		sizeof(runArray)/sizeof(runArray[0]));
   1.444 +	bidiConverter.Reorder();
   1.445 +
   1.446 +	bidiConverter.GetVisualLine(visualText, 0, 1, 0xFFFF);
   1.447 +	TEST( visualText.Length() == 0);
   1.448 +	}
   1.449 +	
   1.450 +	
   1.451 +// INC037549 - TBidiText crashes if  <CR><LF> appear at the end of the text
   1.452 +void CTBiDiDefect::INC037549L()
   1.453 +	{
   1.454 +	// This crash occured when the final character is <cr>
   1.455 +	// and following memory location is <lf>
   1.456 +	// To test this testString has a length of 5, but sPtr has length 4
   1.457 +	_LIT( testString, "123\r\n" ) ;
   1.458 +	TBuf<5> string( testString ) ;
   1.459 +	TPtrC sPtr( string.Ptr(), 4 ) ;
   1.460 +	TBidiText* bText = TBidiText::NewL( sPtr, 1, TBidiText::ELeftToRight ) ;
   1.461 +
   1.462 +	delete bText;
   1.463 +	}
   1.464 +
   1.465 +// INC042422 - when calculated length in BidiCompact.cpp TRunInfoCompact::Reorder < 0
   1.466 +//
   1.467 +// This defect causes an extra blank line to be added when text contains \r\n
   1.468 +// This was caused by a miscalculation in Biditext.cpp SizeLineBreak().
   1.469 +// this test case is modified due to change of TBidiText::DoWrapText for fixing PDEF117110
   1.470 +void CTBiDiDefect::INC042422L()
   1.471 +	{
   1.472 +	_LIT( testString, "123\r\n" ) ;
   1.473 +	TBidiText* bText = TBidiText::NewL( testString, 1, TBidiText::ELeftToRight ) ;
   1.474 +	bText->WrapText(100,*iTestFont,0);
   1.475 +	TPtrC text = bText->DisplayText(); 
   1.476 +
   1.477 +	// The defect caused text to contain an extra blank line
   1.478 +	// So the length was 5 ( text contained:1,2,3, 0x2028, 0x2026)
   1.479 +	// when the correct value is 4 (text should contain: 1,2,3, 0x2026)
   1.480 +	// Note: Due to fix for PDEF117109, the correct value is 3 now (text contains: 1,2,3)
   1.481 +	TEST(text.Length() == 3);
   1.482 +	TEST(text[0] == '1');
   1.483 +	TEST(text[1] == '2');
   1.484 +	TEST(text[2] == '3');
   1.485 +
   1.486 +	delete bText;
   1.487 +	}
   1.488 +
   1.489 +//DEF043720 - Assert fails in TBiDiText wrapping when more than one \n is present in the text 
   1.490 +void CTBiDiDefect::TestDEF043720L()
   1.491 +	{
   1.492 +	delete iTestFont;
   1.493 +	iTestFont = NULL;
   1.494 +	iTestFont = new (ELeave) CTestFont;
   1.495 +	
   1.496 +	delete iBidiText;
   1.497 +	iBidiText = NULL;
   1.498 +	iBidiText = TBidiText::NewL(_L("\n\nAB\n\n\nCD\n"),10);
   1.499 +	iBidiText->WrapText(10,*iTestFont,0);
   1.500 +
   1.501 +	//After wrapping text should look like "\x2028\x2028A\x2028B\x2028\x2028\x2028C\x2028D"
   1.502 +	//where \x2028 is the line separator
   1.503 +	TPtrC afterwrap(iBidiText->DisplayText());
   1.504 +	TEST(afterwrap.Length()==11);
   1.505 +	TEST(afterwrap[0]==0x2028);
   1.506 +	TEST(afterwrap[1]==0x2028);
   1.507 +	TEST(afterwrap[3]==0x2028);
   1.508 +	TEST(afterwrap[5]==0x2028);
   1.509 +	TEST(afterwrap[6]==0x2028);
   1.510 +	TEST(afterwrap[7]==0x2028);
   1.511 +	TEST(afterwrap[9]==0x2028);
   1.512 +
   1.513 +	INFO_PRINTF1(iBidiText->DisplayText());
   1.514 +
   1.515 +	delete iBidiText;
   1.516 +	iBidiText = NULL;
   1.517 +	delete iTestFont;
   1.518 +	iTestFont = NULL;
   1.519 +	}
   1.520 +
   1.521 +void CTBiDiDefect::DEF059214L()
   1.522 +	{
   1.523 +	TBidirectionalState::TRunInfo runs[4];
   1.524 +	TBidirectionalState bs;
   1.525 +	TBool ambig;
   1.526 +
   1.527 +	// entirely left to right paragraph is not ambiguous
   1.528 +	ambig = 3000;
   1.529 +	bs.Reset();
   1.530 +	runs[0].iCategory = TChar::ELeftToRight;
   1.531 +	runs[0].iStart = 0;
   1.532 +	runs[0].iLength = 10;
   1.533 +	bs.ReorderLine(runs, 1, ETrue, EFalse, EFalse, TChar::ELeftToRight,
   1.534 +		TChar::ELeftToRight, ambig);
   1.535 +
   1.536 +	// entirely right to left paragraph is not ambiguous
   1.537 +	ambig = 3000;
   1.538 +	bs.Reset();
   1.539 +	runs[0].iCategory = TChar::ERightToLeft;
   1.540 +	runs[0].iStart = 0;
   1.541 +	runs[0].iLength = 10;
   1.542 +	bs.ReorderLine(runs, 1, ETrue, EFalse, ETrue, TChar::ERightToLeft,
   1.543 +		TChar::ERightToLeft, ambig);
   1.544 +	TEST(!ambig);
   1.545 +
   1.546 +	// right to left portion within left to right paragraph is ambiguous
   1.547 +	ambig = 3000;
   1.548 +	bs.Reset();
   1.549 +	runs[0].iCategory = TChar::ERightToLeft;
   1.550 +	runs[0].iStart = 0;
   1.551 +	runs[0].iLength = 10;
   1.552 +	bs.ReorderLine(runs, 1, ETrue, EFalse, EFalse, TChar::ERightToLeft,
   1.553 +		TChar::ERightToLeft, ambig);
   1.554 +	TEST(ambig && ambig != 3000);
   1.555 +	ambig = 3000;
   1.556 +	bs.Reset();
   1.557 +	runs[0].iCategory = TChar::ERightToLeft;
   1.558 +	runs[0].iStart = 0;
   1.559 +	runs[0].iLength = 10;
   1.560 +	bs.ReorderLine(runs, 1, ETrue, EFalse, EFalse, TChar::EOtherNeutral,
   1.561 +		TChar::ERightToLeft, ambig);
   1.562 +	TEST(ambig && ambig != 3000);
   1.563 +
   1.564 +	// left to right portion within right to left paragraph is ambiguous
   1.565 +	ambig = 3000;
   1.566 +	bs.Reset();
   1.567 +	runs[0].iCategory = TChar::ELeftToRight;
   1.568 +	runs[0].iStart = 0;
   1.569 +	runs[0].iLength = 10;
   1.570 +	bs.ReorderLine(runs, 1, ETrue, EFalse, ETrue, TChar::ELeftToRight,
   1.571 +		TChar::ELeftToRight, ambig);
   1.572 +	TEST(ambig && ambig != 3000);
   1.573 +	ambig = 3000;
   1.574 +	bs.Reset();
   1.575 +	runs[0].iCategory = TChar::ELeftToRight;
   1.576 +	runs[0].iStart = 0;
   1.577 +	runs[0].iLength = 10;
   1.578 +	bs.ReorderLine(runs, 1, ETrue, EFalse, ETrue, TChar::EOtherNeutral,
   1.579 +		TChar::ELeftToRight, ambig);
   1.580 +	TEST(ambig && ambig != 3000);
   1.581 +
   1.582 +	// right to left following on from left to right paragraph is ambiguous
   1.583 +	ambig = 3000;
   1.584 +	bs.Reset();
   1.585 +	runs[0].iCategory = TChar::ELeftToRight;
   1.586 +	runs[0].iStart = 0;
   1.587 +	runs[0].iLength = 10;
   1.588 +	bs.ReorderLine(runs, 1, ETrue, EFalse, EFalse, TChar::ERightToLeft,
   1.589 +		TChar::ERightToLeft, ambig);
   1.590 +	TEST(ambig && ambig != 3000);
   1.591 +	ambig = 3000;
   1.592 +	bs.Reset();
   1.593 +	runs[0].iCategory = TChar::ELeftToRight;
   1.594 +	runs[0].iStart = 0;
   1.595 +	runs[0].iLength = 10;
   1.596 +	bs.ReorderLine(runs, 1, ETrue, EFalse, EFalse, TChar::EOtherNeutral,
   1.597 +		TChar::ERightToLeft, ambig);
   1.598 +	TEST(ambig && ambig != 3000);
   1.599 +
   1.600 +	// left to right following on from right to left paragraph is ambiguous
   1.601 +	ambig = 3000;
   1.602 +	bs.Reset();
   1.603 +	runs[0].iCategory = TChar::ERightToLeft;
   1.604 +	runs[0].iStart = 0;
   1.605 +	runs[0].iLength = 10;
   1.606 +	bs.ReorderLine(runs, 1, ETrue, EFalse, ETrue, TChar::ELeftToRight,
   1.607 +		TChar::ELeftToRight, ambig);
   1.608 +	TEST(ambig && ambig != 3000);
   1.609 +	ambig = 3000;
   1.610 +	bs.Reset();
   1.611 +	runs[0].iCategory = TChar::ERightToLeft;
   1.612 +	runs[0].iStart = 0;
   1.613 +	runs[0].iLength = 10;
   1.614 +	bs.ReorderLine(runs, 1, ETrue, EFalse, ETrue, TChar::EOtherNeutral,
   1.615 +		TChar::ELeftToRight, ambig);
   1.616 +	TEST(ambig && ambig != 3000);
   1.617 +	}
   1.618 +
   1.619 +void CTBiDiDefect::TestPDEF117110L()
   1.620 +	{
   1.621 +	TPtrC wrappedText;
   1.622 +	TPtrC expectedText;
   1.623 +		
   1.624 +	delete iTestFont;
   1.625 +	iTestFont = new (ELeave) CTestFont;
   1.626 +		
   1.627 +	delete iBidiText;
   1.628 +	iBidiText = TBidiText::NewL(_L("Test Text\n"), 5);
   1.629 +	iBidiText->WrapText(KMaxTInt, *iTestFont, NULL, 1);
   1.630 +	wrappedText.Set(iBidiText->DisplayText());
   1.631 +	expectedText.Set(_L("Test Text"));
   1.632 +	TEST(expectedText.Compare(wrappedText) == 0);
   1.633 +		
   1.634 +	delete iBidiText;
   1.635 +	iBidiText = TBidiText::NewL(_L("Test Text\r"), 5);
   1.636 +	iBidiText->WrapText(KMaxTInt, *iTestFont, NULL, 1);
   1.637 +	wrappedText.Set(iBidiText->DisplayText());
   1.638 +	expectedText.Set(_L("Test Text"));
   1.639 +	TEST(expectedText.Compare(wrappedText) == 0);
   1.640 +		
   1.641 +	delete iBidiText;
   1.642 +	iBidiText = TBidiText::NewL(_L("Test Text\r\n"), 5);
   1.643 +	iBidiText->WrapText(KMaxTInt, *iTestFont, NULL, 1);
   1.644 +	wrappedText.Set(iBidiText->DisplayText());
   1.645 +	expectedText.Set(_L("Test Text"));
   1.646 +	TEST(expectedText.Compare(wrappedText) == 0);
   1.647 +		
   1.648 +	delete iBidiText;
   1.649 +	iBidiText = TBidiText::NewL(_L("Test Text\x2028"), 5);
   1.650 +	iBidiText->WrapText(KMaxTInt, *iTestFont, NULL, 1);
   1.651 +	wrappedText.Set(iBidiText->DisplayText());
   1.652 +	expectedText.Set(_L("Test Text"));
   1.653 +	TEST(expectedText.Compare(wrappedText) == 0);
   1.654 +		
   1.655 +	delete iBidiText;
   1.656 +	iBidiText = TBidiText::NewL(_L("Test Text\n\x2028"), 5);
   1.657 +	iBidiText->WrapText(KMaxTInt, *iTestFont, NULL, 2);
   1.658 +	wrappedText.Set(iBidiText->DisplayText());
   1.659 +	expectedText.Set(_L("Test Text\x2028"));
   1.660 +	TEST(expectedText.Compare(wrappedText) == 0);
   1.661 +		
   1.662 +	delete iBidiText;
   1.663 +	iBidiText = TBidiText::NewL(_L("Test\nText\n"), 5);
   1.664 +	iBidiText->WrapText(KMaxTInt, *iTestFont, NULL, 2);
   1.665 +	wrappedText.Set(iBidiText->DisplayText());
   1.666 +	expectedText.Set(_L("Test\x2028Text"));
   1.667 +	TEST(expectedText.Compare(wrappedText) == 0);
   1.668 +	
   1.669 +	delete iBidiText;
   1.670 +	iBidiText = TBidiText::NewL(_L("Test\nText\n"), 5);
   1.671 +	iBidiText->WrapText(KMaxTInt, *iTestFont, NULL, 1);
   1.672 +	wrappedText.Set(iBidiText->DisplayText());
   1.673 +	expectedText.Set(_L("Test\x2026"));
   1.674 +	TEST(expectedText.Compare(wrappedText) == 0);
   1.675 +		
   1.676 +	delete iBidiText;
   1.677 +	iBidiText = TBidiText::NewL(_L("TestText\n"), 5);
   1.678 +	iBidiText->WrapText(45, *iTestFont, NULL, 2);
   1.679 +	wrappedText.Set(iBidiText->DisplayText());
   1.680 +	expectedText.Set(_L("Test\x2028Text"));
   1.681 +	TEST(expectedText.Compare(wrappedText) == 0);
   1.682 +		
   1.683 +	delete iBidiText;
   1.684 +	iBidiText = TBidiText::NewL(_L("Test Text"), 5);
   1.685 +	iBidiText->WrapText(KMaxTInt, *iTestFont, NULL, 1);
   1.686 +	wrappedText.Set(iBidiText->DisplayText());
   1.687 +	expectedText.Set(_L("Test Text"));
   1.688 +	TEST(expectedText.Compare(wrappedText) == 0);
   1.689 +		
   1.690 +	delete iBidiText;
   1.691 +	iBidiText = NULL;
   1.692 +	delete iTestFont;
   1.693 +	iTestFont = NULL;
   1.694 +	}
   1.695 +
   1.696 +//--------------
   1.697 +CTBiDiDefectStep::CTBiDiDefectStep()
   1.698 +	{
   1.699 +	SetTestStepName(KTBiDiDefectStep);
   1.700 +	}
   1.701 +
   1.702 +CTGraphicsBase* CTBiDiDefectStep::CreateTestL()
   1.703 +	{
   1.704 +	return new (ELeave) CTBiDiDefect(this);
   1.705 +	}