networkprotocolmodules/suplprotocolmodule/SuplProtocol/test/src/mtlr8Step.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 mtlr8Step.cpp
       
    20  @internalTechnology
       
    21 */
       
    22 #include "mtlr8Step.h"
       
    23 #include "te_suplprotocolsuitedefs.h"
       
    24 
       
    25 /**
       
    26  Destructor
       
    27  */
       
    28 Cmtlr8Step::~Cmtlr8Step()
       
    29 
       
    30 	{
       
    31 	}
       
    32 
       
    33 /**
       
    34  Constructor
       
    35  */
       
    36 Cmtlr8Step::Cmtlr8Step()
       
    37 	{
       
    38 	SetTestStepName(Kmtlr8Step);
       
    39 	}
       
    40 
       
    41 /**
       
    42  @return - TVerdict code
       
    43  Override of base class virtual
       
    44  */
       
    45 TVerdict Cmtlr8Step::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 Cmtlr8Step test step.
       
    62 
       
    63 This test verifies that the SUPL Protocol Module correctly handles 
       
    64 an MT-LR Network requested for which the requested positioning method is
       
    65 eCid.
       
    66 
       
    67 @return TVerdict test result code
       
    68 */
       
    69 TVerdict Cmtlr8Step::doTestStepL()
       
    70 	{
       
    71 	INFO_PRINTF1(_L("\t********************************************************************"));
       
    72 	INFO_PRINTF1(_L("\tMTLR basic procedure followed - eCid positioning"));
       
    73 	INFO_PRINTF1(_L("\t********************************************************************"));
       
    74 	INFO_PRINTF1(_L("- START -"));	
       
    75 	
       
    76 	// Initiate MT-LR
       
    77 	// Generate received SUPL INIT message (test message content #4)
       
    78 	TPtr8 messagePtr(iReceiveBuffer.Des());
       
    79 	TInt err = iSuplInitGenerator->GenerateSuplInitL(4, messagePtr);
       
    80 	if (err != KErrNone)
       
    81 		{
       
    82 		SetTestStepResult(EFail);
       
    83 		return TestStepResult();
       
    84 		}
       
    85 
       
    86 	// Inject SUPL INIT using the SUPL Push API
       
    87 	INFO_PRINTF1(_L("\tLBS (SuplPush) -> OnSuplInit()"));
       
    88 	TLbsSuplPushRequestId reqId = 12345;
       
    89 	TPtrC8 message(messagePtr);
       
    90 	iSuplPush->SuplInit(reqId, message, 0);
       
    91 	
       
    92 	// ************
       
    93 	// should check that the EProcessLocationRequest specifies "no preferred method"
       
    94 	// as a location request for eCID should not be injected into LBS.
       
    95 	// LBS Should kick off a location request in whatever its preferred method is (assume TB)
       
    96 	// ************
       
    97 
       
    98 	// Check Gateway receives a Privacy request and Location Request
       
    99 	INFO_PRINTF1(_L("\tLBS <- ProcessLocationRequest()"));
       
   100 	if (EFail == CheckGatewayCallbackL(CSuplGatewayObserver::EProcessLocationRequest) ||
       
   101 		!iGatewayObserver->IsPrivReqReceived() ||
       
   102 		MLbsNetworkProtocolObserver::EServiceMobileTerminated != iGatewayObserver->LocType() )
       
   103 		{
       
   104 		SetTestStepResult(EFail);
       
   105 		return TestStepResult();
       
   106 		}
       
   107 
       
   108 	// LBS delivers privacy response
       
   109 	INFO_PRINTF1(_L("\tLBS -> RespondPrivacyRequest ()"));	
       
   110 	CLbsNetworkProtocolBase::TLbsPrivacyResponse privacyResponse = CLbsNetworkProtocolBase::EPrivacyResponseAccepted;
       
   111 	iModule->RespondPrivacyRequest(iGatewayObserver->SessionIdValue(), privacyResponse, 0);
       
   112 	
       
   113 	// Check Connection Manager receives a request for connecting
       
   114 	if (EFail == CheckNetworkCallbackL(CSuplNetworkTestObserver::EConnectReq))
       
   115 		{
       
   116 		SetTestStepResult(EFail);
       
   117 		return TestStepResult();
       
   118 		}
       
   119 	INFO_PRINTF1(_L("\t\t\t\t\t\t\t\t ConnectionRequest -> NET"));
       
   120 
       
   121 	// Simulate the connection is up (inject that event)
       
   122 	INFO_PRINTF1(_L("\t\t\t\t\t\t\t\t Connected <- NET"));
       
   123     iNetworkObserver->InjectConnectedIndication(iNetworkObserver->SessionId());
       
   124     
       
   125 	// LBS Requests assistance data
       
   126 	INFO_PRINTF1(_L("\tLBS -> RequestAssistanceData ()"));	
       
   127 	TLbsAsistanceDataGroup dataRequestMask1 = EAssistanceDataBadSatList;
       
   128 	TLbsNetSessionIdArray dummyIdArray;	
       
   129 	iModule->RequestAssistanceData(dataRequestMask1, dummyIdArray);
       
   130 	
       
   131 	// Check Connection Manager receives a request to send a SUPL POS INIT
       
   132 	// with the assistance data mask requested by the gateway
       
   133 	if (EFail == CheckNetworkCallbackL(CSuplNetworkTestObserver::ESendSuplPosInitSendReq))
       
   134 		{
       
   135 		SetTestStepResult(EFail);
       
   136 		return TestStepResult();
       
   137 		}
       
   138 	INFO_PRINTF1(_L("\t\t\t\t\t\t\t\t SUPL POS INIT -> NET"));
       
   139 
       
   140 	// ************
       
   141 	// Test assumes that SLP is happy with the information received in the POS INIT
       
   142 	// namely the Cell ID information. Therefore it terminates the SUPL negotiation.
       
   143 	// ************
       
   144 
       
   145 
       
   146 	// Inject a SUPL END (without position)
       
   147 	INFO_PRINTF1(_L("\t\t\t\t\t\t\t\t SUPL END <- NET"));
       
   148 	CSuplMessageBase* suplEnd = BuildSuplEndL(EFalse);
       
   149 	iNetworkObserver->InjectSuplMessage(iNetworkObserver->SessionId(), suplEnd);
       
   150 	
       
   151 	// Check gateway session completed
       
   152 	if (EFail == CheckGatewayCallbackL(
       
   153 				CSuplGatewayObserver::EProcessSessionComplete))
       
   154 		{
       
   155 		SetTestStepResult(EFail);
       
   156 		return TestStepResult();
       
   157 		}
       
   158 	INFO_PRINTF1(_L("\tLBS <- ProcessSessionComplete"));
       
   159 
       
   160 	// Check Connection Manager receives a disconnection request
       
   161 	if (EFail == CheckNetworkCallbackL(CSuplNetworkTestObserver::EDisconnectReq))
       
   162 		{
       
   163 		SetTestStepResult(EFail);
       
   164 		return TestStepResult();
       
   165 		}
       
   166 	INFO_PRINTF1(_L("\t\t\t\t\t\t\t\t DisconnectRequest -> NET"));
       
   167 	
       
   168 	// Check if more observer activity takes place
       
   169 	if (iGatewayObserver->IsMoreObserverActivity() ||
       
   170 	iNetworkObserver->IsMoreObserverActivity())
       
   171 		{
       
   172 		SetTestStepResult(EFail);
       
   173 		return TestStepResult();
       
   174 		}
       
   175 	INFO_PRINTF1(_L("- END -"));
       
   176 	
       
   177 	SetTestStepResult(EPass);
       
   178 	return TestStepResult();
       
   179 	
       
   180 	}
       
   181 
       
   182 
       
   183 /**
       
   184  * @return - TVerdict code
       
   185  * Override of base class virtual
       
   186  */
       
   187 TVerdict Cmtlr8Step::doTestStepPostambleL()
       
   188 	{
       
   189 	delete iModule;
       
   190 
       
   191 	delete iSuplPush;
       
   192 	delete iSuplInitGenerator;
       
   193 
       
   194 	// Call base class method for post test actions	
       
   195 	CTe_suplprotocolSuiteStepBase::doTestStepPostambleL();
       
   196 	return TestStepResult();
       
   197 	}
       
   198 
       
   199 
       
   200 /**
       
   201 Overrides the pure virtual MLbsSuplPushObserver::OnSuplInitComplete.
       
   202 Receives the result of the message sending.
       
   203 	
       
   204 @param aError [In] The error code or KErrNone if successful.
       
   205 
       
   206 @see MTe_LbsSuplSmsTriggerSenderObserver::OnMessageSent
       
   207 @see CTe_LbsSuplSmsTriggerSender::SendMessage
       
   208 */
       
   209 void Cmtlr8Step::OnSuplInitComplete(TLbsSuplPushChannel /*aChannel*/, TLbsSuplPushRequestId /*aReqId*/, TInt aError, TInt /*aReserved*/)
       
   210 	{
       
   211 	iSmsSendError = aError;
       
   212 	if (iSmsSendError != KErrNone)
       
   213 		{
       
   214 		User::Invariant();
       
   215 		}
       
   216 	}
       
   217