|
1 /* |
|
2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Symbian Foundation License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 /** |
|
19 @test |
|
20 @internalComponent |
|
21 |
|
22 This contains CT_DataFont |
|
23 */ |
|
24 |
|
25 // User includes |
|
26 #include "T_DataFont.h" |
|
27 |
|
28 // Epoc includes |
|
29 #include <gdi.h> |
|
30 |
|
31 /*@{*/ |
|
32 /// Parameters |
|
33 _LIT(KText, "text"); |
|
34 _LIT(KWidthAvailable, "width_available"); |
|
35 _LIT(KCalculateExcess, "calculate_excess"); |
|
36 _LIT(KExpectedExcess, "expected_excess"); |
|
37 _LIT(KExpectedResult, "expected_result"); |
|
38 _LIT(KExpectedFont, "expected_font"); |
|
39 _LIT(KCharCode, "char_code"); |
|
40 _LIT(KUid, "uid"); |
|
41 _LIT(KMeasureTextOutput, "measure_text_output"); |
|
42 _LIT(KMeasureTextInput, "measure_text_input"); |
|
43 |
|
44 /// Commands |
|
45 _LIT(KCmdFontCapitalAscent, "FontCapitalAscent"); |
|
46 _LIT(KCmdFontMaxAscent, "FontMaxAscent"); |
|
47 _LIT(KCmdFontStandardDescent, "FontStandardDescent"); |
|
48 _LIT(KCmdFontMaxDescent, "FontMaxDescent"); |
|
49 _LIT(KCmdFontLineGap, "FontLineGap"); |
|
50 _LIT(KCmdFontMaxHeight, "FontMaxHeight"); |
|
51 _LIT(KCmdTypeUid, "TypeUid"); |
|
52 _LIT(KCmdHeightInPixels, "HeightInPixels"); |
|
53 _LIT(KCmdAscentInPixels, "AscentInPixels"); |
|
54 _LIT(KCmdDescentInPixels, "DescentInPixels"); |
|
55 _LIT(KCmdCharWidthInPixels, "CharWidthInPixels"); |
|
56 _LIT(KCmdTextCount, "TextCount"); |
|
57 _LIT(KCmdMaxCharWidthInPixels, "MaxCharWidthInPixels"); |
|
58 _LIT(KCmdMaxNormalCharWidthInPixels, "MaxNormalCharWidthInPixels"); |
|
59 _LIT(KCmdFontSpecInTwips, "FontSpecInTwips"); |
|
60 _LIT(KCmdWidthZeroInPixels, "WidthZeroInPixels"); |
|
61 _LIT(KCmdBaselineOffsetInPixels, "BaselineOffsetInPixels"); |
|
62 _LIT(KCmdGetCharacterData, "GetCharacterData"); |
|
63 _LIT(KCmdMeasureText, "MeasureText"); |
|
64 _LIT(KCmdExtendedFunction, "ExtendedFunction"); |
|
65 _LIT(KCmdTextWidthInPixels, "TextWidthInPixels"); |
|
66 /*@}*/ |
|
67 |
|
68 /** |
|
69 * Constructor. First phase construction |
|
70 */ |
|
71 CT_DataFont::CT_DataFont() |
|
72 : CDataWrapperBase() |
|
73 { |
|
74 } |
|
75 |
|
76 /** |
|
77 * Process a command read from the ini file |
|
78 * |
|
79 * @param aDataWrapper test step requiring command to be processed |
|
80 * @param aCommand the command to process |
|
81 * @param aSection the entry in the ini file requiring the command to be processed |
|
82 * |
|
83 * @return ETrue if the command is processed |
|
84 */ |
|
85 TBool CT_DataFont::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt /*aAsyncErrorIndex*/) |
|
86 { |
|
87 TBool ret=ETrue; |
|
88 |
|
89 if (aCommand == KCmdFontCapitalAscent) |
|
90 { |
|
91 DoCmdFontCapitalAscent(aSection); |
|
92 } |
|
93 else if (aCommand == KCmdFontMaxAscent) |
|
94 { |
|
95 DoCmdFontMaxAscent(aSection); |
|
96 } |
|
97 else if (aCommand == KCmdFontStandardDescent) |
|
98 { |
|
99 DoCmdFontStandardDescent(aSection); |
|
100 } |
|
101 else if (aCommand == KCmdFontMaxDescent) |
|
102 { |
|
103 DoCmdFontMaxDescent(aSection); |
|
104 } |
|
105 else if (aCommand == KCmdFontLineGap) |
|
106 { |
|
107 DoCmdFontLineGap(aSection); |
|
108 } |
|
109 else if (aCommand == KCmdFontMaxHeight) |
|
110 { |
|
111 DoCmdFontMaxHeight(aSection); |
|
112 } |
|
113 else if (aCommand == KCmdTypeUid) |
|
114 { |
|
115 DoCmdTypeUid(aSection); |
|
116 } |
|
117 else if (aCommand == KCmdHeightInPixels) |
|
118 { |
|
119 DoCmdHeightInPixels(aSection); |
|
120 } |
|
121 else if (aCommand == KCmdAscentInPixels) |
|
122 { |
|
123 DoCmdAscentInPixels(aSection); |
|
124 } |
|
125 else if (aCommand == KCmdDescentInPixels) |
|
126 { |
|
127 DoCmdDescentInPixels(aSection); |
|
128 } |
|
129 else if (aCommand == KCmdCharWidthInPixels) |
|
130 { |
|
131 DoCmdCharWidthInPixels(aSection); |
|
132 } |
|
133 else if (aCommand == KCmdTextCount) |
|
134 { |
|
135 DoCmdTextCount(aSection); |
|
136 } |
|
137 else if (aCommand == KCmdMaxCharWidthInPixels) |
|
138 { |
|
139 DoCmdMaxCharWidthInPixels(aSection); |
|
140 } |
|
141 else if (aCommand == KCmdMaxNormalCharWidthInPixels) |
|
142 { |
|
143 DoCmdMaxNormalCharWidthInPixels(aSection); |
|
144 } |
|
145 else if (aCommand == KCmdFontSpecInTwips) |
|
146 { |
|
147 DoCmdFontSpecInTwips(aSection); |
|
148 } |
|
149 else if (aCommand == KCmdWidthZeroInPixels) |
|
150 { |
|
151 DoCmdWidthZeroInPixels(aSection); |
|
152 } |
|
153 else if (aCommand == KCmdBaselineOffsetInPixels) |
|
154 { |
|
155 DoCmdBaselineOffsetInPixels(aSection); |
|
156 } |
|
157 else if (aCommand == KCmdGetCharacterData) |
|
158 { |
|
159 DoCmdGetCharacterData(aSection); |
|
160 } |
|
161 else if (aCommand == KCmdMeasureText) |
|
162 { |
|
163 DoCmdMeasureTextL(aSection); |
|
164 } |
|
165 else if (aCommand == KCmdExtendedFunction) |
|
166 { |
|
167 DoCmdExtendedFunction(aSection); |
|
168 } |
|
169 else if (aCommand == KCmdTextWidthInPixels) |
|
170 { |
|
171 DoCmdTextWidthInPixels(aSection); |
|
172 } |
|
173 else |
|
174 { |
|
175 ret=EFalse; |
|
176 } |
|
177 |
|
178 return ret; |
|
179 } |
|
180 |
|
181 |
|
182 ////////////////// COMMANDS IMPLEMENTATION //////////////////////// |
|
183 |
|
184 |
|
185 /** Calls CFont::TextCount() */ |
|
186 void CT_DataFont::DoCmdTextCount(const TDesC& aSection) |
|
187 { |
|
188 INFO_PRINTF1(_L("Calls CFont::TextCount()")); |
|
189 // get text from parameters |
|
190 TPtrC text; |
|
191 if ( !GetStringFromConfig(aSection, KText(), text) ) |
|
192 { |
|
193 ERR_PRINTF2(_L("No %S"), &KText()); |
|
194 SetBlockResult(EFail); |
|
195 } |
|
196 |
|
197 // get available width from parameters |
|
198 TInt widthAvailable = 0; |
|
199 if(!GetIntFromConfig(aSection, KWidthAvailable(), widthAvailable)) |
|
200 { |
|
201 ERR_PRINTF2(_L("No %S"), &KWidthAvailable()); |
|
202 SetBlockResult(EFail); |
|
203 } |
|
204 |
|
205 // get if to use version of TextCount() that calculates excess from parameters |
|
206 TBool calculateExcess = EFalse; |
|
207 GetBoolFromConfig(aSection, KCalculateExcess(), calculateExcess); |
|
208 |
|
209 // call TextCount() |
|
210 TInt result = KErrNone; |
|
211 if ( calculateExcess ) |
|
212 { |
|
213 TInt excess = 0; |
|
214 result = GetFont()->TextCount(text, widthAvailable, excess); |
|
215 |
|
216 // get expected excess from parameters |
|
217 TInt expectedExcess = 0; |
|
218 if ( GetIntFromConfig(aSection, KExpectedExcess(), expectedExcess) ) |
|
219 { |
|
220 ERR_PRINTF1(_L("An expected excess should not be provided if calculate excess is set to false.")); |
|
221 SetBlockResult(EFail); |
|
222 } |
|
223 } |
|
224 else |
|
225 { |
|
226 result = GetFont()->TextCount(text, widthAvailable); |
|
227 } |
|
228 |
|
229 // get expected result from parameters |
|
230 TInt expectedResult = 0; |
|
231 if ( GetIntFromConfig(aSection, KExpectedResult(), expectedResult) ) |
|
232 { |
|
233 if (result != expectedResult) |
|
234 { |
|
235 ERR_PRINTF3(_L("The result is not as expected! expected: %d, actual: %d"), expectedResult, result); |
|
236 SetBlockResult(EFail); |
|
237 } |
|
238 } |
|
239 } |
|
240 |
|
241 |
|
242 /** Calls CFont::TextWidthInPixels() */ |
|
243 void CT_DataFont::DoCmdTextWidthInPixels(const TDesC& aSection) |
|
244 { |
|
245 INFO_PRINTF1(_L("Calls CFont::TextWidthInPixels()")); |
|
246 // get text from parameters |
|
247 TPtrC text; |
|
248 if (!GetStringFromConfig(aSection, KText(), text)) |
|
249 { |
|
250 ERR_PRINTF2(_L("No %S"), &KText()); |
|
251 SetBlockResult(EFail); |
|
252 } |
|
253 |
|
254 // call TextWidthInPixels() |
|
255 TInt result = GetFont()->TextWidthInPixels(text); |
|
256 |
|
257 // get expected result from parameters |
|
258 TInt expectedResult = 0; |
|
259 if(GetIntFromConfig(aSection, KExpectedResult(), expectedResult)) |
|
260 { |
|
261 if (result != expectedResult) |
|
262 { |
|
263 ERR_PRINTF3(_L("The result is not as expected! expected: %d, actual: %d"), expectedResult, result); |
|
264 SetBlockResult(EFail); |
|
265 } |
|
266 } |
|
267 } |
|
268 |
|
269 |
|
270 /** Calls CFont::CharWidthInPixels() */ |
|
271 void CT_DataFont::DoCmdCharWidthInPixels(const TDesC& aSection) |
|
272 { |
|
273 INFO_PRINTF1(_L("Calls CFont::CharWidthInPixels()")); |
|
274 // get character code from parameters |
|
275 TInt charCode = 0; |
|
276 if(!GetIntFromConfig(aSection, KCharCode(), charCode)) |
|
277 { |
|
278 ERR_PRINTF2(_L("No %S"), &KCharCode()); |
|
279 SetBlockResult(EFail); |
|
280 } |
|
281 |
|
282 // call CharWidthInPixels() |
|
283 TInt result = GetFont()->CharWidthInPixels(charCode); |
|
284 |
|
285 // get expected result from parameters |
|
286 TInt expectedResult = 0; |
|
287 if ( GetIntFromConfig(aSection, KExpectedResult(), expectedResult) ) |
|
288 { |
|
289 if (result != expectedResult) |
|
290 { |
|
291 ERR_PRINTF3(_L("The result is not as expected! expected: %d, actual: %d"), expectedResult, result); |
|
292 SetBlockResult(EFail); |
|
293 } |
|
294 } |
|
295 } |
|
296 |
|
297 |
|
298 /** Calls CFont::FontCapitalAscent() */ |
|
299 void CT_DataFont::DoCmdFontCapitalAscent(const TDesC& aSection) |
|
300 { |
|
301 INFO_PRINTF1(_L("Calls CFont::FontCapitalAscent()")); |
|
302 // call FontCapitalAscent() |
|
303 TInt result = GetFont()->FontCapitalAscent(); |
|
304 |
|
305 // get expected result from parameters |
|
306 TInt expectedResult = 0; |
|
307 if ( GetIntFromConfig(aSection, KExpectedResult(), expectedResult) ) |
|
308 { |
|
309 if (result != expectedResult) |
|
310 { |
|
311 ERR_PRINTF3(_L("The result is not as expected! expected: %d, actual: %d"), expectedResult, result); |
|
312 SetBlockResult(EFail); |
|
313 } |
|
314 } |
|
315 } |
|
316 |
|
317 |
|
318 /** Calls CFont::FontMaxAscent() */ |
|
319 void CT_DataFont::DoCmdFontMaxAscent(const TDesC& aSection) |
|
320 { |
|
321 INFO_PRINTF1(_L("Calls CFont::FontMaxAscent()")); |
|
322 // call FontMaxAscent() |
|
323 TInt result = GetFont()->FontMaxAscent(); |
|
324 |
|
325 // get expected result from parameters |
|
326 TInt expectedResult = 0; |
|
327 if ( GetIntFromConfig(aSection, KExpectedResult(), expectedResult) ) |
|
328 { |
|
329 if (result != expectedResult) |
|
330 { |
|
331 ERR_PRINTF3(_L("The result is not as expected! expected: %d, actual: %d"), expectedResult, result); |
|
332 SetBlockResult(EFail); |
|
333 } |
|
334 } |
|
335 } |
|
336 |
|
337 |
|
338 /** Calls CFont::FontStandardDescent() */ |
|
339 void CT_DataFont::DoCmdFontStandardDescent(const TDesC& aSection) |
|
340 { |
|
341 INFO_PRINTF1(_L("Calls CFont::FontStandardDescent()")); |
|
342 // call FontStandardDescent() |
|
343 TInt result = GetFont()->FontStandardDescent(); |
|
344 |
|
345 // get expected result from parameters |
|
346 TInt expectedResult = 0; |
|
347 if(GetIntFromConfig(aSection, KExpectedResult(), expectedResult)) |
|
348 { |
|
349 if (result != expectedResult) |
|
350 { |
|
351 ERR_PRINTF3(_L("The result is not as expected! expected: %d, actual: %d"), expectedResult, result); |
|
352 SetBlockResult(EFail); |
|
353 } |
|
354 } |
|
355 } |
|
356 |
|
357 |
|
358 /** Calls CFont::FontMaxDescent() */ |
|
359 void CT_DataFont::DoCmdFontMaxDescent(const TDesC& aSection) |
|
360 { |
|
361 INFO_PRINTF1(_L("Calls CFont::FontMaxDescent()")); |
|
362 // call FontMaxDescent() |
|
363 TInt result = GetFont()->FontMaxDescent(); |
|
364 |
|
365 // get expected result from parameters |
|
366 TInt expectedResult = 0; |
|
367 if(GetIntFromConfig(aSection, KExpectedResult(), expectedResult)) |
|
368 { |
|
369 if (result != expectedResult) |
|
370 { |
|
371 ERR_PRINTF3(_L("The result is not as expected! expected: %d, actual: %d"), expectedResult, result); |
|
372 SetBlockResult(EFail); |
|
373 } |
|
374 } |
|
375 } |
|
376 |
|
377 |
|
378 /** Calls CFont::FontLineGap() */ |
|
379 void CT_DataFont::DoCmdFontLineGap(const TDesC& aSection) |
|
380 { |
|
381 INFO_PRINTF1(_L("Calls CFont::FontLineGap()")); |
|
382 // call FontLineGap() |
|
383 TInt result = GetFont()->FontLineGap(); |
|
384 |
|
385 // get expected result from parameters |
|
386 TInt expectedResult = 0; |
|
387 if(GetIntFromConfig(aSection, KExpectedResult(), expectedResult)) |
|
388 { |
|
389 if (result != expectedResult) |
|
390 { |
|
391 ERR_PRINTF3(_L("The result is not as expected! expected: %d, actual: %d"), expectedResult, result); |
|
392 SetBlockResult(EFail); |
|
393 } |
|
394 } |
|
395 } |
|
396 |
|
397 |
|
398 /** Calls CFont::FontMaxHeight() */ |
|
399 void CT_DataFont::DoCmdFontMaxHeight(const TDesC& aSection) |
|
400 { |
|
401 INFO_PRINTF1(_L("Calls CFont::FontMaxHeight()")); |
|
402 // call FontMaxHeight() |
|
403 TInt result = GetFont()->FontMaxHeight(); |
|
404 |
|
405 // get expected result from parameters |
|
406 TInt expectedResult = 0; |
|
407 if(GetIntFromConfig(aSection, KExpectedResult(), expectedResult)) |
|
408 { |
|
409 if (result != expectedResult) |
|
410 { |
|
411 ERR_PRINTF3(_L("The result is not as expected! expected: %d, actual: %d"), expectedResult, result); |
|
412 SetBlockResult(EFail); |
|
413 } |
|
414 } |
|
415 } |
|
416 |
|
417 |
|
418 /** Calls CFont::TypeUid() */ |
|
419 void CT_DataFont::DoCmdTypeUid(const TDesC& aSection) |
|
420 { |
|
421 INFO_PRINTF1(_L("Calls CFont::TypeUid()")); |
|
422 // call TypeUid() |
|
423 TUid result = GetFont()->TypeUid(); |
|
424 |
|
425 // get expected result from parameters |
|
426 TInt expectedResult = 0; |
|
427 if(GetIntFromConfig(aSection, KExpectedResult(), expectedResult)) |
|
428 { |
|
429 if (result != TUid::Uid(expectedResult)) |
|
430 { |
|
431 ERR_PRINTF3(_L("The result is not as expected! expected: %d, actual: %d"), expectedResult, result.iUid); |
|
432 SetBlockResult(EFail); |
|
433 } |
|
434 } |
|
435 } |
|
436 |
|
437 |
|
438 /** Calls CFont::HeightInPixels() */ |
|
439 void CT_DataFont::DoCmdHeightInPixels(const TDesC& aSection) |
|
440 { |
|
441 INFO_PRINTF1(_L("Calls CFont::HeightInPixels()")); |
|
442 // call HeightInPixels() |
|
443 TInt result = GetFont()->HeightInPixels(); |
|
444 |
|
445 // get expected result from parameters |
|
446 TInt expectedResult = 0; |
|
447 if(GetIntFromConfig(aSection, KExpectedResult(), expectedResult)) |
|
448 { |
|
449 if (result != expectedResult) |
|
450 { |
|
451 ERR_PRINTF3(_L("The result is not as expected! expected: %d, actual: %d"), expectedResult, result); |
|
452 SetBlockResult(EFail); |
|
453 } |
|
454 } |
|
455 } |
|
456 |
|
457 |
|
458 /** Calls CFont::AscentInPixels() */ |
|
459 void CT_DataFont::DoCmdAscentInPixels(const TDesC& aSection) |
|
460 { |
|
461 INFO_PRINTF1(_L("Calls CFont::AscentInPixels()")); |
|
462 // call AscentInPixels() |
|
463 TInt result = GetFont()->AscentInPixels(); |
|
464 |
|
465 // get expected result from parameters |
|
466 TInt expectedResult = 0; |
|
467 if(GetIntFromConfig(aSection, KExpectedResult(), expectedResult)) |
|
468 { |
|
469 if (result != expectedResult) |
|
470 { |
|
471 ERR_PRINTF3(_L("The result is not as expected! expected: %d, actual: %d"), expectedResult, result); |
|
472 SetBlockResult(EFail); |
|
473 } |
|
474 } |
|
475 } |
|
476 |
|
477 |
|
478 /** Calls CFont::DescentInPixels() */ |
|
479 void CT_DataFont::DoCmdDescentInPixels(const TDesC& aSection) |
|
480 { |
|
481 INFO_PRINTF1(_L("Calls CFont::DescentInPixels()")); |
|
482 // call DescentInPixels() |
|
483 TInt result = GetFont()->DescentInPixels(); |
|
484 |
|
485 // get expected result from parameters |
|
486 TInt expectedResult = 0; |
|
487 if(GetIntFromConfig(aSection, KExpectedResult(), expectedResult)) |
|
488 { |
|
489 if (result != expectedResult) |
|
490 { |
|
491 ERR_PRINTF3(_L("The result is not as expected! expected: %d, actual: %d"), expectedResult, result); |
|
492 SetBlockResult(EFail); |
|
493 } |
|
494 } |
|
495 } |
|
496 |
|
497 |
|
498 /** Calls CFont::MaxCharWidthInPixels() */ |
|
499 void CT_DataFont::DoCmdMaxCharWidthInPixels(const TDesC& aSection) |
|
500 { |
|
501 INFO_PRINTF1(_L("Calls CFont::MaxCharWidthInPixels()")); |
|
502 // call MaxCharWidthInPixels() |
|
503 TInt result = GetFont()->MaxCharWidthInPixels(); |
|
504 |
|
505 // get expected result from parameters |
|
506 TInt expectedResult = 0; |
|
507 if(GetIntFromConfig(aSection, KExpectedResult(), expectedResult)) |
|
508 { |
|
509 if (result != expectedResult) |
|
510 { |
|
511 ERR_PRINTF3(_L("The result is not as expected! expected: %d, actual: %d"), expectedResult, result); |
|
512 SetBlockResult(EFail); |
|
513 } |
|
514 } |
|
515 } |
|
516 |
|
517 |
|
518 /** Calls CFont::MaxNormalCharWidthInPixels() */ |
|
519 void CT_DataFont::DoCmdMaxNormalCharWidthInPixels(const TDesC& aSection) |
|
520 { |
|
521 INFO_PRINTF1(_L("Calls CFont::MaxNormalCharWidthInPixels()")); |
|
522 // call MaxNormalCharWidthInPixels() |
|
523 TInt result = GetFont()->MaxNormalCharWidthInPixels(); |
|
524 |
|
525 // get expected result from parameters |
|
526 TInt expectedResult = 0; |
|
527 if(GetIntFromConfig(aSection, KExpectedResult(), expectedResult)) |
|
528 { |
|
529 if (result != expectedResult) |
|
530 { |
|
531 ERR_PRINTF3(_L("The result is not as expected! expected: %d, actual: %d"), expectedResult, result); |
|
532 SetBlockResult(EFail); |
|
533 } |
|
534 } |
|
535 } |
|
536 |
|
537 |
|
538 /** Calls CFont::FontSpecInTwips() */ |
|
539 void CT_DataFont::DoCmdFontSpecInTwips(const TDesC& aSection) |
|
540 { |
|
541 INFO_PRINTF1(_L("Calls CFont::FontSpecInTwips()")); |
|
542 |
|
543 // call FontSpecInTwips() |
|
544 TFontSpec fontSpec=GetFont()->FontSpecInTwips(); |
|
545 INFO_PRINTF3(_L("iName %S, iHeight %d"), &fontSpec.iTypeface.iName,fontSpec.iHeight); |
|
546 |
|
547 TFontSpec expectedFontSpec; |
|
548 if(GetFontSpecFromConfig(aSection, KExpectedFont(), expectedFontSpec)) |
|
549 { |
|
550 // just check font name |
|
551 if( fontSpec.iTypeface.iName!=expectedFontSpec.iTypeface.iName) |
|
552 { |
|
553 ERR_PRINTF3(_L("The result is not as expected! expected font: %S, actual font: %S"), |
|
554 &expectedFontSpec.iTypeface.iName, &fontSpec.iTypeface.iName); |
|
555 SetError(-1); |
|
556 } |
|
557 } |
|
558 } |
|
559 |
|
560 |
|
561 /** Calls CFont::WidthZeroInPixels() */ |
|
562 void CT_DataFont::DoCmdWidthZeroInPixels(const TDesC& aSection) |
|
563 { |
|
564 INFO_PRINTF1(_L("Calls CFont::WidthZeroInPixels()")); |
|
565 // call WidthZeroInPixels() |
|
566 TInt result = GetFont()->WidthZeroInPixels(); |
|
567 |
|
568 // get expected result from parameters |
|
569 TInt expectedResult = 0; |
|
570 if(GetIntFromConfig(aSection, KExpectedResult(), expectedResult)) |
|
571 { |
|
572 if (result != expectedResult) |
|
573 { |
|
574 ERR_PRINTF3(_L("The result is not as expected! expected: %d, actual: %d"), expectedResult, result); |
|
575 SetBlockResult(EFail); |
|
576 } |
|
577 } |
|
578 } |
|
579 |
|
580 |
|
581 /** Calls CFont::BaselineOffsetInPixels() */ |
|
582 void CT_DataFont::DoCmdBaselineOffsetInPixels(const TDesC& aSection) |
|
583 { |
|
584 INFO_PRINTF1(_L("Calls CFont::BaselineOffsetInPixels()")); |
|
585 // call BaselineOffsetInPixels() |
|
586 TInt result = GetFont()->BaselineOffsetInPixels(); |
|
587 |
|
588 // get expected result from parameters |
|
589 TInt expectedResult = 0; |
|
590 if(GetIntFromConfig(aSection, KExpectedResult(), expectedResult)) |
|
591 { |
|
592 if (result != expectedResult) |
|
593 { |
|
594 ERR_PRINTF3(_L("The result is not as expected! expected: %d, actual: %d"), expectedResult, result); |
|
595 SetBlockResult(EFail); |
|
596 } |
|
597 } |
|
598 } |
|
599 |
|
600 |
|
601 /** Calls CFont::GetCharacterData() */ |
|
602 void CT_DataFont::DoCmdGetCharacterData(const TDesC& aSection) |
|
603 { |
|
604 INFO_PRINTF1(_L("Calls CFont::GetCharacterData()")); |
|
605 // get character code from parameters |
|
606 TInt charCode = 0; |
|
607 if(!GetIntFromConfig(aSection, KCharCode(), charCode)) |
|
608 { |
|
609 ERR_PRINTF2(_L("No %S"), &KCharCode()); |
|
610 SetBlockResult(EFail); |
|
611 } |
|
612 |
|
613 // call GetCharacterData() |
|
614 TUint code = charCode; |
|
615 TOpenFontCharMetrics metrics; |
|
616 const TUint8* bitmapPointer; |
|
617 TSize bitmapSize; |
|
618 CFont::TCharacterDataAvailability ret=GetFont()->GetCharacterData(code, metrics, bitmapPointer, bitmapSize); |
|
619 INFO_PRINTF2(_L("CharacterDataAvailability %d"), ret); |
|
620 INFO_PRINTF2(_L("Height %d"), bitmapSize.iHeight); |
|
621 INFO_PRINTF2(_L("Width %d"), bitmapSize.iWidth); |
|
622 } |
|
623 |
|
624 |
|
625 /** Calls CFont::ExtendedFunction() */ |
|
626 void CT_DataFont::DoCmdExtendedFunction(const TDesC& aSection) |
|
627 { |
|
628 INFO_PRINTF1(_L("Calls CFont::ExtendedFunction()")); |
|
629 // get function UID from parameters |
|
630 TInt uidInt = 0; |
|
631 if(!GetHexFromConfig(aSection, KUid(), uidInt)) |
|
632 { |
|
633 ERR_PRINTF2(_L("No %S"), &KUid()); |
|
634 SetBlockResult(EFail); |
|
635 } |
|
636 |
|
637 // call ExtendedFunction() |
|
638 TInt result=GetFont()->ExtendedFunction(TUid::Uid(uidInt), NULL); |
|
639 |
|
640 // get expected result from parameters |
|
641 TInt expectedResult = 0; |
|
642 if ( GetIntFromConfig(aSection, KExpectedResult(), expectedResult) ) |
|
643 { |
|
644 if (result != expectedResult) |
|
645 { |
|
646 ERR_PRINTF3(_L("The result is not as expected! expected: %d, actual: %d"), expectedResult, result); |
|
647 SetBlockResult(EFail); |
|
648 } |
|
649 } |
|
650 } |
|
651 |
|
652 |
|
653 /** Calls CFbsFont::MeasureText() */ |
|
654 void CT_DataFont::DoCmdMeasureTextL(const TDesC& aSection) |
|
655 { |
|
656 CFont::TMeasureTextInput* measureTextInputPointer = NULL; |
|
657 GetMeasureTextInputL(*this, KMeasureTextInput(), aSection, measureTextInputPointer); |
|
658 if ( measureTextInputPointer==NULL ) |
|
659 { |
|
660 INFO_PRINTF1(_L("measureTextInputPointer NULL")); |
|
661 } |
|
662 |
|
663 CFont::TMeasureTextOutput* measureTextOutputPointer = NULL; |
|
664 GetMeasureTextOutputL(*this, KMeasureTextOutput(), aSection, measureTextOutputPointer); |
|
665 if ( measureTextOutputPointer==NULL ) |
|
666 { |
|
667 INFO_PRINTF1(_L("measureTextOutputPointer NULL")); |
|
668 } |
|
669 |
|
670 // get text from parameters |
|
671 TPtrC text; |
|
672 if (!GetStringFromConfig(aSection, KText(), text)) |
|
673 { |
|
674 ERR_PRINTF2(_L("No %S"), &KText()); |
|
675 SetBlockResult(EFail); |
|
676 } |
|
677 else |
|
678 { |
|
679 TInt width=GetFont()->MeasureText(text, measureTextInputPointer, measureTextOutputPointer); |
|
680 INFO_PRINTF2(_L("MeasureText %d"), width); |
|
681 } |
|
682 } |
|
683 |
|
684 |
|
685 ////////////////// UTIL METHODS //////////////////////// |
|
686 |
|
687 |
|
688 /** |
|
689 * Utility method that fetches TMeasureTextInput pointer by command parameter name from INI-file. |
|
690 */ |
|
691 TBool CT_DataFont::GetMeasureTextInputL(CDataWrapper& aDataWrapper, const TDesC& aParameterName, const TDesC& aSection, CFont::TMeasureTextInput*& aMeasureTextInput) |
|
692 { |
|
693 // get MeasureTextInputData object from parameters |
|
694 TPtrC measureTextInputDataObjectName; |
|
695 TBool ret=aDataWrapper.GetStringFromConfig(aSection, aParameterName, measureTextInputDataObjectName); |
|
696 if ( ret ) |
|
697 { |
|
698 // check that the data object was found |
|
699 aMeasureTextInput=static_cast<CFont::TMeasureTextInput*>(aDataWrapper.GetDataObjectL(measureTextInputDataObjectName)); |
|
700 } |
|
701 |
|
702 return ret; |
|
703 } |
|
704 |
|
705 |
|
706 /** |
|
707 * Utility method that fetches TMeasureTextOutput pointer by command parameter name from INI-file. |
|
708 */ |
|
709 TBool CT_DataFont::GetMeasureTextOutputL(CDataWrapper& aDataWrapper, const TDesC& aParameterName, const TDesC& aSection, CFont::TMeasureTextOutput*& aMeasureTextOutput) |
|
710 { |
|
711 // get MeasureTextOutputData object from parameters |
|
712 TPtrC measureTextOutputDataObjectName; |
|
713 TBool ret=aDataWrapper.GetStringFromConfig(aSection, aParameterName, measureTextOutputDataObjectName); |
|
714 if ( ret ) |
|
715 { |
|
716 // check that the data object was found |
|
717 aMeasureTextOutput=static_cast<CFont::TMeasureTextOutput*>(aDataWrapper.GetDataObjectL(measureTextOutputDataObjectName)); |
|
718 } |
|
719 |
|
720 return ret; |
|
721 } |