telephonyprotocols/umtsgprsscpr/Test/te_spud/src/SpudUnitTestServer.cpp
changeset 68 d0d9cc530d21
parent 62 8ef833fbf5aa
child 75 f45cd1ad4667
equal deleted inserted replaced
62:8ef833fbf5aa 68:d0d9cc530d21
     1 // Copyright (c) 2004-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 // for (WINS && !EKA2) versions will be xxxServer.Dll and require a thread to
       
    15 // be started in the process of the client. The client initialises the server
       
    16 // by calling the one and only ordinal.
       
    17 // 
       
    18 //
       
    19 
       
    20 /**
       
    21  @file
       
    22  @internalComponent
       
    23 */
       
    24 
       
    25 #include "SpudUnitTestServer.h"
       
    26 #include "SpudUnitTestStep.h"
       
    27 
       
    28 _LIT(KServerName,"TE_SpudUnit");
       
    29 
       
    30 CSpudUnitTestServer* CSpudUnitTestServer::NewL()
       
    31 /**
       
    32  * @return - Instance of the test server
       
    33  * Called inside the MainL() function to create and start the
       
    34  * CTestServer derived server.
       
    35  */
       
    36 	{
       
    37 	// Instantiate server class here
       
    38 	CSpudUnitTestServer * server = new (ELeave) CSpudUnitTestServer();
       
    39 	CleanupStack::PushL(server);
       
    40 	// CServer base class call
       
    41 	server->StartL(KServerName);
       
    42 	CleanupStack::Pop(server);
       
    43 	return server;
       
    44 	}
       
    45 
       
    46 // EKA2 much simpler
       
    47 // Just an E32Main and a MainL()
       
    48 LOCAL_C void MainL()
       
    49 /**
       
    50  * Much simpler, uses the new Rendezvous() call to sync with the client
       
    51  */
       
    52 	{
       
    53 	_LIT(KPhbkSyncCMI, "phbsync.cmi");
       
    54 	TInt err = StartC32WithCMISuppressions(KPhbkSyncCMI);
       
    55 	if (err != KErrNone && err != KErrAlreadyExists)
       
    56 		{
       
    57 		User::Leave(err);
       
    58 		}
       
    59 
       
    60 	CActiveScheduler* sched=NULL;
       
    61 	sched=new(ELeave) CActiveScheduler;
       
    62 	CActiveScheduler::Install(sched);
       
    63 
       
    64 	CSpudUnitTestServer* server = NULL;
       
    65 	// Create the CTestServer derived server
       
    66 	TRAP(err,server = CSpudUnitTestServer::NewL());
       
    67 	if(!err)
       
    68 		{
       
    69 		// Sync with the client and enter the active scheduler
       
    70 		RProcess::Rendezvous(KErrNone);
       
    71 		sched->Start();
       
    72 		}
       
    73 	delete server;
       
    74 	delete sched;
       
    75 	}
       
    76 
       
    77 
       
    78 GLDEF_C TInt E32Main()
       
    79 /**
       
    80  * @return - Standard Epoc error code on exit
       
    81  */
       
    82 	{
       
    83 	CTrapCleanup* cleanup = CTrapCleanup::New();
       
    84 	if(cleanup == NULL)
       
    85 		{
       
    86 		return KErrNoMemory;
       
    87 		}
       
    88 	TRAPD(err,MainL());
       
    89 	delete cleanup;
       
    90 	return err;
       
    91 	}
       
    92 
       
    93 /** export function */
       
    94 REtelDriverInput* NewEtelDriverInputL()
       
    95 	{	
       
    96 	return new(ELeave) REtelDriverInput();
       
    97 	}
       
    98 
       
    99 
       
   100 // Create a thread in the calling process
       
   101 // Emulator typhoon and earlier
       
   102 
       
   103 CTestStep* CSpudUnitTestServer::CreateTestStep(const TDesC& aStepName)
       
   104 /**
       
   105  * @return - A CTestStep derived instance
       
   106  * Implementation of CTestServer pure virtual
       
   107  */
       
   108 	{
       
   109 	CTestStep* testStep = NULL;
       
   110 	
       
   111 	TRAPD
       
   112 		(err,
       
   113 		
       
   114 		// SPUD TEL unit tests
       
   115 		if(aStepName == KSpudTelUnitNormalOperation)
       
   116 			{
       
   117 			testStep = new(ELeave) CSpudTelUnitNormalOperation();
       
   118 			}
       
   119 		if(aStepName == KSpudTelUnitNotifications)
       
   120 			{
       
   121 			testStep = new(ELeave) CSpudTelUnitNotifications();
       
   122 			}
       
   123 		if(aStepName == KSpudTelUnitCreatePrimaryError)
       
   124 			{
       
   125 			testStep = new(ELeave) CSpudTelUnitCreatePrimaryError();
       
   126 			}
       
   127 		if(aStepName == KSpudTelUnitSetQosError)
       
   128 			{
       
   129 			testStep = new(ELeave) CSpudTelUnitSetQosError();
       
   130 			}
       
   131 		if(aStepName == KSpudTelUnitSetTftError)
       
   132 			{
       
   133 			testStep = new(ELeave) CSpudTelUnitSetTftError();
       
   134 			}
       
   135 		if(aStepName == KSpudTelUnitActivateError1)
       
   136 			{
       
   137 			testStep = new(ELeave) CSpudTelUnitActivateError1();	
       
   138 			}
       
   139 		if(aStepName == KSpudTelUnitActivateError2)
       
   140 			{
       
   141 			testStep = new(ELeave) CSpudTelUnitActivateError2();	
       
   142 			}
       
   143 		if(aStepName == KSpudTelUnitDeleteError1)
       
   144 			{
       
   145 			testStep = new(ELeave) CSpudTelUnitDeleteError1();
       
   146 			}
       
   147 		if(aStepName == KSpudTelUnitDeleteError2)
       
   148 			{
       
   149 			testStep = new(ELeave) CSpudTelUnitDeleteError2();
       
   150 			}
       
   151 		if(aStepName == KSpudTelUnitMultipleContexts)
       
   152 			{
       
   153 			testStep = new(ELeave) CSpudTelUnitMultipleContexts();	
       
   154 			}
       
   155 		if(aStepName == KSpudTelUnitCancel)
       
   156 			{
       
   157 			testStep = new(ELeave) CSpudTelUnitCancel();	
       
   158 			}
       
   159 		
       
   160 		// SPUD FSM unit tests
       
   161 		if(aStepName == KSpudFsmUnitNormalOperation)
       
   162 			{
       
   163 			testStep = new(ELeave) CSpudFsmUnitNormalOperation();
       
   164 			}
       
   165 		if(aStepName == KSpudFsmCreatePrimaryError1)
       
   166 			{
       
   167 			testStep = new(ELeave) CSpudFsmUnitCreatePrimaryError1();
       
   168 			}
       
   169 		if(aStepName == KSpudFsmCreatePrimaryError2)
       
   170 			{
       
   171 			testStep = new(ELeave) CSpudFsmUnitCreatePrimaryError2();
       
   172 			}
       
   173 		if(aStepName == KSpudFsmCreatePrimaryError3)
       
   174 			{
       
   175 			testStep = new(ELeave) CSpudFsmUnitCreatePrimaryError3();
       
   176 			}
       
   177 		if(aStepName == KSpudFsmSetQosAndTftError)
       
   178 			{
       
   179 			testStep = new(ELeave) CSpudFsmUnitSetQosAndTftError();
       
   180 			}
       
   181 		if(aStepName == KSpudFsmChangeQosAndTftError)
       
   182 			{
       
   183 			testStep = new(ELeave) CSpudFsmUnitChangeQosAndTftError();
       
   184 			}
       
   185 		if(aStepName == KSpudFsmTestNotifications)
       
   186 			{
       
   187 			testStep = new(ELeave) CSpudFsmUnitNotifications();
       
   188 			}
       
   189 		if(aStepName == KSpudFsmNetworkDelete)
       
   190 			{
       
   191 			testStep = new(ELeave) CSpudFsmUnitNetworkDelete();
       
   192 			}
       
   193 		
       
   194 		);
       
   195 	
       
   196 	if (err != KErrNone)
       
   197 		{
       
   198 		return NULL;
       
   199 		}
       
   200 		
       
   201 	return testStep;
       
   202 	}
       
   203