networkprotocolmodules/suplprotocolmodule/SuplProtocol/test/src/mtlr25Step.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 mtlr25Step.cpp
       
    20  @internalTechnology
       
    21 */
       
    22 #include "mtlr25Step.h"
       
    23 #include "te_suplprotocolsuitedefs.h"
       
    24 #include "lbssystemcontroller.h"
       
    25 
       
    26 /**
       
    27  Destructor
       
    28  */
       
    29 Cmtlr25Step::~Cmtlr25Step()
       
    30 
       
    31 	{
       
    32 	}
       
    33 
       
    34 /**
       
    35  Constructor
       
    36  */
       
    37 Cmtlr25Step::Cmtlr25Step()
       
    38 	{
       
    39 	SetTestStepName(Kmtlr25Step);
       
    40 	}
       
    41 
       
    42 /**
       
    43  @return - TVerdict code
       
    44  Override of base class virtual
       
    45  */
       
    46 TVerdict Cmtlr25Step::doTestStepPreambleL()
       
    47 	{
       
    48 	// Call base class method for pre test actions	
       
    49 	CTe_suplprotocolSuiteStepBase::doTestStepPreambleL();
       
    50 	 	 
       
    51 	TLbsNetProtocolModuleParams param(*iGatewayObserver);
       
    52 	iModule = CSuplGatewayInterface::NewL(reinterpret_cast<TAny*>(&param));
       
    53 	
       
    54 	// components for generating incoming SMS SUPL INIT
       
    55 	iSuplPush = CLbsSuplPush::NewL(ELbsSuplPushChannelSMS, *this);
       
    56 	iSuplInitGenerator = CSuplInitGenerator::NewL();
       
    57 
       
    58 	return TestStepResult();
       
    59 	}
       
    60 
       
    61 
       
    62 /** Perform Cmtlr25Step test step.
       
    63 This test verifies that the SUPL Protocol Module correctly handles 
       
    64 an MT-LR Network requested Locate Terminal Based sequence (assistance data
       
    65 delivered via an RRLP payload).
       
    66 
       
    67 @return TVerdict test result code
       
    68 */
       
    69 TVerdict Cmtlr25Step::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 	// Initiate MT-LR
       
    77 	// Generate received SUPL INIT message (test message content #0)
       
    78 	TPtr8 messagePtr(iReceiveBuffer.Des());
       
    79 	TInt err = iSuplInitGenerator->GenerateSuplInitL(0, messagePtr);
       
    80 	if (err != KErrNone)
       
    81 		{
       
    82 		SetTestStepResult(EFail);
       
    83 		return TestStepResult();
       
    84 		}
       
    85 
       
    86 	// Inject SUPL INIT using the SUPL Push API
       
    87 	INFO_PRINTF1(_L("\tLBS (SuplPush) -> OnSuplInit()"));
       
    88 	TLbsSuplPushRequestId reqId = 12345;
       
    89 	TPtrC8 message(messagePtr);
       
    90 	iSuplPush->SuplInit(reqId, message, 0);
       
    91 	
       
    92 	// Check Gateway receives a Privacy request and Location Request (no method specified)
       
    93 	INFO_PRINTF1(_L("\tLBS <- ProcessLocationRequest()"));
       
    94 	if (EFail == CheckGatewayCallbackL(CSuplGatewayObserver::EProcessLocationRequest) ||
       
    95 		!iGatewayObserver->IsPrivReqReceived() ||
       
    96 		MLbsNetworkProtocolObserver::EServiceMobileTerminated != iGatewayObserver->LocType() )
       
    97 		{
       
    98 		SetTestStepResult(EFail);
       
    99 		return TestStepResult();
       
   100 		}
       
   101 
       
   102 	// LBS delivers privacy response
       
   103 	INFO_PRINTF1(_L("\tLBS -> PrivacyResponse (EPrivacyResponseAccepted)"));	
       
   104 	CLbsNetworkProtocolBase::TLbsPrivacyResponse privacyResponse = CLbsNetworkProtocolBase::EPrivacyResponseAccepted;
       
   105 	iModule->RespondPrivacyRequest(iGatewayObserver->SessionIdValue(), privacyResponse, 0);
       
   106 	
       
   107 	// Check Connection Manager receives a request for connecting
       
   108 	if (EFail == CheckNetworkCallbackL(CSuplNetworkTestObserver::EConnectReq))
       
   109 		{
       
   110 		SetTestStepResult(EFail);
       
   111 		return TestStepResult();
       
   112 		}
       
   113 	INFO_PRINTF1(_L("\t\t\t\t\t\t\t\t ConnectionRequest -> NET"));
       
   114 
       
   115 	// Simulate the connection is up (inject that event)
       
   116 	INFO_PRINTF1(_L("\t\t\t\t\t\t\t\t Connected <- NET"));
       
   117     iNetworkObserver->InjectConnectedIndication(iNetworkObserver->SessionId());
       
   118     
       
   119 	// LBS Requests assistance data
       
   120 	INFO_PRINTF1(_L("\tLBS -> RequestAssistanceData ()"));	
       
   121 	TLbsAsistanceDataGroup dataRequestMask1 = EAssistanceDataBadSatList;
       
   122 	TLbsNetSessionIdArray dummyIdArray;	
       
   123 	iModule->RequestAssistanceData(dataRequestMask1, dummyIdArray);
       
   124 	
       
   125 	// Check Connection Manager receives a request to send a SUPL POS INIT
       
   126 	// with the assistance data mask requested by the gateway
       
   127 	if (EFail == CheckNetworkCallbackL(CSuplNetworkTestObserver::ESendSuplPosInitSendReq))
       
   128 		{
       
   129 		SetTestStepResult(EFail);
       
   130 		return TestStepResult();
       
   131 		}
       
   132 	INFO_PRINTF1(_L("\t\t\t\t\t\t\t\t SUPL POS INIT -> NET"));
       
   133 
       
   134 	// Inject a SUPL POS with the Assistance data requested
       
   135 	INFO_PRINTF1(_L("\t\t\t\t\t\t\t\t SUPL POS - RRLP Assitance Data <- NET"));
       
   136 	CSuplMessageBase* suplPos = BuildSuplPosAssitDataL(EAssistanceDataAquisitionAssistance|EAssistanceDataBadSatList, EFalse);
       
   137 	iNetworkObserver->InjectSuplMessage(iNetworkObserver->SessionId(), suplPos);	
       
   138 
       
   139 	// Check gateway receives the assistance data types requested.
       
   140 	INFO_PRINTF1(_L("\tLBS <- ProcessAssistanceData()"));
       
   141 	if (EFail == CheckGatewayCallbackL(
       
   142 				CSuplGatewayObserver::EProcessAssistanceData) ||
       
   143 		(dataRequestMask1 & iGatewayObserver->AssistanceDataSetMask() != dataRequestMask1))
       
   144 		{
       
   145 		SetTestStepResult(EFail);
       
   146 		return TestStepResult();
       
   147 		}
       
   148 
       
   149 	// Check the Connection Manager receives a request to send a SUPL POS (ack to assistance data)
       
   150 	if (EFail == CheckNetworkCallbackL(CSuplNetworkTestObserver::ESendSuplPosSendReq))
       
   151 		{
       
   152 		SetTestStepResult(EFail);
       
   153 		return TestStepResult();
       
   154 		}
       
   155 	INFO_PRINTF1(_L("\t\t\t\t\t\t\t\t SUPL POS - RRLP Assistance Data Ack -> NET"));
       
   156 
       
   157 	// Inject a SUPL POS (RRLP Measure Position Request) - no assistance data
       
   158 	INFO_PRINTF1(_L("\t\t\t\t\t\t\t\t SUPL POS - RRLP Measure Position Request <- NET"));
       
   159 	TLbsAsistanceDataGroup dataRequestMask2 = EAssistanceDataNone;
       
   160 	suplPos = BuildSuplPosRequestL(TPositionModuleInfo::ETechnologyTerminal | TPositionModuleInfo::ETechnologyAssisted, dataRequestMask2);
       
   161 	iNetworkObserver->InjectSuplMessage(iNetworkObserver->SessionId(), suplPos);	
       
   162 
       
   163 	// Check gateway receives a location request (due to the RRLP Measure Position Request)
       
   164 	INFO_PRINTF1(_L("\tLBS <- ProcessLocationRequest()"));
       
   165 	if (EFail == CheckGatewayCallbackL(CSuplGatewayObserver::EProcessLocationRequest) ||
       
   166 		MLbsNetworkProtocolObserver::EServiceMobileTerminated != iGatewayObserver->LocType())
       
   167 		{
       
   168 		SetTestStepResult(EFail);
       
   169 		return TestStepResult();
       
   170 		}
       
   171 	
       
   172 
       
   173 	// Fake LBS sending results (position) to SPM
       
   174 	INFO_PRINTF1(_L("\tLBS -> RespondLocationRequest"));
       
   175 	TReal64 latitude = 10;
       
   176 	TReal64 longitude = 0;
       
   177 	TReal32 HorAccuracy = 10;
       
   178 	TPositionInfo mobilePosInfo;
       
   179 	TTime utcTime;
       
   180 	utcTime.UniversalTime();
       
   181 	TCoordinate coor(latitude,longitude);
       
   182 	TPosition mobilePos(TLocality(coor,HorAccuracy),utcTime);
       
   183 	mobilePosInfo.SetPosition(mobilePos);
       
   184 	iModule->RespondLocationRequest(iGatewayObserver->SessionIdValue(),KErrNone,mobilePosInfo);
       
   185 	
       
   186 
       
   187 	// Check the Connection Manager receives a request to send a SUPL POS (RRLP Measure Position Response)
       
   188 	if (EFail == CheckNetworkCallbackL(CSuplNetworkTestObserver::ESendSuplPosSendReq))
       
   189 		{
       
   190 		SetTestStepResult(EFail);
       
   191 		return TestStepResult();
       
   192 		}
       
   193 	INFO_PRINTF1(_L("\t\t\t\t\t\t\t\t SUPL POS - RRLP Measure Position Response -> NET"));
       
   194 
       
   195 
       
   196 	// Inject a SUPL END (without position)
       
   197 	INFO_PRINTF1(_L("\t\t\t\t\t\t\t\t SUPL END <- NET"));
       
   198 	CSuplMessageBase* suplEnd = BuildSuplEndL(EFalse);
       
   199 	iNetworkObserver->InjectSuplMessage(iNetworkObserver->SessionId(), suplEnd);
       
   200 	
       
   201 	// Check gateway session completed
       
   202 	if (EFail == CheckGatewayCallbackL(
       
   203 				CSuplGatewayObserver::EProcessSessionComplete))
       
   204 		{
       
   205 		SetTestStepResult(EFail);
       
   206 		return TestStepResult();
       
   207 		}
       
   208 	INFO_PRINTF1(_L("\tLBS <- ProcessSessionComplete"));
       
   209 
       
   210 	// Check Connection Manager receives a disconnection request
       
   211 	if (EFail == CheckNetworkCallbackL(CSuplNetworkTestObserver::EDisconnectReq))
       
   212 		{
       
   213 		SetTestStepResult(EFail);
       
   214 		return TestStepResult();
       
   215 		}
       
   216 	INFO_PRINTF1(_L("\t\t\t\t\t\t\t\t DisconnectRequest -> NET"));
       
   217 
       
   218 	
       
   219 	// Check if more observer activity takes place
       
   220 	if (iGatewayObserver->IsMoreObserverActivity() ||
       
   221 	iNetworkObserver->IsMoreObserverActivity())
       
   222 		{
       
   223 		SetTestStepResult(EFail);
       
   224 		return TestStepResult();
       
   225 		}
       
   226 	INFO_PRINTF1(_L("- END -"));
       
   227 	
       
   228 
       
   229 	// --------------- 1st MTLR complete ----------------------
       
   230 
       
   231 
       
   232 	
       
   233 	INFO_PRINTF1(_L("\t********************************************************************"));
       
   234 	INFO_PRINTF1(_L("\t Second MT-LR starting ...                                          "));
       
   235 	INFO_PRINTF1(_L("\t********************************************************************"));
       
   236 
       
   237 	// Initiate MT-LR
       
   238 	// Generate received SUPL INIT message (test message content #0)
       
   239 	TPtr8 messagePtr2(iReceiveBuffer.Des());
       
   240 	err = iSuplInitGenerator->GenerateSuplInitL(0, messagePtr2);
       
   241 	if (err != KErrNone)
       
   242 		{
       
   243 		SetTestStepResult(EFail);
       
   244 		return TestStepResult();
       
   245 		}
       
   246 
       
   247 	// Inject SUPL INIT using the SUPL Push API
       
   248 	INFO_PRINTF1(_L("\tLBS (SuplPush) -> OnSuplInit()"));
       
   249 	TLbsSuplPushRequestId reqId2 = 32145;
       
   250 	TPtrC8 message2(messagePtr2);
       
   251 	iSuplPush->SuplInit(reqId2, message2, 0);
       
   252 	
       
   253 	// Check Gateway receives a Privacy request and Location Request (no method specified)
       
   254 	INFO_PRINTF1(_L("\tLBS <- ProcessLocationRequest()"));
       
   255 	if (EFail == CheckGatewayCallbackL(CSuplGatewayObserver::EProcessLocationRequest) ||
       
   256 		!iGatewayObserver->IsPrivReqReceived() ||
       
   257 		MLbsNetworkProtocolObserver::EServiceMobileTerminated != iGatewayObserver->LocType() )
       
   258 		{
       
   259 		SetTestStepResult(EFail);
       
   260 		return TestStepResult();
       
   261 		}
       
   262 
       
   263 
       
   264 	// LBS delivers privacy response
       
   265 	INFO_PRINTF1(_L("\tLBS -> PrivacyResponse (EPrivacyResponseAccepted)"));	
       
   266 	CLbsNetworkProtocolBase::TLbsPrivacyResponse privacyResponse2 = CLbsNetworkProtocolBase::EPrivacyResponseAccepted;
       
   267 	iModule->RespondPrivacyRequest(iGatewayObserver->SessionIdValue(), privacyResponse2, 0);
       
   268 	
       
   269 	// Check Connection Manager receives a request for connecting
       
   270 	if (EFail == CheckNetworkCallbackL(CSuplNetworkTestObserver::EConnectReq))
       
   271 		{
       
   272 		SetTestStepResult(EFail);
       
   273 		return TestStepResult();
       
   274 		}
       
   275 	INFO_PRINTF1(_L("\t\t\t\t\t\t\t\t ConnectionRequest -> NET"));
       
   276 
       
   277 	// Simulate the connection is up (inject that event)
       
   278 	INFO_PRINTF1(_L("\t\t\t\t\t\t\t\t Connected <- NET"));
       
   279     iNetworkObserver->InjectConnectedIndication(iNetworkObserver->SessionId());
       
   280     
       
   281     // LBS already has a position due to previous LR.
       
   282 
       
   283   	// LBS returns position to SPM
       
   284   	INFO_PRINTF1(_L("\tLBS -> RespondLocationRequest"));
       
   285   	TReal64 latitude2 = 10;
       
   286   	TReal64 longitude2 = 0;
       
   287   	TReal32 HorAccuracy2 = 10;
       
   288   	TPositionInfo mobilePosInfo2;
       
   289   	TTime utcTime2;
       
   290   	utcTime2.UniversalTime();
       
   291   	TCoordinate coor2(latitude2,longitude2);
       
   292   	TPosition mobilePos2(TLocality(coor2,HorAccuracy2),utcTime2);
       
   293   	mobilePosInfo2.SetPosition(mobilePos2);
       
   294   	iModule->RespondLocationRequest(iGatewayObserver->SessionIdValue(),KErrNone,mobilePosInfo2);
       
   295   	
       
   296   	// Check the Connection Manager receives a request to send a SUPL POS (RRLP Measure Position Response)
       
   297   	if (EFail == CheckNetworkCallbackL(CSuplNetworkTestObserver::ESendSuplPosInitSendReq))
       
   298   		{
       
   299   		SetTestStepResult(EFail);
       
   300   		return TestStepResult();
       
   301   		}
       
   302   	INFO_PRINTF1(_L("\t\t\t\t\t\t\t\t SUPL POS - RRLP Measure Position Response -> NET"));
       
   303 
       
   304   	// Inject a SUPL END (without position)
       
   305   	INFO_PRINTF1(_L("\t\t\t\t\t\t\t\t SUPL END <- NET"));
       
   306   	CSuplMessageBase* suplEnd2 = BuildSuplEndL(EFalse);
       
   307   	iNetworkObserver->InjectSuplMessage(iNetworkObserver->SessionId(), suplEnd2);
       
   308 
       
   309   	// Check gateway session completed
       
   310   	if (EFail == CheckGatewayCallbackL(
       
   311   				CSuplGatewayObserver::EProcessSessionComplete))
       
   312   		{
       
   313   		SetTestStepResult(EFail);
       
   314   		return TestStepResult();
       
   315   		}
       
   316   	INFO_PRINTF1(_L("\tLBS <- ProcessSessionComplete"));
       
   317 
       
   318   	// Check Connection Manager receives a disconnection request
       
   319   	if (EFail == CheckNetworkCallbackL(CSuplNetworkTestObserver::EDisconnectReq))
       
   320   		{
       
   321   		SetTestStepResult(EFail);
       
   322   		return TestStepResult();
       
   323   		}
       
   324   	INFO_PRINTF1(_L("\t\t\t\t\t\t\t\t DisconnectRequest -> NET"));
       
   325   	
       
   326   	
       
   327   	
       
   328 	
       
   329 
       
   330 	// --------------- 2nd MTLR complete ----------------------
       
   331 	
       
   332 	// Check if more observer activity takes place
       
   333 	if (iGatewayObserver->IsMoreObserverActivity() ||
       
   334 	iNetworkObserver->IsMoreObserverActivity())
       
   335 		{
       
   336 		SetTestStepResult(EFail);
       
   337 		return TestStepResult();
       
   338 		}
       
   339 	INFO_PRINTF1(_L("- END -"));
       
   340 	
       
   341 	SetTestStepResult(EPass);
       
   342 	return TestStepResult();
       
   343 	
       
   344 	}
       
   345 
       
   346 
       
   347 /**
       
   348  * @return - TVerdict code
       
   349  * Override of base class virtual
       
   350  */
       
   351 TVerdict Cmtlr25Step::doTestStepPostambleL()
       
   352 	{
       
   353 	delete iModule;
       
   354 
       
   355 	delete iSuplPush;
       
   356 	delete iSuplInitGenerator;
       
   357 
       
   358 	// Call base class method for post test actions	
       
   359 	CTe_suplprotocolSuiteStepBase::doTestStepPostambleL();
       
   360 	return TestStepResult();
       
   361 	}
       
   362 
       
   363 
       
   364 /**
       
   365 Overrides the pure virtual MLbsSuplPushObserver::OnSuplInitComplete.
       
   366 Receives the result of the message sending.
       
   367 	
       
   368 @param aError [In] The error code or KErrNone if successful.
       
   369 
       
   370 @see MTe_LbsSuplSmsTriggerSenderObserver::OnMessageSent
       
   371 @see CTe_LbsSuplSmsTriggerSender::SendMessage
       
   372 */
       
   373 void Cmtlr25Step::OnSuplInitComplete(TLbsSuplPushChannel /*aChannel*/, TLbsSuplPushRequestId /*aReqId*/, TInt aError, TInt /*aReserved*/)
       
   374 	{
       
   375 	iSmsSendError = aError;
       
   376 	if (iSmsSendError != KErrNone)
       
   377 		{
       
   378 		User::Invariant();
       
   379 		}
       
   380 	}
       
   381