os/graphics/windowing/windowserver/test/tauto/tgc.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 //
    15 
    16 /**
    17  @file
    18  @test
    19  @internalComponent - Internal Symbian test code
    20 */
    21 #include "tgc.h"
    22 #include "RemoteGc.h"
    23 #include "CommandBuffer.h"
    24 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA
    25 #include "directgdigcwrapper.h"
    26 #include <graphics/directgdidriver.h>
    27 #include <graphics/sgutils.h>
    28 #include <graphics/wsdrawresource.h>
    29 #endif
    30 
    31 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA
    32 GLDEF_C void CopyImageToBitmapL(CFbsBitmap* aBitmap, const RSgImage& aImage, const TRect& aRect);
    33 GLDEF_C void CopyImageToDestination(TAny* aDataAddressDest, TInt aDataStrideDest, TDisplayMode aDisplayModeDest, 
    34 				TAny* aDataAddressSrc, TInt aDataStrideSrc, TDisplayMode aDisplayModeSrc, const TRect& aRect);
    35 GLDEF_C void CopyImageToDestination64K(TAny* aDataAddressDest, TInt aDataStrideDest, TDisplayMode aDisplayModeDest, 
    36 		TUint16* aDataAddressSrc, TInt aDataStrideSrc, const TRect& aRect);
    37 
    38 GLDEF_C void CopyImageToBitmapL(CFbsBitmap* aBitmap, const RSgImage& aImage, const TRect& aRect)
    39 	{
    40 	TSgImageInfo info;
    41 	TInt res = aImage.GetInfo(info);
    42 	if(res == KErrNone)
    43 		{
    44 		info.iUsage = ESgUsageNone;
    45 		info.iCpuAccess = ESgCpuAccessReadOnly;
    46 		RSgImage image;
    47 		res = image.Create(info, aImage);
    48 		if(res == KErrNone)
    49 			{	
    50 			const TAny* dataAddressSrc = NULL; 
    51 			TInt dataStrideSrc = 0;
    52 			res = image.MapReadOnly(dataAddressSrc, dataStrideSrc);
    53 			if(res == KErrNone)
    54 				{
    55 				const TDisplayMode displayModeDest = aBitmap->DisplayMode();
    56 				const TDisplayMode displayModeSrc = SgUtils::PixelFormatToDisplayMode(info.iPixelFormat);
    57 				TUint32* dataAddressDest = aBitmap->DataAddress();
    58 				const TInt dataStrideDest = aBitmap -> DataStride();
    59 				TSize bitmapSize = aBitmap->SizeInPixels();
    60 				TRect rect = aRect;
    61 				TRect rectDest = info.iSizeInPixels;
    62 				rect.Intersection(rectDest);
    63 				if(rect.Height() > bitmapSize.iHeight)
    64 					{
    65 					rect.SetHeight(bitmapSize.iHeight);
    66 					}
    67 				if(rect.Width() > bitmapSize.iWidth)
    68 					{
    69 					rect.SetWidth(bitmapSize.iWidth);
    70 					}
    71 				CopyImageToDestination((TAny*)dataAddressDest, dataStrideDest, displayModeDest, (TAny*)dataAddressSrc, 
    72 								dataStrideSrc, displayModeSrc, rect);
    73 
    74 				image.Unmap();
    75 				}
    76 			image.Close();
    77 			}
    78 		}
    79 	}
    80 
    81 GLDEF_C void CopyImageToDestination(TAny* aDataAddressDest, TInt aDataStrideDest, TDisplayMode aDisplayModeDest, 
    82 				TAny* aDataAddressSrc, TInt aDataStrideSrc, TDisplayMode aDisplayModeSrc, const TRect& aRect) 
    83 	{
    84 	if(aRect.IsEmpty())
    85 		return;
    86 	
    87 	if((aDisplayModeDest == aDisplayModeSrc) && (aDataStrideSrc == aDataStrideDest))
    88 		{
    89 		Mem::Copy(aDataAddressDest, aDataAddressSrc, aDataStrideDest * aRect.Height());
    90 		return;
    91 		}
    92 	
    93 	switch(aDisplayModeSrc)
    94 		{
    95 	case EColor64K:
    96 		{
    97 		CopyImageToDestination64K(aDataAddressDest, aDataStrideDest, aDisplayModeDest, 
    98 						(TUint16*)aDataAddressSrc, aDataStrideSrc, aRect);
    99 		break;
   100 		}
   101 	default:
   102 		break;
   103 		}
   104 	}
   105 
   106 GLDEF_C void CopyImageToDestination64K(TAny* aDataAddressDest, TInt aDataStrideDest, TDisplayMode aDisplayModeDest, 
   107 		TUint16* aDataAddressSrc, TInt aDataStrideSrc, const TRect& aRect) 
   108 	{
   109 	const TInt bppSrc = 2;
   110 	const TInt width = aRect.Width();
   111 	const TInt height = aRect.Height();
   112 	const TInt dataStrideLengthSrc = aDataStrideSrc / bppSrc;
   113 	TUint16* dataAddressSrc =  aDataAddressSrc + aRect.iTl.iY * dataStrideLengthSrc + aRect.iTl.iX; 
   114 	const TUint16* dataAddressSrcEnd = dataAddressSrc + dataStrideLengthSrc *  height;  
   115 
   116 	switch(aDisplayModeDest)
   117 		{
   118 	case EColor64K:
   119 		{
   120 		TUint16* dataAddressDest = static_cast<TUint16*> (aDataAddressDest); 
   121 		const TInt dataStrideLengthDest = aDataStrideDest / bppSrc;
   122 		while(dataAddressSrcEnd > dataAddressSrc)
   123 			{
   124 			Mem::Copy(dataAddressDest, dataAddressSrc, width * bppSrc);
   125 			dataAddressSrc += dataStrideLengthSrc;
   126 			dataAddressDest += dataStrideLengthDest;
   127 			}
   128 		break;
   129 		}
   130 	case EColor16MU:
   131 		{
   132 		const TInt bppDest = 4;
   133 		TUint32* dataAddressDest = static_cast<TUint32*> (aDataAddressDest); 
   134 		const TInt dataStrideLengthDest = aDataStrideDest / bppDest;
   135 		
   136 		while(dataAddressSrcEnd > dataAddressSrc)
   137 			{
   138 			const TUint16* dataAddressSrcLineEnd = dataAddressSrc + width;
   139 			TUint32* dataAddressDestCur = dataAddressDest;
   140 			TUint16* dataAddressSrcCur = dataAddressSrc;
   141 
   142 			while(dataAddressSrcLineEnd > dataAddressSrcCur)
   143 				{
   144 				*dataAddressDestCur = TRgb::Color64K(*dataAddressSrcCur).Color16MU();
   145 				dataAddressDestCur++;
   146 				dataAddressSrcCur++;
   147 				}
   148 			dataAddressSrc += dataStrideLengthSrc;
   149 			dataAddressDest += dataStrideLengthDest;
   150 			}
   151 		break;
   152 		}
   153 	case EGray4:
   154 		{
   155 		TUint8* dataAddressDest = static_cast<TUint8*> (aDataAddressDest);
   156 		const TInt dataStrideLengthDest = aDataStrideDest;
   157 		
   158 		while(dataAddressSrcEnd > dataAddressSrc)
   159 			{
   160 			const TUint8* dataAddressDstLineEnd = dataAddressDest + aDataStrideDest;
   161 			TUint8* dataAddressDestCur = dataAddressDest;
   162 			TUint16* dataAddressSrcCur = dataAddressSrc;
   163 
   164 			while(dataAddressDstLineEnd > dataAddressDestCur)
   165 				{
   166 				*dataAddressDestCur = 0;
   167 				for(TInt index = 0; index < 8; index +=2)
   168 					{
   169 					TInt col = TRgb::Color64K(*dataAddressSrcCur).Gray4();
   170 					col <<= index;
   171 					*dataAddressDestCur |= col;
   172 					dataAddressSrcCur++;
   173 					}
   174 				dataAddressDestCur++;
   175 				}
   176 			dataAddressSrc += dataStrideLengthSrc;
   177 			dataAddressDest += dataStrideLengthDest;
   178 			}
   179 		break;
   180 		}
   181 	case EColor256:
   182 		{
   183 		TUint8* dataAddressDest = static_cast<TUint8*> (aDataAddressDest);
   184 		const TInt dataStrideLengthDest = aDataStrideDest;
   185 		
   186 		while(dataAddressSrcEnd > dataAddressSrc)
   187 			{
   188 			const TUint8* dataAddressDstLineEnd = dataAddressDest + aDataStrideDest;
   189 			TUint8* dataAddressDestCur = dataAddressDest;
   190 			TUint16* dataAddressSrcCur = dataAddressSrc;
   191 
   192 			while(dataAddressDstLineEnd > dataAddressDestCur)
   193 				{
   194 				*dataAddressDestCur = TRgb::Color64K(*dataAddressSrcCur).Color256();
   195 				dataAddressSrcCur++;
   196 				dataAddressDestCur++;
   197 				}
   198 			dataAddressSrc += dataStrideLengthSrc;
   199 			dataAddressDest += dataStrideLengthDest;
   200 			}
   201 		break;
   202 		}
   203 	default:
   204 		break;
   205 		}
   206 	}
   207 
   208 TDisplayMode DisplayModeFromPixelFormat(TUidPixelFormat aPixelFormat)
   209 	{
   210 	switch(aPixelFormat)
   211 		{
   212 	case EUidPixelFormatARGB_8888_PRE:
   213 		return EColor16MAP;
   214 	case EUidPixelFormatARGB_8888:
   215 		return EColor16MA;
   216 	case EUidPixelFormatRGB_565:
   217 		return EColor64K;
   218 	default:
   219 		break;
   220 		}
   221 	return ENone;
   222 	}
   223 
   224 TUidPixelFormat PixelFormatFromDisplayMode(TDisplayMode aDisplayMode)
   225 	{
   226 	switch (aDisplayMode)
   227 		{
   228 		case EGray2:
   229 		case EGray4:
   230 		case EGray16:
   231 		case EGray256:
   232 		case EColor16:
   233 		case EColor256:
   234 		case EColor16M:
   235 		case EColor16MU:
   236 			{
   237 			return EUidPixelFormatXRGB_8888;
   238 			}
   239 		case EColor4K:
   240 			{
   241 			return EUidPixelFormatXRGB_4444;
   242 			}
   243 		case EColor64K:
   244 			{
   245 			return EUidPixelFormatRGB_565;
   246 			}
   247 		case EColor16MA:
   248 			{
   249 			return EUidPixelFormatARGB_8888;
   250 			}
   251 		case EColor16MAP:
   252 			{
   253 			return EUidPixelFormatARGB_8888_PRE;
   254 			}
   255 		default:
   256 			{
   257 			return EUidPixelFormatUnknown;
   258 			}
   259 		}
   260 	}
   261 #endif
   262 
   263 CTGc::CTGc(CTestStep* aStep) : CTWsGraphicsBase(aStep)
   264 	{
   265 	}
   266 
   267 CTGc::~CTGc()
   268 	{
   269 	delete iTest;
   270 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA
   271 	SgDriver::Close();
   272 	CDirectGdiDriver *directGdiDriver = CDirectGdiDriver::Static();
   273 	if(directGdiDriver)
   274 		{
   275 		directGdiDriver->Close();
   276 		}
   277 #endif
   278 	}
   279 
   280 void CTGc::ConstructL()
   281 	{
   282 	_LIT(KTestName,"GC Test");
   283 	iTest=new(ELeave) CTestBase(KTestName,this);
   284 	
   285 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA
   286 	TInt err = CDirectGdiDriver::Open();
   287 	User::LeaveIfError(err);
   288 	err = SgDriver::Open();
   289 	if(err != KErrNone)
   290 		{
   291 		CDirectGdiDriver *directGdiDriver = CDirectGdiDriver::Static();
   292 		if(directGdiDriver)
   293 			{
   294 			directGdiDriver->Close();
   295 			}
   296 		User::Leave(err);
   297 		}
   298 #endif
   299 	}
   300 
   301 //Class derived from MWsGraphicResolver. Used for playing the commands from command buffer
   302 class CWSGraphicsRes: public CBase, public MWsGraphicResolver
   303 	{
   304 public:
   305 	void DrawWsGraphic(TInt /*aId*/, TBool /*aIsUid*/, const TRect& /*aRect*/, const TDesC8& /*aData*/) const
   306 		{
   307 		//Orveriding by giving empty implemention
   308 		}
   309 	};
   310 
   311 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA
   312 //
   313 //Class CDrawTextInContextTest
   314 //
   315 
   316 CDrawTextInContextTest::CDrawTextInContextTest(){}
   317 
   318 CDrawTextInContextTest::~CDrawTextInContextTest()
   319 	{
   320 	delete iRefBitmap;
   321 	delete iRefDevice;
   322 	delete iRefBitGc;
   323 	delete iRemoteGc;
   324 	iMsgBuf.Close();
   325 	delete iCommandBuffer;
   326 	delete iWsGraphicRes;
   327 	
   328 	TheClient->iScreen->ReleaseFont(iFont);
   329 
   330 	delete iDirectGdiGcWrapper;
   331 	if(iWrapperImageTarget)
   332 		{
   333 		iWrapperImageTarget->Close();
   334 		}
   335 	delete iWrapperImageTarget;
   336 	iWrapperImage.Close();
   337 	iWrapperImageCollection.Close();
   338 	}
   339 
   340 void CDrawTextInContextTest::BaseConstructL()
   341 	{
   342 	//Initialise font settings
   343 	TFontSpec fsp;
   344 	fsp.iTypeface.iName=_L("Series 60 Sans");
   345 	fsp.iHeight=430;
   346 	User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInTwips((CFont*&)iFont,fsp));
   347 	
   348 	//Initialise TTextParameter
   349 	iParam.iStart = 27;
   350 	iParam.iEnd = 60;
   351 	
   352 	//Text to draw
   353 	iText.Set(_L("This text will not be drawnK.,!\"\x00A3$%^&*()_+-=;'#:@~/<>? Latin This text will not be drawn"));
   354 	
   355 	//For reference bitmap
   356 	iRefBitmap = new(ELeave) CFbsBitmap();
   357 	User::LeaveIfError(iRefBitmap->Create(KBitmapSize, EColor64K));
   358 	iRefDevice = CFbsBitmapDevice::NewL(iRefBitmap);
   359 	User::LeaveIfError(iRefDevice->CreateContext(iRefBitGc));
   360 	
   361 	CDirectGdiDriver* theDGdiDriver = CDirectGdiDriver::Static();
   362 	User::LeaveIfNull(theDGdiDriver);
   363 	
   364 	TSgImageInfo info;
   365 	info.iUsage = ESgUsageDirectGdiTarget | ESgUsageDirectGdiSource | ESgUsageCompositionSource;
   366 	info.iSizeInPixels = KBitmapSize;
   367 	info.iPixelFormat = EUidPixelFormatRGB_565;
   368 	
   369 	TInt res = iWrapperImageCollection.Create(info, 1);
   370 	User::LeaveIfError(res);
   371 	res = iWrapperImageCollection.OpenImage(0, iWrapperImage);
   372 	User::LeaveIfError(res);
   373 	iWrapperImageTarget = new (ELeave) RDirectGdiImageTarget(*theDGdiDriver);
   374 	res = iWrapperImageTarget->Create(iWrapperImage);
   375 	User::LeaveIfError(res);
   376 	iDirectGdiGcWrapper = CDirectGdiGcWrapper::NewL(*iWrapperImageTarget);
   377 
   378 	//clean image-----------------
   379 	CDirectGdiGcWrapper* directGdiGcWrapper = CDirectGdiGcWrapper::NewL(*iWrapperImageTarget);
   380 	CleanupStack::PushL(directGdiGcWrapper);
   381 
   382 	directGdiGcWrapper->SetDrawMode(MWsGraphicsContext::EDrawModeWriteAlpha);
   383 	directGdiGcWrapper->SetBrushColor(KRgbWhite);
   384 	directGdiGcWrapper->Clear();
   385 
   386 	CleanupStack::PopAndDestroy(1, directGdiGcWrapper);
   387 	//------------------
   388 	
   389 	//Used to record draw commands
   390 	iRemoteGc = CRemoteGc::NewL(TheClient->iScreen);
   391 	
   392 	//Used to play recorded draw commands
   393 	iCommandBuffer = CCommandBuffer::NewL();
   394 	
   395 	//Dummy class created required for CCommandBuffer::Play
   396 	iWsGraphicRes = new (ELeave) CWSGraphicsRes();
   397 	
   398 	//Offset for CCommandBuffer::Play
   399 	iOffset = TPoint(0,0);
   400 	
   401 	//Result of doing the test
   402 	iHasPassedTest = EFalse;
   403 	}
   404 
   405 void CDrawTextInContextTest::Test()
   406 	{	
   407 	/* Create reference bitmap by drawing using bitgc */
   408 	iRefBitGc->UseFont(iFont);
   409 	DoDrawTextBitGc();
   410 	iRefBitGc->DiscardFont();
   411 	
   412 	/* Drawing using CBitGcWrapper via CRemotGc*/
   413 	
   414 	//Capturing the commands in remote gc
   415 	iRemoteGc->BeginDraw(KBitmapRect);
   416 	iRemoteGc->UseFont(iFont);
   417 	DoDrawTextRemoteGc();
   418 	iRemoteGc->DiscardFont();
   419 	iRemoteGc->EndDraw();
   420 		
   421 	//Externalize the captured commands from remote gc in to a buffer
   422 	iRemoteGc->ExternalizeL(iMsgBuf, ETrue);
   423 
   424 	//Internalize the buffer with captured commands (from CRemoteGC) in to CCommandBuffer
   425 	iCommandBuffer->InternalizeL(iMsgBuf.Pckg());
   426 	
   427 	//Play the commands on test window using command buffer
   428 	iCommandBuffer->Play(iOffset,&KBitmapRegion,KBitmapRect,*iWsGraphicRes,*iDirectGdiGcWrapper);
   429 	
   430 	//Test to see if the bitmap drawn to using CRemoteGc is the same as the reference bitmap
   431 	CFbsBitmap* bitmap = new (ELeave) CFbsBitmap;
   432 	CleanupStack::PushL(bitmap);
   433 	
   434 	TSgImageInfo info;
   435 	iWrapperImage.GetInfo(info);
   436 	TDisplayMode displayMode = DisplayModeFromPixelFormat(info.iPixelFormat);
   437 	bitmap->Create(info.iSizeInPixels, displayMode);
   438 	TRect rect(info.iSizeInPixels);
   439 	CopyImageToBitmapL(bitmap, iWrapperImage, rect);
   440 	
   441 	iHasPassedTest = LossyCompareBitmap(*iRefBitmap, *bitmap, KBitmapRect, EFalse);
   442 
   443 	CleanupStack::PopAndDestroy(bitmap);
   444 	}
   445 
   446 TBool CDrawTextInContextTest::HasPassedTest()
   447 	{
   448 	return iHasPassedTest;
   449 	}
   450 
   451 //
   452 // Class DrawTextInContextTestPoint
   453 //
   454 
   455 CDrawTextInContextTestPoint::CDrawTextInContextTestPoint(){}
   456 
   457 CDrawTextInContextTestPoint::~CDrawTextInContextTestPoint(){}
   458 
   459 CDrawTextInContextTestPoint* CDrawTextInContextTestPoint::NewL()
   460 	{
   461 	CDrawTextInContextTestPoint* self = new(ELeave) CDrawTextInContextTestPoint;
   462 	CleanupStack::PushL(self);
   463 	self->ConstructL();
   464 	CleanupStack::Pop(self);
   465 	return self;
   466 	}
   467 
   468 void CDrawTextInContextTestPoint::ConstructL()
   469 	{
   470 	BaseConstructL();
   471 	iPosition = TPoint(0,0);
   472 	}
   473 
   474 void CDrawTextInContextTestPoint::DoDrawTextBitGc()
   475 	{
   476 	iRefBitGc->DrawText(iText,&iParam,iPosition);
   477 	}
   478 
   479 void CDrawTextInContextTestPoint::DoDrawTextRemoteGc()
   480 	{
   481 	iRemoteGc->DrawText(iText,&iParam,iPosition);
   482 	}
   483 
   484 //
   485 // Class DrawTextInContextTestBox
   486 //
   487 
   488 CDrawTextInContextTestBox::CDrawTextInContextTestBox(){}
   489 
   490 CDrawTextInContextTestBox::~CDrawTextInContextTestBox(){}
   491 
   492 CDrawTextInContextTestBox* CDrawTextInContextTestBox::NewL()
   493 	{
   494 	CDrawTextInContextTestBox* self = new(ELeave) CDrawTextInContextTestBox;
   495 	CleanupStack::PushL(self);
   496 	self->ConstructL();
   497 	CleanupStack::Pop(self);
   498 	return self;
   499 	}
   500 
   501 void CDrawTextInContextTestBox::ConstructL()
   502 	{
   503 	BaseConstructL();
   504 	iClipFillRect = TRect(10,50,640,120);
   505 	iBaselineOffset = 40;
   506 	iTTextAlign = CGraphicsContext::ELeft;
   507 	}
   508 
   509 void CDrawTextInContextTestBox::DoDrawTextBitGc()
   510 	{
   511 	iRefBitGc->DrawText(iText,&iParam,iClipFillRect,iBaselineOffset,iTTextAlign);
   512 	}
   513 
   514 void CDrawTextInContextTestBox::DoDrawTextRemoteGc()
   515 	{
   516 	iRemoteGc->DrawText(iText,&iParam,iClipFillRect,iBaselineOffset,iTTextAlign);
   517 	}
   518 
   519 //
   520 // Class CDrawTextInContextTestPointVertical
   521 //
   522 
   523 CDrawTextInContextTestPointVertical::CDrawTextInContextTestPointVertical(){}
   524 
   525 CDrawTextInContextTestPointVertical::~CDrawTextInContextTestPointVertical(){}
   526 
   527 CDrawTextInContextTestPointVertical* CDrawTextInContextTestPointVertical::NewL()
   528 	{
   529 	CDrawTextInContextTestPointVertical* self = new(ELeave) CDrawTextInContextTestPointVertical;
   530 	CleanupStack::PushL(self);
   531 	self->ConstructL();
   532 	CleanupStack::Pop(self);
   533 	return self;
   534 	}
   535 
   536 void CDrawTextInContextTestPointVertical::ConstructL()
   537 	{
   538 	BaseConstructL();
   539 	iPosition = TPoint(0,0);
   540 	iUp = EFalse;
   541 	}
   542 
   543 void CDrawTextInContextTestPointVertical::DoDrawTextBitGc()
   544 	{
   545 	iRefBitGc->DrawTextVertical(iText,&iParam,iPosition,iUp);
   546 	}
   547 
   548 void CDrawTextInContextTestPointVertical::DoDrawTextRemoteGc()
   549 	{
   550 	iRemoteGc->DrawTextVertical(iText,&iParam,iPosition,iUp);
   551 	}
   552 
   553 //
   554 // Class CDrawTextInContextTestBoxVertical
   555 //
   556 
   557 CDrawTextInContextTestBoxVertical::CDrawTextInContextTestBoxVertical(){}
   558 
   559 CDrawTextInContextTestBoxVertical::~CDrawTextInContextTestBoxVertical(){}
   560 
   561 CDrawTextInContextTestBoxVertical* CDrawTextInContextTestBoxVertical::NewL()
   562 	{
   563 	CDrawTextInContextTestBoxVertical* self = new(ELeave) CDrawTextInContextTestBoxVertical;
   564 	CleanupStack::PushL(self);
   565 	self->ConstructL();
   566 	CleanupStack::Pop(self);
   567 	return self;
   568 	}
   569 
   570 void CDrawTextInContextTestBoxVertical::ConstructL()
   571 	{
   572 	BaseConstructL();
   573 	iClipFillRect = TRect(10,50,640,120);
   574 	iBaselineOffset = 40;
   575 	iUp = EFalse;
   576 	iTTextAlign = CGraphicsContext::ELeft;
   577 	}
   578 
   579 void CDrawTextInContextTestBoxVertical::DoDrawTextBitGc()
   580 	{
   581 	iRefBitGc->DrawTextVertical(iText,&iParam,iClipFillRect,iBaselineOffset,iUp,iTTextAlign);
   582 	}
   583 
   584 void CDrawTextInContextTestBoxVertical::DoDrawTextRemoteGc()
   585 	{
   586 	iRemoteGc->DrawTextVertical(iText,&iParam,iClipFillRect,iBaselineOffset,iUp,iTTextAlign);
   587 	}
   588 #endif //TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA
   589 
   590 void CleanUpFont(TAny* aFont)
   591 	{
   592 	//Will be called in case of a leave to release the font
   593 	CFont* font= static_cast<CFont*>(aFont);
   594 	TheClient->iScreen->ReleaseFont(font);
   595 	}
   596 
   597 /**
   598 @SYMTestCaseID		GRAPHICS-WSERV-0437
   599 @SYMPREQ            PREQ1543
   600 @SYMTestCaseDesc    Draw text using CWindowGc and CRemoteGc with both outline and shadow
   601 effect on.
   602 @SYMTestPriority    High
   603 @SYMTestStatus      Implemented
   604 @SYMTestActions     Create a font with both outline and shadow effects. Record the commands 
   605 (like setting colours,drawing text etc) using CRemoteGc and play the recorded commands on a window. Use the same
   606 commands in CWindowGc and draw text on a different window
   607 @SYMTestExpectedResults Text drawn using CWindowGc and CRemoteGc should be same
   608 */
   609 void CTGc::TestOutlineAndShadowL()
   610 	{
   611 	TRect sourceRect(0, 0, TestWin->Size().iWidth, TestWin->Size().iHeight);
   612 	TRegionFix<1> clippingRegion(sourceRect);
   613 	
   614 	CWsScreenDevice* device = TheClient->iScreen;
   615 
   616 	_LIT(KText,"Outline and shadow");
   617 	TFontSpec fSpec(KTestFontTypefaceName,23);
   618 	fSpec.iFontStyle.SetBitmapType(EAntiAliasedGlyphBitmap);
   619 	fSpec.iFontStyle.SetEffects(FontEffect::EDropShadow, ETrue);
   620 	fSpec.iFontStyle.SetEffects(FontEffect::EOutline, ETrue);
   621 	
   622 	CFont *font;
   623 	User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInPixels((CFont *&)font, fSpec));
   624 	CleanupStack::PushL(TCleanupItem(CleanUpFont, font));
   625 	
   626 	CRemoteGc* remoteGc = CRemoteGc::NewL(device);
   627 	CleanupStack::PushL(remoteGc);
   628 	remoteGc->BeginDraw(sourceRect);
   629 	//Capturing the commands in remote gc
   630 	remoteGc->SetBrushColor(KRgbGreen);
   631 	remoteGc->SetShadowColor(KRgbDarkRed);
   632 	remoteGc->SetPenColor(KRgbBlack);
   633 	remoteGc->UseFont(font);
   634 	remoteGc->DrawText(KText, TPoint(2,40));
   635 	remoteGc->DiscardFont();
   636 	remoteGc->EndDraw();
   637 
   638 	RWsGraphicMsgBuf msgBuf;
   639 	CleanupClosePushL(msgBuf);
   640 	//Externalize the captured commands from remote gc in to a buffer
   641 	remoteGc->ExternalizeL(msgBuf, ETrue);
   642 
   643 	CWSGraphicsRes* wsGrap = new (ELeave) CWSGraphicsRes();
   644 	CleanupStack::PushL(wsGrap);
   645 	
   646 	CCommandBuffer* cmdBuf = CCommandBuffer::NewL();
   647 	CleanupStack::PushL(cmdBuf);
   648 	//Internalize the buffer with captured commands (from CRemoteGC) 
   649 	//in to CCommandBuffer
   650 	cmdBuf->InternalizeL(msgBuf.Pckg());
   651 	
   652 	TestWin->Win()->Invalidate();
   653 	TestWin->Win()->BeginRedraw();
   654 	TheGc->Activate(*TestWin->Win());
   655 	TheGc->Clear();
   656 	//Play the commands on test window using command buffer
   657 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA
   658 	cmdBuf->Play(TPoint(0, 0), &clippingRegion, sourceRect, TheClient->iWs, *TheGc);
   659 #else
   660 	cmdBuf->Play(TPoint(),TRect(TestWin->Size()),*wsGrap,*TheGc);
   661 #endif
   662 	TheGc->Deactivate();
   663 	TestWin->Win()->EndRedraw();
   664 	
   665 	BaseWin->Win()->Invalidate();
   666 	BaseWin->Win()->BeginRedraw();
   667 	TheGc->Activate(*BaseWin->Win());
   668 	TheGc->Clear();
   669 	TheGc->SetBrushColor(KRgbGreen);
   670 	TheGc->SetShadowColor(KRgbDarkRed);
   671 	TheGc->SetPenColor(KRgbBlack);
   672 	TheGc->UseFont(font);
   673 	//Draw the text on base window using CWindowGC
   674 	TheGc->DrawText(KText, TPoint(2, 40));
   675 	TheGc->DiscardFont();
   676 	TheGc->Deactivate();
   677 	BaseWin->Win()->EndRedraw();
   678 	TheClient->iWs.Finish();
   679 	TheClient->WaitForRedrawsToFinish();
   680 
   681 	//Check the text drawn on base and test windows.
   682 	CheckRect(BaseWin, TestWin, TRect(0, 0, BaseWin->Size().iWidth, BaseWin->Size().iHeight), _L("CTGc::TestOutlineAndShadowL()"));
   683 
   684 	CleanupStack::PopAndDestroy(4, remoteGc); //cmdBuf, wsGrap, msgBuf and remoteGc
   685 	CleanupStack::Pop();//font
   686 	TheClient->iScreen->ReleaseFont(font);
   687 	}
   688 
   689 void CTGc::TestGcClipRectOrigin_DrawContent(TestWindow& aWindow, TBool bActivateBeforeRedraw /*= ETrue*/)
   690 	{
   691 	TSize winSize = aWindow.Size();
   692 	TPoint gcOrigin(winSize.iWidth >> 3, winSize.iWidth >> 3);
   693 	TRect gcClipRect(0, 0, (winSize.iWidth * 3) >> 2, (winSize.iHeight * 3) >> 2);
   694 	TRect ellipseRect(gcClipRect);
   695 	// Shrink the ellipse for better visibility and to fit well within the clip area.
   696 	ellipseRect.Shrink(3, 3);
   697 	TSize penSize(1, 1);
   698 
   699 	aWindow.Win()->SetBackgroundColor(KRgbGreen);
   700 	aWindow.ClearWin();
   701 	aWindow.Win()->Invalidate();
   702 
   703 	if(!bActivateBeforeRedraw)
   704 		{
   705 		aWindow.Win()->BeginRedraw();
   706 		}
   707 
   708 	TheGc->Activate(*(aWindow.Win()));
   709 	TheGc->SetOrigin(gcOrigin);
   710 	TheGc->SetClippingRect(gcClipRect);
   711 
   712 	if(bActivateBeforeRedraw)
   713 		{
   714 		aWindow.Win()->BeginRedraw();
   715 		}
   716 
   717 	TheGc->SetBrushColor(KRgbDarkRed);
   718 	TheGc->SetPenColor(KRgbDarkRed);
   719 	TheGc->SetPenSize(penSize);
   720 	TheGc->SetPenStyle(CGraphicsContext::ESolidPen);
   721 	TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
   722 	TheGc->DrawEllipse(ellipseRect);
   723 	TheGc->SetBrushStyle(CGraphicsContext::ENullBrush);
   724 	TheGc->SetPenColor(KRgbYellow);
   725 	TheGc->SetPenStyle(CGraphicsContext::EDashedPen);
   726 	TheGc->DrawRect(gcClipRect);
   727 
   728 	aWindow.Win()->EndRedraw();
   729 	TheGc->Deactivate();
   730 	}
   731 
   732 /**
   733 @SYMTestCaseID		GRAPHICS-WSERV-0471
   734 @SYMTestCaseDesc    This test is to verify that the GC correctly applies the clip rect and
   735 					origin attributes irrespective of whether the GC is activated on the
   736 					window before or after the BeginRedraw.
   737 @SYMDEF				PDEF120091
   738 @SYMTestPriority    High
   739 @SYMTestStatus      Implemented
   740 @SYMTestActions     The test has following steps:
   741 	1. For the Test window follow the steps:
   742 		A. Activate the GC on Test window.
   743 		B. Set the Origin of the GC to centre of the window.
   744 		C. Set the Clipping rectangle of the GC to half the size of the window.
   745 		D. In the BeginDraw and EndDraw call bracket perform the following:
   746 			a. Draw an ellipse with the rectangle smaller by 5 pixels than the clip rectangle.
   747 			b. Draw a rectangle that is size of the clip rectangle.
   748 		E. Deactivate the GC. 
   749 	2. For the Base window follow the steps:
   750 		A. In the BeginDraw and EndDraw call bracket perform the following:
   751 			a. Activate the GC on Base window.
   752 			b. Set the Origin of the GC to centre of the window.
   753 			c. Set the Clipping rectangle of the GC to half the size of the window.
   754 			d. Draw an ellipse with the rectangle smaller by 5 pixels than the clip rectangle.
   755 			e. Draw a rectangle that is size of the clip rectangle.
   756 			f. Deactivate the GC. 
   757 	3. Compare Test and Base window.
   758 @SYMTestExpectedResults Both the Test and Base window should have the complete
   759 						non-clipped ellipse completely encapsulated within the rectangle. 
   760 */
   761 void CTGc::TestGcClipRectOrigin()
   762 	{
   763 	TestGcClipRectOrigin_DrawContent(*BaseWin, EFalse);
   764 	TestGcClipRectOrigin_DrawContent(*TestWin, ETrue);
   765 	
   766 	TheClient->Flush();
   767 	
   768 	CheckRect(BaseWin, TestWin, TRect(0, 0, BaseWin->Size().iWidth, BaseWin->Size().iHeight), _L("CTGc::TestGcClipRectOriginL()"));
   769 	}
   770 
   771 /**
   772 @SYMTestCaseID		GRAPHICS-WSERV-0469
   773 @SYMDEF             INC116406
   774 @SYMTestCaseDesc    Try playback on MWsGraphicsContext and CWindowGc to check that the background colour is
   775 set correctly.
   776 @SYMTestPriority    High
   777 @SYMTestStatus      Implemented
   778 @SYMTestActions
   779 @SYMTestExpectedResults Text drawn using CWindowGc should use the background colour of
   780 the window, and MWsGraphicsContext should use transparent white.
   781 */
   782 void CTGc::TestResetWithBackgroundColorL()
   783 	{
   784 	const TRect KSourceRect(0, 0, TestWin->Size().iWidth, TestWin->Size().iHeight);
   785 	const TRegionFix<1> KClippingRegion(KSourceRect);
   786 	
   787 	CWsScreenDevice* device = TheClient->iScreen;
   788 
   789 	CRemoteGc* remoteGc = CRemoteGc::NewL(device);
   790 	CleanupStack::PushL(remoteGc);
   791 	
   792 	//note this remote GC has not been activated on any window
   793 	remoteGc->BeginDraw(KSourceRect);
   794 
   795 	//Draw the commands in remote gc
   796 	remoteGc->SetBrushColor(KRgbGreen);  //nothing green is seen in this test
   797 
   798 	remoteGc->Reset(); //This resets the brush colour to the background colour of the window
   799 					   //where playback is, in the case of playing back to a window
   800 					   //however with a CFbsBitGc the color is transparent white, as there is no window.
   801 	remoteGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
   802 	remoteGc->SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha);
   803 	remoteGc->DrawRect(KSourceRect);
   804 	remoteGc->EndDraw();
   805 
   806 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA
   807 	CDirectGdiDriver* theDGdiDriver = CDirectGdiDriver::Static();
   808 	User::LeaveIfNull(theDGdiDriver);
   809 	
   810 	TSgImageInfo info;
   811 	info.iUsage = ESgUsageDirectGdiTarget | ESgUsageCompositionSource;
   812 	info.iSizeInPixels = TSize(TestWin->Size().iWidth, TestWin->Size().iHeight);
   813 	info.iPixelFormat = EUidPixelFormatXRGB_8888;//among display modes with alpha channel only pre-multiply alpha is supported in directGDI currently
   814 	
   815 	RSgImageCollection imageCollection;
   816 	CleanupClosePushL(imageCollection);
   817 	TInt res = imageCollection.Create(info, 1);
   818 	User::LeaveIfError(res);
   819 	RSgImage image;
   820 	CleanupClosePushL(image);
   821 	res = imageCollection.OpenImage(0, image);
   822 	User::LeaveIfError(res);
   823 	RDirectGdiImageTarget imageTarget(*theDGdiDriver);
   824 	CleanupClosePushL(imageTarget);
   825 	res = imageTarget.Create(image);
   826 	User::LeaveIfError(res);
   827 #endif
   828 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
   829 	//create a bitmap
   830 	CFbsBitmap *bitmap = new (ELeave) CFbsBitmap();
   831 	User::LeaveIfError(bitmap->Create(TSize(TestWin->Size().iWidth, TestWin->Size().iHeight), EColor16MA));
   832 	CleanupStack::PushL(bitmap);
   833 
   834 	CFbsBitmapDevice  *fbsDevice = CFbsBitmapDevice::NewL(bitmap);
   835 	CleanupStack::PushL(fbsDevice);
   836 #endif
   837 
   838 	//prepare the command buffer for playback
   839 	RWsGraphicMsgBuf msgBuf;
   840 	CleanupClosePushL(msgBuf);
   841 
   842 	//Externalize the captured commands from remote gc in to a buffer
   843 	remoteGc->ExternalizeL(msgBuf, ETrue);
   844 
   845 	CWSGraphicsRes* wsGrap = new (ELeave) CWSGraphicsRes();
   846 	CleanupStack::PushL(wsGrap);
   847 
   848 	CCommandBuffer* cmdBuf = CCommandBuffer::NewL();
   849 	CleanupStack::PushL(cmdBuf);
   850 	cmdBuf->InternalizeL(msgBuf.Pckg());
   851 
   852 	TRgb color;
   853 	TRgb testColor(KRgbWhite);
   854 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA
   855 	CDirectGdiGcWrapper* directGdiGcWrapper=CDirectGdiGcWrapper::NewL(imageTarget);
   856 	CleanupStack::PushL(directGdiGcWrapper);
   857 	cmdBuf->Play(TPoint(),&KClippingRegion,KSourceRect,*wsGrap,*directGdiGcWrapper);
   858 
   859 	//check that the background has been cleared to transparent white.
   860 	image.GetInfo(info);
   861 	info.iUsage = ESgUsageNone;
   862 	info.iCpuAccess = ESgCpuAccessReadOnly;
   863 	RSgImage image1;
   864 	CleanupClosePushL(image1);
   865 	res = image1.Create(info, image);
   866 	const TAny* data;
   867 	TInt stride = 0;
   868 	res = image1.MapReadOnly(data, stride);
   869 	User::LeaveIfError(res);
   870 	TPoint pixel(10,10);
   871 	TInt offset = pixel.iY * stride + pixel.iX * 4;
   872 	TAny* non_const_data = const_cast <TAny*> (data);
   873 	TUint8* pointData = static_cast <TUint8*> (non_const_data) + offset;
   874 	color = *(reinterpret_cast <TRgb*> (pointData));
   875 	image1.Unmap();
   876 #endif
   877 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
   878 	CFbsBitGc* fbsBitGc=NULL;
   879 	User::LeaveIfError(fbsDevice->CreateContext(fbsBitGc));
   880 	CleanupStack::PushL(fbsBitGc);
   881 	fbsBitGc->Activate(fbsDevice);
   882 	cmdBuf->Play(TPoint(0, 0), KSourceRect, *wsGrap, *fbsBitGc);
   883 	bitmap->GetPixel(color, TPoint(10,10));
   884 	testColor.SetAlpha(0);
   885 #endif
   886 	iStep->TEST(color==testColor);
   887 
   888 	//now test drawing to a window to ensure that the brush colour is
   889 	//the window background colour
   890 
   891 	//display a blue window
   892 	BaseWin->Win()->SetBackgroundColor(KRgbBlue);
   893 	BaseWin->Win()->Invalidate();
   894 	BaseWin->Win()->BeginRedraw();
   895 	TheGc->Activate(*BaseWin->Win());
   896 	TheGc->Clear();
   897 	TheGc->Deactivate();
   898 	BaseWin->Win()->EndRedraw();
   899 	TheClient->iWs.Finish();
   900 	TheClient->WaitForRedrawsToFinish();
   901 
   902 	//start drawing the display commands with a green background
   903 	
   904 	BaseWin->Win()->SetBackgroundColor(KRgbYellow);
   905 	BaseWin->Win()->Invalidate();
   906 	BaseWin->Win()->BeginRedraw();
   907 	TheGc->Activate(*BaseWin->Win());
   908 
   909 	//Play the commands on test window using command buffer
   910 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA
   911 	cmdBuf->Play(TPoint(0, 0), &KClippingRegion, KSourceRect, TheClient->iWs, *TheGc);
   912 #else
   913 	cmdBuf->Play(TPoint(0, 0), KSourceRect, *wsGrap, *TheGc);
   914 #endif
   915 
   916 	TheGc->Deactivate();
   917 	BaseWin->Win()->EndRedraw();
   918 	TheClient->iWs.Finish();
   919 	TheClient->WaitForRedrawsToFinish();
   920 
   921 	//check that the background has been cleared to yellow, using brush colour
   922 	TPoint position = BaseWin->Win()->InquireOffset(*TheClient->iGroup->WinTreeNode());
   923 	position.iX+=10;
   924 	position.iY+=10;
   925 	TheClient->iScreen->GetPixel(color, position);
   926 	iStep->TEST(color==KRgbYellow);
   927 
   928 	BaseWin->Win()->SetBackgroundColor(KRgbGreen); //set back to original backgroundcolor
   929 
   930 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA
   931 	CleanupStack::PopAndDestroy(9, remoteGc);
   932 #else
   933 	CleanupStack::PopAndDestroy(7, remoteGc);
   934 #endif
   935 	}
   936 
   937 /**
   938 @SYMTestCaseID		GRAPHICS-WSERV-0481
   939 @SYMPREQ            1841
   940 @SYMTestCaseDesc    Create font and graphics with various effect effects. Record the commands 
   941 (like setting colours,drawing text etc) using CRemoteGc and play the recorded commands on a window. Use the same
   942 commands in CWindowGc and draw text on a different window
   943 @SYMTestPriority    Medium
   944 @SYMTestStatus      Implemented
   945 @SYMTestActions
   946 @SYMTestExpectedResults Text/graphics drawn using CWindowGc and CRemoteGc should be same
   947 */
   948 void CTGc::TestCommandBufferL()
   949 	{	
   950 	CWsScreenDevice* device = TheClient->iScreen;
   951 
   952 	_LIT(KBuffText,"Command Buffer");
   953 	TFontSpec fSpec(KTestFontTypefaceName,23);
   954 	fSpec.iFontStyle.SetBitmapType(EAntiAliasedGlyphBitmap);
   955 	fSpec.iFontStyle.SetEffects(FontEffect::EDropShadow, ETrue);
   956 	fSpec.iFontStyle.SetEffects(FontEffect::EOutline, ETrue);
   957 	
   958 	CFont *font;
   959 	User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInPixels((CFont *&)font, fSpec));
   960 	CleanupStack::PushL(TCleanupItem(CleanUpFont, font));
   961 	
   962 	CRemoteGc* remoteGc = CRemoteGc::NewL(device);
   963 	CleanupStack::PushL(remoteGc);	
   964 
   965 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA
   966 	//-------create image---------
   967 	CDirectGdiDriver* theDGdiDriver = CDirectGdiDriver::Static();
   968 	User::LeaveIfNull(theDGdiDriver);
   969 	const TSize KImageSize = TSize(2, 2);
   970 	TSgImageInfo info;
   971 	info.iUsage = ESgUsageWindowGcSource;
   972 	info.iSizeInPixels = KImageSize;
   973 	info.iPixelFormat = EUidPixelFormatRGB_565;
   974 	info.iShareable = ETrue;
   975 	const TInt stride = KImageSize.iWidth * 2;
   976 	TUint8* buf = (TUint8*) (User::AllocL(KImageSize.iHeight * stride));
   977 	CleanupStack::PushL(buf);
   978 	TUint16* bufCur = ((TUint16*)buf);
   979 	*bufCur = KRgbRed.Color64K();
   980 	*(bufCur + 1) = KRgbRed.Color64K();
   981 	*(bufCur + 2) = KRgbRed.Color64K();
   982 	*(bufCur + 3) = KRgbRed.Color64K();
   983 
   984 	RSgImage image;
   985 	TInt res = image.Create(info, buf, stride);
   986 	User::LeaveIfError(res);
   987 	CleanupClosePushL(image);	
   988 	RWsDrawableSource drawableSource(TheClient->iWs);
   989 	res = drawableSource.Create(image, TheClient->iScreen->GetScreenNumber());
   990 	if(res == KErrNotSupported)
   991 		{
   992 		INFO_PRINTF1(_L("The current screen is not supports drawable source. This test case terminates now."));
   993 		CleanupStack::PopAndDestroy(3, remoteGc);
   994 		CleanupStack::Pop();//font
   995 		TheClient->iScreen->ReleaseFont(font);
   996 		return;
   997 		}
   998 	User::LeaveIfError(res);
   999 	CleanupClosePushL(drawableSource);	
  1000 	//-------end create image---------
  1001 #endif	
  1002 	remoteGc->ResetCommandBuffer();
  1003 	remoteGc->BeginDraw(TRect(0, 0, TestWin->Size().iWidth, TestWin->Size().iHeight));
  1004 	//Capturing the commands in remote gc
  1005 	remoteGc->Clear();
  1006 	remoteGc->DrawRect(TRect(10,10,30,30));
  1007 	remoteGc->Clear(TRect(10,10,11,11));
  1008 	remoteGc->CopyRect(TPoint(5,5), TRect(25,25,30,30));
  1009 	CFbsBitmap* bitmap = new (ELeave) CFbsBitmap;
  1010 	CFbsBitmap* bitmapMask = new (ELeave) CFbsBitmap;
  1011 	User::LeaveIfError(bitmap->Load(_L("Z:\\WSTEST\\WSAUTOTEST.MBM"), EMbmWsautotestCircles24b));
  1012 	User::LeaveIfError(bitmapMask->Load(_L("Z:\\WSTEST\\WSAUTOTEST.MBM"), EMbmWsautotestCircles_mask2b));
  1013 	remoteGc->BitBlt(TPoint(100,100), bitmap);
  1014 	remoteGc->BitBlt(TPoint(0,0), bitmap, TRect(0,0,1,1));	
  1015 	remoteGc->BitBltMasked(TPoint(0,5), bitmap, TRect(0,0,1,1), bitmapMask, EFalse);
  1016 	CWsBitmap* bitmapWs = new (ELeave) CWsBitmap(TheClient->iWs);
  1017 	CWsBitmap* bitmapWsMask = new (ELeave) CWsBitmap(TheClient->iWs);
  1018 	User::LeaveIfError(bitmapWs->Load(_L("Z:\\WSTEST\\TEST.MBM"), 0));
  1019 	remoteGc->BitBlt(TPoint(110,110), bitmapWs);
  1020 	remoteGc->BitBlt(TPoint(5,0), bitmapWs, TRect(0,0,1,1));
  1021 	remoteGc->BitBltMasked(TPoint(10,0), bitmap, TRect(0,0,1,1), bitmapWsMask, EFalse);
  1022 	remoteGc->SetFadingParameters(128,128);
  1023 	remoteGc->SetFaded(EFalse);	
  1024 	remoteGc->AlphaBlendBitmaps(TPoint(2,2), bitmap, TRect(0,0,1,1), bitmapMask, TPoint(2,2));
  1025 	remoteGc->AlphaBlendBitmaps(TPoint(3,3), bitmapWs, TRect(0,0,1,1), bitmapWsMask, TPoint(2,2));
  1026 	remoteGc->SetOrigin(TPoint(0,30));
  1027 	remoteGc->SetDrawMode(CGraphicsContext::EDrawModePEN);
  1028 	remoteGc->SetClippingRect(TRect(0,0,10,10));
  1029 	remoteGc->SetPenStyle(CGraphicsContext::ESolidPen);
  1030 	remoteGc->SetPenSize(TSize(1,2));
  1031 	remoteGc->UseBrushPattern(bitmap);
  1032 	remoteGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1033 	remoteGc->SetBrushOrigin(TPoint(0,0));
  1034 	remoteGc->DrawPie(TRect(0,0,15,15),TPoint(0,8),TPoint(15,8));
  1035 	remoteGc->CancelClippingRect();
  1036 	remoteGc->DiscardBrushPattern();
  1037 	remoteGc->CancelClippingRegion();
  1038 	remoteGc->Reset();
  1039 	remoteGc->SetOrigin(TPoint(0,0));
  1040 	remoteGc->SetUnderlineStyle(EUnderlineOff);
  1041 	remoteGc->SetStrikethroughStyle(EStrikethroughOff);
  1042 	remoteGc->SetWordJustification(1,2);
  1043 	remoteGc->SetCharJustification(1,2);
  1044 	remoteGc->UseFont(font);
  1045 	remoteGc->DrawText(KBuffText,TRect(50,0,100,50),10,CGraphicsContext::ELeft,0);
  1046 	remoteGc->DrawTextVertical(KBuffText,TPoint(170,20),EFalse);
  1047 	remoteGc->DrawTextVertical(KBuffText,TRect(120,20,150,100),5,EFalse,CGraphicsContext::ELeft,0);	
  1048 	remoteGc->MoveTo(TPoint(25,150));
  1049 	remoteGc->MoveBy(TPoint(5,5));
  1050 	remoteGc->DrawLineTo(TPoint(35,160));
  1051 	remoteGc->DrawLine(TPoint(35,160),TPoint(25,150));
  1052 	remoteGc->DrawLineBy(TPoint(15,6));	
  1053 	remoteGc->Plot(TPoint(5,5));	
  1054 	remoteGc->DrawArc(TRect(0,80,10,90),TPoint(0,85),TPoint(10,85));
  1055 	remoteGc->DrawEllipse(TRect(0,90,10,100));	
  1056 	remoteGc->DrawRoundRect(TRect(30,80,50,100),TSize(5,5));	
  1057 	remoteGc->DrawBitmap(TPoint(150,150),bitmap);	
  1058 	remoteGc->DrawBitmap(TRect(160,160,170,170), bitmap);	
  1059 	remoteGc->DrawBitmap(TRect(175,175,180,180), bitmap, TRect(0,5,5,10));	
  1060 	remoteGc->DrawBitmapMasked(TRect(185,185,190,190), bitmap, TRect(0,50,5,55),bitmapMask,EFalse);
  1061 	remoteGc->DrawBitmapMasked(TRect(195,195,200,200), bitmapWs, TRect(0,50,5,55),bitmapWsMask,EFalse);		
  1062 	CArrayFixFlat<TPoint>* polyPoints = new(ELeave) CArrayFixFlat<TPoint>(3); //CArrayFixFlat
  1063 	CleanupStack::PushL(polyPoints);
  1064 	TRect rect (200,0,200,100);
  1065 	polyPoints->AppendL(rect.iTl);
  1066 	polyPoints->AppendL(rect.Center());
  1067 	polyPoints->AppendL(TPoint(rect.iBr.iX, rect.iTl.iY));	
  1068 	remoteGc->DrawPolyLine(polyPoints);
  1069 	remoteGc->DrawPolyLine(&polyPoints->At(0), 3);
  1070 	remoteGc->DrawPolygon(polyPoints, CGraphicsContext::EWinding);
  1071 	remoteGc->DrawPolygon(&polyPoints->At(0), 3, CGraphicsContext::EAlternate);
  1072 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA
  1073 	MWsDrawResource* dr = static_cast<MWsDrawResource*>(remoteGc->Interface(KMWsDrawResourceInterfaceUid));
  1074 	if(dr)
  1075 		dr->DrawResource(TPoint(30, 40), drawableSource);
  1076 #endif
  1077 	RRegion region;
  1078 	remoteGc->SetClippingRegion(region);
  1079 	remoteGc->DiscardFont();
  1080 	remoteGc->EndDraw();
  1081 
  1082 	RWsGraphicMsgBuf msgBuf;
  1083 	CleanupClosePushL(msgBuf);
  1084 	//Externalize the captured commands from remote gc in to a buffer
  1085 	remoteGc->ExternalizeL(msgBuf, EFalse);
  1086 	
  1087 	CCommandBuffer* cmdBuf = CCommandBuffer::NewL();
  1088 	CleanupStack::PushL(cmdBuf);
  1089 	const CCommandBuffer* testCmdBuf = CCommandBuffer::NewL();
  1090 	if(cmdBuf->IsIdentical(*testCmdBuf)==EFalse)
  1091 		{
  1092 		User::Panic(_L("TestCommandBufferL"), KErrGeneral);
  1093 		}
  1094 	delete testCmdBuf;
  1095 	//Internalize the buffer with captured commands (from CRemoteGC) 
  1096 	//in to CCommandBuffer
  1097 	cmdBuf->InternalizeL(msgBuf.Pckg());
  1098 	
  1099 	TheGc->Activate(*TestWin->Win());
  1100 	TestWin->Win()->Invalidate();
  1101 	
  1102 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
  1103 	/*
  1104 	 * Make sure anything that can leave is done outside the
  1105 	 * BeginRedraw/EndRedraw bracket.
  1106 	 */
  1107 	CWSGraphicsRes* wsGrap=new(ELeave) CWSGraphicsRes();
  1108 	CleanupStack::PushL(wsGrap);
  1109 #endif
  1110 	/*
  1111 	 * Note we need to still do BeginRedraw/EndRedraw for the TestWin Window
  1112 	 * even though the CRemoteGc we are going to Play into TestWin already has
  1113 	 * BeginRedraw/EndRedraw commands issued into it.  Those commands just allow
  1114 	 * for replacement of draw ops already in the CRemoteGc to be replaced by
  1115 	 * new draw ops covering the same area.  The BeginRedraw/EndRedraws never 
  1116 	 * get Play()'ed into TestWin.
  1117 	 */
  1118 	TestWin->Win()->BeginRedraw();
  1119 	TheGc->Clear();
  1120 	//Play the commands on test window using command buffer
  1121 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA
  1122 	cmdBuf->Play(TPoint(), NULL, TRect(TestWin->Size()), TheClient->iWs, *TheGc);
  1123 #endif
  1124 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
  1125 	cmdBuf->Play(TPoint(),TRect(TestWin->Size()),*wsGrap,*TheGc);
  1126 	CleanupStack::PopAndDestroy(wsGrap);
  1127 #endif
  1128 	TheGc->Deactivate();
  1129 	TestWin->Win()->EndRedraw();
  1130 	remoteGc->ResetCommandBuffer();
  1131 	BaseWin->Win()->Invalidate();
  1132 	BaseWin->Win()->BeginRedraw();
  1133 	TheGc->Activate(*BaseWin->Win());
  1134 	TheGc->Clear();
  1135 	TheGc->DrawRect(TRect(10,10,30,30));
  1136 	TheGc->Clear(TRect(10,10,11,11));
  1137 	TheGc->CopyRect(TPoint(5,5), TRect(25,25,30,30));
  1138 	TheGc->BitBlt(TPoint(100,100), bitmap);
  1139 	TheGc->BitBlt(TPoint(0,0), bitmap, TRect(0,0,1,1));	
  1140 	TheGc->BitBltMasked(TPoint(0,5), bitmap, TRect(0,0,1,1), bitmapMask, EFalse);
  1141 	TheGc->BitBlt(TPoint(110,110), bitmapWs);
  1142 	TheGc->BitBlt(TPoint(5,0), bitmapWs, TRect(0,0,1,1));
  1143 	TheGc->BitBltMasked(TPoint(10,0), bitmap, TRect(0,0,1,1), bitmapWsMask, EFalse);
  1144 	TheGc->SetFadingParameters(128,128);
  1145 	TheGc->SetFaded(EFalse);	
  1146 	TheGc->AlphaBlendBitmaps(TPoint(2,2), bitmap, TRect(0,0,1,1), bitmapMask, TPoint(2,2));
  1147 	TheGc->AlphaBlendBitmaps(TPoint(3,3), bitmapWs, TRect(0,0,1,1), bitmapWsMask, TPoint(2,2));
  1148 	TheGc->SetOrigin(TPoint(0,30));
  1149 	TheGc->SetDrawMode(CGraphicsContext::EDrawModePEN);
  1150 	TheGc->SetClippingRect(TRect(0,0,10,10));
  1151 	TheGc->SetPenStyle(CGraphicsContext::ESolidPen);
  1152 	TheGc->SetPenSize(TSize(1,2));
  1153 	TheGc->UseBrushPattern(bitmap);
  1154 	TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1155 	TheGc->SetBrushOrigin(TPoint(0,0));
  1156 	TheGc->DrawPie(TRect(0,0,15,15),TPoint(0,8),TPoint(15,8));
  1157 	TheGc->CancelClippingRect();
  1158 	TheGc->DiscardBrushPattern();
  1159 	TheGc->CancelClippingRegion();
  1160 	TheGc->Reset();
  1161 	TheGc->SetOrigin(TPoint(0,0));
  1162 	TheGc->SetUnderlineStyle(EUnderlineOff);
  1163 	TheGc->SetStrikethroughStyle(EStrikethroughOff);
  1164 	TheGc->SetWordJustification(1,2);
  1165 	TheGc->SetCharJustification(1,2);
  1166 	TheGc->UseFont(font);
  1167 	TheGc->DrawText(KBuffText,TRect(50,0,100,50),10,CGraphicsContext::ELeft,0);
  1168 	TheGc->DrawTextVertical(KBuffText,TPoint(170,20),EFalse);
  1169 	TheGc->DrawTextVertical(KBuffText,TRect(120,20,150,100),5,EFalse,CGraphicsContext::ELeft,0);	
  1170 	TheGc->MoveTo(TPoint(25,150));
  1171 	TheGc->MoveBy(TPoint(5,5));
  1172 	TheGc->DrawLineTo(TPoint(35,160));
  1173 	TheGc->DrawLine(TPoint(35,160),TPoint(25,150));
  1174 	TheGc->DrawLineBy(TPoint(15,6));	
  1175 	TheGc->Plot(TPoint(5,5));	
  1176 	TheGc->DrawArc(TRect(0,80,10,90),TPoint(0,85),TPoint(10,85));
  1177 	TheGc->DrawEllipse(TRect(0,90,10,100));	
  1178 	TheGc->DrawRoundRect(TRect(30,80,50,100),TSize(5,5));	
  1179 	TheGc->DrawBitmap(TPoint(150,150),bitmap);	
  1180 	TheGc->DrawBitmap(TRect(160,160,170,170), bitmap);	
  1181 	TheGc->DrawBitmap(TRect(175,175,180,180), bitmap, TRect(0,5,5,10));	
  1182 	TheGc->DrawBitmapMasked(TRect(185,185,190,190), bitmap, TRect(0,50,5,55),bitmapMask,EFalse);
  1183 	TheGc->DrawBitmapMasked(TRect(195,195,200,200), bitmapWs, TRect(0,50,5,55),bitmapWsMask,EFalse);
  1184 	TheGc->DrawPolyLine(polyPoints);
  1185 	TheGc->DrawPolyLine(&polyPoints->At(0), 3);
  1186 	TheGc->DrawPolygon(polyPoints, CGraphicsContext::EWinding);
  1187 	TheGc->DrawPolygon(&polyPoints->At(0), 3, CGraphicsContext::EAlternate);
  1188 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA
  1189 	TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1190 	TheGc->SetBrushColor(KRgbRed);
  1191 	TheGc->SetPenColor(KRgbRed);
  1192 	TheGc->DrawRect(TRect(30, 40, 32, 42));
  1193 #endif
  1194 	TheGc->DiscardFont();
  1195 	TheGc->Deactivate();
  1196 	BaseWin->Win()->EndRedraw();
  1197 	TheClient->Flush();
  1198 	TheClient->WaitForRedrawsToFinish();
  1199 
  1200 	//Check the text drawn on base and test windows.
  1201 	TBool err = CheckRect(BaseWin, TestWin, TRect(0, 0, BaseWin->Size().iWidth, BaseWin->Size().iHeight), _L("CTGc::TestCommandBufferL()"));
  1202 	if (err)
  1203 	    {
  1204 	    INFO_PRINTF1(_L("The CheckRect function returned error."));
  1205 	    }
  1206 	delete bitmap;
  1207 	INFO_PRINTF1(_L("bitmap deleted."));
  1208 	delete bitmapMask;
  1209 	INFO_PRINTF1(_L("bitmapMask deleted."));
  1210 	delete bitmapWs;
  1211 	INFO_PRINTF1(_L("bitmapWs deleted."));
  1212 	delete bitmapWsMask;
  1213 	INFO_PRINTF1(_L("bitmapWsMask deleted."));
  1214 	
  1215 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA
  1216 	CleanupStack::PopAndDestroy(7, remoteGc);
  1217 #else
  1218 	CleanupStack::PopAndDestroy(4, remoteGc);
  1219 #endif	
  1220 	CleanupStack::Pop();//font
  1221 	INFO_PRINTF1(_L("CleanupStack popped."));
  1222 	TheClient->iScreen->ReleaseFont(font);
  1223 	}
  1224 
  1225 /**
  1226 @SYMTestCaseID		GRAPHICS-WSERV-0482
  1227 @SYMPREQ            1841
  1228 @SYMTestCaseDesc    Play empty command buffer.
  1229 @SYMTestPriority    Medium
  1230 @SYMTestStatus      Implemented
  1231 @SYMTestActions
  1232 @SYMTestExpectedResults return KErrEof error
  1233 */
  1234 void CTGc::TestEmptyCommandBufferL()
  1235 	{
  1236 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
  1237 	CWSGraphicsRes* wsGrap = new (ELeave) CWSGraphicsRes();
  1238 	CleanupStack::PushL(wsGrap);
  1239 #endif
  1240 
  1241 	CCommandBuffer* cmdBuf = CCommandBuffer::NewL();
  1242 	CleanupStack::PushL(cmdBuf);
  1243 
  1244 	TheGc->Activate(*TestWin->Win());
  1245 	TheGc->Clear();
  1246 	//Play the commands on test window using command buffer
  1247 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
  1248 	TInt err = cmdBuf->Play(TPoint(),TRect(TestWin->Size()),*wsGrap,*TheGc);
  1249 #else
  1250 	TInt err = cmdBuf->Play(TPoint(),NULL,TRect(TestWin->Size()),TheClient->iWs,*TheGc);
  1251 #endif
  1252 	if(err!=KErrEof)
  1253 		{
  1254 		User::Panic(_L("TestEmptyCommandBufferL"), KErrGeneral);
  1255 		}
  1256 	TheGc->Deactivate();
  1257 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
  1258 	CleanupStack::PopAndDestroy(2, wsGrap); //cmdBuf, wsGrap, msgBuf and remoteGc
  1259 #else
  1260 	CleanupStack::PopAndDestroy(cmdBuf);
  1261 #endif
  1262 	}
  1263 
  1264 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA
  1265 /**
  1266 @SYMTestCaseID		GRAPHICS-WSERV-0486
  1267 @SYMPREQ            PREQ2095
  1268 @SYMTestCaseDesc    Draw text using CWindowGc and CRemoteGc with both outline and shadow
  1269 effect on.
  1270 @SYMTestPriority    High
  1271 @SYMTestStatus      Implemented
  1272 @SYMTestActions     Create a font with both outline and shadow effects, also use ClippingRect 
  1273 and ClippingRegion. Record the commands using CRemoteGc and play the recorded commands on a 
  1274 bitmap using MWsGraphicsContext. Use the same commands in CWindowGc and draw text on a 
  1275 different window
  1276 @SYMTestExpectedResults Text drawn using CWindowGc and CRemoteGc(MWsGraphicsContext) should be same
  1277 */
  1278 void CTGc::TestCRemoteGcAndMWsGraphicsContextClippingRectL()
  1279 	{
  1280 	const TRect KTestRect(0, 0, TestWin->Size().iWidth, TestWin->Size().iHeight);
  1281 	const TRegionFix<1> KTestRegion(KTestRect);
  1282 	const TRect KClippingRect1(5, 5, TestWin->Size().iWidth-10, 90);
  1283 	const TRegionFix<1> KClippingRegion(KClippingRect1);
  1284 	const TRect KClippingRect2(15, 15, TestWin->Size().iWidth-10, TestWin->Size().iHeight-10);
  1285 	
  1286 	CWsScreenDevice* device = TheClient->iScreen;
  1287 	/*
  1288 	 * On hardware, the first screen runs in 64K colors, but the second screen (TV OUT)
  1289 	 * cannot run in this mode, it instead falls back to 16M colors.  We need to ensure
  1290 	 * that we use matching color depths for our off-screen bitmaps so that accuracy is
  1291 	 * not lost since we compare bitmaps from the screen versus off-screen.
  1292 	 */
  1293 	TDisplayMode displayMode = device->DisplayMode();
  1294 	if (TDisplayModeUtils::NumDisplayModeBitsPerPixel(displayMode) == 32)
  1295 	    {
  1296 	    displayMode = EColor16MAP;
  1297 	    }
  1298 		
  1299 	_LIT(KText,"RemoteGc & MWsGraphicsContext");
  1300 	TFontSpec fSpec(KTestFontTypefaceName,23);
  1301 	fSpec.iFontStyle.SetBitmapType(EAntiAliasedGlyphBitmap);
  1302 	fSpec.iFontStyle.SetEffects(FontEffect::EDropShadow, ETrue);
  1303 	fSpec.iFontStyle.SetEffects(FontEffect::EOutline, ETrue);
  1304 	
  1305 	CFont *font;
  1306 	User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInPixels((CFont *&)font, fSpec));
  1307 	CleanupStack::PushL(TCleanupItem(CleanUpFont, font));
  1308 
  1309 	//Record the commands using CRemoteGc
  1310 	CRemoteGc* remoteGc = CRemoteGc::NewL(device);
  1311 	CleanupStack::PushL(remoteGc);
  1312 	remoteGc->BeginDraw(KTestRect);
  1313 	//fill background with white
  1314 	remoteGc->SetPenStyle(CFbsBitGc::ENullPen);
  1315 	remoteGc->SetBrushStyle(CFbsBitGc::ESolidBrush);
  1316 	remoteGc->SetBrushColor(KRgbWhite);
  1317 	remoteGc->DrawRect(TRect(TPoint(0,0), TestWin->Size()));
  1318 	remoteGc->SetPenStyle(CFbsBitGc::ESolidPen);
  1319 	//Capturing the commands in remote gc
  1320 	remoteGc->SetClippingRect(KClippingRect2);
  1321 	remoteGc->SetClippingRegion(KClippingRegion);
  1322 	remoteGc->SetBrushStyle(CFbsBitGc::ESolidBrush);
  1323 	remoteGc->SetBrushColor(TRgb(0,150,150));
  1324 	remoteGc->DrawRect(TRect(TPoint(0,0), TSize(160,60)));
  1325 	remoteGc->SetBrushColor(TRgb(150,100,150));
  1326 	remoteGc->DrawRect(TRect(TPoint(0,60), TSize(160,60)));
  1327 	remoteGc->SetBrushColor(KRgbGreen);
  1328 	remoteGc->SetShadowColor(KRgbDarkRed);
  1329 	remoteGc->SetPenColor(KRgbBlack);
  1330 	remoteGc->UseFont(font);
  1331 	remoteGc->DrawText(KText, TPoint(2,40));
  1332 	remoteGc->DiscardFont();
  1333 	remoteGc->EndDraw();
  1334 
  1335 	RWsGraphicMsgBuf msgBuf;
  1336 	CleanupClosePushL(msgBuf);
  1337 	//Externalize the captured commands from remote gc in to a buffer
  1338 	remoteGc->ExternalizeL(msgBuf, ETrue);
  1339 	
  1340 	CCommandBuffer* cmdBuf = CCommandBuffer::NewL();
  1341 	CleanupStack::PushL(cmdBuf);
  1342 	//Internalize the buffer with captured commands (from CRemoteGC) 
  1343 	//in to CCommandBuffer
  1344 	cmdBuf->InternalizeL(msgBuf.Pckg());
  1345 	
  1346 	CDirectGdiDriver* theDGdiDriver = CDirectGdiDriver::Static();
  1347 	User::LeaveIfNull(theDGdiDriver);
  1348 	
  1349 	TSgImageInfo info;
  1350 	info.iUsage = ESgUsageDirectGdiTarget | ESgUsageDirectGdiSource | ESgUsageCompositionSource;
  1351 	info.iSizeInPixels = TestWin->Size();
  1352 	info.iPixelFormat = PixelFormatFromDisplayMode(displayMode);
  1353 	
  1354 	RSgImageCollection imageCollection;
  1355 	CleanupClosePushL(imageCollection);
  1356 	TInt res = imageCollection.Create(info, 1);
  1357 	User::LeaveIfError(res);
  1358 	RSgImage image;
  1359 	CleanupClosePushL(image);
  1360 	res = imageCollection.OpenImage(0, image);
  1361 	User::LeaveIfError(res);
  1362 	RDirectGdiImageTarget imageTarget(*theDGdiDriver);
  1363 	CleanupClosePushL(imageTarget);
  1364 	
  1365 	res = imageTarget.Create(image);
  1366 	User::LeaveIfError(res);
  1367 	
  1368 	CDirectGdiGcWrapper* directGdiGcWrapper = CDirectGdiGcWrapper::NewL(imageTarget);
  1369 	CleanupStack::PushL(directGdiGcWrapper);
  1370 	
  1371 	//Dummy class created
  1372 	CWSGraphicsRes* wsGrap = new (ELeave) CWSGraphicsRes();
  1373 	CleanupStack::PushL(wsGrap);
  1374 
  1375 	//Play the commands on test window using command buffer
  1376 	cmdBuf->Play(TPoint(),&KTestRegion,KTestRect,*wsGrap,*directGdiGcWrapper);
  1377 
  1378 	//Set window back to same as test bitmap background
  1379 	BaseWin->Win()->SetBackgroundColor(KRgbWhite);
  1380 
  1381 	BaseWin->Win()->Invalidate();
  1382 	BaseWin->Win()->BeginRedraw();
  1383 	TheGc->Activate(*BaseWin->Win());
  1384 	TheGc->Clear();
  1385 	TheGc->SetClippingRect(KClippingRect2);
  1386 	TheGc->SetClippingRegion(KClippingRegion);
  1387 	TheGc->SetBrushStyle(CFbsBitGc::ESolidBrush);
  1388 	TheGc->SetBrushColor(TRgb(0,150,150));
  1389 	TheGc->DrawRect(TRect(TPoint(0,0), TSize(160,60)));
  1390 	TheGc->SetBrushColor(TRgb(150,100,150));
  1391 	TheGc->DrawRect(TRect(TPoint(0,60), TSize(160,60)));
  1392 	TheGc->SetBrushColor(KRgbGreen);
  1393 	TheGc->SetShadowColor(KRgbDarkRed);
  1394 	TheGc->SetPenColor(KRgbBlack);
  1395 	TheGc->UseFont(font);
  1396 	//Draw the text on base window using CWindowGC
  1397 	TheGc->DrawText(KText, TPoint(2, 40));
  1398 	TheGc->DiscardFont();
  1399 	TheGc->Deactivate();
  1400 	BaseWin->Win()->EndRedraw();
  1401 	TheClient->iWs.Finish();
  1402 	TheClient->WaitForRedrawsToFinish();
  1403 
  1404 	//Create a bitmap and then copy the screen to it
  1405 	TRect rc(TRect(BaseWin->Win()->AbsPosition(), BaseWin->Win()->Size()));
  1406 	CFbsBitmap *screenBitmap = new (ELeave) CFbsBitmap();
  1407 	User::LeaveIfError(screenBitmap->Create(rc.Size(), displayMode));
  1408 	CleanupStack::PushL(screenBitmap);
  1409 	TheClient->iScreen->CopyScreenToBitmap(screenBitmap, rc);
  1410 
  1411 	CFbsBitmap* bitmap = new (ELeave) CFbsBitmap;
  1412 	CleanupStack::PushL(bitmap);
  1413 
  1414 	image.GetInfo(info);
  1415 	bitmap->Create(info.iSizeInPixels, displayMode);
  1416 	TRect rect(info.iSizeInPixels);
  1417 	CopyImageToBitmapL(bitmap, image, rect);
  1418 
  1419 	//Test to see if the bitmap drawn to using CRemoteGc is the same as the screen copy bitmap
  1420 	TInt differentPixels = 0;
  1421 	res = LossyCompareBitmapRecord(*bitmap, *screenBitmap, KTestRect, EFalse, differentPixels, Logger());
  1422 	if (differentPixels != 0)
  1423 		{
  1424 		INFO_PRINTF2(_L(" Pixels different %d"), differentPixels);
  1425 		}
  1426 	TEST(res);
  1427 	CleanupStack::PopAndDestroy(10, remoteGc); //screenBitmap, imageCollection, image, imageTarget, directGdiGcWrapper, cmdBuf, wsGrap, msgBuf, remoteGc, bitmap
  1428 	CleanupStack::Pop();//font
  1429 	TheClient->iScreen->ReleaseFont(font);
  1430 	}
  1431 
  1432 /**
  1433 @SYMTestCaseID		GRAPHICS-WSERV-0487
  1434 @SYMPREQ            PREQ2095
  1435 @SYMTestCaseDesc    Draw text using CRemoteGc and DrawText(const TDesC&,const TTextParameters*,const TPoint&)
  1436 @SYMTestPriority    High
  1437 @SYMTestStatus      Implemented
  1438 @SYMTestActions     Create a font.  Draw text to a bitmap with the font using CFbsBitGc::DrawText. Draw text with the font using CFbsBitGc::DrawText.
  1439 Record the same DrawText commands using CRemoteGc and play the recorded commands on a 
  1440 bitmap using MWsGraphicsContext. Compare the two bitmaps.
  1441 @SYMTestExpectedResults Text drawn using CFbsBitGc and CRemoteGc(MWsGraphicsContext) should be the same
  1442 */
  1443 void CTGc::TestCRemoteGcDrawTextInContextPointL()
  1444 	{
  1445 	CDrawTextInContextTestPoint* test = CDrawTextInContextTestPoint::NewL();
  1446 	CleanupStack::PushL(test);
  1447 	test->Test();
  1448 	TEST(test->HasPassedTest());
  1449 	CleanupStack::PopAndDestroy(); //test
  1450 	}
  1451 
  1452 /**
  1453 @SYMTestCaseID		GRAPHICS-WSERV-0488
  1454 @SYMPREQ            PREQ2095
  1455 @SYMTestCaseDesc    Draw text using CRemoteGc and DrawText(const TDesC&,const TTextParameters*,const TRect&,TInt,TTextAlign,TInt)
  1456 @SYMTestPriority    High
  1457 @SYMTestStatus      Implemented
  1458 @SYMTestActions     Create a font.  Draw text to a bitmap with the font using CFbsBitGc::DrawText. Draw text with the font using CFbsBitGc::DrawText.
  1459 Record the same DrawText commands using CRemoteGc and play the recorded commands on a 
  1460 bitmap using MWsGraphicsContext. Compare the two bitmaps.
  1461 @SYMTestExpectedResults Text drawn using CFbsBitGc and CRemoteGc(MWsGraphicsContext) should be the same
  1462 */
  1463 void CTGc::TestCRemoteGcDrawTextInContextBoxL()
  1464 	{
  1465 	CDrawTextInContextTestBox* test = CDrawTextInContextTestBox::NewL();
  1466 	CleanupStack::PushL(test);
  1467 	test->Test();
  1468 	TEST(test->HasPassedTest());
  1469 	CleanupStack::PopAndDestroy(); //test
  1470 	}
  1471 
  1472 /**
  1473 @SYMTestCaseID		GRAPHICS-WSERV-0489
  1474 @SYMPREQ            PREQ2095
  1475 @SYMTestCaseDesc    Draw text using CRemoteGc and DrawTextVertical(const TDesC&,const TTextParameters*,const TPoint&)
  1476 @SYMTestPriority    High
  1477 @SYMTestStatus      Implemented
  1478 @SYMTestActions     Create a font.  Draw text to a bitmap with the font using CFbsBitGc::DrawTextVertical. Draw text with the font using CFbsBitGc::DrawText.
  1479 Record the same DrawText commands using CRemoteGc and play the recorded commands on a 
  1480 bitmap using MWsGraphicsContext. Compare the two bitmaps.
  1481 @SYMTestExpectedResults Text drawn using CFbsBitGc and CRemoteGc(MWsGraphicsContext) should be the same
  1482 */
  1483 void CTGc::TestCRemoteGcDrawTextInContextPointVerticalL()
  1484 	{
  1485 	CDrawTextInContextTestPointVertical* test = CDrawTextInContextTestPointVertical::NewL();
  1486 	CleanupStack::PushL(test);
  1487 	test->Test();
  1488 	TEST(test->HasPassedTest());
  1489 	CleanupStack::PopAndDestroy(); //test
  1490 	}
  1491 
  1492 /**
  1493 @SYMTestCaseID		GRAPHICS-WSERV-0490
  1494 @SYMPREQ            PREQ2095
  1495 @SYMTestCaseDesc    Draw text using CRemoteGc and DrawTextVertical(const TDesC&,const TTextParameters*,const TRect&,TInt,TTextAlign,TInt)
  1496 @SYMTestPriority    High
  1497 @SYMTestStatus      Implemented
  1498 @SYMTestActions     Create a font.  Draw text to a bitmap with the font using CFbsBitGc::DrawTextVertical. Draw text with the font using CFbsBitGc::DrawText.
  1499 Record the same DrawText commands using CRemoteGc and play the recorded commands on a 
  1500 bitmap using MWsGraphicsContext. Compare the two bitmaps.
  1501 @SYMTestExpectedResults Text drawn using CFbsBitGc and CRemoteGc(MWsGraphicsContext) should be the same
  1502 */
  1503 void CTGc::TestCRemoteGcDrawTextInContextBoxVerticalL()
  1504 	{
  1505 	CDrawTextInContextTestBoxVertical* test = CDrawTextInContextTestBoxVertical::NewL();
  1506 	CleanupStack::PushL(test);
  1507 	test->Test();
  1508 	TEST(test->HasPassedTest());
  1509 	CleanupStack::PopAndDestroy(); //test
  1510 	}
  1511 #endif //TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA
  1512 
  1513 /**
  1514 @SYMTestCaseID		GRAPHICS-WSERV-0494
  1515 @SYMDEF				DEF131255
  1516 @SYMTestCaseDesc    Negative test to show that using SetBrushStyle() will not panic WServ with different
  1517 					brush bitmaps.
  1518 @SYMTestPriority    High
  1519 @SYMTestStatus      Implemented
  1520 @SYMTestActions		Four seperate panic situations are tested:
  1521 					1)
  1522                     Create a regular CFbsBitmap, set as brush pattern, and set brush style to EPatternedBrush.
  1523                     Draw a line to force the playback to occur.
  1524                     Call Finish on the GC.
  1525                     Destroy the brush bitmap.
  1526                     2)
  1527                     Create a regular CFbsBitmap, set as brush pattern, and set brush style to EPatternedBrush.
  1528                     Draw a line to force the playback to occur.
  1529                     Destroy the brush bitmap. 
  1530                     Call Finish on the GC.
  1531                     3+4)
  1532                     Create an extended bitmap, set as the brush pattern, and set the brush style to EPatternedBrush.
  1533                     Draw a line to force the playback to occur.
  1534                     Set the brush bitmap and style again.
  1535                     Call Finish on the GC.
  1536                     Destroy the brush bitmap. 
  1537 @SYMTestExpectedResults The calls to SetBrushStyle() should not cause WServ to panic when Finish() is called.
  1538 */
  1539 void CTGc::TestGcSetBrushPatternL()
  1540 	{
  1541 	// Extended bitmap test data.
  1542 	const TUint8 KTestData[] = "TEST DATA";
  1543 	const TInt KTestDataSize = sizeof(KTestData);
  1544 	const TUid KTestExtendedBitmapUid = TUid::Uid(0xFFFFFFFF);
  1545 	
  1546 	// First try using a regular bitmap as the brush pattern.
  1547 	BaseWin->Win()->Invalidate();
  1548 	BaseWin->Win()->BeginRedraw();
  1549 	TheGc->Activate(*BaseWin->Win());	
  1550 	CFbsBitmap* bitmapRegular = new (ELeave) CFbsBitmap;
  1551 	CleanupStack::PushL(bitmapRegular);
  1552 	TInt res = bitmapRegular->Create(TSize(10,10), EColor64K);
  1553 	TEST(res == KErrNone);
  1554 	//Record the commands using CWindowGc.
  1555 	TheGc->UseBrushPattern(bitmapRegular);
  1556 	TheGc->SetBrushStyle(CGraphicsContext::EPatternedBrush);
  1557 	// DrawLine() is only used here to force playback of the commands.
  1558 	TheGc->DrawLine(TPoint(0,0), TPoint(1,1));	
  1559 	TheGc->Deactivate();
  1560 	BaseWin->Win()->EndRedraw();
  1561 	TheClient->iWs.Finish();
  1562 	CleanupStack::PopAndDestroy(1, bitmapRegular);
  1563 	
  1564 	// Secondly, try using a regular bitmap as the brush pattern, but deleting the bitmap
  1565 	// before calling Finish().
  1566 	BaseWin->Win()->Invalidate();
  1567 	BaseWin->Win()->BeginRedraw();
  1568 	TheGc->Activate(*BaseWin->Win());		
  1569 	bitmapRegular = new (ELeave) CFbsBitmap;
  1570 	CleanupStack::PushL(bitmapRegular);
  1571 	res = bitmapRegular->Create(TSize(10,10), EColor64K);		
  1572 	TEST(res == KErrNone);
  1573 	//Record the commands using CWindowGc.
  1574 	TheGc->UseBrushPattern(bitmapRegular);
  1575 	TheGc->SetBrushStyle(CGraphicsContext::EPatternedBrush);
  1576 	TheGc->DrawLine(TPoint(0,0), TPoint(1,1));
  1577 	CleanupStack::PopAndDestroy(1, bitmapRegular);	
  1578 	TheGc->Deactivate();
  1579 	BaseWin->Win()->EndRedraw();
  1580 	TheClient->iWs.Finish();
  1581 	
  1582 	// Thirdly, try using an extended bitmap (which is unsupported by DirectGDI) as 
  1583 	// the brush pattern.
  1584 	BaseWin->Win()->Invalidate();
  1585 	BaseWin->Win()->BeginRedraw();
  1586 	TheGc->Activate(*BaseWin->Win());
  1587 	// Create a dummy extended bitmap to use as a brush bitmap.
  1588 	// This is unsupported by the default implementation of DirectGDI.
  1589 	CFbsBitmap* bitmapExtended = new (ELeave) CFbsBitmap;
  1590 	CleanupStack::PushL(bitmapExtended);
  1591 	res = bitmapExtended->CreateExtendedBitmap(TSize(10,10), EColor64K, KTestExtendedBitmapUid, KTestData, KTestDataSize);
  1592 	TEST(res == KErrNone);	
  1593 	//Record the commands using CWindowGc.
  1594 	TheGc->UseBrushPattern(bitmapExtended);
  1595 	TheGc->SetBrushStyle(CGraphicsContext::EPatternedBrush);
  1596 	TheGc->DrawLine(TPoint(0,0), TPoint(100,100));
  1597 	TheGc->UseBrushPattern(bitmapExtended);
  1598 	// Forth, do it twice so that we test the state commands and the drawops commands.
  1599 	TheGc->SetBrushStyle(CGraphicsContext::EPatternedBrush);
  1600 	TheGc->DrawLine(TPoint(0,0), TPoint(100,100));
  1601 	TheGc->Deactivate();
  1602 	BaseWin->Win()->EndRedraw();
  1603 	TheClient->iWs.Finish();
  1604 	CleanupStack::PopAndDestroy(1, bitmapExtended);	
  1605 	}
  1606 
  1607 /**
  1608 @SYMTestCaseID      GRAPHICS-WSERV-0576
  1609 @SYMDEF             
  1610 @SYMTestCaseDesc    Checks window server is still able to draw a bitmap, even after the client has released its handle to the bitmap.
  1611 @SYMTestPriority    High
  1612 @SYMTestStatus      Implemented
  1613 @SYMTestActions     - Draw the bitmap to TestWin (keeping the window hidden)
  1614                     - Delete the bitmap
  1615                     - Show TestWin to cause it to be drawn on screen (after the bitmap has been deleted)
  1616                     - Draw the same bitmap (same image, different bitmap object instance) to BaseWin
  1617                     - Compare contents of TestWin with BaseWin
  1618 @SYMTestExpectedResults TestWin and BaseWin should both show the bitmap.
  1619 */
  1620 void CTGc::TestGcDeleteBitmap1L()
  1621     {
  1622     CFbsBitmap* bitmap = new (ELeave) CFbsBitmap;
  1623     CleanupStack::PushL(bitmap);
  1624     TInt ret = bitmap->Load(TEST_BITMAP_NAME,0);
  1625     TEST(ret == KErrNone);
  1626 
  1627     // send drawing to hidden window
  1628     TestWin->SetVisible(EFalse);
  1629     TestWin->Win()->Invalidate();
  1630     TestWin->Win()->BeginRedraw();
  1631     TheGc->Activate(*TestWin->Win());
  1632     TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1633     TheGc->SetDrawMode(CGraphicsContext::EDrawModePEN);
  1634     TheGc->SetBrushColor(TRgb(255, 0, 0));
  1635     TheGc->Clear();
  1636     TheGc->BitBlt(TPoint(0,0), bitmap);
  1637     CleanupStack::PopAndDestroy(bitmap); // before the bitmap is actually deleted, WsFbsDestroyCallBack flushes the command buffer to ensure the bitmap is duplicated in the window server thread
  1638     bitmap = NULL;
  1639     TheGc->Deactivate();
  1640     TestWin->Win()->EndRedraw();
  1641     TheClient->iWs.Flush(); // calling Flush rather than Finish, as we don't need to wait for any drawing to happen (as the window is currently hidden)
  1642 
  1643     // make window visible (forcing it to draw)
  1644     TestWin->SetVisible(ETrue);
  1645     TheClient->iWs.Finish(); // ensure the bitmap has been drawn on test win
  1646 
  1647     // window server should have duplicated the bitmap when the BitBlt was added to the redraw store, so drawing
  1648     // the window now (by making it visible above) should display the bitmap on screen, even
  1649     // though we've deleted it in this thread
  1650 
  1651     // now create the bitmap again, and draw it to the base win (for comparison with test win)
  1652     bitmap = new (ELeave) CFbsBitmap;
  1653     CleanupStack::PushL(bitmap);
  1654     ret = bitmap->Load(TEST_BITMAP_NAME,0);
  1655     TEST(ret == KErrNone);
  1656     BaseWin->SetVisible(ETrue);
  1657     BaseWin->Win()->Invalidate();
  1658     BaseWin->Win()->BeginRedraw();
  1659     TheGc->Activate(*BaseWin->Win());   
  1660     TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1661     TheGc->SetDrawMode(CGraphicsContext::EDrawModePEN);
  1662     TheGc->SetBrushColor(TRgb(255, 0, 0));
  1663     TheGc->Clear();
  1664     TheGc->BitBlt(TPoint(0,0), bitmap);
  1665     TheGc->Deactivate();
  1666     BaseWin->Win()->EndRedraw();
  1667     TheClient->iWs.Finish(); // ensure the bitmap has been drawn on base win
  1668     
  1669     CleanupStack::PopAndDestroy(bitmap);
  1670 
  1671     // the test bitmap should be shown in both base win and test win, so we now check that the
  1672     // contents of base win and test win are the same
  1673     CheckRect(BaseWin, TestWin, TRect(0, 0, BaseWin->Size().iWidth, BaseWin->Size().iHeight), _L("CTGc::TestGcDeleteBitmap1L()"));
  1674     }
  1675 
  1676 /**
  1677 @SYMTestCaseID      GRAPHICS-WSERV-0577
  1678 @SYMDEF             
  1679 @SYMTestCaseDesc    Check window server is still able to use a bitmap required by window drawing, even
  1680                     after the client has released its handle to the bitmap. Also check window server 
  1681                     releases the bitmap, when it's no longer used by window drawing.
  1682 @SYMTestPriority    High
  1683 @SYMTestStatus      Implemented
  1684 @SYMTestActions     - Clean BaseWin and TestWin from content that has been left over from previous test
  1685                     - Draw test bitmap to TestWin
  1686                     - Delete the bitmap
  1687                     - Using a different bitmap object instance, duplicate bitmap (the bitmap is still used by window drawing)
  1688                     - Delete the bitmap
  1689                     - Draw new content to TestWin, so that previously drawn bitmap is covered
  1690                     - Duplicate bitmap (the bitmap is no longer used by window drawing)
  1691 @SYMTestExpectedResults Bitmap duplication succeeds, when the bitmap used by window drawing, whereas
  1692                         bitmap duplication fails, when the bitmap is no longer used by window drawing.
  1693 */
  1694 void CTGc::TestGcDeleteBitmap2L()
  1695     {
  1696     //send new drawing to test and base windows, in order to cover 
  1697     //any content has been left on them (through previous test)
  1698     BaseWin->SetVisible(ETrue);
  1699     BaseWin->Win()->Invalidate();
  1700     BaseWin->Win()->BeginRedraw();
  1701     TheGc->Activate(*BaseWin->Win());   
  1702     TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1703     TheGc->SetDrawMode(CGraphicsContext::EDrawModePEN);
  1704     TheGc->SetBrushColor(TRgb(0, 0, 255));
  1705     TheGc->Clear();
  1706     TheGc->Deactivate();
  1707     BaseWin->Win()->EndRedraw();
  1708     
  1709     TestWin->SetVisible(ETrue);
  1710     TestWin->Win()->Invalidate();
  1711     TestWin->Win()->BeginRedraw();
  1712     TheGc->Activate(*TestWin->Win());   
  1713     TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1714     TheGc->SetDrawMode(CGraphicsContext::EDrawModePEN);
  1715     TheGc->SetBrushColor(TRgb(0, 0, 255));
  1716     TheGc->Clear();
  1717     TheGc->Deactivate();
  1718     TestWin->Win()->EndRedraw();
  1719     
  1720     TheClient->iWs.Flush(); 
  1721     TheClient->iWs.Finish();
  1722         
  1723     //load test bitmap
  1724     CFbsBitmap* bitmap = new (ELeave) CFbsBitmap;
  1725     CleanupStack::PushL(bitmap);
  1726     TInt ret = bitmap->Load(_L("Z:\\WSTEST\\TESTCIRCLES.MBM"),0);
  1727     TEST(ret == KErrNone);
  1728     TInt bitmapHandle = bitmap->Handle();
  1729     
  1730     //send bitmap drawing to test window
  1731     TestWin->Win()->Invalidate();
  1732     TestWin->Win()->BeginRedraw();
  1733     TheGc->Activate(*TestWin->Win());
  1734     TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1735     TheGc->SetDrawMode(CGraphicsContext::EDrawModePEN);
  1736     TheGc->SetBrushColor(TRgb(0, 255, 0));
  1737     TheGc->Clear();
  1738     TheGc->BitBlt(TPoint(0,0), bitmap);
  1739     TheGc->Deactivate();
  1740     TestWin->Win()->EndRedraw();
  1741     
  1742     CleanupStack::PopAndDestroy(bitmap);
  1743 
  1744     TheClient->iWs.Flush(); 
  1745     TheClient->iWs.Finish();
  1746     
  1747     //using a new bitmap object instance check that wserv can still duplicate test bitmap (even though
  1748     //the initial bitmap object is deleted) , since there is a window segment using it
  1749     bitmap = new (ELeave) CFbsBitmap;
  1750     CleanupStack::PushL(bitmap);
  1751     ret = bitmap->Duplicate(bitmapHandle);
  1752     TEST(ret == KErrNone);
  1753     CleanupStack::PopAndDestroy(bitmap);
  1754 
  1755     //send new drawing to test window, in order to cover the bitmap that was previously drawn
  1756     TestWin->Win()->Invalidate();
  1757     TestWin->Win()->BeginRedraw();
  1758     TheGc->Activate(*TestWin->Win());
  1759     TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1760     TheGc->SetDrawMode(CGraphicsContext::EDrawModePEN);
  1761     TheGc->SetBrushColor(TRgb(0, 0, 255));
  1762     TheGc->Clear();
  1763     TheGc->Deactivate();
  1764     TestWin->Win()->EndRedraw();
  1765     
  1766     TheClient->iWs.Flush(); 
  1767     TheClient->iWs.Finish();
  1768     
  1769     //check that wserv can't duplicate test bitmap, since no window segment uses it any more
  1770     bitmap = new (ELeave) CFbsBitmap;
  1771     CleanupStack::PushL(bitmap);
  1772     ret = bitmap->Duplicate(bitmapHandle);
  1773     TEST(ret != KErrNone);
  1774     CleanupStack::PopAndDestroy(bitmap);
  1775     }
  1776 
  1777 void CTGc::RunTestCaseL(TInt /*aCurTestCase*/)
  1778 	{
  1779 	((CTGcStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
  1780 	switch(++iTest->iState)
  1781 		{
  1782 	case 1:
  1783 		((CTGcStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0437"));
  1784 		iTest->LogSubTest(_L("CRemoteGc&CWindowGc, outline and shadow text"));
  1785 		TestOutlineAndShadowL();		
  1786 		break;	
  1787 	case 2:
  1788 		((CTGcStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0471"));
  1789 		iTest->LogSubTest(_L("Test GC clip rect and origin attributes."));		 
  1790 		TestGcClipRectOrigin();
  1791 		break;
  1792 	case 3:
  1793 		((CTGcStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0469"));
  1794 		iTest->LogSubTest(_L("CRemoteGc&CWindowGc, reset with background colour"));		
  1795 		TestResetWithBackgroundColorL();
  1796 		break;
  1797 	case 4:
  1798 		((CTGcStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0481"));
  1799 		iTest->LogSubTest(_L("CRemoteGc&CCommandBuffer, coverage tests"));
  1800 		TestCommandBufferL();
  1801 		break;			
  1802 	case 5:
  1803 		((CTGcStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0482"));
  1804 		iTest->LogSubTest(_L("CCommandBuffer, coverage tests"));
  1805 		TestEmptyCommandBufferL();
  1806 		break;
  1807 	case 6:
  1808 		((CTGcStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0494"));
  1809 		iTest->LogSubTest(_L("CWindowGc, Brush Pattern test"));
  1810 		TestGcSetBrushPatternL();
  1811 		break;
  1812     case 7:
  1813         ((CTGcStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0576"));
  1814         iTest->LogSubTest(_L("CWindowGc, delete bitmap 1"));
  1815         TestGcDeleteBitmap1L();
  1816         break;
  1817     case 8:
  1818         ((CTGcStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0577"));
  1819         iTest->LogSubTest(_L("CWindowGc, delete bitmap 2"));
  1820         TestGcDeleteBitmap2L();
  1821         break;
  1822 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA
  1823 	case 9:
  1824 		 ((CTGcStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0471"));
  1825 		 iTest->LogSubTest(_L("Test GC clip rect and origin attributes."));
  1826 		 TestGcClipRectOrigin();
  1827 		 break;
  1828 	case 10:
  1829 		((CTGcStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0469"));
  1830 		iTest->LogSubTest(_L("CRemoteGc&CWindowGc, reset with background colour"));
  1831 		TestResetWithBackgroundColorL();
  1832 		break;
  1833 	case 11:
  1834 		((CTGcStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0486"));
  1835 		iTest->LogSubTest(_L("CRemoteGc&MWsGraphicsContext, clipping rect test"));
  1836 		TestCRemoteGcAndMWsGraphicsContextClippingRectL();
  1837 		break;
  1838 	case 12:
  1839 		((CTGcStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0487"));
  1840 		iTest->LogSubTest(_L("CRemoteGc, DrawTextInContext Position test"));
  1841 		TestCRemoteGcDrawTextInContextPointL();
  1842 		break;
  1843 	case 13:
  1844 		((CTGcStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0488"));
  1845 		iTest->LogSubTest(_L("CRemoteGc, DrawTextInContext ClipRect test"));
  1846 		TestCRemoteGcDrawTextInContextBoxL();
  1847 		break;
  1848 	case 14:
  1849 		((CTGcStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0489"));
  1850 		iTest->LogSubTest(_L("CRemoteGc, DrawTextInContext Pos Vertical  test"));
  1851 		TestCRemoteGcDrawTextInContextPointVerticalL();
  1852 		break;
  1853 	case 15:
  1854 		((CTGcStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0490"));
  1855 		iTest->LogSubTest(_L("CRemoteGc, DrawTextInContext ClipRect Vert  test"));
  1856 		TestCRemoteGcDrawTextInContextBoxVerticalL();
  1857 		break;
  1858 #endif //TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA
  1859 	default:
  1860 		((CTGcStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
  1861 		((CTGcStep*)iStep)->CloseTMSGraphicsStep();
  1862 		TestComplete();
  1863 		break;
  1864 		}
  1865 	((CTGcStep*)iStep)->RecordTestResultL();
  1866 	}
  1867 
  1868 __CONSTRUCT_STEP__(Gc)