graphics/fntstore/src/T_DataBitmapFont.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 
       
    18 /**
       
    19 @test
       
    20 @internalComponent
       
    21 
       
    22 This contains CT_DataBitmapFont
       
    23 */
       
    24 
       
    25 #include "T_DataBitmapFont.h"
       
    26 #include "T_GraphicsUtil.h"
       
    27 
       
    28 /*@{*/
       
    29 /// Parameters
       
    30 _LIT(KFldExpected,								"expected");
       
    31 _LIT(KFldCode,									"code");
       
    32 _LIT(KFldIsNull,								"isnull");
       
    33 _LIT(KFldSessHandle,							"handle");
       
    34 _LIT(KFldGlyphBitmapType,						"glyphtype");
       
    35 
       
    36 _LIT(KFldCharMetrics,							"charmetrics");
       
    37 _LIT(KFldOFCharMetrics,							"ofcharmetrics");
       
    38 _LIT(KFldOFFaceAttrib,							"offaceattrib");
       
    39 _LIT(KFldOFMetrics,								"ofmetrics");
       
    40 
       
    41 
       
    42 /// Commands
       
    43 _LIT(KCmdBitmapEncoding,						"BitmapEncoding");
       
    44 _LIT(KCmdCharacterMetrics,						"CharacterMetrics");
       
    45 _LIT(KCmdCharacterNeedsToBeRasterized,			"CharacterNeedsToBeRasterized");
       
    46 _LIT(KCmdGetCharacterData,						"GetCharacterData");
       
    47 _LIT(KCmdGetFaceAttrib,							"GetFaceAttrib");
       
    48 _LIT(KCmdGetFontMetrics,						"GetFontMetrics");
       
    49 _LIT(KCmdGlyphBitmapType,						"GlyphBitmapType");
       
    50 _LIT(KCmdHasCharacterL,							"HasCharacterL");
       
    51 _LIT(KCmdIsOpenFont,							"IsOpenFont");
       
    52 _LIT(KCmdOpenFont,								"OpenFont");
       
    53 _LIT(KCmdRasterize,								"Rasterize");
       
    54 //_LIT(KCmdUniqueFontId,							"UniqueFontId");
       
    55 
       
    56 ///	Constant Literals
       
    57 _LIT(KTagCharMetricsAscent,						"ascent");
       
    58 _LIT(KTagCharMetricsHeight,						"height");
       
    59 _LIT(KTagCharMetricsMove,						"move");
       
    60 _LIT(KTagCharMetricsLeftAdjust,					"leftadjust");
       
    61 _LIT(KTagCharMetricsRightAdjust,				"rightadjust");
       
    62 
       
    63 _LIT(KTagOFCharMetricsHeight,					"height");
       
    64 _LIT(KTagOFCharMetricsWidth,				"width");
       
    65 
       
    66 _LIT(KTagOFFaceAttribFamilyName,				"familyname");
       
    67 _LIT(KTagOFFaceAttribMinSize,					"minsize");
       
    68 
       
    69 _LIT(KTagOFMetricsMaxHeight,					"maxheight");
       
    70 _LIT(KTagOFMetricsSize,							"size");
       
    71 
       
    72 _LIT(KFormatEntryField,		"%S_%S");
       
    73 
       
    74 /// Logging
       
    75 _LIT(KLogError,									"Error=%d");
       
    76 _LIT(KLogMissingParameter,						"Missing parameter '%S'");
       
    77 _LIT(KLogMissingExpectedValue,					"Missing expected value '%S'");
       
    78 _LIT(KLogNotExpectedValueInt,					"'%S' is not as expected=%d, actual=%d");
       
    79 _LIT(KLogNotExpectedValueString,				"'%S' is not as expected='%S', actual='%S'");
       
    80 
       
    81 /*@}*/
       
    82 
       
    83 
       
    84 /**
       
    85 * Two phase constructor
       
    86 */
       
    87 CT_DataBitmapFont* CT_DataBitmapFont::NewL()
       
    88 	{
       
    89 	CT_DataBitmapFont* ret = new (ELeave) CT_DataBitmapFont();
       
    90 	return ret;
       
    91 	}
       
    92 
       
    93 
       
    94 /**
       
    95 * Protected constructor. First phase construction
       
    96 */
       
    97 CT_DataBitmapFont::CT_DataBitmapFont()
       
    98 :	CT_DataFont(), iBitmapFont(NULL)
       
    99 	{
       
   100 	}
       
   101 
       
   102 TAny* CT_DataBitmapFont::GetObject()
       
   103 	{
       
   104 	return iBitmapFont;
       
   105 	}
       
   106 
       
   107 void CT_DataBitmapFont::SetObjectL(TAny* aObject)
       
   108 	{
       
   109 	iBitmapFont	= static_cast<CBitmapFont*> (aObject);
       
   110 	}
       
   111 		
       
   112 void CT_DataBitmapFont::DisownObjectL() 
       
   113 	{
       
   114 	iBitmapFont = NULL;
       
   115 	}
       
   116 
       
   117 CFont* CT_DataBitmapFont::GetFont() const
       
   118 	{
       
   119 	return iBitmapFont;
       
   120 	}
       
   121 
       
   122 /**
       
   123 * Process a command read from the ini file
       
   124 *
       
   125 * @param aDataWrapper	test step requiring command to be processed
       
   126 * @param aCommand	the command to process
       
   127 * @param aSection		the entry in the ini file requiring the command to be processed
       
   128 *
       
   129 * @return ETrue if the command is processed
       
   130 */
       
   131 TBool CT_DataBitmapFont::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex)
       
   132 	{
       
   133 	TBool ret = ETrue;
       
   134 
       
   135 	if (aCommand == KCmdBitmapEncoding)
       
   136 		{
       
   137 		DoCmdBitmapEncoding(aSection);
       
   138 		}
       
   139 	else if (aCommand == KCmdCharacterMetrics)
       
   140 		{
       
   141 		DoCmdCharacterMetrics(aSection);
       
   142 		}
       
   143 	else if (aCommand == KCmdCharacterNeedsToBeRasterized)
       
   144 		{
       
   145 		DoCmdCharacterNeedsToBeRasterized(aSection);
       
   146 		}
       
   147 	else if (aCommand == KCmdGetCharacterData)
       
   148 		{
       
   149 		DoCmdGetCharacterData(aSection);
       
   150 		}
       
   151 	else if (aCommand == KCmdGetFaceAttrib)
       
   152 		{
       
   153 		DoCmdGetFaceAttrib(aSection);
       
   154 		}
       
   155 	else if (aCommand == KCmdGetFontMetrics)
       
   156 		{
       
   157 		DoCmdGetFontMetrics(aSection);
       
   158 		}
       
   159 	else if (aCommand == KCmdGlyphBitmapType)
       
   160 		{
       
   161 		DoCmdGlyphBitmapType(aSection);
       
   162 		}
       
   163 	else if (aCommand == KCmdHasCharacterL)
       
   164 		{
       
   165 		DoCmdHasCharacterL(aSection);
       
   166 		}
       
   167 	else if (aCommand == KCmdIsOpenFont)
       
   168 		{
       
   169 		DoCmdIsOpenFont(aSection);
       
   170 		}
       
   171 	else if (aCommand == KCmdOpenFont)
       
   172 		{
       
   173 		DoCmdOpenFont(aSection);
       
   174 		}
       
   175 	else if (aCommand == KCmdRasterize)
       
   176 		{
       
   177 		DoCmdRasterize(aSection);
       
   178 		}
       
   179 //	else if (aCommand == KCmdUniqueFontId)
       
   180 //		{
       
   181 //		DoCmdUniqueFontId(aSection);
       
   182 //		}
       
   183 	else
       
   184 		{
       
   185 		ret = CT_DataFont::DoCommandL(aCommand, aSection, aAsyncErrorIndex);
       
   186 		}
       
   187 
       
   188 	return ret;
       
   189 	}
       
   190 
       
   191 ////////////////// COMMANDS IMPLEMENTATION  ////////////////////////
       
   192 
       
   193 /** Calls CBitmapFont::DoCmdBitmapEncoding() */
       
   194 void CT_DataBitmapFont::DoCmdBitmapEncoding(const TDesC& aSection)
       
   195 	{
       
   196 	INFO_PRINTF1(_L("Calls CBitmapFont::BitmapEncoding()"));
       
   197 	TInt ret = iBitmapFont->BitmapEncoding();
       
   198 	INFO_PRINTF2(_L("The actual bitmap encoding value is %d"), ret);
       
   199 	
       
   200 	TInt expected;
       
   201 	if( GetIntFromConfig(aSection, KFldExpected, expected) )
       
   202 		{
       
   203 		if (ret != expected)
       
   204 			{
       
   205 			ERR_PRINTF4(KLogNotExpectedValueInt, &KFldExpected, ret, expected);
       
   206 			SetBlockResult(EFail);
       
   207 			}
       
   208 		}
       
   209 	}
       
   210 
       
   211 void CT_DataBitmapFont::DoCmdCharacterMetrics(const TDesC& aSection)
       
   212 	{
       
   213 	TInt code;
       
   214 	if( !GetIntFromConfig(aSection, KFldCode, code) )
       
   215 		{
       
   216 		ERR_PRINTF2(KLogMissingParameter, &KFldCode);
       
   217 		SetBlockResult(EFail);
       
   218 		}
       
   219 	else
       
   220 		{
       
   221 		INFO_PRINTF1(_L("Calls CBitmapFont::CharacterMetrics(TInt, const TUint8*&)"));
       
   222 		TCharacterMetrics metrics;
       
   223 		const TUint8* ptr;
       
   224 		metrics= iBitmapFont->CharacterMetrics(code, ptr);
       
   225 		TBool failed = EFalse;
       
   226 		
       
   227 		TBool isNull;
       
   228 		if( GetBoolFromConfig(aSection, KFldIsNull, isNull) )
       
   229 			{
       
   230 			if(isNull)
       
   231 				{
       
   232 				if(ptr != NULL)
       
   233 					{
       
   234 					ERR_PRINTF1(_L("Should return a NULL pointer") );
       
   235 					failed = ETrue;
       
   236 					}
       
   237 				else
       
   238 					{
       
   239 					INFO_PRINTF1(_L("A NULL pointer is returned"));
       
   240 
       
   241 					}
       
   242 				}
       
   243 			else
       
   244 				{
       
   245 				if(ptr == NULL)
       
   246 					{
       
   247 					ERR_PRINTF1(_L("Should return a pointer to the character bitmap") );
       
   248 					failed = ETrue;
       
   249 					}
       
   250 				else
       
   251 					{
       
   252 					INFO_PRINTF1(_L("A pointer to the character bitmap is returned") );
       
   253 					}
       
   254 				}
       
   255 			}
       
   256 
       
   257 		TCharacterMetrics expected;
       
   258 		if( GetCharacterMetricsFromConfig(*this, aSection, KFldCharMetrics, expected) )
       
   259 			{
       
   260 			if(metrics.iAscentInPixels != expected.iAscentInPixels)
       
   261 				{
       
   262 				
       
   263 				ERR_PRINTF4(KLogNotExpectedValueInt, &KTagCharMetricsAscent, expected.iAscentInPixels, metrics.iAscentInPixels);
       
   264 				failed = ETrue;
       
   265 				}
       
   266 			if(metrics.iHeightInPixels != expected.iHeightInPixels)
       
   267 				{
       
   268 				ERR_PRINTF4(KLogNotExpectedValueInt, &KTagCharMetricsHeight, expected.iHeightInPixels, metrics.iHeightInPixels);
       
   269 				failed = ETrue;
       
   270 				}
       
   271 			if(metrics.iMoveInPixels != expected.iMoveInPixels)
       
   272 				{				
       
   273 				ERR_PRINTF4(KLogNotExpectedValueInt, &KTagCharMetricsMove, expected.iMoveInPixels, metrics.iMoveInPixels);	
       
   274 				failed = ETrue;
       
   275 				}
       
   276 			if(metrics.iLeftAdjustInPixels != expected.iLeftAdjustInPixels)
       
   277 				{
       
   278 				ERR_PRINTF4(KLogNotExpectedValueInt, &KTagCharMetricsLeftAdjust, expected.iLeftAdjustInPixels, metrics.iLeftAdjustInPixels);	
       
   279 				failed = ETrue;
       
   280 				}
       
   281 			if(metrics.iRightAdjustInPixels != expected.iRightAdjustInPixels)
       
   282 				{
       
   283 				ERR_PRINTF4(KLogNotExpectedValueInt, &KTagCharMetricsRightAdjust, expected.iRightAdjustInPixels, metrics.iRightAdjustInPixels);
       
   284 				failed = ETrue;
       
   285 				}
       
   286 			}
       
   287 		
       
   288 		if(failed)
       
   289 			{
       
   290 			SetBlockResult(EFail);
       
   291 			}
       
   292 		else
       
   293 			{
       
   294 			INFO_PRINTF1(_L("Character metrics is expected."));
       
   295 			}
       
   296 		}
       
   297 	}
       
   298 
       
   299 void CT_DataBitmapFont::CT_DataBitmapFont::DoCmdCharacterNeedsToBeRasterized(const TDesC& aSection)
       
   300 	{
       
   301 	TBool dataOK = ETrue;
       
   302 	
       
   303 	TInt handle;
       
   304 	if( !GetIntFromConfig(aSection, KFldSessHandle, handle) )
       
   305 		{
       
   306 		ERR_PRINTF2(KLogMissingParameter, &KFldSessHandle);
       
   307 		dataOK = EFalse;
       
   308 		}
       
   309 	
       
   310 	TInt code;
       
   311 	if( !GetIntFromConfig(aSection, KFldCode, code) )
       
   312 		{
       
   313 		ERR_PRINTF2(KLogMissingParameter, &KFldCode);
       
   314 		dataOK = EFalse;
       
   315 		}
       
   316 	
       
   317 	if(!dataOK)
       
   318 		{
       
   319 		SetBlockResult(EFail);
       
   320 		}
       
   321 	else
       
   322 		{
       
   323 		INFO_PRINTF1(_L("Calls CBitmapFont::CharacterNeedsToBeRasterized(TInt, TInt)"));
       
   324 		TBool ret = iBitmapFont->CharacterNeedsToBeRasterized(handle, code);
       
   325 		
       
   326 		TBool expected;
       
   327 		if( GetBoolFromConfig(aSection, KFldExpected, expected) )
       
   328 			{
       
   329 			if(ret)
       
   330 				{
       
   331 				if(!expected)
       
   332 					{
       
   333 					ERR_PRINTF1(_L("Return value is not as expected: EFalse, actual: ETrue"));
       
   334 					SetBlockResult(EFail);
       
   335 					}
       
   336 				else
       
   337 					{
       
   338 					INFO_PRINTF1(_L("Return value is ETrue"));	
       
   339 					}
       
   340 				}
       
   341 			else
       
   342 				{
       
   343 				if(expected)
       
   344 					{
       
   345 					ERR_PRINTF1(_L("Return value is not as expected: ETrue, actual: EFalse"));
       
   346 					SetBlockResult(EFail);
       
   347 					}
       
   348 				else
       
   349 					{
       
   350 					INFO_PRINTF1(_L("Return value is EFalse"));
       
   351 					}
       
   352 				}
       
   353 			}
       
   354 		}
       
   355 	}
       
   356 
       
   357 
       
   358 void CT_DataBitmapFont::DoCmdGetCharacterData(const TDesC& aSection)
       
   359 	{
       
   360 	TBool dataOK = ETrue;
       
   361 	
       
   362 	TInt handle;
       
   363 	if( !GetIntFromConfig(aSection, KFldSessHandle, handle) )
       
   364 		{
       
   365 		ERR_PRINTF2(KLogMissingParameter, &KFldSessHandle);		
       
   366 		dataOK = EFalse;
       
   367 		}
       
   368 	
       
   369 	TInt code;	
       
   370 	if( !GetIntFromConfig(aSection, KFldCode, code) )
       
   371 		{
       
   372 		ERR_PRINTF2(KLogMissingParameter, &KFldCode);
       
   373 		dataOK = EFalse;
       
   374 		}
       
   375 	
       
   376 	if(!dataOK)
       
   377 		{
       
   378 		SetBlockResult(EFail);
       
   379 		}
       
   380 	else
       
   381 		{
       
   382 		INFO_PRINTF1(_L("Calls CBitmapFont::GetCharacterData(TInt aSessionHandle, TInt aCode, TOpenFontCharMetrics &aMetrics, const TUint8 *&aBitmap)"));
       
   383 		TOpenFontCharMetrics metrics;
       
   384 		const TUint8* ptr;
       
   385 		TBool ret = iBitmapFont->GetCharacterData(handle, code, metrics, ptr);		
       
   386 		
       
   387 		TBool expected;
       
   388 		if( GetBoolFromConfig(aSection, KFldExpected, expected) )
       
   389 			{
       
   390 			if(ret)
       
   391 				{
       
   392 				if(!expected)
       
   393 					{
       
   394 					ERR_PRINTF1(_L("Return value is not as expected: EFalse, actual: ETrue"));
       
   395 					SetBlockResult(EFail);
       
   396 					}
       
   397 				else
       
   398 					{
       
   399 					INFO_PRINTF1(_L("Return value is ETrue"));
       
   400 										
       
   401 					TBool isNull;
       
   402 					if( GetBoolFromConfig(aSection, KFldIsNull, isNull) )
       
   403 						{
       
   404 						if(isNull)
       
   405 							{
       
   406 							if(ptr != NULL)
       
   407 								{
       
   408 								ERR_PRINTF1(_L("Should return a NULL pointer") );
       
   409 								SetBlockResult(EFail);
       
   410 								}
       
   411 							else
       
   412 								{
       
   413 								INFO_PRINTF1(_L("A NULL pointer is returned") );
       
   414 								}
       
   415 							}
       
   416 						else
       
   417 							{
       
   418 							if(ptr == NULL)
       
   419 								{
       
   420 								ERR_PRINTF1(_L("Should return a pointer to the character bitmap.") );
       
   421 								SetBlockResult(EFail);
       
   422 								}
       
   423 							else
       
   424 								{
       
   425 								INFO_PRINTF1(_L("a pointer to the character bitmap is returned") );
       
   426 								}
       
   427 							}
       
   428 						}					
       
   429 					
       
   430 					TBool failed = EFalse;
       
   431 					TOpenFontCharMetrics expectedMetrics;
       
   432 					if( GetOpenFontCharMetricsFromConfig(*this, aSection, KFldOFCharMetrics, expectedMetrics) )
       
   433 						{
       
   434 						if(metrics.Width() != expectedMetrics.Width())
       
   435 							{
       
   436 							ERR_PRINTF4(KLogNotExpectedValueInt, &KTagOFCharMetricsWidth, metrics.Width(), expectedMetrics.Width());
       
   437 							failed = ETrue;
       
   438 							}			
       
   439 						if(metrics.Height() != expectedMetrics.Height())
       
   440 							{
       
   441 							ERR_PRINTF4(KLogNotExpectedValueInt, &KTagOFCharMetricsHeight, metrics.Height(), expectedMetrics.Height());
       
   442 							failed = ETrue;
       
   443 							}
       
   444 						
       
   445 						if(failed)
       
   446 							{
       
   447 							SetBlockResult(EFail);
       
   448 							}
       
   449 						else
       
   450 							{
       
   451 							INFO_PRINTF1(_L("Open font character metrics is expected"));
       
   452 							}
       
   453 						}
       
   454 					}
       
   455 				}
       
   456 			else
       
   457 				{
       
   458 				if(expected)
       
   459 					{
       
   460 					ERR_PRINTF1(_L("Return value is not as expected: ETrue, actual: EFalse"));
       
   461 					SetBlockResult(EFail);
       
   462 					}
       
   463 				else
       
   464 					{
       
   465 					INFO_PRINTF1(_L("Return value is EFalse"));
       
   466 					}
       
   467 				}
       
   468 			}
       
   469 		}	
       
   470 	}
       
   471 
       
   472 void CT_DataBitmapFont::DoCmdGetFaceAttrib(const TDesC& aSection)
       
   473 	{
       
   474 	INFO_PRINTF1(_L("Calls CBitmapFont::GetFaceAttrib(TOpenFontFaceAttrib&)"));
       
   475 	TOpenFontFaceAttrib attrib;
       
   476 	TBool ret = iBitmapFont->GetFaceAttrib(attrib);
       
   477 	
       
   478 	TBool expected;
       
   479 	if( GetBoolFromConfig(aSection, KFldExpected, expected) )
       
   480 		{
       
   481 		if(ret)
       
   482 			{
       
   483 			if(!expected)
       
   484 				{
       
   485 				ERR_PRINTF1(_L("Return value is not as expected: EFalse, actual: ETrue"));
       
   486 				SetBlockResult(EFail);
       
   487 				}
       
   488 			else
       
   489 				{
       
   490 				INFO_PRINTF1(_L("Return value is ETrue"));
       
   491 				TBool failed = EFalse;				
       
   492 				TOpenFontFaceAttrib expectedAttrib;
       
   493 				if( GetOpenFontFaceAttribFromConfig(*this, aSection, KFldOFFaceAttrib, expectedAttrib) )
       
   494 					{
       
   495 					TPtrC actualName = attrib.FamilyName();
       
   496 					TPtrC expectedName = expectedAttrib.FamilyName();
       
   497 					if(actualName != expectedName)
       
   498 						{	
       
   499 						ERR_PRINTF4(KLogNotExpectedValueString, &KTagOFFaceAttribFamilyName, &expectedName, &actualName);
       
   500 						failed = ETrue;
       
   501 						}
       
   502 					if(attrib.MinSizeInPixels() != expectedAttrib.MinSizeInPixels())
       
   503 						{
       
   504 						ERR_PRINTF4(KLogNotExpectedValueInt, &KTagOFFaceAttribMinSize, expectedAttrib.MinSizeInPixels(), attrib.MinSizeInPixels());
       
   505 						failed = ETrue;
       
   506 						}
       
   507 					
       
   508 					if(failed)
       
   509 						{
       
   510 						SetBlockResult(EFail);
       
   511 						}
       
   512 					else
       
   513 						{
       
   514 						INFO_PRINTF1(_L("Open font typeface attributes is expected"));
       
   515 						}
       
   516 					}
       
   517 				}
       
   518 			}
       
   519 		else
       
   520 			{
       
   521 			if(expected)
       
   522 				{
       
   523 				ERR_PRINTF1(_L("Return value is not as expected: ETrue, actual: EFalse"));
       
   524 				SetBlockResult(EFail);
       
   525 				}
       
   526 			else
       
   527 				{
       
   528 				INFO_PRINTF1(_L("Return value is EFalse"));
       
   529 				}
       
   530 			}
       
   531 		}
       
   532 	}
       
   533 
       
   534 void CT_DataBitmapFont::DoCmdGetFontMetrics(const TDesC& aSection)
       
   535 	{
       
   536 	INFO_PRINTF1(_L("Calls CBitmapFont::GetFontMetrics(TOpenFontMetrics&)"));
       
   537 	TOpenFontMetrics metrics;
       
   538 	iBitmapFont->GetFontMetrics(metrics);
       
   539 	
       
   540 	TOpenFontMetrics expectedMetrics;
       
   541 	if( GetOpenFontMetricsFromConfig(*this, aSection, KFldOFMetrics, expectedMetrics) )
       
   542 		{
       
   543 		TBool failed = EFalse;
       
   544 		if(metrics.MaxHeight() != expectedMetrics.MaxHeight())
       
   545 			{
       
   546 			ERR_PRINTF4(KLogNotExpectedValueInt, &KTagOFMetricsMaxHeight, expectedMetrics.MaxHeight(), metrics.MaxHeight());
       
   547 			failed = ETrue;
       
   548 			}
       
   549 		if(metrics.Size() != expectedMetrics.Size())
       
   550 			{
       
   551 			ERR_PRINTF4(KLogNotExpectedValueInt, &KTagOFMetricsSize, expectedMetrics.Size(), metrics.Size());
       
   552 			failed = ETrue;
       
   553 			}
       
   554 		
       
   555 		if(failed)
       
   556 			{
       
   557 			SetBlockResult(EFail);
       
   558 			}
       
   559 		else
       
   560 			{
       
   561 			INFO_PRINTF1(_L("Open font metrics is expected"));
       
   562 			}
       
   563 		}
       
   564 	}
       
   565 
       
   566 void CT_DataBitmapFont::DoCmdGlyphBitmapType(const TDesC& aSection)
       
   567 	{
       
   568 	INFO_PRINTF1(_L("Calls CBitmapFont::GlyphBitmapType()"));
       
   569 	TGlyphBitmapType ret = iBitmapFont->GlyphBitmapType();
       
   570 	INFO_PRINTF2(_L("Glyph bitmap type is %d."), (TInt)ret);
       
   571 	
       
   572 	TGlyphBitmapType expected;
       
   573 	if( CT_GraphicsUtil::ReadGlyphBitmapType(*this, aSection, KFldGlyphBitmapType(), expected) )
       
   574 		{
       
   575 		if(ret != expected)
       
   576 			{
       
   577 			ERR_PRINTF4(KLogNotExpectedValueInt, &KFldExpected, (TInt)ret, (TInt)expected);
       
   578 			SetBlockResult(EFail);
       
   579 			}
       
   580 		}
       
   581 	}
       
   582 
       
   583 void CT_DataBitmapFont::DoCmdHasCharacterL(const TDesC& aSection)
       
   584 	{
       
   585 	TInt code;
       
   586 	if( !GetIntFromConfig(aSection, KFldCode, code) )
       
   587 		{
       
   588 		ERR_PRINTF2(KLogMissingParameter, &KFldCode);
       
   589 		SetBlockResult(EFail);
       
   590 		}
       
   591 	else
       
   592 		{
       
   593 		INFO_PRINTF1(_L("Calls CBitmapFont::HasCharacterL(TInt)"));
       
   594 		TBool ret = iBitmapFont->HasCharacterL(code);
       
   595 		
       
   596 		TBool expected;
       
   597 		if( GetBoolFromConfig(aSection, KFldExpected, expected) )
       
   598 			{
       
   599 			if(ret)
       
   600 				{
       
   601 				if(!expected)
       
   602 					{
       
   603 					ERR_PRINTF1(_L("Return value is not as expected: EFalse, actual: ETrue"));
       
   604 					SetBlockResult(EFail);
       
   605 					}
       
   606 				else
       
   607 					{
       
   608 					INFO_PRINTF1(_L("Return value is ETrue"));
       
   609 					}
       
   610 				}
       
   611 			else
       
   612 				{
       
   613 				if(expected)
       
   614 					{
       
   615 					ERR_PRINTF1(_L("Return value is not as expected: ETrue, actual: EFalse"));
       
   616 					SetBlockResult(EFail);
       
   617 					}
       
   618 				else
       
   619 					{
       
   620 					INFO_PRINTF1(_L("Return value is EFalse"));
       
   621 					}
       
   622 				}
       
   623 			}
       
   624 		}
       
   625 	}
       
   626 
       
   627 void CT_DataBitmapFont::DoCmdIsOpenFont(const TDesC& aSection)
       
   628 	{
       
   629 	INFO_PRINTF1(_L("Calls CBitmapFont::IsOpenFont()"));
       
   630 	TBool ret = iBitmapFont->IsOpenFont();
       
   631 	
       
   632 	TBool expected;
       
   633 	if( GetBoolFromConfig(aSection, KFldExpected, expected) )
       
   634 		{
       
   635 		if(ret)
       
   636 			{
       
   637 			if(!expected)
       
   638 				{
       
   639 				ERR_PRINTF1(_L("Return value is not as expected: EFalse, actual: ETrue"));
       
   640 				SetBlockResult(EFail);
       
   641 				}
       
   642 			else
       
   643 				{
       
   644 				INFO_PRINTF1(_L("Return value is ETrue"));
       
   645 				}
       
   646 			}
       
   647 		else
       
   648 			{
       
   649 			if(expected)
       
   650 				{
       
   651 				ERR_PRINTF1(_L("Return value is not as expected: ETrue, actual: EFalse"));
       
   652 				SetBlockResult(EFail);
       
   653 				}
       
   654 			else
       
   655 				{
       
   656 				INFO_PRINTF1(_L("Return value is EFalse"));
       
   657 				}
       
   658 			}
       
   659 		}
       
   660 	}
       
   661 
       
   662 void CT_DataBitmapFont::DoCmdOpenFont(const TDesC& aSection)
       
   663 	{
       
   664 	INFO_PRINTF1(_L("Calls CBitmapFont::OpenFont()"));
       
   665 	COpenFont* ptr = iBitmapFont->OpenFont();
       
   666 	
       
   667 	TBool isNull;
       
   668 	if( GetBoolFromConfig(aSection, KFldIsNull, isNull) )
       
   669 		{
       
   670 		if(isNull)
       
   671 			{
       
   672 			if(ptr != NULL)
       
   673 				{
       
   674 				ERR_PRINTF1(_L("Should return a NULL pointer") );
       
   675 				SetBlockResult(EFail);
       
   676 				}
       
   677 			else
       
   678 				{
       
   679 				INFO_PRINTF1(_L("A NULL pointer is returned") );
       
   680 				}
       
   681 			}
       
   682 		else
       
   683 			{
       
   684 			if(ptr == NULL)
       
   685 				{
       
   686 				ERR_PRINTF1(_L("Should return a pointer to COpenFont") );
       
   687 				SetBlockResult(EFail);
       
   688 				}
       
   689 			else
       
   690 				{
       
   691 				INFO_PRINTF1(_L("A pointer to COpenFont is returned") );
       
   692 				}
       
   693 			}
       
   694 		}
       
   695 	}
       
   696 
       
   697 void CT_DataBitmapFont::DoCmdRasterize(const TDesC& aSection)
       
   698 	{
       
   699 	TBool dataOK = ETrue;
       
   700 	
       
   701 	TInt handle;
       
   702 	if( !GetIntFromConfig(aSection, KFldSessHandle, handle) )
       
   703 		{
       
   704 		ERR_PRINTF2(KLogMissingParameter, &KFldSessHandle);	
       
   705 		dataOK = EFalse;
       
   706 		}
       
   707 	
       
   708 	TInt code;
       
   709 	if( !GetIntFromConfig(aSection, KFldCode, code) )
       
   710 		{
       
   711 		ERR_PRINTF2(KLogMissingParameter, &KFldCode);
       
   712 		dataOK = EFalse;
       
   713 		}
       
   714 	
       
   715 	if(!dataOK)
       
   716 		{
       
   717 		SetBlockResult(EFail);
       
   718 		}
       
   719 	else
       
   720 		{
       
   721 		INFO_PRINTF1(_L("Calls CBitmapFont::Rasterize(TInt, TInt, TOpenFontGlyphData*)"));
       
   722 		TOpenFontGlyphData* ptr = NULL;
       
   723 		TBool ret = iBitmapFont->Rasterize(handle, code, ptr);
       
   724 		
       
   725 		TBool expected;
       
   726 		if( GetBoolFromConfig(aSection, KFldExpected, expected) )
       
   727 			{
       
   728 			if(ret)
       
   729 				{
       
   730 				if(!expected)
       
   731 					{
       
   732 					ERR_PRINTF1(_L("Return value is not as expected: EFalse, actual: ETrue"));
       
   733 					SetBlockResult(EFail);
       
   734 					}
       
   735 				else
       
   736 					{
       
   737 					// The character was successfully rasterized.
       
   738 					INFO_PRINTF1(_L("Return value is ETrue"));	
       
   739 					TBool isNull;
       
   740 					if( GetBoolFromConfig(aSection, KFldIsNull, isNull) )
       
   741 						{
       
   742 						if(isNull)
       
   743 							{
       
   744 							if(ptr != NULL)
       
   745 								{
       
   746 								ERR_PRINTF1(_L("Should return a NULL pointer") );
       
   747 								SetBlockResult(EFail);
       
   748 								}
       
   749 							else
       
   750 								{
       
   751 								INFO_PRINTF1(_L("A NULL pointer is returned"));
       
   752 								}
       
   753 							}
       
   754 						else
       
   755 							{
       
   756 							if(ptr == NULL)
       
   757 								{
       
   758 								ERR_PRINTF1(_L("Should return a pointer to TOpenFontGlyphData") );
       
   759 								SetBlockResult(EFail);
       
   760 								}
       
   761 							else
       
   762 								{
       
   763 								INFO_PRINTF1(_L("A pointer to TOpenFontGlyphData is returned"));
       
   764 								}
       
   765 							}
       
   766 						}
       
   767 					}
       
   768 				}
       
   769 			// ret = EFalse
       
   770 			else
       
   771 				{
       
   772 				if(expected)
       
   773 					{
       
   774 					ERR_PRINTF1(_L("Return value is not as expected: ETrue, actual: EFalse"));
       
   775 					SetBlockResult(EFail);				
       
   776 					}
       
   777 				else
       
   778 					{
       
   779 					INFO_PRINTF1(_L("Return value is EFalse"));
       
   780 					}
       
   781 				}
       
   782 			}
       
   783 		}
       
   784 	}
       
   785 
       
   786 //void CT_DataBitmapFont::DoCmdUniqueFontId(const TDesC& aSection)
       
   787 //	{
       
   788 //	INFO_PRINTF1(_L("Calls CBitmapFont::UniqueFontId()"));
       
   789 //	TUint32 ret = iBitmapFont->UniqueFontId();
       
   790 //	INFO_PRINTF2(_L("Unique font id is %d"), (TInt)ret);
       
   791 //	
       
   792 //	TInt temp;
       
   793 //	if( GetIntFromConfig(aSection, KFldExpected, temp) )
       
   794 //		{
       
   795 //		TUint32 expected = (TUint32)temp;
       
   796 //		if(ret != expected)
       
   797 //			{
       
   798 //			ERR_PRINTF4(KLogNotExpectedValueInt, &KFldExpected, ret, expected);
       
   799 //			SetBlockResult(EFail);
       
   800 //			}
       
   801 //		}
       
   802 //	}
       
   803 
       
   804 TBool CT_DataBitmapFont::GetCharacterMetricsFromConfig(CDataWrapper& aDataWrapper, const TDesC& aSectName, const TDesC& aKeyName, TCharacterMetrics& aResult)
       
   805 	{
       
   806 	TBuf<KMaxTestExecuteCommandLength>	tempStore;
       
   807 	TInt temp;
       
   808 	TBool ret = EFalse;
       
   809 	
       
   810 	tempStore.Format(KFormatEntryField, &aKeyName, &KTagCharMetricsAscent);
       
   811 	if( aDataWrapper.GetIntFromConfig(aSectName, tempStore, temp) )
       
   812 		{
       
   813 		aResult.iAscentInPixels = temp;
       
   814 		ret = ETrue;
       
   815 		}
       
   816 
       
   817 	tempStore.Format(KFormatEntryField, &aKeyName, &KTagCharMetricsHeight);
       
   818 	if( aDataWrapper.GetIntFromConfig(aSectName, tempStore, temp) )
       
   819 		{
       
   820 		aResult.iHeightInPixels = temp;
       
   821 		ret = ETrue;
       
   822 		}
       
   823 
       
   824 	tempStore.Format(KFormatEntryField, &aKeyName, &KTagCharMetricsLeftAdjust);
       
   825 	if( aDataWrapper.GetIntFromConfig(aSectName, tempStore, temp) )
       
   826 		{
       
   827 		aResult.iLeftAdjustInPixels = temp;
       
   828 		ret = ETrue;
       
   829 		}
       
   830 	
       
   831 	tempStore.Format(KFormatEntryField, &aKeyName, &KTagCharMetricsMove);
       
   832 	if( aDataWrapper.GetIntFromConfig(aSectName, tempStore, temp) )
       
   833 		{
       
   834 		aResult.iMoveInPixels = temp;
       
   835 		ret = ETrue;
       
   836 		}
       
   837 	
       
   838 	tempStore.Format(KFormatEntryField, &aKeyName, &KTagCharMetricsRightAdjust);
       
   839 	if( aDataWrapper.GetIntFromConfig(aSectName, tempStore, temp) )
       
   840 		{
       
   841 		aResult.iRightAdjustInPixels = temp;
       
   842 		ret = ETrue;
       
   843 		}
       
   844 	
       
   845 	return ret;
       
   846 	}
       
   847 
       
   848 
       
   849 TBool CT_DataBitmapFont::GetOpenFontCharMetricsFromConfig(CDataWrapperBase& aDataWrapper,const TDesC& aSectName,const TDesC& aKeyName,TOpenFontCharMetrics& aResult)
       
   850 	{
       
   851 	TBuf<KMaxTestExecuteCommandLength>	tempStore;
       
   852 	TInt width;
       
   853 	TInt height;
       
   854 	
       
   855 	tempStore.Format(KFormatEntryField, &aKeyName, &KTagOFCharMetricsWidth);
       
   856 	if( aDataWrapper.GetIntFromConfig(aSectName, tempStore, width) )
       
   857 		{		
       
   858 		tempStore.Format(KFormatEntryField, &aKeyName, &KTagOFCharMetricsHeight);
       
   859 		if( aDataWrapper.GetIntFromConfig(aSectName, tempStore, height) )
       
   860 			{
       
   861 			aResult.SetHeight(height);
       
   862 			aResult.SetWidth(width);
       
   863 			return ETrue;
       
   864 			}
       
   865 		}
       
   866 	
       
   867 	return EFalse;
       
   868 	}
       
   869 
       
   870 TBool CT_DataBitmapFont::GetOpenFontFaceAttribFromConfig(CDataWrapper& aDataWrapper,const TDesC& aSectName,const TDesC& aKeyName,TOpenFontFaceAttrib& aResult)
       
   871 	{
       
   872 	TBuf<KMaxTestExecuteCommandLength>	tempStore;
       
   873 	tempStore.Format(KFormatEntryField, &aKeyName, &KTagOFFaceAttribFamilyName);
       
   874 	
       
   875 	TPtrC familyname;
       
   876 	TInt minsize;
       
   877 	if( aDataWrapper.GetStringFromConfig(aSectName, tempStore, familyname) )
       
   878 		{
       
   879 		tempStore.Format(KFormatEntryField, &aKeyName, &KTagOFFaceAttribMinSize);
       
   880 		if( aDataWrapper.GetIntFromConfig(aSectName, tempStore, minsize) )
       
   881 			{
       
   882 			aResult.SetFamilyName(familyname);						
       
   883 			aResult.SetMinSizeInPixels(minsize);
       
   884 			return ETrue;
       
   885 			}
       
   886 		}
       
   887 	
       
   888 	return EFalse;
       
   889 	}
       
   890 
       
   891 TBool CT_DataBitmapFont::GetOpenFontMetricsFromConfig(CDataWrapper& aDataWrapper,const TDesC& aSectName, const TDesC& aKeyName, TOpenFontMetrics& aResult)
       
   892 	{ 
       
   893 	TBuf<KMaxTestExecuteCommandLength>	tempStore;
       
   894 	tempStore.Format(KFormatEntryField, &aKeyName, &KTagOFMetricsMaxHeight);
       
   895 	
       
   896 	TInt maxheight;
       
   897 	TInt size;
       
   898 	if( aDataWrapper.GetIntFromConfig(aSectName, tempStore, maxheight) )
       
   899 		{
       
   900 		tempStore.Format(KFormatEntryField, &aKeyName, &KTagOFMetricsSize);
       
   901 		if( aDataWrapper.GetIntFromConfig(aSectName, tempStore, size) )
       
   902 			{
       
   903 			aResult.SetMaxHeight(maxheight);
       
   904 			aResult.SetSize(size);
       
   905 			return ETrue;
       
   906 			}
       
   907 		}
       
   908 	
       
   909 	return EFalse;
       
   910 	}
       
   911