os/graphics/graphicsresourceservices/graphicsresource/test/tsgimagegeneric.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/graphics/graphicsresourceservices/graphicsresource/test/tsgimagegeneric.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,2523 @@
     1.4 +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +/**
    1.20 + @file
    1.21 + @test
    1.22 + @internalComponent - Internal Symbian test code 
    1.23 +*/
    1.24 +
    1.25 +#include "tsgimagegeneric.h"
    1.26 +#include <hal.h>
    1.27 +#include <e32math.h>
    1.28 +
    1.29 +CTSgImageGeneric::CTSgImageGeneric()
    1.30 +	{
    1.31 +	INFO_PRINTF1(_L("Graphics resource component test - RSgImage Generic Tests.\r\n"));
    1.32 +	}
    1.33 +
    1.34 +CTSgImageGeneric::~CTSgImageGeneric()
    1.35 +	{
    1.36 +	TInt count = iTestImages.Count();
    1.37 +	for(TInt i=0; i<count; ++i)
    1.38 +		{
    1.39 +		iTestImages[i].Close();
    1.40 +		}	
    1.41 +	iTestImages.Reset();
    1.42 +	}
    1.43 +
    1.44 +/** 
    1.45 +Overrides of base class pure virtual
    1.46 +Our implementation only gets called if the base class doTestStepPreambleL() did
    1.47 +not leave. That being the case, the current test result value will be EPass.
    1.48 +@leave Gets system wide error code
    1.49 +@return TVerdict code
    1.50 +*/
    1.51 +TVerdict CTSgImageGeneric::doTestStepL()
    1.52 +	{
    1.53 +	SetTestStepID(_L("GRAPHICS-RESOURCE-0003"));
    1.54 +	INFO_PRINTF1(_L("Getting pixel formats supported on all platforms.\r\n"));
    1.55 +	TestGetPixelFormatsL();
    1.56 +	RecordTestResultL();	
    1.57 +
    1.58 +	SetTestStepID(_L("GRAPHICS-RESOURCE-0004"));
    1.59 +	INFO_PRINTF1(_L("Create an uninitialised image.\r\n"));
    1.60 +	TestCreateImageUninitializedL();
    1.61 +	RecordTestResultL();
    1.62 +		
    1.63 +	SetTestStepID(_L("GRAPHICS-RESOURCE-0005"));
    1.64 +	INFO_PRINTF1(_L("Create an image from a block of memory.\r\n"));
    1.65 +	TestCreateImageL();
    1.66 +	RecordTestResultL();
    1.67 +	
    1.68 +	SetTestStepID(_L("GRAPHICS-RESOURCE-0006"));
    1.69 +	INFO_PRINTF1(_L("Create an image from an existing image.\r\n"));
    1.70 +	TestCreateImageFromExistingImageL();
    1.71 +	RecordTestResultL();
    1.72 +		
    1.73 +	SetTestStepID(_L("GRAPHICS-RESOURCE-0007"));
    1.74 +	INFO_PRINTF1(_L("Getting information about the image.\r\n"));
    1.75 +	TestGetImageInfoL();
    1.76 +	RecordTestResultL();
    1.77 +		
    1.78 +	SetTestStepID(_L("GRAPHICS-RESOURCE-0008"));
    1.79 +	INFO_PRINTF1(_L("Retrieving drawable id of an image.\r\n"));
    1.80 +	TestGetImageDrawableIdL();
    1.81 +	RecordTestResultL();
    1.82 +		
    1.83 +	SetTestStepID(_L("GRAPHICS-RESOURCE-0009"));
    1.84 +	INFO_PRINTF1(_L("Mapping and unmapping an image from its creator process.\r\n"));
    1.85 +	TestMapImageL();
    1.86 +	RecordTestResultL();
    1.87 +		
    1.88 +	SetTestStepID(_L("GRAPHICS-RESOURCE-0010"));
    1.89 +	INFO_PRINTF1(_L("Opening a handle to an image in both the current process and another process.\r\n"));
    1.90 +	TestOpenImageL();
    1.91 +	RecordTestResultL();
    1.92 +	
    1.93 +	SetTestStepID(_L("GRAPHICS-RESOURCE-0011"));
    1.94 +	INFO_PRINTF1(_L("Opening a handle to an image with an open mode.\r\n"));
    1.95 +	TestOpenImageInternalL();
    1.96 +	RecordTestResultL();
    1.97 +	
    1.98 +	SetTestStepID(_L("GRAPHICS-RESOURCE-0044"));
    1.99 +	INFO_PRINTF1(_L("Getting the available interfaces from an image.\r\n"));	
   1.100 +	TestGetInterfaceL();
   1.101 +	RecordTestResultL();
   1.102 +
   1.103 +	SetTestStepID(_L("GRAPHICS-RESOURCE-0024"));
   1.104 +	INFO_PRINTF1(_L("Getting supported pixel formats with invalid parameters.\r\n"));
   1.105 +	TestGetPixelFormatsInvalidL();
   1.106 +	RecordTestResultL();
   1.107 +
   1.108 +	SetTestStepID(_L("GRAPHICS-RESOURCE-0025"));
   1.109 +	INFO_PRINTF1(_L("Opening an image with different invalid parameters.\r\n"));
   1.110 +	TestOpenImageInvalidL();
   1.111 +	RecordTestResultL();
   1.112 +
   1.113 +	SetTestStepID(_L("GRAPHICS-RESOURCE-0026"));
   1.114 +	INFO_PRINTF1(_L("Closing the handle to an image object multiple times.\r\n"));
   1.115 +	TestCloseImageManyTimesL();
   1.116 +	RecordTestResultL();
   1.117 +
   1.118 +	SetTestStepID(_L("GRAPHICS-RESOURCE-0027"));
   1.119 +	INFO_PRINTF1(_L("Closing the handle to an image object without opening it.\r\n"));
   1.120 +	TestCloseImageWithoutOpenL();
   1.121 +	RecordTestResultL();
   1.122 +
   1.123 +	SetTestStepID(_L("GRAPHICS-RESOURCE-0028"));
   1.124 +	INFO_PRINTF1(_L("Creating an image with various invalid parameters.\r\n"));
   1.125 +	TestCreateImageInvalidL();
   1.126 +	RecordTestResultL();
   1.127 +
   1.128 +	SetTestStepID(_L("GRAPHICS-RESOURCE-0039"));
   1.129 +	INFO_PRINTF1(_L("Getting information about an invalid image.\r\n"));
   1.130 +	TestGetInfoInvalidImageL();
   1.131 +	RecordTestResultL();
   1.132 +
   1.133 +	SetTestStepID(_L("GRAPHICS-RESOURCE-0030"));
   1.134 +	INFO_PRINTF1(_L("Mapping an image under various invalid conditions. \r\n"));
   1.135 +	TestMapImageInvalidL();
   1.136 +	RecordTestResultL();
   1.137 +
   1.138 +	SetTestStepID(_L("GRAPHICS-RESOURCE-0031"));
   1.139 +	INFO_PRINTF1(_L("Unmapping an image under various invalid conditions.\r\n"));
   1.140 +	TestUnmapImageInvalidL();
   1.141 +	RecordTestResultL();
   1.142 +	
   1.143 +	SetTestStepID(_L("GRAPHICS-RESOURCE-0048"));
   1.144 +	INFO_PRINTF1(_L("RSgImage generic stress test.\r\n"));
   1.145 +	TestStress1L();
   1.146 +	RecordTestResultL();
   1.147 +	
   1.148 +	SetTestStepID(_L("GRAPHICS-RESOURCE-0049"));
   1.149 +	INFO_PRINTF1(_L("RSgImage generic multi-thread stress test.\r\n"));
   1.150 +	TestStress2L();
   1.151 +	RecordTestResultL();
   1.152 +
   1.153 +#ifdef _DEBUG
   1.154 +/**
   1.155 +@SYMTestCaseID			GRAPHICS-RESOURCE-0095
   1.156 +*/
   1.157 +	SetTestStepID(_L("GRAPHICS-RESOURCE-0095"));
   1.158 +	INFO_PRINTF1(_L("RSgImage generic Out of memory test.\r\n"));
   1.159 +	TestOOM();
   1.160 +	RecordTestResultL();
   1.161 +	
   1.162 +	SetTestStepID(_L("GRAPHICS-RESOURCE-0052"));
   1.163 +	INFO_PRINTF1(_L("RSgImage generic panic test - GetInterface() with invalid image handle\r\n"));
   1.164 +	TestPanicImageGetInterfaceInvalidHandleL();
   1.165 +	RecordTestResultL();
   1.166 +	
   1.167 +	SetTestStepID(_L("GRAPHICS-RESOURCE-0052"));
   1.168 +	INFO_PRINTF1(_L("RSgImage generic panic test - GetInterface() with non null image handle and uninitialised driver\r\n"));
   1.169 +	TestPanicImageGetInterfaceNoDriverL();
   1.170 +	RecordTestResultL();
   1.171 +	
   1.172 +	SetTestStepID(_L("GRAPHICS-RESOURCE-0053"));
   1.173 +	INFO_PRINTF1(_L("RSgImage generic panic test - Close() with invalid image handle\r\n"));
   1.174 +	TestPanicImageCloseInvalidHandleL();
   1.175 +	RecordTestResultL();
   1.176 +	
   1.177 +	SetTestStepID(_L("GRAPHICS-RESOURCE-0054"));
   1.178 +	INFO_PRINTF1(_L("RSgImage generic panic test - Close() with non null image handle and uninitialised driver\r\n"));
   1.179 +	TestPanicImageCloseNoDriverL();
   1.180 +	RecordTestResultL();
   1.181 +	
   1.182 +	SetTestStepID(_L("GRAPHICS-RESOURCE-0055"));
   1.183 +	INFO_PRINTF1(_L("RSgImage generic panic test - Id() with invalid image handle\r\n"));
   1.184 +	TestPanicImageIdInvalidHandleL();
   1.185 +	RecordTestResultL();
   1.186 +	
   1.187 +	SetTestStepID(_L("GRAPHICS-RESOURCE-0056"));
   1.188 +	INFO_PRINTF1(_L("RSgImage generic panic test - Id() with non null image handle and uninitialised driver\r\n"));
   1.189 +	TestPanicImageIdNoDriverL();
   1.190 +	RecordTestResultL();
   1.191 +	
   1.192 +	SetTestStepID(_L("GRAPHICS-RESOURCE-0057"));
   1.193 +	INFO_PRINTF1(_L("RSgImage generic panic test - Create() with invalid image handle\r\n"));
   1.194 +	TestPanicImageCreateInvalidHandleL();
   1.195 +	RecordTestResultL();
   1.196 +	
   1.197 +	SetTestStepID(_L("GRAPHICS-RESOURCE-0058"));
   1.198 +	INFO_PRINTF1(_L("RSgImage generic panic test - GetInfo() with invalid image handle\r\n"));
   1.199 +	TestPanicImageGetInfoInvalidHandleL();
   1.200 +	RecordTestResultL();
   1.201 +	
   1.202 +	SetTestStepID(_L("GRAPHICS-RESOURCE-0059"));
   1.203 +	INFO_PRINTF1(_L("RSgImage generic panic test - GetInfo() with non null image handle and uninitialised driver\r\n"));
   1.204 +	TestPanicImageGetInfoNoDriverL();
   1.205 +	RecordTestResultL();
   1.206 +	
   1.207 +	SetTestStepID(_L("GRAPHICS-RESOURCE-0060"));
   1.208 +	INFO_PRINTF1(_L("RSgImage generic panic test - MapReadOnly() with invalid image handle\r\n"));
   1.209 +	TestPanicImageMapReadOnlyInvalidHandleL();
   1.210 +	RecordTestResultL();
   1.211 +	
   1.212 +	SetTestStepID(_L("GRAPHICS-RESOURCE-0061"));
   1.213 +	INFO_PRINTF1(_L("RSgImage generic panic test - MapReadOnly() with non null image handle and uninitialised driver\r\n"));
   1.214 +	TestPanicImageMapReadOnlyNoDriverL();
   1.215 +	RecordTestResultL();
   1.216 +	
   1.217 +	SetTestStepID(_L("GRAPHICS-RESOURCE-0062"));
   1.218 +	INFO_PRINTF1(_L("RSgImage generic panic test - MapWriteOnly() with invalid image handle\r\n"));
   1.219 +	TestPanicImageMapWriteOnlyInvalidHandleL();
   1.220 +	RecordTestResultL();
   1.221 +	
   1.222 +	SetTestStepID(_L("GRAPHICS-RESOURCE-0063"));
   1.223 +	INFO_PRINTF1(_L("RSgImage generic panic test - MapWriteOnly() with non null image handle and uninitialised driver\r\n"));
   1.224 +	TestPanicImageMapWriteOnlyNoDriverL();
   1.225 +	RecordTestResultL();
   1.226 +	
   1.227 +	SetTestStepID(_L("GRAPHICS-RESOURCE-0064"));
   1.228 +	INFO_PRINTF1(_L("RSgImage generic panic test - MapReadWrite() with invalid image handle\r\n"));
   1.229 +	TestPanicImageMapReadWriteInvalidHandleL();
   1.230 +	RecordTestResultL();
   1.231 +	
   1.232 +	SetTestStepID(_L("GRAPHICS-RESOURCE-0065"));
   1.233 +	INFO_PRINTF1(_L("RSgImage generic panic test - MapReadWrite() with non null image handle and uninitialised driver\r\n"));
   1.234 +	TestPanicImageMapReadWriteNoDriverL();
   1.235 +	RecordTestResultL();
   1.236 +
   1.237 +	SetTestStepID(_L("GRAPHICS-RESOURCE-0066"));
   1.238 +	INFO_PRINTF1(_L("RSgImage generic panic test - Unmap() with invalid image handle\r\n"));
   1.239 +	TestPanicImageUnmapInvalidHandleL();
   1.240 +	RecordTestResultL();
   1.241 +
   1.242 +	SetTestStepID(_L("GRAPHICS-RESOURCE-0067"));
   1.243 +	INFO_PRINTF1(_L("RSgImage generic panic test - Unmap() with non null image handle and uninitialised driver\r\n"));
   1.244 +	TestPanicImageUnmapNoDriverL();
   1.245 +	RecordTestResultL();
   1.246 +	
   1.247 +	SetTestStepID(_L("GRAPHICS-RESOURCE-0082"));
   1.248 +	INFO_PRINTF1(_L("RSgImage generic panic test - Open() with an uninitialised driver\r\n"));
   1.249 +	TestPanicImageOpenNoDriver1L();
   1.250 +	RecordTestResultL();
   1.251 +	
   1.252 +	SetTestStepID(_L("GRAPHICS-RESOURCE-0093"));
   1.253 +	INFO_PRINTF1(_L("RSgImage generic panic test - Open() with a mode flag with an uninitialised driver\r\n"));
   1.254 +	TestPanicImageOpenNoDriver2L();
   1.255 +	RecordTestResultL();
   1.256 +	
   1.257 +	SetTestStepID(_L("GRAPHICS-RESOURCE-0083"));
   1.258 +	INFO_PRINTF1(_L("RSgImage generic panic test - Create() from memory with an uninitialised driver\r\n"));
   1.259 +	TestPanicImageCreateNoDriver1L();
   1.260 +	RecordTestResultL();
   1.261 +	
   1.262 +	SetTestStepID(_L("GRAPHICS-RESOURCE-0084"));
   1.263 +	INFO_PRINTF1(_L("RSgImage generic panic test - Create() from existing image with an uninitialised driver\r\n"));
   1.264 +	TestPanicImageCreateNoDriver2L();
   1.265 +	RecordTestResultL();
   1.266 +	
   1.267 +	SetTestStepID(_L("GRAPHICS-RESOURCE-0085"));
   1.268 +	INFO_PRINTF1(_L("RSgImage generic panic test - GetPixelFormats() with an uninitialised driver\r\n"));	
   1.269 +	TestPanicImageGetPixelFormatsNoDriverL();
   1.270 +	RecordTestResultL();
   1.271 +	
   1.272 +	SetTestStepID(_L("GRAPHICS-RESOURCE-0088"));
   1.273 +	INFO_PRINTF1(_L("RSgImage generic panic test - DrawableType() with an uninitialised driver\r\n"));	
   1.274 +	TestPanicImageDrawableTypeNoDriverL();
   1.275 +	RecordTestResultL();
   1.276 +	
   1.277 +	SetTestStepID(_L("GRAPHICS-RESOURCE-0089"));
   1.278 +	INFO_PRINTF1(_L("RSgImage generic panic test - DrawableType() with invalid image handle\r\n"));	
   1.279 +	TestPanicImageDrawableTypeInvalidHandleL();
   1.280 +	RecordTestResultL();
   1.281 +#else
   1.282 +	INFO_PRINTF1(_L("Warning: Skipping the panic tests in release build. \r\n"));
   1.283 +#endif	
   1.284 +	return TestStepResult();
   1.285 +	}
   1.286 +
   1.287 +/**
   1.288 +@SYMTestCaseID			GRAPHICS-RESOURCE-0003
   1.289 +@SYMTestCaseDesc		Gets supported pixel formats on all platforms.
   1.290 +@SYMPREQ				PREQ39
   1.291 +@SYMREQ					REQ8809
   1.292 +@SYMREQ					REQ9175
   1.293 +@SYMREQ					REQ9224 
   1.294 +@SYMREQ					REQ9233  
   1.295 +@SYMREQ					REQ9234
   1.296 +@SYMFssID				RSgImage::GetPixelFormats(const TSgImageInfo&, TUidPixelFormat*, TInt&)
   1.297 +@SYMTestPriority		Critical
   1.298 +@SYMTestType			Unit Test
   1.299 +@SYMTestPurpose			To ensure all the available pixel formats are returned 
   1.300 +						in the array and the actual number of pixel formats in
   1.301 +						the input/output aCount parameter.
   1.302 +@SYMTestActions			Initialise the graphics resource component. Construct a
   1.303 +						TSgImageInfo object and Initialise the member variables.
   1.304 +						Construct a TInt array of size\n
   1.305 +						\t 1. NULL\n						
   1.306 +						\t 2. greater than the number of supported pixel formats\n
   1.307 +						\t 3. equal to the number of supported pixel formats\n
   1.308 +						\t 4. less than the number of supported pixel formats
   1.309 +@SYMTestExpectedResults	The function must return\n
   1.310 +						\t 1. KErrNone\n
   1.311 +						\t 2. KErrNone\n
   1.312 +						\t 3. KErrNone\n
   1.313 +						\t 4. KErrOverFlow\n
   1.314 +						The supported pixel formats are populated into the array
   1.315 +						and aCount stores the actual number of supported pixel formats.
   1.316 +						The returned pixel formats should cover the pixel formats
   1.317 +						in the image compatibility table that works on all platforms.
   1.318 +@SYMTestStatus			Implemented 
   1.319 + */
   1.320 +void CTSgImageGeneric::TestGetPixelFormatsL()
   1.321 +	{
   1.322 +	TestOpenDriverL();
   1.323 +	TSgImageInfo info;
   1.324 +	info.iSizeInPixels = TSize(10, 10);
   1.325 +	info.iCpuAccess = ESgCpuAccessNone;
   1.326 +	info.iUsage = ESgUsageDirectGdiSource;
   1.327 +	info.iShareable = EFalse;
   1.328 +	info.iScreenId = 0;
   1.329 +		
   1.330 +	TInt numPixelFormats = 0;
   1.331 +	//NULL array
   1.332 +	CheckErrorL(KErrNone, RSgImage::GetPixelFormats(info, NULL, numPixelFormats), (TText8*)__FILE__, __LINE__);
   1.333 +	TEST(numPixelFormats > 1);
   1.334 +	
   1.335 +	//array length bigger than available pixel formats
   1.336 +	TInt count = numPixelFormats + 10;
   1.337 +	TUidPixelFormat* pixelFormatArray = new(ELeave) TUidPixelFormat[count];
   1.338 +	CleanupArrayDeletePushL(pixelFormatArray);
   1.339 +	CheckErrorL(KErrNone, RSgImage::GetPixelFormats(info, pixelFormatArray, count), (TText8*)__FILE__, __LINE__);
   1.340 +	TEST(count == numPixelFormats);
   1.341 +	
   1.342 +	info.iScreenId = -1;
   1.343 +	CheckErrorL(KErrNone, RSgImage::GetPixelFormats(info, pixelFormatArray, count), (TText8*)__FILE__, __LINE__);
   1.344 +	TEST(count == numPixelFormats);
   1.345 +	
   1.346 +	info.iScreenId = 0;	
   1.347 +	CleanupStack::PopAndDestroy(pixelFormatArray);
   1.348 +	//array length is equal to the supported pixel formats
   1.349 +	count = numPixelFormats;
   1.350 +	pixelFormatArray = new(ELeave) TUidPixelFormat[count];
   1.351 +	CleanupArrayDeletePushL(pixelFormatArray);
   1.352 +	
   1.353 +	CheckErrorL(KErrNone, RSgImage::GetPixelFormats(info, pixelFormatArray, count), (TText8*)__FILE__, __LINE__);
   1.354 +	TEST(count == numPixelFormats);
   1.355 +	
   1.356 +	CleanupStack::PopAndDestroy(pixelFormatArray);
   1.357 +	//array length is smaller than the supported pixel formats
   1.358 +	count = numPixelFormats - 1;
   1.359 +	pixelFormatArray = new(ELeave) TUidPixelFormat[count];
   1.360 +	CleanupArrayDeletePushL(pixelFormatArray);
   1.361 +	TEST(KErrOverflow == RSgImage::GetPixelFormats(info, pixelFormatArray, count));
   1.362 +	TEST(count == numPixelFormats);
   1.363 +	CleanupStack::PopAndDestroy(pixelFormatArray);
   1.364 +	
   1.365 +	//check all the pixel formats returned are in the common compatibility guarantees table
   1.366 +	TestGetPixelFormatCompatibilityGuaranteesL();
   1.367 +	
   1.368 +	//reset the array used by the GetPixelFormats function to prevent memory leaks
   1.369 +	info.iCpuAccess = ESgCpuAccessReadWrite;
   1.370 +	info.iScreenId = 100;
   1.371 +	TEST(KErrNone == RSgImage::GetPixelFormats(info, NULL, count));
   1.372 +	TEST(count == 0);
   1.373 +	
   1.374 +	TestCloseDriver();
   1.375 +	}
   1.376 +
   1.377 +/**
   1.378 +@SYMTestCaseID			GRAPHICS-RESOURCE-0004
   1.379 +@SYMTestCaseDesc		Creates an uninitialised image.
   1.380 +@SYMPREQ				PREQ39
   1.381 +@SYMREQ					REQ8809
   1.382 +@SYMREQ					REQ9175
   1.383 +@SYMREQ					REQ9224 
   1.384 +@SYMREQ					REQ9233  
   1.385 +@SYMREQ					REQ9234
   1.386 +@SYMFssID				RSgImage::Create(const TSgImageInfo&, const TAny*, TInt)\n 
   1.387 +						RSgImage::IsNull()
   1.388 +@SYMTestPriority		Critical
   1.389 +@SYMTestType			Unit Test
   1.390 +@SYMTestPurpose			To ensure an uninitialised image can be created.
   1.391 +@SYMTestActions			Initialise the graphics resource component. Construct well-defined 
   1.392 +						TSgImageInfo objects that work on all platforms. Create an image 
   1.393 +						with a NULL base address for each of the TSgImageInfo object.
   1.394 +@SYMTestExpectedResults	The function should return KErrNone in all cases. The created images
   1.395 +						are uninitialised.
   1.396 +@SYMTestStatus			Implemented 
   1.397 + */	
   1.398 +void CTSgImageGeneric::TestCreateImageUninitializedL()
   1.399 +	{	
   1.400 +	TestOpenDriverL();
   1.401 +	TSgImageInfo info;
   1.402 +	info.iSizeInPixels = TSize(100, 100);
   1.403 +	info.iUsage = ESgUsageDirectGdiTarget;
   1.404 +	info.iPixelFormat = EUidPixelFormatRGB_565;
   1.405 +	
   1.406 +	RSgImage image;	
   1.407 +	CheckErrorL(KErrNone, image.Create(info, NULL, 0), (TText8*)__FILE__, __LINE__);
   1.408 +	CleanupClosePushL(image);
   1.409 +	
   1.410 +	CleanupStack::PopAndDestroy();
   1.411 +	TestCloseDriver();
   1.412 +	}
   1.413 +
   1.414 +
   1.415 +/**
   1.416 +@SYMTestCaseID			GRAPHICS-RESOURCE-0005
   1.417 +@SYMTestCaseDesc		Creates an image from a block of memory.
   1.418 +@SYMPREQ				PREQ39
   1.419 +@SYMREQ					REQ8809
   1.420 +@SYMREQ					REQ9175
   1.421 +@SYMREQ					REQ9224 
   1.422 +@SYMREQ					REQ9233  
   1.423 +@SYMREQ					REQ9234
   1.424 +@SYMFssID				RSgImage::Create(const TSgImageInfo&, const TAny*, TInt)\n 
   1.425 +						RSgImage::IsNull()
   1.426 +@SYMTestPriority		Critical
   1.427 +@SYMTestType			Unit Test
   1.428 +@SYMTestPurpose			To ensure images can be created from a block of memory.
   1.429 +@SYMTestActions			Initialise the graphics resource component. Construct well-defined 
   1.430 +						TSgImageInfo objects that work on all platforms. Create a block of
   1.431 +						memory with or without initialised data. Then create an image with 
   1.432 +						the starting address of that memory.
   1.433 +@SYMTestExpectedResults	The function should return KErrNone in all cases. The user data starting
   1.434 +						at address aDataAddress will be populated into the new image.
   1.435 +@SYMTestStatus			Implemented 
   1.436 + */	
   1.437 +void CTSgImageGeneric::TestCreateImageL()
   1.438 +	{	
   1.439 +	TestOpenDriverL();
   1.440 +	TSgImageInfo info;
   1.441 +	info.iSizeInPixels = TSize(8, 8);
   1.442 +	info.iPixelFormat = EUidPixelFormatRGB_565;
   1.443 +	info.iUsage = ESgUsageDirectGdiSource;
   1.444 +	info.iShareable = ETrue;
   1.445 +	
   1.446 +	RSgImage image;
   1.447 +	CheckErrorL(KErrNone, image.Create(info, KImageData, 16), (TText8*)__FILE__, __LINE__);
   1.448 +	CleanupClosePushL(image);
   1.449 +	CleanupStack::PopAndDestroy();	
   1.450 +#ifdef __WINS__	
   1.451 +	//create an image with usage set to screen source
   1.452 +	TSize screenSize;
   1.453 +	if(HAL::Get(info.iScreenId, HALData::EDisplayXPixels, screenSize.iWidth) == KErrNone
   1.454 +		&& HAL::Get(info.iScreenId, HALData::EDisplayYPixels, screenSize.iHeight) == KErrNone)
   1.455 +		{
   1.456 +		info.iUsage = ESgUsageScreenSource;
   1.457 +		info.iScreenId = KSgScreenIdMain;
   1.458 +		info.iSizeInPixels = TSize(screenSize.iWidth, screenSize.iHeight);
   1.459 +		CheckErrorL(KErrNone, image.Create(info, KImageData, 16), (TText8*)__FILE__, __LINE__);
   1.460 +		CleanupClosePushL(image);
   1.461 +		CleanupStack::PopAndDestroy();
   1.462 +		
   1.463 +		info.iSizeInPixels = TSize(screenSize.iHeight, screenSize.iWidth);
   1.464 +		CheckErrorL(KErrNone, image.Create(info, KImageData, 16), (TText8*)__FILE__, __LINE__);
   1.465 +		CleanupClosePushL(image);
   1.466 +		CleanupStack::PopAndDestroy();
   1.467 +		}
   1.468 +#endif	
   1.469 +	//create an image with some user attributes
   1.470 +	TSgUserAttribute testAttributes[] = {{0x00008888, 1}, {0x00009999, 2}};
   1.471 +	info.iUserAttributes = testAttributes;
   1.472 +	info.iUserAttributeCount = 2;
   1.473 +	CheckErrorL(KErrNone, image.Create(info, KImageData, 16), (TText8*)__FILE__, __LINE__);
   1.474 +	CleanupClosePushL(image);
   1.475 +	CleanupStack::PopAndDestroy();
   1.476 +	
   1.477 +	TestCloseDriver();
   1.478 +	}
   1.479 +
   1.480 +/**
   1.481 +@SYMTestCaseID			GRAPHICS-RESOURCE-0006
   1.482 +@SYMTestCaseDesc		Creates an image from an existing image.
   1.483 +@SYMPREQ				PREQ39
   1.484 +@SYMREQ					REQ8809
   1.485 +@SYMREQ					REQ9175
   1.486 +@SYMREQ					REQ9192
   1.487 +@SYMREQ					REQ9224 
   1.488 +@SYMREQ					REQ9233  
   1.489 +@SYMREQ					REQ9234
   1.490 +@SYMFssID				RSgImage::Create(const TSgImageInfo&, const RSgImage&)
   1.491 +@SYMTestPriority		Critical
   1.492 +@SYMTestType			Unit Test
   1.493 +@SYMTestPurpose			To ensure images can be created from existing images.
   1.494 +@SYMTestActions			Initialise the graphics resource component. Create an image. Create another
   1.495 +						image with the attributes of this image as the TSgImageInfo.
   1.496 +@SYMTestExpectedResults	The function should return KErrNone. The new image should be identical to
   1.497 +						the old one. 
   1.498 +@SYMTestStatus			Implemented 
   1.499 + */	
   1.500 +void CTSgImageGeneric::TestCreateImageFromExistingImageL()
   1.501 +	{
   1.502 +	RSgImage image1;
   1.503 +	RSgImage image2;
   1.504 +	TSgImageInfo info;
   1.505 +	
   1.506 +	TestOpenDriverL();		
   1.507 +	CreateImageL(image1);
   1.508 +	CleanupClosePushL(image1);
   1.509 +	TEST(KErrNone == image1.GetInfo(info));
   1.510 +	CheckErrorL(KErrNone, image2.Create(info, image1), (TText8*)__FILE__, __LINE__);
   1.511 +	CleanupClosePushL(image2);
   1.512 +	TSgImageInfo info2;
   1.513 +	TEST(KErrNone == image2.GetInfo(info2));
   1.514 +	TEST(CompareInfos(info, info2));
   1.515 +	CleanupStack::PopAndDestroy(2);
   1.516 +	TestCloseDriver();
   1.517 +	}
   1.518 +
   1.519 +
   1.520 +/**
   1.521 +@SYMTestCaseID			GRAPHICS-RESOURCE-0007
   1.522 +@SYMTestCaseDesc		Calls GetInfo on an image.
   1.523 +@SYMPREQ				PREQ39
   1.524 +@SYMREQ					REQ8809
   1.525 +@SYMREQ					REQ9175
   1.526 +@SYMREQ					REQ9224 
   1.527 +@SYMREQ					REQ9233  
   1.528 +@SYMREQ					REQ9234
   1.529 +@SYMFssID				RSgImage::GetInfo(TSgImageInfo&)
   1.530 +@SYMTestPriority		Critical
   1.531 +@SYMTestType			Unit Test
   1.532 +@SYMTestPurpose			To ensure the information about the image is correct.
   1.533 +@SYMTestActions			Initialise the graphics resource component. Construct a TSgImageInfo object
   1.534 +						and Initialise all the member variables. Create images without and with
   1.535 +						user attributes. Call GetInfo() and compare the resulting TSgImageInfo objects 
   1.536 +						with the previous ones.
   1.537 +@SYMTestExpectedResults	The function should return KErrNone. Information about the image object
   1.538 +						is stored in the aInfo parameter. The retrieved TSgImageInfo objects should be 
   1.539 +						identical to the original ones.
   1.540 +@SYMTestStatus			Implemented 
   1.541 + */	
   1.542 +void CTSgImageGeneric::TestGetImageInfoL()
   1.543 +	{
   1.544 +	TestOpenDriverL();
   1.545 +	TSgImageInfo info;
   1.546 +	info.iPixelFormat = EUidPixelFormatRGB_565;
   1.547 +	info.iSizeInPixels = TSize(100, 100);
   1.548 +	info.iUsage = ESgUsageDirectGdiTarget;
   1.549 +	
   1.550 +	RSgImage image;
   1.551 +	CheckErrorL(KErrNone, image.Create(info, NULL, 0), (TText8*)__FILE__, __LINE__);
   1.552 +	CleanupClosePushL(image);
   1.553 +	
   1.554 +	TSgImageInfo info2;
   1.555 +	TEST(KErrNone == image.GetInfo(info2));
   1.556 +	TEST(CompareInfos(info, info2));
   1.557 +	CleanupStack::PopAndDestroy();
   1.558 +	
   1.559 +	//get info of image with user attributes
   1.560 +	TSgUserAttribute testAttributes[] = {{0x00008888, 1}, {0x00009999, 2}};
   1.561 +	info.iUserAttributes = testAttributes;
   1.562 +	info.iUserAttributeCount = 2;
   1.563 +	CheckErrorL(KErrNone, image.Create(info, NULL, 0), (TText8*)__FILE__, __LINE__);
   1.564 +	CleanupClosePushL(image);
   1.565 +	TSgImageInfo info3;
   1.566 +	TSgUserAttribute testAttributes2[2];
   1.567 +	testAttributes2[0].iUid = TUid::Uid(0x00008888);
   1.568 +	testAttributes2[1].iUid = TUid::Uid(0x00009999);
   1.569 +	info3.iUserAttributes = testAttributes2;
   1.570 +	info3.iUserAttributeCount = 2;
   1.571 +	TEST(KErrNone == image.GetInfo(info3));
   1.572 +	TEST(CompareInfos(info, info3));	
   1.573 +	CleanupStack::PopAndDestroy();
   1.574 +	
   1.575 +	info.iShareable = ETrue;
   1.576 +	CheckErrorL(KErrNone, image.Create(info, NULL, 0), (TText8*)__FILE__, __LINE__);
   1.577 +	CleanupClosePushL(image);
   1.578 +	TEST(KErrNone == image.GetInfo(info3));
   1.579 +	TEST(CompareInfos(info, info3));
   1.580 +	CleanupStack::PopAndDestroy();
   1.581 +	
   1.582 +	TestCloseDriver();
   1.583 +	}
   1.584 +
   1.585 +/**
   1.586 +@SYMTestCaseID			GRAPHICS-RESOURCE-0008
   1.587 +@SYMTestCaseDesc		Retrieves drawable id and drawable type of an image.
   1.588 +@SYMPREQ				PREQ39
   1.589 +@SYMREQ					REQ8809
   1.590 +@SYMREQ					REQ9175
   1.591 +@SYMREQ					REQ9224 
   1.592 +@SYMREQ					REQ9233  
   1.593 +@SYMREQ					REQ9234
   1.594 +@SYMFssID				RSgImage::Id()\n
   1.595 +						RSgImage::DrawableType()
   1.596 +@SYMTestPriority		Critical
   1.597 +@SYMTestType			Unit Test
   1.598 +@SYMTestPurpose			To ensure the globally unique drawable id of the image can be retrieved.
   1.599 +@SYMTestActions			Initialise the graphics resource component. Create an image. Call
   1.600 +						Id() to retrieve its drawable id.
   1.601 +@SYMTestExpectedResults	A valid drawable id should be successfully returned.
   1.602 +@SYMTestStatus			Implemented 
   1.603 + */	
   1.604 +void CTSgImageGeneric::TestGetImageDrawableIdL()
   1.605 +	{	
   1.606 +	RSgImage image;
   1.607 +	TEST(KNullUid == image.DrawableType());
   1.608 +	TSgDrawableId id = image.Id();
   1.609 +	TEST(id == KSgNullDrawableId);
   1.610 +	TestOpenDriverL();	
   1.611 +	CreateImageL(image);
   1.612 +	CleanupClosePushL(image);
   1.613 +	id = image.Id();
   1.614 +	TEST(id != KSgNullDrawableId);	
   1.615 +	TEST(KSgImageTypeUid == image.DrawableType());
   1.616 +
   1.617 +	CleanupStack::PopAndDestroy();
   1.618 +	TestCloseDriver();
   1.619 +	}
   1.620 +
   1.621 +/**
   1.622 +@SYMTestCaseID			GRAPHICS-RESOURCE-0009
   1.623 +@SYMTestCaseDesc		Maps and unmaps an image from its creator process.
   1.624 +@SYMPREQ				PREQ39
   1.625 +@SYMREQ					REQ8809
   1.626 +@SYMREQ					REQ9175
   1.627 +@SYMREQ					REQ9193
   1.628 +@SYMREQ					REQ9224 
   1.629 +@SYMREQ					REQ9233  
   1.630 +@SYMREQ					REQ9234
   1.631 +@SYMFssID				RSgImage::MapReadOnly(const TAny*&, TInt&) const\n
   1.632 + 						RSgImage::MapWriteOnly(TAny*&, TInt&)\n 
   1.633 +						RSgImage::MapReadWrite(TAny*&, TInt&)\n 
   1.634 +						RSgImage::Unmap()
   1.635 +						by its creator process.
   1.636 +@SYMTestPriority		Critical
   1.637 +@SYMTestType			Unit Test
   1.638 +@SYMTestPurpose			To ensure an image can be successfully mapped and unmapped
   1.639 +@SYMTestActions			Initialise the graphics resource component. Create mappable images
   1.640 +						with different TSgImageInfo values. Call different map functions the Unmap()
   1.641 +						function on each of them.
   1.642 +@SYMTestExpectedResults	All the functions should return KErrNone.
   1.643 +@SYMTestStatus			Implemented 
   1.644 + */	
   1.645 +void CTSgImageGeneric::TestMapImageL()
   1.646 +	{
   1.647 +	TestOpenDriverL();
   1.648 +	RSgImage image;
   1.649 +	TSgImageInfo info;
   1.650 +	info.iSizeInPixels = TSize(8, 8);
   1.651 +	info.iPixelFormat = EUidPixelFormatRGB_565;
   1.652 +	info.iUsage = ESgUsageDirectGdiSource;
   1.653 +	info.iCpuAccess = ESgCpuAccessReadOnly;
   1.654 +	
   1.655 +	CheckErrorL(KErrNone, image.Create(info, KImageData, 16), (TText8*)__FILE__, __LINE__);
   1.656 +	CleanupClosePushL(image);
   1.657 +	
   1.658 +	//test MapReadOnly
   1.659 +	const TAny* dataAddress;
   1.660 +	TInt dataStride;	
   1.661 +	TInt mapResult = image.MapReadOnly(dataAddress, dataStride);
   1.662 +	TEST(KErrNone == mapResult);
   1.663 +	if(KErrNone == mapResult)
   1.664 +		{
   1.665 +		for (TInt y = 0; y < 8; ++y)
   1.666 +			for (TInt x = 0; x < 8; ++x)
   1.667 +				{
   1.668 +				TUint16 pixelValue = *(TUint16*)PtrAdd(dataAddress, sizeof(TUint16) * x + dataStride * y);
   1.669 +				if (pixelValue != 0x7E0)
   1.670 +					{
   1.671 +					TEST(EFalse);
   1.672 +					break;
   1.673 +					}
   1.674 +				}
   1.675 +		}
   1.676 +	TEST(KErrNone == image.Unmap());
   1.677 +	CleanupStack::PopAndDestroy(&image);
   1.678 +	
   1.679 +	//test MapWriteOnly
   1.680 +	TAny* dataAddress1;
   1.681 +	
   1.682 +	info.iCpuAccess = ESgCpuAccessWriteOnly;
   1.683 +	CheckErrorL(KErrNone, image.Create(info, KImageData, 16), (TText8*)__FILE__, __LINE__);
   1.684 +	CleanupClosePushL(image);
   1.685 +	mapResult = image.MapWriteOnly(dataAddress1, dataStride);
   1.686 +	TEST(KErrNone == mapResult);
   1.687 +	//change the second line to red
   1.688 +	if(KErrNone == mapResult)
   1.689 +		{
   1.690 +		for(TInt x = 0; x < 8; ++x)
   1.691 +			{
   1.692 +			*(TUint16*)PtrAdd(dataAddress1, sizeof(TUint16) * x + dataStride * 1) = 0xF800;
   1.693 +			}
   1.694 +		}
   1.695 +	TEST(KErrNone == image.Unmap());
   1.696 +	
   1.697 +	//check if the modification is successful	
   1.698 +	//create another image from the existing one and map it as read only
   1.699 +	info.iCpuAccess = ESgCpuAccessReadOnly;
   1.700 +	RSgImage image1;
   1.701 +	CheckErrorL(KErrNone, image1.Create(info, image), (TText8*)__FILE__, __LINE__);
   1.702 +	CleanupClosePushL(image1);
   1.703 +	mapResult = image1.MapReadOnly(dataAddress, dataStride);
   1.704 +	TEST(mapResult == KErrNone);
   1.705 +	if(mapResult == KErrNone)
   1.706 +		{
   1.707 +		for(TInt x = 0; x < 8; ++x)
   1.708 +			{
   1.709 +			TUint16 pixelValue = *(TUint16*)PtrAdd(dataAddress, sizeof(TUint16) * x + dataStride * 1);
   1.710 +			if(pixelValue != 0xF800)
   1.711 +				{
   1.712 +				TEST(EFalse);
   1.713 +				break;
   1.714 +				}
   1.715 +			}
   1.716 +		}
   1.717 +	
   1.718 +	TEST(KErrNone == image1.Unmap());
   1.719 +	CleanupStack::PopAndDestroy(2, &image);
   1.720 +	
   1.721 +	//test MapReadWrite
   1.722 +	info.iCpuAccess = ESgCpuAccessReadWrite;
   1.723 +	CheckErrorL(KErrNone, image.Create(info, KImageData, 16), (TText8*)__FILE__, __LINE__);
   1.724 +	CleanupClosePushL(image);
   1.725 +	mapResult = image.MapReadWrite(dataAddress1, dataStride);
   1.726 +	TEST(KErrNone == mapResult);
   1.727 +	
   1.728 +	if(KErrNone == mapResult)
   1.729 +		{
   1.730 +		//modify the image, set first line to blue
   1.731 +		for(TInt x = 0; x < 8; ++x)
   1.732 +			{
   1.733 +			*(TUint16*)PtrAdd(dataAddress1, sizeof(TUint16) * x) = 0x1F;
   1.734 +			}
   1.735 +		
   1.736 +		//check the modification
   1.737 +		for(TInt x = 0; x < 8; ++x)
   1.738 +			{
   1.739 +			TUint16 pixelValue = *(TUint16*)PtrAdd(dataAddress1, sizeof(TUint16) * x);
   1.740 +			if(pixelValue != 0x1F)
   1.741 +				{
   1.742 +				TEST(EFalse);
   1.743 +				break;
   1.744 +				}
   1.745 +			}
   1.746 +		}
   1.747 +	
   1.748 +	TEST(KErrNone == image.Unmap());	
   1.749 +	CleanupStack::PopAndDestroy();
   1.750 +	TestCloseDriver();
   1.751 +	}
   1.752 +
   1.753 +/**
   1.754 +@SYMTestCaseID			GRAPHICS-RESOURCE-0010
   1.755 +@SYMTestCaseDesc		Opens a handle to an image in both the current process and another process.
   1.756 +@SYMPREQ				PREQ39
   1.757 +@SYMREQ					REQ8809
   1.758 +@SYMREQ					REQ9175
   1.759 +@SYMREQ					REQ9224 
   1.760 +@SYMREQ					REQ9233  
   1.761 +@SYMREQ					REQ9234
   1.762 +@SYMFssID				RSgImage::Open(const TSgDrawableId&)
   1.763 +@SYMTestPriority		Critical
   1.764 +@SYMTestType			Unit Test
   1.765 +@SYMTestPurpose			To ensure image can be opened in both a second thread in the current 
   1.766 +						process and another process.
   1.767 +@SYMTestActions			Initialise the graphics resource component. Create a shareable image and
   1.768 +						a non-shareable image. Open() the image in the second thread in the current 
   1.769 +						process and in another process.
   1.770 +						Check various image attributes.
   1.771 +@SYMTestExpectedResults	The function must return KErrNone in both cases.
   1.772 +@SYMTestStatus			Implemented 
   1.773 + */	
   1.774 +void CTSgImageGeneric::TestOpenImageL()
   1.775 +	{	
   1.776 +	TestOpenDriverL();
   1.777 +	
   1.778 +	//shareable image
   1.779 +	RSgImage image1;
   1.780 +	TSgImageInfo info1;
   1.781 +	info1.iSizeInPixels = TSize(8, 8);
   1.782 +	info1.iUsage = ESgUsageDirectGdiSource;
   1.783 +	info1.iPixelFormat = EUidPixelFormatRGB_565;
   1.784 +	info1.iCpuAccess = ESgCpuAccessReadWrite;
   1.785 +	info1.iShareable = ETrue;
   1.786 +	CheckErrorL(KErrNone, image1.Create(info1, KImageData, 16), (TText8*)__FILE__, __LINE__);
   1.787 +	CleanupClosePushL(image1);
   1.788 +	
   1.789 +	//non-shareable image
   1.790 +	RSgImage image2;
   1.791 +	TSgImageInfo info2;
   1.792 +	info2.iSizeInPixels = TSize(8, 8);
   1.793 +	info2.iUsage = ESgUsageDirectGdiSource;
   1.794 +	info2.iPixelFormat = EUidPixelFormatRGB_565;
   1.795 +	info2.iCpuAccess = ESgCpuAccessReadWrite;
   1.796 +	info2.iShareable = EFalse;	
   1.797 +	CheckErrorL(KErrNone, image2.Create(info2, KImageData, 16), (TText8*)__FILE__, __LINE__);
   1.798 +	CleanupClosePushL(image2);
   1.799 +	
   1.800 +	const TSgDrawableId id1 = image1.Id();
   1.801 +	const TSgDrawableId id2 = image2.Id();	
   1.802 +	
   1.803 +	//opening image in the current thread
   1.804 +	RSgImage image3;
   1.805 +	TEST(KErrNone == image3.Open(id1));
   1.806 +	image3.Close();
   1.807 +	TEST(KErrNone == image3.Open(id2));
   1.808 +	image3.Close();
   1.809 +	
   1.810 +	//opening image in a second thread in the current process
   1.811 +	TSgresTestInfo threadInfo = {id1, info1, 0, ESgresSecondThreadOpenImage};
   1.812 +	TInt testResult = CreateSecondThreadAndDoTestL(threadInfo);	
   1.813 +	// Test the results from the second thread
   1.814 +	User::LeaveIfError(testResult);
   1.815 +	TEST(testResult & EFirstTestPassed);
   1.816 +	TEST(testResult & ESecondTestPassed);
   1.817 +	TEST(testResult & EThirdTestPassed);
   1.818 +	TEST(testResult & EFourthTestPassed);
   1.819 +	TEST(testResult & EFifthTestPassed);
   1.820 +	
   1.821 +	threadInfo.iDrawableId = id2;
   1.822 +	threadInfo.iImageInfo = info2;
   1.823 +	testResult = CreateSecondThreadAndDoTestL(threadInfo);	
   1.824 +	// Test the results from the second thread
   1.825 +	User::LeaveIfError(testResult);
   1.826 +	TEST(testResult & EFirstTestPassed);
   1.827 +	TEST(testResult & ESecondTestPassed);
   1.828 +	TEST(testResult & EThirdTestPassed);
   1.829 +	TEST(testResult & EFourthTestPassed);
   1.830 +	TEST(testResult & EFifthTestPassed);
   1.831 +		
   1.832 +	//opening image in a second process	
   1.833 +	TSgresTestInfo processInfo = {id1, info1, 0, ESgresSecondProcessOpenImage};
   1.834 +	testResult = CreateSecondProcessAndDoTestL(KSecondProcess, processInfo);	
   1.835 +	User::LeaveIfError(testResult);
   1.836 +	TEST(testResult & EFirstTestPassed);	
   1.837 +	TEST(testResult & ESecondTestPassed);
   1.838 +	TEST(testResult & EThirdTestPassed);
   1.839 +	TEST(testResult & EFourthTestPassed);
   1.840 +
   1.841 +	CleanupStack::PopAndDestroy(2, &image1);
   1.842 +	TestCloseDriver();
   1.843 +	}
   1.844 +
   1.845 +class MFake
   1.846 +	{
   1.847 +public:
   1.848 +	enum { EInterfaceUid = 0x88888888 };
   1.849 +	};
   1.850 +
   1.851 +/**
   1.852 +@SYMTestCaseID			GRAPHICS-RESOURCE-0011
   1.853 +@SYMTestCaseDesc		Opens a handle to an image with mode flags.
   1.854 +@SYMPREQ				PREQ39
   1.855 +@SYMREQ					REQ8809
   1.856 +@SYMREQ					REQ9175
   1.857 +@SYMREQ					REQ9224 
   1.858 +@SYMREQ					REQ9233  
   1.859 +@SYMREQ					REQ9234
   1.860 +@SYMFssID				RSgImage::Open(const TSgDrawableId&, TUint32)
   1.861 +@SYMTestPriority		Critical
   1.862 +@SYMTestType			Unit Test
   1.863 +@SYMTestPurpose			To ensure image can be opened with mode flags.
   1.864 +@SYMTestActions			Initialise the graphics resource component. Create an image and
   1.865 +						call Open() on the image with flag ESgDoNotRestrictUsage. Call
   1.866 +						GetInfo() on the opened image and check the usage bit. Declare another
   1.867 +						image object and call Open() on it with the Id of the previously
   1.868 +						opened handle and without mode flags. Call GetInfo() on this image
   1.869 +						and check the usage bit.
   1.870 +@SYMTestExpectedResults	Both infos should contain all the possible usages supported by
   1.871 + 						the underlying implementation.						
   1.872 +@SYMTestStatus			Implemented 
   1.873 + */	
   1.874 +void CTSgImageGeneric::TestOpenImageInternalL()
   1.875 +	{
   1.876 +	TestOpenDriverL();
   1.877 +	
   1.878 +	//shareable image
   1.879 +	RSgImage shareableImage;
   1.880 +	TSgImageInfo shareableInfo;
   1.881 +	shareableInfo.iSizeInPixels = TSize(8, 8);
   1.882 +	shareableInfo.iUsage = ESgUsageDirectGdiSource;
   1.883 +	shareableInfo.iPixelFormat = EUidPixelFormatRGB_565;
   1.884 +	shareableInfo.iCpuAccess = ESgCpuAccessReadWrite;
   1.885 +	shareableInfo.iShareable = ETrue;	
   1.886 +	CheckErrorL(KErrNone, shareableImage.Create(shareableInfo, KImageData, 16), (TText8*)__FILE__, __LINE__);
   1.887 +	CleanupClosePushL(shareableImage);
   1.888 +		
   1.889 +	RSgImage image1;
   1.890 +	CheckErrorL(KErrNone, image1.Open(shareableImage.Id(), ESgDoNotRestrictUsage), (TText8*)__FILE__, __LINE__);
   1.891 +	CleanupClosePushL(image1);
   1.892 +	TSgImageInfo info1;
   1.893 +	image1.GetInfo(info1);	
   1.894 +	TEST(ESgUsageDirectGdiSource | info1.iUsage);
   1.895 +	TEST(ESgUsageCompositionSource | info1.iUsage);
   1.896 +	TEST(ESgUsageOpenGlesTexture2D | info1.iUsage);
   1.897 +	TEST(ESgUsageOpenGles2Texture2D | info1.iUsage);
   1.898 +	TEST(ESgUsageOpenVgImage | info1.iUsage);
   1.899 +	
   1.900 +	RSgImage image2;
   1.901 +	CheckErrorL(KErrNone, image2.Open(image1.Id()), (TText8*)__FILE__, __LINE__);
   1.902 +	CleanupClosePushL(image2);
   1.903 +	TSgImageInfo info2;
   1.904 +	image2.GetInfo(info2);
   1.905 +	TEST(ESgUsageDirectGdiSource | info2.iUsage);
   1.906 +	TEST(ESgUsageCompositionSource | info2.iUsage);
   1.907 +	TEST(ESgUsageOpenGlesTexture2D | info2.iUsage);
   1.908 +	TEST(ESgUsageOpenGles2Texture2D | info2.iUsage);
   1.909 +	TEST(ESgUsageOpenVgImage | info2.iUsage);
   1.910 +	
   1.911 +	//non-shareable image
   1.912 +	RSgImage nonshareableImage;
   1.913 +	TSgImageInfo nonshareableInfo;
   1.914 +	nonshareableInfo.iSizeInPixels = TSize(8, 8);
   1.915 +	nonshareableInfo.iUsage = ESgUsageDirectGdiSource;
   1.916 +	nonshareableInfo.iPixelFormat = EUidPixelFormatRGB_565;
   1.917 +	nonshareableInfo.iCpuAccess = ESgCpuAccessReadWrite;
   1.918 +	nonshareableInfo.iShareable = EFalse;	
   1.919 +	CheckErrorL(KErrNone, nonshareableImage.Create(nonshareableInfo, KImageData, 16), (TText8*)__FILE__, __LINE__);
   1.920 +	CleanupClosePushL(nonshareableImage);
   1.921 +	
   1.922 +	RSgImage image3;
   1.923 +	CheckErrorL(KErrNone, image3.Open(nonshareableImage.Id(), ESgDoNotRestrictUsage), (TText8*)__FILE__, __LINE__);
   1.924 +	CleanupClosePushL(image3);
   1.925 +	TSgImageInfo info3;
   1.926 +	image3.GetInfo(info3);	
   1.927 +	TEST(ESgUsageDirectGdiSource | info3.iUsage);
   1.928 +	TEST(ESgUsageCompositionSource | info3.iUsage);
   1.929 +	TEST(ESgUsageOpenGlesTexture2D | info3.iUsage);
   1.930 +	TEST(ESgUsageOpenGles2Texture2D | info3.iUsage);
   1.931 +	TEST(ESgUsageOpenVgImage | info3.iUsage);
   1.932 +	
   1.933 +	RSgImage image4;
   1.934 +	CheckErrorL(KErrNone, image4.Open(image3.Id()), (TText8*)__FILE__, __LINE__);
   1.935 +	CleanupClosePushL(image4);
   1.936 +	TSgImageInfo info4;
   1.937 +	image4.GetInfo(info4);
   1.938 +	TEST(ESgUsageDirectGdiSource | info4.iUsage);
   1.939 +	TEST(ESgUsageCompositionSource | info4.iUsage);
   1.940 +	TEST(ESgUsageOpenGlesTexture2D | info4.iUsage);
   1.941 +	TEST(ESgUsageOpenGles2Texture2D | info4.iUsage);
   1.942 +	TEST(ESgUsageOpenVgImage | info4.iUsage);
   1.943 +	
   1.944 +	CleanupStack::PopAndDestroy(6, &shareableImage);
   1.945 +	TestCloseDriver();
   1.946 +	}
   1.947 +
   1.948 +/**
   1.949 +@SYMTestCaseID			GRAPHICS-RESOURCE-0044
   1.950 +@SYMTestCaseDesc		Gets the interfaces implemented by CSgImageImpl class.
   1.951 +@SYMPREQ				PREQ39
   1.952 +@SYMREQ					REQ8809
   1.953 +@SYMREQ					REQ9175
   1.954 +@SYMREQ					REQ9224 
   1.955 +@SYMREQ					REQ9233  
   1.956 +@SYMREQ					REQ9234
   1.957 +@SYMFssID				RSgImage::Create(const TSgImageInfo&, const TAny*, TInt)\n 
   1.958 +						RSgImage::GetInterface()
   1.959 +@SYMTestPriority		Critical
   1.960 +@SYMTestType			Unit Test
   1.961 +@SYMTestPurpose			To ensure the extension interfaces supported by RSgImage can be
   1.962 +						returned. 
   1.963 +@SYMTestActions			Initialise the graphics resource component. Create an image. Call
   1.964 +						GetInterface() to return the MSgImage_Sw and MSgImage_Chunk interfaces.
   1.965 +						Perform various operations on the interfaces. Declare a fake interface
   1.966 +						MFake and call GetInterface() on the image handle.
   1.967 +@SYMTestExpectedResults	The operations on the MSgImage_Sw and MSgImage_Chunk interfaces should
   1.968 +						succeed. Trying to get the MFake interface should return KErrExtensionNotSupported.
   1.969 +@SYMTestStatus			Implemented 
   1.970 + */
   1.971 +void CTSgImageGeneric::TestGetInterfaceL()
   1.972 +	{
   1.973 +	TestOpenDriverL();
   1.974 +	
   1.975 +	TSgImageInfo info;
   1.976 +	info.iSizeInPixels = TSize(8, 8);
   1.977 +	info.iUsage = ESgUsageDirectGdiSource;
   1.978 +	info.iPixelFormat = EUidPixelFormatRGB_565;
   1.979 +	info.iCpuAccess = ESgCpuAccessReadWrite;
   1.980 +	info.iShareable = ETrue;
   1.981 +	
   1.982 +	RSgImage image;	
   1.983 +	MSgImage_Sw* swInterface = NULL;
   1.984 +	TEST(KErrBadHandle == image.GetInterface(swInterface));
   1.985 +	
   1.986 +	CheckErrorL(KErrNone, image.Create(info, NULL, 0), (TText8*)__FILE__, __LINE__);
   1.987 +	CleanupClosePushL(image);
   1.988 +	
   1.989 +	// check TSgDrawableId is not NULL
   1.990 +	TSgDrawableId id = image.Id();
   1.991 +	TEST(KSgNullDrawableId != id);
   1.992 +	
   1.993 +	TAny* dataAddress1 = NULL;
   1.994 +	TInt dataStride1 = 0;
   1.995 +	TInt result1 = image.GetInterface(swInterface);
   1.996 +	TEST(KErrNone == result1);
   1.997 +	if(KErrNone == result1)
   1.998 +		{		
   1.999 +		// Fill the image with 0xF0
  1.1000 +		TInt sizeInBytes = 8 * 8 * 2;
  1.1001 +		TESTL(swInterface->BeginDataAccess(ESgCpuAccessNone) == KErrArgument);
  1.1002 +		TEST(swInterface->BeginDataAccess(ESgCpuAccessWriteOnly) == KErrNone);
  1.1003 +		dataAddress1 = swInterface->DataAddress();
  1.1004 +		dataStride1 = swInterface->DataStride();
  1.1005 +		Mem::Fill(dataAddress1, sizeInBytes, 0xF0);
  1.1006 +		TEST(swInterface->EndDataAccess() == KErrNone);
  1.1007 +		
  1.1008 +		//Map the image as read only and check if the previous operation is successful
  1.1009 +		const TAny* dataAddressRead;
  1.1010 +		TInt dataStride2;	
  1.1011 +		TInt mapResult = image.MapReadOnly(dataAddressRead, dataStride2);
  1.1012 +		TEST(KErrNone == mapResult);
  1.1013 +		TEST(dataAddress1 == dataAddressRead);
  1.1014 +		TEST(dataStride1 == dataStride2);
  1.1015 +		if(KErrNone == mapResult)
  1.1016 +			{
  1.1017 +			for (TInt y = 0; y < 8; ++y)
  1.1018 +				for (TInt x = 0; x < 8; ++x)
  1.1019 +					{
  1.1020 +					TUint16 pixelValue = *(TUint16*)PtrAdd(dataAddressRead, sizeof(TUint16) * x + dataStride2 * y);
  1.1021 +					if (pixelValue != 0xF0F0)
  1.1022 +						{
  1.1023 +						TEST(EFalse);
  1.1024 +						break;
  1.1025 +						}
  1.1026 +					}
  1.1027 +			}
  1.1028 +		TEST(KErrNone == image.Unmap());
  1.1029 +		}
  1.1030 +	
  1.1031 +	MSgImage_Chunk* smChunk = NULL;
  1.1032 +	TInt result2 = image.GetInterface(smChunk);
  1.1033 +	TEST(KErrNone == result2);
  1.1034 +	if(KErrNone == result2)
  1.1035 +		{
  1.1036 +		TAny* address = PtrAdd(smChunk->DataChunk().Base(), smChunk->DataOffset());
  1.1037 +		TInt datastride = smChunk->DataStride();
  1.1038 +		if(KErrNone == result1)
  1.1039 +			{
  1.1040 +			TEST(address == dataAddress1);
  1.1041 +			TEST(datastride == dataStride1);
  1.1042 +			}
  1.1043 +		}
  1.1044 +	
  1.1045 +	//fake interface
  1.1046 +	MFake* smFake = NULL;
  1.1047 +	TEST(KErrExtensionNotSupported == image.GetInterface(smFake));
  1.1048 +	
  1.1049 +	CleanupStack::PopAndDestroy();
  1.1050 +	TestCloseDriver();
  1.1051 +	}
  1.1052 +
  1.1053 +/**
  1.1054 +@SYMTestCaseID			GRAPHICS-RESOURCE-0024
  1.1055 +@SYMTestCaseDesc		Gets supported pixel formats with invalid parameters.
  1.1056 +@SYMPREQ				PREQ39
  1.1057 +@SYMREQ					REQ8809
  1.1058 +@SYMREQ					REQ9175
  1.1059 +@SYMREQ					REQ9224 
  1.1060 +@SYMREQ					REQ9233  
  1.1061 +@SYMREQ					REQ9234
  1.1062 +@SYMFssID				RSgImage::GetPixelFormats(const TSgImageInfo&, TUidPixelFormat*, TInt&)
  1.1063 +@SYMTestPriority		Critical
  1.1064 +@SYMTestType			Unit Test
  1.1065 +@SYMTestPurpose			To ensure the correct error messages are returned when user tries to
  1.1066 +						call GetPixelFormats() with invalid parameters.
  1.1067 +@SYMTestActions			Initialise the graphics resource component. Call RSgImage::GetPixelFormats with:\n
  1.1068 +						\t 1. invalid TSgImageInfo object, it could be any combinations of the following:\n
  1.1069 +						\t \t negative width or height\n
  1.1070 +						\t \t mutability incompatible with the specified CPU access and usage\n
  1.1071 +						\t \t screen id < -1\n
  1.1072 +						\t \t usage flag ESgUsageScreenSource with screen id -1\n
  1.1073 +						\t 2. invalid aCount
  1.1074 +@SYMTestExpectedResults	The function should return KErrArgument in both cases.
  1.1075 +@SYMTestStatus			Implemented 
  1.1076 + */	
  1.1077 +void CTSgImageGeneric::TestGetPixelFormatsInvalidL()
  1.1078 +	{
  1.1079 +	TSgImageInfo info1;
  1.1080 +	TInt count = 0;
  1.1081 +	
  1.1082 +	TestOpenDriverL();
  1.1083 +	//negative width
  1.1084 +	info1.iSizeInPixels = TSize(-100, 100);
  1.1085 +	TEST(KErrArgument == RSgImage::GetPixelFormats(info1, NULL, count));
  1.1086 +	
  1.1087 +	//negative height
  1.1088 +	TSgImageInfo info2;
  1.1089 +	info2.iSizeInPixels = TSize(100, -100);
  1.1090 +	TEST(KErrArgument == RSgImage::GetPixelFormats(info2, NULL, count));
  1.1091 +	
  1.1092 +	//invalid or non-existent screen id
  1.1093 +	TSgImageInfo info5;
  1.1094 +	info5.iSizeInPixels = TSize(8, 8);
  1.1095 +	info5.iUsage = ESgUsageScreenSource;
  1.1096 +	info5.iCpuAccess = ESgCpuAccessReadWrite;
  1.1097 +	info5.iScreenId = -2;
  1.1098 +	TEST(KErrArgument == RSgImage::GetPixelFormats(info5, NULL, count));
  1.1099 +	info5.iScreenId = 100;
  1.1100 +	TEST(KErrNone == RSgImage::GetPixelFormats(info5, NULL, count));
  1.1101 +	TEST(count == 0);
  1.1102 +	
  1.1103 +	//usage flag ESgUsageScreenSource with screen id -1
  1.1104 +	TSgImageInfo info6;
  1.1105 +	info6.iSizeInPixels = TSize(8, 8);
  1.1106 +	info6.iScreenId = -1;
  1.1107 +	info6.iUsage = ESgUsageScreenSource;
  1.1108 +	TEST(KErrArgument == RSgImage::GetPixelFormats(info6, NULL, count));
  1.1109 +	
  1.1110 +	//negative aCount
  1.1111 +	TSgImageInfo info7;
  1.1112 +	info7.iCpuAccess = ESgCpuAccessNone;
  1.1113 +	info7.iShareable = EFalse;
  1.1114 +	info7.iSizeInPixels = TSize(10, 10);
  1.1115 +	CheckErrorL(KErrNone, RSgImage::GetPixelFormats(info7, NULL, count), (TText8*)__FILE__, __LINE__);
  1.1116 +	
  1.1117 +	if(count > 0)
  1.1118 +		{
  1.1119 +		TUidPixelFormat* pixelFormatArray = new(ELeave) TUidPixelFormat[count];
  1.1120 +		if(!pixelFormatArray)
  1.1121 +			{
  1.1122 +			User::Leave(KErrNoMemory);
  1.1123 +			}
  1.1124 +		CleanupStack::PushL(pixelFormatArray);
  1.1125 +		count = -100;
  1.1126 +		TEST(KErrArgument == RSgImage::GetPixelFormats(info7, pixelFormatArray, count));
  1.1127 +		
  1.1128 +		CleanupStack::PopAndDestroy(pixelFormatArray);
  1.1129 +		}
  1.1130 +	
  1.1131 +	//reset the array used by the GetPixelFormats function to prevent memory leaks
  1.1132 +	TSgImageInfo info8;
  1.1133 +	info8.iSizeInPixels = TSize(10, 10);
  1.1134 +	info8.iCpuAccess = ESgCpuAccessReadWrite;
  1.1135 +	info8.iUsage = ESgUsageDirectGdiSource;
  1.1136 +	info8.iShareable = EFalse;
  1.1137 +	info8.iScreenId = 100;
  1.1138 +	TEST(KErrNone == RSgImage::GetPixelFormats(info8, NULL, count));
  1.1139 +	TEST(count == 0);
  1.1140 +	
  1.1141 +	TestCloseDriver();
  1.1142 +	}
  1.1143 +
  1.1144 +/**
  1.1145 +@SYMTestCaseID			GRAPHICS-RESOURCE-0025
  1.1146 +@SYMTestCaseDesc		Opens an image with different invalid parameters.
  1.1147 +@SYMPREQ				PREQ39
  1.1148 +@SYMREQ					REQ8809
  1.1149 +@SYMREQ					REQ9175
  1.1150 +@SYMREQ					REQ9224 
  1.1151 +@SYMREQ					REQ9233  
  1.1152 +@SYMREQ					REQ9234
  1.1153 +@SYMFssID				RSgImage::Open(const TSgDrawableId&)
  1.1154 +@SYMTestPriority		Critical
  1.1155 +@SYMTestType			Unit Test
  1.1156 +@SYMTestPurpose			To check correct error messages are returned when opening image with 
  1.1157 +						different invalid parameters.
  1.1158 +@SYMTestActions			Initialise the graphics resource component. Construct an RSgImage object. 
  1.1159 +						Call the Open() function in both the current process and another process with:\n
  1.1160 +						\t 1. a non-null RSgImage handle\n
  1.1161 +						\t 2. null drawable id\n
  1.1162 +						\t 3. fake drawable id\n
  1.1163 +						\t 4. a non-sharable RSgImage handle
  1.1164 +						Do the same tests in a second thread and a second process.
  1.1165 +@SYMTestExpectedResults	The function should return:\n
  1.1166 +						\t 1. KErrInUse\n
  1.1167 +						\t 2. KErrArgument\n
  1.1168 +						\t 3. KErrNotFound\n
  1.1169 +						\t 4. KErrNone in the same process and KErrPermissionDenied or KErrNotFound in the second process
  1.1170 +@SYMTestStatus			Implemented 
  1.1171 + */	
  1.1172 +void CTSgImageGeneric::TestOpenImageInvalidL()
  1.1173 +	{	
  1.1174 +	TestOpenDriverL();
  1.1175 +	//create a non-sharable image
  1.1176 +	TSgImageInfo info;
  1.1177 +	info.iSizeInPixels = TSize(8, 8);
  1.1178 +	info.iUsage = ESgUsageDirectGdiTarget;
  1.1179 +	info.iPixelFormat = EUidPixelFormatRGB_565;
  1.1180 +	info.iShareable = EFalse;
  1.1181 +	
  1.1182 +	RSgImage image;
  1.1183 +	CheckErrorL(KErrNone, image.Create(info, KImageData, 16), (TText8*)__FILE__, __LINE__);
  1.1184 +	CleanupClosePushL(image);
  1.1185 +	const TSgDrawableId id = image.Id();
  1.1186 +	
  1.1187 +	//same thread
  1.1188 +	//  non-empty handle
  1.1189 +	RSgImage image1;
  1.1190 +	CreateImageL(image1);
  1.1191 +	CleanupClosePushL(image1);
  1.1192 +	TEST(KErrInUse == image1.Open(id));
  1.1193 +	image1.Close();
  1.1194 +	
  1.1195 +	//  null drawable id
  1.1196 +	CheckErrorL(KErrArgument, image1.Open(KSgNullDrawableId), (TText8*)__FILE__, __LINE__);
  1.1197 +	image1.Close();
  1.1198 +	
  1.1199 +	//  non-existing drawable id
  1.1200 +	TSgDrawableId fakeid = {0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF};
  1.1201 +	CheckErrorL(KErrNotFound, image1.Open(fakeid), (TText8*)__FILE__, __LINE__);
  1.1202 +	image1.Close();
  1.1203 +	
  1.1204 +	//  open a non-sharable image
  1.1205 +	TEST(KErrNone == image1.Open(id));
  1.1206 +	image1.Close();
  1.1207 +	
  1.1208 +	//different thread in the same process
  1.1209 +	TSgresTestInfo threadInfo = {id, info, 0, ESgresSecondThreadOpenImageInvalid};
  1.1210 +	TInt testResult = CreateSecondThreadAndDoTestL(threadInfo);
  1.1211 +	User::LeaveIfError(testResult);
  1.1212 +	// Test the results from the second thread
  1.1213 +	TEST(testResult & EFirstTestPassed);
  1.1214 +	TEST(testResult & ESecondTestPassed);
  1.1215 +	TEST(testResult & EThirdTestPassed);
  1.1216 +	TEST(testResult & EFourthTestPassed);
  1.1217 +	TEST(testResult & EFifthTestPassed);
  1.1218 +	
  1.1219 +	//different process	
  1.1220 +	TSgresTestInfo processInfo = {id, info, 0, ESgresSecondProcessOpenImageInvalid};
  1.1221 +	testResult = CreateSecondProcessAndDoTestL(KSecondProcess, processInfo);	
  1.1222 +	User::LeaveIfError(testResult);
  1.1223 +	TEST(testResult & EFirstTestPassed);	
  1.1224 +	TEST(testResult & ESecondTestPassed);
  1.1225 +	TEST(testResult & EThirdTestPassed);
  1.1226 +	TEST(testResult & EFourthTestPassed);	
  1.1227 +	TEST(testResult & EFifthTestPassed);
  1.1228 +		
  1.1229 +	CleanupStack::PopAndDestroy(2);
  1.1230 +	TestCloseDriver();
  1.1231 +	}
  1.1232 +
  1.1233 +/**
  1.1234 +@SYMTestCaseID			GRAPHICS-RESOURCE-0026
  1.1235 +@SYMTestCaseDesc		Closes an image multiple times.
  1.1236 +@SYMPREQ				PREQ39
  1.1237 +@SYMREQ					REQ8809
  1.1238 +@SYMREQ					REQ9175
  1.1239 +@SYMREQ					REQ9224 
  1.1240 +@SYMREQ					REQ9233  
  1.1241 +@SYMREQ					REQ9234
  1.1242 +@SYMFssID				RSgImage::Close()
  1.1243 +@SYMTestPriority		Critical
  1.1244 +@SYMTestType			Unit Test
  1.1245 +@SYMTestPurpose			To check calling Close() multiple times after Open() does not cause
  1.1246 +						errors or panics.
  1.1247 +@SYMTestActions			Initialise the graphics resource component. Create an image and then
  1.1248 +						call Close() three times on it.
  1.1249 +@SYMTestExpectedResults	The function should not cause any errors or panics.
  1.1250 +@SYMTestStatus			Implemented 
  1.1251 + */
  1.1252 +void CTSgImageGeneric::TestCloseImageManyTimesL()
  1.1253 +	{
  1.1254 +	TestOpenDriverL();
  1.1255 +	RSgImage image;
  1.1256 +	CreateImageL(image);
  1.1257 +	
  1.1258 +	image.Close();
  1.1259 +	image.Close();
  1.1260 +	image.Close();
  1.1261 +	
  1.1262 +	TestCloseDriver();
  1.1263 +	}
  1.1264 +
  1.1265 +
  1.1266 +/**
  1.1267 +@SYMTestCaseID			GRAPHICS-RESOURCE-0027
  1.1268 +@SYMTestCaseDesc		Closes an image object without opening it.
  1.1269 +@SYMPREQ				PREQ39
  1.1270 +@SYMREQ					REQ8809
  1.1271 +@SYMREQ					REQ9175
  1.1272 +@SYMREQ					REQ9224 
  1.1273 +@SYMREQ					REQ9233  
  1.1274 +@SYMREQ					REQ9234
  1.1275 +@SYMFssID				RSgImage::Close ()
  1.1276 +@SYMTestPriority		Critical
  1.1277 +@SYMTestType			Unit Test
  1.1278 +@SYMTestPurpose			To check Close() does nothing if the image is not already opened.
  1.1279 +@SYMTestActions			Initialise the graphics resource component. Declare an RSgImage object and
  1.1280 +						call Close() on it.
  1.1281 +@SYMTestExpectedResults	The function should not cause any errors or panics.
  1.1282 +@SYMTestStatus			Implemented 
  1.1283 + */	
  1.1284 +void CTSgImageGeneric::TestCloseImageWithoutOpenL()
  1.1285 +	{	
  1.1286 +	TestOpenDriverL();
  1.1287 +	RSgImage image;
  1.1288 +	image.Close();
  1.1289 +	TestCloseDriver();
  1.1290 +	}
  1.1291 +
  1.1292 +/**
  1.1293 +@SYMTestCaseID			GRAPHICS-RESOURCE-0028
  1.1294 +@SYMTestCaseDesc		Creates an image with various invalid parameters.
  1.1295 +@SYMPREQ				PREQ39
  1.1296 +@SYMREQ					REQ8809
  1.1297 +@SYMREQ					REQ9175
  1.1298 +@SYMREQ					REQ9192
  1.1299 +@SYMREQ					REQ9224 
  1.1300 +@SYMREQ					REQ9233  
  1.1301 +@SYMREQ					REQ9234
  1.1302 +@SYMFssID				RSgImage::Create(const TSgImageInfo&, const TAny*, TInt)\n 
  1.1303 +						RSgImage::Create(const TSgImageInfo, const RSgImage&)
  1.1304 +@SYMTestPriority		Critical
  1.1305 +@SYMTestType			Unit Test
  1.1306 +@SYMTestPurpose			To check the function returns the correct error messages when the parameters
  1.1307 +						are invalid.
  1.1308 +@SYMTestActions			Initialise the graphics resource component. Construct a TSgImageInfo object 
  1.1309 +						and Initialise the all the member variables with random values. Call the appropriate 
  1.1310 +						Create() function with:\n
  1.1311 +						\t 1. invalid TSgImageInfo\n
  1.1312 +						\t 2. unsupported TSgImageInfo\n
  1.1313 +						\t 3. the creating RSgImage handle is not null\n
  1.1314 +						\t 4. the aSgImage handle is null\n
  1.1315 +						\t 5. the size and pixel format in TSgImageInfo is not the same as that of aSgImage\n
  1.1316 +						\t 6. number of iUserAttributes is more than KMaxHint (8)\n
  1.1317 +@SYMTestExpectedResults	The function should return\n
  1.1318 +						\t 1. KErrArgument\n
  1.1319 +						\t 2. KErrNotSupported\n
  1.1320 +						\t 3. KErrInUse\n
  1.1321 +						\t 4. KErrArgument\n
  1.1322 +						\t 5. KErrNotSupported\n
  1.1323 +						\t 6. KErrOverflow\n
  1.1324 +@SYMTestStatus			Implemented 
  1.1325 + */	
  1.1326 +void CTSgImageGeneric::TestCreateImageInvalidL()
  1.1327 +	{
  1.1328 +	TestOpenDriverL();
  1.1329 +	RSgImage image;
  1.1330 +	
  1.1331 +	//invalid info 1 - invalid size
  1.1332 +	TSgImageInfo info1;
  1.1333 +	info1.iSizeInPixels = TSize(-100, 100);
  1.1334 +	TEST(KErrArgument == image.Create(info1, NULL, 0));
  1.1335 +	
  1.1336 +	//invalid info 2 - const image with writable cpu access flag
  1.1337 +	info1.iUsage = ESgUsageDirectGdiSource;
  1.1338 +	info1.iCpuAccess = ESgCpuAccessReadWrite;
  1.1339 +	TEST(KErrArgument == image.Create(info1, NULL, 0));
  1.1340 +	
  1.1341 +	//invalid info 3 - the image is used as a screen source but screen id is set to -1
  1.1342 +	info1.iUsage = ESgUsageScreenSource;
  1.1343 +	info1.iScreenId = KSgScreenIdAny;
  1.1344 +	TEST(KErrArgument == image.Create(info1, NULL, 0));
  1.1345 +	
  1.1346 +	//invalid info 4 - incorrect user attribute count
  1.1347 +	info1.iScreenId = KSgScreenIdMain;
  1.1348 +	TSgUserAttribute KTestAttributes[] = {{0x00008888, 1}, {0x00009999, 2}};
  1.1349 +	info1.iUserAttributes = KTestAttributes;
  1.1350 +	info1.iUserAttributeCount = 0;
  1.1351 +	TEST(KErrArgument == image.Create(info1, NULL, 0));
  1.1352 +	
  1.1353 +	//unsupported info 1 - unsupported pixel format
  1.1354 +	TSgImageInfo info2;
  1.1355 +	info2.iSizeInPixels = TSize(10, 10);
  1.1356 +	info2.iUsage = ESgUsageDirectGdiTarget;
  1.1357 +	info2.iPixelFormat = EUidPixelFormatAP_88;
  1.1358 +	TEST(KErrNotSupported == image.Create(info2, NULL, 0));
  1.1359 +
  1.1360 +	//unsupported info 2 - usage set to screen source and size is not the same as screen size
  1.1361 +	info2.iUsage = ESgUsageScreenSource|ESgUsageDirectGdiTarget;
  1.1362 +	info2.iSizeInPixels = TSize(9999, 8888);
  1.1363 +	TEST(KErrNotSupported == image.Create(info2, NULL, 0));
  1.1364 +
  1.1365 +#ifdef __WINS__
  1.1366 +	TSize screenSize;
  1.1367 +	if(HAL::Get(info2.iScreenId, HALData::EDisplayXPixels, screenSize.iWidth) == KErrNone
  1.1368 +		&& HAL::Get(info2.iScreenId, HALData::EDisplayYPixels, screenSize.iHeight) == KErrNone)
  1.1369 +		{
  1.1370 +		info2.iUsage = ESgUsageScreenSource;
  1.1371 +		info2.iScreenId = KSgScreenIdMain;
  1.1372 +		info2.iCpuAccess = ESgCpuAccessReadWrite;
  1.1373 +		info2.iSizeInPixels = TSize(screenSize.iWidth + 10, screenSize.iHeight);
  1.1374 +		TEST(KErrNotSupported == image.Create(info2, NULL, 0));
  1.1375 +		
  1.1376 +		info2.iSizeInPixels = TSize(screenSize.iWidth, screenSize.iHeight + 10);
  1.1377 +		TEST(KErrNotSupported == image.Create(info2, NULL, 0));
  1.1378 +		
  1.1379 +		info2.iSizeInPixels = TSize(screenSize.iHeight, screenSize.iWidth + 10);
  1.1380 +		TEST(KErrNotSupported == image.Create(info2, NULL, 0));
  1.1381 +		}	
  1.1382 +#endif
  1.1383 +	
  1.1384 +	//non-null handle
  1.1385 +	CreateImageL(image);
  1.1386 +	CleanupClosePushL(image);
  1.1387 +	TSgImageInfo info3;
  1.1388 +	info3.iSizeInPixels = TSize(8, 8);
  1.1389 +	info3.iUsage = ESgUsageDirectGdiSource;
  1.1390 +	info3.iPixelFormat = EUidPixelFormatRGB_565;
  1.1391 +	info3.iCpuAccess = ESgCpuAccessReadWrite;
  1.1392 +	TInt ret = image.Create(info3, NULL, 0);	
  1.1393 +	TEST(KErrInUse == ret);
  1.1394 +	
  1.1395 +	//non-null handle: create from an existing image
  1.1396 +	RSgImage image1;
  1.1397 +	CreateImageL(image1);
  1.1398 +	CleanupClosePushL(image1);
  1.1399 +	TEST(KErrInUse == image1.Create(info3, image));
  1.1400 +	CleanupStack::PopAndDestroy();
  1.1401 +	
  1.1402 +	//null existing image handle
  1.1403 +	RSgImage image2;
  1.1404 +	TEST(image2.IsNull());
  1.1405 +	TEST(KErrArgument == image1.Create(info3, image2));
  1.1406 +		
  1.1407 +	//the size and pixel format in TSgImageInfo is not the same as that of aSgImage
  1.1408 +	TSgImageInfo info4;
  1.1409 +	info4.iSizeInPixels = TSize(100, 100);
  1.1410 +	info4.iUsage = ESgUsageDirectGdiSource;
  1.1411 +	info4.iCpuAccess = ESgCpuAccessReadWrite;
  1.1412 +	TEST(KErrNotSupported == image1.Create(info4, image));
  1.1413 +	
  1.1414 +	info4.iSizeInPixels = info3.iSizeInPixels;
  1.1415 +	info4.iPixelFormat = EUidPixelFormatXRGB_8888;
  1.1416 +	TEST(KErrNotSupported == image1.Create(info4, image));
  1.1417 +	
  1.1418 +	//number of iUserAttributes more than KMaxHint(8)
  1.1419 +	TSgImageInfo info5;
  1.1420 +	info5.iSizeInPixels = TSize(100, 100);
  1.1421 +	info5.iPixelFormat = EUidPixelFormatRGB_565;
  1.1422 +	info5.iCpuAccess = ESgCpuAccessNone;
  1.1423 +	info5.iUsage = ESgUsageDirectGdiTarget;
  1.1424 +	info5.iShareable = ETrue;
  1.1425 +	TSgUserAttribute testAttributes[] = {{0x00008888, 1}, {0x00009999, 2}};
  1.1426 +	info5.iUserAttributes = testAttributes;
  1.1427 +	info5.iUserAttributeCount = 100;	
  1.1428 +	CheckErrorL(KErrOverflow, image1.Create(info5, NULL, 0), (TText8*)__FILE__, __LINE__);
  1.1429 +	
  1.1430 +	CleanupStack::PopAndDestroy(&image);
  1.1431 +	TestCloseDriver();
  1.1432 +	}
  1.1433 +
  1.1434 +/**
  1.1435 +@SYMTestCaseID			GRAPHICS-RESOURCE-0039
  1.1436 +@SYMTestCaseDesc		Calls GetInfo() on an invalid image.
  1.1437 +@SYMPREQ				PREQ39
  1.1438 +@SYMREQ					REQ8809
  1.1439 +@SYMREQ					REQ9175
  1.1440 +@SYMREQ					REQ9224 
  1.1441 +@SYMREQ					REQ9233  
  1.1442 +@SYMREQ					REQ9234
  1.1443 +@SYMFssID				RSgImage::GetInfo(TSgImageInfo&)
  1.1444 +@SYMTestPriority		Critical
  1.1445 +@SYMTestType			Unit Test
  1.1446 +@SYMTestPurpose			To check the correct error is returned when the client tries to get 
  1.1447 +						information on an invalid image.
  1.1448 +@SYMTestActions			Initialise the graphics resource component. Call GetInfo on an image:\n
  1.1449 +						\t 1. that is not initialised\n
  1.1450 +						\t 2. TSgImageInfo has different user attributes Ids from the existing Ids.
  1.1451 +@SYMTestExpectedResults	The function should return:\n
  1.1452 +						\t 1. KErrBadHandle\n
  1.1453 +						\t 2. KErrNotFound or KErrArgument
  1.1454 +@SYMTestStatus			Implemented 
  1.1455 + */	
  1.1456 +void CTSgImageGeneric::TestGetInfoInvalidImageL()
  1.1457 +	{
  1.1458 +	TestOpenDriverL();	
  1.1459 +	RSgImage image;
  1.1460 +	TSgImageInfo info;
  1.1461 +	
  1.1462 +	//uninitialised image
  1.1463 +	TEST(KErrBadHandle == image.GetInfo(info));
  1.1464 +	
  1.1465 +	//TSgImageInfo has different user attributes Ids from the existing Ids.
  1.1466 +	info.iPixelFormat = EUidPixelFormatRGB_565;
  1.1467 +	info.iSizeInPixels = TSize(100, 100);
  1.1468 +	info.iUsage = ESgUsageDirectGdiTarget;
  1.1469 +	TSgUserAttribute testAttributes[] = {{0x00008888, 1}, {0x00009999, 2}};
  1.1470 +	info.iUserAttributes = testAttributes;
  1.1471 +	info.iUserAttributeCount = 2;
  1.1472 +	CheckErrorL(KErrNone, image.Create(info, NULL, 0), (TText8*)__FILE__, __LINE__);
  1.1473 +	CleanupClosePushL(image);
  1.1474 +	TSgImageInfo info2;
  1.1475 +	TSgUserAttribute testAttributes2[1];
  1.1476 +	info2.iUserAttributes = testAttributes2;
  1.1477 +	info2.iUserAttributes[0].iUid = TUid::Uid(0x11111111);
  1.1478 +	info2.iUserAttributeCount = 1;
  1.1479 +	TInt result = image.GetInfo(info2);
  1.1480 +	TEST(KErrNotFound == result || KErrArgument == result);
  1.1481 +	TEST(!CompareInfos(info, info2));
  1.1482 +	
  1.1483 +	CleanupStack::PopAndDestroy();
  1.1484 +	TestCloseDriver();
  1.1485 +	}
  1.1486 +
  1.1487 +/**
  1.1488 +@SYMTestCaseID			GRAPHICS-RESOURCE-0030
  1.1489 +@SYMTestCaseDesc		Maps an image under various invalid conditions. 
  1.1490 +@SYMPREQ				PREQ39
  1.1491 +@SYMREQ					REQ8809
  1.1492 +@SYMREQ					REQ9175
  1.1493 +@SYMREQ					REQ9193
  1.1494 +@SYMREQ					REQ9224 
  1.1495 +@SYMREQ					REQ9233  
  1.1496 +@SYMREQ					REQ9234
  1.1497 +@SYMFssID				RSgImage::MapReadOnly(const TAny*&, TInt&) const\n 
  1.1498 +						RSgImage::MapWriteOnly(TAny*&, TInt&)\n 
  1.1499 +						RSgImage::MapReadWrite(TAny*&, TInt&)
  1.1500 +@SYMTestPriority		Critical
  1.1501 +@SYMTestType			Unit Test
  1.1502 +@SYMTestPurpose			To check the correct error messages are returned when different map
  1.1503 +						functions are called under various invalid conditions.
  1.1504 +@SYMTestActions			Initialise the graphics resource component. \n
  1.1505 +						\t 1. call any map function on an uninitialised RSgImage\n
  1.1506 +						\t 2. call any map function twice\n
  1.1507 +						\t 3. call MapReadOnly() on an RSgImage created without CPU access
  1.1508 +						flag ESgCpuAccessReadOnly or ESgCpuAccessReadWrite\n
  1.1509 +						\t 4. call MapWriteOnly() on an RSgImage created without CPU access
  1.1510 +						flag ESgCpuAccessWriteOnly or ESgCpuAccessReadWrite\n
  1.1511 +						\t 5. call MapReadWrite() on an RSgImage created without CPU access
  1.1512 +						flag ESgCpuAccessReadWrite\n
  1.1513 +						\t 6. call any map function in a second process
  1.1514 +@SYMTestExpectedResults	The function should return:\n
  1.1515 +						\t 1. KErrBadHandle\n
  1.1516 +						\t 2. KErrInUse\n
  1.1517 +						\t 3. KErrAccessDenied\n
  1.1518 +						\t 4. KErrAccessDenied\n
  1.1519 +						\t 5. KErrAccessDenied\n
  1.1520 +						\t 6. KErrPermissionDenied
  1.1521 +@SYMTestStatus			Implemented 
  1.1522 + */	
  1.1523 +void CTSgImageGeneric::TestMapImageInvalidL()
  1.1524 +	{
  1.1525 +	TestOpenDriverL();
  1.1526 +	RSgImage image;
  1.1527 +	const TAny* dataAddressRead;
  1.1528 +	TAny* dataAddressWrite;
  1.1529 +	TInt dataStride;
  1.1530 +	
  1.1531 +	//an uninitialised image
  1.1532 +	TEST(KErrBadHandle == image.MapReadOnly(dataAddressRead, dataStride));
  1.1533 +	TEST(KErrBadHandle == image.MapWriteOnly(dataAddressWrite, dataStride));
  1.1534 +	TEST(KErrBadHandle == image.MapReadWrite(dataAddressWrite, dataStride));
  1.1535 +	
  1.1536 +	//map twice
  1.1537 +	RSgImage image1;
  1.1538 +	CreateImageL(image1);
  1.1539 +	CleanupClosePushL(image1);
  1.1540 +	TEST(KErrNone == image1.MapReadOnly(dataAddressRead, dataStride));
  1.1541 +	TEST(KErrInUse == image1.MapReadOnly(dataAddressRead, dataStride));
  1.1542 +	TEST(KErrNone == image1.Unmap());
  1.1543 +	
  1.1544 +	TEST(KErrNone == image1.MapWriteOnly(dataAddressWrite, dataStride));
  1.1545 +	TEST(KErrInUse == image1.MapWriteOnly(dataAddressWrite, dataStride));
  1.1546 +	TEST(KErrNone == image1.Unmap());
  1.1547 +	
  1.1548 +	TEST(KErrNone == image1.MapReadWrite(dataAddressWrite, dataStride));
  1.1549 +	TEST(KErrInUse == image1.MapReadWrite(dataAddressWrite, dataStride));
  1.1550 +	TEST(KErrNone == image1.Unmap());
  1.1551 +	
  1.1552 +	CleanupStack::PopAndDestroy();	
  1.1553 +	
  1.1554 +	//  Initialise image
  1.1555 +	TSgImageInfo info;
  1.1556 +	info.iSizeInPixels = TSize(8, 8);
  1.1557 +	info.iUsage = ESgUsageDirectGdiSource;
  1.1558 +	info.iPixelFormat = EUidPixelFormatRGB_565;
  1.1559 +	info.iCpuAccess = ESgCpuAccessReadWrite;
  1.1560 +	info.iShareable = ETrue;
  1.1561 +	CheckErrorL(KErrNone, image.Create(info, KImageData, 16), (TText8*)__FILE__, __LINE__);
  1.1562 +	CleanupClosePushL(image);
  1.1563 +	TEST(KErrNone == image.MapReadWrite(dataAddressWrite, dataStride)); //first time should pass
  1.1564 +	TEST(KErrInUse == image.MapReadWrite(dataAddressWrite, dataStride)); //second time should fail
  1.1565 +	TEST(KErrNone == image.Unmap());
  1.1566 +	image.Close();
  1.1567 +	
  1.1568 +	//call MapReadOnly() on an RSgImage created without CPU access
  1.1569 +	//flag ESgCpuAccessReadOnly or ESgCpuAccessReadWrite
  1.1570 +	info.iCpuAccess = ESgCpuAccessNone;
  1.1571 +	CheckErrorL(KErrNone, image.Create(info, KImageData, 16), (TText8*)__FILE__, __LINE__);
  1.1572 +	TEST(KErrAccessDenied == image.MapReadOnly(dataAddressRead, dataStride));
  1.1573 +	image.Close();
  1.1574 +	
  1.1575 +	info.iCpuAccess = ESgCpuAccessWriteOnly;
  1.1576 +	CheckErrorL(KErrNone, image.Create(info, KImageData, 16), (TText8*)__FILE__, __LINE__);
  1.1577 +	TEST(KErrAccessDenied == image.MapReadOnly(dataAddressRead, dataStride));
  1.1578 +	image.Close();
  1.1579 +	
  1.1580 +	//call MapWriteOnly() on an RSgImage created without CPU access
  1.1581 +	//flag ESgCpuAccessWriteOnly or ESgCpuAccessReadWrite
  1.1582 +	info.iCpuAccess = ESgCpuAccessNone;
  1.1583 +	CheckErrorL(KErrNone, image.Create(info, KImageData, 16), (TText8*)__FILE__, __LINE__);
  1.1584 +	TEST(KErrAccessDenied == image.MapWriteOnly(dataAddressWrite, dataStride));
  1.1585 +	image.Close();
  1.1586 +	
  1.1587 +	info.iCpuAccess = ESgCpuAccessReadOnly;
  1.1588 +	CheckErrorL(KErrNone, image.Create(info, KImageData, 16), (TText8*)__FILE__, __LINE__);
  1.1589 +	TEST(KErrAccessDenied == image.MapWriteOnly(dataAddressWrite, dataStride));
  1.1590 +	image.Close();
  1.1591 +	
  1.1592 +	//call MapReadWrite() on an RSgImage created without CPU access
  1.1593 +	//flag ESgCpuAccessReadWrite
  1.1594 +	info.iCpuAccess = ESgCpuAccessNone;
  1.1595 +	CheckErrorL(KErrNone, image.Create(info, KImageData, 16), (TText8*)__FILE__, __LINE__);
  1.1596 +	TEST(KErrAccessDenied == image.MapReadWrite(dataAddressWrite, dataStride));
  1.1597 +	image.Close();
  1.1598 +	
  1.1599 +	info.iCpuAccess = ESgCpuAccessReadOnly;
  1.1600 +	CheckErrorL(KErrNone, image.Create(info, KImageData, 16), (TText8*)__FILE__, __LINE__);
  1.1601 +	TEST(KErrAccessDenied == image.MapReadWrite(dataAddressWrite, dataStride));
  1.1602 +	image.Close();
  1.1603 +	
  1.1604 +	info.iCpuAccess = ESgCpuAccessWriteOnly;
  1.1605 +	CheckErrorL(KErrNone, image.Create(info, KImageData, 16), (TText8*)__FILE__, __LINE__);
  1.1606 +	TEST(KErrAccessDenied == image.MapReadWrite(dataAddressWrite, dataStride));
  1.1607 +	image.Close();
  1.1608 +	
  1.1609 +	info.iCpuAccess = ESgCpuAccessReadWrite;
  1.1610 +	CheckErrorL(KErrNone, image.Create(info, KImageData, 16), (TText8*)__FILE__, __LINE__);
  1.1611 +	
  1.1612 +	//call map in a second thread in the current process - should succeed
  1.1613 +	TSgresTestInfo threadInfo = {image.Id(), info, 0, ESgresSecondThreadMapImage};	
  1.1614 +	TInt testResult = CreateSecondThreadAndDoTestL(threadInfo);
  1.1615 +	User::LeaveIfError(testResult);
  1.1616 +	TEST(testResult & EFirstTestPassed);
  1.1617 +	TEST(testResult & ESecondTestPassed);
  1.1618 +	TEST(testResult & EThirdTestPassed);
  1.1619 +	TEST(testResult & EFourthTestPassed);
  1.1620 +	TEST(testResult & EFifthTestPassed);
  1.1621 +	TEST(testResult & ESixthTestPassed);
  1.1622 +	TEST(testResult & ESeventhTestPassed);
  1.1623 +	
  1.1624 +	//call map in a non-owner process
  1.1625 +	TSgresTestInfo processInfo = {image.Id(), info, 0, ESgresSecondProcessMapImage};
  1.1626 +	testResult = CreateSecondProcessAndDoTestL(KSecondProcess, processInfo);	
  1.1627 +	User::LeaveIfError(testResult);	
  1.1628 +	TEST(testResult & EFirstTestPassed);
  1.1629 +	TEST(testResult & ESecondTestPassed);
  1.1630 +	TEST(testResult & EThirdTestPassed);
  1.1631 +	TEST(testResult & EFourthTestPassed);
  1.1632 +	TEST(testResult & EFifthTestPassed);
  1.1633 +	
  1.1634 +	CleanupStack::PopAndDestroy();
  1.1635 +	TestCloseDriver();
  1.1636 +	}
  1.1637 +
  1.1638 +/**
  1.1639 +@SYMTestCaseID			GRAPHICS-RESOURCE-0031
  1.1640 +@SYMTestCaseDesc		Unmaps an image under various invalid conditions.
  1.1641 +@SYMPREQ				PREQ39
  1.1642 +@SYMREQ					REQ8809
  1.1643 +@SYMREQ					REQ9175
  1.1644 +@SYMREQ					REQ9193
  1.1645 +@SYMREQ					REQ9224 
  1.1646 +@SYMREQ					REQ9233  
  1.1647 +@SYMREQ					REQ9234
  1.1648 +@SYMFssID				RSgImage::MapReadOnly(const TAny*&, TInt&) const\n 
  1.1649 +						RSgImage::MapWriteOnly(TAny*&, TInt&)\n 
  1.1650 +						RSgImage::MapReadWrite(TAny*&, TInt&)\n 
  1.1651 +						RSgImage::Unmap()
  1.1652 +@SYMTestPriority		Critical
  1.1653 +@SYMTestType			Unit Test
  1.1654 +@SYMTestPurpose			To check the correct error messages are returned when the Unmap()
  1.1655 +						function is called under various invalid conditions.
  1.1656 +@SYMTestActions			Initialise the graphics resource component.\n
  1.1657 +						\t 1. call Unmap() on an uninitialised image object\n
  1.1658 +						\t 2. create an image with CPU access flag ESgCpuAccessNone and then unmap it\n
  1.1659 +						\t 3. call Unmap() on an image that was not mapped.\n
  1.1660 +						\t 4. call Unmap() on a mapped image in a second thread in the same process.\n
  1.1661 +						\t 5. call Unmap() on an image in a non-owner process
  1.1662 +@SYMTestExpectedResults	The function should return:\n
  1.1663 +						\t 1. KErrBadHandle\n
  1.1664 +						\t 2. KErrGeneral\n
  1.1665 +						\t 3. KErrGeneral\n
  1.1666 +						\t 4. KErrNone\n
  1.1667 +						\t 5. KErrGeneral
  1.1668 +@SYMTestStatus			Implemented 
  1.1669 + */	
  1.1670 +void CTSgImageGeneric::TestUnmapImageInvalidL()
  1.1671 +	{
  1.1672 +	TestOpenDriverL();
  1.1673 +	RSgImage image;
  1.1674 +	
  1.1675 +	//unitialized image
  1.1676 +	TEST(KErrBadHandle == image.Unmap());
  1.1677 +	
  1.1678 +	//create an image
  1.1679 +	TSgImageInfo info;
  1.1680 +	info.iSizeInPixels = TSize(8, 8);
  1.1681 +	info.iUsage = ESgUsageDirectGdiSource;
  1.1682 +	info.iPixelFormat = EUidPixelFormatRGB_565;
  1.1683 +	info.iShareable = ETrue;
  1.1684 +	info.iCpuAccess = ESgCpuAccessReadWrite;
  1.1685 +	const TAny* dataAddressRead;
  1.1686 +	TInt dataStride;
  1.1687 +	CheckErrorL(KErrNone, image.Create(info, KImageData, 16), (TText8*)__FILE__, __LINE__);
  1.1688 +	CleanupClosePushL(image);
  1.1689 +	
  1.1690 +	//call on an unmapped image
  1.1691 +	TEST(KErrGeneral == image.Unmap());
  1.1692 +	
  1.1693 +	//map in the current thread and try to unmap in another thread in the current process
  1.1694 +	//should fail	
  1.1695 +	TEST(KErrNone == image.MapReadOnly(dataAddressRead, dataStride));	
  1.1696 +	TSgDrawableId id = image.Id();
  1.1697 +	TSgImageInfo imageinfo;
  1.1698 +	image.GetInfo(imageinfo);
  1.1699 +	
  1.1700 +	TSgresTestInfo threadInfo = {id, imageinfo, 0, ESgresSecondThreadUnmapImage};
  1.1701 +	TInt testResult = CreateSecondThreadAndDoTestL(threadInfo);
  1.1702 +	User::LeaveIfError(testResult);
  1.1703 +	TEST(testResult & EFirstTestPassed);
  1.1704 +	TEST(testResult & ESecondTestPassed);
  1.1705 +	
  1.1706 +	//image should already be unmapped
  1.1707 +	TEST(KErrGeneral == image.Unmap());
  1.1708 +	
  1.1709 +	//map in the current thread and try to unmap in another process
  1.1710 +	//should fail
  1.1711 +	TEST(KErrNone == image.MapReadOnly(dataAddressRead, dataStride));	
  1.1712 +	TSgresTestInfo processInfo = {id, imageinfo, 0, ESgresSecondProcessUnmapImage};
  1.1713 +	testResult = CreateSecondProcessAndDoTestL(KSecondProcess, processInfo);	
  1.1714 +	User::LeaveIfError(testResult);
  1.1715 +	TEST(testResult & EFirstTestPassed);	
  1.1716 +	TEST(testResult & ESecondTestPassed);
  1.1717 +	
  1.1718 +	//image should still be mapped
  1.1719 +	TEST(KErrNone == image.Unmap());
  1.1720 +	
  1.1721 +	CleanupStack::PopAndDestroy();
  1.1722 +	TestCloseDriver();
  1.1723 +	}
  1.1724 +
  1.1725 +/**
  1.1726 +@SYMTestCaseID			GRAPHICS-RESOURCE-0048
  1.1727 +@SYMTestCaseDesc		RSgImage stress tests
  1.1728 +@SYMPREQ				PREQ39
  1.1729 +@SYMREQ					REQ8809
  1.1730 +@SYMREQ					REQ9175
  1.1731 +@SYMREQ					REQ9224 
  1.1732 +@SYMREQ					REQ9233  
  1.1733 +@SYMREQ					REQ9234
  1.1734 +@SYMFssID				RSgImage::Create(const TSgImageInfo&, const TAny*, TInt)\n
  1.1735 +						RSgImage::Close() 
  1.1736 +@SYMTestPriority		Critical
  1.1737 +@SYMTestType			Unit Test
  1.1738 +@SYMTestPurpose			To ensure creating and destroying RSgImage multiple times work well.
  1.1739 +@SYMTestActions			Create images 1000 times but only store KMaxImagesInArray of them 
  1.1740 +						at one time in an RArray. When a new image is to be added to the 
  1.1741 +						array, a random image from the array is removed.
  1.1742 +@SYMTestExpectedResults	There should be no panics or leaves.
  1.1743 +@SYMTestStatus			Implemented 
  1.1744 + */
  1.1745 +void CTSgImageGeneric::TestStress1L()
  1.1746 +	{
  1.1747 +	TestOpenDriverL();
  1.1748 +	TSgImageInfo info;
  1.1749 +	info.iPixelFormat = EUidPixelFormatRGB_565;
  1.1750 +	info.iSizeInPixels = TSize(100, 100);
  1.1751 +	info.iUsage = ESgUsageDirectGdiTarget;
  1.1752 +	
  1.1753 +	TInt KMaxImagesInArray =40;
  1.1754 +	TInt64 seed = 0;
  1.1755 +	for (TInt count = 1000; count > 0; --count)
  1.1756 +		{
  1.1757 +		RSgImage image;
  1.1758 +		CheckErrorL(KErrNone, image.Create(info, NULL, 0), (TText8*)__FILE__, __LINE__);
  1.1759 +		CleanupClosePushL(image);
  1.1760 +		iTestImages.AppendL(image);
  1.1761 +		CleanupStack::Pop();
  1.1762 +		if (iTestImages.Count() >= KMaxImagesInArray)
  1.1763 +			{
  1.1764 +			TInt i = Math::Rand(seed) % KMaxImagesInArray;
  1.1765 +			iTestImages[i].Close();
  1.1766 +			iTestImages.Remove(i);
  1.1767 +			}
  1.1768 +		}
  1.1769 +	TInt count = iTestImages.Count();
  1.1770 +	for(TInt i=0; i<count; ++i)
  1.1771 +		{
  1.1772 +		iTestImages[i].Close();
  1.1773 +		}	
  1.1774 +	iTestImages.Reset();
  1.1775 +	TestCloseDriver();
  1.1776 +	}
  1.1777 +
  1.1778 +/**
  1.1779 +@SYMTestCaseID			GRAPHICS-RESOURCE-0049
  1.1780 +@SYMTestCaseDesc		RSgImage multiple threads open and close stress tests
  1.1781 +@SYMPREQ				PREQ39
  1.1782 +@SYMREQ					REQ8809
  1.1783 +@SYMREQ					REQ9175
  1.1784 +@SYMREQ					REQ9224 
  1.1785 +@SYMREQ					REQ9233  
  1.1786 +@SYMREQ					REQ9234
  1.1787 +@SYMFssID				RSgImage::Open(const TSgDrawableId&)\n
  1.1788 +						RSgImage::Close() 
  1.1789 +@SYMTestPriority		Critical
  1.1790 +@SYMTestType			Unit Test
  1.1791 +@SYMTestPurpose			To ensure opening and destroying RSgImage multiple times and randomly
  1.1792 +						in other threads work well.
  1.1793 +@SYMTestActions			Create an image in the main thread. In a loop of 1000 times, randomly select
  1.1794 +						one of the five threads and either open or close the image depending on the 
  1.1795 +						state of the thread.
  1.1796 +@SYMTestExpectedResults	There should be no panics or leaves.
  1.1797 +@SYMTestStatus			Implemented 
  1.1798 + */
  1.1799 +void CTSgImageGeneric::TestStress2L()
  1.1800 +	{
  1.1801 +	TestOpenDriverL();
  1.1802 +	RSgImage image;
  1.1803 +	CreateImageL(image);
  1.1804 +	CleanupClosePushL(image);
  1.1805 +	const TSgDrawableId id = image.Id();
  1.1806 +	
  1.1807 +	TSgImageInfo info;
  1.1808 +	TEST(KErrNone == image.GetInfo(info));
  1.1809 +	TSgresTestInfo threadInfo = {id, info, 0, ESgresMultipleThreadStressTest, EFalse};
  1.1810 +	
  1.1811 +	//create a semaphore
  1.1812 +	RSemaphore sem;
  1.1813 +	User::LeaveIfError(sem.CreateGlobal(KSecondThreadSemaphore, 0, EOwnerThread));
  1.1814 +	CleanupClosePushL(sem);
  1.1815 +	
  1.1816 +	//create threads
  1.1817 +	const TInt KNoOfThreads = 5;
  1.1818 +	RArray<RThread> threads;
  1.1819 +	_LIT(KMultipleThreadName, "Multiple Threads Stress Test Thread ");
  1.1820 +	for (TInt i = 0; i < KNoOfThreads; ++i)
  1.1821 +		{
  1.1822 +		TBuf<50> threadName(KMultipleThreadName);
  1.1823 +		threadName.AppendNum(i);
  1.1824 +		RThread thread;
  1.1825 +		User::LeaveIfError(thread.Create(threadName, SecondThreadStart, KDefaultStackSize, &User::Heap(), &threadInfo));
  1.1826 +		thread.SetPriority(EPriorityLess);
  1.1827 +		threads.AppendL(thread);
  1.1828 +		}
  1.1829 +	// run threads
  1.1830 +	for (TInt i = 0; i < KNoOfThreads; ++i)
  1.1831 +		{
  1.1832 +		threads[i].Resume();
  1.1833 +		}
  1.1834 +	// wait for the threads to terminate processing
  1.1835 +	for (TInt i = 0; i < KNoOfThreads; ++i)
  1.1836 +		{
  1.1837 +		sem.Wait();
  1.1838 +		}
  1.1839 +	for (TInt i = 0; i < KNoOfThreads; ++i)
  1.1840 +		{
  1.1841 +		threads[i].Close();
  1.1842 +		}
  1.1843 +	CleanupStack::PopAndDestroy(2); // image, sem
  1.1844 +	TestCloseDriver();
  1.1845 +	}
  1.1846 +
  1.1847 +/**
  1.1848 +@SYMTestCaseID			GRAPHICS-RESOURCE-0051
  1.1849 +@SYMTestCaseDesc		Calls RSgImage::GetInterface() with an invalid image handle
  1.1850 +@SYMPREQ				PREQ39
  1.1851 +@SYMREQ					REQ8809
  1.1852 +@SYMREQ					REQ9175
  1.1853 +@SYMFssID				RSgImage::GetInterface(TUid, TAny*&)\n 
  1.1854 +@SYMTestPriority		Critical
  1.1855 +@SYMTestType			Unit Test
  1.1856 +@SYMTestPurpose			To ensure calling GetInterface() with an invalid image handle will cause a panic.
  1.1857 +@SYMTestActions			Initialise the graphics resource component and create an image in a second thread. 
  1.1858 +						Declare another image and assign it to the current image handle. Close the current
  1.1859 +						image so the second image handle becomes invalid. Call GetInterface() on the second
  1.1860 +						handle.
  1.1861 +@SYMTestExpectedResults The function should panic in the second thread with panic code SGRES 2(ESgPanicBadDrawableHandle).
  1.1862 +@SYMTestStatus			Implemented 
  1.1863 + */
  1.1864 +void CTSgImageGeneric::TestPanicImageGetInterfaceInvalidHandleL()
  1.1865 +	{
  1.1866 +	TSgImageInfo info;
  1.1867 +	TSgresTestInfo threadInfo = {KSgNullDrawableId, info, 0, ESgresSecondThreadPanicImageGetInterfaceInvalidHandle, ETrue};
  1.1868 + 	TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
  1.1869 +	_LIT(KTestName, "TestImageGetInterfaceInvalidHandleLThread");
  1.1870 + 	CreateSecondThreadAndCheckPanicL(threadInfo, 2, exitCategoryName, KTestName);
  1.1871 +	}
  1.1872 +
  1.1873 +/**
  1.1874 +@SYMTestCaseID			GRAPHICS-RESOURCE-0052
  1.1875 +@SYMTestCaseDesc		Calls RSgImage::GetInterface() with a non-null handle and an uninitialised driver
  1.1876 +@SYMPREQ				PREQ39
  1.1877 +@SYMREQ					REQ8809
  1.1878 +@SYMREQ					REQ9175
  1.1879 +@SYMFssID				RSgImage::GetInterface(TUid, TAny*&)\n 
  1.1880 +@SYMTestPriority		Critical
  1.1881 +@SYMTestType			Unit Test
  1.1882 +@SYMTestPurpose			To ensure calling GetInterface() with a non-null handle and an uninitialised driver will cause a panic.
  1.1883 +@SYMTestActions			Initialise the graphics resource component and create an image in a second thread. 
  1.1884 +						Declare another image and assign it to the current image handle. Close the current
  1.1885 +						image so the second image handle becomes invalid. Close the graphics resource driver.
  1.1886 +						Call GetInterface() on the second handle.
  1.1887 +@SYMTestExpectedResults The function should panic in the second thread with panic code SGRES 5 (ESgPanicNoDriver).
  1.1888 +@SYMTestStatus			Implemented 
  1.1889 + */
  1.1890 +void CTSgImageGeneric::TestPanicImageGetInterfaceNoDriverL()
  1.1891 +	{	
  1.1892 +	TSgImageInfo info;
  1.1893 +	TSgresTestInfo threadInfo = {KSgNullDrawableId, info, 0, ESgresSecondThreadPanicImageGetInterfaceNoDriver, ETrue};
  1.1894 + 	TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
  1.1895 +	_LIT(KTestName, "TestImageGetInterfaceNoDriverL");
  1.1896 + 	CreateSecondThreadAndCheckPanicL(threadInfo, 5, exitCategoryName, KTestName);
  1.1897 +	}
  1.1898 +
  1.1899 +/**
  1.1900 +@SYMTestCaseID			GRAPHICS-RESOURCE-0053
  1.1901 +@SYMTestCaseDesc		Calls RSgImage::Close() with an invalid image handle
  1.1902 +@SYMPREQ				PREQ39
  1.1903 +@SYMREQ					REQ8809
  1.1904 +@SYMREQ					REQ9175
  1.1905 +@SYMFssID				RSgImage::Close()\n 
  1.1906 +@SYMTestPriority		Critical
  1.1907 +@SYMTestType			Unit Test
  1.1908 +@SYMTestPurpose			To ensure calling Close() with an invalid image handle will cause a panic.
  1.1909 +@SYMTestActions			Initialise the graphics resource component and create an image in a second thread. 
  1.1910 +						Declare another image and assign it to the current image handle. Close the current
  1.1911 +						image so the second image handle becomes invalid. Call Close() on the second handle.
  1.1912 +@SYMTestExpectedResults The function should panic in the second thread with panic code SGRES 2(ESgPanicBadDrawableHandle).
  1.1913 +@SYMTestStatus			Implemented 
  1.1914 + */
  1.1915 +void CTSgImageGeneric::TestPanicImageCloseInvalidHandleL()
  1.1916 +	{
  1.1917 +	TSgImageInfo info;
  1.1918 +	TSgresTestInfo threadInfo = {KSgNullDrawableId, info, 0, ESgresSecondThreadPanicImageCloseInvalidHandle, ETrue};
  1.1919 + 	TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
  1.1920 +	_LIT(KTestName, "TestImageCloseInvalidHandleL");
  1.1921 + 	CreateSecondThreadAndCheckPanicL(threadInfo, 2, exitCategoryName, KTestName);
  1.1922 +	}
  1.1923 +
  1.1924 +/**
  1.1925 +@SYMTestCaseID			GRAPHICS-RESOURCE-0054
  1.1926 +@SYMTestCaseDesc		Calls RSgImage::Close() with a non-null handle and an uninitialised driver
  1.1927 +@SYMPREQ				PREQ39
  1.1928 +@SYMREQ					REQ8809
  1.1929 +@SYMREQ					REQ9175
  1.1930 +@SYMFssID				RSgImage::Close()\n 
  1.1931 +@SYMTestPriority		Critical
  1.1932 +@SYMTestType			Unit Test
  1.1933 +@SYMTestPurpose			To ensure calling Close() with a non-null handle and an uninitialised driver will cause a panic.
  1.1934 +@SYMTestActions			Initialise the graphics resource component and create an image in a second thread. 
  1.1935 +						Declare another image and assign it to the current image handle. Close the current
  1.1936 +						image so the second image handle becomes invalid. Close the graphics resource driver.
  1.1937 +						Call Close() on the second handle.
  1.1938 +@SYMTestExpectedResults The function should panic in the second thread with panic code SGRES 5 (ESgPanicNoDriver).
  1.1939 +@SYMTestStatus			Implemented 
  1.1940 + */
  1.1941 +void CTSgImageGeneric::TestPanicImageCloseNoDriverL()
  1.1942 +	{
  1.1943 +	TSgImageInfo info;
  1.1944 +	TSgresTestInfo threadInfo = {KSgNullDrawableId, info, 0, ESgresSecondThreadPanicImageCloseNoDriver, ETrue};
  1.1945 + 	TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
  1.1946 +	_LIT(KTestName, "TestImageCloseNoDriverL");
  1.1947 + 	CreateSecondThreadAndCheckPanicL(threadInfo, 5, exitCategoryName, KTestName);
  1.1948 +	}
  1.1949 +
  1.1950 +/**
  1.1951 +@SYMTestCaseID			GRAPHICS-RESOURCE-0055
  1.1952 +@SYMTestCaseDesc		Calls RSgImage::Id() with an invalid image handle
  1.1953 +@SYMPREQ				PREQ39
  1.1954 +@SYMREQ					REQ8809
  1.1955 +@SYMREQ					REQ9175
  1.1956 +@SYMFssID				RSgImage::Id()\n 
  1.1957 +@SYMTestPriority		Critical
  1.1958 +@SYMTestType			Unit Test
  1.1959 +@SYMTestPurpose			To ensure calling Id() with an invalid image handle will cause a panic.
  1.1960 +@SYMTestActions			Initialise the graphics resource component and create an image in a second thread. 
  1.1961 +						Declare another image and assign it to the current image handle. Close the current
  1.1962 +						image so the second image handle becomes invalid. Call Id() on the second
  1.1963 +						handle.
  1.1964 +@SYMTestExpectedResults The function should panic in the second thread with panic code SGRES 2(ESgPanicBadDrawableHandle).
  1.1965 +@SYMTestStatus			Implemented 
  1.1966 + */
  1.1967 +void CTSgImageGeneric::TestPanicImageIdInvalidHandleL()
  1.1968 +	{
  1.1969 +	TSgImageInfo info;
  1.1970 +	TSgresTestInfo threadInfo = {KSgNullDrawableId, info, 0, ESgresSecondThreadPanicImageIdInvalidHandle, ETrue};
  1.1971 + 	TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
  1.1972 +	_LIT(KTestName, "TestImageIdInvalidHandleL");
  1.1973 + 	CreateSecondThreadAndCheckPanicL(threadInfo, 2, exitCategoryName, KTestName);
  1.1974 +	}
  1.1975 +
  1.1976 +/**
  1.1977 +@SYMTestCaseID			GRAPHICS-RESOURCE-0056
  1.1978 +@SYMTestCaseDesc		Calls RSgImage::Id() with a non-null handle and an uninitialised driver
  1.1979 +@SYMPREQ				PREQ39
  1.1980 +@SYMREQ					REQ8809
  1.1981 +@SYMREQ					REQ9175
  1.1982 +@SYMFssID				RSgImage::Id()\n 
  1.1983 +@SYMTestPriority		Critical
  1.1984 +@SYMTestType			Unit Test
  1.1985 +@SYMTestPurpose			To ensure calling Id() with a non-null handle and an uninitialised driver will cause a panic.
  1.1986 +@SYMTestActions			Initialise the graphics resource component and create an image in a second thread. 
  1.1987 +						Declare another image and assign it to the current image handle. Close the current
  1.1988 +						image so the second image handle becomes invalid. Close the graphics resource driver.
  1.1989 +						Call Id() on the second handle.
  1.1990 +@SYMTestExpectedResults The function should panic in the second thread with panic code SGRES 5 (ESgPanicNoDriver).
  1.1991 +@SYMTestStatus			Implemented 
  1.1992 + */
  1.1993 +void CTSgImageGeneric::TestPanicImageIdNoDriverL()
  1.1994 +	{
  1.1995 +	TSgImageInfo info;
  1.1996 +	TSgresTestInfo threadInfo = {KSgNullDrawableId, info, 0, ESgresSecondThreadPanicImageIdNoDriver, ETrue};
  1.1997 + 	TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
  1.1998 +	_LIT(KTestName, "TestImageIdNoDriverL");
  1.1999 + 	CreateSecondThreadAndCheckPanicL(threadInfo, 5, exitCategoryName, KTestName);
  1.2000 +	}
  1.2001 +
  1.2002 +/**
  1.2003 +@SYMTestCaseID			GRAPHICS-RESOURCE-0057
  1.2004 +@SYMTestCaseDesc		Calls RSgImage::Create() with an invalid image handle
  1.2005 +@SYMPREQ				PREQ39
  1.2006 +@SYMREQ					REQ8809
  1.2007 +@SYMREQ					REQ9175
  1.2008 +@SYMREQ					REQ9192
  1.2009 +@SYMFssID				RSgImage::Create(const TSgImageInfo&, const RSgImage&)\n 
  1.2010 +@SYMTestPriority		Critical
  1.2011 +@SYMTestType			Unit Test
  1.2012 +@SYMTestPurpose			To ensure calling Create() with an invalid image handle will cause a panic.
  1.2013 +@SYMTestActions			Initialise the graphics resource component and create an image in a second thread. 
  1.2014 +						Declare another image and assign it to the current image handle. Close the current
  1.2015 +						image so the second image handle becomes invalid. Call Create() on the second
  1.2016 +						handle.
  1.2017 +@SYMTestExpectedResults The function should panic in the second thread with panic code SGRES 2(ESgPanicBadDrawableHandle).
  1.2018 +@SYMTestStatus			Implemented 
  1.2019 + */
  1.2020 +void CTSgImageGeneric::TestPanicImageCreateInvalidHandleL()
  1.2021 +	{
  1.2022 +	TSgImageInfo info;
  1.2023 +	TSgresTestInfo threadInfo = {KSgNullDrawableId, info, 0, ESgresSecondThreadPanicImageCreateInvalidHandle, ETrue};
  1.2024 + 	TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
  1.2025 +	_LIT(KTestName, "TestImageCreateInvalidHandleL");
  1.2026 + 	CreateSecondThreadAndCheckPanicL(threadInfo, 3, exitCategoryName, KTestName);
  1.2027 +	}
  1.2028 +
  1.2029 +/**
  1.2030 +@SYMTestCaseID			GRAPHICS-RESOURCE-0058
  1.2031 +@SYMTestCaseDesc		Calls RSgImage::GetInfo() with an invalid image handle
  1.2032 +@SYMPREQ				PREQ39
  1.2033 +@SYMREQ					REQ8809
  1.2034 +@SYMREQ					REQ9175
  1.2035 +@SYMFssID				RSgImage::GetInfo(TSgImageInfo&)\n 
  1.2036 +@SYMTestPriority		Critical
  1.2037 +@SYMTestType			Unit Test
  1.2038 +@SYMTestPurpose			To ensure calling GetInfo() with an invalid image handle will cause a panic.
  1.2039 +@SYMTestActions			Initialise the graphics resource component and create an image in a second thread. 
  1.2040 +						Declare another image and assign it to the current image handle. Close the current
  1.2041 +						image so the second image handle becomes invalid. Call GetInfo() on the second
  1.2042 +						handle.
  1.2043 +@SYMTestExpectedResults The function should panic in the second thread with panic code SGRES 2(ESgPanicBadDrawableHandle).
  1.2044 +@SYMTestStatus			Implemented 
  1.2045 + */
  1.2046 +void CTSgImageGeneric::TestPanicImageGetInfoInvalidHandleL()
  1.2047 +	{
  1.2048 +	TSgImageInfo info;
  1.2049 +	TSgresTestInfo threadInfo = {KSgNullDrawableId, info, 0, ESgresSecondThreadPanicImageGetInfoInvalidHandle, ETrue};
  1.2050 + 	TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
  1.2051 +	_LIT(KTestName, "TestImageGetInfoInvalidHandleL");
  1.2052 + 	CreateSecondThreadAndCheckPanicL(threadInfo, 3, exitCategoryName, KTestName);
  1.2053 +	}
  1.2054 +
  1.2055 +/**
  1.2056 +@SYMTestCaseID			GRAPHICS-RESOURCE-0059
  1.2057 +@SYMTestCaseDesc		Calls RSgImage::GetInfo() with a non-null handle and an uninitialised driver
  1.2058 +@SYMPREQ				PREQ39
  1.2059 +@SYMREQ					REQ8809
  1.2060 +@SYMREQ					REQ9175
  1.2061 +@SYMFssID				SgImage::GetInfo(TSgImageInfo&)\n 
  1.2062 +@SYMTestPriority		Critical
  1.2063 +@SYMTestType			Unit Test
  1.2064 +@SYMTestPurpose			To ensure calling GetInfo() with a non-null handle and an uninitialised driver will cause a panic.
  1.2065 +@SYMTestActions			Initialise the graphics resource component and create an image in a second thread. 
  1.2066 +						Declare another image and assign it to the current image handle. Close the current
  1.2067 +						image so the second image handle becomes invalid. Close the graphics resource driver.
  1.2068 +						Call GetInfo() on the second handle.
  1.2069 +@SYMTestExpectedResults The function should panic in the second thread with panic code SGRES 5 (ESgPanicNoDriver).
  1.2070 +@SYMTestStatus			Implemented 
  1.2071 + */
  1.2072 +void CTSgImageGeneric::TestPanicImageGetInfoNoDriverL()
  1.2073 +	{
  1.2074 +	TSgImageInfo info;
  1.2075 +	TSgresTestInfo threadInfo = {KSgNullDrawableId, info, 0, ESgresSecondThreadPanicImageGetInfoNoDriver, ETrue};
  1.2076 + 	TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
  1.2077 +	_LIT(KTestName, "TestImageGetInfoNoDriverL");
  1.2078 + 	CreateSecondThreadAndCheckPanicL(threadInfo, 5, exitCategoryName, KTestName);
  1.2079 +	}
  1.2080 +
  1.2081 +/**
  1.2082 +@SYMTestCaseID			GRAPHICS-RESOURCE-0060
  1.2083 +@SYMTestCaseDesc		Calls RSgImage::MapReadOnly with an invalid image handle
  1.2084 +@SYMPREQ				PREQ39
  1.2085 +@SYMREQ					REQ8809
  1.2086 +@SYMREQ					REQ9175
  1.2087 +@SYMREQ					REQ9193
  1.2088 +@SYMFssID				RSgImage::MapReadOnly(const TAny*&, TInt&) const\n 
  1.2089 +@SYMTestPriority		Critical
  1.2090 +@SYMTestType			Unit Test
  1.2091 +@SYMTestPurpose			To ensure calling MapReadOnly() with an invalid image handle will cause a panic.
  1.2092 +@SYMTestActions			Initialise the graphics resource component and create an image in a second thread. 
  1.2093 +						Declare another image and assign it to the current image handle. Close the current
  1.2094 +						image so the second image handle becomes invalid. Call MapReadOnly() on the second
  1.2095 +						handle.
  1.2096 +@SYMTestExpectedResults The function should panic in the second thread with panic code SGRES 2(ESgPanicBadDrawableHandle).
  1.2097 +@SYMTestStatus			Implemented 
  1.2098 + */
  1.2099 +void CTSgImageGeneric::TestPanicImageMapReadOnlyInvalidHandleL()
  1.2100 +	{
  1.2101 +	TSgImageInfo info;
  1.2102 +	TSgresTestInfo threadInfo = {KSgNullDrawableId, info, 0, ESgresSecondThreadPanicImageMapReadOnlyInvalidHandle, ETrue};
  1.2103 + 	TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
  1.2104 +	_LIT(KTestName, "TestImageMapReadOnlyInvalidHandleL");
  1.2105 + 	CreateSecondThreadAndCheckPanicL(threadInfo, 3, exitCategoryName, KTestName);
  1.2106 +	}
  1.2107 +
  1.2108 +/**
  1.2109 +@SYMTestCaseID			GRAPHICS-RESOURCE-0061
  1.2110 +@SYMTestCaseDesc		Calls RSgImage::MapReadOnly with a non-null handle and an uninitialised driver
  1.2111 +@SYMPREQ				PREQ39
  1.2112 +@SYMREQ					REQ8809
  1.2113 +@SYMREQ					REQ9175
  1.2114 +@SYMREQ					REQ9193
  1.2115 +@SYMFssID				RSgImage::MapReadOnly(const TAny*&, TInt&) const\n 
  1.2116 +@SYMTestPriority		Critical
  1.2117 +@SYMTestType			Unit Test
  1.2118 +@SYMTestPurpose			To ensure calling MapReadOnly() with a non-null handle and an uninitialised driver will cause a panic.
  1.2119 +@SYMTestActions			Initialise the graphics resource component and create an image in a second thread. 
  1.2120 +						Declare another image and assign it to the current image handle. Close the current
  1.2121 +						image so the second image handle becomes invalid. Close the graphics resource driver.
  1.2122 +						Call MapReadOnly() on the second handle.
  1.2123 +@SYMTestExpectedResults The function should panic in the second thread with panic code SGRES 5 (ESgPanicNoDriver).
  1.2124 +@SYMTestStatus			Implemented 
  1.2125 + */
  1.2126 +void CTSgImageGeneric::TestPanicImageMapReadOnlyNoDriverL()
  1.2127 +	{
  1.2128 +	TSgImageInfo info;
  1.2129 +	TSgresTestInfo threadInfo = {KSgNullDrawableId, info, 0, ESgresSecondThreadPanicImageMapReadOnlyNoDriver, ETrue};
  1.2130 + 	TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
  1.2131 +	_LIT(KTestName, "TestImageMapReadOnlyNoDriverL");
  1.2132 + 	CreateSecondThreadAndCheckPanicL(threadInfo, 5, exitCategoryName, KTestName);
  1.2133 +	}
  1.2134 +
  1.2135 +/**
  1.2136 +@SYMTestCaseID			GRAPHICS-RESOURCE-0062
  1.2137 +@SYMTestCaseDesc		Calls RSgImage::MapWriteOnly() with an invalid image handle
  1.2138 +@SYMPREQ				PREQ39
  1.2139 +@SYMREQ					REQ8809
  1.2140 +@SYMREQ					REQ9175
  1.2141 +@SYMREQ					REQ9193
  1.2142 +@SYMFssID				RSgImage::MapWriteOnly(TAny*&, TInt&)\n 
  1.2143 +@SYMTestPriority		Critical
  1.2144 +@SYMTestType			Unit Test
  1.2145 +@SYMTestPurpose			To ensure calling MapWriteOnly() with an invalid image handle will cause a panic.
  1.2146 +@SYMTestActions			Initialise the graphics resource component and create an image in a second thread. 
  1.2147 +						Declare another image and assign it to the current image handle. Close the current
  1.2148 +						image so the second image handle becomes invalid. Call MapWriteOnly() on the second
  1.2149 +						handle.
  1.2150 +@SYMTestExpectedResults The function should panic in the second thread with panic code SGRES 2(ESgPanicBadDrawableHandle).
  1.2151 +@SYMTestStatus			Implemented 
  1.2152 + */
  1.2153 +void CTSgImageGeneric::TestPanicImageMapWriteOnlyInvalidHandleL()
  1.2154 +	{
  1.2155 +	TSgImageInfo info;
  1.2156 +	TSgresTestInfo threadInfo = {KSgNullDrawableId, info, 0, ESgresSecondThreadPanicImageMapWriteOnlyInvalidHandle, ETrue};
  1.2157 + 	TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
  1.2158 +	_LIT(KTestName, "TestImageMapWriteOnlyInvalidHandleL");
  1.2159 + 	CreateSecondThreadAndCheckPanicL(threadInfo, 3, exitCategoryName, KTestName);
  1.2160 +	}
  1.2161 +
  1.2162 +/**
  1.2163 +@SYMTestCaseID			GRAPHICS-RESOURCE-0063
  1.2164 +@SYMTestCaseDesc		Calls RSgImage::MapWriteOnly() with a non-null handle and an uninitialised driver
  1.2165 +@SYMPREQ				PREQ39
  1.2166 +@SYMREQ					REQ8809
  1.2167 +@SYMREQ					REQ9175
  1.2168 +@SYMREQ					REQ9193
  1.2169 +@SYMFssID				RSgImage::MapWriteOnly(TAny*&, TInt&)\n 
  1.2170 +@SYMTestPriority		Critical
  1.2171 +@SYMTestType			Unit Test
  1.2172 +@SYMTestPurpose			To ensure calling MapWriteOnly() with a non-null handle and an uninitialised driver will cause a panic.
  1.2173 +@SYMTestActions			Initialise the graphics resource component and create an image in a second thread. 
  1.2174 +						Declare another image and assign it to the current image handle. Close the current
  1.2175 +						image so the second image handle becomes invalid. Close the graphics resource driver.
  1.2176 +						Call MapWriteOnly() on the second handle.
  1.2177 +@SYMTestExpectedResults The function should panic in the second thread with panic code SGRES 5 (ESgPanicNoDriver).
  1.2178 +@SYMTestStatus			Implemented 
  1.2179 + */
  1.2180 +void CTSgImageGeneric::TestPanicImageMapWriteOnlyNoDriverL()
  1.2181 +	{
  1.2182 +	TSgImageInfo info;
  1.2183 +	TSgresTestInfo threadInfo = {KSgNullDrawableId, info, 0, ESgresSecondThreadPanicImageMapWriteOnlyNoDriver, ETrue};
  1.2184 + 	TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
  1.2185 +	_LIT(KTestName, "TestImageMapWriteOnlyNoDriverL");
  1.2186 + 	CreateSecondThreadAndCheckPanicL(threadInfo, 5, exitCategoryName, KTestName);
  1.2187 +	}
  1.2188 +
  1.2189 +/**
  1.2190 +@SYMTestCaseID			GRAPHICS-RESOURCE-0064
  1.2191 +@SYMTestCaseDesc		Calls RSgImage::MapReadWrite() with an invalid image handle
  1.2192 +@SYMPREQ				PREQ39
  1.2193 +@SYMREQ					REQ8809
  1.2194 +@SYMREQ					REQ9175
  1.2195 +@SYMREQ					REQ9193
  1.2196 +@SYMFssID				RSgImage::MapReadWrite(TAny*&, TInt&)\n 
  1.2197 +@SYMTestPriority		Critical
  1.2198 +@SYMTestType			Unit Test
  1.2199 +@SYMTestPurpose			To ensure calling MapReadWrite() with an invalid image handle will cause a panic.
  1.2200 +@SYMTestActions			Initialise the graphics resource component and create an image in a second thread. 
  1.2201 +						Declare another image and assign it to the current image handle. Close the current
  1.2202 +						image so the second image handle becomes invalid. Call MapReadWrite() on the second
  1.2203 +						handle.
  1.2204 +@SYMTestExpectedResults The function should panic in the second thread with panic code SGRES 2(ESgPanicBadDrawableHandle).
  1.2205 +@SYMTestStatus			Implemented 
  1.2206 + */
  1.2207 +void CTSgImageGeneric::TestPanicImageMapReadWriteInvalidHandleL()
  1.2208 +	{
  1.2209 +	TSgImageInfo info;
  1.2210 +	TSgresTestInfo threadInfo = {KSgNullDrawableId, info, 0, ESgresSecondThreadPanicImageMapReadWriteInvalidHandle, ETrue};
  1.2211 + 	TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
  1.2212 +	_LIT(KTestName, "TestImageMapReadWriteInvalidHandleL");
  1.2213 + 	CreateSecondThreadAndCheckPanicL(threadInfo, 3, exitCategoryName, KTestName);
  1.2214 +	}
  1.2215 +
  1.2216 +/**
  1.2217 +@SYMTestCaseID			GRAPHICS-RESOURCE-0065
  1.2218 +@SYMTestCaseDesc		Calls RSgImage::MapReadWrite() with a non-null handle and an uninitialised driver
  1.2219 +@SYMPREQ				PREQ39
  1.2220 +@SYMREQ					REQ8809
  1.2221 +@SYMREQ					REQ9175
  1.2222 +@SYMREQ					REQ9193
  1.2223 +@SYMFssID				RSgImage::MapReadWrite(TAny*&, TInt&)\n 
  1.2224 +@SYMTestPriority		Critical
  1.2225 +@SYMTestType			Unit Test
  1.2226 +@SYMTestPurpose			To ensure calling MapReadWrite() with a non-null handle and an uninitialised driver will cause a panic.
  1.2227 +@SYMTestActions			Initialise the graphics resource component and create an image in a second thread. 
  1.2228 +						Declare another image and assign it to the current image handle. Close the current
  1.2229 +						image so the second image handle becomes invalid. Close the graphics resource driver.
  1.2230 +						Call MapReadWrite() on the second handle.
  1.2231 +@SYMTestExpectedResults The function should panic in the second thread with panic code SGRES 5 (ESgPanicNoDriver).
  1.2232 +@SYMTestStatus			Implemented 
  1.2233 + */
  1.2234 +void CTSgImageGeneric::TestPanicImageMapReadWriteNoDriverL()
  1.2235 +	{
  1.2236 +	TSgImageInfo info;
  1.2237 +	TSgresTestInfo threadInfo = {KSgNullDrawableId, info, 0, ESgresSecondThreadPanicImageMapReadWriteNoDriver, ETrue};
  1.2238 + 	TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
  1.2239 +	_LIT(KTestName, "TestImageMapReadWriteNoDriverL");
  1.2240 + 	CreateSecondThreadAndCheckPanicL(threadInfo, 5, exitCategoryName, KTestName);
  1.2241 +	}
  1.2242 +
  1.2243 +/**
  1.2244 +@SYMTestCaseID			GRAPHICS-RESOURCE-0066
  1.2245 +@SYMTestCaseDesc		Calls RSgImage::Unmap() with an invalid image handle
  1.2246 +@SYMPREQ				PREQ39
  1.2247 +@SYMREQ					REQ8809
  1.2248 +@SYMREQ					REQ9175
  1.2249 +@SYMREQ					REQ9193
  1.2250 +@SYMFssID				RSgImage::Unmap()\n 
  1.2251 +@SYMTestPriority		Critical
  1.2252 +@SYMTestType			Unit Test
  1.2253 +@SYMTestPurpose			To ensure calling Unmap() with an invalid image handle will cause a panic.
  1.2254 +@SYMTestActions			Initialise the graphics resource component and create an image in a second thread. 
  1.2255 +						Declare another image and assign it to the current image handle. Close the current
  1.2256 +						image so the second image handle becomes invalid. Call Unmap() on the second
  1.2257 +						handle.
  1.2258 +@SYMTestExpectedResults The function should panic in the second thread with panic code SGRES 2(ESgPanicBadDrawableHandle).
  1.2259 +@SYMTestStatus			Implemented 
  1.2260 + */
  1.2261 +void CTSgImageGeneric::TestPanicImageUnmapInvalidHandleL()
  1.2262 +	{
  1.2263 +	TSgImageInfo info;
  1.2264 +	TSgresTestInfo threadInfo = {KSgNullDrawableId, info, 0, ESgresSecondThreadPanicImageUnmapInvalidHandle, ETrue};
  1.2265 + 	TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
  1.2266 +	_LIT(KTestName, "TestImageUnmapInvalidHandleL");
  1.2267 + 	CreateSecondThreadAndCheckPanicL(threadInfo, 3, exitCategoryName, KTestName);
  1.2268 +	}
  1.2269 +
  1.2270 +/**
  1.2271 +@SYMTestCaseID			GRAPHICS-RESOURCE-0067
  1.2272 +@SYMTestCaseDesc		Calls RSgImage::Unmap() with a non-null handle and an uninitialised driver
  1.2273 +@SYMPREQ				PREQ39
  1.2274 +@SYMREQ					REQ8809
  1.2275 +@SYMREQ					REQ9175
  1.2276 +@SYMFssID				RSgImage::Unmap()\n 
  1.2277 +@SYMTestPriority		Critical
  1.2278 +@SYMTestType			Unit Test
  1.2279 +@SYMTestPurpose			To ensure calling Unmap() with a non-null handle and an uninitialised driver will cause a panic.
  1.2280 +@SYMTestActions			Initialise the graphics resource component and create an image in a second thread. 
  1.2281 +						Declare another image and assign it to the current image handle. Close the current
  1.2282 +						image so the second image handle becomes invalid. Close the graphics resource driver.
  1.2283 +						Call Unmap() on the second handle.
  1.2284 +@SYMTestExpectedResults The function should panic in the second thread with panic code SGRES 5 (ESgPanicNoDriver).
  1.2285 +@SYMTestStatus			Implemented 
  1.2286 + */
  1.2287 +void CTSgImageGeneric::TestPanicImageUnmapNoDriverL()
  1.2288 +	{
  1.2289 +	TSgImageInfo info;
  1.2290 +	TSgresTestInfo threadInfo = {KSgNullDrawableId, info, 0, ESgresSecondThreadPanicImageUnmapNoDriver, ETrue};
  1.2291 + 	TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
  1.2292 +	_LIT(KTestName, "TestImageUnmapNoDriverL");
  1.2293 + 	CreateSecondThreadAndCheckPanicL(threadInfo, 5, exitCategoryName, KTestName);
  1.2294 +	}
  1.2295 +
  1.2296 +/**
  1.2297 +@SYMTestCaseID			GRAPHICS-RESOURCE-0082
  1.2298 +@SYMTestCaseDesc		Calls RSgImage::Open() when the driver was not initialised.
  1.2299 +@SYMPREQ				PREQ39
  1.2300 +@SYMREQ					REQ8809
  1.2301 +@SYMREQ					REQ9175
  1.2302 +@SYMFssID				RSgImage::Open(const TSgDrawableId&, TUint32)\n 
  1.2303 +@SYMTestPriority		Critical
  1.2304 +@SYMTestType			Unit Test
  1.2305 +@SYMTestPurpose			To ensure calling RSgImage::Open() with an uninitialised driver will cause a panic.
  1.2306 +@SYMTestActions			Do not Initialise the graphics resource component and call RSgImage::Open() in a second thread.
  1.2307 +@SYMTestExpectedResults The function should panic in the second thread with panic code SGRES 5 (ESgPanicNoDriver).
  1.2308 +@SYMTestStatus			Implemented 
  1.2309 + */
  1.2310 +void CTSgImageGeneric::TestPanicImageOpenNoDriver1L()
  1.2311 +	{
  1.2312 +	TSgImageInfo info;
  1.2313 +	TSgresTestInfo threadInfo = {KSgNullDrawableId, info, 0, ESgresSecondThreadPanicImageOpenNoDriver1, ETrue};
  1.2314 + 	TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
  1.2315 +	_LIT(KTestName, "TestPanicImageOpenNoDriverL");
  1.2316 + 	CreateSecondThreadAndCheckPanicL(threadInfo, 5, exitCategoryName, KTestName);
  1.2317 +	}
  1.2318 +
  1.2319 +/**
  1.2320 +@SYMTestCaseID			GRAPHICS-RESOURCE-0083
  1.2321 +@SYMTestCaseDesc		Creates an image from memory when the driver was not initialised.
  1.2322 +@SYMPREQ				PREQ39
  1.2323 +@SYMREQ					REQ8809
  1.2324 +@SYMREQ					REQ9175
  1.2325 +@SYMFssID				RSgImage::Create(const TSgImageInfo&, const TAny*, TInt)\n 
  1.2326 +@SYMTestPriority		Critical
  1.2327 +@SYMTestType			Unit Test
  1.2328 +@SYMTestPurpose			To ensure calling RSgImage::Create() with an uninitialised driver will cause a panic.
  1.2329 +@SYMTestActions			Do not Initialise the graphics resource component and call RSgImage::Open() in a second thread.
  1.2330 +@SYMTestExpectedResults The function should panic in the second thread with panic code SGRES 5 (ESgPanicNoDriver).
  1.2331 +@SYMTestStatus			Implemented 
  1.2332 + */
  1.2333 +void CTSgImageGeneric::TestPanicImageCreateNoDriver1L()
  1.2334 +	{
  1.2335 +	TSgImageInfo info;
  1.2336 +	TSgresTestInfo threadInfo = {KSgNullDrawableId, info, 0, ESgresSecondThreadPanicImageCreateNoDriver1, ETrue};
  1.2337 + 	TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
  1.2338 +	_LIT(KTestName, "TestPanicImageCreateNoDriver1L");
  1.2339 + 	CreateSecondThreadAndCheckPanicL(threadInfo, 5, exitCategoryName, KTestName);
  1.2340 +	}
  1.2341 +
  1.2342 +/**
  1.2343 +@SYMTestCaseID			GRAPHICS-RESOURCE-0084
  1.2344 +@SYMTestCaseDesc		Creates an image from an existing image when the driver was not initialised.
  1.2345 +@SYMPREQ				PREQ39
  1.2346 +@SYMREQ					REQ8809
  1.2347 +@SYMREQ					REQ9175
  1.2348 +@SYMFssID				RSgImage::Create(const TSgImageInfo&, const RSgImage&)\n 
  1.2349 +@SYMTestPriority		Critical
  1.2350 +@SYMTestType			Unit Test
  1.2351 +@SYMTestPurpose			To ensure calling RSgImage::Create() with an uninitialised driver will cause a panic.
  1.2352 +@SYMTestActions			Do not Initialise the graphics resource component and call RSgImage::Open() in a second thread.
  1.2353 +@SYMTestExpectedResults The function should panic in the second thread with panic code SGRES 5 (ESgPanicNoDriver).
  1.2354 +@SYMTestStatus			Implemented 
  1.2355 + */
  1.2356 +void CTSgImageGeneric::TestPanicImageCreateNoDriver2L()
  1.2357 +	{
  1.2358 +	TSgImageInfo info;
  1.2359 +	TSgresTestInfo threadInfo = {KSgNullDrawableId, info, 0, ESgresSecondThreadPanicImageCreateNoDriver2, ETrue};
  1.2360 + 	TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
  1.2361 +	_LIT(KTestName, "TestPanicImageCreateNoDriver2L");
  1.2362 + 	CreateSecondThreadAndCheckPanicL(threadInfo, 5, exitCategoryName, KTestName);
  1.2363 +	}
  1.2364 +
  1.2365 +/**
  1.2366 +@SYMTestCaseID			GRAPHICS-RESOURCE-0085
  1.2367 +@SYMTestCaseDesc		Calls RSgImage::GetPixelFormats() when the driver was not initialised.
  1.2368 +@SYMPREQ				PREQ39
  1.2369 +@SYMREQ					REQ8809
  1.2370 +@SYMREQ					REQ9175
  1.2371 +@SYMFssID				RSgImage::GetPixelFormats(const TSgImageInfo&, TUidPixelFormat*, TInt&) \n
  1.2372 +@SYMTestPriority		Critical
  1.2373 +@SYMTestType			Unit Test
  1.2374 +@SYMTestPurpose			To ensure calling RSgImage::GetPixelFormats() with an uninitialised driver will cause a panic.
  1.2375 +@SYMTestActions			Do not Initialise the graphics resource component and call RSgImage::GetPixelFormats() in a second thread.
  1.2376 +@SYMTestExpectedResults The function should panic in the second thread with panic code SGRES 5 (ESgPanicNoDriver).
  1.2377 +@SYMTestStatus			Implemented 
  1.2378 + */
  1.2379 +void CTSgImageGeneric::TestPanicImageGetPixelFormatsNoDriverL()
  1.2380 +	{
  1.2381 +	TSgImageInfo info;
  1.2382 +	TSgresTestInfo threadInfo = {KSgNullDrawableId, info, 0, ESgresSecondThreadPanicImageGetPixelFormatsNoDriver, ETrue};
  1.2383 + 	TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
  1.2384 +	_LIT(KTestName, "TestPanicImageGetPixelFormatsNoDriverL");
  1.2385 + 	CreateSecondThreadAndCheckPanicL(threadInfo, 5, exitCategoryName, KTestName);
  1.2386 +	}
  1.2387 +
  1.2388 +/**
  1.2389 +@SYMTestCaseID			GRAPHICS-RESOURCE-0093
  1.2390 +@SYMTestCaseDesc		Calls RSgImage::Open() with mode flags when the driver was not initialised.
  1.2391 +@SYMPREQ				PREQ39
  1.2392 +@SYMREQ					REQ8809
  1.2393 +@SYMREQ					REQ9175
  1.2394 +@SYMFssID				RSgImage::Open(const TSgDrawableId&, TUint32)\n 
  1.2395 +@SYMTestPriority		Critical
  1.2396 +@SYMTestType			Unit Test
  1.2397 +@SYMTestPurpose			To ensure calling RSgImage::Open() with an uninitialised driver will cause a panic.
  1.2398 +@SYMTestActions			Do not Initialise the graphics resource component and call RSgImage::Open() in a second thread.
  1.2399 +@SYMTestExpectedResults The function should panic in the second thread with panic code SGRES 5 (ESgPanicNoDriver).
  1.2400 +@SYMTestStatus			Implemented 
  1.2401 + */
  1.2402 +void CTSgImageGeneric::TestPanicImageOpenNoDriver2L()
  1.2403 +	{
  1.2404 +	TSgImageInfo info;
  1.2405 +	TSgresTestInfo threadInfo = {KSgNullDrawableId, info, 0, ESgresSecondThreadPanicImageOpenNoDriver2, ETrue};
  1.2406 + 	TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
  1.2407 +	_LIT(KTestName, "TestPanicImageOpenNoDriverL");
  1.2408 + 	CreateSecondThreadAndCheckPanicL(threadInfo, 5, exitCategoryName, KTestName);
  1.2409 +	}
  1.2410 +
  1.2411 +/**
  1.2412 +@SYMTestCaseID			GRAPHICS-RESOURCE-0088
  1.2413 +@SYMTestCaseDesc		Calls RSgImage::DrawableType() when the driver was not initialised.
  1.2414 +@SYMPREQ				PREQ39
  1.2415 +@SYMREQ					REQ8809
  1.2416 +@SYMREQ					REQ9175
  1.2417 +@SYMFssID				RSgImage::DrawableType()\n 
  1.2418 +@SYMTestPriority		Critical
  1.2419 +@SYMTestType			Unit Test
  1.2420 +@SYMTestPurpose			To ensure calling RSgImage::DrawableType() with an uninitialised driver will cause a panic.
  1.2421 +@SYMTestActions			Do not Initialise the graphics resource component and call RSgImage::DrawableType() in a second thread.
  1.2422 +@SYMTestExpectedResults The function should panic in the second thread with panic code SGRES 5 (ESgPanicNoDriver).
  1.2423 +@SYMTestStatus			Implemented 
  1.2424 + */
  1.2425 +void CTSgImageGeneric::TestPanicImageDrawableTypeNoDriverL()
  1.2426 +	{
  1.2427 +	TSgImageInfo info;
  1.2428 +	TSgresTestInfo threadInfo = {KSgNullDrawableId, info, 0, ESgresSecondThreadPanicImageDrawableTypeInvalidHandle, ETrue};
  1.2429 + 	TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
  1.2430 +	_LIT(KTestName, "TestPanicImageOpenNoDriverL");
  1.2431 + 	CreateSecondThreadAndCheckPanicL(threadInfo, 2, exitCategoryName, KTestName);
  1.2432 +	}
  1.2433 +
  1.2434 +/**
  1.2435 +@SYMTestCaseID			GRAPHICS-RESOURCE-0089
  1.2436 +@SYMTestCaseDesc		Calls RSgImage::DrawableType() with an invalid image handle
  1.2437 +@SYMPREQ				PREQ39
  1.2438 +@SYMREQ					REQ8809
  1.2439 +@SYMREQ					REQ9175
  1.2440 +@SYMFssID				RSgImage::DrawableType()\n 
  1.2441 +@SYMTestPriority		Critical
  1.2442 +@SYMTestType			Unit Test
  1.2443 +@SYMTestPurpose			To ensure calling RSgImage::DrawableType() with an uninitialised driver will cause a panic.
  1.2444 +@SYMTestActions			Do not Initialise the graphics resource component and call RSgImage::DrawableType() in a second thread.
  1.2445 +@SYMTestExpectedResults The function should panic in the second thread with panic code SGRES SGRES 2(ESgPanicBadDrawableHandle).
  1.2446 +@SYMTestStatus			Implemented 
  1.2447 + */
  1.2448 +void CTSgImageGeneric::TestPanicImageDrawableTypeInvalidHandleL()
  1.2449 +	{
  1.2450 +	TSgImageInfo info;
  1.2451 +	TSgresTestInfo threadInfo = {KSgNullDrawableId, info, 0, ESgresSecondThreadPanicImageDrawableTypeNoDriver, ETrue};
  1.2452 + 	TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
  1.2453 +	_LIT(KTestName, "TestPanicImageOpenNoDriverL");
  1.2454 + 	CreateSecondThreadAndCheckPanicL(threadInfo, 5, exitCategoryName, KTestName);
  1.2455 +	}
  1.2456 +
  1.2457 +void CTSgImageGeneric::DoMemoryTestsL()
  1.2458 +	{
  1.2459 +	__UHEAP_MARK; SgDriver::AllocMarkStart();
  1.2460 +	TestGetPixelFormatsL();
  1.2461 +	__UHEAP_MARKEND; SgDriver::AllocMarkEnd(0);
  1.2462 +	
  1.2463 +	__UHEAP_MARK; SgDriver::AllocMarkStart();
  1.2464 +	TestCreateImageUninitializedL();
  1.2465 +	__UHEAP_MARKEND; SgDriver::AllocMarkEnd(0);
  1.2466 +	
  1.2467 +	__UHEAP_MARK; SgDriver::AllocMarkStart();
  1.2468 +	TestCreateImageL();
  1.2469 +	__UHEAP_MARKEND; SgDriver::AllocMarkEnd(0);
  1.2470 +	
  1.2471 +	__UHEAP_MARK; SgDriver::AllocMarkStart();
  1.2472 +	TestCreateImageFromExistingImageL();
  1.2473 +	__UHEAP_MARKEND; SgDriver::AllocMarkEnd(0);
  1.2474 +	
  1.2475 +	__UHEAP_MARK; SgDriver::AllocMarkStart();
  1.2476 +	TestGetImageInfoL();
  1.2477 +	__UHEAP_MARKEND; SgDriver::AllocMarkEnd(0);
  1.2478 +	
  1.2479 +	__UHEAP_MARK; SgDriver::AllocMarkStart();
  1.2480 +	TestGetImageDrawableIdL(); 
  1.2481 +	__UHEAP_MARKEND; SgDriver::AllocMarkEnd(0);
  1.2482 +	
  1.2483 +	__UHEAP_MARK; SgDriver::AllocMarkStart();
  1.2484 +	TestMapImageL();
  1.2485 +	__UHEAP_MARKEND; SgDriver::AllocMarkEnd(0);
  1.2486 +	
  1.2487 +	__UHEAP_MARK; SgDriver::AllocMarkStart();
  1.2488 +	TestOpenImageL();
  1.2489 +	__UHEAP_MARKEND; SgDriver::AllocMarkEnd(0);
  1.2490 +	
  1.2491 +	__UHEAP_MARK; SgDriver::AllocMarkStart();
  1.2492 +	TestGetInterfaceL();
  1.2493 +	__UHEAP_MARKEND; SgDriver::AllocMarkEnd(0);
  1.2494 +	
  1.2495 +	__UHEAP_MARK; SgDriver::AllocMarkStart();
  1.2496 +	TestGetPixelFormatsInvalidL();
  1.2497 +	__UHEAP_MARKEND; SgDriver::AllocMarkEnd(0);
  1.2498 +	
  1.2499 +	__UHEAP_MARK; SgDriver::AllocMarkStart();
  1.2500 +	TestOpenImageInvalidL();
  1.2501 +	__UHEAP_MARKEND; SgDriver::AllocMarkEnd(0);
  1.2502 +	
  1.2503 +	__UHEAP_MARK; SgDriver::AllocMarkStart();
  1.2504 +	TestCloseImageManyTimesL();
  1.2505 +	__UHEAP_MARKEND; SgDriver::AllocMarkEnd(0);
  1.2506 +	
  1.2507 +	__UHEAP_MARK; SgDriver::AllocMarkStart();
  1.2508 +	TestCloseImageWithoutOpenL();
  1.2509 +	__UHEAP_MARKEND; SgDriver::AllocMarkEnd(0);
  1.2510 +	
  1.2511 +	__UHEAP_MARK; SgDriver::AllocMarkStart();
  1.2512 +	TestCreateImageInvalidL();
  1.2513 +	__UHEAP_MARKEND; SgDriver::AllocMarkEnd(0);
  1.2514 +	
  1.2515 +	__UHEAP_MARK; SgDriver::AllocMarkStart();
  1.2516 +	TestGetInfoInvalidImageL();
  1.2517 +	__UHEAP_MARKEND; SgDriver::AllocMarkEnd(0);
  1.2518 +	
  1.2519 +	__UHEAP_MARK; SgDriver::AllocMarkStart();
  1.2520 +	TestMapImageInvalidL();
  1.2521 +	__UHEAP_MARKEND; SgDriver::AllocMarkEnd(0);
  1.2522 +	
  1.2523 +	__UHEAP_MARK; SgDriver::AllocMarkStart();
  1.2524 +	TestUnmapImageInvalidL();
  1.2525 +	__UHEAP_MARKEND; SgDriver::AllocMarkEnd(0);
  1.2526 +	}