lbstest/lbstestproduct/lbsconflict/src/ctlbsconflictstepmtlrnetlocreq.cpp
changeset 0 9cfd9a3ee49c
equal deleted inserted replaced
-1:000000000000 0:9cfd9a3ee49c
       
     1 // Copyright (c) 2006-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 // @file ctlbsconflictstepmtlrnetlocreq.cpp
       
    15 // This is the class implementation for a MTLR - Network Location Request conflict test.
       
    16 // EPOC includes.
       
    17 // 
       
    18 //
       
    19 
       
    20 // LBS includes. 
       
    21 #include <lbs.h>
       
    22 #include <lbs/lbsnetcommon.h>
       
    23 #include <lbssatellite.h>
       
    24 #include <lbs/lbsnetprotocolbase.h>
       
    25 #include <lbs/lbsassistancedatabuilderset.h>
       
    26 #include <e32math.h>
       
    27 
       
    28 // LBS test includes.
       
    29 #include "ctlbsconflictstepmtlrnetlocreq.h"
       
    30 #include <lbs/test/tlbsutils.h>
       
    31 
       
    32 
       
    33 /** Static Constructor
       
    34 */
       
    35 CT_LbsConflictStep_MTLRNETLOCREQ* CT_LbsConflictStep_MTLRNETLOCREQ::New(CT_LbsConflictServer& aParent)
       
    36 	{
       
    37 	// Note the lack of ELeave.
       
    38 	// This means that having insufficient memory will return NULL;
       
    39 	CT_LbsConflictStep_MTLRNETLOCREQ* testStep = new CT_LbsConflictStep_MTLRNETLOCREQ(aParent);
       
    40 	if (testStep)
       
    41 		{
       
    42 		TInt err = KErrNone;
       
    43 
       
    44 		TRAP(err, testStep->ConstructL());
       
    45 		if (err)
       
    46 			{
       
    47 			delete testStep;
       
    48 			testStep = NULL;
       
    49 			}
       
    50 		}
       
    51 	return testStep;
       
    52 	}
       
    53 
       
    54 
       
    55 /** Constructor
       
    56  */
       
    57 CT_LbsConflictStep_MTLRNETLOCREQ::CT_LbsConflictStep_MTLRNETLOCREQ(CT_LbsConflictServer& aParent) : CT_LbsConflictStep(aParent)
       
    58 	{
       
    59 	SetTestStepName(KLbsConflictStep_MTLRNETLOCREQ);
       
    60 	}
       
    61 
       
    62 
       
    63 void CT_LbsConflictStep_MTLRNETLOCREQ::ConstructL()
       
    64 	{
       
    65 	// Create the base class objects.
       
    66 	CT_LbsConflictStep::ConstructL();
       
    67 	
       
    68 	// MTLR privacy controller.
       
    69 	iPrivacyController = CLbsPrivacyController::NewL(*this);	
       
    70 
       
    71 	// Self locate async wrapper - NOTE: we're doing a *cellbased* location update
       
    72 	iDoPosUpdate = CT_LbsDoPosUpdate::NewL(this, TPositionModuleInfo::ETechnologyNetwork);
       
    73 	}
       
    74 
       
    75 
       
    76 /** Destructor
       
    77  */
       
    78 CT_LbsConflictStep_MTLRNETLOCREQ::~CT_LbsConflictStep_MTLRNETLOCREQ()
       
    79 	{
       
    80 	iPrivacyController->CancelNetworkLocationRequest(0);
       
    81 	delete iPrivacyController;
       
    82 
       
    83 	iDoPosUpdate->Cancel();
       
    84 	delete iDoPosUpdate;
       
    85 	}
       
    86 
       
    87 
       
    88 /** Expected sequence events.
       
    89 */
       
    90 void CT_LbsConflictStep_MTLRNETLOCREQ::SetExpectedSeq()
       
    91 	{
       
    92 	// note that client flags are commented out here because they vary in order between runs
       
    93 #ifdef PM_HACK_FOR_INC103104
       
    94 	// Set expected sequence for this test:
       
    95 	SetVerifySeqEvent(EClient_Priv_Got_ProcessNetworkLocationRequest);
       
    96 	SetVerifySeqEvent(EMTLR_NetSim_Got_NotifyReleaseLcsLocationNotification);
       
    97 	
       
    98 	// after location notification (iState = EStartMTLRLocReq)
       
    99 	SetVerifySeqEvent(EMTLR_NetSim_Got_NotifyMeasurementControlLocation);
       
   100 	//SetVerifySeqEvent(EClient_Priv_Got_ProcessNetworkPositionUpdate);	// Expect reference position.
       
   101 	
       
   102 	// Network Based Location
       
   103 	// SetVerifySeqEvent(EClient_Got_PosUpdate_Complete);
       
   104 	
       
   105 	// MTLR contd
       
   106 	//SetVerifySeqEvent(EClient_Priv_Got_ProcessNetworkPositionUpdate);	// Expect real position.
       
   107 	SetVerifySeqEvent(EMTLR_NetSim_Got_NotifyMeasurementReportLocation);
       
   108 	//SetVerifySeqEvent(EClient_Priv_Got_ProcessRequestComplete);
       
   109 	
       
   110 #else	// our standard PM
       
   111 	// Set expected sequence for this test:
       
   112 	SetVerifySeqEvent(EClient_Priv_Got_ProcessNetworkLocationRequest);
       
   113 	SetVerifySeqEvent(EMTLR_NetSim_Got_NotifyReleaseLcsLocationNotification);
       
   114 	
       
   115 	// after location notification (iState = EStartMTLRLocReq)
       
   116 	SetVerifySeqEvent(EMTLR_NetSim_Got_NotifyMeasurementControlLocation);
       
   117 	//SetVerifySeqEvent(EClient_Priv_Got_ProcessNetworkPositionUpdate);	// reference position.
       
   118 	//SetVerifySeqEvent(EClient_Priv_Got_ProcessNetworkPositionUpdate);	// real position.
       
   119 	SetVerifySeqEvent(EMTLR_NetSim_Got_NotifyMeasurementReportLocation);
       
   120 	//SetVerifySeqEvent(EClient_Priv_Got_ProcessRequestComplete);
       
   121 			
       
   122 	// Network Based Location	
       
   123 	SetVerifySeqEvent(ESelf_MOLR_NetSim_Got_NotifyRegisterLcsMoLr);	
       
   124 	SetVerifySeqEvent(EMTLR_NetSim_Got_NotifyMeasurementControlLocation);	
       
   125 	SetVerifySeqEvent(EMTLR_NetSim_Got_NotifyMeasurementReportLocation);
       
   126 	//SetVerifySeqEvent(EClient_Got_PosUpdate_Complete);
       
   127 	SetVerifySeqEvent(ESelf_MOLR_NetSim_Got_NotifyFacilityLcsMoLrResult);	
       
   128 	SetVerifySeqEvent(ESelf_MOLR_NetSim_Got_NotifyReleaseLcsMoLr);
       
   129 
       
   130 #endif 
       
   131 	}
       
   132 
       
   133 
       
   134 /** Run the test.
       
   135  */
       
   136 TVerdict CT_LbsConflictStep_MTLRNETLOCREQ::doTestStepL()
       
   137 	{
       
   138 	// Generic test step used to test the LBS Client Notify position update API.
       
   139 	INFO_PRINTF1(_L("&gt;&gt;CT_LbsConflictStep_MTLRNETLOCREQ::doTestStepL()"));
       
   140 
       
   141 	if (TestStepResult() == EPass)
       
   142 		{		
       
   143 		// Setup the expected sequence events for the test.
       
   144 		SetExpectedSeq();
       
   145 				
       
   146 		// Open and setup net sim.
       
   147 		OpenNetSim(this);
       
   148 		
       
   149 		// Kick off the test abort and keep alive timers.
       
   150 		TTimeIntervalMicroSeconds32 abortInterval(120*1000000);	// give it long enough for locserver timeout to fire
       
   151 		TTimeIntervalMicroSeconds32 keepAliveInterval(KLbsKeepAlivePeriod);
       
   152 
       
   153 		iAbortTimer->SetTimer(abortInterval);
       
   154 		iKeepAliveTimer->SetTimer(keepAliveInterval);
       
   155 		
       
   156 		// Set up test module so there's a delay in responding to request for fix:
       
   157 		TModuleDataIn modDataInTimeout; // Used to send test information to the test module.
       
   158 		const TInt KLbsTestModuleTimeOut = 3000000;	// 3 sec delay
       
   159 		// The module request type - time out value.
       
   160 		modDataInTimeout.iRequestType = TModuleDataIn::EModuleRequestTimeOut;
       
   161 		// Micro seconds time value to delay the return position update from the module.
       
   162 		modDataInTimeout.iTimeOut = KLbsTestModuleTimeOut;
       
   163 		T_LbsUtils utils;
       
   164 		utils.NotifyModuleOfConfigChangeL(modDataInTimeout);
       
   165 		
       
   166 		// Kick off test.
       
   167 		CActiveScheduler::Start();
       
   168 
       
   169 		// Clean up.
       
   170 		CloseNetSim();
       
   171 		}
       
   172 
       
   173 	INFO_PRINTF1(_L("&lt;&lt;CT_LbsConflictStep_MTLRNETLOCREQ::doTestStepL()"));
       
   174 
       
   175 	return TestStepResult();
       
   176 	}
       
   177 
       
   178 
       
   179 /** NetSim callbacks.
       
   180 */
       
   181 void CT_LbsConflictStep_MTLRNETLOCREQ::Connected()
       
   182 	{
       
   183 	// Call base implementation.
       
   184 	CT_LbsConflictStep::Connected();
       
   185 	INFO_PRINTF1(_L("Got - Connected"));
       
   186 	
       
   187 	// Start a privacy request:
       
   188 	_LIT8(KTestRequesterId, "LbsConflictMTLRNetLocReq test requester id");
       
   189 	_LIT8(KTestClientName, "LbsConflictMTLRNetLocReq test client name");
       
   190 	_LIT8(KTestClientExternalId, "LbsConflictMTLRNetLocReq test client external id");
       
   191 
       
   192 	TLbsExternalRequestInfo reqInfo; 	
       
   193 	reqInfo.SetRequesterId(KTestRequesterId);
       
   194 	reqInfo.SetClientName(KTestClientName);
       
   195 	reqInfo.SetClientExternalId(KTestClientExternalId);	
       
   196 
       
   197 	TLbsNetPosRequestPrivacy reqType;
       
   198 	reqType.SetRequestAction(TLbsNetPosRequestPrivacy::ERequestActionAllow);
       
   199 	reqType.SetRequestAdvice(TLbsNetPosRequestPrivacy::ERequestAdviceNotify);
       
   200 
       
   201 	iNetSim.SetEmergenyStatus(EFalse);
       
   202 
       
   203 	// kick off the privacy request:
       
   204 	iNetSim.StartNetworkPrivacyRequest(reqType, reqInfo);
       
   205 	
       
   206 	}
       
   207 
       
   208 
       
   209 void CT_LbsConflictStep_MTLRNETLOCREQ::Disconnected()
       
   210 	{
       
   211 	INFO_PRINTF1(_L("Got - Disconnected"));
       
   212 	// Call base implementation.
       
   213 	CT_LbsConflictStep::Disconnected();
       
   214 	}
       
   215 
       
   216 
       
   217 
       
   218 void CT_LbsConflictStep_MTLRNETLOCREQ::NotifyMeasurementControlLocation(const TPositionInfo& aPosition, 
       
   219 															  const RLbsAssistanceDataBuilderSet& aData, 
       
   220 															  const TLbsNetPosRequestQuality& aQuality)
       
   221 	{
       
   222 	INFO_PRINTF1(_L("Got - NetSim Notify Measurement Control Location"));
       
   223 	
       
   224 	(void)aQuality;
       
   225 	(void)aPosition;
       
   226 	(void)aData;
       
   227 	
       
   228 	SetCurrentSeqEvent(EMTLR_NetSim_Got_NotifyMeasurementControlLocation);
       
   229 	}
       
   230 
       
   231 
       
   232 void CT_LbsConflictStep_MTLRNETLOCREQ::NotifyReleaseLcsLocationNotification(const CLbsNetworkProtocolBase::TLbsPrivacyResponse& aResult)
       
   233 	{
       
   234 	//
       
   235 	(void)aResult;
       
   236 	INFO_PRINTF1(_L("Got - NetSim NotifyReleaseLcsLocationNotification."));
       
   237 	SetCurrentSeqEvent(EMTLR_NetSim_Got_NotifyReleaseLcsLocationNotification);
       
   238 	}
       
   239 
       
   240 
       
   241 void CT_LbsConflictStep_MTLRNETLOCREQ::NotifyFacilityLcsMoLrResult(TInt aReason, const TPositionInfo& aPosition)
       
   242 	{
       
   243 	(void)aReason;
       
   244 	(void)aPosition;
       
   245 
       
   246 	INFO_PRINTF1(_L("Got - NetSim Notify Facility Lcs MoLr Result - Event."));
       
   247 	SetCurrentSeqEvent(ESelf_MOLR_NetSim_Got_NotifyFacilityLcsMoLrResult);
       
   248 #ifdef PM_HACK_FOR_INC103104
       
   249 	SetTestStepResult(EFail);
       
   250 #endif
       
   251 	iState = EWaiting;
       
   252 	}
       
   253 
       
   254 
       
   255 void CT_LbsConflictStep_MTLRNETLOCREQ::NotifyMeasurementReportLocation(const TPositionInfo& aPosition)
       
   256 	{
       
   257 	
       
   258 	(void)aPosition;
       
   259 	INFO_PRINTF1(_L("Got - NetSim NotifyMeasurementReportLocation."));
       
   260 	SetCurrentSeqEvent(EMTLR_NetSim_Got_NotifyMeasurementReportLocation);
       
   261     }
       
   262 
       
   263 
       
   264 void CT_LbsConflictStep_MTLRNETLOCREQ::NotifyMeasurementReportRequestMoreAssistanceData(const TLbsAssistanceDataGroup& aFilter)
       
   265 	{
       
   266 	(void)aFilter;
       
   267 
       
   268 	INFO_PRINTF1(_L("Got unxpected - NetSim Notify Measurement Report Request More Assistance Data - Event."));
       
   269 	SetTestStepResult(EFail);
       
   270 	iState = EWaiting;
       
   271 	}
       
   272 
       
   273 
       
   274 void CT_LbsConflictStep_MTLRNETLOCREQ::NotifyMeasurementReportControlFailure(TInt aReason)
       
   275 	{	
       
   276 	INFO_PRINTF2(_L("Got unxpected - Net Sim Notify Measurement Report Control Failure - Event. Reason = %d"), aReason);
       
   277 	SetTestStepResult(EFail);
       
   278 	iState = EWaiting;
       
   279 	}
       
   280 
       
   281 
       
   282 /** MTLR Privacy controller callbacks.
       
   283 */
       
   284 void CT_LbsConflictStep_MTLRNETLOCREQ::ProcessNetworkLocationRequest(TUint aRequestId, const TLbsExternalRequestInfo& aRequestInfo, const TNotificationType& aNotificationType)
       
   285 	{
       
   286 	// We're not aiming to test MT-LR in general here so only carryout minimal verification - verify the request id only.
       
   287 	(void)aRequestInfo;
       
   288 	(void)aNotificationType;
       
   289 	
       
   290 	// Record sequence event.
       
   291 	INFO_PRINTF2(_L("Got - Privacy Process Network Location Request. Request Id = %d."), aRequestId);
       
   292 	SetCurrentSeqEvent(EClient_Priv_Got_ProcessNetworkLocationRequest);
       
   293 	
       
   294 	INFO_PRINTF1(_L("Accepting privacy Request/n"));
       
   295 	iPrivacyController->RespondNetworkLocationRequest(aRequestId, CLbsPrivacyController::ERequestAccepted);
       
   296 	
       
   297 	// Start the MTLR location request. 
       
   298 	INFO_PRINTF1(_L("Asking NetSim to start MTLR location request/n"));
       
   299 	iNetSim.StartNetworkLocationRequest();
       
   300 	}
       
   301 
       
   302 
       
   303 void CT_LbsConflictStep_MTLRNETLOCREQ::ProcessNetworkPositionUpdate(TUint aRequestId, const TPositionInfo& aPosInfo)
       
   304 	{
       
   305 	
       
   306 	// This should be called twice - once for the reference position and once for the gps fix
       
   307 	(void)aRequestId;
       
   308 	(void)aPosInfo;	
       
   309 	// Record sequence event.
       
   310 	INFO_PRINTF2(_L("Got - Privacy Process Network Position Update. Request Id = %d."), aRequestId);
       
   311 	
       
   312 	if(!iProcessNetworkPositionUpdateCount)
       
   313 		{
       
   314 		INFO_PRINTF1(_L("Starting Cell-based Request\n"));
       
   315 		// Start Cell-based location request: 
       
   316 		iPositionInfo = new(ELeave) TPositionInfo();
       
   317 		iDoPosUpdate->StartL(*iPositionInfo);
       
   318 		}
       
   319 		
       
   320 	iProcessNetworkPositionUpdateCount++;
       
   321 	
       
   322 	// SetCurrentSeqEvent(EClient_Priv_Got_ProcessNetworkPositionUpdate); - lrm order not consistent, check some other way
       
   323 	// lrm - to do: log the position details
       
   324 	}
       
   325 
       
   326 
       
   327 void CT_LbsConflictStep_MTLRNETLOCREQ::ProcessRequestComplete(TUint aRequestId, TInt aReason)
       
   328 	{	
       
   329 	
       
   330 	// This should be called at the end of the MTLR
       
   331 	INFO_PRINTF3(_L("Got - Privacy Process Request Complete. Request Id = %d, Reason = %d."), aRequestId, aReason);
       
   332 	if(KErrNone != aReason)
       
   333 		{
       
   334 		SetTestStepResult(EFail);
       
   335 		INFO_PRINTF2(_L("FAILED: Got - Privacy Process Request Complete with reason %d, expected KErrNone."), aReason);
       
   336 		}
       
   337 	// SetCurrentSeqEvent(EClient_Priv_Got_ProcessRequestComplete); - lrm order not consistent, check some other way
       
   338 	iState = EWaiting;
       
   339 	}
       
   340 
       
   341 
       
   342 
       
   343 		
       
   344 void CT_LbsConflictStep_MTLRNETLOCREQ::MT_LbsDoPosUpdateCallback(TRequestStatus& aStatus)
       
   345 	{
       
   346 	TInt err = aStatus.Int();
       
   347 	
       
   348 	INFO_PRINTF2(_L("Got - Location Client notified of Update - Completion reason: %d"), err);
       
   349 	
       
   350 #ifdef PM_HACK_FOR_INC103104	
       
   351 	if(KErrServerBusy != err)		
       
   352 #else
       
   353 	if(KErrNone != err)
       
   354 #endif
       
   355 		{
       
   356 		INFO_PRINTF2(_L("FAILED: Got unexpected error code %d"), err);
       
   357 		SetTestStepResult(EFail);
       
   358 		iState = EWaiting;
       
   359 		}
       
   360 		
       
   361 	//SetCurrentSeqEvent(EClient_Got_PosUpdate_Complete);
       
   362 	
       
   363 	delete iPositionInfo;
       
   364 		
       
   365 	}	
       
   366 
       
   367 void CT_LbsConflictStep_MTLRNETLOCREQ::NotifyRegisterLcsMoLr(const TDesC& aData)
       
   368 	{
       
   369 	if (aData != KNullDesC)
       
   370 		{
       
   371 		INFO_PRINTF1(_L("Got unexpected - NetSim Notify Register Lcs MoLr - Event."));
       
   372 		SetTestStepResult(EFail);
       
   373 		iState = EWaiting;
       
   374 		}
       
   375 	else
       
   376 		INFO_PRINTF1(_L("Got - NetSim Notify Register Lcs MoLr - Callback Event."));
       
   377 
       
   378 	SetCurrentSeqEvent(ESelf_MOLR_NetSim_Got_NotifyRegisterLcsMoLr);
       
   379 	}
       
   380 
       
   381 	
       
   382 
       
   383 void CT_LbsConflictStep_MTLRNETLOCREQ::NotifyReleaseLcsMoLr(TInt aReason)
       
   384 	{
       
   385 	(void)aReason;
       
   386 
       
   387 	INFO_PRINTF1(_L("Got - NetSim Notify Release Lcs MoLr - Callback Event."));
       
   388 	SetCurrentSeqEvent(ESelf_MOLR_NetSim_Got_NotifyReleaseLcsMoLr);
       
   389 	}
       
   390