os/graphics/egl/egltest/src/egltestcommonprocess.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) 2007-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
*/
sl@0
    20
sl@0
    21
sl@0
    22
#include <e32debug.h>
sl@0
    23
sl@0
    24
#include "egltestcommonprocess.h"
sl@0
    25
#include "egltestcommonstep.h"
sl@0
    26
sl@0
    27
// static
sl@0
    28
void EglTestCommonProcess::MainL()
sl@0
    29
	{
sl@0
    30
	TPckgBuf<TProcessInfo> pckgInfo;
sl@0
    31
	TInt ret = User::GetDesParameter(EProcSlotParams, pckgInfo);
sl@0
    32
	User::LeaveIfError(ret);
sl@0
    33
	TProcessInfo& info = pckgInfo();
sl@0
    34
	
sl@0
    35
	TBuf<200> bufTestDllName;
sl@0
    36
	ret = User::GetDesParameter(EProcSlotTestDllName, bufTestDllName);
sl@0
    37
	User::LeaveIfError(ret);
sl@0
    38
sl@0
    39
    TBuf<200> bufTestStepName;
sl@0
    40
    ret = User::GetDesParameter(EProcSlotTestStepName, bufTestStepName);
sl@0
    41
    User::LeaveIfError(ret);
sl@0
    42
sl@0
    43
#ifdef __WINS__
sl@0
    44
	// Construct and destroy a process-wide state object in emulator builds.
sl@0
    45
	// This will cause initialisation of PLS for EGL and SgDriver
sl@0
    46
	// and allow checking for leaks in tests
sl@0
    47
	eglReleaseThread();
sl@0
    48
#endif //__WINS__ 
sl@0
    49
sl@0
    50
    // Create test step and perform CTestStep style initialisation (e.g. logging)
sl@0
    51
	CEglTestStep* testStep = NULL;
sl@0
    52
    RLibrary library;
sl@0
    53
    if(library.Load(bufTestDllName) == KErrNone)
sl@0
    54
        {
sl@0
    55
        typedef CEglTestStep* (* TFnPtrGetEglTestStep) (const TDesC&);
sl@0
    56
        TFnPtrGetEglTestStep fnGetEglTestStep = reinterpret_cast<TFnPtrGetEglTestStep>(library.Lookup(1));
sl@0
    57
        testStep = fnGetEglTestStep(bufTestStepName);
sl@0
    58
        }
sl@0
    59
	
sl@0
    60
	if (testStep == NULL)
sl@0
    61
		{
sl@0
    62
		User::Leave(KErrNotFound);
sl@0
    63
		}
sl@0
    64
	CleanupStack::PushL(testStep);
sl@0
    65
sl@0
    66
	// perform CTestStep style initialisation (e.g. logging)
sl@0
    67
	testStep->PartialInitialiseL(bufTestStepName);
sl@0
    68
	
sl@0
    69
	User::LeaveIfError(testStep->iSemaphore[0].Open(EProcSlotSemaphore0, EOwnerThread));
sl@0
    70
	User::LeaveIfError(testStep->iSemaphore[1].Open(EProcSlotSemaphore1, EOwnerThread));
sl@0
    71
		
sl@0
    72
	// perform CTestStep pre-amble
sl@0
    73
	User::LeaveIfError(testStep->doTestStepPreambleL());
sl@0
    74
	
sl@0
    75
#ifdef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
sl@0
    76
	TBool sgIdHasBeenPassed = info.iSgId.iId != TUint64(0);
sl@0
    77
#else
sl@0
    78
	TBool sgIdHasBeenPassed = EFalse;
sl@0
    79
	for(TUint i = 0; i < 5; i++)
sl@0
    80
		{
sl@0
    81
		if((info.iSgId).iId[i] != 0)
sl@0
    82
			{
sl@0
    83
			sgIdHasBeenPassed = ETrue;
sl@0
    84
			break;
sl@0
    85
			}		
sl@0
    86
		}
sl@0
    87
#endif //SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
sl@0
    88
	
sl@0
    89
	if(!sgIdHasBeenPassed)
sl@0
    90
		{
sl@0
    91
		testStep->doProcessFunctionL(info.iIdx);
sl@0
    92
		}
sl@0
    93
	else
sl@0
    94
		{
sl@0
    95
		testStep->doProcessFunctionL(info.iIdx, info.iSgId);
sl@0
    96
		}
sl@0
    97
sl@0
    98
	// perform CTestStep post-amble
sl@0
    99
	User::LeaveIfError(testStep->doTestStepPostambleL());
sl@0
   100
	
sl@0
   101
	//clean-up
sl@0
   102
	CleanupStack::PopAndDestroy(testStep);
sl@0
   103
	}
sl@0
   104
sl@0
   105
sl@0
   106
GLDEF_C TInt E32Main()
sl@0
   107
	{
sl@0
   108
	//When EGL Logging is enabled this causes a file server session to be allocated
sl@0
   109
	//Which needs to be done before any allocation checks otherwise the test will fail
sl@0
   110
	eglReleaseThread();
sl@0
   111
sl@0
   112
	__UHEAP_MARK;
sl@0
   113
	CTrapCleanup* cleanup = CTrapCleanup::New();
sl@0
   114
	if(cleanup == NULL)
sl@0
   115
		{
sl@0
   116
		return KErrNoMemory;
sl@0
   117
		}
sl@0
   118
	
sl@0
   119
	TRAPD(err, EglTestCommonProcess::MainL());
sl@0
   120
	
sl@0
   121
	delete cleanup;
sl@0
   122
	__UHEAP_MARKEND;
sl@0
   123
sl@0
   124
	return err;	
sl@0
   125
	}