graphicstest/uibench/src/tgcesuiteserver.cpp
changeset 0 5d03bc08d59c
child 116 171fae344dd4
child 187 9f66f99ee56f
equal deleted inserted replaced
-1:000000000000 0:5d03bc08d59c
       
     1 // Copyright (c) 2008-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 "tgcesuiteserver.h"
       
    23 #include "tgraphicsresource.h"
       
    24 #include "tbitbltperf_directgdi.h"
       
    25 #include "tsimpledrawing_directgdi.h"
       
    26 #include "tdirectgdiperf.h"
       
    27 #include "teventhandlingperf.h"
       
    28 #include "tflipframerate.h"
       
    29 
       
    30 /**
       
    31 Same code for Secure and non-secure variants
       
    32 Called inside the MainL() function to create and start the
       
    33 CTestServer derived server.
       
    34 
       
    35 @return - Instance of the test server
       
    36 */
       
    37 CGceSuiteServer* CGceSuiteServer::NewL()
       
    38 	{
       
    39 	CGceSuiteServer * server = new (ELeave) CGceSuiteServer();
       
    40 	CleanupStack::PushL(server);
       
    41 
       
    42 	// Get server name from process so we can use SetCap to change the capabilites and use this server with a different filename
       
    43 	RProcess handle = RProcess();
       
    44 	TParsePtrC serverName(handle.FileName());
       
    45 
       
    46 	server->ConstructL(serverName.Name());
       
    47 	CleanupStack::Pop(server);
       
    48 	return server;
       
    49 	}
       
    50 
       
    51 
       
    52 /**
       
    53 MainL - uses the new Rendezvous() call to sync with the client
       
    54 */
       
    55 LOCAL_C void MainL()
       
    56 	{
       
    57 	// Active scheduler only for this thread. Test need to create own active scheduler	
       
    58 	CActiveScheduler* scheduler = new(ELeave) CActiveScheduler;
       
    59 	CActiveScheduler::Install(scheduler);
       
    60 
       
    61 	CGceSuiteServer* server = NULL;
       
    62 
       
    63 	// Create the CTestServer derived server
       
    64 	TRAPD(err,server = CGceSuiteServer::NewL());
       
    65 	if(!err)
       
    66 		{
       
    67 		// Sync with the client and enter the active scheduler
       
    68 		RProcess::Rendezvous(KErrNone);
       
    69 		scheduler->Start();
       
    70 		}
       
    71 	delete server;
       
    72 	delete scheduler;
       
    73 	}
       
    74 
       
    75 
       
    76 /**
       
    77 Secure variant only
       
    78 Process entry point. Called by client using RProcess API
       
    79 
       
    80 @return - Standard Epoc error code on process exit
       
    81 */
       
    82 GLDEF_C TInt E32Main()
       
    83 	{
       
    84 	__UHEAP_MARK;
       
    85 	CTrapCleanup* cleanup = CTrapCleanup::New();
       
    86 	if(cleanup == NULL)
       
    87 		{
       
    88 		return KErrNoMemory;
       
    89 		}
       
    90 	TRAPD(err,MainL());
       
    91 	delete cleanup;
       
    92 	__UHEAP_MARKEND;
       
    93 	return err;
       
    94     }
       
    95 
       
    96 /**
       
    97 Secure and non-secure variants
       
    98 Implementation of CTestServer pure virtual
       
    99 
       
   100 @return - A CTestStep derived instance
       
   101 */
       
   102 CTestStep* CGceSuiteServer::CreateTestStep(const TDesC& aStepName)
       
   103 	{
       
   104 	CTestStep* testStep = NULL;
       
   105 	if(aStepName == KTGraphicsResource)
       
   106 		testStep = new CTGraphicsResource();
       
   107 	else if(aStepName == KTBitBltPerfDirectGdi)
       
   108 		testStep = new CTBitBltPerfDirectGdi();
       
   109 	else if(aStepName == KTDirectGdiPerfTest)
       
   110 		testStep = new CTDirectGdiPerf();
       
   111 	else if(aStepName == KTSimpleDrawingPerfDirectGdi)
       
   112 		testStep = new CTSimpleDrawingDirectGdi();
       
   113 	else if(aStepName == KEventHandlingPerfName)
       
   114 		testStep = new CTEventHandlingPerf();
       
   115 	else if(aStepName == KTFlipFramerate)
       
   116 	    testStep = new CTFlipFramerate;
       
   117 	return testStep;
       
   118 	}