datasourcemodules/gpspositioningmodule/lbsagpspsy/test/src/te_lbsagpspsysuite.cpp
changeset 36 b47902b73a93
parent 0 9cfd9a3ee49c
child 48 81c9bee26a45
equal deleted inserted replaced
35:a2efdd544abf 36:b47902b73a93
       
     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 // This is the test server for Lbs AGPS PSY tests.
       
    15 // 
       
    16 //
       
    17 
       
    18 #include <centralrepository.h>
       
    19 #include <lbs/test/lbsnetsimtest.h> 
       
    20 
       
    21 #include "lbssystemcontroller.h"
       
    22 #include "lbsrootcenrepdefs.h"
       
    23 
       
    24 #include "te_lbspsyutils.h"
       
    25 #include "te_lbsagpspsysuite.h"
       
    26 #include "te_lbsagpspsyposupdatemodestep.h"
       
    27 #include "te_lbsagpspsyposupdatestep.h"
       
    28 #include "te_lbspsyposupdatetimingstep.h"
       
    29 #include "te_lbsagpspsyposupdateerrstep.h"
       
    30 #include "te_lbspsymodinfostep.h"
       
    31 #include "te_lbspsypoweradvicestep.h"
       
    32 
       
    33 /** The string name of the test suite */
       
    34 _LIT(KServerName, "te_lbsagpspsysuite");
       
    35 
       
    36 /** The UID of the unit test suite*/
       
    37 const TUid  KServerUid = {0x10285ACB};
       
    38 
       
    39 const RLbsPositionUpdateRequests::TChannelIdentifer KChannelIdentifierLS2GpsLocManager = 
       
    40 	{
       
    41 		{KLbsGpsLocManagerUidValue},{KLbsLocServerUidValue}
       
    42 	};
       
    43 
       
    44 
       
    45 /**
       
    46 Static factory method for creating an instance of the CTe_LbsAgpsPsySuite class.
       
    47 
       
    48 @return An instance of the class. The calling application becomes the
       
    49 owner of the returned instance and is responsible its disposal.
       
    50 
       
    51 @leave If a error happens, it leaves with one of the system error codes.
       
    52 */
       
    53 CTe_LbsAgpsPsySuite* CTe_LbsAgpsPsySuite::NewL()
       
    54 	{
       
    55 	CTe_LbsAgpsPsySuite* server = new (ELeave) CTe_LbsAgpsPsySuite();
       
    56 	CleanupStack::PushL(server);
       
    57 	server->ConstructL();
       
    58 	CleanupStack::Pop(server);
       
    59 	return server;
       
    60 	}
       
    61 
       
    62 /**
       
    63 2nd phase constructor. Calls the base class method passing the name of the suite.
       
    64 
       
    65 @leave If a error happens, it leaves with one of the system error codes.
       
    66 */	
       
    67 void CTe_LbsAgpsPsySuite::ConstructL()
       
    68 	{
       
    69 	//ConstructL of the base class
       
    70 	CTestServer::ConstructL(KServerName);
       
    71 	
       
    72 	CTe_SystemStarter starter(KServerUid);
       
    73 	
       
    74 	starter.RestartLbs_RootOnlyL(iFirstExe);
       
    75 
       
    76 	}
       
    77 
       
    78 CTe_LbsAgpsPsySuite::~CTe_LbsAgpsPsySuite()
       
    79 	{
       
    80 	CTe_SystemStarter starter(KServerUid);
       
    81 	
       
    82 	TRAP_IGNORE(starter.RestartLbs_NormalL(iFirstExe));
       
    83 
       
    84 	}
       
    85 
       
    86 /**
       
    87 Overrides the pure virtual CTestServer::CreateTestStep. Creates a test step by its name.
       
    88 
       
    89 @return - A CTestStep derived instance or NULL if error or there is no a test step with the name
       
    90 specified.
       
    91 
       
    92 @see CTestServer::CreateTestStep
       
    93 */
       
    94 CTestStep* CTe_LbsAgpsPsySuite::CreateTestStep(const TDesC& aStepName)
       
    95 	{
       
    96 	iCurrentStep = NULL;
       
    97 	TRAPD(err, iCurrentStep = CreateTestStepL(aStepName));
       
    98 	if(err!=KErrNone)
       
    99 		{
       
   100 		return NULL;
       
   101 		}
       
   102 	return iCurrentStep;
       
   103 	}
       
   104 
       
   105 /**
       
   106 The leaving version of the CTe_LbsSuplSmsTriggerSuiteCreateTestStep. The leaving new operator is used 
       
   107 to initialize the test step object with zeroes.
       
   108 
       
   109 @return - A CTestStep derived instance or NULL if error or there is no a test step with the name
       
   110 specified.
       
   111 
       
   112 @leave KErrNoMemory if not enough memory to create the test step.
       
   113 
       
   114 @see CTe_LbsAgpsPsySuite::CreateTestStep
       
   115 */
       
   116 CTestStep* CTe_LbsAgpsPsySuite::CreateTestStepL(const TDesC& aStepName)
       
   117 	{
       
   118 	if(aStepName==KLbsNotifyPositionUpdateModeStep)
       
   119 	   	{
       
   120 	   	return CTe_LbsAgpsPsyPosUpdateModeStep::NewL(this);
       
   121 	  	}	
       
   122 	if(aStepName==KLbsNotifyPositionUpdateStep)
       
   123 	   	{
       
   124 	   	return CTe_LbsAgpsPsyPosUpdateStep::NewL(this);
       
   125 	  	} 
       
   126 	else if(aStepName==KLbsNotifyPositionUpdateTimingStep)
       
   127 	   	{
       
   128 	   	return CTe_LbsNotifyPositionUpdateTimingStep::NewL(this);
       
   129 	  	}
       
   130 	else if(aStepName==KLbsNotifyPositionUpdateErrStep)
       
   131 		{
       
   132 		return CTe_LbsAgpsNotifyPositionUpdateErrStep::NewL(this);
       
   133 		}
       
   134 	else if(aStepName==KLbsModuleInfoStep)
       
   135 		{
       
   136 		return CTe_LbsModuleInfoStep::NewL(this);
       
   137 		}
       
   138 	else if(aStepName==KLbsPowerAdviceStep)
       
   139 		{
       
   140 		return CTe_LbsPsyPowerAdviceStep::NewL(this);
       
   141 		}	
       
   142 	
       
   143 	return NULL;
       
   144 	}
       
   145 
       
   146 
       
   147 TUid CTe_LbsAgpsPsySuite::ModuleUid() const
       
   148 	{
       
   149 	return KLbsGpsLocManagerUid;
       
   150 	}
       
   151 
       
   152 const RLbsPositionUpdateRequests::TChannelIdentifer& CTe_LbsAgpsPsySuite::UpdateReqChanId() const
       
   153 	{
       
   154 	return KChannelIdentifierLS2GpsLocManager;
       
   155 	}
       
   156 
       
   157 TUint CTe_LbsAgpsPsySuite::CountPositioner()
       
   158 	{
       
   159 	return iPositionerCount++;
       
   160 	}
       
   161 
       
   162 CTestExecuteLogger& CTe_LbsAgpsPsySuite::Logger() const
       
   163 	{
       
   164 	__ASSERT_ALWAYS(iCurrentStep, User::Invariant());
       
   165 	return iCurrentStep->Logger();
       
   166 	}
       
   167 
       
   168 
       
   169 /**
       
   170 Secure variant. Much simpler, uses the new Rendezvous() call to sync with the client.
       
   171 
       
   172 @leave If a error happens, it leaves with one of the system error codes.
       
   173 */
       
   174 LOCAL_C void MainL()
       
   175 	{
       
   176 	// Leave the hooks in for platform security
       
   177 #if (defined __DATA_CAGING__)
       
   178 	RProcess().DataCaging(RProcess::EDataCagingOn);
       
   179 	RProcess().DataCaging(RProcess::ESecureApiOn);
       
   180 #endif
       
   181 	CActiveScheduler* sched=NULL;
       
   182 	sched=new(ELeave) CActiveScheduler;
       
   183 	CActiveScheduler::Install(sched);
       
   184 	
       
   185 	CTe_LbsAgpsPsySuite* server = NULL;
       
   186 	// Create the CTestServer derived server
       
   187 	TRAPD(err,server = CTe_LbsAgpsPsySuite::NewL());
       
   188 	if(!err)
       
   189 		{
       
   190 		// Sync with the client and enter the active scheduler
       
   191 		RProcess::Rendezvous(KErrNone);
       
   192 		sched->Start();
       
   193 		}
       
   194 	
       
   195 	delete server;
       
   196 	delete sched;
       
   197 	}
       
   198 
       
   199 
       
   200 /**
       
   201 Secure variant only. Process entry point. Called by client using RProcess API.
       
   202  
       
   203 @return - Standard Epoc error code on process exit.
       
   204 */
       
   205 GLDEF_C TInt E32Main()
       
   206 	{
       
   207 	__UHEAP_MARK;
       
   208 	CTrapCleanup* cleanup = CTrapCleanup::New();
       
   209 	if(cleanup == NULL)
       
   210 		{
       
   211 		return KErrNoMemory;
       
   212 		}
       
   213 	TRAPD(err,MainL());
       
   214 	delete cleanup;
       
   215 	__UHEAP_MARKEND;
       
   216 	return err;
       
   217     }
       
   218