networkprotocolmodules/suplprotocolmodule/SuplProtocol/test/src/mtlr1Step.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 mtlr1Step.cpp
       
    20  @internalTechnology
       
    21 */
       
    22 #include "mtlr1Step.h"
       
    23 #include "te_suplprotocolsuitedefs.h"
       
    24 #include "lbssystemcontroller.h"
       
    25 
       
    26 /**
       
    27  Destructor
       
    28  */
       
    29 Cmtlr1Step::~Cmtlr1Step()
       
    30 
       
    31 	{
       
    32 	}
       
    33 
       
    34 /**
       
    35  Constructor
       
    36  */
       
    37 Cmtlr1Step::Cmtlr1Step()
       
    38 	{
       
    39 	SetTestStepName(Kmtlr1Step);
       
    40 	}
       
    41 
       
    42 /**
       
    43  @return - TVerdict code
       
    44  Override of base class virtual
       
    45  */
       
    46 TVerdict Cmtlr1Step::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 Cmtlr1Step 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 Cmtlr1Step::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 	
       
   126 	// Check Connection Manager receives a request to send a SUPL POS INIT
       
   127 	// with the assistance data mask requested by the gateway
       
   128 	if (EFail == CheckNetworkCallbackL(CSuplNetworkTestObserver::ESendSuplPosInitSendReq))
       
   129 		{
       
   130 		SetTestStepResult(EFail);
       
   131 		return TestStepResult();
       
   132 		}
       
   133 	INFO_PRINTF1(_L("\t\t\t\t\t\t\t\t SUPL POS INIT -> NET"));
       
   134 
       
   135 	// Inject a SUPL POS with the Assistance data requested
       
   136 	INFO_PRINTF1(_L("\t\t\t\t\t\t\t\t SUPL POS - RRLP Assitance Data <- NET"));
       
   137 	CSuplMessageBase* suplPos = BuildSuplPosAssitDataL(EAssistanceDataAquisitionAssistance|EAssistanceDataBadSatList, EFalse);
       
   138 	iNetworkObserver->InjectSuplMessage(iNetworkObserver->SessionId(), suplPos);	
       
   139 
       
   140 
       
   141 
       
   142 	// Check gateway receives the assistance data types requested.
       
   143 	INFO_PRINTF1(_L("\tLBS <- ProcessAssistanceData()"));
       
   144 	if (EFail == CheckGatewayCallbackL(
       
   145 				CSuplGatewayObserver::EProcessAssistanceData) ||
       
   146 		(dataRequestMask1 & iGatewayObserver->AssistanceDataSetMask() != dataRequestMask1))
       
   147 		{
       
   148 		SetTestStepResult(EFail);
       
   149 		return TestStepResult();
       
   150 		}
       
   151 	
       
   152 
       
   153 	// Check the Connection Manager receives a request to send a SUPL POS (ack to assistance data)
       
   154 	if (EFail == CheckNetworkCallbackL(CSuplNetworkTestObserver::ESendSuplPosSendReq))
       
   155 		{
       
   156 		SetTestStepResult(EFail);
       
   157 		return TestStepResult();
       
   158 		}
       
   159 	INFO_PRINTF1(_L("\t\t\t\t\t\t\t\t SUPL POS - RRLP Assistance Data Ack -> NET"));
       
   160 
       
   161 
       
   162 
       
   163 	// Inject a SUPL POS (RRLP Measure Position Request) - no assistance data
       
   164 	INFO_PRINTF1(_L("\t\t\t\t\t\t\t\t SUPL POS - RRLP Measure Position Request <- NET"));
       
   165 	TLbsAsistanceDataGroup dataRequestMask2 = EAssistanceDataNone;
       
   166 	suplPos = BuildSuplPosRequestL(TPositionModuleInfo::ETechnologyTerminal | TPositionModuleInfo::ETechnologyAssisted, dataRequestMask2);
       
   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 (position) to SPM
       
   182 	INFO_PRINTF1(_L("\tLBS -> RespondLocationRequest"));
       
   183 	TReal64 latitude = 10;
       
   184 	TReal64 longitude = 0;
       
   185 	TReal32 HorAccuracy = 10;
       
   186 	TPositionInfo mobilePosInfo;
       
   187 	TTime utcTime;
       
   188 	utcTime.UniversalTime();
       
   189 	TCoordinate coor(latitude,longitude);
       
   190 	TPosition mobilePos(TLocality(coor,HorAccuracy),utcTime);
       
   191 	mobilePosInfo.SetPosition(mobilePos);
       
   192 	iModule->RespondLocationRequest(iGatewayObserver->SessionIdValue(),KErrNone,mobilePosInfo);
       
   193 	
       
   194 
       
   195 	// Check the Connection Manager receives a request to send a SUPL POS (RRLP Measure Position Response)
       
   196 	if (EFail == CheckNetworkCallbackL(CSuplNetworkTestObserver::ESendSuplPosSendReq))
       
   197 		{
       
   198 		SetTestStepResult(EFail);
       
   199 		return TestStepResult();
       
   200 		}
       
   201 	INFO_PRINTF1(_L("\t\t\t\t\t\t\t\t SUPL POS - RRLP Measure Position Response -> NET"));
       
   202 
       
   203 
       
   204 	// Inject a SUPL END (without position)
       
   205 	INFO_PRINTF1(_L("\t\t\t\t\t\t\t\t SUPL END <- NET"));
       
   206 	CSuplMessageBase* suplEnd = BuildSuplEndL(EFalse);
       
   207 	iNetworkObserver->InjectSuplMessage(iNetworkObserver->SessionId(), suplEnd);
       
   208 	
       
   209 	// Check gateway session completed
       
   210 	if (EFail == CheckGatewayCallbackL(
       
   211 				CSuplGatewayObserver::EProcessSessionComplete))
       
   212 		{
       
   213 		SetTestStepResult(EFail);
       
   214 		return TestStepResult();
       
   215 		}
       
   216 	INFO_PRINTF1(_L("\tLBS <- ProcessSessionComplete"));
       
   217 
       
   218 	// Check Connection Manager receives a disconnection request
       
   219 	if (EFail == CheckNetworkCallbackL(CSuplNetworkTestObserver::EDisconnectReq))
       
   220 		{
       
   221 		SetTestStepResult(EFail);
       
   222 		return TestStepResult();
       
   223 		}
       
   224 	INFO_PRINTF1(_L("\t\t\t\t\t\t\t\t DisconnectRequest -> NET"));
       
   225 	
       
   226 	// Check if more observer activity takes place
       
   227 	if (iGatewayObserver->IsMoreObserverActivity() ||
       
   228 	iNetworkObserver->IsMoreObserverActivity())
       
   229 		{
       
   230 		SetTestStepResult(EFail);
       
   231 		return TestStepResult();
       
   232 		}
       
   233 	INFO_PRINTF1(_L("- END -"));
       
   234 	
       
   235 	SetTestStepResult(EPass);
       
   236 	return TestStepResult();
       
   237 	
       
   238 	}
       
   239 
       
   240 
       
   241 /**
       
   242  * @return - TVerdict code
       
   243  * Override of base class virtual
       
   244  */
       
   245 TVerdict Cmtlr1Step::doTestStepPostambleL()
       
   246 	{
       
   247 	delete iModule;
       
   248 
       
   249 	delete iSuplPush;
       
   250 	delete iSuplInitGenerator;
       
   251 
       
   252 	// Call base class method for post test actions	
       
   253 	CTe_suplprotocolSuiteStepBase::doTestStepPostambleL();
       
   254 	return TestStepResult();
       
   255 	}
       
   256 
       
   257 
       
   258 /**
       
   259 Overrides the pure virtual MLbsSuplPushObserver::OnSuplInitComplete.
       
   260 Receives the result of the message sending.
       
   261 	
       
   262 @param aError [In] The error code or KErrNone if successful.
       
   263 
       
   264 @see MTe_LbsSuplSmsTriggerSenderObserver::OnMessageSent
       
   265 @see CTe_LbsSuplSmsTriggerSender::SendMessage
       
   266 */
       
   267 void Cmtlr1Step::OnSuplInitComplete(TLbsSuplPushChannel /*aChannel*/, TLbsSuplPushRequestId /*aReqId*/, TInt aError, TInt /*aReserved*/)
       
   268 	{
       
   269 	iSmsSendError = aError;
       
   270 	if (iSmsSendError != KErrNone)
       
   271 		{
       
   272 		User::Invariant();
       
   273 		}
       
   274 	}
       
   275