networkprotocolmodules/suplprotocolmodule/SuplProtocol/test/src/mtlr7Step.cpp
changeset 36 b47902b73a93
parent 0 9cfd9a3ee49c
equal deleted inserted replaced
35:a2efdd544abf 36:b47902b73a93
       
     1 // Copyright (c) 2005-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 // Example CTestStep derived implementation
       
    15 // 
       
    16 //
       
    17 
       
    18 /**
       
    19  @file mtlr7Step.cpp
       
    20  @internalTechnology
       
    21 */
       
    22 #include "mtlr7Step.h"
       
    23 #include "te_suplprotocolsuitedefs.h"
       
    24 #include<lbs/lbsextendedsatellite.h> 
       
    25 /**
       
    26  Destructor
       
    27  */
       
    28 Cmtlr7Step::~Cmtlr7Step()
       
    29 
       
    30 	{
       
    31 	}
       
    32 
       
    33 /**
       
    34  Constructor
       
    35  */
       
    36 Cmtlr7Step::Cmtlr7Step()
       
    37 	{
       
    38 	SetTestStepName(Kmtlr7Step);
       
    39 	}
       
    40 
       
    41 /**
       
    42  @return - TVerdict code
       
    43  Override of base class virtual
       
    44  */
       
    45 TVerdict Cmtlr7Step::doTestStepPreambleL()
       
    46 	{
       
    47 	// Call base class method for pre test actions	
       
    48 	CTe_suplprotocolSuiteStepBase::doTestStepPreambleL();
       
    49 	 
       
    50 	TLbsNetProtocolModuleParams param(*iGatewayObserver);
       
    51 	iModule = CSuplGatewayInterface::NewL(reinterpret_cast<TAny*>(&param));
       
    52 	
       
    53 	// components for generating incoming SMS SUPL INIT
       
    54 	iSuplPush = CLbsSuplPush::NewL(ELbsSuplPushChannelSMS, *this);
       
    55 	iSuplInitGenerator = CSuplInitGenerator::NewL();
       
    56 
       
    57 	return TestStepResult();
       
    58 	}
       
    59 
       
    60 
       
    61 /** Perform Cmtlr7Step test step.
       
    62 
       
    63 This test verifies that the SUPL Protocol Module correctly handles an MT-LR 
       
    64 when the requested positioning type is Terminal Assisted 
       
    65 (and Terminal Assisted Positioning is supported)
       
    66 
       
    67 @return TVerdict test result code
       
    68 */
       
    69 TVerdict Cmtlr7Step::doTestStepL()
       
    70 	{
       
    71 	INFO_PRINTF1(_L("\t********************************************************************"));
       
    72 	INFO_PRINTF1(_L("\tMTLR basic procedure followed - Assistance Data in RRLP message"));
       
    73 	INFO_PRINTF1(_L("\t********************************************************************"));
       
    74 	INFO_PRINTF1(_L("- START -"));	
       
    75 	
       
    76 
       
    77 	// Initiate MT-LR
       
    78 	// Generate received SUPL INIT message (test message content #3 - terminal assisted)
       
    79 	TPtr8 messagePtr(iReceiveBuffer.Des());
       
    80 	TInt err = iSuplInitGenerator->GenerateSuplInitL(3, messagePtr);
       
    81 	if (err != KErrNone)
       
    82 		{
       
    83 		SetTestStepResult(EFail);
       
    84 		return TestStepResult();
       
    85 		}
       
    86 
       
    87 	// Inject SUPL INIT using the SUPL Push API
       
    88 	INFO_PRINTF1(_L("\tLBS (SuplPush) -> OnSuplInit()"));
       
    89 	TLbsSuplPushRequestId reqId = 12345;
       
    90 	TPtrC8 message(messagePtr);
       
    91 	iSuplPush->SuplInit(reqId, message, 0);
       
    92 	
       
    93 	// Check Gateway receives a Privacy request and Location Request
       
    94 	INFO_PRINTF1(_L("\tLBS <- ProcessLocationRequest()"));
       
    95 	if (EFail == CheckGatewayCallbackL(CSuplGatewayObserver::EProcessLocationRequest) ||
       
    96 		!iGatewayObserver->IsPrivReqReceived() ||
       
    97 		MLbsNetworkProtocolObserver::EServiceMobileTerminated != iGatewayObserver->LocType() )
       
    98 		{
       
    99 		SetTestStepResult(EFail);
       
   100 		return TestStepResult();
       
   101 		}
       
   102 
       
   103 	// LBS delivers privacy response
       
   104 	INFO_PRINTF1(_L("\tLBS -> RespondPrivacyRequest ()"));	
       
   105 	CLbsNetworkProtocolBase::TLbsPrivacyResponse privacyResponse = CLbsNetworkProtocolBase::EPrivacyResponseAccepted;
       
   106 	iModule->RespondPrivacyRequest(iGatewayObserver->SessionIdValue(), privacyResponse, 0);
       
   107 	
       
   108 	// Check Connection Manager receives a request for connecting
       
   109 	if (EFail == CheckNetworkCallbackL(CSuplNetworkTestObserver::EConnectReq))
       
   110 		{
       
   111 		SetTestStepResult(EFail);
       
   112 		return TestStepResult();
       
   113 		}
       
   114 	INFO_PRINTF1(_L("\t\t\t\t\t\t\t\t ConnectionRequest -> NET"));
       
   115 
       
   116 	// Simulate the connection is up (inject that event)
       
   117 	INFO_PRINTF1(_L("\t\t\t\t\t\t\t\t Connected <- NET"));
       
   118     iNetworkObserver->InjectConnectedIndication(iNetworkObserver->SessionId());
       
   119     
       
   120 	// LBS Requests assistance data
       
   121 	INFO_PRINTF1(_L("\tLBS -> RequestAssistanceData ()"));	
       
   122 	TLbsAsistanceDataGroup dataRequestMask1 = EAssistanceDataBadSatList;
       
   123 	TLbsNetSessionIdArray dummyIdArray;	
       
   124 	iModule->RequestAssistanceData(dataRequestMask1, dummyIdArray);
       
   125 	
       
   126 	
       
   127 	// Check Connection Manager receives a request to send a SUPL POS INIT
       
   128 	// with the assistance data mask requested by the gateway
       
   129 	if (EFail == CheckNetworkCallbackL(CSuplNetworkTestObserver::ESendSuplPosInitSendReq))
       
   130 		{
       
   131 		SetTestStepResult(EFail);
       
   132 		return TestStepResult();
       
   133 		}
       
   134 	INFO_PRINTF1(_L("\t\t\t\t\t\t\t\t SUPL POS INIT -> NET"));
       
   135 
       
   136 	// Inject a SUPL POS with the Assistance data requested
       
   137 	INFO_PRINTF1(_L("\t\t\t\t\t\t\t\t SUPL POS - RRLP Assitance Data <- NET"));
       
   138 	CSuplMessageBase* suplPos = BuildSuplPosAssitDataL(EAssistanceDataAquisitionAssistance|EAssistanceDataBadSatList, EFalse);
       
   139 	iNetworkObserver->InjectSuplMessage(iNetworkObserver->SessionId(), suplPos);	
       
   140 
       
   141 
       
   142 
       
   143 	// Check gateway receives the assistance data types requested.
       
   144 	INFO_PRINTF1(_L("\tLBS <- ProcessAssistanceData()"));
       
   145 	if (EFail == CheckGatewayCallbackL(
       
   146 				CSuplGatewayObserver::EProcessAssistanceData) ||
       
   147 		(dataRequestMask1 & iGatewayObserver->AssistanceDataSetMask() != dataRequestMask1))
       
   148 		{
       
   149 		SetTestStepResult(EFail);
       
   150 		return TestStepResult();
       
   151 		}
       
   152 	
       
   153 
       
   154 	// Check the Connection Manager receives a request to send a SUPL POS (ack to assistance data)
       
   155 	if (EFail == CheckNetworkCallbackL(CSuplNetworkTestObserver::ESendSuplPosSendReq))
       
   156 		{
       
   157 		SetTestStepResult(EFail);
       
   158 		return TestStepResult();
       
   159 		}
       
   160 	INFO_PRINTF1(_L("\t\t\t\t\t\t\t\t SUPL POS - RRLP Assistance Data Ack -> NET"));
       
   161 
       
   162 
       
   163 
       
   164 	// Inject a SUPL POS (RRLP Measure Position Request) - no assistance data
       
   165 	INFO_PRINTF1(_L("\t\t\t\t\t\t\t\t SUPL POS - RRLP Measure Position Request <- NET"));
       
   166 	suplPos = BuildSuplPosRequestL(TPositionModuleInfo::ETechnologyTerminal | TPositionModuleInfo::ETechnologyAssisted, EAssistanceDataNone);
       
   167 	iNetworkObserver->InjectSuplMessage(iNetworkObserver->SessionId(), suplPos);	
       
   168 
       
   169 
       
   170 
       
   171 	// Check gateway receives a location request (due to the RRLP Measure Position Request)
       
   172 	INFO_PRINTF1(_L("\tLBS <- ProcessLocationRequest()"));
       
   173 	if (EFail == CheckGatewayCallbackL(CSuplGatewayObserver::EProcessLocationRequest) ||
       
   174 		MLbsNetworkProtocolObserver::EServiceMobileTerminated != iGatewayObserver->LocType())
       
   175 		{
       
   176 		SetTestStepResult(EFail);
       
   177 		return TestStepResult();
       
   178 		}
       
   179 	
       
   180 
       
   181 	// Fake LBS sending results (measurements) to SPM
       
   182 	INFO_PRINTF1(_L("\tLBS -> RespondLocationRequest"));
       
   183 	TPositionExtendedSatelliteInfo satelliteInfo;
       
   184 	TSatelliteData satelliteData;
       
   185 	satelliteData.SetSatelliteId(23);
       
   186 	satelliteData.SetAzimuth(32);
       
   187 	satelliteData.SetElevation(64);
       
   188 	satelliteData.SetIsUsed(ETrue);
       
   189 	satelliteData.SetSignalStrength(15);	
       
   190 	satelliteInfo.AppendSatelliteData(satelliteData);
       
   191 	iModule->RespondLocationRequest(iGatewayObserver->SessionIdValue(),KErrNone,satelliteInfo);
       
   192 	
       
   193 
       
   194 	// Check the Connection Manager receives a request to send a SUPL POS (RRLP Measure Position Response)
       
   195 	if (EFail == CheckNetworkCallbackL(CSuplNetworkTestObserver::ESendSuplPosSendReq))
       
   196 		{
       
   197 		SetTestStepResult(EFail);
       
   198 		return TestStepResult();
       
   199 		}
       
   200 	INFO_PRINTF1(_L("\t\t\t\t\t\t\t\t SUPL POS - RRLP Measure Position Response -> NET"));
       
   201 
       
   202 
       
   203 	// Inject a SUPL END (with position)
       
   204 	INFO_PRINTF1(_L("\t\t\t\t\t\t\t\t SUPL END <- NET"));
       
   205 	CSuplMessageBase* suplEnd = BuildSuplEndL(ETrue);
       
   206 	iNetworkObserver->InjectSuplMessage(iNetworkObserver->SessionId(), suplEnd);
       
   207 	
       
   208 
       
   209 	// Check gateway receives a location update (due to the received final position)
       
   210 	INFO_PRINTF1(_L("\tLBS <- ProcessLocationUpdate()"));
       
   211 	if (EFail == CheckGatewayCallbackL(CSuplGatewayObserver::EProcessLocationUpdate))
       
   212 		{
       
   213 		SetTestStepResult(EFail);
       
   214 		return TestStepResult();
       
   215 		}
       
   216 	
       
   217 
       
   218 	// Check gateway session completed
       
   219 	if (EFail == CheckGatewayCallbackL(CSuplGatewayObserver::EProcessSessionComplete))
       
   220 		{
       
   221 		SetTestStepResult(EFail);
       
   222 		return TestStepResult();
       
   223 		}
       
   224 	INFO_PRINTF1(_L("\tLBS <- ProcessSessionComplete"));
       
   225 
       
   226 	// Check Connection Manager receives a disconnection request
       
   227 	if (EFail == CheckNetworkCallbackL(CSuplNetworkTestObserver::EDisconnectReq))
       
   228 		{
       
   229 		SetTestStepResult(EFail);
       
   230 		return TestStepResult();
       
   231 		}
       
   232 	INFO_PRINTF1(_L("\t\t\t\t\t\t\t\t DisconnectRequest -> NET"));
       
   233 	
       
   234 	// Check if more observer activity takes place
       
   235 	if (iGatewayObserver->IsMoreObserverActivity() ||
       
   236 	iNetworkObserver->IsMoreObserverActivity())
       
   237 		{
       
   238 		SetTestStepResult(EFail);
       
   239 		return TestStepResult();
       
   240 		}
       
   241 	INFO_PRINTF1(_L("- END -"));
       
   242 	
       
   243 	SetTestStepResult(EPass);
       
   244 	return TestStepResult();
       
   245 	
       
   246 	}
       
   247 
       
   248 
       
   249 /**
       
   250  * @return - TVerdict code
       
   251  * Override of base class virtual
       
   252  */
       
   253 TVerdict Cmtlr7Step::doTestStepPostambleL()
       
   254 	{
       
   255 	delete iModule;
       
   256 
       
   257 	delete iSuplPush;
       
   258 	delete iSuplInitGenerator;
       
   259 
       
   260 	// Call base class method for post test actions	
       
   261 	CTe_suplprotocolSuiteStepBase::doTestStepPostambleL();
       
   262 	return TestStepResult();
       
   263 	}
       
   264 
       
   265 
       
   266 /**
       
   267 Overrides the pure virtual MLbsSuplPushObserver::OnSuplInitComplete.
       
   268 Receives the result of the message sending.
       
   269 	
       
   270 @param aError [In] The error code or KErrNone if successful.
       
   271 
       
   272 @see MTe_LbsSuplSmsTriggerSenderObserver::OnMessageSent
       
   273 @see CTe_LbsSuplSmsTriggerSender::SendMessage
       
   274 */
       
   275 void Cmtlr7Step::OnSuplInitComplete(TLbsSuplPushChannel /*aChannel*/, TLbsSuplPushRequestId /*aReqId*/, TInt aError, TInt /*aReserved*/)
       
   276 	{
       
   277 	iSmsSendError = aError;
       
   278 	if (iSmsSendError != KErrNone)
       
   279 		{
       
   280 		User::Invariant();
       
   281 		}
       
   282 	}
       
   283