servicediscoveryandcontrol/pnp/test/upnp/unittests/te_serverbase/src/te_serverbase.cpp
changeset 0 f5a58ecadc66
equal deleted inserted replaced
-1:000000000000 0:f5a58ecadc66
       
     1 /*
       
     2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #include <e32base.h>
       
    21 
       
    22 // Test system includes
       
    23 #include "te_serverbase.h"
       
    24 #include "te_serverbaseteststep.h"
       
    25 
       
    26 
       
    27 LOCAL_C void MainL()
       
    28 /**
       
    29  * Much simpler, uses the new Rendezvous() call to sync with the client
       
    30  */
       
    31 	{
       
    32 	// Leave the hooks in for platform security
       
    33 #if (defined __DATA_CAGING__)
       
    34 	RProcess().DataCaging(RProcess::EDataCagingOn);
       
    35 	RProcess().SecureApi(RProcess::ESecureApiOn);
       
    36 #endif
       
    37 	CActiveScheduler* sched=NULL;
       
    38 	sched=new(ELeave) CActiveScheduler;
       
    39 	CActiveScheduler::Install(sched);
       
    40 
       
    41 	CTestServer* server = NULL;
       
    42 	// Create the CTestServer derived server
       
    43 
       
    44 	TRAPD(err,server = CTestServerBase::NewL());
       
    45 	if(!err)
       
    46 		{
       
    47 		// Sync with the client and enter the active scheduler
       
    48 		RProcess::Rendezvous(KErrNone);
       
    49 		sched->Start();
       
    50 		}
       
    51 	delete server;
       
    52 	delete sched;
       
    53 	}
       
    54 
       
    55 // Only a DLL on emulator for typhoon and earlier
       
    56 
       
    57 GLDEF_C TInt E32Main()
       
    58 /**
       
    59  * @return - Standard Epoc error code on exit
       
    60  */
       
    61 	{
       
    62 	CTrapCleanup* cleanup = CTrapCleanup::New();
       
    63 	if(cleanup == NULL)
       
    64 		{
       
    65 		return KErrNoMemory;
       
    66 		}
       
    67 	TRAPD(err,MainL());
       
    68 	delete cleanup;
       
    69 	if(KErrNone != err)
       
    70 		{
       
    71 		return err;
       
    72 		}
       
    73 	return KErrNone;
       
    74     }
       
    75 
       
    76 // Create a thread in the calling process
       
    77 // Emulator typhoon and earlier
       
    78 
       
    79 //---------------------------------------------------------------------------------------------------------------------------
       
    80 //this is the test server which instantiates the test steps
       
    81 
       
    82 CTestServer* CTestServerBase::NewL ()
       
    83 	{
       
    84 	CTestServerBase* server = new ( ELeave ) CTestServerBase;
       
    85 	CleanupStack::PushL(server);
       
    86 	server->ConstructL(KServerName);
       
    87 	CleanupStack::Pop(server);
       
    88 	return server;
       
    89 	}
       
    90 
       
    91 CTestServerBase::~CTestServerBase ()
       
    92 	{
       
    93 	}
       
    94 
       
    95 CTestServerBase::CTestServerBase ()
       
    96 	{
       
    97 	}
       
    98 
       
    99 CTestStep* CTestServerBase::CreateTestStep(const TDesC& aStepName)
       
   100 	{
       
   101 	// removed ELeave as harness will test ptr. This is more efficient
       
   102 	// than using TRAP_IGNORE
       
   103 	CTestServerTestStep* ret = new CTestServerTestStep;			//creating the test step
       
   104 	//CTestServerTestStep derives from CTestStep
       
   105 	if(ret)
       
   106 	{
       
   107 		ret->SetTestStepName(aStepName);
       
   108 	}
       
   109 	return ret;
       
   110 	}