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