|
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 #include "FT_CPosTp43.h" |
|
22 |
|
23 #include <EPos_CPosLandmarkParser.h> |
|
24 #include <EPos_CPosLandmarkEncoder.h> |
|
25 #include <EPos_CPosLandmarkDatabase.h> |
|
26 #include <LbsPosition.h> |
|
27 #include <e32math.h> |
|
28 #include <bautils.h> |
|
29 |
|
30 // CONST |
|
31 _LIT(KFileName, "c:\\documents\\Tp43EncodeOutput.xml"); |
|
32 _LIT(KFileName2, "c:\\documents\\Tp43EncodeOutputIncMode.xml"); |
|
33 _LIT(KFileName3, "c:\\documents\\Tp43EncodeOutputCollectionData1.xml"); |
|
34 _LIT(KFileName4, "c:\\documents\\Tp43EncodeOutputCollectionData2.xml"); |
|
35 _LIT(KFileEmptyCollectionData, "c:\\documents\\Tp43EncodeOutputEmptyCollectionData.xml"); |
|
36 _LIT(KFileEmptyCollectionData2, "c:\\documents\\Tp43EncodeOutputEmptyCollectionData2.xml"); |
|
37 _LIT(KFileLongCollectionFieldName, "c:\\documents\\Tp43EncodeOutputLongCollectionField.xml"); |
|
38 |
|
39 // Filename with 260 characters |
|
40 _LIT(KLongFileName, "c:\\File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File12"); |
|
41 _LIT(KEmptyFileName, ""); |
|
42 _LIT8(KLongMimeType, "application/vnd.nokia.landmarkcollection+xmlFile123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File123456File12"); |
|
43 |
|
44 _LIT(KFileNameCorrect, "c:\\system\\test\\TestData\\Tp43EncodeOutput_Correct.xml"); |
|
45 _LIT(KFileName2Correct, "c:\\system\\test\\TestData\\Tp43EncodeOutputIncMode_Correct.xml"); |
|
46 _LIT(KFileName3Correct, "c:\\system\\test\\TestData\\Tp43EncodeOutputCollectionData1_Correct.xml"); |
|
47 _LIT(KFileName4Correct, "c:\\system\\test\\TestData\\Tp43EncodeOutputCollectionData2_Correct.xml"); |
|
48 _LIT(KFileEmptyCollectionDataCorrect, "c:\\system\\test\\TestData\\Tp43EncodeOutputEmptyCollectionData_Correct.xml"); |
|
49 _LIT(KFileEmptyCollectionData2Correct, "c:\\system\\test\\TestData\\Tp43EncodeOutputEmptyCollectionData2_Correct.xml"); |
|
50 _LIT(KFileLongCollectionFieldNameCorrect, "c:\\system\\test\\TestData\\Tp43EncodeOutputLongCollectionField_Correct.xml"); |
|
51 _LIT(KErrorScenario4FileCorrect, "c:\\system\\test\\TestData\\Tp43EncodeOutputErrorScenario4_Correct.xml"); |
|
52 _LIT(KErrorScenario5FileCorrect, "c:\\system\\test\\TestData\\Tp43EncodeOutputErrorScenario5_Correct.xml"); |
|
53 |
|
54 _LIT(KErrorTestFileName, "c:\\documents\\Tp43EncodeOutputErrorTest.xml"); |
|
55 _LIT(KErrorScenario4File, "c:\\documents\\Tp43EncodeOutputErrorScenario4.xml"); |
|
56 _LIT(KErrorScenario5File, "c:\\documents\\Tp43EncodeOutputErrorScenario5.xml"); |
|
57 |
|
58 // This number must be updated if any more landmarks are added |
|
59 const TInt KNrOfAddedLandmarks = 7; |
|
60 |
|
61 const TInt KBufSize = 1024; |
|
62 |
|
63 // ================= MEMBER FUNCTIONS ======================= |
|
64 |
|
65 |
|
66 // --------------------------------------------------------- |
|
67 // CPosTp43::CloseTest |
|
68 // |
|
69 // (other items were commented in a header). |
|
70 // --------------------------------------------------------- |
|
71 // |
|
72 void CPosTp43::CloseTest() |
|
73 { |
|
74 iLog->Log(_L("CloseTest")); |
|
75 |
|
76 iLandmarks.ResetAndDestroy(); |
|
77 iLandmarks.Close(); |
|
78 |
|
79 delete iLandmarkSearch; |
|
80 iLandmarkSearch = NULL; |
|
81 |
|
82 delete iDatabase; |
|
83 iDatabase=NULL; |
|
84 |
|
85 delete iLandmarkEncoder; |
|
86 iLandmarkEncoder = NULL; |
|
87 |
|
88 delete iLandmarkParser; |
|
89 iLandmarkParser = NULL; |
|
90 |
|
91 delete iOperation; |
|
92 iOperation = NULL; |
|
93 |
|
94 } |
|
95 |
|
96 // --------------------------------------------------------- |
|
97 // CPosTp43::StartL |
|
98 // |
|
99 // (other items were commented in a header). |
|
100 // --------------------------------------------------------- |
|
101 // |
|
102 void CPosTp43::StartL() |
|
103 { |
|
104 BaflUtils::EnsurePathExistsL( iFileSession, KFileName ); |
|
105 |
|
106 DeleteFileL(KFileName); |
|
107 DeleteFileL(KFileName2); |
|
108 DeleteFileL(KFileName3); |
|
109 DeleteFileL(KFileName4); |
|
110 DeleteFileL(KFileEmptyCollectionData); |
|
111 DeleteFileL(KFileEmptyCollectionData2); |
|
112 |
|
113 |
|
114 RemoveAllLmDatabasesL(); |
|
115 |
|
116 // Use same lm db as in composite search test |
|
117 iDatabase = UseCompositeLandmarksDbFileL(); |
|
118 if (iDatabase->IsInitializingNeeded()) |
|
119 { |
|
120 ExecuteAndDeleteLD(iDatabase->InitializeL()); |
|
121 } |
|
122 |
|
123 delete iDatabase; |
|
124 iDatabase = NULL; |
|
125 |
|
126 iDatabase = CPosLandmarkDatabase::OpenL(); |
|
127 |
|
128 if (iDatabase->IsInitializingNeeded()) |
|
129 { |
|
130 ExecuteAndDeleteLD(iDatabase->InitializeL()); |
|
131 } |
|
132 |
|
133 iLandmarkSearch = CPosLandmarkSearch::NewL(*iDatabase); |
|
134 |
|
135 // Do reset so that global categories are included |
|
136 CPosLmCategoryManager* categoryManager = CPosLmCategoryManager::NewL(*iDatabase); |
|
137 CleanupStack::PushL(categoryManager); |
|
138 ExecuteAndDeleteLD(categoryManager->ResetGlobalCategoriesL()); |
|
139 CleanupStack::PopAndDestroy(categoryManager); |
|
140 |
|
141 |
|
142 // 1) Create an encoder object |
|
143 iLandmarkEncoder = CPosLandmarkEncoder::NewL(KLmxMimeType); |
|
144 |
|
145 // 2) Use file for encoding, set output file |
|
146 iLandmarkEncoder->SetOutputFileL(KFileName); |
|
147 CreateEncoderPartsL(); |
|
148 |
|
149 // 13 Finalize encoding |
|
150 iLog->Log(_L("FinalizeEncodingL")); |
|
151 ExecuteAndDeleteLD(iLandmarkEncoder->FinalizeEncodingL()); |
|
152 iLog->Log(_L("FinalizeEncodingL Done")); |
|
153 |
|
154 // Check data |
|
155 HBufC8* emptyBuffer=NULL; |
|
156 ParseAndCheckDataFromEncoderL(KFileName, _L(""), _L(""), *emptyBuffer); |
|
157 |
|
158 // Repeate step 2-12, finalize with incremental mode and monitor progress |
|
159 iLandmarkEncoder->SetOutputFileL(KFileName2); |
|
160 CreateEncoderPartsL(); |
|
161 |
|
162 // 15 Finalize encoding with incremental mode and monitor progress |
|
163 iOperation = iLandmarkEncoder->FinalizeEncodingL(); |
|
164 |
|
165 CActiveLmOperation* activeLmOperation = new(ELeave) CActiveLmOperation(iLog); |
|
166 CleanupStack::PushL(activeLmOperation); |
|
167 |
|
168 // Progress is monitored in CLandmarkTestProcedureBase class |
|
169 activeLmOperation->Start(iOperation); |
|
170 CActiveScheduler::Start(); |
|
171 |
|
172 // Check for no errors |
|
173 iLog->Log(_L("CheckOperationL")); |
|
174 activeLmOperation->CheckOperationL(); |
|
175 delete iOperation; |
|
176 iOperation = NULL; |
|
177 |
|
178 ParseAndCheckDataFromEncoderL(KFileName2, _L(""), _L(""), *emptyBuffer); |
|
179 |
|
180 CleanupStack::PopAndDestroy(activeLmOperation); |
|
181 |
|
182 // 16 Repeat step 3-15, use buffer |
|
183 CBufBase* myEncoderBuffer = iLandmarkEncoder->SetUseOutputBufferL(); |
|
184 CleanupStack::PushL(myEncoderBuffer); |
|
185 |
|
186 // 17a Repeat step 3-15, use buffer |
|
187 iLog->Log(_L("Part 17a Repeat step 3-15 use buffer")); |
|
188 CreateEncoderPartsL(); |
|
189 |
|
190 iLog->Log(_L("FinalizeEncodingL")); |
|
191 ExecuteAndDeleteLD(iLandmarkEncoder->FinalizeEncodingL()); |
|
192 iLog->Log(_L("FinalizeEncodingL Done")); |
|
193 |
|
194 HBufC8* filecontent = HBufC8::NewLC(myEncoderBuffer->Size()); |
|
195 TPtr8 ptr = filecontent->Des(); |
|
196 myEncoderBuffer->Read(0, ptr, myEncoderBuffer->Size()); |
|
197 ParseAndCheckDataFromEncoderL(KNullDesC, _L(""), _L(""), *filecontent); |
|
198 myEncoderBuffer->Reset(); |
|
199 CleanupStack::PopAndDestroy(filecontent); |
|
200 CleanupStack::PopAndDestroy(myEncoderBuffer); |
|
201 |
|
202 // 17b Repeat step 3-15 use buffer, finalize with incremental mode and monitor progress |
|
203 iLog->Log(_L("Part 17b Repeat step 3-15 use buffer")); |
|
204 CBufBase* myEncoderBuffer2 = iLandmarkEncoder->SetUseOutputBufferL(); |
|
205 CleanupStack::PushL(myEncoderBuffer2); |
|
206 |
|
207 CreateEncoderPartsL(); |
|
208 iOperation = iLandmarkEncoder->FinalizeEncodingL(); |
|
209 |
|
210 activeLmOperation = new(ELeave) CActiveLmOperation(iLog); |
|
211 CleanupStack::PushL(activeLmOperation); |
|
212 |
|
213 // Progress is monitored in CLandmarkTestProcedureBase class |
|
214 activeLmOperation->Start(iOperation); |
|
215 CActiveScheduler::Start(); |
|
216 |
|
217 // Check for no errors |
|
218 iLog->Log(_L("CheckOperationL")); |
|
219 activeLmOperation->CheckOperationL(); |
|
220 delete iOperation; |
|
221 iOperation = NULL; |
|
222 |
|
223 HBufC8* filecontent2 = HBufC8::NewLC(myEncoderBuffer2->Size()); |
|
224 TPtr8 ptr2 = filecontent2->Des(); |
|
225 myEncoderBuffer2->Read(0, ptr2, myEncoderBuffer2->Size()); |
|
226 |
|
227 ParseAndCheckDataFromEncoderL(KNullDesC, _L(""), _L(""), *filecontent2); |
|
228 |
|
229 myEncoderBuffer2->Reset(); |
|
230 CleanupStack::PopAndDestroy(filecontent2); |
|
231 CleanupStack::PopAndDestroy(activeLmOperation); |
|
232 CleanupStack::PopAndDestroy(myEncoderBuffer2); |
|
233 |
|
234 // 18 Use file when encoding, set output file |
|
235 iLog->Log(_L("Part 18 Use file when encoding, set output file")); |
|
236 iLandmarkEncoder->SetOutputFileL(KFileName3); |
|
237 |
|
238 // 19 Add collection data to the encoder, name and description set |
|
239 iLandmarkEncoder->AddCollectionDataL(EPosLmCollDataCollectionName, _L("TP43CollectionDataNameFile1")); |
|
240 iLandmarkEncoder->AddCollectionDataL(EPosLmCollDataCollectionDescription, _L("TP43CollectionDataDescriptionFile1")); |
|
241 |
|
242 CreateEncoderPartsL(); |
|
243 |
|
244 // Finalize encoding |
|
245 iLog->Log(_L("FinalizeEncodingL")); |
|
246 ExecuteAndDeleteLD(iLandmarkEncoder->FinalizeEncodingL()); |
|
247 iLog->Log(_L("FinalizeEncodingL Done")); |
|
248 |
|
249 // Check data |
|
250 ParseAndCheckDataFromEncoderL(KFileName3, _L("TP43CollectionDataNameFile1"), _L("TP43CollectionDataDescriptionFile1"), *emptyBuffer); |
|
251 |
|
252 // 20a Repeat step 3-17 Use file when encoding, set output file, finalize with incremental mode and monitor progress |
|
253 iLog->Log(_L("Part 20a ")); |
|
254 iLandmarkEncoder->SetOutputFileL(KFileName4); |
|
255 |
|
256 // Add collection data to the encoder, name and description set |
|
257 iLandmarkEncoder->AddCollectionDataL(EPosLmCollDataCollectionName, _L("TP43CollectionDataNameFile2")); |
|
258 iLandmarkEncoder->AddCollectionDataL(EPosLmCollDataCollectionDescription, _L("TP43CollectionDataDescriptionFile2")); |
|
259 |
|
260 CreateEncoderPartsL(); |
|
261 |
|
262 // finalize with incremental mode and monitor progress |
|
263 iOperation = iLandmarkEncoder->FinalizeEncodingL(); |
|
264 |
|
265 activeLmOperation = new(ELeave) CActiveLmOperation(iLog); |
|
266 CleanupStack::PushL(activeLmOperation); |
|
267 |
|
268 // Progress is monitored in CLandmarkTestProcedureBase class |
|
269 activeLmOperation->Start(iOperation); |
|
270 CActiveScheduler::Start(); |
|
271 |
|
272 // Check for no errors |
|
273 iLog->Log(_L("CheckOperationL")); |
|
274 activeLmOperation->CheckOperationL(); |
|
275 delete iOperation; |
|
276 iOperation = NULL; |
|
277 CleanupStack::PopAndDestroy(activeLmOperation); |
|
278 |
|
279 // Check data |
|
280 ParseAndCheckDataFromEncoderL(KFileName4, _L("TP43CollectionDataNameFile2"), _L("TP43CollectionDataDescriptionFile2"), *emptyBuffer); |
|
281 |
|
282 // 20b Use buffer when encoding |
|
283 iLog->Log(_L("Part 20b ")); |
|
284 CBufBase* myEncoderBuffer3 = iLandmarkEncoder->SetUseOutputBufferL(); |
|
285 CleanupStack::PushL(myEncoderBuffer3); |
|
286 |
|
287 // Add collection data to the encoder, name and description set |
|
288 iLandmarkEncoder->AddCollectionDataL(EPosLmCollDataCollectionName, _L("TP43CollectionDataNameBuffer1")); |
|
289 iLandmarkEncoder->AddCollectionDataL(EPosLmCollDataCollectionDescription, _L("TP43CollectionDataDescriptionBuffer1")); |
|
290 CreateEncoderPartsL(); |
|
291 |
|
292 // Finalize encoding |
|
293 iLog->Log(_L("FinalizeEncodingL")); |
|
294 ExecuteAndDeleteLD(iLandmarkEncoder->FinalizeEncodingL()); |
|
295 iLog->Log(_L("FinalizeEncodingL Done")); |
|
296 |
|
297 HBufC8* filecontent3 = HBufC8::NewLC(myEncoderBuffer3->Size()); |
|
298 TPtr8 ptr3 = filecontent3->Des(); |
|
299 myEncoderBuffer3->Read(0, ptr3, myEncoderBuffer3->Size()); |
|
300 ParseAndCheckDataFromEncoderL(KNullDesC, _L("TP43CollectionDataNameBuffer1"), _L("TP43CollectionDataDescriptionBuffer1"), *filecontent3); |
|
301 myEncoderBuffer3->Reset(); |
|
302 CleanupStack::PopAndDestroy(filecontent3); |
|
303 CleanupStack::PopAndDestroy(myEncoderBuffer3); |
|
304 |
|
305 |
|
306 // 20c Repeat step 3-17 Use buffer when encoding, set output file, finalize with incremental mode and monitor progress |
|
307 iLog->Log(_L("Part 20c ")); |
|
308 CBufBase* myEncoderBuffer4 = iLandmarkEncoder->SetUseOutputBufferL(); |
|
309 CleanupStack::PushL(myEncoderBuffer4); |
|
310 |
|
311 // Add collection data to the encoder, name and description set |
|
312 iLandmarkEncoder->AddCollectionDataL(EPosLmCollDataCollectionName, _L("TP43CollectionDataNameBuffer2")); |
|
313 iLandmarkEncoder->AddCollectionDataL(EPosLmCollDataCollectionDescription, _L("TP43CollectionDataDescriptionBuffer2")); |
|
314 |
|
315 CreateEncoderPartsL(); |
|
316 |
|
317 // finalize with incremental mode and monitor progress |
|
318 iOperation = iLandmarkEncoder->FinalizeEncodingL(); |
|
319 |
|
320 activeLmOperation = new(ELeave) CActiveLmOperation(iLog); |
|
321 CleanupStack::PushL(activeLmOperation); |
|
322 |
|
323 // Progress is monitored in CLandmarkTestProcedureBase class |
|
324 activeLmOperation->Start(iOperation); |
|
325 CActiveScheduler::Start(); |
|
326 |
|
327 // Check for no errors |
|
328 iLog->Log(_L("CheckOperationL")); |
|
329 activeLmOperation->CheckOperationL(); |
|
330 delete iOperation; |
|
331 iOperation = NULL; |
|
332 |
|
333 HBufC8* filecontent4 = HBufC8::NewLC(myEncoderBuffer4->Size()); |
|
334 TPtr8 ptr4 = filecontent4->Des(); |
|
335 myEncoderBuffer4->Read(0, ptr4, myEncoderBuffer4->Size()); |
|
336 ParseAndCheckDataFromEncoderL(KNullDesC, _L("TP43CollectionDataNameBuffer2"), _L("TP43CollectionDataDescriptionBuffer2"), *filecontent4); |
|
337 myEncoderBuffer4->Reset(); |
|
338 CleanupStack::PopAndDestroy(filecontent4); |
|
339 |
|
340 CleanupStack::PopAndDestroy(activeLmOperation); |
|
341 CleanupStack::PopAndDestroy(myEncoderBuffer4); |
|
342 |
|
343 // 21 Use file when encoding, set output file |
|
344 iLog->Log(_L("Part 21 ")); |
|
345 iLandmarkEncoder->SetOutputFileL(KFileEmptyCollectionData); |
|
346 // 22 Add collection data to the encoder, but without specifying name and description |
|
347 iLandmarkEncoder->AddCollectionDataL(EPosLmCollDataCollectionName, _L("")); |
|
348 iLandmarkEncoder->AddCollectionDataL(EPosLmCollDataCollectionDescription, _L("")); |
|
349 |
|
350 CreateEncoderPartsL(); |
|
351 |
|
352 // Finalize encoding |
|
353 iLog->Log(_L("FinalizeEncodingL")); |
|
354 ExecuteAndDeleteLD(iLandmarkEncoder->FinalizeEncodingL()); |
|
355 iLog->Log(_L("FinalizeEncodingL Done")); |
|
356 |
|
357 // Check data |
|
358 ParseAndCheckDataFromEncoderL(KFileEmptyCollectionData, _L(""), _L(""), *emptyBuffer); |
|
359 |
|
360 // 23a Repeat step 3-17 Use file when encoding, set output file, finalize with incr. mode |
|
361 iLog->Log(_L("Part 23a ")); |
|
362 iLandmarkEncoder->SetOutputFileL(KFileEmptyCollectionData2); |
|
363 // Add collection data to the encoder, but without specifying name and description |
|
364 iLandmarkEncoder->AddCollectionDataL(EPosLmCollDataCollectionName, _L("")); |
|
365 iLandmarkEncoder->AddCollectionDataL(EPosLmCollDataCollectionDescription, _L("")); |
|
366 |
|
367 CreateEncoderPartsL(); |
|
368 |
|
369 // finalize with incremental mode and monitor progress |
|
370 iOperation = iLandmarkEncoder->FinalizeEncodingL(); |
|
371 |
|
372 activeLmOperation = new(ELeave) CActiveLmOperation(iLog); |
|
373 CleanupStack::PushL(activeLmOperation); |
|
374 |
|
375 // Progress is monitored in CLandmarkTestProcedureBase class |
|
376 activeLmOperation->Start(iOperation); |
|
377 CActiveScheduler::Start(); |
|
378 |
|
379 // Check for no errors |
|
380 iLog->Log(_L("CheckOperationL")); |
|
381 activeLmOperation->CheckOperationL(); |
|
382 delete iOperation; |
|
383 iOperation = NULL; |
|
384 CleanupStack::PopAndDestroy(activeLmOperation); |
|
385 |
|
386 // Check data |
|
387 ParseAndCheckDataFromEncoderL(KFileEmptyCollectionData, _L(""), _L(""), *emptyBuffer); |
|
388 |
|
389 // 23b Repeat step 3-17 Use buffer when encoding |
|
390 iLog->Log(_L("Part 23b ")); |
|
391 CBufBase* myEncoderBuffer5 = iLandmarkEncoder->SetUseOutputBufferL(); |
|
392 CleanupStack::PushL(myEncoderBuffer5); |
|
393 |
|
394 // Add collection data to the encoder, name and description set |
|
395 iLandmarkEncoder->AddCollectionDataL(EPosLmCollDataCollectionName, _L("TP43CollectionDataNameBuffer3")); |
|
396 iLandmarkEncoder->AddCollectionDataL(EPosLmCollDataCollectionDescription, _L("TP43CollectionDataDescriptionBuffer3")); |
|
397 CreateEncoderPartsL(); |
|
398 |
|
399 // Finalize encoding |
|
400 iLog->Log(_L("FinalizeEncodingL")); |
|
401 ExecuteAndDeleteLD(iLandmarkEncoder->FinalizeEncodingL()); |
|
402 iLog->Log(_L("FinalizeEncodingL Done")); |
|
403 |
|
404 // Check data here |
|
405 HBufC8* filecontent5 = HBufC8::NewLC(myEncoderBuffer5->Size()); |
|
406 TPtr8 ptr5 = filecontent5->Des(); |
|
407 myEncoderBuffer5->Read(0, ptr5, myEncoderBuffer5->Size()); |
|
408 ParseAndCheckDataFromEncoderL(KNullDesC, _L("TP43CollectionDataNameBuffer3"), _L("TP43CollectionDataDescriptionBuffer3"), *filecontent5); |
|
409 myEncoderBuffer5->Reset(); |
|
410 CleanupStack::PopAndDestroy(filecontent5); |
|
411 CleanupStack::PopAndDestroy(myEncoderBuffer5); |
|
412 |
|
413 // 23c Repeat step 3-17 Use buffer when encoding, finalize with incremental mode and monitor progress |
|
414 iLog->Log(_L("Part 23c ")); |
|
415 CBufBase* myEncoderBuffer6 = iLandmarkEncoder->SetUseOutputBufferL(); |
|
416 CleanupStack::PushL(myEncoderBuffer6); |
|
417 |
|
418 // Add collection data to the encoder, name and description set |
|
419 iLandmarkEncoder->AddCollectionDataL(EPosLmCollDataCollectionName, _L("TP43CollectionDataNameBuffer4")); |
|
420 iLandmarkEncoder->AddCollectionDataL(EPosLmCollDataCollectionDescription, _L("TP43CollectionDataDescriptionBuffer4")); |
|
421 CreateEncoderPartsL(); |
|
422 |
|
423 // finalize with incremental mode and monitor progress |
|
424 iOperation = iLandmarkEncoder->FinalizeEncodingL(); |
|
425 |
|
426 activeLmOperation = new(ELeave) CActiveLmOperation(iLog); |
|
427 CleanupStack::PushL(activeLmOperation); |
|
428 |
|
429 // Progress is monitored in CLandmarkTestProcedureBase class |
|
430 activeLmOperation->Start(iOperation); |
|
431 CActiveScheduler::Start(); |
|
432 |
|
433 // Check for no errors |
|
434 iLog->Log(_L("CheckOperationL")); |
|
435 activeLmOperation->CheckOperationL(); |
|
436 delete iOperation; |
|
437 iOperation = NULL; |
|
438 CleanupStack::PopAndDestroy(activeLmOperation); |
|
439 |
|
440 // Check data here |
|
441 HBufC8* filecontent6 = HBufC8::NewLC(myEncoderBuffer6->Size()); |
|
442 TPtr8 ptr6 = filecontent6->Des(); |
|
443 myEncoderBuffer6->Read(0, ptr6, myEncoderBuffer6->Size()); |
|
444 ParseAndCheckDataFromEncoderL(KNullDesC, _L("TP43CollectionDataNameBuffer4"), _L("TP43CollectionDataDescriptionBuffer4"), *filecontent6); |
|
445 myEncoderBuffer6->Reset(); |
|
446 CleanupStack::PopAndDestroy(filecontent6); |
|
447 CleanupStack::PopAndDestroy(myEncoderBuffer6); |
|
448 |
|
449 delete iLandmarkEncoder; |
|
450 iLandmarkEncoder = NULL; |
|
451 |
|
452 DeleteFileL(KFileLongCollectionFieldName); |
|
453 // Test with file |
|
454 TestLongCollectionFieldsL(ETrue); |
|
455 // Test with buffer |
|
456 TestLongCollectionFieldsL(EFalse); |
|
457 |
|
458 // Check that all created XML files are correct by comparing to saved files |
|
459 iLog->Log(_L("Comparing files...")); |
|
460 |
|
461 TFileName filename; |
|
462 CreateCorrectXmlFileL( KFileNameCorrect, filename ); |
|
463 CompareTwoFilesL(filename, KFileName); |
|
464 |
|
465 CreateCorrectXmlFileL( KFileName2Correct, filename ); |
|
466 CompareTwoFilesL(filename, KFileName2); |
|
467 |
|
468 CreateCorrectXmlFileL( KFileName3Correct, filename ); |
|
469 CompareTwoFilesL(filename, KFileName3); |
|
470 |
|
471 CreateCorrectXmlFileL( KFileName4Correct, filename ); |
|
472 CompareTwoFilesL(filename, KFileName4); |
|
473 |
|
474 CreateCorrectXmlFileL( KFileEmptyCollectionDataCorrect, filename ); |
|
475 CompareTwoFilesL(filename, KFileEmptyCollectionData); |
|
476 |
|
477 CreateCorrectXmlFileL( KFileEmptyCollectionData2Correct, filename ); |
|
478 CompareTwoFilesL(filename, KFileEmptyCollectionData2); |
|
479 |
|
480 CreateCorrectXmlFileL( KFileLongCollectionFieldNameCorrect, filename ); |
|
481 CompareTwoFilesL(filename, KFileLongCollectionFieldName); |
|
482 |
|
483 // Test for correct leave codes |
|
484 TestErrorScenariosL(); |
|
485 |
|
486 // check for correct output |
|
487 CreateCorrectXmlFileL( KErrorScenario4FileCorrect, filename ); |
|
488 CompareTwoFilesL(filename, KErrorScenario4File); |
|
489 |
|
490 CreateCorrectXmlFileL( KErrorScenario5FileCorrect, filename ); |
|
491 CompareTwoFilesL(filename, KErrorScenario5File); |
|
492 |
|
493 // Test to encode to file with long filename (more than 255 characters) |
|
494 TestWithLongFileNameL(); |
|
495 |
|
496 if (iErrorsFound != KErrNone) |
|
497 { |
|
498 iLog->Log(_L("Errors found in TP43")); |
|
499 User::Leave(-1); |
|
500 } |
|
501 } |
|
502 |
|
503 // --------------------------------------------------------- |
|
504 // CPosTp43::CreateEncoderPartsL |
|
505 // |
|
506 // (other items were commented in a header). |
|
507 // --------------------------------------------------------- |
|
508 // |
|
509 void CPosTp43::CreateEncoderPartsL() |
|
510 { |
|
511 iLog->Log(_L("CreateEncoderPartsL")); |
|
512 // 3 Add one landmark to be encoded (id7 name "Billigt" in categories 1-3,14-17) |
|
513 CPosLandmark* lm1 = iDatabase->ReadLandmarkLC(7); |
|
514 iLandmarkEncoder->AddLandmarkL(*lm1); |
|
515 // Remove field 408 which is not exported |
|
516 lm1->RemovePositionField(408); |
|
517 iLandmarks.Append(lm1); |
|
518 CleanupStack::Pop(lm1); |
|
519 // 4 Add one more landmark to be encoded (id27 "LOG9" in categories 11-17) |
|
520 CPosLandmark* lm2 = iDatabase->ReadLandmarkLC(27); |
|
521 iLandmarkEncoder->AddLandmarkL(*lm2); |
|
522 // Remove field 408 which is not exported |
|
523 lm2->RemovePositionField(408); |
|
524 iLandmarks.Append(lm2); |
|
525 CleanupStack::Pop(lm2); |
|
526 |
|
527 // 5 Add one category to the latest added landmark |
|
528 CPosLmCategoryManager* categoryManager = CPosLmCategoryManager::NewL(*iDatabase); |
|
529 CleanupStack::PushL(categoryManager); |
|
530 CPosLandmarkCategory* landmarkCategory = categoryManager->ReadCategoryLC(1); |
|
531 |
|
532 iLandmarkEncoder->AddCategoryForLatestLandmarkL(*landmarkCategory); |
|
533 CleanupStack::PopAndDestroy(landmarkCategory); |
|
534 CleanupStack::PopAndDestroy(categoryManager); |
|
535 |
|
536 // 6 Add one more landmark to be encoded (id52 "Kalles Hundgård" in category 19) |
|
537 lm2 = iDatabase->ReadLandmarkLC(52); |
|
538 iLandmarkEncoder->AddLandmarkL(*lm2); |
|
539 // Remove field 408 which is not exported |
|
540 lm2->RemovePositionField(408); |
|
541 iLandmarks.Append(lm2); |
|
542 CleanupStack::Pop(lm2); |
|
543 |
|
544 // 7 Add several global and local categories to the latest added landmark |
|
545 categoryManager = CPosLmCategoryManager::NewL(*iDatabase); |
|
546 CleanupStack::PushL(categoryManager); |
|
547 landmarkCategory = categoryManager->ReadCategoryLC(26); |
|
548 iLandmarkEncoder->AddCategoryForLatestLandmarkL(*landmarkCategory); |
|
549 CleanupStack::PopAndDestroy(landmarkCategory); |
|
550 |
|
551 landmarkCategory = categoryManager->ReadCategoryLC(25); |
|
552 iLandmarkEncoder->AddCategoryForLatestLandmarkL(*landmarkCategory); |
|
553 CleanupStack::PopAndDestroy(landmarkCategory); |
|
554 |
|
555 TPosLmItemId globalCategoryId = categoryManager->GetGlobalCategoryL(3000); |
|
556 if (globalCategoryId != KPosLmNullItemId) |
|
557 { |
|
558 landmarkCategory = categoryManager->ReadCategoryLC(globalCategoryId); |
|
559 iLandmarkEncoder->AddCategoryForLatestLandmarkL(*landmarkCategory); |
|
560 CleanupStack::PopAndDestroy(landmarkCategory); |
|
561 } |
|
562 else |
|
563 { |
|
564 iLog->Log(_L("Global category was not found1")); |
|
565 User::Leave(-1); |
|
566 } |
|
567 |
|
568 //globalCategoryId = categoryManager->GetGlobalCategoryL(6000); |
|
569 globalCategoryId = categoryManager->GetGlobalCategoryL(15000); |
|
570 if (globalCategoryId != KPosLmNullItemId) |
|
571 { |
|
572 landmarkCategory = categoryManager->ReadCategoryLC(globalCategoryId); |
|
573 iLandmarkEncoder->AddCategoryForLatestLandmarkL(*landmarkCategory); |
|
574 CleanupStack::PopAndDestroy(landmarkCategory); |
|
575 } |
|
576 else |
|
577 { |
|
578 iLog->Log(_L("Global category was not found2")); |
|
579 User::Leave(-1); |
|
580 } |
|
581 |
|
582 CleanupStack::PopAndDestroy(categoryManager); |
|
583 |
|
584 // 8 Add one landmark (not containing any categories), id=11 "MLFW" |
|
585 lm2 = iDatabase->ReadLandmarkLC(11); |
|
586 iLandmarkEncoder->AddLandmarkL(*lm2); |
|
587 // Remove field 408 which is not exported |
|
588 lm2->RemovePositionField(408); |
|
589 iLandmarks.Append(lm2); |
|
590 CleanupStack::Pop(lm2); |
|
591 |
|
592 // 9 Add one more landmark (not containing any categories), id=56 "TE, Lund" |
|
593 lm2 = iDatabase->ReadLandmarkLC(56); |
|
594 iLandmarkEncoder->AddLandmarkL(*lm2); |
|
595 // Remove field 408 which is not exported |
|
596 lm2->RemovePositionField(408); |
|
597 iLandmarks.Append(lm2); |
|
598 CleanupStack::Pop(lm2); |
|
599 |
|
600 // 10 Add one category to the latest added landmark |
|
601 categoryManager = CPosLmCategoryManager::NewL(*iDatabase); |
|
602 CleanupStack::PushL(categoryManager); |
|
603 landmarkCategory = categoryManager->ReadCategoryLC(18); |
|
604 |
|
605 iLandmarkEncoder->AddCategoryForLatestLandmarkL(*landmarkCategory); |
|
606 CleanupStack::PopAndDestroy(landmarkCategory); |
|
607 CleanupStack::PopAndDestroy(categoryManager); |
|
608 |
|
609 // 11 Add one landmark (not containing any categories), id=43 "asdf" |
|
610 lm2 = iDatabase->ReadLandmarkLC(43); |
|
611 iLandmarkEncoder->AddLandmarkL(*lm2); |
|
612 // Remove field 408 which is not exported |
|
613 lm2->RemovePositionField(408); |
|
614 iLandmarks.Append(lm2); |
|
615 CleanupStack::Pop(lm2); |
|
616 |
|
617 // 12 Add several local and global categories to the latest added landmark |
|
618 categoryManager = CPosLmCategoryManager::NewL(*iDatabase); |
|
619 CleanupStack::PushL(categoryManager); |
|
620 landmarkCategory = categoryManager->ReadCategoryLC(23); |
|
621 |
|
622 iLandmarkEncoder->AddCategoryForLatestLandmarkL(*landmarkCategory); |
|
623 CleanupStack::PopAndDestroy(landmarkCategory); |
|
624 landmarkCategory = categoryManager->ReadCategoryLC(17); |
|
625 |
|
626 iLandmarkEncoder->AddCategoryForLatestLandmarkL(*landmarkCategory); |
|
627 CleanupStack::PopAndDestroy(landmarkCategory); |
|
628 |
|
629 |
|
630 globalCategoryId = categoryManager->GetGlobalCategoryL(24000); |
|
631 if (globalCategoryId != KPosLmNullItemId) |
|
632 { |
|
633 landmarkCategory = categoryManager->ReadCategoryLC(globalCategoryId); |
|
634 iLandmarkEncoder->AddCategoryForLatestLandmarkL(*landmarkCategory); |
|
635 CleanupStack::PopAndDestroy(landmarkCategory); |
|
636 } |
|
637 else |
|
638 { |
|
639 iLog->Log(_L("Global category was not found3")); |
|
640 User::Leave(-1); |
|
641 } |
|
642 |
|
643 |
|
644 globalCategoryId = categoryManager->GetGlobalCategoryL(27000); |
|
645 if (globalCategoryId != KPosLmNullItemId) |
|
646 { |
|
647 landmarkCategory = categoryManager->ReadCategoryLC(globalCategoryId); |
|
648 iLandmarkEncoder->AddCategoryForLatestLandmarkL(*landmarkCategory); |
|
649 CleanupStack::PopAndDestroy(landmarkCategory); |
|
650 } |
|
651 else |
|
652 { |
|
653 iLog->Log(_L("Global category was not found4")); |
|
654 User::Leave(-1); |
|
655 } |
|
656 |
|
657 // 13) Add a landmark with fields that are encoded to XML set |
|
658 lm1 = CreateXMLLandmarkLC(_L("TP43LandmarkWithAllXMLFields")); |
|
659 AddAllXMLFieldsL(lm1); |
|
660 iLandmarkEncoder->AddLandmarkL(*lm1); |
|
661 iLandmarks.Append(lm1); |
|
662 CleanupStack::Pop(lm1); |
|
663 |
|
664 // 13) Add one global category (Garage) to the latest added landmark |
|
665 globalCategoryId = categoryManager->GetGlobalCategoryL(36000); |
|
666 if (globalCategoryId != KPosLmNullItemId) |
|
667 { |
|
668 landmarkCategory = categoryManager->ReadCategoryLC(globalCategoryId); |
|
669 iLandmarkEncoder->AddCategoryForLatestLandmarkL(*landmarkCategory); |
|
670 CleanupStack::PopAndDestroy(landmarkCategory); |
|
671 } |
|
672 else |
|
673 { |
|
674 iLog->Log(_L("Global category was not found3")); |
|
675 User::Leave(-1); |
|
676 } |
|
677 |
|
678 // 14) Add one global category (Bus stop) to the latest added landmark |
|
679 globalCategoryId = categoryManager->GetGlobalCategoryL(39000); |
|
680 if (globalCategoryId != KPosLmNullItemId) |
|
681 { |
|
682 landmarkCategory = categoryManager->ReadCategoryLC(globalCategoryId); |
|
683 iLandmarkEncoder->AddCategoryForLatestLandmarkL(*landmarkCategory); |
|
684 CleanupStack::PopAndDestroy(landmarkCategory); |
|
685 } |
|
686 else |
|
687 { |
|
688 iLog->Log(_L("Global category was not found4")); |
|
689 User::Leave(-1); |
|
690 } |
|
691 |
|
692 // 15) Add one category (BurgerKing) to the latest added landmark |
|
693 landmarkCategory = categoryManager->ReadCategoryLC(17); |
|
694 |
|
695 iLandmarkEncoder->AddCategoryForLatestLandmarkL(*landmarkCategory); |
|
696 CleanupStack::PopAndDestroy(landmarkCategory); |
|
697 |
|
698 CleanupStack::PopAndDestroy(categoryManager); |
|
699 iLog->Log(_L("CreateEncoderParts Done")); |
|
700 } |
|
701 |
|
702 // --------------------------------------------------------- |
|
703 // CPosTp43::PrintLandmarkIdFieldsL |
|
704 // |
|
705 // (other items were commented in a header). |
|
706 // --------------------------------------------------------- |
|
707 // |
|
708 void CPosTp43::PrintLandmarkIdFieldsL(const CPosLandmark& aLandmark) |
|
709 { |
|
710 TPositionFieldId sourceFieldId = aLandmark.FirstPositionFieldId(); |
|
711 TLocality loc; |
|
712 TBuf<150> buf; |
|
713 TInt err = aLandmark.GetPosition(loc); |
|
714 if (err == KErrNone) |
|
715 { |
|
716 TReal vertAcc(loc.VerticalAccuracy()); |
|
717 TReal horAcc(loc.HorizontalAccuracy()); |
|
718 TReal alt(loc.Altitude()); |
|
719 TReal lon = loc.Longitude(); |
|
720 TReal lat = loc.Latitude(); |
|
721 TReal32 sourceR; |
|
722 err = aLandmark.GetCoverageRadius(sourceR); |
|
723 if (err == KErrNone ) |
|
724 { |
|
725 buf.Format(_L("LM: Long %f Lat %f vertAcc %f horAcc %f alt %f srcRadius %f"), lon, lat, vertAcc, horAcc, alt, sourceR); |
|
726 } |
|
727 else |
|
728 { |
|
729 buf.Format(_L("LM: Long %f Lat %f vertAcc %f horAcc %f alt %f "), lon, lat, vertAcc, horAcc, alt); |
|
730 } |
|
731 //iLog->Log(buf); |
|
732 } |
|
733 |
|
734 while (sourceFieldId != EPositionFieldNone) |
|
735 { |
|
736 TPtrC sourceValue; |
|
737 aLandmark.GetPositionField(sourceFieldId, sourceValue); |
|
738 buf.Format(_L("IdField Id: %d Value:"), sourceFieldId); |
|
739 buf.Append(sourceValue); |
|
740 //iLog->Log(buf); |
|
741 sourceFieldId = aLandmark.NextPositionFieldId(sourceFieldId); |
|
742 } |
|
743 } |
|
744 |
|
745 // --------------------------------------------------------- |
|
746 // CPosTp43::PrintParsedDataFromEncoderL |
|
747 // |
|
748 // (other items were commented in a header). |
|
749 // --------------------------------------------------------- |
|
750 // |
|
751 void CPosTp43::PrintParsedDataFromEncoderL(const TDesC& aFile, const TDesC8& aBuffer) |
|
752 { |
|
753 iLog->Log(_L("PrintParsedDataFromEncoderL")); |
|
754 |
|
755 iLandmarkParser = CPosLandmarkParser::NewL(KLmxMimeType); |
|
756 |
|
757 if (aFile != KNullDesC) |
|
758 { |
|
759 iLog->Log(_L("----->Using FILE<-------")); |
|
760 iLandmarkParser->SetInputFileL(aFile); |
|
761 } |
|
762 else |
|
763 { |
|
764 iLog->Log(_L("----->Using BUFFER<-------")); |
|
765 iLandmarkParser->SetInputBuffer(aBuffer); |
|
766 } |
|
767 |
|
768 iOperation = iLandmarkParser->ParseContentL(); |
|
769 TRequestStatus status = KPosLmOperationNotComplete; |
|
770 TReal32 progress; |
|
771 TInt number = 0; |
|
772 |
|
773 RArray<TPosLmItemId> array; |
|
774 CleanupClosePushL(array); |
|
775 |
|
776 while (status == KPosLmOperationNotComplete) |
|
777 { |
|
778 //iLog->Log(_L("------------------------------")); |
|
779 iOperation->NextStep(status, progress); |
|
780 |
|
781 // Wait for NextStep to complete |
|
782 User::WaitForRequest(status); |
|
783 // Get last parsed landmark |
|
784 CPosLandmark* lm = iLandmarkParser->LandmarkLC(); |
|
785 TPtrC lmName; |
|
786 TPtrC catName; |
|
787 lm->GetLandmarkName(lmName); |
|
788 lm->GetCategoriesL(array); |
|
789 //iLog->Log(lmName); |
|
790 for (TInt i=0;i<array.Count();i++) |
|
791 { |
|
792 TBuf<150> buf; |
|
793 CPosLandmarkCategory* category = iLandmarkParser->LandmarkCategoryLC(array[i]); |
|
794 |
|
795 if (category->GlobalCategory()) buf.Append(_L("Global category: ")); |
|
796 else buf.Append(_L("Local category: ")); |
|
797 category->GetCategoryName(catName); |
|
798 buf.Append(catName); |
|
799 //iLog->Log(buf); |
|
800 CleanupStack::PopAndDestroy(category); |
|
801 } |
|
802 PrintLandmarkIdFieldsL(*lm); |
|
803 //iLog->Log(_L("---------->")); |
|
804 PrintLandmarkIdFieldsL(*iLandmarks[number]); |
|
805 //iLog->Log(_L("<----------")); |
|
806 number++; |
|
807 // CPosLmOperation::NextStep call will parse a new landmark. |
|
808 CleanupStack::PopAndDestroy(lm); |
|
809 } |
|
810 |
|
811 //iLog->Log(_L("------------------------------")); |
|
812 CleanupStack::PopAndDestroy(&array); |
|
813 |
|
814 TPosLmCollectionDataId lmId = iLandmarkParser->FirstCollectionDataId(); |
|
815 |
|
816 //iLog->Log(_L("----->CollectionData")); |
|
817 |
|
818 TBuf<100> buf; |
|
819 if (lmId != EPosLmCollDataNone) |
|
820 { |
|
821 TPtrC first = iLandmarkParser->CollectionData(lmId); |
|
822 buf.Format(_L("Collectiond Id: %d CollectionData: "), lmId); |
|
823 buf.Append(first); |
|
824 //iLog->Log(buf); |
|
825 } |
|
826 //else iLog->Log(_L("No collection data found 1")); |
|
827 |
|
828 while (lmId != EPosLmCollDataNone) |
|
829 { |
|
830 lmId = iLandmarkParser->NextCollectionDataId(lmId); |
|
831 if (lmId != EPosLmCollDataNone) |
|
832 { |
|
833 TPtrC first = iLandmarkParser->CollectionData(lmId); |
|
834 buf.Format(_L("Collectiond Id: %d CollectionData: "), lmId); |
|
835 buf.Append(first); |
|
836 //iLog->Log(buf); |
|
837 } |
|
838 //else iLog->Log(_L("No collection data found 2")); |
|
839 } |
|
840 |
|
841 //iLog->Log(_L("<-----CollectionData")); |
|
842 |
|
843 delete iOperation; |
|
844 iOperation = NULL; |
|
845 delete iLandmarkParser; |
|
846 iLandmarkParser = NULL; |
|
847 iLog->Log(_L("PrintParsedDataFromEncoderL Done")); |
|
848 } |
|
849 |
|
850 // --------------------------------------------------------- |
|
851 // CPosTp43::ParseAndCheckDataFromEncoderL |
|
852 // |
|
853 // (other items were commented in a header). |
|
854 // --------------------------------------------------------- |
|
855 // |
|
856 void CPosTp43::ParseAndCheckDataFromEncoderL(const TDesC& aFile , const TDesC& aCollectionName, |
|
857 const TDesC& aCollectiondDescription, const TDesC8& aBuffer) |
|
858 { |
|
859 iLog->Log(_L("ParseAndCheckDataFromEncoderL")); |
|
860 |
|
861 PrintParsedDataFromEncoderL(aFile, aBuffer); |
|
862 |
|
863 CPosLmCategoryManager* categoryManager = CPosLmCategoryManager::NewL(*iDatabase); |
|
864 CleanupStack::PushL(categoryManager); |
|
865 |
|
866 iLandmarkParser = CPosLandmarkParser::NewL(KLmxMimeType); |
|
867 |
|
868 if (aFile != KNullDesC) |
|
869 { |
|
870 //iLog->Log(_L("----->Using FILE<-------")); |
|
871 iLandmarkParser->SetInputFileL(aFile); |
|
872 } |
|
873 else |
|
874 { |
|
875 //iLog->Log(_L("----->Using BUFFER<-------")); |
|
876 iLandmarkParser->SetInputBuffer(aBuffer); |
|
877 } |
|
878 |
|
879 iLog->Log(_L("ParseContentL")); |
|
880 iOperation = iLandmarkParser->ParseContentL(); |
|
881 iLog->Log(_L("ParseContentL Done")); |
|
882 |
|
883 TRequestStatus status = KPosLmOperationNotComplete; |
|
884 TReal32 progress; |
|
885 TInt number = 0; |
|
886 |
|
887 RArray<TPosLmItemId> array; |
|
888 CleanupClosePushL(array); |
|
889 |
|
890 // 1) Get the first landmark, "Billigt", no categories |
|
891 iOperation->NextStep(status, progress); |
|
892 // Wait for NextStep to complete |
|
893 User::WaitForRequest(status); |
|
894 // Get last parsed landmark |
|
895 CPosLandmark* lm = iLandmarkParser->LandmarkLC(); |
|
896 lm->GetCategoriesL(array); |
|
897 AssertTrueSecL(array.Count() == 0, _L("Wrong number of landmark categories")); |
|
898 iErrorsFound += CompareXMLLandmarksL(*iLandmarks[number++], *lm); |
|
899 CleanupStack::PopAndDestroy(lm); |
|
900 |
|
901 // 2) Get LOG9, included category Pizzeria |
|
902 iOperation->NextStep(status, progress); |
|
903 // Wait for NextStep to complete |
|
904 User::WaitForRequest(status); |
|
905 // Get last parsed landmark |
|
906 lm = iLandmarkParser->LandmarkLC(); |
|
907 lm->GetCategoriesL(array); |
|
908 AssertTrueSecL(array.Count() == 1, _L("Wrong number of landmark categories")); |
|
909 iErrorsFound += CompareXMLLandmarksL(*iLandmarks[number++], *lm); |
|
910 CPosLandmarkCategory* category = iLandmarkParser->LandmarkCategoryLC(array[0]); |
|
911 CPosLandmarkCategory* cat = categoryManager->ReadCategoryLC(1); |
|
912 iErrorsFound += CompareXMLCategoriesL(*cat, *category); |
|
913 CleanupStack::PopAndDestroy(cat); |
|
914 CleanupStack::PopAndDestroy(category); |
|
915 CleanupStack::PopAndDestroy(lm); |
|
916 |
|
917 // 3) Get Kalles Hundgård, included categories sjukhus, läkare, global Restaurant, Shop |
|
918 iOperation->NextStep(status, progress); |
|
919 // Wait for NextStep to complete |
|
920 User::WaitForRequest(status); |
|
921 // Get last parsed landmark |
|
922 lm = iLandmarkParser->LandmarkLC(); |
|
923 lm->GetCategoriesL(array); |
|
924 if (array.Count()!=4) |
|
925 { |
|
926 iLog->Log(_L("ERROR: Wrong number of landmark categories")); |
|
927 iErrorsFound++; |
|
928 } |
|
929 iErrorsFound += CompareXMLLandmarksL(*iLandmarks[number++], *lm); |
|
930 |
|
931 category = iLandmarkParser->LandmarkCategoryLC(array[0]); |
|
932 cat = categoryManager->ReadCategoryLC(26); |
|
933 iErrorsFound += CompareXMLCategoriesL(*cat, *category); |
|
934 CleanupStack::PopAndDestroy(cat); |
|
935 CleanupStack::PopAndDestroy(category); |
|
936 |
|
937 category = iLandmarkParser->LandmarkCategoryLC(array[1]); |
|
938 cat = categoryManager->ReadCategoryLC(25); |
|
939 iErrorsFound += CompareXMLCategoriesL(*cat, *category); |
|
940 CleanupStack::PopAndDestroy(cat); |
|
941 CleanupStack::PopAndDestroy(category); |
|
942 |
|
943 //Check global category "id=1 Restaurant" here |
|
944 category = iLandmarkParser->LandmarkCategoryLC(array[2]); |
|
945 cat = categoryManager->ReadCategoryLC(27); |
|
946 iErrorsFound += CompareXMLCategoriesL(*cat, *category); |
|
947 CleanupStack::PopAndDestroy(cat); |
|
948 CleanupStack::PopAndDestroy(category); |
|
949 |
|
950 //Check global category "id=5 Shop" here |
|
951 if (array.Count()== 4) |
|
952 { |
|
953 category = iLandmarkParser->LandmarkCategoryLC(array[3]); |
|
954 cat = categoryManager->ReadCategoryLC(31);//28 |
|
955 iErrorsFound += CompareXMLCategoriesL(*cat, *category); |
|
956 CleanupStack::PopAndDestroy(cat); |
|
957 CleanupStack::PopAndDestroy(category); |
|
958 } |
|
959 |
|
960 CleanupStack::PopAndDestroy(lm); |
|
961 |
|
962 // 4) Get MLFW, no categories |
|
963 iOperation->NextStep(status, progress); |
|
964 // Wait for NextStep to complete |
|
965 User::WaitForRequest(status); |
|
966 // Get last parsed landmark |
|
967 lm = iLandmarkParser->LandmarkLC(); |
|
968 lm->GetCategoriesL(array); |
|
969 AssertTrueSecL(array.Count() == 0, _L("Wrong number of landmark categories")); |
|
970 iErrorsFound += CompareXMLLandmarksL(*iLandmarks[number++], *lm); |
|
971 CleanupStack::PopAndDestroy(lm); |
|
972 |
|
973 // 5) Get Te, Lund category Frisör |
|
974 iOperation->NextStep(status, progress); |
|
975 // Wait for NextStep to complete |
|
976 User::WaitForRequest(status); |
|
977 // Get last parsed landmark |
|
978 lm = iLandmarkParser->LandmarkLC(); |
|
979 lm->GetCategoriesL(array); |
|
980 AssertTrueSecL(array.Count() == 1, _L("Wrong number of landmark categories")); |
|
981 iErrorsFound += CompareXMLLandmarksL(*iLandmarks[number++], *lm); |
|
982 |
|
983 category = iLandmarkParser->LandmarkCategoryLC(array[0]); |
|
984 cat = categoryManager->ReadCategoryLC(18); |
|
985 iErrorsFound += CompareXMLCategoriesL(*cat, *category); |
|
986 CleanupStack::PopAndDestroy(cat); |
|
987 CleanupStack::PopAndDestroy(category); |
|
988 CleanupStack::PopAndDestroy(lm); |
|
989 |
|
990 // 6) Get asdf, category Dagis, Burger King and global hotel, car park |
|
991 iOperation->NextStep(status, progress); |
|
992 // Wait for NextStep to complete |
|
993 User::WaitForRequest(status); |
|
994 // Get last parsed landmark |
|
995 lm = iLandmarkParser->LandmarkLC(); |
|
996 lm->GetCategoriesL(array); |
|
997 AssertTrueSecL(array.Count() == 4, _L("Wrong number of landmark categories")); |
|
998 iErrorsFound += CompareXMLLandmarksL(*iLandmarks[number++], *lm); |
|
999 |
|
1000 category = iLandmarkParser->LandmarkCategoryLC(array[0]); |
|
1001 cat = categoryManager->ReadCategoryLC(23); |
|
1002 iErrorsFound += CompareXMLCategoriesL(*cat, *category); |
|
1003 CleanupStack::PopAndDestroy(cat); |
|
1004 CleanupStack::PopAndDestroy(category); |
|
1005 |
|
1006 category = iLandmarkParser->LandmarkCategoryLC(array[1]); |
|
1007 cat = categoryManager->ReadCategoryLC(17); |
|
1008 iErrorsFound += CompareXMLCategoriesL(*cat, *category); |
|
1009 CleanupStack::PopAndDestroy(cat); |
|
1010 CleanupStack::PopAndDestroy(category); |
|
1011 |
|
1012 //Check global category "id=4 Hotel" here |
|
1013 category = iLandmarkParser->LandmarkCategoryLC(array[2]); |
|
1014 cat = categoryManager->ReadCategoryLC(34);//39 |
|
1015 iErrorsFound += CompareXMLCategoriesL(*cat, *category); |
|
1016 CleanupStack::PopAndDestroy(cat); |
|
1017 CleanupStack::PopAndDestroy(category); |
|
1018 |
|
1019 //Check global category "id=9 Car Park" here |
|
1020 category = iLandmarkParser->LandmarkCategoryLC(array[3]); |
|
1021 cat = categoryManager->ReadCategoryLC(35);//30 |
|
1022 iErrorsFound += CompareXMLCategoriesL(*cat, *category); |
|
1023 CleanupStack::PopAndDestroy(cat); |
|
1024 CleanupStack::PopAndDestroy(category); |
|
1025 CleanupStack::PopAndDestroy(lm); |
|
1026 |
|
1027 // 7) Get TP43LandmarkWithAllXMLFields, category Burger King and global Garage, Bus stop |
|
1028 iOperation->NextStep(status, progress); |
|
1029 // Wait for NextStep to complete |
|
1030 User::WaitForRequest(status); |
|
1031 // Get last parsed landmark |
|
1032 lm = iLandmarkParser->LandmarkLC(); |
|
1033 lm->GetCategoriesL(array); |
|
1034 AssertTrueSecL(array.Count() == 3, _L("Wrong number of landmark categories")); |
|
1035 iErrorsFound += CompareXMLLandmarksL(*iLandmarks[number++], *lm); |
|
1036 |
|
1037 //Check global category "id=4 Garage" here |
|
1038 category = iLandmarkParser->LandmarkCategoryLC(array[0]); |
|
1039 cat = categoryManager->ReadCategoryLC(38);//31 |
|
1040 iErrorsFound += CompareXMLCategoriesL(*cat, *category); |
|
1041 CleanupStack::PopAndDestroy(cat); |
|
1042 CleanupStack::PopAndDestroy(category); |
|
1043 |
|
1044 //Check global category "id=10 Bus Stop" here |
|
1045 category = iLandmarkParser->LandmarkCategoryLC(array[1]); |
|
1046 cat = categoryManager->ReadCategoryLC(39);//34 |
|
1047 iErrorsFound += CompareXMLCategoriesL(*cat, *category); |
|
1048 CleanupStack::PopAndDestroy(cat); |
|
1049 CleanupStack::PopAndDestroy(category); |
|
1050 |
|
1051 // Check local category here, burger king |
|
1052 category = iLandmarkParser->LandmarkCategoryLC(array[2]); |
|
1053 cat = categoryManager->ReadCategoryLC(17); |
|
1054 iErrorsFound += CompareXMLCategoriesL(*cat, *category); |
|
1055 CleanupStack::PopAndDestroy(cat); |
|
1056 CleanupStack::PopAndDestroy(category); |
|
1057 |
|
1058 CleanupStack::PopAndDestroy(lm); |
|
1059 |
|
1060 // Check that correct number of landmarks has been parsed |
|
1061 if (number != KNrOfAddedLandmarks) |
|
1062 { |
|
1063 iLog->Log(_L("Wrong number of landmarks parsed")); |
|
1064 User::Leave(-1); |
|
1065 } |
|
1066 TUint32 nr = iLandmarkParser->NumOfParsedLandmarks(); |
|
1067 if ((TInt)nr != KNrOfAddedLandmarks) |
|
1068 { |
|
1069 iLog->Log(_L("Wrong number of landmarks parsed")); |
|
1070 User::Leave(-1); |
|
1071 } |
|
1072 |
|
1073 CleanupStack::PopAndDestroy(&array); |
|
1074 |
|
1075 TPosLmCollectionDataId lmId = iLandmarkParser->FirstCollectionDataId(); |
|
1076 // Check that collection data and name is correct |
|
1077 if (lmId == EPosLmCollDataCollectionName) |
|
1078 { |
|
1079 TPtrC first = iLandmarkParser->CollectionData(lmId); |
|
1080 if (aCollectionName != first) |
|
1081 { |
|
1082 |
|
1083 iLog->Log(_L("CollectionName does not match")); |
|
1084 User::Leave(-1); |
|
1085 } |
|
1086 } |
|
1087 else if (lmId == EPosLmCollDataNone) |
|
1088 { |
|
1089 if (aCollectionName != KNullDesC) |
|
1090 { |
|
1091 iLog->Log(_L("ERROR: CollectionName should be defined")); |
|
1092 iErrorsFound++; |
|
1093 } |
|
1094 } |
|
1095 else |
|
1096 { |
|
1097 iLog->Log(_L("Wrong order of collection data1")); |
|
1098 User::Leave(-1); |
|
1099 } |
|
1100 |
|
1101 lmId = iLandmarkParser->NextCollectionDataId(lmId); |
|
1102 |
|
1103 if (lmId == EPosLmCollDataCollectionDescription) |
|
1104 { |
|
1105 TPtrC first = iLandmarkParser->CollectionData(lmId); |
|
1106 if (aCollectiondDescription != first) |
|
1107 { |
|
1108 |
|
1109 iLog->Log(_L("CollectionDescription does not match")); |
|
1110 User::Leave(-1); |
|
1111 } |
|
1112 } |
|
1113 else if (lmId == EPosLmCollDataNone) |
|
1114 { |
|
1115 if (aCollectiondDescription != KNullDesC) |
|
1116 { |
|
1117 |
|
1118 iLog->Log(_L(" CollectionDescription should be defined")); |
|
1119 User::Leave(KErrNone); |
|
1120 } |
|
1121 } |
|
1122 else |
|
1123 { |
|
1124 iLog->Log(_L("Wrong order of collection data2 ")); |
|
1125 User::Leave(-1); |
|
1126 } |
|
1127 |
|
1128 // Test with some non existing ids |
|
1129 lmId = iLandmarkParser->NextCollectionDataId((TPosLmCollectionDataId)66700); |
|
1130 if (lmId != EPosLmCollDataNone) |
|
1131 { |
|
1132 iLog->Log(_L("ERROR: No collection data should be found")); |
|
1133 iErrorsFound++; |
|
1134 } |
|
1135 |
|
1136 TPtrC empty = iLandmarkParser->CollectionData((TPosLmCollectionDataId)66700); |
|
1137 if (empty != KNullDesC) |
|
1138 { |
|
1139 iLog->Log(_L("ERROR: CollectionData should be emtpy")); |
|
1140 iErrorsFound++; |
|
1141 } |
|
1142 |
|
1143 delete iOperation; |
|
1144 iOperation = NULL; |
|
1145 delete iLandmarkParser; |
|
1146 iLandmarkParser = NULL; |
|
1147 |
|
1148 CleanupStack::PopAndDestroy(categoryManager); |
|
1149 iLandmarks.ResetAndDestroy(); |
|
1150 |
|
1151 iLog->Log(_L("ParseAndCheckDataFromEncoderL Done")); |
|
1152 } |
|
1153 |
|
1154 // --------------------------------------------------------- |
|
1155 // CPosTp43::CompareTwoFilesL |
|
1156 // |
|
1157 // (other items were commented in a header). |
|
1158 // --------------------------------------------------------- |
|
1159 // |
|
1160 void CPosTp43::CompareTwoFilesL(const TDesC16& aCorrectFile, const TDesC16& aFile) |
|
1161 { |
|
1162 iLog->Log(_L("ComparingTwoFilesL")); |
|
1163 // Now compare tha trace file against the correct one |
|
1164 RFile correctFile; |
|
1165 RFile file; |
|
1166 |
|
1167 TBuf<150> buf; |
|
1168 buf.Append(_L("Comparing files ")); |
|
1169 buf.Append(aCorrectFile); |
|
1170 buf.Append(_L(" and ")); |
|
1171 buf.Append(aFile); |
|
1172 iLog->Log(buf); |
|
1173 |
|
1174 CleanupClosePushL(correctFile); |
|
1175 CleanupClosePushL(file); |
|
1176 TInt err = KErrNone; |
|
1177 err = correctFile.Open(iFileSession, aCorrectFile, EFileRead); |
|
1178 if (err != KErrNone) |
|
1179 { |
|
1180 iLog->Log(_L(" Problem with correct file")); |
|
1181 User::Leave(err); |
|
1182 } |
|
1183 err = file.Open(iFileSession, aFile, EFileRead); |
|
1184 if (err != KErrNone) |
|
1185 { |
|
1186 iLog->Log(_L(" Problem with encoded XML file")); |
|
1187 User::Leave(err); |
|
1188 } |
|
1189 |
|
1190 TBuf<KBufSize> correctLine; |
|
1191 TBuf<KBufSize> line; |
|
1192 TBool done = EFalse; |
|
1193 TInt lineNr = 0; |
|
1194 |
|
1195 while (ReadLn(correctFile, correctLine) != KErrEof && !done) |
|
1196 { |
|
1197 lineNr++; |
|
1198 err = ReadLn(file, line); |
|
1199 if (err == KErrEof) done = ETrue; |
|
1200 |
|
1201 if (correctLine.CompareC(line) != KErrNone) |
|
1202 { |
|
1203 TBuf<50> buffe; |
|
1204 buffe.Format(_L("ERROR in XML file on line %d: "), lineNr); |
|
1205 iLog->Log(buffe); |
|
1206 iLog->Log(correctLine); |
|
1207 iLog->Log(line); |
|
1208 iErrorsFound++; |
|
1209 } |
|
1210 } |
|
1211 |
|
1212 // EOF for trace file was reach before EOF in the correct file |
|
1213 if (done) |
|
1214 { |
|
1215 iLog->Log(_L("ERROR: EOF for Trace file was reached to early")); |
|
1216 iErrorsFound++; |
|
1217 } |
|
1218 |
|
1219 CleanupStack::PopAndDestroy(&file); |
|
1220 CleanupStack::PopAndDestroy(&correctFile); |
|
1221 } |
|
1222 |
|
1223 // --------------------------------------------------------- |
|
1224 // CPosTp43::TestLongCollectionFieldsL |
|
1225 // |
|
1226 // (other items were commented in a header). |
|
1227 // --------------------------------------------------------- |
|
1228 // |
|
1229 void CPosTp43::TestLongCollectionFieldsL(TBool aUseFile) |
|
1230 { |
|
1231 iLog->Log(_L("TestLongCollectionFieldsL")); |
|
1232 // 1) Create an encoder object |
|
1233 iLandmarkEncoder = CPosLandmarkEncoder::NewL(KLmxMimeType); |
|
1234 CBufBase* myEncoderBuffer = NULL; |
|
1235 HBufC8* filecontent = NULL; |
|
1236 |
|
1237 if (aUseFile) |
|
1238 { |
|
1239 // 2) Use file for encoding, set output file |
|
1240 iLandmarkEncoder->SetOutputFileL(KFileLongCollectionFieldName); |
|
1241 } |
|
1242 else |
|
1243 { |
|
1244 // 2) Use buffer for encoding |
|
1245 myEncoderBuffer = iLandmarkEncoder->SetUseOutputBufferL(); |
|
1246 CleanupStack::PushL(myEncoderBuffer); |
|
1247 } |
|
1248 |
|
1249 // 300 characters |
|
1250 _LIT(KLongFieldName, "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"); |
|
1251 _LIT(KLongFieldDescription, "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"); |
|
1252 |
|
1253 iLandmarkEncoder->AddCollectionDataL(EPosLmCollDataCollectionName, KLongFieldName); |
|
1254 iLandmarkEncoder->AddCollectionDataL(EPosLmCollDataCollectionDescription, KLongFieldDescription); |
|
1255 |
|
1256 iLog->Log(_L("Create Data...")); |
|
1257 // 3) Add one landmark to be encoded (id7 name "Billigt" in categories 1-3,14-17) |
|
1258 CPosLandmark* lm1 = iDatabase->ReadLandmarkLC(7); |
|
1259 iLandmarkEncoder->AddLandmarkL(*lm1); |
|
1260 // Remove field 408 which is not exported |
|
1261 lm1->RemovePositionField(408); |
|
1262 iLandmarks.Append(lm1); |
|
1263 CleanupStack::Pop(lm1); |
|
1264 // 4) Add one more landmark to be encoded (id27 "LOG9" in categories 11-17) |
|
1265 CPosLandmark* lm2 = iDatabase->ReadLandmarkLC(27); |
|
1266 iLandmarkEncoder->AddLandmarkL(*lm2); |
|
1267 // Remove field 408 which is not exported |
|
1268 lm2->RemovePositionField(408); |
|
1269 iLandmarks.Append(lm2); |
|
1270 CleanupStack::Pop(lm2); |
|
1271 |
|
1272 // 5) Add one category (pizzeria) to the latest added landmark |
|
1273 CPosLmCategoryManager* categoryManager = CPosLmCategoryManager::NewL(*iDatabase); |
|
1274 CleanupStack::PushL(categoryManager); |
|
1275 CPosLandmarkCategory* landmarkCategory = categoryManager->ReadCategoryLC(1); |
|
1276 |
|
1277 iLandmarkEncoder->AddCategoryForLatestLandmarkL(*landmarkCategory); |
|
1278 CleanupStack::PopAndDestroy(landmarkCategory); |
|
1279 CleanupStack::PopAndDestroy(categoryManager); |
|
1280 |
|
1281 // 6) Finalize encoding |
|
1282 iLog->Log(_L("FinalizeEncodingL")); |
|
1283 ExecuteAndDeleteLD(iLandmarkEncoder->FinalizeEncodingL()); |
|
1284 iLog->Log(_L("FinalizeEncodingL Done")); |
|
1285 |
|
1286 delete iLandmarkEncoder; |
|
1287 iLandmarkEncoder = NULL; |
|
1288 |
|
1289 // Check data |
|
1290 iLandmarkParser = CPosLandmarkParser::NewL(KLmxMimeType); |
|
1291 if (aUseFile) |
|
1292 { |
|
1293 iLog->Log(_L("----->Using FILE<-------")); |
|
1294 iLandmarkParser->SetInputFileL(KFileLongCollectionFieldName); |
|
1295 } |
|
1296 else |
|
1297 { |
|
1298 iLog->Log(_L("----->Using BUFFER<-------")); |
|
1299 filecontent = HBufC8::NewLC(myEncoderBuffer->Size()); |
|
1300 TPtr8 ptr = filecontent->Des(); |
|
1301 myEncoderBuffer->Read(0, ptr, myEncoderBuffer->Size()); |
|
1302 iLandmarkParser->SetInputBuffer(*filecontent); |
|
1303 ptr.Zero(); |
|
1304 } |
|
1305 |
|
1306 iLog->Log(_L("ParseContentL")); |
|
1307 iOperation = iLandmarkParser->ParseContentL(); |
|
1308 iLog->Log(_L("ParseContentL Done")); |
|
1309 |
|
1310 TRequestStatus status = KPosLmOperationNotComplete; |
|
1311 TReal32 progress; |
|
1312 TInt number = 0; |
|
1313 |
|
1314 RArray<TPosLmItemId> array; |
|
1315 CleanupClosePushL(array); |
|
1316 |
|
1317 // 1) Get the first landmark, "Billigt", no categories |
|
1318 iOperation->NextStep(status, progress); |
|
1319 // Wait for NextStep to complete |
|
1320 User::WaitForRequest(status); |
|
1321 // Get last parsed landmark |
|
1322 CPosLandmark* lm = iLandmarkParser->LandmarkLC(); |
|
1323 lm->GetCategoriesL(array); |
|
1324 AssertTrueSecL(array.Count() == 0, _L("Wrong number of landmark categories")); |
|
1325 iErrorsFound += CompareXMLLandmarksL(*iLandmarks[number++], *lm); |
|
1326 CleanupStack::PopAndDestroy(lm); |
|
1327 |
|
1328 iLog->Log(_L("----->CollectionData")); |
|
1329 TPosLmCollectionDataId lmId = iLandmarkParser->FirstCollectionDataId(); |
|
1330 // First should be name |
|
1331 TPtrC first = iLandmarkParser->CollectionData(lmId); |
|
1332 if (first.Compare(KLongFieldName) != KErrNone) |
|
1333 { |
|
1334 iLog->Log(_L("ERROR: Wrong name!!")); |
|
1335 iErrorsFound++; |
|
1336 } |
|
1337 |
|
1338 lmId = iLandmarkParser->NextCollectionDataId(lmId); |
|
1339 TPtrC next = iLandmarkParser->CollectionData(lmId); |
|
1340 if (next.Compare(KLongFieldDescription) != KErrNone) |
|
1341 { |
|
1342 iLog->Log(_L("ERROR: Wrong description!!")); |
|
1343 iErrorsFound++; |
|
1344 } |
|
1345 |
|
1346 lmId = iLandmarkParser->NextCollectionDataId(lmId); |
|
1347 if (lmId != EPosLmCollDataNone) |
|
1348 { |
|
1349 iLog->Log(_L("ERROR: Wrong description!!")); |
|
1350 iErrorsFound++; |
|
1351 } |
|
1352 |
|
1353 |
|
1354 iLog->Log(_L("<-----CollectionData")); |
|
1355 CleanupStack::PopAndDestroy(&array); |
|
1356 if (!aUseFile) |
|
1357 { |
|
1358 CleanupStack::PopAndDestroy(filecontent); |
|
1359 myEncoderBuffer->Reset(); |
|
1360 CleanupStack::PopAndDestroy(myEncoderBuffer); |
|
1361 } |
|
1362 |
|
1363 delete iLandmarkParser; |
|
1364 iLandmarkParser = NULL; |
|
1365 |
|
1366 delete iOperation; |
|
1367 iOperation = NULL; |
|
1368 |
|
1369 iLandmarks.ResetAndDestroy(); |
|
1370 iLog->Log(_L("TestLongCollectionFieldsL Done")); |
|
1371 } |
|
1372 |
|
1373 // --------------------------------------------------------- |
|
1374 // CPosTp43::TestErrorScenariosL |
|
1375 // |
|
1376 // (other items were commented in a header). |
|
1377 // --------------------------------------------------------- |
|
1378 // |
|
1379 void CPosTp43::TestErrorScenariosL() |
|
1380 { |
|
1381 iLog->Log(_L("TestErrorScenariosL")); |
|
1382 |
|
1383 TInt err = KErrNone; |
|
1384 TRAP(err, ErrorScenario1L()); |
|
1385 if (err != KErrAlreadyExists) //LogErrorAndLeave(_L("ErrorScenario1L did not leave with error KErrAlreadyExists")); |
|
1386 { |
|
1387 iLog->Log(_L(" ErrorScenario1L did not leave with error KErrAlreadyExists")); |
|
1388 User::Leave(err); |
|
1389 } |
|
1390 delete iLandmarkEncoder; |
|
1391 iLandmarkEncoder = NULL; |
|
1392 DeleteFileL(KErrorTestFileName); |
|
1393 |
|
1394 ErrorScenario2L(); |
|
1395 DeleteFileL(KErrorTestFileName); |
|
1396 |
|
1397 TRAP(err, ErrorScenario3L()); |
|
1398 if (err != KErrAlreadyExists)// LogErrorAndLeave(_L("ErrorScenario3L did not leave with error KErrAlreadyExists")); |
|
1399 { |
|
1400 iLog->Log(_L(" ErrorScenario3L did not leave with error KErrAlreadyExists")); |
|
1401 User::Leave(err); |
|
1402 } |
|
1403 delete iLandmarkEncoder; |
|
1404 iLandmarkEncoder = NULL; |
|
1405 DeleteFileL(KErrorTestFileName); |
|
1406 |
|
1407 TRAP(err, ErrorScenario4L()); |
|
1408 if (err != KErrNone) |
|
1409 { |
|
1410 iLog->Log(_L("ERROR: Adding meta data \"out-of-range\" should be silently ignored, instead leave error")); |
|
1411 iErrorsFound++; |
|
1412 } |
|
1413 delete iLandmarkEncoder; |
|
1414 iLandmarkEncoder = NULL; |
|
1415 DeleteFileL(KErrorTestFileName); |
|
1416 |
|
1417 ErrorScenario5L(); |
|
1418 |
|
1419 } |
|
1420 |
|
1421 // --------------------------------------------------------- |
|
1422 // CPosTp43::ErrorScenario1L |
|
1423 // |
|
1424 // (other items were commented in a header). |
|
1425 // --------------------------------------------------------- |
|
1426 // |
|
1427 void CPosTp43::ErrorScenario1L() |
|
1428 { |
|
1429 iLog->Log(_L("ErrorScenario1L")); |
|
1430 |
|
1431 // 1) Create an encoder object |
|
1432 iLandmarkEncoder = CPosLandmarkEncoder::NewL(KLmxMimeType); |
|
1433 |
|
1434 RFile file; |
|
1435 CleanupClosePushL(file); |
|
1436 |
|
1437 // Make sure that file exist |
|
1438 TInt err = file.Replace(iFileSession, KErrorTestFileName, EFileShareAny); |
|
1439 if (err != KErrNone) |
|
1440 { |
|
1441 iLog->Log(_L("Error when replacing file ")); |
|
1442 User::Leave(err); |
|
1443 } |
|
1444 |
|
1445 CleanupStack::PopAndDestroy(&file); |
|
1446 |
|
1447 // 2) Use file for encoding, set output file should leave |
|
1448 iLandmarkEncoder->SetOutputFileL(KErrorTestFileName); |
|
1449 |
|
1450 delete iLandmarkEncoder; |
|
1451 iLandmarkEncoder = NULL; |
|
1452 } |
|
1453 |
|
1454 // --------------------------------------------------------- |
|
1455 // CPosTp43::ErrorScenario2L |
|
1456 // |
|
1457 // (other items were commented in a header). |
|
1458 // --------------------------------------------------------- |
|
1459 // |
|
1460 void CPosTp43::ErrorScenario2L() |
|
1461 { |
|
1462 iLog->Log(_L("ErrorScenario2L")); |
|
1463 |
|
1464 // 1) Create an encoder object |
|
1465 iLandmarkEncoder = CPosLandmarkEncoder::NewL(KLmxMimeType); |
|
1466 // 2) Use file for encoding, set output file |
|
1467 DeleteFileL(KErrorTestFileName); |
|
1468 iLandmarkEncoder->SetOutputFileL(KErrorTestFileName); |
|
1469 |
|
1470 RFile file; |
|
1471 CleanupClosePushL(file); |
|
1472 |
|
1473 // Make sure that file exist |
|
1474 TInt err = file.Open(iFileSession, KErrorTestFileName, EFileShareAny); |
|
1475 if (err != KErrInUse) //LogErrorAndLeave(_L("File should not be able to open")); |
|
1476 { |
|
1477 iLog->Log(_L("File should not be able to open")); |
|
1478 User::Leave(err); |
|
1479 } |
|
1480 |
|
1481 CleanupStack::PopAndDestroy(&file); |
|
1482 |
|
1483 delete iLandmarkEncoder; |
|
1484 iLandmarkEncoder = NULL; |
|
1485 } |
|
1486 |
|
1487 // --------------------------------------------------------- |
|
1488 // CPosTp43::ErrorScenario3L |
|
1489 // |
|
1490 // (other items were commented in a header). |
|
1491 // --------------------------------------------------------- |
|
1492 // |
|
1493 void CPosTp43::ErrorScenario3L() |
|
1494 { |
|
1495 iLog->Log(_L("ErrorScenario3L")); |
|
1496 |
|
1497 // 1) Create an encoder object |
|
1498 iLandmarkEncoder = CPosLandmarkEncoder::NewL(KLmxMimeType); |
|
1499 // 2) Use file for encoding, set output file |
|
1500 DeleteFileL(KErrorTestFileName); |
|
1501 iLandmarkEncoder->SetOutputFileL(KErrorTestFileName); |
|
1502 |
|
1503 // AddCollectionDataL(id) with same id twice should leave |
|
1504 iLandmarkEncoder->AddCollectionDataL(EPosLmCollDataCollectionDescription, _L("A yada yada collextion of landmarks")); |
|
1505 iLandmarkEncoder->AddCollectionDataL(EPosLmCollDataCollectionDescription, _L("Another yada yada collextion of landmarks")); |
|
1506 |
|
1507 // We should never get here |
|
1508 iLog->Log(_L("FinalizeEncodingL")); |
|
1509 ExecuteAndDeleteLD(iLandmarkEncoder->FinalizeEncodingL()); |
|
1510 iLog->Log(_L("FinalizeEncodingL Done")); |
|
1511 |
|
1512 delete iLandmarkEncoder; |
|
1513 iLandmarkEncoder = NULL; |
|
1514 } |
|
1515 |
|
1516 // --------------------------------------------------------- |
|
1517 // CPosTp43::ErrorScenario4L |
|
1518 // |
|
1519 // (other items were commented in a header). |
|
1520 // --------------------------------------------------------- |
|
1521 // |
|
1522 void CPosTp43::ErrorScenario4L() |
|
1523 { |
|
1524 iLog->Log(_L("ErrorScenario4L")); |
|
1525 |
|
1526 // 1) Create an encoder object |
|
1527 iLandmarkEncoder = CPosLandmarkEncoder::NewL(KLmxMimeType); |
|
1528 // 2) Use file for encoding, set output file |
|
1529 DeleteFileL(KErrorScenario4File); |
|
1530 iLandmarkEncoder->SetOutputFileL(KErrorScenario4File); |
|
1531 |
|
1532 iLandmarkEncoder->AddCollectionDataL(EPosLmCollDataCollectionName, _L("A yada yada name for landmarks")); |
|
1533 iLandmarkEncoder->AddCollectionDataL(EPosLmCollDataCollectionDescription, _L("A yada yada description for landmarks")); |
|
1534 |
|
1535 // Will be silently ignored |
|
1536 iLandmarkEncoder->AddCollectionDataL((TPosLmCollectionDataId)5, _L("A dummy string")); |
|
1537 |
|
1538 TInt pos = EPosLmCollDataContentSpecificDataBegin; |
|
1539 _LIT(KFormatString, "Dummmmmmmmmmmy string: %d"); |
|
1540 TBuf<100> buf; |
|
1541 |
|
1542 for (TInt i=0;i<10;i++) |
|
1543 { |
|
1544 buf.Format(KFormatString, pos); |
|
1545 iLog->Log(buf); |
|
1546 // Will be silently ignored |
|
1547 iLandmarkEncoder->AddCollectionDataL((TPosLmCollectionDataId)pos, buf); |
|
1548 pos++; |
|
1549 } |
|
1550 |
|
1551 // Will be silently ignored |
|
1552 iLog->Log(_L("Adding the last meta data collection allowed")); |
|
1553 iLandmarkEncoder->AddCollectionDataL(EPosLmCollDataLast, _L("The last dummy string")); |
|
1554 iLog->Log(_L("After adding the last meta data collection allowed")); |
|
1555 |
|
1556 CPosLandmark* lm1 = iDatabase->ReadLandmarkLC(7); |
|
1557 iLandmarkEncoder->AddLandmarkL(*lm1); |
|
1558 CleanupStack::PopAndDestroy(lm1); |
|
1559 |
|
1560 iLog->Log(_L("FinalizeEncodingL")); |
|
1561 ExecuteAndDeleteLD(iLandmarkEncoder->FinalizeEncodingL()); |
|
1562 iLog->Log(_L("FinalizeEncodingL Done")); |
|
1563 |
|
1564 delete iLandmarkEncoder; |
|
1565 iLandmarkEncoder = NULL; |
|
1566 } |
|
1567 |
|
1568 // --------------------------------------------------------- |
|
1569 // CPosTp43::ErrorScenario5L |
|
1570 // |
|
1571 // (other items were commented in a header). |
|
1572 // --------------------------------------------------------- |
|
1573 // |
|
1574 void CPosTp43::ErrorScenario5L() |
|
1575 { |
|
1576 iLog->Log(_L("ErrorScenario5L")); |
|
1577 |
|
1578 // 1) Create an encoder object |
|
1579 iLandmarkEncoder = CPosLandmarkEncoder::NewL(KLmxMimeType); |
|
1580 // 2) Use file for encoding, set output file |
|
1581 DeleteFileL(KErrorScenario5File); |
|
1582 iLandmarkEncoder->SetOutputFileL(KErrorScenario5File); |
|
1583 |
|
1584 iLandmarkEncoder->AddCollectionDataL(EPosLmCollDataCollectionName, _L("A yada yada name for landmarks")); |
|
1585 iLandmarkEncoder->AddCollectionDataL(EPosLmCollDataCollectionDescription, _L("</lm:lmx>")); |
|
1586 |
|
1587 CPosLandmark* lm1 = CreateXMLLandmarkLC(_L("</lm:lmx>")); |
|
1588 iLandmarkEncoder->AddLandmarkL(*lm1); |
|
1589 CleanupStack::PopAndDestroy(lm1); |
|
1590 |
|
1591 lm1 = CreateXMLLandmarkLC(_L("</lm:lmx>")); |
|
1592 iLandmarkEncoder->AddLandmarkL(*lm1); |
|
1593 CleanupStack::PopAndDestroy(lm1); |
|
1594 |
|
1595 iLog->Log(_L("FinalizeEncodingL")); |
|
1596 ExecuteAndDeleteLD(iLandmarkEncoder->FinalizeEncodingL()); |
|
1597 iLog->Log(_L("FinalizeEncodingL Done")); |
|
1598 |
|
1599 delete iLandmarkEncoder; |
|
1600 iLandmarkEncoder = NULL; |
|
1601 } |
|
1602 |
|
1603 // --------------------------------------------------------- |
|
1604 // CPosTp43::TestWithLongFileNameL |
|
1605 // |
|
1606 // (other items were commented in a header). |
|
1607 // --------------------------------------------------------- |
|
1608 // |
|
1609 void CPosTp43::TestWithLongFileNameL() |
|
1610 { |
|
1611 iLog->Log(_L("TestWithLongFileNameL")); |
|
1612 delete iLandmarkEncoder; |
|
1613 iLandmarkEncoder = NULL; |
|
1614 // 1) Create an encoder object |
|
1615 iLandmarkEncoder = CPosLandmarkEncoder::NewL(KLmxMimeType); |
|
1616 TInt errorsFound = KErrNone; |
|
1617 |
|
1618 // 2) Set file with long filename (more than 255 characters) |
|
1619 TRAPD(err, iLandmarkEncoder->SetOutputFileL(KLongFileName)); |
|
1620 |
|
1621 |
|
1622 |
|
1623 if ( err != KErrBadName ) |
|
1624 { |
|
1625 TBuf<100> buf; |
|
1626 buf.Format(_L("ERROR: SetInputFileL should leave with KErrBadName, instead err: %d"), err); |
|
1627 iLog->Log(buf); |
|
1628 iErrorsFound++; |
|
1629 } |
|
1630 |
|
1631 |
|
1632 // 3) Set file to 0 characters |
|
1633 TRAP(err, iLandmarkEncoder->SetOutputFileL(KEmptyFileName)); |
|
1634 if (err != KErrBadName) |
|
1635 { |
|
1636 TBuf<100> buf; |
|
1637 buf.Format(_L("ERROR: SetOutputFileL(KEmptyFileName) should leave with KErrBadName, instead err: %d"), err); |
|
1638 iLog->Log(buf); |
|
1639 errorsFound++; |
|
1640 } |
|
1641 |
|
1642 delete iLandmarkEncoder; |
|
1643 iLandmarkEncoder = NULL; |
|
1644 |
|
1645 // Try to create an encoder with the long file name, should leave with KErrNotSupported |
|
1646 TRAP(err, CPosLandmarkEncoder::NewL(KLongMimeType)); |
|
1647 if (err != KErrNotSupported) |
|
1648 { |
|
1649 iLog->Log(_L("CPosLandmarkEncoder::NewL should leave with KErrNotSupported")); |
|
1650 User::Leave(err); |
|
1651 } |
|
1652 |
|
1653 if (errorsFound != KErrNone) |
|
1654 { |
|
1655 iLog->Log(_L("SetOutputFileL leaved with wrong error code")); |
|
1656 User::Leave(-1); |
|
1657 |
|
1658 } |
|
1659 |
|
1660 |
|
1661 |
|
1662 } |
|
1663 |
|
1664 |
|
1665 // End of File |