|
1 /* |
|
2 * Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * ?description_line |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // INCLUDES |
|
21 |
|
22 #include "FT_CPosTp5.h" |
|
23 #include <EPos_CPosLandmark.h> |
|
24 #include <LbsPosition.h> |
|
25 #include <e32def.h> |
|
26 #include <e32std.h> |
|
27 #include <e32math.h> |
|
28 |
|
29 |
|
30 #include "FT_LandmarkConstants.h" |
|
31 |
|
32 // CONSTANTS |
|
33 // _LIT(KGetNameErr, "GetLandmarks name returns incorrect error code"); |
|
34 _LIT(KNameErr, "Landmark name is incorrect"); |
|
35 _LIT(KIdErr, "Landmark Id is incorrect"); |
|
36 _LIT(KLongitudeErr, "Longitude is incorrect"); |
|
37 |
|
38 _LIT(KLatitudeErr, "Latitude is incorrect"); |
|
39 _LIT(KHorizontalAccErr, "Horizontal accuracy is incorrect"); |
|
40 _LIT(KVerticalAccErr, "Vertical accuracy is incorrect"); |
|
41 _LIT(KAltitudeErr, "Altitude is incorrect"); |
|
42 _LIT(KNumOfAvailablePositionFieldsErr, "NumOfAvailablePositionFields is incorrect"); |
|
43 _LIT(KNumOfategoriesErr, "Number of categories is incorrect"); |
|
44 _LIT(KCoverageRadiusErr, "CoverageRadius is incorrect"); |
|
45 _LIT(KIconIndexErr, "Icon index is incorrect"); |
|
46 _LIT(KIconMaskIndexErr, "Icon MaskIndex is incorrect"); |
|
47 _LIT(KMbmFileNameErr, "MbmFileName is incorrect"); |
|
48 _LIT(KDescriptionErr, "Description is incorrect"); |
|
49 _LIT(KPositionFieldErr, "Error in positions fields"); |
|
50 |
|
51 _LIT(KNameTp5, "Lm-Tp5"); |
|
52 |
|
53 // ================= MEMBER FUNCTIONS ======================= |
|
54 |
|
55 |
|
56 // --------------------------------------------------------- |
|
57 // CPosTp5::StartL |
|
58 // |
|
59 // (other items were commented in a header). |
|
60 // --------------------------------------------------------- |
|
61 // |
|
62 void CPosTp5::StartL() |
|
63 { |
|
64 _LIT(KNameTp5, "Lm-Tp5"); |
|
65 RemoveDefaultDbL(); |
|
66 CPosLandmark* landmark = CreateLandmarkLC(KNameTp5); |
|
67 |
|
68 CheckGetMethodsL(landmark); |
|
69 |
|
70 CheckRemoveMethodsL(landmark); |
|
71 |
|
72 CheckFieldsMaxLengthL(); |
|
73 |
|
74 CleanupStack::PopAndDestroy(); // landmark |
|
75 |
|
76 CheckNaNErrorL(); |
|
77 } |
|
78 |
|
79 // --------------------------------------------------------- |
|
80 // CPosTp5::CheckGetMethods |
|
81 // |
|
82 // (other items were commented in a header). |
|
83 // --------------------------------------------------------- |
|
84 // |
|
85 void CPosTp5::CheckGetMethodsL(CPosLandmark* aLandmark) |
|
86 { |
|
87 |
|
88 TPtrC landmarkName; |
|
89 aLandmark->GetLandmarkName(landmarkName); |
|
90 AssertTrueSecL(landmarkName.Compare(KNameTp5) == KErrNone, KNameErr); |
|
91 AssertTrueSecL(aLandmark->LandmarkId() == 0, KIdErr); |
|
92 |
|
93 CPosLandmarkDatabase* lmd = OpenDatabaseLC(); |
|
94 TPosLmItemId id=lmd->AddLandmarkL(*aLandmark); |
|
95 AssertTrueSecL(aLandmark->LandmarkId() == id, KIdErr); |
|
96 |
|
97 TLocality loc2; |
|
98 aLandmark->GetPosition(loc2); |
|
99 AssertTrueSecL(loc2.Longitude() == KLongitude, KLongitudeErr); |
|
100 AssertTrueSecL(loc2.Latitude() == KLatitude, KLatitudeErr); |
|
101 AssertTrueSecL(loc2.HorizontalAccuracy() == KHorizontalAcc, KHorizontalAccErr); |
|
102 AssertTrueSecL(loc2.VerticalAccuracy() == KVerticalAcc, KVerticalAccErr); |
|
103 AssertTrueSecL(loc2.Altitude() == KAltitude, KAltitudeErr); |
|
104 |
|
105 TReal32 r; |
|
106 aLandmark->GetCoverageRadius(r); |
|
107 AssertTrueSecL(r == KCoverageRadius, KCoverageRadiusErr); |
|
108 |
|
109 TPtrC mbmFileName; |
|
110 TInt index; |
|
111 TInt indexMask; |
|
112 aLandmark->GetIcon(mbmFileName, index, indexMask); |
|
113 AssertTrueSecL(mbmFileName.Compare(KMbmFileName) == KErrNone, KMbmFileNameErr); |
|
114 AssertTrueSecL(index == KIconIndex, KIconIndexErr); |
|
115 AssertTrueSecL(indexMask == KIconMaskIndex, KIconMaskIndexErr); |
|
116 |
|
117 TPtrC desc; |
|
118 aLandmark->GetLandmarkDescription(desc); |
|
119 AssertTrueSecL(desc.Compare(KDescription) == KErrNone, KDescriptionErr); |
|
120 AssertTrueSecL(KNoPosFields == aLandmark->NumOfAvailablePositionFields(), KNumOfAvailablePositionFieldsErr); |
|
121 |
|
122 TPositionFieldId posFieldId = aLandmark->FirstPositionFieldId(); |
|
123 for (TUint i=0; i<KNoPosFields-1; i++) |
|
124 { |
|
125 CheckPositionFieldL(*aLandmark, posFieldId); |
|
126 posFieldId=aLandmark->NextPositionFieldId(posFieldId); |
|
127 } |
|
128 |
|
129 RArray<TPosLmItemId> categories; |
|
130 CleanupClosePushL(categories); |
|
131 aLandmark->GetCategoriesL(categories); |
|
132 AssertTrueSecL(categories.Count() == KNoCategories, KNumOfategoriesErr); |
|
133 CleanupStack::PopAndDestroy(2,lmd); |
|
134 |
|
135 } |
|
136 |
|
137 // --------------------------------------------------------- |
|
138 // CPosTp5::CheckRemoveMethodsL |
|
139 // |
|
140 // (other items were commented in a header). |
|
141 // --------------------------------------------------------- |
|
142 // |
|
143 void CPosTp5::CheckRemoveMethodsL(CPosLandmark* aLandmark) |
|
144 { |
|
145 aLandmark->RemoveLandmarkAttributes(CPosLandmark::ENoAttribute); |
|
146 aLandmark->RemoveLandmarkAttributes(CPosLandmark::EPosition); |
|
147 aLandmark->RemoveLandmarkAttributes(CPosLandmark::ECoverageRadius); |
|
148 aLandmark->RemoveLandmarkAttributes(CPosLandmark::ECategoryInfo); |
|
149 aLandmark->RemoveLandmarkAttributes(CPosLandmark::EIcon); |
|
150 aLandmark->RemoveLandmarkAttributes(CPosLandmark::EDescription); |
|
151 |
|
152 CheckRemovedL(aLandmark); |
|
153 _LIT(KLandmarkName, "Nisse"); |
|
154 CPosLandmark* landmark = CreateLandmarkLC(KLandmarkName); |
|
155 landmark->RemoveLandmarkAttributes(CPosLandmark::EAllAttributes); |
|
156 CheckRemovedL(landmark); |
|
157 |
|
158 |
|
159 TUint16 tmp = (TUint16)EPositionFieldMediaLinksStart; |
|
160 landmark->RemovePositionField(EPositionFieldMediaLinksStart); |
|
161 landmark->RemovePositionField(EPositionFieldCountry); |
|
162 landmark->RemovePositionField(EPositionFieldHorizontalSpeed); |
|
163 // FrBo Below has been removed |
|
164 |
|
165 landmark->RemovePositionField(EPositionFieldMediaLinks); |
|
166 landmark->RemovePositionField(EPositionFieldMediaLinksStart); |
|
167 landmark->RemovePositionField(++tmp); |
|
168 landmark->RemovePositionField(++tmp); |
|
169 landmark->RemovePositionField(EPositionFieldIdLast); |
|
170 |
|
171 TPtrC ptr; |
|
172 AssertTrueSecL(landmark->GetPositionField(EPositionFieldMediaLinksStart, ptr) == KErrNotFound, KPositionFieldErr); |
|
173 AssertTrueSecL(landmark->GetPositionField(EPositionFieldCountry, ptr) == KErrNotFound, KPositionFieldErr); |
|
174 AssertTrueSecL(landmark->GetPositionField(EPositionFieldHorizontalSpeed, ptr) == KErrNotFound, KPositionFieldErr); |
|
175 // FrBo Below has been removed |
|
176 |
|
177 AssertTrueSecL(landmark->GetPositionField(EPositionFieldMediaLinks, ptr) == KErrNotFound, KPositionFieldErr); |
|
178 AssertTrueSecL(landmark->GetPositionField(EPositionFieldMediaLinksStart, ptr) == KErrNotFound, KPositionFieldErr); |
|
179 AssertTrueSecL(landmark->GetPositionField(++tmp, ptr) == KErrNotFound, KPositionFieldErr); |
|
180 AssertTrueSecL(landmark->GetPositionField(++tmp, ptr) == KErrNotFound, KPositionFieldErr); |
|
181 AssertTrueSecL(landmark->GetPositionField(EPositionFieldIdLast, ptr) == KErrNotFound, KPositionFieldErr); |
|
182 |
|
183 // Remove some non-existing fields, nothing should happen |
|
184 landmark->RemovePositionField(6000); |
|
185 AssertTrueSecL(landmark->GetPositionField(6000, ptr) == KErrNotFound, KPositionFieldErr); |
|
186 landmark->RemovePositionField(6001); |
|
187 AssertTrueSecL(landmark->GetPositionField(6001, ptr) == KErrNotFound, KPositionFieldErr); |
|
188 |
|
189 CleanupStack::PopAndDestroy(); // landmark |
|
190 |
|
191 } |
|
192 |
|
193 // --------------------------------------------------------- |
|
194 // CPosTp5::CheckRemovedL |
|
195 // |
|
196 // (other items were commented in a header). |
|
197 // --------------------------------------------------------- |
|
198 // |
|
199 void CPosTp5::CheckRemovedL(CPosLandmark* aLandmark) |
|
200 { |
|
201 _LIT(KPositionRemovedErr, "GetPosition is not returning an error code when position is not set"); |
|
202 TLocality loc; |
|
203 AssertTrueSecL(aLandmark->GetPosition(loc) == KErrNotFound, KPositionRemovedErr); |
|
204 |
|
205 RArray<TPosLmItemId> categories; |
|
206 CleanupClosePushL(categories); |
|
207 aLandmark->GetCategoriesL(categories); |
|
208 AssertTrueSecL(categories.Count() == 0, KNumOfategoriesErr); |
|
209 CleanupStack::PopAndDestroy(&categories); |
|
210 |
|
211 TReal32 r; |
|
212 AssertTrueSecL(aLandmark->GetCoverageRadius(r) == KErrNotFound, KCoverageRadiusErr); |
|
213 |
|
214 TPtrC mbmFileName; |
|
215 TInt index; |
|
216 TInt indexMask; |
|
217 AssertTrueSecL(aLandmark->GetIcon(mbmFileName, index, indexMask) == KErrNotFound, KMbmFileNameErr); |
|
218 |
|
219 TPtrC desc; |
|
220 AssertTrueSecL(aLandmark->GetLandmarkDescription(desc) == KErrNotFound, KDescriptionErr); |
|
221 } |
|
222 |
|
223 //--------------------------------------------------------- |
|
224 // CPosTp5::CheckPositionFieldIdL |
|
225 // |
|
226 // (other items were commented in a header). |
|
227 // --------------------------------------------------------- |
|
228 // |
|
229 void CPosTp5::CheckPositionFieldL(const CPosLandmark& aLandmark, const TUint16 aId) |
|
230 { |
|
231 |
|
232 _LIT(KPositionFieldIdErr, "PositionFieldId is incorrect"); |
|
233 _LIT(KComparePositionFieldValueErr, "PositionField value is different from set value"); |
|
234 |
|
235 TUint16 tmp = (TUint16)EPositionFieldMediaLinksStart; |
|
236 TBuf<100> buf; |
|
237 buf.Format(_L("Looking for id:%d "),aId); |
|
238 iLog->Log(buf); |
|
239 |
|
240 TPtrC value; |
|
241 if (aId == EPositionFieldCountry) |
|
242 { |
|
243 aLandmark.GetPositionField(aId, value); |
|
244 AssertTrueSecL(value.Compare(KCountry) == KErrNone, KComparePositionFieldValueErr); |
|
245 } |
|
246 else if (aId == EPositionFieldHorizontalSpeed) |
|
247 { |
|
248 aLandmark.GetPositionField(aId, value); |
|
249 AssertTrueSecL(value.Compare(KHorizontalSpeed) == KErrNone, KComparePositionFieldValueErr); |
|
250 } |
|
251 |
|
252 else if (aId == EPositionFieldMediaLinks) |
|
253 { |
|
254 aLandmark.GetPositionField(aId, value); |
|
255 AssertTrueSecL(value.Compare(KMediaLinks) == KErrNone, KComparePositionFieldValueErr); |
|
256 } |
|
257 else if (aId == EPositionFieldMediaLinksStart) |
|
258 { |
|
259 aLandmark.GetPositionField(aId, value); |
|
260 AssertTrueSecL(value.Compare(KMediaLink1) == KErrNone, KComparePositionFieldValueErr); |
|
261 iLog->Log(_L("EPositionFieldMediaLinksStart")); |
|
262 } |
|
263 else if (aId == EPositionFieldIdLast) |
|
264 { |
|
265 aLandmark.GetPositionField(aId, value); |
|
266 AssertTrueSecL(value.Compare(KLast) == KErrNone, KComparePositionFieldValueErr); |
|
267 } |
|
268 else if (aId == (tmp+1)) |
|
269 { |
|
270 aLandmark.GetPositionField(aId, value); |
|
271 AssertTrueSecL(value.Compare(KMediaLink2) == KErrNone, KComparePositionFieldValueErr); |
|
272 } |
|
273 else if(aId == (tmp+2)) |
|
274 { |
|
275 aLandmark.GetPositionField(aId, value); |
|
276 AssertTrueSecL(value.Compare(KMediaLink3) == KErrNone, KComparePositionFieldValueErr); |
|
277 } |
|
278 else |
|
279 { |
|
280 buf.Format(_L("Looking for id: %d %d %d"), aId, (tmp+1), (tmp+2)); |
|
281 iLog->Log(buf); |
|
282 iLog->Log(KPositionFieldIdErr); |
|
283 User::Leave(KErrGeneral); |
|
284 } |
|
285 } |
|
286 |
|
287 // --------------------------------------------------------- |
|
288 // CPosTp5::CheckFieldsMaxLength |
|
289 // |
|
290 // (other items were commented in a header). |
|
291 // --------------------------------------------------------- |
|
292 // |
|
293 void CPosTp5::CheckFieldsMaxLengthL() |
|
294 { |
|
295 |
|
296 _LIT(K255Error, "Text field is not limited to 255 characters"); |
|
297 _LIT(K4095Error, "Description field is not limited to 4095 characters"); |
|
298 _LIT(KIconError, "Icon File Name field is not limited to correct nr of characters"); |
|
299 |
|
300 HBufC* hbuf = HBufC::NewLC(4096); |
|
301 while(hbuf->Des().Length() < 255) |
|
302 { |
|
303 hbuf->Des().Append(_L("X")); |
|
304 } |
|
305 |
|
306 CPosLandmark* landmark = CPosLandmark::NewLC(); |
|
307 landmark->SetLandmarkNameL(*hbuf); |
|
308 landmark->SetLandmarkDescriptionL(*hbuf); |
|
309 landmark->SetPositionFieldL(EPositionFieldCountry, *hbuf); |
|
310 hbuf->Des().Append(_L("X")); |
|
311 |
|
312 TRAPD(err, landmark->SetLandmarkNameL(*hbuf)); |
|
313 AssertTrueSecL(err == KErrArgument, K255Error); |
|
314 |
|
315 landmark->SetLandmarkDescriptionL(*hbuf); |
|
316 |
|
317 TRAP(err, landmark->SetPositionFieldL(EPositionFieldCountry, *hbuf)); |
|
318 AssertTrueSecL(err == KErrArgument, K255Error); |
|
319 |
|
320 while(hbuf->Des().Length() < 4095) |
|
321 { |
|
322 hbuf->Des().Append(_L("X")); |
|
323 } |
|
324 landmark->SetLandmarkDescriptionL(*hbuf); |
|
325 hbuf->Des().Append(_L("X")); |
|
326 TRAP(err, landmark->SetLandmarkDescriptionL(*hbuf)); |
|
327 AssertTrueSecL(err == KErrArgument, K4095Error); |
|
328 |
|
329 CleanupStack::PopAndDestroy(2, hbuf); |
|
330 |
|
331 // Test setIconL |
|
332 // KMaxFileName is defined in e32const.h |
|
333 HBufC* icon = HBufC::NewLC(KMaxFileName+1); |
|
334 while(icon->Des().Length() < KMaxFileName) |
|
335 { |
|
336 icon->Des().Append(_L("X")); |
|
337 } |
|
338 |
|
339 landmark = CPosLandmark::NewLC(); |
|
340 landmark->SetLandmarkNameL(_L("SomeLandmarkName")); |
|
341 landmark->SetLandmarkDescriptionL(_L("SomeLandmarkDescription")); |
|
342 landmark->SetIconL(*icon, 1, KPosLmIconMaskNotUsed); |
|
343 |
|
344 icon->Des().Append(_L("X")); |
|
345 |
|
346 TRAP(err, landmark->SetIconL(*icon, 1, KPosLmIconMaskNotUsed)); |
|
347 AssertTrueSecL(err == KErrArgument, KIconError); |
|
348 CleanupStack::PopAndDestroy(landmark); |
|
349 CleanupStack::PopAndDestroy(icon); |
|
350 |
|
351 |
|
352 } |
|
353 |
|
354 // --------------------------------------------------------- |
|
355 // CPosTp5::CheckNaNErrorL |
|
356 // |
|
357 // (other items were commented in a header). |
|
358 // --------------------------------------------------------- |
|
359 // |
|
360 void CPosTp5::CheckNaNErrorL() |
|
361 { |
|
362 iLog->Log(_L("CheckErrorL")); |
|
363 CPosLandmarkDatabase* lmdb = OpenDatabaseLC(); |
|
364 CPosLandmark* landmark = CPosLandmark::NewLC(); |
|
365 |
|
366 ExecuteAndDeleteLD(lmdb->CompactL()); |
|
367 TInt errorsFound = KErrNone; |
|
368 TRealX NaN; |
|
369 NaN.SetNaN(); |
|
370 |
|
371 // Used for testing SDK: |
|
372 // This part should result in log: |
|
373 // Not Equal1 |
|
374 // Not Equal2 |
|
375 TRealX pos1; |
|
376 TRealX pos2; |
|
377 |
|
378 iLog->Log(_L("Testing with NaN and 45")); |
|
379 pos1.SetNaN(); |
|
380 pos2 = 45; |
|
381 |
|
382 if (pos2 == pos1) |
|
383 iLog->Log(_L("Equal1")); |
|
384 else |
|
385 iLog->Log(_L("Not Equal1")); |
|
386 |
|
387 if (pos2 != pos1) |
|
388 iLog->Log(_L("Not Equal2")); |
|
389 else |
|
390 iLog->Log(_L("Equal2")); |
|
391 |
|
392 |
|
393 iLog->Log(_L("Testing with NaN and 0")); |
|
394 pos1.SetNaN(); |
|
395 pos2 = 0; |
|
396 |
|
397 if (pos2 == pos1) |
|
398 iLog->Log(_L("Equal1")); |
|
399 else |
|
400 iLog->Log(_L("Not Equal1")); |
|
401 |
|
402 if (pos2 != pos1) |
|
403 iLog->Log(_L("Not Equal2")); |
|
404 else |
|
405 iLog->Log(_L("Equal2")); |
|
406 |
|
407 iLog->Log(_L("Testing with NaN and NaN")); |
|
408 pos1.SetNaN(); |
|
409 pos2.SetNaN(); |
|
410 |
|
411 if (pos2 == pos1) |
|
412 iLog->Log(_L("Equal1")); |
|
413 else |
|
414 iLog->Log(_L("Not Equal1")); |
|
415 |
|
416 if (pos2 != pos1) |
|
417 iLog->Log(_L("Not Equal2")); |
|
418 else |
|
419 iLog->Log(_L("Equal2")); |
|
420 |
|
421 landmark->SetLandmarkNameL(_L("TestingLandmarkError")); |
|
422 |
|
423 // Only set position with Latitude and Longitude (thus Altitude and Accuracy is NaN) |
|
424 TLocality loc; |
|
425 loc.SetCoordinate(1,2); |
|
426 landmark->SetPositionL(loc); |
|
427 |
|
428 TPosLmItemId myId = lmdb->AddLandmarkL(*landmark); |
|
429 CleanupStack::PopAndDestroy(landmark); |
|
430 |
|
431 ////////////////////////////////////// |
|
432 // Test Altitude |
|
433 landmark = lmdb->ReadLandmarkLC(myId); |
|
434 landmark->GetPosition(loc); |
|
435 |
|
436 loc.SetCoordinate(1,2, 123); |
|
437 landmark->SetPositionL(loc); |
|
438 |
|
439 lmdb->UpdateLandmarkL(*landmark); |
|
440 CleanupStack::PopAndDestroy(landmark); |
|
441 |
|
442 landmark = lmdb->ReadLandmarkLC(myId); |
|
443 TLocality loc3; |
|
444 landmark->GetPosition(loc3); |
|
445 |
|
446 if (TRealX(loc3.Altitude()).IsNaN()) |
|
447 { |
|
448 iLog->Log(_L("Error: Altitude is Nan")); |
|
449 errorsFound++; |
|
450 } |
|
451 else if (loc3.Altitude() != 123) |
|
452 { |
|
453 iLog->Log(_L("Error: Incorrect altitude returned")); |
|
454 errorsFound++; |
|
455 } |
|
456 |
|
457 // Reset landmark |
|
458 loc.SetCoordinate(1,2, NaN); |
|
459 landmark->SetPositionL(loc); |
|
460 lmdb->UpdateLandmarkL(*landmark); |
|
461 CleanupStack::PopAndDestroy(landmark); |
|
462 |
|
463 ////////////////////////////////////// |
|
464 // Test Horizontal accuracy |
|
465 landmark = lmdb->ReadLandmarkLC(myId); |
|
466 loc.SetCoordinate(1,2, NaN); |
|
467 loc.SetHorizontalAccuracy(12); |
|
468 landmark->SetPositionL(loc); |
|
469 |
|
470 lmdb->UpdateLandmarkL(*landmark); |
|
471 CleanupStack::PopAndDestroy(landmark); |
|
472 |
|
473 landmark = lmdb->ReadLandmarkLC(myId); |
|
474 landmark->GetPosition(loc3); |
|
475 |
|
476 if (TRealX(loc3.HorizontalAccuracy()).IsNaN()) |
|
477 { |
|
478 iLog->Log(_L("Error: Horizontal accuracy is Nan")); |
|
479 errorsFound++; |
|
480 } |
|
481 else if (loc3.HorizontalAccuracy() != 12) |
|
482 { |
|
483 iLog->Log(_L("Error: Incorrect horizontal accuracy returned")); |
|
484 errorsFound++; |
|
485 } |
|
486 |
|
487 CleanupStack::PopAndDestroy(landmark); |
|
488 |
|
489 ////////////////////////////////////// |
|
490 // Test with NaN for hor acc |
|
491 landmark = lmdb->ReadLandmarkLC(myId); |
|
492 loc.SetCoordinate(1,2, NaN); |
|
493 loc.SetHorizontalAccuracy(NaN); |
|
494 landmark->SetPositionL(loc); |
|
495 |
|
496 lmdb->UpdateLandmarkL(*landmark); |
|
497 CleanupStack::PopAndDestroy(landmark); |
|
498 |
|
499 landmark = lmdb->ReadLandmarkLC(myId); |
|
500 landmark->GetPosition(loc3); |
|
501 |
|
502 if (TRealX(loc3.HorizontalAccuracy()).IsNaN()) |
|
503 { |
|
504 iLog->Log(_L("Horizontal accuracy is correctly set to Nan")); |
|
505 } |
|
506 else |
|
507 { |
|
508 iLog->Log(_L("Error: Incorrect horizontal accuracy returned")); |
|
509 errorsFound++; |
|
510 } |
|
511 |
|
512 CleanupStack::PopAndDestroy(landmark); |
|
513 |
|
514 ////////////////////////////////////// |
|
515 // Test Vertical accuracy |
|
516 landmark = lmdb->ReadLandmarkLC(myId); |
|
517 loc.SetCoordinate(1,2, NaN); |
|
518 loc.SetVerticalAccuracy(21); |
|
519 landmark->SetPositionL(loc); |
|
520 |
|
521 lmdb->UpdateLandmarkL(*landmark); |
|
522 CleanupStack::PopAndDestroy(landmark); |
|
523 |
|
524 landmark = lmdb->ReadLandmarkLC(myId); |
|
525 landmark->GetPosition(loc3); |
|
526 |
|
527 if (TRealX(loc3.VerticalAccuracy()).IsNaN()) |
|
528 { |
|
529 iLog->Log(_L("Error: Vertical accuracy is Nan")); |
|
530 errorsFound++; |
|
531 } |
|
532 else if (loc3.VerticalAccuracy() != 21) |
|
533 { |
|
534 iLog->Log(_L("Error: Incorrect vertical accuracy returned")); |
|
535 errorsFound++; |
|
536 } |
|
537 |
|
538 CleanupStack::PopAndDestroy(landmark); |
|
539 |
|
540 ////////////////////////////////////// |
|
541 // Test landmark description |
|
542 landmark = lmdb->ReadLandmarkLC(myId); |
|
543 landmark->SetLandmarkDescriptionL(_L("TestingLandmarkErrorDescription")); |
|
544 lmdb->UpdateLandmarkL(*landmark); |
|
545 CleanupStack::PopAndDestroy(landmark); |
|
546 |
|
547 landmark = lmdb->ReadLandmarkLC(myId); |
|
548 TPtrC des; |
|
549 landmark->GetLandmarkDescription(des); |
|
550 TInt res = des.CompareC(_L("TestingLandmarkErrorDescription")); |
|
551 |
|
552 if (res != KErrNone) |
|
553 { |
|
554 iLog->Log(_L("Error: Incorrect description returned")); |
|
555 errorsFound++; |
|
556 } |
|
557 |
|
558 CleanupStack::PopAndDestroy(landmark); |
|
559 |
|
560 ////////////////////////////////////// |
|
561 // Test coverage radius |
|
562 landmark = lmdb->ReadLandmarkLC(myId); |
|
563 landmark->SetCoverageRadius(15); |
|
564 lmdb->UpdateLandmarkL(*landmark); |
|
565 CleanupStack::PopAndDestroy(landmark); |
|
566 |
|
567 landmark = lmdb->ReadLandmarkLC(myId); |
|
568 landmark->GetPosition(loc3); |
|
569 TReal32 radius; |
|
570 landmark->GetCoverageRadius(radius); |
|
571 if (TRealX(radius).IsNaN()) |
|
572 { |
|
573 iLog->Log(_L("Error: Radius is Nan")); |
|
574 errorsFound++; |
|
575 } |
|
576 else if (radius != 15) |
|
577 { |
|
578 iLog->Log(_L("Error: Incorrect radius returned")); |
|
579 errorsFound++; |
|
580 } |
|
581 ////////////////////////////////////// |
|
582 CleanupStack::PopAndDestroy(landmark); |
|
583 ////////////////////////////////////// |
|
584 // Test coverage radius, part2 |
|
585 // Set coverage radius to NaN |
|
586 landmark = lmdb->ReadLandmarkLC(myId); |
|
587 TRealX nan; |
|
588 nan.SetNaN(); |
|
589 landmark->SetCoverageRadius(nan); |
|
590 lmdb->UpdateLandmarkL(*landmark); |
|
591 CleanupStack::PopAndDestroy(landmark); |
|
592 |
|
593 landmark = lmdb->ReadLandmarkLC(myId); |
|
594 landmark->GetPosition(loc3); |
|
595 |
|
596 res = landmark->GetCoverageRadius(radius); |
|
597 if (res != KErrNotFound) |
|
598 { |
|
599 iLog->Log(_L("Error: GetCoverageRadius should return KErrNotFound when set to NaN")); |
|
600 errorsFound++; |
|
601 } |
|
602 ////////////////////////////////////// |
|
603 CleanupStack::PopAndDestroy(landmark); |
|
604 |
|
605 CleanupStack::PopAndDestroy(lmdb); |
|
606 |
|
607 if (errorsFound != KErrNone) |
|
608 { |
|
609 |
|
610 iLog->Log(_L("Errors found in part CheckNaNErrorL()")); |
|
611 User::Leave(-1); |
|
612 } |
|
613 |
|
614 } |