common/tools/ats/smoketest/graphics/wserv/src/T_DataWsScreenDevice.cpp
changeset 833 6ffc235847d0
child 872 17498133d9ad
equal deleted inserted replaced
832:9b2bf01d4d36 833:6ffc235847d0
       
     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 #include "T_DataWsScreenDevice.h"
       
    19 #include "T_GraphicsUtil.h"
       
    20 
       
    21 /*@{*/
       
    22 _LIT(KDataClassname,							"CWsScreenDevice");
       
    23 
       
    24 ///	Fields
       
    25 _LIT(KFldAlgStyle,								"alg_style");
       
    26 _LIT(KFldBackLight,								"backlight");
       
    27 _LIT(KFldBitmap,								"bitmap");
       
    28 _LIT(KFldDefaultScreenNumber,					"defaultscreennumber");
       
    29 _LIT(KFldExpected,								"expected");
       
    30 _LIT(KFldExpectedCount,							"expectedcount");
       
    31 _LIT(KFldFinish,								"finish");
       
    32 _LIT(KFldFlags,									"flags");
       
    33 _LIT(KFldFormatFieldNumber,						"%S%d");
       
    34 _LIT(KFldFontUid,								"font_uid");
       
    35 _LIT(KFldMode,									"mode");
       
    36 _LIT(KFldPalette,								"palette");
       
    37 _LIT(KFldPixel,									"pixel");
       
    38 _LIT(KFldPixelSize,								"pixelsize");
       
    39 _LIT(KFldRect,									"rect");
       
    40 _LIT(KFldRect1,									"rect1");
       
    41 _LIT(KFldRect2,									"rect2");
       
    42 _LIT(KFldRotation,								"rotation");
       
    43 _LIT(KFldStart,									"start");
       
    44 _LIT(KFldTwips,									"twips");
       
    45 _LIT(KFldTwipsSize,								"twipssize");
       
    46 _LIT(KFldWindowGc,								"windowgc");
       
    47 _LIT(KFldWs,									"ws");
       
    48 _LIT(KFldFont,									"font");
       
    49 _LIT(KFldContext,								"context");
       
    50 
       
    51 ///	Commands
       
    52 _LIT(KCmdnew,									"new");
       
    53 _LIT(KCmddisown,								"disown");
       
    54 _LIT(KCmdDestructor,							"~CWsScreenDevice");
       
    55 _LIT(KCmdDestructorGeneral,						"~");
       
    56 _LIT(KCmdConstruct,								"Construct");
       
    57 _LIT(KCmdCopyScreenToBitmap,					"CopyScreenToBitmap");
       
    58 _LIT(KCmdCreateContext,							"CreateContext");
       
    59 _LIT(KCmdCurrentScreenMode,						"CurrentScreenMode");
       
    60 _LIT(KCmdGetCurrentScreenModeScale,				"GetCurrentScreenModeScale");
       
    61 _LIT(KCmdGetCurrentScreenModeScaledOrigin,		"GetCurrentScreenModeScaledOrigin");
       
    62 _LIT(KCmdGetDefaultScreenModeOrigin,			"GetDefaultScreenModeOrigin");
       
    63 _LIT(KCmdGetDefaultScreenSizeAndRotation,		"GetDefaultScreenSizeAndRotation");
       
    64 _LIT(KCmdGetFontById,							"GetFontById");
       
    65 _LIT(KCmdGetRotationsList,						"GetRotationsList");
       
    66 _LIT(KCmdGetScreenModeDisplayMode,				"GetScreenModeDisplayMode");
       
    67 _LIT(KCmdGetScreenModeOrigin,					"GetScreenModeOrigin");
       
    68 _LIT(KCmdGetScreenModeScale,					"GetScreenModeScale");
       
    69 _LIT(KCmdGetScreenModeScaledOrigin,				"GetScreenModeScaledOrigin");
       
    70 _LIT(KCmdGetScreenModeSizeAndRotation,			"GetScreenModeSizeAndRotation");
       
    71 _LIT(KCmdGetScreenNumber,						"GetScreenNumber");
       
    72 _LIT(KCmdGetScreenSizeModeList,					"GetScreenSizeModeList");
       
    73 _LIT(KCmdNumScreenModes,						"NumScreenModes");
       
    74 _LIT(KCmdRectCompare,							"RectCompare");
       
    75 _LIT(KCmdPointerRect,							"PointerRect");
       
    76 _LIT(KCmdScreenModeEnforcement,					"ScreenModeEnforcement");
       
    77 _LIT(KCmdSetAppScreenMode,						"SetAppScreenMode");
       
    78 _LIT(KCmdSetBackLight,							"SetBackLight");
       
    79 _LIT(KCmdSetCustomPalette,						"SetCustomPalette");
       
    80 _LIT(KCmdSetScreenSizeAndRotation,				"SetScreenSizeAndRotation");
       
    81 
       
    82 _LIT(KCmdcheckPixels,							"checkPixels");
       
    83 _LIT(KCmdcheckLineColor,						"checkLineColor");
       
    84 _LIT(KCmdcheckRectColor,						"checkRectColor");
       
    85 
       
    86 _LIT(KFormatFieldNumber,	"%S%d");
       
    87 
       
    88 ///	Logging
       
    89 _LIT(KLogColor,									"Color Red=%d Green=%d Blue=%d Alpha=%d");
       
    90 _LIT(KLogPoint,									"Point X=%d Y=%d");
       
    91 _LIT(KLogError,									"Error=%d");
       
    92 _LIT(KLogMissingParameter,						"Missing parameter '%S'");
       
    93 _LIT(KLogNotExpectedValue,						"Not expected value");
       
    94 /*@}*/
       
    95 
       
    96 //////////////////////////////////////////////////////////////////////
       
    97 // Construction/Destruction
       
    98 //////////////////////////////////////////////////////////////////////
       
    99 
       
   100 CT_DataWsScreenDevice* CT_DataWsScreenDevice::NewL()
       
   101 /**
       
   102  * Two phase constructor
       
   103  */
       
   104 	{
       
   105 	CT_DataWsScreenDevice*	ret=new (ELeave) CT_DataWsScreenDevice();
       
   106 	CleanupStack::PushL(ret);
       
   107 	ret->ConstructL();
       
   108 	CleanupStack::Pop(ret);
       
   109 	return ret;
       
   110 	}
       
   111 
       
   112 CT_DataWsScreenDevice::CT_DataWsScreenDevice()
       
   113 /**
       
   114  * Protected constructor. First phase construction
       
   115  */
       
   116 :	CT_DataBitmapDevice()
       
   117 ,	iWsScreenDevice(NULL)
       
   118 	{
       
   119 	}
       
   120 
       
   121 void CT_DataWsScreenDevice::ConstructL()
       
   122 /**
       
   123  * Second phase construction
       
   124  */
       
   125 	{
       
   126 	}
       
   127 
       
   128 CT_DataWsScreenDevice::~CT_DataWsScreenDevice()
       
   129 /**
       
   130  * Public destructor
       
   131  */
       
   132 	{
       
   133 	DestroyData();
       
   134 	}
       
   135 
       
   136 TAny* CT_DataWsScreenDevice::GetObject()
       
   137 /**
       
   138  * Return a pointer to the object that the data wraps
       
   139  *
       
   140  * @return	pointer to the object that the data wraps
       
   141  */
       
   142 	{
       
   143 	return iWsScreenDevice;
       
   144 	}
       
   145 
       
   146 void CT_DataWsScreenDevice::SetObjectL(TAny* aAny)
       
   147 /**
       
   148  * Set the object that the data wraps
       
   149  *
       
   150  * @param	aObject object that the wrapper is testing
       
   151  *
       
   152  */
       
   153 	{
       
   154 	DestroyData();
       
   155 	iWsScreenDevice = static_cast<CWsScreenDevice*> (aAny);
       
   156 	}
       
   157 
       
   158 void CT_DataWsScreenDevice::DisownObjectL()
       
   159 /**
       
   160  * The object will no longer be owned by this
       
   161  *
       
   162  * @leave	KErrNotSupported if the the function is not supported
       
   163  */
       
   164 	{
       
   165 	iWsScreenDevice = NULL;
       
   166 	}
       
   167 
       
   168 void CT_DataWsScreenDevice::DestroyData()
       
   169 	{
       
   170 	delete iWsScreenDevice;
       
   171 	iWsScreenDevice=NULL;
       
   172 	}
       
   173 
       
   174 MWsClientClass* CT_DataWsScreenDevice::GetClientClass() const
       
   175 	{
       
   176 	return iWsScreenDevice;
       
   177 	}
       
   178 
       
   179 MGraphicsDeviceMap*	CT_DataWsScreenDevice::GetGraphicsDeviceMap() const
       
   180 	{
       
   181 	return iWsScreenDevice;
       
   182 	}
       
   183 
       
   184 CGraphicsDevice*	CT_DataWsScreenDevice::GetGraphicsDevice() const
       
   185 	{
       
   186 	return iWsScreenDevice;
       
   187 	}
       
   188 
       
   189 CBitmapDevice*	CT_DataWsScreenDevice::GetBitmapDevice() const
       
   190 	{
       
   191 	return iWsScreenDevice;
       
   192 	}
       
   193 
       
   194 
       
   195 /**
       
   196 * Process a command read from the ini file
       
   197 *
       
   198 * @param aCommand			the command to process
       
   199 * @param aSection			the entry in the ini file requiring the command to be processed
       
   200 * @param aAsyncErrorIndex	index of command. used for async calls
       
   201 *
       
   202 * @return ETrue if the command is processed
       
   203 */
       
   204 TBool CT_DataWsScreenDevice::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex)
       
   205 	{
       
   206 	TBool	ret = ETrue;
       
   207 
       
   208 	if ( aCommand==KCmdDestructor || aCommand==KCmdDestructorGeneral )
       
   209 		{
       
   210 		DoCmdDestructor();
       
   211 		}
       
   212 	else if ( aCommand==KCmdnew || aCommand==KDataClassname )
       
   213 		{
       
   214 		DoCmdnewL(aSection);
       
   215 		}
       
   216 	else if ( aCommand==KCmddisown )
       
   217 		{
       
   218 		DisownObjectL();
       
   219 		}	
       
   220 	else if ( aCommand==KCmdConstruct )
       
   221 		{
       
   222 		DoCmdConstruct(aSection);
       
   223 		}
       
   224 	else if ( aCommand==KCmdCopyScreenToBitmap )
       
   225 		{
       
   226 		DoCmdCopyScreenToBitmapL(aSection);
       
   227 		}
       
   228 	else if ( aCommand==KCmdCreateContext )
       
   229 		{
       
   230 		DoCmdCreateContextL(aSection);
       
   231 		}
       
   232 	else if ( aCommand==KCmdCurrentScreenMode )
       
   233 		{
       
   234 		DoCmdCurrentScreenMode(aSection);
       
   235 		}
       
   236 	else if ( aCommand==KCmdGetCurrentScreenModeScale )
       
   237 		{
       
   238 		DoCmdGetCurrentScreenModeScale(aSection);
       
   239 		}
       
   240 	else if ( aCommand==KCmdGetCurrentScreenModeScaledOrigin )
       
   241 		{
       
   242 		DoCmdGetCurrentScreenModeScaledOrigin(aSection);
       
   243 		}
       
   244 	else if ( aCommand==KCmdGetDefaultScreenModeOrigin )
       
   245 		{
       
   246 		DoCmdGetDefaultScreenModeOrigin(aSection);
       
   247 		}
       
   248 	else if ( aCommand==KCmdGetDefaultScreenSizeAndRotation )
       
   249 		{
       
   250 		DoCmdGetDefaultScreenSizeAndRotation(aSection);
       
   251 		}
       
   252 	else if ( aCommand==KCmdGetFontById )
       
   253 		{
       
   254 		DoCmdGetFontByIdL(aSection);
       
   255 		}
       
   256 	else if ( aCommand==KCmdGetRotationsList )
       
   257 		{
       
   258 			DoCmdGetRotationsListL(aSection);
       
   259 		}
       
   260 	else if ( aCommand==KCmdGetScreenModeDisplayMode )
       
   261 		{
       
   262 		DoCmdGetScreenModeDisplayMode(aSection);
       
   263 		}
       
   264 	else if ( aCommand==KCmdGetScreenModeOrigin )
       
   265 		{
       
   266 		DoCmdGetScreenModeOrigin(aSection);
       
   267 		}
       
   268 	else if ( aCommand==KCmdGetScreenModeScale )
       
   269 		{
       
   270 		DoCmdGetScreenModeScale(aSection);
       
   271 		}
       
   272 	else if ( aCommand==KCmdGetScreenModeScaledOrigin )
       
   273 		{
       
   274 		DoCmdGetScreenModeScaledOrigin(aSection);
       
   275 		}
       
   276 	else if ( aCommand==KCmdGetScreenModeSizeAndRotation )
       
   277 		{
       
   278 		DoCmdGetScreenModeSizeAndRotation(aSection);
       
   279 		}
       
   280 	else if ( aCommand==KCmdGetScreenNumber )
       
   281 		{
       
   282 		DoCmdGetScreenNumber(aSection);
       
   283 		}
       
   284 	else if ( aCommand==KCmdGetScreenSizeModeList )
       
   285 		{
       
   286 		DoCmdGetScreenSizeModeListL(aSection);
       
   287 		}
       
   288 	else if ( aCommand==KCmdNumScreenModes )
       
   289 		{
       
   290 		DoCmdNumScreenModes(aSection);
       
   291 		}
       
   292 	else if ( aCommand==KCmdPointerRect )
       
   293 		{
       
   294 		DoCmdPointerRect(aSection);
       
   295 		}
       
   296 	else if ( aCommand==KCmdRectCompare )
       
   297 		{
       
   298 		DoCmdRectCompare(aSection);
       
   299 		}
       
   300 	else if ( aCommand==KCmdScreenModeEnforcement )
       
   301 		{
       
   302 		DoCmdScreenModeEnforcement(aSection);
       
   303 		}
       
   304 	else if ( aCommand==KCmdSetAppScreenMode )
       
   305 		{
       
   306 		DoCmdSetAppScreenMode(aSection);
       
   307 		}
       
   308 	else if ( aCommand==KCmdSetBackLight )
       
   309 		{
       
   310 		DoCmdSetBackLight(aSection);
       
   311 		}
       
   312 	else if ( aCommand==KCmdSetCustomPalette )
       
   313 		{
       
   314 		DoCmdSetCustomPaletteL(aSection);
       
   315 		}
       
   316 	else if ( aCommand==KCmdSetScreenSizeAndRotation )
       
   317 		{
       
   318 		DoCmdSetScreenSizeAndRotation(aSection);
       
   319 		}
       
   320 	else if ( aCommand==KCmdcheckPixels )
       
   321 		{
       
   322 		DoCmdcheckPixels(aSection);
       
   323 		}
       
   324 	else if ( aCommand==KCmdcheckLineColor )
       
   325 		{
       
   326 		DoCmdcheckLineColor(aSection);
       
   327 		}
       
   328 	else if ( aCommand==KCmdcheckRectColor )
       
   329 		{
       
   330 		DoCmdcheckRectColor(aSection);
       
   331 		}
       
   332 	else if ( CT_DataBitmapDevice::DoCommandL(aCommand, aSection, aAsyncErrorIndex) )
       
   333 		{
       
   334 		}
       
   335 	else
       
   336 		{
       
   337 		ret=CT_DataWsClientClass::DoCommandL(*this, aCommand, aSection, aAsyncErrorIndex);
       
   338 		}
       
   339 
       
   340 	return ret;
       
   341 	}
       
   342 
       
   343 /**
       
   344 Test Constructor
       
   345 */
       
   346 void CT_DataWsScreenDevice::DoCmdnewL(const TDesC& aSection)
       
   347 	{
       
   348 	DestroyData();
       
   349 
       
   350 	// Get test data for command input parameter(s)
       
   351 	RWsSession*	ws=NULL;
       
   352 	TPtrC		wsName;
       
   353 	if ( GetStringFromConfig(aSection, KFldWs, wsName) )
       
   354 		{
       
   355 		ws = static_cast<RWsSession*>(GetDataObjectL(wsName));
       
   356 		}
       
   357 
       
   358 	TInt	err;
       
   359 	if ( ws!= NULL )
       
   360 		{
       
   361 		// Execute command and log parameters
       
   362 		INFO_PRINTF1(_L("execute new CWsScreenDevice(RWsSession)"));
       
   363 		TRAP( err, iWsScreenDevice = new (ELeave) CWsScreenDevice(*ws) );
       
   364 		}
       
   365 	else
       
   366 		{
       
   367 		// Execute command and log parameters
       
   368 		INFO_PRINTF1(_L("execute new CWsScreenDevice()"));
       
   369 		TRAP(err, iWsScreenDevice = new (ELeave) CWsScreenDevice());
       
   370 		}
       
   371 
       
   372 	if ( err!=KErrNone )
       
   373 		{
       
   374 		ERR_PRINTF2(KLogError, err);
       
   375 		SetError(err);
       
   376 		}
       
   377 	}
       
   378 
       
   379 /**
       
   380 Test Destructor
       
   381 */
       
   382 void CT_DataWsScreenDevice::DoCmdDestructor()
       
   383 	{
       
   384 	INFO_PRINTF1(_L("execute ~CWsScreenDevice()"));
       
   385 	DestroyData();
       
   386 	}
       
   387 
       
   388 /**
       
   389 Test Construct()
       
   390 */
       
   391 void CT_DataWsScreenDevice::DoCmdConstruct(const TDesC& aSection)
       
   392 	{
       
   393 	// Get test data for command input parameter(s)
       
   394 	TInt	err=KErrNone;
       
   395 
       
   396 	TInt	datDefaultScreenNumber;
       
   397 	if ( GetIntFromConfig(aSection, KFldDefaultScreenNumber, datDefaultScreenNumber) )
       
   398 		{
       
   399 		// Execute command and log parameters
       
   400 		INFO_PRINTF1(_L("execute Construct(TInt)"));
       
   401 		err=iWsScreenDevice->Construct(datDefaultScreenNumber);
       
   402 		}
       
   403 	else
       
   404 		{
       
   405 		// Execute command and log parameters
       
   406 		INFO_PRINTF1(_L("execute Construct()"));
       
   407 		err=iWsScreenDevice->Construct();
       
   408 		}
       
   409 
       
   410 	// Check the command return code.
       
   411 	if ( err!=KErrNone )
       
   412 		{
       
   413 		ERR_PRINTF2(KLogError, err);
       
   414 		SetError(err);
       
   415 		}
       
   416 	}
       
   417 
       
   418 /**
       
   419 Test CopyScreenToBitmap()
       
   420 */
       
   421 void CT_DataWsScreenDevice::DoCmdCopyScreenToBitmapL(const TDesC& aSection)
       
   422 	{
       
   423 	// Get test data for command input parameter(s)
       
   424 	CFbsBitmap*	bitmap=NULL;
       
   425 	TBool	hasBitmap=CT_GraphicsUtil::GetFbsBitmapL(*this, aSection, KFldBitmap, bitmap);
       
   426 	if ( !hasBitmap )
       
   427 		{
       
   428 		ERR_PRINTF2(KLogMissingParameter, &KFldBitmap);
       
   429 		SetBlockResult(EFail);
       
   430 		}
       
   431 	else
       
   432 		{
       
   433 		// Execute command and log parameters
       
   434 		TInt	err=KErrNone;
       
   435 
       
   436 		TRect	datRect;
       
   437 		if ( GetRectFromConfig(aSection, KFldRect, datRect) )
       
   438 			{
       
   439 			INFO_PRINTF1(_L("execute CopyScreenToBitmap(CFbsBitmap, TRect)"));
       
   440 			err=iWsScreenDevice->CopyScreenToBitmap(bitmap, datRect);
       
   441 			}
       
   442 		else
       
   443 			{
       
   444 			INFO_PRINTF1(_L("execute CopyScreenToBitmap(CFbsBitmap)"));
       
   445 			err=iWsScreenDevice->CopyScreenToBitmap(bitmap);
       
   446 			}
       
   447 
       
   448 		// Check the command return code.
       
   449 		if ( err!=KErrNone )
       
   450 			{
       
   451 			ERR_PRINTF2(KLogError, err);
       
   452 			SetError(err);
       
   453 			}
       
   454 		}
       
   455 	}
       
   456 
       
   457 /**
       
   458 Test CreateContext()
       
   459 */
       
   460 void CT_DataWsScreenDevice::DoCmdCreateContextL(const TDesC& aSection)
       
   461 	{
       
   462 	// Get test data for command input parameter(s)
       
   463 	TPtrC	datWindowGc;
       
   464 	if ( !GetStringFromConfig(aSection, KFldWindowGc, datWindowGc) )
       
   465 		{
       
   466 		//CT_DataBitmapDevice::DoCommandL(aCommand, aSection, aAsyncErrorIndex);
       
   467 		
       
   468 		// get BitmapUtilData object from parameters
       
   469 		if ( !GetStringFromConfig(aSection, KFldContext, datWindowGc) )
       
   470 			{
       
   471 			ERR_PRINTF2(KLogMissingParameter, &KFldContext());
       
   472 			SetBlockResult(EFail);
       
   473 			}
       
   474 		else
       
   475 			{
       
   476 			CGraphicsContext*	context=NULL;
       
   477 			INFO_PRINTF1(_L("execute CreateContext(CGraphicsContext*&)"));
       
   478 			TInt	returnCode=GetGraphicsDevice()->CreateContext(context);
       
   479 			// Check the command return code.
       
   480 			if ( returnCode!=KErrNone )
       
   481 				{
       
   482 				ERR_PRINTF2(KLogError, returnCode);
       
   483 				SetError(returnCode);
       
   484 				}
       
   485 			else
       
   486 				{
       
   487 				SetDataObjectL(datWindowGc, context);
       
   488 				}
       
   489 			}
       
   490 		}
       
   491 	else
       
   492 		{
       
   493 		// Execute command and log parameters
       
   494 		CWindowGc*	windowGc;
       
   495 
       
   496 		INFO_PRINTF1(_L("execute CreateContext(CWindowGc)"));
       
   497 		TInt	returnCode = iWsScreenDevice->CreateContext(windowGc);
       
   498 
       
   499 		// Check the command return code.
       
   500 		if ( returnCode!=KErrNone )
       
   501 			{
       
   502 			ERR_PRINTF2(KLogError, returnCode);
       
   503 			SetError(returnCode);
       
   504 			}
       
   505 		else
       
   506 			{
       
   507 			SetDataObjectL(datWindowGc, windowGc);
       
   508 			}
       
   509 		}
       
   510 	}
       
   511 
       
   512 /**
       
   513 Test CurrentScreenMode()
       
   514 */
       
   515 void CT_DataWsScreenDevice::DoCmdCurrentScreenMode(const TDesC& aSection)
       
   516 	{
       
   517 	TInt	actual=iWsScreenDevice->CurrentScreenMode();
       
   518 	INFO_PRINTF2(_L("CurrentScreenMode()=%d"), actual);
       
   519 
       
   520 	TInt	expected;
       
   521 	if ( !GetIntFromConfig(aSection, KFldExpected, expected) )
       
   522 		{
       
   523 		ERR_PRINTF2(KLogMissingParameter, &KFldExpected);
       
   524 		SetBlockResult(EFail);
       
   525 		}
       
   526 	else
       
   527 		{
       
   528 		if ( actual!=expected )
       
   529 			{
       
   530 			ERR_PRINTF1(KLogNotExpectedValue);
       
   531 			SetBlockResult(EFail);
       
   532 			}
       
   533 		}
       
   534 	}
       
   535 
       
   536 /**
       
   537 Test GetCurrentScreenModeScale()
       
   538 */
       
   539 void CT_DataWsScreenDevice::DoCmdGetCurrentScreenModeScale(const TDesC& aSection)
       
   540 	{
       
   541 	TSize	actual=iWsScreenDevice->GetCurrentScreenModeScale();
       
   542 	INFO_PRINTF3(_L("GetCurrentScreenModeScale(TInt) height=%d width=%d"), actual.iHeight, actual.iWidth);
       
   543 
       
   544 	TSize	expected;
       
   545 	if ( !GetSizeFromConfig(aSection, KFldExpected, expected) )
       
   546 		{
       
   547 		ERR_PRINTF2(KLogMissingParameter, &KFldExpected);
       
   548 		SetBlockResult(EFail);
       
   549 		}
       
   550 	else
       
   551 		{
       
   552 		if ( actual!=expected )
       
   553 			{
       
   554 			ERR_PRINTF1(KLogNotExpectedValue);
       
   555 			SetBlockResult(EFail);
       
   556 			}
       
   557 		}
       
   558 	}
       
   559 
       
   560 /**
       
   561 Test GetCurrentScreenModeScaledOrigin()
       
   562 */
       
   563 void CT_DataWsScreenDevice::DoCmdGetCurrentScreenModeScaledOrigin(const TDesC& aSection)
       
   564 	{
       
   565 	TPoint	actual=iWsScreenDevice->GetCurrentScreenModeScaledOrigin();
       
   566 	INFO_PRINTF3(_L("GetCurrentScreenModeScaledOrigin() x=%d y=%d"), actual.iX, actual.iY);
       
   567 
       
   568 	TPoint	expected;
       
   569 	if ( !GetPointFromConfig(aSection, KFldExpected, expected) )
       
   570 		{
       
   571 		ERR_PRINTF2(KLogMissingParameter, &KFldExpected);
       
   572 		SetBlockResult(EFail);
       
   573 		}
       
   574 	else
       
   575 		{
       
   576 		if ( actual!=expected )
       
   577 			{
       
   578 			ERR_PRINTF1(KLogNotExpectedValue);
       
   579 			SetBlockResult(EFail);
       
   580 			}
       
   581 		}
       
   582 	}
       
   583 
       
   584 /**
       
   585 Test GetDefaultScreenModeOrigin()
       
   586 */
       
   587 void CT_DataWsScreenDevice::DoCmdGetDefaultScreenModeOrigin(const TDesC& aSection)
       
   588 	{
       
   589 	TPoint	actual=iWsScreenDevice->GetDefaultScreenModeOrigin();
       
   590 	INFO_PRINTF3(_L("GetDefaultScreenModeOrigin() x=%d y=%d"), actual.iX, actual.iY);
       
   591 
       
   592 	TPoint	expected;
       
   593 	if ( !GetPointFromConfig(aSection, KFldExpected, expected) )
       
   594 		{
       
   595 		ERR_PRINTF2(KLogMissingParameter, &KFldExpected);
       
   596 		SetBlockResult(EFail);
       
   597 		}
       
   598 	else
       
   599 		{
       
   600 		if ( actual!=expected )
       
   601 			{
       
   602 			ERR_PRINTF1(KLogNotExpectedValue);
       
   603 			SetBlockResult(EFail);
       
   604 			}
       
   605 		}
       
   606 	}
       
   607 
       
   608 /**
       
   609 Test GetDefaultScreenSizeAndRotation()
       
   610 */
       
   611 void CT_DataWsScreenDevice::DoCmdGetDefaultScreenSizeAndRotation(const TDesC& aSection)
       
   612 	{
       
   613 	CFbsBitGc::TGraphicsOrientation	rotation;
       
   614 	TBool							checkRotation=CT_GraphicsUtil::ReadGraphicsOrientation(*this, aSection, KFldRotation, rotation);
       
   615 
       
   616 	TSize	pixelSize;
       
   617 	TBool	checkPixelSize=GetSizeFromConfig(aSection, KFldPixelSize, pixelSize);
       
   618 
       
   619 	TBool	twips=EFalse;
       
   620 	GetBoolFromConfig(aSection, KFldTwips, twips);
       
   621 	if ( twips )
       
   622 		{
       
   623 		TPixelsTwipsAndRotation	param;
       
   624 		iWsScreenDevice->GetDefaultScreenSizeAndRotation(param);
       
   625 		INFO_PRINTF2(_L("GetDefaultScreenSizeAndRotation(TPixelsTwipsAndRotation) Rotation=%d"), param.iRotation);
       
   626 		INFO_PRINTF3(_L("Pixel height=%d width=%d"), param.iPixelSize.iHeight, param.iPixelSize.iWidth);
       
   627 		INFO_PRINTF3(_L("Twips height=%d width=%d"), param.iTwipsSize.iHeight, param.iTwipsSize.iWidth);
       
   628 
       
   629 		if ( checkRotation )
       
   630 			{
       
   631 			if ( rotation!=param.iRotation )
       
   632 				{
       
   633 				ERR_PRINTF1(KLogNotExpectedValue);
       
   634 				SetBlockResult(EFail);
       
   635 				}
       
   636 			}
       
   637 
       
   638 		if ( checkPixelSize )
       
   639 			{
       
   640 			if ( pixelSize!=param.iPixelSize )
       
   641 				{
       
   642 				ERR_PRINTF1(KLogNotExpectedValue);
       
   643 				SetBlockResult(EFail);
       
   644 				}
       
   645 			}
       
   646 
       
   647 		TSize	twipsSize;
       
   648 		if ( GetSizeFromConfig(aSection, KFldTwipsSize, twipsSize) )
       
   649 			{
       
   650 			if ( twipsSize!=param.iTwipsSize )
       
   651 				{
       
   652 				ERR_PRINTF1(KLogNotExpectedValue);
       
   653 				SetBlockResult(EFail);
       
   654 				}
       
   655 			}
       
   656 		}
       
   657 	else
       
   658 		{
       
   659 		TPixelsAndRotation	param;
       
   660 		iWsScreenDevice->GetDefaultScreenSizeAndRotation(param);
       
   661 		INFO_PRINTF2(_L("GetDefaultScreenSizeAndRotation(TPixelsAndRotation) Rotation=%d"), param.iRotation);
       
   662 		INFO_PRINTF3(_L("Pixel height=%d width=%d"), param.iPixelSize.iHeight, param.iPixelSize.iWidth);
       
   663 
       
   664 		if ( checkRotation )
       
   665 			{
       
   666 			if ( rotation!=param.iRotation )
       
   667 				{
       
   668 				ERR_PRINTF1(KLogNotExpectedValue);
       
   669 				SetBlockResult(EFail);
       
   670 				}
       
   671 			}
       
   672 
       
   673 		if ( checkPixelSize )
       
   674 			{
       
   675 			if ( pixelSize!=param.iPixelSize )
       
   676 				{
       
   677 				ERR_PRINTF1(KLogNotExpectedValue);
       
   678 				SetBlockResult(EFail);
       
   679 				}
       
   680 			}
       
   681 		}
       
   682 	}
       
   683 
       
   684 /**
       
   685 Test GetFontById()
       
   686 */
       
   687 void CT_DataWsScreenDevice::DoCmdGetFontByIdL(const TDesC& aSection)
       
   688 	{
       
   689 	INFO_PRINTF1(_L("Call GetFontById()"));
       
   690 	TBool	dataOk=ETrue;
       
   691 
       
   692 	// get font uid from parameters
       
   693 	TInt	fontUid;
       
   694 	if(!GetIntFromConfig(aSection, KFldFontUid(), fontUid))
       
   695 		{
       
   696 		dataOk=EFalse;
       
   697 		ERR_PRINTF2(_L("No %S"), &KFldFontUid());
       
   698 		SetBlockResult(EFail);
       
   699 		}
       
   700 	// get TAlgStyle from parameters
       
   701 	TAlgStyle*	algStyle=NULL;
       
   702 	CT_GraphicsUtil::GetAlgStyleL(*this, aSection, KFldAlgStyle(), algStyle);
       
   703 	if ( algStyle==NULL )
       
   704 		{
       
   705 		dataOk=EFalse;
       
   706 		ERR_PRINTF2(_L("No %S"), &KFldAlgStyle());
       
   707 		SetBlockResult(EFail);
       
   708 		}
       
   709 	// get font wrapper name
       
   710 	TPtrC datFbsFont;
       
   711 	if( !GetStringFromConfig(aSection, KFldFont, datFbsFont) )
       
   712 		{
       
   713 		ERR_PRINTF2(KLogMissingParameter, &KFldFont());
       
   714 		SetBlockResult(EFail);
       
   715 		}
       
   716 	// call GetFontById()
       
   717 	else
       
   718 		{
       
   719 		if ( dataOk )
       
   720 			{
       
   721 			CFont* fbsFont=NULL;
       
   722 			INFO_PRINTF1(_L("execute GetFontById(CFont *&aFont, TUid aUid, const TAlgStyle &aAlgStyle)"));
       
   723 			TInt err = iWsScreenDevice->GetFontById(fbsFont, TUid::Uid(fontUid), *algStyle);
       
   724 			
       
   725 			if ( err!=KErrNone )
       
   726 				{
       
   727 				ERR_PRINTF2(KLogError, err);
       
   728 				SetError(err);
       
   729 				}
       
   730 			else
       
   731 				{
       
   732 				SetDataObjectL(datFbsFont, fbsFont);
       
   733 				}
       
   734 			}
       
   735 		}
       
   736 	}
       
   737 
       
   738 /**
       
   739 Test GetRotationsList()
       
   740 */
       
   741 void CT_DataWsScreenDevice::DoCmdGetRotationsListL(const TDesC& aSection)
       
   742 	{
       
   743 	CArrayFixFlat<TInt>*	rotations=new(ELeave) CArrayFixFlat<TInt>(1);
       
   744 	CleanupStack::PushL(rotations);
       
   745 
       
   746 	TInt	mode=0;
       
   747 	if ( !GetIntFromConfig(aSection, KFldMode, mode) )
       
   748 		{
       
   749 		ERR_PRINTF2(KLogMissingParameter, &KFldMode);
       
   750 		SetBlockResult(EFail);
       
   751 		}
       
   752 	else
       
   753 		{
       
   754 		TInt	err=iWsScreenDevice->GetRotationsList(mode, rotations);
       
   755 		if ( err!=KErrNone )
       
   756 			{
       
   757 			ERR_PRINTF2(KLogError, err);
       
   758 			SetError(err);
       
   759 			}
       
   760 		else
       
   761 			{
       
   762 			INFO_PRINTF2(_L("GetRotationsList count=%d"), rotations->Count());
       
   763 			TInt	expectedCount;
       
   764 			if ( GetIntFromConfig(aSection, KFldExpectedCount, expectedCount) )
       
   765 				{
       
   766 				if ( expectedCount!=rotations->Count() )
       
   767 					{
       
   768 					ERR_PRINTF1(KLogNotExpectedValue);
       
   769 					SetBlockResult(EFail);
       
   770 					}
       
   771 				else
       
   772 					{
       
   773 					INFO_PRINTF1(_L("Check elements in the rotations list"));
       
   774 					TBuf<KMaxTestExecuteCommandLength>	tempStore;
       
   775 
       
   776 					TBool	ok=ETrue;
       
   777 					for ( TInt index = 0; (index < expectedCount) && (ok); )
       
   778 						{
       
   779 						tempStore.Format(KFormatFieldNumber, &KFldRotation, ++index);
       
   780 						
       
   781 						CFbsBitGc::TGraphicsOrientation	rotation;
       
   782 						ok = CT_GraphicsUtil::ReadGraphicsOrientation(*this, aSection, tempStore, rotation);
       
   783 						if ( !ok )
       
   784 							{
       
   785 							ERR_PRINTF2(KLogMissingParameter, &tempStore);
       
   786 							SetBlockResult(EFail);
       
   787 							}
       
   788 						else
       
   789 							{
       
   790 							if( rotation != (*rotations)[index-1])
       
   791 								{
       
   792 								ERR_PRINTF1(KLogNotExpectedValue);
       
   793 								SetBlockResult(EFail);
       
   794 								ok = EFalse;
       
   795 								}
       
   796 							}
       
   797 						}
       
   798 					}
       
   799 				}
       
   800 			}
       
   801 		}
       
   802 
       
   803 	CleanupStack::PopAndDestroy();
       
   804 	}
       
   805 
       
   806 /**
       
   807 Test GetScreenModeDisplayMode()
       
   808 */
       
   809 void CT_DataWsScreenDevice::DoCmdGetScreenModeDisplayMode(const TDesC& aSection)
       
   810 	{
       
   811 	TInt	mode=0;
       
   812 	if ( !GetIntFromConfig(aSection, KFldMode, mode) )
       
   813 		{
       
   814 		ERR_PRINTF2(KLogMissingParameter, &KFldMode);
       
   815 		SetBlockResult(EFail);
       
   816 		}
       
   817 	else
       
   818 		{
       
   819 		TDisplayMode	actual=iWsScreenDevice->GetScreenModeDisplayMode(mode);
       
   820 		INFO_PRINTF2(_L("GetScreenModeDisplayMode(TInt)=%d"), actual);
       
   821 
       
   822 		TDisplayMode	expected;
       
   823 		if ( !CT_GraphicsUtil::ReadDisplayMode(*this, aSection, KFldExpected, expected) )
       
   824 			{
       
   825 			ERR_PRINTF2(KLogMissingParameter, &KFldExpected);
       
   826 			SetBlockResult(EFail);
       
   827 			}
       
   828 		else
       
   829 			{
       
   830 			if ( actual!=expected )
       
   831 				{
       
   832 				ERR_PRINTF1(KLogNotExpectedValue);
       
   833 				SetBlockResult(EFail);
       
   834 				}
       
   835 			}
       
   836 		}
       
   837 	}
       
   838 
       
   839 /**
       
   840 Test GetScreenModeOrigin()
       
   841 */
       
   842 void CT_DataWsScreenDevice::DoCmdGetScreenModeOrigin(const TDesC& aSection)
       
   843 	{
       
   844 	TInt	mode=0;
       
   845 	if ( !GetIntFromConfig(aSection, KFldMode, mode) )
       
   846 		{
       
   847 		ERR_PRINTF2(KLogMissingParameter, &KFldMode);
       
   848 		SetBlockResult(EFail);
       
   849 		}
       
   850 	else
       
   851 		{
       
   852 		TPoint	actual=iWsScreenDevice->GetScreenModeOrigin(mode);
       
   853 		INFO_PRINTF3(_L("GetScreenModeOrigin(TInt) x=%d y=%d"), actual.iX, actual.iY);
       
   854 
       
   855 		TPoint	expected;
       
   856 		if ( !GetPointFromConfig(aSection, KFldExpected, expected) )
       
   857 			{
       
   858 			ERR_PRINTF2(KLogMissingParameter, &KFldExpected);
       
   859 			SetBlockResult(EFail);
       
   860 			}
       
   861 		else
       
   862 			{
       
   863 			if ( actual!=expected )
       
   864 				{
       
   865 				ERR_PRINTF1(KLogNotExpectedValue);
       
   866 				SetBlockResult(EFail);
       
   867 				}
       
   868 			}
       
   869 		}
       
   870 	}
       
   871 
       
   872 /**
       
   873 Test GetScreenModeScale()
       
   874 */
       
   875 void CT_DataWsScreenDevice::DoCmdGetScreenModeScale(const TDesC& aSection)
       
   876 	{
       
   877 	TInt	mode=0;
       
   878 	if ( !GetIntFromConfig(aSection, KFldMode, mode) )
       
   879 		{
       
   880 		ERR_PRINTF2(KLogMissingParameter, &KFldMode);
       
   881 		SetBlockResult(EFail);
       
   882 		}
       
   883 	else
       
   884 		{
       
   885 		TSize	actual=iWsScreenDevice->GetScreenModeScale(mode);
       
   886 		INFO_PRINTF3(_L("GetScreenModeScale(TInt) height=%d width=%d"), actual.iHeight, actual.iWidth);
       
   887 
       
   888 		TSize	expected;
       
   889 		if ( !GetSizeFromConfig(aSection, KFldExpected, expected) )
       
   890 			{
       
   891 			ERR_PRINTF2(KLogMissingParameter, &KFldExpected);
       
   892 			SetBlockResult(EFail);
       
   893 			}
       
   894 		else
       
   895 			{
       
   896 			if ( actual!=expected )
       
   897 				{
       
   898 				ERR_PRINTF1(KLogNotExpectedValue);
       
   899 				SetBlockResult(EFail);
       
   900 				}
       
   901 			}
       
   902 		}
       
   903 	}
       
   904 
       
   905 /**
       
   906 Test GetScreenModeScaledOrigin()
       
   907 */
       
   908 void CT_DataWsScreenDevice::DoCmdGetScreenModeScaledOrigin(const TDesC& aSection)
       
   909 	{
       
   910 	TInt	mode=0;
       
   911 	if ( !GetIntFromConfig(aSection, KFldMode, mode) )
       
   912 		{
       
   913 		ERR_PRINTF2(KLogMissingParameter, &KFldMode);
       
   914 		SetBlockResult(EFail);
       
   915 		}
       
   916 	else
       
   917 		{
       
   918 		TPoint	actual=iWsScreenDevice->GetScreenModeScaledOrigin(mode);
       
   919 		INFO_PRINTF3(_L("GetScreenModeScaledOrigin(TInt) x=%d y=%d"), actual.iX, actual.iY);
       
   920 
       
   921 		TPoint	expected;
       
   922 		if ( !GetPointFromConfig(aSection, KFldExpected, expected) )
       
   923 			{
       
   924 			ERR_PRINTF2(KLogMissingParameter, &KFldExpected);
       
   925 			SetBlockResult(EFail);
       
   926 			}
       
   927 		else
       
   928 			{
       
   929 			if ( actual!=expected )
       
   930 				{
       
   931 				ERR_PRINTF1(KLogNotExpectedValue);
       
   932 				SetBlockResult(EFail);
       
   933 				}
       
   934 			}
       
   935 		}
       
   936 	}
       
   937 
       
   938 /**
       
   939 Test GetScreenModeSizeAndRotation()
       
   940 */
       
   941 void CT_DataWsScreenDevice::DoCmdGetScreenModeSizeAndRotation(const TDesC& aSection)
       
   942 	{
       
   943 	TInt	mode=0;
       
   944 	if ( !GetIntFromConfig(aSection, KFldMode, mode) )
       
   945 		{
       
   946 		ERR_PRINTF2(KLogMissingParameter, &KFldMode);
       
   947 		SetBlockResult(EFail);
       
   948 		}
       
   949 
       
   950 	CFbsBitGc::TGraphicsOrientation	rotation;
       
   951 	TBool							checkRotation=CT_GraphicsUtil::ReadGraphicsOrientation(*this, aSection, KFldRotation, rotation);
       
   952 
       
   953 	TSize	pixelSize;
       
   954 	TBool	checkPixelSize=GetSizeFromConfig(aSection, KFldPixelSize, pixelSize);
       
   955 
       
   956 	TBool	twips=EFalse;
       
   957 	GetBoolFromConfig(aSection, KFldTwips, twips);
       
   958 	if ( twips )
       
   959 		{
       
   960 		TPixelsTwipsAndRotation	param;
       
   961 		iWsScreenDevice->GetScreenModeSizeAndRotation(mode, param);
       
   962 		INFO_PRINTF2(_L("GetScreenModeSizeAndRotation(TInt, TPixelsTwipsAndRotation) Rotation=%d"), param.iRotation);
       
   963 		INFO_PRINTF3(_L("Pixel height=%d width=%d"), param.iPixelSize.iHeight, param.iPixelSize.iWidth);
       
   964 		INFO_PRINTF3(_L("Twips height=%d width=%d"), param.iTwipsSize.iHeight, param.iTwipsSize.iWidth);
       
   965 
       
   966 		if ( checkRotation )
       
   967 			{
       
   968 			if ( rotation!=param.iRotation )
       
   969 				{
       
   970 				ERR_PRINTF1(KLogNotExpectedValue);
       
   971 				SetBlockResult(EFail);
       
   972 				}
       
   973 			}
       
   974 
       
   975 		if ( checkPixelSize )
       
   976 			{
       
   977 			if ( pixelSize!=param.iPixelSize )
       
   978 				{
       
   979 				ERR_PRINTF1(KLogNotExpectedValue);
       
   980 				SetBlockResult(EFail);
       
   981 				}
       
   982 			}
       
   983 
       
   984 		TSize	twipsSize;
       
   985 		if ( GetSizeFromConfig(aSection, KFldTwipsSize, twipsSize) )
       
   986 			{
       
   987 			if ( twipsSize!=param.iTwipsSize )
       
   988 				{
       
   989 				ERR_PRINTF1(KLogNotExpectedValue);
       
   990 				SetBlockResult(EFail);
       
   991 				}
       
   992 			}
       
   993 		}
       
   994 	else
       
   995 		{
       
   996 		TPixelsAndRotation	param;
       
   997 		iWsScreenDevice->GetScreenModeSizeAndRotation(mode, param);
       
   998 		INFO_PRINTF2(_L("GetScreenModeSizeAndRotation(TInt, TPixelsAndRotation) Rotation=%d"), param.iRotation);
       
   999 		INFO_PRINTF3(_L("Pixel height=%d width=%d"), param.iPixelSize.iHeight, param.iPixelSize.iWidth);
       
  1000 
       
  1001 		if ( checkRotation )
       
  1002 			{
       
  1003 			if ( rotation!=param.iRotation )
       
  1004 				{
       
  1005 				ERR_PRINTF1(KLogNotExpectedValue);
       
  1006 				SetBlockResult(EFail);
       
  1007 				}
       
  1008 			}
       
  1009 
       
  1010 		if ( checkPixelSize )
       
  1011 			{
       
  1012 			if ( pixelSize!=param.iPixelSize )
       
  1013 				{
       
  1014 				ERR_PRINTF1(KLogNotExpectedValue);
       
  1015 				SetBlockResult(EFail);
       
  1016 				}
       
  1017 			}
       
  1018 		}
       
  1019 	}
       
  1020 
       
  1021 /**
       
  1022 Test GetScreenNumber()
       
  1023 */
       
  1024 void CT_DataWsScreenDevice::DoCmdGetScreenNumber(const TDesC& aSection)
       
  1025 	{
       
  1026 	// Execute command and log parameters
       
  1027 	TInt	actual=iWsScreenDevice->GetScreenNumber();
       
  1028 	INFO_PRINTF2(_L("execute GetScreenNumber()=%d"), actual);
       
  1029 
       
  1030 	// Diaplay command return value, check if it matches the expected value
       
  1031 	TInt	expected;
       
  1032 	if ( !GetIntFromConfig(aSection, KFldExpected, expected) )
       
  1033 		{
       
  1034 		ERR_PRINTF2(KLogMissingParameter, &KFldExpected);
       
  1035 		SetBlockResult(EFail);
       
  1036 		}
       
  1037 	else
       
  1038 		{
       
  1039 		if ( actual!=expected )
       
  1040 			{
       
  1041 			ERR_PRINTF1(KLogNotExpectedValue);
       
  1042 			SetBlockResult(EFail);
       
  1043 			}
       
  1044 		}
       
  1045 	}
       
  1046 
       
  1047 /**
       
  1048 Test GetScreenSizeModeList()
       
  1049 */
       
  1050 void CT_DataWsScreenDevice::DoCmdGetScreenSizeModeListL(const TDesC& aSection)
       
  1051 	{
       
  1052 	RArray<TInt>	screenModes;
       
  1053 	CleanupClosePushL(screenModes);
       
  1054 
       
  1055 	TInt	number = iWsScreenDevice->GetScreenSizeModeList(&screenModes);
       
  1056 
       
  1057 	if (number < 0)
       
  1058 		{
       
  1059 		ERR_PRINTF2(KLogError, number);
       
  1060 		SetError(number);
       
  1061 		}
       
  1062 	else
       
  1063 		{
       
  1064 		INFO_PRINTF2(_L("GetScreenSizeModeList count=%d"), screenModes.Count());
       
  1065 		TInt	expectedCount;
       
  1066 		if ( GetIntFromConfig(aSection, KFldExpectedCount, expectedCount) )
       
  1067 			{
       
  1068 			if ( expectedCount!=screenModes.Count() || expectedCount != number)
       
  1069 				{
       
  1070 				ERR_PRINTF1(KLogNotExpectedValue);
       
  1071 				SetBlockResult(EFail);
       
  1072 				}
       
  1073 			else
       
  1074 				{
       
  1075 				INFO_PRINTF1(_L("Check elements in the modes list"));
       
  1076 				TBuf<KMaxTestExecuteCommandLength>	tempStore;
       
  1077 
       
  1078 				TBool	ok=ETrue;
       
  1079 				for ( TInt index = 0; (index < number) && (ok); )
       
  1080 					{
       
  1081 					tempStore.Format(KFormatFieldNumber, &KFldMode, ++index);
       
  1082 					
       
  1083 					TInt expectedMode = 0;
       
  1084 					ok=GetIntFromConfig(aSection, tempStore, expectedMode);
       
  1085 					if ( !ok )
       
  1086 						{
       
  1087 						ERR_PRINTF2(KLogMissingParameter, &tempStore);
       
  1088 						SetBlockResult(EFail);
       
  1089 						}
       
  1090 					else
       
  1091 						{
       
  1092 						if( expectedMode != screenModes[index-1])
       
  1093 							{
       
  1094 							ERR_PRINTF1(KLogNotExpectedValue);
       
  1095 							SetBlockResult(EFail);
       
  1096 							ok = EFalse;
       
  1097 							}
       
  1098 						}
       
  1099 					}
       
  1100 				}
       
  1101 			}
       
  1102 		}
       
  1103 
       
  1104 	CleanupStack::PopAndDestroy(&screenModes);
       
  1105 	}
       
  1106 
       
  1107 /**
       
  1108 Test NumScreenModes()
       
  1109 */
       
  1110 void CT_DataWsScreenDevice::DoCmdNumScreenModes(const TDesC& aSection)
       
  1111 	{
       
  1112 	TInt	actual=iWsScreenDevice->NumScreenModes();
       
  1113 	INFO_PRINTF2(_L("NumScreenModes()=%d"), actual);
       
  1114 
       
  1115 	TInt	expected;
       
  1116 	if ( GetIntFromConfig(aSection, KFldExpected, expected) )
       
  1117 		{
       
  1118 		if ( actual!=expected )
       
  1119 			{
       
  1120 			ERR_PRINTF1(KLogNotExpectedValue);
       
  1121 			SetBlockResult(EFail);
       
  1122 			}
       
  1123 		}
       
  1124 	}
       
  1125 
       
  1126 /**
       
  1127 Test PointerRect()
       
  1128 */
       
  1129 void CT_DataWsScreenDevice::DoCmdPointerRect(const TDesC& aSection)
       
  1130 	{
       
  1131 	TRect	actual=iWsScreenDevice->PointerRect();
       
  1132 	LogRect(_L("PointerRect()"), actual);
       
  1133 
       
  1134 	TRect	expected;
       
  1135 	if ( GetRectFromConfig(aSection, KFldExpected, expected) )
       
  1136 		{
       
  1137 		if ( actual!=expected )
       
  1138 			{
       
  1139 			ERR_PRINTF1(KLogNotExpectedValue);
       
  1140 			SetBlockResult(EFail);
       
  1141 			}
       
  1142 		}
       
  1143 	}
       
  1144 
       
  1145 /**
       
  1146 Test RectCompare()
       
  1147 */
       
  1148 void CT_DataWsScreenDevice::DoCmdRectCompare(const TDesC& aSection)
       
  1149 	{
       
  1150 	TBool	dataOk=ETrue;
       
  1151 
       
  1152 	// Get test data for command input parameter(s)
       
  1153 	TRect	datRect1;
       
  1154 	if ( !GetRectFromConfig(aSection, KFldRect1, datRect1) )
       
  1155 		{
       
  1156 		dataOk=EFalse;
       
  1157 		ERR_PRINTF2(KLogMissingParameter, &KFldRect1);
       
  1158 		SetBlockResult(EFail);
       
  1159 		}
       
  1160 
       
  1161 	TRect	datRect2;
       
  1162 	if ( !GetRectFromConfig(aSection, KFldRect2, datRect2) )
       
  1163 		{
       
  1164 		dataOk=EFalse;
       
  1165 		ERR_PRINTF2(KLogMissingParameter, &KFldRect2);
       
  1166 		SetBlockResult(EFail);
       
  1167 		}
       
  1168 
       
  1169 	if ( dataOk )
       
  1170 		{
       
  1171 		TBool	actual=EFalse;
       
  1172 
       
  1173 		// Execute command and log parameters
       
  1174 		TUint	datFlags;
       
  1175 		if ( CT_GraphicsUtil::ReadSpriteInCompare(*this, aSection, KFldFlags, datFlags) )
       
  1176 			{
       
  1177 			actual=iWsScreenDevice->RectCompare(datRect1, datRect2, datFlags);
       
  1178 			INFO_PRINTF2(_L("execute RectCompare(TRect, TRect, TUint)=%d"), actual);
       
  1179 			}
       
  1180 		else
       
  1181 			{
       
  1182 			actual=iWsScreenDevice->RectCompare(datRect1, datRect2);
       
  1183 			INFO_PRINTF2(_L("execute RectCompare(TRect, TRect)=%d"), actual);
       
  1184 			}
       
  1185 
       
  1186 		// Diaplay command return value, check if it matches the expected value
       
  1187 		TBool	expected;
       
  1188 		if ( !GetBoolFromConfig(aSection, KFldExpected, expected) )
       
  1189 			{
       
  1190 			ERR_PRINTF2(KLogMissingParameter, &KFldExpected);
       
  1191 			SetBlockResult(EFail);
       
  1192 			}
       
  1193 		else
       
  1194 			{
       
  1195 			if ( actual!=expected )
       
  1196 				{
       
  1197 				ERR_PRINTF1(KLogNotExpectedValue);
       
  1198 				SetBlockResult(EFail);
       
  1199 				}
       
  1200 			}
       
  1201 		}
       
  1202 	}
       
  1203 
       
  1204 /**
       
  1205 Test ScreenModeEnforcement()
       
  1206 */
       
  1207 void CT_DataWsScreenDevice::DoCmdScreenModeEnforcement(const TDesC& aSection)
       
  1208 	{
       
  1209 	TScreenModeEnforcement	actual=iWsScreenDevice->ScreenModeEnforcement();
       
  1210 	INFO_PRINTF2(_L("execute ScreenModeEnforcement()=%d"), actual);
       
  1211 
       
  1212 	TScreenModeEnforcement	expected;
       
  1213 	if ( CT_GraphicsUtil::ReadScreenModeEnforcement(*this, aSection, KFldExpected, expected) )
       
  1214 		{
       
  1215 		if ( actual!=expected )
       
  1216 			{
       
  1217 			ERR_PRINTF1(KLogNotExpectedValue);
       
  1218 			SetBlockResult(EFail);
       
  1219 			}
       
  1220 		}
       
  1221 	}
       
  1222 
       
  1223 /**
       
  1224 Test SetAppScreenMode()
       
  1225 */
       
  1226 void CT_DataWsScreenDevice::DoCmdSetAppScreenMode(const TDesC& aSection)
       
  1227 	{
       
  1228 	TInt	mode;
       
  1229 	if ( !GetIntFromConfig(aSection, KFldMode, mode) )
       
  1230 		{
       
  1231 		ERR_PRINTF2(KLogMissingParameter, &KFldRect2);
       
  1232 		SetBlockResult(EFail);
       
  1233 		}
       
  1234 	else
       
  1235 		{
       
  1236 		INFO_PRINTF1(_L("SetAppScreenMode()"));
       
  1237 		iWsScreenDevice->SetAppScreenMode(mode);
       
  1238 		}
       
  1239 	}
       
  1240 
       
  1241 /**
       
  1242 Test SetBackLight()
       
  1243 */
       
  1244 void CT_DataWsScreenDevice::DoCmdSetBackLight(const TDesC& aSection)
       
  1245 	{
       
  1246 	TBool	backLight;
       
  1247 	if ( !GetBoolFromConfig(aSection, KFldBackLight, backLight) )
       
  1248 		{
       
  1249 		ERR_PRINTF2(KLogMissingParameter, &KFldBackLight);
       
  1250 		SetBlockResult(EFail);
       
  1251 		}
       
  1252 	else
       
  1253 		{
       
  1254 		TInt	err=iWsScreenDevice->SetBackLight(backLight);
       
  1255 		if ( err!=KErrNone )
       
  1256 			{
       
  1257 			ERR_PRINTF2(KLogError, err);
       
  1258 			SetError(err);
       
  1259 			}
       
  1260 		}
       
  1261 	}
       
  1262 
       
  1263 /**
       
  1264 Test SetCustomPalette()
       
  1265 */
       
  1266 void CT_DataWsScreenDevice::DoCmdSetCustomPaletteL(const TDesC& aSection)
       
  1267 	{
       
  1268 	INFO_PRINTF1(_L("Calls CWsScreenDevice::SetCustomPalette() by previously created palette"));
       
  1269 
       
  1270 	// get CPalette object passed as a parameter
       
  1271 	CPalette*	palette = NULL;
       
  1272 	
       
  1273 	if(!CT_GraphicsUtil::GetPaletteL(*this, aSection, KFldPalette(), palette))
       
  1274 		{
       
  1275 		ERR_PRINTF2(KLogMissingParameter, &KFldPalette);
       
  1276 		SetBlockResult(EFail);
       
  1277 		}
       
  1278 	else
       
  1279 		{
       
  1280 		// call SetPalette()
       
  1281 		TInt err = iWsScreenDevice->SetCustomPalette(palette);
       
  1282 		if(err != KErrNone)
       
  1283 			{
       
  1284 			ERR_PRINTF2(KLogError, err);
       
  1285 			SetError(err);
       
  1286 			}
       
  1287 		}	
       
  1288 	}
       
  1289 
       
  1290 /**
       
  1291 Test SetScreenSizeAndRotation()
       
  1292 */
       
  1293 void CT_DataWsScreenDevice::DoCmdSetScreenSizeAndRotation(const TDesC& aSection)
       
  1294 	{
       
  1295 	TBool	dataOk=ETrue;
       
  1296 
       
  1297 	CFbsBitGc::TGraphicsOrientation	rotation;
       
  1298 	if ( !CT_GraphicsUtil::ReadGraphicsOrientation(*this, aSection, KFldRotation, rotation) )
       
  1299 		{
       
  1300 		dataOk=EFalse;
       
  1301 		ERR_PRINTF2(KLogMissingParameter, &KFldRotation);
       
  1302 		SetBlockResult(EFail);
       
  1303 		}
       
  1304 
       
  1305 	TSize	pixelSize;
       
  1306 	if ( !GetSizeFromConfig(aSection, KFldPixelSize, pixelSize) )
       
  1307 		{
       
  1308 		dataOk=EFalse;
       
  1309 		ERR_PRINTF2(KLogMissingParameter, &KFldPixelSize);
       
  1310 		SetBlockResult(EFail);
       
  1311 		}
       
  1312 
       
  1313 	if ( dataOk )
       
  1314 		{
       
  1315 		TSize	twipsSize;
       
  1316 		if ( GetSizeFromConfig(aSection, KFldTwipsSize, twipsSize) )
       
  1317 			{
       
  1318 			TPixelsTwipsAndRotation	param;
       
  1319 			param.iPixelSize=pixelSize;
       
  1320 			param.iRotation=rotation;
       
  1321 			param.iTwipsSize=twipsSize;
       
  1322 			INFO_PRINTF1(_L("execute SetScreenSizeAndRotation(const TPixelsTwipsAndRotation&)"));
       
  1323 			iWsScreenDevice->SetScreenSizeAndRotation(param);
       
  1324 			}
       
  1325 		else
       
  1326 			{
       
  1327 			TPixelsAndRotation	param;
       
  1328 			param.iPixelSize=pixelSize;
       
  1329 			param.iRotation=rotation;
       
  1330 			INFO_PRINTF1(_L("execute SetScreenSizeAndRotation(const TPixelsAndRotation&)"));
       
  1331 			iWsScreenDevice->SetScreenSizeAndRotation(param);
       
  1332 			}
       
  1333 		}
       
  1334 	}
       
  1335 
       
  1336 /**
       
  1337 * The source codes hereafter are NOT simple wrapper functions of CWsScreenDevice class,
       
  1338 * but use combinations of CWsScreenDevice (and other) class functions to check if what
       
  1339 * take from the CWsScreenDevice matches with the expected value specified in TEF testdata.
       
  1340 *
       
  1341 */
       
  1342 
       
  1343 /**
       
  1344 * DoCmdcheckPixels: to check the color of specified pixels on the screen device, and compare
       
  1345 * with the expected color specidied in the TEF testdata.
       
  1346 *		pixel<n>: specify the position of the screen device to check
       
  1347 *		expected<n>: specify the expected color to be compared with
       
  1348 *
       
  1349 */
       
  1350 void CT_DataWsScreenDevice::DoCmdcheckPixels(const TDesC& aSection)
       
  1351 	{
       
  1352 	TBuf<KMaxTestExecuteCommandLength>	tempStore;
       
  1353 
       
  1354 	TBool	moreData=ETrue;
       
  1355 	for ( TInt index=1; moreData; ++index )
       
  1356 		{
       
  1357 		// get the pixel position on the screen to check/verify
       
  1358 		tempStore.Format(KFldFormatFieldNumber, &KFldPixel, index);
       
  1359 		TPoint	point;
       
  1360 		if ( !GetPointFromConfig(aSection, tempStore, point) )
       
  1361 			{
       
  1362 			moreData=EFalse;
       
  1363 			}
       
  1364 		else
       
  1365 			{
       
  1366 			TRgb	actual;
       
  1367 			iWsScreenDevice->GetPixel(actual, point);
       
  1368 
       
  1369 			tempStore.Format(KFldFormatFieldNumber, &KFldExpected, index);
       
  1370 			TRgb	expected;
       
  1371 			if ( GetRgbFromConfig(aSection, tempStore, expected) )
       
  1372 				{
       
  1373 				if ( actual!=expected )
       
  1374 					{
       
  1375 					ERR_PRINTF5(KLogColor, actual.Red(), actual.Green(), actual.Blue(), actual.Alpha());
       
  1376 					ERR_PRINTF5(KLogColor, expected.Red(), expected.Green(), expected.Blue(), expected.Alpha());
       
  1377 					SetBlockResult(EFail);
       
  1378 					}
       
  1379 				}
       
  1380 			}
       
  1381 		}
       
  1382 	}
       
  1383 
       
  1384 /**
       
  1385 * DoCmdcheckLineColor: to check the color of specified lines on the screen device, and compare
       
  1386 * with the expected color specidied in the TEF testdata.
       
  1387 *		start<n>: specify the starting position of the line on the screen device to check
       
  1388 *		finish<n>: specify the finish position of the line on the screen device to check
       
  1389 *		expected<n>: specify the expected color to be compared with
       
  1390 * Note: the straight line (from start to the finish points) is constructed by TLinearDDA
       
  1391 *
       
  1392 */
       
  1393 void CT_DataWsScreenDevice::DoCmdcheckLineColor(const TDesC& aSection)
       
  1394 	{
       
  1395 	TBuf<KMaxTestExecuteCommandLength>	tempStore;
       
  1396 
       
  1397 	CPalette*	palette=NULL;
       
  1398 	iWsScreenDevice->GetPalette(palette);
       
  1399 
       
  1400 	TBool	moreData=ETrue;
       
  1401 	for ( TInt index=1; moreData; ++index )
       
  1402 		{
       
  1403 		// get the the start and finish points of the line to check/verify
       
  1404 		tempStore.Format(KFldFormatFieldNumber, &KFldStart, index);
       
  1405 		TPoint	startPoint;
       
  1406 		if ( !GetPointFromConfig(aSection, tempStore, startPoint) )
       
  1407 			{
       
  1408 			moreData=EFalse;
       
  1409 			}
       
  1410 
       
  1411 		tempStore.Format(KFldFormatFieldNumber, &KFldFinish, index);
       
  1412 		TPoint	endPoint;
       
  1413 		if ( !GetPointFromConfig(aSection, tempStore, endPoint) )
       
  1414 			{
       
  1415 			moreData=EFalse;
       
  1416 			}
       
  1417 
       
  1418 		if ( moreData )
       
  1419 			{
       
  1420 			// get the expected color from testdata
       
  1421 			tempStore.Format(KFldFormatFieldNumber, &KFldExpected, index);
       
  1422 			TRgb	expected;
       
  1423 			if ( !GetRgbFromConfig(aSection, tempStore, expected) )
       
  1424 				{
       
  1425 				ERR_PRINTF2(KLogMissingParameter, &tempStore);
       
  1426 				SetBlockResult(EFail);
       
  1427 				}
       
  1428 			else
       
  1429 				{
       
  1430 				if ( palette!=NULL )
       
  1431 					{
       
  1432 					expected=palette->NearestEntry(expected);
       
  1433 					}
       
  1434 
       
  1435 				TLinearDDA	lineDDA;
       
  1436 				lineDDA.Construct(startPoint, endPoint, TLinearDDA::ECenter);
       
  1437 
       
  1438 				// for each pixels on the line (from start to finish points), check if its color matches expected
       
  1439 				TPoint	point;
       
  1440 				while ( !lineDDA.SingleStep(point) )
       
  1441 					{
       
  1442 					TRgb	actual;
       
  1443 					iWsScreenDevice->GetPixel(actual, point);
       
  1444 
       
  1445 					if ( actual!=expected )
       
  1446 						{
       
  1447 						ERR_PRINTF5(KLogColor, actual.Red(), actual.Green(), actual.Blue(), actual.Alpha());
       
  1448 						ERR_PRINTF5(KLogColor, expected.Red(), expected.Green(), expected.Blue(), expected.Alpha());
       
  1449 						ERR_PRINTF3(KLogPoint, point.iX, point.iY);
       
  1450 						SetBlockResult(EFail);
       
  1451 						}
       
  1452 					}
       
  1453 				}
       
  1454 			}
       
  1455 		}
       
  1456 
       
  1457 	delete palette;
       
  1458 	}
       
  1459 
       
  1460 /**
       
  1461 * DoCmdcheckRectColor: to check the color of specified rectangle on the screen device, and
       
  1462 * compare with the expected color specidied in the TEF testdata.
       
  1463 *		rect<n>: specify the rectangle area on the screen device to check
       
  1464 *		expected<n>: specify the expected color to be compared with
       
  1465 *
       
  1466 */
       
  1467 void CT_DataWsScreenDevice::DoCmdcheckRectColor(const TDesC& aSection)
       
  1468 	{
       
  1469 	TBuf<KMaxTestExecuteCommandLength>	tempStore;
       
  1470 
       
  1471 	CPalette*	palette=NULL;
       
  1472 	iWsScreenDevice->GetPalette(palette);
       
  1473 
       
  1474 	TBool	moreData=ETrue;
       
  1475 	for ( TInt index=1; moreData; ++index )
       
  1476 		{
       
  1477 		// get the the rectangle to check/verify
       
  1478 		tempStore.Format(KFldFormatFieldNumber, &KFldRect, index);
       
  1479 		TRect	rect;
       
  1480 		if ( !GetRectFromConfig(aSection, tempStore, rect) )
       
  1481 			{
       
  1482 			moreData=EFalse;
       
  1483 			}
       
  1484 		else
       
  1485 			{
       
  1486 			// get the expected color from testdata
       
  1487 			tempStore.Format(KFldFormatFieldNumber, &KFldExpected, index);
       
  1488 			TRgb	expected;
       
  1489 			if ( !GetRgbFromConfig(aSection, tempStore, expected) )
       
  1490 				{
       
  1491 				ERR_PRINTF2(KLogMissingParameter, &tempStore);
       
  1492 				SetBlockResult(EFail);
       
  1493 				}
       
  1494 			else
       
  1495 				{
       
  1496 				if ( palette!=NULL )
       
  1497 					{
       
  1498 					expected=palette->NearestEntry(expected);
       
  1499 					}
       
  1500 
       
  1501 				TPoint	point;
       
  1502 				for ( point.iX=rect.iTl.iX; point.iX<rect.iBr.iX; ++point.iX)
       
  1503 					{
       
  1504 					for ( point.iY=rect.iTl.iY; point.iY<rect.iBr.iY; ++point.iY )
       
  1505 						{
       
  1506 						TRgb	actual;
       
  1507 						iWsScreenDevice->GetPixel(actual, point);
       
  1508 
       
  1509 						if ( actual!=expected )
       
  1510 							{
       
  1511 							ERR_PRINTF5(KLogColor, actual.Red(), actual.Green(), actual.Blue(), actual.Alpha());
       
  1512 							ERR_PRINTF5(KLogColor, expected.Red(), expected.Green(), expected.Blue(), expected.Alpha());
       
  1513 							ERR_PRINTF3(KLogPoint, point.iX, point.iY);
       
  1514 							SetBlockResult(EFail);
       
  1515 							}
       
  1516 						}
       
  1517 					}
       
  1518 				}
       
  1519 			}
       
  1520 		}
       
  1521 
       
  1522 	delete palette;
       
  1523 	}