|
1 // Copyright (c) 2005-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 // Example CTestStep derived implementation |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file DataClassesStep.cpp |
|
20 @internalTechnology |
|
21 */ |
|
22 #include "dataclassesstep.h" |
|
23 #include "te_lbsapisuitedefs.h" |
|
24 |
|
25 #include "lcfsbucommondefinitions.h" |
|
26 |
|
27 #include <lbs.h> |
|
28 #include <lbs/lbsextendedsatellite.h> |
|
29 #include <lbs/lbsgpstimingmeasurement.h> |
|
30 #include <lbs/lbsgpsmeasurement.h> |
|
31 |
|
32 // used to confirm that PositionXInfo class sizes do not change |
|
33 const TUint KPositionSatelliteInfoSize = 920; |
|
34 const TUint KPositionGpsMeasurementInfoSize = 832; |
|
35 |
|
36 |
|
37 CDataClassesStep::~CDataClassesStep() |
|
38 /** |
|
39 * Destructor |
|
40 */ |
|
41 { |
|
42 } |
|
43 |
|
44 CDataClassesStep::CDataClassesStep() |
|
45 /** |
|
46 * Constructor |
|
47 */ |
|
48 { |
|
49 // **MUST** call SetTestStepName in the constructor as the controlling |
|
50 // framework uses the test step name immediately following construction to set |
|
51 // up the step's unique logging ID. |
|
52 SetTestStepName(KDataClassesStep); |
|
53 } |
|
54 |
|
55 TVerdict CDataClassesStep::doTestStepPreambleL() |
|
56 /** |
|
57 * @return - TVerdict code |
|
58 * Override of base class virtual |
|
59 */ |
|
60 { |
|
61 CTe_LbsApiSuiteStepBase::doTestStepPreambleL(); |
|
62 if (TestStepResult()!=EPass) |
|
63 return TestStepResult(); |
|
64 // process some pre setting to this test step then set SetTestStepResult to EFail or Epass. |
|
65 SetTestStepResult(EPass); |
|
66 return TestStepResult(); |
|
67 } |
|
68 |
|
69 |
|
70 TVerdict CDataClassesStep::doTestStepL() |
|
71 /** |
|
72 * @return - TVerdict code |
|
73 * Override of base class pure virtual |
|
74 * Our implementation only gets called if the base class doTestStepPreambleL() did |
|
75 * not leave. That being the case, the current test result value will be EPass. |
|
76 */ |
|
77 { |
|
78 if (TestStepResult()==EPass) |
|
79 { |
|
80 TInt test; |
|
81 if(!GetIntFromConfig(ConfigSection(),KTe_LbsApiSuiteInt,test) |
|
82 ) |
|
83 { |
|
84 // Leave if there's any error. |
|
85 User::Leave(KErrNotFound); |
|
86 } |
|
87 SetTestStepResult(EPass); |
|
88 StartL(test); |
|
89 } |
|
90 return TestStepResult(); |
|
91 } |
|
92 |
|
93 |
|
94 |
|
95 TVerdict CDataClassesStep::doTestStepPostambleL() |
|
96 /** |
|
97 * @return - TVerdict code |
|
98 * Override of base class virtual |
|
99 */ |
|
100 { |
|
101 // process something post setting to the test step |
|
102 // uncomment the following line if you have common post setting to all the test steps in there |
|
103 // CTe_LbsApiVariant2SuiteStepBase::doTestStepPostambleL(); |
|
104 // uncomment the following line if you have post process or remove the following line if no post process |
|
105 // SetTestStepResult(EPass); // or EFail |
|
106 return TestStepResult(); |
|
107 } |
|
108 |
|
109 void CDataClassesStep::StartL(TInt aIndex) |
|
110 { |
|
111 switch (aIndex) |
|
112 { |
|
113 case 0: |
|
114 TCoordinate_BlankConstructionL (); |
|
115 break; |
|
116 case 1: |
|
117 TCoordinate_ConstructorsL (); |
|
118 break; |
|
119 case 2: |
|
120 TCoordinate_Constructors2L (); |
|
121 break; |
|
122 case 3: |
|
123 TCoordinate_InvalidL (); |
|
124 break; |
|
125 case 4: |
|
126 TCoordinate_NormalizationWithNansL (); |
|
127 break; |
|
128 case 5: |
|
129 TLocality_BlankConstructionL (); |
|
130 break; |
|
131 case 6: |
|
132 TLocality_ConstructorsL (); |
|
133 break; |
|
134 case 7: |
|
135 TLocality_Constructors2L (); |
|
136 break; |
|
137 case 8: |
|
138 TLocality_NegativeL (); |
|
139 break; |
|
140 case 9: |
|
141 TPosition_ConstructionL (); |
|
142 break; |
|
143 case 10: |
|
144 TPosition_SettersL (); |
|
145 break; |
|
146 case 11: |
|
147 TPositionInfo_ConstructionL (); |
|
148 break; |
|
149 case 12: |
|
150 TPositionInfo_ModificationL (); |
|
151 break; |
|
152 case 13: |
|
153 CourseClasses_ConstructionL (); |
|
154 break; |
|
155 case 14: |
|
156 CourseClasses_Modification2L (); |
|
157 break; |
|
158 case 15: |
|
159 CourseClasses_ModificationL (); |
|
160 break; |
|
161 case 16: |
|
162 CourseClasses_InvalidL (); |
|
163 break; |
|
164 case 17: |
|
165 SatelliteClasses_ConstructionL (); |
|
166 break; |
|
167 case 18: |
|
168 SatelliteClasses_PropertiesL (); |
|
169 break; |
|
170 case 19: |
|
171 SatelliteClasses_Properties2L (); |
|
172 break; |
|
173 case 20: |
|
174 SatelliteClasses_InfoL (); |
|
175 break; |
|
176 case 21: |
|
177 SatelliteClasses_SatelliteInfoL (); |
|
178 break; |
|
179 case 22: |
|
180 SatelliteClasses_OverflowL (); |
|
181 break; |
|
182 case 23: |
|
183 GpsMeasurementClasses_PropertiesL (); |
|
184 break; |
|
185 default: |
|
186 break; |
|
187 } |
|
188 } |
|
189 |
|
190 |
|
191 extern void CheckPanic(const char* aFileName, TInt aLine); |
|
192 |
|
193 // |
|
194 // |
|
195 // TCoordinate |
|
196 // |
|
197 // |
|
198 |
|
199 // 2.1.1. Default constructor sets values to NAN |
|
200 void CDataClassesStep::TCoordinate_BlankConstructionL() |
|
201 { |
|
202 DECLARE_ERROR_LOGGING; |
|
203 StandardPrepareL(); |
|
204 |
|
205 TCoordinate coordinate; |
|
206 CHECK(Math::IsNaN(coordinate.Latitude())); |
|
207 CHECK(Math::IsNaN(coordinate.Longitude())); |
|
208 CHECK(Math::IsNaN(coordinate.Altitude())); |
|
209 CHECK_EQUAL_(KPositionDatumWgs84.iUid, coordinate.Datum().iUid); |
|
210 |
|
211 StandardCleanup(); |
|
212 } |
|
213 |
|
214 // 2.1.2 Parameterized constructors and Setters work same |
|
215 void CDataClassesStep::TCoordinate_ConstructorsL() |
|
216 { |
|
217 DECLARE_ERROR_LOGGING; |
|
218 StandardPrepareL(); |
|
219 |
|
220 const TReal64 dumLat = 11.111; |
|
221 const TReal64 dumLon = 22.222; |
|
222 const TReal32 dumAlt = TReal32(33.333); |
|
223 |
|
224 TCoordinate coordSet; |
|
225 |
|
226 // 2 parameters |
|
227 |
|
228 coordSet.SetCoordinate(dumLat, dumLon); |
|
229 |
|
230 CHECK_REAL_EQUAL(coordSet.Latitude() , dumLat); |
|
231 CHECK_REAL_EQUAL(coordSet.Longitude(), dumLon); |
|
232 CHECK(Math::IsNaN(coordSet.Altitude())); |
|
233 |
|
234 TCoordinate coord2p(dumLat, dumLon); |
|
235 |
|
236 CHECK_REAL_EQUAL(coord2p.Latitude() , coordSet.Latitude()); |
|
237 CHECK_REAL_EQUAL(coord2p.Longitude() , coordSet.Longitude()); |
|
238 CHECK(Math::IsNaN(coord2p.Altitude())); |
|
239 |
|
240 // 3 params |
|
241 coordSet.SetCoordinate(dumLat, dumLon, dumAlt); |
|
242 |
|
243 CHECK_REAL_EQUAL(coordSet.Latitude() , dumLat); |
|
244 CHECK_REAL_EQUAL(coordSet.Longitude(), dumLon); |
|
245 CHECK_REAL_EQUAL(coordSet.Altitude() , dumAlt); |
|
246 |
|
247 TCoordinate coord3p(dumLat, dumLon, dumAlt); |
|
248 |
|
249 CHECK_REAL_EQUAL(coord3p.Latitude() , coordSet.Latitude()); |
|
250 CHECK_REAL_EQUAL(coord3p.Longitude(), coordSet.Longitude()); |
|
251 CHECK_REAL_EQUAL(coord3p.Altitude() , coordSet.Altitude()); |
|
252 |
|
253 // datum |
|
254 const TPositionDatumId otherDatum = {0x10101010}; |
|
255 coordSet.SetDatum(otherDatum); |
|
256 CHECK_EQUAL_(otherDatum.iUid, coordSet.Datum().iUid); |
|
257 |
|
258 StandardCleanup(); |
|
259 } |
|
260 |
|
261 // 2.1.3 Parameterized constructors and Setters work same with NANs |
|
262 void CDataClassesStep::TCoordinate_Constructors2L() |
|
263 { |
|
264 DECLARE_ERROR_LOGGING; |
|
265 StandardPrepareL(); |
|
266 |
|
267 TRealX nan; |
|
268 nan.SetNaN(); |
|
269 |
|
270 TReal64 dumLat(nan); |
|
271 TReal64 dumLon(nan); |
|
272 TReal32 dumAlt(nan); |
|
273 |
|
274 TCoordinate coordSet; |
|
275 |
|
276 // 2 parameters |
|
277 |
|
278 coordSet.SetCoordinate(dumLat, dumLon); |
|
279 |
|
280 CHECK(Math::IsNaN(coordSet.Latitude())); |
|
281 CHECK(Math::IsNaN(coordSet.Longitude())); |
|
282 CHECK(Math::IsNaN(coordSet.Altitude())); |
|
283 |
|
284 TCoordinate coord2p(dumLat, dumLon); |
|
285 |
|
286 CHECK(Math::IsNaN(coord2p.Latitude())); |
|
287 CHECK(Math::IsNaN(coord2p.Longitude())); |
|
288 CHECK(Math::IsNaN(coord2p.Altitude())); |
|
289 |
|
290 // 3 params |
|
291 coordSet.SetCoordinate(dumLat, dumLon, dumAlt); |
|
292 |
|
293 CHECK(Math::IsNaN(coordSet.Latitude())); |
|
294 CHECK(Math::IsNaN(coordSet.Longitude())); |
|
295 CHECK(Math::IsNaN(coordSet.Altitude())); |
|
296 |
|
297 TCoordinate coord3p(dumLat, dumLon, dumAlt); |
|
298 |
|
299 CHECK(Math::IsNaN(coord3p.Latitude())); |
|
300 CHECK(Math::IsNaN(coord3p.Longitude())); |
|
301 CHECK(Math::IsNaN(coord3p.Altitude())); |
|
302 |
|
303 StandardCleanup(); |
|
304 } |
|
305 |
|
306 // 2.1.4 Bad Input in TCoordinate |
|
307 |
|
308 // The function is to normalize Lat/Lon parameters |
|
309 // to [-90,+90] and (-180,+180] ranges respectively. |
|
310 // If Latitude wraps +90 or -90 boundary, than Longitude |
|
311 // is corrected to be shifted to another hemisphere |
|
312 // |
|
313 // IF Latitude is in 1st quarter of circle THEN nothing to do |
|
314 // IF Latitude is in 2nd or 3rd quarter, |
|
315 // THEN Longitude is shifted to opposite hemisphere, and Latitude |
|
316 // is mirrored about 90 degrees (to accord with longitude) |
|
317 // IF Latitude is in 4th quarter, THEN Latitude is mirrored |
|
318 // about 0 degrees (to be below equator) |
|
319 // |
|
320 // NOTE that as +90 and -90 a valid Latitude values, |
|
321 // then 4th quarter begins from +270 inclusively (it is -90 inclusively in fact) |
|
322 // |
|
323 // Latitude is processed first as it has its influence on Longitude |
|
324 void NormalLatLon(TReal lat, TReal lon, TReal& nlat, TReal& nlon) |
|
325 { |
|
326 // 1. latitude |
|
327 |
|
328 // save sign, because negative and positive latitude |
|
329 // values are processed same way |
|
330 TBool isNegLat = (lat < 0); |
|
331 |
|
332 // truncate by 360, work with positive values |
|
333 TReal absLat = isNegLat ? -lat : lat; |
|
334 Math::Mod(lat, absLat, 360); // 0 <= lat < 360 |
|
335 |
|
336 // correct values, if latitude wraps 90 deg boundary |
|
337 if (lat >= 270) // 4th quarter |
|
338 { |
|
339 lat = lat - 360; // reverse |
|
340 } |
|
341 else |
|
342 if (lat > 90) // 2nd or 3rd quarter |
|
343 { |
|
344 lat = 180 - lat; // round about 90 |
|
345 lon = lon + 180; // another hemisphere |
|
346 } |
|
347 |
|
348 // recall latutide sign |
|
349 if (isNegLat) lat = - lat; |
|
350 |
|
351 // 2. longitude |
|
352 |
|
353 // -360 < lon < 360 |
|
354 Math::Mod(lon, lon, 360); |
|
355 // let's put lon to -180 .. 180 range |
|
356 if (lon > 180) |
|
357 { |
|
358 lon = lon - 360; |
|
359 } |
|
360 else |
|
361 if (lon < - 180) // for negative longitudes |
|
362 { |
|
363 lon = lon + 360; |
|
364 } |
|
365 |
|
366 nlat = lat; |
|
367 nlon = lon; |
|
368 } |
|
369 |
|
370 void XYZfromLatLon(TReal& x, TReal& y, TReal& z, TReal lat, TReal lon) |
|
371 { |
|
372 Math::Mod(lat, lat, 360); // -360 < lat < 360 |
|
373 Math::Mod(lon, lon, 360); // -360 < lon < 360 |
|
374 |
|
375 |
|
376 // if latitude is 90 deg or -90 deg, then reduce it by one degree : 89 deg. |
|
377 // it allows to check longitude direction more correctly (avoid cos(lat)==0) |
|
378 if ((lat == 90) || (lat == -270)) |
|
379 { |
|
380 lat -= 1; |
|
381 } |
|
382 else |
|
383 if ((lat == -90) || (lat == 270)) |
|
384 { |
|
385 lat += 1; |
|
386 } |
|
387 |
|
388 TReal latCos, latSin, lonCos, lonSin; |
|
389 Math::Cos(latCos, lat * KDegToRad); |
|
390 Math::Sin(latSin, lat * KDegToRad); |
|
391 Math::Cos(lonCos, lon * KDegToRad); |
|
392 Math::Sin(lonSin, lon * KDegToRad); |
|
393 |
|
394 x = latCos * lonCos; |
|
395 y = latCos * lonSin; |
|
396 z = latSin; |
|
397 } |
|
398 |
|
399 TBool IsSamePoint(TReal lat1, TReal lon1, TReal lat2, TReal lon2) |
|
400 { |
|
401 TReal x1,y1,z1, x2,y2,z2; |
|
402 |
|
403 XYZfromLatLon(x1,y1,z1, lat1, lon1); // source values |
|
404 XYZfromLatLon(x2,y2,z2, lat2, lon2); // TCoordinate |
|
405 |
|
406 const TReal tolerance = 0.0000001; // 1 of million |
|
407 |
|
408 TBool same = (Abs(x1 - x2) < tolerance) && |
|
409 (Abs(y1 - y2) < tolerance) && |
|
410 (Abs(z1 - z2) < tolerance); |
|
411 return same; |
|
412 } |
|
413 |
|
414 |
|
415 void CDataClassesStep::TCoordinate_InvalidL() |
|
416 { |
|
417 DECLARE_ERROR_LOGGING; |
|
418 StandardPrepareL(); |
|
419 |
|
420 const TReal32 alt = 10; |
|
421 TBool noErrors = ETrue; |
|
422 |
|
423 // 1. Valid WGS84 range + Out of WGS84 range |
|
424 |
|
425 // check values (step 30 degrees) in (-540..+540] of longitude |
|
426 for (TReal64 lon = 540; lon > -540; lon -= 30) |
|
427 { |
|
428 // check values (step 30 degrees) in [-450; 450] of latitude |
|
429 for (TReal64 lat = 720; lat >= -720; lat -= 30) |
|
430 { |
|
431 // set |
|
432 TCoordinate coordinate2, coordinate3; |
|
433 coordinate2.SetCoordinate(lat,lon); |
|
434 coordinate3.SetCoordinate(lat,lon, alt); |
|
435 |
|
436 // construct |
|
437 TCoordinate coord2(lat, lon); |
|
438 TCoordinate coord3(lat, lon, alt); |
|
439 |
|
440 TBool isValidCoordinate2 = IsSamePoint(lat, lon, coordinate2.Latitude(), coordinate2.Longitude()); |
|
441 TBool isValidCoordinate3 = IsSamePoint(lat, lon, coordinate3.Latitude(), coordinate3.Longitude()); |
|
442 TBool isValidCoord2 = IsSamePoint(lat, lon, coord2.Latitude(), coord2.Longitude()); |
|
443 TBool isValidCoord3 = IsSamePoint(lat, lon, coord3.Latitude(), coord3.Longitude()); |
|
444 |
|
445 |
|
446 TReal nlat, nlon; |
|
447 NormalLatLon(lat, lon, nlat, nlon); |
|
448 TBool isValidNormalLatLon = IsSamePoint(lat, lon, nlat, nlon); |
|
449 |
|
450 if (!isValidCoordinate2 || !isValidCoordinate3 || !isValidCoord2 || !isValidCoord3 || !isValidNormalLatLon) |
|
451 { |
|
452 noErrors = EFalse; |
|
453 } |
|
454 } |
|
455 } |
|
456 |
|
457 if (!noErrors) LOG("There were errors in Normalization."); |
|
458 CHECK(noErrors); |
|
459 |
|
460 StandardCleanup(); |
|
461 } |
|
462 |
|
463 |
|
464 |
|
465 TInt TCoordinate_NormalizationWithNans_Panic(TAny* /*aPtr*/) |
|
466 { |
|
467 TRealX nan; nan.SetNaN(); |
|
468 |
|
469 const TReal KBigLatitude = 120.0; |
|
470 const TReal KBigLongitude = 200.0; |
|
471 |
|
472 const TReal KGoodLatitude = 180 - KBigLatitude; |
|
473 const TReal KGoodLongitude = KBigLongitude - 360; |
|
474 |
|
475 TCoordinate coord; |
|
476 |
|
477 // this will cause normalization process |
|
478 // this should not panic even though longitude is NaN |
|
479 coord.SetCoordinate(KBigLatitude, nan); |
|
480 CHECK_PANIC(coord.Latitude() == KGoodLatitude); |
|
481 CHECK_PANIC(Math::IsNaN(coord.Longitude())); |
|
482 |
|
483 // this will cause normalization process |
|
484 // this should not panic even though latitude is NaN |
|
485 coord.SetCoordinate(nan, KBigLongitude); |
|
486 CHECK_PANIC(coord.Longitude() == KGoodLongitude); |
|
487 CHECK_PANIC(Math::IsNaN(coord.Latitude())); |
|
488 |
|
489 return KErrNone; |
|
490 } |
|
491 |
|
492 // 2.1.5 Normalization if one of members is NaN |
|
493 void CDataClassesStep::TCoordinate_NormalizationWithNansL() |
|
494 { |
|
495 DECLARE_ERROR_LOGGING; |
|
496 StandardPrepareL(); |
|
497 |
|
498 DO_PANIC_TEST_L( |
|
499 TCoordinate_NormalizationWithNans_Panic, |
|
500 KNoClientFault, |
|
501 KErrNone, |
|
502 KDefaultTestTimeout); |
|
503 |
|
504 StandardCleanup(); |
|
505 } |
|
506 |
|
507 |
|
508 // |
|
509 // |
|
510 // TLocality |
|
511 // |
|
512 // |
|
513 |
|
514 // 2.3.1. Blank constructor |
|
515 void CDataClassesStep::TLocality_BlankConstructionL() |
|
516 { |
|
517 DECLARE_ERROR_LOGGING; |
|
518 StandardPrepareL(); |
|
519 |
|
520 TLocality locality; |
|
521 CHECK(Math::IsNaN(locality.Latitude())); |
|
522 CHECK(Math::IsNaN(locality.Longitude())); |
|
523 CHECK(Math::IsNaN(locality.Altitude())); |
|
524 CHECK(Math::IsNaN(locality.HorizontalAccuracy())); |
|
525 CHECK(Math::IsNaN(locality.VerticalAccuracy())); |
|
526 |
|
527 StandardCleanup(); |
|
528 } |
|
529 |
|
530 // 2.3.2. Compare constructor parameters setting and using setters |
|
531 void CDataClassesStep::TLocality_ConstructorsL() |
|
532 { |
|
533 DECLARE_ERROR_LOGGING; |
|
534 StandardPrepareL(); |
|
535 |
|
536 const TReal64 dumLat = 11.111; |
|
537 const TReal64 dumLon = 22.222; |
|
538 const TReal32 dumAlt = TReal32(33.333); |
|
539 const TReal32 dumHorAcc = TReal32(0.444); |
|
540 const TReal32 dumVerAcc = TReal32(0.555); |
|
541 |
|
542 TCoordinate coord(dumLat, dumLon, dumAlt); |
|
543 |
|
544 // hor |
|
545 TLocality localSetHor; |
|
546 localSetHor.SetHorizontalAccuracy(dumHorAcc); |
|
547 |
|
548 CHECK_REAL_EQUAL(localSetHor.HorizontalAccuracy() , dumHorAcc); |
|
549 CHECK(Math::IsNaN(localSetHor.VerticalAccuracy())); |
|
550 |
|
551 TLocality localHor(coord, dumHorAcc); |
|
552 |
|
553 CHECK_REAL_EQUAL(localHor.Latitude() , dumLat); |
|
554 CHECK_REAL_EQUAL(localHor.Longitude(), dumLon); |
|
555 CHECK_REAL_EQUAL(localHor.Altitude() , dumAlt); |
|
556 |
|
557 CHECK_REAL_EQUAL(localHor.HorizontalAccuracy(), dumHorAcc); |
|
558 CHECK(Math::IsNaN(localHor.VerticalAccuracy())); |
|
559 |
|
560 // ver |
|
561 TLocality localSetVer; |
|
562 localSetVer.SetVerticalAccuracy(dumVerAcc); |
|
563 |
|
564 CHECK(Math::IsNaN(localSetVer.HorizontalAccuracy())); |
|
565 CHECK_REAL_EQUAL(localSetVer.VerticalAccuracy() , dumVerAcc); |
|
566 |
|
567 // both |
|
568 TLocality localSet; |
|
569 localSet.SetAccuracy(dumHorAcc, dumVerAcc); |
|
570 |
|
571 CHECK_REAL_EQUAL(localSet.HorizontalAccuracy(), dumHorAcc); |
|
572 CHECK_REAL_EQUAL(localSet.VerticalAccuracy() , dumVerAcc); |
|
573 |
|
574 TLocality localVer(coord, dumHorAcc, dumVerAcc); |
|
575 |
|
576 CHECK_REAL_EQUAL(localVer.Latitude() , dumLat); |
|
577 CHECK_REAL_EQUAL(localVer.Longitude(), dumLon); |
|
578 CHECK_REAL_EQUAL(localVer.Altitude() , dumAlt); |
|
579 |
|
580 CHECK_REAL_EQUAL(localVer.HorizontalAccuracy(), dumHorAcc); |
|
581 CHECK_REAL_EQUAL(localVer.VerticalAccuracy() , dumVerAcc); |
|
582 |
|
583 StandardCleanup(); |
|
584 } |
|
585 |
|
586 // 2.3.3. Compare constructor parameters setting and using setters, NANs |
|
587 TInt TLocality_Constructors_and_Setters_with_NANs(TAny* /*aPtr*/) |
|
588 { |
|
589 TRealX nan; nan.SetNaN(); |
|
590 |
|
591 const TReal64 dumLat(nan); |
|
592 const TReal64 dumLon(nan); |
|
593 const TReal32 dumAlt(nan); |
|
594 const TReal32 dumHorAcc(nan); |
|
595 const TReal32 dumVerAcc(nan); |
|
596 |
|
597 TCoordinate coord(dumLat, dumLon, dumAlt); |
|
598 |
|
599 // hor |
|
600 TLocality localSetHor; |
|
601 localSetHor.SetHorizontalAccuracy(dumHorAcc); |
|
602 |
|
603 CHECK_PANIC(Math::IsNaN(localSetHor.HorizontalAccuracy())); |
|
604 CHECK_PANIC(Math::IsNaN(localSetHor.VerticalAccuracy())); |
|
605 |
|
606 TLocality localHor(coord, dumHorAcc); |
|
607 |
|
608 CHECK_PANIC(Math::IsNaN(localHor.Latitude())); |
|
609 CHECK_PANIC(Math::IsNaN(localHor.Longitude())); |
|
610 CHECK_PANIC(Math::IsNaN(localHor.Altitude())); |
|
611 |
|
612 CHECK_PANIC(Math::IsNaN(localHor.HorizontalAccuracy())); |
|
613 CHECK_PANIC(Math::IsNaN(localHor.VerticalAccuracy())); |
|
614 |
|
615 // ver |
|
616 TLocality localSetVer; |
|
617 localSetVer.SetVerticalAccuracy(dumVerAcc); |
|
618 |
|
619 CHECK_PANIC(Math::IsNaN(localSetVer.HorizontalAccuracy())); |
|
620 CHECK_PANIC(Math::IsNaN(localSetVer.VerticalAccuracy())); |
|
621 |
|
622 // both |
|
623 TLocality localSet; |
|
624 localSet.SetAccuracy(dumHorAcc, dumVerAcc); |
|
625 |
|
626 CHECK_PANIC(Math::IsNaN(localSet.HorizontalAccuracy())); |
|
627 CHECK_PANIC(Math::IsNaN(localSet.VerticalAccuracy())); |
|
628 |
|
629 TLocality localVer(coord, dumHorAcc, dumVerAcc); |
|
630 |
|
631 CHECK_PANIC(Math::IsNaN(localVer.Latitude())); |
|
632 CHECK_PANIC(Math::IsNaN(localVer.Longitude())); |
|
633 CHECK_PANIC(Math::IsNaN(localVer.Altitude())); |
|
634 |
|
635 CHECK_PANIC(Math::IsNaN(localVer.HorizontalAccuracy())); |
|
636 CHECK_PANIC(Math::IsNaN(localVer.VerticalAccuracy())); |
|
637 |
|
638 return KErrNone; |
|
639 } |
|
640 |
|
641 |
|
642 void CDataClassesStep::TLocality_Constructors2L() |
|
643 { |
|
644 DECLARE_ERROR_LOGGING; |
|
645 StandardPrepareL(); |
|
646 |
|
647 DO_PANIC_TEST_L( |
|
648 TLocality_Constructors_and_Setters_with_NANs, |
|
649 KNoClientFault, |
|
650 KErrNone, |
|
651 KDefaultTestTimeout); |
|
652 |
|
653 StandardCleanup(); |
|
654 } |
|
655 |
|
656 // 2.3.4 Negative Accuracy values |
|
657 TInt TLocality_Negative_Accuracy_Construct_HorAcc(TAny* /*aPtr*/) |
|
658 { |
|
659 const TReal32 dumAcc = TReal32(0.1); |
|
660 TLocality locality(TCoordinate(1,2,3), -dumAcc); |
|
661 |
|
662 locality.Altitude(); |
|
663 return KErrGeneral; |
|
664 } |
|
665 |
|
666 |
|
667 TInt TLocality_Negative_Accuracy_Construct_VerAcc(TAny* /*aPtr*/) |
|
668 { |
|
669 const TReal32 dumAcc = TReal32(0.1); |
|
670 TLocality locality(TCoordinate(1,2,3), dumAcc, -dumAcc); |
|
671 |
|
672 locality.Altitude(); |
|
673 return KErrGeneral; |
|
674 } |
|
675 |
|
676 |
|
677 TInt TLocality_Negative_Accuracy_Set_Both_HorNegative(TAny* /*aPtr*/) |
|
678 { |
|
679 const TReal32 dumAcc = TReal32(0.1); |
|
680 TLocality locality; |
|
681 locality.SetAccuracy(-dumAcc, dumAcc); |
|
682 return KErrGeneral; |
|
683 } |
|
684 |
|
685 |
|
686 TInt TLocality_Negative_Accuracy_Set_Both_VerNegative(TAny* /*aPtr*/) |
|
687 { |
|
688 const TReal32 dumAcc = TReal32(0.1); |
|
689 TLocality locality; |
|
690 locality.SetAccuracy(dumAcc, -dumAcc); |
|
691 return KErrGeneral; |
|
692 } |
|
693 |
|
694 |
|
695 TInt TLocality_Negative_Accuracy_Set_HorNegative(TAny* /*aPtr*/) |
|
696 { |
|
697 const TReal32 dumAcc = TReal32(0.1); |
|
698 TLocality locality; |
|
699 locality.SetHorizontalAccuracy(-dumAcc); |
|
700 return KErrGeneral; |
|
701 } |
|
702 |
|
703 |
|
704 TInt TLocality_Negative_Accuracy_Set_VerNegative(TAny* /*aPtr*/) |
|
705 { |
|
706 const TReal32 dumAcc = TReal32(0.1); |
|
707 TLocality locality; |
|
708 locality.SetVerticalAccuracy(-dumAcc); |
|
709 return KErrGeneral; |
|
710 } |
|
711 |
|
712 |
|
713 void CDataClassesStep::TLocality_NegativeL() |
|
714 { |
|
715 DECLARE_ERROR_LOGGING; |
|
716 StandardPrepareL(); |
|
717 |
|
718 DO_PANIC_TEST_L(TLocality_Negative_Accuracy_Construct_HorAcc, |
|
719 KPosClientFault, EPositionBadAccuracy, KDefaultTestTimeout); |
|
720 DO_PANIC_TEST_L(TLocality_Negative_Accuracy_Construct_VerAcc, |
|
721 KPosClientFault, EPositionBadAccuracy, KDefaultTestTimeout); |
|
722 |
|
723 DO_PANIC_TEST_L(TLocality_Negative_Accuracy_Set_Both_HorNegative, |
|
724 KPosClientFault, EPositionBadAccuracy, KDefaultTestTimeout); |
|
725 DO_PANIC_TEST_L(TLocality_Negative_Accuracy_Set_Both_VerNegative, |
|
726 KPosClientFault, EPositionBadAccuracy, KDefaultTestTimeout); |
|
727 |
|
728 DO_PANIC_TEST_L(TLocality_Negative_Accuracy_Set_HorNegative, |
|
729 KPosClientFault, EPositionBadAccuracy, KDefaultTestTimeout); |
|
730 DO_PANIC_TEST_L(TLocality_Negative_Accuracy_Set_VerNegative, |
|
731 KPosClientFault, EPositionBadAccuracy, KDefaultTestTimeout); |
|
732 |
|
733 StandardCleanup(); |
|
734 } |
|
735 |
|
736 |
|
737 // |
|
738 // |
|
739 // TPosition |
|
740 // |
|
741 // |
|
742 |
|
743 // 2.5.1. Constructors |
|
744 void CDataClassesStep::TPosition_ConstructionL() |
|
745 { |
|
746 DECLARE_ERROR_LOGGING; |
|
747 StandardPrepareL(); |
|
748 |
|
749 // blank |
|
750 TPosition position; |
|
751 |
|
752 CHECK(position.Time() == TTime(0)); |
|
753 CHECK(Math::IsNaN(position.Latitude())); |
|
754 CHECK(Math::IsNaN(position.Longitude())); |
|
755 CHECK(Math::IsNaN(position.Altitude())); |
|
756 CHECK(Math::IsNaN(position.HorizontalAccuracy())); |
|
757 CHECK(Math::IsNaN(position.VerticalAccuracy())); |
|
758 |
|
759 // full |
|
760 |
|
761 const TReal64 dumLat = 11.111; |
|
762 const TReal64 dumLon = 22.222; |
|
763 const TReal32 dumAlt = TReal32(33.333); |
|
764 const TReal32 dumHorAcc = TReal32(0.444); |
|
765 const TReal32 dumVerAcc = TReal32(0.555); |
|
766 |
|
767 TTime dumTime; |
|
768 dumTime.HomeTime(); |
|
769 |
|
770 TCoordinate coordinate(dumLat, dumLon, dumAlt); |
|
771 TLocality locality(coordinate, dumHorAcc, dumVerAcc); |
|
772 position = TPosition(locality, dumTime); |
|
773 |
|
774 CHECK(position.Time() == dumTime); |
|
775 CHECK_REAL_EQUAL(position.Latitude(), dumLat); |
|
776 CHECK_REAL_EQUAL(position.Longitude(), dumLon); |
|
777 CHECK_REAL_EQUAL(position.Altitude(), dumAlt); |
|
778 CHECK_REAL_EQUAL(position.HorizontalAccuracy(), dumHorAcc); |
|
779 CHECK_REAL_EQUAL(position.VerticalAccuracy(), dumVerAcc); |
|
780 |
|
781 StandardCleanup(); |
|
782 } |
|
783 |
|
784 // 2.5.2. Setters/Getters (time) |
|
785 void CDataClassesStep::TPosition_SettersL() |
|
786 { |
|
787 DECLARE_ERROR_LOGGING; |
|
788 StandardPrepareL(); |
|
789 |
|
790 // time |
|
791 TTime dumTime; |
|
792 dumTime.HomeTime(); |
|
793 |
|
794 TPosition pos; |
|
795 pos.SetTime(dumTime); |
|
796 CHECK_EQUAL_(dumTime, pos.Time()); |
|
797 |
|
798 // current time |
|
799 TPosition position; |
|
800 position.SetCurrentTime(); |
|
801 |
|
802 TTime uniTime; |
|
803 uniTime.UniversalTime(); |
|
804 |
|
805 TTimeIntervalSeconds last; |
|
806 uniTime.SecondsFrom(position.Time(), last); |
|
807 CHECK(last <= TTimeIntervalSeconds(1)); |
|
808 |
|
809 StandardCleanup(); |
|
810 } |
|
811 |
|
812 |
|
813 // |
|
814 // |
|
815 // TPositionInfo |
|
816 // |
|
817 // |
|
818 |
|
819 // 3.1.1. TPositionInfo construction |
|
820 void CDataClassesStep::TPositionInfo_ConstructionL() |
|
821 { |
|
822 DECLARE_ERROR_LOGGING; |
|
823 StandardPrepareL(); |
|
824 |
|
825 TPositionInfo posInfo; |
|
826 |
|
827 // position |
|
828 TPosition pos; |
|
829 posInfo.GetPosition(pos); |
|
830 |
|
831 CHECK(Math::IsNaN(pos.Latitude())); |
|
832 CHECK(Math::IsNaN(pos.Longitude())); |
|
833 CHECK(Math::IsNaN(pos.Altitude())); |
|
834 CHECK(Math::IsNaN(pos.HorizontalAccuracy())); |
|
835 CHECK(Math::IsNaN(pos.VerticalAccuracy())); |
|
836 CHECK_EQUAL_(TTime(0), pos.Time()); |
|
837 |
|
838 // From Base |
|
839 |
|
840 // class type |
|
841 CHECK(posInfo.PositionClassType() == EPositionInfoClass); |
|
842 CHECK(posInfo.PositionClassSize() == sizeof(TPositionInfo)); |
|
843 |
|
844 // module id |
|
845 CHECK_EQUAL_((TInt)posInfo.ModuleId().iUid, (TInt)KPositionNullModuleId.iUid); |
|
846 |
|
847 // update info |
|
848 CHECK(posInfo.UpdateType() == EPositionUpdateGeneral); |
|
849 |
|
850 StandardCleanup(); |
|
851 } |
|
852 |
|
853 // 3.1.2. TPositionInfo modification |
|
854 void CDataClassesStep::TPositionInfo_ModificationL() |
|
855 { |
|
856 DECLARE_ERROR_LOGGING; |
|
857 StandardPrepareL(); |
|
858 |
|
859 const TReal64 dumLat = 11.111; |
|
860 const TReal64 dumLon = 22.222; |
|
861 const TReal32 dumAlt = TReal32(33.333); |
|
862 const TReal32 dumHorAcc = TReal32(0.444); |
|
863 const TReal32 dumVerAcc = TReal32(0.555); |
|
864 |
|
865 TTime dumTime; |
|
866 dumTime.HomeTime(); |
|
867 |
|
868 TPositionInfo posInfo; |
|
869 TCoordinate dumCoordinate = TCoordinate(dumLat, dumLon, dumAlt); |
|
870 TLocality dumLocality = TLocality(dumCoordinate, dumHorAcc, dumVerAcc); |
|
871 |
|
872 // position |
|
873 TPosition pos(dumLocality, dumTime); |
|
874 posInfo.SetPosition(pos); |
|
875 |
|
876 TPosition pos2; |
|
877 posInfo.GetPosition(pos2); |
|
878 |
|
879 CHECK_REAL_EQUAL(pos2.Latitude(), pos.Latitude()); |
|
880 CHECK_REAL_EQUAL(pos2.Longitude(), pos.Longitude()); |
|
881 CHECK_REAL_EQUAL(pos2.Altitude(), pos.Altitude()); |
|
882 CHECK_REAL_EQUAL(pos2.HorizontalAccuracy(), pos.HorizontalAccuracy()); |
|
883 CHECK_REAL_EQUAL(pos2.VerticalAccuracy(), pos.VerticalAccuracy()); |
|
884 CHECK_EQUAL_(pos2.Time(), pos.Time()); |
|
885 |
|
886 // From Base |
|
887 |
|
888 // module id |
|
889 |
|
890 const TPositionModuleId dumModId = {0x12345678}; |
|
891 posInfo.SetModuleId(dumModId); |
|
892 CHECK_EQUAL_((TInt)dumModId.iUid, (TInt)posInfo.ModuleId().iUid); |
|
893 |
|
894 // update info |
|
895 |
|
896 posInfo.SetUpdateType(EPositionUpdateUnknown); |
|
897 CHECK(posInfo.UpdateType() == EPositionUpdateUnknown); |
|
898 |
|
899 posInfo.SetUpdateType(EPositionUpdateGeneral); |
|
900 CHECK(posInfo.UpdateType() == EPositionUpdateGeneral); |
|
901 |
|
902 StandardCleanup(); |
|
903 } |
|
904 |
|
905 |
|
906 // |
|
907 // |
|
908 // Course classes |
|
909 // |
|
910 // |
|
911 |
|
912 // 4.1.1. Construction |
|
913 void CDataClassesStep::CourseClasses_ConstructionL() |
|
914 { |
|
915 DECLARE_ERROR_LOGGING; |
|
916 StandardPrepareL(); |
|
917 |
|
918 // course |
|
919 TCourse course; |
|
920 CHECK(Math::IsNaN(course.Speed())); |
|
921 CHECK(Math::IsNaN(course.Heading())); |
|
922 CHECK(Math::IsNaN(course.SpeedAccuracy())); |
|
923 CHECK(Math::IsNaN(course.HeadingAccuracy())); |
|
924 |
|
925 // course info |
|
926 TPositionCourseInfo courseInfo; |
|
927 CHECK(courseInfo.PositionClassType()==(EPositionInfoClass|EPositionCourseInfoClass)); |
|
928 CHECK_EQUAL_(courseInfo.PositionClassSize(), sizeof(TPositionCourseInfo)); |
|
929 |
|
930 CHECK_EQUAL_((TInt)courseInfo.ModuleId().iUid, (TInt)KPositionNullModuleId.iUid); |
|
931 CHECK(courseInfo.UpdateType() == EPositionUpdateGeneral); |
|
932 |
|
933 StandardCleanup(); |
|
934 } |
|
935 |
|
936 |
|
937 // 4.1.2. Modification |
|
938 void CDataClassesStep::CourseClasses_ModificationL() |
|
939 { |
|
940 DECLARE_ERROR_LOGGING; |
|
941 StandardPrepareL(); |
|
942 |
|
943 const TReal32 KDummyValue1 = (TReal32)43.342; |
|
944 const TReal32 KDummyValue2 = (TReal32)34.5236; |
|
945 const TReal32 KDummyValue3 = (TReal32)983.45; |
|
946 const TReal32 KDummyValue4 = (TReal32)12.432; |
|
947 |
|
948 TCourse course; |
|
949 course.SetSpeed(KDummyValue1); |
|
950 course.SetHeading(KDummyValue2); |
|
951 course.SetSpeedAccuracy(KDummyValue3); |
|
952 course.SetHeadingAccuracy(KDummyValue4); |
|
953 |
|
954 CHECK_REAL_EQUAL(course.Speed(), KDummyValue1); |
|
955 CHECK_REAL_EQUAL(course.Heading(), KDummyValue2); |
|
956 CHECK_REAL_EQUAL(course.SpeedAccuracy(), KDummyValue3); |
|
957 CHECK_REAL_EQUAL(course.HeadingAccuracy(), KDummyValue4); |
|
958 |
|
959 TCourse course2; //Use new course object so we can be sure data is transfered properly |
|
960 |
|
961 TPositionCourseInfo courseInfo; |
|
962 courseInfo.SetCourse(course); |
|
963 courseInfo.GetCourse(course2); |
|
964 |
|
965 CHECK_REAL_EQUAL(course2.Speed(), KDummyValue1); |
|
966 CHECK_REAL_EQUAL(course2.Heading(), KDummyValue2); |
|
967 CHECK_REAL_EQUAL(course2.SpeedAccuracy(), KDummyValue3); |
|
968 CHECK_REAL_EQUAL(course2.HeadingAccuracy(), KDummyValue4); |
|
969 |
|
970 StandardCleanup(); |
|
971 } |
|
972 |
|
973 |
|
974 // 4.1.3. NaNs |
|
975 TInt CourseClasses_Setters_with_NANs(TAny* /*aPtr*/) |
|
976 { |
|
977 TRealX nan; |
|
978 nan.SetNaN(); |
|
979 |
|
980 TCourse course; |
|
981 course.SetSpeed(nan); |
|
982 course.SetHeading(nan); |
|
983 course.SetCourse(nan); |
|
984 course.SetSpeedAccuracy(nan); |
|
985 course.SetHeadingAccuracy(nan); |
|
986 course.SetCourseAccuracy(nan); |
|
987 |
|
988 CHECK_PANIC(Math::IsNaN(course.Speed())); |
|
989 CHECK_PANIC(Math::IsNaN(course.Heading())); |
|
990 CHECK_PANIC(Math::IsNaN(course.Course())); |
|
991 CHECK_PANIC(Math::IsNaN(course.SpeedAccuracy())); |
|
992 CHECK_PANIC(Math::IsNaN(course.HeadingAccuracy())); |
|
993 CHECK_PANIC(Math::IsNaN(course.CourseAccuracy())); |
|
994 |
|
995 return KErrNone; |
|
996 } |
|
997 |
|
998 |
|
999 void CDataClassesStep::CourseClasses_Modification2L() |
|
1000 { |
|
1001 DECLARE_ERROR_LOGGING; |
|
1002 StandardPrepareL(); |
|
1003 |
|
1004 DO_PANIC_TEST_L(CourseClasses_Setters_with_NANs, |
|
1005 KNoClientFault, KErrNone, KDefaultTestTimeout); |
|
1006 |
|
1007 StandardCleanup(); |
|
1008 } |
|
1009 |
|
1010 |
|
1011 // 4.1.4. Invalid values |
|
1012 TInt CourseClasses_Invalid_Input_HeadAcc(TAny* /*aPtr*/) |
|
1013 { |
|
1014 TCourse course; |
|
1015 course.SetHeadingAccuracy(TReal32(-0.1)); |
|
1016 return KErrGeneral; |
|
1017 } |
|
1018 |
|
1019 |
|
1020 TInt CourseClasses_Invalid_Input_SpeedAcc(TAny* /*aPtr*/) |
|
1021 { |
|
1022 TCourse course; |
|
1023 course.SetSpeedAccuracy(TReal32(-0.1)); |
|
1024 return KErrGeneral; |
|
1025 } |
|
1026 |
|
1027 |
|
1028 void CDataClassesStep::CourseClasses_InvalidL() |
|
1029 { |
|
1030 DECLARE_ERROR_LOGGING; |
|
1031 StandardPrepareL(); |
|
1032 |
|
1033 DO_PANIC_TEST_L(CourseClasses_Invalid_Input_HeadAcc, |
|
1034 KPosClientFault, EPositionBadAccuracy, KDefaultTestTimeout); |
|
1035 |
|
1036 DO_PANIC_TEST_L(CourseClasses_Invalid_Input_SpeedAcc, |
|
1037 KPosClientFault, EPositionBadAccuracy, KDefaultTestTimeout); |
|
1038 |
|
1039 StandardCleanup(); |
|
1040 } |
|
1041 |
|
1042 // |
|
1043 // |
|
1044 // Satellite classes |
|
1045 // |
|
1046 // |
|
1047 |
|
1048 // 4.3.1. Construction |
|
1049 void CDataClassesStep::SatelliteClasses_ConstructionL() |
|
1050 { |
|
1051 DECLARE_ERROR_LOGGING; |
|
1052 StandardPrepareL(); |
|
1053 |
|
1054 // satellite |
|
1055 TSatelliteData satData; |
|
1056 |
|
1057 CHECK_EQUAL_(-1, satData.SatelliteId()); |
|
1058 CHECK(Math::IsNaN(satData.Azimuth())); |
|
1059 CHECK(Math::IsNaN(satData.Elevation())); |
|
1060 CHECK(!satData.IsUsed()); |
|
1061 CHECK_EQUAL_(0, satData.SignalStrength()); |
|
1062 |
|
1063 //Sizeof(class) not always same in emulator and hardware as alignment restriction in hardware. |
|
1064 #if defined(_DEBUG) |
|
1065 // Check the size of the TPositionSatelliteInfo class is unchanged |
|
1066 CHECK_EQUAL_(KPositionSatelliteInfoSize, sizeof(TPositionSatelliteInfo)); |
|
1067 #endif |
|
1068 |
|
1069 // satellite info |
|
1070 TPositionSatelliteInfo satInfo; |
|
1071 |
|
1072 CHECK_EQUAL_(KErrNotFound, satInfo.GetSatelliteData(0, satData)); |
|
1073 CHECK_EQUAL_(0, satInfo.NumSatellitesInView()); |
|
1074 CHECK_EQUAL_(0, satInfo.NumSatellitesUsed()); |
|
1075 CHECK(TTime(0) == satInfo.SatelliteTime()); |
|
1076 CHECK(Math::IsNaN(satInfo.HorizontalDoP())); |
|
1077 CHECK(Math::IsNaN(satInfo.VerticalDoP())); |
|
1078 CHECK(Math::IsNaN(satInfo.TimeDoP())); |
|
1079 |
|
1080 StandardCleanup(); |
|
1081 } |
|
1082 |
|
1083 |
|
1084 // 4.3.2. Properties |
|
1085 void CDataClassesStep::SatelliteClasses_PropertiesL() |
|
1086 { |
|
1087 DECLARE_ERROR_LOGGING; |
|
1088 StandardPrepareL(); |
|
1089 |
|
1090 TSatelliteData satData; |
|
1091 |
|
1092 const TInt dumSatelliteId = 11111; |
|
1093 const TInt dumSignalStrength = 22222; |
|
1094 const TReal32 dumAzimuth = TReal32(234.2345); |
|
1095 const TReal32 dumElevation = TReal32(4745.1231); |
|
1096 |
|
1097 satData.SetSignalStrength(dumSignalStrength); |
|
1098 satData.SetSatelliteId(dumSatelliteId); |
|
1099 satData.SetAzimuth(dumAzimuth); |
|
1100 satData.SetElevation(dumElevation); |
|
1101 |
|
1102 CHECK_EQUAL_(dumSatelliteId, satData.SatelliteId()); |
|
1103 CHECK_EQUAL_(dumSignalStrength, satData.SignalStrength()); |
|
1104 CHECK_REAL_EQUAL(dumAzimuth, satData.Azimuth()); |
|
1105 CHECK_REAL_EQUAL(dumElevation, satData.Elevation()); |
|
1106 |
|
1107 satData.SetIsUsed(ETrue); |
|
1108 CHECK(satData.IsUsed()); |
|
1109 satData.SetIsUsed(EFalse); |
|
1110 CHECK(!satData.IsUsed()); |
|
1111 |
|
1112 TPositionSatelliteInfo satInfo; |
|
1113 |
|
1114 const TTime dumSatTime(TInt64(54)); |
|
1115 const TReal32 dumHorzDoP = (TReal32) 345.2131; |
|
1116 const TReal32 dumVertDoP = (TReal32) 34.1; |
|
1117 const TReal32 dumTimeDoP = (TReal32) 876.68; |
|
1118 |
|
1119 satInfo.SetSatelliteTime(dumSatTime); |
|
1120 satInfo.SetHorizontalDoP(dumHorzDoP); |
|
1121 satInfo.SetVerticalDoP(dumVertDoP); |
|
1122 satInfo.SetTimeDoP(dumTimeDoP); |
|
1123 |
|
1124 CHECK_REAL_EQUAL(dumHorzDoP, satInfo.HorizontalDoP()); |
|
1125 CHECK_REAL_EQUAL(dumVertDoP, satInfo.VerticalDoP()); |
|
1126 CHECK_REAL_EQUAL(dumTimeDoP, satInfo.TimeDoP()); |
|
1127 CHECK_EQUAL_( dumSatTime, satInfo.SatelliteTime()); |
|
1128 |
|
1129 TPositionExtendedSatelliteInfo extSatInfo; |
|
1130 TGpsTimingMeasurementData gpsTimingData; |
|
1131 |
|
1132 // all max values for UTran/Fdd |
|
1133 const TInt dumGpsTocMs = (TInt) 16383; |
|
1134 const TUint dumGpsTocLs = (TUint) 4294967295UL; |
|
1135 const TInt dumRefId = (TInt) 511; |
|
1136 const TInt dumSfn = (TInt) 4095; |
|
1137 |
|
1138 gpsTimingData.SetDataType(TGpsTimingMeasurementData::EGpsTimingDataTypeUtran); |
|
1139 gpsTimingData.SetNetworkMode(TGpsTimingMeasurementData::ENetworkModeFdd); |
|
1140 gpsTimingData.SetGPSTimingOfCellMsPart(dumGpsTocMs); |
|
1141 gpsTimingData.SetGPSTimingOfCellLsPart(dumGpsTocLs); |
|
1142 gpsTimingData.SetReferenceIdentity(dumRefId); |
|
1143 gpsTimingData.SetSfn(dumSfn); |
|
1144 |
|
1145 extSatInfo.SetGpsTimingData(gpsTimingData); |
|
1146 |
|
1147 TGpsTimingMeasurementData gpsTimingDataReturned; |
|
1148 CHECK_EQUAL_(KErrNone, extSatInfo.GetGpsTimingData(gpsTimingDataReturned)); |
|
1149 |
|
1150 CHECK_EQUAL_(TGpsTimingMeasurementData::EGpsTimingDataTypeUtran, gpsTimingData.DataType()); |
|
1151 CHECK_EQUAL_(TGpsTimingMeasurementData::ENetworkModeFdd, gpsTimingData.NetworkMode()); |
|
1152 CHECK_EQUAL_(dumGpsTocMs, gpsTimingDataReturned.GPSTimingOfCellMsPart()); |
|
1153 CHECK_EQUAL_(dumGpsTocLs, gpsTimingDataReturned.GPSTimingOfCellLsPart()); |
|
1154 CHECK_EQUAL_(dumRefId, gpsTimingDataReturned.ReferenceIdentity()); |
|
1155 CHECK_EQUAL_(dumSfn, gpsTimingDataReturned.Sfn()); |
|
1156 |
|
1157 |
|
1158 TGpsTimingMeasurementData gpsTimingData2; |
|
1159 |
|
1160 // all max values for GSM |
|
1161 const TInt refFrameMsb = (TInt) 63; |
|
1162 const TInt gpsTowSubms = (TInt) 9999; |
|
1163 const TInt deltaTow = (TInt) 127; |
|
1164 const TInt gpsRefTimeUncert = (TInt) 127; |
|
1165 |
|
1166 gpsTimingData2.SetDataType(TGpsTimingMeasurementData::EGpsTimingDataTypeGsm); |
|
1167 |
|
1168 // check default GSM values |
|
1169 CHECK_EQUAL_(TGpsTimingMeasurementData::EGpsTimingDataTypeGsm, gpsTimingData2.DataType()); |
|
1170 CHECK_EQUAL_(0, gpsTimingData2.ReferenceFrameMsb()); |
|
1171 CHECK_EQUAL_(KErrNotFound, gpsTimingData2.GpsTowSubms()); |
|
1172 CHECK_EQUAL_(KErrNotFound, gpsTimingData2.DeltaTow()); |
|
1173 CHECK_EQUAL_(KErrNotFound, gpsTimingData2.GpsReferenceTimeUncertainty()); |
|
1174 |
|
1175 // update values |
|
1176 gpsTimingData2.SetReferenceFrameMsb(refFrameMsb); |
|
1177 gpsTimingData2.SetGpsTowSubms(gpsTowSubms); |
|
1178 gpsTimingData2.SetDeltaTow(deltaTow); |
|
1179 gpsTimingData2.SetGpsReferenceTimeUncertainty(gpsRefTimeUncert); |
|
1180 |
|
1181 CHECK_EQUAL_(refFrameMsb, gpsTimingData2.ReferenceFrameMsb()); |
|
1182 CHECK_EQUAL_(gpsTowSubms, gpsTimingData2.GpsTowSubms()); |
|
1183 CHECK_EQUAL_(deltaTow, gpsTimingData2.DeltaTow()); |
|
1184 CHECK_EQUAL_(gpsRefTimeUncert, gpsTimingData2.GpsReferenceTimeUncertainty()); |
|
1185 |
|
1186 |
|
1187 StandardCleanup(); |
|
1188 } |
|
1189 |
|
1190 |
|
1191 // 4.3.3. Properties with NANs |
|
1192 void CDataClassesStep::SatelliteClasses_Properties2L() |
|
1193 { |
|
1194 DECLARE_ERROR_LOGGING; |
|
1195 StandardPrepareL(); |
|
1196 |
|
1197 TRealX nan; |
|
1198 nan.SetNaN(); |
|
1199 |
|
1200 TSatelliteData satData; |
|
1201 |
|
1202 const TReal32 dumAzimuth = nan; |
|
1203 const TReal32 dumElevation = nan; |
|
1204 |
|
1205 satData.SetAzimuth(dumAzimuth); |
|
1206 satData.SetElevation(dumElevation); |
|
1207 |
|
1208 CHECK(Math::IsNaN(satData.Azimuth())); |
|
1209 CHECK(Math::IsNaN(satData.Elevation())); |
|
1210 |
|
1211 TPositionSatelliteInfo satInfo; |
|
1212 |
|
1213 const TReal32 dumHorzDoP = nan; |
|
1214 const TReal32 dumVertDoP = nan; |
|
1215 const TReal32 dumTimeDoP = nan; |
|
1216 |
|
1217 satInfo.SetHorizontalDoP(dumHorzDoP); |
|
1218 satInfo.SetVerticalDoP(dumVertDoP); |
|
1219 satInfo.SetTimeDoP(dumTimeDoP); |
|
1220 |
|
1221 CHECK(Math::IsNaN(satInfo.HorizontalDoP())); |
|
1222 CHECK(Math::IsNaN(satInfo.VerticalDoP())); |
|
1223 CHECK(Math::IsNaN(satInfo.TimeDoP())); |
|
1224 |
|
1225 StandardCleanup(); |
|
1226 } |
|
1227 |
|
1228 |
|
1229 // 4.3.4. TPositionSatelliteInfo accepts TSatelliteData |
|
1230 void CDataClassesStep::SatelliteClasses_InfoL() |
|
1231 { |
|
1232 DECLARE_ERROR_LOGGING; |
|
1233 StandardPrepareL(); |
|
1234 |
|
1235 TSatelliteData satData; |
|
1236 |
|
1237 const TInt dumSatelliteId = 11111; |
|
1238 const TInt dumSignalStrength = 22222; |
|
1239 const TReal32 dumAzimuth = TReal32(111.111); |
|
1240 const TReal32 dumElevation = TReal32(222.222); |
|
1241 |
|
1242 satData.SetSignalStrength(dumSignalStrength); |
|
1243 satData.SetSatelliteId(dumSatelliteId); |
|
1244 satData.SetAzimuth(dumAzimuth); |
|
1245 satData.SetElevation(dumElevation); |
|
1246 satData.SetIsUsed(ETrue); |
|
1247 |
|
1248 TPositionSatelliteInfo satInfo; |
|
1249 TSatelliteData satData2; |
|
1250 |
|
1251 // append data |
|
1252 satInfo.AppendSatelliteData(satData); |
|
1253 |
|
1254 CHECK_EQUAL_(1, satInfo.NumSatellitesInView()); //Have added 1 satellite |
|
1255 CHECK_EQUAL_(KErrNone, satInfo.GetSatelliteData(0, satData2)); |
|
1256 |
|
1257 // check data |
|
1258 CHECK_EQUAL_(dumSatelliteId, satData2.SatelliteId()); |
|
1259 CHECK_EQUAL_(dumSignalStrength, satData2.SignalStrength()); |
|
1260 CHECK_REAL_EQUAL(dumAzimuth, satData2.Azimuth()); |
|
1261 CHECK_REAL_EQUAL(dumElevation, satData2.Elevation()); |
|
1262 CHECK(satData2.IsUsed()); |
|
1263 |
|
1264 StandardCleanup(); |
|
1265 } |
|
1266 |
|
1267 |
|
1268 // |
|
1269 // Satellites list |
|
1270 // |
|
1271 |
|
1272 // 4.4.1. Satellite data list integrity |
|
1273 void CDataClassesStep::SatelliteClasses_SatelliteInfoL() |
|
1274 { |
|
1275 DECLARE_ERROR_LOGGING; |
|
1276 StandardPrepareL(); |
|
1277 |
|
1278 TSatelliteData satData, satData2; |
|
1279 TPositionSatelliteInfo satInfo; |
|
1280 |
|
1281 // append data |
|
1282 for (TInt ii = 0; (TUint)ii < KPositionMaxSatellitesInView; ii++) |
|
1283 { |
|
1284 TBool isUsed = ( ii % 2 != 0 ); |
|
1285 |
|
1286 satData.SetIsUsed( isUsed ); |
|
1287 |
|
1288 CHECK(KErrNotFound == satInfo.GetSatelliteData(ii, satData2)); |
|
1289 CHECK_EQUAL_(KErrNone, satInfo.AppendSatelliteData(satData)); |
|
1290 |
|
1291 CHECK_EQUAL_(ii + 1, satInfo.NumSatellitesInView()); //Have added 1 satellite |
|
1292 CHECK_EQUAL_((ii+1)/2, satInfo.NumSatellitesUsed()); |
|
1293 |
|
1294 CHECK_EQUAL_(KErrNone, satInfo.GetSatelliteData(ii, satData2)); |
|
1295 CHECK_EQUAL_(isUsed, satData2.IsUsed()); |
|
1296 } |
|
1297 |
|
1298 satInfo.ClearSatellitesInView(); |
|
1299 CHECK_EQUAL_(KErrNotFound, satInfo.GetSatelliteData(0, satData2)); |
|
1300 CHECK_EQUAL_(0, satInfo.NumSatellitesInView()); |
|
1301 CHECK_EQUAL_(0, satInfo.NumSatellitesUsed()); |
|
1302 |
|
1303 StandardCleanup(); |
|
1304 } |
|
1305 |
|
1306 // 4.4.2. Too much SatelliteData is added |
|
1307 void CDataClassesStep::SatelliteClasses_OverflowL() |
|
1308 { |
|
1309 DECLARE_ERROR_LOGGING; |
|
1310 StandardPrepareL(); |
|
1311 |
|
1312 TPositionSatelliteInfo satInfo; |
|
1313 TSatelliteData satData; |
|
1314 for (TInt i=0; i < static_cast<TInt>(KPositionMaxSatellitesInView); i++) |
|
1315 { |
|
1316 satData.SetSatelliteId(i); |
|
1317 CHECK_EQUAL_(KErrNone, satInfo.AppendSatelliteData(satData)); |
|
1318 } |
|
1319 |
|
1320 CHECK_EQUAL_(KErrOverflow, satInfo.AppendSatelliteData(satData)); |
|
1321 |
|
1322 StandardCleanup(); |
|
1323 } |
|
1324 void CDataClassesStep::GpsMeasurementClasses_PropertiesL() |
|
1325 { |
|
1326 DECLARE_ERROR_LOGGING; |
|
1327 StandardPrepareL(); |
|
1328 |
|
1329 // Check the size of the TPositionGpsMeasurementInfo class is unchanged |
|
1330 CHECK_EQUAL_(KPositionGpsMeasurementInfoSize, sizeof(TPositionGpsMeasurementInfo)); |
|
1331 |
|
1332 TPositionGpsMeasurementInfo gpsMeasurementInfo; |
|
1333 TGpsTimingMeasurementData gpsTimingData; |
|
1334 |
|
1335 // all max values for UTran/Fdd |
|
1336 const TInt dumGpsTocMs = (TInt) 16383; |
|
1337 const TUint dumGpsTocLs = (TUint) 4294967295UL; |
|
1338 const TInt dumRefId = (TInt) 511; |
|
1339 const TInt dumSfn = (TInt) 4095; |
|
1340 |
|
1341 gpsTimingData.SetDataType(TGpsTimingMeasurementData::EGpsTimingDataTypeUtran); |
|
1342 gpsTimingData.SetNetworkMode(TGpsTimingMeasurementData::ENetworkModeFdd); |
|
1343 gpsTimingData.SetGPSTimingOfCellMsPart(dumGpsTocMs); |
|
1344 gpsTimingData.SetGPSTimingOfCellLsPart(dumGpsTocLs); |
|
1345 gpsTimingData.SetReferenceIdentity(dumRefId); |
|
1346 gpsTimingData.SetSfn(dumSfn); |
|
1347 |
|
1348 gpsMeasurementInfo.SetGpsTimingData(gpsTimingData); |
|
1349 |
|
1350 TGpsTimingMeasurementData gpsTimingDataReturned; |
|
1351 CHECK_EQUAL_(KErrNone, gpsMeasurementInfo.GetGpsTimingData(gpsTimingDataReturned)); |
|
1352 |
|
1353 CHECK_EQUAL_(TGpsTimingMeasurementData::EGpsTimingDataTypeUtran, gpsTimingData.DataType()); |
|
1354 CHECK_EQUAL_(TGpsTimingMeasurementData::ENetworkModeFdd, gpsTimingData.NetworkMode()); |
|
1355 CHECK_EQUAL_(dumGpsTocMs, gpsTimingDataReturned.GPSTimingOfCellMsPart()); |
|
1356 CHECK_EQUAL_(dumGpsTocLs, gpsTimingDataReturned.GPSTimingOfCellLsPart()); |
|
1357 CHECK_EQUAL_(dumRefId, gpsTimingDataReturned.ReferenceIdentity()); |
|
1358 CHECK_EQUAL_(dumSfn, gpsTimingDataReturned.Sfn()); |
|
1359 StandardCleanup(); |
|
1360 } |
|
1361 |