testexecmdw/tef/tef/test/regressiontest/teststep/src/te_regsteptestsuiteserver.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_RegressionSuiteServer.cpp
       
    27 */
       
    28 
       
    29 #include "te_regsteptestsuiteserver.h"
       
    30 #include "readwriteconfigstep.h"
       
    31 #include "readwriteconfignegstep.h"
       
    32 #include "seterrorstep.h"
       
    33 #include "writeboolstep.h"
       
    34 #include "writehexstep.h"
       
    35 #include "writeintstep.h"
       
    36 #include "writestringstep.h"
       
    37 #include "abortstep.h"
       
    38 #include "oomstep.h"
       
    39 #include "shortfunsstep.h"
       
    40 #include "testmacrosstep.h"
       
    41 #include "panicstep.h"
       
    42 #include "leaveforever.h"
       
    43 #include "te_regsteptestsuitedefs.h"
       
    44 
       
    45 CTe_RegStepTespSuiteServer* CTe_RegStepTespSuiteServer::NewL()
       
    46 /**
       
    47  * @return - Instance of the test server
       
    48  * Same code for Secure and non-secure variants
       
    49  * Called inside the MainL() function to create and start the
       
    50  * CTestServer derived server.
       
    51  */
       
    52 	{
       
    53 	CTe_RegStepTespSuiteServer * server = new (ELeave) CTe_RegStepTespSuiteServer();
       
    54 	CleanupStack::PushL(server);
       
    55 
       
    56 	server->ConstructL(KServerName);
       
    57 	CleanupStack::Pop(server);
       
    58 	return server;
       
    59 	}
       
    60 
       
    61 
       
    62 // Secure variants much simpler
       
    63 // For EKA2, just an E32Main and a MainL()
       
    64 LOCAL_C void MainL()
       
    65 /**
       
    66  * Secure variant
       
    67  * Much simpler, uses the new Rendezvous() call to sync with the client
       
    68  */
       
    69 	{
       
    70 	// Leave the hooks in for platform security
       
    71 #if (defined __DATA_CAGING__)
       
    72 	RProcess().DataCaging(RProcess::EDataCagingOn);
       
    73 	RProcess().DataCaging(RProcess::ESecureApiOn);
       
    74 #endif
       
    75 	CActiveScheduler* sched=NULL;
       
    76 	sched=new(ELeave) CActiveScheduler;
       
    77 	CActiveScheduler::Install(sched);
       
    78 	CTe_RegStepTespSuiteServer* server = NULL;
       
    79 	// Create the CTestServer derived server
       
    80 	TRAPD(err,server = CTe_RegStepTespSuiteServer::NewL());
       
    81 	if(!err)
       
    82 		{
       
    83 		// Sync with the client and enter the active scheduler
       
    84 		RProcess::Rendezvous(KErrNone);
       
    85 		sched->Start();
       
    86 		}
       
    87 	delete server;
       
    88 	delete sched;
       
    89 	}
       
    90 
       
    91 
       
    92 
       
    93 GLDEF_C TInt E32Main()
       
    94 /**
       
    95  * @return - Standard Epoc error code on process exit
       
    96  * Secure variant only
       
    97  * Process entry point. Called by client using RProcess API
       
    98  */
       
    99 	{
       
   100 	__UHEAP_MARK;
       
   101 	CTrapCleanup* cleanup = CTrapCleanup::New();
       
   102 	if(cleanup == NULL)
       
   103 		{
       
   104 		return KErrNoMemory;
       
   105 		}
       
   106 	TRAPD(err,MainL());
       
   107 	delete cleanup;
       
   108 	__UHEAP_MARKEND;
       
   109 	return err;
       
   110     }
       
   111 
       
   112 
       
   113 CTestStep* CTe_RegStepTespSuiteServer::CreateTestStep(const TDesC& aStepName)
       
   114 /**
       
   115  * @return - A CTestStep derived instance
       
   116  * Secure and non-secure variants
       
   117  * Implementation of CTestServer pure virtual
       
   118  */
       
   119 	{
       
   120 	CTestStep* testStep = NULL;
       
   121 	if(aStepName == KReadWriteConfigStep)
       
   122 		{
       
   123 		testStep = new CReadWriteConfigStep();
       
   124 		}
       
   125 	else if(aStepName == KReadWriteConfigNegStep)
       
   126 		{
       
   127 		testStep = new CReadWriteConfigNegStep();
       
   128 		}
       
   129 	else if(aStepName == KSetErrorStep)
       
   130 		{
       
   131 		testStep = new CSetErrorStep();
       
   132 		}
       
   133 	else if(aStepName == KWriteBoolStep)
       
   134 		{
       
   135 		testStep = new CWriteBoolStep();
       
   136 		}
       
   137 	else if(aStepName == KWriteHexStep)
       
   138 		{
       
   139 		testStep = new CWriteHexStep();
       
   140 		}
       
   141 	else if(aStepName == KWriteIntStep)
       
   142 		{
       
   143 		testStep = new CWriteIntStep();
       
   144 		}
       
   145 	else if(aStepName == KWriteStringStep)
       
   146 		{
       
   147 		testStep = new CWriteStringStep();
       
   148 		}
       
   149 	else if (aStepName == KAbortTestStep)
       
   150 		{
       
   151 		testStep = new CAbortTestStep();
       
   152 		}
       
   153 	else if (aStepName == KOOMTestStep)
       
   154 		{
       
   155 		testStep = new COOMTestStep();
       
   156 		}
       
   157 	else if (aStepName == KShortFunsTestStep)
       
   158 		{
       
   159 		testStep = new CShortFunsTestStep();
       
   160 		}
       
   161 	else if (aStepName == KMacrosTestStep)
       
   162 		{
       
   163 		testStep = new CTestMacrosTestStep();
       
   164 		}
       
   165 	else if (aStepName == KPanicTestStep)
       
   166 		{
       
   167 		testStep = new CPanicTestStep();
       
   168 		}
       
   169 	else if(aStepName == KLeaveForever)
       
   170 		{
       
   171 		testStep = new CLeaveForever();
       
   172 		}
       
   173 
       
   174 	return testStep;
       
   175 	}