lafagnosticuifoundation/uigraphicsutils/tef/tetultestserver.cpp
changeset 0 2f259fa3e83a
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     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 "tetultestserver.h"
       
    23 #include "t_textresourceutils.h"
       
    24 #include "t_addressstringtokenizer.h"
       
    25 #include "t_phonenumberutils.h"
       
    26 
       
    27 /**
       
    28    @return - Instance of the test server
       
    29    Called inside the MainL() function to create and start the
       
    30    CTestServer derived server.
       
    31  */
       
    32 CTEtulTestServer* CTEtulTestServer::NewL()
       
    33 	{
       
    34 	CTEtulTestServer * server = new (ELeave) CTEtulTestServer();
       
    35 	CleanupStack::PushL(server);
       
    36 	// CServer base class call
       
    37 	TParsePtrC serverName(RProcess().FileName());	
       
    38 	server->StartL(serverName.Name());
       
    39 	CleanupStack::Pop(server);
       
    40 	return server;
       
    41 	}
       
    42 
       
    43 /** Secure variant
       
    44     Much simpler, uses the new Rendezvous() call to sync with the client
       
    45 */
       
    46 LOCAL_C void MainL()
       
    47 	{
       
    48 	CActiveScheduler* sched=NULL;
       
    49 	sched=new(ELeave) CActiveScheduler;
       
    50 	CActiveScheduler::Install(sched);
       
    51 	CTEtulTestServer* server = NULL;
       
    52 	// Create the CTestServer derived server
       
    53 	TRAPD(err,server = CTEtulTestServer::NewL());
       
    54 	if(!err)
       
    55 		{
       
    56 		// Sync with the client and enter the active scheduler
       
    57 		RProcess::Rendezvous(KErrNone);
       
    58 		sched->Start();
       
    59 		}
       
    60 	delete server;
       
    61 	delete sched;
       
    62 	}
       
    63 
       
    64 /*
       
    65    @return - Standard Epoc error code on process exit
       
    66    Secure variant only
       
    67    Process entry point. Called by client using RProcess API
       
    68 */
       
    69 GLDEF_C TInt E32Main()
       
    70 	{
       
    71 	__UHEAP_MARK;
       
    72 	CTrapCleanup* cleanup = CTrapCleanup::New();
       
    73 	if(cleanup == NULL)
       
    74 		{
       
    75 		return KErrNoMemory;
       
    76 		}
       
    77 	TRAP_IGNORE(MainL());
       
    78 	delete cleanup;
       
    79 	__UHEAP_MARKEND;
       
    80 	return KErrNone;
       
    81     }
       
    82 
       
    83 /**
       
    84    @return - A CTestStep derived instance
       
    85    Implementation of CTestServer pure virtual
       
    86  */
       
    87 CTestStep* CTEtulTestServer::CreateTestStep(const TDesC& aStepName)
       
    88 	{
       
    89 	CTestStep* testStep = NULL;
       
    90 	if(aStepName == KT_TextResourceUtilsStep)
       
    91 		testStep = new CT_TextResourceUtilsStep();
       
    92 	else if(aStepName == KT_AddressStringTokenizerStep)
       
    93 		testStep = new CT_AddressStringTokenizerStep();
       
    94 	else if(aStepName == KT_PhoneNumberUtilsStep)
       
    95 		testStep = new CT_PhoneNumberUtilsStep();
       
    96 	return testStep;
       
    97 	}