sysstatemgmt/systemstatereferenceplugins/test/tunitcustcmd/src/tcmd_server.cpp
changeset 0 4e1aa6a622a0
child 3 a811597961f0
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 "tcmd_server.h"
       
    23 #include "tcmd_step_simsecuritycheck.h"
       
    24 #include "tcmd_step_devicesecuritycheck.h"
       
    25 #include "tcmd_step_coopsysselftest.h"
       
    26 #include "tcmd_step_coopsysperformrestartactions.h"
       
    27 #include "tcmd_step_coopsysperformshutdownactions.h"
       
    28 #include "tcmd_step_coopsysperformrfsactions.h"
       
    29 #include "tcmd_step_activaterfforemergencycall.h"
       
    30 #include "tcmd_step_deactivaterfforemergencycall.h"
       
    31 #include "tcmd_step_coopsysstatechange.h"
       
    32 #include "tcmd_step_publishstartupmode.h"
       
    33 #include "tcmd_step_publishsimownedandchanged.h"
       
    34 #include "tcmd_step_execute.h"
       
    35 
       
    36 _LIT(KCustomCmdTestServerName, "tunitcustcmd_server");
       
    37 
       
    38 CCmdTestServer* CCmdTestServer::NewLC( )
       
    39 	{
       
    40 	CCmdTestServer * server = new (ELeave) CCmdTestServer();
       
    41 	CleanupStack::PushL(server);
       
    42 	TParsePtrC serverName(RProcess().FileName());
       
    43 	server->StartL(serverName.Name());
       
    44 	return server;
       
    45 	}
       
    46 
       
    47 static void MainL()
       
    48 	{
       
    49 	CActiveScheduler* sched = new(ELeave) CActiveScheduler;
       
    50 	CleanupStack::PushL (sched);
       
    51 	CActiveScheduler::Install (sched);
       
    52 
       
    53 	CCmdTestServer* server = CCmdTestServer::NewLC( );
       
    54 	RProcess::Rendezvous (KErrNone );
       
    55 	sched->Start( );
       
    56 
       
    57 	CleanupStack::PopAndDestroy (server );
       
    58 	CleanupStack::PopAndDestroy (sched );
       
    59 	}
       
    60 
       
    61 /**
       
    62  Process entry point. Called by client using RProcess API
       
    63  @return - Standard Epoc error code on process exit
       
    64  */
       
    65 TInt E32Main(void)
       
    66 	{
       
    67 	__UHEAP_MARK;
       
    68 	CTrapCleanup* cleanup = CTrapCleanup::New();
       
    69 	if(cleanup == NULL)
       
    70 		{
       
    71 		return KErrNoMemory;
       
    72 		}
       
    73 
       
    74 	TRAPD(err,MainL());
       
    75 	if (err)
       
    76 		{
       
    77 		RDebug::Print(_L("CmdTestServer::MainL - Error: %d"), err);
       
    78 		User::Panic(KCustomCmdTestServerName, err);
       
    79 		}
       
    80 	delete cleanup;
       
    81 
       
    82 	__UHEAP_MARKEND;
       
    83 	return KErrNone;
       
    84 	}
       
    85 
       
    86 /**
       
    87  @return - A CTestStep derived instance
       
    88  */
       
    89 CTestStep* CCmdTestServer::CreateTestStep(const TDesC& aStepName)
       
    90 	{
       
    91 	RDebug::Print(_L("CCmdTestServer::CreateTestStep"));
       
    92 	CTestStep* testStep = NULL;
       
    93 	if (aStepName == KTCCustomCmdTestSimSecurityCheck)
       
    94 		{
       
    95 		testStep = new CCustomCmdTestSimSecurityCheck();
       
    96 		}
       
    97 	else if (aStepName == KTCCustomCmdTestDeviceSecurityCheck)
       
    98 		{
       
    99 		testStep = new CCustomCmdTestDeviceSecurityCheck();
       
   100 		}
       
   101 	else if (aStepName == KTCCustomCmdTestCoopSysSelfTest)
       
   102 		{
       
   103 		testStep = new CCustomCmdTestCoopSysSelfTest();
       
   104 		}
       
   105 	else if (aStepName == KTCCustomCmdTestCoopSysPerformRestartActions)
       
   106 		{
       
   107 		testStep = new CCustomCmdTestCoopSysPerformRestartActions();
       
   108 		}
       
   109 	else if (aStepName == KTCCustomCmdTestCoopSysPerformShutdownActions)
       
   110 		{
       
   111 		testStep = new CCustomCmdTestCoopSysPerformShutdownActions();
       
   112 		}
       
   113 	else if (aStepName == KTCCustomCmdTestCoopSysPerformRfsActions)
       
   114 		{
       
   115 		testStep = new CCustomCmdTestCoopSysPerformRfsActions();
       
   116 		}
       
   117 	else if (aStepName == KTCCustomCmdTestActivateRfForEmergencyCall)
       
   118 		{
       
   119 		testStep = new CCustomCmdTestActivateRfForEmergencyCall();
       
   120 		}
       
   121 	else if (aStepName == KTCCustomCmdTestDeactivateRfForEmergencyCall)
       
   122 		{
       
   123 		testStep = new CCustomCmdTestDeactivateRfForEmergencyCall();
       
   124 		}
       
   125 	else if (aStepName == KTCCustomCmdTestCoopSysStateChange)
       
   126 		{
       
   127 		testStep = new CCustomCmdTestCoopSysStateChange();
       
   128 		}
       
   129 	else if (aStepName == KTCCustomCmdTestPublishStartupMode)
       
   130 		{
       
   131 		testStep = new CCustomCmdTestPublishStartupMode();
       
   132 		}
       
   133 	else if (aStepName == KTCCustomCmdTestPublishSimOwnedAndChanged)
       
   134 	    {
       
   135 	    testStep = new CCustomCmdTestPublishSimOwnedAndChanged();
       
   136 	    }
       
   137 	else if (aStepName == KTestCustomCmdExecute)
       
   138 		{
       
   139 		testStep = new CTestCustomCmdExecute();
       
   140 		}
       
   141 	else
       
   142 		{
       
   143 		RDebug::Print(_L("Unknown CmdTest step %S"), &aStepName);
       
   144 	   	User::Panic(KCustomCmdTestServerName, KErrArgument);
       
   145 		}
       
   146 
       
   147 	return testStep;
       
   148 	}