os/graphics/graphicsresourceservices/graphicsresourceimplementation/test/src/tgraphicsresourceinternalserver.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 "tgraphicsresourceinternalserver.h"
    23 #include "tgraphicsresourceinternal.h"
    24 
    25 /**
    26    @return - Instance of the test server
    27    Same code for Secure and non-secure variants
    28    Called inside the MainL() function to create and start the
    29    CTestServer derived server.
    30  */
    31 CTGraphicsResourceInternalServer* CTGraphicsResourceInternalServer::NewL()
    32 	{
    33 	CTGraphicsResourceInternalServer * server = new (ELeave) CTGraphicsResourceInternalServer();
    34 	CleanupStack::PushL(server);
    35 	
    36 	// Get server name from process so we can use SetCap to change the capabilites and use this server with a different filename
    37 	RProcess handle = RProcess();
    38 	TParsePtrC serverName(handle.FileName());
    39 	
    40 	// CServer base class call
    41 	server->StartL(serverName.Name());
    42 	CleanupStack::Pop(server);
    43 	return server;
    44 	}
    45 
    46 LOCAL_C void MainL()
    47 	{
    48 	CActiveScheduler* sched = new(ELeave) CActiveScheduler;
    49   	CActiveScheduler::Install(sched);
    50 
    51   	CTGraphicsResourceInternalServer* server = NULL;
    52 	// Create the CTestServer derived server
    53 	TRAPD(err,server = CTGraphicsResourceInternalServer::NewL());
    54 	if(err == KErrNone)
    55 		{
    56 		// Sync with the client
    57 		RProcess::Rendezvous(KErrNone);
    58 		sched->Start();
    59 		}
    60 	delete server;
    61 	delete sched;
    62 	}
    63 
    64 /**
    65 @return - Standard Epoc error code on process exit
    66 */
    67 GLDEF_C TInt E32Main()
    68 	{
    69 	__UHEAP_MARK;
    70 	CTrapCleanup* cleanup = CTrapCleanup::New();
    71 	if(cleanup == NULL)
    72 		{
    73 		return KErrNoMemory;
    74 		}
    75 	TRAPD(err,MainL());
    76 	if (err != KErrNone)
    77 	    {
    78 	    RProcess handle = RProcess();
    79 		TParsePtrC serverName(handle.FileName());
    80 	   	User::Panic(serverName.Name(),err);
    81 	    }
    82 	delete cleanup;
    83 	__UHEAP_MARKEND;
    84 	return KErrNone;
    85     }
    86 
    87 /**
    88 @return - A CTestStep derived instance
    89  */
    90 CTestStep* CTGraphicsResourceInternalServer::CreateTestStep(const TDesC& aStepName)
    91 	{
    92 	CTestStep* testStep = NULL;
    93 
    94 	if(aStepName == KTGraphicsResourceInternalStep)
    95 		{
    96 		testStep = new CTGraphicsResourceInternal();
    97 		}
    98 
    99 	return testStep;
   100 	}