os/graphics/egl/egltest/endpointtestsuite/automated/tsrc/egltest_endpointapiexposure_local.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/graphics/egl/egltest/endpointtestsuite/automated/tsrc/egltest_endpointapiexposure_local.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,137 @@
     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 +
    1.17 +/**
    1.18 + @file
    1.19 + @test
    1.20 + @internalComponent - Internal Symbian test code
    1.21 +*/
    1.22 +
    1.23 +
    1.24 +#include "egltest_endpointapiexposure.h"
    1.25 +
    1.26 +
    1.27 +CEglTest_LocalTestStep_EndpointApiExposure::CEglTest_LocalTestStep_EndpointApiExposure() :
    1.28 +    CLocalTestStepBase(ETestUidEndpointApiExposure)
    1.29 +    {
    1.30 +    //Temp solution. We probably want a local side Egl helper class.
    1.31 +    //If this fails, the test will fail in a round about way with EGL_NOT_INITIALIZED.
    1.32 +    eglInitialize(eglGetDisplay(EGL_DEFAULT_DISPLAY), NULL, NULL);
    1.33 +    }
    1.34 +
    1.35 +
    1.36 +CEglTest_LocalTestStep_EndpointApiExposure::~CEglTest_LocalTestStep_EndpointApiExposure()
    1.37 +    {
    1.38 +    //Temp Solution. See note above.
    1.39 +    eglTerminate(eglGetDisplay(EGL_DEFAULT_DISPLAY));
    1.40 +    }
    1.41 +
    1.42 +
    1.43 +void CEglTest_LocalTestStep_EndpointApiExposure::DoPreambleL()
    1.44 +    {
    1.45 +    //Register the test id.
    1.46 +    _LIT(KTestId, "563");
    1.47 +    RegisterTestIdsL(KTestId);
    1.48 +    SetCurrentTestIds(KTestId);
    1.49 +    }
    1.50 +
    1.51 +
    1.52 +TVerdict CEglTest_LocalTestStep_EndpointApiExposure::doTestStepL()
    1.53 +    {
    1.54 +    //First, test the local side.
    1.55 +
    1.56 +    //temp solution. We probably want an Egl helper class for the local side too.
    1.57 +    eglInitialize(eglGetDisplay(EGL_DEFAULT_DISPLAY), NULL, NULL);
    1.58 +
    1.59 +    //Check that the extension does not exist in the egl implementation.
    1.60 +    TPtrC8 extensionString((TUint8*)eglQueryString(eglGetDisplay(EGL_DEFAULT_DISPLAY), EGL_EXTENSIONS));
    1.61 +    _LIT8(KExtensionName, "EGL_NOK_image_endpoint");
    1.62 +    if(extensionString.Find(KExtensionName) != KErrNotFound)
    1.63 +        {
    1.64 +        ERR_PRINTF1(_L("Incorrect result for extensionString"));
    1.65 +        INFO_PRINTF1(_L("Rest of test is being skipped due to failure."));
    1.66 +        eglTerminate(eglGetDisplay(EGL_DEFAULT_DISPLAY));
    1.67 +        SetTestStepResult(EFail);
    1.68 +        return TestStepResult();
    1.69 +        }
    1.70 +    else
    1.71 +        {
    1.72 +        INFO_PRINTF1(_L("Correct result for extensionString"));
    1.73 +        }
    1.74 +
    1.75 +    //If this function leaves, a function pointer was returned from EGL.
    1.76 +    //Since we are outside wserv, we expect EGL never to advertise the existance
    1.77 +    //of the Endpoint API.
    1.78 +    TRAPD(err, AttemptToGetProcAddressForAllEndpointFunctionsL());
    1.79 +    if(err != KErrNone)
    1.80 +        {
    1.81 +        INFO_PRINTF1(_L("Rest of test is being skipped due to failure."));
    1.82 +        eglTerminate(eglGetDisplay(EGL_DEFAULT_DISPLAY));
    1.83 +        SetTestStepResult(EFail);
    1.84 +        return TestStepResult();
    1.85 +        }
    1.86 +
    1.87 +    eglTerminate(eglGetDisplay(EGL_DEFAULT_DISPLAY));
    1.88 +
    1.89 +
    1.90 +    //Now test remote side.
    1.91 +
    1.92 +    //Params for the remote test step.
    1.93 +    TRemoteTestParams params;
    1.94 +
    1.95 +    //Run the test step and return the result.
    1.96 +    StartRemoteTestStep(TRemoteTestParams());
    1.97 +    RunRemoteTestCase(0, params);
    1.98 +    EndRemoteTestStep(TRemoteTestParams());
    1.99 +
   1.100 +    return TestStepResult();
   1.101 +    }
   1.102 +
   1.103 +
   1.104 +void CEglTest_LocalTestStep_EndpointApiExposure::AttemptToGetProcAddressForAllEndpointFunctionsL()
   1.105 +    {
   1.106 +    //Attempt to get the proc address for each endpoint function. The expected outcome is
   1.107 +    //for them all to fail. If any succeed, ProcAddressL() will leave.
   1.108 +    ProcAddressL("eglCreateEndpointNOK");
   1.109 +    ProcAddressL("eglDestroyEndpointNOK");
   1.110 +    ProcAddressL("eglGetEndpointAttribNOK");
   1.111 +    ProcAddressL("eglSetEndpointAttribNOK");
   1.112 +    ProcAddressL("eglEndpointBeginStreamingNOK");
   1.113 +    ProcAddressL("eglEndpointEndStreamingNOK");
   1.114 +    ProcAddressL("eglAcquireImageNOK");
   1.115 +    ProcAddressL("eglReleaseImageNOK");
   1.116 +    ProcAddressL("eglGetEndpointDirtyAreaNOK");
   1.117 +    ProcAddressL("eglEndpointRequestNotificationNOK");
   1.118 +    ProcAddressL("eglEndpointCancelNotificationNOK");
   1.119 +    }
   1.120 +
   1.121 +
   1.122 +void CEglTest_LocalTestStep_EndpointApiExposure::ProcAddressL(const char *aProcName)
   1.123 +    {
   1.124 +    //Convert the 8bit string to a 16 bit descriptor for logging.
   1.125 +    //None of the function names are longer than 128 chars.
   1.126 +    TBuf<128> procName;
   1.127 +    procName.Copy(TPtrC8((TText8*)aProcName));
   1.128 +
   1.129 +    //Attempt to get the function pointer. We are expecting to fail since we are outside wserv.
   1.130 +    if(eglGetProcAddress(aProcName) != NULL)
   1.131 +        {
   1.132 +        ERR_PRINTF2(_L("Incorrect result for funcPtr: %S"), &procName);
   1.133 +        User::Leave(KErrUnknown);
   1.134 +        }
   1.135 +    else
   1.136 +        {
   1.137 +        INFO_PRINTF2(_L("Correct result for funcPtr: %S"), &procName);
   1.138 +        }
   1.139 +    }
   1.140 +