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