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