os/graphics/graphicsresourceservices/graphicsresourceimplementation/test/src/tgraphicsresourceinternal.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/graphics/graphicsresourceservices/graphicsresourceimplementation/test/src/tgraphicsresourceinternal.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,425 @@
     1.4 +// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +/**
    1.20 + @file
    1.21 + @test
    1.22 + @internalComponent - Internal Symbian test code
    1.23 +*/
    1.24 +
    1.25 +#include "tgraphicsresourceinternal.h"
    1.26 +
    1.27 +#include <sgresource/sgresource.h>
    1.28 +#include <sgresource/sgimage.h>
    1.29 +
    1.30 +#include "tgraphicsresourceteststepbase.h"
    1.31 +#include "tgraphicsresourceinternalextensions.h"
    1.32 +
    1.33 +
    1.34 +CTGraphicsResourceInternal::CTGraphicsResourceInternal()
    1.35 +	{
    1.36 +	SetTestStepName(KTGraphicsResourceInternalStep);
    1.37 +	}
    1.38 +
    1.39 +CTGraphicsResourceInternal::~CTGraphicsResourceInternal()
    1.40 +	{
    1.41 +	}
    1.42 +
    1.43 +/**
    1.44 +Overrides of base class pure virtual
    1.45 +Our implementation only gets called if the base class doTestStepPreambleL() did
    1.46 +not leave. That being the case, the current test result value will be EPass.
    1.47 +@leave Gets system wide error code
    1.48 +@return TVerdict code
    1.49 +*/
    1.50 +TVerdict CTGraphicsResourceInternal::doTestStepL()
    1.51 +	{
    1.52 +#ifndef _DEBUG
    1.53 +	INFO_PRINTF1(_L("Some tests cannot run in release builds, skipping..."));
    1.54 +#else
    1.55 +	// These tests use KInternalTestsSecondProcess, which can only run in UDEB mode
    1.56 +	// otherwise a panic will occur when attempting to find the UDEB extension interface
    1.57 +	// MSgDriver_Test...
    1.58 +	
    1.59 +	SetTestStepID(_L("GRAPHICS-RESOURCE-0200"));
    1.60 +	TestDriverMemoryLeakL();
    1.61 +	RecordTestResultL();
    1.62 +
    1.63 +	SetTestStepID(_L("GRAPHICS-RESOURCE-0201"));
    1.64 +	TestOOML();
    1.65 +	RecordTestResultL();
    1.66 +
    1.67 +	SetTestStepID(_L("GRAPHICS-RESOURCE-0202"));
    1.68 +	TestInitializeAndShutdownL();
    1.69 +	RecordTestResultL();
    1.70 +
    1.71 +	SetTestStepID(_L("GRAPHICS-RESOURCE-0203"));
    1.72 +	TestInitializeAndShutdownManyTimesL();
    1.73 +	RecordTestResultL();
    1.74 +	
    1.75 +	SetTestStepID(_L("GRAPHICS-RESOURCE-0111"));
    1.76 +	TestResourceProfilingL();
    1.77 +	RecordTestResultL();	
    1.78 +#endif
    1.79 +	
    1.80 +	SetTestStepID(_L("GRAPHICS-RESOURCE-0204"));
    1.81 +	TestUsageBitsL();
    1.82 +	RecordTestResultL();
    1.83 +
    1.84 +	return TestStepResult();
    1.85 +	}
    1.86 +
    1.87 +
    1.88 +/**
    1.89 +@SYMTestCaseID			GRAPHICS-RESOURCE-0200
    1.90 +@SYMTestCaseDesc		Test SGAlloc panic occurs when we deliberately leak resources.
    1.91 +@SYMPREQ				PREQ2637
    1.92 +@SYMFssID				RSgImage::Create()
    1.93 +						RSgDriver:AllocMarkEnd()
    1.94 +@SYMTestPriority		Medium
    1.95 +@SYMTestType			UT
    1.96 +@SYMTestPurpose			To ensure that leaking resources causes the internal Memory Leak checking routine to panic
    1.97 +@SYMTestActions			Initialise the graphics resource component. Call AllocMarkStart to begin memory leak checking
    1.98 +						Create a new RSgImage and then call AllocMarkEnd before closing the RSgImage to cause an 
    1.99 +						SGALLOC panic
   1.100 +@SYMTestExpectedResults	The panic SGALLOC:xxxxxxxx where xxxxxxxx is the address of the leak.
   1.101 + */	
   1.102 +void CTGraphicsResourceInternal::TestDriverMemoryLeakL()
   1.103 +	{
   1.104 +	TSgResIntTestInfo testInfo = { ESgResIntDriverMemoryLeak };
   1.105 +	CreateSecondProcessAndCheckAllocPanicL(KInternalTestsSecondProcess, testInfo, KSgAllocPanic);
   1.106 +	}
   1.107 +
   1.108 +/**
   1.109 +@SYMTestCaseID			GRAPHICS-RESOURCE-0201
   1.110 +@SYMTestCaseDesc		Test Graphics Resource with low memory conditions.
   1.111 +@SYMPREQ				PREQ2637
   1.112 +@SYMFssID				RSgImage
   1.113 +						RSgDrawable
   1.114 +						RSgDriver
   1.115 +@SYMTestPriority		High
   1.116 +@SYMTestType			UT
   1.117 +@SYMTestPurpose			To ensure the correct errors or KErrNoMemory are returned by graphics resource apis under low
   1.118 +						memory conditions.
   1.119 +@SYMTestActions			Force allocations to fail on the RSgDrivers heap, try running each of the conformance tests and
   1.120 +						stress tests to ensure no RSgDriver allocated memory or heap memory is leaked. It also creates
   1.121 +						an image in this process which is used in another process for OOM testing. 
   1.122 +@SYMTestExpectedResults	Return codes of the functions tested should be either the expected value or KErrNoMemory
   1.123 +						This is handled by CTSgTestStepBase::CheckErrorL. No ALLOC or SGALLOC panics should occur.
   1.124 + */	
   1.125 +void CTGraphicsResourceInternal::TestOOML()
   1.126 +	{
   1.127 +	// drawable OOM test
   1.128 +	TSgResIntTestInfo testInfo = { ESgResIntDrawableOOM };
   1.129 +	TInt result = CreateSecondProcessAndDoTestL(KInternalTestsSecondProcess, testInfo);
   1.130 +	TEST(result & EFirstTestPassed);
   1.131 +	
   1.132 +	// image OOM test
   1.133 +    testInfo.iTestCase = ESgResIntImageOOM;
   1.134 +    
   1.135 +    RSgDriver sgDriver;
   1.136 +    TInt err = sgDriver.Open();
   1.137 +    TESTEL(err == KErrNone, err);
   1.138 +    CleanupClosePushL(sgDriver);
   1.139 +    
   1.140 +    RSgImage image1;
   1.141 +    TSgImageInfo info1(TSize(8, 8), EUidPixelFormatRGB_565, ESgUsageBitOpenVgImage);
   1.142 +    err = image1.Create(info1);
   1.143 +    TESTEL(err == KErrNone, err);
   1.144 +    CleanupClosePushL(image1);
   1.145 +    testInfo.iDrawableId = image1.Id();
   1.146 +            
   1.147 +    result = CreateSecondProcessAndDoTestL(KInternalTestsSecondProcess, testInfo);
   1.148 +    TEST(result & EFirstTestPassed);
   1.149 +        
   1.150 +    CleanupStack::PopAndDestroy(2, &sgDriver); 
   1.151 +	}
   1.152 +/**
   1.153 +@SYMTestCaseID			GRAPHICS-RESOURCE-0202
   1.154 +@SYMTestCaseDesc		Test valid resource count
   1.155 +@SYMPREQ				PREQ2637
   1.156 +@SYMFssID				RSgImage
   1.157 +						RSgDrawable
   1.158 +						RSgDriver
   1.159 +@SYMTestPriority		Low
   1.160 +@SYMTestType			UT
   1.161 +@SYMTestPurpose			To ensure that RSgDriver reports the correct local resource count when images are opened and closed.
   1.162 +@SYMTestActions			Open an RSgDriver and create an image, then close it checking the resource count of the
   1.163 +						driver is valid at each stage (0,1,0).
   1.164 +@SYMTestExpectedResults	Resource counts should be as expected.
   1.165 + */	
   1.166 +void CTGraphicsResourceInternal::TestInitializeAndShutdownL()
   1.167 +	{
   1.168 +	TSgResIntTestInfo testInfo = { ESgResIntInitializeAndShutdown };
   1.169 +	TInt result = CreateSecondProcessAndDoTestL(KInternalTestsSecondProcess, testInfo);
   1.170 +	TEST(result & EFirstTestPassed);
   1.171 +	TEST(result & ESecondTestPassed);
   1.172 +	TEST(result & EThirdTestPassed);
   1.173 +	}
   1.174 +
   1.175 +/*
   1.176 +@SYMTestCaseID			GRAPHICS-RESOURCE-0203
   1.177 +@SYMTestCaseDesc		Test valid resource count with multiple driver sessions
   1.178 +@SYMPREQ				PREQ2637
   1.179 +@SYMFssID				RSgImage
   1.180 +						RSgDrawable
   1.181 +						RSgDriver
   1.182 +@SYMTestPriority		Low
   1.183 +@SYMTestType			UT
   1.184 +@SYMTestPurpose			To ensure that RSgDriver reports the correct local resource count when images are opened and closed.
   1.185 +@SYMTestActions			Open an RSgDriver and create an image, then close it checking the resource count of the
   1.186 +						driver is valid at each stage (0,1,0). Attempt to close the driver multiple times and then perform the
   1.187 +						same tests again.
   1.188 +@SYMTestExpectedResults	Resource counts should be as expected.
   1.189 + */	
   1.190 +void CTGraphicsResourceInternal::TestInitializeAndShutdownManyTimesL()
   1.191 +	{
   1.192 +	TSgResIntTestInfo testInfo = { ESgResIntInitializeAndShutdownManyTimes };
   1.193 +	TInt result = CreateSecondProcessAndDoTestL(KInternalTestsSecondProcess, testInfo);
   1.194 +	TEST(result & EFirstTestPassed);
   1.195 +	TEST(result & ESecondTestPassed);
   1.196 +	TEST(result & EThirdTestPassed);
   1.197 +	TEST(result & EFourthTestPassed);
   1.198 +	}
   1.199 +
   1.200 +/*
   1.201 +@SYMTestCaseID			GRAPHICS-RESOURCE-0111
   1.202 +@SYMTestCaseDesc		Test MSgDriver_Profiling extension.
   1.203 +@SYMPREQ				PREQ2637
   1.204 +@SYMFssID				RSgImage
   1.205 +						RSgDriver
   1.206 +						MSgDriver_Profiling
   1.207 +@SYMTestPriority		Medium
   1.208 +@SYMTestType			UT
   1.209 +@SYMTestPurpose			To test that the extension MSgDriver_Profiling correctly reports
   1.210 +						the correct global and local resource count and memory usage when
   1.211 +						resources are created in separate processes.
   1.212 +@SYMTestActions			Get the MSgDriver_Profiling extension, query memory/resource usage.
   1.213 +						Create an image and check  the memory usage and count.
   1.214 +						Launch a separate process that checks the same memory usage/count.
   1.215 +						Create an image in this separate process and check the global resource 
   1.216 +						count and memory. Close the image nad check the memory usage and resource
   1.217 +						count. Terminate the second process. Check the local and global count 
   1.218 +						in the first process. Close the image in this process and check the global 
   1.219 +						and local resource count.
   1.220 +@SYMTestExpectedResults When creating the first image, the local resource count should equal one,
   1.221 +						the global count should increment. The local memory usage should increase
   1.222 +						by at least the size of the image in pixels * byte-depth. The global memory
   1.223 +						usage should increase by the same amount.
   1.224 +						Second process should report the same global resouce count and memory as
   1.225 +						the first process. 
   1.226 +						Second process image creation to cause same usage/count increase as did 
   1.227 +						first image.
   1.228 +						Closing the image in the second process should set count and memory usage 
   1.229 +						back to initial values, and local count/usage to zero. 
   1.230 +						Closing the image in the first process should set the count and memory usage
   1.231 +						back to their pre-test values, and local count/usage to zero.
   1.232 + */	
   1.233 +void CTGraphicsResourceInternal::TestResourceProfilingL()
   1.234 +	{
   1.235 +	__UHEAP_MARK;
   1.236 +	
   1.237 +	RSgDriver sgDriver;
   1.238 +	TInt err = sgDriver.Open();
   1.239 +	TESTE(err == KErrNone, err);
   1.240 +
   1.241 +	if (KErrNone == err)
   1.242 +		{
   1.243 +		MSgDriver_Profiling* profiling = NULL;
   1.244 +		err = sgDriver.GetInterface(profiling);
   1.245 +		if (!profiling || err != KErrNone)
   1.246 +			{
   1.247 +			ERR_PRINTF2(_L("Failed to get MSgDriver_Profiling extension [%d]"), err);
   1.248 +			SetTestStepResult(EFail);
   1.249 +			return;
   1.250 +			}
   1.251 +		
   1.252 +		const TInt originalGlobalResourceCount = profiling->GlobalResourceCount();
   1.253 +		const TInt originalGlobalGraphicsMemory = profiling->GlobalGraphicsMemoryUsed();
   1.254 +
   1.255 +		TEST(profiling->LocalGraphicsMemoryUsed() == 0);
   1.256 +		
   1.257 +		RSgImage image;
   1.258 +		const TSize KImageSize(8, 8);
   1.259 +		err = image.Create(TSgImageInfo(KImageSize, EUidPixelFormatARGB_8888, ESgUsageBitOpenVgImage));
   1.260 +		TESTE(err == KErrNone, err);
   1.261 +
   1.262 +		// Check that having created an image, the global resource count and memory usage has
   1.263 +		// increased.
   1.264 +		TInt localGraphicsMemory = profiling->LocalGraphicsMemoryUsed();
   1.265 +		TEST(localGraphicsMemory >= (KImageSize.iWidth * KImageSize.iHeight * 4));
   1.266 +		TEST(profiling->GlobalResourceCount() == (originalGlobalResourceCount + 1));
   1.267 +		TEST(profiling->GlobalGraphicsMemoryUsed() == (localGraphicsMemory + originalGlobalResourceCount));
   1.268 +		
   1.269 +		TSgResIntTestInfo testInfo = { ESgResIntResourceProfiling };
   1.270 +		testInfo.iGlobalGraphicsMemory = profiling->GlobalGraphicsMemoryUsed();
   1.271 +		testInfo.iGlobalResourceCount = profiling->GlobalResourceCount();
   1.272 +		TInt result = CreateSecondProcessAndDoTestL(KInternalTestsSecondProcess, testInfo);
   1.273 +		TEST(result & EFirstTestPassed);
   1.274 +		TEST(result & ESecondTestPassed);
   1.275 +		TEST(result & EThirdTestPassed);
   1.276 +		TEST(result & EFourthTestPassed);
   1.277 +		TEST(result & EFifthTestPassed);
   1.278 +		TEST(result & ESixthTestPassed);
   1.279 +		TEST(result & ESeventhTestPassed);
   1.280 +		TEST(result & EEighthTestPassed);
   1.281 +		TEST(result & ENinthTestPassed);
   1.282 +		TEST(result & ETenthTestPassed);
   1.283 +		TEST(result & EEleventhTestPassed);
   1.284 +		
   1.285 +		// Check that the global and local counts are unchanged.
   1.286 +		TEST(profiling->LocalGraphicsMemoryUsed() == localGraphicsMemory);
   1.287 +		TEST(profiling->GlobalResourceCount() == (originalGlobalResourceCount + 1));
   1.288 +		TEST(profiling->GlobalGraphicsMemoryUsed() == (localGraphicsMemory + originalGlobalResourceCount));
   1.289 +				
   1.290 +		// Check that closing the image shows the image memory is back to zero.
   1.291 +		image.Close();		
   1.292 +		TEST(profiling->LocalGraphicsMemoryUsed() == 0);
   1.293 +		TEST(profiling->GlobalGraphicsMemoryUsed() == originalGlobalGraphicsMemory);
   1.294 +		TEST(profiling->GlobalResourceCount() == originalGlobalResourceCount);
   1.295 +		
   1.296 +		// Cleanup
   1.297 +		sgDriver.Close();
   1.298 +		profiling = NULL;
   1.299 +		}
   1.300 +	__UHEAP_MARKEND;
   1.301 +	}
   1.302 +
   1.303 + /*
   1.304 + Used for Usage Bit test (GRAPHICS-RESOURCE-0204)
   1.305 + */
   1.306 +struct TUsageBitTest
   1.307 +    {
   1.308 +    TUint32     iUsageBit;              // usage bit to create an image
   1.309 +    TInt        iPixelFormat;           // pixel format to create an inmage
   1.310 +    
   1.311 +    TInt        iExpectedReturnCode;    // expected return code for RSgImage::Create with the usage bit iRequestedUsageBit
   1.312 +    TUint32     iExpectedUsageBit;      // expected usage bit of TSgImageInfo that is obtained by calling RSgImage::GetInfo
   1.313 +    };
   1.314 +
   1.315 +/*
   1.316 + set of usage bit test cases
   1.317 + */
   1.318 +const static TUsageBitTest KUsageBitTestCases[] = {
   1.319 +        // with ESgPixelFormatARGB_8888_PRE
   1.320 +        { ESgUsageBitOpenVgImage,       ESgPixelFormatARGB_8888_PRE, KErrNone,           ESgUsageBitOpenVgImage}, // 0
   1.321 +        { ESgUsageBitOpenGlesTexture2D, ESgPixelFormatARGB_8888_PRE, KErrNone,           ESgUsageBitOpenGlesTexture2D}, // 1
   1.322 +        { ESgUsageBitOpenGles2Texture2D,ESgPixelFormatARGB_8888_PRE, KErrNotSupported,   ESgUsageBitOpenGles2Texture2D}, // 2
   1.323 +        { ESgUsageBitOpenVgSurface,     ESgPixelFormatARGB_8888_PRE, KErrNone,           ESgUsageBitOpenVgSurface | ESgUsageBitOpenGlesSurface}, // 3
   1.324 +        { ESgUsageBitOpenGlesSurface,   ESgPixelFormatARGB_8888_PRE, KErrNone,           ESgUsageBitOpenVgSurface | ESgUsageBitOpenGlesSurface }, // 4
   1.325 +        { ESgUsageBitOpenGles2Surface,  ESgPixelFormatARGB_8888_PRE, KErrNotSupported,   0 }, // 5
   1.326 +        { ESgUsageBitOpenGlSurface,     ESgPixelFormatARGB_8888_PRE, KErrNotSupported,   0 }, // 6
   1.327 +        
   1.328 +        { ESgUsageBitOpenVgImage | ESgUsageBitOpenGlesTexture2D,    ESgPixelFormatARGB_8888_PRE, KErrNone, ESgUsageBitOpenVgImage | ESgUsageBitOpenGlesTexture2D},// 7
   1.329 +        { ESgUsageBitOpenVgImage | ESgUsageBitOpenVgSurface,        ESgPixelFormatARGB_8888_PRE, KErrNone, ESgUsageBitOpenVgImage | ESgUsageBitOpenVgSurface | ESgUsageBitOpenGlesSurface}, // 8
   1.330 +        { ESgUsageBitOpenVgSurface | ESgUsageBitOpenGlesSurface,    ESgPixelFormatARGB_8888_PRE, KErrNone, ESgUsageBitOpenVgSurface | ESgUsageBitOpenGlesSurface}, // 9
   1.331 +        { ESgUsageBitOpenVgSurface | ESgUsageBitOpenGles2Surface,   ESgPixelFormatARGB_8888_PRE, KErrNotSupported, 0}, // 10
   1.332 +        { ESgUsageBitOpenVgSurface | ESgUsageBitOpenGlSurface,      ESgPixelFormatARGB_8888_PRE, KErrNotSupported, 0}, // 11
   1.333 +        { ESgUsageBitOpenVgSurface | ESgUsageBitOpenGles2Texture2D, ESgPixelFormatARGB_8888_PRE, KErrNotSupported, 0},//  12
   1.334 +        
   1.335 +        { ESgUsageBitOpenVgImage | ESgUsageBitOpenGlesTexture2D |ESgUsageBitOpenVgSurface |ESgUsageBitOpenGlesSurface, ESgPixelFormatARGB_8888_PRE, KErrNone, 
   1.336 +          ESgUsageBitOpenVgImage | ESgUsageBitOpenGlesTexture2D |ESgUsageBitOpenVgSurface |ESgUsageBitOpenGlesSurface}, //  13
   1.337 +        
   1.338 +
   1.339 +        //with ESgPixelFormatA_8
   1.340 +        { ESgUsageBitOpenVgImage,       ESgPixelFormatA_8, KErrNone,           ESgUsageBitOpenVgImage}, // 14
   1.341 +        { ESgUsageBitOpenGlesTexture2D, ESgPixelFormatA_8, KErrNone,           ESgUsageBitOpenGlesTexture2D}, // 15
   1.342 +        { ESgUsageBitOpenGles2Texture2D,ESgPixelFormatA_8, KErrNotSupported,   ESgUsageBitOpenGles2Texture2D}, // 16
   1.343 +        { ESgUsageBitOpenVgSurface,     ESgPixelFormatA_8, KErrNotSupported,   0 }, // 17
   1.344 +        { ESgUsageBitOpenGlesSurface,   ESgPixelFormatA_8, KErrNotSupported,   0 }, // 18
   1.345 +        { ESgUsageBitOpenGles2Surface,  ESgPixelFormatA_8, KErrNotSupported,   0 }, // 19
   1.346 +        { ESgUsageBitOpenGlSurface,     ESgPixelFormatA_8, KErrNotSupported,   0 }, // 20
   1.347 +        
   1.348 +        // with EUidPixelFormatARGB_8888
   1.349 +        { ESgUsageBitOpenVgImage,       ESgPixelFormatARGB_8888, KErrNone,           ESgUsageBitOpenVgImage}, // 21
   1.350 +        { ESgUsageBitOpenGlesTexture2D, ESgPixelFormatARGB_8888, KErrNone,           ESgUsageBitOpenGlesTexture2D}, // 22
   1.351 +        { ESgUsageBitOpenGles2Texture2D,ESgPixelFormatARGB_8888, KErrNotSupported,   ESgUsageBitOpenGles2Texture2D}, // 23
   1.352 +        { ESgUsageBitOpenVgSurface,     ESgPixelFormatARGB_8888, KErrNone,           ESgUsageBitOpenVgSurface | ESgUsageBitOpenGlesSurface}, // 3
   1.353 +        { ESgUsageBitOpenGlesSurface,   ESgPixelFormatARGB_8888, KErrNone,           ESgUsageBitOpenVgSurface | ESgUsageBitOpenGlesSurface }, // 4
   1.354 +        { ESgUsageBitOpenGles2Surface,  ESgPixelFormatARGB_8888, KErrNotSupported,   0 }, // 24
   1.355 +        { ESgUsageBitOpenGlSurface,     ESgPixelFormatARGB_8888, KErrNotSupported,   0 }, // 25
   1.356 +        
   1.357 +        // with ESgPixelFormatXRGB_8888
   1.358 +        { ESgUsageBitOpenVgImage,       ESgPixelFormatXRGB_8888, KErrNone,           ESgUsageBitOpenVgImage}, // 26
   1.359 +        { ESgUsageBitOpenGlesTexture2D, ESgPixelFormatXRGB_8888, KErrNone,           ESgUsageBitOpenGlesTexture2D}, // 27
   1.360 +        { ESgUsageBitOpenGles2Texture2D,ESgPixelFormatXRGB_8888, KErrNotSupported,   ESgUsageBitOpenGles2Texture2D}, // 28
   1.361 +        { ESgUsageBitOpenVgSurface,     ESgPixelFormatXRGB_8888, KErrNone,           ESgUsageBitOpenVgSurface | ESgUsageBitOpenGlesSurface}, // 29
   1.362 +        { ESgUsageBitOpenGlesSurface,   ESgPixelFormatXRGB_8888, KErrNone,           ESgUsageBitOpenVgSurface | ESgUsageBitOpenGlesSurface }, // 30
   1.363 +        { ESgUsageBitOpenGles2Surface,  ESgPixelFormatXRGB_8888, KErrNotSupported,   0 }, // 31
   1.364 +        { ESgUsageBitOpenGlSurface,     ESgPixelFormatXRGB_8888, KErrNotSupported,   0 }, // 32
   1.365 +        
   1.366 +        // invalid usage bit
   1.367 +        { 0x0000, ESgPixelFormatRGB_565, KErrArgument, 0 }, // 33
   1.368 +        { 0x1000, ESgPixelFormatRGB_565, KErrNotSupported, 0 }, // 34
   1.369 +    };
   1.370 +
   1.371 +const TInt KUsageBitTestCount = sizeof(KUsageBitTestCases)/sizeof(KUsageBitTestCases[0]);
   1.372 +
   1.373 +/*
   1.374 +@SYMTestCaseID          GRAPHICS-RESOURCE-0204
   1.375 +@SYMTestCaseDesc        Test usage bit
   1.376 +@SYMPREQ                PREQ2637
   1.377 +@SYMFssID               RSgImage
   1.378 +                        RSgDrawable
   1.379 +                        RSgDriver
   1.380 +@SYMTestPriority        High
   1.381 +@SYMTestType            UT
   1.382 +@SYMTestPurpose         To ensure that an image can be created using various usage bit, and the usage bit of created image
   1.383 +                        is correct.
   1.384 +@SYMTestActions         Create an image with selection of usage bit. Check if the return code of SgImage::Create
   1.385 +                        is correct. If creation succeeds, open the image and check if the usage bit is the same 
   1.386 +                        to the one expected. 
   1.387 +                        NOTE: The usage bit may not be the same as the one that is used to create an image - it 
   1.388 +                        depends on the implementation.
   1.389 +@SYMTestExpectedResults The usage bit should match the expected usage bit.
   1.390 + */ 
   1.391 +void CTGraphicsResourceInternal::TestUsageBitsL()
   1.392 +    {
   1.393 + 
   1.394 +    RSgDriver driver;
   1.395 +    User::LeaveIfError(driver.Open());
   1.396 +    CleanupClosePushL(driver);
   1.397 +    
   1.398 +    for(TInt i=0; i < KUsageBitTestCount; ++i)
   1.399 +        {
   1.400 +        TSgImageInfo info(TSize(8, 8), KUsageBitTestCases[i].iPixelFormat,  KUsageBitTestCases[i].iUsageBit);
   1.401 +            
   1.402 +        RSgImage image;
   1.403 +        TInt err = image.Create(info);
   1.404 +        CleanupClosePushL(image);
   1.405 +        
   1.406 +        if(err != KUsageBitTestCases[i].iExpectedReturnCode)
   1.407 +            {
   1.408 +            ERR_PRINTF3(_L("Test case index: %d, Test failed with error: %d"), i, err);
   1.409 +            SetTestStepResult(EFail);
   1.410 +            }
   1.411 +        
   1.412 +        if(err == KErrNone)
   1.413 +            {    
   1.414 +            TSgImageInfo info1;
   1.415 +            User::LeaveIfError(image.GetInfo(info1));   
   1.416 +            if(info1.iUsage != KUsageBitTestCases[i].iExpectedUsageBit)
   1.417 +                {
   1.418 +                ERR_PRINTF3(_L("Test case index: %d, info1 usage bit 0x%04X"), i, info1.iUsage);
   1.419 +                SetTestStepResult(EFail);
   1.420 +                }
   1.421 +            }
   1.422 +            
   1.423 +        CleanupStack::PopAndDestroy(&image);
   1.424 +        }
   1.425 +    
   1.426 +    CleanupStack::PopAndDestroy(&driver);
   1.427 +    }
   1.428 +