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