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