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