os/graphics/graphicshwdrivers/surfacemgr/test/src/tsurfacemanagerserver.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/graphics/graphicshwdrivers/surfacemgr/test/src/tsurfacemanagerserver.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,117 @@
     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 + @internalComponent Internal Symbian test code
    1.23 +*/
    1.24 +
    1.25 +#include "tsurfacemanagerserver.h"
    1.26 +#include "tsurfacemanager.h"
    1.27 +#include "tsurfacemanagermultithread.h" 
    1.28 +#include "tsurfacemanagermultiprocess.h"
    1.29 +
    1.30 +CTSurfaceManagerServer* CTSurfaceManagerServer::NewL()
    1.31 +/**
    1.32 +   @return - Instance of the test server
    1.33 +   Same code for Secure and non-secure variants
    1.34 +   Called inside the MainL() function to create and start the
    1.35 +   CTestServer derived server.
    1.36 + */
    1.37 +	{
    1.38 +	CTSurfaceManagerServer * server = new (ELeave) CTSurfaceManagerServer();
    1.39 +	CleanupStack::PushL(server);
    1.40 +	
    1.41 +	// Get server name from process so we can use SetCap to change the capabilites and use this server with a different filename
    1.42 +	RProcess handle = RProcess();
    1.43 +	TParsePtrC serverName(handle.FileName());
    1.44 +	
    1.45 +	// CServer base class call
    1.46 +	server->StartL(serverName.Name());
    1.47 +	CleanupStack::Pop(server);
    1.48 +	return server;
    1.49 +	}
    1.50 +
    1.51 +
    1.52 +LOCAL_C void MainL()
    1.53 +//
    1.54 +// Secure variant
    1.55 +// Much simpler, uses the new Rendezvous() call to sync with the client
    1.56 +//
    1.57 +	{
    1.58 + 	RProcess().DataCaging(RProcess::EDataCagingOn);
    1.59 +	RProcess().SecureApi(RProcess::ESecureApiOn);
    1.60 +	CActiveScheduler* sched=NULL;
    1.61 +	sched=new(ELeave) CActiveScheduler;
    1.62 +	CActiveScheduler::Install(sched);
    1.63 +	CTSurfaceManagerServer* server = NULL;
    1.64 +	// Create the CTestServer derived server
    1.65 +	TRAPD(err,server = CTSurfaceManagerServer::NewL());
    1.66 +	if(!err)
    1.67 +		{
    1.68 +		// Sync with the client and enter the active scheduler
    1.69 +		RProcess::Rendezvous(KErrNone);
    1.70 +		sched->Start();
    1.71 +		}
    1.72 +	delete server;
    1.73 +	delete sched;
    1.74 +	}
    1.75 +
    1.76 +/** @return - Standard Epoc error code on process exit
    1.77 +    Secure variant only
    1.78 +    Process entry point. Called by client using RProcess API
    1.79 +*/
    1.80 +GLDEF_C TInt E32Main()
    1.81 +	{
    1.82 +	__UHEAP_MARK;
    1.83 +	CTrapCleanup* cleanup = CTrapCleanup::New();
    1.84 +	if(cleanup == NULL)
    1.85 +		{
    1.86 +		return KErrNoMemory;
    1.87 +		}
    1.88 +	TRAPD(err,MainL());
    1.89 +	if (err)
    1.90 +	    {
    1.91 +		RDebug::Print(_L("CTSurfaceManagerServer::MainL - Error: %d"), err);
    1.92 +	   	User::Panic(_L("CTSurfaceManagerServer"),err);
    1.93 +	    }
    1.94 +	delete cleanup;
    1.95 +	__UHEAP_MARKEND;
    1.96 +	return KErrNone;
    1.97 +    }
    1.98 +
    1.99 +CTestStep* CTSurfaceManagerServer::CreateTestStep(const TDesC& aStepName)
   1.100 +/**
   1.101 +   @return - A CTestStep derived instance
   1.102 +   Secure and non-secure variants
   1.103 +   Implementation of CTestServer pure virtual
   1.104 + */
   1.105 +	{
   1.106 +	if(aStepName == KTSurfaceManagerStep)
   1.107 +		{
   1.108 +		return new CTSurfaceManagerStep();
   1.109 +		}
   1.110 +	else if(aStepName == KTSurfaceManagerMultiThreadStep)
   1.111 +		{
   1.112 +		return new CTSurfaceManagerMultiThreadStep();
   1.113 +		}
   1.114 +	else if(aStepName == KTSurfaceManagerMultiProcessStep)
   1.115 +		{
   1.116 +		return new CTSurfaceManagerMultiProcessStep();
   1.117 +		}
   1.118 +    return NULL;
   1.119 +	}
   1.120 +