datacommsserver/esockserver/test/util/src/te_esockutilserver.cpp
changeset 0 dfb7c4ff071f
equal deleted inserted replaced
-1:000000000000 0:dfb7c4ff071f
       
     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 //
       
    15 
       
    16 #include "te_esockutilserver.h"
       
    17 #include "te_esockutilsteps.h"
       
    18 #include <cfshared.h>
       
    19 using namespace CommsFW;
       
    20 
       
    21 _LIT(KServerName,"te_esockutil");
       
    22 
       
    23 CESockUtilServer* CESockUtilServer::NewL()
       
    24 /**
       
    25 @return - Instance of the test server
       
    26 Called inside the MainL() function to create and start the \
       
    27 CTestServer derived server.
       
    28  */
       
    29 	{
       
    30 	CESockUtilServer * server = new (ELeave) CESockUtilServer();
       
    31 	CleanupStack::PushL(server);
       
    32 
       
    33 	server->ConstructL(KServerName);
       
    34 	CleanupStack::Pop(server);
       
    35 	return server;
       
    36 	}
       
    37 
       
    38 // EKA2 much simpler
       
    39 // Just an E32Main and a MainL()
       
    40 LOCAL_C void MainL()
       
    41 /**
       
    42  * Much simpler, uses the new Rendezvous() call to sync with the client
       
    43  */
       
    44 	{
       
    45 	// Leave the hooks in for platform security
       
    46 #if (defined __DATA_CAGING__)
       
    47 	RProcess().DataCaging(RProcess::EDataCagingOn);
       
    48 	RProcess().SecureApi(RProcess::ESecureApiOn);
       
    49 #endif
       
    50 	CActiveScheduler* sched=NULL;
       
    51 	sched=new(ELeave) CActiveScheduler;
       
    52 	CActiveScheduler::Install(sched);
       
    53 
       
    54 	CESockUtilServer* server = NULL;
       
    55 
       
    56 	// Create the CTestServer derived server
       
    57 	TRAPD(err,server = CESockUtilServer::NewL());
       
    58 	if(!err)
       
    59 		{
       
    60 		// Sync with the client and enter the active scheduler
       
    61 		RProcess::Rendezvous(KErrNone);
       
    62 		sched->Start();
       
    63 		}
       
    64 	delete server;
       
    65 	delete sched;
       
    66 	}
       
    67 
       
    68 // Only a DLL on emulator for typhoon and earlier
       
    69 
       
    70 GLDEF_C TInt E32Main()
       
    71 /**
       
    72  * @return - Standard Epoc error code on exit
       
    73  */
       
    74 	{
       
    75 	CTrapCleanup* cleanup = CTrapCleanup::New();
       
    76 	if(cleanup == NULL)
       
    77 		{
       
    78 		return KErrNoMemory;
       
    79 		}
       
    80 	TRAP_IGNORE(MainL());
       
    81 	delete cleanup;
       
    82 	return KErrNone;
       
    83     }
       
    84 
       
    85 // Create a thread in the calling process
       
    86 // Emulator typhoon and earlier
       
    87 
       
    88 CTestStep* CESockUtilServer::CreateTestStep(const TDesC& aStepName)
       
    89 /** 
       
    90 Implementation of CTestServer pure virtual
       
    91 @return A CTestStep derived instance
       
    92 */
       
    93 	{
       
    94 	CTestStep* testStep = NULL;
       
    95 
       
    96 	if(aStepName == KTestStepLoadESock)
       
    97 		{
       
    98 		testStep = new CTestStepLoadESock();
       
    99 		}
       
   100 	else if(aStepName == KTestStepUnloadESock)
       
   101 		{
       
   102 		testStep = new CTestStepUnloadESock(EGraceful, CTestStepUnloadESock::ENoLeak, EFalse);
       
   103    		}
       
   104    	else if(aStepName == KTestStepUnloadESockForced)
       
   105    		{
       
   106 		testStep = new CTestStepUnloadESock(EImmediate, CTestStepUnloadESock::ENoLeak, EFalse);
       
   107 		}
       
   108 	else if(aStepName == KTestStepUnloadESockForcedTimeout)
       
   109 		{
       
   110 		testStep = new CTestStepUnloadESock(EImmediate, CTestStepUnloadESock::ENoLeak, ETrue);
       
   111 		}
       
   112 	else if(aStepName == KTestStepUnloadESock_MayLeak)
       
   113 		{
       
   114 		testStep = new CTestStepUnloadESock(EImmediate, CTestStepUnloadESock::EMayLeak, EFalse);
       
   115 		}
       
   116 	else if(aStepName == KTestStepUnloadESock_Leaks)
       
   117 		{
       
   118 		testStep = new CTestStepUnloadESock(EImmediate, CTestStepUnloadESock::ELeaks, EFalse);
       
   119 		}
       
   120 	else if(aStepName == KTestStepStopAllInterfaces)
       
   121 		{
       
   122 		testStep = new CTestStepStopAllInterfaces();
       
   123 		}
       
   124 	else if(aStepName == KTestStepDefaultToConfig1)
       
   125 		{
       
   126 		testStep = new CTestStepDefaultToConfig1();
       
   127 		}
       
   128 	else if(aStepName == KTestStepIsNetworkNotActive)
       
   129 		{
       
   130 		testStep = new CTestStepIsNetworkNotActive();
       
   131 		}
       
   132 	else if(aStepName == KTestStepDelay)
       
   133 		{
       
   134 		testStep = new CTestStepDelay();
       
   135 		}
       
   136 	else if(aStepName == KTestStepAlwaysFail)
       
   137 		{
       
   138 		testStep = new CTestStepAlwaysFail();
       
   139 		}
       
   140 	else if(aStepName == KTestStepResetAllocFails)
       
   141 		{
       
   142 		testStep = new CTestStepResetAllocFails();
       
   143 		}
       
   144 	else if(aStepName == KTestStepLoadConfig)
       
   145 		{
       
   146 		testStep = new CTestStepLoadConfig();
       
   147 		}
       
   148 	else if(aStepName == KTestStepCopyFiles)
       
   149 		{
       
   150 		testStep = new CTestStepCopyFiles();
       
   151 		}
       
   152 
       
   153 	return testStep;
       
   154 	}
       
   155