os/graphics/egl/egltest/endpointtestsuite/automated/tsrc/egltest_endpointimagelifetime.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.
     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 // Description:
    14 //
    15 
    16 /**
    17  @file
    18  @test
    19  @internalComponent - Internal Symbian test code
    20 */
    21 
    22 #include "egltest_endpointimage.h"
    23 #include "egltest_surface.h"
    24 #include "egltest_endpoint_util.h"
    25 
    26 CEglTest_LocalTestStep_EndpointImageLifetimeProcess::CEglTest_LocalTestStep_EndpointImageLifetimeProcess()
    27     {
    28     TRAPD(err, TEndpointUtil::SetLoggerForProcessWrapperL(Logger()));
    29     if (err != KErrNone)
    30         {
    31         RDebug::Printf("Logging is not set up... Err = %d. Panicking...", err);
    32         ENGINE_ASSERT(0);
    33         }
    34     }
    35 
    36 
    37 //function used for creating the queues.
    38 TVerdict CEglTest_LocalTestStep_EndpointImageLifetimeProcess::doTestStepPreambleL()
    39     {
    40     //Open the queues.
    41     User::LeaveIfError(iResultOutQueue.OpenGlobal(KResultProcessQueueName));
    42     User::LeaveIfError(iParamsInQueue.OpenGlobal(KParamsProcessQueueName));
    43     SetTestStepResult(EPass);
    44     return EPass;
    45     }
    46 
    47 TVerdict CEglTest_LocalTestStep_EndpointImageLifetimeProcess::doTestStepPostambleL()
    48     {
    49     iResultOutQueue.Close();
    50     iParamsInQueue.Close();
    51     return EPass;
    52     }
    53 
    54 CEglTest_LocalTestStep_EndpointImageLifetimeProcess::~CEglTest_LocalTestStep_EndpointImageLifetimeProcess()
    55     {
    56     //closing an already closed handle is harmless
    57     iResultOutQueue.Close();
    58     iParamsInQueue.Close();
    59     }
    60 
    61 
    62 TVerdict CEglTest_LocalTestStep_EndpointImageLifetimeProcess::doTestStepL()
    63     {
    64     EGLDisplay dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY);
    65 
    66     if (!eglInitialize(dpy, NULL, NULL))
    67         {
    68         INFO_PRINTF2(_L("EglInitialize failed, error %x"), eglGetError());
    69         User::Leave(KErrNotFound);
    70         }
    71 
    72     TInt surfType;
    73     iResultOutQueue.ReceiveBlocking(surfType);
    74 
    75     CSurface *surface = CSurface::SurfaceFactoryL(static_cast<TSurfaceType>(surfType));
    76     CleanupStack::PushL(surface);
    77 
    78     surface->CreateL(EStandardSurface);
    79     INFO_PRINTF2(_L("Using surface type %s"), surface->GetSurfaceTypeStr());
    80     TSurfaceId id = surface->SurfaceId();
    81     iParamsInQueue.SendBlocking(id);
    82 
    83     TInt result;
    84     iResultOutQueue.ReceiveBlocking(result);
    85 
    86     // Draw something.
    87     surface->DrawContentL(0);
    88     User::LeaveIfError(surface->SubmitContent(ETrue));
    89 
    90     if (result)
    91         {
    92         User::Panic(_L("Expected Panic"), 1);
    93         }
    94 
    95     eglTerminate(dpy);
    96     eglReleaseThread();
    97     CleanupStack::PopAndDestroy(surface);
    98     return EPass;
    99     }
   100 
   101 
   102 // static
   103 void CEglTest_LocalTestStep_EndpointImageLifetimeProcess::MainL()
   104     {
   105 #ifdef __WINS__
   106     // Construct and destroy a process-wide state object in emulator builds.
   107     // This will cause initialisation of PLS for EGL and SgDriver
   108     // and allow checking for leaks in tests
   109     eglReleaseThread();
   110 #endif //__WINS__
   111 
   112     // Create test step and perform CTestStep style initialisation (e.g. logging)
   113     CEglTest_LocalTestStep_EndpointImageLifetimeProcess* testStep = new CEglTest_LocalTestStep_EndpointImageLifetimeProcess();
   114     if (testStep == NULL)
   115         {
   116         User::Leave(KErrNotFound);
   117         }
   118     CleanupStack::PushL(testStep);
   119 
   120     // perform CTestStep pre-amble
   121     User::LeaveIfError(testStep->doTestStepPreambleL());
   122 
   123     testStep->doTestStepL();
   124     // perform CTestStep post-amble
   125     User::LeaveIfError(testStep->doTestStepPostambleL());
   126 
   127     //clean-up
   128     CleanupStack::PopAndDestroy(testStep);
   129     }
   130 
   131 
   132 GLDEF_C TInt E32Main()
   133     {
   134     //When EGL Logging is enabled this causes a file server session to be allocated
   135     //Which needs to be done before any allocation checks otherwise the test will fail
   136     eglReleaseThread();
   137 
   138     __UHEAP_MARK;
   139     CTrapCleanup* cleanup = CTrapCleanup::New();
   140     if(cleanup == NULL)
   141         {
   142         return KErrNoMemory;
   143         }
   144 
   145     TRAPD(err, CEglTest_LocalTestStep_EndpointImageLifetimeProcess::MainL());
   146 
   147     delete cleanup;
   148     __UHEAP_MARKEND;
   149 
   150     return err;
   151     }
   152 
   153