|
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.h> |
|
19 #include <lbs/lbsnetcommon.h> |
|
20 #include <lbs/lbsnetprotocolbase.h> |
|
21 #include <lbs/lbsloccommon.h> |
|
22 #include <lbs/lbsx3p.h> |
|
23 #include <lbs/lbsassistancedatabuilderset.h> |
|
24 |
|
25 // LBS test includes. |
|
26 #include "ctlbshybridueassistedx3pnogpstimeout.h" |
|
27 #include <lbs/test/tlbsutils.h> |
|
28 #include <lbs/test/lbsnetprotocolproxy.h> |
|
29 #include "argutils.h" |
|
30 |
|
31 /** |
|
32 Static Constructor |
|
33 */ |
|
34 CT_LbsHybridUEAssistedX3PNoGPSTimeout* CT_LbsHybridUEAssistedX3PNoGPSTimeout::New(CT_LbsHybridX3PServer& aParent) |
|
35 { |
|
36 // Note the lack of ELeave. |
|
37 // This means that having insufficient memory will return NULL; |
|
38 CT_LbsHybridUEAssistedX3PNoGPSTimeout* testStep = new CT_LbsHybridUEAssistedX3PNoGPSTimeout(aParent); |
|
39 if (testStep) |
|
40 { |
|
41 TInt err = KErrNone; |
|
42 |
|
43 TRAP(err, testStep->ConstructL()); |
|
44 if (err) |
|
45 { |
|
46 delete testStep; |
|
47 testStep = NULL; |
|
48 } |
|
49 } |
|
50 return testStep; |
|
51 } |
|
52 |
|
53 |
|
54 /** |
|
55 * Constructor |
|
56 */ |
|
57 CT_LbsHybridUEAssistedX3PNoGPSTimeout::CT_LbsHybridUEAssistedX3PNoGPSTimeout(CT_LbsHybridX3PServer& aParent) : CT_LbsHybridX3PStep(aParent) |
|
58 { |
|
59 SetTestStepName(KLbsHybridUEAssistedX3PNoGPSTimeout); |
|
60 } |
|
61 |
|
62 |
|
63 void CT_LbsHybridUEAssistedX3PNoGPSTimeout::ConstructL() |
|
64 { |
|
65 // Create the base class objects. |
|
66 CT_LbsHybridX3PStep::ConstructL(); |
|
67 User::LeaveIfError(iServer.Connect()); |
|
68 User::LeaveIfError(iTransmitter.Open(iServer)); |
|
69 iProxy = CNetProtocolProxy::NewL(); |
|
70 } |
|
71 |
|
72 |
|
73 /** |
|
74 * Destructor |
|
75 */ |
|
76 CT_LbsHybridUEAssistedX3PNoGPSTimeout::~CT_LbsHybridUEAssistedX3PNoGPSTimeout() |
|
77 { |
|
78 iTransmitter.Close(); |
|
79 iServer.Close(); |
|
80 delete iProxy; |
|
81 } |
|
82 |
|
83 |
|
84 |
|
85 TVerdict CT_LbsHybridUEAssistedX3PNoGPSTimeout::doTestStepL() |
|
86 { |
|
87 // Generic test step used to test the LBS Client Notify position update API. |
|
88 INFO_PRINTF1(_L("CT_LbsHybridUEAssistedX3PNoGPSTimeout::doTestStepL()")); |
|
89 |
|
90 // Stop the test if the preamble failed |
|
91 TESTL(TestStepResult() == EPass); |
|
92 |
|
93 const TInt KTimeOut = 30*1000*1000; |
|
94 const TInt KAdviceSystemStatusTimeout = 40*1000*1000; |
|
95 const TInt KSmallTimeOut = 3*1000*1000; |
|
96 |
|
97 // >> AdviceSystemStatus(0) |
|
98 TESTL(iProxy->WaitForResponse(KAdviceSystemStatusTimeout) == ENetMsgGetCurrentCapabilitiesResponse); |
|
99 CLbsNetworkProtocolBase::TLbsSystemStatus status; |
|
100 TInt cleanupCnt; |
|
101 cleanupCnt = iProxy->GetArgsLC(ENetMsgGetCurrentCapabilitiesResponse, &status); |
|
102 TESTL(status == CLbsNetworkProtocolBase::ESystemStatusNone); |
|
103 CleanupStack::PopAndDestroy(cleanupCnt); |
|
104 |
|
105 //Initiate X3P start |
|
106 // TransmitPosition() |
|
107 _LIT(KThirdParty,"+4407463842101"); |
|
108 const TInt KPriority= 1; |
|
109 TLbsTransmitPositionOptions options(TTimeIntervalMicroSeconds(500*1000*1000)); |
|
110 TRequestStatus refPosStatus=KRequestPending; |
|
111 TRequestStatus transPosStatus=KRequestPending; |
|
112 TPositionInfo refPosInfo; |
|
113 TPositionInfo transPosInfo; |
|
114 iTransmitter.SetTransmitOptions(options); |
|
115 iTransmitter.TransmitPosition(KThirdParty, KPriority, refPosStatus, refPosInfo, transPosStatus, transPosInfo); |
|
116 |
|
117 // RequestTransmitLocation() |
|
118 TESTL(iProxy->WaitForResponse(KTimeOut) == ENetMsgRequestTransmitLocation); |
|
119 TBufC16<14> thirdParty(KThirdParty); |
|
120 TPtr16 ptr = thirdParty.Des(); |
|
121 HBufC16* getThirdParty = NULL; |
|
122 TLbsNetSessionId* getSessionId = NULL; |
|
123 TInt getPriority(0); |
|
124 cleanupCnt = iProxy->GetArgsLC(ENetMsgRequestTransmitLocation, &getSessionId, &getThirdParty, &getPriority); |
|
125 TESTL(ptr.Compare(*getThirdParty)==KErrNone); |
|
126 TESTL(getPriority == KPriority); |
|
127 iSessionId = *getSessionId; //session ID is initialised by LBS |
|
128 CleanupStack::PopAndDestroy(cleanupCnt); |
|
129 |
|
130 // ProcessStatusUpdate() |
|
131 MLbsNetworkProtocolObserver::TLbsNetProtocolService service = MLbsNetworkProtocolObserver::EServiceTransmitThirdParty; |
|
132 iProxy->CallL(ENetMsgProcessStatusUpdate, &service); |
|
133 //End Initiate |
|
134 |
|
135 //Reference Position Notification Start |
|
136 // ProcessLocationUpdate() |
|
137 refPosInfo = ArgUtils::ReferencePositionInfo(); |
|
138 iProxy->CallL(ENetMsgProcessLocationUpdate, &iSessionId, &refPosInfo); |
|
139 //Reference Position Notification End |
|
140 |
|
141 //Assistance Data Notification Start |
|
142 // ProcessAssistanceData() |
|
143 TLbsAsistanceDataGroup dataRequestMask = EAssistanceDataReferenceTime; |
|
144 RLbsAssistanceDataBuilderSet assistanceData; |
|
145 ArgUtils::PopulateLC(assistanceData); |
|
146 TInt reason(KErrNone); |
|
147 iProxy->CallL(ENetMsgProcessAssistanceData, &dataRequestMask, &assistanceData, &reason); |
|
148 CleanupStack::PopAndDestroy(1); //assistanceData |
|
149 // Assistance Data Notification End |
|
150 |
|
151 |
|
152 // Network Location Request Start |
|
153 // ProcessLocationRequest() |
|
154 const TBool emergency(EFalse); |
|
155 TLbsNetPosRequestQuality quality = ArgUtils::QualityAlpha2(); |
|
156 TLbsNetPosRequestMethod method = ArgUtils::RequestHybridMethod(); |
|
157 iProxy->CallL(ENetMsgProcessLocationRequest, &iSessionId, &emergency, &service, &quality, &method); |
|
158 // Network Location Request End |
|
159 |
|
160 //Start the timer |
|
161 TTime timerStart; |
|
162 timerStart.HomeTime(); |
|
163 |
|
164 // RequestAssistanceData(0) |
|
165 TESTL(iProxy->WaitForResponse(KSmallTimeOut) == ENetMsgRequestAssistanceData); |
|
166 TLbsAsistanceDataGroup dataGroup; |
|
167 cleanupCnt = iProxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataGroup); |
|
168 TESTL(dataGroup == EAssistanceDataNone); |
|
169 CleanupStack::PopAndDestroy(cleanupCnt); |
|
170 |
|
171 // here we wait for either of the asynchrnous requestst to complete |
|
172 User::WaitForRequest(refPosStatus, transPosStatus); |
|
173 // but now we do expect that only the REF position asyn request to complete |
|
174 TESTL(refPosStatus==KErrNone); |
|
175 TESTL(transPosStatus.Int() == KRequestPending); |
|
176 |
|
177 //Find the time elapsed from timer |
|
178 TTimeIntervalMicroSeconds microseconds; |
|
179 TTime timerStop; |
|
180 timerStop.HomeTime(); |
|
181 microseconds = timerStop.MicroSecondsFrom(timerStart); |
|
182 TInt64 timeElapsed = microseconds.Int64(); |
|
183 |
|
184 /*** NRH's Alpha2 timer expires. We enter Hybrid mode.***/ |
|
185 //Test that we do not get response before alpha2 has expired |
|
186 TESTL(iProxy->WaitForResponse(KAlpha2Timeout-timeElapsed-KDelta) == ENetMsgTimeoutExpired); |
|
187 TESTL(iProxy->WaitForResponse(2*KDelta) == ENetMsgRespondLocationRequest); |
|
188 getSessionId = NULL; |
|
189 TInt getReason = KErrNone; |
|
190 TPositionSatelliteInfo* getPositionInfo = NULL; |
|
191 cleanupCnt = iProxy->GetArgsLC(ENetMsgRespondLocationRequest, &getSessionId, &getReason, &getPositionInfo); |
|
192 TESTL(getSessionId->SessionNum() == iSessionId.SessionNum()); |
|
193 TESTL(getReason == KErrNone); |
|
194 CleanupStack::PopAndDestroy(cleanupCnt); |
|
195 |
|
196 quality = ArgUtils::Quality(); |
|
197 const TInt KN = 2; |
|
198 for(TInt i=0;i<KN;i++) |
|
199 { |
|
200 iProxy->CallL(ENetMsgProcessLocationRequest, &iSessionId, &emergency, &service, &quality, &method); |
|
201 |
|
202 timerStart.HomeTime(); |
|
203 |
|
204 // RequestAssistanceData(0) |
|
205 TESTL(iProxy->WaitForResponse(KSmallTimeOut) == ENetMsgRequestAssistanceData); |
|
206 cleanupCnt = iProxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataGroup); |
|
207 TESTL(dataGroup == EAssistanceDataNone); |
|
208 CleanupStack::PopAndDestroy(cleanupCnt); |
|
209 |
|
210 timerStop.HomeTime(); |
|
211 microseconds = timerStop.MicroSecondsFrom(timerStart); |
|
212 timeElapsed = microseconds.Int64(); |
|
213 |
|
214 TESTL(iProxy->WaitForResponse(KTTimeout-timeElapsed-KDelta) == ENetMsgTimeoutExpired); |
|
215 TESTL(iProxy->WaitForResponse(2*KDelta) == ENetMsgRespondLocationRequest); |
|
216 |
|
217 getSessionId = NULL; |
|
218 getReason = KErrNone; |
|
219 getPositionInfo = NULL; |
|
220 |
|
221 cleanupCnt = iProxy->GetArgsLC(ENetMsgRespondLocationRequest, &getSessionId, &getReason, &getPositionInfo); |
|
222 TESTL(getReason == KErrNone); |
|
223 TESTL(getSessionId->SessionNum() == iSessionId.SessionNum()); |
|
224 CleanupStack::PopAndDestroy(cleanupCnt); |
|
225 } |
|
226 |
|
227 // Alpha4 expires. |
|
228 // The Protocol Module requests the network for the MC release |
|
229 |
|
230 // Network Result Notification Start |
|
231 // Add extra delay to simulate the Facility timing out |
|
232 User::After(2*KTimeOut); |
|
233 // Test that LBS is not sending any response to the Protocol Module |
|
234 TESTL(iProxy->WaitForResponse(KTimeOut) == ENetMsgTimeoutExpired); |
|
235 // Network Result Notification End |
|
236 |
|
237 // Session Complete Start |
|
238 // The network times out and pass an error to the Protocol Module, in this test, we use KErrTimedOut |
|
239 // The protocol module passes the error to the client app |
|
240 reason = KErrTimedOut; |
|
241 iProxy->CallL(ENetMsgProcessSessionComplete, &iSessionId, &reason); |
|
242 |
|
243 MLbsNetworkProtocolObserver::TLbsNetProtocolServiceMask activeServiceMask = MLbsNetworkProtocolObserver::EServiceNone; |
|
244 iProxy->CallL(ENetMsgProcessStatusUpdate, &activeServiceMask); |
|
245 // Session Complete End |
|
246 |
|
247 User::WaitForRequest(transPosStatus); |
|
248 // We test the error returned from the network |
|
249 TESTL(transPosStatus==KErrTimedOut); |
|
250 |
|
251 return TestStepResult(); |
|
252 } |