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