sysstatemgmt/systemstatereferenceplugins/test/tclayer/src/tclayer_server.cpp
changeset 0 4e1aa6a622a0
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 "tclayer_server.h"
       
    23 #include "tclayer_step_startersession.h"
       
    24 #include "tclayer_step_startupadaptationadapter.h"
       
    25 #include "tclayer_step_ssmpropertyobserver.h"
       
    26 #include "tclayer_step_ssmsimstatusobserver.h"
       
    27 #include "tclayer_step_ssmsecurityeventobserver.h"
       
    28 
       
    29 #include "ssmdebug.h"
       
    30 
       
    31 CCLayerTestServer* CCLayerTestServer::NewLC( )
       
    32 	{
       
    33 	CCLayerTestServer * server = new (ELeave) CCLayerTestServer();
       
    34 	CleanupStack::PushL(server);
       
    35 	TParsePtrC serverName(RProcess().FileName());	
       
    36 	server->StartL(serverName.Name());
       
    37 	return server;
       
    38 	}
       
    39 
       
    40 static void MainL()
       
    41 	{
       
    42 	CActiveScheduler* sched = new(ELeave) CActiveScheduler;
       
    43 	CleanupStack::PushL (sched);
       
    44 	CActiveScheduler::Install (sched);
       
    45 
       
    46 	CCLayerTestServer* server = CCLayerTestServer::NewLC( );
       
    47 	RProcess::Rendezvous (KErrNone );
       
    48 	sched->Start( );
       
    49 
       
    50 	CleanupStack::PopAndDestroy (server );
       
    51 	CleanupStack::PopAndDestroy (sched );
       
    52 	}
       
    53 
       
    54 /**
       
    55  Process entry point. Called by client using RProcess API
       
    56  @return - Standard Epoc error code on process exit
       
    57  */
       
    58 TInt E32Main(void)
       
    59 	{
       
    60 	__UHEAP_MARK;
       
    61 	CTrapCleanup* cleanup = CTrapCleanup::New();
       
    62 	if(cleanup == NULL)
       
    63 		{
       
    64 		return KErrNoMemory;
       
    65 		}
       
    66 	TRAPD(err,MainL());
       
    67 	if (err)
       
    68 		{
       
    69 		DEBUGPRINT2(_L("CCLayerTestServer::MainL - Error: %d"), err);
       
    70 		}
       
    71 	delete cleanup;
       
    72 		
       
    73 	__UHEAP_MARKEND;
       
    74 	return err;
       
    75 	} //lint -esym(765, E32Main) Suppress 'E32Main' could be made static
       
    76 	  //lint -esym(714, E32Main) Suppress 'E32Main' not referenced
       
    77 
       
    78 /**
       
    79  @return - A CTestStep derived instance
       
    80  */
       
    81 CTestStep* CCLayerTestServer::CreateTestStep(const TDesC& aStepName)
       
    82 	{
       
    83 	CTestStep* testStep = NULL;
       
    84 	if (aStepName == KTCCLayerTestStarterSession)
       
    85 		{
       
    86 		testStep = new CCLayerTestStarterSession();
       
    87 		}
       
    88 	else if (aStepName == KTCCLayerTestStartupAdaptationAdapter)
       
    89 		{
       
    90 		testStep = new CCLayerTestStartupAdaptationAdapter();
       
    91 		}
       
    92 	else if (aStepName == KTCCLayerTestSsmSimStatusObserver)
       
    93 		{
       
    94 		testStep = new CCLayerTestSsmSimStatusObserver();
       
    95 		}
       
    96 	else if (aStepName == KTCCLayerTestSsmPropertyObserver)
       
    97 		{
       
    98 		testStep = new CCLayerTestSsmPropertyObserver();
       
    99 		}
       
   100 	else if (aStepName == KTCLayerTestSsmEventObserver)
       
   101 		{
       
   102 		testStep = new CLayerTestSsmEventObserver();
       
   103 		}
       
   104 	else
       
   105 		{
       
   106 		DEBUGPRINT2(_L("Unknown ClayerTest step %S"), &aStepName);
       
   107 		}
       
   108 
       
   109 	return testStep;
       
   110 	}