networkprotocolmodules/suplprotocolmodule/SuplProtocol/test/src/mtlr17Step.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 mtlr17Step.cpp
       
    20  @internalTechnology
       
    21 */
       
    22 #include "mtlr17Step.h"
       
    23 #include "te_suplprotocolsuitedefs.h"
       
    24 
       
    25 /**
       
    26  Destructor
       
    27  */
       
    28 Cmtlr17Step::~Cmtlr17Step()
       
    29 
       
    30 	{
       
    31 	}
       
    32 
       
    33 /**
       
    34  Constructor
       
    35  */
       
    36 Cmtlr17Step::Cmtlr17Step()
       
    37 	{
       
    38 	SetTestStepName(Kmtlr17Step);
       
    39 	}
       
    40 
       
    41 /**
       
    42  @return - TVerdict code
       
    43  Override of base class virtual
       
    44  */
       
    45 TVerdict Cmtlr17Step::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 Cmtlr17Step test step.
       
    62 
       
    63 MT-LR - cancel after Privacy Response accepted and connection set up,
       
    64 but before Assistance data requested.
       
    65 
       
    66 Protocol Module should connect and send SUPL END with error code 
       
    67 indicating user denied request
       
    68 
       
    69 @return TVerdict test result code
       
    70 */
       
    71 TVerdict Cmtlr17Step::doTestStepL()
       
    72 	{
       
    73 	INFO_PRINTF1(_L("\t********************************************************************"));
       
    74 	INFO_PRINTF1(_L("\tMTLR - Cancel after Privacy Response (accept) received / before assistance data response"));
       
    75 	INFO_PRINTF1(_L("\t********************************************************************"));
       
    76 	INFO_PRINTF1(_L("- START -"));	
       
    77 	
       
    78 	// Initiate MT-LR
       
    79 	// Generate received SUPL INIT message (test message content #0)
       
    80 	TPtr8 messagePtr(iReceiveBuffer.Des());
       
    81 	TInt err = iSuplInitGenerator->GenerateSuplInitL(0, messagePtr);
       
    82 	if (err != KErrNone)
       
    83 		{
       
    84 		SetTestStepResult(EFail);
       
    85 		return TestStepResult();
       
    86 		}
       
    87 
       
    88 	// Inject SUPL INIT using the SUPL Push API
       
    89 	INFO_PRINTF1(_L("\tLBS (SuplPush) -> OnSuplInit()"));
       
    90 	TLbsSuplPushRequestId reqId = 12345;
       
    91 	TPtrC8 message(messagePtr);
       
    92 	iSuplPush->SuplInit(reqId, message, 0);
       
    93 	
       
    94 	// Check Gateway receives a Privacy request and Location Request (no method specified)
       
    95 	INFO_PRINTF1(_L("\tLBS <- ProcessLocationRequest()"));
       
    96 	if (EFail == CheckGatewayCallbackL(CSuplGatewayObserver::EProcessLocationRequest) ||
       
    97 		!iGatewayObserver->IsPrivReqReceived() ||
       
    98 		MLbsNetworkProtocolObserver::EServiceMobileTerminated != iGatewayObserver->LocType() )
       
    99 		{
       
   100 		SetTestStepResult(EFail);
       
   101 		return TestStepResult();
       
   102 		}
       
   103 
       
   104 	// LBS delivers privacy response
       
   105 	INFO_PRINTF1(_L("\tLBS -> PrivacyResponse (EPrivacyResponseAccepted)"));	
       
   106 	CLbsNetworkProtocolBase::TLbsPrivacyResponse privacyResponse = CLbsNetworkProtocolBase::EPrivacyResponseAccepted;
       
   107 	iModule->RespondPrivacyRequest(iGatewayObserver->SessionIdValue(), privacyResponse, 0);
       
   108 	
       
   109 	// Check Connection Manager receives a request for connecting
       
   110 	if (EFail == CheckNetworkCallbackL(CSuplNetworkTestObserver::EConnectReq))
       
   111 		{
       
   112 		SetTestStepResult(EFail);
       
   113 		return TestStepResult();
       
   114 		}
       
   115 	INFO_PRINTF1(_L("\t\t\t\t\t\t\t\t ConnectionRequest -> NET"));
       
   116 
       
   117 	// Simulate the connection is up (inject that event)
       
   118 	INFO_PRINTF1(_L("\t\t\t\t\t\t\t\t Connected <- NET"));
       
   119     iNetworkObserver->InjectConnectedIndication(iNetworkObserver->SessionId());
       
   120     
       
   121     // Inject a RespondLocationRequest() with aReason == KErrCancel
       
   122 	INFO_PRINTF1(_L("\tLBS -> RespondLocationRequest (KErrCancel)"));
       
   123 	TPositionInfo mobilePosInfo;
       
   124 	iModule->RespondLocationRequest(iGatewayObserver->SessionIdValue(), KErrCancel, mobilePosInfo);
       
   125 	
       
   126 	// Check the Connection Manager receives a request to send a SUPL END 
       
   127 	if (EFail == CheckNetworkCallbackL(CSuplNetworkTestObserver::ESendSuplEndSendReq))
       
   128 		{
       
   129 		SetTestStepResult(EFail);
       
   130 		return TestStepResult();
       
   131 		}
       
   132 	INFO_PRINTF1(_L("\t\t\t\t\t\t\t\t SUPL END -> NET"));
       
   133 
       
   134 	// Check gateway session completes
       
   135 	if (EFail == CheckGatewayCallbackL(
       
   136 				CSuplGatewayObserver::EProcessSessionComplete))
       
   137 		{
       
   138 		SetTestStepResult(EFail);
       
   139 		return TestStepResult();
       
   140 		}
       
   141 	INFO_PRINTF1(_L("\tLBS <- ProcessSessionComplete"));
       
   142 
       
   143 	// Check Connection Manager receives a disconnection request
       
   144 	if (EFail == CheckNetworkCallbackL(CSuplNetworkTestObserver::EDisconnectReq))
       
   145 		{
       
   146 		SetTestStepResult(EFail);
       
   147 		return TestStepResult();
       
   148 		}
       
   149 	INFO_PRINTF1(_L("\t\t\t\t\t\t\t\t DisconnectRequest -> NET"));
       
   150 
       
   151 	// Check if more observer activity takes place
       
   152 	if (iGatewayObserver->IsMoreObserverActivity() ||
       
   153 	iNetworkObserver->IsMoreObserverActivity())
       
   154 	{
       
   155 	SetTestStepResult(EFail);
       
   156 	return TestStepResult();
       
   157 	}
       
   158 	INFO_PRINTF1(_L("- END -"));
       
   159 	
       
   160 	SetTestStepResult(EPass);
       
   161 	return TestStepResult();
       
   162 	}
       
   163 
       
   164 
       
   165 /**
       
   166  * @return - TVerdict code
       
   167  * Override of base class virtual
       
   168  */
       
   169 TVerdict Cmtlr17Step::doTestStepPostambleL()
       
   170 	{
       
   171 	delete iModule;
       
   172 
       
   173 	delete iSuplPush;
       
   174 	delete iSuplInitGenerator;
       
   175 
       
   176 	// Call base class method for post test actions	
       
   177 	CTe_suplprotocolSuiteStepBase::doTestStepPostambleL();
       
   178 	return TestStepResult();
       
   179 	}
       
   180 
       
   181 
       
   182 /**
       
   183 Overrides the pure virtual MLbsSuplPushObserver::OnSuplInitComplete.
       
   184 Receives the result of the message sending.
       
   185 	
       
   186 @param aError [In] The error code or KErrNone if successful.
       
   187 
       
   188 @see MTe_LbsSuplSmsTriggerSenderObserver::OnMessageSent
       
   189 @see CTe_LbsSuplSmsTriggerSender::SendMessage
       
   190 */
       
   191 void Cmtlr17Step::OnSuplInitComplete(TLbsSuplPushChannel /*aChannel*/, TLbsSuplPushRequestId /*aReqId*/, TInt aError, TInt /*aReserved*/)
       
   192 	{
       
   193 	iSmsSendError = aError;
       
   194 	if (iSmsSendError != KErrNone)
       
   195 		{
       
   196 		User::Invariant();
       
   197 		}
       
   198 	}
       
   199