1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/graphics/egl/egltest/src/egltest_general.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,383 @@
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 +*/
1.23 +
1.24 +#ifdef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
1.25 +#include <sgresource/sgimage.h>
1.26 +#else
1.27 +#include <graphics/sgimage.h>
1.28 +#endif //SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
1.29 +#include <test/tefunit.h> // for ASSERT macros
1.30 +#include <GLES/gl.h>
1.31 +
1.32 +#include "egltest_general.h"
1.33 +
1.34 +#include <test/egltestcommonconversion.h>
1.35 +#include <test/egltestcommoninisettings.h>
1.36 +#include <test/egltestcommonsgimageinfo.h>
1.37 +
1.38 +
1.39 +/**
1.40 +@SYMTestCaseID GRAPHICS-EGL-0005
1.41 +
1.42 +@SYMTestPriority 1
1.43 +
1.44 +@SYMPREQ 39
1.45 +
1.46 +@SYMREQ See SGL.GT0386.401 document
1.47 +
1.48 +@SYMTestCaseDesc
1.49 +Dump diagnostic information that may help in debugging any issues found in the other tests.
1.50 +This is not really a test in itself, but can be listed in the test script as a specific test step.
1.51 +It is expected always to pass.
1.52 +
1.53 +@SYMTestActions
1.54 +Repeatedly call eglQueryString() with each of the following parameters:
1.55 + * EGL_CLIENT_APIS
1.56 + * EGL_EXTENSIONS
1.57 + * EGL_VENDOR
1.58 + * EGL_VERSION
1.59 +For each call, dump the resulting string to the test log file.
1.60 +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
1.61 + * VG_VENDOR
1.62 + * VG_RENDERER
1.63 + * VG_VERSION
1.64 + * VG_EXTENSIONS
1.65 +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
1.66 + * VENDOR
1.67 + * RENDERER
1.68 + * VERSION
1.69 + * EXTENSIONS.
1.70 +
1.71 +@SYMTestExpectedResults
1.72 +All data will be dumped to the test log file.
1.73 +There are no specific pass criteria for this test case.
1.74 +*/
1.75 +TVerdict CEglTest_DumpStrings::doTestStepL()
1.76 + {
1.77 + SetTestStepID(_L("GRAPHICS-EGL-0005"));
1.78 + INFO_PRINTF1(_L("CEglTest_DumpStrings::doTestStepL"));
1.79 +
1.80 + // Create display object
1.81 + GetDisplayL();
1.82 +
1.83 + CTestEglSession* eglSess = CTestEglSession::NewLC(Logger(), iDisplay, 0);
1.84 +
1.85 + // Initialise the display object
1.86 + eglSess->InitializeL();
1.87 +
1.88 + // EGL Strings
1.89 + INFO_PRINTF1(_L("Dumping EGL strings"));
1.90 +
1.91 + // Note that eglQueryString() MUST be called AFTER eglInitialize() for iDisplay
1.92 + TPtrC8 ptrEglClientApis((const TText8 *)eglQueryString(iDisplay, EGL_CLIENT_APIS));
1.93 + DumpString(_L("EGL_CLIENT_APIS"),ptrEglClientApis);
1.94 +
1.95 + const char* strEglExtensions = eglQueryString(iDisplay, EGL_EXTENSIONS);
1.96 + ASSERT_EGL_TRUE(strEglExtensions!=NULL);
1.97 + DumpString(_L("EGL_EXTENSIONS"), TPtrC8((const TText8 *)strEglExtensions));
1.98 +
1.99 + const char* strEglVendor = eglQueryString(iDisplay, EGL_VENDOR);
1.100 + ASSERT_EGL_TRUE(strEglVendor!=NULL);
1.101 + DumpString(_L("EGL_VENDOR"), TPtrC8((const TText8 *)strEglVendor));
1.102 +
1.103 + const char* strEglVersion = eglQueryString(iDisplay, EGL_VERSION);
1.104 + ASSERT_EGL_TRUE(strEglVersion!=NULL);
1.105 + DumpString(_L("EGL_VERSION"), TPtrC8((const TText8 *)strEglVersion));
1.106 +
1.107 + // OpenVG Strings
1.108 + if (ptrEglClientApis.Find(_L8("OpenVG")) >= 0)
1.109 + {
1.110 + INFO_PRINTF1(_L("Dumping OpenVG strings"));
1.111 +
1.112 + // OpenVG needs a current VG context before it will allow the call to vgGetString
1.113 + EGLConfig currentConfig = eglSess->GetConfigExactMatchL(EPBufferAttribsColor64K);
1.114 + eglSess->CreatePbufferSurfaceAndMakeCurrentL(currentConfig, KPixmapSize, EGL_OPENVG_API);
1.115 +
1.116 + TPtrC8 ptrVgVendor((const TText8 *)vgGetString(VG_VENDOR));
1.117 + DumpString(_L("VG_VENDOR"), ptrVgVendor);
1.118 +
1.119 + TPtrC8 ptrVgRenderer((const TText8 *)vgGetString(VG_RENDERER));
1.120 + DumpString(_L("VG_RENDERER"), ptrVgRenderer);
1.121 +
1.122 + TPtrC8 ptrVgVersion((const TText8 *)vgGetString(VG_VERSION));
1.123 + DumpString(_L("VERSION"), ptrVgVersion);
1.124 +
1.125 + TPtrC8 ptrVgExtensions((const TText8 *)vgGetString(VG_EXTENSIONS));
1.126 + DumpString(_L("VG_EXTENSIONS"), ptrVgExtensions);
1.127 +
1.128 + //cleanup the context & surface
1.129 + eglSess->CleanupSurfaceSgImageL();
1.130 + }
1.131 +
1.132 + // OpenGLES Strings
1.133 + if (ptrEglClientApis.Find(_L8("OpenGL_ES")) >= 0)
1.134 + {
1.135 + INFO_PRINTF1(_L("Dumping OpenGLES strings"));
1.136 +
1.137 + // OpenGLES needs a current GLES context before it will allow the call to glGetString
1.138 + EGLConfig currentConfig = eglSess->GetConfigExactMatchL(EPBufferAttribsColor64K);
1.139 + eglSess->CreatePbufferSurfaceAndMakeCurrentL(currentConfig, KPixmapSize, EGL_OPENGL_ES_API);
1.140 +
1.141 + TPtrC8 ptrGlesVendor((const TText8 *)glGetString(GL_VENDOR));
1.142 + DumpString(_L("GL_VENDOR"), ptrGlesVendor);
1.143 +
1.144 + TPtrC8 ptrGlesRenderer((const TText8 *)glGetString(GL_RENDERER));
1.145 + DumpString(_L("GL_RENDERER"), ptrGlesRenderer);
1.146 +
1.147 + TPtrC8 ptrGlesVersion((const TText8 *)glGetString(GL_VERSION));
1.148 + DumpString(_L("GL_VERSION"), ptrGlesVersion);
1.149 +
1.150 + TPtrC8 ptrGlesExtensions((const TText8 *)glGetString(GL_EXTENSIONS));
1.151 + DumpString(_L("GL_EXTENSIONS"), ptrGlesExtensions);
1.152 +
1.153 + //cleanup the context & surface
1.154 + eglSess->CleanupSurfaceSgImageL();
1.155 + }
1.156 +
1.157 + CleanupStack::PopAndDestroy(eglSess);
1.158 + TerminateDisplayL();
1.159 + RecordTestResultL();
1.160 + CloseTMSGraphicsStep();
1.161 + return TestStepResult();
1.162 + }
1.163 +
1.164 +void CEglTest_DumpStrings::DumpString(const TDesC& aField, const TDesC8& aValue)
1.165 + {
1.166 + const TInt KMaxValueLength = 256;
1.167 + TBuf16<KMaxValueLength> bufValue;
1.168 + bufValue.Copy(aValue.Left(KMaxValueLength));
1.169 + INFO_PRINTF3(_L("%S: \"%S\""), &aField, &bufValue);
1.170 + }
1.171 +
1.172 +/**
1.173 +@SYMTestCaseID GRAPHICS-EGL-0010
1.174 +
1.175 +@SYMTestPriority 1
1.176 +
1.177 +@SYMPREQ 39
1.178 +
1.179 +@SYMREQ See SGL.GT0386.401 document
1.180 +
1.181 +@SYMTestCaseDesc
1.182 +To ensure that eglQueryString() returns the correct information.
1.183 +
1.184 +@SYMTestActions
1.185 +Call eglQueryString() with the EGL_EXTENSIONS parameter
1.186 +
1.187 +@SYMTestExpectedResults
1.188 +The returned space separated list is expected to include the items as defined in the .ini file.
1.189 +This list is implementation specific, so the .ini file can be configured depending on each implementation.
1.190 +As an example, the following ones are expected in most EGL implementations:
1.191 + * EGL_NOK_pixmap_type_rsgimage
1.192 + * EGL_SYMBIAN_COMPOSITION
1.193 + * EGL_KHR_image_base
1.194 + * EGL_KHR_image_pixmap
1.195 + * EGL_KHR_reusable_sync
1.196 +The above list will be configurable on a per-platform basis, via an INI file. If a platform does not support
1.197 +any of the above extensions then it may opt not to test for it via the INI file.
1.198 +*/
1.199 +TVerdict CEglTest_QueryString_Extensions::doTestStepL()
1.200 + {
1.201 + SetTestStepID(_L("GRAPHICS-EGL-0010"));
1.202 + INFO_PRINTF1(_L("CEglTest_QueryString_Extensions::doTestStepL"));
1.203 +
1.204 + TInt numExtensions=0;
1.205 + if (!GetIntFromConfig(ConfigSection(), KKeyCountExtensionsEGL, numExtensions))
1.206 + {
1.207 + ERR_PRINTF2(_L("Cannot find key '%S' in INI file"), &KKeyCountExtensionsEGL);
1.208 + User::Leave(KErrArgument);
1.209 + }
1.210 + INFO_PRINTF2(_L("Looking for %d EGL extensions"), numExtensions);
1.211 + TBuf<32> bufExtensionNameKey;
1.212 + TBuf16<128> bufExtensionNameValue16;
1.213 + TPtrC16 ptrExtensionNameValue16(bufExtensionNameValue16);
1.214 + for(TInt i=0; i<numExtensions; i++)
1.215 + {
1.216 + bufExtensionNameKey.Format(KKeyExtensionEGLX, i);
1.217 + if (!GetStringFromConfig(ConfigSection(), bufExtensionNameKey, ptrExtensionNameValue16))
1.218 + {
1.219 + ERR_PRINTF2(_L("Cannot find key '%S' in INI file"), &bufExtensionNameKey);
1.220 + User::Leave(KErrArgument);
1.221 + }
1.222 + INFO_PRINTF2(_L("Checking for extension \"%S\""), &ptrExtensionNameValue16);
1.223 + TEST(CheckForExtensionL(0, ptrExtensionNameValue16));
1.224 + }
1.225 +
1.226 + numExtensions=0;
1.227 + if (!GetIntFromConfig(ConfigSection(), KKeyCountExtensionsVG, numExtensions))
1.228 + {
1.229 + ERR_PRINTF2(_L("Cannot find key '%S' in INI file"), &KKeyCountExtensionsVG);
1.230 + User::Leave(KErrArgument);
1.231 + }
1.232 + INFO_PRINTF2(_L("Looking for %d VG extensions"), numExtensions);
1.233 + for(TUint i=0; i<numExtensions; i++)
1.234 + {
1.235 + bufExtensionNameKey.Format(KKeyExtensionVGX, i);
1.236 + if (!GetStringFromConfig(ConfigSection(), bufExtensionNameKey, ptrExtensionNameValue16))
1.237 + {
1.238 + ERR_PRINTF2(_L("Cannot find key '%S' in INI file"), &bufExtensionNameKey);
1.239 + User::Leave(KErrArgument);
1.240 + }
1.241 + INFO_PRINTF2(_L("Checking for extension \"%S\""), &ptrExtensionNameValue16);
1.242 + TEST(CheckForExtensionL(0, ptrExtensionNameValue16));
1.243 + }
1.244 +
1.245 + RecordTestResultL();
1.246 + CloseTMSGraphicsStep();
1.247 + return TestStepResult();
1.248 + }
1.249 +
1.250 +/**
1.251 +@SYMTestCaseID GRAPHICS-EGL-0012
1.252 +
1.253 +@SYMTestPriority 3
1.254 +
1.255 +@SYMPREQ 39
1.256 +
1.257 +@SYMREQ ReqNum
1.258 +
1.259 +@SYMTestCaseDesc
1.260 +Ensure that eglGetProcAddress() returns NULL when given invalid data.
1.261 +
1.262 +@SYMTestActions
1.263 +Call eglGetProcAddress() with a <procname> that is known not to be supported - e.g. "qwerty"
1.264 +Call eglGetProcAddress() with an empty <procname> - i.e. ""
1.265 +Call eglGetProcAddress() with a null <procname> - i.e. NULL
1.266 +
1.267 +@SYMTestExpectedResults
1.268 +For each case, eglGetProcAddress() should return NULL, without raising an EGL error.
1.269 +*/
1.270 +TVerdict CEglTest_General_Negative_ProcAddress::doTestStepL()
1.271 + {
1.272 + SetTestStepID(_L("GRAPHICS-EGL-0012"));
1.273 + INFO_PRINTF1(_L("CEglTest_General_Negative_ProcAddress::doTestStepL"));
1.274 +
1.275 + // Create display object
1.276 + GetDisplayL();
1.277 +
1.278 + // Initialize display object
1.279 + INFO_PRINTF1(_L("Calling eglInitialize"));
1.280 + TEST_EGL_ERROR(eglInitialize(iDisplay, NULL, NULL), EGL_SUCCESS);
1.281 +
1.282 + INFO_PRINTF1(_L("Calling eglGetProcAddress() with a 'procname' that is known not to be supported"));
1.283 + TEST_EGL_ERROR(eglGetProcAddress("qwerty") == NULL, EGL_SUCCESS);
1.284 +
1.285 + INFO_PRINTF1(_L("Calling eglGetProcAddress() with an empty 'procname'"));
1.286 + TEST_EGL_ERROR(eglGetProcAddress("") == NULL, EGL_SUCCESS);
1.287 +
1.288 + INFO_PRINTF1(_L("Calling eglGetProcAddress() with a null 'procname'"));
1.289 + TEST_EGL_ERROR(eglGetProcAddress(NULL) == NULL, EGL_SUCCESS);
1.290 +
1.291 + TerminateDisplayL();
1.292 + RecordTestResultL();
1.293 + CloseTMSGraphicsStep();
1.294 + return TestStepResult();
1.295 + }
1.296 +
1.297 +
1.298 +/**
1.299 +@SYMTestCaseID GRAPHICS-EGL-0309
1.300 +
1.301 +@SYMPREQ PREQ2650
1.302 +
1.303 +@SYMTestCaseDesc
1.304 +1. EglTerminate() with an invalid/non-existant display
1.305 +2. Double eglTerminate() with an uninitialised display
1.306 +3. Double eglTerminate() with an initialised display
1.307 +
1.308 +@SYMTestPriority High
1.309 +
1.310 +@SYMTestStatus Implemented
1.311 +
1.312 +@SYMTestActions
1.313 +1. Call eglTerminate with an invalid display handle argument. Call eglTerminate with EGL_NO_DISPLAY argument
1.314 +2. Create an uninitialised display and call eglTerminate() twice. Re-create and terminate the display to check for memory leaks.
1.315 +3. Create an initialised display and call eglTerminate() twice. Re-create and terminate the display to check for memory leaks.
1.316 +
1.317 +@SYMTestExpectedResults
1.318 +1. eglTerminate should return EGL_FALSE on both calls with error EGL_BAD_DISPLAY
1.319 +2. eglTerminate should return EGL_TRUE on all calls and the display should not be set to EGL_NO_DISPLAY.
1.320 +3. eglTerminate should return EGL_TRUE on all calls and the display should not be set to EGL_NO_DISPLAY.
1.321 +The UHEAP markers should indicate no memory leaks after this test case has run.
1.322 +*/
1.323 +TVerdict CEglTest_EglTerminate_Negative::doTestStepL()
1.324 + {
1.325 + INFO_PRINTF1(_L("CEglTest_EglTerminate_Negative::doTestStepL"));
1.326 + SetTestStepID(_L("GRAPHICS-EGL-0309"));
1.327 +
1.328 + //Test 1 - Arbitrary invalid display handle
1.329 + const EGLDisplay invalidDisplay = 77;
1.330 +
1.331 + //Call eglTerminate with the invalid display handle
1.332 + TEST(eglTerminate(invalidDisplay) == EGL_FALSE);
1.333 + ASSERT_EGL_ERROR(EGL_BAD_DISPLAY);
1.334 +
1.335 + //Call eglTerminate with argument EGL_NO_DISPLAY
1.336 + TEST(eglTerminate(EGL_NO_DISPLAY) == EGL_FALSE);
1.337 + ASSERT_EGL_ERROR(EGL_BAD_DISPLAY);
1.338 +
1.339 + //Test 2 - Create display object
1.340 + iDisplay = EGL_NO_DISPLAY;
1.341 + GetDisplayL();
1.342 +
1.343 + //Call eglTerminate twice
1.344 + ASSERT_EGL_TRUE(eglTerminate(iDisplay));
1.345 + TEST(eglGetError() == EGL_SUCCESS);
1.346 +
1.347 + ASSERT_EGL_TRUE(eglTerminate(iDisplay));
1.348 + TEST(eglGetError() == EGL_SUCCESS);
1.349 +
1.350 + //Recreate display object and call eglTerminate()
1.351 + iDisplay = EGL_NO_DISPLAY;
1.352 + GetDisplayL();
1.353 + ASSERT_EGL_TRUE(eglTerminate(iDisplay));
1.354 + TEST(eglGetError() == EGL_SUCCESS);
1.355 +
1.356 + //Test 3
1.357 + iDisplay = EGL_NO_DISPLAY;
1.358 + GetDisplayL();
1.359 + CTestEglSession* eglSess = CTestEglSession::NewLC(Logger(), iDisplay, 0);
1.360 +
1.361 + // Initialise the display object
1.362 + eglSess->InitializeL();
1.363 +
1.364 + //Call eglTerminate twice
1.365 + ASSERT_EGL_TRUE(eglTerminate(iDisplay));
1.366 + TEST(eglGetError() == EGL_SUCCESS);
1.367 +
1.368 + ASSERT_EGL_TRUE(eglTerminate(iDisplay));
1.369 + TEST(eglGetError() == EGL_SUCCESS);
1.370 +
1.371 + //Recreate display object
1.372 + iDisplay = EGL_NO_DISPLAY;
1.373 + GetDisplayL();
1.374 +
1.375 + //Call eglTerminate
1.376 + ASSERT_EGL_TRUE(eglTerminate(iDisplay));
1.377 + TEST(eglGetError() == EGL_SUCCESS);
1.378 +
1.379 + //cleanup and stuff...
1.380 + CleanupStack::PopAndDestroy(1, eglSess);
1.381 + ASSERT_EGL_TRUE(eglReleaseThread());
1.382 +
1.383 + RecordTestResultL();
1.384 + CloseTMSGraphicsStep();
1.385 + return TestStepResult();
1.386 + }