os/graphics/windowing/windowserver/test/tauto/tgc.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/graphics/windowing/windowserver/test/tauto/tgc.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,1868 @@
     1.4 +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +/**
    1.20 + @file
    1.21 + @test
    1.22 + @internalComponent - Internal Symbian test code
    1.23 +*/
    1.24 +#include "tgc.h"
    1.25 +#include "RemoteGc.h"
    1.26 +#include "CommandBuffer.h"
    1.27 +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA
    1.28 +#include "directgdigcwrapper.h"
    1.29 +#include <graphics/directgdidriver.h>
    1.30 +#include <graphics/sgutils.h>
    1.31 +#include <graphics/wsdrawresource.h>
    1.32 +#endif
    1.33 +
    1.34 +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA
    1.35 +GLDEF_C void CopyImageToBitmapL(CFbsBitmap* aBitmap, const RSgImage& aImage, const TRect& aRect);
    1.36 +GLDEF_C void CopyImageToDestination(TAny* aDataAddressDest, TInt aDataStrideDest, TDisplayMode aDisplayModeDest, 
    1.37 +				TAny* aDataAddressSrc, TInt aDataStrideSrc, TDisplayMode aDisplayModeSrc, const TRect& aRect);
    1.38 +GLDEF_C void CopyImageToDestination64K(TAny* aDataAddressDest, TInt aDataStrideDest, TDisplayMode aDisplayModeDest, 
    1.39 +		TUint16* aDataAddressSrc, TInt aDataStrideSrc, const TRect& aRect);
    1.40 +
    1.41 +GLDEF_C void CopyImageToBitmapL(CFbsBitmap* aBitmap, const RSgImage& aImage, const TRect& aRect)
    1.42 +	{
    1.43 +	TSgImageInfo info;
    1.44 +	TInt res = aImage.GetInfo(info);
    1.45 +	if(res == KErrNone)
    1.46 +		{
    1.47 +		info.iUsage = ESgUsageNone;
    1.48 +		info.iCpuAccess = ESgCpuAccessReadOnly;
    1.49 +		RSgImage image;
    1.50 +		res = image.Create(info, aImage);
    1.51 +		if(res == KErrNone)
    1.52 +			{	
    1.53 +			const TAny* dataAddressSrc = NULL; 
    1.54 +			TInt dataStrideSrc = 0;
    1.55 +			res = image.MapReadOnly(dataAddressSrc, dataStrideSrc);
    1.56 +			if(res == KErrNone)
    1.57 +				{
    1.58 +				const TDisplayMode displayModeDest = aBitmap->DisplayMode();
    1.59 +				const TDisplayMode displayModeSrc = SgUtils::PixelFormatToDisplayMode(info.iPixelFormat);
    1.60 +				TUint32* dataAddressDest = aBitmap->DataAddress();
    1.61 +				const TInt dataStrideDest = aBitmap -> DataStride();
    1.62 +				TSize bitmapSize = aBitmap->SizeInPixels();
    1.63 +				TRect rect = aRect;
    1.64 +				TRect rectDest = info.iSizeInPixels;
    1.65 +				rect.Intersection(rectDest);
    1.66 +				if(rect.Height() > bitmapSize.iHeight)
    1.67 +					{
    1.68 +					rect.SetHeight(bitmapSize.iHeight);
    1.69 +					}
    1.70 +				if(rect.Width() > bitmapSize.iWidth)
    1.71 +					{
    1.72 +					rect.SetWidth(bitmapSize.iWidth);
    1.73 +					}
    1.74 +				CopyImageToDestination((TAny*)dataAddressDest, dataStrideDest, displayModeDest, (TAny*)dataAddressSrc, 
    1.75 +								dataStrideSrc, displayModeSrc, rect);
    1.76 +
    1.77 +				image.Unmap();
    1.78 +				}
    1.79 +			image.Close();
    1.80 +			}
    1.81 +		}
    1.82 +	}
    1.83 +
    1.84 +GLDEF_C void CopyImageToDestination(TAny* aDataAddressDest, TInt aDataStrideDest, TDisplayMode aDisplayModeDest, 
    1.85 +				TAny* aDataAddressSrc, TInt aDataStrideSrc, TDisplayMode aDisplayModeSrc, const TRect& aRect) 
    1.86 +	{
    1.87 +	if(aRect.IsEmpty())
    1.88 +		return;
    1.89 +	
    1.90 +	if((aDisplayModeDest == aDisplayModeSrc) && (aDataStrideSrc == aDataStrideDest))
    1.91 +		{
    1.92 +		Mem::Copy(aDataAddressDest, aDataAddressSrc, aDataStrideDest * aRect.Height());
    1.93 +		return;
    1.94 +		}
    1.95 +	
    1.96 +	switch(aDisplayModeSrc)
    1.97 +		{
    1.98 +	case EColor64K:
    1.99 +		{
   1.100 +		CopyImageToDestination64K(aDataAddressDest, aDataStrideDest, aDisplayModeDest, 
   1.101 +						(TUint16*)aDataAddressSrc, aDataStrideSrc, aRect);
   1.102 +		break;
   1.103 +		}
   1.104 +	default:
   1.105 +		break;
   1.106 +		}
   1.107 +	}
   1.108 +
   1.109 +GLDEF_C void CopyImageToDestination64K(TAny* aDataAddressDest, TInt aDataStrideDest, TDisplayMode aDisplayModeDest, 
   1.110 +		TUint16* aDataAddressSrc, TInt aDataStrideSrc, const TRect& aRect) 
   1.111 +	{
   1.112 +	const TInt bppSrc = 2;
   1.113 +	const TInt width = aRect.Width();
   1.114 +	const TInt height = aRect.Height();
   1.115 +	const TInt dataStrideLengthSrc = aDataStrideSrc / bppSrc;
   1.116 +	TUint16* dataAddressSrc =  aDataAddressSrc + aRect.iTl.iY * dataStrideLengthSrc + aRect.iTl.iX; 
   1.117 +	const TUint16* dataAddressSrcEnd = dataAddressSrc + dataStrideLengthSrc *  height;  
   1.118 +
   1.119 +	switch(aDisplayModeDest)
   1.120 +		{
   1.121 +	case EColor64K:
   1.122 +		{
   1.123 +		TUint16* dataAddressDest = static_cast<TUint16*> (aDataAddressDest); 
   1.124 +		const TInt dataStrideLengthDest = aDataStrideDest / bppSrc;
   1.125 +		while(dataAddressSrcEnd > dataAddressSrc)
   1.126 +			{
   1.127 +			Mem::Copy(dataAddressDest, dataAddressSrc, width * bppSrc);
   1.128 +			dataAddressSrc += dataStrideLengthSrc;
   1.129 +			dataAddressDest += dataStrideLengthDest;
   1.130 +			}
   1.131 +		break;
   1.132 +		}
   1.133 +	case EColor16MU:
   1.134 +		{
   1.135 +		const TInt bppDest = 4;
   1.136 +		TUint32* dataAddressDest = static_cast<TUint32*> (aDataAddressDest); 
   1.137 +		const TInt dataStrideLengthDest = aDataStrideDest / bppDest;
   1.138 +		
   1.139 +		while(dataAddressSrcEnd > dataAddressSrc)
   1.140 +			{
   1.141 +			const TUint16* dataAddressSrcLineEnd = dataAddressSrc + width;
   1.142 +			TUint32* dataAddressDestCur = dataAddressDest;
   1.143 +			TUint16* dataAddressSrcCur = dataAddressSrc;
   1.144 +
   1.145 +			while(dataAddressSrcLineEnd > dataAddressSrcCur)
   1.146 +				{
   1.147 +				*dataAddressDestCur = TRgb::Color64K(*dataAddressSrcCur).Color16MU();
   1.148 +				dataAddressDestCur++;
   1.149 +				dataAddressSrcCur++;
   1.150 +				}
   1.151 +			dataAddressSrc += dataStrideLengthSrc;
   1.152 +			dataAddressDest += dataStrideLengthDest;
   1.153 +			}
   1.154 +		break;
   1.155 +		}
   1.156 +	case EGray4:
   1.157 +		{
   1.158 +		TUint8* dataAddressDest = static_cast<TUint8*> (aDataAddressDest);
   1.159 +		const TInt dataStrideLengthDest = aDataStrideDest;
   1.160 +		
   1.161 +		while(dataAddressSrcEnd > dataAddressSrc)
   1.162 +			{
   1.163 +			const TUint8* dataAddressDstLineEnd = dataAddressDest + aDataStrideDest;
   1.164 +			TUint8* dataAddressDestCur = dataAddressDest;
   1.165 +			TUint16* dataAddressSrcCur = dataAddressSrc;
   1.166 +
   1.167 +			while(dataAddressDstLineEnd > dataAddressDestCur)
   1.168 +				{
   1.169 +				*dataAddressDestCur = 0;
   1.170 +				for(TInt index = 0; index < 8; index +=2)
   1.171 +					{
   1.172 +					TInt col = TRgb::Color64K(*dataAddressSrcCur).Gray4();
   1.173 +					col <<= index;
   1.174 +					*dataAddressDestCur |= col;
   1.175 +					dataAddressSrcCur++;
   1.176 +					}
   1.177 +				dataAddressDestCur++;
   1.178 +				}
   1.179 +			dataAddressSrc += dataStrideLengthSrc;
   1.180 +			dataAddressDest += dataStrideLengthDest;
   1.181 +			}
   1.182 +		break;
   1.183 +		}
   1.184 +	case EColor256:
   1.185 +		{
   1.186 +		TUint8* dataAddressDest = static_cast<TUint8*> (aDataAddressDest);
   1.187 +		const TInt dataStrideLengthDest = aDataStrideDest;
   1.188 +		
   1.189 +		while(dataAddressSrcEnd > dataAddressSrc)
   1.190 +			{
   1.191 +			const TUint8* dataAddressDstLineEnd = dataAddressDest + aDataStrideDest;
   1.192 +			TUint8* dataAddressDestCur = dataAddressDest;
   1.193 +			TUint16* dataAddressSrcCur = dataAddressSrc;
   1.194 +
   1.195 +			while(dataAddressDstLineEnd > dataAddressDestCur)
   1.196 +				{
   1.197 +				*dataAddressDestCur = TRgb::Color64K(*dataAddressSrcCur).Color256();
   1.198 +				dataAddressSrcCur++;
   1.199 +				dataAddressDestCur++;
   1.200 +				}
   1.201 +			dataAddressSrc += dataStrideLengthSrc;
   1.202 +			dataAddressDest += dataStrideLengthDest;
   1.203 +			}
   1.204 +		break;
   1.205 +		}
   1.206 +	default:
   1.207 +		break;
   1.208 +		}
   1.209 +	}
   1.210 +
   1.211 +TDisplayMode DisplayModeFromPixelFormat(TUidPixelFormat aPixelFormat)
   1.212 +	{
   1.213 +	switch(aPixelFormat)
   1.214 +		{
   1.215 +	case EUidPixelFormatARGB_8888_PRE:
   1.216 +		return EColor16MAP;
   1.217 +	case EUidPixelFormatARGB_8888:
   1.218 +		return EColor16MA;
   1.219 +	case EUidPixelFormatRGB_565:
   1.220 +		return EColor64K;
   1.221 +	default:
   1.222 +		break;
   1.223 +		}
   1.224 +	return ENone;
   1.225 +	}
   1.226 +
   1.227 +TUidPixelFormat PixelFormatFromDisplayMode(TDisplayMode aDisplayMode)
   1.228 +	{
   1.229 +	switch (aDisplayMode)
   1.230 +		{
   1.231 +		case EGray2:
   1.232 +		case EGray4:
   1.233 +		case EGray16:
   1.234 +		case EGray256:
   1.235 +		case EColor16:
   1.236 +		case EColor256:
   1.237 +		case EColor16M:
   1.238 +		case EColor16MU:
   1.239 +			{
   1.240 +			return EUidPixelFormatXRGB_8888;
   1.241 +			}
   1.242 +		case EColor4K:
   1.243 +			{
   1.244 +			return EUidPixelFormatXRGB_4444;
   1.245 +			}
   1.246 +		case EColor64K:
   1.247 +			{
   1.248 +			return EUidPixelFormatRGB_565;
   1.249 +			}
   1.250 +		case EColor16MA:
   1.251 +			{
   1.252 +			return EUidPixelFormatARGB_8888;
   1.253 +			}
   1.254 +		case EColor16MAP:
   1.255 +			{
   1.256 +			return EUidPixelFormatARGB_8888_PRE;
   1.257 +			}
   1.258 +		default:
   1.259 +			{
   1.260 +			return EUidPixelFormatUnknown;
   1.261 +			}
   1.262 +		}
   1.263 +	}
   1.264 +#endif
   1.265 +
   1.266 +CTGc::CTGc(CTestStep* aStep) : CTWsGraphicsBase(aStep)
   1.267 +	{
   1.268 +	}
   1.269 +
   1.270 +CTGc::~CTGc()
   1.271 +	{
   1.272 +	delete iTest;
   1.273 +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA
   1.274 +	SgDriver::Close();
   1.275 +	CDirectGdiDriver *directGdiDriver = CDirectGdiDriver::Static();
   1.276 +	if(directGdiDriver)
   1.277 +		{
   1.278 +		directGdiDriver->Close();
   1.279 +		}
   1.280 +#endif
   1.281 +	}
   1.282 +
   1.283 +void CTGc::ConstructL()
   1.284 +	{
   1.285 +	_LIT(KTestName,"GC Test");
   1.286 +	iTest=new(ELeave) CTestBase(KTestName,this);
   1.287 +	
   1.288 +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA
   1.289 +	TInt err = CDirectGdiDriver::Open();
   1.290 +	User::LeaveIfError(err);
   1.291 +	err = SgDriver::Open();
   1.292 +	if(err != KErrNone)
   1.293 +		{
   1.294 +		CDirectGdiDriver *directGdiDriver = CDirectGdiDriver::Static();
   1.295 +		if(directGdiDriver)
   1.296 +			{
   1.297 +			directGdiDriver->Close();
   1.298 +			}
   1.299 +		User::Leave(err);
   1.300 +		}
   1.301 +#endif
   1.302 +	}
   1.303 +
   1.304 +//Class derived from MWsGraphicResolver. Used for playing the commands from command buffer
   1.305 +class CWSGraphicsRes: public CBase, public MWsGraphicResolver
   1.306 +	{
   1.307 +public:
   1.308 +	void DrawWsGraphic(TInt /*aId*/, TBool /*aIsUid*/, const TRect& /*aRect*/, const TDesC8& /*aData*/) const
   1.309 +		{
   1.310 +		//Orveriding by giving empty implemention
   1.311 +		}
   1.312 +	};
   1.313 +
   1.314 +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA
   1.315 +//
   1.316 +//Class CDrawTextInContextTest
   1.317 +//
   1.318 +
   1.319 +CDrawTextInContextTest::CDrawTextInContextTest(){}
   1.320 +
   1.321 +CDrawTextInContextTest::~CDrawTextInContextTest()
   1.322 +	{
   1.323 +	delete iRefBitmap;
   1.324 +	delete iRefDevice;
   1.325 +	delete iRefBitGc;
   1.326 +	delete iRemoteGc;
   1.327 +	iMsgBuf.Close();
   1.328 +	delete iCommandBuffer;
   1.329 +	delete iWsGraphicRes;
   1.330 +	
   1.331 +	TheClient->iScreen->ReleaseFont(iFont);
   1.332 +
   1.333 +	delete iDirectGdiGcWrapper;
   1.334 +	if(iWrapperImageTarget)
   1.335 +		{
   1.336 +		iWrapperImageTarget->Close();
   1.337 +		}
   1.338 +	delete iWrapperImageTarget;
   1.339 +	iWrapperImage.Close();
   1.340 +	iWrapperImageCollection.Close();
   1.341 +	}
   1.342 +
   1.343 +void CDrawTextInContextTest::BaseConstructL()
   1.344 +	{
   1.345 +	//Initialise font settings
   1.346 +	TFontSpec fsp;
   1.347 +	fsp.iTypeface.iName=_L("Series 60 Sans");
   1.348 +	fsp.iHeight=430;
   1.349 +	User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInTwips((CFont*&)iFont,fsp));
   1.350 +	
   1.351 +	//Initialise TTextParameter
   1.352 +	iParam.iStart = 27;
   1.353 +	iParam.iEnd = 60;
   1.354 +	
   1.355 +	//Text to draw
   1.356 +	iText.Set(_L("This text will not be drawnK.,!\"\x00A3$%^&*()_+-=;'#:@~/<>? Latin This text will not be drawn"));
   1.357 +	
   1.358 +	//For reference bitmap
   1.359 +	iRefBitmap = new(ELeave) CFbsBitmap();
   1.360 +	User::LeaveIfError(iRefBitmap->Create(KBitmapSize, EColor64K));
   1.361 +	iRefDevice = CFbsBitmapDevice::NewL(iRefBitmap);
   1.362 +	User::LeaveIfError(iRefDevice->CreateContext(iRefBitGc));
   1.363 +	
   1.364 +	CDirectGdiDriver* theDGdiDriver = CDirectGdiDriver::Static();
   1.365 +	User::LeaveIfNull(theDGdiDriver);
   1.366 +	
   1.367 +	TSgImageInfo info;
   1.368 +	info.iUsage = ESgUsageDirectGdiTarget | ESgUsageDirectGdiSource | ESgUsageCompositionSource;
   1.369 +	info.iSizeInPixels = KBitmapSize;
   1.370 +	info.iPixelFormat = EUidPixelFormatRGB_565;
   1.371 +	
   1.372 +	TInt res = iWrapperImageCollection.Create(info, 1);
   1.373 +	User::LeaveIfError(res);
   1.374 +	res = iWrapperImageCollection.OpenImage(0, iWrapperImage);
   1.375 +	User::LeaveIfError(res);
   1.376 +	iWrapperImageTarget = new (ELeave) RDirectGdiImageTarget(*theDGdiDriver);
   1.377 +	res = iWrapperImageTarget->Create(iWrapperImage);
   1.378 +	User::LeaveIfError(res);
   1.379 +	iDirectGdiGcWrapper = CDirectGdiGcWrapper::NewL(*iWrapperImageTarget);
   1.380 +
   1.381 +	//clean image-----------------
   1.382 +	CDirectGdiGcWrapper* directGdiGcWrapper = CDirectGdiGcWrapper::NewL(*iWrapperImageTarget);
   1.383 +	CleanupStack::PushL(directGdiGcWrapper);
   1.384 +
   1.385 +	directGdiGcWrapper->SetDrawMode(MWsGraphicsContext::EDrawModeWriteAlpha);
   1.386 +	directGdiGcWrapper->SetBrushColor(KRgbWhite);
   1.387 +	directGdiGcWrapper->Clear();
   1.388 +
   1.389 +	CleanupStack::PopAndDestroy(1, directGdiGcWrapper);
   1.390 +	//------------------
   1.391 +	
   1.392 +	//Used to record draw commands
   1.393 +	iRemoteGc = CRemoteGc::NewL(TheClient->iScreen);
   1.394 +	
   1.395 +	//Used to play recorded draw commands
   1.396 +	iCommandBuffer = CCommandBuffer::NewL();
   1.397 +	
   1.398 +	//Dummy class created required for CCommandBuffer::Play
   1.399 +	iWsGraphicRes = new (ELeave) CWSGraphicsRes();
   1.400 +	
   1.401 +	//Offset for CCommandBuffer::Play
   1.402 +	iOffset = TPoint(0,0);
   1.403 +	
   1.404 +	//Result of doing the test
   1.405 +	iHasPassedTest = EFalse;
   1.406 +	}
   1.407 +
   1.408 +void CDrawTextInContextTest::Test()
   1.409 +	{	
   1.410 +	/* Create reference bitmap by drawing using bitgc */
   1.411 +	iRefBitGc->UseFont(iFont);
   1.412 +	DoDrawTextBitGc();
   1.413 +	iRefBitGc->DiscardFont();
   1.414 +	
   1.415 +	/* Drawing using CBitGcWrapper via CRemotGc*/
   1.416 +	
   1.417 +	//Capturing the commands in remote gc
   1.418 +	iRemoteGc->BeginDraw(KBitmapRect);
   1.419 +	iRemoteGc->UseFont(iFont);
   1.420 +	DoDrawTextRemoteGc();
   1.421 +	iRemoteGc->DiscardFont();
   1.422 +	iRemoteGc->EndDraw();
   1.423 +		
   1.424 +	//Externalize the captured commands from remote gc in to a buffer
   1.425 +	iRemoteGc->ExternalizeL(iMsgBuf, ETrue);
   1.426 +
   1.427 +	//Internalize the buffer with captured commands (from CRemoteGC) in to CCommandBuffer
   1.428 +	iCommandBuffer->InternalizeL(iMsgBuf.Pckg());
   1.429 +	
   1.430 +	//Play the commands on test window using command buffer
   1.431 +	iCommandBuffer->Play(iOffset,&KBitmapRegion,KBitmapRect,*iWsGraphicRes,*iDirectGdiGcWrapper);
   1.432 +	
   1.433 +	//Test to see if the bitmap drawn to using CRemoteGc is the same as the reference bitmap
   1.434 +	CFbsBitmap* bitmap = new (ELeave) CFbsBitmap;
   1.435 +	CleanupStack::PushL(bitmap);
   1.436 +	
   1.437 +	TSgImageInfo info;
   1.438 +	iWrapperImage.GetInfo(info);
   1.439 +	TDisplayMode displayMode = DisplayModeFromPixelFormat(info.iPixelFormat);
   1.440 +	bitmap->Create(info.iSizeInPixels, displayMode);
   1.441 +	TRect rect(info.iSizeInPixels);
   1.442 +	CopyImageToBitmapL(bitmap, iWrapperImage, rect);
   1.443 +	
   1.444 +	iHasPassedTest = LossyCompareBitmap(*iRefBitmap, *bitmap, KBitmapRect, EFalse);
   1.445 +
   1.446 +	CleanupStack::PopAndDestroy(bitmap);
   1.447 +	}
   1.448 +
   1.449 +TBool CDrawTextInContextTest::HasPassedTest()
   1.450 +	{
   1.451 +	return iHasPassedTest;
   1.452 +	}
   1.453 +
   1.454 +//
   1.455 +// Class DrawTextInContextTestPoint
   1.456 +//
   1.457 +
   1.458 +CDrawTextInContextTestPoint::CDrawTextInContextTestPoint(){}
   1.459 +
   1.460 +CDrawTextInContextTestPoint::~CDrawTextInContextTestPoint(){}
   1.461 +
   1.462 +CDrawTextInContextTestPoint* CDrawTextInContextTestPoint::NewL()
   1.463 +	{
   1.464 +	CDrawTextInContextTestPoint* self = new(ELeave) CDrawTextInContextTestPoint;
   1.465 +	CleanupStack::PushL(self);
   1.466 +	self->ConstructL();
   1.467 +	CleanupStack::Pop(self);
   1.468 +	return self;
   1.469 +	}
   1.470 +
   1.471 +void CDrawTextInContextTestPoint::ConstructL()
   1.472 +	{
   1.473 +	BaseConstructL();
   1.474 +	iPosition = TPoint(0,0);
   1.475 +	}
   1.476 +
   1.477 +void CDrawTextInContextTestPoint::DoDrawTextBitGc()
   1.478 +	{
   1.479 +	iRefBitGc->DrawText(iText,&iParam,iPosition);
   1.480 +	}
   1.481 +
   1.482 +void CDrawTextInContextTestPoint::DoDrawTextRemoteGc()
   1.483 +	{
   1.484 +	iRemoteGc->DrawText(iText,&iParam,iPosition);
   1.485 +	}
   1.486 +
   1.487 +//
   1.488 +// Class DrawTextInContextTestBox
   1.489 +//
   1.490 +
   1.491 +CDrawTextInContextTestBox::CDrawTextInContextTestBox(){}
   1.492 +
   1.493 +CDrawTextInContextTestBox::~CDrawTextInContextTestBox(){}
   1.494 +
   1.495 +CDrawTextInContextTestBox* CDrawTextInContextTestBox::NewL()
   1.496 +	{
   1.497 +	CDrawTextInContextTestBox* self = new(ELeave) CDrawTextInContextTestBox;
   1.498 +	CleanupStack::PushL(self);
   1.499 +	self->ConstructL();
   1.500 +	CleanupStack::Pop(self);
   1.501 +	return self;
   1.502 +	}
   1.503 +
   1.504 +void CDrawTextInContextTestBox::ConstructL()
   1.505 +	{
   1.506 +	BaseConstructL();
   1.507 +	iClipFillRect = TRect(10,50,640,120);
   1.508 +	iBaselineOffset = 40;
   1.509 +	iTTextAlign = CGraphicsContext::ELeft;
   1.510 +	}
   1.511 +
   1.512 +void CDrawTextInContextTestBox::DoDrawTextBitGc()
   1.513 +	{
   1.514 +	iRefBitGc->DrawText(iText,&iParam,iClipFillRect,iBaselineOffset,iTTextAlign);
   1.515 +	}
   1.516 +
   1.517 +void CDrawTextInContextTestBox::DoDrawTextRemoteGc()
   1.518 +	{
   1.519 +	iRemoteGc->DrawText(iText,&iParam,iClipFillRect,iBaselineOffset,iTTextAlign);
   1.520 +	}
   1.521 +
   1.522 +//
   1.523 +// Class CDrawTextInContextTestPointVertical
   1.524 +//
   1.525 +
   1.526 +CDrawTextInContextTestPointVertical::CDrawTextInContextTestPointVertical(){}
   1.527 +
   1.528 +CDrawTextInContextTestPointVertical::~CDrawTextInContextTestPointVertical(){}
   1.529 +
   1.530 +CDrawTextInContextTestPointVertical* CDrawTextInContextTestPointVertical::NewL()
   1.531 +	{
   1.532 +	CDrawTextInContextTestPointVertical* self = new(ELeave) CDrawTextInContextTestPointVertical;
   1.533 +	CleanupStack::PushL(self);
   1.534 +	self->ConstructL();
   1.535 +	CleanupStack::Pop(self);
   1.536 +	return self;
   1.537 +	}
   1.538 +
   1.539 +void CDrawTextInContextTestPointVertical::ConstructL()
   1.540 +	{
   1.541 +	BaseConstructL();
   1.542 +	iPosition = TPoint(0,0);
   1.543 +	iUp = EFalse;
   1.544 +	}
   1.545 +
   1.546 +void CDrawTextInContextTestPointVertical::DoDrawTextBitGc()
   1.547 +	{
   1.548 +	iRefBitGc->DrawTextVertical(iText,&iParam,iPosition,iUp);
   1.549 +	}
   1.550 +
   1.551 +void CDrawTextInContextTestPointVertical::DoDrawTextRemoteGc()
   1.552 +	{
   1.553 +	iRemoteGc->DrawTextVertical(iText,&iParam,iPosition,iUp);
   1.554 +	}
   1.555 +
   1.556 +//
   1.557 +// Class CDrawTextInContextTestBoxVertical
   1.558 +//
   1.559 +
   1.560 +CDrawTextInContextTestBoxVertical::CDrawTextInContextTestBoxVertical(){}
   1.561 +
   1.562 +CDrawTextInContextTestBoxVertical::~CDrawTextInContextTestBoxVertical(){}
   1.563 +
   1.564 +CDrawTextInContextTestBoxVertical* CDrawTextInContextTestBoxVertical::NewL()
   1.565 +	{
   1.566 +	CDrawTextInContextTestBoxVertical* self = new(ELeave) CDrawTextInContextTestBoxVertical;
   1.567 +	CleanupStack::PushL(self);
   1.568 +	self->ConstructL();
   1.569 +	CleanupStack::Pop(self);
   1.570 +	return self;
   1.571 +	}
   1.572 +
   1.573 +void CDrawTextInContextTestBoxVertical::ConstructL()
   1.574 +	{
   1.575 +	BaseConstructL();
   1.576 +	iClipFillRect = TRect(10,50,640,120);
   1.577 +	iBaselineOffset = 40;
   1.578 +	iUp = EFalse;
   1.579 +	iTTextAlign = CGraphicsContext::ELeft;
   1.580 +	}
   1.581 +
   1.582 +void CDrawTextInContextTestBoxVertical::DoDrawTextBitGc()
   1.583 +	{
   1.584 +	iRefBitGc->DrawTextVertical(iText,&iParam,iClipFillRect,iBaselineOffset,iUp,iTTextAlign);
   1.585 +	}
   1.586 +
   1.587 +void CDrawTextInContextTestBoxVertical::DoDrawTextRemoteGc()
   1.588 +	{
   1.589 +	iRemoteGc->DrawTextVertical(iText,&iParam,iClipFillRect,iBaselineOffset,iUp,iTTextAlign);
   1.590 +	}
   1.591 +#endif //TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA
   1.592 +
   1.593 +void CleanUpFont(TAny* aFont)
   1.594 +	{
   1.595 +	//Will be called in case of a leave to release the font
   1.596 +	CFont* font= static_cast<CFont*>(aFont);
   1.597 +	TheClient->iScreen->ReleaseFont(font);
   1.598 +	}
   1.599 +
   1.600 +/**
   1.601 +@SYMTestCaseID		GRAPHICS-WSERV-0437
   1.602 +@SYMPREQ            PREQ1543
   1.603 +@SYMTestCaseDesc    Draw text using CWindowGc and CRemoteGc with both outline and shadow
   1.604 +effect on.
   1.605 +@SYMTestPriority    High
   1.606 +@SYMTestStatus      Implemented
   1.607 +@SYMTestActions     Create a font with both outline and shadow effects. Record the commands 
   1.608 +(like setting colours,drawing text etc) using CRemoteGc and play the recorded commands on a window. Use the same
   1.609 +commands in CWindowGc and draw text on a different window
   1.610 +@SYMTestExpectedResults Text drawn using CWindowGc and CRemoteGc should be same
   1.611 +*/
   1.612 +void CTGc::TestOutlineAndShadowL()
   1.613 +	{
   1.614 +	TRect sourceRect(0, 0, TestWin->Size().iWidth, TestWin->Size().iHeight);
   1.615 +	TRegionFix<1> clippingRegion(sourceRect);
   1.616 +	
   1.617 +	CWsScreenDevice* device = TheClient->iScreen;
   1.618 +
   1.619 +	_LIT(KText,"Outline and shadow");
   1.620 +	TFontSpec fSpec(KTestFontTypefaceName,23);
   1.621 +	fSpec.iFontStyle.SetBitmapType(EAntiAliasedGlyphBitmap);
   1.622 +	fSpec.iFontStyle.SetEffects(FontEffect::EDropShadow, ETrue);
   1.623 +	fSpec.iFontStyle.SetEffects(FontEffect::EOutline, ETrue);
   1.624 +	
   1.625 +	CFont *font;
   1.626 +	User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInPixels((CFont *&)font, fSpec));
   1.627 +	CleanupStack::PushL(TCleanupItem(CleanUpFont, font));
   1.628 +	
   1.629 +	CRemoteGc* remoteGc = CRemoteGc::NewL(device);
   1.630 +	CleanupStack::PushL(remoteGc);
   1.631 +	remoteGc->BeginDraw(sourceRect);
   1.632 +	//Capturing the commands in remote gc
   1.633 +	remoteGc->SetBrushColor(KRgbGreen);
   1.634 +	remoteGc->SetShadowColor(KRgbDarkRed);
   1.635 +	remoteGc->SetPenColor(KRgbBlack);
   1.636 +	remoteGc->UseFont(font);
   1.637 +	remoteGc->DrawText(KText, TPoint(2,40));
   1.638 +	remoteGc->DiscardFont();
   1.639 +	remoteGc->EndDraw();
   1.640 +
   1.641 +	RWsGraphicMsgBuf msgBuf;
   1.642 +	CleanupClosePushL(msgBuf);
   1.643 +	//Externalize the captured commands from remote gc in to a buffer
   1.644 +	remoteGc->ExternalizeL(msgBuf, ETrue);
   1.645 +
   1.646 +	CWSGraphicsRes* wsGrap = new (ELeave) CWSGraphicsRes();
   1.647 +	CleanupStack::PushL(wsGrap);
   1.648 +	
   1.649 +	CCommandBuffer* cmdBuf = CCommandBuffer::NewL();
   1.650 +	CleanupStack::PushL(cmdBuf);
   1.651 +	//Internalize the buffer with captured commands (from CRemoteGC) 
   1.652 +	//in to CCommandBuffer
   1.653 +	cmdBuf->InternalizeL(msgBuf.Pckg());
   1.654 +	
   1.655 +	TestWin->Win()->Invalidate();
   1.656 +	TestWin->Win()->BeginRedraw();
   1.657 +	TheGc->Activate(*TestWin->Win());
   1.658 +	TheGc->Clear();
   1.659 +	//Play the commands on test window using command buffer
   1.660 +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA
   1.661 +	cmdBuf->Play(TPoint(0, 0), &clippingRegion, sourceRect, TheClient->iWs, *TheGc);
   1.662 +#else
   1.663 +	cmdBuf->Play(TPoint(),TRect(TestWin->Size()),*wsGrap,*TheGc);
   1.664 +#endif
   1.665 +	TheGc->Deactivate();
   1.666 +	TestWin->Win()->EndRedraw();
   1.667 +	
   1.668 +	BaseWin->Win()->Invalidate();
   1.669 +	BaseWin->Win()->BeginRedraw();
   1.670 +	TheGc->Activate(*BaseWin->Win());
   1.671 +	TheGc->Clear();
   1.672 +	TheGc->SetBrushColor(KRgbGreen);
   1.673 +	TheGc->SetShadowColor(KRgbDarkRed);
   1.674 +	TheGc->SetPenColor(KRgbBlack);
   1.675 +	TheGc->UseFont(font);
   1.676 +	//Draw the text on base window using CWindowGC
   1.677 +	TheGc->DrawText(KText, TPoint(2, 40));
   1.678 +	TheGc->DiscardFont();
   1.679 +	TheGc->Deactivate();
   1.680 +	BaseWin->Win()->EndRedraw();
   1.681 +	TheClient->iWs.Finish();
   1.682 +	TheClient->WaitForRedrawsToFinish();
   1.683 +
   1.684 +	//Check the text drawn on base and test windows.
   1.685 +	CheckRect(BaseWin, TestWin, TRect(0, 0, BaseWin->Size().iWidth, BaseWin->Size().iHeight), _L("CTGc::TestOutlineAndShadowL()"));
   1.686 +
   1.687 +	CleanupStack::PopAndDestroy(4, remoteGc); //cmdBuf, wsGrap, msgBuf and remoteGc
   1.688 +	CleanupStack::Pop();//font
   1.689 +	TheClient->iScreen->ReleaseFont(font);
   1.690 +	}
   1.691 +
   1.692 +void CTGc::TestGcClipRectOrigin_DrawContent(TestWindow& aWindow, TBool bActivateBeforeRedraw /*= ETrue*/)
   1.693 +	{
   1.694 +	TSize winSize = aWindow.Size();
   1.695 +	TPoint gcOrigin(winSize.iWidth >> 3, winSize.iWidth >> 3);
   1.696 +	TRect gcClipRect(0, 0, (winSize.iWidth * 3) >> 2, (winSize.iHeight * 3) >> 2);
   1.697 +	TRect ellipseRect(gcClipRect);
   1.698 +	// Shrink the ellipse for better visibility and to fit well within the clip area.
   1.699 +	ellipseRect.Shrink(3, 3);
   1.700 +	TSize penSize(1, 1);
   1.701 +
   1.702 +	aWindow.Win()->SetBackgroundColor(KRgbGreen);
   1.703 +	aWindow.ClearWin();
   1.704 +	aWindow.Win()->Invalidate();
   1.705 +
   1.706 +	if(!bActivateBeforeRedraw)
   1.707 +		{
   1.708 +		aWindow.Win()->BeginRedraw();
   1.709 +		}
   1.710 +
   1.711 +	TheGc->Activate(*(aWindow.Win()));
   1.712 +	TheGc->SetOrigin(gcOrigin);
   1.713 +	TheGc->SetClippingRect(gcClipRect);
   1.714 +
   1.715 +	if(bActivateBeforeRedraw)
   1.716 +		{
   1.717 +		aWindow.Win()->BeginRedraw();
   1.718 +		}
   1.719 +
   1.720 +	TheGc->SetBrushColor(KRgbDarkRed);
   1.721 +	TheGc->SetPenColor(KRgbDarkRed);
   1.722 +	TheGc->SetPenSize(penSize);
   1.723 +	TheGc->SetPenStyle(CGraphicsContext::ESolidPen);
   1.724 +	TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
   1.725 +	TheGc->DrawEllipse(ellipseRect);
   1.726 +	TheGc->SetBrushStyle(CGraphicsContext::ENullBrush);
   1.727 +	TheGc->SetPenColor(KRgbYellow);
   1.728 +	TheGc->SetPenStyle(CGraphicsContext::EDashedPen);
   1.729 +	TheGc->DrawRect(gcClipRect);
   1.730 +
   1.731 +	aWindow.Win()->EndRedraw();
   1.732 +	TheGc->Deactivate();
   1.733 +	}
   1.734 +
   1.735 +/**
   1.736 +@SYMTestCaseID		GRAPHICS-WSERV-0471
   1.737 +@SYMTestCaseDesc    This test is to verify that the GC correctly applies the clip rect and
   1.738 +					origin attributes irrespective of whether the GC is activated on the
   1.739 +					window before or after the BeginRedraw.
   1.740 +@SYMDEF				PDEF120091
   1.741 +@SYMTestPriority    High
   1.742 +@SYMTestStatus      Implemented
   1.743 +@SYMTestActions     The test has following steps:
   1.744 +	1. For the Test window follow the steps:
   1.745 +		A. Activate the GC on Test window.
   1.746 +		B. Set the Origin of the GC to centre of the window.
   1.747 +		C. Set the Clipping rectangle of the GC to half the size of the window.
   1.748 +		D. In the BeginDraw and EndDraw call bracket perform the following:
   1.749 +			a. Draw an ellipse with the rectangle smaller by 5 pixels than the clip rectangle.
   1.750 +			b. Draw a rectangle that is size of the clip rectangle.
   1.751 +		E. Deactivate the GC. 
   1.752 +	2. For the Base window follow the steps:
   1.753 +		A. In the BeginDraw and EndDraw call bracket perform the following:
   1.754 +			a. Activate the GC on Base window.
   1.755 +			b. Set the Origin of the GC to centre of the window.
   1.756 +			c. Set the Clipping rectangle of the GC to half the size of the window.
   1.757 +			d. Draw an ellipse with the rectangle smaller by 5 pixels than the clip rectangle.
   1.758 +			e. Draw a rectangle that is size of the clip rectangle.
   1.759 +			f. Deactivate the GC. 
   1.760 +	3. Compare Test and Base window.
   1.761 +@SYMTestExpectedResults Both the Test and Base window should have the complete
   1.762 +						non-clipped ellipse completely encapsulated within the rectangle. 
   1.763 +*/
   1.764 +void CTGc::TestGcClipRectOrigin()
   1.765 +	{
   1.766 +	TestGcClipRectOrigin_DrawContent(*BaseWin, EFalse);
   1.767 +	TestGcClipRectOrigin_DrawContent(*TestWin, ETrue);
   1.768 +	
   1.769 +	TheClient->Flush();
   1.770 +	
   1.771 +	CheckRect(BaseWin, TestWin, TRect(0, 0, BaseWin->Size().iWidth, BaseWin->Size().iHeight), _L("CTGc::TestGcClipRectOriginL()"));
   1.772 +	}
   1.773 +
   1.774 +/**
   1.775 +@SYMTestCaseID		GRAPHICS-WSERV-0469
   1.776 +@SYMDEF             INC116406
   1.777 +@SYMTestCaseDesc    Try playback on MWsGraphicsContext and CWindowGc to check that the background colour is
   1.778 +set correctly.
   1.779 +@SYMTestPriority    High
   1.780 +@SYMTestStatus      Implemented
   1.781 +@SYMTestActions
   1.782 +@SYMTestExpectedResults Text drawn using CWindowGc should use the background colour of
   1.783 +the window, and MWsGraphicsContext should use transparent white.
   1.784 +*/
   1.785 +void CTGc::TestResetWithBackgroundColorL()
   1.786 +	{
   1.787 +	const TRect KSourceRect(0, 0, TestWin->Size().iWidth, TestWin->Size().iHeight);
   1.788 +	const TRegionFix<1> KClippingRegion(KSourceRect);
   1.789 +	
   1.790 +	CWsScreenDevice* device = TheClient->iScreen;
   1.791 +
   1.792 +	CRemoteGc* remoteGc = CRemoteGc::NewL(device);
   1.793 +	CleanupStack::PushL(remoteGc);
   1.794 +	
   1.795 +	//note this remote GC has not been activated on any window
   1.796 +	remoteGc->BeginDraw(KSourceRect);
   1.797 +
   1.798 +	//Draw the commands in remote gc
   1.799 +	remoteGc->SetBrushColor(KRgbGreen);  //nothing green is seen in this test
   1.800 +
   1.801 +	remoteGc->Reset(); //This resets the brush colour to the background colour of the window
   1.802 +					   //where playback is, in the case of playing back to a window
   1.803 +					   //however with a CFbsBitGc the color is transparent white, as there is no window.
   1.804 +	remoteGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
   1.805 +	remoteGc->SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha);
   1.806 +	remoteGc->DrawRect(KSourceRect);
   1.807 +	remoteGc->EndDraw();
   1.808 +
   1.809 +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA
   1.810 +	CDirectGdiDriver* theDGdiDriver = CDirectGdiDriver::Static();
   1.811 +	User::LeaveIfNull(theDGdiDriver);
   1.812 +	
   1.813 +	TSgImageInfo info;
   1.814 +	info.iUsage = ESgUsageDirectGdiTarget | ESgUsageCompositionSource;
   1.815 +	info.iSizeInPixels = TSize(TestWin->Size().iWidth, TestWin->Size().iHeight);
   1.816 +	info.iPixelFormat = EUidPixelFormatXRGB_8888;//among display modes with alpha channel only pre-multiply alpha is supported in directGDI currently
   1.817 +	
   1.818 +	RSgImageCollection imageCollection;
   1.819 +	CleanupClosePushL(imageCollection);
   1.820 +	TInt res = imageCollection.Create(info, 1);
   1.821 +	User::LeaveIfError(res);
   1.822 +	RSgImage image;
   1.823 +	CleanupClosePushL(image);
   1.824 +	res = imageCollection.OpenImage(0, image);
   1.825 +	User::LeaveIfError(res);
   1.826 +	RDirectGdiImageTarget imageTarget(*theDGdiDriver);
   1.827 +	CleanupClosePushL(imageTarget);
   1.828 +	res = imageTarget.Create(image);
   1.829 +	User::LeaveIfError(res);
   1.830 +#endif
   1.831 +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
   1.832 +	//create a bitmap
   1.833 +	CFbsBitmap *bitmap = new (ELeave) CFbsBitmap();
   1.834 +	User::LeaveIfError(bitmap->Create(TSize(TestWin->Size().iWidth, TestWin->Size().iHeight), EColor16MA));
   1.835 +	CleanupStack::PushL(bitmap);
   1.836 +
   1.837 +	CFbsBitmapDevice  *fbsDevice = CFbsBitmapDevice::NewL(bitmap);
   1.838 +	CleanupStack::PushL(fbsDevice);
   1.839 +#endif
   1.840 +
   1.841 +	//prepare the command buffer for playback
   1.842 +	RWsGraphicMsgBuf msgBuf;
   1.843 +	CleanupClosePushL(msgBuf);
   1.844 +
   1.845 +	//Externalize the captured commands from remote gc in to a buffer
   1.846 +	remoteGc->ExternalizeL(msgBuf, ETrue);
   1.847 +
   1.848 +	CWSGraphicsRes* wsGrap = new (ELeave) CWSGraphicsRes();
   1.849 +	CleanupStack::PushL(wsGrap);
   1.850 +
   1.851 +	CCommandBuffer* cmdBuf = CCommandBuffer::NewL();
   1.852 +	CleanupStack::PushL(cmdBuf);
   1.853 +	cmdBuf->InternalizeL(msgBuf.Pckg());
   1.854 +
   1.855 +	TRgb color;
   1.856 +	TRgb testColor(KRgbWhite);
   1.857 +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA
   1.858 +	CDirectGdiGcWrapper* directGdiGcWrapper=CDirectGdiGcWrapper::NewL(imageTarget);
   1.859 +	CleanupStack::PushL(directGdiGcWrapper);
   1.860 +	cmdBuf->Play(TPoint(),&KClippingRegion,KSourceRect,*wsGrap,*directGdiGcWrapper);
   1.861 +
   1.862 +	//check that the background has been cleared to transparent white.
   1.863 +	image.GetInfo(info);
   1.864 +	info.iUsage = ESgUsageNone;
   1.865 +	info.iCpuAccess = ESgCpuAccessReadOnly;
   1.866 +	RSgImage image1;
   1.867 +	CleanupClosePushL(image1);
   1.868 +	res = image1.Create(info, image);
   1.869 +	const TAny* data;
   1.870 +	TInt stride = 0;
   1.871 +	res = image1.MapReadOnly(data, stride);
   1.872 +	User::LeaveIfError(res);
   1.873 +	TPoint pixel(10,10);
   1.874 +	TInt offset = pixel.iY * stride + pixel.iX * 4;
   1.875 +	TAny* non_const_data = const_cast <TAny*> (data);
   1.876 +	TUint8* pointData = static_cast <TUint8*> (non_const_data) + offset;
   1.877 +	color = *(reinterpret_cast <TRgb*> (pointData));
   1.878 +	image1.Unmap();
   1.879 +#endif
   1.880 +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
   1.881 +	CFbsBitGc* fbsBitGc=NULL;
   1.882 +	User::LeaveIfError(fbsDevice->CreateContext(fbsBitGc));
   1.883 +	CleanupStack::PushL(fbsBitGc);
   1.884 +	fbsBitGc->Activate(fbsDevice);
   1.885 +	cmdBuf->Play(TPoint(0, 0), KSourceRect, *wsGrap, *fbsBitGc);
   1.886 +	bitmap->GetPixel(color, TPoint(10,10));
   1.887 +	testColor.SetAlpha(0);
   1.888 +#endif
   1.889 +	iStep->TEST(color==testColor);
   1.890 +
   1.891 +	//now test drawing to a window to ensure that the brush colour is
   1.892 +	//the window background colour
   1.893 +
   1.894 +	//display a blue window
   1.895 +	BaseWin->Win()->SetBackgroundColor(KRgbBlue);
   1.896 +	BaseWin->Win()->Invalidate();
   1.897 +	BaseWin->Win()->BeginRedraw();
   1.898 +	TheGc->Activate(*BaseWin->Win());
   1.899 +	TheGc->Clear();
   1.900 +	TheGc->Deactivate();
   1.901 +	BaseWin->Win()->EndRedraw();
   1.902 +	TheClient->iWs.Finish();
   1.903 +	TheClient->WaitForRedrawsToFinish();
   1.904 +
   1.905 +	//start drawing the display commands with a green background
   1.906 +	
   1.907 +	BaseWin->Win()->SetBackgroundColor(KRgbYellow);
   1.908 +	BaseWin->Win()->Invalidate();
   1.909 +	BaseWin->Win()->BeginRedraw();
   1.910 +	TheGc->Activate(*BaseWin->Win());
   1.911 +
   1.912 +	//Play the commands on test window using command buffer
   1.913 +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA
   1.914 +	cmdBuf->Play(TPoint(0, 0), &KClippingRegion, KSourceRect, TheClient->iWs, *TheGc);
   1.915 +#else
   1.916 +	cmdBuf->Play(TPoint(0, 0), KSourceRect, *wsGrap, *TheGc);
   1.917 +#endif
   1.918 +
   1.919 +	TheGc->Deactivate();
   1.920 +	BaseWin->Win()->EndRedraw();
   1.921 +	TheClient->iWs.Finish();
   1.922 +	TheClient->WaitForRedrawsToFinish();
   1.923 +
   1.924 +	//check that the background has been cleared to yellow, using brush colour
   1.925 +	TPoint position = BaseWin->Win()->InquireOffset(*TheClient->iGroup->WinTreeNode());
   1.926 +	position.iX+=10;
   1.927 +	position.iY+=10;
   1.928 +	TheClient->iScreen->GetPixel(color, position);
   1.929 +	iStep->TEST(color==KRgbYellow);
   1.930 +
   1.931 +	BaseWin->Win()->SetBackgroundColor(KRgbGreen); //set back to original backgroundcolor
   1.932 +
   1.933 +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA
   1.934 +	CleanupStack::PopAndDestroy(9, remoteGc);
   1.935 +#else
   1.936 +	CleanupStack::PopAndDestroy(7, remoteGc);
   1.937 +#endif
   1.938 +	}
   1.939 +
   1.940 +/**
   1.941 +@SYMTestCaseID		GRAPHICS-WSERV-0481
   1.942 +@SYMPREQ            1841
   1.943 +@SYMTestCaseDesc    Create font and graphics with various effect effects. Record the commands 
   1.944 +(like setting colours,drawing text etc) using CRemoteGc and play the recorded commands on a window. Use the same
   1.945 +commands in CWindowGc and draw text on a different window
   1.946 +@SYMTestPriority    Medium
   1.947 +@SYMTestStatus      Implemented
   1.948 +@SYMTestActions
   1.949 +@SYMTestExpectedResults Text/graphics drawn using CWindowGc and CRemoteGc should be same
   1.950 +*/
   1.951 +void CTGc::TestCommandBufferL()
   1.952 +	{	
   1.953 +	CWsScreenDevice* device = TheClient->iScreen;
   1.954 +
   1.955 +	_LIT(KBuffText,"Command Buffer");
   1.956 +	TFontSpec fSpec(KTestFontTypefaceName,23);
   1.957 +	fSpec.iFontStyle.SetBitmapType(EAntiAliasedGlyphBitmap);
   1.958 +	fSpec.iFontStyle.SetEffects(FontEffect::EDropShadow, ETrue);
   1.959 +	fSpec.iFontStyle.SetEffects(FontEffect::EOutline, ETrue);
   1.960 +	
   1.961 +	CFont *font;
   1.962 +	User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInPixels((CFont *&)font, fSpec));
   1.963 +	CleanupStack::PushL(TCleanupItem(CleanUpFont, font));
   1.964 +	
   1.965 +	CRemoteGc* remoteGc = CRemoteGc::NewL(device);
   1.966 +	CleanupStack::PushL(remoteGc);	
   1.967 +
   1.968 +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA
   1.969 +	//-------create image---------
   1.970 +	CDirectGdiDriver* theDGdiDriver = CDirectGdiDriver::Static();
   1.971 +	User::LeaveIfNull(theDGdiDriver);
   1.972 +	const TSize KImageSize = TSize(2, 2);
   1.973 +	TSgImageInfo info;
   1.974 +	info.iUsage = ESgUsageWindowGcSource;
   1.975 +	info.iSizeInPixels = KImageSize;
   1.976 +	info.iPixelFormat = EUidPixelFormatRGB_565;
   1.977 +	info.iShareable = ETrue;
   1.978 +	const TInt stride = KImageSize.iWidth * 2;
   1.979 +	TUint8* buf = (TUint8*) (User::AllocL(KImageSize.iHeight * stride));
   1.980 +	CleanupStack::PushL(buf);
   1.981 +	TUint16* bufCur = ((TUint16*)buf);
   1.982 +	*bufCur = KRgbRed.Color64K();
   1.983 +	*(bufCur + 1) = KRgbRed.Color64K();
   1.984 +	*(bufCur + 2) = KRgbRed.Color64K();
   1.985 +	*(bufCur + 3) = KRgbRed.Color64K();
   1.986 +
   1.987 +	RSgImage image;
   1.988 +	TInt res = image.Create(info, buf, stride);
   1.989 +	User::LeaveIfError(res);
   1.990 +	CleanupClosePushL(image);	
   1.991 +	RWsDrawableSource drawableSource(TheClient->iWs);
   1.992 +	res = drawableSource.Create(image, TheClient->iScreen->GetScreenNumber());
   1.993 +	if(res == KErrNotSupported)
   1.994 +		{
   1.995 +		INFO_PRINTF1(_L("The current screen is not supports drawable source. This test case terminates now."));
   1.996 +		CleanupStack::PopAndDestroy(3, remoteGc);
   1.997 +		CleanupStack::Pop();//font
   1.998 +		TheClient->iScreen->ReleaseFont(font);
   1.999 +		return;
  1.1000 +		}
  1.1001 +	User::LeaveIfError(res);
  1.1002 +	CleanupClosePushL(drawableSource);	
  1.1003 +	//-------end create image---------
  1.1004 +#endif	
  1.1005 +	remoteGc->ResetCommandBuffer();
  1.1006 +	remoteGc->BeginDraw(TRect(0, 0, TestWin->Size().iWidth, TestWin->Size().iHeight));
  1.1007 +	//Capturing the commands in remote gc
  1.1008 +	remoteGc->Clear();
  1.1009 +	remoteGc->DrawRect(TRect(10,10,30,30));
  1.1010 +	remoteGc->Clear(TRect(10,10,11,11));
  1.1011 +	remoteGc->CopyRect(TPoint(5,5), TRect(25,25,30,30));
  1.1012 +	CFbsBitmap* bitmap = new (ELeave) CFbsBitmap;
  1.1013 +	CFbsBitmap* bitmapMask = new (ELeave) CFbsBitmap;
  1.1014 +	User::LeaveIfError(bitmap->Load(_L("Z:\\WSTEST\\WSAUTOTEST.MBM"), EMbmWsautotestCircles24b));
  1.1015 +	User::LeaveIfError(bitmapMask->Load(_L("Z:\\WSTEST\\WSAUTOTEST.MBM"), EMbmWsautotestCircles_mask2b));
  1.1016 +	remoteGc->BitBlt(TPoint(100,100), bitmap);
  1.1017 +	remoteGc->BitBlt(TPoint(0,0), bitmap, TRect(0,0,1,1));	
  1.1018 +	remoteGc->BitBltMasked(TPoint(0,5), bitmap, TRect(0,0,1,1), bitmapMask, EFalse);
  1.1019 +	CWsBitmap* bitmapWs = new (ELeave) CWsBitmap(TheClient->iWs);
  1.1020 +	CWsBitmap* bitmapWsMask = new (ELeave) CWsBitmap(TheClient->iWs);
  1.1021 +	User::LeaveIfError(bitmapWs->Load(_L("Z:\\WSTEST\\TEST.MBM"), 0));
  1.1022 +	remoteGc->BitBlt(TPoint(110,110), bitmapWs);
  1.1023 +	remoteGc->BitBlt(TPoint(5,0), bitmapWs, TRect(0,0,1,1));
  1.1024 +	remoteGc->BitBltMasked(TPoint(10,0), bitmap, TRect(0,0,1,1), bitmapWsMask, EFalse);
  1.1025 +	remoteGc->SetFadingParameters(128,128);
  1.1026 +	remoteGc->SetFaded(EFalse);	
  1.1027 +	remoteGc->AlphaBlendBitmaps(TPoint(2,2), bitmap, TRect(0,0,1,1), bitmapMask, TPoint(2,2));
  1.1028 +	remoteGc->AlphaBlendBitmaps(TPoint(3,3), bitmapWs, TRect(0,0,1,1), bitmapWsMask, TPoint(2,2));
  1.1029 +	remoteGc->SetOrigin(TPoint(0,30));
  1.1030 +	remoteGc->SetDrawMode(CGraphicsContext::EDrawModePEN);
  1.1031 +	remoteGc->SetClippingRect(TRect(0,0,10,10));
  1.1032 +	remoteGc->SetPenStyle(CGraphicsContext::ESolidPen);
  1.1033 +	remoteGc->SetPenSize(TSize(1,2));
  1.1034 +	remoteGc->UseBrushPattern(bitmap);
  1.1035 +	remoteGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.1036 +	remoteGc->SetBrushOrigin(TPoint(0,0));
  1.1037 +	remoteGc->DrawPie(TRect(0,0,15,15),TPoint(0,8),TPoint(15,8));
  1.1038 +	remoteGc->CancelClippingRect();
  1.1039 +	remoteGc->DiscardBrushPattern();
  1.1040 +	remoteGc->CancelClippingRegion();
  1.1041 +	remoteGc->Reset();
  1.1042 +	remoteGc->SetOrigin(TPoint(0,0));
  1.1043 +	remoteGc->SetUnderlineStyle(EUnderlineOff);
  1.1044 +	remoteGc->SetStrikethroughStyle(EStrikethroughOff);
  1.1045 +	remoteGc->SetWordJustification(1,2);
  1.1046 +	remoteGc->SetCharJustification(1,2);
  1.1047 +	remoteGc->UseFont(font);
  1.1048 +	remoteGc->DrawText(KBuffText,TRect(50,0,100,50),10,CGraphicsContext::ELeft,0);
  1.1049 +	remoteGc->DrawTextVertical(KBuffText,TPoint(170,20),EFalse);
  1.1050 +	remoteGc->DrawTextVertical(KBuffText,TRect(120,20,150,100),5,EFalse,CGraphicsContext::ELeft,0);	
  1.1051 +	remoteGc->MoveTo(TPoint(25,150));
  1.1052 +	remoteGc->MoveBy(TPoint(5,5));
  1.1053 +	remoteGc->DrawLineTo(TPoint(35,160));
  1.1054 +	remoteGc->DrawLine(TPoint(35,160),TPoint(25,150));
  1.1055 +	remoteGc->DrawLineBy(TPoint(15,6));	
  1.1056 +	remoteGc->Plot(TPoint(5,5));	
  1.1057 +	remoteGc->DrawArc(TRect(0,80,10,90),TPoint(0,85),TPoint(10,85));
  1.1058 +	remoteGc->DrawEllipse(TRect(0,90,10,100));	
  1.1059 +	remoteGc->DrawRoundRect(TRect(30,80,50,100),TSize(5,5));	
  1.1060 +	remoteGc->DrawBitmap(TPoint(150,150),bitmap);	
  1.1061 +	remoteGc->DrawBitmap(TRect(160,160,170,170), bitmap);	
  1.1062 +	remoteGc->DrawBitmap(TRect(175,175,180,180), bitmap, TRect(0,5,5,10));	
  1.1063 +	remoteGc->DrawBitmapMasked(TRect(185,185,190,190), bitmap, TRect(0,50,5,55),bitmapMask,EFalse);
  1.1064 +	remoteGc->DrawBitmapMasked(TRect(195,195,200,200), bitmapWs, TRect(0,50,5,55),bitmapWsMask,EFalse);		
  1.1065 +	CArrayFixFlat<TPoint>* polyPoints = new(ELeave) CArrayFixFlat<TPoint>(3); //CArrayFixFlat
  1.1066 +	CleanupStack::PushL(polyPoints);
  1.1067 +	TRect rect (200,0,200,100);
  1.1068 +	polyPoints->AppendL(rect.iTl);
  1.1069 +	polyPoints->AppendL(rect.Center());
  1.1070 +	polyPoints->AppendL(TPoint(rect.iBr.iX, rect.iTl.iY));	
  1.1071 +	remoteGc->DrawPolyLine(polyPoints);
  1.1072 +	remoteGc->DrawPolyLine(&polyPoints->At(0), 3);
  1.1073 +	remoteGc->DrawPolygon(polyPoints, CGraphicsContext::EWinding);
  1.1074 +	remoteGc->DrawPolygon(&polyPoints->At(0), 3, CGraphicsContext::EAlternate);
  1.1075 +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA
  1.1076 +	MWsDrawResource* dr = static_cast<MWsDrawResource*>(remoteGc->Interface(KMWsDrawResourceInterfaceUid));
  1.1077 +	if(dr)
  1.1078 +		dr->DrawResource(TPoint(30, 40), drawableSource);
  1.1079 +#endif
  1.1080 +	RRegion region;
  1.1081 +	remoteGc->SetClippingRegion(region);
  1.1082 +	remoteGc->DiscardFont();
  1.1083 +	remoteGc->EndDraw();
  1.1084 +
  1.1085 +	RWsGraphicMsgBuf msgBuf;
  1.1086 +	CleanupClosePushL(msgBuf);
  1.1087 +	//Externalize the captured commands from remote gc in to a buffer
  1.1088 +	remoteGc->ExternalizeL(msgBuf, EFalse);
  1.1089 +	
  1.1090 +	CCommandBuffer* cmdBuf = CCommandBuffer::NewL();
  1.1091 +	CleanupStack::PushL(cmdBuf);
  1.1092 +	const CCommandBuffer* testCmdBuf = CCommandBuffer::NewL();
  1.1093 +	if(cmdBuf->IsIdentical(*testCmdBuf)==EFalse)
  1.1094 +		{
  1.1095 +		User::Panic(_L("TestCommandBufferL"), KErrGeneral);
  1.1096 +		}
  1.1097 +	delete testCmdBuf;
  1.1098 +	//Internalize the buffer with captured commands (from CRemoteGC) 
  1.1099 +	//in to CCommandBuffer
  1.1100 +	cmdBuf->InternalizeL(msgBuf.Pckg());
  1.1101 +	
  1.1102 +	TheGc->Activate(*TestWin->Win());
  1.1103 +	TestWin->Win()->Invalidate();
  1.1104 +	
  1.1105 +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
  1.1106 +	/*
  1.1107 +	 * Make sure anything that can leave is done outside the
  1.1108 +	 * BeginRedraw/EndRedraw bracket.
  1.1109 +	 */
  1.1110 +	CWSGraphicsRes* wsGrap=new(ELeave) CWSGraphicsRes();
  1.1111 +	CleanupStack::PushL(wsGrap);
  1.1112 +#endif
  1.1113 +	/*
  1.1114 +	 * Note we need to still do BeginRedraw/EndRedraw for the TestWin Window
  1.1115 +	 * even though the CRemoteGc we are going to Play into TestWin already has
  1.1116 +	 * BeginRedraw/EndRedraw commands issued into it.  Those commands just allow
  1.1117 +	 * for replacement of draw ops already in the CRemoteGc to be replaced by
  1.1118 +	 * new draw ops covering the same area.  The BeginRedraw/EndRedraws never 
  1.1119 +	 * get Play()'ed into TestWin.
  1.1120 +	 */
  1.1121 +	TestWin->Win()->BeginRedraw();
  1.1122 +	TheGc->Clear();
  1.1123 +	//Play the commands on test window using command buffer
  1.1124 +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA
  1.1125 +	cmdBuf->Play(TPoint(), NULL, TRect(TestWin->Size()), TheClient->iWs, *TheGc);
  1.1126 +#endif
  1.1127 +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
  1.1128 +	cmdBuf->Play(TPoint(),TRect(TestWin->Size()),*wsGrap,*TheGc);
  1.1129 +	CleanupStack::PopAndDestroy(wsGrap);
  1.1130 +#endif
  1.1131 +	TheGc->Deactivate();
  1.1132 +	TestWin->Win()->EndRedraw();
  1.1133 +	remoteGc->ResetCommandBuffer();
  1.1134 +	BaseWin->Win()->Invalidate();
  1.1135 +	BaseWin->Win()->BeginRedraw();
  1.1136 +	TheGc->Activate(*BaseWin->Win());
  1.1137 +	TheGc->Clear();
  1.1138 +	TheGc->DrawRect(TRect(10,10,30,30));
  1.1139 +	TheGc->Clear(TRect(10,10,11,11));
  1.1140 +	TheGc->CopyRect(TPoint(5,5), TRect(25,25,30,30));
  1.1141 +	TheGc->BitBlt(TPoint(100,100), bitmap);
  1.1142 +	TheGc->BitBlt(TPoint(0,0), bitmap, TRect(0,0,1,1));	
  1.1143 +	TheGc->BitBltMasked(TPoint(0,5), bitmap, TRect(0,0,1,1), bitmapMask, EFalse);
  1.1144 +	TheGc->BitBlt(TPoint(110,110), bitmapWs);
  1.1145 +	TheGc->BitBlt(TPoint(5,0), bitmapWs, TRect(0,0,1,1));
  1.1146 +	TheGc->BitBltMasked(TPoint(10,0), bitmap, TRect(0,0,1,1), bitmapWsMask, EFalse);
  1.1147 +	TheGc->SetFadingParameters(128,128);
  1.1148 +	TheGc->SetFaded(EFalse);	
  1.1149 +	TheGc->AlphaBlendBitmaps(TPoint(2,2), bitmap, TRect(0,0,1,1), bitmapMask, TPoint(2,2));
  1.1150 +	TheGc->AlphaBlendBitmaps(TPoint(3,3), bitmapWs, TRect(0,0,1,1), bitmapWsMask, TPoint(2,2));
  1.1151 +	TheGc->SetOrigin(TPoint(0,30));
  1.1152 +	TheGc->SetDrawMode(CGraphicsContext::EDrawModePEN);
  1.1153 +	TheGc->SetClippingRect(TRect(0,0,10,10));
  1.1154 +	TheGc->SetPenStyle(CGraphicsContext::ESolidPen);
  1.1155 +	TheGc->SetPenSize(TSize(1,2));
  1.1156 +	TheGc->UseBrushPattern(bitmap);
  1.1157 +	TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.1158 +	TheGc->SetBrushOrigin(TPoint(0,0));
  1.1159 +	TheGc->DrawPie(TRect(0,0,15,15),TPoint(0,8),TPoint(15,8));
  1.1160 +	TheGc->CancelClippingRect();
  1.1161 +	TheGc->DiscardBrushPattern();
  1.1162 +	TheGc->CancelClippingRegion();
  1.1163 +	TheGc->Reset();
  1.1164 +	TheGc->SetOrigin(TPoint(0,0));
  1.1165 +	TheGc->SetUnderlineStyle(EUnderlineOff);
  1.1166 +	TheGc->SetStrikethroughStyle(EStrikethroughOff);
  1.1167 +	TheGc->SetWordJustification(1,2);
  1.1168 +	TheGc->SetCharJustification(1,2);
  1.1169 +	TheGc->UseFont(font);
  1.1170 +	TheGc->DrawText(KBuffText,TRect(50,0,100,50),10,CGraphicsContext::ELeft,0);
  1.1171 +	TheGc->DrawTextVertical(KBuffText,TPoint(170,20),EFalse);
  1.1172 +	TheGc->DrawTextVertical(KBuffText,TRect(120,20,150,100),5,EFalse,CGraphicsContext::ELeft,0);	
  1.1173 +	TheGc->MoveTo(TPoint(25,150));
  1.1174 +	TheGc->MoveBy(TPoint(5,5));
  1.1175 +	TheGc->DrawLineTo(TPoint(35,160));
  1.1176 +	TheGc->DrawLine(TPoint(35,160),TPoint(25,150));
  1.1177 +	TheGc->DrawLineBy(TPoint(15,6));	
  1.1178 +	TheGc->Plot(TPoint(5,5));	
  1.1179 +	TheGc->DrawArc(TRect(0,80,10,90),TPoint(0,85),TPoint(10,85));
  1.1180 +	TheGc->DrawEllipse(TRect(0,90,10,100));	
  1.1181 +	TheGc->DrawRoundRect(TRect(30,80,50,100),TSize(5,5));	
  1.1182 +	TheGc->DrawBitmap(TPoint(150,150),bitmap);	
  1.1183 +	TheGc->DrawBitmap(TRect(160,160,170,170), bitmap);	
  1.1184 +	TheGc->DrawBitmap(TRect(175,175,180,180), bitmap, TRect(0,5,5,10));	
  1.1185 +	TheGc->DrawBitmapMasked(TRect(185,185,190,190), bitmap, TRect(0,50,5,55),bitmapMask,EFalse);
  1.1186 +	TheGc->DrawBitmapMasked(TRect(195,195,200,200), bitmapWs, TRect(0,50,5,55),bitmapWsMask,EFalse);
  1.1187 +	TheGc->DrawPolyLine(polyPoints);
  1.1188 +	TheGc->DrawPolyLine(&polyPoints->At(0), 3);
  1.1189 +	TheGc->DrawPolygon(polyPoints, CGraphicsContext::EWinding);
  1.1190 +	TheGc->DrawPolygon(&polyPoints->At(0), 3, CGraphicsContext::EAlternate);
  1.1191 +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA
  1.1192 +	TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.1193 +	TheGc->SetBrushColor(KRgbRed);
  1.1194 +	TheGc->SetPenColor(KRgbRed);
  1.1195 +	TheGc->DrawRect(TRect(30, 40, 32, 42));
  1.1196 +#endif
  1.1197 +	TheGc->DiscardFont();
  1.1198 +	TheGc->Deactivate();
  1.1199 +	BaseWin->Win()->EndRedraw();
  1.1200 +	TheClient->Flush();
  1.1201 +	TheClient->WaitForRedrawsToFinish();
  1.1202 +
  1.1203 +	//Check the text drawn on base and test windows.
  1.1204 +	TBool err = CheckRect(BaseWin, TestWin, TRect(0, 0, BaseWin->Size().iWidth, BaseWin->Size().iHeight), _L("CTGc::TestCommandBufferL()"));
  1.1205 +	if (err)
  1.1206 +	    {
  1.1207 +	    INFO_PRINTF1(_L("The CheckRect function returned error."));
  1.1208 +	    }
  1.1209 +	delete bitmap;
  1.1210 +	INFO_PRINTF1(_L("bitmap deleted."));
  1.1211 +	delete bitmapMask;
  1.1212 +	INFO_PRINTF1(_L("bitmapMask deleted."));
  1.1213 +	delete bitmapWs;
  1.1214 +	INFO_PRINTF1(_L("bitmapWs deleted."));
  1.1215 +	delete bitmapWsMask;
  1.1216 +	INFO_PRINTF1(_L("bitmapWsMask deleted."));
  1.1217 +	
  1.1218 +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA
  1.1219 +	CleanupStack::PopAndDestroy(7, remoteGc);
  1.1220 +#else
  1.1221 +	CleanupStack::PopAndDestroy(4, remoteGc);
  1.1222 +#endif	
  1.1223 +	CleanupStack::Pop();//font
  1.1224 +	INFO_PRINTF1(_L("CleanupStack popped."));
  1.1225 +	TheClient->iScreen->ReleaseFont(font);
  1.1226 +	}
  1.1227 +
  1.1228 +/**
  1.1229 +@SYMTestCaseID		GRAPHICS-WSERV-0482
  1.1230 +@SYMPREQ            1841
  1.1231 +@SYMTestCaseDesc    Play empty command buffer.
  1.1232 +@SYMTestPriority    Medium
  1.1233 +@SYMTestStatus      Implemented
  1.1234 +@SYMTestActions
  1.1235 +@SYMTestExpectedResults return KErrEof error
  1.1236 +*/
  1.1237 +void CTGc::TestEmptyCommandBufferL()
  1.1238 +	{
  1.1239 +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
  1.1240 +	CWSGraphicsRes* wsGrap = new (ELeave) CWSGraphicsRes();
  1.1241 +	CleanupStack::PushL(wsGrap);
  1.1242 +#endif
  1.1243 +
  1.1244 +	CCommandBuffer* cmdBuf = CCommandBuffer::NewL();
  1.1245 +	CleanupStack::PushL(cmdBuf);
  1.1246 +
  1.1247 +	TheGc->Activate(*TestWin->Win());
  1.1248 +	TheGc->Clear();
  1.1249 +	//Play the commands on test window using command buffer
  1.1250 +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
  1.1251 +	TInt err = cmdBuf->Play(TPoint(),TRect(TestWin->Size()),*wsGrap,*TheGc);
  1.1252 +#else
  1.1253 +	TInt err = cmdBuf->Play(TPoint(),NULL,TRect(TestWin->Size()),TheClient->iWs,*TheGc);
  1.1254 +#endif
  1.1255 +	if(err!=KErrEof)
  1.1256 +		{
  1.1257 +		User::Panic(_L("TestEmptyCommandBufferL"), KErrGeneral);
  1.1258 +		}
  1.1259 +	TheGc->Deactivate();
  1.1260 +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
  1.1261 +	CleanupStack::PopAndDestroy(2, wsGrap); //cmdBuf, wsGrap, msgBuf and remoteGc
  1.1262 +#else
  1.1263 +	CleanupStack::PopAndDestroy(cmdBuf);
  1.1264 +#endif
  1.1265 +	}
  1.1266 +
  1.1267 +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA
  1.1268 +/**
  1.1269 +@SYMTestCaseID		GRAPHICS-WSERV-0486
  1.1270 +@SYMPREQ            PREQ2095
  1.1271 +@SYMTestCaseDesc    Draw text using CWindowGc and CRemoteGc with both outline and shadow
  1.1272 +effect on.
  1.1273 +@SYMTestPriority    High
  1.1274 +@SYMTestStatus      Implemented
  1.1275 +@SYMTestActions     Create a font with both outline and shadow effects, also use ClippingRect 
  1.1276 +and ClippingRegion. Record the commands using CRemoteGc and play the recorded commands on a 
  1.1277 +bitmap using MWsGraphicsContext. Use the same commands in CWindowGc and draw text on a 
  1.1278 +different window
  1.1279 +@SYMTestExpectedResults Text drawn using CWindowGc and CRemoteGc(MWsGraphicsContext) should be same
  1.1280 +*/
  1.1281 +void CTGc::TestCRemoteGcAndMWsGraphicsContextClippingRectL()
  1.1282 +	{
  1.1283 +	const TRect KTestRect(0, 0, TestWin->Size().iWidth, TestWin->Size().iHeight);
  1.1284 +	const TRegionFix<1> KTestRegion(KTestRect);
  1.1285 +	const TRect KClippingRect1(5, 5, TestWin->Size().iWidth-10, 90);
  1.1286 +	const TRegionFix<1> KClippingRegion(KClippingRect1);
  1.1287 +	const TRect KClippingRect2(15, 15, TestWin->Size().iWidth-10, TestWin->Size().iHeight-10);
  1.1288 +	
  1.1289 +	CWsScreenDevice* device = TheClient->iScreen;
  1.1290 +	/*
  1.1291 +	 * On hardware, the first screen runs in 64K colors, but the second screen (TV OUT)
  1.1292 +	 * cannot run in this mode, it instead falls back to 16M colors.  We need to ensure
  1.1293 +	 * that we use matching color depths for our off-screen bitmaps so that accuracy is
  1.1294 +	 * not lost since we compare bitmaps from the screen versus off-screen.
  1.1295 +	 */
  1.1296 +	TDisplayMode displayMode = device->DisplayMode();
  1.1297 +	if (TDisplayModeUtils::NumDisplayModeBitsPerPixel(displayMode) == 32)
  1.1298 +	    {
  1.1299 +	    displayMode = EColor16MAP;
  1.1300 +	    }
  1.1301 +		
  1.1302 +	_LIT(KText,"RemoteGc & MWsGraphicsContext");
  1.1303 +	TFontSpec fSpec(KTestFontTypefaceName,23);
  1.1304 +	fSpec.iFontStyle.SetBitmapType(EAntiAliasedGlyphBitmap);
  1.1305 +	fSpec.iFontStyle.SetEffects(FontEffect::EDropShadow, ETrue);
  1.1306 +	fSpec.iFontStyle.SetEffects(FontEffect::EOutline, ETrue);
  1.1307 +	
  1.1308 +	CFont *font;
  1.1309 +	User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInPixels((CFont *&)font, fSpec));
  1.1310 +	CleanupStack::PushL(TCleanupItem(CleanUpFont, font));
  1.1311 +
  1.1312 +	//Record the commands using CRemoteGc
  1.1313 +	CRemoteGc* remoteGc = CRemoteGc::NewL(device);
  1.1314 +	CleanupStack::PushL(remoteGc);
  1.1315 +	remoteGc->BeginDraw(KTestRect);
  1.1316 +	//fill background with white
  1.1317 +	remoteGc->SetPenStyle(CFbsBitGc::ENullPen);
  1.1318 +	remoteGc->SetBrushStyle(CFbsBitGc::ESolidBrush);
  1.1319 +	remoteGc->SetBrushColor(KRgbWhite);
  1.1320 +	remoteGc->DrawRect(TRect(TPoint(0,0), TestWin->Size()));
  1.1321 +	remoteGc->SetPenStyle(CFbsBitGc::ESolidPen);
  1.1322 +	//Capturing the commands in remote gc
  1.1323 +	remoteGc->SetClippingRect(KClippingRect2);
  1.1324 +	remoteGc->SetClippingRegion(KClippingRegion);
  1.1325 +	remoteGc->SetBrushStyle(CFbsBitGc::ESolidBrush);
  1.1326 +	remoteGc->SetBrushColor(TRgb(0,150,150));
  1.1327 +	remoteGc->DrawRect(TRect(TPoint(0,0), TSize(160,60)));
  1.1328 +	remoteGc->SetBrushColor(TRgb(150,100,150));
  1.1329 +	remoteGc->DrawRect(TRect(TPoint(0,60), TSize(160,60)));
  1.1330 +	remoteGc->SetBrushColor(KRgbGreen);
  1.1331 +	remoteGc->SetShadowColor(KRgbDarkRed);
  1.1332 +	remoteGc->SetPenColor(KRgbBlack);
  1.1333 +	remoteGc->UseFont(font);
  1.1334 +	remoteGc->DrawText(KText, TPoint(2,40));
  1.1335 +	remoteGc->DiscardFont();
  1.1336 +	remoteGc->EndDraw();
  1.1337 +
  1.1338 +	RWsGraphicMsgBuf msgBuf;
  1.1339 +	CleanupClosePushL(msgBuf);
  1.1340 +	//Externalize the captured commands from remote gc in to a buffer
  1.1341 +	remoteGc->ExternalizeL(msgBuf, ETrue);
  1.1342 +	
  1.1343 +	CCommandBuffer* cmdBuf = CCommandBuffer::NewL();
  1.1344 +	CleanupStack::PushL(cmdBuf);
  1.1345 +	//Internalize the buffer with captured commands (from CRemoteGC) 
  1.1346 +	//in to CCommandBuffer
  1.1347 +	cmdBuf->InternalizeL(msgBuf.Pckg());
  1.1348 +	
  1.1349 +	CDirectGdiDriver* theDGdiDriver = CDirectGdiDriver::Static();
  1.1350 +	User::LeaveIfNull(theDGdiDriver);
  1.1351 +	
  1.1352 +	TSgImageInfo info;
  1.1353 +	info.iUsage = ESgUsageDirectGdiTarget | ESgUsageDirectGdiSource | ESgUsageCompositionSource;
  1.1354 +	info.iSizeInPixels = TestWin->Size();
  1.1355 +	info.iPixelFormat = PixelFormatFromDisplayMode(displayMode);
  1.1356 +	
  1.1357 +	RSgImageCollection imageCollection;
  1.1358 +	CleanupClosePushL(imageCollection);
  1.1359 +	TInt res = imageCollection.Create(info, 1);
  1.1360 +	User::LeaveIfError(res);
  1.1361 +	RSgImage image;
  1.1362 +	CleanupClosePushL(image);
  1.1363 +	res = imageCollection.OpenImage(0, image);
  1.1364 +	User::LeaveIfError(res);
  1.1365 +	RDirectGdiImageTarget imageTarget(*theDGdiDriver);
  1.1366 +	CleanupClosePushL(imageTarget);
  1.1367 +	
  1.1368 +	res = imageTarget.Create(image);
  1.1369 +	User::LeaveIfError(res);
  1.1370 +	
  1.1371 +	CDirectGdiGcWrapper* directGdiGcWrapper = CDirectGdiGcWrapper::NewL(imageTarget);
  1.1372 +	CleanupStack::PushL(directGdiGcWrapper);
  1.1373 +	
  1.1374 +	//Dummy class created
  1.1375 +	CWSGraphicsRes* wsGrap = new (ELeave) CWSGraphicsRes();
  1.1376 +	CleanupStack::PushL(wsGrap);
  1.1377 +
  1.1378 +	//Play the commands on test window using command buffer
  1.1379 +	cmdBuf->Play(TPoint(),&KTestRegion,KTestRect,*wsGrap,*directGdiGcWrapper);
  1.1380 +
  1.1381 +	//Set window back to same as test bitmap background
  1.1382 +	BaseWin->Win()->SetBackgroundColor(KRgbWhite);
  1.1383 +
  1.1384 +	BaseWin->Win()->Invalidate();
  1.1385 +	BaseWin->Win()->BeginRedraw();
  1.1386 +	TheGc->Activate(*BaseWin->Win());
  1.1387 +	TheGc->Clear();
  1.1388 +	TheGc->SetClippingRect(KClippingRect2);
  1.1389 +	TheGc->SetClippingRegion(KClippingRegion);
  1.1390 +	TheGc->SetBrushStyle(CFbsBitGc::ESolidBrush);
  1.1391 +	TheGc->SetBrushColor(TRgb(0,150,150));
  1.1392 +	TheGc->DrawRect(TRect(TPoint(0,0), TSize(160,60)));
  1.1393 +	TheGc->SetBrushColor(TRgb(150,100,150));
  1.1394 +	TheGc->DrawRect(TRect(TPoint(0,60), TSize(160,60)));
  1.1395 +	TheGc->SetBrushColor(KRgbGreen);
  1.1396 +	TheGc->SetShadowColor(KRgbDarkRed);
  1.1397 +	TheGc->SetPenColor(KRgbBlack);
  1.1398 +	TheGc->UseFont(font);
  1.1399 +	//Draw the text on base window using CWindowGC
  1.1400 +	TheGc->DrawText(KText, TPoint(2, 40));
  1.1401 +	TheGc->DiscardFont();
  1.1402 +	TheGc->Deactivate();
  1.1403 +	BaseWin->Win()->EndRedraw();
  1.1404 +	TheClient->iWs.Finish();
  1.1405 +	TheClient->WaitForRedrawsToFinish();
  1.1406 +
  1.1407 +	//Create a bitmap and then copy the screen to it
  1.1408 +	TRect rc(TRect(BaseWin->Win()->AbsPosition(), BaseWin->Win()->Size()));
  1.1409 +	CFbsBitmap *screenBitmap = new (ELeave) CFbsBitmap();
  1.1410 +	User::LeaveIfError(screenBitmap->Create(rc.Size(), displayMode));
  1.1411 +	CleanupStack::PushL(screenBitmap);
  1.1412 +	TheClient->iScreen->CopyScreenToBitmap(screenBitmap, rc);
  1.1413 +
  1.1414 +	CFbsBitmap* bitmap = new (ELeave) CFbsBitmap;
  1.1415 +	CleanupStack::PushL(bitmap);
  1.1416 +
  1.1417 +	image.GetInfo(info);
  1.1418 +	bitmap->Create(info.iSizeInPixels, displayMode);
  1.1419 +	TRect rect(info.iSizeInPixels);
  1.1420 +	CopyImageToBitmapL(bitmap, image, rect);
  1.1421 +
  1.1422 +	//Test to see if the bitmap drawn to using CRemoteGc is the same as the screen copy bitmap
  1.1423 +	TInt differentPixels = 0;
  1.1424 +	res = LossyCompareBitmapRecord(*bitmap, *screenBitmap, KTestRect, EFalse, differentPixels, Logger());
  1.1425 +	if (differentPixels != 0)
  1.1426 +		{
  1.1427 +		INFO_PRINTF2(_L(" Pixels different %d"), differentPixels);
  1.1428 +		}
  1.1429 +	TEST(res);
  1.1430 +	CleanupStack::PopAndDestroy(10, remoteGc); //screenBitmap, imageCollection, image, imageTarget, directGdiGcWrapper, cmdBuf, wsGrap, msgBuf, remoteGc, bitmap
  1.1431 +	CleanupStack::Pop();//font
  1.1432 +	TheClient->iScreen->ReleaseFont(font);
  1.1433 +	}
  1.1434 +
  1.1435 +/**
  1.1436 +@SYMTestCaseID		GRAPHICS-WSERV-0487
  1.1437 +@SYMPREQ            PREQ2095
  1.1438 +@SYMTestCaseDesc    Draw text using CRemoteGc and DrawText(const TDesC&,const TTextParameters*,const TPoint&)
  1.1439 +@SYMTestPriority    High
  1.1440 +@SYMTestStatus      Implemented
  1.1441 +@SYMTestActions     Create a font.  Draw text to a bitmap with the font using CFbsBitGc::DrawText. Draw text with the font using CFbsBitGc::DrawText.
  1.1442 +Record the same DrawText commands using CRemoteGc and play the recorded commands on a 
  1.1443 +bitmap using MWsGraphicsContext. Compare the two bitmaps.
  1.1444 +@SYMTestExpectedResults Text drawn using CFbsBitGc and CRemoteGc(MWsGraphicsContext) should be the same
  1.1445 +*/
  1.1446 +void CTGc::TestCRemoteGcDrawTextInContextPointL()
  1.1447 +	{
  1.1448 +	CDrawTextInContextTestPoint* test = CDrawTextInContextTestPoint::NewL();
  1.1449 +	CleanupStack::PushL(test);
  1.1450 +	test->Test();
  1.1451 +	TEST(test->HasPassedTest());
  1.1452 +	CleanupStack::PopAndDestroy(); //test
  1.1453 +	}
  1.1454 +
  1.1455 +/**
  1.1456 +@SYMTestCaseID		GRAPHICS-WSERV-0488
  1.1457 +@SYMPREQ            PREQ2095
  1.1458 +@SYMTestCaseDesc    Draw text using CRemoteGc and DrawText(const TDesC&,const TTextParameters*,const TRect&,TInt,TTextAlign,TInt)
  1.1459 +@SYMTestPriority    High
  1.1460 +@SYMTestStatus      Implemented
  1.1461 +@SYMTestActions     Create a font.  Draw text to a bitmap with the font using CFbsBitGc::DrawText. Draw text with the font using CFbsBitGc::DrawText.
  1.1462 +Record the same DrawText commands using CRemoteGc and play the recorded commands on a 
  1.1463 +bitmap using MWsGraphicsContext. Compare the two bitmaps.
  1.1464 +@SYMTestExpectedResults Text drawn using CFbsBitGc and CRemoteGc(MWsGraphicsContext) should be the same
  1.1465 +*/
  1.1466 +void CTGc::TestCRemoteGcDrawTextInContextBoxL()
  1.1467 +	{
  1.1468 +	CDrawTextInContextTestBox* test = CDrawTextInContextTestBox::NewL();
  1.1469 +	CleanupStack::PushL(test);
  1.1470 +	test->Test();
  1.1471 +	TEST(test->HasPassedTest());
  1.1472 +	CleanupStack::PopAndDestroy(); //test
  1.1473 +	}
  1.1474 +
  1.1475 +/**
  1.1476 +@SYMTestCaseID		GRAPHICS-WSERV-0489
  1.1477 +@SYMPREQ            PREQ2095
  1.1478 +@SYMTestCaseDesc    Draw text using CRemoteGc and DrawTextVertical(const TDesC&,const TTextParameters*,const TPoint&)
  1.1479 +@SYMTestPriority    High
  1.1480 +@SYMTestStatus      Implemented
  1.1481 +@SYMTestActions     Create a font.  Draw text to a bitmap with the font using CFbsBitGc::DrawTextVertical. Draw text with the font using CFbsBitGc::DrawText.
  1.1482 +Record the same DrawText commands using CRemoteGc and play the recorded commands on a 
  1.1483 +bitmap using MWsGraphicsContext. Compare the two bitmaps.
  1.1484 +@SYMTestExpectedResults Text drawn using CFbsBitGc and CRemoteGc(MWsGraphicsContext) should be the same
  1.1485 +*/
  1.1486 +void CTGc::TestCRemoteGcDrawTextInContextPointVerticalL()
  1.1487 +	{
  1.1488 +	CDrawTextInContextTestPointVertical* test = CDrawTextInContextTestPointVertical::NewL();
  1.1489 +	CleanupStack::PushL(test);
  1.1490 +	test->Test();
  1.1491 +	TEST(test->HasPassedTest());
  1.1492 +	CleanupStack::PopAndDestroy(); //test
  1.1493 +	}
  1.1494 +
  1.1495 +/**
  1.1496 +@SYMTestCaseID		GRAPHICS-WSERV-0490
  1.1497 +@SYMPREQ            PREQ2095
  1.1498 +@SYMTestCaseDesc    Draw text using CRemoteGc and DrawTextVertical(const TDesC&,const TTextParameters*,const TRect&,TInt,TTextAlign,TInt)
  1.1499 +@SYMTestPriority    High
  1.1500 +@SYMTestStatus      Implemented
  1.1501 +@SYMTestActions     Create a font.  Draw text to a bitmap with the font using CFbsBitGc::DrawTextVertical. Draw text with the font using CFbsBitGc::DrawText.
  1.1502 +Record the same DrawText commands using CRemoteGc and play the recorded commands on a 
  1.1503 +bitmap using MWsGraphicsContext. Compare the two bitmaps.
  1.1504 +@SYMTestExpectedResults Text drawn using CFbsBitGc and CRemoteGc(MWsGraphicsContext) should be the same
  1.1505 +*/
  1.1506 +void CTGc::TestCRemoteGcDrawTextInContextBoxVerticalL()
  1.1507 +	{
  1.1508 +	CDrawTextInContextTestBoxVertical* test = CDrawTextInContextTestBoxVertical::NewL();
  1.1509 +	CleanupStack::PushL(test);
  1.1510 +	test->Test();
  1.1511 +	TEST(test->HasPassedTest());
  1.1512 +	CleanupStack::PopAndDestroy(); //test
  1.1513 +	}
  1.1514 +#endif //TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA
  1.1515 +
  1.1516 +/**
  1.1517 +@SYMTestCaseID		GRAPHICS-WSERV-0494
  1.1518 +@SYMDEF				DEF131255
  1.1519 +@SYMTestCaseDesc    Negative test to show that using SetBrushStyle() will not panic WServ with different
  1.1520 +					brush bitmaps.
  1.1521 +@SYMTestPriority    High
  1.1522 +@SYMTestStatus      Implemented
  1.1523 +@SYMTestActions		Four seperate panic situations are tested:
  1.1524 +					1)
  1.1525 +                    Create a regular CFbsBitmap, set as brush pattern, and set brush style to EPatternedBrush.
  1.1526 +                    Draw a line to force the playback to occur.
  1.1527 +                    Call Finish on the GC.
  1.1528 +                    Destroy the brush bitmap.
  1.1529 +                    2)
  1.1530 +                    Create a regular CFbsBitmap, set as brush pattern, and set brush style to EPatternedBrush.
  1.1531 +                    Draw a line to force the playback to occur.
  1.1532 +                    Destroy the brush bitmap. 
  1.1533 +                    Call Finish on the GC.
  1.1534 +                    3+4)
  1.1535 +                    Create an extended bitmap, set as the brush pattern, and set the brush style to EPatternedBrush.
  1.1536 +                    Draw a line to force the playback to occur.
  1.1537 +                    Set the brush bitmap and style again.
  1.1538 +                    Call Finish on the GC.
  1.1539 +                    Destroy the brush bitmap. 
  1.1540 +@SYMTestExpectedResults The calls to SetBrushStyle() should not cause WServ to panic when Finish() is called.
  1.1541 +*/
  1.1542 +void CTGc::TestGcSetBrushPatternL()
  1.1543 +	{
  1.1544 +	// Extended bitmap test data.
  1.1545 +	const TUint8 KTestData[] = "TEST DATA";
  1.1546 +	const TInt KTestDataSize = sizeof(KTestData);
  1.1547 +	const TUid KTestExtendedBitmapUid = TUid::Uid(0xFFFFFFFF);
  1.1548 +	
  1.1549 +	// First try using a regular bitmap as the brush pattern.
  1.1550 +	BaseWin->Win()->Invalidate();
  1.1551 +	BaseWin->Win()->BeginRedraw();
  1.1552 +	TheGc->Activate(*BaseWin->Win());	
  1.1553 +	CFbsBitmap* bitmapRegular = new (ELeave) CFbsBitmap;
  1.1554 +	CleanupStack::PushL(bitmapRegular);
  1.1555 +	TInt res = bitmapRegular->Create(TSize(10,10), EColor64K);
  1.1556 +	TEST(res == KErrNone);
  1.1557 +	//Record the commands using CWindowGc.
  1.1558 +	TheGc->UseBrushPattern(bitmapRegular);
  1.1559 +	TheGc->SetBrushStyle(CGraphicsContext::EPatternedBrush);
  1.1560 +	// DrawLine() is only used here to force playback of the commands.
  1.1561 +	TheGc->DrawLine(TPoint(0,0), TPoint(1,1));	
  1.1562 +	TheGc->Deactivate();
  1.1563 +	BaseWin->Win()->EndRedraw();
  1.1564 +	TheClient->iWs.Finish();
  1.1565 +	CleanupStack::PopAndDestroy(1, bitmapRegular);
  1.1566 +	
  1.1567 +	// Secondly, try using a regular bitmap as the brush pattern, but deleting the bitmap
  1.1568 +	// before calling Finish().
  1.1569 +	BaseWin->Win()->Invalidate();
  1.1570 +	BaseWin->Win()->BeginRedraw();
  1.1571 +	TheGc->Activate(*BaseWin->Win());		
  1.1572 +	bitmapRegular = new (ELeave) CFbsBitmap;
  1.1573 +	CleanupStack::PushL(bitmapRegular);
  1.1574 +	res = bitmapRegular->Create(TSize(10,10), EColor64K);		
  1.1575 +	TEST(res == KErrNone);
  1.1576 +	//Record the commands using CWindowGc.
  1.1577 +	TheGc->UseBrushPattern(bitmapRegular);
  1.1578 +	TheGc->SetBrushStyle(CGraphicsContext::EPatternedBrush);
  1.1579 +	TheGc->DrawLine(TPoint(0,0), TPoint(1,1));
  1.1580 +	CleanupStack::PopAndDestroy(1, bitmapRegular);	
  1.1581 +	TheGc->Deactivate();
  1.1582 +	BaseWin->Win()->EndRedraw();
  1.1583 +	TheClient->iWs.Finish();
  1.1584 +	
  1.1585 +	// Thirdly, try using an extended bitmap (which is unsupported by DirectGDI) as 
  1.1586 +	// the brush pattern.
  1.1587 +	BaseWin->Win()->Invalidate();
  1.1588 +	BaseWin->Win()->BeginRedraw();
  1.1589 +	TheGc->Activate(*BaseWin->Win());
  1.1590 +	// Create a dummy extended bitmap to use as a brush bitmap.
  1.1591 +	// This is unsupported by the default implementation of DirectGDI.
  1.1592 +	CFbsBitmap* bitmapExtended = new (ELeave) CFbsBitmap;
  1.1593 +	CleanupStack::PushL(bitmapExtended);
  1.1594 +	res = bitmapExtended->CreateExtendedBitmap(TSize(10,10), EColor64K, KTestExtendedBitmapUid, KTestData, KTestDataSize);
  1.1595 +	TEST(res == KErrNone);	
  1.1596 +	//Record the commands using CWindowGc.
  1.1597 +	TheGc->UseBrushPattern(bitmapExtended);
  1.1598 +	TheGc->SetBrushStyle(CGraphicsContext::EPatternedBrush);
  1.1599 +	TheGc->DrawLine(TPoint(0,0), TPoint(100,100));
  1.1600 +	TheGc->UseBrushPattern(bitmapExtended);
  1.1601 +	// Forth, do it twice so that we test the state commands and the drawops commands.
  1.1602 +	TheGc->SetBrushStyle(CGraphicsContext::EPatternedBrush);
  1.1603 +	TheGc->DrawLine(TPoint(0,0), TPoint(100,100));
  1.1604 +	TheGc->Deactivate();
  1.1605 +	BaseWin->Win()->EndRedraw();
  1.1606 +	TheClient->iWs.Finish();
  1.1607 +	CleanupStack::PopAndDestroy(1, bitmapExtended);	
  1.1608 +	}
  1.1609 +
  1.1610 +/**
  1.1611 +@SYMTestCaseID      GRAPHICS-WSERV-0576
  1.1612 +@SYMDEF             
  1.1613 +@SYMTestCaseDesc    Checks window server is still able to draw a bitmap, even after the client has released its handle to the bitmap.
  1.1614 +@SYMTestPriority    High
  1.1615 +@SYMTestStatus      Implemented
  1.1616 +@SYMTestActions     - Draw the bitmap to TestWin (keeping the window hidden)
  1.1617 +                    - Delete the bitmap
  1.1618 +                    - Show TestWin to cause it to be drawn on screen (after the bitmap has been deleted)
  1.1619 +                    - Draw the same bitmap (same image, different bitmap object instance) to BaseWin
  1.1620 +                    - Compare contents of TestWin with BaseWin
  1.1621 +@SYMTestExpectedResults TestWin and BaseWin should both show the bitmap.
  1.1622 +*/
  1.1623 +void CTGc::TestGcDeleteBitmap1L()
  1.1624 +    {
  1.1625 +    CFbsBitmap* bitmap = new (ELeave) CFbsBitmap;
  1.1626 +    CleanupStack::PushL(bitmap);
  1.1627 +    TInt ret = bitmap->Load(TEST_BITMAP_NAME,0);
  1.1628 +    TEST(ret == KErrNone);
  1.1629 +
  1.1630 +    // send drawing to hidden window
  1.1631 +    TestWin->SetVisible(EFalse);
  1.1632 +    TestWin->Win()->Invalidate();
  1.1633 +    TestWin->Win()->BeginRedraw();
  1.1634 +    TheGc->Activate(*TestWin->Win());
  1.1635 +    TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.1636 +    TheGc->SetDrawMode(CGraphicsContext::EDrawModePEN);
  1.1637 +    TheGc->SetBrushColor(TRgb(255, 0, 0));
  1.1638 +    TheGc->Clear();
  1.1639 +    TheGc->BitBlt(TPoint(0,0), bitmap);
  1.1640 +    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
  1.1641 +    bitmap = NULL;
  1.1642 +    TheGc->Deactivate();
  1.1643 +    TestWin->Win()->EndRedraw();
  1.1644 +    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)
  1.1645 +
  1.1646 +    // make window visible (forcing it to draw)
  1.1647 +    TestWin->SetVisible(ETrue);
  1.1648 +    TheClient->iWs.Finish(); // ensure the bitmap has been drawn on test win
  1.1649 +
  1.1650 +    // window server should have duplicated the bitmap when the BitBlt was added to the redraw store, so drawing
  1.1651 +    // the window now (by making it visible above) should display the bitmap on screen, even
  1.1652 +    // though we've deleted it in this thread
  1.1653 +
  1.1654 +    // now create the bitmap again, and draw it to the base win (for comparison with test win)
  1.1655 +    bitmap = new (ELeave) CFbsBitmap;
  1.1656 +    CleanupStack::PushL(bitmap);
  1.1657 +    ret = bitmap->Load(TEST_BITMAP_NAME,0);
  1.1658 +    TEST(ret == KErrNone);
  1.1659 +    BaseWin->SetVisible(ETrue);
  1.1660 +    BaseWin->Win()->Invalidate();
  1.1661 +    BaseWin->Win()->BeginRedraw();
  1.1662 +    TheGc->Activate(*BaseWin->Win());   
  1.1663 +    TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.1664 +    TheGc->SetDrawMode(CGraphicsContext::EDrawModePEN);
  1.1665 +    TheGc->SetBrushColor(TRgb(255, 0, 0));
  1.1666 +    TheGc->Clear();
  1.1667 +    TheGc->BitBlt(TPoint(0,0), bitmap);
  1.1668 +    TheGc->Deactivate();
  1.1669 +    BaseWin->Win()->EndRedraw();
  1.1670 +    TheClient->iWs.Finish(); // ensure the bitmap has been drawn on base win
  1.1671 +    
  1.1672 +    CleanupStack::PopAndDestroy(bitmap);
  1.1673 +
  1.1674 +    // the test bitmap should be shown in both base win and test win, so we now check that the
  1.1675 +    // contents of base win and test win are the same
  1.1676 +    CheckRect(BaseWin, TestWin, TRect(0, 0, BaseWin->Size().iWidth, BaseWin->Size().iHeight), _L("CTGc::TestGcDeleteBitmap1L()"));
  1.1677 +    }
  1.1678 +
  1.1679 +/**
  1.1680 +@SYMTestCaseID      GRAPHICS-WSERV-0577
  1.1681 +@SYMDEF             
  1.1682 +@SYMTestCaseDesc    Check window server is still able to use a bitmap required by window drawing, even
  1.1683 +                    after the client has released its handle to the bitmap. Also check window server 
  1.1684 +                    releases the bitmap, when it's no longer used by window drawing.
  1.1685 +@SYMTestPriority    High
  1.1686 +@SYMTestStatus      Implemented
  1.1687 +@SYMTestActions     - Clean BaseWin and TestWin from content that has been left over from previous test
  1.1688 +                    - Draw test bitmap to TestWin
  1.1689 +                    - Delete the bitmap
  1.1690 +                    - Using a different bitmap object instance, duplicate bitmap (the bitmap is still used by window drawing)
  1.1691 +                    - Delete the bitmap
  1.1692 +                    - Draw new content to TestWin, so that previously drawn bitmap is covered
  1.1693 +                    - Duplicate bitmap (the bitmap is no longer used by window drawing)
  1.1694 +@SYMTestExpectedResults Bitmap duplication succeeds, when the bitmap used by window drawing, whereas
  1.1695 +                        bitmap duplication fails, when the bitmap is no longer used by window drawing.
  1.1696 +*/
  1.1697 +void CTGc::TestGcDeleteBitmap2L()
  1.1698 +    {
  1.1699 +    //send new drawing to test and base windows, in order to cover 
  1.1700 +    //any content has been left on them (through previous test)
  1.1701 +    BaseWin->SetVisible(ETrue);
  1.1702 +    BaseWin->Win()->Invalidate();
  1.1703 +    BaseWin->Win()->BeginRedraw();
  1.1704 +    TheGc->Activate(*BaseWin->Win());   
  1.1705 +    TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.1706 +    TheGc->SetDrawMode(CGraphicsContext::EDrawModePEN);
  1.1707 +    TheGc->SetBrushColor(TRgb(0, 0, 255));
  1.1708 +    TheGc->Clear();
  1.1709 +    TheGc->Deactivate();
  1.1710 +    BaseWin->Win()->EndRedraw();
  1.1711 +    
  1.1712 +    TestWin->SetVisible(ETrue);
  1.1713 +    TestWin->Win()->Invalidate();
  1.1714 +    TestWin->Win()->BeginRedraw();
  1.1715 +    TheGc->Activate(*TestWin->Win());   
  1.1716 +    TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.1717 +    TheGc->SetDrawMode(CGraphicsContext::EDrawModePEN);
  1.1718 +    TheGc->SetBrushColor(TRgb(0, 0, 255));
  1.1719 +    TheGc->Clear();
  1.1720 +    TheGc->Deactivate();
  1.1721 +    TestWin->Win()->EndRedraw();
  1.1722 +    
  1.1723 +    TheClient->iWs.Flush(); 
  1.1724 +    TheClient->iWs.Finish();
  1.1725 +        
  1.1726 +    //load test bitmap
  1.1727 +    CFbsBitmap* bitmap = new (ELeave) CFbsBitmap;
  1.1728 +    CleanupStack::PushL(bitmap);
  1.1729 +    TInt ret = bitmap->Load(_L("Z:\\WSTEST\\TESTCIRCLES.MBM"),0);
  1.1730 +    TEST(ret == KErrNone);
  1.1731 +    TInt bitmapHandle = bitmap->Handle();
  1.1732 +    
  1.1733 +    //send bitmap drawing to test window
  1.1734 +    TestWin->Win()->Invalidate();
  1.1735 +    TestWin->Win()->BeginRedraw();
  1.1736 +    TheGc->Activate(*TestWin->Win());
  1.1737 +    TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.1738 +    TheGc->SetDrawMode(CGraphicsContext::EDrawModePEN);
  1.1739 +    TheGc->SetBrushColor(TRgb(0, 255, 0));
  1.1740 +    TheGc->Clear();
  1.1741 +    TheGc->BitBlt(TPoint(0,0), bitmap);
  1.1742 +    TheGc->Deactivate();
  1.1743 +    TestWin->Win()->EndRedraw();
  1.1744 +    
  1.1745 +    CleanupStack::PopAndDestroy(bitmap);
  1.1746 +
  1.1747 +    TheClient->iWs.Flush(); 
  1.1748 +    TheClient->iWs.Finish();
  1.1749 +    
  1.1750 +    //using a new bitmap object instance check that wserv can still duplicate test bitmap (even though
  1.1751 +    //the initial bitmap object is deleted) , since there is a window segment using it
  1.1752 +    bitmap = new (ELeave) CFbsBitmap;
  1.1753 +    CleanupStack::PushL(bitmap);
  1.1754 +    ret = bitmap->Duplicate(bitmapHandle);
  1.1755 +    TEST(ret == KErrNone);
  1.1756 +    CleanupStack::PopAndDestroy(bitmap);
  1.1757 +
  1.1758 +    //send new drawing to test window, in order to cover the bitmap that was previously drawn
  1.1759 +    TestWin->Win()->Invalidate();
  1.1760 +    TestWin->Win()->BeginRedraw();
  1.1761 +    TheGc->Activate(*TestWin->Win());
  1.1762 +    TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.1763 +    TheGc->SetDrawMode(CGraphicsContext::EDrawModePEN);
  1.1764 +    TheGc->SetBrushColor(TRgb(0, 0, 255));
  1.1765 +    TheGc->Clear();
  1.1766 +    TheGc->Deactivate();
  1.1767 +    TestWin->Win()->EndRedraw();
  1.1768 +    
  1.1769 +    TheClient->iWs.Flush(); 
  1.1770 +    TheClient->iWs.Finish();
  1.1771 +    
  1.1772 +    //check that wserv can't duplicate test bitmap, since no window segment uses it any more
  1.1773 +    bitmap = new (ELeave) CFbsBitmap;
  1.1774 +    CleanupStack::PushL(bitmap);
  1.1775 +    ret = bitmap->Duplicate(bitmapHandle);
  1.1776 +    TEST(ret != KErrNone);
  1.1777 +    CleanupStack::PopAndDestroy(bitmap);
  1.1778 +    }
  1.1779 +
  1.1780 +void CTGc::RunTestCaseL(TInt /*aCurTestCase*/)
  1.1781 +	{
  1.1782 +	((CTGcStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
  1.1783 +	switch(++iTest->iState)
  1.1784 +		{
  1.1785 +	case 1:
  1.1786 +		((CTGcStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0437"));
  1.1787 +		iTest->LogSubTest(_L("CRemoteGc&CWindowGc, outline and shadow text"));
  1.1788 +		TestOutlineAndShadowL();		
  1.1789 +		break;	
  1.1790 +	case 2:
  1.1791 +		((CTGcStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0471"));
  1.1792 +		iTest->LogSubTest(_L("Test GC clip rect and origin attributes."));		 
  1.1793 +		TestGcClipRectOrigin();
  1.1794 +		break;
  1.1795 +	case 3:
  1.1796 +		((CTGcStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0469"));
  1.1797 +		iTest->LogSubTest(_L("CRemoteGc&CWindowGc, reset with background colour"));		
  1.1798 +		TestResetWithBackgroundColorL();
  1.1799 +		break;
  1.1800 +	case 4:
  1.1801 +		((CTGcStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0481"));
  1.1802 +		iTest->LogSubTest(_L("CRemoteGc&CCommandBuffer, coverage tests"));
  1.1803 +		TestCommandBufferL();
  1.1804 +		break;			
  1.1805 +	case 5:
  1.1806 +		((CTGcStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0482"));
  1.1807 +		iTest->LogSubTest(_L("CCommandBuffer, coverage tests"));
  1.1808 +		TestEmptyCommandBufferL();
  1.1809 +		break;
  1.1810 +	case 6:
  1.1811 +		((CTGcStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0494"));
  1.1812 +		iTest->LogSubTest(_L("CWindowGc, Brush Pattern test"));
  1.1813 +		TestGcSetBrushPatternL();
  1.1814 +		break;
  1.1815 +    case 7:
  1.1816 +        ((CTGcStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0576"));
  1.1817 +        iTest->LogSubTest(_L("CWindowGc, delete bitmap 1"));
  1.1818 +        TestGcDeleteBitmap1L();
  1.1819 +        break;
  1.1820 +    case 8:
  1.1821 +        ((CTGcStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0577"));
  1.1822 +        iTest->LogSubTest(_L("CWindowGc, delete bitmap 2"));
  1.1823 +        TestGcDeleteBitmap2L();
  1.1824 +        break;
  1.1825 +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA
  1.1826 +	case 9:
  1.1827 +		 ((CTGcStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0471"));
  1.1828 +		 iTest->LogSubTest(_L("Test GC clip rect and origin attributes."));
  1.1829 +		 TestGcClipRectOrigin();
  1.1830 +		 break;
  1.1831 +	case 10:
  1.1832 +		((CTGcStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0469"));
  1.1833 +		iTest->LogSubTest(_L("CRemoteGc&CWindowGc, reset with background colour"));
  1.1834 +		TestResetWithBackgroundColorL();
  1.1835 +		break;
  1.1836 +	case 11:
  1.1837 +		((CTGcStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0486"));
  1.1838 +		iTest->LogSubTest(_L("CRemoteGc&MWsGraphicsContext, clipping rect test"));
  1.1839 +		TestCRemoteGcAndMWsGraphicsContextClippingRectL();
  1.1840 +		break;
  1.1841 +	case 12:
  1.1842 +		((CTGcStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0487"));
  1.1843 +		iTest->LogSubTest(_L("CRemoteGc, DrawTextInContext Position test"));
  1.1844 +		TestCRemoteGcDrawTextInContextPointL();
  1.1845 +		break;
  1.1846 +	case 13:
  1.1847 +		((CTGcStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0488"));
  1.1848 +		iTest->LogSubTest(_L("CRemoteGc, DrawTextInContext ClipRect test"));
  1.1849 +		TestCRemoteGcDrawTextInContextBoxL();
  1.1850 +		break;
  1.1851 +	case 14:
  1.1852 +		((CTGcStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0489"));
  1.1853 +		iTest->LogSubTest(_L("CRemoteGc, DrawTextInContext Pos Vertical  test"));
  1.1854 +		TestCRemoteGcDrawTextInContextPointVerticalL();
  1.1855 +		break;
  1.1856 +	case 15:
  1.1857 +		((CTGcStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0490"));
  1.1858 +		iTest->LogSubTest(_L("CRemoteGc, DrawTextInContext ClipRect Vert  test"));
  1.1859 +		TestCRemoteGcDrawTextInContextBoxVerticalL();
  1.1860 +		break;
  1.1861 +#endif //TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA
  1.1862 +	default:
  1.1863 +		((CTGcStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
  1.1864 +		((CTGcStep*)iStep)->CloseTMSGraphicsStep();
  1.1865 +		TestComplete();
  1.1866 +		break;
  1.1867 +		}
  1.1868 +	((CTGcStep*)iStep)->RecordTestResultL();
  1.1869 +	}
  1.1870 +
  1.1871 +__CONSTRUCT_STEP__(Gc)