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