os/mm/mmlibs/mmfw/tsrc/mmfintegrationtest/SDevSound/SDSCapTestServer/src/CapTestServer.cpp
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/mm/mmlibs/mmfw/tsrc/mmfintegrationtest/SDevSound/SDSCapTestServer/src/CapTestServer.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,152 @@
1.4 +// Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// Example file/test code to demonstrate how to develop a TestExecute Server
1.18 +// Developers should take this project as a template and substitute their own
1.19 +// code at the __EDIT_ME__ tags
1.20 +// for (WINS && !EKA2) versions will be xxxServer.Dll and require a thread to be started
1.21 +// in the process of the client. The client initialises the server by calling the
1.22 +// one and only ordinal.
1.23 +//
1.24 +//
1.25 +
1.26 +/**
1.27 + @file CapTestServer.cpp
1.28 +*/
1.29 +
1.30 +#include <simulprocclient.h>
1.31 +
1.32 +#include "CapTestServer.h"
1.33 +#include "CapTestStep0002.h"
1.34 +#include "CapTestStep0004.h"
1.35 +#include "CapTestStep0006.h"
1.36 +#include "CapTestStep0008.h"
1.37 +#include "CapTestStep0010.h"
1.38 +#include "CapTestStep0036.h"
1.39 +
1.40 +_LIT(KServerName,"SDSCapTestServer");
1.41 +// __EDIT_ME__ - Use your own server class name
1.42 +CCapTestServer* CCapTestServer::NewL()
1.43 +/**
1.44 + * @return - Instance of the test server
1.45 + * Called inside the MainL() function to create and start the
1.46 + * CTestServer derived server.
1.47 + */
1.48 + {
1.49 + // __EDIT_ME__ new your server class here
1.50 + CCapTestServer * server = new (ELeave) CCapTestServer();
1.51 + CleanupStack::PushL(server);
1.52 +
1.53 + // Either use a StartL or ConstructL, the latter will permit
1.54 + // Server Logging.
1.55 +
1.56 + server->StartL(KServerName);
1.57 + //server-> ConstructL(KServerName);
1.58 + CleanupStack::Pop(server);
1.59 + return server;
1.60 + }
1.61 +
1.62 +CSession2* CCapTestServer::NewSessionL(const TVersion& aVersion,const RMessage2& aMessage) const
1.63 + {
1.64 + // Retrieve client's thread Id
1.65 + RThread clientThread;
1.66 + aMessage.ClientL(clientThread);
1.67 + const_cast<CCapTestServer*>(this)->iClientThreadId = clientThread.Id();
1.68 + clientThread.Close();
1.69 +
1.70 + return CSimulProcServer::NewSessionL(aVersion, aMessage);
1.71 + }
1.72 +
1.73 +CCapTestServer::CCapTestServer()
1.74 + {
1.75 + }
1.76 +
1.77 +CCapTestServer::~CCapTestServer()
1.78 + {
1.79 + }
1.80 +
1.81 +
1.82 +// EKA2 much simpler
1.83 +// Just an E32Main and a MainL()
1.84 +LOCAL_C void MainL()
1.85 +/**
1.86 + * Much simpler, uses the new Rendezvous() call to sync with the client
1.87 + */
1.88 + {
1.89 + // Leave the hooks in for platform security
1.90 +#if (defined __DATA_CAGING__)
1.91 + RProcess().DataCaging(RProcess::EDataCagingOn);
1.92 + RProcess().SecureApi(RProcess::ESecureApiOn);
1.93 +#endif
1.94 + CActiveScheduler* sched=NULL;
1.95 + sched=new(ELeave) CActiveScheduler;
1.96 + CActiveScheduler::Install(sched);
1.97 + // __EDIT_ME__ Your server name
1.98 + CCapTestServer* server = NULL;
1.99 + // Create the CTestServer derived server
1.100 + // __EDIT_ME__ Your server name
1.101 + TRAPD(err,server = CCapTestServer::NewL());
1.102 + if(!err)
1.103 + {
1.104 + // Sync with the client and enter the active scheduler
1.105 + RProcess::Rendezvous(KErrNone);
1.106 + sched->Start();
1.107 + }
1.108 + delete server;
1.109 + delete sched;
1.110 + }
1.111 +
1.112 +
1.113 +GLDEF_C TInt E32Main()
1.114 +/**
1.115 + * @return - Standard Epoc error code on exit
1.116 + */
1.117 + {
1.118 + CTrapCleanup* cleanup = CTrapCleanup::New();
1.119 + if(cleanup == NULL)
1.120 + {
1.121 + return KErrNoMemory;
1.122 + }
1.123 + TRAP_IGNORE(MainL());
1.124 + delete cleanup;
1.125 + return KErrNone;
1.126 + }
1.127 +
1.128 +
1.129 +CSimulProcTestStep* CCapTestServer::CreateTestStep(const TDesC& aStepName) const
1.130 +/**
1.131 + * @return - A CTestStep derived instance
1.132 + * Implementation of CTestServer pure virtual
1.133 + */
1.134 + {
1.135 + CSimulProcTestStep* testStep = NULL;
1.136 + // __EDIT_ME__ - Create your own test steps here
1.137 + // This server creates just one step but create as many as you want
1.138 + // They are created "just in time" when the worker thread is created
1.139 +
1.140 + if(aStepName == _L("SecDevSndTS0002"))
1.141 + testStep = CSecDevSndTS0002::NewL();
1.142 + else if(aStepName == _L("SecDevSndTS0004"))
1.143 + testStep = CSecDevSndTS0004::NewL();
1.144 + else if(aStepName == _L("SecDevSndTS0006"))
1.145 + testStep = CSecDevSndTS0006::NewL();
1.146 + else if(aStepName == _L("SecDevSndTS0008"))
1.147 + testStep = CSecDevSndTS0008::NewL();
1.148 + else if(aStepName == _L("SecDevSndTS0010"))
1.149 + testStep = CSecDevSndTS0010::NewL();
1.150 + else if(aStepName == _L("SecDevSndTS0036"))
1.151 + testStep = CSecDevSndTS0036::NewL(iClientThreadId);
1.152 +
1.153 + return testStep;
1.154 + }
1.155 +