os/graphics/egl/egltest/endpointtestsuite/automated/tsrc/egltest_endpointapiexposure_local.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 
    13 
    14 /**
    15  @file
    16  @test
    17  @internalComponent - Internal Symbian test code
    18 */
    19 
    20 
    21 #include "egltest_endpointapiexposure.h"
    22 
    23 
    24 CEglTest_LocalTestStep_EndpointApiExposure::CEglTest_LocalTestStep_EndpointApiExposure() :
    25     CLocalTestStepBase(ETestUidEndpointApiExposure)
    26     {
    27     //Temp solution. We probably want a local side Egl helper class.
    28     //If this fails, the test will fail in a round about way with EGL_NOT_INITIALIZED.
    29     eglInitialize(eglGetDisplay(EGL_DEFAULT_DISPLAY), NULL, NULL);
    30     }
    31 
    32 
    33 CEglTest_LocalTestStep_EndpointApiExposure::~CEglTest_LocalTestStep_EndpointApiExposure()
    34     {
    35     //Temp Solution. See note above.
    36     eglTerminate(eglGetDisplay(EGL_DEFAULT_DISPLAY));
    37     }
    38 
    39 
    40 void CEglTest_LocalTestStep_EndpointApiExposure::DoPreambleL()
    41     {
    42     //Register the test id.
    43     _LIT(KTestId, "563");
    44     RegisterTestIdsL(KTestId);
    45     SetCurrentTestIds(KTestId);
    46     }
    47 
    48 
    49 TVerdict CEglTest_LocalTestStep_EndpointApiExposure::doTestStepL()
    50     {
    51     //First, test the local side.
    52 
    53     //temp solution. We probably want an Egl helper class for the local side too.
    54     eglInitialize(eglGetDisplay(EGL_DEFAULT_DISPLAY), NULL, NULL);
    55 
    56     //Check that the extension does not exist in the egl implementation.
    57     TPtrC8 extensionString((TUint8*)eglQueryString(eglGetDisplay(EGL_DEFAULT_DISPLAY), EGL_EXTENSIONS));
    58     _LIT8(KExtensionName, "EGL_NOK_image_endpoint");
    59     if(extensionString.Find(KExtensionName) != KErrNotFound)
    60         {
    61         ERR_PRINTF1(_L("Incorrect result for extensionString"));
    62         INFO_PRINTF1(_L("Rest of test is being skipped due to failure."));
    63         eglTerminate(eglGetDisplay(EGL_DEFAULT_DISPLAY));
    64         SetTestStepResult(EFail);
    65         return TestStepResult();
    66         }
    67     else
    68         {
    69         INFO_PRINTF1(_L("Correct result for extensionString"));
    70         }
    71 
    72     //If this function leaves, a function pointer was returned from EGL.
    73     //Since we are outside wserv, we expect EGL never to advertise the existance
    74     //of the Endpoint API.
    75     TRAPD(err, AttemptToGetProcAddressForAllEndpointFunctionsL());
    76     if(err != KErrNone)
    77         {
    78         INFO_PRINTF1(_L("Rest of test is being skipped due to failure."));
    79         eglTerminate(eglGetDisplay(EGL_DEFAULT_DISPLAY));
    80         SetTestStepResult(EFail);
    81         return TestStepResult();
    82         }
    83 
    84     eglTerminate(eglGetDisplay(EGL_DEFAULT_DISPLAY));
    85 
    86 
    87     //Now test remote side.
    88 
    89     //Params for the remote test step.
    90     TRemoteTestParams params;
    91 
    92     //Run the test step and return the result.
    93     StartRemoteTestStep(TRemoteTestParams());
    94     RunRemoteTestCase(0, params);
    95     EndRemoteTestStep(TRemoteTestParams());
    96 
    97     return TestStepResult();
    98     }
    99 
   100 
   101 void CEglTest_LocalTestStep_EndpointApiExposure::AttemptToGetProcAddressForAllEndpointFunctionsL()
   102     {
   103     //Attempt to get the proc address for each endpoint function. The expected outcome is
   104     //for them all to fail. If any succeed, ProcAddressL() will leave.
   105     ProcAddressL("eglCreateEndpointNOK");
   106     ProcAddressL("eglDestroyEndpointNOK");
   107     ProcAddressL("eglGetEndpointAttribNOK");
   108     ProcAddressL("eglSetEndpointAttribNOK");
   109     ProcAddressL("eglEndpointBeginStreamingNOK");
   110     ProcAddressL("eglEndpointEndStreamingNOK");
   111     ProcAddressL("eglAcquireImageNOK");
   112     ProcAddressL("eglReleaseImageNOK");
   113     ProcAddressL("eglGetEndpointDirtyAreaNOK");
   114     ProcAddressL("eglEndpointRequestNotificationNOK");
   115     ProcAddressL("eglEndpointCancelNotificationNOK");
   116     }
   117 
   118 
   119 void CEglTest_LocalTestStep_EndpointApiExposure::ProcAddressL(const char *aProcName)
   120     {
   121     //Convert the 8bit string to a 16 bit descriptor for logging.
   122     //None of the function names are longer than 128 chars.
   123     TBuf<128> procName;
   124     procName.Copy(TPtrC8((TText8*)aProcName));
   125 
   126     //Attempt to get the function pointer. We are expecting to fail since we are outside wserv.
   127     if(eglGetProcAddress(aProcName) != NULL)
   128         {
   129         ERR_PRINTF2(_L("Incorrect result for funcPtr: %S"), &procName);
   130         User::Leave(KErrUnknown);
   131         }
   132     else
   133         {
   134         INFO_PRINTF2(_L("Correct result for funcPtr: %S"), &procName);
   135         }
   136     }
   137