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