os/graphics/graphicsresourceservices/graphicsresourceimplementation/test/src/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-2010 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 - Graphics Resource API Conformance Test Suite
sl@0
    20
*/
sl@0
    21
sl@0
    22
sl@0
    23
#include "tsgimagegeneric.h"
sl@0
    24
sl@0
    25
#include <e32math.h>
sl@0
    26
sl@0
    27
CTSgImageGeneric::CTSgImageGeneric(TBool aConformanceTests) :
sl@0
    28
	CTSgTestStepBase(aConformanceTests)
sl@0
    29
	{
sl@0
    30
	INFO_PRINTF1(_L("Graphics resource component test - RSgImage Generic Tests.\r\n"));
sl@0
    31
	}
sl@0
    32
sl@0
    33
CTSgImageGeneric::~CTSgImageGeneric()
sl@0
    34
	{
sl@0
    35
	DestroyImages();
sl@0
    36
	}
sl@0
    37
sl@0
    38
void CTSgImageGeneric::DestroyImages()
sl@0
    39
	{
sl@0
    40
	TInt count = iTestImages.Count();
sl@0
    41
	for(TInt i=0; i<count; ++i)
sl@0
    42
		{
sl@0
    43
		iTestImages[i].Close();
sl@0
    44
		}   
sl@0
    45
	iTestImages.Reset();    
sl@0
    46
    }
sl@0
    47
sl@0
    48
/** 
sl@0
    49
Overrides of base class pure virtual
sl@0
    50
Our implementation only gets called if the base class doTestStepPreambleL() did
sl@0
    51
not leave. That being the case, the current test result value will be EPass.
sl@0
    52
@leave Gets system wide error code
sl@0
    53
@return TVerdict code
sl@0
    54
*/
sl@0
    55
TVerdict CTSgImageGeneric::doTestStepL()
sl@0
    56
	{
sl@0
    57
	SetTestStepID(_L("GRAPHICS-RESOURCE-0003"));
sl@0
    58
	INFO_PRINTF1(_L("Getting pixel formats supported on all platforms.\r\n"));
sl@0
    59
	TestGetPixelFormatsL();
sl@0
    60
	RecordTestResultL();	
sl@0
    61
sl@0
    62
	SetTestStepID(_L("GRAPHICS-RESOURCE-0004"));
sl@0
    63
	INFO_PRINTF1(_L("Create an uninitialised image.\r\n"));
sl@0
    64
	TestCreateImageUninitializedL();
sl@0
    65
	RecordTestResultL();
sl@0
    66
		
sl@0
    67
	SetTestStepID(_L("GRAPHICS-RESOURCE-0005"));
sl@0
    68
	INFO_PRINTF1(_L("Create an image from a block of memory.\r\n"));
sl@0
    69
	TestCreateImageL();
sl@0
    70
	RecordTestResultL();
sl@0
    71
	
sl@0
    72
	SetTestStepID(_L("GRAPHICS-RESOURCE-0011"));
sl@0
    73
	INFO_PRINTF1(_L("Ensure all mandatory image pixel formats supported.\r\n"));
sl@0
    74
	TestCreateImageAllPixelFormatsL();
sl@0
    75
	RecordTestResultL();
sl@0
    76
	
sl@0
    77
	SetTestStepID(_L("GRAPHICS-RESOURCE-0006"));
sl@0
    78
	INFO_PRINTF1(_L("Create an image from an existing image.\r\n"));
sl@0
    79
	TestCreateImageFromExistingImageL();
sl@0
    80
	RecordTestResultL();
sl@0
    81
		
sl@0
    82
	SetTestStepID(_L("GRAPHICS-RESOURCE-0007"));
sl@0
    83
	INFO_PRINTF1(_L("Getting information about the image.\r\n"));
sl@0
    84
	TestGetImageInfoL();
sl@0
    85
	RecordTestResultL();
sl@0
    86
		
sl@0
    87
	SetTestStepID(_L("GRAPHICS-RESOURCE-0008"));
sl@0
    88
	INFO_PRINTF1(_L("Retrieving drawable id of an image.\r\n"));
sl@0
    89
	TestGetImageDrawableIdL();
sl@0
    90
	RecordTestResultL();
sl@0
    91
		
sl@0
    92
	SetTestStepID(_L("GRAPHICS-RESOURCE-0010"));
sl@0
    93
	INFO_PRINTF1(_L("Opening a handle to an image in both the current process and another process.\r\n"));
sl@0
    94
	TestOpenImageL();
sl@0
    95
	RecordTestResultL();
sl@0
    96
	
sl@0
    97
	SetTestStepID(_L("GRAPHICS-RESOURCE-0100"));
sl@0
    98
	INFO_PRINTF1(_L("Creating images with negative and invalid data strides.\r\n"));
sl@0
    99
	TestCreateImageDataStrideL();
sl@0
   100
	RecordTestResultL();
sl@0
   101
	
sl@0
   102
	SetTestStepID(_L("GRAPHICS-RESOURCE-0044"));
sl@0
   103
	INFO_PRINTF1(_L("Getting the available interfaces from an image.\r\n"));	
sl@0
   104
	TestGetInterfaceL();
sl@0
   105
	RecordTestResultL();
sl@0
   106
sl@0
   107
	SetTestStepID(_L("GRAPHICS-RESOURCE-0024"));
sl@0
   108
	INFO_PRINTF1(_L("Getting supported pixel formats with invalid parameters.\r\n"));
sl@0
   109
	TestGetPixelFormatsInvalidL();
sl@0
   110
	RecordTestResultL();
sl@0
   111
sl@0
   112
	SetTestStepID(_L("GRAPHICS-RESOURCE-0025"));
sl@0
   113
	INFO_PRINTF1(_L("Opening an image with different invalid parameters.\r\n"));
sl@0
   114
	TestOpenImageInvalidL();
sl@0
   115
	RecordTestResultL();
sl@0
   116
sl@0
   117
	SetTestStepID(_L("GRAPHICS-RESOURCE-0026"));
sl@0
   118
	INFO_PRINTF1(_L("Closing the handle to an image object multiple times.\r\n"));
sl@0
   119
	TestCloseImageManyTimesL();
sl@0
   120
	RecordTestResultL();
sl@0
   121
sl@0
   122
	SetTestStepID(_L("GRAPHICS-RESOURCE-0027"));
sl@0
   123
	INFO_PRINTF1(_L("Closing the handle to an image object without opening it.\r\n"));
sl@0
   124
	TestCloseImageWithoutOpenL();
sl@0
   125
	RecordTestResultL();
sl@0
   126
sl@0
   127
	SetTestStepID(_L("GRAPHICS-RESOURCE-0028"));
sl@0
   128
	INFO_PRINTF1(_L("Creating an image with various invalid parameters.\r\n"));
sl@0
   129
	TestCreateImageInvalidL();
sl@0
   130
	RecordTestResultL();
sl@0
   131
sl@0
   132
	SetTestStepID(_L("GRAPHICS-RESOURCE-0039"));
sl@0
   133
	INFO_PRINTF1(_L("Getting information about an invalid image.\r\n"));
sl@0
   134
	TestGetInfoImageInvalidL();
sl@0
   135
	RecordTestResultL();
sl@0
   136
	
sl@0
   137
	SetTestStepID(_L("GRAPHICS-RESOURCE-0092"));
sl@0
   138
	INFO_PRINTF1(_L("Getting Attributes about an invalid image.\r\n"));
sl@0
   139
	TestGetAttributesImageInvalidL();
sl@0
   140
	RecordTestResultL();
sl@0
   141
		
sl@0
   142
	SetTestStepID(_L("GRAPHICS-RESOURCE-0048"));
sl@0
   143
	INFO_PRINTF1(_L("RSgImage generic stress test.\r\n"));
sl@0
   144
	TestStress1L();
sl@0
   145
	RecordTestResultL();
sl@0
   146
	
sl@0
   147
	SetTestStepID(_L("GRAPHICS-RESOURCE-0049")); 
sl@0
   148
	INFO_PRINTF1(_L("RSgImage generic multi-thread stress test.\r\n"));
sl@0
   149
	TestStress2L();
sl@0
   150
	RecordTestResultL();
sl@0
   151
sl@0
   152
	SetTestStepID(_L("GRAPHICS-RESOURCE-0104"));
sl@0
   153
	INFO_PRINTF1(_L("Opening a RSgImage in a second process with multiple threads.\r\n"));
sl@0
   154
	TestOpenImageMultithreadedL();
sl@0
   155
	RecordTestResultL();
sl@0
   156
sl@0
   157
#ifdef _DEBUG
sl@0
   158
sl@0
   159
	SetTestStepID(_L("GRAPHICS-RESOURCE-0052"));
sl@0
   160
	INFO_PRINTF1(_L("RSgImage generic panic test - GetInterface() with non null image handle and uninitialised driver\r\n"));
sl@0
   161
	TestPanicImageGetInterfaceNoDriverL();
sl@0
   162
	RecordTestResultL();
sl@0
   163
	
sl@0
   164
	SetTestStepID(_L("GRAPHICS-RESOURCE-0054"));
sl@0
   165
	INFO_PRINTF1(_L("RSgImage generic panic test - Close() with non null image handle and uninitialised driver\r\n"));
sl@0
   166
	TestPanicImageCloseNoDriverL();
sl@0
   167
	RecordTestResultL();
sl@0
   168
	
sl@0
   169
	SetTestStepID(_L("GRAPHICS-RESOURCE-0056"));
sl@0
   170
	INFO_PRINTF1(_L("RSgImage generic panic test - Id() with non null image handle and uninitialised driver\r\n"));
sl@0
   171
	TestPanicImageIdNoDriverL();
sl@0
   172
	RecordTestResultL();
sl@0
   173
	
sl@0
   174
	SetTestStepID(_L("GRAPHICS-RESOURCE-0059"));
sl@0
   175
	INFO_PRINTF1(_L("RSgImage generic panic test - GetInfo() with non null image handle and uninitialised driver\r\n"));
sl@0
   176
	TestPanicImageGetInfoNoDriverL();
sl@0
   177
	RecordTestResultL();
sl@0
   178
	
sl@0
   179
	SetTestStepID(_L("GRAPHICS-RESOURCE-0082"));
sl@0
   180
	INFO_PRINTF1(_L("RSgImage generic panic test - Open() with an uninitialised driver\r\n"));
sl@0
   181
	TestPanicImageOpenNoDriverL();
sl@0
   182
	RecordTestResultL();
sl@0
   183
	
sl@0
   184
	SetTestStepID(_L("GRAPHICS-RESOURCE-0083"));
sl@0
   185
	INFO_PRINTF1(_L("RSgImage generic panic test - Create() from memory with an uninitialised driver\r\n"));
sl@0
   186
	TestPanicImageCreateNoDriver1L();
sl@0
   187
	RecordTestResultL();
sl@0
   188
	
sl@0
   189
	SetTestStepID(_L("GRAPHICS-RESOURCE-0084"));
sl@0
   190
	INFO_PRINTF1(_L("RSgImage generic panic test - Create() from existing image with an uninitialised driver\r\n"));
sl@0
   191
	TestPanicImageCreateNoDriver2L();
sl@0
   192
	RecordTestResultL();
sl@0
   193
	
sl@0
   194
	SetTestStepID(_L("GRAPHICS-RESOURCE-0088"));
sl@0
   195
	INFO_PRINTF1(_L("RSgImage generic panic test - DrawableType() with an uninitialised driver\r\n"));	
sl@0
   196
	TestPanicImageDrawableTypeNoDriverL();
sl@0
   197
	RecordTestResultL();
sl@0
   198
	
sl@0
   199
	INFO_PRINTF1(_L("RSgImage generic panic test - GetAttribute() with an uninitialised driver\r\n")); 
sl@0
   200
	TestPanicImageGetAttributeNoDriverL();
sl@0
   201
	RecordTestResultL();
sl@0
   202
	
sl@0
   203
	SetTestStepID(_L("GRAPHICS-RESOURCE-0097"));
sl@0
   204
	INFO_PRINTF1(_L("RSgAttributeArray generic panic test - Out of bounds array index specified\r\n"));	
sl@0
   205
	TestPanicImageAttributeArrayInvalidIndexL();
sl@0
   206
	RecordTestResultL();
sl@0
   207
	
sl@0
   208
	SetTestStepID(_L("GRAPHICS-RESOURCE-0098"));
sl@0
   209
	INFO_PRINTF1(_L("RSgAttributeArray generic panic test - Out of bounds array index specified\r\n"));	
sl@0
   210
	TestPanicImageAttributeArrayInvalidIndex2L();
sl@0
   211
	RecordTestResultL();
sl@0
   212
		
sl@0
   213
	SetTestStepID(_L("GRAPHICS-RESOURCE-0102"));
sl@0
   214
	INFO_PRINTF1(_L("RSgDriver/RSgImage multi processs Create, Open and Close test\r\n"));	
sl@0
   215
	TestCreateOpenCloseImageAndDriverInSecondThreadL();
sl@0
   216
	RecordTestResultL();
sl@0
   217
		
sl@0
   218
	SetTestStepID(_L("GRAPHICS-RESOURCE-0052"));
sl@0
   219
	INFO_PRINTF1(_L("RSgImage generic panic test - GetInterface() with invalid image handle\r\n"));
sl@0
   220
	TestPanicImageGetInterfaceInvalidHandleL();
sl@0
   221
	RecordTestResultL();
sl@0
   222
	
sl@0
   223
	SetTestStepID(_L("GRAPHICS-RESOURCE-0053"));
sl@0
   224
	INFO_PRINTF1(_L("RSgImage generic panic test - Close() with invalid image handle\r\n"));
sl@0
   225
	TestPanicImageCloseInvalidHandleL();
sl@0
   226
	RecordTestResultL();
sl@0
   227
		
sl@0
   228
	SetTestStepID(_L("GRAPHICS-RESOURCE-0055"));
sl@0
   229
	INFO_PRINTF1(_L("RSgImage generic panic test - Id() with invalid image handle\r\n"));
sl@0
   230
	TestPanicImageIdInvalidHandleL();
sl@0
   231
	RecordTestResultL();
sl@0
   232
	
sl@0
   233
	SetTestStepID(_L("GRAPHICS-RESOURCE-0057"));
sl@0
   234
	INFO_PRINTF1(_L("RSgImage generic panic test - Create() with invalid image handle\r\n"));
sl@0
   235
	TestPanicImageCreateInvalidHandleL();
sl@0
   236
	RecordTestResultL();
sl@0
   237
	
sl@0
   238
	SetTestStepID(_L("GRAPHICS-RESOURCE-0058"));
sl@0
   239
	INFO_PRINTF1(_L("RSgImage generic panic test - GetInfo() with invalid image handle\r\n"));
sl@0
   240
	TestPanicImageGetInfoInvalidHandleL();
sl@0
   241
	RecordTestResultL();
sl@0
   242
	
sl@0
   243
	SetTestStepID(_L("GRAPHICS-RESOURCE-0089"));
sl@0
   244
	INFO_PRINTF1(_L("RSgImage generic panic test - DrawableType() with invalid image handle\r\n"));	
sl@0
   245
	TestPanicImageDrawableTypeInvalidHandleL();
sl@0
   246
	RecordTestResultL();
sl@0
   247
sl@0
   248
	INFO_PRINTF1(_L("RSgImage generic panic test - GetInfo() with invalid image handle\r\n")); 
sl@0
   249
	TestPanicImageGetAttributeInvalidHandleL();
sl@0
   250
	RecordTestResultL();
sl@0
   251
sl@0
   252
	SetTestStepID(_L("GRAPHICS-RESOURCE-0101"));
sl@0
   253
	INFO_PRINTF1(_L("RSgDriver generic panic test - Closing a driver with open resources\r\n"));	
sl@0
   254
	TestPanicDriverCloseOpenResourcesL();
sl@0
   255
	RecordTestResultL();
sl@0
   256
#else
sl@0
   257
	INFO_PRINTF1(_L("Warning: Skipping the panic tests in release build. \r\n"));
sl@0
   258
#endif	
sl@0
   259
	return TestStepResult();
sl@0
   260
	}
sl@0
   261
sl@0
   262
sl@0
   263
/**
sl@0
   264
@SYMTestCaseID			GRAPHICS-RESOURCE-0003
sl@0
   265
@SYMTestCaseDesc		Gets supported pixel formats on all platforms.
sl@0
   266
@SYMPREQ				PREQ2637
sl@0
   267
@SYMFssID				RSgImage::GetPixelFormats(const TSgImageInfo&, TUidPixelFormat*, TInt&)
sl@0
   268
@SYMTestPriority		High
sl@0
   269
@SYMTestType			UT
sl@0
   270
@SYMTestPurpose			To ensure all the available pixel formats are returned 
sl@0
   271
						in the array.
sl@0
   272
@SYMTestActions			Initialise the graphics resource component.
sl@0
   273
						Construct an RArray to recieve the pixel formats.
sl@0
   274
						1. Retrieve pixel formats with an RArray<TInt>. Check the array size.
sl@0
   275
						2. Retrieve pixel formats when using an invalid usage bit value.
sl@0
   276
						3. Retrieve pixel formats supporting OpenGL ES.
sl@0
   277
						4. Retrieve pixel formats supporting OpenGL ES 2.
sl@0
   278
						5. Ensure the mandated pixel formats are available					
sl@0
   279
@SYMTestExpectedResults	The function must return:
sl@0
   280
						1. KErrNone
sl@0
   281
						2. KErrNone, but zero entries in the returned array.
sl@0
   282
						3. KErrNone, and a non-zero array size.
sl@0
   283
						4. KErrNone, and a non-zero array size.
sl@0
   284
						5. The returned pixel formats should cover the pixel formats 
sl@0
   285
						in the image compatibility table that works on all platforms.
sl@0
   286
 */
sl@0
   287
void CTSgImageGeneric::TestGetPixelFormatsL()
sl@0
   288
	{
sl@0
   289
	TestOpenDriverL();
sl@0
   290
	
sl@0
   291
	//Retrieve the pixel formats
sl@0
   292
	RArray<TInt> pixelFormatArray;
sl@0
   293
	CheckErrorL(KErrNone, RSgImage::GetPixelFormats(ESgUsageBitOpenVgImage, pixelFormatArray), (TText8*)__FILE__, __LINE__);
sl@0
   294
	TEST(pixelFormatArray.Count() > 0);
sl@0
   295
	pixelFormatArray.Reset();
sl@0
   296
sl@0
   297
	// invalid usage bit
sl@0
   298
	const TInt KInvalidUsageBit = 0x1000;
sl@0
   299
	CheckErrorL(KErrNone, RSgImage::GetPixelFormats(KInvalidUsageBit, pixelFormatArray), (TText8*)__FILE__, __LINE__);
sl@0
   300
	TEST(pixelFormatArray.Count() == 0);
sl@0
   301
	pixelFormatArray.Reset();
sl@0
   302
sl@0
   303
	//check all the pixel formats returned are in the common compatibility guarantees table
sl@0
   304
	TestGetPixelFormatCompatibilityGuaranteesL();
sl@0
   305
sl@0
   306
	TestCloseDriver();
sl@0
   307
	}
sl@0
   308
sl@0
   309
/**
sl@0
   310
@SYMTestCaseID			GRAPHICS-RESOURCE-0004
sl@0
   311
@SYMTestCaseDesc		Creates an uninitialised image.
sl@0
   312
@SYMPREQ				PREQ2637
sl@0
   313
@SYMFssID				RSgImage::Create(const TSgImageInfo&, const TAny*, TInt) 
sl@0
   314
						RSgImage::IsNull()
sl@0
   315
@SYMTestPriority		Critical
sl@0
   316
@SYMTestType			UT
sl@0
   317
@SYMTestPurpose			To ensure an uninitialised image can be created.
sl@0
   318
@SYMTestActions			Initialise the graphics resource component.
sl@0
   319
						Construct a well-defined TSgImageInfo object to work on all platforms.
sl@0
   320
						Create an image	with a NULL base address for the TSgImageInfo object.
sl@0
   321
@SYMTestExpectedResults	Create() should return KErrNone in all cases.
sl@0
   322
						The image data in the created images is uninitialised.
sl@0
   323
 */	
sl@0
   324
void CTSgImageGeneric::TestCreateImageUninitializedL()
sl@0
   325
	{	
sl@0
   326
	TestOpenDriverL();
sl@0
   327
	TSgImageInfo info;
sl@0
   328
	info.iSizeInPixels = TSize(100, 100);
sl@0
   329
	info.iUsage = ESgUsageBitOpenVgImage;
sl@0
   330
	info.iPixelFormat = EUidPixelFormatRGB_565;
sl@0
   331
	
sl@0
   332
	RSgImage image;	
sl@0
   333
	CheckErrorL(KErrNone, image.Create(info, NULL, 0), (TText8*)__FILE__, __LINE__);
sl@0
   334
	TEST(!image.IsNull());
sl@0
   335
	image.Close();
sl@0
   336
	
sl@0
   337
	TestCloseDriver();
sl@0
   338
	}
sl@0
   339
sl@0
   340
sl@0
   341
/**
sl@0
   342
@SYMTestCaseID			GRAPHICS-RESOURCE-0005
sl@0
   343
@SYMTestCaseDesc		Creates an image from a block of memory.
sl@0
   344
@SYMPREQ				PREQ2637
sl@0
   345
@SYMFssID				RSgImage::Create(const TSgImageInfo&, const TAny*, TInt) 
sl@0
   346
						RSgImage::IsNull()
sl@0
   347
@SYMTestPriority		Critical
sl@0
   348
@SYMTestType			UT
sl@0
   349
@SYMTestPurpose			To ensure images can be created from a block of memory.
sl@0
   350
@SYMTestActions			Initialise the graphics resource component.
sl@0
   351
						Construct well-defined TSgImageInfo objects that work on all platforms.
sl@0
   352
						Create a block of memory with or without initialised data.
sl@0
   353
						Then create an image with the starting address of that memory.
sl@0
   354
@SYMTestExpectedResults	The function should return KErrNone in all cases.
sl@0
   355
						The user data starting at address aDataAddress will be populated into the new image.
sl@0
   356
 */	
sl@0
   357
void CTSgImageGeneric::TestCreateImageL()
sl@0
   358
	{	
sl@0
   359
	TestOpenDriverL();
sl@0
   360
	TSgImageInfo info;
sl@0
   361
	info.iSizeInPixels = TSize(8, 8);
sl@0
   362
	info.iPixelFormat = EUidPixelFormatRGB_565;
sl@0
   363
	info.iUsage = ESgUsageBitOpenVgImage;
sl@0
   364
	
sl@0
   365
	RSgImage image;
sl@0
   366
	CheckErrorL(KErrNone, image.Create(info, KCrossImageData, KCrossImageDataStride), (TText8*)__FILE__, __LINE__);
sl@0
   367
	TEST(!image.IsNull());
sl@0
   368
	image.Close();
sl@0
   369
	
sl@0
   370
	//Ensure that it is possible to create an image of at least 2048x2048
sl@0
   371
    RSgImage image2;
sl@0
   372
    TSgImageInfo info2;
sl@0
   373
    info2.iSizeInPixels = TSize(2048, 2048);
sl@0
   374
    info2.iPixelFormat = EUidPixelFormatXRGB_8888;
sl@0
   375
    info2.iUsage = ESgUsageBitOpenVgImage;
sl@0
   376
    
sl@0
   377
    TEST(KErrNone == image2.Create(info2));
sl@0
   378
    image2.Close();
sl@0
   379
	
sl@0
   380
    info2.iSizeInPixels = TSize(KDiagonalImageSize, KDiagonalImageSize);
sl@0
   381
    // This should create an image with a green diagonal from top-left to bottom-right on white background
sl@0
   382
    TEST(KErrNone == image.Create(info2, iDiagonalImageData, KDiagonalImageDataStride));
sl@0
   383
    image.Close();
sl@0
   384
    // This should create an image with a green diagonal from top-right to bottom-left on white background
sl@0
   385
    TEST(KErrNone == image.Create(info2, iDiagonalImageData, -KDiagonalImageDataStride));
sl@0
   386
    image.Close();
sl@0
   387
    
sl@0
   388
	TestCloseDriver();
sl@0
   389
	}
sl@0
   390
sl@0
   391
/**
sl@0
   392
@SYMTestCaseID			GRAPHICS-RESOURCE-0011
sl@0
   393
@SYMTestCaseDesc		Creates an uninitialised image in all mandatory pixel formats.
sl@0
   394
@SYMPREQ				PREQ2637
sl@0
   395
@SYMFssID				RSgImage::Create(const TSgImageInfo&, const TAny*, TInt) 
sl@0
   396
@SYMTestPriority		High
sl@0
   397
@SYMTestType			UT
sl@0
   398
@SYMTestPurpose			To ensure all mandatory image pixel formats are supported.
sl@0
   399
@SYMTestActions			Initialise the graphics resource component. 
sl@0
   400
						Create an image	with a NULL base address for each mandatory pixel 
sl@0
   401
						format of Graphics Resource implementations.						
sl@0
   402
@SYMTestExpectedResults	The function should return KErrNone in all cases.
sl@0
   403
 */	
sl@0
   404
void CTSgImageGeneric::TestCreateImageAllPixelFormatsL()
sl@0
   405
	{	
sl@0
   406
	TestOpenDriverL();
sl@0
   407
sl@0
   408
	RSgImage image;
sl@0
   409
	const TSize KImageSize = TSize(8, 8);
sl@0
   410
	const TUint32 KImageUsage = ESgUsageBitOpenVgImage;
sl@0
   411
	TInt err = KErrNone;
sl@0
   412
sl@0
   413
	err = image.Create(TSgImageInfo(KImageSize, EUidPixelFormatA_8, KImageUsage), NULL, 0);
sl@0
   414
	TESTE(err == KErrNone, err);
sl@0
   415
	TEST(!image.IsNull());
sl@0
   416
	image.Close();
sl@0
   417
	
sl@0
   418
	err = image.Create(TSgImageInfo(KImageSize, EUidPixelFormatRGB_565, KImageUsage), NULL, 0);
sl@0
   419
	TESTE(err == KErrNone, err);
sl@0
   420
	TEST(!image.IsNull());
sl@0
   421
	image.Close();
sl@0
   422
	
sl@0
   423
	err = image.Create(TSgImageInfo(KImageSize, EUidPixelFormatXRGB_8888, KImageUsage), NULL, 0);
sl@0
   424
	TESTE(err == KErrNone, err);
sl@0
   425
	TEST(!image.IsNull());
sl@0
   426
	image.Close();
sl@0
   427
	
sl@0
   428
	err = image.Create(TSgImageInfo(KImageSize, EUidPixelFormatARGB_8888, KImageUsage), NULL, 0);
sl@0
   429
	TESTE(err == KErrNone, err);
sl@0
   430
	TEST(!image.IsNull());
sl@0
   431
	image.Close();
sl@0
   432
	
sl@0
   433
	err = image.Create(TSgImageInfo(KImageSize, EUidPixelFormatARGB_8888_PRE, KImageUsage), NULL, 0);
sl@0
   434
	TESTE(err == KErrNone, err);
sl@0
   435
	TEST(!image.IsNull());
sl@0
   436
	image.Close();
sl@0
   437
	
sl@0
   438
	TestCloseDriver();
sl@0
   439
	}
sl@0
   440
sl@0
   441
/**
sl@0
   442
@SYMTestCaseID			GRAPHICS-RESOURCE-0006
sl@0
   443
@SYMTestCaseDesc		Creates an image from an existing image.
sl@0
   444
@SYMPREQ				PREQ2637
sl@0
   445
@SYMFssID				RSgImage::Create(const TSgImageInfo&, const RSgImage&)
sl@0
   446
@SYMTestPriority		Critical
sl@0
   447
@SYMTestType			UT
sl@0
   448
@SYMTestPurpose			To ensure images can be created from existing images.
sl@0
   449
@SYMTestActions			Initialise the graphics resource component. 
sl@0
   450
						Create an image.
sl@0
   451
						Create another image with the attributes of this image as the TSgImageInfo.
sl@0
   452
@SYMTestExpectedResults	The function should return KErrNone.
sl@0
   453
						The new image should be identical to the old one. 
sl@0
   454
 */	
sl@0
   455
void CTSgImageGeneric::TestCreateImageFromExistingImageL()
sl@0
   456
	{
sl@0
   457
	RSgImage image1;
sl@0
   458
	RSgImage image2;
sl@0
   459
	TSgImageInfo info;
sl@0
   460
	info.iUsage = ESgUsageBitOpenVgImage;
sl@0
   461
	
sl@0
   462
	TestOpenDriverL();		
sl@0
   463
	CreateImageL(image1);
sl@0
   464
	CleanupClosePushL(image1);
sl@0
   465
	TEST(KErrNone == image1.GetInfo(info));
sl@0
   466
	
sl@0
   467
	info.iUsage = ESgUsageBitOpenVgImage;
sl@0
   468
	CheckErrorL(KErrNone, image2.Create(info, image1), (TText8*)__FILE__, __LINE__);
sl@0
   469
	CleanupClosePushL(image2);
sl@0
   470
	TSgImageInfo info2;
sl@0
   471
	TEST(KErrNone == image2.GetInfo(info2));
sl@0
   472
	TEST(CompareInfos(info, info2));
sl@0
   473
	CleanupStack::PopAndDestroy(2);
sl@0
   474
	TestCloseDriver();
sl@0
   475
	}
sl@0
   476
sl@0
   477
sl@0
   478
/**
sl@0
   479
@SYMTestCaseID			GRAPHICS-RESOURCE-0007
sl@0
   480
@SYMTestCaseDesc		Calls GetInfo on an image.
sl@0
   481
@SYMPREQ				PREQ2637
sl@0
   482
@SYMFssID				RSgImage::GetInfo(TSgImageInfo&)
sl@0
   483
@SYMTestPriority		Critical
sl@0
   484
@SYMTestType			UT
sl@0
   485
@SYMTestPurpose			To ensure the information about the image is correct.
sl@0
   486
@SYMTestActions			Initialise the graphics resource component.
sl@0
   487
						Construct a TSgImageInfo object and initialise all the member variables.
sl@0
   488
						Call GetInfo() and compare the resulting TSgImageInfo objects with previous ones.
sl@0
   489
@SYMTestExpectedResults	The function should return KErrNone.
sl@0
   490
						Information about the image object is stored in the aInfo parameter. 
sl@0
   491
						The retrieved TSgImageInfo objects should be identical to the original ones.
sl@0
   492
 */	
sl@0
   493
void CTSgImageGeneric::TestGetImageInfoL()
sl@0
   494
	{
sl@0
   495
	TestOpenDriverL();
sl@0
   496
	TSgImageInfo info;
sl@0
   497
	info.iPixelFormat = EUidPixelFormatRGB_565;
sl@0
   498
	info.iSizeInPixels = TSize(100, 100);
sl@0
   499
	info.iUsage = ESgUsageBitOpenVgImage;
sl@0
   500
	
sl@0
   501
	RSgImage image;
sl@0
   502
	CheckErrorL(KErrNone, image.Create(info, NULL, 0), (TText8*)__FILE__, __LINE__);
sl@0
   503
	CleanupClosePushL(image);
sl@0
   504
	
sl@0
   505
	TSgImageInfo info2;
sl@0
   506
	TEST(KErrNone == image.GetInfo(info2));
sl@0
   507
	TEST(CompareInfos(info, info2));
sl@0
   508
	CleanupStack::PopAndDestroy();
sl@0
   509
	
sl@0
   510
	TestCloseDriver();
sl@0
   511
	}
sl@0
   512
sl@0
   513
/**
sl@0
   514
@SYMTestCaseID			GRAPHICS-RESOURCE-0008
sl@0
   515
@SYMTestCaseDesc		Retrieves drawable id and drawable type of an image.
sl@0
   516
@SYMPREQ				PREQ2637
sl@0
   517
@SYMFssID				RSgImage::Id()
sl@0
   518
						RSgImage::DrawableType()
sl@0
   519
@SYMTestPriority		Critical
sl@0
   520
@SYMTestType			UT
sl@0
   521
@SYMTestPurpose			To ensure the globally unique drawable id of the image can be retrieved.
sl@0
   522
@SYMTestActions			Initialise the graphics resource component. Create an image. Call
sl@0
   523
						Id() to retrieve its drawable id.
sl@0
   524
@SYMTestExpectedResults	A valid drawable id should be successfully returned when the image has been opened.
sl@0
   525
                        KSgNullDrawableId should be returned if it has not; the default drawable type should
sl@0
   526
                        be KNullUid.
sl@0
   527
 */	
sl@0
   528
void CTSgImageGeneric::TestGetImageDrawableIdL()
sl@0
   529
	{	
sl@0
   530
	RSgImage image;
sl@0
   531
	TEST(KNullUid == image.DrawableType());
sl@0
   532
	TSgDrawableId id = image.Id();
sl@0
   533
	TEST(id == KSgNullDrawableId);
sl@0
   534
	TestOpenDriverL();	
sl@0
   535
	
sl@0
   536
	CreateImageL(image);
sl@0
   537
	id = image.Id();
sl@0
   538
	TEST(id != KSgNullDrawableId);	
sl@0
   539
	TEST(KSgImageTypeUid == image.DrawableType());
sl@0
   540
sl@0
   541
	image.Close();
sl@0
   542
	TestCloseDriver();
sl@0
   543
	}
sl@0
   544
sl@0
   545
/**
sl@0
   546
@SYMTestCaseID			GRAPHICS-RESOURCE-0010
sl@0
   547
@SYMTestCaseDesc		Opens a handle to an image in both the current process and another process.
sl@0
   548
@SYMPREQ				PREQ2637
sl@0
   549
@SYMFssID				RSgImage::Open(const TSgDrawableId&)
sl@0
   550
@SYMTestPriority		Critical
sl@0
   551
@SYMTestType			UT
sl@0
   552
@SYMTestPurpose			To ensure image can be opened in both a second thread in the current 
sl@0
   553
						process and another process.
sl@0
   554
@SYMTestActions			Initialise the graphics resource component. Create an image and call
sl@0
   555
                        Open() on the image in the second thread in the current process and in 
sl@0
   556
                        another process. To ensure they are correct compare their Id and attributes.
sl@0
   557
@SYMTestExpectedResults	The function must return KErrNone in all cases. 
sl@0
   558
 */	
sl@0
   559
void CTSgImageGeneric::TestOpenImageL()
sl@0
   560
	{	
sl@0
   561
	TestOpenDriverL();
sl@0
   562
	
sl@0
   563
	RSgImage image1;
sl@0
   564
	TSgImageInfo info1;
sl@0
   565
	info1.iSizeInPixels = TSize(8, 8);
sl@0
   566
	info1.iUsage = ESgUsageBitOpenVgImage;
sl@0
   567
	info1.iPixelFormat = EUidPixelFormatRGB_565;
sl@0
   568
	CheckErrorL(KErrNone, image1.Create(info1, KCrossImageData, KCrossImageDataStride), (TText8*)__FILE__, __LINE__);
sl@0
   569
	
sl@0
   570
	const TSgDrawableId id1 = image1.Id();
sl@0
   571
	
sl@0
   572
	//opening image in the current thread
sl@0
   573
	RSgImage image2;
sl@0
   574
	TEST(KErrNone == image2.Open(id1));
sl@0
   575
	TEST(image1.Id() == image2.Id());
sl@0
   576
	
sl@0
   577
	TSgImageInfo getInfo1;
sl@0
   578
	TSgImageInfo getInfo2;
sl@0
   579
	
sl@0
   580
	image1.GetInfo(getInfo1);
sl@0
   581
	image2.GetInfo(getInfo2);
sl@0
   582
	
sl@0
   583
	TEST(CompareInfos(info1, getInfo1));
sl@0
   584
	TEST(getInfo1.iPixelFormat == getInfo2.iPixelFormat
sl@0
   585
		 && getInfo1.iSizeInPixels == getInfo2.iSizeInPixels
sl@0
   586
		 && getInfo1.iUsage == getInfo2.iUsage);
sl@0
   587
	
sl@0
   588
	if (iEnableConformanceTests)
sl@0
   589
		{
sl@0
   590
		//opening image in a second thread in the current process
sl@0
   591
		TSgThreadTestInfo threadInfo(id1, info1, ESgresSecondThreadOpenImage);
sl@0
   592
		TInt testResult = 0;
sl@0
   593
		TRAPD(err, testResult = CreateSecondThreadAndDoTestL(threadInfo));
sl@0
   594
		TEST(err == KErrNone);
sl@0
   595
		TEST(testResult >= 0);
sl@0
   596
		
sl@0
   597
		// Test the results from the second thread
sl@0
   598
		TEST(testResult & EFirstTestPassed);
sl@0
   599
		TEST(testResult & ESecondTestPassed);
sl@0
   600
		TEST(testResult & EThirdTestPassed);
sl@0
   601
		TEST(testResult & EFourthTestPassed);
sl@0
   602
		TEST(testResult & EFifthTestPassed);
sl@0
   603
		TEST(testResult & ESixthTestPassed);
sl@0
   604
		TEST(testResult & ESeventhTestPassed);
sl@0
   605
		TEST(testResult & EEighthTestPassed);
sl@0
   606
			
sl@0
   607
		//opening image in a second process	
sl@0
   608
		TSgProcessTestInfo processInfo(id1, getInfo1, ESgresSecondProcessOpenImage);
sl@0
   609
		TRAP(err, testResult = CreateSecondProcessAndDoTestL(KSecondProcess, processInfo));
sl@0
   610
		TEST(err == KErrNone);
sl@0
   611
		TEST(testResult >= 0);
sl@0
   612
		
sl@0
   613
		TEST(testResult & EFirstTestPassed);	
sl@0
   614
		TEST(testResult & ESecondTestPassed);
sl@0
   615
		TEST(testResult & EThirdTestPassed);
sl@0
   616
		TEST(testResult & EFourthTestPassed);
sl@0
   617
		TEST(testResult & EFifthTestPassed);
sl@0
   618
		TEST(testResult & ESixthTestPassed);
sl@0
   619
		TEST(testResult & ESeventhTestPassed);
sl@0
   620
		}
sl@0
   621
    
sl@0
   622
	image1.Close();
sl@0
   623
	image2.Close();
sl@0
   624
	
sl@0
   625
	TestCloseDriver();
sl@0
   626
	}
sl@0
   627
sl@0
   628
/**
sl@0
   629
Fake RSgImage extension interface used in negative RSgImage::GetInterface() Tests
sl@0
   630
 */
sl@0
   631
class MFake
sl@0
   632
    {
sl@0
   633
public:
sl@0
   634
    enum { EInterfaceUid = 0x88888888 };
sl@0
   635
    };
sl@0
   636
sl@0
   637
class MFakeNullUid
sl@0
   638
    {
sl@0
   639
public:
sl@0
   640
    enum { EInterfaceUid = KNullUidValue};
sl@0
   641
    };
sl@0
   642
sl@0
   643
/**
sl@0
   644
@SYMTestCaseID			GRAPHICS-RESOURCE-0044
sl@0
   645
@SYMTestCaseDesc		Gets an invalid/unsupported image extension interface
sl@0
   646
@SYMPREQ				PREQ2637
sl@0
   647
@SYMFssID				RSgImage::Create(const TSgImageInfo&, const TAny*, TInt) 
sl@0
   648
						RSgImage::GetInterface()
sl@0
   649
@SYMTestPriority		Low
sl@0
   650
@SYMTestType			UT
sl@0
   651
@SYMTestPurpose			Negative test to ensure the correct error code is returned when attempting
sl@0
   652
						to retrieve an invalid RSgImage extension interface.
sl@0
   653
@SYMTestActions			Initialise the graphics resource component. Create an image. 
sl@0
   654
						1. Declare an unsupported interface MFake and pass to GetInterface().
sl@0
   655
						2. Declare an interface MFakeNullUid which has a null uid and pass to GetInterface().
sl@0
   656
@SYMTestExpectedResults	1. GetInterface() should return KErrExtensionNotSupported.
sl@0
   657
						2. GetInterface() should return KErrArgument since null uids are not acceptable.
sl@0
   658
 */
sl@0
   659
void CTSgImageGeneric::TestGetInterfaceL()
sl@0
   660
	{
sl@0
   661
	TestOpenDriverL();
sl@0
   662
	
sl@0
   663
	TSgImageInfo info;
sl@0
   664
	info.iSizeInPixels = TSize(8, 8);
sl@0
   665
	info.iUsage = ESgUsageBitOpenVgImage;
sl@0
   666
	info.iPixelFormat = EUidPixelFormatRGB_565;
sl@0
   667
	
sl@0
   668
	RSgImage image;	
sl@0
   669
	
sl@0
   670
	//fake interface
sl@0
   671
	MFake* smFake = reinterpret_cast<MFake*>(1);	
sl@0
   672
	MFake* smFake2 = reinterpret_cast<MFake*>(1);
sl@0
   673
	
sl@0
   674
	//Check Calls to Get Interface on Null Image Handle
sl@0
   675
	TEST(KErrBadHandle == image.GetInterface(smFake));
sl@0
   676
	TEST(KErrBadHandle == image.GetInterface(smFake2));
sl@0
   677
	TEST(!smFake);
sl@0
   678
	TEST(!smFake2);
sl@0
   679
	
sl@0
   680
	CheckErrorL(KErrNone, image.Create(info, NULL, 0), (TText8*)__FILE__, __LINE__);
sl@0
   681
	
sl@0
   682
	// check TSgDrawableId is not NULL
sl@0
   683
	TSgDrawableId id = image.Id();
sl@0
   684
	TEST(KSgNullDrawableId != id);
sl@0
   685
sl@0
   686
	smFake = reinterpret_cast<MFake*>(1);	
sl@0
   687
	smFake2 = reinterpret_cast<MFake*>(1);
sl@0
   688
sl@0
   689
	TEST(KErrExtensionNotSupported == image.GetInterface(smFake));
sl@0
   690
	TEST(!smFake);
sl@0
   691
	
sl@0
   692
	TEST(KErrExtensionNotSupported == image.GetInterface(smFake2));
sl@0
   693
	TEST(!smFake2);
sl@0
   694
	
sl@0
   695
	// null interface uid
sl@0
   696
	MFakeNullUid* smFake3 = NULL;
sl@0
   697
	TEST(KErrArgument == image.GetInterface(smFake3));
sl@0
   698
	TEST(!smFake3);
sl@0
   699
sl@0
   700
	image.Close();
sl@0
   701
	
sl@0
   702
	TestCloseDriver();
sl@0
   703
	}
sl@0
   704
sl@0
   705
/**
sl@0
   706
@SYMTestCaseID			GRAPHICS-RESOURCE-0024
sl@0
   707
@SYMTestCaseDesc		Gets supported pixel formats with invalid parameters.
sl@0
   708
@SYMPREQ				PREQ2637
sl@0
   709
@SYMFssID				RSgImage::GetPixelFormats(TUint32, RArray<TInt>, 
sl@0
   710
						const TSgAttributeArrayBase*)
sl@0
   711
@SYMTestPriority		Low
sl@0
   712
@SYMTestType			UT
sl@0
   713
@SYMTestPurpose			Negative test to ensure the correct error messages are returned when user tries to
sl@0
   714
						call GetPixelFormats() with invalid parameters.
sl@0
   715
@SYMTestActions			Initialise the graphics resource component. Call RSgImage::GetPixelFormats with:
sl@0
   716
						1. Usage of 0
sl@0
   717
						2. Invalid attribute array
sl@0
   718
						3. Valid arguments
sl@0
   719
						4. Pixel formats array is not empty
sl@0
   720
@SYMTestExpectedResults	RSgImage::GetPixelFormats() should return:
sl@0
   721
						1. KErrArgument
sl@0
   722
						2. KErrNotSupported
sl@0
   723
						3. KErrNone
sl@0
   724
						4. KErrArgument
sl@0
   725
 */	
sl@0
   726
void CTSgImageGeneric::TestGetPixelFormatsInvalidL()
sl@0
   727
	{
sl@0
   728
	RArray<TInt> pixelFormats;
sl@0
   729
	CleanupClosePushL(pixelFormats);
sl@0
   730
	TSgAttributeArray<1> attribArray;
sl@0
   731
	attribArray[0].iUid = KNullUid;
sl@0
   732
	attribArray[0].iValue = 0;
sl@0
   733
	TEST(attribArray.Count() == 1);
sl@0
   734
	
sl@0
   735
	TestOpenDriverL();
sl@0
   736
sl@0
   737
	TEST(KErrArgument == RSgImage::GetPixelFormats(0, pixelFormats));
sl@0
   738
	pixelFormats.Reset();
sl@0
   739
		
sl@0
   740
	TEST(KErrNotSupported == RSgImage::GetPixelFormats(ESgUsageBitOpenVgImage, pixelFormats, &attribArray));
sl@0
   741
	pixelFormats.Reset();
sl@0
   742
	
sl@0
   743
	TEST(KErrNone == RSgImage::GetPixelFormats(ESgUsageBitOpenVgImage, pixelFormats));
sl@0
   744
	TEST(pixelFormats.Count() > 0);
sl@0
   745
	//Don't reset pixel formats for next test
sl@0
   746
	
sl@0
   747
	TEST(KErrArgument == RSgImage::GetPixelFormats(ESgUsageBitOpenVgImage, pixelFormats));
sl@0
   748
	pixelFormats.Reset();
sl@0
   749
	
sl@0
   750
	TestCloseDriver();
sl@0
   751
	CleanupStack::PopAndDestroy(&pixelFormats);
sl@0
   752
	}
sl@0
   753
sl@0
   754
/**
sl@0
   755
@SYMTestCaseID			GRAPHICS-RESOURCE-0025
sl@0
   756
@SYMTestCaseDesc		Opens an image with different invalid and valid parameters.
sl@0
   757
@SYMPREQ				PREQ2637
sl@0
   758
@SYMFssID				RSgImage::Open(const TSgDrawableId&)
sl@0
   759
@SYMTestPriority		Medium
sl@0
   760
@SYMTestType			UT
sl@0
   761
@SYMTestPurpose			Negative test to check correct error messages are returned when opening 
sl@0
   762
						image with different invalid parameters.
sl@0
   763
@SYMTestActions			Initialise the graphics resource component. Construct an RSgImage object. 
sl@0
   764
						Call the Open() function in both the current process and another process with:
sl@0
   765
						1. a non-null RSgImage handle
sl@0
   766
						2. null drawable id
sl@0
   767
						3. fake drawable id
sl@0
   768
						4. a valid RSgImage handle
sl@0
   769
						Do the same tests in a second thread and a second process.
sl@0
   770
@SYMTestExpectedResults	The function should return:
sl@0
   771
						1. KErrInUse
sl@0
   772
						2. KErrArgument
sl@0
   773
						3. KErrNotFound
sl@0
   774
						4. KErrNone
sl@0
   775
 */	
sl@0
   776
void CTSgImageGeneric::TestOpenImageInvalidL()
sl@0
   777
	{	
sl@0
   778
	TestOpenDriverL();
sl@0
   779
	//create a non-sharable image
sl@0
   780
	TSgImageInfo info;
sl@0
   781
	info.iSizeInPixels = TSize(8, 8);
sl@0
   782
	info.iUsage = ESgUsageBitOpenVgImage;
sl@0
   783
	info.iPixelFormat = EUidPixelFormatRGB_565;
sl@0
   784
	
sl@0
   785
	RSgImage image;
sl@0
   786
	CheckErrorL(KErrNone, image.Create(info, KCrossImageData, KCrossImageDataStride), (TText8*)__FILE__, __LINE__);
sl@0
   787
	CleanupClosePushL(image);
sl@0
   788
	const TSgDrawableId id = image.Id();
sl@0
   789
	
sl@0
   790
	//Attempt to create the image again using the same object
sl@0
   791
	TEST(KErrInUse ==  image.Create(info, KCrossImageData, KCrossImageDataStride));
sl@0
   792
	
sl@0
   793
	//same thread
sl@0
   794
	//  non-empty handle
sl@0
   795
	RSgImage image1;
sl@0
   796
	CreateImageL(image1);
sl@0
   797
	CleanupClosePushL(image1);
sl@0
   798
	TEST(KErrInUse == image1.Open(id));
sl@0
   799
	image1.Close();
sl@0
   800
	
sl@0
   801
	//  non-existing drawable id
sl@0
   802
	TSgDrawableId fakeid = {0xFFFFFFFFFFFFFFFFU};
sl@0
   803
	CheckErrorL(KErrNotFound, image1.Open(fakeid), (TText8*)__FILE__, __LINE__);
sl@0
   804
	image1.Close();
sl@0
   805
	
sl@0
   806
	if (iEnableConformanceTests)
sl@0
   807
		{
sl@0
   808
		//different thread in the same process
sl@0
   809
		TSgThreadTestInfo threadInfo(id, info, ESgresSecondThreadOpenImageInvalid);
sl@0
   810
		TInt testResult = 0;
sl@0
   811
		TRAPD(err, testResult = CreateSecondThreadAndDoTestL(threadInfo));
sl@0
   812
		TEST(testResult >= 0);
sl@0
   813
		// Test the results from the second thread
sl@0
   814
		TEST(testResult & EFirstTestPassed);
sl@0
   815
		TEST(testResult & ESecondTestPassed);
sl@0
   816
		TEST(testResult & EThirdTestPassed);
sl@0
   817
		TEST(testResult & EFourthTestPassed);
sl@0
   818
		TEST(testResult & EFifthTestPassed);
sl@0
   819
		
sl@0
   820
		//different process	
sl@0
   821
		TSgProcessTestInfo processInfo(id, info, ESgresSecondProcessOpenImageInvalid);
sl@0
   822
		TRAP(err, testResult = CreateSecondProcessAndDoTestL(KSecondProcess, processInfo));
sl@0
   823
		TEST(testResult >= 0);
sl@0
   824
		TEST(testResult & EFirstTestPassed);	
sl@0
   825
		TEST(testResult & ESecondTestPassed);
sl@0
   826
		TEST(testResult & EThirdTestPassed);
sl@0
   827
		TEST(testResult & EFourthTestPassed);
sl@0
   828
		TEST(testResult & EFifthTestPassed);
sl@0
   829
		}
sl@0
   830
		
sl@0
   831
	CleanupStack::PopAndDestroy(2);
sl@0
   832
	TestCloseDriver();
sl@0
   833
	}
sl@0
   834
sl@0
   835
/**
sl@0
   836
@SYMTestCaseID			GRAPHICS-RESOURCE-0026
sl@0
   837
@SYMTestCaseDesc		Closes an image multiple times.
sl@0
   838
@SYMPREQ				PREQ2637
sl@0
   839
@SYMFssID				RSgImage::Close()
sl@0
   840
@SYMTestPriority		High
sl@0
   841
@SYMTestType			UT
sl@0
   842
@SYMTestPurpose			To check calling Close() multiple times after Open() does not cause
sl@0
   843
						errors or panics.
sl@0
   844
@SYMTestActions			Initialise the graphics resource component. Create an image and then
sl@0
   845
						call Close() three times on it.
sl@0
   846
@SYMTestExpectedResults	The function should not cause any errors or panics.
sl@0
   847
 */
sl@0
   848
void CTSgImageGeneric::TestCloseImageManyTimesL()
sl@0
   849
	{
sl@0
   850
	TestOpenDriverL();
sl@0
   851
	RSgImage image;
sl@0
   852
	CreateImageL(image);
sl@0
   853
	TEST(!image.IsNull());
sl@0
   854
	
sl@0
   855
	image.Close();
sl@0
   856
	TEST(image.IsNull());
sl@0
   857
	image.Close();
sl@0
   858
	TEST(image.IsNull());
sl@0
   859
	image.Close();
sl@0
   860
	TEST(image.IsNull());
sl@0
   861
	
sl@0
   862
	TestCloseDriver();
sl@0
   863
	}
sl@0
   864
sl@0
   865
sl@0
   866
/**
sl@0
   867
@SYMTestCaseID			GRAPHICS-RESOURCE-0027
sl@0
   868
@SYMTestCaseDesc		Closes an image object without opening it.
sl@0
   869
@SYMPREQ				PREQ2637
sl@0
   870
@SYMFssID				RSgImage::Close()
sl@0
   871
@SYMTestPriority		Medium
sl@0
   872
@SYMTestType			UT
sl@0
   873
@SYMTestPurpose			To check Close() does nothing if the image is not already opened.
sl@0
   874
@SYMTestActions			Initialise the graphics resource component. Declare an RSgImage object and
sl@0
   875
						call Close() on it.
sl@0
   876
@SYMTestExpectedResults	The function should not cause any errors or panics.
sl@0
   877
 */	
sl@0
   878
void CTSgImageGeneric::TestCloseImageWithoutOpenL()
sl@0
   879
	{	
sl@0
   880
	TestOpenDriverL();
sl@0
   881
	RSgImage image;
sl@0
   882
	TEST(image.IsNull());
sl@0
   883
	image.Close();
sl@0
   884
	TEST(image.IsNull());
sl@0
   885
	TestCloseDriver();
sl@0
   886
	}
sl@0
   887
sl@0
   888
/**
sl@0
   889
@SYMTestCaseID			GRAPHICS-RESOURCE-0028
sl@0
   890
@SYMTestCaseDesc		Creates an image with various invalid parameters.
sl@0
   891
@SYMPREQ				PREQ2637
sl@0
   892
@SYMFssID				RSgImage::Create(const TSgImageInfo&, const TAny*, TInt, const TSgAttributeArrayBase* = NULL)
sl@0
   893
						RSgImage::Create(const TSgImageInfo&, const RSgImage&, const TSgAttributeArrayBase* = NULL)
sl@0
   894
@SYMTestPriority		Medium
sl@0
   895
@SYMTestType			UT
sl@0
   896
@SYMTestPurpose			Negative test to check the function returns the correct error messages when 
sl@0
   897
						the parameters are invalid.
sl@0
   898
@SYMTestActions			Initialise the graphics resource component. Construct a TSgImageInfo object 
sl@0
   899
						and initialise the all the member variables with random values. Call the appropriate 
sl@0
   900
						Create() function with:
sl@0
   901
						1. invalid TSgImageInfo.iSizeInPixels
sl@0
   902
						2. unsupported TSgImageInfo Pixel Format
sl@0
   903
						3. the creating RSgImage handle is not null
sl@0
   904
						4. the aSgImage handle is null
sl@0
   905
						5. the size and pixel format in TSgImageInfo is not the same as that of aSgImage
sl@0
   906
						6. the pixel stride specified is 0 when bitmap data is given
sl@0
   907
@SYMTestExpectedResults	The function should return
sl@0
   908
						1. KErrArgument or KErrNotSupported for the overload taking an RSgImage
sl@0
   909
						2. KErrNotSupported
sl@0
   910
						3. KErrInUse
sl@0
   911
						4. KErrArgument
sl@0
   912
						5. KErrNotSupported
sl@0
   913
						6. KErrArgument
sl@0
   914
 */	
sl@0
   915
void CTSgImageGeneric::TestCreateImageInvalidL()
sl@0
   916
	{
sl@0
   917
	TestOpenDriverL();
sl@0
   918
	RSgImage image;
sl@0
   919
	
sl@0
   920
	RSgImage validImage;
sl@0
   921
	TSgImageInfo validInfo(TSize(8,8), EUidPixelFormatRGB_565, ESgUsageBitOpenVgImage);
sl@0
   922
	TEST(KErrNone == validImage.Create(validInfo, KCrossImageData, KCrossImageDataStride));
sl@0
   923
	
sl@0
   924
	//invalid info 1 - invalid width
sl@0
   925
	TSgImageInfo info1(TSize(-100,100), EUidPixelFormatRGB_565, ESgUsageBitOpenVgImage);
sl@0
   926
	TEST(KErrArgument == image.Create(info1, NULL, 0));
sl@0
   927
	image.Close();
sl@0
   928
	TEST(KErrArgument == image.Create(info1, KCrossImageData, KCrossImageDataStride));
sl@0
   929
	image.Close();
sl@0
   930
	//invalid height
sl@0
   931
	info1.iSizeInPixels = TSize(100, -100);
sl@0
   932
	TEST(KErrArgument == image.Create(info1, NULL, 0));
sl@0
   933
	image.Close();
sl@0
   934
	//Sizes don't match
sl@0
   935
	TEST(KErrNotSupported == image.Create(info1, validImage));
sl@0
   936
	image.Close();
sl@0
   937
	
sl@0
   938
	info1.iSizeInPixels = TSize(0,0);
sl@0
   939
    TEST(KErrArgument == image.Create(info1, NULL, 0));
sl@0
   940
    image.Close();
sl@0
   941
	TEST(KErrArgument == image.Create(info1, KCrossImageData, KCrossImageDataStride));
sl@0
   942
	image.Close();
sl@0
   943
	//Sizes don't match
sl@0
   944
	TEST(KErrNotSupported == image.Create(info1, validImage));
sl@0
   945
	image.Close();
sl@0
   946
	
sl@0
   947
	//Invalid usage
sl@0
   948
	info1.iUsage = KMaxTUint32;
sl@0
   949
	info1.iSizeInPixels = TSize(8,8);
sl@0
   950
	TEST(KErrNotSupported == image.Create(info1, KCrossImageData, KCrossImageDataStride));
sl@0
   951
	image.Close();
sl@0
   952
	TEST(KErrNotSupported == image.Create(info1, validImage));
sl@0
   953
	image.Close();
sl@0
   954
	
sl@0
   955
	//unsupported info 1 - invalid pixel format
sl@0
   956
	TSgImageInfo info2;
sl@0
   957
	info2.iSizeInPixels = TSize(8, 8);
sl@0
   958
	info2.iUsage = ESgUsageBitOpenVgImage;
sl@0
   959
	info2.iPixelFormat = EUidPixelFormatUnknown;
sl@0
   960
	TEST(KErrArgument == image.Create(info2, NULL, 0));
sl@0
   961
	image.Close();
sl@0
   962
	TEST(KErrArgument == image.Create(info2, KCrossImageData, KCrossImageDataStride));
sl@0
   963
	image.Close();
sl@0
   964
		
sl@0
   965
	//unsupported info 2 - large image size
sl@0
   966
	info2.iPixelFormat = ESgPixelFormatRGB_565;
sl@0
   967
	info2.iSizeInPixels = TSize(40000, 100);
sl@0
   968
	TEST(KErrTooBig == image.Create(info2, NULL, 0));
sl@0
   969
	info2.iSizeInPixels = TSize(100, 40000);
sl@0
   970
	TEST(KErrTooBig == image.Create(info2, NULL, 0));
sl@0
   971
	image.Close();
sl@0
   972
	
sl@0
   973
	//non-null handle
sl@0
   974
	CreateImageL(image);
sl@0
   975
	TSgImageInfo info3;
sl@0
   976
	info3.iSizeInPixels = TSize(8, 8);
sl@0
   977
	info3.iUsage = ESgUsageBitOpenVgImage;
sl@0
   978
	info3.iPixelFormat = ESgPixelFormatRGB_565;
sl@0
   979
sl@0
   980
	TInt ret = image.Create(info3, NULL, 16);	
sl@0
   981
	TEST(KErrInUse == ret);
sl@0
   982
	
sl@0
   983
	//non-null handle: create from an existing image
sl@0
   984
	RSgImage image1;
sl@0
   985
	CreateImageL(image1);
sl@0
   986
	TEST(KErrInUse == image1.Create(info3, image));
sl@0
   987
	image1.Close();
sl@0
   988
	
sl@0
   989
	//null existing image handle
sl@0
   990
	RSgImage image2;
sl@0
   991
	TEST(image2.IsNull());
sl@0
   992
	TEST(KErrArgument == image1.Create(info3, image2));
sl@0
   993
	
sl@0
   994
	//the size and pixel format in TSgImageInfo is not the same as that of aSgImage
sl@0
   995
	TSgImageInfo info4(TSize(100,100), ESgPixelFormatARGB_8888, ESgUsageBitOpenVgImage);
sl@0
   996
	TEST(KErrNotSupported == image1.Create(info4, image));
sl@0
   997
	
sl@0
   998
	image1.GetInfo(info3);
sl@0
   999
	info4.iSizeInPixels = info3.iSizeInPixels;
sl@0
  1000
	info4.iPixelFormat = ESgPixelFormatXRGB_8888;
sl@0
  1001
	TEST(KErrNotSupported == image1.Create(info4, image));
sl@0
  1002
	
sl@0
  1003
	image.Close();
sl@0
  1004
	image1.Close();
sl@0
  1005
	
sl@0
  1006
	TSgImageInfo info5(TSize(8,8),  ESgPixelFormatRGB_565, ESgUsageBitOpenVgImage);
sl@0
  1007
	
sl@0
  1008
	TSgAttributeArray<1> attribArray;
sl@0
  1009
	attribArray[0].iUid = KNullUid;
sl@0
  1010
	attribArray[0].iValue = 0;
sl@0
  1011
	
sl@0
  1012
	TEST(KErrNotSupported == image1.Create(info5, KCrossImageData, KCrossImageDataStride, &attribArray));
sl@0
  1013
	image1.Close();
sl@0
  1014
	
sl@0
  1015
	//Stride of 0
sl@0
  1016
	TEST(KErrArgument == image1.Create(info5, KCrossImageData, 0));
sl@0
  1017
	image1.Close();
sl@0
  1018
	
sl@0
  1019
	validImage.Close();
sl@0
  1020
	
sl@0
  1021
	TestCloseDriver();
sl@0
  1022
	}
sl@0
  1023
sl@0
  1024
/**
sl@0
  1025
@SYMTestCaseID			GRAPHICS-RESOURCE-0039
sl@0
  1026
@SYMTestCaseDesc		Calls GetInfo() on an invalid image.
sl@0
  1027
@SYMPREQ				PREQ2637
sl@0
  1028
@SYMFssID				RSgImage::GetInfo(TSgImageInfo&)
sl@0
  1029
@SYMTestPriority		Low
sl@0
  1030
@SYMTestType			UT
sl@0
  1031
@SYMTestPurpose			Negative test to check the correct error is returned when the client 
sl@0
  1032
						tries to get information on an invalid image.
sl@0
  1033
@SYMTestActions			Initialise the graphics resource component.
sl@0
  1034
						Call GetInfo() on an image that is not initialised.
sl@0
  1035
@SYMTestExpectedResults	GetInfo() should return KErrBadHandle
sl@0
  1036
 */	
sl@0
  1037
void CTSgImageGeneric::TestGetInfoImageInvalidL()
sl@0
  1038
	{
sl@0
  1039
	TestOpenDriverL();	
sl@0
  1040
	RSgImage image;
sl@0
  1041
	TSgImageInfo info(TSize(5,5), ESgPixelFormatARGB_8888, ESgUsageBitOpenVgImage);
sl@0
  1042
	
sl@0
  1043
	//uninitialised image
sl@0
  1044
	TEST(KErrBadHandle == image.GetInfo(info));
sl@0
  1045
sl@0
  1046
	TestCloseDriver();
sl@0
  1047
	}
sl@0
  1048
sl@0
  1049
/**
sl@0
  1050
@SYMTestCaseID			GRAPHICS-RESOURCE-0092
sl@0
  1051
@SYMTestCaseDesc		Calls GetAttribute() on an invalid image.
sl@0
  1052
@SYMPREQ				PREQ2637
sl@0
  1053
@SYMFssID				RSgImage::GetAttribute(TUid, TInt&)
sl@0
  1054
@SYMTestPriority		Low
sl@0
  1055
@SYMTestType			UT
sl@0
  1056
@SYMTestPurpose			Negative test to check the correct error is returned when the client
sl@0
  1057
						tries to get attributes on an invalid image.
sl@0
  1058
@SYMTestActions			Initialise the graphics resource component. 
sl@0
  1059
						Call GetInfo on an image that is not initialised.
sl@0
  1060
@SYMTestExpectedResults	GetAttribute() should return KErrBadHandle
sl@0
  1061
 */	
sl@0
  1062
void CTSgImageGeneric::TestGetAttributesImageInvalidL()
sl@0
  1063
	{
sl@0
  1064
	TestOpenDriverL();	
sl@0
  1065
	RSgImage image;
sl@0
  1066
	TSgImageInfo info(TSize(5,5), ESgPixelFormatARGB_8888, ESgUsageBitOpenVgImage);
sl@0
  1067
	
sl@0
  1068
	TUid uid = {0x12345678};
sl@0
  1069
	TInt val = 0;
sl@0
  1070
	TEST(KErrBadHandle == image.GetAttribute(uid, val));
sl@0
  1071
	
sl@0
  1072
	image.Close();
sl@0
  1073
	
sl@0
  1074
	TestCloseDriver();
sl@0
  1075
	}
sl@0
  1076
sl@0
  1077
/**
sl@0
  1078
@SYMTestCaseID			GRAPHICS-RESOURCE-0100
sl@0
  1079
@SYMTestCaseDesc		Creates images using negative and invalid data strides.
sl@0
  1080
@SYMPREQ				PREQ2637
sl@0
  1081
@SYMFssID				RSgImage::Create(TUid, TInt&)
sl@0
  1082
@SYMTestPriority		Medium
sl@0
  1083
@SYMTestType			UT
sl@0
  1084
@SYMTestPurpose			Positive test for using negative data strides.
sl@0
  1085
						Negative test for using invalid data strides.
sl@0
  1086
@SYMTestActions			Initialise the graphics resource component. 
sl@0
  1087
						1. Create an image with a data stride that is smaller than the width 
sl@0
  1088
						of the image.
sl@0
  1089
						2. Create an image with a pointer to bitmap data, but 0 data stride.
sl@0
  1090
						3. Create an image with a negative data stride equal to the width 
sl@0
  1091
						of the image.
sl@0
  1092
						4. Create an image with a negative data stride less than the width 
sl@0
  1093
						of the image.
sl@0
  1094
@SYMTestExpectedResults	1. Create() should return KErrArgument.
sl@0
  1095
						2. Create() should return KErrArgument.
sl@0
  1096
						3. Create() should successfully create the image and return KErrNone.
sl@0
  1097
						4. Create() should return KErrArgument.
sl@0
  1098
 */
sl@0
  1099
void CTSgImageGeneric::TestCreateImageDataStrideL()
sl@0
  1100
	{
sl@0
  1101
	TestOpenDriverL();
sl@0
  1102
	
sl@0
  1103
	RSgImage image;
sl@0
  1104
	TSgImageInfo info1(TSize(8,8), EUidPixelFormatRGB_565, ESgUsageBitOpenVgImage);
sl@0
  1105
sl@0
  1106
	TEST(KErrArgument == image.Create(info1, KCrossImageData, KCrossImageDataStride-1));
sl@0
  1107
	image.Close();
sl@0
  1108
	TEST(KErrArgument == image.Create(info1, KCrossImageData, 0));
sl@0
  1109
	image.Close();
sl@0
  1110
	
sl@0
  1111
	TEST(KErrNone == image.Create(info1, KCrossImageData, -KCrossImageDataStride));
sl@0
  1112
	image.Close();
sl@0
  1113
	
sl@0
  1114
	TEST(KErrArgument == image.Create(info1, KCrossImageData, -KCrossImageDataStride+1));
sl@0
  1115
	image.Close();
sl@0
  1116
sl@0
  1117
	TestCloseDriver();
sl@0
  1118
	}
sl@0
  1119
sl@0
  1120
/**
sl@0
  1121
@SYMTestCaseID			GRAPHICS-RESOURCE-0048
sl@0
  1122
@SYMTestCaseDesc		RSgImage stress tests
sl@0
  1123
@SYMPREQ				PREQ2637
sl@0
  1124
@SYMFssID				RSgImage::Create(const TSgImageInfo&, const TAny*, TInt)
sl@0
  1125
						RSgImage::Close() 
sl@0
  1126
@SYMTestPriority		Medium
sl@0
  1127
@SYMTestType			CT
sl@0
  1128
@SYMTestPurpose			To ensure creating and destroying RSgImage multiple times work well.
sl@0
  1129
@SYMTestActions			Create images 1000 times but only store KMaxImagesInArray of them 
sl@0
  1130
						at one time in an RArray. When a new image is to be added to the 
sl@0
  1131
						array, a random image from the array is removed.
sl@0
  1132
@SYMTestExpectedResults	There should be no panics or leaves.
sl@0
  1133
 */
sl@0
  1134
void CTSgImageGeneric::TestStress1L()
sl@0
  1135
	{
sl@0
  1136
	TestOpenDriverL();
sl@0
  1137
	TSgImageInfo info;
sl@0
  1138
	info.iPixelFormat = EUidPixelFormatRGB_565;
sl@0
  1139
	info.iSizeInPixels = TSize(100, 100);
sl@0
  1140
	info.iUsage = ESgUsageBitOpenVgImage;
sl@0
  1141
	
sl@0
  1142
	TInt KMaxImagesInArray =40;
sl@0
  1143
	TInt64 seed = 0;
sl@0
  1144
	for (TInt count = 1000; count > 0; --count)
sl@0
  1145
		{
sl@0
  1146
		RSgImage image;
sl@0
  1147
		CheckErrorL(KErrNone, image.Create(info, NULL, 0), (TText8*)__FILE__, __LINE__);
sl@0
  1148
		CleanupClosePushL(image);
sl@0
  1149
		iTestImages.AppendL(image);
sl@0
  1150
		CleanupStack::Pop();
sl@0
  1151
		if (iTestImages.Count() >= KMaxImagesInArray)
sl@0
  1152
			{
sl@0
  1153
			TInt i = Math::Rand(seed) % KMaxImagesInArray;
sl@0
  1154
			iTestImages[i].Close();
sl@0
  1155
			iTestImages.Remove(i);
sl@0
  1156
			}
sl@0
  1157
		}
sl@0
  1158
	TInt count = iTestImages.Count();
sl@0
  1159
	for(TInt i=0; i<count; ++i)
sl@0
  1160
		{
sl@0
  1161
		iTestImages[i].Close();
sl@0
  1162
		}	
sl@0
  1163
	iTestImages.Reset();
sl@0
  1164
	TestCloseDriver();
sl@0
  1165
	}
sl@0
  1166
sl@0
  1167
/**
sl@0
  1168
@SYMTestCaseID			GRAPHICS-RESOURCE-0049
sl@0
  1169
@SYMTestCaseDesc		RSgImage multiple threads open and close stress tests
sl@0
  1170
@SYMPREQ				PREQ2637
sl@0
  1171
@SYMFssID				RSgImage::Open(const TSgDrawableId&)
sl@0
  1172
						RSgImage::Close() 
sl@0
  1173
@SYMTestPriority		Medium
sl@0
  1174
@SYMTestType			CT
sl@0
  1175
@SYMTestPurpose			To ensure opening and destroying RSgImage multiple times and randomly
sl@0
  1176
						in other threads work well.
sl@0
  1177
@SYMTestActions			Create an image in the main thread. In a loop of 1000 times, randomly select
sl@0
  1178
						one of the five threads and either open or close the image depending on the 
sl@0
  1179
						state of the thread.
sl@0
  1180
@SYMTestExpectedResults	There should be no panics or leaves.
sl@0
  1181
 */
sl@0
  1182
void CTSgImageGeneric::TestStress2L()
sl@0
  1183
	{
sl@0
  1184
	TestOpenDriverL();
sl@0
  1185
	RSgImage image;
sl@0
  1186
	CreateImageL(image);
sl@0
  1187
	CleanupClosePushL(image);
sl@0
  1188
	const TSgDrawableId id = image.Id();
sl@0
  1189
	
sl@0
  1190
	TSgImageInfo info;
sl@0
  1191
	TEST(KErrNone == image.GetInfo(info));
sl@0
  1192
	TSgThreadTestInfo threadInfo(id, info, ESgresMultipleThreadStressTest);
sl@0
  1193
	
sl@0
  1194
	//create a semaphore
sl@0
  1195
	RSemaphore sem;
sl@0
  1196
	User::LeaveIfError(sem.CreateGlobal(KSecondThreadSemaphore, 0, EOwnerThread));
sl@0
  1197
	CleanupClosePushL(sem);
sl@0
  1198
	
sl@0
  1199
	//create threads
sl@0
  1200
	const TInt KNoOfThreads = 5;
sl@0
  1201
	RArray<RThread> threads;
sl@0
  1202
	_LIT(KMultipleThreadName, "Multiple Threads Stress Test Thread ");
sl@0
  1203
	for (TInt i = 0; i < KNoOfThreads; ++i)
sl@0
  1204
		{
sl@0
  1205
		TBuf<50> threadName(KMultipleThreadName);
sl@0
  1206
		threadName.AppendNum(i);
sl@0
  1207
		RThread thread;
sl@0
  1208
		User::LeaveIfError(thread.Create(threadName, SgTestSecondThread::ThreadStart, KDefaultStackSize, KSecondThreadMinHeapSize, KSecondThreadMaxHeapSize, &threadInfo));
sl@0
  1209
		thread.SetPriority(EPriorityLess);
sl@0
  1210
		threads.AppendL(thread);
sl@0
  1211
		}
sl@0
  1212
	// run threads
sl@0
  1213
	for (TInt i = 0; i < KNoOfThreads; ++i)
sl@0
  1214
		{
sl@0
  1215
		threads[i].Resume();
sl@0
  1216
		}
sl@0
  1217
	// wait for the threads to terminate processing
sl@0
  1218
	for (TInt i = 0; i < KNoOfThreads; ++i)
sl@0
  1219
		{
sl@0
  1220
		sem.Wait();
sl@0
  1221
		}
sl@0
  1222
	for (TInt i = 0; i < KNoOfThreads; ++i)
sl@0
  1223
		{
sl@0
  1224
		threads[i].Close();
sl@0
  1225
		}
sl@0
  1226
	CleanupStack::PopAndDestroy(2, &image); // image, sem
sl@0
  1227
	TestCloseDriver();
sl@0
  1228
	}
sl@0
  1229
sl@0
  1230
/**
sl@0
  1231
@SYMTestCaseID			GRAPHICS-RESOURCE-0051
sl@0
  1232
@SYMTestCaseDesc		Calls RSgImage::GetInterface() with an invalid image handle
sl@0
  1233
@SYMPREQ				PREQ2637
sl@0
  1234
@SYMFssID				RSgImage::GetInterface(TUid, TAny*&)
sl@0
  1235
@SYMTestPriority		Low
sl@0
  1236
@SYMTestType			UT
sl@0
  1237
@SYMTestPurpose			Negative test to ensure calling GetInterface() with an invalid image handle 
sl@0
  1238
						will cause a panic.
sl@0
  1239
@SYMTestActions			Initialise the graphics resource component and create an image in a second thread. 
sl@0
  1240
						Declare another image and assign it to the current image handle. Close the current
sl@0
  1241
						image so the second image handle becomes invalid. Call GetInterface() on the 
sl@0
  1242
						second handle.
sl@0
  1243
@SYMTestExpectedResults Should panic in the second thread with panic code SGRES 3(ESgPanicBadDrawableHandle).
sl@0
  1244
 */
sl@0
  1245
void CTSgImageGeneric::TestPanicImageGetInterfaceInvalidHandleL()
sl@0
  1246
	{
sl@0
  1247
	TSgImageInfo info(TSize(),0,0);
sl@0
  1248
	TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadPanicImageGetInterfaceInvalidHandle);
sl@0
  1249
 	TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
sl@0
  1250
	_LIT(KTestName, "TestImageGetInterfaceInvalidHandleLThread");
sl@0
  1251
	CreateSecondThreadAndCheckPanicL(threadInfo, 3, exitCategoryName, KTestName);
sl@0
  1252
	}
sl@0
  1253
sl@0
  1254
/**
sl@0
  1255
@SYMTestCaseID			GRAPHICS-RESOURCE-0052
sl@0
  1256
@SYMTestCaseDesc		Calls RSgImage::GetInterface() with a non-null handle and an uninitialised driver
sl@0
  1257
@SYMPREQ				PREQ2637
sl@0
  1258
@SYMFssID				RSgImage::GetInterface(TUid, TAny*&)
sl@0
  1259
@SYMTestPriority		Low
sl@0
  1260
@SYMTestType			UT
sl@0
  1261
@SYMTestPurpose			Negative test to ensure calling GetInterface() with a non-null handle and an 
sl@0
  1262
						uninitialised driver will cause a panic.
sl@0
  1263
@SYMTestActions			Initialise the graphics resource component and create an image in a second thread. 
sl@0
  1264
						Declare another image and assign it to the current image handle. Close the current
sl@0
  1265
						image so the second image handle becomes invalid. Close the graphics resource driver.
sl@0
  1266
						Call GetInterface() on the second handle.
sl@0
  1267
@SYMTestExpectedResults Should panic in the second thread with panic code SGRES 1 (ESgPanicNoDriver).
sl@0
  1268
 */
sl@0
  1269
void CTSgImageGeneric::TestPanicImageGetInterfaceNoDriverL()
sl@0
  1270
	{	
sl@0
  1271
	TSgImageInfo info(TSize(),0,0);
sl@0
  1272
	TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadPanicImageGetInterfaceNoDriver);
sl@0
  1273
 	TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
sl@0
  1274
	_LIT(KTestName, "TestImageGetInterfaceNoDriverL");
sl@0
  1275
 	CreateSecondThreadAndCheckPanicL(threadInfo, 1, exitCategoryName, KTestName);
sl@0
  1276
	}
sl@0
  1277
sl@0
  1278
/**
sl@0
  1279
@SYMTestCaseID			GRAPHICS-RESOURCE-0053
sl@0
  1280
@SYMTestCaseDesc		Calls RSgImage::Close() with an invalid image handle
sl@0
  1281
@SYMPREQ				PREQ2637
sl@0
  1282
@SYMFssID				RSgImage::Close()
sl@0
  1283
@SYMTestPriority		Low
sl@0
  1284
@SYMTestType			UT
sl@0
  1285
@SYMTestPurpose			Negative test to ensure calling Close() with an invalid image handle will 
sl@0
  1286
						cause a panic.
sl@0
  1287
@SYMTestActions			Initialise the graphics resource component and create an image in a second thread. 
sl@0
  1288
						Declare another image and assign it to the current image handle. Close the current
sl@0
  1289
						image so the second image handle becomes invalid. Call Close() on the second handle.
sl@0
  1290
@SYMTestExpectedResults Should panic in the second thread with panic code SGRES 3(ESgPanicBadDrawableHandle).
sl@0
  1291
 */
sl@0
  1292
void CTSgImageGeneric::TestPanicImageCloseInvalidHandleL()
sl@0
  1293
	{
sl@0
  1294
	TSgImageInfo info(TSize(),0,0);
sl@0
  1295
	TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadPanicImageCloseInvalidHandle);
sl@0
  1296
 	TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
sl@0
  1297
	_LIT(KTestName, "TestImageCloseInvalidHandleL");
sl@0
  1298
 	CreateSecondThreadAndCheckPanicL(threadInfo, 3, exitCategoryName, KTestName);
sl@0
  1299
	}
sl@0
  1300
sl@0
  1301
/**
sl@0
  1302
@SYMTestCaseID			GRAPHICS-RESOURCE-0054
sl@0
  1303
@SYMTestCaseDesc		Calls RSgImage::Close() with a non-null handle and an uninitialised driver
sl@0
  1304
@SYMPREQ				PREQ2637
sl@0
  1305
@SYMFssID				RSgImage::Close()
sl@0
  1306
@SYMTestPriority		Low
sl@0
  1307
@SYMTestType			UT
sl@0
  1308
@SYMTestPurpose			Negative test to ensure calling Close() with a non-null handle and an 
sl@0
  1309
						uninitialised driver will cause a panic.
sl@0
  1310
@SYMTestActions			Initialise the graphics resource component and create an image in a second thread. 
sl@0
  1311
						Declare another image and assign it to the current image handle. Close the current
sl@0
  1312
						image so the second image handle becomes invalid. Close the graphics resource driver.
sl@0
  1313
						Call Close() on the second handle.
sl@0
  1314
@SYMTestExpectedResults Should panic in the second thread with panic code SGRES 1 (ESgPanicNoDriver).
sl@0
  1315
 */
sl@0
  1316
void CTSgImageGeneric::TestPanicImageCloseNoDriverL()
sl@0
  1317
	{
sl@0
  1318
	TSgImageInfo info(TSize(),0,0);
sl@0
  1319
	TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadPanicImageCloseNoDriver);
sl@0
  1320
 	TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
sl@0
  1321
	_LIT(KTestName, "TestImageCloseNoDriverL");
sl@0
  1322
	CreateSecondThreadAndCheckPanicL(threadInfo, 1, exitCategoryName, KTestName);
sl@0
  1323
	}
sl@0
  1324
sl@0
  1325
/**
sl@0
  1326
@SYMTestCaseID			GRAPHICS-RESOURCE-0055
sl@0
  1327
@SYMTestCaseDesc		Calls RSgImage::Id() with an invalid image handle
sl@0
  1328
@SYMPREQ				PREQ2637
sl@0
  1329
@SYMFssID				RSgImage::Id()
sl@0
  1330
@SYMTestPriority		Low
sl@0
  1331
@SYMTestType			UT
sl@0
  1332
@SYMTestPurpose			Negative test to ensure calling Id() with an invalid image handle will 
sl@0
  1333
						cause a panic.
sl@0
  1334
@SYMTestActions			Initialise the graphics resource component and create an image in a second thread. 
sl@0
  1335
						Declare another image and assign it to the current image handle. Close the current
sl@0
  1336
						image so the second image handle becomes invalid. Call Id() on the second
sl@0
  1337
						handle.
sl@0
  1338
@SYMTestExpectedResults Should panic in the second thread with panic code SGRES 3(ESgPanicBadDrawableHandle).
sl@0
  1339
 */
sl@0
  1340
void CTSgImageGeneric::TestPanicImageIdInvalidHandleL()
sl@0
  1341
	{
sl@0
  1342
	TSgImageInfo info(TSize(),0,0);
sl@0
  1343
	TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadPanicImageIdInvalidHandle);
sl@0
  1344
 	TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
sl@0
  1345
	_LIT(KTestName, "TestImageIdInvalidHandleL");
sl@0
  1346
 	CreateSecondThreadAndCheckPanicL(threadInfo, 3, exitCategoryName, KTestName);
sl@0
  1347
 	}
sl@0
  1348
sl@0
  1349
/**
sl@0
  1350
@SYMTestCaseID			GRAPHICS-RESOURCE-0056
sl@0
  1351
@SYMTestCaseDesc		Calls RSgImage::Id() with a non-null handle and an uninitialised driver
sl@0
  1352
@SYMPREQ				PREQ2637
sl@0
  1353
@SYMFssID				RSgImage::Id()
sl@0
  1354
@SYMTestPriority		Low
sl@0
  1355
@SYMTestType			UT
sl@0
  1356
@SYMTestPurpose			Negative test to ensure calling Id() with a non-null handle and an 
sl@0
  1357
						uninitialised driver will cause a panic.
sl@0
  1358
@SYMTestActions			Initialise the graphics resource component and create an image in a second thread. 
sl@0
  1359
						Declare another image and assign it to the current image handle. Close the current
sl@0
  1360
						image so the second image handle becomes invalid. Close the graphics resource driver.
sl@0
  1361
						Call Id() on the second handle.
sl@0
  1362
@SYMTestExpectedResults Should panic in the second thread with panic code SGRES 1 (ESgPanicNoDriver).
sl@0
  1363
 */
sl@0
  1364
void CTSgImageGeneric::TestPanicImageIdNoDriverL()
sl@0
  1365
	{
sl@0
  1366
	TSgImageInfo info(TSize(),0,0);
sl@0
  1367
	TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadPanicImageIdNoDriver);
sl@0
  1368
 	TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
sl@0
  1369
	_LIT(KTestName, "TestImageIdNoDriverL");
sl@0
  1370
 	CreateSecondThreadAndCheckPanicL(threadInfo, 1, exitCategoryName, KTestName);
sl@0
  1371
	}
sl@0
  1372
sl@0
  1373
/**
sl@0
  1374
@SYMTestCaseID			GRAPHICS-RESOURCE-0057
sl@0
  1375
@SYMTestCaseDesc		Calls RSgImage::Create() with an invalid image handle
sl@0
  1376
@SYMPREQ				PREQ2637
sl@0
  1377
@SYMFssID				RSgImage::Create(const TSgImageInfo&, const RSgImage&)
sl@0
  1378
@SYMTestPriority		Low
sl@0
  1379
@SYMTestType			UT
sl@0
  1380
@SYMTestPurpose			Negative test to ensure calling Create() with an invalid image handle will 
sl@0
  1381
						cause a panic.
sl@0
  1382
@SYMTestActions			Initialise the graphics resource component and create an image in a second thread. 
sl@0
  1383
						Declare another image and assign it to the current image handle. Close the current
sl@0
  1384
						image so the second image handle becomes invalid. Call Create() on the second
sl@0
  1385
						handle.
sl@0
  1386
@SYMTestExpectedResults Should panic in the second thread with panic code SGRES 3(ESgPanicBadDrawableHandle).
sl@0
  1387
 */
sl@0
  1388
void CTSgImageGeneric::TestPanicImageCreateInvalidHandleL()
sl@0
  1389
	{
sl@0
  1390
	TSgImageInfo info(TSize(),0,0);
sl@0
  1391
	TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadPanicImageCreateInvalidHandle);
sl@0
  1392
 	TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
sl@0
  1393
	_LIT(KTestName, "TestImageCreateInvalidHandleL");
sl@0
  1394
 	CreateSecondThreadAndCheckPanicL(threadInfo, 3, exitCategoryName, KTestName);
sl@0
  1395
	}
sl@0
  1396
sl@0
  1397
/**
sl@0
  1398
@SYMTestCaseID			GRAPHICS-RESOURCE-0058
sl@0
  1399
@SYMTestCaseDesc		Calls RSgImage::GetInfo() with an invalid image handle
sl@0
  1400
@SYMPREQ				PREQ2637
sl@0
  1401
@SYMFssID				RSgImage::GetInfo(TSgImageInfo&)
sl@0
  1402
@SYMTestPriority		Low
sl@0
  1403
@SYMTestType			UT
sl@0
  1404
@SYMTestPurpose			Negative test to ensure calling GetInfo() with an invalid image handle will 
sl@0
  1405
						cause a panic.
sl@0
  1406
@SYMTestActions			Initialise the graphics resource component and create an image in a second thread. 
sl@0
  1407
						Declare another image and assign it to the current image handle. Close the current
sl@0
  1408
						image so the second image handle becomes invalid. Call GetInfo() on the second
sl@0
  1409
						handle.
sl@0
  1410
@SYMTestExpectedResults Should panic in the second thread with panic code SGRES 3(ESgPanicBadDrawableHandle).
sl@0
  1411
 */
sl@0
  1412
void CTSgImageGeneric::TestPanicImageGetInfoInvalidHandleL()
sl@0
  1413
	{
sl@0
  1414
	TSgImageInfo info(TSize(),0,0);
sl@0
  1415
	TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadPanicImageGetInfoInvalidHandle);
sl@0
  1416
 	TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
sl@0
  1417
	_LIT(KTestName, "TestImageGetInfoInvalidHandleL");
sl@0
  1418
 	CreateSecondThreadAndCheckPanicL(threadInfo, 3, exitCategoryName, KTestName);
sl@0
  1419
	}
sl@0
  1420
sl@0
  1421
/**
sl@0
  1422
@SYMTestCaseID			GRAPHICS-RESOURCE-0059
sl@0
  1423
@SYMTestCaseDesc		Calls RSgImage::GetInfo() with a non-null handle and an uninitialised driver
sl@0
  1424
@SYMPREQ				PREQ2637
sl@0
  1425
@SYMFssID				SgImage::GetInfo(TSgImageInfo&)
sl@0
  1426
@SYMTestPriority		Low
sl@0
  1427
@SYMTestType			UT
sl@0
  1428
@SYMTestPurpose			Negative test to ensure calling GetInfo() with a non-null handle and an 
sl@0
  1429
						uninitialised driver will cause a panic.
sl@0
  1430
@SYMTestActions			Initialise the graphics resource component and create an image in a second thread. 
sl@0
  1431
						Declare another image and assign it to the current image handle. Close the current
sl@0
  1432
						image so the second image handle becomes invalid. Close the graphics resource driver.
sl@0
  1433
						Call GetInfo() on the second handle.
sl@0
  1434
@SYMTestExpectedResults Should panic in the second thread with panic code SGRES 1 (ESgPanicNoDriver).
sl@0
  1435
 */
sl@0
  1436
void CTSgImageGeneric::TestPanicImageGetInfoNoDriverL()
sl@0
  1437
	{
sl@0
  1438
	TSgImageInfo info(TSize(),0,0);
sl@0
  1439
	TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadPanicImageGetInfoNoDriver);
sl@0
  1440
 	TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
sl@0
  1441
	_LIT(KTestName, "TestImageGetInfoNoDriverL");
sl@0
  1442
     CreateSecondThreadAndCheckPanicL(threadInfo, 1, exitCategoryName, KTestName);
sl@0
  1443
	}
sl@0
  1444
sl@0
  1445
/**
sl@0
  1446
@SYMTestCaseID			GRAPHICS-RESOURCE-0082
sl@0
  1447
@SYMTestCaseDesc		Calls RSgImage::Open() when the driver was not initialised.
sl@0
  1448
@SYMPREQ				PREQ2637
sl@0
  1449
@SYMFssID				RSgImage::Open(const TSgDrawableId&, TUint32)
sl@0
  1450
@SYMTestPriority		Low
sl@0
  1451
@SYMTestType			UT
sl@0
  1452
@SYMTestPurpose			Negative test to ensure calling RSgImage::Open() with an uninitialised driver 
sl@0
  1453
						will cause a panic.
sl@0
  1454
@SYMTestActions			Do not initialise the graphics resource component and call RSgImage::Open() 
sl@0
  1455
						in a second thread.
sl@0
  1456
@SYMTestExpectedResults Should panic in the second thread with panic code SGRES 1 (ESgPanicNoDriver).
sl@0
  1457
 */
sl@0
  1458
void CTSgImageGeneric::TestPanicImageOpenNoDriverL()
sl@0
  1459
	{
sl@0
  1460
	TSgImageInfo info(TSize(),0,0);
sl@0
  1461
	TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadPanicImageOpenNoDriver);
sl@0
  1462
 	TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
sl@0
  1463
	_LIT(KTestName, "TestPanicImageOpenNoDriverL");
sl@0
  1464
	CreateSecondThreadAndCheckPanicL(threadInfo, 1, exitCategoryName, KTestName);
sl@0
  1465
	}
sl@0
  1466
sl@0
  1467
/**
sl@0
  1468
@SYMTestCaseID			GRAPHICS-RESOURCE-0083
sl@0
  1469
@SYMTestCaseDesc		Creates an image from memory when the driver was not initialised.
sl@0
  1470
@SYMPREQ				PREQ2637
sl@0
  1471
@SYMFssID				RSgImage::Create(const TSgImageInfo&, const TAny*, TInt)
sl@0
  1472
@SYMTestPriority		Low
sl@0
  1473
@SYMTestType			UT
sl@0
  1474
@SYMTestPurpose			Negative test to ensure calling RSgImage::Create() with an uninitialised 
sl@0
  1475
						driver will cause a panic.
sl@0
  1476
@SYMTestActions			Do not initialise the graphics resource component and call RSgImage::Open() 
sl@0
  1477
						in a second thread.
sl@0
  1478
@SYMTestExpectedResults Should panic in the second thread with panic code SGRES 1 (ESgPanicNoDriver).
sl@0
  1479
 */
sl@0
  1480
void CTSgImageGeneric::TestPanicImageCreateNoDriver1L()
sl@0
  1481
	{
sl@0
  1482
	TSgImageInfo info(TSize(),0,0);
sl@0
  1483
	TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadPanicImageCreateNoDriver1);
sl@0
  1484
 	TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
sl@0
  1485
	_LIT(KTestName, "TestPanicImageCreateNoDriver1L");
sl@0
  1486
	CreateSecondThreadAndCheckPanicL(threadInfo, 1, exitCategoryName, KTestName);
sl@0
  1487
	}
sl@0
  1488
sl@0
  1489
/**
sl@0
  1490
@SYMTestCaseID			GRAPHICS-RESOURCE-0084
sl@0
  1491
@SYMTestCaseDesc		Creates an image from an existing image when the driver was not initialised.
sl@0
  1492
@SYMPREQ				PREQ2637
sl@0
  1493
@SYMFssID				RSgImage::Create(const TSgImageInfo&, const RSgImage&)
sl@0
  1494
@SYMTestPriority		Low
sl@0
  1495
@SYMTestType			UT
sl@0
  1496
@SYMTestPurpose			Negative test to ensure calling RSgImage::Create() with an uninitialised driver 
sl@0
  1497
						will cause a panic.
sl@0
  1498
@SYMTestActions			Do not initialise the graphics resource component and call RSgImage::Open() in 
sl@0
  1499
						a second thread.
sl@0
  1500
@SYMTestExpectedResults	Should panic in the second thread with panic code SGRES 1 (ESgPanicNoDriver).
sl@0
  1501
 */
sl@0
  1502
void CTSgImageGeneric::TestPanicImageCreateNoDriver2L()
sl@0
  1503
	{
sl@0
  1504
	TSgImageInfo info(TSize(),0,0);
sl@0
  1505
	TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadPanicImageCreateNoDriver2);
sl@0
  1506
 	TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
sl@0
  1507
	_LIT(KTestName, "TestPanicImageCreateNoDriver2L");
sl@0
  1508
	CreateSecondThreadAndCheckPanicL(threadInfo, 1, exitCategoryName, KTestName);
sl@0
  1509
	}
sl@0
  1510
sl@0
  1511
/**
sl@0
  1512
@SYMTestCaseID			GRAPHICS-RESOURCE-0088
sl@0
  1513
@SYMTestCaseDesc		Calls RSgImage::DrawableType() when the driver was not initialised.
sl@0
  1514
@SYMPREQ				PREQ2637
sl@0
  1515
@SYMFssID				RSgImage::DrawableType()
sl@0
  1516
@SYMTestPriority		Low
sl@0
  1517
@SYMTestType			UT
sl@0
  1518
@SYMTestPurpose			Negative test to ensure calling RSgImage::DrawableType() with an uninitialised
sl@0
  1519
						driver will cause a panic.
sl@0
  1520
@SYMTestActions			Do not initialise the graphics resource component and call RSgImage::DrawableType()
sl@0
  1521
						in a second thread.
sl@0
  1522
@SYMTestExpectedResults Should panic in the second thread with panic code SGRES 1 (ESgPanicNoDriver).
sl@0
  1523
 */
sl@0
  1524
void CTSgImageGeneric::TestPanicImageDrawableTypeNoDriverL()
sl@0
  1525
	{
sl@0
  1526
	TSgImageInfo info(TSize(),0,0);
sl@0
  1527
	TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadPanicImageDrawableTypeNoDriver);
sl@0
  1528
 	TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
sl@0
  1529
	_LIT(KTestName, "TestPanicImageOpenNoDriverL");
sl@0
  1530
	CreateSecondThreadAndCheckPanicL(threadInfo, 1, exitCategoryName, KTestName);
sl@0
  1531
	}
sl@0
  1532
sl@0
  1533
/**
sl@0
  1534
@SYMTestCaseID			GRAPHICS-RESOURCE-0089
sl@0
  1535
@SYMTestCaseDesc		Calls RSgImage::DrawableType() with an invalid image handle
sl@0
  1536
@SYMPREQ				PREQ2637
sl@0
  1537
@SYMFssID				RSgImage::DrawableType()
sl@0
  1538
@SYMTestPriority		Low
sl@0
  1539
@SYMTestType			UT
sl@0
  1540
@SYMTestPurpose			Negative test to ensure calling RSgImage::DrawableType() with an uninitialised 
sl@0
  1541
						driver will cause a panic.
sl@0
  1542
@SYMTestActions			Do not initialise the graphics resource component and call RSgImage::DrawableType()
sl@0
  1543
						in a second thread.
sl@0
  1544
@SYMTestExpectedResults Should panic in the second thread with panic code SGRES 3 (ESgPanicBadDrawableHandle).
sl@0
  1545
 */
sl@0
  1546
void CTSgImageGeneric::TestPanicImageDrawableTypeInvalidHandleL()
sl@0
  1547
	{
sl@0
  1548
	TSgImageInfo info(TSize(),0,0);
sl@0
  1549
	TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadPanicImageDrawableTypeInvalidHandle);
sl@0
  1550
 	TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
sl@0
  1551
	_LIT(KTestName, "TestPanicImageOpenNoDriverL");
sl@0
  1552
	CreateSecondThreadAndCheckPanicL(threadInfo, 3, exitCategoryName, KTestName);
sl@0
  1553
	}
sl@0
  1554
sl@0
  1555
/**
sl@0
  1556
@SYMTestCaseID          GRAPHICS-RESOURCE-0090
sl@0
  1557
@SYMTestCaseDesc        Calls RSgImage::DrawableType() with an invalid image handle
sl@0
  1558
@SYMPREQ                PREQ2637
sl@0
  1559
@SYMFssID               RSgImage::GetAttribute()
sl@0
  1560
@SYMTestPriority        Low
sl@0
  1561
@SYMTestType            UT
sl@0
  1562
@SYMTestPurpose         Negative test to ensure calling RSgImage::GetAttribute() with an invalid handle
sl@0
  1563
						will cause a panic.
sl@0
  1564
@SYMTestActions         Initialise the graphics resource component and call RSgImage::GetAttribute()
sl@0
  1565
						in a second thread with an invalid handle.
sl@0
  1566
@SYMTestExpectedResults Should panic in the second thread with panic code SGRES 3 (ESgPanicBadDrawableHandle).
sl@0
  1567
 */
sl@0
  1568
void CTSgImageGeneric::TestPanicImageGetAttributeInvalidHandleL()
sl@0
  1569
    {
sl@0
  1570
    TSgImageInfo info(TSize(),0,0);
sl@0
  1571
    TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadPanicImageGetAttributeInvalidHandle);
sl@0
  1572
    TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
sl@0
  1573
    _LIT(KTestName, "TestPanicImageGetAttributeInvalidHandleL");
sl@0
  1574
    CreateSecondThreadAndCheckPanicL(threadInfo, 3, exitCategoryName, KTestName);
sl@0
  1575
    }
sl@0
  1576
sl@0
  1577
/**
sl@0
  1578
@SYMTestCaseID          GRAPHICS-RESOURCE-0091
sl@0
  1579
@SYMTestCaseDesc        Calls RSgImage::GetAttribute() with no open driver
sl@0
  1580
@SYMPREQ                PREQ2637
sl@0
  1581
@SYMFssID               RSgImage::GetAttribute()
sl@0
  1582
@SYMTestPriority        Low
sl@0
  1583
@SYMTestType            UT
sl@0
  1584
@SYMTestPurpose         Negative test to ensure calling RSgImage::GetAttribute() with an uninitialised
sl@0
  1585
						driver will cause a panic.
sl@0
  1586
@SYMTestActions         Do not initialise the graphics resource component and call RSgImage::GetAttribute()
sl@0
  1587
						in a second thread.
sl@0
  1588
@SYMTestExpectedResults Should panic in the second thread with panic code SGRES 1 (ESgPanicNoDriver).
sl@0
  1589
 */
sl@0
  1590
void CTSgImageGeneric::TestPanicImageGetAttributeNoDriverL()
sl@0
  1591
    {
sl@0
  1592
    TSgImageInfo info(TSize(),0,0);
sl@0
  1593
    TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadPanicImageGetAttributeNoDriver);
sl@0
  1594
    TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
sl@0
  1595
    _LIT(KTestName, "TestPanicImageGetAttributeNoDriverL");
sl@0
  1596
    CreateSecondThreadAndCheckPanicL(threadInfo, 1, exitCategoryName, KTestName);
sl@0
  1597
    }
sl@0
  1598
sl@0
  1599
/**
sl@0
  1600
@SYMTestCaseID          GRAPHICS-RESOURCE-0097
sl@0
  1601
@SYMTestCaseDesc        Access out of bound TSgAttibuteArray index
sl@0
  1602
@SYMPREQ                PREQ2637
sl@0
  1603
@SYMFssID               TSgAttributeArray
sl@0
  1604
@SYMTestPriority        Low
sl@0
  1605
@SYMTestType            UT
sl@0
  1606
@SYMTestPurpose         Negative test to ensure calling an out of bound index on a TSgAttributeArray 
sl@0
  1607
						will cause a panic.
sl@0
  1608
@SYMTestActions         Create a TSgAttributeArray of size 5 and attempt to access an element higher 
sl@0
  1609
						than the size.
sl@0
  1610
@SYMTestExpectedResults Should panic in the second thread with panic code SGRES 4 (ESgPanicBadAttributeArrayIndex).
sl@0
  1611
 */
sl@0
  1612
void CTSgImageGeneric::TestPanicImageAttributeArrayInvalidIndexL()
sl@0
  1613
    {
sl@0
  1614
    TSgImageInfo info(TSize(),0,0);
sl@0
  1615
    TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadPanicAttributeArrayInvalidIndex);
sl@0
  1616
    TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
sl@0
  1617
    _LIT(KTestName, "AttributeArrayInvalidIndexL");
sl@0
  1618
    CreateSecondThreadAndCheckPanicL(threadInfo, 4, exitCategoryName, KTestName);
sl@0
  1619
    }
sl@0
  1620
sl@0
  1621
/**
sl@0
  1622
@SYMTestCaseID          GRAPHICS-RESOURCE-0098
sl@0
  1623
@SYMTestCaseDesc        Access out of bound TSgAttibuteArray index 
sl@0
  1624
@SYMPREQ                PREQ2637
sl@0
  1625
@SYMFssID               TSgAttributeArray        
sl@0
  1626
@SYMTestPriority        Low
sl@0
  1627
@SYMTestType            UT
sl@0
  1628
@SYMTestPurpose         Negative test to ensure calling an out of bound index on a TSgAttributeArray
sl@0
  1629
						will cause a panic.
sl@0
  1630
@SYMTestActions         Create a TSgAttributeArray of size 5 and attempt to access an element higher
sl@0
  1631
						than the size.
sl@0
  1632
@SYMTestExpectedResults Should panic in the second thread with panic code SGRES 4 (ESgPanicBadAttributeArrayIndex).
sl@0
  1633
 */
sl@0
  1634
void CTSgImageGeneric::TestPanicImageAttributeArrayInvalidIndex2L()
sl@0
  1635
    {
sl@0
  1636
    TSgImageInfo info(TSize(),0,0);
sl@0
  1637
    TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadPanicAttributeArrayInvalidIndex2);
sl@0
  1638
    TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
sl@0
  1639
    _LIT(KTestName, "AttributeArrayInvalidIndexL");
sl@0
  1640
    CreateSecondThreadAndCheckPanicL(threadInfo, 4, exitCategoryName, KTestName);
sl@0
  1641
    }
sl@0
  1642
sl@0
  1643
/**
sl@0
  1644
@SYMTestCaseID          GRAPHICS-RESOURCE-0101
sl@0
  1645
@SYMTestCaseDesc        Close an RSgDriver with open resources
sl@0
  1646
@SYMPREQ                PREQ2637
sl@0
  1647
@SYMFssID				RSgDriver       
sl@0
  1648
@SYMTestPriority        Low
sl@0
  1649
@SYMTestType            UT
sl@0
  1650
@SYMTestPurpose         Negative test to ensure closing a driver with open resources will cause a panic.
sl@0
  1651
@SYMTestActions         Create an RSgImage on an open driver, then close the driver.
sl@0
  1652
@SYMTestExpectedResults Should panic in the second thread with panic code SGRES 2 (ESgPanicUnclosedResources).
sl@0
  1653
 */
sl@0
  1654
void CTSgImageGeneric::TestPanicDriverCloseOpenResourcesL()
sl@0
  1655
    {
sl@0
  1656
    TSgImageInfo info(TSize(),0,0);
sl@0
  1657
    TSgProcessTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondProcessPanicDriverCloseOpenResources);
sl@0
  1658
    TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
sl@0
  1659
    CreateSecondProcessAndCheckPanicL(threadInfo, 2, exitCategoryName, KSecondProcess);
sl@0
  1660
    }
sl@0
  1661
sl@0
  1662
/**
sl@0
  1663
@SYMTestCaseID          GRAPHICS-RESOURCE-0102
sl@0
  1664
@SYMTestCaseDesc        Open/Close RSgDriver and Create/Close RSgImage in separate threads
sl@0
  1665
@SYMPREQ                PREQ2637
sl@0
  1666
@SYMFssID				RSgDriver, RSgImage      
sl@0
  1667
@SYMTestPriority        High
sl@0
  1668
@SYMTestType            UT
sl@0
  1669
@SYMTestPurpose         To ensure that it is possible to Open/Close the RSgDriver from
sl@0
  1670
						a separate thread, and to ensure that it is possible to Create/Open/Close 
sl@0
  1671
						RSgImages from a seperate thread.
sl@0
  1672
@SYMTestActions         1. Declare a RSgDriver, and pass to another thread to open.
sl@0
  1673
						2. Declare a RSgImage, and pass to another thread to create.
sl@0
  1674
						3. Pass created RSgImage to another thread to Open().
sl@0
  1675
						4. Pass the image to another thread to Close().
sl@0
  1676
						5. Pass the RSgDriver to another thread to Close()
sl@0
  1677
@SYMTestExpectedResults All steps to succeed with no errors reported.
sl@0
  1678
 */
sl@0
  1679
void CTSgImageGeneric::TestCreateOpenCloseImageAndDriverInSecondThreadL()
sl@0
  1680
    {
sl@0
  1681
    TSgImageInfo info(TSize(),0,0);
sl@0
  1682
    TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadOpenPassedDriver);
sl@0
  1683
    
sl@0
  1684
    RSgDriver driver;
sl@0
  1685
    threadInfo.iSgDriver = &driver;
sl@0
  1686
    
sl@0
  1687
    RSgImage image;
sl@0
  1688
    threadInfo.iSgImage = &image;
sl@0
  1689
    
sl@0
  1690
    //Open the driver in another thread
sl@0
  1691
    TEST(CreateSecondThreadAndDoTestL(threadInfo)==0);
sl@0
  1692
   
sl@0
  1693
    //Create the image in a thread
sl@0
  1694
    threadInfo.iTestCase = ESgresSecondThreadCreatePassedImage;
sl@0
  1695
    TEST(CreateSecondThreadAndDoTestL(threadInfo)==0);    
sl@0
  1696
    
sl@0
  1697
    //Now try opening the image in another thread
sl@0
  1698
    RSgImage image2;
sl@0
  1699
    threadInfo.iTestCase = ESgresSecondThreadOpenPassedImage;
sl@0
  1700
    threadInfo.iDrawableId = image.Id();
sl@0
  1701
    threadInfo.iSgImage = &image2;
sl@0
  1702
    TEST(CreateSecondThreadAndDoTestL(threadInfo)==0);   
sl@0
  1703
    
sl@0
  1704
    //Close the "Opened" image in another thread
sl@0
  1705
    threadInfo.iTestCase = ESgresSecondThreadClosePassedImage;
sl@0
  1706
    TEST(CreateSecondThreadAndDoTestL(threadInfo)==0);
sl@0
  1707
    
sl@0
  1708
    //Close the "Created" image in another thread
sl@0
  1709
    threadInfo.iTestCase = ESgresSecondThreadClosePassedImage;
sl@0
  1710
    threadInfo.iSgImage = &image;
sl@0
  1711
    TEST(CreateSecondThreadAndDoTestL(threadInfo)==0);
sl@0
  1712
    
sl@0
  1713
    //Close the driver in another thread
sl@0
  1714
    threadInfo.iTestCase = ESgresSecondThreadClosePassedDriver;
sl@0
  1715
    TEST(CreateSecondThreadAndDoTestL(threadInfo)==0);
sl@0
  1716
    }
sl@0
  1717
sl@0
  1718
/**
sl@0
  1719
@SYMTestCaseID			GRAPHICS-RESOURCE-0104
sl@0
  1720
@SYMTestCaseDesc		Open a RSgImage using multiple threads.
sl@0
  1721
@SYMDEF					ou1cimx1#197357
sl@0
  1722
@SYMFssID				RSgImage      
sl@0
  1723
@SYMTestPriority		Low
sl@0
  1724
@SYMTestType			UT
sl@0
  1725
@SYMTestPurpose			To show that images can be opened safely when used with multiple threads in 
sl@0
  1726
						separate processes.
sl@0
  1727
@SYMTestActions			1. Process A, creates an RSgImage
sl@0
  1728
						2. Process B, creates a secondary thread, which creates a handle to the image
sl@0
  1729
						created in A.
sl@0
  1730
						3. Process B, primary thread opens a handle to the same image.
sl@0
  1731
						4. Process B, secondary thread closes the handle and terminates thread.
sl@0
  1732
						5. Process B, primary thread waits for thread cleanup, then attempts to 
sl@0
  1733
						access the data of the image by creating a copy of it.
sl@0
  1734
@SYMTestExpectedResults All steps to succeed with no errors reported.
sl@0
  1735
 */
sl@0
  1736
void CTSgImageGeneric::TestOpenImageMultithreadedL()
sl@0
  1737
	{
sl@0
  1738
	TestOpenDriverL();
sl@0
  1739
	RSgImage image;
sl@0
  1740
	CreateImageL(image);
sl@0
  1741
	CleanupClosePushL(image);
sl@0
  1742
	
sl@0
  1743
	TSgImageInfo info;
sl@0
  1744
	TInt err = image.GetInfo(info);
sl@0
  1745
	TESTE(err == KErrNone, err);
sl@0
  1746
	
sl@0
  1747
	TSgProcessTestInfo processInfo(image.Id(), info, ESgresSecondProcessOpenImageMultithreaded);
sl@0
  1748
	TInt testResult = 0;
sl@0
  1749
	TRAP(err, testResult = CreateSecondProcessAndDoTestL(KSecondProcess, processInfo));
sl@0
  1750
	TESTE(err == KErrNone, err);
sl@0
  1751
	TEST(testResult & EFirstTestPassed);
sl@0
  1752
	TEST(testResult & ESecondTestPassed);
sl@0
  1753
	TEST(testResult <= (EFirstTestPassed | ESecondTestPassed));
sl@0
  1754
sl@0
  1755
	CleanupStack::PopAndDestroy(1); // image
sl@0
  1756
	TestCloseDriver();	
sl@0
  1757
	}