networkprotocolmodules/suplprotocolmodule/SuplProtocol/test/src/molr21Step.cpp
changeset 36 b47902b73a93
parent 0 9cfd9a3ee49c
equal deleted inserted replaced
35:a2efdd544abf 36:b47902b73a93
       
     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 molr21Step.cpp
       
    20  @internalTechnology
       
    21 */
       
    22 #include "molr21Step.h"
       
    23 #include "te_suplprotocolsuitedefs.h"
       
    24 
       
    25 /**
       
    26  Destructor
       
    27  */
       
    28 Cmolr21Step::~Cmolr21Step()
       
    29 
       
    30 	{
       
    31 	}
       
    32 
       
    33 /**
       
    34  Constructor
       
    35  */
       
    36 Cmolr21Step::Cmolr21Step()
       
    37 	{
       
    38 	SetTestStepName(Kmolr21Step);
       
    39 	}
       
    40 
       
    41 /**
       
    42  @return - TVerdict code
       
    43  Override of base class virtual
       
    44  */
       
    45 TVerdict Cmolr21Step::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 	return TestStepResult();
       
    54 	}
       
    55 
       
    56 
       
    57 /** Perform CMoLrStep1 test step.
       
    58 This test verifies that the SUPL Protocol Module correctly handles 
       
    59 an MO-LR Self Locate Terminal Based sequence. Assistance data is
       
    60 partially delivered whith an RRLP assistance data message and then complemented
       
    61 with more assistance data received in an RRLP Measure Position Request.
       
    62 
       
    63 This test also ensures that Reference Location is one of the assistance data
       
    64 types requested by LBS after SUPL RESPONSE. The test verifies that a reference
       
    65 location is delivered to LBS if it is received from the network in the 
       
    66 Reference Location assistance data type.
       
    67 
       
    68 @return TVerdict test result code
       
    69 */
       
    70 TVerdict Cmolr21Step::doTestStepL()
       
    71 	{
       
    72  	
       
    73 	INFO_PRINTF1(_L("\t********************************************************************"));
       
    74 	INFO_PRINTF1(_L("\tMOLR basic procedure - RRLP Assistance Data + RRLP Request/Response"));
       
    75 	INFO_PRINTF1(_L("\t********************************************************************"));
       
    76 	INFO_PRINTF1(_L("- START -"));
       
    77 	// Initiate MO-LR
       
    78 	TLbsNetSessionId sessionId1(TUid::Uid(0x87654321), 0x1111);
       
    79 	TLbsNetPosRequestOptionsAssistance options1;
       
    80 	options1.SetNewClientConnected(ETrue);
       
    81 	TLbsNetPosRequestQuality quality1;
       
    82 	options1.SetRequestQuality(quality1);
       
    83 	TLbsAsistanceDataGroup dataRequestMask1 = EAssistanceDataBadSatList;
       
    84 	TLbsAsistanceDataGroup dataRequestMask2 = EAssistanceDataReferenceLocation;
       
    85 	// Request both sets of assitance data. They'll be delivered in different
       
    86 	// SUPL POS messages later on in the test.
       
    87 	TLbsAsistanceDataGroup dataRequestMask = dataRequestMask1|dataRequestMask2;
       
    88 	options1.SetDataRequestMask(dataRequestMask); 
       
    89 	INFO_PRINTF1(_L("\tLBS -> RequestSelfLocation"));
       
    90 	iModule->RequestSelfLocation(sessionId1, options1);
       
    91 
       
    92 	// Check Connection Manager receives a request for connecting
       
    93 	if (EFail == CheckNetworkCallbackL(CSuplNetworkTestObserver::EConnectReq))
       
    94 		{
       
    95 		SetTestStepResult(EFail);
       
    96 		return TestStepResult();
       
    97 		}
       
    98 	INFO_PRINTF1(_L("\t\t\t\t\t\t\t\t ConnectionRequest -> NET"));
       
    99 
       
   100 
       
   101 	// Simulate the connection is up (inject that event)
       
   102 	INFO_PRINTF1(_L("\t\t\t\t\t\t\t\t Connected <- NET"));
       
   103     iNetworkObserver->InjectConnectedIndication(iNetworkObserver->SessionId());
       
   104 	
       
   105 	// Check Connection Manager receives a request to send a SUPL START
       
   106 	if (EFail == CheckNetworkCallbackL(CSuplNetworkTestObserver::ESuplStartSendReq))
       
   107 	{
       
   108 	SetTestStepResult(EFail);
       
   109 	return TestStepResult();
       
   110 	}
       
   111 	INFO_PRINTF1(_L("\t\t\t\t\t\t\t\t SUPL START -> NET"));
       
   112 	
       
   113 	// Inject a SUPL RESPONSE
       
   114 	INFO_PRINTF1(_L("\t\t\t\t\t\t\t\t SUPL RESPONSE <- NET"));
       
   115 	CSuplMessageBase* resp = BuildSuplResponseL(TPositionModuleInfo::ETechnologyTerminal | TPositionModuleInfo::ETechnologyAssisted);
       
   116 	iNetworkObserver->InjectSuplMessage(iNetworkObserver->SessionId(), resp);
       
   117 	
       
   118 
       
   119 	// Check gateway receives Location Request
       
   120 	INFO_PRINTF1(_L("\tLBS <- ProcessLocationRequest()"));
       
   121 	if (EFail == CheckGatewayCallbackL(
       
   122 				CSuplGatewayObserver::EProcessLocationRequest) ||
       
   123 		MLbsNetworkProtocolObserver::EServiceSelfLocation != iGatewayObserver->LocType())
       
   124 		{
       
   125 		SetTestStepResult(EFail);
       
   126 		return TestStepResult();
       
   127 		}
       
   128 		
       
   129 	// LBS Requests assistance data
       
   130 	INFO_PRINTF1(_L("\tLBS -> RequestAssistanceData ()"));
       
   131 	TLbsNetSessionIdArray dummyIdArray;		
       
   132 	iModule->RequestAssistanceData(dataRequestMask, dummyIdArray);
       
   133 	
       
   134 	// Check Connection Manager receives a request to send a SUPL POS INIT
       
   135 	// with the assistance data mask requested by the gateway
       
   136 	if (EFail == CheckNetworkCallbackL(CSuplNetworkTestObserver::ESendSuplPosInitSendReq))
       
   137 	{
       
   138 	SetTestStepResult(EFail);
       
   139 	return TestStepResult();
       
   140 	}
       
   141 	INFO_PRINTF1(_L("\t\t\t\t\t\t\t\t SUPL POS INIT -> NET"));
       
   142 
       
   143 	// Inject a SUPL POS (RRLP ASSIST DATA) with some of the Assistance data requested
       
   144 	INFO_PRINTF1(_L("\t\t\t\t\t\t\t\t SUPL POS - RRLP Assitance Data <- NET"));
       
   145 	CSuplMessageBase* suplPos = BuildSuplPosAssitDataL(dataRequestMask2, ETrue); // ETrue = more assistance data underway
       
   146 	iNetworkObserver->InjectSuplMessage(iNetworkObserver->SessionId(), suplPos);	
       
   147 
       
   148 	// Check the Connection Manager receives a request to send a SUPL POS (ack to assistance data)
       
   149 	if (EFail == CheckNetworkCallbackL(CSuplNetworkTestObserver::ESendSuplPosSendReq))
       
   150 		{
       
   151 		SetTestStepResult(EFail);
       
   152 		return TestStepResult();
       
   153 		}
       
   154 	INFO_PRINTF1(_L("\t\t\t\t\t\t\t\t SUPL POS - RRLP Assistance Data Ack -> NET"));
       
   155 
       
   156 	// Inject a SUPL POS (RRLP MEASURE POSITION REQUEST) wich carries
       
   157 	// assistance data
       
   158 	INFO_PRINTF1(_L("\t\t\t\t\t\t\t\t SUPL POS - RRLP Measure Position Request <- NET"));
       
   159 	suplPos = BuildSuplPosRequestL(TPositionModuleInfo::ETechnologyTerminal | TPositionModuleInfo::ETechnologyAssisted, dataRequestMask1);
       
   160 	iNetworkObserver->InjectSuplMessage(iNetworkObserver->SessionId(), suplPos);	
       
   161 
       
   162 
       
   163 	// Check gateway receives the assistance data types contained in both SUPL POS messages
       
   164 	// received earlier.
       
   165 	if (EFail == CheckGatewayCallbackL(CSuplGatewayObserver::EProcessAssistanceData) ||
       
   166 		(dataRequestMask & iGatewayObserver->AssistanceDataSetMask() != dataRequestMask) )
       
   167 		{
       
   168 		SetTestStepResult(EFail);
       
   169 		return TestStepResult();
       
   170 		}
       
   171 	
       
   172 	// Ref Loc has been requested. Make sure it's been notified	(the callback mechanism does
       
   173 	// not work well because EProcessAssistanceData overwrites EProcessLocationUpdate as they
       
   174 	// happen in the same RunL of the SUPL Protocol). Instead, a flag has to be checked after
       
   175 	// having received EProcessAssistanceData above
       
   176 	if (!iGatewayObserver->IsRefLocNotified())
       
   177 		{
       
   178 		SetTestStepResult(EFail);
       
   179 		return TestStepResult();			
       
   180 		}
       
   181 	
       
   182 	// Reference Location is reported before Assistance Data...if we got this far,
       
   183 	// both ref loc and assist data have been notified:
       
   184 	INFO_PRINTF1(_L("\tLBS <- ProcessLocationUpdate(Reference Location)"));
       
   185 	INFO_PRINTF1(_L("\tLBS <- ProcessAssistanceData()"));
       
   186 
       
   187 	
       
   188 	// Check gateway receives a location request (due to the RRLP Measure Position Request)
       
   189 	//
       
   190 	INFO_PRINTF1(_L("\tLBS <- ProcessLocationRequest()"));
       
   191 	if (EFail == CheckGatewayCallbackL(
       
   192 				CSuplGatewayObserver::EProcessLocationRequest) ||
       
   193 		MLbsNetworkProtocolObserver::EServiceSelfLocation != iGatewayObserver->LocType())
       
   194 		{
       
   195 		SetTestStepResult(EFail);
       
   196 		return TestStepResult();
       
   197 		}
       
   198 	
       
   199 	// Fake the empty assistance data request normally produced by
       
   200 	// the GPS module after it gets the Location Request above
       
   201 	// (should just be disregarded by the protocol module)
       
   202 	INFO_PRINTF1(_L("\tLBS -> RequestAssistanceData (empty)"));
       
   203 	iModule->RequestAssistanceData(0, dummyIdArray);
       
   204 	
       
   205 	
       
   206 	// Fake LBS sending results (position) to SPM
       
   207 	INFO_PRINTF1(_L("\tLBS -> RespondLocationRequest"));
       
   208 	TReal64 latitude = 10;
       
   209 	TReal64 longitude = 0;
       
   210 	TReal32 HorAccuracy = 10;
       
   211 	TPositionInfo mobilePosInfo;
       
   212 	TTime utcTime;
       
   213 	utcTime.UniversalTime();
       
   214 	TCoordinate coor(latitude,longitude);
       
   215 	TPosition mobilePos(TLocality(coor,HorAccuracy),utcTime);
       
   216 	mobilePosInfo.SetPosition(mobilePos);
       
   217 	iModule->RespondLocationRequest(sessionId1,KErrNone,mobilePosInfo);
       
   218 
       
   219 	
       
   220 	// Check the Connection Manager receives a request to send a SUPL POS (RRLP MEASURE POSITION RESPONSE)
       
   221 	//
       
   222 	if (EFail == CheckNetworkCallbackL(CSuplNetworkTestObserver::ESendSuplPosSendReq))
       
   223 		{
       
   224 		SetTestStepResult(EFail);
       
   225 		return TestStepResult();
       
   226 		}
       
   227 	INFO_PRINTF1(_L("\t\t\t\t\t\t\t\t SUPL POS - RRLP Measure Position Response -> NET"));
       
   228 
       
   229 	// Inject a SUPL END (without position)
       
   230 	INFO_PRINTF1(_L("\t\t\t\t\t\t\t\t SUPL END <- NET"));
       
   231 	CSuplMessageBase* suplEnd = BuildSuplEndL(EFalse); // EFalse means no position
       
   232 	iNetworkObserver->InjectSuplMessage(iNetworkObserver->SessionId(), suplEnd);
       
   233 	
       
   234 	// Check gateway session completed
       
   235 	if (EFail == CheckGatewayCallbackL(
       
   236 				CSuplGatewayObserver::EProcessSessionComplete))
       
   237 		{
       
   238 		SetTestStepResult(EFail);
       
   239 		return TestStepResult();
       
   240 		}
       
   241 	INFO_PRINTF1(_L("\tLBS <- ProcessSessionComplete"));
       
   242 
       
   243 	// Check Connection Manager receives a disconnection request
       
   244 	if (EFail == CheckNetworkCallbackL(CSuplNetworkTestObserver::EDisconnectReq))
       
   245 		{
       
   246 		SetTestStepResult(EFail);
       
   247 		return TestStepResult();
       
   248 		}
       
   249 	INFO_PRINTF1(_L("\t\t\t\t\t\t\t\t DisconnectRequest -> NET"));
       
   250 	
       
   251 	// Check if more observer activity takes place
       
   252 	if (iGatewayObserver->IsMoreObserverActivity() ||
       
   253 	iNetworkObserver->IsMoreObserverActivity())
       
   254 	{
       
   255 	SetTestStepResult(EFail);
       
   256 	return TestStepResult();
       
   257 	}
       
   258 	INFO_PRINTF1(_L("- END -"));
       
   259 	
       
   260 	SetTestStepResult(EPass);
       
   261 	return TestStepResult();	
       
   262 }
       
   263 
       
   264 
       
   265 /**
       
   266  * @return - TVerdict code
       
   267  * Override of base class virtual
       
   268  */
       
   269 TVerdict Cmolr21Step::doTestStepPostambleL()
       
   270 	{
       
   271 	delete iModule;
       
   272 
       
   273 	// Call base class method for post test actions	
       
   274 	CTe_suplprotocolSuiteStepBase::doTestStepPostambleL();
       
   275 	return TestStepResult();
       
   276 	}