sysstatemgmt/systemstateplugins/test/tcmncustomcmd/src/tcmncustomcmd_server.cpp
changeset 0 4e1aa6a622a0
child 70 653a8b91b95e
equal deleted inserted replaced
-1:000000000000 0:4e1aa6a622a0
       
     1 // Copyright (c) 2007-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 "tcmncustomcmd_server.h"
       
    23 #include "tcmncustomcmd_step_rendezvouswithestart.h"
       
    24 #include "tcmncustomcmd_step_persistreboots.h"
       
    25 #include "tcmncustomcmd_step_cancelmonitoring.h"
       
    26 
       
    27 _LIT(KCustomCmdTestServerName, "tcmncustomcmd_server");
       
    28 
       
    29 CCmdTestServer* CCmdTestServer::NewLC( )
       
    30 	{
       
    31 	CCmdTestServer * server = new (ELeave) CCmdTestServer();
       
    32 	CleanupStack::PushL(server);
       
    33 	TParsePtrC serverName(RProcess().FileName());
       
    34 	server->StartL(serverName.Name());
       
    35 	return server;
       
    36 	}
       
    37 
       
    38 static void MainL()
       
    39 	{
       
    40 	CActiveScheduler* sched = new(ELeave) CActiveScheduler;
       
    41 	CleanupStack::PushL (sched);
       
    42 	CActiveScheduler::Install (sched);
       
    43 
       
    44 	CCmdTestServer* server = CCmdTestServer::NewLC( );
       
    45 	RProcess::Rendezvous (KErrNone );
       
    46 	sched->Start( );
       
    47 
       
    48 	CleanupStack::PopAndDestroy (server );
       
    49 	CleanupStack::PopAndDestroy (sched );
       
    50 	}
       
    51 
       
    52 /**
       
    53  Process entry point. Called by client using RProcess API
       
    54  @return - Standard Epoc error code on process exit
       
    55  */
       
    56 TInt E32Main(void)
       
    57 	{
       
    58 	__UHEAP_MARK;
       
    59 	CTrapCleanup* cleanup = CTrapCleanup::New();
       
    60 	if(cleanup == NULL)
       
    61 		{
       
    62 		return KErrNoMemory;
       
    63 		}
       
    64 
       
    65 	TRAPD(err,MainL());
       
    66 	if (err)
       
    67 		{
       
    68 		RDebug::Print(_L("CmdTestServer::MainL - Error: %d"), err);
       
    69 		User::Panic(KCustomCmdTestServerName, err);
       
    70 		}
       
    71 	delete cleanup;
       
    72 
       
    73 	__UHEAP_MARKEND;
       
    74 	return KErrNone;
       
    75 	}
       
    76 
       
    77 /**
       
    78  @return - A CTestStep derived instance
       
    79  */
       
    80 CTestStep* CCmdTestServer::CreateTestStep(const TDesC& aStepName)
       
    81 	{
       
    82 	CTestStep* testStep = NULL;
       
    83 	if (aStepName == KTCCustomCmdTestRendezvousWithEStart)
       
    84 		{
       
    85 		testStep = new CCustomCmdTestRendezvousWithEStart();
       
    86 		}
       
    87 	else if (aStepName == KTCCustomCmdTestPersistReboots)
       
    88 		{
       
    89 		testStep = new CCustomCmdTestPersistReboots();
       
    90 		}	
       
    91     else if (aStepName == KTCCustomCmdTestCancelMonitoring)
       
    92         {
       
    93         testStep = new CCustomCmdTestCancelMonitoring();
       
    94         }   
       
    95 	else
       
    96 		{
       
    97 		RDebug::Print(_L("Unknown CmdTest step %S"), &aStepName);
       
    98 	   	User::Panic(KCustomCmdTestServerName, KErrArgument);
       
    99 		}
       
   100 
       
   101 	return testStep;
       
   102 	}