|
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 "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-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_DataFbsDevice |
|
23 */ |
|
24 |
|
25 #include "T_DataFbsDevice.h" |
|
26 #include "T_GraphicsUtil.h" |
|
27 |
|
28 /*@{*/ |
|
29 //Commands |
|
30 _LIT(KCmdcheckPixels, "checkPixels"); |
|
31 _LIT(KCmdcheckLineColor, "checkLineColor"); |
|
32 _LIT(KCmdcheckRectColor, "checkRectColor"); |
|
33 _LIT(KCmdSizeInPixels, "SizeInPixels"); |
|
34 _LIT(KCmdGetFontById, "GetFontById"); |
|
35 _LIT(KCmdGetNearestFontInPixels, "GetNearestFontInPixels"); |
|
36 _LIT(KCmdGetNearestFontInTwips, "GetNearestFontInTwips"); |
|
37 _LIT(KCmdGetNearestFontToDesignHeightInPixels, "GetNearestFontToDesignHeightInPixels"); |
|
38 _LIT(KCmdGetNearestFontToDesignHeightInTwips, "GetNearestFontToDesignHeightInTwips"); |
|
39 _LIT(KCmdGetNearestFontToMaxHeightInPixels, "GetNearestFontToMaxHeightInPixels"); |
|
40 _LIT(KCmdGetNearestFontToMaxHeightInTwips, "GetNearestFontToMaxHeightInTwips"); |
|
41 _LIT(KCmdCreateContext, "CreateContext"); |
|
42 _LIT(KCmdRectCompare, "RectCompare"); |
|
43 _LIT(KCmdSetCustomPalette, "SetCustomPalette"); |
|
44 _LIT(KCmdGraphicsAccelerator, "GraphicsAccelerator"); |
|
45 _LIT(KCmdOrientation, "Orientation"); |
|
46 _LIT(KCmdDisplayMode16M, "DisplayMode16M"); |
|
47 _LIT(KCmdSetScalingFactor, "SetScalingFactor"); |
|
48 _LIT(KCmdGetDrawRect, "GetDrawRect"); |
|
49 _LIT(KCmdSetDrawDeviceOffset, "SetDrawDeviceOffset"); |
|
50 _LIT(KCmdRegisterLinkedTypeface, "RegisterLinkedTypeface"); |
|
51 |
|
52 //Fields |
|
53 _LIT(KFldAlgStyle, "alg_style"); |
|
54 _LIT(KFldExpected, "expected"); |
|
55 _LIT(KFldFinish, "finish"); |
|
56 _LIT(KFldFormatFieldNumber, "%S%d"); |
|
57 _LIT(KFldFont, "font"); |
|
58 _LIT(KFldFbsFont, "fbsfont"); |
|
59 _LIT(KFldFontUid, "font_uid"); |
|
60 _LIT(KFldMaxHeight, "maxheight"); |
|
61 _LIT(KFldPixel, "pixel"); |
|
62 _LIT(KFldRect, "rect"); |
|
63 _LIT(KFldStart, "start"); |
|
64 _LIT(KFldBitGc, "bitgc"); |
|
65 _LIT(KFldRect1, "rect1"); |
|
66 _LIT(KFldRect2, "rect2"); |
|
67 _LIT(KFldFbsDevice, "fbsdevice"); |
|
68 _LIT(KFldExpectedOrientation, "expectedorientation"); |
|
69 _LIT(KFldPalette, "palette"); |
|
70 _LIT(KFldGraphicsAccelerator, "graphicsaccelerator"); |
|
71 _LIT(KFldExpectedDisplayMode, "expecteddisplaymode"); |
|
72 _LIT(KFldOrigin, "origin"); |
|
73 _LIT(KFldFactorX, "factorx"); |
|
74 _LIT(KFldFactorY, "factory"); |
|
75 _LIT(KFldDivisorX, "divisorx"); |
|
76 _LIT(KFldDivisorY, "divisory"); |
|
77 _LIT(KFldExpectedDrawRect, "expecteddrawrect"); |
|
78 _LIT(KFldOffset, "offset"); |
|
79 _LIT(KFldLinkedTypefaceSpec, "linkedtypefacespec"); |
|
80 _LIT(KFldExpectedUid, "expecteduid"); |
|
81 |
|
82 //Logs |
|
83 _LIT(KLogColor, "Color Red=%d Green=%d Blue=%d Alpha=%d"); |
|
84 _LIT(KLogPoint, "Point X=%d Y=%d"); |
|
85 _LIT(KLogError, "Error=%d"); |
|
86 _LIT(KLogMissingParameter, "Missing parameter '%S'"); |
|
87 _LIT(KLogMissingWrapper, "Missing wrapper for '%S'"); |
|
88 _LIT(KLogNotExpectedValue, "Not expected value"); |
|
89 /*@}*/ |
|
90 |
|
91 /** |
|
92 * Constructor. First phase construction |
|
93 */ |
|
94 CT_DataFbsDevice::CT_DataFbsDevice() |
|
95 : CT_DataBitmapDevice() |
|
96 { |
|
97 } |
|
98 |
|
99 /** |
|
100 * Process a command read from the ini file |
|
101 * |
|
102 * @param aDataWrapper test step requiring command to be processed |
|
103 * @param aCommand the command to process |
|
104 * @param aSection the entry in the ini file requiring the command to be processed |
|
105 * |
|
106 * @return ETrue if the command is processed |
|
107 */ |
|
108 TBool CT_DataFbsDevice::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex) |
|
109 { |
|
110 /* Another work package will implement this */ |
|
111 TBool retVal = ETrue; |
|
112 |
|
113 if (aCommand == KCmdcheckPixels) |
|
114 { |
|
115 DoCmdCheckPixels(aSection); |
|
116 } |
|
117 else if (aCommand == KCmdcheckLineColor) |
|
118 { |
|
119 DoCmdCheckLineColor(aSection); |
|
120 } |
|
121 else if (aCommand == KCmdcheckRectColor) |
|
122 { |
|
123 DoCmdCheckRectColor(aSection); |
|
124 } |
|
125 else if (aCommand == KCmdSizeInPixels) |
|
126 { |
|
127 DoCmdSizeInPixels(aSection); |
|
128 } |
|
129 else if (aCommand == KCmdGetFontById) |
|
130 { |
|
131 DoCmdGetFontByIdL(aSection); |
|
132 } |
|
133 else if (aCommand == KCmdGetNearestFontInPixels) |
|
134 { |
|
135 if( !DoCmdGetNearestFontInPixelsL(aSection) ) |
|
136 { |
|
137 retVal = CT_DataBitmapDevice::DoCommandL(aCommand, aSection, aAsyncErrorIndex); |
|
138 } |
|
139 } |
|
140 else if (aCommand == KCmdGetNearestFontInTwips) |
|
141 { |
|
142 if( !DoCmdGetNearestFontInTwipsL(aSection) ) |
|
143 { |
|
144 retVal = CT_DataBitmapDevice::DoCommandL(aCommand, aSection, aAsyncErrorIndex); |
|
145 } |
|
146 } |
|
147 else if (aCommand == KCmdGetNearestFontToDesignHeightInPixels) |
|
148 { |
|
149 if( !DoCmdGetNearestFontToDesignHeightInPixelsL(aSection) ) |
|
150 { |
|
151 retVal = CT_DataBitmapDevice::DoCommandL(aCommand, aSection, aAsyncErrorIndex); |
|
152 } |
|
153 } |
|
154 else if (aCommand == KCmdGetNearestFontToDesignHeightInTwips) |
|
155 { |
|
156 if( !DoCmdGetNearestFontToDesignHeightInTwipsL(aSection) ) |
|
157 { |
|
158 retVal = CT_DataBitmapDevice::DoCommandL(aCommand, aSection, aAsyncErrorIndex); |
|
159 } |
|
160 } |
|
161 else if (aCommand == KCmdGetNearestFontToMaxHeightInPixels) |
|
162 { |
|
163 if( !DoCmdGetNearestFontToMaxHeightInPixelsL(aSection) ) |
|
164 { |
|
165 retVal = CT_DataBitmapDevice::DoCommandL(aCommand, aSection, aAsyncErrorIndex); |
|
166 } |
|
167 } |
|
168 else if (aCommand == KCmdGetNearestFontToMaxHeightInTwips) |
|
169 { |
|
170 if( !DoCmdGetNearestFontToMaxHeightInTwipsL(aSection) ) |
|
171 { |
|
172 retVal = CT_DataBitmapDevice::DoCommandL(aCommand, aSection, aAsyncErrorIndex); |
|
173 } |
|
174 } |
|
175 else if (aCommand == KCmdCreateContext) |
|
176 { |
|
177 if (!DoCmdCreateContextL(aSection)) |
|
178 { |
|
179 retVal = CT_DataBitmapDevice::DoCommandL(aCommand, aSection, aAsyncErrorIndex); |
|
180 } |
|
181 } |
|
182 else if (aCommand == KCmdRectCompare) |
|
183 { |
|
184 DoCmdRectCompareL(aSection); |
|
185 } |
|
186 else if (aCommand == KCmdOrientation) |
|
187 { |
|
188 DoCmdOrientation(aSection); |
|
189 } |
|
190 else if (aCommand == KCmdSetCustomPalette) |
|
191 { |
|
192 DoCmdSetCustomPaletteL(aSection); |
|
193 } |
|
194 else if (aCommand == KCmdGraphicsAccelerator) |
|
195 { |
|
196 DoCmdGraphicsAccelerator(); |
|
197 } |
|
198 else if (aCommand == KCmdDisplayMode16M) |
|
199 { |
|
200 DoCmdDisplayMode16M(aSection); |
|
201 } |
|
202 else if (aCommand == KCmdSetScalingFactor) |
|
203 { |
|
204 DoCmdSetScalingFactor(aSection); |
|
205 } |
|
206 else if (aCommand == KCmdGetDrawRect) |
|
207 { |
|
208 DoCmdGetDrawRect(aSection); |
|
209 } |
|
210 else if (aCommand == KCmdRegisterLinkedTypeface) |
|
211 { |
|
212 DoCmdRegisterLinkedTypefaceL(aSection); |
|
213 } |
|
214 else if (aCommand == KCmdSetDrawDeviceOffset) |
|
215 { |
|
216 DoCmdSetDrawDeviceOffset(aSection); |
|
217 } |
|
218 else |
|
219 { |
|
220 retVal = CT_DataBitmapDevice::DoCommandL(aCommand, aSection, aAsyncErrorIndex); |
|
221 } |
|
222 return retVal; |
|
223 } |
|
224 |
|
225 |
|
226 void CT_DataFbsDevice::DoCmdSizeInPixels(const TDesC& aSection) |
|
227 { |
|
228 INFO_PRINTF1(_L("execute SizeInPixels()")); |
|
229 TSize actualsize; |
|
230 TInt expectheight = 0; |
|
231 TInt expectwidth = 0; |
|
232 TSize expectsize; |
|
233 |
|
234 if (!GetSizeFromConfig(aSection, KFldExpected, expectsize)) |
|
235 { |
|
236 ERR_PRINTF2(KLogMissingParameter, &KFldExpected); |
|
237 SetBlockResult(EFail); |
|
238 } |
|
239 else |
|
240 { |
|
241 actualsize = GetFbsDevice()->SizeInPixels(); |
|
242 if (actualsize != expectsize) |
|
243 { |
|
244 ERR_PRINTF3(_L("The actual size is width=%d, height=%d"), actualsize.iWidth, actualsize.iHeight); |
|
245 ERR_PRINTF3(_L("The expect size is width=%d, height=%d"), expectsize.iWidth, expectsize.iHeight); |
|
246 SetBlockResult(EFail); |
|
247 } |
|
248 } |
|
249 } |
|
250 |
|
251 /** |
|
252 * DoCmdcheckPixels: to check the color of specified pixels on the screen device, and compare |
|
253 * with the expected color specidied in the TEF testdata. |
|
254 * pixel<n>: specify the position of the screen device to check |
|
255 * expected<n>: specify the expected color to be compared with |
|
256 * |
|
257 */ |
|
258 void CT_DataFbsDevice::DoCmdCheckPixels(const TDesC& aSection) |
|
259 { |
|
260 TBuf<KMaxTestExecuteCommandLength> tempStore; |
|
261 |
|
262 TBool moreData = ETrue; |
|
263 for (TInt index=1; moreData; ++index) |
|
264 { |
|
265 // get the pixel position on the screen to check/verify |
|
266 tempStore.Format(KFldFormatFieldNumber, &KFldPixel, index); |
|
267 TPoint point; |
|
268 if ( !GetPointFromConfig(aSection, tempStore, point) ) |
|
269 { |
|
270 moreData = EFalse; |
|
271 } |
|
272 else |
|
273 { |
|
274 TRgb actual; |
|
275 GetFbsDevice()->GetPixel(actual, point); |
|
276 |
|
277 tempStore.Format(KFldFormatFieldNumber, &KFldExpected, index); |
|
278 TRgb expected; |
|
279 if (GetRgbFromConfig(aSection, tempStore, expected)) |
|
280 { |
|
281 if (actual != expected) |
|
282 { |
|
283 ERR_PRINTF5(KLogColor, actual.Red(), actual.Green(), actual.Blue(), actual.Alpha()); |
|
284 ERR_PRINTF5(KLogColor, expected.Red(), expected.Green(), expected.Blue(), expected.Alpha()); |
|
285 SetBlockResult(EFail); |
|
286 } |
|
287 } |
|
288 } |
|
289 } |
|
290 } |
|
291 |
|
292 /** |
|
293 * DoCmdcheckLineColor: to check the color of specified lines on the screen device, and compare |
|
294 * with the expected color specidied in the TEF testdata. |
|
295 * start<n>: specify the starting position of the line on the screen device to check |
|
296 * finish<n>: specify the finish position of the line on the screen device to check |
|
297 * expected<n>: specify the expected color to be compared with |
|
298 * Note: the straight line (from start to the finish points) is constructed by TLinearDDA |
|
299 * |
|
300 */ |
|
301 void CT_DataFbsDevice::DoCmdCheckLineColor(const TDesC& aSection) |
|
302 { |
|
303 TBuf<KMaxTestExecuteCommandLength> tempStore; |
|
304 CPalette* palette = NULL; |
|
305 GetFbsDevice()->GetPalette(palette); |
|
306 |
|
307 TBool moreData = ETrue; |
|
308 for (TInt index=1; moreData; ++index) |
|
309 { |
|
310 // get the the start and finish points of the line to check/verify |
|
311 tempStore.Format(KFldFormatFieldNumber, &KFldStart, index); |
|
312 TPoint startPoint; |
|
313 if (!GetPointFromConfig(aSection, tempStore, startPoint)) |
|
314 { |
|
315 moreData = EFalse; |
|
316 } |
|
317 |
|
318 tempStore.Format(KFldFormatFieldNumber, &KFldFinish, index); |
|
319 TPoint endPoint; |
|
320 if (!GetPointFromConfig(aSection, tempStore, endPoint)) |
|
321 { |
|
322 moreData = EFalse; |
|
323 } |
|
324 |
|
325 if (moreData) |
|
326 { |
|
327 // get the expected color from testdata |
|
328 tempStore.Format(KFldFormatFieldNumber, &KFldExpected, index); |
|
329 TRgb expected; |
|
330 if (!GetRgbFromConfig(aSection, tempStore, expected)) |
|
331 { |
|
332 ERR_PRINTF2(KLogMissingParameter, &tempStore); |
|
333 SetBlockResult(EFail); |
|
334 } |
|
335 else |
|
336 { |
|
337 if (palette!=NULL) |
|
338 { |
|
339 expected = palette->NearestEntry(expected); |
|
340 } |
|
341 |
|
342 TLinearDDA lineDDA; |
|
343 lineDDA.Construct(startPoint, endPoint, TLinearDDA::ECenter); |
|
344 |
|
345 // for each pixels on the line (from start to finish points), check if its color matches expected |
|
346 TPoint point; |
|
347 while (!lineDDA.SingleStep(point)) |
|
348 { |
|
349 TRgb actual; |
|
350 GetFbsDevice()->GetPixel(actual, point); |
|
351 |
|
352 if (actual != expected) |
|
353 { |
|
354 ERR_PRINTF5(KLogColor, actual.Red(), actual.Green(), actual.Blue(), actual.Alpha()); |
|
355 ERR_PRINTF5(KLogColor, expected.Red(), expected.Green(), expected.Blue(), expected.Alpha()); |
|
356 ERR_PRINTF3(KLogPoint, point.iX, point.iY); |
|
357 SetBlockResult(EFail); |
|
358 } |
|
359 } |
|
360 } |
|
361 } |
|
362 } |
|
363 delete palette; |
|
364 } |
|
365 |
|
366 /** |
|
367 * DoCmdcheckRectColor: to check the color of specified rectangle on the screen device, and |
|
368 * compare with the expected color specidied in the TEF testdata. |
|
369 * rect<n>: specify the rectangle area on the screen device to check |
|
370 * expected<n>: specify the expected color to be compared with |
|
371 * |
|
372 */ |
|
373 void CT_DataFbsDevice::DoCmdCheckRectColor(const TDesC& aSection) |
|
374 { |
|
375 TBuf<KMaxTestExecuteCommandLength> tempStore; |
|
376 |
|
377 CPalette* palette=NULL; |
|
378 GetFbsDevice()->GetPalette(palette); |
|
379 |
|
380 TBool moreData = ETrue; |
|
381 for (TInt index=1; moreData; ++index) |
|
382 { |
|
383 // get the the rectangle to check/verify |
|
384 tempStore.Format(KFldFormatFieldNumber, &KFldRect, index); |
|
385 TRect rect; |
|
386 if (!GetRectFromConfig(aSection, tempStore, rect)) |
|
387 { |
|
388 moreData = EFalse; |
|
389 } |
|
390 else |
|
391 { |
|
392 // get the expected color from testdata |
|
393 tempStore.Format(KFldFormatFieldNumber, &KFldExpected, index); |
|
394 TRgb expected; |
|
395 if (!GetRgbFromConfig(aSection, tempStore, expected)) |
|
396 { |
|
397 ERR_PRINTF2(KLogMissingParameter, &tempStore); |
|
398 SetBlockResult(EFail); |
|
399 } |
|
400 else |
|
401 { |
|
402 if (palette!=NULL) |
|
403 { |
|
404 expected = palette->NearestEntry(expected); |
|
405 } |
|
406 |
|
407 TPoint point; |
|
408 for (point.iX=rect.iTl.iX; point.iX<rect.iBr.iX; ++point.iX) |
|
409 { |
|
410 for (point.iY=rect.iTl.iY; point.iY<rect.iBr.iY; ++point.iY) |
|
411 { |
|
412 TRgb actual; |
|
413 GetFbsDevice()->GetPixel(actual, point); |
|
414 |
|
415 if (actual!=expected) |
|
416 { |
|
417 ERR_PRINTF5(KLogColor, actual.Red(), actual.Green(), actual.Blue(), actual.Alpha()); |
|
418 ERR_PRINTF5(KLogColor, expected.Red(), expected.Green(), expected.Blue(), expected.Alpha()); |
|
419 ERR_PRINTF3(KLogPoint, point.iX, point.iY); |
|
420 SetBlockResult(EFail); |
|
421 } |
|
422 } |
|
423 } |
|
424 } |
|
425 } |
|
426 } |
|
427 delete palette; |
|
428 } |
|
429 |
|
430 void CT_DataFbsDevice::DoCmdGetFontByIdL(const TDesC& aSection) |
|
431 { |
|
432 TBool dataOk=ETrue; |
|
433 |
|
434 // get font uid |
|
435 TInt fontUid; |
|
436 if( !GetIntFromConfig(aSection, KFldFontUid(), fontUid) ) |
|
437 { |
|
438 dataOk = EFalse; |
|
439 ERR_PRINTF2(KLogMissingParameter, &KFldFontUid()); |
|
440 SetBlockResult(EFail); |
|
441 } |
|
442 |
|
443 // get algorithmic style |
|
444 TAlgStyle* algStyle = NULL; |
|
445 CT_GraphicsUtil::GetAlgStyleL(*this, aSection, KFldAlgStyle(), algStyle); |
|
446 if (NULL == algStyle) |
|
447 { |
|
448 dataOk = EFalse; |
|
449 ERR_PRINTF2(KLogMissingParameter, &KFldAlgStyle()); |
|
450 SetBlockResult(EFail); |
|
451 } |
|
452 |
|
453 TPtrC wrapperName; |
|
454 if( GetStringFromConfig(aSection, KFldFbsFont, wrapperName) ) |
|
455 { |
|
456 // "CFbsFont*&" type |
|
457 if ( dataOk ) |
|
458 { |
|
459 CFbsFont* fbsFont = NULL; |
|
460 INFO_PRINTF1(_L("execute GetFontById(CFbsFont *&aFont, TUid aFileId, const TAlgStyle &aAlgStyle)")); |
|
461 TInt err = GetFbsDevice()->GetFontById(fbsFont, TUid::Uid(fontUid), *algStyle); |
|
462 |
|
463 if (KErrNone != err) |
|
464 { |
|
465 ERR_PRINTF2(KLogError, err); |
|
466 SetError(err); |
|
467 } |
|
468 else |
|
469 { |
|
470 SetDataObjectL(wrapperName, fbsFont); |
|
471 } |
|
472 } |
|
473 } |
|
474 else if( GetStringFromConfig(aSection, KFldFont, wrapperName) ) |
|
475 { |
|
476 // "CFont*&" type |
|
477 if( dataOk ) |
|
478 { |
|
479 CFont* font = NULL; |
|
480 INFO_PRINTF1(_L("execute GetFontById(CFont *&aFont, TUid aFileId, const TAlgStyle &aAlgStyle)")); |
|
481 TInt err = GetFbsDevice()->GetFontById(font, TUid::Uid(fontUid), *algStyle); |
|
482 |
|
483 if (KErrNone != err) |
|
484 { |
|
485 ERR_PRINTF2(KLogError, err); |
|
486 SetError(err); |
|
487 } |
|
488 else |
|
489 { |
|
490 SetDataObjectL(wrapperName, font); |
|
491 } |
|
492 } |
|
493 } |
|
494 else |
|
495 { |
|
496 ERR_PRINTF2(KLogMissingParameter, &KFldFont()); |
|
497 SetBlockResult(EFail); |
|
498 } |
|
499 } |
|
500 |
|
501 TBool CT_DataFbsDevice::DoCmdGetNearestFontInPixelsL(const TDesC& aSection) |
|
502 { |
|
503 TBool dataOk = ETrue; |
|
504 |
|
505 // get font specification |
|
506 TFontSpec fontSpec; |
|
507 if ( !GetFontSpecFromConfig(aSection, KFldFont, fontSpec) ) |
|
508 { |
|
509 dataOk = EFalse; |
|
510 ERR_PRINTF2(KLogMissingParameter, &KFldFont()); |
|
511 SetBlockResult(EFail); |
|
512 } |
|
513 |
|
514 TPtrC wrapperName; |
|
515 if ( GetStringFromConfig(aSection, KFldFbsFont, wrapperName) ) |
|
516 { |
|
517 // "CFbsFont*&" type |
|
518 if(dataOk) |
|
519 { |
|
520 CFbsFont* fbsFont = NULL; |
|
521 INFO_PRINTF1(_L("execute GetNearestFontInPixels(CFbsFont*&, TFontSpec)")); |
|
522 TInt err = GetFbsDevice()->GetNearestFontInPixels(fbsFont, fontSpec); |
|
523 if (KErrNone != err) |
|
524 { |
|
525 ERR_PRINTF2(KLogError, err); |
|
526 SetError(err); |
|
527 } |
|
528 else |
|
529 { |
|
530 SetDataObjectL(wrapperName, fbsFont); |
|
531 } |
|
532 } |
|
533 } |
|
534 else if( GetStringFromConfig(aSection, KFldFont, wrapperName) ) |
|
535 { |
|
536 // "CFont*&" type |
|
537 // hand over the ownership to parent class |
|
538 return EFalse; |
|
539 } |
|
540 else |
|
541 { |
|
542 ERR_PRINTF2(KLogMissingParameter, &KFldFont()); |
|
543 SetBlockResult(EFail); |
|
544 } |
|
545 |
|
546 return ETrue; |
|
547 } |
|
548 |
|
549 TBool CT_DataFbsDevice::DoCmdGetNearestFontInTwipsL(const TDesC& aSection) |
|
550 { |
|
551 TBool dataOk = ETrue; |
|
552 |
|
553 // get font specification |
|
554 TFontSpec fontSpec; |
|
555 if ( !GetFontSpecFromConfig(aSection, KFldFont, fontSpec) ) |
|
556 { |
|
557 dataOk = EFalse; |
|
558 ERR_PRINTF2(KLogMissingParameter, &KFldFont()); |
|
559 SetBlockResult(EFail); |
|
560 } |
|
561 |
|
562 TPtrC wrapperName; |
|
563 if ( GetStringFromConfig(aSection, KFldFbsFont, wrapperName) ) |
|
564 { |
|
565 // "CFbsFont*&" type |
|
566 if(dataOk) |
|
567 { |
|
568 CFbsFont* fbsFont = NULL; |
|
569 INFO_PRINTF1(_L("execute GetNearestFontInTwips(CFbsFont*&, TFontSpec)")); |
|
570 TInt err = GetFbsDevice()->GetNearestFontInTwips(fbsFont, fontSpec); |
|
571 if (KErrNone != err) |
|
572 { |
|
573 ERR_PRINTF2(KLogError, err); |
|
574 SetError(err); |
|
575 } |
|
576 else |
|
577 { |
|
578 SetDataObjectL(wrapperName, fbsFont); |
|
579 } |
|
580 } |
|
581 } |
|
582 else if( GetStringFromConfig(aSection, KFldFont, wrapperName) ) |
|
583 { |
|
584 // "CFont*&" type |
|
585 // hand over the ownership to parent class |
|
586 return EFalse; |
|
587 } |
|
588 else |
|
589 { |
|
590 ERR_PRINTF2(KLogMissingParameter, &KFldFont()); |
|
591 SetBlockResult(EFail); |
|
592 } |
|
593 |
|
594 return ETrue; |
|
595 } |
|
596 |
|
597 TBool CT_DataFbsDevice::DoCmdGetNearestFontToDesignHeightInPixelsL(const TDesC& aSection) |
|
598 { |
|
599 TBool dataOk = ETrue; |
|
600 |
|
601 // get font specification |
|
602 TFontSpec fontSpec; |
|
603 if ( !GetFontSpecFromConfig(aSection, KFldFont, fontSpec) ) |
|
604 { |
|
605 dataOk = EFalse; |
|
606 ERR_PRINTF2(KLogMissingParameter, &KFldFont()); |
|
607 SetBlockResult(EFail); |
|
608 } |
|
609 |
|
610 TPtrC wrapperName; |
|
611 if ( GetStringFromConfig(aSection, KFldFbsFont, wrapperName) ) |
|
612 { |
|
613 // "CFbsFont*&" type |
|
614 if(dataOk) |
|
615 { |
|
616 CFbsFont* fbsFont = NULL; |
|
617 INFO_PRINTF1(_L("execute DoCmdGetNearestFontToDesignHeightInPixels(CFbsFont*&, TFontSpec)")); |
|
618 TInt err = GetFbsDevice()->GetNearestFontToDesignHeightInPixels(fbsFont, fontSpec); |
|
619 if (KErrNone != err) |
|
620 { |
|
621 ERR_PRINTF2(KLogError, err); |
|
622 SetError(err); |
|
623 } |
|
624 else |
|
625 { |
|
626 SetDataObjectL(wrapperName, fbsFont); |
|
627 } |
|
628 } |
|
629 } |
|
630 else if( GetStringFromConfig(aSection, KFldFont, wrapperName) ) |
|
631 { |
|
632 // "CFont*&" type |
|
633 // hand over the ownership to parent class |
|
634 return EFalse; |
|
635 } |
|
636 else |
|
637 { |
|
638 ERR_PRINTF2(KLogMissingParameter, &KFldFont()); |
|
639 SetBlockResult(EFail); |
|
640 } |
|
641 |
|
642 return ETrue; |
|
643 } |
|
644 |
|
645 TBool CT_DataFbsDevice::DoCmdGetNearestFontToDesignHeightInTwipsL(const TDesC& aSection) |
|
646 { |
|
647 TBool dataOk = ETrue; |
|
648 |
|
649 // get font specification |
|
650 TFontSpec fontSpec; |
|
651 if ( !GetFontSpecFromConfig(aSection, KFldFont, fontSpec) ) |
|
652 { |
|
653 dataOk = EFalse; |
|
654 ERR_PRINTF2(KLogMissingParameter, &KFldFont()); |
|
655 SetBlockResult(EFail); |
|
656 } |
|
657 |
|
658 TPtrC wrapperName; |
|
659 if ( GetStringFromConfig(aSection, KFldFbsFont, wrapperName) ) |
|
660 { |
|
661 // "CFbsFont*&" type |
|
662 if(dataOk) |
|
663 { |
|
664 CFbsFont* fbsFont = NULL; |
|
665 INFO_PRINTF1(_L("execute DoCmdGetNearestFontToDesignHeightInTwips(CFbsFont*&, TFontSpec)")); |
|
666 TInt err = GetFbsDevice()->GetNearestFontToDesignHeightInTwips(fbsFont, fontSpec); |
|
667 if (KErrNone != err) |
|
668 { |
|
669 ERR_PRINTF2(KLogError, err); |
|
670 SetError(err); |
|
671 } |
|
672 else |
|
673 { |
|
674 SetDataObjectL(wrapperName, fbsFont); |
|
675 } |
|
676 } |
|
677 } |
|
678 else if( GetStringFromConfig(aSection, KFldFont, wrapperName) ) |
|
679 { |
|
680 // "CFont*&" type |
|
681 // hand over the ownership to parent class |
|
682 return EFalse; |
|
683 } |
|
684 else |
|
685 { |
|
686 ERR_PRINTF2(KLogMissingParameter, &KFldFont()); |
|
687 SetBlockResult(EFail); |
|
688 } |
|
689 |
|
690 return ETrue; |
|
691 } |
|
692 |
|
693 TBool CT_DataFbsDevice::DoCmdGetNearestFontToMaxHeightInPixelsL(const TDesC& aSection) |
|
694 { |
|
695 TBool dataOk = ETrue; |
|
696 |
|
697 // get font specification |
|
698 TFontSpec fontSpec; |
|
699 if ( !GetFontSpecFromConfig(aSection, KFldFont, fontSpec) ) |
|
700 { |
|
701 dataOk = EFalse; |
|
702 ERR_PRINTF2(KLogMissingParameter, &KFldFont()); |
|
703 SetBlockResult(EFail); |
|
704 } |
|
705 |
|
706 // get maximum height in pixels |
|
707 TInt maxHeight; |
|
708 if ( !GetIntFromConfig(aSection, KFldMaxHeight, maxHeight) ) |
|
709 { |
|
710 dataOk = EFalse; |
|
711 ERR_PRINTF2(KLogMissingParameter, &KFldMaxHeight()); |
|
712 SetBlockResult(EFail); |
|
713 } |
|
714 |
|
715 TPtrC wrapperName; |
|
716 if ( GetStringFromConfig(aSection, KFldFbsFont, wrapperName) ) |
|
717 { |
|
718 // "CFbsFont*&" type |
|
719 if(dataOk) |
|
720 { |
|
721 CFbsFont* fbsFont = NULL; |
|
722 INFO_PRINTF1(_L("execute DoCmdGetNearestFontToMaxHeightInPixels(CFbsFont*&, TFontSpec)")); |
|
723 TInt err = GetFbsDevice()->GetNearestFontToMaxHeightInPixels(fbsFont, fontSpec, maxHeight); |
|
724 if (KErrNone != err) |
|
725 { |
|
726 ERR_PRINTF2(KLogError, err); |
|
727 SetError(err); |
|
728 } |
|
729 else |
|
730 { |
|
731 SetDataObjectL(wrapperName, fbsFont); |
|
732 } |
|
733 } |
|
734 } |
|
735 else if( GetStringFromConfig(aSection, KFldFont, wrapperName) ) |
|
736 { |
|
737 // "CFont*&" type |
|
738 // hand over the ownership to parent class |
|
739 return EFalse; |
|
740 } |
|
741 else |
|
742 { |
|
743 ERR_PRINTF2(KLogMissingParameter, &KFldFont()); |
|
744 SetBlockResult(EFail); |
|
745 } |
|
746 |
|
747 return ETrue; |
|
748 } |
|
749 |
|
750 TBool CT_DataFbsDevice::DoCmdGetNearestFontToMaxHeightInTwipsL(const TDesC& aSection) |
|
751 { |
|
752 TBool dataOk = ETrue; |
|
753 |
|
754 // get font specification |
|
755 TFontSpec fontSpec; |
|
756 if ( !GetFontSpecFromConfig(aSection, KFldFont, fontSpec) ) |
|
757 { |
|
758 dataOk = EFalse; |
|
759 ERR_PRINTF2(KLogMissingParameter, &KFldFont()); |
|
760 SetBlockResult(EFail); |
|
761 } |
|
762 |
|
763 // get maximum height in twips |
|
764 TInt maxHeight; |
|
765 if ( !GetIntFromConfig(aSection, KFldMaxHeight, maxHeight) ) |
|
766 { |
|
767 dataOk = EFalse; |
|
768 ERR_PRINTF2(KLogMissingParameter, &KFldMaxHeight()); |
|
769 SetBlockResult(EFail); |
|
770 } |
|
771 |
|
772 TPtrC wrapperName; |
|
773 if ( GetStringFromConfig(aSection, KFldFbsFont, wrapperName) ) |
|
774 { |
|
775 // "CFbsFont*&" type |
|
776 if(dataOk) |
|
777 { |
|
778 CFbsFont* fbsFont = NULL; |
|
779 INFO_PRINTF1(_L("execute DoCmdGetNearestFontToMaxHeightInTwips(CFbsFont*&, TFontSpec)")); |
|
780 TInt err = GetFbsDevice()->GetNearestFontToMaxHeightInTwips(fbsFont, fontSpec, maxHeight); |
|
781 if (KErrNone != err) |
|
782 { |
|
783 ERR_PRINTF2(KLogError, err); |
|
784 SetError(err); |
|
785 } |
|
786 else |
|
787 { |
|
788 SetDataObjectL(wrapperName, fbsFont); |
|
789 } |
|
790 } |
|
791 } |
|
792 else if( GetStringFromConfig(aSection, KFldFont, wrapperName) ) |
|
793 { |
|
794 // "CFont*&" type |
|
795 // hand over the ownership to parent class |
|
796 return EFalse; |
|
797 } |
|
798 else |
|
799 { |
|
800 ERR_PRINTF2(KLogMissingParameter, &KFldFont()); |
|
801 SetBlockResult(EFail); |
|
802 } |
|
803 |
|
804 return ETrue; |
|
805 } |
|
806 |
|
807 TBool CT_DataFbsDevice::DoCmdCreateContextL(const TDesC& aSection) |
|
808 { |
|
809 TPtrC wrapperName; |
|
810 |
|
811 if (!GetStringFromConfig(aSection, KFldBitGc, wrapperName)) |
|
812 { |
|
813 return EFalse; |
|
814 } |
|
815 else |
|
816 { |
|
817 CDataWrapper* wrapper = GetDataWrapperL(wrapperName); |
|
818 if (wrapper == NULL) |
|
819 { |
|
820 ERR_PRINTF2(KLogMissingWrapper, &wrapperName); |
|
821 SetBlockResult(EFail); |
|
822 } |
|
823 else |
|
824 { |
|
825 CFbsBitGc* context = NULL; |
|
826 INFO_PRINTF1(_L("execute CreateContext(CFbsBitGc*&)")); |
|
827 TInt err = GetFbsDevice()->CreateContext(context); |
|
828 if (err != KErrNone) |
|
829 { |
|
830 ERR_PRINTF2(KLogError, err); |
|
831 SetError(err); |
|
832 } |
|
833 else |
|
834 { |
|
835 wrapper->SetObjectL(context); |
|
836 } |
|
837 } |
|
838 return ETrue; |
|
839 } |
|
840 } |
|
841 |
|
842 void CT_DataFbsDevice::DoCmdRectCompareL(const TDesC& aSection) |
|
843 { |
|
844 TBool dataOk = ETrue; |
|
845 |
|
846 // Get test data for command input parameter(s) |
|
847 TRect datRect1; |
|
848 if ( !GetRectFromConfig(aSection, KFldRect1, datRect1) ) |
|
849 { |
|
850 dataOk = EFalse; |
|
851 ERR_PRINTF2(KLogMissingParameter, &KFldRect1); |
|
852 SetBlockResult(EFail); |
|
853 } |
|
854 |
|
855 TRect datRect2; |
|
856 if ( !GetRectFromConfig(aSection, KFldRect2, datRect2) ) |
|
857 { |
|
858 dataOk = EFalse; |
|
859 ERR_PRINTF2(KLogMissingParameter, &KFldRect2); |
|
860 SetBlockResult(EFail); |
|
861 } |
|
862 |
|
863 TBool expected; |
|
864 if ( !GetBoolFromConfig(aSection, KFldExpected, expected) ) |
|
865 { |
|
866 dataOk = EFalse; |
|
867 ERR_PRINTF2(KLogMissingParameter, &KFldExpected); |
|
868 SetBlockResult(EFail); |
|
869 } |
|
870 |
|
871 if (dataOk) |
|
872 { |
|
873 TBool actual; |
|
874 CFbsDevice* device = NULL; |
|
875 CFbsDevice* self = GetFbsDevice(); |
|
876 if (!CT_GraphicsUtil::GetFbsDeviceL(*this, aSection, KFldFbsDevice, device) ) |
|
877 { |
|
878 device = self; |
|
879 } |
|
880 actual = self->RectCompare(datRect1, *device, datRect2); |
|
881 INFO_PRINTF2(_L("execute RectCompare(const TRect&, const CFbsDevice&, const TRect&)=%d"), actual); |
|
882 |
|
883 if (actual != expected) |
|
884 { |
|
885 ERR_PRINTF1(KLogNotExpectedValue); |
|
886 SetBlockResult(EFail); |
|
887 } |
|
888 } |
|
889 } |
|
890 |
|
891 void CT_DataFbsDevice::DoCmdSetCustomPaletteL(const TDesC& aSection) |
|
892 { |
|
893 CPalette* palette= NULL; |
|
894 |
|
895 if ( !CT_GraphicsUtil::GetPaletteL(*this, aSection, KFldPalette(), palette) ) |
|
896 { |
|
897 INFO_PRINTF1(_L("execute SetCustomPalette(NULL)")); |
|
898 } |
|
899 else |
|
900 { |
|
901 INFO_PRINTF1(_L("execute SetCustomPalette(const CPalette*)")); |
|
902 } |
|
903 |
|
904 TInt err = GetFbsDevice()->SetCustomPalette(palette); |
|
905 if (err != KErrNone) |
|
906 { |
|
907 ERR_PRINTF2(KLogError, err); |
|
908 SetError(err); |
|
909 } |
|
910 } |
|
911 |
|
912 void CT_DataFbsDevice::DoCmdGraphicsAccelerator() |
|
913 { |
|
914 CGraphicsAccelerator* ga= NULL; |
|
915 INFO_PRINTF1(_L("execute GraphicsAccelerator()")); |
|
916 ga = GetFbsDevice()->GraphicsAccelerator(); |
|
917 if (ga != NULL) |
|
918 { |
|
919 INFO_PRINTF1(_L("GraphicsAccelerator Supported")); |
|
920 } |
|
921 else |
|
922 { |
|
923 INFO_PRINTF1(_L("GraphicsAccelerator Not Supported")); |
|
924 } |
|
925 } |
|
926 |
|
927 void CT_DataFbsDevice::DoCmdOrientation(const TDesC& aSection) |
|
928 { |
|
929 CFbsBitGc::TGraphicsOrientation actual = GetFbsDevice()->Orientation(); |
|
930 INFO_PRINTF2(_L("execute Orientation()=%d"), actual); |
|
931 |
|
932 CFbsBitGc::TGraphicsOrientation expected; |
|
933 if (!CT_GraphicsUtil::GetGraphicsOrientation(*this, aSection, KFldExpectedOrientation, expected)) |
|
934 { |
|
935 ERR_PRINTF2(KLogMissingParameter, &KFldExpectedOrientation); |
|
936 SetBlockResult(EFail); |
|
937 } |
|
938 else |
|
939 { |
|
940 if (actual != expected) |
|
941 { |
|
942 ERR_PRINTF1(KLogNotExpectedValue); |
|
943 SetBlockResult(EFail); |
|
944 } |
|
945 } |
|
946 } |
|
947 |
|
948 void CT_DataFbsDevice::DoCmdDisplayMode16M(const TDesC& aSection) |
|
949 { |
|
950 TDisplayMode actual = GetFbsDevice()->DisplayMode16M(); |
|
951 INFO_PRINTF2(_L("execute DisplayMode16M()=%d"), actual); |
|
952 |
|
953 // get display mode from parameters |
|
954 TDisplayMode expected; |
|
955 if (CT_GraphicsUtil::ReadDisplayMode(*this, aSection, KFldExpectedDisplayMode(), expected) ) |
|
956 { |
|
957 if (actual != expected) |
|
958 { |
|
959 ERR_PRINTF1(KLogNotExpectedValue); |
|
960 SetBlockResult(EFail); |
|
961 } |
|
962 } |
|
963 } |
|
964 |
|
965 void CT_DataFbsDevice::DoCmdSetScalingFactor(const TDesC& aSection) |
|
966 { |
|
967 TBool dataOk = ETrue; |
|
968 TPoint point; |
|
969 |
|
970 if ( !GetPointFromConfig(aSection, KFldOrigin, point) ) |
|
971 { |
|
972 dataOk = EFalse; |
|
973 ERR_PRINTF2(KLogMissingParameter, &KFldOrigin); |
|
974 SetBlockResult(EFail); |
|
975 } |
|
976 |
|
977 TInt factorX; |
|
978 if ( !GetIntFromConfig(aSection, KFldFactorX, factorX) ) |
|
979 { |
|
980 dataOk = EFalse; |
|
981 ERR_PRINTF2(KLogMissingParameter, &KFldFactorX); |
|
982 SetBlockResult(EFail); |
|
983 } |
|
984 |
|
985 TInt factorY; |
|
986 if ( !GetIntFromConfig(aSection, KFldFactorY, factorY) ) |
|
987 { |
|
988 dataOk = EFalse; |
|
989 ERR_PRINTF2(KLogMissingParameter, &KFldFactorY); |
|
990 SetBlockResult(EFail); |
|
991 } |
|
992 |
|
993 TInt divisorX; |
|
994 if ( !GetIntFromConfig(aSection, KFldDivisorX, divisorX) ) |
|
995 { |
|
996 dataOk = EFalse; |
|
997 ERR_PRINTF2(KLogMissingParameter, &KFldDivisorX); |
|
998 SetBlockResult(EFail); |
|
999 } |
|
1000 |
|
1001 TInt divisorY; |
|
1002 if ( !GetIntFromConfig(aSection, KFldDivisorY, divisorY) ) |
|
1003 { |
|
1004 dataOk = EFalse; |
|
1005 ERR_PRINTF2(KLogMissingParameter, &KFldDivisorY); |
|
1006 SetBlockResult(EFail); |
|
1007 } |
|
1008 |
|
1009 if (dataOk) |
|
1010 { |
|
1011 INFO_PRINTF1(_L("execute SetScalingFactor(const TPoint&, TInt, TInt, TInt, TInt)")); |
|
1012 TInt err = GetFbsDevice()->SetScalingFactor(point, factorX, factorY, divisorX, divisorY); |
|
1013 if (err != KErrNone) |
|
1014 { |
|
1015 ERR_PRINTF2(KLogError, err); |
|
1016 SetError(err); |
|
1017 } |
|
1018 } |
|
1019 } |
|
1020 |
|
1021 void CT_DataFbsDevice::DoCmdGetDrawRect(const TDesC& aSection) |
|
1022 { |
|
1023 TRect actual; |
|
1024 |
|
1025 INFO_PRINTF1(_L("execute GetDrawRect(TRect&)")); |
|
1026 GetFbsDevice()->GetDrawRect(actual); |
|
1027 INFO_PRINTF5(_L("DrawRect = (top.x=%d, top.y=%d, bottom.x=%d, bottom.y=%d)"), actual.iTl.iX, actual.iTl.iY, actual.iBr.iX, actual.iBr.iY); |
|
1028 |
|
1029 TRect expected; |
|
1030 if ( GetRectFromConfig(aSection, KFldExpectedDrawRect, expected) ) |
|
1031 { |
|
1032 if (actual != expected) |
|
1033 { |
|
1034 ERR_PRINTF1(KLogNotExpectedValue); |
|
1035 SetBlockResult(EFail); |
|
1036 } |
|
1037 } |
|
1038 } |
|
1039 |
|
1040 void CT_DataFbsDevice::DoCmdRegisterLinkedTypefaceL(const TDesC& aSection) |
|
1041 { |
|
1042 CLinkedTypefaceSpecification* spec = NULL; |
|
1043 if (!CT_GraphicsUtil::GetLinkedTypefaceSpecificationL(*this, aSection, KFldLinkedTypefaceSpec, spec)) |
|
1044 { |
|
1045 ERR_PRINTF2(KLogMissingParameter, &KFldLinkedTypefaceSpec); |
|
1046 SetBlockResult(EFail); |
|
1047 } |
|
1048 else |
|
1049 { |
|
1050 TInt actual; |
|
1051 INFO_PRINTF1(_L("execute RegisterLinkedTypeface(const CLinkedTypefaceSpecification&, TInt&)")); |
|
1052 TInt err = GetFbsDevice()->RegisterLinkedTypeface(*spec, actual); |
|
1053 if (err != KErrNone) |
|
1054 { |
|
1055 ERR_PRINTF2(KLogError, err); |
|
1056 SetError(err); |
|
1057 return; |
|
1058 } |
|
1059 |
|
1060 TInt expected; |
|
1061 if (GetIntFromConfig(aSection, KFldExpectedUid, expected)) |
|
1062 { |
|
1063 if (actual != expected) |
|
1064 { |
|
1065 ERR_PRINTF1(KLogNotExpectedValue); |
|
1066 SetBlockResult(EFail); |
|
1067 } |
|
1068 } |
|
1069 } |
|
1070 } |
|
1071 |
|
1072 void CT_DataFbsDevice::DoCmdSetDrawDeviceOffset(const TDesC& aSection) |
|
1073 { |
|
1074 TPoint point; |
|
1075 |
|
1076 if ( !GetPointFromConfig(aSection, KFldOffset, point) ) |
|
1077 { |
|
1078 ERR_PRINTF2(KLogMissingParameter, &KFldOrigin); |
|
1079 SetBlockResult(EFail); |
|
1080 } |
|
1081 else |
|
1082 { |
|
1083 TInt err = GetFbsDevice()->SetDrawDeviceOffset(point); |
|
1084 if (err != KErrNone) |
|
1085 { |
|
1086 ERR_PRINTF2(KLogError, err); |
|
1087 SetError(err); |
|
1088 } |
|
1089 } |
|
1090 } |