os/graphics/graphicsresourceservices/graphicsresource/test/tsgimagegeneric.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
//
sl@0
    15
sl@0
    16
/**
sl@0
    17
 @file
sl@0
    18
 @test
sl@0
    19
 @internalComponent - Internal Symbian test code 
sl@0
    20
*/
sl@0
    21
sl@0
    22
#include "tsgimagegeneric.h"
sl@0
    23
#include <hal.h>
sl@0
    24
#include <e32math.h>
sl@0
    25
sl@0
    26
CTSgImageGeneric::CTSgImageGeneric()
sl@0
    27
	{
sl@0
    28
	INFO_PRINTF1(_L("Graphics resource component test - RSgImage Generic Tests.\r\n"));
sl@0
    29
	}
sl@0
    30
sl@0
    31
CTSgImageGeneric::~CTSgImageGeneric()
sl@0
    32
	{
sl@0
    33
	TInt count = iTestImages.Count();
sl@0
    34
	for(TInt i=0; i<count; ++i)
sl@0
    35
		{
sl@0
    36
		iTestImages[i].Close();
sl@0
    37
		}	
sl@0
    38
	iTestImages.Reset();
sl@0
    39
	}
sl@0
    40
sl@0
    41
/** 
sl@0
    42
Overrides of base class pure virtual
sl@0
    43
Our implementation only gets called if the base class doTestStepPreambleL() did
sl@0
    44
not leave. That being the case, the current test result value will be EPass.
sl@0
    45
@leave Gets system wide error code
sl@0
    46
@return TVerdict code
sl@0
    47
*/
sl@0
    48
TVerdict CTSgImageGeneric::doTestStepL()
sl@0
    49
	{
sl@0
    50
	SetTestStepID(_L("GRAPHICS-RESOURCE-0003"));
sl@0
    51
	INFO_PRINTF1(_L("Getting pixel formats supported on all platforms.\r\n"));
sl@0
    52
	TestGetPixelFormatsL();
sl@0
    53
	RecordTestResultL();	
sl@0
    54
sl@0
    55
	SetTestStepID(_L("GRAPHICS-RESOURCE-0004"));
sl@0
    56
	INFO_PRINTF1(_L("Create an uninitialised image.\r\n"));
sl@0
    57
	TestCreateImageUninitializedL();
sl@0
    58
	RecordTestResultL();
sl@0
    59
		
sl@0
    60
	SetTestStepID(_L("GRAPHICS-RESOURCE-0005"));
sl@0
    61
	INFO_PRINTF1(_L("Create an image from a block of memory.\r\n"));
sl@0
    62
	TestCreateImageL();
sl@0
    63
	RecordTestResultL();
sl@0
    64
	
sl@0
    65
	SetTestStepID(_L("GRAPHICS-RESOURCE-0006"));
sl@0
    66
	INFO_PRINTF1(_L("Create an image from an existing image.\r\n"));
sl@0
    67
	TestCreateImageFromExistingImageL();
sl@0
    68
	RecordTestResultL();
sl@0
    69
		
sl@0
    70
	SetTestStepID(_L("GRAPHICS-RESOURCE-0007"));
sl@0
    71
	INFO_PRINTF1(_L("Getting information about the image.\r\n"));
sl@0
    72
	TestGetImageInfoL();
sl@0
    73
	RecordTestResultL();
sl@0
    74
		
sl@0
    75
	SetTestStepID(_L("GRAPHICS-RESOURCE-0008"));
sl@0
    76
	INFO_PRINTF1(_L("Retrieving drawable id of an image.\r\n"));
sl@0
    77
	TestGetImageDrawableIdL();
sl@0
    78
	RecordTestResultL();
sl@0
    79
		
sl@0
    80
	SetTestStepID(_L("GRAPHICS-RESOURCE-0009"));
sl@0
    81
	INFO_PRINTF1(_L("Mapping and unmapping an image from its creator process.\r\n"));
sl@0
    82
	TestMapImageL();
sl@0
    83
	RecordTestResultL();
sl@0
    84
		
sl@0
    85
	SetTestStepID(_L("GRAPHICS-RESOURCE-0010"));
sl@0
    86
	INFO_PRINTF1(_L("Opening a handle to an image in both the current process and another process.\r\n"));
sl@0
    87
	TestOpenImageL();
sl@0
    88
	RecordTestResultL();
sl@0
    89
	
sl@0
    90
	SetTestStepID(_L("GRAPHICS-RESOURCE-0011"));
sl@0
    91
	INFO_PRINTF1(_L("Opening a handle to an image with an open mode.\r\n"));
sl@0
    92
	TestOpenImageInternalL();
sl@0
    93
	RecordTestResultL();
sl@0
    94
	
sl@0
    95
	SetTestStepID(_L("GRAPHICS-RESOURCE-0044"));
sl@0
    96
	INFO_PRINTF1(_L("Getting the available interfaces from an image.\r\n"));	
sl@0
    97
	TestGetInterfaceL();
sl@0
    98
	RecordTestResultL();
sl@0
    99
sl@0
   100
	SetTestStepID(_L("GRAPHICS-RESOURCE-0024"));
sl@0
   101
	INFO_PRINTF1(_L("Getting supported pixel formats with invalid parameters.\r\n"));
sl@0
   102
	TestGetPixelFormatsInvalidL();
sl@0
   103
	RecordTestResultL();
sl@0
   104
sl@0
   105
	SetTestStepID(_L("GRAPHICS-RESOURCE-0025"));
sl@0
   106
	INFO_PRINTF1(_L("Opening an image with different invalid parameters.\r\n"));
sl@0
   107
	TestOpenImageInvalidL();
sl@0
   108
	RecordTestResultL();
sl@0
   109
sl@0
   110
	SetTestStepID(_L("GRAPHICS-RESOURCE-0026"));
sl@0
   111
	INFO_PRINTF1(_L("Closing the handle to an image object multiple times.\r\n"));
sl@0
   112
	TestCloseImageManyTimesL();
sl@0
   113
	RecordTestResultL();
sl@0
   114
sl@0
   115
	SetTestStepID(_L("GRAPHICS-RESOURCE-0027"));
sl@0
   116
	INFO_PRINTF1(_L("Closing the handle to an image object without opening it.\r\n"));
sl@0
   117
	TestCloseImageWithoutOpenL();
sl@0
   118
	RecordTestResultL();
sl@0
   119
sl@0
   120
	SetTestStepID(_L("GRAPHICS-RESOURCE-0028"));
sl@0
   121
	INFO_PRINTF1(_L("Creating an image with various invalid parameters.\r\n"));
sl@0
   122
	TestCreateImageInvalidL();
sl@0
   123
	RecordTestResultL();
sl@0
   124
sl@0
   125
	SetTestStepID(_L("GRAPHICS-RESOURCE-0039"));
sl@0
   126
	INFO_PRINTF1(_L("Getting information about an invalid image.\r\n"));
sl@0
   127
	TestGetInfoInvalidImageL();
sl@0
   128
	RecordTestResultL();
sl@0
   129
sl@0
   130
	SetTestStepID(_L("GRAPHICS-RESOURCE-0030"));
sl@0
   131
	INFO_PRINTF1(_L("Mapping an image under various invalid conditions. \r\n"));
sl@0
   132
	TestMapImageInvalidL();
sl@0
   133
	RecordTestResultL();
sl@0
   134
sl@0
   135
	SetTestStepID(_L("GRAPHICS-RESOURCE-0031"));
sl@0
   136
	INFO_PRINTF1(_L("Unmapping an image under various invalid conditions.\r\n"));
sl@0
   137
	TestUnmapImageInvalidL();
sl@0
   138
	RecordTestResultL();
sl@0
   139
	
sl@0
   140
	SetTestStepID(_L("GRAPHICS-RESOURCE-0048"));
sl@0
   141
	INFO_PRINTF1(_L("RSgImage generic stress test.\r\n"));
sl@0
   142
	TestStress1L();
sl@0
   143
	RecordTestResultL();
sl@0
   144
	
sl@0
   145
	SetTestStepID(_L("GRAPHICS-RESOURCE-0049"));
sl@0
   146
	INFO_PRINTF1(_L("RSgImage generic multi-thread stress test.\r\n"));
sl@0
   147
	TestStress2L();
sl@0
   148
	RecordTestResultL();
sl@0
   149
sl@0
   150
#ifdef _DEBUG
sl@0
   151
/**
sl@0
   152
@SYMTestCaseID			GRAPHICS-RESOURCE-0095
sl@0
   153
*/
sl@0
   154
	SetTestStepID(_L("GRAPHICS-RESOURCE-0095"));
sl@0
   155
	INFO_PRINTF1(_L("RSgImage generic Out of memory test.\r\n"));
sl@0
   156
	TestOOM();
sl@0
   157
	RecordTestResultL();
sl@0
   158
	
sl@0
   159
	SetTestStepID(_L("GRAPHICS-RESOURCE-0052"));
sl@0
   160
	INFO_PRINTF1(_L("RSgImage generic panic test - GetInterface() with invalid image handle\r\n"));
sl@0
   161
	TestPanicImageGetInterfaceInvalidHandleL();
sl@0
   162
	RecordTestResultL();
sl@0
   163
	
sl@0
   164
	SetTestStepID(_L("GRAPHICS-RESOURCE-0052"));
sl@0
   165
	INFO_PRINTF1(_L("RSgImage generic panic test - GetInterface() with non null image handle and uninitialised driver\r\n"));
sl@0
   166
	TestPanicImageGetInterfaceNoDriverL();
sl@0
   167
	RecordTestResultL();
sl@0
   168
	
sl@0
   169
	SetTestStepID(_L("GRAPHICS-RESOURCE-0053"));
sl@0
   170
	INFO_PRINTF1(_L("RSgImage generic panic test - Close() with invalid image handle\r\n"));
sl@0
   171
	TestPanicImageCloseInvalidHandleL();
sl@0
   172
	RecordTestResultL();
sl@0
   173
	
sl@0
   174
	SetTestStepID(_L("GRAPHICS-RESOURCE-0054"));
sl@0
   175
	INFO_PRINTF1(_L("RSgImage generic panic test - Close() with non null image handle and uninitialised driver\r\n"));
sl@0
   176
	TestPanicImageCloseNoDriverL();
sl@0
   177
	RecordTestResultL();
sl@0
   178
	
sl@0
   179
	SetTestStepID(_L("GRAPHICS-RESOURCE-0055"));
sl@0
   180
	INFO_PRINTF1(_L("RSgImage generic panic test - Id() with invalid image handle\r\n"));
sl@0
   181
	TestPanicImageIdInvalidHandleL();
sl@0
   182
	RecordTestResultL();
sl@0
   183
	
sl@0
   184
	SetTestStepID(_L("GRAPHICS-RESOURCE-0056"));
sl@0
   185
	INFO_PRINTF1(_L("RSgImage generic panic test - Id() with non null image handle and uninitialised driver\r\n"));
sl@0
   186
	TestPanicImageIdNoDriverL();
sl@0
   187
	RecordTestResultL();
sl@0
   188
	
sl@0
   189
	SetTestStepID(_L("GRAPHICS-RESOURCE-0057"));
sl@0
   190
	INFO_PRINTF1(_L("RSgImage generic panic test - Create() with invalid image handle\r\n"));
sl@0
   191
	TestPanicImageCreateInvalidHandleL();
sl@0
   192
	RecordTestResultL();
sl@0
   193
	
sl@0
   194
	SetTestStepID(_L("GRAPHICS-RESOURCE-0058"));
sl@0
   195
	INFO_PRINTF1(_L("RSgImage generic panic test - GetInfo() with invalid image handle\r\n"));
sl@0
   196
	TestPanicImageGetInfoInvalidHandleL();
sl@0
   197
	RecordTestResultL();
sl@0
   198
	
sl@0
   199
	SetTestStepID(_L("GRAPHICS-RESOURCE-0059"));
sl@0
   200
	INFO_PRINTF1(_L("RSgImage generic panic test - GetInfo() with non null image handle and uninitialised driver\r\n"));
sl@0
   201
	TestPanicImageGetInfoNoDriverL();
sl@0
   202
	RecordTestResultL();
sl@0
   203
	
sl@0
   204
	SetTestStepID(_L("GRAPHICS-RESOURCE-0060"));
sl@0
   205
	INFO_PRINTF1(_L("RSgImage generic panic test - MapReadOnly() with invalid image handle\r\n"));
sl@0
   206
	TestPanicImageMapReadOnlyInvalidHandleL();
sl@0
   207
	RecordTestResultL();
sl@0
   208
	
sl@0
   209
	SetTestStepID(_L("GRAPHICS-RESOURCE-0061"));
sl@0
   210
	INFO_PRINTF1(_L("RSgImage generic panic test - MapReadOnly() with non null image handle and uninitialised driver\r\n"));
sl@0
   211
	TestPanicImageMapReadOnlyNoDriverL();
sl@0
   212
	RecordTestResultL();
sl@0
   213
	
sl@0
   214
	SetTestStepID(_L("GRAPHICS-RESOURCE-0062"));
sl@0
   215
	INFO_PRINTF1(_L("RSgImage generic panic test - MapWriteOnly() with invalid image handle\r\n"));
sl@0
   216
	TestPanicImageMapWriteOnlyInvalidHandleL();
sl@0
   217
	RecordTestResultL();
sl@0
   218
	
sl@0
   219
	SetTestStepID(_L("GRAPHICS-RESOURCE-0063"));
sl@0
   220
	INFO_PRINTF1(_L("RSgImage generic panic test - MapWriteOnly() with non null image handle and uninitialised driver\r\n"));
sl@0
   221
	TestPanicImageMapWriteOnlyNoDriverL();
sl@0
   222
	RecordTestResultL();
sl@0
   223
	
sl@0
   224
	SetTestStepID(_L("GRAPHICS-RESOURCE-0064"));
sl@0
   225
	INFO_PRINTF1(_L("RSgImage generic panic test - MapReadWrite() with invalid image handle\r\n"));
sl@0
   226
	TestPanicImageMapReadWriteInvalidHandleL();
sl@0
   227
	RecordTestResultL();
sl@0
   228
	
sl@0
   229
	SetTestStepID(_L("GRAPHICS-RESOURCE-0065"));
sl@0
   230
	INFO_PRINTF1(_L("RSgImage generic panic test - MapReadWrite() with non null image handle and uninitialised driver\r\n"));
sl@0
   231
	TestPanicImageMapReadWriteNoDriverL();
sl@0
   232
	RecordTestResultL();
sl@0
   233
sl@0
   234
	SetTestStepID(_L("GRAPHICS-RESOURCE-0066"));
sl@0
   235
	INFO_PRINTF1(_L("RSgImage generic panic test - Unmap() with invalid image handle\r\n"));
sl@0
   236
	TestPanicImageUnmapInvalidHandleL();
sl@0
   237
	RecordTestResultL();
sl@0
   238
sl@0
   239
	SetTestStepID(_L("GRAPHICS-RESOURCE-0067"));
sl@0
   240
	INFO_PRINTF1(_L("RSgImage generic panic test - Unmap() with non null image handle and uninitialised driver\r\n"));
sl@0
   241
	TestPanicImageUnmapNoDriverL();
sl@0
   242
	RecordTestResultL();
sl@0
   243
	
sl@0
   244
	SetTestStepID(_L("GRAPHICS-RESOURCE-0082"));
sl@0
   245
	INFO_PRINTF1(_L("RSgImage generic panic test - Open() with an uninitialised driver\r\n"));
sl@0
   246
	TestPanicImageOpenNoDriver1L();
sl@0
   247
	RecordTestResultL();
sl@0
   248
	
sl@0
   249
	SetTestStepID(_L("GRAPHICS-RESOURCE-0093"));
sl@0
   250
	INFO_PRINTF1(_L("RSgImage generic panic test - Open() with a mode flag with an uninitialised driver\r\n"));
sl@0
   251
	TestPanicImageOpenNoDriver2L();
sl@0
   252
	RecordTestResultL();
sl@0
   253
	
sl@0
   254
	SetTestStepID(_L("GRAPHICS-RESOURCE-0083"));
sl@0
   255
	INFO_PRINTF1(_L("RSgImage generic panic test - Create() from memory with an uninitialised driver\r\n"));
sl@0
   256
	TestPanicImageCreateNoDriver1L();
sl@0
   257
	RecordTestResultL();
sl@0
   258
	
sl@0
   259
	SetTestStepID(_L("GRAPHICS-RESOURCE-0084"));
sl@0
   260
	INFO_PRINTF1(_L("RSgImage generic panic test - Create() from existing image with an uninitialised driver\r\n"));
sl@0
   261
	TestPanicImageCreateNoDriver2L();
sl@0
   262
	RecordTestResultL();
sl@0
   263
	
sl@0
   264
	SetTestStepID(_L("GRAPHICS-RESOURCE-0085"));
sl@0
   265
	INFO_PRINTF1(_L("RSgImage generic panic test - GetPixelFormats() with an uninitialised driver\r\n"));	
sl@0
   266
	TestPanicImageGetPixelFormatsNoDriverL();
sl@0
   267
	RecordTestResultL();
sl@0
   268
	
sl@0
   269
	SetTestStepID(_L("GRAPHICS-RESOURCE-0088"));
sl@0
   270
	INFO_PRINTF1(_L("RSgImage generic panic test - DrawableType() with an uninitialised driver\r\n"));	
sl@0
   271
	TestPanicImageDrawableTypeNoDriverL();
sl@0
   272
	RecordTestResultL();
sl@0
   273
	
sl@0
   274
	SetTestStepID(_L("GRAPHICS-RESOURCE-0089"));
sl@0
   275
	INFO_PRINTF1(_L("RSgImage generic panic test - DrawableType() with invalid image handle\r\n"));	
sl@0
   276
	TestPanicImageDrawableTypeInvalidHandleL();
sl@0
   277
	RecordTestResultL();
sl@0
   278
#else
sl@0
   279
	INFO_PRINTF1(_L("Warning: Skipping the panic tests in release build. \r\n"));
sl@0
   280
#endif	
sl@0
   281
	return TestStepResult();
sl@0
   282
	}
sl@0
   283
sl@0
   284
/**
sl@0
   285
@SYMTestCaseID			GRAPHICS-RESOURCE-0003
sl@0
   286
@SYMTestCaseDesc		Gets supported pixel formats on all platforms.
sl@0
   287
@SYMPREQ				PREQ39
sl@0
   288
@SYMREQ					REQ8809
sl@0
   289
@SYMREQ					REQ9175
sl@0
   290
@SYMREQ					REQ9224 
sl@0
   291
@SYMREQ					REQ9233  
sl@0
   292
@SYMREQ					REQ9234
sl@0
   293
@SYMFssID				RSgImage::GetPixelFormats(const TSgImageInfo&, TUidPixelFormat*, TInt&)
sl@0
   294
@SYMTestPriority		Critical
sl@0
   295
@SYMTestType			Unit Test
sl@0
   296
@SYMTestPurpose			To ensure all the available pixel formats are returned 
sl@0
   297
						in the array and the actual number of pixel formats in
sl@0
   298
						the input/output aCount parameter.
sl@0
   299
@SYMTestActions			Initialise the graphics resource component. Construct a
sl@0
   300
						TSgImageInfo object and Initialise the member variables.
sl@0
   301
						Construct a TInt array of size\n
sl@0
   302
						\t 1. NULL\n						
sl@0
   303
						\t 2. greater than the number of supported pixel formats\n
sl@0
   304
						\t 3. equal to the number of supported pixel formats\n
sl@0
   305
						\t 4. less than the number of supported pixel formats
sl@0
   306
@SYMTestExpectedResults	The function must return\n
sl@0
   307
						\t 1. KErrNone\n
sl@0
   308
						\t 2. KErrNone\n
sl@0
   309
						\t 3. KErrNone\n
sl@0
   310
						\t 4. KErrOverFlow\n
sl@0
   311
						The supported pixel formats are populated into the array
sl@0
   312
						and aCount stores the actual number of supported pixel formats.
sl@0
   313
						The returned pixel formats should cover the pixel formats
sl@0
   314
						in the image compatibility table that works on all platforms.
sl@0
   315
@SYMTestStatus			Implemented 
sl@0
   316
 */
sl@0
   317
void CTSgImageGeneric::TestGetPixelFormatsL()
sl@0
   318
	{
sl@0
   319
	TestOpenDriverL();
sl@0
   320
	TSgImageInfo info;
sl@0
   321
	info.iSizeInPixels = TSize(10, 10);
sl@0
   322
	info.iCpuAccess = ESgCpuAccessNone;
sl@0
   323
	info.iUsage = ESgUsageDirectGdiSource;
sl@0
   324
	info.iShareable = EFalse;
sl@0
   325
	info.iScreenId = 0;
sl@0
   326
		
sl@0
   327
	TInt numPixelFormats = 0;
sl@0
   328
	//NULL array
sl@0
   329
	CheckErrorL(KErrNone, RSgImage::GetPixelFormats(info, NULL, numPixelFormats), (TText8*)__FILE__, __LINE__);
sl@0
   330
	TEST(numPixelFormats > 1);
sl@0
   331
	
sl@0
   332
	//array length bigger than available pixel formats
sl@0
   333
	TInt count = numPixelFormats + 10;
sl@0
   334
	TUidPixelFormat* pixelFormatArray = new(ELeave) TUidPixelFormat[count];
sl@0
   335
	CleanupArrayDeletePushL(pixelFormatArray);
sl@0
   336
	CheckErrorL(KErrNone, RSgImage::GetPixelFormats(info, pixelFormatArray, count), (TText8*)__FILE__, __LINE__);
sl@0
   337
	TEST(count == numPixelFormats);
sl@0
   338
	
sl@0
   339
	info.iScreenId = -1;
sl@0
   340
	CheckErrorL(KErrNone, RSgImage::GetPixelFormats(info, pixelFormatArray, count), (TText8*)__FILE__, __LINE__);
sl@0
   341
	TEST(count == numPixelFormats);
sl@0
   342
	
sl@0
   343
	info.iScreenId = 0;	
sl@0
   344
	CleanupStack::PopAndDestroy(pixelFormatArray);
sl@0
   345
	//array length is equal to the supported pixel formats
sl@0
   346
	count = numPixelFormats;
sl@0
   347
	pixelFormatArray = new(ELeave) TUidPixelFormat[count];
sl@0
   348
	CleanupArrayDeletePushL(pixelFormatArray);
sl@0
   349
	
sl@0
   350
	CheckErrorL(KErrNone, RSgImage::GetPixelFormats(info, pixelFormatArray, count), (TText8*)__FILE__, __LINE__);
sl@0
   351
	TEST(count == numPixelFormats);
sl@0
   352
	
sl@0
   353
	CleanupStack::PopAndDestroy(pixelFormatArray);
sl@0
   354
	//array length is smaller than the supported pixel formats
sl@0
   355
	count = numPixelFormats - 1;
sl@0
   356
	pixelFormatArray = new(ELeave) TUidPixelFormat[count];
sl@0
   357
	CleanupArrayDeletePushL(pixelFormatArray);
sl@0
   358
	TEST(KErrOverflow == RSgImage::GetPixelFormats(info, pixelFormatArray, count));
sl@0
   359
	TEST(count == numPixelFormats);
sl@0
   360
	CleanupStack::PopAndDestroy(pixelFormatArray);
sl@0
   361
	
sl@0
   362
	//check all the pixel formats returned are in the common compatibility guarantees table
sl@0
   363
	TestGetPixelFormatCompatibilityGuaranteesL();
sl@0
   364
	
sl@0
   365
	//reset the array used by the GetPixelFormats function to prevent memory leaks
sl@0
   366
	info.iCpuAccess = ESgCpuAccessReadWrite;
sl@0
   367
	info.iScreenId = 100;
sl@0
   368
	TEST(KErrNone == RSgImage::GetPixelFormats(info, NULL, count));
sl@0
   369
	TEST(count == 0);
sl@0
   370
	
sl@0
   371
	TestCloseDriver();
sl@0
   372
	}
sl@0
   373
sl@0
   374
/**
sl@0
   375
@SYMTestCaseID			GRAPHICS-RESOURCE-0004
sl@0
   376
@SYMTestCaseDesc		Creates an uninitialised image.
sl@0
   377
@SYMPREQ				PREQ39
sl@0
   378
@SYMREQ					REQ8809
sl@0
   379
@SYMREQ					REQ9175
sl@0
   380
@SYMREQ					REQ9224 
sl@0
   381
@SYMREQ					REQ9233  
sl@0
   382
@SYMREQ					REQ9234
sl@0
   383
@SYMFssID				RSgImage::Create(const TSgImageInfo&, const TAny*, TInt)\n 
sl@0
   384
						RSgImage::IsNull()
sl@0
   385
@SYMTestPriority		Critical
sl@0
   386
@SYMTestType			Unit Test
sl@0
   387
@SYMTestPurpose			To ensure an uninitialised image can be created.
sl@0
   388
@SYMTestActions			Initialise the graphics resource component. Construct well-defined 
sl@0
   389
						TSgImageInfo objects that work on all platforms. Create an image 
sl@0
   390
						with a NULL base address for each of the TSgImageInfo object.
sl@0
   391
@SYMTestExpectedResults	The function should return KErrNone in all cases. The created images
sl@0
   392
						are uninitialised.
sl@0
   393
@SYMTestStatus			Implemented 
sl@0
   394
 */	
sl@0
   395
void CTSgImageGeneric::TestCreateImageUninitializedL()
sl@0
   396
	{	
sl@0
   397
	TestOpenDriverL();
sl@0
   398
	TSgImageInfo info;
sl@0
   399
	info.iSizeInPixels = TSize(100, 100);
sl@0
   400
	info.iUsage = ESgUsageDirectGdiTarget;
sl@0
   401
	info.iPixelFormat = EUidPixelFormatRGB_565;
sl@0
   402
	
sl@0
   403
	RSgImage image;	
sl@0
   404
	CheckErrorL(KErrNone, image.Create(info, NULL, 0), (TText8*)__FILE__, __LINE__);
sl@0
   405
	CleanupClosePushL(image);
sl@0
   406
	
sl@0
   407
	CleanupStack::PopAndDestroy();
sl@0
   408
	TestCloseDriver();
sl@0
   409
	}
sl@0
   410
sl@0
   411
sl@0
   412
/**
sl@0
   413
@SYMTestCaseID			GRAPHICS-RESOURCE-0005
sl@0
   414
@SYMTestCaseDesc		Creates an image from a block of memory.
sl@0
   415
@SYMPREQ				PREQ39
sl@0
   416
@SYMREQ					REQ8809
sl@0
   417
@SYMREQ					REQ9175
sl@0
   418
@SYMREQ					REQ9224 
sl@0
   419
@SYMREQ					REQ9233  
sl@0
   420
@SYMREQ					REQ9234
sl@0
   421
@SYMFssID				RSgImage::Create(const TSgImageInfo&, const TAny*, TInt)\n 
sl@0
   422
						RSgImage::IsNull()
sl@0
   423
@SYMTestPriority		Critical
sl@0
   424
@SYMTestType			Unit Test
sl@0
   425
@SYMTestPurpose			To ensure images can be created from a block of memory.
sl@0
   426
@SYMTestActions			Initialise the graphics resource component. Construct well-defined 
sl@0
   427
						TSgImageInfo objects that work on all platforms. Create a block of
sl@0
   428
						memory with or without initialised data. Then create an image with 
sl@0
   429
						the starting address of that memory.
sl@0
   430
@SYMTestExpectedResults	The function should return KErrNone in all cases. The user data starting
sl@0
   431
						at address aDataAddress will be populated into the new image.
sl@0
   432
@SYMTestStatus			Implemented 
sl@0
   433
 */	
sl@0
   434
void CTSgImageGeneric::TestCreateImageL()
sl@0
   435
	{	
sl@0
   436
	TestOpenDriverL();
sl@0
   437
	TSgImageInfo info;
sl@0
   438
	info.iSizeInPixels = TSize(8, 8);
sl@0
   439
	info.iPixelFormat = EUidPixelFormatRGB_565;
sl@0
   440
	info.iUsage = ESgUsageDirectGdiSource;
sl@0
   441
	info.iShareable = ETrue;
sl@0
   442
	
sl@0
   443
	RSgImage image;
sl@0
   444
	CheckErrorL(KErrNone, image.Create(info, KImageData, 16), (TText8*)__FILE__, __LINE__);
sl@0
   445
	CleanupClosePushL(image);
sl@0
   446
	CleanupStack::PopAndDestroy();	
sl@0
   447
#ifdef __WINS__	
sl@0
   448
	//create an image with usage set to screen source
sl@0
   449
	TSize screenSize;
sl@0
   450
	if(HAL::Get(info.iScreenId, HALData::EDisplayXPixels, screenSize.iWidth) == KErrNone
sl@0
   451
		&& HAL::Get(info.iScreenId, HALData::EDisplayYPixels, screenSize.iHeight) == KErrNone)
sl@0
   452
		{
sl@0
   453
		info.iUsage = ESgUsageScreenSource;
sl@0
   454
		info.iScreenId = KSgScreenIdMain;
sl@0
   455
		info.iSizeInPixels = TSize(screenSize.iWidth, screenSize.iHeight);
sl@0
   456
		CheckErrorL(KErrNone, image.Create(info, KImageData, 16), (TText8*)__FILE__, __LINE__);
sl@0
   457
		CleanupClosePushL(image);
sl@0
   458
		CleanupStack::PopAndDestroy();
sl@0
   459
		
sl@0
   460
		info.iSizeInPixels = TSize(screenSize.iHeight, screenSize.iWidth);
sl@0
   461
		CheckErrorL(KErrNone, image.Create(info, KImageData, 16), (TText8*)__FILE__, __LINE__);
sl@0
   462
		CleanupClosePushL(image);
sl@0
   463
		CleanupStack::PopAndDestroy();
sl@0
   464
		}
sl@0
   465
#endif	
sl@0
   466
	//create an image with some user attributes
sl@0
   467
	TSgUserAttribute testAttributes[] = {{0x00008888, 1}, {0x00009999, 2}};
sl@0
   468
	info.iUserAttributes = testAttributes;
sl@0
   469
	info.iUserAttributeCount = 2;
sl@0
   470
	CheckErrorL(KErrNone, image.Create(info, KImageData, 16), (TText8*)__FILE__, __LINE__);
sl@0
   471
	CleanupClosePushL(image);
sl@0
   472
	CleanupStack::PopAndDestroy();
sl@0
   473
	
sl@0
   474
	TestCloseDriver();
sl@0
   475
	}
sl@0
   476
sl@0
   477
/**
sl@0
   478
@SYMTestCaseID			GRAPHICS-RESOURCE-0006
sl@0
   479
@SYMTestCaseDesc		Creates an image from an existing image.
sl@0
   480
@SYMPREQ				PREQ39
sl@0
   481
@SYMREQ					REQ8809
sl@0
   482
@SYMREQ					REQ9175
sl@0
   483
@SYMREQ					REQ9192
sl@0
   484
@SYMREQ					REQ9224 
sl@0
   485
@SYMREQ					REQ9233  
sl@0
   486
@SYMREQ					REQ9234
sl@0
   487
@SYMFssID				RSgImage::Create(const TSgImageInfo&, const RSgImage&)
sl@0
   488
@SYMTestPriority		Critical
sl@0
   489
@SYMTestType			Unit Test
sl@0
   490
@SYMTestPurpose			To ensure images can be created from existing images.
sl@0
   491
@SYMTestActions			Initialise the graphics resource component. Create an image. Create another
sl@0
   492
						image with the attributes of this image as the TSgImageInfo.
sl@0
   493
@SYMTestExpectedResults	The function should return KErrNone. The new image should be identical to
sl@0
   494
						the old one. 
sl@0
   495
@SYMTestStatus			Implemented 
sl@0
   496
 */	
sl@0
   497
void CTSgImageGeneric::TestCreateImageFromExistingImageL()
sl@0
   498
	{
sl@0
   499
	RSgImage image1;
sl@0
   500
	RSgImage image2;
sl@0
   501
	TSgImageInfo info;
sl@0
   502
	
sl@0
   503
	TestOpenDriverL();		
sl@0
   504
	CreateImageL(image1);
sl@0
   505
	CleanupClosePushL(image1);
sl@0
   506
	TEST(KErrNone == image1.GetInfo(info));
sl@0
   507
	CheckErrorL(KErrNone, image2.Create(info, image1), (TText8*)__FILE__, __LINE__);
sl@0
   508
	CleanupClosePushL(image2);
sl@0
   509
	TSgImageInfo info2;
sl@0
   510
	TEST(KErrNone == image2.GetInfo(info2));
sl@0
   511
	TEST(CompareInfos(info, info2));
sl@0
   512
	CleanupStack::PopAndDestroy(2);
sl@0
   513
	TestCloseDriver();
sl@0
   514
	}
sl@0
   515
sl@0
   516
sl@0
   517
/**
sl@0
   518
@SYMTestCaseID			GRAPHICS-RESOURCE-0007
sl@0
   519
@SYMTestCaseDesc		Calls GetInfo on an image.
sl@0
   520
@SYMPREQ				PREQ39
sl@0
   521
@SYMREQ					REQ8809
sl@0
   522
@SYMREQ					REQ9175
sl@0
   523
@SYMREQ					REQ9224 
sl@0
   524
@SYMREQ					REQ9233  
sl@0
   525
@SYMREQ					REQ9234
sl@0
   526
@SYMFssID				RSgImage::GetInfo(TSgImageInfo&)
sl@0
   527
@SYMTestPriority		Critical
sl@0
   528
@SYMTestType			Unit Test
sl@0
   529
@SYMTestPurpose			To ensure the information about the image is correct.
sl@0
   530
@SYMTestActions			Initialise the graphics resource component. Construct a TSgImageInfo object
sl@0
   531
						and Initialise all the member variables. Create images without and with
sl@0
   532
						user attributes. Call GetInfo() and compare the resulting TSgImageInfo objects 
sl@0
   533
						with the previous ones.
sl@0
   534
@SYMTestExpectedResults	The function should return KErrNone. Information about the image object
sl@0
   535
						is stored in the aInfo parameter. The retrieved TSgImageInfo objects should be 
sl@0
   536
						identical to the original ones.
sl@0
   537
@SYMTestStatus			Implemented 
sl@0
   538
 */	
sl@0
   539
void CTSgImageGeneric::TestGetImageInfoL()
sl@0
   540
	{
sl@0
   541
	TestOpenDriverL();
sl@0
   542
	TSgImageInfo info;
sl@0
   543
	info.iPixelFormat = EUidPixelFormatRGB_565;
sl@0
   544
	info.iSizeInPixels = TSize(100, 100);
sl@0
   545
	info.iUsage = ESgUsageDirectGdiTarget;
sl@0
   546
	
sl@0
   547
	RSgImage image;
sl@0
   548
	CheckErrorL(KErrNone, image.Create(info, NULL, 0), (TText8*)__FILE__, __LINE__);
sl@0
   549
	CleanupClosePushL(image);
sl@0
   550
	
sl@0
   551
	TSgImageInfo info2;
sl@0
   552
	TEST(KErrNone == image.GetInfo(info2));
sl@0
   553
	TEST(CompareInfos(info, info2));
sl@0
   554
	CleanupStack::PopAndDestroy();
sl@0
   555
	
sl@0
   556
	//get info of image with user attributes
sl@0
   557
	TSgUserAttribute testAttributes[] = {{0x00008888, 1}, {0x00009999, 2}};
sl@0
   558
	info.iUserAttributes = testAttributes;
sl@0
   559
	info.iUserAttributeCount = 2;
sl@0
   560
	CheckErrorL(KErrNone, image.Create(info, NULL, 0), (TText8*)__FILE__, __LINE__);
sl@0
   561
	CleanupClosePushL(image);
sl@0
   562
	TSgImageInfo info3;
sl@0
   563
	TSgUserAttribute testAttributes2[2];
sl@0
   564
	testAttributes2[0].iUid = TUid::Uid(0x00008888);
sl@0
   565
	testAttributes2[1].iUid = TUid::Uid(0x00009999);
sl@0
   566
	info3.iUserAttributes = testAttributes2;
sl@0
   567
	info3.iUserAttributeCount = 2;
sl@0
   568
	TEST(KErrNone == image.GetInfo(info3));
sl@0
   569
	TEST(CompareInfos(info, info3));	
sl@0
   570
	CleanupStack::PopAndDestroy();
sl@0
   571
	
sl@0
   572
	info.iShareable = ETrue;
sl@0
   573
	CheckErrorL(KErrNone, image.Create(info, NULL, 0), (TText8*)__FILE__, __LINE__);
sl@0
   574
	CleanupClosePushL(image);
sl@0
   575
	TEST(KErrNone == image.GetInfo(info3));
sl@0
   576
	TEST(CompareInfos(info, info3));
sl@0
   577
	CleanupStack::PopAndDestroy();
sl@0
   578
	
sl@0
   579
	TestCloseDriver();
sl@0
   580
	}
sl@0
   581
sl@0
   582
/**
sl@0
   583
@SYMTestCaseID			GRAPHICS-RESOURCE-0008
sl@0
   584
@SYMTestCaseDesc		Retrieves drawable id and drawable type of an image.
sl@0
   585
@SYMPREQ				PREQ39
sl@0
   586
@SYMREQ					REQ8809
sl@0
   587
@SYMREQ					REQ9175
sl@0
   588
@SYMREQ					REQ9224 
sl@0
   589
@SYMREQ					REQ9233  
sl@0
   590
@SYMREQ					REQ9234
sl@0
   591
@SYMFssID				RSgImage::Id()\n
sl@0
   592
						RSgImage::DrawableType()
sl@0
   593
@SYMTestPriority		Critical
sl@0
   594
@SYMTestType			Unit Test
sl@0
   595
@SYMTestPurpose			To ensure the globally unique drawable id of the image can be retrieved.
sl@0
   596
@SYMTestActions			Initialise the graphics resource component. Create an image. Call
sl@0
   597
						Id() to retrieve its drawable id.
sl@0
   598
@SYMTestExpectedResults	A valid drawable id should be successfully returned.
sl@0
   599
@SYMTestStatus			Implemented 
sl@0
   600
 */	
sl@0
   601
void CTSgImageGeneric::TestGetImageDrawableIdL()
sl@0
   602
	{	
sl@0
   603
	RSgImage image;
sl@0
   604
	TEST(KNullUid == image.DrawableType());
sl@0
   605
	TSgDrawableId id = image.Id();
sl@0
   606
	TEST(id == KSgNullDrawableId);
sl@0
   607
	TestOpenDriverL();	
sl@0
   608
	CreateImageL(image);
sl@0
   609
	CleanupClosePushL(image);
sl@0
   610
	id = image.Id();
sl@0
   611
	TEST(id != KSgNullDrawableId);	
sl@0
   612
	TEST(KSgImageTypeUid == image.DrawableType());
sl@0
   613
sl@0
   614
	CleanupStack::PopAndDestroy();
sl@0
   615
	TestCloseDriver();
sl@0
   616
	}
sl@0
   617
sl@0
   618
/**
sl@0
   619
@SYMTestCaseID			GRAPHICS-RESOURCE-0009
sl@0
   620
@SYMTestCaseDesc		Maps and unmaps an image from its creator process.
sl@0
   621
@SYMPREQ				PREQ39
sl@0
   622
@SYMREQ					REQ8809
sl@0
   623
@SYMREQ					REQ9175
sl@0
   624
@SYMREQ					REQ9193
sl@0
   625
@SYMREQ					REQ9224 
sl@0
   626
@SYMREQ					REQ9233  
sl@0
   627
@SYMREQ					REQ9234
sl@0
   628
@SYMFssID				RSgImage::MapReadOnly(const TAny*&, TInt&) const\n
sl@0
   629
 						RSgImage::MapWriteOnly(TAny*&, TInt&)\n 
sl@0
   630
						RSgImage::MapReadWrite(TAny*&, TInt&)\n 
sl@0
   631
						RSgImage::Unmap()
sl@0
   632
						by its creator process.
sl@0
   633
@SYMTestPriority		Critical
sl@0
   634
@SYMTestType			Unit Test
sl@0
   635
@SYMTestPurpose			To ensure an image can be successfully mapped and unmapped
sl@0
   636
@SYMTestActions			Initialise the graphics resource component. Create mappable images
sl@0
   637
						with different TSgImageInfo values. Call different map functions the Unmap()
sl@0
   638
						function on each of them.
sl@0
   639
@SYMTestExpectedResults	All the functions should return KErrNone.
sl@0
   640
@SYMTestStatus			Implemented 
sl@0
   641
 */	
sl@0
   642
void CTSgImageGeneric::TestMapImageL()
sl@0
   643
	{
sl@0
   644
	TestOpenDriverL();
sl@0
   645
	RSgImage image;
sl@0
   646
	TSgImageInfo info;
sl@0
   647
	info.iSizeInPixels = TSize(8, 8);
sl@0
   648
	info.iPixelFormat = EUidPixelFormatRGB_565;
sl@0
   649
	info.iUsage = ESgUsageDirectGdiSource;
sl@0
   650
	info.iCpuAccess = ESgCpuAccessReadOnly;
sl@0
   651
	
sl@0
   652
	CheckErrorL(KErrNone, image.Create(info, KImageData, 16), (TText8*)__FILE__, __LINE__);
sl@0
   653
	CleanupClosePushL(image);
sl@0
   654
	
sl@0
   655
	//test MapReadOnly
sl@0
   656
	const TAny* dataAddress;
sl@0
   657
	TInt dataStride;	
sl@0
   658
	TInt mapResult = image.MapReadOnly(dataAddress, dataStride);
sl@0
   659
	TEST(KErrNone == mapResult);
sl@0
   660
	if(KErrNone == mapResult)
sl@0
   661
		{
sl@0
   662
		for (TInt y = 0; y < 8; ++y)
sl@0
   663
			for (TInt x = 0; x < 8; ++x)
sl@0
   664
				{
sl@0
   665
				TUint16 pixelValue = *(TUint16*)PtrAdd(dataAddress, sizeof(TUint16) * x + dataStride * y);
sl@0
   666
				if (pixelValue != 0x7E0)
sl@0
   667
					{
sl@0
   668
					TEST(EFalse);
sl@0
   669
					break;
sl@0
   670
					}
sl@0
   671
				}
sl@0
   672
		}
sl@0
   673
	TEST(KErrNone == image.Unmap());
sl@0
   674
	CleanupStack::PopAndDestroy(&image);
sl@0
   675
	
sl@0
   676
	//test MapWriteOnly
sl@0
   677
	TAny* dataAddress1;
sl@0
   678
	
sl@0
   679
	info.iCpuAccess = ESgCpuAccessWriteOnly;
sl@0
   680
	CheckErrorL(KErrNone, image.Create(info, KImageData, 16), (TText8*)__FILE__, __LINE__);
sl@0
   681
	CleanupClosePushL(image);
sl@0
   682
	mapResult = image.MapWriteOnly(dataAddress1, dataStride);
sl@0
   683
	TEST(KErrNone == mapResult);
sl@0
   684
	//change the second line to red
sl@0
   685
	if(KErrNone == mapResult)
sl@0
   686
		{
sl@0
   687
		for(TInt x = 0; x < 8; ++x)
sl@0
   688
			{
sl@0
   689
			*(TUint16*)PtrAdd(dataAddress1, sizeof(TUint16) * x + dataStride * 1) = 0xF800;
sl@0
   690
			}
sl@0
   691
		}
sl@0
   692
	TEST(KErrNone == image.Unmap());
sl@0
   693
	
sl@0
   694
	//check if the modification is successful	
sl@0
   695
	//create another image from the existing one and map it as read only
sl@0
   696
	info.iCpuAccess = ESgCpuAccessReadOnly;
sl@0
   697
	RSgImage image1;
sl@0
   698
	CheckErrorL(KErrNone, image1.Create(info, image), (TText8*)__FILE__, __LINE__);
sl@0
   699
	CleanupClosePushL(image1);
sl@0
   700
	mapResult = image1.MapReadOnly(dataAddress, dataStride);
sl@0
   701
	TEST(mapResult == KErrNone);
sl@0
   702
	if(mapResult == KErrNone)
sl@0
   703
		{
sl@0
   704
		for(TInt x = 0; x < 8; ++x)
sl@0
   705
			{
sl@0
   706
			TUint16 pixelValue = *(TUint16*)PtrAdd(dataAddress, sizeof(TUint16) * x + dataStride * 1);
sl@0
   707
			if(pixelValue != 0xF800)
sl@0
   708
				{
sl@0
   709
				TEST(EFalse);
sl@0
   710
				break;
sl@0
   711
				}
sl@0
   712
			}
sl@0
   713
		}
sl@0
   714
	
sl@0
   715
	TEST(KErrNone == image1.Unmap());
sl@0
   716
	CleanupStack::PopAndDestroy(2, &image);
sl@0
   717
	
sl@0
   718
	//test MapReadWrite
sl@0
   719
	info.iCpuAccess = ESgCpuAccessReadWrite;
sl@0
   720
	CheckErrorL(KErrNone, image.Create(info, KImageData, 16), (TText8*)__FILE__, __LINE__);
sl@0
   721
	CleanupClosePushL(image);
sl@0
   722
	mapResult = image.MapReadWrite(dataAddress1, dataStride);
sl@0
   723
	TEST(KErrNone == mapResult);
sl@0
   724
	
sl@0
   725
	if(KErrNone == mapResult)
sl@0
   726
		{
sl@0
   727
		//modify the image, set first line to blue
sl@0
   728
		for(TInt x = 0; x < 8; ++x)
sl@0
   729
			{
sl@0
   730
			*(TUint16*)PtrAdd(dataAddress1, sizeof(TUint16) * x) = 0x1F;
sl@0
   731
			}
sl@0
   732
		
sl@0
   733
		//check the modification
sl@0
   734
		for(TInt x = 0; x < 8; ++x)
sl@0
   735
			{
sl@0
   736
			TUint16 pixelValue = *(TUint16*)PtrAdd(dataAddress1, sizeof(TUint16) * x);
sl@0
   737
			if(pixelValue != 0x1F)
sl@0
   738
				{
sl@0
   739
				TEST(EFalse);
sl@0
   740
				break;
sl@0
   741
				}
sl@0
   742
			}
sl@0
   743
		}
sl@0
   744
	
sl@0
   745
	TEST(KErrNone == image.Unmap());	
sl@0
   746
	CleanupStack::PopAndDestroy();
sl@0
   747
	TestCloseDriver();
sl@0
   748
	}
sl@0
   749
sl@0
   750
/**
sl@0
   751
@SYMTestCaseID			GRAPHICS-RESOURCE-0010
sl@0
   752
@SYMTestCaseDesc		Opens a handle to an image in both the current process and another process.
sl@0
   753
@SYMPREQ				PREQ39
sl@0
   754
@SYMREQ					REQ8809
sl@0
   755
@SYMREQ					REQ9175
sl@0
   756
@SYMREQ					REQ9224 
sl@0
   757
@SYMREQ					REQ9233  
sl@0
   758
@SYMREQ					REQ9234
sl@0
   759
@SYMFssID				RSgImage::Open(const TSgDrawableId&)
sl@0
   760
@SYMTestPriority		Critical
sl@0
   761
@SYMTestType			Unit Test
sl@0
   762
@SYMTestPurpose			To ensure image can be opened in both a second thread in the current 
sl@0
   763
						process and another process.
sl@0
   764
@SYMTestActions			Initialise the graphics resource component. Create a shareable image and
sl@0
   765
						a non-shareable image. Open() the image in the second thread in the current 
sl@0
   766
						process and in another process.
sl@0
   767
						Check various image attributes.
sl@0
   768
@SYMTestExpectedResults	The function must return KErrNone in both cases.
sl@0
   769
@SYMTestStatus			Implemented 
sl@0
   770
 */	
sl@0
   771
void CTSgImageGeneric::TestOpenImageL()
sl@0
   772
	{	
sl@0
   773
	TestOpenDriverL();
sl@0
   774
	
sl@0
   775
	//shareable image
sl@0
   776
	RSgImage image1;
sl@0
   777
	TSgImageInfo info1;
sl@0
   778
	info1.iSizeInPixels = TSize(8, 8);
sl@0
   779
	info1.iUsage = ESgUsageDirectGdiSource;
sl@0
   780
	info1.iPixelFormat = EUidPixelFormatRGB_565;
sl@0
   781
	info1.iCpuAccess = ESgCpuAccessReadWrite;
sl@0
   782
	info1.iShareable = ETrue;
sl@0
   783
	CheckErrorL(KErrNone, image1.Create(info1, KImageData, 16), (TText8*)__FILE__, __LINE__);
sl@0
   784
	CleanupClosePushL(image1);
sl@0
   785
	
sl@0
   786
	//non-shareable image
sl@0
   787
	RSgImage image2;
sl@0
   788
	TSgImageInfo info2;
sl@0
   789
	info2.iSizeInPixels = TSize(8, 8);
sl@0
   790
	info2.iUsage = ESgUsageDirectGdiSource;
sl@0
   791
	info2.iPixelFormat = EUidPixelFormatRGB_565;
sl@0
   792
	info2.iCpuAccess = ESgCpuAccessReadWrite;
sl@0
   793
	info2.iShareable = EFalse;	
sl@0
   794
	CheckErrorL(KErrNone, image2.Create(info2, KImageData, 16), (TText8*)__FILE__, __LINE__);
sl@0
   795
	CleanupClosePushL(image2);
sl@0
   796
	
sl@0
   797
	const TSgDrawableId id1 = image1.Id();
sl@0
   798
	const TSgDrawableId id2 = image2.Id();	
sl@0
   799
	
sl@0
   800
	//opening image in the current thread
sl@0
   801
	RSgImage image3;
sl@0
   802
	TEST(KErrNone == image3.Open(id1));
sl@0
   803
	image3.Close();
sl@0
   804
	TEST(KErrNone == image3.Open(id2));
sl@0
   805
	image3.Close();
sl@0
   806
	
sl@0
   807
	//opening image in a second thread in the current process
sl@0
   808
	TSgresTestInfo threadInfo = {id1, info1, 0, ESgresSecondThreadOpenImage};
sl@0
   809
	TInt testResult = CreateSecondThreadAndDoTestL(threadInfo);	
sl@0
   810
	// Test the results from the second thread
sl@0
   811
	User::LeaveIfError(testResult);
sl@0
   812
	TEST(testResult & EFirstTestPassed);
sl@0
   813
	TEST(testResult & ESecondTestPassed);
sl@0
   814
	TEST(testResult & EThirdTestPassed);
sl@0
   815
	TEST(testResult & EFourthTestPassed);
sl@0
   816
	TEST(testResult & EFifthTestPassed);
sl@0
   817
	
sl@0
   818
	threadInfo.iDrawableId = id2;
sl@0
   819
	threadInfo.iImageInfo = info2;
sl@0
   820
	testResult = CreateSecondThreadAndDoTestL(threadInfo);	
sl@0
   821
	// Test the results from the second thread
sl@0
   822
	User::LeaveIfError(testResult);
sl@0
   823
	TEST(testResult & EFirstTestPassed);
sl@0
   824
	TEST(testResult & ESecondTestPassed);
sl@0
   825
	TEST(testResult & EThirdTestPassed);
sl@0
   826
	TEST(testResult & EFourthTestPassed);
sl@0
   827
	TEST(testResult & EFifthTestPassed);
sl@0
   828
		
sl@0
   829
	//opening image in a second process	
sl@0
   830
	TSgresTestInfo processInfo = {id1, info1, 0, ESgresSecondProcessOpenImage};
sl@0
   831
	testResult = CreateSecondProcessAndDoTestL(KSecondProcess, processInfo);	
sl@0
   832
	User::LeaveIfError(testResult);
sl@0
   833
	TEST(testResult & EFirstTestPassed);	
sl@0
   834
	TEST(testResult & ESecondTestPassed);
sl@0
   835
	TEST(testResult & EThirdTestPassed);
sl@0
   836
	TEST(testResult & EFourthTestPassed);
sl@0
   837
sl@0
   838
	CleanupStack::PopAndDestroy(2, &image1);
sl@0
   839
	TestCloseDriver();
sl@0
   840
	}
sl@0
   841
sl@0
   842
class MFake
sl@0
   843
	{
sl@0
   844
public:
sl@0
   845
	enum { EInterfaceUid = 0x88888888 };
sl@0
   846
	};
sl@0
   847
sl@0
   848
/**
sl@0
   849
@SYMTestCaseID			GRAPHICS-RESOURCE-0011
sl@0
   850
@SYMTestCaseDesc		Opens a handle to an image with mode flags.
sl@0
   851
@SYMPREQ				PREQ39
sl@0
   852
@SYMREQ					REQ8809
sl@0
   853
@SYMREQ					REQ9175
sl@0
   854
@SYMREQ					REQ9224 
sl@0
   855
@SYMREQ					REQ9233  
sl@0
   856
@SYMREQ					REQ9234
sl@0
   857
@SYMFssID				RSgImage::Open(const TSgDrawableId&, TUint32)
sl@0
   858
@SYMTestPriority		Critical
sl@0
   859
@SYMTestType			Unit Test
sl@0
   860
@SYMTestPurpose			To ensure image can be opened with mode flags.
sl@0
   861
@SYMTestActions			Initialise the graphics resource component. Create an image and
sl@0
   862
						call Open() on the image with flag ESgDoNotRestrictUsage. Call
sl@0
   863
						GetInfo() on the opened image and check the usage bit. Declare another
sl@0
   864
						image object and call Open() on it with the Id of the previously
sl@0
   865
						opened handle and without mode flags. Call GetInfo() on this image
sl@0
   866
						and check the usage bit.
sl@0
   867
@SYMTestExpectedResults	Both infos should contain all the possible usages supported by
sl@0
   868
 						the underlying implementation.						
sl@0
   869
@SYMTestStatus			Implemented 
sl@0
   870
 */	
sl@0
   871
void CTSgImageGeneric::TestOpenImageInternalL()
sl@0
   872
	{
sl@0
   873
	TestOpenDriverL();
sl@0
   874
	
sl@0
   875
	//shareable image
sl@0
   876
	RSgImage shareableImage;
sl@0
   877
	TSgImageInfo shareableInfo;
sl@0
   878
	shareableInfo.iSizeInPixels = TSize(8, 8);
sl@0
   879
	shareableInfo.iUsage = ESgUsageDirectGdiSource;
sl@0
   880
	shareableInfo.iPixelFormat = EUidPixelFormatRGB_565;
sl@0
   881
	shareableInfo.iCpuAccess = ESgCpuAccessReadWrite;
sl@0
   882
	shareableInfo.iShareable = ETrue;	
sl@0
   883
	CheckErrorL(KErrNone, shareableImage.Create(shareableInfo, KImageData, 16), (TText8*)__FILE__, __LINE__);
sl@0
   884
	CleanupClosePushL(shareableImage);
sl@0
   885
		
sl@0
   886
	RSgImage image1;
sl@0
   887
	CheckErrorL(KErrNone, image1.Open(shareableImage.Id(), ESgDoNotRestrictUsage), (TText8*)__FILE__, __LINE__);
sl@0
   888
	CleanupClosePushL(image1);
sl@0
   889
	TSgImageInfo info1;
sl@0
   890
	image1.GetInfo(info1);	
sl@0
   891
	TEST(ESgUsageDirectGdiSource | info1.iUsage);
sl@0
   892
	TEST(ESgUsageCompositionSource | info1.iUsage);
sl@0
   893
	TEST(ESgUsageOpenGlesTexture2D | info1.iUsage);
sl@0
   894
	TEST(ESgUsageOpenGles2Texture2D | info1.iUsage);
sl@0
   895
	TEST(ESgUsageOpenVgImage | info1.iUsage);
sl@0
   896
	
sl@0
   897
	RSgImage image2;
sl@0
   898
	CheckErrorL(KErrNone, image2.Open(image1.Id()), (TText8*)__FILE__, __LINE__);
sl@0
   899
	CleanupClosePushL(image2);
sl@0
   900
	TSgImageInfo info2;
sl@0
   901
	image2.GetInfo(info2);
sl@0
   902
	TEST(ESgUsageDirectGdiSource | info2.iUsage);
sl@0
   903
	TEST(ESgUsageCompositionSource | info2.iUsage);
sl@0
   904
	TEST(ESgUsageOpenGlesTexture2D | info2.iUsage);
sl@0
   905
	TEST(ESgUsageOpenGles2Texture2D | info2.iUsage);
sl@0
   906
	TEST(ESgUsageOpenVgImage | info2.iUsage);
sl@0
   907
	
sl@0
   908
	//non-shareable image
sl@0
   909
	RSgImage nonshareableImage;
sl@0
   910
	TSgImageInfo nonshareableInfo;
sl@0
   911
	nonshareableInfo.iSizeInPixels = TSize(8, 8);
sl@0
   912
	nonshareableInfo.iUsage = ESgUsageDirectGdiSource;
sl@0
   913
	nonshareableInfo.iPixelFormat = EUidPixelFormatRGB_565;
sl@0
   914
	nonshareableInfo.iCpuAccess = ESgCpuAccessReadWrite;
sl@0
   915
	nonshareableInfo.iShareable = EFalse;	
sl@0
   916
	CheckErrorL(KErrNone, nonshareableImage.Create(nonshareableInfo, KImageData, 16), (TText8*)__FILE__, __LINE__);
sl@0
   917
	CleanupClosePushL(nonshareableImage);
sl@0
   918
	
sl@0
   919
	RSgImage image3;
sl@0
   920
	CheckErrorL(KErrNone, image3.Open(nonshareableImage.Id(), ESgDoNotRestrictUsage), (TText8*)__FILE__, __LINE__);
sl@0
   921
	CleanupClosePushL(image3);
sl@0
   922
	TSgImageInfo info3;
sl@0
   923
	image3.GetInfo(info3);	
sl@0
   924
	TEST(ESgUsageDirectGdiSource | info3.iUsage);
sl@0
   925
	TEST(ESgUsageCompositionSource | info3.iUsage);
sl@0
   926
	TEST(ESgUsageOpenGlesTexture2D | info3.iUsage);
sl@0
   927
	TEST(ESgUsageOpenGles2Texture2D | info3.iUsage);
sl@0
   928
	TEST(ESgUsageOpenVgImage | info3.iUsage);
sl@0
   929
	
sl@0
   930
	RSgImage image4;
sl@0
   931
	CheckErrorL(KErrNone, image4.Open(image3.Id()), (TText8*)__FILE__, __LINE__);
sl@0
   932
	CleanupClosePushL(image4);
sl@0
   933
	TSgImageInfo info4;
sl@0
   934
	image4.GetInfo(info4);
sl@0
   935
	TEST(ESgUsageDirectGdiSource | info4.iUsage);
sl@0
   936
	TEST(ESgUsageCompositionSource | info4.iUsage);
sl@0
   937
	TEST(ESgUsageOpenGlesTexture2D | info4.iUsage);
sl@0
   938
	TEST(ESgUsageOpenGles2Texture2D | info4.iUsage);
sl@0
   939
	TEST(ESgUsageOpenVgImage | info4.iUsage);
sl@0
   940
	
sl@0
   941
	CleanupStack::PopAndDestroy(6, &shareableImage);
sl@0
   942
	TestCloseDriver();
sl@0
   943
	}
sl@0
   944
sl@0
   945
/**
sl@0
   946
@SYMTestCaseID			GRAPHICS-RESOURCE-0044
sl@0
   947
@SYMTestCaseDesc		Gets the interfaces implemented by CSgImageImpl class.
sl@0
   948
@SYMPREQ				PREQ39
sl@0
   949
@SYMREQ					REQ8809
sl@0
   950
@SYMREQ					REQ9175
sl@0
   951
@SYMREQ					REQ9224 
sl@0
   952
@SYMREQ					REQ9233  
sl@0
   953
@SYMREQ					REQ9234
sl@0
   954
@SYMFssID				RSgImage::Create(const TSgImageInfo&, const TAny*, TInt)\n 
sl@0
   955
						RSgImage::GetInterface()
sl@0
   956
@SYMTestPriority		Critical
sl@0
   957
@SYMTestType			Unit Test
sl@0
   958
@SYMTestPurpose			To ensure the extension interfaces supported by RSgImage can be
sl@0
   959
						returned. 
sl@0
   960
@SYMTestActions			Initialise the graphics resource component. Create an image. Call
sl@0
   961
						GetInterface() to return the MSgImage_Sw and MSgImage_Chunk interfaces.
sl@0
   962
						Perform various operations on the interfaces. Declare a fake interface
sl@0
   963
						MFake and call GetInterface() on the image handle.
sl@0
   964
@SYMTestExpectedResults	The operations on the MSgImage_Sw and MSgImage_Chunk interfaces should
sl@0
   965
						succeed. Trying to get the MFake interface should return KErrExtensionNotSupported.
sl@0
   966
@SYMTestStatus			Implemented 
sl@0
   967
 */
sl@0
   968
void CTSgImageGeneric::TestGetInterfaceL()
sl@0
   969
	{
sl@0
   970
	TestOpenDriverL();
sl@0
   971
	
sl@0
   972
	TSgImageInfo info;
sl@0
   973
	info.iSizeInPixels = TSize(8, 8);
sl@0
   974
	info.iUsage = ESgUsageDirectGdiSource;
sl@0
   975
	info.iPixelFormat = EUidPixelFormatRGB_565;
sl@0
   976
	info.iCpuAccess = ESgCpuAccessReadWrite;
sl@0
   977
	info.iShareable = ETrue;
sl@0
   978
	
sl@0
   979
	RSgImage image;	
sl@0
   980
	MSgImage_Sw* swInterface = NULL;
sl@0
   981
	TEST(KErrBadHandle == image.GetInterface(swInterface));
sl@0
   982
	
sl@0
   983
	CheckErrorL(KErrNone, image.Create(info, NULL, 0), (TText8*)__FILE__, __LINE__);
sl@0
   984
	CleanupClosePushL(image);
sl@0
   985
	
sl@0
   986
	// check TSgDrawableId is not NULL
sl@0
   987
	TSgDrawableId id = image.Id();
sl@0
   988
	TEST(KSgNullDrawableId != id);
sl@0
   989
	
sl@0
   990
	TAny* dataAddress1 = NULL;
sl@0
   991
	TInt dataStride1 = 0;
sl@0
   992
	TInt result1 = image.GetInterface(swInterface);
sl@0
   993
	TEST(KErrNone == result1);
sl@0
   994
	if(KErrNone == result1)
sl@0
   995
		{		
sl@0
   996
		// Fill the image with 0xF0
sl@0
   997
		TInt sizeInBytes = 8 * 8 * 2;
sl@0
   998
		TESTL(swInterface->BeginDataAccess(ESgCpuAccessNone) == KErrArgument);
sl@0
   999
		TEST(swInterface->BeginDataAccess(ESgCpuAccessWriteOnly) == KErrNone);
sl@0
  1000
		dataAddress1 = swInterface->DataAddress();
sl@0
  1001
		dataStride1 = swInterface->DataStride();
sl@0
  1002
		Mem::Fill(dataAddress1, sizeInBytes, 0xF0);
sl@0
  1003
		TEST(swInterface->EndDataAccess() == KErrNone);
sl@0
  1004
		
sl@0
  1005
		//Map the image as read only and check if the previous operation is successful
sl@0
  1006
		const TAny* dataAddressRead;
sl@0
  1007
		TInt dataStride2;	
sl@0
  1008
		TInt mapResult = image.MapReadOnly(dataAddressRead, dataStride2);
sl@0
  1009
		TEST(KErrNone == mapResult);
sl@0
  1010
		TEST(dataAddress1 == dataAddressRead);
sl@0
  1011
		TEST(dataStride1 == dataStride2);
sl@0
  1012
		if(KErrNone == mapResult)
sl@0
  1013
			{
sl@0
  1014
			for (TInt y = 0; y < 8; ++y)
sl@0
  1015
				for (TInt x = 0; x < 8; ++x)
sl@0
  1016
					{
sl@0
  1017
					TUint16 pixelValue = *(TUint16*)PtrAdd(dataAddressRead, sizeof(TUint16) * x + dataStride2 * y);
sl@0
  1018
					if (pixelValue != 0xF0F0)
sl@0
  1019
						{
sl@0
  1020
						TEST(EFalse);
sl@0
  1021
						break;
sl@0
  1022
						}
sl@0
  1023
					}
sl@0
  1024
			}
sl@0
  1025
		TEST(KErrNone == image.Unmap());
sl@0
  1026
		}
sl@0
  1027
	
sl@0
  1028
	MSgImage_Chunk* smChunk = NULL;
sl@0
  1029
	TInt result2 = image.GetInterface(smChunk);
sl@0
  1030
	TEST(KErrNone == result2);
sl@0
  1031
	if(KErrNone == result2)
sl@0
  1032
		{
sl@0
  1033
		TAny* address = PtrAdd(smChunk->DataChunk().Base(), smChunk->DataOffset());
sl@0
  1034
		TInt datastride = smChunk->DataStride();
sl@0
  1035
		if(KErrNone == result1)
sl@0
  1036
			{
sl@0
  1037
			TEST(address == dataAddress1);
sl@0
  1038
			TEST(datastride == dataStride1);
sl@0
  1039
			}
sl@0
  1040
		}
sl@0
  1041
	
sl@0
  1042
	//fake interface
sl@0
  1043
	MFake* smFake = NULL;
sl@0
  1044
	TEST(KErrExtensionNotSupported == image.GetInterface(smFake));
sl@0
  1045
	
sl@0
  1046
	CleanupStack::PopAndDestroy();
sl@0
  1047
	TestCloseDriver();
sl@0
  1048
	}
sl@0
  1049
sl@0
  1050
/**
sl@0
  1051
@SYMTestCaseID			GRAPHICS-RESOURCE-0024
sl@0
  1052
@SYMTestCaseDesc		Gets supported pixel formats with invalid parameters.
sl@0
  1053
@SYMPREQ				PREQ39
sl@0
  1054
@SYMREQ					REQ8809
sl@0
  1055
@SYMREQ					REQ9175
sl@0
  1056
@SYMREQ					REQ9224 
sl@0
  1057
@SYMREQ					REQ9233  
sl@0
  1058
@SYMREQ					REQ9234
sl@0
  1059
@SYMFssID				RSgImage::GetPixelFormats(const TSgImageInfo&, TUidPixelFormat*, TInt&)
sl@0
  1060
@SYMTestPriority		Critical
sl@0
  1061
@SYMTestType			Unit Test
sl@0
  1062
@SYMTestPurpose			To ensure the correct error messages are returned when user tries to
sl@0
  1063
						call GetPixelFormats() with invalid parameters.
sl@0
  1064
@SYMTestActions			Initialise the graphics resource component. Call RSgImage::GetPixelFormats with:\n
sl@0
  1065
						\t 1. invalid TSgImageInfo object, it could be any combinations of the following:\n
sl@0
  1066
						\t \t negative width or height\n
sl@0
  1067
						\t \t mutability incompatible with the specified CPU access and usage\n
sl@0
  1068
						\t \t screen id < -1\n
sl@0
  1069
						\t \t usage flag ESgUsageScreenSource with screen id -1\n
sl@0
  1070
						\t 2. invalid aCount
sl@0
  1071
@SYMTestExpectedResults	The function should return KErrArgument in both cases.
sl@0
  1072
@SYMTestStatus			Implemented 
sl@0
  1073
 */	
sl@0
  1074
void CTSgImageGeneric::TestGetPixelFormatsInvalidL()
sl@0
  1075
	{
sl@0
  1076
	TSgImageInfo info1;
sl@0
  1077
	TInt count = 0;
sl@0
  1078
	
sl@0
  1079
	TestOpenDriverL();
sl@0
  1080
	//negative width
sl@0
  1081
	info1.iSizeInPixels = TSize(-100, 100);
sl@0
  1082
	TEST(KErrArgument == RSgImage::GetPixelFormats(info1, NULL, count));
sl@0
  1083
	
sl@0
  1084
	//negative height
sl@0
  1085
	TSgImageInfo info2;
sl@0
  1086
	info2.iSizeInPixels = TSize(100, -100);
sl@0
  1087
	TEST(KErrArgument == RSgImage::GetPixelFormats(info2, NULL, count));
sl@0
  1088
	
sl@0
  1089
	//invalid or non-existent screen id
sl@0
  1090
	TSgImageInfo info5;
sl@0
  1091
	info5.iSizeInPixels = TSize(8, 8);
sl@0
  1092
	info5.iUsage = ESgUsageScreenSource;
sl@0
  1093
	info5.iCpuAccess = ESgCpuAccessReadWrite;
sl@0
  1094
	info5.iScreenId = -2;
sl@0
  1095
	TEST(KErrArgument == RSgImage::GetPixelFormats(info5, NULL, count));
sl@0
  1096
	info5.iScreenId = 100;
sl@0
  1097
	TEST(KErrNone == RSgImage::GetPixelFormats(info5, NULL, count));
sl@0
  1098
	TEST(count == 0);
sl@0
  1099
	
sl@0
  1100
	//usage flag ESgUsageScreenSource with screen id -1
sl@0
  1101
	TSgImageInfo info6;
sl@0
  1102
	info6.iSizeInPixels = TSize(8, 8);
sl@0
  1103
	info6.iScreenId = -1;
sl@0
  1104
	info6.iUsage = ESgUsageScreenSource;
sl@0
  1105
	TEST(KErrArgument == RSgImage::GetPixelFormats(info6, NULL, count));
sl@0
  1106
	
sl@0
  1107
	//negative aCount
sl@0
  1108
	TSgImageInfo info7;
sl@0
  1109
	info7.iCpuAccess = ESgCpuAccessNone;
sl@0
  1110
	info7.iShareable = EFalse;
sl@0
  1111
	info7.iSizeInPixels = TSize(10, 10);
sl@0
  1112
	CheckErrorL(KErrNone, RSgImage::GetPixelFormats(info7, NULL, count), (TText8*)__FILE__, __LINE__);
sl@0
  1113
	
sl@0
  1114
	if(count > 0)
sl@0
  1115
		{
sl@0
  1116
		TUidPixelFormat* pixelFormatArray = new(ELeave) TUidPixelFormat[count];
sl@0
  1117
		if(!pixelFormatArray)
sl@0
  1118
			{
sl@0
  1119
			User::Leave(KErrNoMemory);
sl@0
  1120
			}
sl@0
  1121
		CleanupStack::PushL(pixelFormatArray);
sl@0
  1122
		count = -100;
sl@0
  1123
		TEST(KErrArgument == RSgImage::GetPixelFormats(info7, pixelFormatArray, count));
sl@0
  1124
		
sl@0
  1125
		CleanupStack::PopAndDestroy(pixelFormatArray);
sl@0
  1126
		}
sl@0
  1127
	
sl@0
  1128
	//reset the array used by the GetPixelFormats function to prevent memory leaks
sl@0
  1129
	TSgImageInfo info8;
sl@0
  1130
	info8.iSizeInPixels = TSize(10, 10);
sl@0
  1131
	info8.iCpuAccess = ESgCpuAccessReadWrite;
sl@0
  1132
	info8.iUsage = ESgUsageDirectGdiSource;
sl@0
  1133
	info8.iShareable = EFalse;
sl@0
  1134
	info8.iScreenId = 100;
sl@0
  1135
	TEST(KErrNone == RSgImage::GetPixelFormats(info8, NULL, count));
sl@0
  1136
	TEST(count == 0);
sl@0
  1137
	
sl@0
  1138
	TestCloseDriver();
sl@0
  1139
	}
sl@0
  1140
sl@0
  1141
/**
sl@0
  1142
@SYMTestCaseID			GRAPHICS-RESOURCE-0025
sl@0
  1143
@SYMTestCaseDesc		Opens an image with different invalid parameters.
sl@0
  1144
@SYMPREQ				PREQ39
sl@0
  1145
@SYMREQ					REQ8809
sl@0
  1146
@SYMREQ					REQ9175
sl@0
  1147
@SYMREQ					REQ9224 
sl@0
  1148
@SYMREQ					REQ9233  
sl@0
  1149
@SYMREQ					REQ9234
sl@0
  1150
@SYMFssID				RSgImage::Open(const TSgDrawableId&)
sl@0
  1151
@SYMTestPriority		Critical
sl@0
  1152
@SYMTestType			Unit Test
sl@0
  1153
@SYMTestPurpose			To check correct error messages are returned when opening image with 
sl@0
  1154
						different invalid parameters.
sl@0
  1155
@SYMTestActions			Initialise the graphics resource component. Construct an RSgImage object. 
sl@0
  1156
						Call the Open() function in both the current process and another process with:\n
sl@0
  1157
						\t 1. a non-null RSgImage handle\n
sl@0
  1158
						\t 2. null drawable id\n
sl@0
  1159
						\t 3. fake drawable id\n
sl@0
  1160
						\t 4. a non-sharable RSgImage handle
sl@0
  1161
						Do the same tests in a second thread and a second process.
sl@0
  1162
@SYMTestExpectedResults	The function should return:\n
sl@0
  1163
						\t 1. KErrInUse\n
sl@0
  1164
						\t 2. KErrArgument\n
sl@0
  1165
						\t 3. KErrNotFound\n
sl@0
  1166
						\t 4. KErrNone in the same process and KErrPermissionDenied or KErrNotFound in the second process
sl@0
  1167
@SYMTestStatus			Implemented 
sl@0
  1168
 */	
sl@0
  1169
void CTSgImageGeneric::TestOpenImageInvalidL()
sl@0
  1170
	{	
sl@0
  1171
	TestOpenDriverL();
sl@0
  1172
	//create a non-sharable image
sl@0
  1173
	TSgImageInfo info;
sl@0
  1174
	info.iSizeInPixels = TSize(8, 8);
sl@0
  1175
	info.iUsage = ESgUsageDirectGdiTarget;
sl@0
  1176
	info.iPixelFormat = EUidPixelFormatRGB_565;
sl@0
  1177
	info.iShareable = EFalse;
sl@0
  1178
	
sl@0
  1179
	RSgImage image;
sl@0
  1180
	CheckErrorL(KErrNone, image.Create(info, KImageData, 16), (TText8*)__FILE__, __LINE__);
sl@0
  1181
	CleanupClosePushL(image);
sl@0
  1182
	const TSgDrawableId id = image.Id();
sl@0
  1183
	
sl@0
  1184
	//same thread
sl@0
  1185
	//  non-empty handle
sl@0
  1186
	RSgImage image1;
sl@0
  1187
	CreateImageL(image1);
sl@0
  1188
	CleanupClosePushL(image1);
sl@0
  1189
	TEST(KErrInUse == image1.Open(id));
sl@0
  1190
	image1.Close();
sl@0
  1191
	
sl@0
  1192
	//  null drawable id
sl@0
  1193
	CheckErrorL(KErrArgument, image1.Open(KSgNullDrawableId), (TText8*)__FILE__, __LINE__);
sl@0
  1194
	image1.Close();
sl@0
  1195
	
sl@0
  1196
	//  non-existing drawable id
sl@0
  1197
	TSgDrawableId fakeid = {0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF};
sl@0
  1198
	CheckErrorL(KErrNotFound, image1.Open(fakeid), (TText8*)__FILE__, __LINE__);
sl@0
  1199
	image1.Close();
sl@0
  1200
	
sl@0
  1201
	//  open a non-sharable image
sl@0
  1202
	TEST(KErrNone == image1.Open(id));
sl@0
  1203
	image1.Close();
sl@0
  1204
	
sl@0
  1205
	//different thread in the same process
sl@0
  1206
	TSgresTestInfo threadInfo = {id, info, 0, ESgresSecondThreadOpenImageInvalid};
sl@0
  1207
	TInt testResult = CreateSecondThreadAndDoTestL(threadInfo);
sl@0
  1208
	User::LeaveIfError(testResult);
sl@0
  1209
	// Test the results from the second thread
sl@0
  1210
	TEST(testResult & EFirstTestPassed);
sl@0
  1211
	TEST(testResult & ESecondTestPassed);
sl@0
  1212
	TEST(testResult & EThirdTestPassed);
sl@0
  1213
	TEST(testResult & EFourthTestPassed);
sl@0
  1214
	TEST(testResult & EFifthTestPassed);
sl@0
  1215
	
sl@0
  1216
	//different process	
sl@0
  1217
	TSgresTestInfo processInfo = {id, info, 0, ESgresSecondProcessOpenImageInvalid};
sl@0
  1218
	testResult = CreateSecondProcessAndDoTestL(KSecondProcess, processInfo);	
sl@0
  1219
	User::LeaveIfError(testResult);
sl@0
  1220
	TEST(testResult & EFirstTestPassed);	
sl@0
  1221
	TEST(testResult & ESecondTestPassed);
sl@0
  1222
	TEST(testResult & EThirdTestPassed);
sl@0
  1223
	TEST(testResult & EFourthTestPassed);	
sl@0
  1224
	TEST(testResult & EFifthTestPassed);
sl@0
  1225
		
sl@0
  1226
	CleanupStack::PopAndDestroy(2);
sl@0
  1227
	TestCloseDriver();
sl@0
  1228
	}
sl@0
  1229
sl@0
  1230
/**
sl@0
  1231
@SYMTestCaseID			GRAPHICS-RESOURCE-0026
sl@0
  1232
@SYMTestCaseDesc		Closes an image multiple times.
sl@0
  1233
@SYMPREQ				PREQ39
sl@0
  1234
@SYMREQ					REQ8809
sl@0
  1235
@SYMREQ					REQ9175
sl@0
  1236
@SYMREQ					REQ9224 
sl@0
  1237
@SYMREQ					REQ9233  
sl@0
  1238
@SYMREQ					REQ9234
sl@0
  1239
@SYMFssID				RSgImage::Close()
sl@0
  1240
@SYMTestPriority		Critical
sl@0
  1241
@SYMTestType			Unit Test
sl@0
  1242
@SYMTestPurpose			To check calling Close() multiple times after Open() does not cause
sl@0
  1243
						errors or panics.
sl@0
  1244
@SYMTestActions			Initialise the graphics resource component. Create an image and then
sl@0
  1245
						call Close() three times on it.
sl@0
  1246
@SYMTestExpectedResults	The function should not cause any errors or panics.
sl@0
  1247
@SYMTestStatus			Implemented 
sl@0
  1248
 */
sl@0
  1249
void CTSgImageGeneric::TestCloseImageManyTimesL()
sl@0
  1250
	{
sl@0
  1251
	TestOpenDriverL();
sl@0
  1252
	RSgImage image;
sl@0
  1253
	CreateImageL(image);
sl@0
  1254
	
sl@0
  1255
	image.Close();
sl@0
  1256
	image.Close();
sl@0
  1257
	image.Close();
sl@0
  1258
	
sl@0
  1259
	TestCloseDriver();
sl@0
  1260
	}
sl@0
  1261
sl@0
  1262
sl@0
  1263
/**
sl@0
  1264
@SYMTestCaseID			GRAPHICS-RESOURCE-0027
sl@0
  1265
@SYMTestCaseDesc		Closes an image object without opening it.
sl@0
  1266
@SYMPREQ				PREQ39
sl@0
  1267
@SYMREQ					REQ8809
sl@0
  1268
@SYMREQ					REQ9175
sl@0
  1269
@SYMREQ					REQ9224 
sl@0
  1270
@SYMREQ					REQ9233  
sl@0
  1271
@SYMREQ					REQ9234
sl@0
  1272
@SYMFssID				RSgImage::Close ()
sl@0
  1273
@SYMTestPriority		Critical
sl@0
  1274
@SYMTestType			Unit Test
sl@0
  1275
@SYMTestPurpose			To check Close() does nothing if the image is not already opened.
sl@0
  1276
@SYMTestActions			Initialise the graphics resource component. Declare an RSgImage object and
sl@0
  1277
						call Close() on it.
sl@0
  1278
@SYMTestExpectedResults	The function should not cause any errors or panics.
sl@0
  1279
@SYMTestStatus			Implemented 
sl@0
  1280
 */	
sl@0
  1281
void CTSgImageGeneric::TestCloseImageWithoutOpenL()
sl@0
  1282
	{	
sl@0
  1283
	TestOpenDriverL();
sl@0
  1284
	RSgImage image;
sl@0
  1285
	image.Close();
sl@0
  1286
	TestCloseDriver();
sl@0
  1287
	}
sl@0
  1288
sl@0
  1289
/**
sl@0
  1290
@SYMTestCaseID			GRAPHICS-RESOURCE-0028
sl@0
  1291
@SYMTestCaseDesc		Creates an image with various invalid parameters.
sl@0
  1292
@SYMPREQ				PREQ39
sl@0
  1293
@SYMREQ					REQ8809
sl@0
  1294
@SYMREQ					REQ9175
sl@0
  1295
@SYMREQ					REQ9192
sl@0
  1296
@SYMREQ					REQ9224 
sl@0
  1297
@SYMREQ					REQ9233  
sl@0
  1298
@SYMREQ					REQ9234
sl@0
  1299
@SYMFssID				RSgImage::Create(const TSgImageInfo&, const TAny*, TInt)\n 
sl@0
  1300
						RSgImage::Create(const TSgImageInfo, const RSgImage&)
sl@0
  1301
@SYMTestPriority		Critical
sl@0
  1302
@SYMTestType			Unit Test
sl@0
  1303
@SYMTestPurpose			To check the function returns the correct error messages when the parameters
sl@0
  1304
						are invalid.
sl@0
  1305
@SYMTestActions			Initialise the graphics resource component. Construct a TSgImageInfo object 
sl@0
  1306
						and Initialise the all the member variables with random values. Call the appropriate 
sl@0
  1307
						Create() function with:\n
sl@0
  1308
						\t 1. invalid TSgImageInfo\n
sl@0
  1309
						\t 2. unsupported TSgImageInfo\n
sl@0
  1310
						\t 3. the creating RSgImage handle is not null\n
sl@0
  1311
						\t 4. the aSgImage handle is null\n
sl@0
  1312
						\t 5. the size and pixel format in TSgImageInfo is not the same as that of aSgImage\n
sl@0
  1313
						\t 6. number of iUserAttributes is more than KMaxHint (8)\n
sl@0
  1314
@SYMTestExpectedResults	The function should return\n
sl@0
  1315
						\t 1. KErrArgument\n
sl@0
  1316
						\t 2. KErrNotSupported\n
sl@0
  1317
						\t 3. KErrInUse\n
sl@0
  1318
						\t 4. KErrArgument\n
sl@0
  1319
						\t 5. KErrNotSupported\n
sl@0
  1320
						\t 6. KErrOverflow\n
sl@0
  1321
@SYMTestStatus			Implemented 
sl@0
  1322
 */	
sl@0
  1323
void CTSgImageGeneric::TestCreateImageInvalidL()
sl@0
  1324
	{
sl@0
  1325
	TestOpenDriverL();
sl@0
  1326
	RSgImage image;
sl@0
  1327
	
sl@0
  1328
	//invalid info 1 - invalid size
sl@0
  1329
	TSgImageInfo info1;
sl@0
  1330
	info1.iSizeInPixels = TSize(-100, 100);
sl@0
  1331
	TEST(KErrArgument == image.Create(info1, NULL, 0));
sl@0
  1332
	
sl@0
  1333
	//invalid info 2 - const image with writable cpu access flag
sl@0
  1334
	info1.iUsage = ESgUsageDirectGdiSource;
sl@0
  1335
	info1.iCpuAccess = ESgCpuAccessReadWrite;
sl@0
  1336
	TEST(KErrArgument == image.Create(info1, NULL, 0));
sl@0
  1337
	
sl@0
  1338
	//invalid info 3 - the image is used as a screen source but screen id is set to -1
sl@0
  1339
	info1.iUsage = ESgUsageScreenSource;
sl@0
  1340
	info1.iScreenId = KSgScreenIdAny;
sl@0
  1341
	TEST(KErrArgument == image.Create(info1, NULL, 0));
sl@0
  1342
	
sl@0
  1343
	//invalid info 4 - incorrect user attribute count
sl@0
  1344
	info1.iScreenId = KSgScreenIdMain;
sl@0
  1345
	TSgUserAttribute KTestAttributes[] = {{0x00008888, 1}, {0x00009999, 2}};
sl@0
  1346
	info1.iUserAttributes = KTestAttributes;
sl@0
  1347
	info1.iUserAttributeCount = 0;
sl@0
  1348
	TEST(KErrArgument == image.Create(info1, NULL, 0));
sl@0
  1349
	
sl@0
  1350
	//unsupported info 1 - unsupported pixel format
sl@0
  1351
	TSgImageInfo info2;
sl@0
  1352
	info2.iSizeInPixels = TSize(10, 10);
sl@0
  1353
	info2.iUsage = ESgUsageDirectGdiTarget;
sl@0
  1354
	info2.iPixelFormat = EUidPixelFormatAP_88;
sl@0
  1355
	TEST(KErrNotSupported == image.Create(info2, NULL, 0));
sl@0
  1356
sl@0
  1357
	//unsupported info 2 - usage set to screen source and size is not the same as screen size
sl@0
  1358
	info2.iUsage = ESgUsageScreenSource|ESgUsageDirectGdiTarget;
sl@0
  1359
	info2.iSizeInPixels = TSize(9999, 8888);
sl@0
  1360
	TEST(KErrNotSupported == image.Create(info2, NULL, 0));
sl@0
  1361
sl@0
  1362
#ifdef __WINS__
sl@0
  1363
	TSize screenSize;
sl@0
  1364
	if(HAL::Get(info2.iScreenId, HALData::EDisplayXPixels, screenSize.iWidth) == KErrNone
sl@0
  1365
		&& HAL::Get(info2.iScreenId, HALData::EDisplayYPixels, screenSize.iHeight) == KErrNone)
sl@0
  1366
		{
sl@0
  1367
		info2.iUsage = ESgUsageScreenSource;
sl@0
  1368
		info2.iScreenId = KSgScreenIdMain;
sl@0
  1369
		info2.iCpuAccess = ESgCpuAccessReadWrite;
sl@0
  1370
		info2.iSizeInPixels = TSize(screenSize.iWidth + 10, screenSize.iHeight);
sl@0
  1371
		TEST(KErrNotSupported == image.Create(info2, NULL, 0));
sl@0
  1372
		
sl@0
  1373
		info2.iSizeInPixels = TSize(screenSize.iWidth, screenSize.iHeight + 10);
sl@0
  1374
		TEST(KErrNotSupported == image.Create(info2, NULL, 0));
sl@0
  1375
		
sl@0
  1376
		info2.iSizeInPixels = TSize(screenSize.iHeight, screenSize.iWidth + 10);
sl@0
  1377
		TEST(KErrNotSupported == image.Create(info2, NULL, 0));
sl@0
  1378
		}	
sl@0
  1379
#endif
sl@0
  1380
	
sl@0
  1381
	//non-null handle
sl@0
  1382
	CreateImageL(image);
sl@0
  1383
	CleanupClosePushL(image);
sl@0
  1384
	TSgImageInfo info3;
sl@0
  1385
	info3.iSizeInPixels = TSize(8, 8);
sl@0
  1386
	info3.iUsage = ESgUsageDirectGdiSource;
sl@0
  1387
	info3.iPixelFormat = EUidPixelFormatRGB_565;
sl@0
  1388
	info3.iCpuAccess = ESgCpuAccessReadWrite;
sl@0
  1389
	TInt ret = image.Create(info3, NULL, 0);	
sl@0
  1390
	TEST(KErrInUse == ret);
sl@0
  1391
	
sl@0
  1392
	//non-null handle: create from an existing image
sl@0
  1393
	RSgImage image1;
sl@0
  1394
	CreateImageL(image1);
sl@0
  1395
	CleanupClosePushL(image1);
sl@0
  1396
	TEST(KErrInUse == image1.Create(info3, image));
sl@0
  1397
	CleanupStack::PopAndDestroy();
sl@0
  1398
	
sl@0
  1399
	//null existing image handle
sl@0
  1400
	RSgImage image2;
sl@0
  1401
	TEST(image2.IsNull());
sl@0
  1402
	TEST(KErrArgument == image1.Create(info3, image2));
sl@0
  1403
		
sl@0
  1404
	//the size and pixel format in TSgImageInfo is not the same as that of aSgImage
sl@0
  1405
	TSgImageInfo info4;
sl@0
  1406
	info4.iSizeInPixels = TSize(100, 100);
sl@0
  1407
	info4.iUsage = ESgUsageDirectGdiSource;
sl@0
  1408
	info4.iCpuAccess = ESgCpuAccessReadWrite;
sl@0
  1409
	TEST(KErrNotSupported == image1.Create(info4, image));
sl@0
  1410
	
sl@0
  1411
	info4.iSizeInPixels = info3.iSizeInPixels;
sl@0
  1412
	info4.iPixelFormat = EUidPixelFormatXRGB_8888;
sl@0
  1413
	TEST(KErrNotSupported == image1.Create(info4, image));
sl@0
  1414
	
sl@0
  1415
	//number of iUserAttributes more than KMaxHint(8)
sl@0
  1416
	TSgImageInfo info5;
sl@0
  1417
	info5.iSizeInPixels = TSize(100, 100);
sl@0
  1418
	info5.iPixelFormat = EUidPixelFormatRGB_565;
sl@0
  1419
	info5.iCpuAccess = ESgCpuAccessNone;
sl@0
  1420
	info5.iUsage = ESgUsageDirectGdiTarget;
sl@0
  1421
	info5.iShareable = ETrue;
sl@0
  1422
	TSgUserAttribute testAttributes[] = {{0x00008888, 1}, {0x00009999, 2}};
sl@0
  1423
	info5.iUserAttributes = testAttributes;
sl@0
  1424
	info5.iUserAttributeCount = 100;	
sl@0
  1425
	CheckErrorL(KErrOverflow, image1.Create(info5, NULL, 0), (TText8*)__FILE__, __LINE__);
sl@0
  1426
	
sl@0
  1427
	CleanupStack::PopAndDestroy(&image);
sl@0
  1428
	TestCloseDriver();
sl@0
  1429
	}
sl@0
  1430
sl@0
  1431
/**
sl@0
  1432
@SYMTestCaseID			GRAPHICS-RESOURCE-0039
sl@0
  1433
@SYMTestCaseDesc		Calls GetInfo() on an invalid image.
sl@0
  1434
@SYMPREQ				PREQ39
sl@0
  1435
@SYMREQ					REQ8809
sl@0
  1436
@SYMREQ					REQ9175
sl@0
  1437
@SYMREQ					REQ9224 
sl@0
  1438
@SYMREQ					REQ9233  
sl@0
  1439
@SYMREQ					REQ9234
sl@0
  1440
@SYMFssID				RSgImage::GetInfo(TSgImageInfo&)
sl@0
  1441
@SYMTestPriority		Critical
sl@0
  1442
@SYMTestType			Unit Test
sl@0
  1443
@SYMTestPurpose			To check the correct error is returned when the client tries to get 
sl@0
  1444
						information on an invalid image.
sl@0
  1445
@SYMTestActions			Initialise the graphics resource component. Call GetInfo on an image:\n
sl@0
  1446
						\t 1. that is not initialised\n
sl@0
  1447
						\t 2. TSgImageInfo has different user attributes Ids from the existing Ids.
sl@0
  1448
@SYMTestExpectedResults	The function should return:\n
sl@0
  1449
						\t 1. KErrBadHandle\n
sl@0
  1450
						\t 2. KErrNotFound or KErrArgument
sl@0
  1451
@SYMTestStatus			Implemented 
sl@0
  1452
 */	
sl@0
  1453
void CTSgImageGeneric::TestGetInfoInvalidImageL()
sl@0
  1454
	{
sl@0
  1455
	TestOpenDriverL();	
sl@0
  1456
	RSgImage image;
sl@0
  1457
	TSgImageInfo info;
sl@0
  1458
	
sl@0
  1459
	//uninitialised image
sl@0
  1460
	TEST(KErrBadHandle == image.GetInfo(info));
sl@0
  1461
	
sl@0
  1462
	//TSgImageInfo has different user attributes Ids from the existing Ids.
sl@0
  1463
	info.iPixelFormat = EUidPixelFormatRGB_565;
sl@0
  1464
	info.iSizeInPixels = TSize(100, 100);
sl@0
  1465
	info.iUsage = ESgUsageDirectGdiTarget;
sl@0
  1466
	TSgUserAttribute testAttributes[] = {{0x00008888, 1}, {0x00009999, 2}};
sl@0
  1467
	info.iUserAttributes = testAttributes;
sl@0
  1468
	info.iUserAttributeCount = 2;
sl@0
  1469
	CheckErrorL(KErrNone, image.Create(info, NULL, 0), (TText8*)__FILE__, __LINE__);
sl@0
  1470
	CleanupClosePushL(image);
sl@0
  1471
	TSgImageInfo info2;
sl@0
  1472
	TSgUserAttribute testAttributes2[1];
sl@0
  1473
	info2.iUserAttributes = testAttributes2;
sl@0
  1474
	info2.iUserAttributes[0].iUid = TUid::Uid(0x11111111);
sl@0
  1475
	info2.iUserAttributeCount = 1;
sl@0
  1476
	TInt result = image.GetInfo(info2);
sl@0
  1477
	TEST(KErrNotFound == result || KErrArgument == result);
sl@0
  1478
	TEST(!CompareInfos(info, info2));
sl@0
  1479
	
sl@0
  1480
	CleanupStack::PopAndDestroy();
sl@0
  1481
	TestCloseDriver();
sl@0
  1482
	}
sl@0
  1483
sl@0
  1484
/**
sl@0
  1485
@SYMTestCaseID			GRAPHICS-RESOURCE-0030
sl@0
  1486
@SYMTestCaseDesc		Maps an image under various invalid conditions. 
sl@0
  1487
@SYMPREQ				PREQ39
sl@0
  1488
@SYMREQ					REQ8809
sl@0
  1489
@SYMREQ					REQ9175
sl@0
  1490
@SYMREQ					REQ9193
sl@0
  1491
@SYMREQ					REQ9224 
sl@0
  1492
@SYMREQ					REQ9233  
sl@0
  1493
@SYMREQ					REQ9234
sl@0
  1494
@SYMFssID				RSgImage::MapReadOnly(const TAny*&, TInt&) const\n 
sl@0
  1495
						RSgImage::MapWriteOnly(TAny*&, TInt&)\n 
sl@0
  1496
						RSgImage::MapReadWrite(TAny*&, TInt&)
sl@0
  1497
@SYMTestPriority		Critical
sl@0
  1498
@SYMTestType			Unit Test
sl@0
  1499
@SYMTestPurpose			To check the correct error messages are returned when different map
sl@0
  1500
						functions are called under various invalid conditions.
sl@0
  1501
@SYMTestActions			Initialise the graphics resource component. \n
sl@0
  1502
						\t 1. call any map function on an uninitialised RSgImage\n
sl@0
  1503
						\t 2. call any map function twice\n
sl@0
  1504
						\t 3. call MapReadOnly() on an RSgImage created without CPU access
sl@0
  1505
						flag ESgCpuAccessReadOnly or ESgCpuAccessReadWrite\n
sl@0
  1506
						\t 4. call MapWriteOnly() on an RSgImage created without CPU access
sl@0
  1507
						flag ESgCpuAccessWriteOnly or ESgCpuAccessReadWrite\n
sl@0
  1508
						\t 5. call MapReadWrite() on an RSgImage created without CPU access
sl@0
  1509
						flag ESgCpuAccessReadWrite\n
sl@0
  1510
						\t 6. call any map function in a second process
sl@0
  1511
@SYMTestExpectedResults	The function should return:\n
sl@0
  1512
						\t 1. KErrBadHandle\n
sl@0
  1513
						\t 2. KErrInUse\n
sl@0
  1514
						\t 3. KErrAccessDenied\n
sl@0
  1515
						\t 4. KErrAccessDenied\n
sl@0
  1516
						\t 5. KErrAccessDenied\n
sl@0
  1517
						\t 6. KErrPermissionDenied
sl@0
  1518
@SYMTestStatus			Implemented 
sl@0
  1519
 */	
sl@0
  1520
void CTSgImageGeneric::TestMapImageInvalidL()
sl@0
  1521
	{
sl@0
  1522
	TestOpenDriverL();
sl@0
  1523
	RSgImage image;
sl@0
  1524
	const TAny* dataAddressRead;
sl@0
  1525
	TAny* dataAddressWrite;
sl@0
  1526
	TInt dataStride;
sl@0
  1527
	
sl@0
  1528
	//an uninitialised image
sl@0
  1529
	TEST(KErrBadHandle == image.MapReadOnly(dataAddressRead, dataStride));
sl@0
  1530
	TEST(KErrBadHandle == image.MapWriteOnly(dataAddressWrite, dataStride));
sl@0
  1531
	TEST(KErrBadHandle == image.MapReadWrite(dataAddressWrite, dataStride));
sl@0
  1532
	
sl@0
  1533
	//map twice
sl@0
  1534
	RSgImage image1;
sl@0
  1535
	CreateImageL(image1);
sl@0
  1536
	CleanupClosePushL(image1);
sl@0
  1537
	TEST(KErrNone == image1.MapReadOnly(dataAddressRead, dataStride));
sl@0
  1538
	TEST(KErrInUse == image1.MapReadOnly(dataAddressRead, dataStride));
sl@0
  1539
	TEST(KErrNone == image1.Unmap());
sl@0
  1540
	
sl@0
  1541
	TEST(KErrNone == image1.MapWriteOnly(dataAddressWrite, dataStride));
sl@0
  1542
	TEST(KErrInUse == image1.MapWriteOnly(dataAddressWrite, dataStride));
sl@0
  1543
	TEST(KErrNone == image1.Unmap());
sl@0
  1544
	
sl@0
  1545
	TEST(KErrNone == image1.MapReadWrite(dataAddressWrite, dataStride));
sl@0
  1546
	TEST(KErrInUse == image1.MapReadWrite(dataAddressWrite, dataStride));
sl@0
  1547
	TEST(KErrNone == image1.Unmap());
sl@0
  1548
	
sl@0
  1549
	CleanupStack::PopAndDestroy();	
sl@0
  1550
	
sl@0
  1551
	//  Initialise image
sl@0
  1552
	TSgImageInfo info;
sl@0
  1553
	info.iSizeInPixels = TSize(8, 8);
sl@0
  1554
	info.iUsage = ESgUsageDirectGdiSource;
sl@0
  1555
	info.iPixelFormat = EUidPixelFormatRGB_565;
sl@0
  1556
	info.iCpuAccess = ESgCpuAccessReadWrite;
sl@0
  1557
	info.iShareable = ETrue;
sl@0
  1558
	CheckErrorL(KErrNone, image.Create(info, KImageData, 16), (TText8*)__FILE__, __LINE__);
sl@0
  1559
	CleanupClosePushL(image);
sl@0
  1560
	TEST(KErrNone == image.MapReadWrite(dataAddressWrite, dataStride)); //first time should pass
sl@0
  1561
	TEST(KErrInUse == image.MapReadWrite(dataAddressWrite, dataStride)); //second time should fail
sl@0
  1562
	TEST(KErrNone == image.Unmap());
sl@0
  1563
	image.Close();
sl@0
  1564
	
sl@0
  1565
	//call MapReadOnly() on an RSgImage created without CPU access
sl@0
  1566
	//flag ESgCpuAccessReadOnly or ESgCpuAccessReadWrite
sl@0
  1567
	info.iCpuAccess = ESgCpuAccessNone;
sl@0
  1568
	CheckErrorL(KErrNone, image.Create(info, KImageData, 16), (TText8*)__FILE__, __LINE__);
sl@0
  1569
	TEST(KErrAccessDenied == image.MapReadOnly(dataAddressRead, dataStride));
sl@0
  1570
	image.Close();
sl@0
  1571
	
sl@0
  1572
	info.iCpuAccess = ESgCpuAccessWriteOnly;
sl@0
  1573
	CheckErrorL(KErrNone, image.Create(info, KImageData, 16), (TText8*)__FILE__, __LINE__);
sl@0
  1574
	TEST(KErrAccessDenied == image.MapReadOnly(dataAddressRead, dataStride));
sl@0
  1575
	image.Close();
sl@0
  1576
	
sl@0
  1577
	//call MapWriteOnly() on an RSgImage created without CPU access
sl@0
  1578
	//flag ESgCpuAccessWriteOnly or ESgCpuAccessReadWrite
sl@0
  1579
	info.iCpuAccess = ESgCpuAccessNone;
sl@0
  1580
	CheckErrorL(KErrNone, image.Create(info, KImageData, 16), (TText8*)__FILE__, __LINE__);
sl@0
  1581
	TEST(KErrAccessDenied == image.MapWriteOnly(dataAddressWrite, dataStride));
sl@0
  1582
	image.Close();
sl@0
  1583
	
sl@0
  1584
	info.iCpuAccess = ESgCpuAccessReadOnly;
sl@0
  1585
	CheckErrorL(KErrNone, image.Create(info, KImageData, 16), (TText8*)__FILE__, __LINE__);
sl@0
  1586
	TEST(KErrAccessDenied == image.MapWriteOnly(dataAddressWrite, dataStride));
sl@0
  1587
	image.Close();
sl@0
  1588
	
sl@0
  1589
	//call MapReadWrite() on an RSgImage created without CPU access
sl@0
  1590
	//flag ESgCpuAccessReadWrite
sl@0
  1591
	info.iCpuAccess = ESgCpuAccessNone;
sl@0
  1592
	CheckErrorL(KErrNone, image.Create(info, KImageData, 16), (TText8*)__FILE__, __LINE__);
sl@0
  1593
	TEST(KErrAccessDenied == image.MapReadWrite(dataAddressWrite, dataStride));
sl@0
  1594
	image.Close();
sl@0
  1595
	
sl@0
  1596
	info.iCpuAccess = ESgCpuAccessReadOnly;
sl@0
  1597
	CheckErrorL(KErrNone, image.Create(info, KImageData, 16), (TText8*)__FILE__, __LINE__);
sl@0
  1598
	TEST(KErrAccessDenied == image.MapReadWrite(dataAddressWrite, dataStride));
sl@0
  1599
	image.Close();
sl@0
  1600
	
sl@0
  1601
	info.iCpuAccess = ESgCpuAccessWriteOnly;
sl@0
  1602
	CheckErrorL(KErrNone, image.Create(info, KImageData, 16), (TText8*)__FILE__, __LINE__);
sl@0
  1603
	TEST(KErrAccessDenied == image.MapReadWrite(dataAddressWrite, dataStride));
sl@0
  1604
	image.Close();
sl@0
  1605
	
sl@0
  1606
	info.iCpuAccess = ESgCpuAccessReadWrite;
sl@0
  1607
	CheckErrorL(KErrNone, image.Create(info, KImageData, 16), (TText8*)__FILE__, __LINE__);
sl@0
  1608
	
sl@0
  1609
	//call map in a second thread in the current process - should succeed
sl@0
  1610
	TSgresTestInfo threadInfo = {image.Id(), info, 0, ESgresSecondThreadMapImage};	
sl@0
  1611
	TInt testResult = CreateSecondThreadAndDoTestL(threadInfo);
sl@0
  1612
	User::LeaveIfError(testResult);
sl@0
  1613
	TEST(testResult & EFirstTestPassed);
sl@0
  1614
	TEST(testResult & ESecondTestPassed);
sl@0
  1615
	TEST(testResult & EThirdTestPassed);
sl@0
  1616
	TEST(testResult & EFourthTestPassed);
sl@0
  1617
	TEST(testResult & EFifthTestPassed);
sl@0
  1618
	TEST(testResult & ESixthTestPassed);
sl@0
  1619
	TEST(testResult & ESeventhTestPassed);
sl@0
  1620
	
sl@0
  1621
	//call map in a non-owner process
sl@0
  1622
	TSgresTestInfo processInfo = {image.Id(), info, 0, ESgresSecondProcessMapImage};
sl@0
  1623
	testResult = CreateSecondProcessAndDoTestL(KSecondProcess, processInfo);	
sl@0
  1624
	User::LeaveIfError(testResult);	
sl@0
  1625
	TEST(testResult & EFirstTestPassed);
sl@0
  1626
	TEST(testResult & ESecondTestPassed);
sl@0
  1627
	TEST(testResult & EThirdTestPassed);
sl@0
  1628
	TEST(testResult & EFourthTestPassed);
sl@0
  1629
	TEST(testResult & EFifthTestPassed);
sl@0
  1630
	
sl@0
  1631
	CleanupStack::PopAndDestroy();
sl@0
  1632
	TestCloseDriver();
sl@0
  1633
	}
sl@0
  1634
sl@0
  1635
/**
sl@0
  1636
@SYMTestCaseID			GRAPHICS-RESOURCE-0031
sl@0
  1637
@SYMTestCaseDesc		Unmaps an image under various invalid conditions.
sl@0
  1638
@SYMPREQ				PREQ39
sl@0
  1639
@SYMREQ					REQ8809
sl@0
  1640
@SYMREQ					REQ9175
sl@0
  1641
@SYMREQ					REQ9193
sl@0
  1642
@SYMREQ					REQ9224 
sl@0
  1643
@SYMREQ					REQ9233  
sl@0
  1644
@SYMREQ					REQ9234
sl@0
  1645
@SYMFssID				RSgImage::MapReadOnly(const TAny*&, TInt&) const\n 
sl@0
  1646
						RSgImage::MapWriteOnly(TAny*&, TInt&)\n 
sl@0
  1647
						RSgImage::MapReadWrite(TAny*&, TInt&)\n 
sl@0
  1648
						RSgImage::Unmap()
sl@0
  1649
@SYMTestPriority		Critical
sl@0
  1650
@SYMTestType			Unit Test
sl@0
  1651
@SYMTestPurpose			To check the correct error messages are returned when the Unmap()
sl@0
  1652
						function is called under various invalid conditions.
sl@0
  1653
@SYMTestActions			Initialise the graphics resource component.\n
sl@0
  1654
						\t 1. call Unmap() on an uninitialised image object\n
sl@0
  1655
						\t 2. create an image with CPU access flag ESgCpuAccessNone and then unmap it\n
sl@0
  1656
						\t 3. call Unmap() on an image that was not mapped.\n
sl@0
  1657
						\t 4. call Unmap() on a mapped image in a second thread in the same process.\n
sl@0
  1658
						\t 5. call Unmap() on an image in a non-owner process
sl@0
  1659
@SYMTestExpectedResults	The function should return:\n
sl@0
  1660
						\t 1. KErrBadHandle\n
sl@0
  1661
						\t 2. KErrGeneral\n
sl@0
  1662
						\t 3. KErrGeneral\n
sl@0
  1663
						\t 4. KErrNone\n
sl@0
  1664
						\t 5. KErrGeneral
sl@0
  1665
@SYMTestStatus			Implemented 
sl@0
  1666
 */	
sl@0
  1667
void CTSgImageGeneric::TestUnmapImageInvalidL()
sl@0
  1668
	{
sl@0
  1669
	TestOpenDriverL();
sl@0
  1670
	RSgImage image;
sl@0
  1671
	
sl@0
  1672
	//unitialized image
sl@0
  1673
	TEST(KErrBadHandle == image.Unmap());
sl@0
  1674
	
sl@0
  1675
	//create an image
sl@0
  1676
	TSgImageInfo info;
sl@0
  1677
	info.iSizeInPixels = TSize(8, 8);
sl@0
  1678
	info.iUsage = ESgUsageDirectGdiSource;
sl@0
  1679
	info.iPixelFormat = EUidPixelFormatRGB_565;
sl@0
  1680
	info.iShareable = ETrue;
sl@0
  1681
	info.iCpuAccess = ESgCpuAccessReadWrite;
sl@0
  1682
	const TAny* dataAddressRead;
sl@0
  1683
	TInt dataStride;
sl@0
  1684
	CheckErrorL(KErrNone, image.Create(info, KImageData, 16), (TText8*)__FILE__, __LINE__);
sl@0
  1685
	CleanupClosePushL(image);
sl@0
  1686
	
sl@0
  1687
	//call on an unmapped image
sl@0
  1688
	TEST(KErrGeneral == image.Unmap());
sl@0
  1689
	
sl@0
  1690
	//map in the current thread and try to unmap in another thread in the current process
sl@0
  1691
	//should fail	
sl@0
  1692
	TEST(KErrNone == image.MapReadOnly(dataAddressRead, dataStride));	
sl@0
  1693
	TSgDrawableId id = image.Id();
sl@0
  1694
	TSgImageInfo imageinfo;
sl@0
  1695
	image.GetInfo(imageinfo);
sl@0
  1696
	
sl@0
  1697
	TSgresTestInfo threadInfo = {id, imageinfo, 0, ESgresSecondThreadUnmapImage};
sl@0
  1698
	TInt testResult = CreateSecondThreadAndDoTestL(threadInfo);
sl@0
  1699
	User::LeaveIfError(testResult);
sl@0
  1700
	TEST(testResult & EFirstTestPassed);
sl@0
  1701
	TEST(testResult & ESecondTestPassed);
sl@0
  1702
	
sl@0
  1703
	//image should already be unmapped
sl@0
  1704
	TEST(KErrGeneral == image.Unmap());
sl@0
  1705
	
sl@0
  1706
	//map in the current thread and try to unmap in another process
sl@0
  1707
	//should fail
sl@0
  1708
	TEST(KErrNone == image.MapReadOnly(dataAddressRead, dataStride));	
sl@0
  1709
	TSgresTestInfo processInfo = {id, imageinfo, 0, ESgresSecondProcessUnmapImage};
sl@0
  1710
	testResult = CreateSecondProcessAndDoTestL(KSecondProcess, processInfo);	
sl@0
  1711
	User::LeaveIfError(testResult);
sl@0
  1712
	TEST(testResult & EFirstTestPassed);	
sl@0
  1713
	TEST(testResult & ESecondTestPassed);
sl@0
  1714
	
sl@0
  1715
	//image should still be mapped
sl@0
  1716
	TEST(KErrNone == image.Unmap());
sl@0
  1717
	
sl@0
  1718
	CleanupStack::PopAndDestroy();
sl@0
  1719
	TestCloseDriver();
sl@0
  1720
	}
sl@0
  1721
sl@0
  1722
/**
sl@0
  1723
@SYMTestCaseID			GRAPHICS-RESOURCE-0048
sl@0
  1724
@SYMTestCaseDesc		RSgImage stress tests
sl@0
  1725
@SYMPREQ				PREQ39
sl@0
  1726
@SYMREQ					REQ8809
sl@0
  1727
@SYMREQ					REQ9175
sl@0
  1728
@SYMREQ					REQ9224 
sl@0
  1729
@SYMREQ					REQ9233  
sl@0
  1730
@SYMREQ					REQ9234
sl@0
  1731
@SYMFssID				RSgImage::Create(const TSgImageInfo&, const TAny*, TInt)\n
sl@0
  1732
						RSgImage::Close() 
sl@0
  1733
@SYMTestPriority		Critical
sl@0
  1734
@SYMTestType			Unit Test
sl@0
  1735
@SYMTestPurpose			To ensure creating and destroying RSgImage multiple times work well.
sl@0
  1736
@SYMTestActions			Create images 1000 times but only store KMaxImagesInArray of them 
sl@0
  1737
						at one time in an RArray. When a new image is to be added to the 
sl@0
  1738
						array, a random image from the array is removed.
sl@0
  1739
@SYMTestExpectedResults	There should be no panics or leaves.
sl@0
  1740
@SYMTestStatus			Implemented 
sl@0
  1741
 */
sl@0
  1742
void CTSgImageGeneric::TestStress1L()
sl@0
  1743
	{
sl@0
  1744
	TestOpenDriverL();
sl@0
  1745
	TSgImageInfo info;
sl@0
  1746
	info.iPixelFormat = EUidPixelFormatRGB_565;
sl@0
  1747
	info.iSizeInPixels = TSize(100, 100);
sl@0
  1748
	info.iUsage = ESgUsageDirectGdiTarget;
sl@0
  1749
	
sl@0
  1750
	TInt KMaxImagesInArray =40;
sl@0
  1751
	TInt64 seed = 0;
sl@0
  1752
	for (TInt count = 1000; count > 0; --count)
sl@0
  1753
		{
sl@0
  1754
		RSgImage image;
sl@0
  1755
		CheckErrorL(KErrNone, image.Create(info, NULL, 0), (TText8*)__FILE__, __LINE__);
sl@0
  1756
		CleanupClosePushL(image);
sl@0
  1757
		iTestImages.AppendL(image);
sl@0
  1758
		CleanupStack::Pop();
sl@0
  1759
		if (iTestImages.Count() >= KMaxImagesInArray)
sl@0
  1760
			{
sl@0
  1761
			TInt i = Math::Rand(seed) % KMaxImagesInArray;
sl@0
  1762
			iTestImages[i].Close();
sl@0
  1763
			iTestImages.Remove(i);
sl@0
  1764
			}
sl@0
  1765
		}
sl@0
  1766
	TInt count = iTestImages.Count();
sl@0
  1767
	for(TInt i=0; i<count; ++i)
sl@0
  1768
		{
sl@0
  1769
		iTestImages[i].Close();
sl@0
  1770
		}	
sl@0
  1771
	iTestImages.Reset();
sl@0
  1772
	TestCloseDriver();
sl@0
  1773
	}
sl@0
  1774
sl@0
  1775
/**
sl@0
  1776
@SYMTestCaseID			GRAPHICS-RESOURCE-0049
sl@0
  1777
@SYMTestCaseDesc		RSgImage multiple threads open and close stress tests
sl@0
  1778
@SYMPREQ				PREQ39
sl@0
  1779
@SYMREQ					REQ8809
sl@0
  1780
@SYMREQ					REQ9175
sl@0
  1781
@SYMREQ					REQ9224 
sl@0
  1782
@SYMREQ					REQ9233  
sl@0
  1783
@SYMREQ					REQ9234
sl@0
  1784
@SYMFssID				RSgImage::Open(const TSgDrawableId&)\n
sl@0
  1785
						RSgImage::Close() 
sl@0
  1786
@SYMTestPriority		Critical
sl@0
  1787
@SYMTestType			Unit Test
sl@0
  1788
@SYMTestPurpose			To ensure opening and destroying RSgImage multiple times and randomly
sl@0
  1789
						in other threads work well.
sl@0
  1790
@SYMTestActions			Create an image in the main thread. In a loop of 1000 times, randomly select
sl@0
  1791
						one of the five threads and either open or close the image depending on the 
sl@0
  1792
						state of the thread.
sl@0
  1793
@SYMTestExpectedResults	There should be no panics or leaves.
sl@0
  1794
@SYMTestStatus			Implemented 
sl@0
  1795
 */
sl@0
  1796
void CTSgImageGeneric::TestStress2L()
sl@0
  1797
	{
sl@0
  1798
	TestOpenDriverL();
sl@0
  1799
	RSgImage image;
sl@0
  1800
	CreateImageL(image);
sl@0
  1801
	CleanupClosePushL(image);
sl@0
  1802
	const TSgDrawableId id = image.Id();
sl@0
  1803
	
sl@0
  1804
	TSgImageInfo info;
sl@0
  1805
	TEST(KErrNone == image.GetInfo(info));
sl@0
  1806
	TSgresTestInfo threadInfo = {id, info, 0, ESgresMultipleThreadStressTest, EFalse};
sl@0
  1807
	
sl@0
  1808
	//create a semaphore
sl@0
  1809
	RSemaphore sem;
sl@0
  1810
	User::LeaveIfError(sem.CreateGlobal(KSecondThreadSemaphore, 0, EOwnerThread));
sl@0
  1811
	CleanupClosePushL(sem);
sl@0
  1812
	
sl@0
  1813
	//create threads
sl@0
  1814
	const TInt KNoOfThreads = 5;
sl@0
  1815
	RArray<RThread> threads;
sl@0
  1816
	_LIT(KMultipleThreadName, "Multiple Threads Stress Test Thread ");
sl@0
  1817
	for (TInt i = 0; i < KNoOfThreads; ++i)
sl@0
  1818
		{
sl@0
  1819
		TBuf<50> threadName(KMultipleThreadName);
sl@0
  1820
		threadName.AppendNum(i);
sl@0
  1821
		RThread thread;
sl@0
  1822
		User::LeaveIfError(thread.Create(threadName, SecondThreadStart, KDefaultStackSize, &User::Heap(), &threadInfo));
sl@0
  1823
		thread.SetPriority(EPriorityLess);
sl@0
  1824
		threads.AppendL(thread);
sl@0
  1825
		}
sl@0
  1826
	// run threads
sl@0
  1827
	for (TInt i = 0; i < KNoOfThreads; ++i)
sl@0
  1828
		{
sl@0
  1829
		threads[i].Resume();
sl@0
  1830
		}
sl@0
  1831
	// wait for the threads to terminate processing
sl@0
  1832
	for (TInt i = 0; i < KNoOfThreads; ++i)
sl@0
  1833
		{
sl@0
  1834
		sem.Wait();
sl@0
  1835
		}
sl@0
  1836
	for (TInt i = 0; i < KNoOfThreads; ++i)
sl@0
  1837
		{
sl@0
  1838
		threads[i].Close();
sl@0
  1839
		}
sl@0
  1840
	CleanupStack::PopAndDestroy(2); // image, sem
sl@0
  1841
	TestCloseDriver();
sl@0
  1842
	}
sl@0
  1843
sl@0
  1844
/**
sl@0
  1845
@SYMTestCaseID			GRAPHICS-RESOURCE-0051
sl@0
  1846
@SYMTestCaseDesc		Calls RSgImage::GetInterface() with an invalid image handle
sl@0
  1847
@SYMPREQ				PREQ39
sl@0
  1848
@SYMREQ					REQ8809
sl@0
  1849
@SYMREQ					REQ9175
sl@0
  1850
@SYMFssID				RSgImage::GetInterface(TUid, TAny*&)\n 
sl@0
  1851
@SYMTestPriority		Critical
sl@0
  1852
@SYMTestType			Unit Test
sl@0
  1853
@SYMTestPurpose			To ensure calling GetInterface() with an invalid image handle will cause a panic.
sl@0
  1854
@SYMTestActions			Initialise the graphics resource component and create an image in a second thread. 
sl@0
  1855
						Declare another image and assign it to the current image handle. Close the current
sl@0
  1856
						image so the second image handle becomes invalid. Call GetInterface() on the second
sl@0
  1857
						handle.
sl@0
  1858
@SYMTestExpectedResults The function should panic in the second thread with panic code SGRES 2(ESgPanicBadDrawableHandle).
sl@0
  1859
@SYMTestStatus			Implemented 
sl@0
  1860
 */
sl@0
  1861
void CTSgImageGeneric::TestPanicImageGetInterfaceInvalidHandleL()
sl@0
  1862
	{
sl@0
  1863
	TSgImageInfo info;
sl@0
  1864
	TSgresTestInfo threadInfo = {KSgNullDrawableId, info, 0, ESgresSecondThreadPanicImageGetInterfaceInvalidHandle, ETrue};
sl@0
  1865
 	TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
sl@0
  1866
	_LIT(KTestName, "TestImageGetInterfaceInvalidHandleLThread");
sl@0
  1867
 	CreateSecondThreadAndCheckPanicL(threadInfo, 2, exitCategoryName, KTestName);
sl@0
  1868
	}
sl@0
  1869
sl@0
  1870
/**
sl@0
  1871
@SYMTestCaseID			GRAPHICS-RESOURCE-0052
sl@0
  1872
@SYMTestCaseDesc		Calls RSgImage::GetInterface() with a non-null handle and an uninitialised driver
sl@0
  1873
@SYMPREQ				PREQ39
sl@0
  1874
@SYMREQ					REQ8809
sl@0
  1875
@SYMREQ					REQ9175
sl@0
  1876
@SYMFssID				RSgImage::GetInterface(TUid, TAny*&)\n 
sl@0
  1877
@SYMTestPriority		Critical
sl@0
  1878
@SYMTestType			Unit Test
sl@0
  1879
@SYMTestPurpose			To ensure calling GetInterface() with a non-null handle and an uninitialised driver will cause a panic.
sl@0
  1880
@SYMTestActions			Initialise the graphics resource component and create an image in a second thread. 
sl@0
  1881
						Declare another image and assign it to the current image handle. Close the current
sl@0
  1882
						image so the second image handle becomes invalid. Close the graphics resource driver.
sl@0
  1883
						Call GetInterface() on the second handle.
sl@0
  1884
@SYMTestExpectedResults The function should panic in the second thread with panic code SGRES 5 (ESgPanicNoDriver).
sl@0
  1885
@SYMTestStatus			Implemented 
sl@0
  1886
 */
sl@0
  1887
void CTSgImageGeneric::TestPanicImageGetInterfaceNoDriverL()
sl@0
  1888
	{	
sl@0
  1889
	TSgImageInfo info;
sl@0
  1890
	TSgresTestInfo threadInfo = {KSgNullDrawableId, info, 0, ESgresSecondThreadPanicImageGetInterfaceNoDriver, ETrue};
sl@0
  1891
 	TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
sl@0
  1892
	_LIT(KTestName, "TestImageGetInterfaceNoDriverL");
sl@0
  1893
 	CreateSecondThreadAndCheckPanicL(threadInfo, 5, exitCategoryName, KTestName);
sl@0
  1894
	}
sl@0
  1895
sl@0
  1896
/**
sl@0
  1897
@SYMTestCaseID			GRAPHICS-RESOURCE-0053
sl@0
  1898
@SYMTestCaseDesc		Calls RSgImage::Close() with an invalid image handle
sl@0
  1899
@SYMPREQ				PREQ39
sl@0
  1900
@SYMREQ					REQ8809
sl@0
  1901
@SYMREQ					REQ9175
sl@0
  1902
@SYMFssID				RSgImage::Close()\n 
sl@0
  1903
@SYMTestPriority		Critical
sl@0
  1904
@SYMTestType			Unit Test
sl@0
  1905
@SYMTestPurpose			To ensure calling Close() with an invalid image handle will cause a panic.
sl@0
  1906
@SYMTestActions			Initialise the graphics resource component and create an image in a second thread. 
sl@0
  1907
						Declare another image and assign it to the current image handle. Close the current
sl@0
  1908
						image so the second image handle becomes invalid. Call Close() on the second handle.
sl@0
  1909
@SYMTestExpectedResults The function should panic in the second thread with panic code SGRES 2(ESgPanicBadDrawableHandle).
sl@0
  1910
@SYMTestStatus			Implemented 
sl@0
  1911
 */
sl@0
  1912
void CTSgImageGeneric::TestPanicImageCloseInvalidHandleL()
sl@0
  1913
	{
sl@0
  1914
	TSgImageInfo info;
sl@0
  1915
	TSgresTestInfo threadInfo = {KSgNullDrawableId, info, 0, ESgresSecondThreadPanicImageCloseInvalidHandle, ETrue};
sl@0
  1916
 	TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
sl@0
  1917
	_LIT(KTestName, "TestImageCloseInvalidHandleL");
sl@0
  1918
 	CreateSecondThreadAndCheckPanicL(threadInfo, 2, exitCategoryName, KTestName);
sl@0
  1919
	}
sl@0
  1920
sl@0
  1921
/**
sl@0
  1922
@SYMTestCaseID			GRAPHICS-RESOURCE-0054
sl@0
  1923
@SYMTestCaseDesc		Calls RSgImage::Close() with a non-null handle and an uninitialised driver
sl@0
  1924
@SYMPREQ				PREQ39
sl@0
  1925
@SYMREQ					REQ8809
sl@0
  1926
@SYMREQ					REQ9175
sl@0
  1927
@SYMFssID				RSgImage::Close()\n 
sl@0
  1928
@SYMTestPriority		Critical
sl@0
  1929
@SYMTestType			Unit Test
sl@0
  1930
@SYMTestPurpose			To ensure calling Close() with a non-null handle and an uninitialised driver will cause a panic.
sl@0
  1931
@SYMTestActions			Initialise the graphics resource component and create an image in a second thread. 
sl@0
  1932
						Declare another image and assign it to the current image handle. Close the current
sl@0
  1933
						image so the second image handle becomes invalid. Close the graphics resource driver.
sl@0
  1934
						Call Close() on the second handle.
sl@0
  1935
@SYMTestExpectedResults The function should panic in the second thread with panic code SGRES 5 (ESgPanicNoDriver).
sl@0
  1936
@SYMTestStatus			Implemented 
sl@0
  1937
 */
sl@0
  1938
void CTSgImageGeneric::TestPanicImageCloseNoDriverL()
sl@0
  1939
	{
sl@0
  1940
	TSgImageInfo info;
sl@0
  1941
	TSgresTestInfo threadInfo = {KSgNullDrawableId, info, 0, ESgresSecondThreadPanicImageCloseNoDriver, ETrue};
sl@0
  1942
 	TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
sl@0
  1943
	_LIT(KTestName, "TestImageCloseNoDriverL");
sl@0
  1944
 	CreateSecondThreadAndCheckPanicL(threadInfo, 5, exitCategoryName, KTestName);
sl@0
  1945
	}
sl@0
  1946
sl@0
  1947
/**
sl@0
  1948
@SYMTestCaseID			GRAPHICS-RESOURCE-0055
sl@0
  1949
@SYMTestCaseDesc		Calls RSgImage::Id() with an invalid image handle
sl@0
  1950
@SYMPREQ				PREQ39
sl@0
  1951
@SYMREQ					REQ8809
sl@0
  1952
@SYMREQ					REQ9175
sl@0
  1953
@SYMFssID				RSgImage::Id()\n 
sl@0
  1954
@SYMTestPriority		Critical
sl@0
  1955
@SYMTestType			Unit Test
sl@0
  1956
@SYMTestPurpose			To ensure calling Id() with an invalid image handle will cause a panic.
sl@0
  1957
@SYMTestActions			Initialise the graphics resource component and create an image in a second thread. 
sl@0
  1958
						Declare another image and assign it to the current image handle. Close the current
sl@0
  1959
						image so the second image handle becomes invalid. Call Id() on the second
sl@0
  1960
						handle.
sl@0
  1961
@SYMTestExpectedResults The function should panic in the second thread with panic code SGRES 2(ESgPanicBadDrawableHandle).
sl@0
  1962
@SYMTestStatus			Implemented 
sl@0
  1963
 */
sl@0
  1964
void CTSgImageGeneric::TestPanicImageIdInvalidHandleL()
sl@0
  1965
	{
sl@0
  1966
	TSgImageInfo info;
sl@0
  1967
	TSgresTestInfo threadInfo = {KSgNullDrawableId, info, 0, ESgresSecondThreadPanicImageIdInvalidHandle, ETrue};
sl@0
  1968
 	TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
sl@0
  1969
	_LIT(KTestName, "TestImageIdInvalidHandleL");
sl@0
  1970
 	CreateSecondThreadAndCheckPanicL(threadInfo, 2, exitCategoryName, KTestName);
sl@0
  1971
	}
sl@0
  1972
sl@0
  1973
/**
sl@0
  1974
@SYMTestCaseID			GRAPHICS-RESOURCE-0056
sl@0
  1975
@SYMTestCaseDesc		Calls RSgImage::Id() with a non-null handle and an uninitialised driver
sl@0
  1976
@SYMPREQ				PREQ39
sl@0
  1977
@SYMREQ					REQ8809
sl@0
  1978
@SYMREQ					REQ9175
sl@0
  1979
@SYMFssID				RSgImage::Id()\n 
sl@0
  1980
@SYMTestPriority		Critical
sl@0
  1981
@SYMTestType			Unit Test
sl@0
  1982
@SYMTestPurpose			To ensure calling Id() with a non-null handle and an uninitialised driver will cause a panic.
sl@0
  1983
@SYMTestActions			Initialise the graphics resource component and create an image in a second thread. 
sl@0
  1984
						Declare another image and assign it to the current image handle. Close the current
sl@0
  1985
						image so the second image handle becomes invalid. Close the graphics resource driver.
sl@0
  1986
						Call Id() on the second handle.
sl@0
  1987
@SYMTestExpectedResults The function should panic in the second thread with panic code SGRES 5 (ESgPanicNoDriver).
sl@0
  1988
@SYMTestStatus			Implemented 
sl@0
  1989
 */
sl@0
  1990
void CTSgImageGeneric::TestPanicImageIdNoDriverL()
sl@0
  1991
	{
sl@0
  1992
	TSgImageInfo info;
sl@0
  1993
	TSgresTestInfo threadInfo = {KSgNullDrawableId, info, 0, ESgresSecondThreadPanicImageIdNoDriver, ETrue};
sl@0
  1994
 	TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
sl@0
  1995
	_LIT(KTestName, "TestImageIdNoDriverL");
sl@0
  1996
 	CreateSecondThreadAndCheckPanicL(threadInfo, 5, exitCategoryName, KTestName);
sl@0
  1997
	}
sl@0
  1998
sl@0
  1999
/**
sl@0
  2000
@SYMTestCaseID			GRAPHICS-RESOURCE-0057
sl@0
  2001
@SYMTestCaseDesc		Calls RSgImage::Create() with an invalid image handle
sl@0
  2002
@SYMPREQ				PREQ39
sl@0
  2003
@SYMREQ					REQ8809
sl@0
  2004
@SYMREQ					REQ9175
sl@0
  2005
@SYMREQ					REQ9192
sl@0
  2006
@SYMFssID				RSgImage::Create(const TSgImageInfo&, const RSgImage&)\n 
sl@0
  2007
@SYMTestPriority		Critical
sl@0
  2008
@SYMTestType			Unit Test
sl@0
  2009
@SYMTestPurpose			To ensure calling Create() with an invalid image handle will cause a panic.
sl@0
  2010
@SYMTestActions			Initialise the graphics resource component and create an image in a second thread. 
sl@0
  2011
						Declare another image and assign it to the current image handle. Close the current
sl@0
  2012
						image so the second image handle becomes invalid. Call Create() on the second
sl@0
  2013
						handle.
sl@0
  2014
@SYMTestExpectedResults The function should panic in the second thread with panic code SGRES 2(ESgPanicBadDrawableHandle).
sl@0
  2015
@SYMTestStatus			Implemented 
sl@0
  2016
 */
sl@0
  2017
void CTSgImageGeneric::TestPanicImageCreateInvalidHandleL()
sl@0
  2018
	{
sl@0
  2019
	TSgImageInfo info;
sl@0
  2020
	TSgresTestInfo threadInfo = {KSgNullDrawableId, info, 0, ESgresSecondThreadPanicImageCreateInvalidHandle, ETrue};
sl@0
  2021
 	TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
sl@0
  2022
	_LIT(KTestName, "TestImageCreateInvalidHandleL");
sl@0
  2023
 	CreateSecondThreadAndCheckPanicL(threadInfo, 3, exitCategoryName, KTestName);
sl@0
  2024
	}
sl@0
  2025
sl@0
  2026
/**
sl@0
  2027
@SYMTestCaseID			GRAPHICS-RESOURCE-0058
sl@0
  2028
@SYMTestCaseDesc		Calls RSgImage::GetInfo() with an invalid image handle
sl@0
  2029
@SYMPREQ				PREQ39
sl@0
  2030
@SYMREQ					REQ8809
sl@0
  2031
@SYMREQ					REQ9175
sl@0
  2032
@SYMFssID				RSgImage::GetInfo(TSgImageInfo&)\n 
sl@0
  2033
@SYMTestPriority		Critical
sl@0
  2034
@SYMTestType			Unit Test
sl@0
  2035
@SYMTestPurpose			To ensure calling GetInfo() with an invalid image handle will cause a panic.
sl@0
  2036
@SYMTestActions			Initialise the graphics resource component and create an image in a second thread. 
sl@0
  2037
						Declare another image and assign it to the current image handle. Close the current
sl@0
  2038
						image so the second image handle becomes invalid. Call GetInfo() on the second
sl@0
  2039
						handle.
sl@0
  2040
@SYMTestExpectedResults The function should panic in the second thread with panic code SGRES 2(ESgPanicBadDrawableHandle).
sl@0
  2041
@SYMTestStatus			Implemented 
sl@0
  2042
 */
sl@0
  2043
void CTSgImageGeneric::TestPanicImageGetInfoInvalidHandleL()
sl@0
  2044
	{
sl@0
  2045
	TSgImageInfo info;
sl@0
  2046
	TSgresTestInfo threadInfo = {KSgNullDrawableId, info, 0, ESgresSecondThreadPanicImageGetInfoInvalidHandle, ETrue};
sl@0
  2047
 	TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
sl@0
  2048
	_LIT(KTestName, "TestImageGetInfoInvalidHandleL");
sl@0
  2049
 	CreateSecondThreadAndCheckPanicL(threadInfo, 3, exitCategoryName, KTestName);
sl@0
  2050
	}
sl@0
  2051
sl@0
  2052
/**
sl@0
  2053
@SYMTestCaseID			GRAPHICS-RESOURCE-0059
sl@0
  2054
@SYMTestCaseDesc		Calls RSgImage::GetInfo() with a non-null handle and an uninitialised driver
sl@0
  2055
@SYMPREQ				PREQ39
sl@0
  2056
@SYMREQ					REQ8809
sl@0
  2057
@SYMREQ					REQ9175
sl@0
  2058
@SYMFssID				SgImage::GetInfo(TSgImageInfo&)\n 
sl@0
  2059
@SYMTestPriority		Critical
sl@0
  2060
@SYMTestType			Unit Test
sl@0
  2061
@SYMTestPurpose			To ensure calling GetInfo() with a non-null handle and an uninitialised driver will cause a panic.
sl@0
  2062
@SYMTestActions			Initialise the graphics resource component and create an image in a second thread. 
sl@0
  2063
						Declare another image and assign it to the current image handle. Close the current
sl@0
  2064
						image so the second image handle becomes invalid. Close the graphics resource driver.
sl@0
  2065
						Call GetInfo() on the second handle.
sl@0
  2066
@SYMTestExpectedResults The function should panic in the second thread with panic code SGRES 5 (ESgPanicNoDriver).
sl@0
  2067
@SYMTestStatus			Implemented 
sl@0
  2068
 */
sl@0
  2069
void CTSgImageGeneric::TestPanicImageGetInfoNoDriverL()
sl@0
  2070
	{
sl@0
  2071
	TSgImageInfo info;
sl@0
  2072
	TSgresTestInfo threadInfo = {KSgNullDrawableId, info, 0, ESgresSecondThreadPanicImageGetInfoNoDriver, ETrue};
sl@0
  2073
 	TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
sl@0
  2074
	_LIT(KTestName, "TestImageGetInfoNoDriverL");
sl@0
  2075
 	CreateSecondThreadAndCheckPanicL(threadInfo, 5, exitCategoryName, KTestName);
sl@0
  2076
	}
sl@0
  2077
sl@0
  2078
/**
sl@0
  2079
@SYMTestCaseID			GRAPHICS-RESOURCE-0060
sl@0
  2080
@SYMTestCaseDesc		Calls RSgImage::MapReadOnly with an invalid image handle
sl@0
  2081
@SYMPREQ				PREQ39
sl@0
  2082
@SYMREQ					REQ8809
sl@0
  2083
@SYMREQ					REQ9175
sl@0
  2084
@SYMREQ					REQ9193
sl@0
  2085
@SYMFssID				RSgImage::MapReadOnly(const TAny*&, TInt&) const\n 
sl@0
  2086
@SYMTestPriority		Critical
sl@0
  2087
@SYMTestType			Unit Test
sl@0
  2088
@SYMTestPurpose			To ensure calling MapReadOnly() with an invalid image handle will cause a panic.
sl@0
  2089
@SYMTestActions			Initialise the graphics resource component and create an image in a second thread. 
sl@0
  2090
						Declare another image and assign it to the current image handle. Close the current
sl@0
  2091
						image so the second image handle becomes invalid. Call MapReadOnly() on the second
sl@0
  2092
						handle.
sl@0
  2093
@SYMTestExpectedResults The function should panic in the second thread with panic code SGRES 2(ESgPanicBadDrawableHandle).
sl@0
  2094
@SYMTestStatus			Implemented 
sl@0
  2095
 */
sl@0
  2096
void CTSgImageGeneric::TestPanicImageMapReadOnlyInvalidHandleL()
sl@0
  2097
	{
sl@0
  2098
	TSgImageInfo info;
sl@0
  2099
	TSgresTestInfo threadInfo = {KSgNullDrawableId, info, 0, ESgresSecondThreadPanicImageMapReadOnlyInvalidHandle, ETrue};
sl@0
  2100
 	TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
sl@0
  2101
	_LIT(KTestName, "TestImageMapReadOnlyInvalidHandleL");
sl@0
  2102
 	CreateSecondThreadAndCheckPanicL(threadInfo, 3, exitCategoryName, KTestName);
sl@0
  2103
	}
sl@0
  2104
sl@0
  2105
/**
sl@0
  2106
@SYMTestCaseID			GRAPHICS-RESOURCE-0061
sl@0
  2107
@SYMTestCaseDesc		Calls RSgImage::MapReadOnly with a non-null handle and an uninitialised driver
sl@0
  2108
@SYMPREQ				PREQ39
sl@0
  2109
@SYMREQ					REQ8809
sl@0
  2110
@SYMREQ					REQ9175
sl@0
  2111
@SYMREQ					REQ9193
sl@0
  2112
@SYMFssID				RSgImage::MapReadOnly(const TAny*&, TInt&) const\n 
sl@0
  2113
@SYMTestPriority		Critical
sl@0
  2114
@SYMTestType			Unit Test
sl@0
  2115
@SYMTestPurpose			To ensure calling MapReadOnly() with a non-null handle and an uninitialised driver will cause a panic.
sl@0
  2116
@SYMTestActions			Initialise the graphics resource component and create an image in a second thread. 
sl@0
  2117
						Declare another image and assign it to the current image handle. Close the current
sl@0
  2118
						image so the second image handle becomes invalid. Close the graphics resource driver.
sl@0
  2119
						Call MapReadOnly() on the second handle.
sl@0
  2120
@SYMTestExpectedResults The function should panic in the second thread with panic code SGRES 5 (ESgPanicNoDriver).
sl@0
  2121
@SYMTestStatus			Implemented 
sl@0
  2122
 */
sl@0
  2123
void CTSgImageGeneric::TestPanicImageMapReadOnlyNoDriverL()
sl@0
  2124
	{
sl@0
  2125
	TSgImageInfo info;
sl@0
  2126
	TSgresTestInfo threadInfo = {KSgNullDrawableId, info, 0, ESgresSecondThreadPanicImageMapReadOnlyNoDriver, ETrue};
sl@0
  2127
 	TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
sl@0
  2128
	_LIT(KTestName, "TestImageMapReadOnlyNoDriverL");
sl@0
  2129
 	CreateSecondThreadAndCheckPanicL(threadInfo, 5, exitCategoryName, KTestName);
sl@0
  2130
	}
sl@0
  2131
sl@0
  2132
/**
sl@0
  2133
@SYMTestCaseID			GRAPHICS-RESOURCE-0062
sl@0
  2134
@SYMTestCaseDesc		Calls RSgImage::MapWriteOnly() with an invalid image handle
sl@0
  2135
@SYMPREQ				PREQ39
sl@0
  2136
@SYMREQ					REQ8809
sl@0
  2137
@SYMREQ					REQ9175
sl@0
  2138
@SYMREQ					REQ9193
sl@0
  2139
@SYMFssID				RSgImage::MapWriteOnly(TAny*&, TInt&)\n 
sl@0
  2140
@SYMTestPriority		Critical
sl@0
  2141
@SYMTestType			Unit Test
sl@0
  2142
@SYMTestPurpose			To ensure calling MapWriteOnly() with an invalid image handle will cause a panic.
sl@0
  2143
@SYMTestActions			Initialise the graphics resource component and create an image in a second thread. 
sl@0
  2144
						Declare another image and assign it to the current image handle. Close the current
sl@0
  2145
						image so the second image handle becomes invalid. Call MapWriteOnly() on the second
sl@0
  2146
						handle.
sl@0
  2147
@SYMTestExpectedResults The function should panic in the second thread with panic code SGRES 2(ESgPanicBadDrawableHandle).
sl@0
  2148
@SYMTestStatus			Implemented 
sl@0
  2149
 */
sl@0
  2150
void CTSgImageGeneric::TestPanicImageMapWriteOnlyInvalidHandleL()
sl@0
  2151
	{
sl@0
  2152
	TSgImageInfo info;
sl@0
  2153
	TSgresTestInfo threadInfo = {KSgNullDrawableId, info, 0, ESgresSecondThreadPanicImageMapWriteOnlyInvalidHandle, ETrue};
sl@0
  2154
 	TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
sl@0
  2155
	_LIT(KTestName, "TestImageMapWriteOnlyInvalidHandleL");
sl@0
  2156
 	CreateSecondThreadAndCheckPanicL(threadInfo, 3, exitCategoryName, KTestName);
sl@0
  2157
	}
sl@0
  2158
sl@0
  2159
/**
sl@0
  2160
@SYMTestCaseID			GRAPHICS-RESOURCE-0063
sl@0
  2161
@SYMTestCaseDesc		Calls RSgImage::MapWriteOnly() with a non-null handle and an uninitialised driver
sl@0
  2162
@SYMPREQ				PREQ39
sl@0
  2163
@SYMREQ					REQ8809
sl@0
  2164
@SYMREQ					REQ9175
sl@0
  2165
@SYMREQ					REQ9193
sl@0
  2166
@SYMFssID				RSgImage::MapWriteOnly(TAny*&, TInt&)\n 
sl@0
  2167
@SYMTestPriority		Critical
sl@0
  2168
@SYMTestType			Unit Test
sl@0
  2169
@SYMTestPurpose			To ensure calling MapWriteOnly() with a non-null handle and an uninitialised driver will cause a panic.
sl@0
  2170
@SYMTestActions			Initialise the graphics resource component and create an image in a second thread. 
sl@0
  2171
						Declare another image and assign it to the current image handle. Close the current
sl@0
  2172
						image so the second image handle becomes invalid. Close the graphics resource driver.
sl@0
  2173
						Call MapWriteOnly() on the second handle.
sl@0
  2174
@SYMTestExpectedResults The function should panic in the second thread with panic code SGRES 5 (ESgPanicNoDriver).
sl@0
  2175
@SYMTestStatus			Implemented 
sl@0
  2176
 */
sl@0
  2177
void CTSgImageGeneric::TestPanicImageMapWriteOnlyNoDriverL()
sl@0
  2178
	{
sl@0
  2179
	TSgImageInfo info;
sl@0
  2180
	TSgresTestInfo threadInfo = {KSgNullDrawableId, info, 0, ESgresSecondThreadPanicImageMapWriteOnlyNoDriver, ETrue};
sl@0
  2181
 	TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
sl@0
  2182
	_LIT(KTestName, "TestImageMapWriteOnlyNoDriverL");
sl@0
  2183
 	CreateSecondThreadAndCheckPanicL(threadInfo, 5, exitCategoryName, KTestName);
sl@0
  2184
	}
sl@0
  2185
sl@0
  2186
/**
sl@0
  2187
@SYMTestCaseID			GRAPHICS-RESOURCE-0064
sl@0
  2188
@SYMTestCaseDesc		Calls RSgImage::MapReadWrite() with an invalid image handle
sl@0
  2189
@SYMPREQ				PREQ39
sl@0
  2190
@SYMREQ					REQ8809
sl@0
  2191
@SYMREQ					REQ9175
sl@0
  2192
@SYMREQ					REQ9193
sl@0
  2193
@SYMFssID				RSgImage::MapReadWrite(TAny*&, TInt&)\n 
sl@0
  2194
@SYMTestPriority		Critical
sl@0
  2195
@SYMTestType			Unit Test
sl@0
  2196
@SYMTestPurpose			To ensure calling MapReadWrite() with an invalid image handle will cause a panic.
sl@0
  2197
@SYMTestActions			Initialise the graphics resource component and create an image in a second thread. 
sl@0
  2198
						Declare another image and assign it to the current image handle. Close the current
sl@0
  2199
						image so the second image handle becomes invalid. Call MapReadWrite() on the second
sl@0
  2200
						handle.
sl@0
  2201
@SYMTestExpectedResults The function should panic in the second thread with panic code SGRES 2(ESgPanicBadDrawableHandle).
sl@0
  2202
@SYMTestStatus			Implemented 
sl@0
  2203
 */
sl@0
  2204
void CTSgImageGeneric::TestPanicImageMapReadWriteInvalidHandleL()
sl@0
  2205
	{
sl@0
  2206
	TSgImageInfo info;
sl@0
  2207
	TSgresTestInfo threadInfo = {KSgNullDrawableId, info, 0, ESgresSecondThreadPanicImageMapReadWriteInvalidHandle, ETrue};
sl@0
  2208
 	TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
sl@0
  2209
	_LIT(KTestName, "TestImageMapReadWriteInvalidHandleL");
sl@0
  2210
 	CreateSecondThreadAndCheckPanicL(threadInfo, 3, exitCategoryName, KTestName);
sl@0
  2211
	}
sl@0
  2212
sl@0
  2213
/**
sl@0
  2214
@SYMTestCaseID			GRAPHICS-RESOURCE-0065
sl@0
  2215
@SYMTestCaseDesc		Calls RSgImage::MapReadWrite() with a non-null handle and an uninitialised driver
sl@0
  2216
@SYMPREQ				PREQ39
sl@0
  2217
@SYMREQ					REQ8809
sl@0
  2218
@SYMREQ					REQ9175
sl@0
  2219
@SYMREQ					REQ9193
sl@0
  2220
@SYMFssID				RSgImage::MapReadWrite(TAny*&, TInt&)\n 
sl@0
  2221
@SYMTestPriority		Critical
sl@0
  2222
@SYMTestType			Unit Test
sl@0
  2223
@SYMTestPurpose			To ensure calling MapReadWrite() with a non-null handle and an uninitialised driver will cause a panic.
sl@0
  2224
@SYMTestActions			Initialise the graphics resource component and create an image in a second thread. 
sl@0
  2225
						Declare another image and assign it to the current image handle. Close the current
sl@0
  2226
						image so the second image handle becomes invalid. Close the graphics resource driver.
sl@0
  2227
						Call MapReadWrite() on the second handle.
sl@0
  2228
@SYMTestExpectedResults The function should panic in the second thread with panic code SGRES 5 (ESgPanicNoDriver).
sl@0
  2229
@SYMTestStatus			Implemented 
sl@0
  2230
 */
sl@0
  2231
void CTSgImageGeneric::TestPanicImageMapReadWriteNoDriverL()
sl@0
  2232
	{
sl@0
  2233
	TSgImageInfo info;
sl@0
  2234
	TSgresTestInfo threadInfo = {KSgNullDrawableId, info, 0, ESgresSecondThreadPanicImageMapReadWriteNoDriver, ETrue};
sl@0
  2235
 	TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
sl@0
  2236
	_LIT(KTestName, "TestImageMapReadWriteNoDriverL");
sl@0
  2237
 	CreateSecondThreadAndCheckPanicL(threadInfo, 5, exitCategoryName, KTestName);
sl@0
  2238
	}
sl@0
  2239
sl@0
  2240
/**
sl@0
  2241
@SYMTestCaseID			GRAPHICS-RESOURCE-0066
sl@0
  2242
@SYMTestCaseDesc		Calls RSgImage::Unmap() with an invalid image handle
sl@0
  2243
@SYMPREQ				PREQ39
sl@0
  2244
@SYMREQ					REQ8809
sl@0
  2245
@SYMREQ					REQ9175
sl@0
  2246
@SYMREQ					REQ9193
sl@0
  2247
@SYMFssID				RSgImage::Unmap()\n 
sl@0
  2248
@SYMTestPriority		Critical
sl@0
  2249
@SYMTestType			Unit Test
sl@0
  2250
@SYMTestPurpose			To ensure calling Unmap() with an invalid image handle will cause a panic.
sl@0
  2251
@SYMTestActions			Initialise the graphics resource component and create an image in a second thread. 
sl@0
  2252
						Declare another image and assign it to the current image handle. Close the current
sl@0
  2253
						image so the second image handle becomes invalid. Call Unmap() on the second
sl@0
  2254
						handle.
sl@0
  2255
@SYMTestExpectedResults The function should panic in the second thread with panic code SGRES 2(ESgPanicBadDrawableHandle).
sl@0
  2256
@SYMTestStatus			Implemented 
sl@0
  2257
 */
sl@0
  2258
void CTSgImageGeneric::TestPanicImageUnmapInvalidHandleL()
sl@0
  2259
	{
sl@0
  2260
	TSgImageInfo info;
sl@0
  2261
	TSgresTestInfo threadInfo = {KSgNullDrawableId, info, 0, ESgresSecondThreadPanicImageUnmapInvalidHandle, ETrue};
sl@0
  2262
 	TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
sl@0
  2263
	_LIT(KTestName, "TestImageUnmapInvalidHandleL");
sl@0
  2264
 	CreateSecondThreadAndCheckPanicL(threadInfo, 3, exitCategoryName, KTestName);
sl@0
  2265
	}
sl@0
  2266
sl@0
  2267
/**
sl@0
  2268
@SYMTestCaseID			GRAPHICS-RESOURCE-0067
sl@0
  2269
@SYMTestCaseDesc		Calls RSgImage::Unmap() with a non-null handle and an uninitialised driver
sl@0
  2270
@SYMPREQ				PREQ39
sl@0
  2271
@SYMREQ					REQ8809
sl@0
  2272
@SYMREQ					REQ9175
sl@0
  2273
@SYMFssID				RSgImage::Unmap()\n 
sl@0
  2274
@SYMTestPriority		Critical
sl@0
  2275
@SYMTestType			Unit Test
sl@0
  2276
@SYMTestPurpose			To ensure calling Unmap() with a non-null handle and an uninitialised driver will cause a panic.
sl@0
  2277
@SYMTestActions			Initialise the graphics resource component and create an image in a second thread. 
sl@0
  2278
						Declare another image and assign it to the current image handle. Close the current
sl@0
  2279
						image so the second image handle becomes invalid. Close the graphics resource driver.
sl@0
  2280
						Call Unmap() on the second handle.
sl@0
  2281
@SYMTestExpectedResults The function should panic in the second thread with panic code SGRES 5 (ESgPanicNoDriver).
sl@0
  2282
@SYMTestStatus			Implemented 
sl@0
  2283
 */
sl@0
  2284
void CTSgImageGeneric::TestPanicImageUnmapNoDriverL()
sl@0
  2285
	{
sl@0
  2286
	TSgImageInfo info;
sl@0
  2287
	TSgresTestInfo threadInfo = {KSgNullDrawableId, info, 0, ESgresSecondThreadPanicImageUnmapNoDriver, ETrue};
sl@0
  2288
 	TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
sl@0
  2289
	_LIT(KTestName, "TestImageUnmapNoDriverL");
sl@0
  2290
 	CreateSecondThreadAndCheckPanicL(threadInfo, 5, exitCategoryName, KTestName);
sl@0
  2291
	}
sl@0
  2292
sl@0
  2293
/**
sl@0
  2294
@SYMTestCaseID			GRAPHICS-RESOURCE-0082
sl@0
  2295
@SYMTestCaseDesc		Calls RSgImage::Open() when the driver was not initialised.
sl@0
  2296
@SYMPREQ				PREQ39
sl@0
  2297
@SYMREQ					REQ8809
sl@0
  2298
@SYMREQ					REQ9175
sl@0
  2299
@SYMFssID				RSgImage::Open(const TSgDrawableId&, TUint32)\n 
sl@0
  2300
@SYMTestPriority		Critical
sl@0
  2301
@SYMTestType			Unit Test
sl@0
  2302
@SYMTestPurpose			To ensure calling RSgImage::Open() with an uninitialised driver will cause a panic.
sl@0
  2303
@SYMTestActions			Do not Initialise the graphics resource component and call RSgImage::Open() in a second thread.
sl@0
  2304
@SYMTestExpectedResults The function should panic in the second thread with panic code SGRES 5 (ESgPanicNoDriver).
sl@0
  2305
@SYMTestStatus			Implemented 
sl@0
  2306
 */
sl@0
  2307
void CTSgImageGeneric::TestPanicImageOpenNoDriver1L()
sl@0
  2308
	{
sl@0
  2309
	TSgImageInfo info;
sl@0
  2310
	TSgresTestInfo threadInfo = {KSgNullDrawableId, info, 0, ESgresSecondThreadPanicImageOpenNoDriver1, ETrue};
sl@0
  2311
 	TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
sl@0
  2312
	_LIT(KTestName, "TestPanicImageOpenNoDriverL");
sl@0
  2313
 	CreateSecondThreadAndCheckPanicL(threadInfo, 5, exitCategoryName, KTestName);
sl@0
  2314
	}
sl@0
  2315
sl@0
  2316
/**
sl@0
  2317
@SYMTestCaseID			GRAPHICS-RESOURCE-0083
sl@0
  2318
@SYMTestCaseDesc		Creates an image from memory when the driver was not initialised.
sl@0
  2319
@SYMPREQ				PREQ39
sl@0
  2320
@SYMREQ					REQ8809
sl@0
  2321
@SYMREQ					REQ9175
sl@0
  2322
@SYMFssID				RSgImage::Create(const TSgImageInfo&, const TAny*, TInt)\n 
sl@0
  2323
@SYMTestPriority		Critical
sl@0
  2324
@SYMTestType			Unit Test
sl@0
  2325
@SYMTestPurpose			To ensure calling RSgImage::Create() with an uninitialised driver will cause a panic.
sl@0
  2326
@SYMTestActions			Do not Initialise the graphics resource component and call RSgImage::Open() in a second thread.
sl@0
  2327
@SYMTestExpectedResults The function should panic in the second thread with panic code SGRES 5 (ESgPanicNoDriver).
sl@0
  2328
@SYMTestStatus			Implemented 
sl@0
  2329
 */
sl@0
  2330
void CTSgImageGeneric::TestPanicImageCreateNoDriver1L()
sl@0
  2331
	{
sl@0
  2332
	TSgImageInfo info;
sl@0
  2333
	TSgresTestInfo threadInfo = {KSgNullDrawableId, info, 0, ESgresSecondThreadPanicImageCreateNoDriver1, ETrue};
sl@0
  2334
 	TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
sl@0
  2335
	_LIT(KTestName, "TestPanicImageCreateNoDriver1L");
sl@0
  2336
 	CreateSecondThreadAndCheckPanicL(threadInfo, 5, exitCategoryName, KTestName);
sl@0
  2337
	}
sl@0
  2338
sl@0
  2339
/**
sl@0
  2340
@SYMTestCaseID			GRAPHICS-RESOURCE-0084
sl@0
  2341
@SYMTestCaseDesc		Creates an image from an existing image when the driver was not initialised.
sl@0
  2342
@SYMPREQ				PREQ39
sl@0
  2343
@SYMREQ					REQ8809
sl@0
  2344
@SYMREQ					REQ9175
sl@0
  2345
@SYMFssID				RSgImage::Create(const TSgImageInfo&, const RSgImage&)\n 
sl@0
  2346
@SYMTestPriority		Critical
sl@0
  2347
@SYMTestType			Unit Test
sl@0
  2348
@SYMTestPurpose			To ensure calling RSgImage::Create() with an uninitialised driver will cause a panic.
sl@0
  2349
@SYMTestActions			Do not Initialise the graphics resource component and call RSgImage::Open() in a second thread.
sl@0
  2350
@SYMTestExpectedResults The function should panic in the second thread with panic code SGRES 5 (ESgPanicNoDriver).
sl@0
  2351
@SYMTestStatus			Implemented 
sl@0
  2352
 */
sl@0
  2353
void CTSgImageGeneric::TestPanicImageCreateNoDriver2L()
sl@0
  2354
	{
sl@0
  2355
	TSgImageInfo info;
sl@0
  2356
	TSgresTestInfo threadInfo = {KSgNullDrawableId, info, 0, ESgresSecondThreadPanicImageCreateNoDriver2, ETrue};
sl@0
  2357
 	TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
sl@0
  2358
	_LIT(KTestName, "TestPanicImageCreateNoDriver2L");
sl@0
  2359
 	CreateSecondThreadAndCheckPanicL(threadInfo, 5, exitCategoryName, KTestName);
sl@0
  2360
	}
sl@0
  2361
sl@0
  2362
/**
sl@0
  2363
@SYMTestCaseID			GRAPHICS-RESOURCE-0085
sl@0
  2364
@SYMTestCaseDesc		Calls RSgImage::GetPixelFormats() when the driver was not initialised.
sl@0
  2365
@SYMPREQ				PREQ39
sl@0
  2366
@SYMREQ					REQ8809
sl@0
  2367
@SYMREQ					REQ9175
sl@0
  2368
@SYMFssID				RSgImage::GetPixelFormats(const TSgImageInfo&, TUidPixelFormat*, TInt&) \n
sl@0
  2369
@SYMTestPriority		Critical
sl@0
  2370
@SYMTestType			Unit Test
sl@0
  2371
@SYMTestPurpose			To ensure calling RSgImage::GetPixelFormats() with an uninitialised driver will cause a panic.
sl@0
  2372
@SYMTestActions			Do not Initialise the graphics resource component and call RSgImage::GetPixelFormats() in a second thread.
sl@0
  2373
@SYMTestExpectedResults The function should panic in the second thread with panic code SGRES 5 (ESgPanicNoDriver).
sl@0
  2374
@SYMTestStatus			Implemented 
sl@0
  2375
 */
sl@0
  2376
void CTSgImageGeneric::TestPanicImageGetPixelFormatsNoDriverL()
sl@0
  2377
	{
sl@0
  2378
	TSgImageInfo info;
sl@0
  2379
	TSgresTestInfo threadInfo = {KSgNullDrawableId, info, 0, ESgresSecondThreadPanicImageGetPixelFormatsNoDriver, ETrue};
sl@0
  2380
 	TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
sl@0
  2381
	_LIT(KTestName, "TestPanicImageGetPixelFormatsNoDriverL");
sl@0
  2382
 	CreateSecondThreadAndCheckPanicL(threadInfo, 5, exitCategoryName, KTestName);
sl@0
  2383
	}
sl@0
  2384
sl@0
  2385
/**
sl@0
  2386
@SYMTestCaseID			GRAPHICS-RESOURCE-0093
sl@0
  2387
@SYMTestCaseDesc		Calls RSgImage::Open() with mode flags when the driver was not initialised.
sl@0
  2388
@SYMPREQ				PREQ39
sl@0
  2389
@SYMREQ					REQ8809
sl@0
  2390
@SYMREQ					REQ9175
sl@0
  2391
@SYMFssID				RSgImage::Open(const TSgDrawableId&, TUint32)\n 
sl@0
  2392
@SYMTestPriority		Critical
sl@0
  2393
@SYMTestType			Unit Test
sl@0
  2394
@SYMTestPurpose			To ensure calling RSgImage::Open() with an uninitialised driver will cause a panic.
sl@0
  2395
@SYMTestActions			Do not Initialise the graphics resource component and call RSgImage::Open() in a second thread.
sl@0
  2396
@SYMTestExpectedResults The function should panic in the second thread with panic code SGRES 5 (ESgPanicNoDriver).
sl@0
  2397
@SYMTestStatus			Implemented 
sl@0
  2398
 */
sl@0
  2399
void CTSgImageGeneric::TestPanicImageOpenNoDriver2L()
sl@0
  2400
	{
sl@0
  2401
	TSgImageInfo info;
sl@0
  2402
	TSgresTestInfo threadInfo = {KSgNullDrawableId, info, 0, ESgresSecondThreadPanicImageOpenNoDriver2, ETrue};
sl@0
  2403
 	TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
sl@0
  2404
	_LIT(KTestName, "TestPanicImageOpenNoDriverL");
sl@0
  2405
 	CreateSecondThreadAndCheckPanicL(threadInfo, 5, exitCategoryName, KTestName);
sl@0
  2406
	}
sl@0
  2407
sl@0
  2408
/**
sl@0
  2409
@SYMTestCaseID			GRAPHICS-RESOURCE-0088
sl@0
  2410
@SYMTestCaseDesc		Calls RSgImage::DrawableType() when the driver was not initialised.
sl@0
  2411
@SYMPREQ				PREQ39
sl@0
  2412
@SYMREQ					REQ8809
sl@0
  2413
@SYMREQ					REQ9175
sl@0
  2414
@SYMFssID				RSgImage::DrawableType()\n 
sl@0
  2415
@SYMTestPriority		Critical
sl@0
  2416
@SYMTestType			Unit Test
sl@0
  2417
@SYMTestPurpose			To ensure calling RSgImage::DrawableType() with an uninitialised driver will cause a panic.
sl@0
  2418
@SYMTestActions			Do not Initialise the graphics resource component and call RSgImage::DrawableType() in a second thread.
sl@0
  2419
@SYMTestExpectedResults The function should panic in the second thread with panic code SGRES 5 (ESgPanicNoDriver).
sl@0
  2420
@SYMTestStatus			Implemented 
sl@0
  2421
 */
sl@0
  2422
void CTSgImageGeneric::TestPanicImageDrawableTypeNoDriverL()
sl@0
  2423
	{
sl@0
  2424
	TSgImageInfo info;
sl@0
  2425
	TSgresTestInfo threadInfo = {KSgNullDrawableId, info, 0, ESgresSecondThreadPanicImageDrawableTypeInvalidHandle, ETrue};
sl@0
  2426
 	TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
sl@0
  2427
	_LIT(KTestName, "TestPanicImageOpenNoDriverL");
sl@0
  2428
 	CreateSecondThreadAndCheckPanicL(threadInfo, 2, exitCategoryName, KTestName);
sl@0
  2429
	}
sl@0
  2430
sl@0
  2431
/**
sl@0
  2432
@SYMTestCaseID			GRAPHICS-RESOURCE-0089
sl@0
  2433
@SYMTestCaseDesc		Calls RSgImage::DrawableType() with an invalid image handle
sl@0
  2434
@SYMPREQ				PREQ39
sl@0
  2435
@SYMREQ					REQ8809
sl@0
  2436
@SYMREQ					REQ9175
sl@0
  2437
@SYMFssID				RSgImage::DrawableType()\n 
sl@0
  2438
@SYMTestPriority		Critical
sl@0
  2439
@SYMTestType			Unit Test
sl@0
  2440
@SYMTestPurpose			To ensure calling RSgImage::DrawableType() with an uninitialised driver will cause a panic.
sl@0
  2441
@SYMTestActions			Do not Initialise the graphics resource component and call RSgImage::DrawableType() in a second thread.
sl@0
  2442
@SYMTestExpectedResults The function should panic in the second thread with panic code SGRES SGRES 2(ESgPanicBadDrawableHandle).
sl@0
  2443
@SYMTestStatus			Implemented 
sl@0
  2444
 */
sl@0
  2445
void CTSgImageGeneric::TestPanicImageDrawableTypeInvalidHandleL()
sl@0
  2446
	{
sl@0
  2447
	TSgImageInfo info;
sl@0
  2448
	TSgresTestInfo threadInfo = {KSgNullDrawableId, info, 0, ESgresSecondThreadPanicImageDrawableTypeNoDriver, ETrue};
sl@0
  2449
 	TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
sl@0
  2450
	_LIT(KTestName, "TestPanicImageOpenNoDriverL");
sl@0
  2451
 	CreateSecondThreadAndCheckPanicL(threadInfo, 5, exitCategoryName, KTestName);
sl@0
  2452
	}
sl@0
  2453
sl@0
  2454
void CTSgImageGeneric::DoMemoryTestsL()
sl@0
  2455
	{
sl@0
  2456
	__UHEAP_MARK; SgDriver::AllocMarkStart();
sl@0
  2457
	TestGetPixelFormatsL();
sl@0
  2458
	__UHEAP_MARKEND; SgDriver::AllocMarkEnd(0);
sl@0
  2459
	
sl@0
  2460
	__UHEAP_MARK; SgDriver::AllocMarkStart();
sl@0
  2461
	TestCreateImageUninitializedL();
sl@0
  2462
	__UHEAP_MARKEND; SgDriver::AllocMarkEnd(0);
sl@0
  2463
	
sl@0
  2464
	__UHEAP_MARK; SgDriver::AllocMarkStart();
sl@0
  2465
	TestCreateImageL();
sl@0
  2466
	__UHEAP_MARKEND; SgDriver::AllocMarkEnd(0);
sl@0
  2467
	
sl@0
  2468
	__UHEAP_MARK; SgDriver::AllocMarkStart();
sl@0
  2469
	TestCreateImageFromExistingImageL();
sl@0
  2470
	__UHEAP_MARKEND; SgDriver::AllocMarkEnd(0);
sl@0
  2471
	
sl@0
  2472
	__UHEAP_MARK; SgDriver::AllocMarkStart();
sl@0
  2473
	TestGetImageInfoL();
sl@0
  2474
	__UHEAP_MARKEND; SgDriver::AllocMarkEnd(0);
sl@0
  2475
	
sl@0
  2476
	__UHEAP_MARK; SgDriver::AllocMarkStart();
sl@0
  2477
	TestGetImageDrawableIdL(); 
sl@0
  2478
	__UHEAP_MARKEND; SgDriver::AllocMarkEnd(0);
sl@0
  2479
	
sl@0
  2480
	__UHEAP_MARK; SgDriver::AllocMarkStart();
sl@0
  2481
	TestMapImageL();
sl@0
  2482
	__UHEAP_MARKEND; SgDriver::AllocMarkEnd(0);
sl@0
  2483
	
sl@0
  2484
	__UHEAP_MARK; SgDriver::AllocMarkStart();
sl@0
  2485
	TestOpenImageL();
sl@0
  2486
	__UHEAP_MARKEND; SgDriver::AllocMarkEnd(0);
sl@0
  2487
	
sl@0
  2488
	__UHEAP_MARK; SgDriver::AllocMarkStart();
sl@0
  2489
	TestGetInterfaceL();
sl@0
  2490
	__UHEAP_MARKEND; SgDriver::AllocMarkEnd(0);
sl@0
  2491
	
sl@0
  2492
	__UHEAP_MARK; SgDriver::AllocMarkStart();
sl@0
  2493
	TestGetPixelFormatsInvalidL();
sl@0
  2494
	__UHEAP_MARKEND; SgDriver::AllocMarkEnd(0);
sl@0
  2495
	
sl@0
  2496
	__UHEAP_MARK; SgDriver::AllocMarkStart();
sl@0
  2497
	TestOpenImageInvalidL();
sl@0
  2498
	__UHEAP_MARKEND; SgDriver::AllocMarkEnd(0);
sl@0
  2499
	
sl@0
  2500
	__UHEAP_MARK; SgDriver::AllocMarkStart();
sl@0
  2501
	TestCloseImageManyTimesL();
sl@0
  2502
	__UHEAP_MARKEND; SgDriver::AllocMarkEnd(0);
sl@0
  2503
	
sl@0
  2504
	__UHEAP_MARK; SgDriver::AllocMarkStart();
sl@0
  2505
	TestCloseImageWithoutOpenL();
sl@0
  2506
	__UHEAP_MARKEND; SgDriver::AllocMarkEnd(0);
sl@0
  2507
	
sl@0
  2508
	__UHEAP_MARK; SgDriver::AllocMarkStart();
sl@0
  2509
	TestCreateImageInvalidL();
sl@0
  2510
	__UHEAP_MARKEND; SgDriver::AllocMarkEnd(0);
sl@0
  2511
	
sl@0
  2512
	__UHEAP_MARK; SgDriver::AllocMarkStart();
sl@0
  2513
	TestGetInfoInvalidImageL();
sl@0
  2514
	__UHEAP_MARKEND; SgDriver::AllocMarkEnd(0);
sl@0
  2515
	
sl@0
  2516
	__UHEAP_MARK; SgDriver::AllocMarkStart();
sl@0
  2517
	TestMapImageInvalidL();
sl@0
  2518
	__UHEAP_MARKEND; SgDriver::AllocMarkEnd(0);
sl@0
  2519
	
sl@0
  2520
	__UHEAP_MARK; SgDriver::AllocMarkStart();
sl@0
  2521
	TestUnmapImageInvalidL();
sl@0
  2522
	__UHEAP_MARKEND; SgDriver::AllocMarkEnd(0);
sl@0
  2523
	}