systemhealthmanagement/systemhealthmgr/test/tsysmon/src/tsysmon_server.cpp
changeset 0 4e1aa6a622a0
child 21 ccb4f6b3db21
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 "tsysmon_server.h"
       
    23 
       
    24 #include "tsysmon_stepmultiprocmon.h"
       
    25 #include "tsysmon_stepnoprocmon.h"
       
    26 #include "tsysmon_stepprocmonignore.h"
       
    27 #include "tsysmon_stepselfmonignore.h"
       
    28 #include "tsysmon_stepprocmoninit.h"
       
    29 #include "tsysmon_stepprocrestart.h"
       
    30 #include "tsysmon_steprestartthrottle.h"
       
    31 #include "tsysmon_stepselfmoncancel.h"
       
    32 #include "tsysmon_stepselfmoncancel2.h"
       
    33 #include "tsysmon_stepnomoncancel.h"
       
    34 
       
    35 #include "tsysmon_step_connect_disconnect.h"
       
    36 #include "tsysmon_step_register.h"
       
    37 #include "tsysmon_step_register_twice_different.h"
       
    38 #include "tsysmon_step_register_twice_same.h"
       
    39 #include "tsysmon_step_result_check.h"
       
    40 #include "tsysmon_step_run_count_check.h"
       
    41 #include "tsysmon_steploadsysmon.h"
       
    42 #include "tsysmon_stepoomsysmon.h"
       
    43 #include "tsysmon_stepcancelallmonitors.h"
       
    44 
       
    45 CSysMonTestServer* CSysMonTestServer::NewLC()
       
    46 	{
       
    47 	CSysMonTestServer * server = new (ELeave) CSysMonTestServer();
       
    48 	CleanupStack::PushL(server);
       
    49 	TParsePtrC serverName(RProcess().FileName());
       
    50 	server->StartL(serverName.Name());
       
    51 	return server;
       
    52 	}
       
    53 	
       
    54 
       
    55 static void MainL()
       
    56 	{
       
    57 	CActiveScheduler* sched = new(ELeave) CActiveScheduler;
       
    58 	CleanupStack::PushL(sched);
       
    59 	CActiveScheduler::Install(sched);
       
    60 	
       
    61 	// Create the CTestServer derived server
       
    62 	CSysMonTestServer* server = CSysMonTestServer::NewLC();
       
    63 	RProcess::Rendezvous(KErrNone);
       
    64 	sched->Start();
       
    65 	
       
    66 	CleanupStack::PopAndDestroy(server);
       
    67 	CleanupStack::PopAndDestroy(sched);
       
    68 	}
       
    69 
       
    70 
       
    71 TInt E32Main()
       
    72 	{
       
    73 	__UHEAP_MARK;
       
    74 	
       
    75 	CTrapCleanup* cleanup = CTrapCleanup::New();
       
    76 	TInt err = KErrNoMemory;
       
    77 	if(cleanup)
       
    78 		{
       
    79 		TRAP(err, MainL());
       
    80 		delete cleanup;
       
    81 		}
       
    82 		
       
    83 	__UHEAP_MARKEND; 
       
    84 	return err;
       
    85     } //lint -e765 -e714 Suppress 'not referenced' and 'could be static'
       
    86 
       
    87 
       
    88 /**
       
    89  * @return - A CTestStep derived instance
       
    90  * Implementation of CTestServer pure virtual
       
    91  */
       
    92 CTestStep* CSysMonTestServer::CreateTestStep(const TDesC& aStepName)
       
    93 	{
       
    94 	CTestStep* testStep = NULL;
       
    95 
       
    96 	if (aStepName == KCTestCaseMultiProcMon)
       
    97 		{
       
    98 		testStep = new CStepMultiProcMon();
       
    99 		}
       
   100 	else if (aStepName == KCTestCaseNoProcMon)
       
   101 		{
       
   102 		testStep = new CStepNoProcMon();
       
   103 		}
       
   104 	else if (aStepName == KCTestCaseProcMonIgnore)
       
   105 		{
       
   106 		testStep = new CStepProcMonIgnore();
       
   107 		}
       
   108 	else if (aStepName == KCTestCaseProcMonInit)
       
   109 		{
       
   110 		testStep = new CStepProcMonInit();
       
   111 		}
       
   112 	else if (aStepName == KCTestCaseProcRestart)
       
   113 		{
       
   114 		testStep = new CStepProcRestart();
       
   115 		}
       
   116 	else if (aStepName == KCTestCaseRestartThrottle)
       
   117 		{
       
   118 		testStep = new CStepRestartThrottle();
       
   119 		}
       
   120 	else if (aStepName == KCTestCaseSelfMonCancel)
       
   121 		{
       
   122 		testStep = new CStepSelfMonCancel();
       
   123 		}
       
   124 	else if (aStepName == KCTestCaseSelfMonIgnore)
       
   125 		{
       
   126 		testStep = new CStepSelfMonIgnore();
       
   127 		}
       
   128 	else if (aStepName == KCTestCaseSelfMonCancel2)
       
   129 		{
       
   130 		testStep = new CStepSelfMonCancel2();
       
   131 		}
       
   132 	else if (aStepName == KCTestCaseNoMonCancel)
       
   133 		{
       
   134 		testStep = new CStepNoMonCancel();
       
   135 		}
       
   136 	else if(aStepName == KConnectDisconnectStep)
       
   137 		{
       
   138         testStep = new CConnectDisconnectStep();
       
   139 		}
       
   140     else if(aStepName == KRegisterStep)
       
   141 		{
       
   142         testStep = new CRegisterStep();
       
   143 		}
       
   144     else if(aStepName == KRegisterTwiceDifferentStep)
       
   145 		{
       
   146         testStep = new CRegisterTwiceDifferentStep();
       
   147 		}
       
   148     else if(aStepName == KRegisterTwiceSameStep)
       
   149 		{
       
   150         testStep = new CRegisterTwiceSameStep();
       
   151 		}
       
   152     else if(aStepName == KResultCheckStep)
       
   153 		{
       
   154         testStep = new CResultCheckStep();
       
   155 		}
       
   156     else if(aStepName == KRunCountCheckStep)
       
   157 		{
       
   158 		testStep = new CRunCountCheckStep();
       
   159 		}
       
   160     else if(aStepName == KCTestCaseLoadSysMon)
       
   161 		{
       
   162 		testStep = new CStepLoadSysMon();
       
   163 		}
       
   164     else if(aStepName == KOOMTestCaseSysMon)
       
   165 		{
       
   166 		testStep = new CTOOMSysMonTestStep();
       
   167 		}
       
   168     else if(aStepName == KCTestCaseCancelAllMonitors)
       
   169         {
       
   170         testStep = new CStepCancelAllMonitors();
       
   171         }
       
   172 	else 
       
   173 		{
       
   174 		RDebug::Printf("Unknown sysmon teststep %S", &aStepName);	
       
   175 		}
       
   176 		
       
   177 	return testStep;
       
   178 	}
       
   179