networkprotocolmodules/suplprotocolmodule/SuplProtocol/test/src/mtlr4Step.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 mtlr4Step.cpp
       
    20  @internalTechnology
       
    21 */
       
    22 #include "mtlr4Step.h"
       
    23 #include "te_suplprotocolsuitedefs.h"
       
    24 
       
    25 /**
       
    26  Destructor
       
    27  */
       
    28 Cmtlr4Step::~Cmtlr4Step()
       
    29 
       
    30 	{
       
    31 	}
       
    32 
       
    33 /**
       
    34  Constructor
       
    35  */
       
    36 Cmtlr4Step::Cmtlr4Step()
       
    37 	{
       
    38 	SetTestStepName(Kmtlr4Step);
       
    39 	}
       
    40 
       
    41 /**
       
    42  @return - TVerdict code
       
    43  Override of base class virtual
       
    44  */
       
    45 TVerdict Cmtlr4Step::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 Cmtlr4Step test step.
       
    62 
       
    63 This test verifies that the SUPL Protocol Module correctly handles 
       
    64 an MT-LR Network requested Locate Terminal Based sequence where some of the
       
    65 requested assistance data is included in the rrlp assistance data message and
       
    66 the remainder is included in the Rrlp Measure Position Request.
       
    67 
       
    68 @return TVerdict test result code
       
    69 */
       
    70 TVerdict Cmtlr4Step::doTestStepL()
       
    71 	{
       
    72 	INFO_PRINTF1(_L("\t********************************************************************"));
       
    73 	INFO_PRINTF1(_L("\tMTLR basic procedure with request for additional assistance before MPReq received"));
       
    74 	INFO_PRINTF1(_L("\t********************************************************************"));
       
    75 	INFO_PRINTF1(_L("- START -"));	
       
    76 	
       
    77 	// Initiate MT-LR
       
    78 	// Generate received SUPL INIT message (test message content #0)
       
    79 	TPtr8 messagePtr(iReceiveBuffer.Des());
       
    80 	TInt err = iSuplInitGenerator->GenerateSuplInitL(0, 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 	// Request both sets of assitance data. 
       
   123 	// They'll be delivered in different SUPL POS messages later on in the test.
       
   124 	TLbsAsistanceDataGroup dataRequestMask1 = EAssistanceDataBadSatList;
       
   125 	TLbsAsistanceDataGroup dataRequestMask2 = EAssistanceDataReferenceLocation;
       
   126 	TLbsNetSessionIdArray dummyIdArray;
       
   127 	iModule->RequestAssistanceData(dataRequestMask1, dummyIdArray);
       
   128 	
       
   129 	
       
   130 	// Check Connection Manager receives a request to send a SUPL POS INIT
       
   131 	// with the assistance data mask requested by the gateway
       
   132 	if (EFail == CheckNetworkCallbackL(CSuplNetworkTestObserver::ESendSuplPosInitSendReq))
       
   133 		{
       
   134 		SetTestStepResult(EFail);
       
   135 		return TestStepResult();
       
   136 		}
       
   137 	INFO_PRINTF1(_L("\t\t\t\t\t\t\t\t SUPL POS INIT -> NET"));
       
   138 
       
   139 	// Inject a SUPL POS with some of the Assistance data requested
       
   140 	INFO_PRINTF1(_L("\t\t\t\t\t\t\t\t SUPL POS - RRLP Assitance Data <- NET"));
       
   141 	CSuplMessageBase* suplPos = BuildSuplPosAssitDataL(dataRequestMask1, EFalse);
       
   142 	iNetworkObserver->InjectSuplMessage(iNetworkObserver->SessionId(), suplPos);	
       
   143 
       
   144 
       
   145 
       
   146 	// Check gateway receives the assistance data types requested.
       
   147 	INFO_PRINTF1(_L("\tLBS <- ProcessAssistanceData()"));
       
   148 	if (EFail == CheckGatewayCallbackL(
       
   149 				CSuplGatewayObserver::EProcessAssistanceData) ||
       
   150 		(dataRequestMask1 & iGatewayObserver->AssistanceDataSetMask() != dataRequestMask1))
       
   151 		{
       
   152 		SetTestStepResult(EFail);
       
   153 		return TestStepResult();
       
   154 		}
       
   155 	
       
   156 
       
   157 	// Check the Connection Manager receives a request to send a SUPL POS (ack to assistance data)
       
   158 	if (EFail == CheckNetworkCallbackL(CSuplNetworkTestObserver::ESendSuplPosSendReq))
       
   159 		{
       
   160 		SetTestStepResult(EFail);
       
   161 		return TestStepResult();
       
   162 		}
       
   163 	INFO_PRINTF1(_L("\t\t\t\t\t\t\t\t SUPL POS - RRLP Assistance Data Ack -> NET"));
       
   164 	
       
   165 	// LBS re-requests assistance data
       
   166 	INFO_PRINTF1(_L("\tLBS -> RequestAssistanceData ()"));	
       
   167 	// Request assitance data that was not delivered.
       
   168 	iModule->RequestAssistanceData(dataRequestMask2, dummyIdArray);
       
   169 
       
   170 
       
   171 	// Inject a SUPL POS (RRLP Measure Position Request) - contains remaining assistance data
       
   172 	INFO_PRINTF1(_L("\t\t\t\t\t\t\t\t SUPL POS - RRLP Measure Position Request <- NET"));
       
   173 	suplPos = BuildSuplPosRequestL(TPositionModuleInfo::ETechnologyTerminal | TPositionModuleInfo::ETechnologyAssisted, dataRequestMask2);
       
   174 	iNetworkObserver->InjectSuplMessage(iNetworkObserver->SessionId(), suplPos);	
       
   175 
       
   176 	// Check gateway receives the assistance data types requested.
       
   177 	INFO_PRINTF1(_L("\tLBS <- ProcessAssistanceData()"));
       
   178 	if (EFail == CheckGatewayCallbackL(
       
   179 				CSuplGatewayObserver::EProcessAssistanceData) ||
       
   180 		(dataRequestMask1 & iGatewayObserver->AssistanceDataSetMask() != dataRequestMask2))
       
   181 		{
       
   182 		SetTestStepResult(EFail);
       
   183 		return TestStepResult();
       
   184 		}
       
   185 
       
   186 
       
   187 	// Check gateway receives a location request (due to the RRLP Measure Position Request)
       
   188 	INFO_PRINTF1(_L("\tLBS <- ProcessLocationRequest()"));
       
   189 	if (EFail == CheckGatewayCallbackL(CSuplGatewayObserver::EProcessLocationRequest) ||
       
   190 		MLbsNetworkProtocolObserver::EServiceMobileTerminated != iGatewayObserver->LocType())
       
   191 		{
       
   192 		SetTestStepResult(EFail);
       
   193 		return TestStepResult();
       
   194 		}
       
   195 	
       
   196 
       
   197 	// Fake LBS sending results (position) to SPM
       
   198 	INFO_PRINTF1(_L("\tLBS -> RespondLocationRequest"));
       
   199 	TReal64 latitude = 10;
       
   200 	TReal64 longitude = 0;
       
   201 	TReal32 HorAccuracy = 10;
       
   202 	TPositionInfo mobilePosInfo;
       
   203 	TTime utcTime;
       
   204 	utcTime.UniversalTime();
       
   205 	TCoordinate coor(latitude,longitude);
       
   206 	TPosition mobilePos(TLocality(coor,HorAccuracy),utcTime);
       
   207 	mobilePosInfo.SetPosition(mobilePos);
       
   208 	iModule->RespondLocationRequest(iGatewayObserver->SessionIdValue(),KErrNone,mobilePosInfo);
       
   209 	
       
   210 
       
   211 	// Check the Connection Manager receives a request to send a SUPL POS (RRLP Measure Position Response)
       
   212 	if (EFail == CheckNetworkCallbackL(CSuplNetworkTestObserver::ESendSuplPosSendReq))
       
   213 		{
       
   214 		SetTestStepResult(EFail);
       
   215 		return TestStepResult();
       
   216 		}
       
   217 	INFO_PRINTF1(_L("\t\t\t\t\t\t\t\t SUPL POS - RRLP Measure Position Response -> NET"));
       
   218 
       
   219 
       
   220 	// Inject a SUPL END (without position)
       
   221 	INFO_PRINTF1(_L("\t\t\t\t\t\t\t\t SUPL END <- NET"));
       
   222 	CSuplMessageBase* suplEnd = BuildSuplEndL(EFalse);
       
   223 	iNetworkObserver->InjectSuplMessage(iNetworkObserver->SessionId(), suplEnd);
       
   224 	
       
   225 	// Check gateway session completed
       
   226 	if (EFail == CheckGatewayCallbackL(
       
   227 				CSuplGatewayObserver::EProcessSessionComplete))
       
   228 		{
       
   229 		SetTestStepResult(EFail);
       
   230 		return TestStepResult();
       
   231 		}
       
   232 	INFO_PRINTF1(_L("\tLBS <- ProcessSessionComplete"));
       
   233 
       
   234 	// Check Connection Manager receives a disconnection request
       
   235 	if (EFail == CheckNetworkCallbackL(CSuplNetworkTestObserver::EDisconnectReq))
       
   236 		{
       
   237 		SetTestStepResult(EFail);
       
   238 		return TestStepResult();
       
   239 		}
       
   240 	INFO_PRINTF1(_L("\t\t\t\t\t\t\t\t DisconnectRequest -> NET"));
       
   241 	
       
   242 	// Check if more observer activity takes place
       
   243 	if (iGatewayObserver->IsMoreObserverActivity() ||
       
   244 	iNetworkObserver->IsMoreObserverActivity())
       
   245 		{
       
   246 		SetTestStepResult(EFail);
       
   247 		return TestStepResult();
       
   248 		}
       
   249 	INFO_PRINTF1(_L("- END -"));
       
   250 	
       
   251 	SetTestStepResult(EPass);
       
   252 	return TestStepResult();
       
   253 	
       
   254 	}
       
   255 
       
   256 
       
   257 /**
       
   258  * @return - TVerdict code
       
   259  * Override of base class virtual
       
   260  */
       
   261 TVerdict Cmtlr4Step::doTestStepPostambleL()
       
   262 	{
       
   263 	delete iModule;
       
   264 
       
   265 	delete iSuplPush;
       
   266 	delete iSuplInitGenerator;
       
   267 
       
   268 	// Call base class method for post test actions	
       
   269 	CTe_suplprotocolSuiteStepBase::doTestStepPostambleL();
       
   270 	return TestStepResult();
       
   271 	}
       
   272 
       
   273 
       
   274 /**
       
   275 Overrides the pure virtual MLbsSuplPushObserver::OnSuplInitComplete.
       
   276 Receives the result of the message sending.
       
   277 	
       
   278 @param aError [In] The error code or KErrNone if successful.
       
   279 
       
   280 @see MTe_LbsSuplSmsTriggerSenderObserver::OnMessageSent
       
   281 @see CTe_LbsSuplSmsTriggerSender::SendMessage
       
   282 */
       
   283 void Cmtlr4Step::OnSuplInitComplete(TLbsSuplPushChannel /*aChannel*/, TLbsSuplPushRequestId /*aReqId*/, TInt aError, TInt /*aReserved*/)
       
   284 	{
       
   285 	iSmsSendError = aError;
       
   286 	if (iSmsSendError != KErrNone)
       
   287 		{
       
   288 		User::Invariant();
       
   289 		}
       
   290 	}
       
   291