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