os/mm/mmlibs/mmfw/tsrc/mmfintegrationtest/DSCapTestServer/CapTestServer.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) 2002-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 // Example file/test code to demonstrate how to develop a TestExecute Server
    15 // Developers should take this project as a template and substitute their own
    16 // code at the __EDIT_ME__ tags
    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  @file CapTestServer.cpp
    25 */
    26 
    27 #include <simulprocclient.h>
    28 
    29 #include "CapTestServer.h"
    30 //#include "CapTestStep.h"
    31 #include "DevSoundServerTestStep.h"
    32 
    33 
    34 
    35 _LIT(KServerName,"DSCapTestServer");
    36 // __EDIT_ME__ - Use your own server class name
    37 CCapTestServer* CCapTestServer::NewL()
    38 /**
    39  * @return - Instance of the test server
    40  * Called inside the MainL() function to create and start the
    41  * CTestServer derived server.
    42  */
    43 	{
    44 	// __EDIT_ME__ new your server class here
    45 	CCapTestServer * server = new (ELeave) CCapTestServer();
    46 	CleanupStack::PushL(server);
    47 	
    48 	// Either use a StartL or ConstructL, the latter will permit
    49 	// Server Logging.
    50 
    51 	server->StartL(KServerName); 
    52 	//server-> ConstructL(KServerName);
    53 	CleanupStack::Pop(server);
    54 	return server;
    55 	}
    56 	
    57 CCapTestServer::CCapTestServer()
    58 	{
    59 	}
    60 	
    61 CCapTestServer::~CCapTestServer()
    62 	{
    63 	}
    64 	
    65 
    66 // EKA2 much simpler
    67 // Just an E32Main and a MainL()
    68 LOCAL_C void MainL()
    69 /**
    70  * Much simpler, uses the new Rendezvous() call to sync with the client
    71  */
    72 	{
    73 	// Leave the hooks in for platform security
    74 #if (defined __DATA_CAGING__)
    75 	RProcess().DataCaging(RProcess::EDataCagingOn);
    76 	RProcess().SecureApi(RProcess::ESecureApiOn);
    77 #endif
    78 	CActiveScheduler* sched=NULL;
    79 	sched=new(ELeave) CActiveScheduler;
    80 	CActiveScheduler::Install(sched);
    81 	// __EDIT_ME__ Your server name
    82 	CCapTestServer* server = NULL;
    83 	// Create the CTestServer derived server
    84 	// __EDIT_ME__ Your server name
    85 	TRAPD(err,server = CCapTestServer::NewL());
    86 	if(!err)
    87 		{
    88 		// Sync with the client and enter the active scheduler
    89 		RProcess::Rendezvous(KErrNone);
    90 		sched->Start();
    91 		}
    92 	delete server;
    93 	delete sched;
    94 	}
    95 
    96 
    97 GLDEF_C TInt E32Main()
    98 /**
    99  * @return - Standard Epoc error code on exit
   100  */
   101 	{
   102 	CTrapCleanup* cleanup = CTrapCleanup::New();
   103 	if(cleanup == NULL)
   104 		{
   105 		return KErrNoMemory;
   106 		}
   107 	TRAP_IGNORE(MainL());
   108 	delete cleanup;
   109 	return KErrNone;
   110     }
   111 
   112 
   113 //Add TestStep
   114 CSimulProcTestStep* CCapTestServer::CreateTestStep(const TDesC& aStepName) const
   115 /**
   116  * @return - A CTestStep derived instance
   117  * Implementation of CTestServer pure virtual
   118  */
   119 	{
   120 	CSimulProcTestStep* testStep = NULL; 
   121 	// __EDIT_ME__ - Create your own test steps here
   122 	// This server creates just one step but create as many as you want
   123 	// They are created "just in time" when the worker thread is created
   124 	
   125 	//
   126 	//1) SDevSound IntTest: Access DevSoundServer test mm-mmf-sdevsound-i-0016
   127 	if(aStepName == _L("CSDevSoundTestStep1"))
   128 		{
   129 		testStep = CSDevSoundTestStep1::NewL();
   130 		}
   131 	
   132 
   133 	return testStep;
   134 	}
   135