os/security/authorisation/userpromptservice/database/test/tupsdb/source/tupsdb.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 /*
     2 * Copyright (c) 2004-2009 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 the License "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  @file
    21 */
    22 
    23 #include "tupsdb.h" // TEF Test Server
    24 #include "tupsdbstep.h" // TEF Steps Test Code
    25 
    26 
    27 CTUpsDbServer* CTUpsDbServer::NewL()
    28 /**
    29  * @return - Instance of the test server
    30  * Called inside the MainL() function to create and start the
    31  * CTestServer derived server.
    32  */
    33 	{	
    34 	CTUpsDbServer * server = new (ELeave) CTUpsDbServer();
    35 	CleanupStack::PushL(server);
    36 
    37 	server->ConstructL(KDbServerName);
    38 	CleanupStack::Pop(server);
    39 	return server;
    40 	}
    41 	
    42 
    43 LOCAL_C void MainL()
    44 /**
    45  * Secure variant
    46  * Much simpler, uses the new Rendezvous() call to sync with the client
    47  */
    48 	{
    49 	
    50 	CActiveScheduler *sched = new(ELeave) CActiveScheduler;
    51 	CActiveScheduler::Install(sched);
    52 
    53 	CTUpsDbServer* server = NULL;
    54 	
    55 	// Create the CTestServer derived server
    56 	TRAPD(err,server = CTUpsDbServer::NewL());
    57 	if(!err)
    58 		{
    59 		// Sync with the client and enter the active scheduler
    60 		RProcess::Rendezvous(KErrNone);
    61 		sched->Start();
    62 		}
    63 		
    64 	delete server;
    65 	delete sched;
    66 	}
    67 
    68 GLDEF_C TInt E32Main()
    69 /**
    70  * @return - Standard Epoc error code on process exit
    71  * Process entry point. Called by client using RProcess API
    72  */
    73 	{
    74 	__UHEAP_MARK;
    75 	CTrapCleanup* cleanup = CTrapCleanup::New();
    76 	if(cleanup == NULL)
    77 		{
    78 		return KErrNoMemory;
    79 		}
    80 	TRAPD(err,MainL());
    81 	delete cleanup;
    82 	__UHEAP_MARKEND;
    83 	return err;
    84     }
    85 	
    86 
    87 CTestStep* CTUpsDbServer::CreateTestStep(const TDesC& aStepName)
    88 	{
    89 	// Initialise test step object to NULL if no TEF steps are assigned
    90 	CTestStep* testStep = NULL;
    91 
    92 	if(aStepName == KStepPerformance)
    93 		testStep = new CUpsDbStepPerformance();
    94 	else if (aStepName == KStepUnitTest)
    95 		testStep = new CUpsDbStepUnitTest();
    96 
    97 	return testStep;
    98 	}