networkprotocolmodules/suplprotocolmodule/SuplProtocol/test/src/mtlr19Step.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 mtlr19Step.cpp
       
    20  @internalTechnology
       
    21 */
       
    22 #include "mtlr19Step.h"
       
    23 #include "te_suplprotocolsuitedefs.h"
       
    24 
       
    25 /**
       
    26  Destructor
       
    27  */
       
    28 Cmtlr19Step::~Cmtlr19Step()
       
    29 
       
    30 	{
       
    31 	}
       
    32 
       
    33 /**
       
    34  Constructor
       
    35  */
       
    36 Cmtlr19Step::Cmtlr19Step()
       
    37 	{
       
    38 	SetTestStepName(Kmtlr19Step);
       
    39 	}
       
    40 
       
    41 /**
       
    42  @return - TVerdict code
       
    43  Override of base class virtual
       
    44  */
       
    45 TVerdict Cmtlr19Step::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 Cmtlr19Step test step.
       
    62 
       
    63 MT-LR - cancel after Privacy Response accepted, connection is set up and 
       
    64 SUPL POS INIT sent, but before first SUPL POS message is received.
       
    65 
       
    66 Protocol Module should immediately send SUPL END with error code 
       
    67 indicating user has cancelled request.
       
    68 
       
    69 @return TVerdict test result code
       
    70 */
       
    71 TVerdict Cmtlr19Step::doTestStepL()
       
    72 	{
       
    73 	INFO_PRINTF1(_L("\t********************************************************************"));
       
    74 	INFO_PRINTF1(_L("\tMTLR - Cancel after POS INIT sent / before 1st POS Message received."));
       
    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 	// LBS Requests assistance data
       
   122 	INFO_PRINTF1(_L("\tLBS -> RequestAssistanceData ()"));	
       
   123 	TLbsAsistanceDataGroup dataRequestMask1 = EAssistanceDataBadSatList;
       
   124 	TLbsNetSessionIdArray dummyIdArray;	
       
   125 	iModule->RequestAssistanceData(dataRequestMask1, dummyIdArray);
       
   126 	
       
   127 	
       
   128 	// Check Connection Manager receives a request to send a SUPL POS INIT
       
   129 	// with the assistance data mask requested by the gateway
       
   130 	if (EFail == CheckNetworkCallbackL(CSuplNetworkTestObserver::ESendSuplPosInitSendReq))
       
   131 		{
       
   132 		SetTestStepResult(EFail);
       
   133 		return TestStepResult();
       
   134 		}
       
   135 	INFO_PRINTF1(_L("\t\t\t\t\t\t\t\t SUPL POS INIT -> NET"));
       
   136 	
       
   137 	
       
   138 	// USER CANCELS...
       
   139 	// Inject a RespondLocationRequest() with aReason == KErrCancel
       
   140 	INFO_PRINTF1(_L("\tLBS -> RespondLocationRequest (KErrCancel)"));
       
   141 	TPositionInfo mobilePosInfo;
       
   142 	iModule->RespondLocationRequest(iGatewayObserver->SessionIdValue(), KErrCancel, mobilePosInfo);
       
   143 	
       
   144 	// Check the Connection Manager receives a request to send a SUPL END 
       
   145 	if (EFail == CheckNetworkCallbackL(CSuplNetworkTestObserver::ESendSuplEndSendReq))
       
   146 		{
       
   147 		SetTestStepResult(EFail);
       
   148 		return TestStepResult();
       
   149 		}
       
   150 	INFO_PRINTF1(_L("\t\t\t\t\t\t\t\t SUPL END -> NET"));
       
   151 
       
   152 	// Check Connection Manager receives a disconnection request
       
   153 	if (EFail == CheckNetworkCallbackL(CSuplNetworkTestObserver::EDisconnectReq))
       
   154 		{
       
   155 		SetTestStepResult(EFail);
       
   156 		return TestStepResult();
       
   157 		}
       
   158 	INFO_PRINTF1(_L("\t\t\t\t\t\t\t\t DisconnectRequest -> NET"));
       
   159 
       
   160 	// Check if more observer activity takes place
       
   161 	if (iGatewayObserver->IsMoreObserverActivity() ||
       
   162 	iNetworkObserver->IsMoreObserverActivity())
       
   163 	{
       
   164 	SetTestStepResult(EFail);
       
   165 	return TestStepResult();
       
   166 	}
       
   167 	INFO_PRINTF1(_L("- END -"));
       
   168 	
       
   169 	SetTestStepResult(EPass);
       
   170 	return TestStepResult();
       
   171 	}
       
   172 
       
   173 
       
   174 /**
       
   175  * @return - TVerdict code
       
   176  * Override of base class virtual
       
   177  */
       
   178 TVerdict Cmtlr19Step::doTestStepPostambleL()
       
   179 	{
       
   180 	delete iModule;
       
   181 
       
   182 	delete iSuplPush;
       
   183 	delete iSuplInitGenerator;
       
   184 
       
   185 	// Call base class method for post test actions	
       
   186 	CTe_suplprotocolSuiteStepBase::doTestStepPostambleL();
       
   187 	return TestStepResult();
       
   188 	}
       
   189 
       
   190 
       
   191 /**
       
   192 Overrides the pure virtual MLbsSuplPushObserver::OnSuplInitComplete.
       
   193 Receives the result of the message sending.
       
   194 	
       
   195 @param aError [In] The error code or KErrNone if successful.
       
   196 
       
   197 @see MTe_LbsSuplSmsTriggerSenderObserver::OnMessageSent
       
   198 @see CTe_LbsSuplSmsTriggerSender::SendMessage
       
   199 */
       
   200 void Cmtlr19Step::OnSuplInitComplete(TLbsSuplPushChannel /*aChannel*/, TLbsSuplPushRequestId /*aReqId*/, TInt aError, TInt /*aReserved*/)
       
   201 	{
       
   202 	iSmsSendError = aError;
       
   203 	if (iSmsSendError != KErrNone)
       
   204 		{
       
   205 		User::Invariant();
       
   206 		}
       
   207 	}
       
   208