networkprotocolmodules/suplprotocolmodule/SuplProtocol/test/src/mtlr24Step.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 mtlr24Step.cpp
       
    20  @internalTechnology
       
    21 */
       
    22 #include "mtlr24Step.h"
       
    23 #include "te_suplprotocolsuitedefs.h"
       
    24 
       
    25 /**
       
    26  Destructor
       
    27  */
       
    28 Cmtlr24Step::~Cmtlr24Step()
       
    29 
       
    30 	{
       
    31 	}
       
    32 
       
    33 /**
       
    34  Constructor
       
    35  */
       
    36 Cmtlr24Step::Cmtlr24Step()
       
    37 	{
       
    38 	SetTestStepName(Kmtlr24Step);
       
    39 	}
       
    40 
       
    41 /**
       
    42  @return - TVerdict code
       
    43  Override of base class virtual
       
    44  */
       
    45 TVerdict Cmtlr24Step::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 Cmtlr24Step test step.
       
    62 This test verifies that the SUPL Protocol Module correctly handles 
       
    63 an MT-LR Network requested Locate Terminal Based sequence (assistance data
       
    64 delivered via an RRLP payload).
       
    65 
       
    66 @return TVerdict test result code
       
    67 */
       
    68 TVerdict Cmtlr24Step::doTestStepL()
       
    69 	{
       
    70 	INFO_PRINTF1(_L("\t********************************************************************"));
       
    71 	INFO_PRINTF1(_L("\tMTLR - LBS sends response before connection is established)"));
       
    72 	INFO_PRINTF1(_L("\t********************************************************************"));
       
    73 	INFO_PRINTF1(_L("- START -"));	
       
    74 	
       
    75 	// Initiate MT-LR
       
    76 	// Generate received SUPL INIT message (test message content #0)
       
    77 	TPtr8 messagePtr(iReceiveBuffer.Des());
       
    78 	TInt err = iSuplInitGenerator->GenerateSuplInitL(0, messagePtr);
       
    79 	if (err != KErrNone)
       
    80 		{
       
    81 		SetTestStepResult(EFail);
       
    82 		return TestStepResult();
       
    83 		}
       
    84 
       
    85 	// Inject SUPL INIT using the SUPL Push API
       
    86 	INFO_PRINTF1(_L("\tLBS (SuplPush) -> OnSuplInit()"));
       
    87 	TLbsSuplPushRequestId reqId = 12445;
       
    88 	TPtrC8 message(messagePtr);
       
    89 	iSuplPush->SuplInit(reqId, message, 0);
       
    90 	
       
    91 	// Check Gateway receives a Privacy request and Location Request
       
    92 	INFO_PRINTF1(_L("\tLBS <- ProcessLocationRequest()"));
       
    93 	if (EFail == CheckGatewayCallbackL(CSuplGatewayObserver::EProcessLocationRequest) ||
       
    94 		!iGatewayObserver->IsPrivReqReceived() ||
       
    95 		MLbsNetworkProtocolObserver::EServiceMobileTerminated != iGatewayObserver->LocType() )
       
    96 		{
       
    97 		SetTestStepResult(EFail);
       
    98 		return TestStepResult();
       
    99 		}
       
   100 	
       
   101 	// Wait a couple of seconds for user instructions
       
   102     INFO_PRINTF1(_L("...user taking a couple of seconds for privacy response"));
       
   103 	if (iGatewayObserver->IsMoreObserverActivity() ||
       
   104 	    iNetworkObserver->IsMoreObserverActivity())
       
   105 	{
       
   106 	SetTestStepResult(EFail);
       
   107 	return TestStepResult();
       
   108 	}
       
   109 
       
   110     // LBS delivers privacy response
       
   111 	INFO_PRINTF1(_L("\tLBS -> PrivacyResponse (EPrivacyResponseAccepted)"));	
       
   112 	CLbsNetworkProtocolBase::TLbsPrivacyResponse privacyResponse = CLbsNetworkProtocolBase::EPrivacyResponseAccepted;
       
   113 	iModule->RespondPrivacyRequest(iGatewayObserver->SessionIdValue(), privacyResponse, 0);
       
   114 
       
   115 	// Check Connection Manager receives a request for connecting
       
   116 	if (EFail == CheckNetworkCallbackL(CSuplNetworkTestObserver::EConnectReq))
       
   117 		{
       
   118 		SetTestStepResult(EFail);
       
   119 		return TestStepResult();
       
   120 		}
       
   121 	INFO_PRINTF1(_L("\t\t\t\t\t\t\t\t ConnectionRequest -> NET"));
       
   122 
       
   123 	// ****************   Location Response is sent by LBS before the connection is up  *****************
       
   124 	// **************************************************************************************************
       
   125 
       
   126 	// Fake LBS sending results (position) to SPM
       
   127 	INFO_PRINTF1(_L("\tLBS -> RespondLocationRequest"));
       
   128 	TReal64 latitude = 10;
       
   129 	TReal64 longitude = 0;
       
   130 	TReal32 HorAccuracy = 10;
       
   131 	TPositionInfo mobilePosInfo;
       
   132 	TTime utcTime;
       
   133 	utcTime.UniversalTime();
       
   134 	TCoordinate coor(latitude,longitude);
       
   135 	TPosition mobilePos(TLocality(coor,HorAccuracy),utcTime);
       
   136 	mobilePosInfo.SetPosition(mobilePos);
       
   137 	iModule->RespondLocationRequest(iGatewayObserver->SessionIdValue(),KErrNone,mobilePosInfo);
       
   138 
       
   139 	// Wait a couple of seconds for connection activation
       
   140     INFO_PRINTF1(_L("...connection taking a couple of seconds to activate"));
       
   141 	if (iGatewayObserver->IsMoreObserverActivity() ||
       
   142 	    iNetworkObserver->IsMoreObserverActivity())
       
   143 	{
       
   144 	SetTestStepResult(EFail);
       
   145 	return TestStepResult();
       
   146 	}
       
   147 
       
   148 	// Simulate the connection is up (inject that event)
       
   149 	INFO_PRINTF1(_L("\t\t\t\t\t\t\t\t Connected <- NET"));
       
   150     iNetworkObserver->InjectConnectedIndication(iNetworkObserver->SessionId());
       
   151 
       
   152 	// Check Connection Manager receives a request to send a SUPL POS INIT
       
   153 	// with the assistance data mask requested by the gateway
       
   154 	if (EFail == CheckNetworkCallbackL(CSuplNetworkTestObserver::ESendSuplPosInitSendReq))
       
   155 	{
       
   156 	SetTestStepResult(EFail);
       
   157 	return TestStepResult();
       
   158 	}
       
   159 	INFO_PRINTF1(_L("\t\t\t\t\t\t\t\t SUPL POS INIT -> NET"));
       
   160 
       
   161 	// Inject a SUPL END (without position)
       
   162 	INFO_PRINTF1(_L("\t\t\t\t\t\t\t\t SUPL END <- NET"));
       
   163 	CSuplMessageBase* suplEnd = BuildSuplEndL(EFalse);
       
   164 	iNetworkObserver->InjectSuplMessage(iNetworkObserver->SessionId(), suplEnd);
       
   165 	
       
   166 	// Check gateway session completed
       
   167 	if (EFail == CheckGatewayCallbackL(
       
   168 				CSuplGatewayObserver::EProcessSessionComplete))
       
   169 		{
       
   170 		SetTestStepResult(EFail);
       
   171 		return TestStepResult();
       
   172 		}
       
   173 	INFO_PRINTF1(_L("\tLBS <- ProcessSessionComplete"));
       
   174 
       
   175 	// Check Connection Manager receives a disconnection request
       
   176 	if (EFail == CheckNetworkCallbackL(CSuplNetworkTestObserver::EDisconnectReq))
       
   177 		{
       
   178 		SetTestStepResult(EFail);
       
   179 		return TestStepResult();
       
   180 		}
       
   181 	INFO_PRINTF1(_L("\t\t\t\t\t\t\t\t DisconnectRequest -> NET"));
       
   182 	
       
   183 	// Check if more observer activity takes place
       
   184 	if (iGatewayObserver->IsMoreObserverActivity() ||
       
   185 	iNetworkObserver->IsMoreObserverActivity())
       
   186 	{
       
   187 	SetTestStepResult(EFail);
       
   188 	return TestStepResult();
       
   189 	}
       
   190 	INFO_PRINTF1(_L("- END -"));
       
   191 	
       
   192 		SetTestStepResult(EPass);
       
   193 	return TestStepResult();
       
   194 	
       
   195 }
       
   196 
       
   197 
       
   198 /**
       
   199  * @return - TVerdict code
       
   200  * Override of base class virtual
       
   201  */
       
   202 TVerdict Cmtlr24Step::doTestStepPostambleL()
       
   203 	{
       
   204 	delete iModule;
       
   205 
       
   206 	delete iSuplPush;
       
   207 	delete iSuplInitGenerator;
       
   208 
       
   209 	// Call base class method for post test actions	
       
   210 	CTe_suplprotocolSuiteStepBase::doTestStepPostambleL();
       
   211 	return TestStepResult();
       
   212 	}
       
   213 
       
   214 
       
   215 /**
       
   216 Overrides the pure virtual MTe_LbsSuplSmsTriggerSenderObserver::OnMessageSent.
       
   217 Receives the result of the message sending.
       
   218 	
       
   219 @param aError [In] The error code or KErrNone if successful.
       
   220 
       
   221 @see MTe_LbsSuplSmsTriggerSenderObserver::OnMessageSent
       
   222 @see CTe_LbsSuplSmsTriggerSender::SendMessage
       
   223 */
       
   224 void Cmtlr24Step::OnSuplInitComplete(TLbsSuplPushChannel /*aChannel*/, TLbsSuplPushRequestId /*aReqId*/, TInt aError, TInt /*aReserved*/)
       
   225 	{
       
   226 	iSmsSendError = aError;
       
   227 	if (iSmsSendError != KErrNone)
       
   228 		{
       
   229 		User::Invariant();
       
   230 		}
       
   231 	}
       
   232