networkprotocolmodules/suplprotocolmodule/SuplProtocol/test/src/mtlr20Step.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 mtlr20Step.cpp
       
    20  @internalTechnology
       
    21 */
       
    22 #include "mtlr20Step.h"
       
    23 #include "te_suplprotocolsuitedefs.h"
       
    24 
       
    25 /**
       
    26  Destructor
       
    27  */
       
    28 Cmtlr20Step::~Cmtlr20Step()
       
    29 
       
    30 	{
       
    31 	}
       
    32 
       
    33 /**
       
    34  Constructor
       
    35  */
       
    36 Cmtlr20Step::Cmtlr20Step()
       
    37 	{
       
    38 	SetTestStepName(Kmtlr20Step);
       
    39 	}
       
    40 
       
    41 /**
       
    42  @return - TVerdict code
       
    43  Override of base class virtual
       
    44  */
       
    45 TVerdict Cmtlr20Step::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 Cmtlr20Step 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 Cmtlr20Step::doTestStepL()
       
    69 	{
       
    70 	INFO_PRINTF1(_L("\t********************************************************************"));
       
    71 	INFO_PRINTF1(_L("\tMTLR rejected by user + connection inmediately available)"));
       
    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 = 12345;
       
    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 	// LBS delivers privacy response
       
   102 	INFO_PRINTF1(_L("\tLBS -> PrivacyResponse (EPrivacyResponseRejected)"));	
       
   103 	CLbsNetworkProtocolBase::TLbsPrivacyResponse privacyResponse = CLbsNetworkProtocolBase::EPrivacyResponseRejected;
       
   104 	iModule->RespondPrivacyRequest(iGatewayObserver->SessionIdValue(), privacyResponse, 0);
       
   105 
       
   106 	// LBS delivers a Location Response with KErrAccessDenied after privacy is rejected.
       
   107 	INFO_PRINTF1(_L("\tLBS -> RespondLocationRequest (KErrAccessDenied)"));
       
   108 	TPositionInfo mobilePosInfo;
       
   109 	iModule->RespondLocationRequest(iGatewayObserver->SessionIdValue(), KErrAccessDenied, mobilePosInfo);
       
   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 	// Check the Connection Manager receives a request to send a SUPL END 
       
   124 	if (EFail == CheckNetworkCallbackL(CSuplNetworkTestObserver::ESendSuplEndSendReq))
       
   125 		{
       
   126 		SetTestStepResult(EFail);
       
   127 		return TestStepResult();
       
   128 		}
       
   129 	INFO_PRINTF1(_L("\t\t\t\t\t\t\t\t SUPL END -> NET"));
       
   130 
       
   131 	// Check Connection Manager receives a disconnection request
       
   132 	if (EFail == CheckNetworkCallbackL(CSuplNetworkTestObserver::EDisconnectReq))
       
   133 		{
       
   134 		SetTestStepResult(EFail);
       
   135 		return TestStepResult();
       
   136 		}
       
   137 	INFO_PRINTF1(_L("\t\t\t\t\t\t\t\t DisconnectRequest -> NET"));
       
   138 
       
   139 	// Check if more observer activity takes place
       
   140 	if (iGatewayObserver->IsMoreObserverActivity() ||
       
   141 	iNetworkObserver->IsMoreObserverActivity())
       
   142 	{
       
   143 	SetTestStepResult(EFail);
       
   144 	return TestStepResult();
       
   145 	}
       
   146 	INFO_PRINTF1(_L("- END -"));
       
   147 
       
   148 	
       
   149 	SetTestStepResult(EPass);
       
   150 	return TestStepResult();
       
   151 	
       
   152 }
       
   153 
       
   154 
       
   155 /**
       
   156  * @return - TVerdict code
       
   157  * Override of base class virtual
       
   158  */
       
   159 TVerdict Cmtlr20Step::doTestStepPostambleL()
       
   160 	{
       
   161 	delete iModule;
       
   162 
       
   163 	delete iSuplPush;
       
   164 	delete iSuplInitGenerator;
       
   165 
       
   166 	// Call base class method for post test actions	
       
   167 	CTe_suplprotocolSuiteStepBase::doTestStepPostambleL();
       
   168 	return TestStepResult();
       
   169 	}
       
   170 
       
   171 
       
   172 /**
       
   173 Overrides the pure virtual MTe_LbsSuplSmsTriggerSenderObserver::OnMessageSent.
       
   174 Receives the result of the message sending.
       
   175 	
       
   176 @param aError [In] The error code or KErrNone if successful.
       
   177 
       
   178 @see MTe_LbsSuplSmsTriggerSenderObserver::OnMessageSent
       
   179 @see CTe_LbsSuplSmsTriggerSender::SendMessage
       
   180 */
       
   181 void Cmtlr20Step::OnSuplInitComplete(TLbsSuplPushChannel /*aChannel*/, TLbsSuplPushRequestId /*aReqId*/, TInt aError, TInt /*aReserved*/)
       
   182 	{
       
   183 	iSmsSendError = aError;
       
   184 	if (iSmsSendError != KErrNone)
       
   185 		{
       
   186 		User::Invariant();
       
   187 		}
       
   188 	}
       
   189