1 /* |
1 /* |
2 * Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2002-2010 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". |
21 #include "TGraphicsContext.h" |
21 #include "TGraphicsContext.h" |
22 #include <gdi.h> |
22 #include <gdi.h> |
23 #include "TAGMA.H" |
23 #include "TAGMA.H" |
24 #include "TmLayoutImp.h" |
24 #include "TmLayoutImp.h" |
25 #include "TMINTERP.H" |
25 #include "TMINTERP.H" |
26 |
26 #include "tbidicursorpos.h" |
27 CTrapCleanup* TrapCleanup; |
27 |
28 RTest test(_L("TBidiCursorPos - GetNextVisualCursorPos tests")); |
28 namespace LocalToTBidiCursorPos |
|
29 { |
|
30 CTBidiCursorPosStep* TestStep; |
|
31 #define TESTPOINT(p) TestStep->testpoint(p,(TText8*)__FILE__,__LINE__) |
|
32 #define TESTPRINT(p) TestStep->print(p,(TText8*)__FILE__,__LINE__) |
|
33 |
|
34 } |
|
35 |
|
36 using namespace LocalToTBidiCursorPos; |
29 |
37 |
30 class CTestSource : public CBase, public MTmSource |
38 class CTestSource : public CBase, public MTmSource |
31 { |
39 { |
32 public: |
40 public: |
33 static CTestSource* NewLC(); |
41 static CTestSource* NewLC(); |
187 TBuf<40> msg; |
195 TBuf<40> msg; |
188 |
196 |
189 for (TInt ii = 0; ii < NO_OF_TEST_CASES; ii++) |
197 for (TInt ii = 0; ii < NO_OF_TEST_CASES; ii++) |
190 { |
198 { |
191 msg.Format(_L("GetNextVisualCursorPos test case %d\n"), ii + 1); |
199 msg.Format(_L("GetNextVisualCursorPos test case %d\n"), ii + 1); |
192 test.Next(msg); |
200 TESTPRINT(msg); |
193 aSource->SetText(logicalText[ii]); |
201 aSource->SetText(logicalText[ii]); |
194 format.iEndChar = logicalText[ii]->Length(); |
202 format.iEndChar = logicalText[ii]->Length(); |
195 if (rightToLeftPara[ii]) |
203 if (rightToLeftPara[ii]) |
196 aSource->iParFormat.iFlags |= RTmParFormat::ERightToLeft; |
204 aSource->iParFormat.iFlags |= RTmParFormat::ERightToLeft; |
197 aLayout->SetTextL(*aSource, format); |
205 aLayout->SetTextL(*aSource, format); |
202 while (aLayout->GetNextVisualCursorPos(pos, info, moveToLeft[ii])) |
210 while (aLayout->GetNextVisualCursorPos(pos, info, moveToLeft[ii])) |
203 { |
211 { |
204 while (info.iDocPos.iPos != expectedCursorPos[ii][charIndex].iPos |
212 while (info.iDocPos.iPos != expectedCursorPos[ii][charIndex].iPos |
205 || info.iDocPos.iLeadingEdge != expectedCursorPos[ii][charIndex].iLeading) |
213 || info.iDocPos.iLeadingEdge != expectedCursorPos[ii][charIndex].iLeading) |
206 { |
214 { |
207 test(expectedCursorPos[ii][charIndex].iOptional); |
215 TESTPOINT(expectedCursorPos[ii][charIndex].iOptional); |
208 ++charIndex; |
216 ++charIndex; |
209 test(charIndex != numberOfCursorPositionsToCheck[ii]); |
217 TESTPOINT(charIndex != numberOfCursorPositionsToCheck[ii]); |
210 } |
218 } |
211 pos = info.iDocPos; |
219 pos = info.iDocPos; |
212 ++charIndex; |
220 ++charIndex; |
213 test(charIndex <= numberOfCursorPositionsToCheck[ii]); |
221 TESTPOINT(charIndex <= numberOfCursorPositionsToCheck[ii]); |
214 } |
222 } |
215 test(charIndex == numberOfCursorPositionsToCheck[ii]); |
223 TESTPOINT(charIndex == numberOfCursorPositionsToCheck[ii]); |
216 aSource->iParFormat.iFlags &= ~(RTmParFormat::ERightToLeft); // reset back to default of LeftToRight |
224 aSource->iParFormat.iFlags &= ~(RTmParFormat::ERightToLeft); // reset back to default of LeftToRight |
217 } |
225 } |
218 |
226 |
219 CleanupStack::PopAndDestroy(NO_OF_TEST_CASES); // cleanup all HBufC* stored in logicalText array |
227 CleanupStack::PopAndDestroy(NO_OF_TEST_CASES); // cleanup all HBufC* stored in logicalText array |
220 } |
228 } |
255 TInt type = 0; |
263 TInt type = 0; |
256 TInt pos = 0; |
264 TInt pos = 0; |
257 TTmDocPosSpec posSpec(pos,static_cast<TTmDocPosSpec::TType>(type)); |
265 TTmDocPosSpec posSpec(pos,static_cast<TTmDocPosSpec::TType>(type)); |
258 TBool result = aLayout->GetCursor(posSpec, ECursorVertical, |
266 TBool result = aLayout->GetCursor(posSpec, ECursorVertical, |
259 lineInfo, position, width, ascent, descent); |
267 lineInfo, position, width, ascent, descent); |
260 test(result); |
268 TESTPOINT(result); |
261 //Test that the LHS is non negative. Because we are allowing bidirectional text the |
269 //Test that the LHS is non negative. Because we are allowing bidirectional text the |
262 //text shouldnt wrap to next line but instead the cursor can scroll left or right to see the text. |
270 //text shouldnt wrap to next line but instead the cursor can scroll left or right to see the text. |
263 test(lineInfo.iInnerRect.iTl.iX >= 0); |
271 TESTPOINT(lineInfo.iInnerRect.iTl.iX >= 0); |
264 CleanupStack::PopAndDestroy(buf); |
272 CleanupStack::PopAndDestroy(buf); |
265 } |
273 } |
266 |
274 |
267 /** INC041367 - Cursor in wrong position when it is one char before the |
275 /** INC041367 - Cursor in wrong position when it is one char before the |
268 beginning of RTL text. |
276 beginning of RTL text. |
295 TInt descent; |
303 TInt descent; |
296 TTmDocPosSpec posSpec(pos, |
304 TTmDocPosSpec posSpec(pos, |
297 static_cast<TTmDocPosSpec::TType>(type)); |
305 static_cast<TTmDocPosSpec::TType>(type)); |
298 TBool result = aLayout->GetCursor(posSpec, ECursorVertical, |
306 TBool result = aLayout->GetCursor(posSpec, ECursorVertical, |
299 lineInfo, position, width, ascent, descent); |
307 lineInfo, position, width, ascent, descent); |
300 test(result); |
308 TESTPOINT(result); |
301 test(0 < width); |
309 TESTPOINT(0 < width); |
302 } |
310 } |
303 } |
311 } |
304 CleanupStack::PopAndDestroy(buf); |
312 CleanupStack::PopAndDestroy(buf); |
305 } |
313 } |
306 |
314 |
307 void RunTestsL() |
315 TVerdict CTBidiCursorPosStep::doTestStepL() |
308 { |
316 { |
|
317 SetTestStepResult(EPass); |
|
318 TestStep = this; |
|
319 TESTPRINT(_L("TBidiCursorPos - GetNextVisualCursorPos tests")); |
309 CTmTextLayout* layout = new(ELeave) CTmTextLayout; |
320 CTmTextLayout* layout = new(ELeave) CTmTextLayout; |
310 CleanupStack::PushL(layout); |
321 CleanupStack::PushL(layout); |
311 CTestSource* source = CTestSource::NewLC(); |
322 CTestSource* source = CTestSource::NewLC(); |
312 test.Start(_L(" @SYMTestCaseID:SYSLIB-FORM-UT-3610 GetNextVisualCursorPos tests ")); |
323 TESTPRINT(_L(" @SYMTestCaseID:SYSLIB-FORM-UT-3610 GetNextVisualCursorPos tests ")); |
313 GetNextVisualCursorPosTestsL(layout, source); |
324 GetNextVisualCursorPosTestsL(layout, source); |
314 test.Next(_L("INC041367")); |
325 TESTPRINT(_L("INC041367")); |
315 INC041367(layout, source); |
326 INC041367(layout, source); |
316 test.Next(_L("DEF109737")); |
327 TESTPRINT(_L("DEF109737")); |
317 DEF109737(layout, source); |
328 DEF109737(layout, source); |
318 test.End(); |
329 |
319 CleanupStack::PopAndDestroy(source); |
330 CleanupStack::PopAndDestroy(source); |
320 CleanupStack::PopAndDestroy(layout); |
331 CleanupStack::PopAndDestroy(layout); |
321 } |
332 return TestStepResult(); |
322 |
333 } |
323 TInt E32Main() |
334 |
324 { |
|
325 TrapCleanup = CTrapCleanup::New(); |
|
326 TRAPD(err, RunTestsL()); |
|
327 test(err == KErrNone); |
|
328 test.Close(); |
|
329 delete TrapCleanup; |
|
330 return 0; |
|
331 } |
|