os/graphics/egl/egltest/src/egltest_general.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) 2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
//
sl@0
    15
sl@0
    16
/**
sl@0
    17
 @file
sl@0
    18
 @test
sl@0
    19
*/
sl@0
    20
sl@0
    21
#ifdef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
sl@0
    22
#include <sgresource/sgimage.h>
sl@0
    23
#else
sl@0
    24
#include <graphics/sgimage.h>
sl@0
    25
#endif //SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
sl@0
    26
#include <test/tefunit.h> // for ASSERT macros
sl@0
    27
#include <GLES/gl.h>
sl@0
    28
sl@0
    29
#include "egltest_general.h"
sl@0
    30
sl@0
    31
#include <test/egltestcommonconversion.h>
sl@0
    32
#include <test/egltestcommoninisettings.h>
sl@0
    33
#include <test/egltestcommonsgimageinfo.h>
sl@0
    34
sl@0
    35
sl@0
    36
/**
sl@0
    37
@SYMTestCaseID GRAPHICS-EGL-0005
sl@0
    38
sl@0
    39
@SYMTestPriority 1
sl@0
    40
sl@0
    41
@SYMPREQ 39
sl@0
    42
sl@0
    43
@SYMREQ See SGL.GT0386.401 document
sl@0
    44
sl@0
    45
@SYMTestCaseDesc
sl@0
    46
Dump diagnostic information that may help in debugging any issues found in the other tests.
sl@0
    47
This is not really a test in itself, but can be listed in the test script as a specific test step.
sl@0
    48
It is expected always to pass.
sl@0
    49
sl@0
    50
@SYMTestActions
sl@0
    51
Repeatedly call eglQueryString() with each of the following parameters:
sl@0
    52
	*	EGL_CLIENT_APIS
sl@0
    53
	*	EGL_EXTENSIONS
sl@0
    54
	*	EGL_VENDOR
sl@0
    55
	*	EGL_VERSION
sl@0
    56
For each call, dump the resulting string to the test log file.
sl@0
    57
If the result of EGL_CLIENT_APIS includes "OpenVG" then bind to the OpenVG API and repeatedly call vgGetString() with each of the following parameters
sl@0
    58
	*	VG_VENDOR
sl@0
    59
	*	VG_RENDERER
sl@0
    60
	*	VG_VERSION
sl@0
    61
	*	VG_EXTENSIONS
sl@0
    62
If the result of EGL_CLIENT_APIS includes "OpenGLES" then bind to the OpenGLES API and repeatedly call GetString() with each of the following parameters
sl@0
    63
	*	VENDOR
sl@0
    64
	*	RENDERER
sl@0
    65
	*	VERSION
sl@0
    66
	*	EXTENSIONS.
sl@0
    67
sl@0
    68
@SYMTestExpectedResults
sl@0
    69
All data will be dumped to the test log file.
sl@0
    70
There are no specific pass criteria for this test case.
sl@0
    71
*/
sl@0
    72
TVerdict CEglTest_DumpStrings::doTestStepL()
sl@0
    73
	{
sl@0
    74
	SetTestStepID(_L("GRAPHICS-EGL-0005"));
sl@0
    75
	INFO_PRINTF1(_L("CEglTest_DumpStrings::doTestStepL"));
sl@0
    76
sl@0
    77
	// Create display object
sl@0
    78
	GetDisplayL();
sl@0
    79
sl@0
    80
	CTestEglSession* eglSess = CTestEglSession::NewLC(Logger(), iDisplay, 0);
sl@0
    81
sl@0
    82
	// Initialise the display object
sl@0
    83
	eglSess->InitializeL();
sl@0
    84
sl@0
    85
	// EGL Strings
sl@0
    86
	INFO_PRINTF1(_L("Dumping EGL strings"));
sl@0
    87
sl@0
    88
	// Note that eglQueryString() MUST be called AFTER eglInitialize() for iDisplay
sl@0
    89
	TPtrC8 ptrEglClientApis((const TText8 *)eglQueryString(iDisplay, EGL_CLIENT_APIS));
sl@0
    90
	DumpString(_L("EGL_CLIENT_APIS"),ptrEglClientApis);
sl@0
    91
sl@0
    92
	const char* strEglExtensions = eglQueryString(iDisplay, EGL_EXTENSIONS);
sl@0
    93
	ASSERT_EGL_TRUE(strEglExtensions!=NULL);
sl@0
    94
	DumpString(_L("EGL_EXTENSIONS"), TPtrC8((const TText8 *)strEglExtensions));
sl@0
    95
sl@0
    96
	const char* strEglVendor = eglQueryString(iDisplay, EGL_VENDOR);
sl@0
    97
	ASSERT_EGL_TRUE(strEglVendor!=NULL);
sl@0
    98
	DumpString(_L("EGL_VENDOR"), TPtrC8((const TText8 *)strEglVendor));
sl@0
    99
sl@0
   100
	const char* strEglVersion = eglQueryString(iDisplay, EGL_VERSION);
sl@0
   101
	ASSERT_EGL_TRUE(strEglVersion!=NULL);
sl@0
   102
	DumpString(_L("EGL_VERSION"), TPtrC8((const TText8 *)strEglVersion));
sl@0
   103
sl@0
   104
	// OpenVG Strings
sl@0
   105
	if (ptrEglClientApis.Find(_L8("OpenVG")) >= 0)
sl@0
   106
		{
sl@0
   107
		INFO_PRINTF1(_L("Dumping OpenVG strings"));
sl@0
   108
sl@0
   109
		// OpenVG needs a current VG context before it will allow the call to vgGetString
sl@0
   110
        EGLConfig currentConfig = eglSess->GetConfigExactMatchL(EPBufferAttribsColor64K);
sl@0
   111
        eglSess->CreatePbufferSurfaceAndMakeCurrentL(currentConfig, KPixmapSize, EGL_OPENVG_API);
sl@0
   112
sl@0
   113
		TPtrC8 ptrVgVendor((const TText8 *)vgGetString(VG_VENDOR));
sl@0
   114
		DumpString(_L("VG_VENDOR"), ptrVgVendor);
sl@0
   115
sl@0
   116
		TPtrC8 ptrVgRenderer((const TText8 *)vgGetString(VG_RENDERER));
sl@0
   117
		DumpString(_L("VG_RENDERER"), ptrVgRenderer);
sl@0
   118
sl@0
   119
		TPtrC8 ptrVgVersion((const TText8 *)vgGetString(VG_VERSION));
sl@0
   120
		DumpString(_L("VERSION"), ptrVgVersion);
sl@0
   121
sl@0
   122
		TPtrC8 ptrVgExtensions((const TText8 *)vgGetString(VG_EXTENSIONS));
sl@0
   123
		DumpString(_L("VG_EXTENSIONS"), ptrVgExtensions);
sl@0
   124
		
sl@0
   125
		//cleanup the context & surface
sl@0
   126
		eglSess->CleanupSurfaceSgImageL();
sl@0
   127
		}
sl@0
   128
sl@0
   129
	// OpenGLES Strings
sl@0
   130
	if (ptrEglClientApis.Find(_L8("OpenGL_ES")) >= 0)
sl@0
   131
		{
sl@0
   132
		INFO_PRINTF1(_L("Dumping OpenGLES strings"));
sl@0
   133
sl@0
   134
		// OpenGLES needs a current GLES context before it will allow the call to glGetString
sl@0
   135
        EGLConfig currentConfig = eglSess->GetConfigExactMatchL(EPBufferAttribsColor64K);
sl@0
   136
        eglSess->CreatePbufferSurfaceAndMakeCurrentL(currentConfig, KPixmapSize, EGL_OPENGL_ES_API);
sl@0
   137
sl@0
   138
		TPtrC8 ptrGlesVendor((const TText8 *)glGetString(GL_VENDOR));
sl@0
   139
		DumpString(_L("GL_VENDOR"), ptrGlesVendor);
sl@0
   140
sl@0
   141
		TPtrC8 ptrGlesRenderer((const TText8 *)glGetString(GL_RENDERER));
sl@0
   142
		DumpString(_L("GL_RENDERER"), ptrGlesRenderer);
sl@0
   143
sl@0
   144
		TPtrC8 ptrGlesVersion((const TText8 *)glGetString(GL_VERSION));
sl@0
   145
		DumpString(_L("GL_VERSION"), ptrGlesVersion);
sl@0
   146
sl@0
   147
		TPtrC8 ptrGlesExtensions((const TText8 *)glGetString(GL_EXTENSIONS));
sl@0
   148
		DumpString(_L("GL_EXTENSIONS"), ptrGlesExtensions);
sl@0
   149
		
sl@0
   150
		//cleanup the context & surface
sl@0
   151
		eglSess->CleanupSurfaceSgImageL();
sl@0
   152
		}
sl@0
   153
sl@0
   154
	CleanupStack::PopAndDestroy(eglSess);
sl@0
   155
	TerminateDisplayL();
sl@0
   156
	RecordTestResultL();
sl@0
   157
	CloseTMSGraphicsStep();
sl@0
   158
	return TestStepResult();
sl@0
   159
	}
sl@0
   160
sl@0
   161
void CEglTest_DumpStrings::DumpString(const TDesC& aField, const TDesC8& aValue)
sl@0
   162
	{
sl@0
   163
	const TInt KMaxValueLength = 256;
sl@0
   164
	TBuf16<KMaxValueLength> bufValue;
sl@0
   165
	bufValue.Copy(aValue.Left(KMaxValueLength));
sl@0
   166
	INFO_PRINTF3(_L("%S: \"%S\""), &aField, &bufValue);
sl@0
   167
	}
sl@0
   168
sl@0
   169
/**
sl@0
   170
@SYMTestCaseID GRAPHICS-EGL-0010
sl@0
   171
sl@0
   172
@SYMTestPriority 1
sl@0
   173
sl@0
   174
@SYMPREQ 39
sl@0
   175
sl@0
   176
@SYMREQ See SGL.GT0386.401 document
sl@0
   177
sl@0
   178
@SYMTestCaseDesc
sl@0
   179
To ensure that eglQueryString() returns the correct information.
sl@0
   180
sl@0
   181
@SYMTestActions
sl@0
   182
Call eglQueryString() with the EGL_EXTENSIONS parameter
sl@0
   183
sl@0
   184
@SYMTestExpectedResults
sl@0
   185
The returned space separated list is expected to include the items as defined in the .ini file.
sl@0
   186
This list is implementation specific, so the .ini file can be configured depending on each implementation.
sl@0
   187
As an example, the following ones are expected in most EGL implementations:
sl@0
   188
	*	EGL_NOK_pixmap_type_rsgimage
sl@0
   189
	*	EGL_SYMBIAN_COMPOSITION
sl@0
   190
	*	EGL_KHR_image_base
sl@0
   191
	*	EGL_KHR_image_pixmap 	
sl@0
   192
	*	EGL_KHR_reusable_sync
sl@0
   193
The above list will be configurable on a per-platform basis, via an INI file.  If a platform does not support
sl@0
   194
any of the above extensions then it may opt not to test for it via the INI file.
sl@0
   195
*/
sl@0
   196
TVerdict CEglTest_QueryString_Extensions::doTestStepL()
sl@0
   197
	{
sl@0
   198
	SetTestStepID(_L("GRAPHICS-EGL-0010"));
sl@0
   199
	INFO_PRINTF1(_L("CEglTest_QueryString_Extensions::doTestStepL"));
sl@0
   200
sl@0
   201
	TInt numExtensions=0;
sl@0
   202
	if (!GetIntFromConfig(ConfigSection(), KKeyCountExtensionsEGL, numExtensions))
sl@0
   203
		{
sl@0
   204
		ERR_PRINTF2(_L("Cannot find key '%S' in INI file"), &KKeyCountExtensionsEGL);
sl@0
   205
		User::Leave(KErrArgument);
sl@0
   206
		}
sl@0
   207
	INFO_PRINTF2(_L("Looking for %d EGL extensions"), numExtensions);
sl@0
   208
	TBuf<32> bufExtensionNameKey;
sl@0
   209
	TBuf16<128> bufExtensionNameValue16;
sl@0
   210
	TPtrC16 ptrExtensionNameValue16(bufExtensionNameValue16);
sl@0
   211
	for(TInt i=0; i<numExtensions; i++)
sl@0
   212
		{
sl@0
   213
		bufExtensionNameKey.Format(KKeyExtensionEGLX, i);
sl@0
   214
		if (!GetStringFromConfig(ConfigSection(), bufExtensionNameKey, ptrExtensionNameValue16))
sl@0
   215
			{
sl@0
   216
			ERR_PRINTF2(_L("Cannot find key '%S' in INI file"), &bufExtensionNameKey);
sl@0
   217
			User::Leave(KErrArgument);
sl@0
   218
			}
sl@0
   219
		INFO_PRINTF2(_L("Checking for extension \"%S\""), &ptrExtensionNameValue16);
sl@0
   220
		TEST(CheckForExtensionL(0, ptrExtensionNameValue16));
sl@0
   221
		}
sl@0
   222
sl@0
   223
	numExtensions=0;
sl@0
   224
	if (!GetIntFromConfig(ConfigSection(), KKeyCountExtensionsVG, numExtensions))
sl@0
   225
		{
sl@0
   226
		ERR_PRINTF2(_L("Cannot find key '%S' in INI file"), &KKeyCountExtensionsVG);
sl@0
   227
		User::Leave(KErrArgument);
sl@0
   228
		}
sl@0
   229
	INFO_PRINTF2(_L("Looking for %d VG extensions"), numExtensions);
sl@0
   230
	for(TUint i=0; i<numExtensions; i++)
sl@0
   231
		{
sl@0
   232
		bufExtensionNameKey.Format(KKeyExtensionVGX, i);
sl@0
   233
		if (!GetStringFromConfig(ConfigSection(), bufExtensionNameKey, ptrExtensionNameValue16))
sl@0
   234
			{
sl@0
   235
			ERR_PRINTF2(_L("Cannot find key '%S' in INI file"), &bufExtensionNameKey);
sl@0
   236
			User::Leave(KErrArgument);
sl@0
   237
			}
sl@0
   238
		INFO_PRINTF2(_L("Checking for extension \"%S\""), &ptrExtensionNameValue16);
sl@0
   239
		TEST(CheckForExtensionL(0, ptrExtensionNameValue16));
sl@0
   240
		}
sl@0
   241
sl@0
   242
	RecordTestResultL();
sl@0
   243
	CloseTMSGraphicsStep();
sl@0
   244
	return TestStepResult();
sl@0
   245
	}
sl@0
   246
sl@0
   247
/**
sl@0
   248
@SYMTestCaseID GRAPHICS-EGL-0012
sl@0
   249
sl@0
   250
@SYMTestPriority 3
sl@0
   251
sl@0
   252
@SYMPREQ 39
sl@0
   253
sl@0
   254
@SYMREQ ReqNum
sl@0
   255
sl@0
   256
@SYMTestCaseDesc
sl@0
   257
Ensure that eglGetProcAddress() returns NULL when given invalid data.
sl@0
   258
sl@0
   259
@SYMTestActions
sl@0
   260
Call eglGetProcAddress() with a <procname> that is known not to be supported - e.g. "qwerty"
sl@0
   261
Call eglGetProcAddress() with an empty <procname> - i.e. ""
sl@0
   262
Call eglGetProcAddress() with a null <procname> - i.e. NULL
sl@0
   263
sl@0
   264
@SYMTestExpectedResults
sl@0
   265
For each case, eglGetProcAddress() should return NULL, without raising an EGL error.
sl@0
   266
*/
sl@0
   267
TVerdict CEglTest_General_Negative_ProcAddress::doTestStepL()
sl@0
   268
    {
sl@0
   269
    SetTestStepID(_L("GRAPHICS-EGL-0012"));
sl@0
   270
    INFO_PRINTF1(_L("CEglTest_General_Negative_ProcAddress::doTestStepL"));
sl@0
   271
sl@0
   272
    // Create display object
sl@0
   273
    GetDisplayL();
sl@0
   274
sl@0
   275
    // Initialize display object
sl@0
   276
    INFO_PRINTF1(_L("Calling eglInitialize"));
sl@0
   277
    TEST_EGL_ERROR(eglInitialize(iDisplay, NULL, NULL), EGL_SUCCESS);
sl@0
   278
sl@0
   279
    INFO_PRINTF1(_L("Calling eglGetProcAddress() with a 'procname' that is known not to be supported"));
sl@0
   280
    TEST_EGL_ERROR(eglGetProcAddress("qwerty") == NULL, EGL_SUCCESS);
sl@0
   281
sl@0
   282
    INFO_PRINTF1(_L("Calling eglGetProcAddress() with an empty 'procname'"));
sl@0
   283
    TEST_EGL_ERROR(eglGetProcAddress("") == NULL, EGL_SUCCESS);
sl@0
   284
sl@0
   285
    INFO_PRINTF1(_L("Calling eglGetProcAddress() with a null 'procname'"));
sl@0
   286
    TEST_EGL_ERROR(eglGetProcAddress(NULL) == NULL, EGL_SUCCESS);
sl@0
   287
sl@0
   288
    TerminateDisplayL();
sl@0
   289
    RecordTestResultL();
sl@0
   290
    CloseTMSGraphicsStep();
sl@0
   291
    return TestStepResult();
sl@0
   292
    }
sl@0
   293
sl@0
   294
sl@0
   295
/**
sl@0
   296
@SYMTestCaseID GRAPHICS-EGL-0309
sl@0
   297
sl@0
   298
@SYMPREQ 			PREQ2650
sl@0
   299
sl@0
   300
@SYMTestCaseDesc 	
sl@0
   301
1. EglTerminate() with an invalid/non-existant display
sl@0
   302
2. Double eglTerminate() with an uninitialised display
sl@0
   303
3. Double eglTerminate() with an initialised display
sl@0
   304
sl@0
   305
@SYMTestPriority 	High
sl@0
   306
sl@0
   307
@SYMTestStatus 		Implemented
sl@0
   308
sl@0
   309
@SYMTestActions		
sl@0
   310
1. Call eglTerminate with an invalid display handle argument. Call eglTerminate with EGL_NO_DISPLAY argument
sl@0
   311
2. Create an uninitialised display and call eglTerminate() twice. Re-create and terminate the display to check for memory leaks.
sl@0
   312
3. Create an initialised display and call eglTerminate() twice. Re-create and terminate the display to check for memory leaks.
sl@0
   313
sl@0
   314
@SYMTestExpectedResults		
sl@0
   315
1. eglTerminate should return EGL_FALSE on both calls with error EGL_BAD_DISPLAY
sl@0
   316
2. eglTerminate should return EGL_TRUE on all calls and the display should not be set to EGL_NO_DISPLAY.
sl@0
   317
3. eglTerminate should return EGL_TRUE on all calls and the display should not be set to EGL_NO_DISPLAY.
sl@0
   318
The UHEAP markers should indicate no memory leaks after this test case has run.
sl@0
   319
*/
sl@0
   320
TVerdict CEglTest_EglTerminate_Negative::doTestStepL()
sl@0
   321
	{
sl@0
   322
	INFO_PRINTF1(_L("CEglTest_EglTerminate_Negative::doTestStepL"));
sl@0
   323
	SetTestStepID(_L("GRAPHICS-EGL-0309"));
sl@0
   324
sl@0
   325
    //Test 1 - Arbitrary invalid display handle
sl@0
   326
    const EGLDisplay invalidDisplay = 77;
sl@0
   327
sl@0
   328
    //Call eglTerminate with the invalid display handle
sl@0
   329
    TEST(eglTerminate(invalidDisplay) == EGL_FALSE);
sl@0
   330
    ASSERT_EGL_ERROR(EGL_BAD_DISPLAY);
sl@0
   331
sl@0
   332
    //Call eglTerminate with argument EGL_NO_DISPLAY
sl@0
   333
    TEST(eglTerminate(EGL_NO_DISPLAY) == EGL_FALSE);
sl@0
   334
    ASSERT_EGL_ERROR(EGL_BAD_DISPLAY);
sl@0
   335
sl@0
   336
    //Test 2 - Create display object
sl@0
   337
    iDisplay = EGL_NO_DISPLAY;
sl@0
   338
    GetDisplayL();
sl@0
   339
sl@0
   340
	//Call eglTerminate twice
sl@0
   341
    ASSERT_EGL_TRUE(eglTerminate(iDisplay));
sl@0
   342
    TEST(eglGetError() == EGL_SUCCESS);
sl@0
   343
sl@0
   344
    ASSERT_EGL_TRUE(eglTerminate(iDisplay));
sl@0
   345
    TEST(eglGetError() == EGL_SUCCESS);
sl@0
   346
sl@0
   347
    //Recreate display object and call eglTerminate()
sl@0
   348
    iDisplay = EGL_NO_DISPLAY;
sl@0
   349
    GetDisplayL();
sl@0
   350
    ASSERT_EGL_TRUE(eglTerminate(iDisplay));
sl@0
   351
    TEST(eglGetError() == EGL_SUCCESS);
sl@0
   352
sl@0
   353
    //Test 3
sl@0
   354
    iDisplay = EGL_NO_DISPLAY;
sl@0
   355
    GetDisplayL();
sl@0
   356
    CTestEglSession* eglSess = CTestEglSession::NewLC(Logger(), iDisplay, 0);
sl@0
   357
sl@0
   358
    // Initialise the display object
sl@0
   359
    eglSess->InitializeL();
sl@0
   360
sl@0
   361
    //Call eglTerminate twice
sl@0
   362
    ASSERT_EGL_TRUE(eglTerminate(iDisplay));
sl@0
   363
    TEST(eglGetError() == EGL_SUCCESS);
sl@0
   364
sl@0
   365
    ASSERT_EGL_TRUE(eglTerminate(iDisplay));
sl@0
   366
    TEST(eglGetError() == EGL_SUCCESS);
sl@0
   367
sl@0
   368
    //Recreate display object
sl@0
   369
    iDisplay = EGL_NO_DISPLAY;
sl@0
   370
    GetDisplayL();
sl@0
   371
sl@0
   372
    //Call eglTerminate
sl@0
   373
    ASSERT_EGL_TRUE(eglTerminate(iDisplay));
sl@0
   374
    TEST(eglGetError() == EGL_SUCCESS);
sl@0
   375
sl@0
   376
    //cleanup and stuff...
sl@0
   377
    CleanupStack::PopAndDestroy(1, eglSess);
sl@0
   378
    ASSERT_EGL_TRUE(eglReleaseThread());
sl@0
   379
sl@0
   380
    RecordTestResultL();
sl@0
   381
    CloseTMSGraphicsStep();
sl@0
   382
    return TestStepResult();
sl@0
   383
	}