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