|
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 "ctlbshybridueassistedx3paccurategpstimeout.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_LbsHybridUEAssistedX3PAccurateGPSTimeout* CT_LbsHybridUEAssistedX3PAccurateGPSTimeout::New(CT_LbsHybridX3PServer& aParent) |
|
35 { |
|
36 // Note the lack of ELeave. |
|
37 // This means that having insufficient memory will return NULL; |
|
38 CT_LbsHybridUEAssistedX3PAccurateGPSTimeout* testStep = new CT_LbsHybridUEAssistedX3PAccurateGPSTimeout(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 * Constructor |
|
55 */ |
|
56 CT_LbsHybridUEAssistedX3PAccurateGPSTimeout::CT_LbsHybridUEAssistedX3PAccurateGPSTimeout(CT_LbsHybridX3PServer& aParent) : CT_LbsHybridX3PStep(aParent) |
|
57 { |
|
58 SetTestStepName(KLbsHybridUEAssistedX3PAccurateGPSTimeout); |
|
59 } |
|
60 |
|
61 void CT_LbsHybridUEAssistedX3PAccurateGPSTimeout::ConstructL() |
|
62 { |
|
63 // Create the base class objects. |
|
64 CT_LbsHybridX3PStep::ConstructL(); |
|
65 User::LeaveIfError(iServer.Connect()); |
|
66 User::LeaveIfError(iTransmitter.Open(iServer)); |
|
67 iProxy = CNetProtocolProxy::NewL(); |
|
68 } |
|
69 |
|
70 /** |
|
71 * Destructor |
|
72 */ |
|
73 CT_LbsHybridUEAssistedX3PAccurateGPSTimeout::~CT_LbsHybridUEAssistedX3PAccurateGPSTimeout() |
|
74 { |
|
75 iTransmitter.Close(); |
|
76 iServer.Close(); |
|
77 delete iProxy; |
|
78 } |
|
79 |
|
80 TVerdict CT_LbsHybridUEAssistedX3PAccurateGPSTimeout::doTestStepL() |
|
81 { |
|
82 // Generic test step used to test the LBS Client Notify position update API. |
|
83 INFO_PRINTF1(_L("CT_LbsHybridUEAssistedX3PAccurateGPSTimeout::doTestStepL()")); |
|
84 |
|
85 // Stop the test if the preable failed |
|
86 TESTL(TestStepResult() == EPass); |
|
87 |
|
88 const TInt KTimeOut = 30*1000*1000; |
|
89 const TInt KAdviceSystemStatusTimeout = 40*1000*1000; |
|
90 const TInt KSmallTimeOut = 3*1000*1000; |
|
91 |
|
92 // >> AdviceSystemStatus(0) |
|
93 TESTL(iProxy->WaitForResponse(KAdviceSystemStatusTimeout) == ENetMsgGetCurrentCapabilitiesResponse); |
|
94 CLbsNetworkProtocolBase::TLbsSystemStatus status; |
|
95 TInt cleanupCnt; |
|
96 cleanupCnt = iProxy->GetArgsLC(ENetMsgGetCurrentCapabilitiesResponse, &status); |
|
97 TESTL(status == CLbsNetworkProtocolBase::ESystemStatusNone); |
|
98 CleanupStack::PopAndDestroy(cleanupCnt); |
|
99 |
|
100 //Initiate X3P start |
|
101 // TransmitPosition() |
|
102 _LIT(KThirdParty,"+4407463842101"); |
|
103 const TInt KPriority= 6; |
|
104 TLbsTransmitPositionOptions options(TTimeIntervalMicroSeconds(500*1000*1000)); |
|
105 TRequestStatus refPosStatus=KRequestPending; |
|
106 TRequestStatus transPosStatus=KRequestPending; |
|
107 TPositionInfo refPosInfo; |
|
108 TPositionInfo transPosInfo; |
|
109 iTransmitter.SetTransmitOptions(options); |
|
110 iTransmitter.TransmitPosition(KThirdParty, KPriority, refPosStatus, refPosInfo, transPosStatus, transPosInfo); |
|
111 |
|
112 // RequestTransmitLocation() |
|
113 TESTL(iProxy->WaitForResponse(KTimeOut) == ENetMsgRequestTransmitLocation); |
|
114 TBufC16<14> thirdParty(KThirdParty); |
|
115 TPtr16 ptr = thirdParty.Des(); |
|
116 HBufC16* getThirdParty = NULL; |
|
117 TLbsNetSessionId* getSessionId = NULL; |
|
118 TInt getPriority(0); |
|
119 cleanupCnt = iProxy->GetArgsLC(ENetMsgRequestTransmitLocation, &getSessionId, &getThirdParty, &getPriority); |
|
120 TESTL(ptr.Compare(*getThirdParty)==KErrNone); |
|
121 TESTL(getPriority == KPriority); |
|
122 iSessionId = *getSessionId; //session ID is initialised by LBS |
|
123 CleanupStack::PopAndDestroy(cleanupCnt); |
|
124 |
|
125 // ProcessStatusUpdate() |
|
126 MLbsNetworkProtocolObserver::TLbsNetProtocolService service = MLbsNetworkProtocolObserver::EServiceTransmitThirdParty; |
|
127 iProxy->CallL(ENetMsgProcessStatusUpdate, &service); |
|
128 //End Initiate |
|
129 |
|
130 //Reference Position Notification Start |
|
131 // ProcessLocationUpdate() |
|
132 refPosInfo = ArgUtils::ReferencePositionInfo(); |
|
133 iProxy->CallL(ENetMsgProcessLocationUpdate, &iSessionId, &refPosInfo); |
|
134 //Reference Position Notification End |
|
135 |
|
136 |
|
137 //Assistance Data Notification Start |
|
138 // ProcessAssistanceData() |
|
139 TLbsAsistanceDataGroup dataRequestMask = EAssistanceDataReferenceTime; |
|
140 RLbsAssistanceDataBuilderSet assistanceData; |
|
141 ArgUtils::PopulateLC(assistanceData); |
|
142 TInt reason = KErrNone; |
|
143 iProxy->CallL(ENetMsgProcessAssistanceData, &dataRequestMask, &assistanceData, &reason); |
|
144 CleanupStack::PopAndDestroy(1); //assistanceData |
|
145 // Assistance Data Notification End |
|
146 |
|
147 // Network Location Request Start |
|
148 // ProcessLocationRequest() |
|
149 const TBool emergency(EFalse); |
|
150 TLbsNetPosRequestQuality quality = ArgUtils::QualityAlpha2(); |
|
151 TLbsNetPosRequestMethod method = ArgUtils::RequestHybridMethod(); |
|
152 iProxy->CallL(ENetMsgProcessLocationRequest, &iSessionId, &emergency, &service, &quality, &method); |
|
153 // Network Location Request Stop |
|
154 |
|
155 //Start the timer |
|
156 TTime timerStart; |
|
157 timerStart.HomeTime(); |
|
158 |
|
159 // RequestAssistanceData(0) |
|
160 TESTL(iProxy->WaitForResponse(KSmallTimeOut) == ENetMsgRequestAssistanceData); |
|
161 TLbsAsistanceDataGroup dataGroup; |
|
162 cleanupCnt = iProxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataGroup); |
|
163 TESTL(dataGroup == EAssistanceDataNone); |
|
164 CleanupStack::PopAndDestroy(cleanupCnt); |
|
165 |
|
166 User::WaitForRequest(refPosStatus, transPosStatus); |
|
167 TESTL(refPosStatus==KErrNone); |
|
168 |
|
169 //Find the time elapsed from timer |
|
170 TTimeIntervalMicroSeconds microseconds; |
|
171 TTime timerStop; |
|
172 timerStop.HomeTime(); |
|
173 microseconds = timerStop.MicroSecondsFrom(timerStart); |
|
174 TInt64 timeElapsed = microseconds.Int64(); |
|
175 |
|
176 /*** NRH's Alpha2 timer expires. We enter Hybrid mode.***/ |
|
177 //Test that we do not get response before alpha2 has expired |
|
178 TESTL(iProxy->WaitForResponse(KAlpha2Timeout-timeElapsed-KDelta) == ENetMsgTimeoutExpired); |
|
179 TESTL(iProxy->WaitForResponse(2*KDelta) == ENetMsgRespondLocationRequest); |
|
180 getSessionId = NULL; |
|
181 TInt getReason = KErrNone; |
|
182 TPositionSatelliteInfo* getPositionInfo = NULL; |
|
183 cleanupCnt = iProxy->GetArgsLC(ENetMsgRespondLocationRequest, &getSessionId, &getReason, &getPositionInfo); |
|
184 TESTL(getSessionId->SessionNum() == iSessionId.SessionNum()); |
|
185 TESTL(getReason == KErrNone); |
|
186 CleanupStack::PopAndDestroy(cleanupCnt); |
|
187 |
|
188 // no need for looping, we assume that the next update location from GPS will give accurate fix |
|
189 quality = ArgUtils::Quality(); |
|
190 iProxy->CallL(ENetMsgProcessLocationRequest, &iSessionId, &emergency, &service, &quality, &method); |
|
191 |
|
192 // RequestAssistanceData(0) |
|
193 TESTL(iProxy->WaitForResponse(KSmallTimeOut) == ENetMsgRequestAssistanceData); |
|
194 cleanupCnt = iProxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataGroup); |
|
195 TESTL(dataGroup == EAssistanceDataNone); |
|
196 CleanupStack::PopAndDestroy(cleanupCnt); |
|
197 |
|
198 // GPS positions meets required accuracy. This is sent immediately to protocol module |
|
199 // The ini file should contain accurate gps fix for this test case to work |
|
200 TESTL(iProxy->WaitForResponse(KTTimeout) == ENetMsgRespondLocationRequest); |
|
201 getSessionId = NULL; |
|
202 getReason = KErrNone; |
|
203 getPositionInfo = NULL; |
|
204 cleanupCnt = iProxy->GetArgsLC(ENetMsgRespondLocationRequest, &getSessionId, &getReason, &getPositionInfo); |
|
205 TESTL(getSessionId->SessionNum() == iSessionId.SessionNum()); |
|
206 TESTL(getReason == KErrNone); |
|
207 // Test position is the same as in the ini file data fed to the GPS module |
|
208 // $update,1,2,51.5015,-0.105,50,2,3* |
|
209 TPosition gpsPos; |
|
210 getPositionInfo->GetPosition(gpsPos); |
|
211 TESTL(gpsPos.Latitude()==51.5015 && gpsPos.Longitude()==-0.105 && gpsPos.Altitude()==50 && gpsPos.HorizontalAccuracy()==2 && gpsPos.VerticalAccuracy()==3); |
|
212 CleanupStack::PopAndDestroy(cleanupCnt); |
|
213 |
|
214 // Network Result Notification Start |
|
215 // Add extra delay to simulate the Facility timing out |
|
216 User::After(2*KTimeOut); |
|
217 // Test that LBS is not sending any response to the Protocol Module |
|
218 TESTL(iProxy->WaitForResponse(KTimeOut) == ENetMsgTimeoutExpired); |
|
219 // Network Result Notification Stop |
|
220 |
|
221 // Session Complete Start |
|
222 // The network times out and pass an error to the Protocol Module, in this test, we use KErrTimedOut |
|
223 // The protocol module passes the error to the client app |
|
224 reason = KErrTimedOut; |
|
225 iProxy->CallL(ENetMsgProcessSessionComplete, &iSessionId, &reason); |
|
226 |
|
227 MLbsNetworkProtocolObserver::TLbsNetProtocolServiceMask activeServiceMask = MLbsNetworkProtocolObserver::EServiceNone; |
|
228 iProxy->CallL(ENetMsgProcessStatusUpdate, &activeServiceMask); |
|
229 // Session Complete Stop |
|
230 |
|
231 User::WaitForRequest(transPosStatus); |
|
232 // We test the error returned from the network |
|
233 TESTL(transPosStatus==KErrTimedOut); |
|
234 return TestStepResult(); |
|
235 } |
|
236 |
|
237 |
|
238 |
|
239 |
|
240 |
|
241 |