|
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 // This is the class implementation for the Module Information Tests |
|
15 // EPOC includes. |
|
16 // |
|
17 // |
|
18 |
|
19 // LBS includes. |
|
20 #include <lbs/lbsextendedsatellite.h> |
|
21 #include <lbs/lbsnetprotocolbase.h> |
|
22 #include <lbs/lbsassistancedatabuilderset.h> |
|
23 #include <e32math.h> |
|
24 #include <lbs/lbsloccommon.h> |
|
25 #include <lbs/lbsx3p.h> |
|
26 #include <lbs/lbsnetprotocolbase.h> |
|
27 |
|
28 // LBS test includes. |
|
29 #include "ctlbsuebasedmolrself.h" |
|
30 #include <lbs/test/tlbsutils.h> |
|
31 #include "argutils.h" |
|
32 |
|
33 #include <lbs/test/activeyield.h> |
|
34 |
|
35 |
|
36 /** |
|
37 Static Constructor |
|
38 */ |
|
39 CT_LbsUEBasedMOLRSelf* CT_LbsUEBasedMOLRSelf::New(CT_LbsHybridMOLRServer& aParent) |
|
40 { |
|
41 // Note the lack of ELeave. |
|
42 // This means that having insufficient memory will return NULL; |
|
43 CT_LbsUEBasedMOLRSelf* testStep = new CT_LbsUEBasedMOLRSelf(aParent); |
|
44 if (testStep) |
|
45 { |
|
46 TInt err = KErrNone; |
|
47 |
|
48 TRAP(err, testStep->ConstructL()); |
|
49 if (err) |
|
50 { |
|
51 delete testStep; |
|
52 testStep = NULL; |
|
53 } |
|
54 } |
|
55 return testStep; |
|
56 } |
|
57 |
|
58 |
|
59 /** |
|
60 * Constructor |
|
61 */ |
|
62 CT_LbsUEBasedMOLRSelf::CT_LbsUEBasedMOLRSelf(CT_LbsHybridMOLRServer& aParent) : CT_LbsHybridMOLRStep(aParent) |
|
63 { |
|
64 SetTestStepName(KLbsUEBasedMOLRSelf); |
|
65 iSessionId.SetSessionOwner(KRequestUid); |
|
66 iSessionId.SetSessionNum(0x0001); |
|
67 } |
|
68 |
|
69 |
|
70 void CT_LbsUEBasedMOLRSelf::ConstructL() |
|
71 { |
|
72 // Create the base class objects. |
|
73 CT_LbsHybridMOLRStep::ConstructL(); |
|
74 } |
|
75 |
|
76 /** |
|
77 * Destructor |
|
78 */ |
|
79 CT_LbsUEBasedMOLRSelf::~CT_LbsUEBasedMOLRSelf() |
|
80 { |
|
81 } |
|
82 |
|
83 |
|
84 TVerdict CT_LbsUEBasedMOLRSelf::doTestStepL() |
|
85 { |
|
86 INFO_PRINTF1(_L("CT_LbsUEBasedMOLRSelf::doTestStepL()")); |
|
87 // Stop the test if the preable failed |
|
88 TESTL(TestStepResult() == EPass); |
|
89 |
|
90 const TInt KTimeOut = 60*1000*1000; |
|
91 |
|
92 // Create Network Protocol Proxy |
|
93 CNetProtocolProxy* proxy = CNetProtocolProxy::NewL(); |
|
94 CleanupStack::PushL(proxy); |
|
95 |
|
96 TESTL(proxy->WaitForResponse(KTimeOut) == ENetMsgGetCurrentCapabilitiesResponse); |
|
97 CLbsNetworkProtocolBase::TLbsSystemStatus status; |
|
98 TInt cleanupCnt; |
|
99 cleanupCnt = proxy->GetArgsLC(ENetMsgGetCurrentCapabilitiesResponse, &status); |
|
100 TESTL(status == CLbsNetworkProtocolBase::ESystemStatusNone); |
|
101 CleanupStack::PopAndDestroy(cleanupCnt); |
|
102 |
|
103 // Do the /actual/ test step! |
|
104 RPositionServer server; |
|
105 TESTL(KErrNone == server.Connect()); |
|
106 CleanupClosePushL(server); |
|
107 |
|
108 RPositioner pos; |
|
109 TESTL(KErrNone == pos.Open(server)); |
|
110 CleanupClosePushL(pos); |
|
111 |
|
112 CPosServerWatcher *pWatch = CPosServerWatcher::NewLC(pos, *this); |
|
113 |
|
114 // <<(App) NotifyPositionUpdate(). |
|
115 pWatch->IssueNotifyPositionUpdate(); |
|
116 |
|
117 // >> RequestSelfLocation() |
|
118 TESTL(proxy->WaitForResponse(KTimeOut) == ENetMsgRequestSelfLocation); |
|
119 |
|
120 // Process the response. |
|
121 TLbsNetSessionId* sessionId = NULL; |
|
122 TLbsNetPosRequestOptionsAssistance* opts = NULL; |
|
123 |
|
124 cleanupCnt = proxy->GetArgsLC(ENetMsgRequestSelfLocation, &sessionId, &opts); |
|
125 |
|
126 TBool qualitycheck = ArgUtils::CompareQuality( opts, |
|
127 ETrue, |
|
128 KMinHorizontalAcc, |
|
129 KMinVerticalAcc, |
|
130 KDefaultMaxFixTime, |
|
131 0, |
|
132 EAssistanceDataReferenceTime, |
|
133 (TPositionModuleInfo::ETechnologyTerminal |
|
134 | TPositionModuleInfo::ETechnologyAssisted) |
|
135 ); |
|
136 |
|
137 TESTL(qualitycheck); |
|
138 |
|
139 iSessionId.SetSessionNum(sessionId->SessionNum()); |
|
140 iSessionId.SetSessionOwner(sessionId->SessionOwner()); |
|
141 |
|
142 CleanupStack::PopAndDestroy(cleanupCnt); |
|
143 sessionId = NULL; |
|
144 opts = NULL; |
|
145 |
|
146 // << ProcessStatusUpdate(EServiceSelfLocation) |
|
147 MLbsNetworkProtocolObserver::TLbsNetProtocolServiceMask activeServiceMask1 = MLbsNetworkProtocolObserver::EServiceSelfLocation; |
|
148 proxy->CallL(ENetMsgProcessStatusUpdate, &activeServiceMask1); |
|
149 |
|
150 // << ProcessLocationUpdate(SessionId, RefPosition) |
|
151 TPositionInfo refPosInfo = ArgUtils::MolrReferencePositionInfo(); |
|
152 proxy->CallL(ENetMsgProcessLocationUpdate, &iSessionId, &refPosInfo); |
|
153 |
|
154 // TEST: Get NotifyPositionUpdate app side - get the ref pos. |
|
155 CheckForObserverEventTestsL(KTimeOut, *this); |
|
156 |
|
157 pWatch->IssueNotifyPositionUpdate(); |
|
158 |
|
159 |
|
160 // >> RequestAssistanceData - as a result of the second client request. |
|
161 TLbsAsistanceDataGroup dataMask; |
|
162 TESTL(proxy->WaitForResponse(KTimeOut) == ENetMsgRequestAssistanceData); |
|
163 cleanupCnt = proxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataMask); |
|
164 TESTL(dataMask == EAssistanceDataNone); |
|
165 CleanupStack::PopAndDestroy(cleanupCnt); |
|
166 |
|
167 // << ProcessAssistanceData() |
|
168 dataMask = EAssistanceDataReferenceTime; |
|
169 RLbsAssistanceDataBuilderSet assistanceData; |
|
170 ArgUtils::PopulateLC(assistanceData); |
|
171 TInt reason = KErrNone; |
|
172 proxy->CallL(ENetMsgProcessAssistanceData, &dataMask, &assistanceData, &reason); |
|
173 CleanupStack::PopAndDestroy(); // assistanceData |
|
174 |
|
175 // << ProcessLocationRequest() - this will cancel the client req. |
|
176 TBool emergency = EFalse; |
|
177 MLbsNetworkProtocolObserver::TLbsNetProtocolService service = MLbsNetworkProtocolObserver::EServiceSelfLocation; |
|
178 TLbsNetPosRequestQuality quality = ArgUtils::Quality(); |
|
179 TLbsNetPosRequestMethod method = ArgUtils::RequestHybridMethod(); |
|
180 proxy->CallL(ENetMsgProcessLocationRequest, &iSessionId, &emergency, &service, &quality, &method); |
|
181 |
|
182 // >> RequestAssistanceData - as a result of the NRH request. |
|
183 TESTL(proxy->WaitForResponse(KTimeOut) == ENetMsgRequestAssistanceData); |
|
184 cleanupCnt = proxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataMask); |
|
185 TESTL(dataMask == EAssistanceDataNone); |
|
186 CleanupStack::PopAndDestroy(cleanupCnt); |
|
187 |
|
188 // >> RespondLocationRequest() |
|
189 TESTL(proxy->WaitForResponse(KTimeOut) == ENetMsgRespondLocationRequest); |
|
190 sessionId = NULL; |
|
191 reason = KErrNone; |
|
192 TPositionExtendedSatelliteInfo* getPositionInfo = NULL; |
|
193 cleanupCnt = proxy->GetArgsLC(ENetMsgRespondLocationRequest, &sessionId, &reason, &getPositionInfo); |
|
194 TESTL(sessionId->SessionNum() == iSessionId.SessionNum()); |
|
195 TESTL(reason == KErrNone); |
|
196 /* Check whether ExtendedSatelliteInfo data received by protocol module is the same as data fed to the GPS module or not. |
|
197 Latitude(49.2),Longitude(3.5),Altitude(50),HorizontalAccuracy(2),VerticalAccuracy(3), speed(26.0),vertical speed(20.0),heading(25.0),course(30.0), |
|
198 SPEED_ACCURACY(2.0),VERTICAL_SPEED_ACCURACY(3.0),HEADING_ACCURACY(10.0),COURSE_ACCURACY(4.0), |
|
199 SD_OF_LONG_ERROR(5.0),SD_OF_LAT_ERROR(6.0),SD_OF_ALT_ERROR(7.0),SD_OF_SEMI_MAJOR_AXIS_ERROR(8.0), |
|
200 SD_OF_SEMI_MINOR_AXIS_ERROR(9.0),ORIEN_OF_SEMI_MAJOR_AXIS_ERROR(10.0),RMS_VAL_OF_SD_OF_RANGE(11.0), |
|
201 GEOIDAL_SEPARATION(12.0),MAGNETIC_VARIATION(13.0),COURSE_OVER_GROUND_MAGNETIC(14.0) |
|
202 GPS_TIMING_OF_CELL_MsPart(16383),GPS_TIMING_OF_CELL_LsPart(4294967295),REFERENCE_IDENTITY(511) |
|
203 SFN(4095)*/ |
|
204 |
|
205 TPosition gpsPos; |
|
206 getPositionInfo->GetPosition(gpsPos); |
|
207 TESTL(gpsPos.Latitude()==49.2 && gpsPos.Longitude()== 3.5 && gpsPos.Altitude()==50 |
|
208 && gpsPos.HorizontalAccuracy()==2 && gpsPos.VerticalAccuracy()==3); |
|
209 TCourse course; |
|
210 getPositionInfo->GetCourse(course); |
|
211 |
|
212 TESTL(course.Speed()==26.0 && course.VerticalSpeed()==20.0 && course.Heading()==25.0 && course.Course()==30.0 && |
|
213 course.SpeedAccuracy()==2.0 && course.VerticalSpeedAccuracy()==3.0 && course.HeadingAccuracy()==10.0 && |
|
214 course.CourseAccuracy()==4.0); |
|
215 |
|
216 TDetailedErrorReport detErrRep; |
|
217 getPositionInfo->GetDetailedErrorReport(detErrRep); |
|
218 TESTL(detErrRep.StanDeviOfLongitudeError()==5.0 && detErrRep.StanDeviOfLatiitudeError()==6.0 && |
|
219 detErrRep.StanDeviOfAltitudeError()==7.0 && detErrRep.StanDeviOfSemiMajorAxisError()==8.0 && |
|
220 detErrRep.StanDeviOfSemiMinorAxisError()==9.0 && detErrRep.OrientationOfSemiMajorAxisError()==10.0 && |
|
221 detErrRep.RmsValOfStanDeviOfRange()==11.0); |
|
222 |
|
223 TGpsTimingMeasurementData gpsTimingData; |
|
224 getPositionInfo->GetGpsTimingData(gpsTimingData); |
|
225 |
|
226 TESTL(gpsTimingData.DataType()== TGpsTimingMeasurementData::EGpsTimingDataTypeUtran && |
|
227 gpsTimingData.NetworkMode()== TGpsTimingMeasurementData::ENetworkModeFdd && |
|
228 gpsTimingData.GPSTimingOfCellMsPart()==16383 && gpsTimingData.GPSTimingOfCellLsPart()==4294967295UL && |
|
229 gpsTimingData.ReferenceIdentity()==511 && gpsTimingData.Sfn()==4095); |
|
230 |
|
231 |
|
232 TESTL(getPositionInfo->GeoidalSeparation()==12.0 && getPositionInfo->MagneticVariation()==13.0 && |
|
233 getPositionInfo->CourseOverGroundMagnetic()==14.0); |
|
234 |
|
235 |
|
236 // << ProcessLocationUpdate(SessionId, FinalNetworkPosition) |
|
237 proxy->CallL(ENetMsgProcessLocationUpdate, &iSessionId, getPositionInfo); |
|
238 |
|
239 CleanupStack::PopAndDestroy(cleanupCnt); |
|
240 |
|
241 // Client recv - the gps position determined by the gps module. |
|
242 CheckForObserverEventTestsL(KTimeOut, *this); |
|
243 TESTL(iState == EGpsLocReceived); |
|
244 |
|
245 // << ProcessSessionComplete() |
|
246 reason = KErrNone; |
|
247 proxy->CallL(ENetMsgProcessSessionComplete, &iSessionId, &reason); |
|
248 |
|
249 // << ProcessStatusUpdate() |
|
250 MLbsNetworkProtocolObserver::TLbsNetProtocolServiceMask activeServiceMask2 = MLbsNetworkProtocolObserver::EServiceNone; |
|
251 proxy->CallL(ENetMsgProcessStatusUpdate, &activeServiceMask2); |
|
252 |
|
253 // Wait for 10 seconds to ensure no additional responses turn up. |
|
254 TInt delta = 10 * 1000 * 1000; |
|
255 TNetProtocolResponseType mType = proxy->WaitForResponse(delta); |
|
256 TESTL(mType == ENetMsgTimeoutExpired); |
|
257 |
|
258 |
|
259 // Done. Now cleanup... |
|
260 CleanupStack::PopAndDestroy(pWatch); |
|
261 CleanupStack::PopAndDestroy(); // pos |
|
262 CleanupStack::PopAndDestroy(); // server |
|
263 CleanupStack::PopAndDestroy(proxy); |
|
264 |
|
265 return TestStepResult(); |
|
266 } |
|
267 |
|
268 // MPosServerObserver |
|
269 void CT_LbsUEBasedMOLRSelf::OnGetLastKnownPosition(TInt32 /*aErr*/, const TPositionInfoBase& /*aPosInfo*/) |
|
270 { |
|
271 TEST(EFalse); // Shouldn't see this... |
|
272 ReturnToTestStep(); |
|
273 } |
|
274 |
|
275 |
|
276 void CT_LbsUEBasedMOLRSelf::OnNotifyPositionUpdate(TInt32 aErr, const TPositionInfoBase& aPosInfo) |
|
277 { |
|
278 // Verify error. |
|
279 TEST(aErr == KErrNone); |
|
280 |
|
281 // Verify position. |
|
282 |
|
283 // Expecting ref pos. |
|
284 if (iState == EInitializing) |
|
285 { |
|
286 iState = ERefLocReceived; |
|
287 |
|
288 TEST(aPosInfo.PositionClassType() == EPositionInfoClass); |
|
289 TEST(aPosInfo.PositionMode() == TPositionModuleInfo::ETechnologyNetwork); |
|
290 |
|
291 // check for refpos details |
|
292 const TPositionInfo posInfo = static_cast<const TPositionInfo&>(aPosInfo); |
|
293 TEST(ArgUtils::ComparePositionInfoToMolrRefPos(posInfo)); |
|
294 } |
|
295 |
|
296 // Expecting gps pos. |
|
297 else if (iState == ERefLocReceived) |
|
298 { |
|
299 iState = EGpsLocReceived; |
|
300 |
|
301 TEST(aPosInfo.PositionClassType() == EPositionInfoClass); |
|
302 TEST(aPosInfo.PositionMode() == (TPositionModuleInfo::ETechnologyTerminal | TPositionModuleInfo::ETechnologyAssisted)); |
|
303 } |
|
304 |
|
305 // Not expecting anything else. |
|
306 else |
|
307 { |
|
308 TEST(EFalse); |
|
309 } |
|
310 |
|
311 ReturnToTestStep(); |
|
312 } |
|
313 |