|
1 // Copyright (c) 2007-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 // LBS includes. |
|
15 // |
|
16 // |
|
17 |
|
18 #include <lbs/test/lbsnetextendedprotocolproxy.h> |
|
19 #include <lbs/lbsnetprotocolbase.h> |
|
20 #include <lbs/lbsassistancedatabuilderset.h> |
|
21 // LBS test includes. |
|
22 #include "ctlbsextptbmtlrcancel.h" |
|
23 #include <lbs/test/tlbsutils.h> |
|
24 #include "argutils.h" |
|
25 #include <lbs/test/activeyield.h> |
|
26 /** |
|
27 Static Constructor |
|
28 */ |
|
29 CT_LbsExtPtbMTLRCancel* CT_LbsExtPtbMTLRCancel::New(CT_LbsExtendedMTLRServer& aParent) |
|
30 { |
|
31 // Note that we do not use ELeave. |
|
32 // This means that having insufficient memory will return NULL; |
|
33 CT_LbsExtPtbMTLRCancel* testStep = new CT_LbsExtPtbMTLRCancel(aParent); |
|
34 if (testStep) |
|
35 { |
|
36 TInt err = KErrNone; |
|
37 |
|
38 TRAP(err, testStep->ConstructL()); |
|
39 if (err) |
|
40 { |
|
41 delete testStep; |
|
42 testStep = NULL; |
|
43 } |
|
44 } |
|
45 return testStep; |
|
46 } |
|
47 |
|
48 |
|
49 /** |
|
50 * Constructor |
|
51 */ |
|
52 CT_LbsExtPtbMTLRCancel::CT_LbsExtPtbMTLRCancel(CT_LbsExtendedMTLRServer& aParent) : CT_LbsExtendedMTLRStep(aParent) |
|
53 { |
|
54 SetTestStepName(KLbsExtPtbMtlrCancel); |
|
55 iState = EInitializing; |
|
56 iSessionId.SetSessionOwner(KRequestUid); |
|
57 iSessionId.SetSessionNum(0x0005); |
|
58 } |
|
59 |
|
60 |
|
61 void CT_LbsExtPtbMTLRCancel::ConstructL() |
|
62 { |
|
63 // Create the base class objects. |
|
64 CT_LbsExtendedMTLRStep::ConstructL(); |
|
65 iController = CLbsPrivacyController::NewL(*this); |
|
66 iProxy = CNetProtocolProxy::NewL(); |
|
67 } |
|
68 |
|
69 |
|
70 /** |
|
71 * Destructor |
|
72 */ |
|
73 CT_LbsExtPtbMTLRCancel::~CT_LbsExtPtbMTLRCancel() |
|
74 { |
|
75 delete iController; |
|
76 delete iProxy; |
|
77 } |
|
78 |
|
79 |
|
80 TVerdict CT_LbsExtPtbMTLRCancel::doTestStepL() |
|
81 { |
|
82 INFO_PRINTF1(_L("CT_LbsPTBMTLRCancel::doTestStepL()")); |
|
83 // Stop the test if the preamble failed |
|
84 TESTL(TestStepResult() == EPass); |
|
85 |
|
86 const TInt KTimeOut = 60*1000*1000; |
|
87 const TInt KAdviceSystemStatusTimeout = 40*1000*1000; |
|
88 const TInt KSmallTimeOut = 3*1000*1000; |
|
89 |
|
90 // reset integration modules count of number of cancels recieved from LBS |
|
91 T_LbsUtils utils; |
|
92 utils.ResetIntegrationModulesCountOfCancelsL(); |
|
93 |
|
94 // >> AdviceSystemStatus(0) |
|
95 TESTL(iProxy->WaitForResponse(KAdviceSystemStatusTimeout) == ENetMsgGetCurrentCapabilitiesResponse); |
|
96 CLbsNetworkProtocolBase::TLbsSystemStatus status; |
|
97 TInt cleanupCnt; |
|
98 cleanupCnt = iProxy->GetArgsLC(ENetMsgGetCurrentCapabilitiesResponse, &status); |
|
99 TESTL(status == CLbsNetworkProtocolBase::ESystemStatusNone); |
|
100 CleanupStack::PopAndDestroy(cleanupCnt); |
|
101 |
|
102 // Initiate MTLR Start |
|
103 // << ProcessStatusUpdate() |
|
104 MLbsNetworkProtocolObserver::TLbsNetProtocolServiceMask activeServiceMask = MLbsNetworkProtocolObserver::EServiceMobileTerminated; |
|
105 iProxy->CallL(ENetMsgProcessStatusUpdate, &activeServiceMask); |
|
106 |
|
107 // << ProcessPrivacyRequest() |
|
108 const TBool emergency = EFalse; |
|
109 TLbsNetPosRequestPrivacy privacy = ArgUtils::Privacy(); |
|
110 TLbsExternalRequestInfo requestInfo = ArgUtils::RequestInfo(); |
|
111 iProxy->CallL(ENetMsgProcessPrivacyRequest, &iSessionId, &emergency, &privacy, &requestInfo); |
|
112 |
|
113 // >> Callback from RespondNetworkLocationRequest(ERequestAccepted) |
|
114 CheckForObserverEventTestsL(KTimeOut, *this); |
|
115 |
|
116 // >> Respond Privacy Request |
|
117 TESTL(iProxy->WaitForResponse(KTimeOut) == ENetMsgRespondPrivacyRequest); |
|
118 TLbsNetSessionId* getSessionId = NULL; |
|
119 CLbsNetworkProtocolBase::TLbsPrivacyResponse getPrivacy; |
|
120 cleanupCnt = iProxy->GetArgsLC(ENetMsgRespondPrivacyRequest, &getSessionId, &getPrivacy); |
|
121 TESTL(getSessionId->SessionNum()==iSessionId.SessionNum()); |
|
122 TESTL(getPrivacy==CLbsNetworkProtocolBase::EPrivacyResponseAccepted); |
|
123 CleanupStack::PopAndDestroy(cleanupCnt);//getSessionId |
|
124 // Initiate MTLR End |
|
125 |
|
126 // MTLR Reference Position Notification Start |
|
127 // << ProcessLocationUpdate() |
|
128 TPositionInfo positionInfo = ArgUtils::ReferencePositionInfo(); |
|
129 iProxy->CallL(ENetMsgProcessLocationUpdate, &iSessionId, &positionInfo); |
|
130 // MTLR Reference Position Notification Stop |
|
131 |
|
132 // MTLR Assistance Data Notification Start |
|
133 // << ProcessAssistanceData() |
|
134 TLbsAsistanceDataGroup dataRequestMask = EAssistanceDataReferenceTime; |
|
135 RLbsAssistanceDataBuilderSet assistanceData; |
|
136 ArgUtils::PopulateLC(assistanceData); |
|
137 TInt reason = KErrNone; |
|
138 iProxy->CallL(ENetMsgProcessAssistanceData, &dataRequestMask, &assistanceData, &reason); |
|
139 CleanupStack::PopAndDestroy(); //assistanceData |
|
140 // MTLR Assistance Data Notification Stop |
|
141 |
|
142 // MTLR Network Location Request Start |
|
143 // << ProcessLocationRequest() |
|
144 MLbsNetworkProtocolObserver::TLbsNetProtocolService service = MLbsNetworkProtocolObserver::EServiceMobileTerminated; |
|
145 TLbsNetPosRequestQuality quality = ArgUtils::QualityAlpha2(); |
|
146 TLbsNetPosRequestMethod method = ArgUtils::RequestTerminalBasedMethod(); |
|
147 iProxy->CallL(ENetMsgProcessLocationRequest, &iSessionId, &emergency, &service, &quality, &method); |
|
148 // MTLR Network Location Request Stop |
|
149 |
|
150 // >> Callback from ProcessNetworkPostionUpdate(refPosition) |
|
151 CheckForObserverEventTestsL(KSmallTimeOut, *this); |
|
152 |
|
153 // >> RequestAssistanceData(0) |
|
154 TESTL(iProxy->WaitForResponse(KSmallTimeOut) == ENetMsgRequestAssistanceData); |
|
155 TLbsAsistanceDataGroup dataGroup; |
|
156 cleanupCnt = iProxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataGroup); |
|
157 TESTL(dataGroup == EAssistanceDataNone); |
|
158 CleanupStack::PopAndDestroy(cleanupCnt); |
|
159 |
|
160 // this tests the case when we cancel AFTER we have injected a location request |
|
161 InitiateCancelMTLR(iSessionId.SessionNum()); |
|
162 |
|
163 // for this test the protocol module is the extended module and therefore the CancelExternalLocation is expected ... |
|
164 // >> CancelExternalLocation() |
|
165 TInt response = iProxy->WaitForResponse(KSmallTimeOut); |
|
166 TESTL(response == ENetMsgCancelExternalLocation); |
|
167 |
|
168 TInt getReason = KErrGeneral; |
|
169 getSessionId = NULL; |
|
170 cleanupCnt = iProxy->GetArgsLC(ENetMsgCancelExternalLocation, &getSessionId, &getReason); |
|
171 TESTL(getSessionId->SessionNum() == iSessionId.SessionNum()); |
|
172 TESTL(getReason==KErrCancel); |
|
173 CleanupStack::PopAndDestroy(cleanupCnt); |
|
174 |
|
175 // >> RespondLocationRequest() |
|
176 |
|
177 response = iProxy->WaitForResponse(KSmallTimeOut); |
|
178 TESTL(response == ENetMsgRespondLocationRequest); |
|
179 |
|
180 getSessionId = NULL; |
|
181 getReason = KErrCancel; |
|
182 TPositionSatelliteInfo* getPositionInfo = NULL; |
|
183 cleanupCnt = iProxy->GetArgsLC(ENetMsgRespondLocationRequest, &getSessionId, &getReason, &getPositionInfo); |
|
184 TESTL(getSessionId->SessionNum() == iSessionId.SessionNum()); |
|
185 TESTL(getReason==KErrCancel); |
|
186 CleanupStack::PopAndDestroy(cleanupCnt); //getSessionId,getPositionInfo |
|
187 |
|
188 // MTLR Session Completion Start |
|
189 // << ProcessSessionComplete() |
|
190 reason = KErrCancel; |
|
191 iProxy->CallL(ENetMsgProcessSessionComplete, &iSessionId, &reason); |
|
192 |
|
193 // >> Callback from ProcessRequestComplete() |
|
194 CheckForObserverEventTestsL(KTimeOut, *this); |
|
195 |
|
196 // Verify that the last callback was to ProcessSessionComplete() |
|
197 TESTL(iState==ERequestComplete); |
|
198 // MTLR Session Completion Stop |
|
199 |
|
200 // and finally check that one cancel was sent to test integration module |
|
201 |
|
202 TInt cancelCount = utils.IntegrationModulesCountOfCancelsL(); |
|
203 |
|
204 INFO_PRINTF2(_L("--- cancel count = %d"), cancelCount); |
|
205 |
|
206 TESTL(cancelCount== 1); |
|
207 INFO_PRINTF1(_L("CT_LbsPTBMTLRCancel::doTestStepL() END")); |
|
208 |
|
209 return TestStepResult(); |
|
210 } |
|
211 |
|
212 void CT_LbsExtPtbMTLRCancel::ProcessNetworkLocationRequest(TUint aRequestId, const TLbsExternalRequestInfo& /*aRequestInfo*/, const TNotificationType& /*aNotificationType*/) |
|
213 { |
|
214 INFO_PRINTF1(_L(">>CT_LbsExtPtbMTLRCancel::ProcessNetworkLocationRequest()")); |
|
215 TEST(iState==EInitializing); |
|
216 iController->RespondNetworkLocationRequest(aRequestId, CLbsPrivacyController::ERequestAccepted); |
|
217 iState = EPrivacyCheckOk; |
|
218 ReturnToTestStep(); |
|
219 } |
|
220 |
|
221 void CT_LbsExtPtbMTLRCancel::ProcessNetworkPositionUpdate(TUint /*aRequestId*/, const TPositionInfo& aPosInfo) |
|
222 { |
|
223 if(iState==EPrivacyCheckOk) |
|
224 { |
|
225 // check that it is the REF postion we are expecting! |
|
226 if (aPosInfo.PositionMode() == TPositionModuleInfo::ETechnologyNetwork) |
|
227 { |
|
228 TPosition getPos; |
|
229 aPosInfo.GetPosition(getPos); |
|
230 if (getPos.Longitude()==-0.096) // and others ... |
|
231 { |
|
232 iState=ERefLocReceived; |
|
233 } |
|
234 } |
|
235 INFO_PRINTF1(_L(">>CT_LbsExtPtbMTLRCancel::ProcessNetworkPositionUpdate(RefPosition)")); |
|
236 } |
|
237 ReturnToTestStep(); |
|
238 } |
|
239 |
|
240 void CT_LbsExtPtbMTLRCancel::ProcessRequestComplete(TUint /*aRequestId*/, TInt aReason) |
|
241 { |
|
242 INFO_PRINTF2(_L(">>CT_LbsPTBMTLRCancel::ProcessRequestComplete(%d)"), aReason); |
|
243 TEST(KErrCancel==aReason); |
|
244 TEST(iState==ERefLocReceived); |
|
245 iState=ERequestComplete; |
|
246 ReturnToTestStep(); |
|
247 } |
|
248 |
|
249 void CT_LbsExtPtbMTLRCancel::InitiateCancelMTLR(TUint aRequestId) |
|
250 { |
|
251 INFO_PRINTF1(_L(">>CT_LbsExtPtbMTLRCancel::initiateCancelMTLR()")); |
|
252 iController->CancelNetworkLocationRequest(aRequestId); |
|
253 INFO_PRINTF1(_L("Cancel Initiated")); |
|
254 } |