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