os/graphics/egl/egltest/src/egltestcommonprocess.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/graphics/egl/egltest/src/egltestcommonprocess.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,125 @@
     1.4 +// Copyright (c) 2007-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 +
    1.25 +#include <e32debug.h>
    1.26 +
    1.27 +#include "egltestcommonprocess.h"
    1.28 +#include "egltestcommonstep.h"
    1.29 +
    1.30 +// static
    1.31 +void EglTestCommonProcess::MainL()
    1.32 +	{
    1.33 +	TPckgBuf<TProcessInfo> pckgInfo;
    1.34 +	TInt ret = User::GetDesParameter(EProcSlotParams, pckgInfo);
    1.35 +	User::LeaveIfError(ret);
    1.36 +	TProcessInfo& info = pckgInfo();
    1.37 +	
    1.38 +	TBuf<200> bufTestDllName;
    1.39 +	ret = User::GetDesParameter(EProcSlotTestDllName, bufTestDllName);
    1.40 +	User::LeaveIfError(ret);
    1.41 +
    1.42 +    TBuf<200> bufTestStepName;
    1.43 +    ret = User::GetDesParameter(EProcSlotTestStepName, bufTestStepName);
    1.44 +    User::LeaveIfError(ret);
    1.45 +
    1.46 +#ifdef __WINS__
    1.47 +	// Construct and destroy a process-wide state object in emulator builds.
    1.48 +	// This will cause initialisation of PLS for EGL and SgDriver
    1.49 +	// and allow checking for leaks in tests
    1.50 +	eglReleaseThread();
    1.51 +#endif //__WINS__ 
    1.52 +
    1.53 +    // Create test step and perform CTestStep style initialisation (e.g. logging)
    1.54 +	CEglTestStep* testStep = NULL;
    1.55 +    RLibrary library;
    1.56 +    if(library.Load(bufTestDllName) == KErrNone)
    1.57 +        {
    1.58 +        typedef CEglTestStep* (* TFnPtrGetEglTestStep) (const TDesC&);
    1.59 +        TFnPtrGetEglTestStep fnGetEglTestStep = reinterpret_cast<TFnPtrGetEglTestStep>(library.Lookup(1));
    1.60 +        testStep = fnGetEglTestStep(bufTestStepName);
    1.61 +        }
    1.62 +	
    1.63 +	if (testStep == NULL)
    1.64 +		{
    1.65 +		User::Leave(KErrNotFound);
    1.66 +		}
    1.67 +	CleanupStack::PushL(testStep);
    1.68 +
    1.69 +	// perform CTestStep style initialisation (e.g. logging)
    1.70 +	testStep->PartialInitialiseL(bufTestStepName);
    1.71 +	
    1.72 +	User::LeaveIfError(testStep->iSemaphore[0].Open(EProcSlotSemaphore0, EOwnerThread));
    1.73 +	User::LeaveIfError(testStep->iSemaphore[1].Open(EProcSlotSemaphore1, EOwnerThread));
    1.74 +		
    1.75 +	// perform CTestStep pre-amble
    1.76 +	User::LeaveIfError(testStep->doTestStepPreambleL());
    1.77 +	
    1.78 +#ifdef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
    1.79 +	TBool sgIdHasBeenPassed = info.iSgId.iId != TUint64(0);
    1.80 +#else
    1.81 +	TBool sgIdHasBeenPassed = EFalse;
    1.82 +	for(TUint i = 0; i < 5; i++)
    1.83 +		{
    1.84 +		if((info.iSgId).iId[i] != 0)
    1.85 +			{
    1.86 +			sgIdHasBeenPassed = ETrue;
    1.87 +			break;
    1.88 +			}		
    1.89 +		}
    1.90 +#endif //SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
    1.91 +	
    1.92 +	if(!sgIdHasBeenPassed)
    1.93 +		{
    1.94 +		testStep->doProcessFunctionL(info.iIdx);
    1.95 +		}
    1.96 +	else
    1.97 +		{
    1.98 +		testStep->doProcessFunctionL(info.iIdx, info.iSgId);
    1.99 +		}
   1.100 +
   1.101 +	// perform CTestStep post-amble
   1.102 +	User::LeaveIfError(testStep->doTestStepPostambleL());
   1.103 +	
   1.104 +	//clean-up
   1.105 +	CleanupStack::PopAndDestroy(testStep);
   1.106 +	}
   1.107 +
   1.108 +
   1.109 +GLDEF_C TInt E32Main()
   1.110 +	{
   1.111 +	//When EGL Logging is enabled this causes a file server session to be allocated
   1.112 +	//Which needs to be done before any allocation checks otherwise the test will fail
   1.113 +	eglReleaseThread();
   1.114 +
   1.115 +	__UHEAP_MARK;
   1.116 +	CTrapCleanup* cleanup = CTrapCleanup::New();
   1.117 +	if(cleanup == NULL)
   1.118 +		{
   1.119 +		return KErrNoMemory;
   1.120 +		}
   1.121 +	
   1.122 +	TRAPD(err, EglTestCommonProcess::MainL());
   1.123 +	
   1.124 +	delete cleanup;
   1.125 +	__UHEAP_MARKEND;
   1.126 +
   1.127 +	return err;	
   1.128 +	}