testexecmdw/tef/tef/test/regressiontest/performancetest/src/te_regperformancetestsuiteserver.cpp
branchRCL_3
changeset 3 9397a16b6eb8
parent 1 6edeef394eb7
equal deleted inserted replaced
1:6edeef394eb7 3:9397a16b6eb8
     1 /*
       
     2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  
       
    15 * Example file/test code to demonstrate how to develop a TestExecute Server
       
    16 * Developers should take this project as a template and substitute their own
       
    17 * for (WINS && !EKA2) versions will be xxxServer.Dll and require a thread to be started
       
    18 * in the process of the client. The client initialises the server by calling the
       
    19 * one and only ordinal.
       
    20 *
       
    21 */
       
    22 
       
    23 
       
    24 
       
    25 /**
       
    26  @file te_performancetestsuiteserver.cpp
       
    27  @internalTechnology
       
    28 */
       
    29 
       
    30 #include "te_regperformancetestsuiteserver.h"
       
    31 #include "te_regperformancelowmemoryteststep.h"
       
    32 #include "te_regperformancereleasememteststep.h"
       
    33 #include "te_regperformancesetlowmemteststep.h"
       
    34 
       
    35 _LIT(KServerName,"Te_RegPerformanceTestSuite");
       
    36 
       
    37 CTe_RegPerformanceTestSuiteServer* CTe_RegPerformanceTestSuiteServer::NewL()
       
    38 /**
       
    39  * @return - Instance of the test server
       
    40  * Same code for Secure and non-secure variants
       
    41  * Called inside the MainL() function to create and start the
       
    42  * CTestServer derived server.
       
    43  */
       
    44 	{
       
    45 	CTe_RegPerformanceTestSuiteServer * server = new (ELeave) CTe_RegPerformanceTestSuiteServer();
       
    46 	CleanupStack::PushL(server);
       
    47 
       
    48 	server->ConstructL(KServerName);
       
    49 	CleanupStack::Pop(server);
       
    50 	return server;
       
    51 	}
       
    52 
       
    53 // Secure variants much simpler
       
    54 // For EKA2, just an E32Main and a MainL()
       
    55 LOCAL_C void MainL()
       
    56 /**
       
    57  * Secure variant
       
    58  * Much simpler, uses the new Rendezvous() call to sync with the client
       
    59  */
       
    60 	{
       
    61 	// Leave the hooks in for platform security
       
    62 #if (defined __DATA_CAGING__)
       
    63 	RProcess().DataCaging(RProcess::EDataCagingOn);
       
    64 	RProcess().DataCaging(RProcess::ESecureApiOn);
       
    65 #endif
       
    66 	CActiveScheduler* sched=NULL;
       
    67 	sched=new(ELeave) CActiveScheduler;
       
    68 	CActiveScheduler::Install(sched);
       
    69 	CTe_RegPerformanceTestSuiteServer* server = NULL;
       
    70 	// Create the CTestServer derived server
       
    71 	TRAPD(err,server = CTe_RegPerformanceTestSuiteServer::NewL());
       
    72 	if(!err)
       
    73 		{
       
    74 		// Sync with the client and enter the active scheduler
       
    75 		RProcess::Rendezvous(KErrNone);
       
    76 		sched->Start();
       
    77 		}
       
    78 	delete server;
       
    79 	delete sched;
       
    80 	}
       
    81 
       
    82 
       
    83 
       
    84 GLDEF_C TInt E32Main()
       
    85 /**
       
    86  * @return - Standard Epoc error code on process exit
       
    87  * Secure variant only
       
    88  * Process entry point. Called by client using RProcess API
       
    89  */
       
    90 	{
       
    91 	__UHEAP_MARK;
       
    92 	CTrapCleanup* cleanup = CTrapCleanup::New();
       
    93 	if(cleanup == NULL)
       
    94 		{
       
    95 		return KErrNoMemory;
       
    96 		}
       
    97 	TRAPD(err,MainL());
       
    98 	delete cleanup;
       
    99 	__UHEAP_MARKEND;
       
   100 	return err;
       
   101     }
       
   102 
       
   103 
       
   104 CTestStep* CTe_RegPerformanceTestSuiteServer::CreateTestStep(const TDesC& aStepName)
       
   105 /**
       
   106  * @return - A CTestStep derived instance
       
   107  * Secure and non-secure variants
       
   108  * Implementation of CTestServer pure virtual
       
   109  */
       
   110 	{
       
   111 	CTestStep* testStep = NULL;
       
   112     if(aStepName == KTe_RegPerformanceSetLowMemTestStep)
       
   113     	{
       
   114     	testStep = new CTe_RegPerformanceSetLowMemTestStep(iChunk);
       
   115     	}
       
   116     else if(aStepName == KTe_RegPerformanceLowMemoryTestStep)
       
   117     	{
       
   118     	testStep = new CTe_RegPerformanceLowMemoryTestStep();
       
   119     	}
       
   120     if(aStepName == KTe_RegPerformanceReleaseMemTestStep)
       
   121     	{
       
   122     	testStep = new CTe_RegPerformanceReleaseMemTestStep(iChunk);
       
   123     	}
       
   124 
       
   125 	return testStep;
       
   126 	}