|
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_CPosTp51.h" |
|
23 #include <EPos_CPosLandmarkDatabase.h> |
|
24 #include <EPos_CPosLMCategoryManager.h> |
|
25 #include <EPos_CPosLandmarkEncoder.h> |
|
26 #include <EPos_CPosLandmarkParser.h> |
|
27 #include <e32std.h> |
|
28 //#include <ss_std.h> |
|
29 |
|
30 // CONSTANTS |
|
31 _LIT8(KNonExistingMimeType1, "APPLICATION/VND.NOKIA.LANDMARKCOLLECTION+XML"); |
|
32 _LIT8(KNonExistingMimeType2, "application/vnd.nokia.kokoibollen"); |
|
33 //_LIT8(KNonExistingMimeType3, "application/vnd.nokia.kokoibollenapplication/vnd.nokia.kokoibollenapplication/vnd.nokia.kokoibollenapplication/vnd.nokia.kokoibollenapplication/vnd.nokia.kokoibollenapplication/vnd.nokia.kokoibollenapplication/vnd.nokia.kokoibollenapplication/vnd.nokia.kokoibollenapplication/vnd.nokia.kokoibollenapplication/vnd.nokia.kokoibollenapplication/vnd.nokia.kokoibollen"); |
|
34 _LIT8(KEmptyMimeType, ""); |
|
35 _LIT(KPosLandmarksServerName, "*eposlmserver*"); |
|
36 |
|
37 // ================= MEMBER FUNCTIONS ======================= |
|
38 |
|
39 // --------------------------------------------------------- |
|
40 // CPosTp51::StartL |
|
41 // |
|
42 // (other items were commented in a header). |
|
43 // --------------------------------------------------------- |
|
44 // |
|
45 void CPosTp51::StartL() |
|
46 { |
|
47 iErrorsFound = 0; |
|
48 MakeSurePanicDebugFileExistsL(); |
|
49 |
|
50 RemoveDefaultDbL(); |
|
51 iDatabase = UseGeneratedDbFileL(); |
|
52 |
|
53 if (iDatabase->IsInitializingNeeded()) |
|
54 { |
|
55 ExecuteAndDeleteLD(iDatabase->InitializeL()); |
|
56 } |
|
57 |
|
58 // <<<<<<<<<<<<<<Panic testing below>>>>>>>>>>>>>>>>>>> |
|
59 iLog->Log(_L(">>>>>>>Start Panic test<<<<<<<<<")); |
|
60 |
|
61 // 1 The client asks the API to parse XML content both synchronously |
|
62 // and incrementally without specifying the input method. |
|
63 iExpectedExitType = ExitPanic; |
|
64 iLog->Log(_L("Panic test 1")); |
|
65 iTestCase = 1; |
|
66 iExpectedErrorCode = EPosLmProtocolBreak; |
|
67 iMimeType.Set( KLmxMimeType ); |
|
68 ResumeThreadAndVerifyExitL(); |
|
69 iMimeType.Set( KGpxMimeType ); |
|
70 ResumeThreadAndVerifyExitL(); |
|
71 |
|
72 iExpectedExitType = ExitPanic; |
|
73 iLog->Log(_L("Panic test 2")); |
|
74 iTestCase = 2; |
|
75 iExpectedErrorCode = EPosLmProtocolBreak; |
|
76 iMimeType.Set( KLmxMimeType ); |
|
77 ResumeThreadAndVerifyExitL(); |
|
78 iMimeType.Set( KGpxMimeType ); |
|
79 ResumeThreadAndVerifyExitL(); |
|
80 |
|
81 // Import landmarks with an invalid transfer option |
|
82 iExpectedExitType = ExitPanic; |
|
83 iLog->Log(_L("Panic test 3")); |
|
84 iTestCase = 3; |
|
85 iExpectedErrorCode = EPosLmInvalidArgument; |
|
86 iMimeType.Set( KLmxMimeType ); |
|
87 ResumeThreadAndVerifyExitL(); |
|
88 iMimeType.Set( KGpxMimeType ); |
|
89 ResumeThreadAndVerifyExitL(); |
|
90 |
|
91 // Import landmarks with an invalid transfer option |
|
92 iExpectedExitType = ExitPanic; |
|
93 iLog->Log(_L("Panic test 9")); |
|
94 iTestCase = 9; |
|
95 iExpectedErrorCode = EPosLmInvalidArgument; |
|
96 iMimeType.Set( KLmxMimeType ); |
|
97 ResumeThreadAndVerifyExitL(); |
|
98 iMimeType.Set( KGpxMimeType ); |
|
99 ResumeThreadAndVerifyExitL(); |
|
100 |
|
101 // Import landmarks with an invalid transfer option |
|
102 iExpectedExitType = ExitPanic; |
|
103 iLog->Log(_L("Panic test 10")); |
|
104 iTestCase = 10; |
|
105 iExpectedErrorCode = EPosLmInvalidArgument; |
|
106 iMimeType.Set( KLmxMimeType ); |
|
107 ResumeThreadAndVerifyExitL(); |
|
108 iMimeType.Set( KGpxMimeType ); |
|
109 ResumeThreadAndVerifyExitL(); |
|
110 |
|
111 // Create a parser with incorrect MIME type, should leave |
|
112 iExpectedExitType = ExitLeave; |
|
113 iLog->Log(_L("Leave test 4")); |
|
114 iTestCase = 4; |
|
115 iExpectedErrorCode = KErrNotSupported; |
|
116 ResumeThreadAndVerifyExitL(); |
|
117 |
|
118 // Create a parser with incorrect MIME (correct MIME type but with capital letters) type, should leave |
|
119 iExpectedExitType = ExitLeave; |
|
120 iLog->Log(_L("Leave test 5")); |
|
121 iTestCase = 5; |
|
122 iExpectedErrorCode = KErrNotSupported; |
|
123 ResumeThreadAndVerifyExitL(); |
|
124 |
|
125 // Create a parser with incorrect MIME type, should leave |
|
126 iExpectedExitType = ExitLeave; |
|
127 iLog->Log(_L("Leave test 18")); |
|
128 iTestCase = 18; |
|
129 iExpectedErrorCode = KErrNotSupported; |
|
130 ResumeThreadAndVerifyExitL(); |
|
131 |
|
132 #if 0 |
|
133 // Create a parser with incorrect MIME type, should leave |
|
134 // TE: the REComSession::CreateImplementationL( leaves with KErrArgument which I think is acceptable |
|
135 // Nokia: This is not part of API definition, case removed |
|
136 iExpectedExitType = ExitLeave; |
|
137 iLog->Log(_L("Leave test 19")); |
|
138 iTestCase = 19; |
|
139 iExpectedErrorCode = KErrArgument; |
|
140 ResumeThreadAndVerifyExitL(); |
|
141 #endif |
|
142 |
|
143 // Create a parser, parse inc. but change input method after one step |
|
144 iExpectedExitType = ExitPanic; |
|
145 iLog->Log(_L("Leave test 6")); |
|
146 iTestCase = 6; |
|
147 iExpectedErrorCode = EPosLmProtocolBreak; |
|
148 iMimeType.Set( KLmxMimeType ); |
|
149 ResumeThreadAndVerifyExitL(); |
|
150 iMimeType.Set( KGpxMimeType ); |
|
151 ResumeThreadAndVerifyExitL(); |
|
152 |
|
153 #ifndef __WINS__ |
|
154 // Fetch Import Iterator with NULL argument |
|
155 iExpectedExitType = ExitPanic; |
|
156 iLog->Log(_L("Panic test 7")); |
|
157 iTestCase = 7; |
|
158 iExpectedErrorCode = 3; // Kern-Exec 3 |
|
159 ResumeThreadAndVerifyExitL(); |
|
160 ListAllServers(); |
|
161 if (!ServerAlive(KPosLandmarksServerName)) |
|
162 { |
|
163 iLog->Log(_L("Server not alive as expected(1)!")); |
|
164 User::Leave(-1); |
|
165 |
|
166 } |
|
167 |
|
168 // Use a CPosLmOperation object from a compact operation as input to an |
|
169 // ImportedLandmarksIteratorL function call |
|
170 iExpectedExitType = ExitPanic; |
|
171 iLog->Log(_L("Panic test 8")); |
|
172 iTestCase = 8; |
|
173 iExpectedErrorCode = 3; // Kern-Exec 3 |
|
174 ResumeThreadAndVerifyExitL(); |
|
175 ListAllServers(); |
|
176 if (!ServerAlive(KPosLandmarksServerName)) |
|
177 { |
|
178 iLog->Log(_L("Server not alive as expected(2)!")); |
|
179 User::Leave(-1); |
|
180 |
|
181 } |
|
182 #endif |
|
183 |
|
184 // Import subset of landmarks with non existing ids |
|
185 iLog->Log(_L("Panic test 11")); |
|
186 iTestCase = 11; |
|
187 iExpectedExitType = ExitPanic; |
|
188 iExpectedErrorCode = EPosInvalidIndex; |
|
189 iMimeType.Set( KLmxMimeType ); |
|
190 ResumeThreadAndVerifyExitL(); |
|
191 iMimeType.Set( KGpxMimeType ); |
|
192 ResumeThreadAndVerifyExitL(); |
|
193 |
|
194 // Import subset of landmarks with empty subset of ids |
|
195 // should leave with KErrArgument |
|
196 iLog->Log(_L("Panic test 12")); |
|
197 iTestCase = 12; |
|
198 iExpectedExitType = ExitLeave; |
|
199 iExpectedErrorCode = KErrArgument; |
|
200 iMimeType.Set( KLmxMimeType ); |
|
201 ResumeThreadAndVerifyExitL(); |
|
202 iMimeType.Set( KGpxMimeType ); |
|
203 ResumeThreadAndVerifyExitL(); |
|
204 |
|
205 // Try to receive parsed landmark with invalid index |
|
206 iLog->Log(_L("Panic test 13")); |
|
207 iTestCase = 13; |
|
208 iExpectedExitType = ExitPanic; |
|
209 iExpectedErrorCode = EPosInvalidIndex; |
|
210 iMimeType.Set( KLmxMimeType ); |
|
211 ResumeThreadAndVerifyExitL(); |
|
212 iMimeType.Set( KGpxMimeType ); |
|
213 ResumeThreadAndVerifyExitL(); |
|
214 |
|
215 // Try to ParseContentL from empty buffer |
|
216 iLog->Log(_L("Panic test 14")); |
|
217 iTestCase = 14; |
|
218 iExpectedExitType = ExitLeave; |
|
219 iExpectedErrorCode = KErrPosLmUnknownFormat; |
|
220 iMimeType.Set( KLmxMimeType ); |
|
221 ResumeThreadAndVerifyExitL(); |
|
222 iMimeType.Set( KGpxMimeType ); |
|
223 ResumeThreadAndVerifyExitL(); |
|
224 |
|
225 // Try toParseContentL from NULL input buffer |
|
226 iLog->Log(_L("Panic test 15")); |
|
227 iTestCase = 15; |
|
228 iExpectedExitType = ExitPanic; |
|
229 iExpectedErrorCode = 3; // Kern-Exec 3 |
|
230 iMimeType.Set( KLmxMimeType ); |
|
231 ResumeThreadAndVerifyExitL(); |
|
232 iMimeType.Set( KGpxMimeType ); |
|
233 ResumeThreadAndVerifyExitL(); |
|
234 |
|
235 // Try to ImportLandmarks from empty buffer |
|
236 iLog->Log(_L("Panic test 16")); |
|
237 iTestCase = 16; |
|
238 iExpectedExitType = ExitLeave; |
|
239 iExpectedErrorCode = KErrPosLmUnknownFormat; |
|
240 iMimeType.Set( KLmxMimeType ); |
|
241 ResumeThreadAndVerifyExitL(); |
|
242 iMimeType.Set( KGpxMimeType ); |
|
243 ResumeThreadAndVerifyExitL(); |
|
244 |
|
245 // Try to ImportLandmarks from NULL buffer |
|
246 iLog->Log(_L("Panic test 17")); |
|
247 iTestCase = 17; |
|
248 iExpectedExitType = ExitPanic; |
|
249 iExpectedErrorCode = 3; // Kern-Exec 3 |
|
250 iMimeType.Set( KLmxMimeType ); |
|
251 ResumeThreadAndVerifyExitL(); |
|
252 iMimeType.Set( KGpxMimeType ); |
|
253 ResumeThreadAndVerifyExitL(); |
|
254 |
|
255 iLog->Log(_L(">>>>>>>Panic test Done<<<<<<<<<")); |
|
256 |
|
257 if (iErrorsFound != KErrNone) |
|
258 { |
|
259 iLog->Log(_L("Errors found in TP51")); |
|
260 User::Leave(-2); |
|
261 } |
|
262 } |
|
263 |
|
264 // --------------------------------------------------------- |
|
265 // CPosTp51::ResumeThreadAndVerifyExitL |
|
266 // |
|
267 // (other items were commented in a header). |
|
268 // --------------------------------------------------------- |
|
269 // |
|
270 void CPosTp51::ResumeThreadAndVerifyExitL() |
|
271 { |
|
272 iLog->Log(_L("ResumeThreadAndVerifyExitL")); |
|
273 _LIT(KPanicErr, "ERROR: Method didn't panic, exit type %d"); |
|
274 _LIT(KPanicCodeErr, "ERROR: Unexpected panic code, actual %d, expected %d"); |
|
275 _LIT(KLeaveErr, "ERROR: Method didn't leave, exit type %d"); |
|
276 _LIT(KLeaveCodeErr, "ERROR: Unexpected leave error, actual %d, expected %d"); |
|
277 |
|
278 CreateThreadL(); |
|
279 TRequestStatus status; |
|
280 iThread.Logon(status); |
|
281 iThread.Resume(); |
|
282 |
|
283 User::WaitForRequest(status); |
|
284 |
|
285 if (iExpectedExitType == ExitPanic) |
|
286 { |
|
287 if (iThread.ExitType() != EExitPanic ) |
|
288 { |
|
289 iLog->Log( KPanicErr, iThread.ExitType() ); |
|
290 iErrorsFound++; |
|
291 } |
|
292 if ( iThread.ExitReason() != iExpectedErrorCode ) |
|
293 { |
|
294 iLog->Log( KPanicCodeErr, iThread.ExitReason(), iExpectedErrorCode ); |
|
295 iErrorsFound++; |
|
296 } |
|
297 } |
|
298 else if (iExpectedExitType == ExitLeave) |
|
299 { |
|
300 if (iThread.ExitType() != EExitKill ) |
|
301 { |
|
302 iLog->Log( KLeaveErr, iThread.ExitType() ); |
|
303 iErrorsFound++; |
|
304 } |
|
305 if ( iThread.ExitReason() != iExpectedErrorCode ) |
|
306 { |
|
307 iLog->Log( KLeaveCodeErr, iThread.ExitReason(), iExpectedErrorCode ); |
|
308 iErrorsFound++; |
|
309 } |
|
310 } |
|
311 iThread.Close(); |
|
312 } |
|
313 |
|
314 // --------------------------------------------------------- |
|
315 // CPosTp51::CloseTest |
|
316 // |
|
317 // (other items were commented in a header). |
|
318 // --------------------------------------------------------- |
|
319 // |
|
320 void CPosTp51::CloseTest() |
|
321 { |
|
322 iLog->Log(_L("CloseTest")); |
|
323 iThread.Close(); |
|
324 |
|
325 delete iDatabase; |
|
326 iDatabase = NULL; |
|
327 |
|
328 iLog->Log(_L("CloseTest Done")); |
|
329 } |
|
330 |
|
331 // --------------------------------------------------------- |
|
332 // CPosTp51::RunPanicTestL |
|
333 // |
|
334 // (other items were commented in a header). |
|
335 // --------------------------------------------------------- |
|
336 void CPosTp51::RunPanicTestL(TAny* aData) |
|
337 { |
|
338 CPosTp51* self = reinterpret_cast<CPosTp51*>(aData); |
|
339 |
|
340 _LIT(KXML1, "c:\\system\\test\\TestData\\TP47_UTF-16-bigEndian.xml"); |
|
341 _LIT(KXML2, "c:\\system\\test\\TestData\\TP47_UTF-16-littleEndian.xml"); |
|
342 _LIT(KXML3, "c:\\system\\test\\TestData\\TP47_UTF-16-bigEndian.gpx"); |
|
343 _LIT(KXML4, "c:\\system\\test\\TestData\\TP47_UTF-16-littleEndian.gpx"); |
|
344 |
|
345 if (self->iTestCase == 1) |
|
346 { |
|
347 // Create parser |
|
348 CPosLandmarkParser* landmarkParser = CPosLandmarkParser::NewL(self->iMimeType); |
|
349 |
|
350 //Should Panic when no input is set, parse sync |
|
351 ExecuteAndDeleteLD(landmarkParser->ParseContentL()); |
|
352 } |
|
353 else if (self->iTestCase == 2) |
|
354 { |
|
355 // Create parser, |
|
356 CPosLandmarkParser* landmarkParser = CPosLandmarkParser::NewL(self->iMimeType); |
|
357 // Parse content, should panic when no input set, parse incrementally |
|
358 CPosLmOperation* operation = landmarkParser->ParseContentL(); |
|
359 self->RunAsyncOperationLD(operation); |
|
360 } |
|
361 else if (self->iTestCase == 3) |
|
362 { |
|
363 CPosLandmarkDatabase* database = self->OpenDatabaseLC(); |
|
364 // Create parser |
|
365 CPosLandmarkParser* landmarkParser = CPosLandmarkParser::NewL(self->iMimeType); |
|
366 // Importlandmarks with invalid transfer option, should panic |
|
367 ExecuteAndDeleteLD(database->ImportLandmarksL(*landmarkParser, 666)); |
|
368 CleanupStack::PopAndDestroy(landmarkParser); |
|
369 CleanupStack::PopAndDestroy(database); |
|
370 } |
|
371 else if (self->iTestCase == 4) |
|
372 { |
|
373 // Create parser with incorrect MIME type, should leave with KErrNotSupported |
|
374 CPosLandmarkParser* landmarkParser = CPosLandmarkParser::NewL(KNonExistingMimeType2); |
|
375 CleanupStack::PushL(landmarkParser); |
|
376 CleanupStack::PopAndDestroy(landmarkParser); |
|
377 } |
|
378 else if (self->iTestCase == 5) |
|
379 { |
|
380 // Create parser with incorrect MIME (including capital letters) type, should leave with KErrNotSupported |
|
381 CPosLandmarkParser* landmarkParser = CPosLandmarkParser::NewL(KNonExistingMimeType1); |
|
382 CleanupStack::PushL(landmarkParser); |
|
383 CleanupStack::PopAndDestroy(landmarkParser); |
|
384 } |
|
385 else if (self->iTestCase == 18) |
|
386 { |
|
387 // Create parser with incorrect MIME type (long string), should leave with KErrNotSupported |
|
388 CPosLandmarkParser* landmarkParser = CPosLandmarkParser::NewL(KNonExistingMimeType2); |
|
389 CleanupStack::PushL(landmarkParser); |
|
390 CleanupStack::PopAndDestroy(landmarkParser); |
|
391 } |
|
392 else if (self->iTestCase == 19) |
|
393 { |
|
394 // Create parser with incorrect MIME (empty string) type, should leave with KErrNotSupported (or KErrArgument) |
|
395 // however the REComSession::CreateImplementationL( leaves with KErrArgument which I think is acceptable |
|
396 CPosLandmarkParser* landmarkParser = CPosLandmarkParser::NewL(KEmptyMimeType); |
|
397 CleanupStack::PushL(landmarkParser); |
|
398 CleanupStack::PopAndDestroy(landmarkParser); |
|
399 } |
|
400 else if (self->iTestCase == 6) |
|
401 { |
|
402 CPosLandmarkDatabase* database = self->OpenDatabaseLC(); |
|
403 // Create parser |
|
404 CPosLandmarkParser* landmarkParser = CPosLandmarkParser::NewL(self->iMimeType); |
|
405 landmarkParser->SetInputFileL(KXML1); |
|
406 // Call ParseContentL |
|
407 CPosLmOperation* operation = landmarkParser->ParseContentL(); |
|
408 TRequestStatus status = KPosLmOperationNotComplete; |
|
409 TReal32 progress; |
|
410 |
|
411 // Set new input method before first operation has completed |
|
412 landmarkParser->SetInputFileL(KXML2); |
|
413 |
|
414 // Use first operation object->should panic |
|
415 operation->NextStep(status, progress); |
|
416 User::WaitForRequest(status); |
|
417 |
|
418 CleanupStack::PopAndDestroy(landmarkParser); |
|
419 CleanupStack::PopAndDestroy(database); |
|
420 } |
|
421 else if (self->iTestCase == 7) |
|
422 { |
|
423 // <<<<<<<<<<<<<< Fetch iterator with CPosLmOperation == NULL >>>>>>>>>>>>>>>>>>> |
|
424 CPosLandmarkDatabase* databasen = self->OpenDatabaseLC(); |
|
425 CPosLmItemIterator* iterator = databasen->ImportedLandmarksIteratorL(NULL); |
|
426 delete iterator; |
|
427 CleanupStack::PopAndDestroy(databasen); |
|
428 } |
|
429 else if (self->iTestCase == 8) |
|
430 { |
|
431 // <<<<<<<<<<<<<< Fetch iterator with CPosLmOperation != ImportLandmarksL() >>>>>>>>>>>>>>>>>>> |
|
432 CPosLandmarkDatabase* databasen = self->OpenDatabaseLC(); |
|
433 CPosLmOperation* operation = databasen->CompactL(); |
|
434 CleanupStack::PushL(operation); |
|
435 CPosLmItemIterator* iterator = databasen->ImportedLandmarksIteratorL(operation); |
|
436 delete iterator; |
|
437 CleanupStack::PopAndDestroy(2, databasen); |
|
438 } |
|
439 else if (self->iTestCase == 9) |
|
440 { |
|
441 CPosLandmarkDatabase* database = self->OpenDatabaseLC(); |
|
442 // Create parser |
|
443 CPosLandmarkParser* landmarkParser = CPosLandmarkParser::NewL(self->iMimeType); |
|
444 // Importlandmarks with invalid transfer option, should panic |
|
445 ExecuteAndDeleteLD(database->ImportLandmarksL(*landmarkParser, 0x17)); |
|
446 CleanupStack::PopAndDestroy(landmarkParser); |
|
447 CleanupStack::PopAndDestroy(database); |
|
448 } |
|
449 else if (self->iTestCase == 10) |
|
450 { |
|
451 CPosLandmarkDatabase* database = self->OpenDatabaseLC(); |
|
452 // Create parser |
|
453 CPosLandmarkParser* landmarkParser = CPosLandmarkParser::NewL(self->iMimeType); |
|
454 CleanupStack::PushL(landmarkParser); |
|
455 RArray<TUint> subset; |
|
456 CleanupClosePushL(subset); |
|
457 subset.Append(12);subset.Append(13); |
|
458 // Importlandmarks with invalid transfer option, should panic |
|
459 ExecuteAndDeleteLD(database->ImportLandmarksL(*landmarkParser, subset, 0x17)); |
|
460 CleanupStack::PopAndDestroy(landmarkParser); |
|
461 CleanupStack::PopAndDestroy(database); |
|
462 } |
|
463 else if (self->iTestCase == 11) |
|
464 { |
|
465 // Importlandmarks with non existing subset of ids, should panic |
|
466 CPosLandmarkDatabase* database = self->OpenDatabaseLC(); |
|
467 // Create parser |
|
468 CPosLandmarkParser* landmarkParser = CPosLandmarkParser::NewL(self->iMimeType); |
|
469 CleanupStack::PushL(landmarkParser); |
|
470 if ( self->iMimeType != KGpxMimeType ) |
|
471 { |
|
472 landmarkParser->SetInputFileL(KXML1); |
|
473 } |
|
474 else |
|
475 { |
|
476 landmarkParser->SetInputFileL(KXML3); |
|
477 } |
|
478 RArray<TUint> subset; |
|
479 CleanupClosePushL(subset); |
|
480 subset.Append(1);subset.Append(2);subset.Append(1200);subset.Append(1300); |
|
481 // Importlandmarks with non existing subset of ids, should panic |
|
482 // Should it Panic with EPosInvalidIndex |
|
483 ExecuteAndDeleteLD(database->ImportLandmarksL(*landmarkParser, subset, CPosLandmarkDatabase::EIncludeCategories)); |
|
484 CleanupStack::PopAndDestroy(&subset); |
|
485 CleanupStack::PopAndDestroy(landmarkParser); |
|
486 CleanupStack::PopAndDestroy(database); |
|
487 } |
|
488 else if (self->iTestCase == 12) |
|
489 { |
|
490 // Importlandmarks with empty subset of id, leaves with KErrArgument |
|
491 CPosLandmarkDatabase* database = self->OpenDatabaseLC(); |
|
492 // Create parser |
|
493 CPosLandmarkParser* landmarkParser = CPosLandmarkParser::NewL(self->iMimeType); |
|
494 CleanupStack::PushL(landmarkParser); |
|
495 landmarkParser->SetInputFileL(KXML1); |
|
496 RArray<TUint> subset; |
|
497 CleanupClosePushL(subset); |
|
498 // Importlandmarks with empty subset of ids, should leave with KErrArgument |
|
499 ExecuteAndDeleteLD(database->ImportLandmarksL(*landmarkParser, subset, CPosLandmarkDatabase::EIncludeCategories)); |
|
500 CleanupStack::PopAndDestroy(&subset); |
|
501 CleanupStack::PopAndDestroy(landmarkParser); |
|
502 CleanupStack::PopAndDestroy(database); |
|
503 } |
|
504 else if (self->iTestCase == 13) |
|
505 { |
|
506 // Retreive parsed landmark with index outside interval of parsed landmarks |
|
507 CPosLandmarkDatabase* database = self->OpenDatabaseLC(); |
|
508 // Create parser |
|
509 CPosLandmarkParser* landmarkParser = CPosLandmarkParser::NewL(self->iMimeType); |
|
510 CleanupStack::PushL(landmarkParser); |
|
511 if ( self->iMimeType != KGpxMimeType ) |
|
512 { |
|
513 landmarkParser->SetInputFileL(KXML1); |
|
514 } |
|
515 else |
|
516 { |
|
517 landmarkParser->SetInputFileL(KXML3); |
|
518 } |
|
519 |
|
520 ExecuteAndDeleteLD(landmarkParser->ParseContentL()); |
|
521 |
|
522 // Should panic with EPosInvalidIndex |
|
523 landmarkParser->LandmarkLC(2000); |
|
524 |
|
525 CleanupStack::PopAndDestroy(landmarkParser); |
|
526 CleanupStack::PopAndDestroy(database); |
|
527 } |
|
528 else if (self->iTestCase == 14) |
|
529 { |
|
530 // ParseContentL from empty buffer |
|
531 CPosLandmarkDatabase* database = self->OpenDatabaseLC(); |
|
532 // Create parser |
|
533 CPosLandmarkParser* landmarkParser = CPosLandmarkParser::NewL(self->iMimeType); |
|
534 CleanupStack::PushL(landmarkParser); |
|
535 HBufC8* bufferContent = HBufC8::NewLC(0); |
|
536 landmarkParser->SetInputBuffer(*bufferContent); |
|
537 |
|
538 CPosLmOperation* operation = landmarkParser->ParseContentL(); |
|
539 ExecuteAndDeleteLD(operation); |
|
540 |
|
541 CleanupStack::PopAndDestroy(landmarkParser); |
|
542 CleanupStack::PopAndDestroy(database); |
|
543 } |
|
544 else if (self->iTestCase == 15) |
|
545 { |
|
546 // ParseContentL from NULL input buffer |
|
547 CPosLandmarkDatabase* database = self->OpenDatabaseLC(); |
|
548 // Create parser |
|
549 CPosLandmarkParser* landmarkParser = CPosLandmarkParser::NewL(self->iMimeType); |
|
550 CleanupStack::PushL(landmarkParser); |
|
551 HBufC8* bufferContent = NULL; |
|
552 landmarkParser->SetInputBuffer(*bufferContent); |
|
553 |
|
554 ExecuteAndDeleteLD(landmarkParser->ParseContentL()); |
|
555 |
|
556 CleanupStack::PopAndDestroy(landmarkParser); |
|
557 CleanupStack::PopAndDestroy(database); |
|
558 } |
|
559 else if (self->iTestCase == 16) |
|
560 { |
|
561 // ImportLandmarks from empty buffer |
|
562 CPosLandmarkDatabase* database = self->OpenDatabaseLC(); |
|
563 // Create parser |
|
564 CPosLandmarkParser* landmarkParser = CPosLandmarkParser::NewL(self->iMimeType); |
|
565 CleanupStack::PushL(landmarkParser); |
|
566 HBufC8* bufferContent = HBufC8::NewLC(0); |
|
567 landmarkParser->SetInputBuffer(*bufferContent); |
|
568 |
|
569 CPosLmOperation* operation = database->ImportLandmarksL(*landmarkParser, CPosLandmarkDatabase::EIncludeCategories); |
|
570 ExecuteAndDeleteLD(operation); |
|
571 |
|
572 CleanupStack::PopAndDestroy(bufferContent); |
|
573 CleanupStack::PopAndDestroy(landmarkParser); |
|
574 CleanupStack::PopAndDestroy(database); |
|
575 } |
|
576 else if (self->iTestCase == 17) |
|
577 { |
|
578 // ImportLandmarks from NULL input buffer |
|
579 CPosLandmarkDatabase* database = self->OpenDatabaseLC(); |
|
580 // Create parser |
|
581 CPosLandmarkParser* landmarkParser = CPosLandmarkParser::NewL(self->iMimeType); |
|
582 CleanupStack::PushL(landmarkParser); |
|
583 HBufC8* bufferContent = NULL; |
|
584 landmarkParser->SetInputBuffer(*bufferContent); |
|
585 |
|
586 CPosLmOperation* operation = database->ImportLandmarksL(*landmarkParser, CPosLandmarkDatabase::EIncludeCategories); |
|
587 ExecuteAndDeleteLD(operation); |
|
588 CleanupStack::PopAndDestroy(landmarkParser); |
|
589 CleanupStack::PopAndDestroy(database); |
|
590 } |
|
591 } |
|
592 |
|
593 // --------------------------------------------------------- |
|
594 // LOCAL_C ThreadFunction |
|
595 // |
|
596 // (other items were commented in a header). |
|
597 // --------------------------------------------------------- |
|
598 // |
|
599 LOCAL_C TInt ThreadFunction(TAny* aData) |
|
600 { |
|
601 CTrapCleanup* cleanup=CTrapCleanup::New(); |
|
602 |
|
603 CActiveScheduler* actSch = new (ELeave) CActiveScheduler; |
|
604 CActiveScheduler::Install(actSch); |
|
605 |
|
606 TRAPD(err, CPosTp51::RunPanicTestL(aData)); |
|
607 |
|
608 delete actSch; |
|
609 delete cleanup; |
|
610 return err; |
|
611 } |
|
612 |
|
613 // --------------------------------------------------------- |
|
614 // CPosTp51::ListAllServers |
|
615 // |
|
616 // (other items were commented in a header). |
|
617 // --------------------------------------------------------- |
|
618 // |
|
619 void CPosTp51::ListAllServers() |
|
620 { |
|
621 TFindServer find(_L("*")); |
|
622 TFullName name; |
|
623 |
|
624 iLog->Log(_L("ListAllServers")); |
|
625 |
|
626 while (find.Next(name) == KErrNone) |
|
627 { |
|
628 iLog->Log(name); |
|
629 |
|
630 |
|
631 } |
|
632 iLog->Log(_L("--------------------")); |
|
633 } |
|
634 |
|
635 // --------------------------------------------------------- |
|
636 // CPosTp51::CreateThreadL |
|
637 // |
|
638 // (other items were commented in a header). |
|
639 // --------------------------------------------------------- |
|
640 // |
|
641 void CPosTp51::CreateThreadL() |
|
642 { |
|
643 _LIT(KThreadName, "Tp51test%dthread%d"); |
|
644 _LIT(KCreateThreadErr, "Create thread failed with %d"); |
|
645 |
|
646 TBuf<100> buf; |
|
647 buf.Format(KThreadName, iTestCase, ++iThreadCounter); |
|
648 |
|
649 TInt err=0; |
|
650 err = iThread.Create(buf, ThreadFunction, KDefaultStackSize, KMinHeapSize, KMaxHeapSize, this); |
|
651 AssertTrueSecL(err == KErrNone, KCreateThreadErr, err); |
|
652 } |
|
653 |
|
654 // End of File |