lbstest/lbstestproduct/lbscalculation/src/ctlbscalculationserver.cpp
changeset 0 9cfd9a3ee49c
equal deleted inserted replaced
-1:000000000000 0:9cfd9a3ee49c
       
     1 // Copyright (c) 2008-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 // Test server for calculation tests
       
    15 // 
       
    16 //
       
    17 
       
    18 // User includes
       
    19 #include "ctlbscalculationserver.h"
       
    20 
       
    21 // System includes
       
    22 #include <e32std.h>
       
    23 #include <rsshared.h>
       
    24 
       
    25 // Header files of LBS Client API Test Steps
       
    26 #include "ctlbscalculationtp233.h"
       
    27 #include "ctlbscalculationtp234.h"
       
    28 #include "ctlbscalculationtp235.h"
       
    29 #include "ctlbscalculationtp236.h"
       
    30 
       
    31 /**
       
    32   MainL()
       
    33   Description :		This is the main function which installs the 
       
    34 					active scheduler and creates an object of the Email server
       
    35   @internalTechnology
       
    36   @param  none
       
    37   @return none
       
    38   @pre    None
       
    39   @post   None
       
    40 */
       
    41 LOCAL_C void MainL()
       
    42 	{
       
    43 	CActiveScheduler* sched = new (ELeave) CActiveScheduler;
       
    44 	CleanupStack::PushL(sched);
       
    45 	CActiveScheduler::Install(sched);
       
    46 
       
    47 	__UHEAP_MARK;
       
    48 	// this registers the server with the active scheduler and calls SetActive
       
    49 	CT_LbsCalculationServer* server = CT_LbsCalculationServer::NewL();
       
    50 
       
    51 	// signal to the client that we are ready by
       
    52 	// rendevousing process
       
    53 	RProcess::Rendezvous(KErrNone);
       
    54 
       
    55 	// run the active scheduler
       
    56 	sched->Start();
       
    57 
       
    58 	// clean up
       
    59 	delete server;
       
    60 	__UHEAP_MARKEND;
       
    61 	CleanupStack::PopAndDestroy(sched);
       
    62 	}
       
    63 
       
    64 
       
    65 
       
    66 
       
    67 /**
       
    68   E32Main()
       
    69   Description :	It is the entry point 
       
    70   @internalTechnology
       
    71   @param  none
       
    72   @return Returns the error code
       
    73   @pre    None
       
    74   @post   None
       
    75 */
       
    76 GLDEF_C TInt E32Main()
       
    77 	{
       
    78 	__UHEAP_MARK;
       
    79 	CTrapCleanup* cleanup = CTrapCleanup::New();
       
    80 	if(cleanup == NULL)
       
    81 		{
       
    82 		return KErrNoMemory;
       
    83 		}
       
    84 
       
    85 	TRAPD(err, MainL());
       
    86 
       
    87 	delete cleanup;
       
    88 	__UHEAP_MARKEND;
       
    89 
       
    90 	return err;
       
    91 	}
       
    92     
       
    93 
       
    94 
       
    95 /**
       
    96   NewL()
       
    97   Constructs a CT_LbsCalculationServer object.
       
    98   Uses two phase construction and leaves nothing on the CleanupStack.
       
    99   @internalTechnology
       
   100   @param  none
       
   101   @return Created object of type CT_LbsCalculationServer
       
   102   @pre    None
       
   103   @post   None
       
   104 */
       
   105 CT_LbsCalculationServer* CT_LbsCalculationServer::NewL()
       
   106 	{
       
   107 	CT_LbsCalculationServer *server = new(ELeave) CT_LbsCalculationServer();
       
   108 	CleanupStack::PushL(server);
       
   109 	server->ConstructL(KLbsCalculationTestServer);
       
   110 	CleanupStack::Pop(server);
       
   111 	return server;
       
   112 	}
       
   113 
       
   114 
       
   115 CT_LbsCalculationServer::~CT_LbsCalculationServer()
       
   116 	{
       
   117 	}
       
   118 	
       
   119 	
       
   120 /**
       
   121   Function : CT_LbsCalculationServer
       
   122   Description : Constructor
       
   123   @internalTechnology
       
   124   @param :
       
   125   @return : N/A
       
   126   @precondition : none
       
   127   @postcondition : none
       
   128 */
       
   129 CT_LbsCalculationServer::CT_LbsCalculationServer()
       
   130 	{
       
   131 	}
       
   132 
       
   133 	
       
   134 /**
       
   135   Function : CreateTestStep
       
   136   Description : Creates a test step based on the step name read from the script file
       
   137   @internalTechnology
       
   138   @param : aStepName   The step name which needs to be created
       
   139   @return : Created object of type CTestStep
       
   140   @precondition : none
       
   141   @postcondition : none
       
   142 */
       
   143 CTestStep* CT_LbsCalculationServer::CreateTestStep(const TDesC& aStepName)
       
   144 	{
       
   145 	// NULL if insufficient memory. This suits the API.
       
   146     if(aStepName == KLbsCalculationCalculateDistance)   
       
   147         {
       
   148         return CT_LbsCalculationTP233::New(*this);
       
   149         }
       
   150     else if(aStepName == KLbsCalculationCalculateBearing)   
       
   151         {
       
   152         return CT_LbsCalculationTP234::New(*this);
       
   153         }
       
   154     else if(aStepName == KLbsCalculationCalculateSpeed)   
       
   155         {
       
   156         return CT_LbsCalculationTP235::New(*this);
       
   157         }
       
   158     else if(aStepName == KLbsCalculationCoordinateMove)   
       
   159         {
       
   160         return CT_LbsCalculationTP236::New(*this);
       
   161         }
       
   162 
       
   163 	// Let base class handle any common test steps - will return NULL if test step is not supported.
       
   164     return CT_LbsServer::CreateTestStep(aStepName);
       
   165 	}
       
   166