|
1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // Implementation of Component Tests for CR JROE6C2LB7. |
|
15 // Those tests are based on the parser plugins provided with Symbian OS |
|
16 // and test parsers written for this purpose: |
|
17 // 1. XML parser - production code (mime type: text/xml, variant ID: Symbian) |
|
18 // 2. WBXML parser - production code (mime type: text/wbxml, variant ID: Symbian) |
|
19 // 3. XML/WBXML parser - test code (mime type: text/xml||text/wbxml, variant ID: SymbianExtended) |
|
20 // 4. XML parser - test code (mime type: text/xml, variant ID: SymbianExtended) |
|
21 // 5 XML parser - test code (mime type: text/testparser, variant ID: ) |
|
22 // If the number of Symbian production parsers is changed, |
|
23 // those test could require necessary updates. |
|
24 // |
|
25 // |
|
26 |
|
27 /** |
|
28 @file |
|
29 @internalComponent |
|
30 */ |
|
31 |
|
32 #include <e32test.h> |
|
33 #include <f32file.h> |
|
34 #include <ecom/ecom.h> |
|
35 |
|
36 #include <xml/matchdata.h> |
|
37 #include <xml/parser.h> |
|
38 #include <xml/parserfeature.h> |
|
39 #include <xml/xmlframeworkerrors.h> |
|
40 |
|
41 #include "contenthandlers.h" |
|
42 |
|
43 using namespace Xml; |
|
44 |
|
45 _LIT(KXmlTestSimpleTestFile, "z:\\System\\XmlTest\\Resolver\\simple.xml"); |
|
46 _LIT8(KXmlTestParserMimeType, "text/xml"); |
|
47 _LIT8(KXmlTestParserMimeTypeCS, "TEXT/XML"); |
|
48 _LIT8(KXmlTestWbXmlParserMimeType, "text/wbxml"); |
|
49 _LIT8(KXmlTestSymbianString, "Symbian"); |
|
50 _LIT8(KXmlTestSymbianStringCS, "SYMBIAN"); |
|
51 _LIT8(KXmlTestSymbianExtendedString, "SymbianExtended"); |
|
52 _LIT8(KXmlTestTestParser, "text/testparser"); |
|
53 |
|
54 RTest test(_L("t_XmlCustomResolverTests")); |
|
55 |
|
56 //========================================================================= |
|
57 // Class declaration |
|
58 |
|
59 class CXmlCustomResolverTests : public CBase |
|
60 { |
|
61 public: |
|
62 CXmlCustomResolverTests(); |
|
63 |
|
64 public: |
|
65 // The tests to run |
|
66 void Test1L(RFs& aRFs); |
|
67 void Test2L(); |
|
68 void Test3L(RFs& aRFs); |
|
69 void Test4L(RFs& aRFs); |
|
70 void Test5L(); |
|
71 void Test6L(); |
|
72 void Test7L(); |
|
73 void Test8L(); |
|
74 void Test9L(RFs& aRFs); |
|
75 void Test10L(RFs& aRFs); |
|
76 void Test11L(); |
|
77 void Test12L(); |
|
78 void Test13L(RFs& aRFs); |
|
79 void Test14L(RFs& aRFs); |
|
80 }; |
|
81 |
|
82 |
|
83 |
|
84 //========================================================================= |
|
85 // Class constructor |
|
86 CXmlCustomResolverTests::CXmlCustomResolverTests() |
|
87 { |
|
88 } |
|
89 |
|
90 //========================================================================= |
|
91 |
|
92 /** |
|
93 Test Xmlparser creation - 1. |
|
94 MimeType: text/xml |
|
95 Variant: NULL |
|
96 CaseSensitivity: TRUE |
|
97 Rom-Only: FALSE |
|
98 LeaveOnMany: FALSE |
|
99 |
|
100 Expected: handler->iNumElements > 0 |
|
101 Any XML parser |
|
102 |
|
103 @SYMTestCaseID SYSLIB-XML-CT-1377 |
|
104 @SYMTestCaseDesc |
|
105 @SYMTestPriority Medium |
|
106 @SYMTestActions |
|
107 @SYMTestExpectedResults |
|
108 @SYMCR CR0000 |
|
109 */ |
|
110 void CXmlCustomResolverTests::Test1L(RFs& aRFs) |
|
111 { |
|
112 test.Next(_L(" @SYMTestCaseID:SYSLIB-XML-CT-1377 ")); |
|
113 |
|
114 CMatchData* matchData = CMatchData::NewLC(); |
|
115 matchData->SetMimeTypeL(KXmlTestParserMimeType); |
|
116 |
|
117 TSimpleContentHandler* handler = new (ELeave) TSimpleContentHandler(); |
|
118 |
|
119 // NewL test |
|
120 CParser* parser = NULL; |
|
121 parser = CParser::NewL(*matchData, *handler); |
|
122 ParseL(*parser, aRFs, KXmlTestSimpleTestFile); |
|
123 test(handler->iNumElements>0); |
|
124 delete parser; parser = NULL; |
|
125 |
|
126 // NewLC test |
|
127 handler->iNumElements = 0; |
|
128 parser = CParser::NewLC(*matchData, *handler); |
|
129 ParseL(*parser, aRFs, KXmlTestSimpleTestFile); |
|
130 test(handler->iNumElements>0); |
|
131 |
|
132 delete handler; |
|
133 CleanupStack::PopAndDestroy(2, matchData); |
|
134 } |
|
135 |
|
136 |
|
137 /** |
|
138 Test Xmlparser creation - 2. |
|
139 MimeType: text/xml |
|
140 Variant: NULL |
|
141 CaseSensitivity: TRUE |
|
142 Rom-Only: FALSE |
|
143 LeaveOnMany: TRUE |
|
144 |
|
145 Expected: leave, KErrXmlMoreThanOneParserMatched |
|
146 |
|
147 @SYMTestCaseID SYSLIB-XML-CT-1378 |
|
148 @SYMTestCaseDesc |
|
149 @SYMTestPriority Medium |
|
150 @SYMTestActions |
|
151 @SYMTestExpectedResults |
|
152 @SYMCR CR0000 |
|
153 */ |
|
154 void CXmlCustomResolverTests::Test2L() |
|
155 { |
|
156 test.Next(_L(" @SYMTestCaseID:SYSLIB-XML-CT-1378 ")); |
|
157 |
|
158 CMatchData* matchData = CMatchData::NewLC(); |
|
159 matchData->SetMimeTypeL(KXmlTestParserMimeType); |
|
160 matchData->SetLeaveOnMany(ETrue); |
|
161 |
|
162 // NewL test |
|
163 TSimpleContentHandler* handler = new (ELeave) TSimpleContentHandler(); |
|
164 TRAPD(err, CParser::NewL(*matchData, *handler)); |
|
165 test(err == KErrXmlMoreThanOneParserMatched); |
|
166 |
|
167 // NewLC test |
|
168 TRAP(err, CParser::NewLC(*matchData, *handler)); |
|
169 test(err == KErrXmlMoreThanOneParserMatched); |
|
170 |
|
171 delete handler; |
|
172 CleanupStack::PopAndDestroy(matchData); |
|
173 } |
|
174 |
|
175 /** |
|
176 Test Xmlparser creation - 3. |
|
177 MimeType: text/xml |
|
178 Variant: Symbian |
|
179 CaseSensitivity: TRUE |
|
180 Rom-Only: FALSE |
|
181 LeaveOnMany: FALSE |
|
182 |
|
183 Expected: handler->iNumElements == 6 |
|
184 Production, Symbian parser. |
|
185 |
|
186 @SYMTestCaseID SYSLIB-XML-CT-1379 |
|
187 @SYMTestCaseDesc |
|
188 @SYMTestPriority Medium |
|
189 @SYMTestActions |
|
190 @SYMTestExpectedResults |
|
191 @SYMCR CR0000 |
|
192 */ |
|
193 void CXmlCustomResolverTests::Test3L(RFs& aRFs) |
|
194 { |
|
195 test.Next(_L(" @SYMTestCaseID:SYSLIB-XML-CT-1379 ")); |
|
196 |
|
197 CMatchData* matchData = CMatchData::NewLC(); |
|
198 matchData->SetMimeTypeL(KXmlTestParserMimeType); |
|
199 matchData->SetVariantL(KXmlTestSymbianString); |
|
200 |
|
201 TSimpleContentHandler* handler = new (ELeave) TSimpleContentHandler(); |
|
202 |
|
203 // NewL |
|
204 CParser* parser = CParser::NewL(*matchData, *handler); |
|
205 ParseL(*parser, aRFs, KXmlTestSimpleTestFile); |
|
206 test(handler->iNumElements==6); |
|
207 delete parser; parser = NULL; |
|
208 |
|
209 // NewLC |
|
210 parser = CParser::NewLC(*matchData, *handler); |
|
211 ParseL(*parser, aRFs, KXmlTestSimpleTestFile); |
|
212 test(handler->iNumElements==6); |
|
213 |
|
214 delete handler; |
|
215 CleanupStack::PopAndDestroy(2, matchData); |
|
216 } |
|
217 |
|
218 /** |
|
219 Test Xmlparser creation - 4. |
|
220 MimeType: text/xml |
|
221 Variant: SymbianExtended |
|
222 CaseSensitivity: TRUE |
|
223 Rom-Only: FALSE |
|
224 LeaveOnMany: FALSE |
|
225 |
|
226 Expected: handler->iNumElements == 1 || handler->iNumElements == 2 |
|
227 Either of two test parsers. |
|
228 |
|
229 @SYMTestCaseID SYSLIB-XML-CT-1380 |
|
230 @SYMTestCaseDesc |
|
231 @SYMTestPriority Medium |
|
232 @SYMTestActions |
|
233 @SYMTestExpectedResults |
|
234 @SYMCR CR0000 |
|
235 */ |
|
236 void CXmlCustomResolverTests::Test4L(RFs& aRFs) |
|
237 { |
|
238 test.Next(_L(" @SYMTestCaseID:SYSLIB-XML-CT-1380 ")); |
|
239 |
|
240 CMatchData* matchData = CMatchData::NewLC(); |
|
241 matchData->SetMimeTypeL(KXmlTestParserMimeType); |
|
242 matchData->SetVariantL(KXmlTestSymbianExtendedString); |
|
243 TSimpleContentHandler* handler = new (ELeave) TSimpleContentHandler(); |
|
244 |
|
245 // NewL test |
|
246 CParser* parser = CParser::NewL(*matchData, *handler); |
|
247 ParseL(*parser, aRFs, KXmlTestSimpleTestFile); |
|
248 test(handler->iNumElements==1 || handler->iNumElements==2 ); |
|
249 delete parser; parser = NULL; |
|
250 |
|
251 // NewLC test |
|
252 parser = CParser::NewLC(*matchData, *handler); |
|
253 ParseL(*parser, aRFs, KXmlTestSimpleTestFile); |
|
254 test(handler->iNumElements==1 || handler->iNumElements==2 ); |
|
255 |
|
256 delete handler; |
|
257 CleanupStack::PopAndDestroy(2, matchData); |
|
258 } |
|
259 |
|
260 /** |
|
261 Test Xmlparser createion - 5. |
|
262 MimeType: text/xml |
|
263 Variant: SymbianExtended |
|
264 CaseSensitivity: TRUE |
|
265 Rom-Only: FALSE |
|
266 LeaveOnMany: TRUE |
|
267 |
|
268 Expected: leave, KErrXmlMoreThanOneParserMatched |
|
269 |
|
270 @SYMTestCaseID SYSLIB-XML-CT-1381 |
|
271 @SYMTestCaseDesc |
|
272 @SYMTestPriority Medium |
|
273 @SYMTestActions |
|
274 @SYMTestExpectedResults |
|
275 @SYMCR CR0000 |
|
276 */ |
|
277 void CXmlCustomResolverTests::Test5L() |
|
278 { |
|
279 test.Next(_L(" @SYMTestCaseID:SYSLIB-XML-CT-1381 ")); |
|
280 |
|
281 CMatchData* matchData = CMatchData::NewLC(); |
|
282 matchData->SetMimeTypeL(KXmlTestParserMimeType); |
|
283 matchData->SetVariantL(KXmlTestSymbianExtendedString); |
|
284 matchData->SetLeaveOnMany(ETrue); |
|
285 |
|
286 TSimpleContentHandler* handler = new (ELeave) TSimpleContentHandler(); |
|
287 |
|
288 // NewL test |
|
289 TRAPD(err, CParser::NewL(*matchData, *handler)); |
|
290 test (err == KErrXmlMoreThanOneParserMatched); |
|
291 |
|
292 // NewLC test |
|
293 TRAP(err, CParser::NewLC(*matchData, *handler)); |
|
294 test (err == KErrXmlMoreThanOneParserMatched); |
|
295 |
|
296 delete handler; |
|
297 CleanupStack::PopAndDestroy(matchData); |
|
298 } |
|
299 |
|
300 /** |
|
301 Test Xmlparser createion - 6. |
|
302 MimeType: text/wbxml |
|
303 Variant: NULL |
|
304 CaseSensitivity: TRUE |
|
305 Rom-Only: FALSE |
|
306 LeaveOnMany: FALSE |
|
307 |
|
308 Expected: any of wbxml parsers |
|
309 |
|
310 @SYMTestCaseID SYSLIB-XML-CT-1382 |
|
311 @SYMTestCaseDesc |
|
312 @SYMTestPriority Medium |
|
313 @SYMTestActions |
|
314 @SYMTestExpectedResults |
|
315 @SYMCR CR0000 |
|
316 */ |
|
317 void CXmlCustomResolverTests::Test6L() |
|
318 { |
|
319 test.Next(_L(" @SYMTestCaseID:SYSLIB-XML-CT-1382 ")); |
|
320 |
|
321 CMatchData* matchData = CMatchData::NewLC(); |
|
322 matchData->SetMimeTypeL(KXmlTestWbXmlParserMimeType); |
|
323 TSimpleContentHandler* handler = new (ELeave) TSimpleContentHandler(); |
|
324 |
|
325 // NewL test |
|
326 CParser* parser = CParser::NewL(*matchData, *handler); |
|
327 delete parser; parser = NULL; |
|
328 |
|
329 // NewLC test |
|
330 parser = CParser::NewLC(*matchData, *handler); |
|
331 |
|
332 delete handler; |
|
333 CleanupStack::PopAndDestroy(2, matchData); |
|
334 } |
|
335 |
|
336 /** |
|
337 Test Xmlparser createion - 7. |
|
338 MimeType: text/wbxml |
|
339 Variant: NULL |
|
340 CaseSensitivity: TRUE |
|
341 Rom-Only: FALSE |
|
342 LeaveOnMany: TRUE |
|
343 |
|
344 Expected: leave, KErrXmlMoreThanOneParserMatched |
|
345 |
|
346 @SYMTestCaseID SYSLIB-XML-CT-1383 |
|
347 @SYMTestCaseDesc |
|
348 @SYMTestPriority Medium |
|
349 @SYMTestActions |
|
350 @SYMTestExpectedResults |
|
351 @SYMCR CR0000 |
|
352 */ |
|
353 void CXmlCustomResolverTests::Test7L() |
|
354 { |
|
355 test.Next(_L(" @SYMTestCaseID:SYSLIB-XML-CT-1383 ")); |
|
356 |
|
357 CMatchData* matchData = CMatchData::NewLC(); |
|
358 matchData->SetMimeTypeL(KXmlTestWbXmlParserMimeType); |
|
359 matchData->SetLeaveOnMany(ETrue); |
|
360 |
|
361 TSimpleContentHandler* handler = new (ELeave) TSimpleContentHandler(); |
|
362 |
|
363 // NewL test |
|
364 TRAPD(err, CParser::NewL(*matchData, *handler)); |
|
365 test(err == KErrXmlMoreThanOneParserMatched); |
|
366 |
|
367 // NewLC test |
|
368 TRAP(err, CParser::NewLC(*matchData, *handler)); |
|
369 test(err == KErrXmlMoreThanOneParserMatched); |
|
370 |
|
371 delete handler; |
|
372 CleanupStack::PopAndDestroy(matchData); |
|
373 } |
|
374 |
|
375 /** |
|
376 Test Xmlparser createion - 8. |
|
377 MimeType: TEXT/XML |
|
378 Variant: NULL |
|
379 CaseSensitivity: TRUE |
|
380 Rom-Only: FALSE |
|
381 LeaveOnMany: FALSE |
|
382 |
|
383 Expected: leave, KErrXmlParserPluginNotFound |
|
384 |
|
385 @SYMTestCaseID SYSLIB-XML-CT-1384 |
|
386 @SYMTestCaseDesc |
|
387 @SYMTestPriority Medium |
|
388 @SYMTestActions |
|
389 @SYMTestExpectedResults |
|
390 @SYMCR CR0000 |
|
391 */ |
|
392 void CXmlCustomResolverTests::Test8L() |
|
393 { |
|
394 test.Next(_L(" @SYMTestCaseID:SYSLIB-XML-CT-1384 ")); |
|
395 |
|
396 CMatchData* matchData = CMatchData::NewLC(); |
|
397 matchData->SetMimeTypeL(KXmlTestParserMimeTypeCS); |
|
398 |
|
399 TSimpleContentHandler* handler = new (ELeave) TSimpleContentHandler(); |
|
400 |
|
401 // NewL test |
|
402 TRAPD(err, CParser::NewL(*matchData, *handler)); |
|
403 test(err == KErrXmlParserPluginNotFound); |
|
404 |
|
405 // NewLC test |
|
406 TRAP(err, CParser::NewLC(*matchData, *handler)); |
|
407 test(err == KErrXmlParserPluginNotFound); |
|
408 |
|
409 delete handler; |
|
410 CleanupStack::PopAndDestroy(matchData); |
|
411 } |
|
412 |
|
413 /** |
|
414 Test Xmlparser createion - 9. |
|
415 MimeType: TEXT/XML |
|
416 Variant: NULL |
|
417 CaseSensitivity: FALSE |
|
418 Rom-Only: FALSE |
|
419 LeaveOnMany: FALSE |
|
420 |
|
421 Expected: handler->iNumElements > 0 |
|
422 Any XML parser |
|
423 |
|
424 @SYMTestCaseID SYSLIB-XML-CT-1385 |
|
425 @SYMTestCaseDesc |
|
426 @SYMTestPriority Medium |
|
427 @SYMTestActions |
|
428 @SYMTestExpectedResults |
|
429 @SYMCR CR0000 |
|
430 */ |
|
431 void CXmlCustomResolverTests::Test9L(RFs& aRFs) |
|
432 { |
|
433 test.Next(_L(" @SYMTestCaseID:SYSLIB-XML-CT-1385 ")); |
|
434 |
|
435 CMatchData* matchData = CMatchData::NewLC(); |
|
436 matchData->SetMimeTypeL(KXmlTestParserMimeTypeCS); |
|
437 matchData->SetCaseSensitivity(EFalse); |
|
438 |
|
439 TSimpleContentHandler* handler = new (ELeave) TSimpleContentHandler(); |
|
440 |
|
441 // NewL test |
|
442 CParser* parser = CParser::NewL(*matchData, *handler); |
|
443 ParseL(*parser, aRFs, KXmlTestSimpleTestFile); |
|
444 test(handler->iNumElements > 0); |
|
445 delete parser; parser = NULL; |
|
446 |
|
447 // NewLC test |
|
448 parser = CParser::NewLC(*matchData, *handler); |
|
449 ParseL(*parser, aRFs, KXmlTestSimpleTestFile); |
|
450 test(handler->iNumElements > 0); |
|
451 |
|
452 delete handler; |
|
453 CleanupStack::PopAndDestroy(2, matchData); |
|
454 } |
|
455 |
|
456 /** |
|
457 Test Xmlparser createion - 10. |
|
458 MimeType: TEXT/XML |
|
459 Variant: SYMBIAN |
|
460 CaseSensitivity: FALSE |
|
461 Rom-Only: FALSE |
|
462 LeaveOnMany: FALSE |
|
463 |
|
464 Expected: handler->iNumElements > 0 |
|
465 Any XML parser |
|
466 |
|
467 @SYMTestCaseID SYSLIB-XML-CT-1386 |
|
468 @SYMTestCaseDesc |
|
469 @SYMTestPriority Medium |
|
470 @SYMTestActions |
|
471 @SYMTestExpectedResults |
|
472 @SYMCR CR0000 |
|
473 */ |
|
474 void CXmlCustomResolverTests::Test10L(RFs& aRFs) |
|
475 { |
|
476 test.Next(_L(" @SYMTestCaseID:SYSLIB-XML-CT-1386 ")); |
|
477 |
|
478 CMatchData* matchData = CMatchData::NewLC(); |
|
479 matchData->SetMimeTypeL(KXmlTestParserMimeTypeCS); |
|
480 matchData->SetVariantL(KXmlTestSymbianStringCS); |
|
481 matchData->SetCaseSensitivity(EFalse); |
|
482 |
|
483 TSimpleContentHandler* handler = new (ELeave) TSimpleContentHandler(); |
|
484 |
|
485 // NewL test |
|
486 CParser* parser = CParser::NewL(*matchData, *handler); |
|
487 ParseL(*parser, aRFs, KXmlTestSimpleTestFile); |
|
488 test(handler->iNumElements == 6); |
|
489 delete parser; parser = NULL; |
|
490 |
|
491 // NewLC test |
|
492 parser = CParser::NewLC(*matchData, *handler); |
|
493 ParseL(*parser, aRFs, KXmlTestSimpleTestFile); |
|
494 test(handler->iNumElements == 6); |
|
495 |
|
496 delete handler; |
|
497 CleanupStack::PopAndDestroy(2, matchData); |
|
498 } |
|
499 |
|
500 /** |
|
501 Test Xmlparser createion - 11. |
|
502 MimeType: TEXT/XML |
|
503 Variant: SYMBIAN |
|
504 CaseSensitivity: TRUE |
|
505 Rom-Only: FALSE |
|
506 LeaveOnMany: FALSE |
|
507 |
|
508 Expected: handler->iNumElements > 0 |
|
509 Any XML parser |
|
510 |
|
511 @SYMTestCaseID SYSLIB-XML-CT-3752 |
|
512 @SYMTestCaseDesc |
|
513 @SYMTestPriority Medium |
|
514 @SYMTestActions |
|
515 @SYMTestExpectedResults |
|
516 @SYMCR CR0000 |
|
517 */ |
|
518 void CXmlCustomResolverTests::Test11L() |
|
519 { |
|
520 test.Next(_L(" @SYMTestCaseID:SYSLIB-XML-CT-3752 ")); |
|
521 |
|
522 CMatchData* matchData = CMatchData::NewLC(); |
|
523 matchData->SetMimeTypeL(KXmlTestParserMimeTypeCS); |
|
524 matchData->SetVariantL(KXmlTestSymbianStringCS); |
|
525 matchData->SetCaseSensitivity(ETrue); |
|
526 |
|
527 TSimpleContentHandler* handler = new (ELeave) TSimpleContentHandler(); |
|
528 |
|
529 // NewL test |
|
530 TRAPD(err, CParser::NewL(*matchData, *handler)); |
|
531 test(err == KErrXmlParserPluginNotFound); |
|
532 |
|
533 // NewLC test |
|
534 TRAP(err, CParser::NewLC(*matchData, *handler)); |
|
535 test(err == KErrXmlParserPluginNotFound); |
|
536 |
|
537 delete handler; |
|
538 CleanupStack::PopAndDestroy(matchData); |
|
539 } |
|
540 |
|
541 /** |
|
542 Test Xmlparser creation - 12. |
|
543 MimeType: NULL |
|
544 Variant: NULL |
|
545 CaseSensitivity: TRUE |
|
546 Rom-Only: FALSE |
|
547 LeaveOnMany: FALSE |
|
548 |
|
549 Expected: Leave, KErrArgument - mime type mandatory |
|
550 |
|
551 @SYMTestCaseID SYSLIB-XML-CT-3753 |
|
552 @SYMTestCaseDesc |
|
553 @SYMTestPriority Medium |
|
554 @SYMTestActions |
|
555 @SYMTestExpectedResults |
|
556 @SYMCR CR0000 |
|
557 */ |
|
558 void CXmlCustomResolverTests::Test12L() |
|
559 { |
|
560 test.Next(_L(" @SYMTestCaseID:SYSLIB-XML-CT-3753 ")); |
|
561 |
|
562 CMatchData* matchData = CMatchData::NewLC(); |
|
563 TSimpleContentHandler* handler = new (ELeave) TSimpleContentHandler(); |
|
564 |
|
565 // NewL test |
|
566 TRAPD(err, CParser::NewL(*matchData, *handler)); |
|
567 test(err == KErrArgument); |
|
568 |
|
569 // NewLC test |
|
570 TRAP(err, CParser::NewLC(*matchData, *handler)); |
|
571 test(err == KErrArgument); |
|
572 |
|
573 delete handler; |
|
574 CleanupStack::PopAndDestroy(matchData); |
|
575 |
|
576 } |
|
577 |
|
578 /** |
|
579 Test Xmlparser creation - 13. |
|
580 MimeType: text/testparser |
|
581 Variant: NULL |
|
582 CaseSensitivity: TRUE |
|
583 Rom-Only: FALSE |
|
584 LeaveOnMany: FALSE |
|
585 |
|
586 Expected: handler->iNumPrefixMappings should be equal to 1 |
|
587 |
|
588 @SYMTestCaseID SYSLIB-XML-CT-1411 |
|
589 @SYMTestCaseDesc |
|
590 @SYMTestPriority Medium |
|
591 @SYMTestActions |
|
592 @SYMTestExpectedResults |
|
593 @SYMCR CR0000 |
|
594 */ |
|
595 void CXmlCustomResolverTests::Test13L(RFs& aRFs) |
|
596 { |
|
597 test.Next(_L(" @SYMTestCaseID:SYSLIB-XML-CT-1411 ")); |
|
598 |
|
599 CMatchData* matchData = CMatchData::NewLC(); |
|
600 TSimpleContentHandler* handler = new (ELeave) TSimpleContentHandler(); |
|
601 |
|
602 matchData->SetMimeTypeL(KXmlTestTestParser); |
|
603 CParser* parser = CParser::NewL(*matchData, *handler); |
|
604 TRAPD(err, ParseL(*parser, aRFs, KXmlTestSimpleTestFile)); |
|
605 test(err == KErrXmlUnsupportedExtInterface); |
|
606 |
|
607 delete parser; |
|
608 delete handler; |
|
609 CleanupStack::PopAndDestroy(matchData); |
|
610 } |
|
611 |
|
612 /** |
|
613 Test Xmlparser swap test - 14. |
|
614 This method is testing parser swapping using ParseBeginL method. |
|
615 Test steps: |
|
616 1. Get xml test parser |
|
617 Test for 1 or 2 events generated. |
|
618 |
|
619 2. Swap to xml production parser |
|
620 Test for 6 events genrated. |
|
621 |
|
622 3. Swap to wbxml production parser |
|
623 Test for no errors. |
|
624 |
|
625 4. Swap to xml production parser |
|
626 Test for 6 events gerated. |
|
627 |
|
628 @SYMTestCaseID SYSLIB-XML-CT-1412 |
|
629 @SYMTestCaseDesc |
|
630 @SYMTestPriority Medium |
|
631 @SYMTestActions |
|
632 @SYMTestExpectedResults |
|
633 @SYMCR CR0000 |
|
634 */ |
|
635 void CXmlCustomResolverTests::Test14L(RFs& aRFs) |
|
636 { |
|
637 test.Next(_L(" @SYMTestCaseID:SYSLIB-XML-CT-1412 ")); |
|
638 |
|
639 CMatchData* matchData = CMatchData::NewLC(); |
|
640 TSimpleContentHandler* handler = new (ELeave) TSimpleContentHandler(); |
|
641 |
|
642 // Get the tests parser of xml |
|
643 matchData->SetMimeTypeL(KXmlTestParserMimeType); |
|
644 matchData->SetVariantL(KXmlTestSymbianExtendedString); |
|
645 CParser* parser = CParser::NewL(*matchData, *handler); |
|
646 ParseL(*parser, aRFs, KXmlTestSimpleTestFile); |
|
647 test(handler->iNumElements == 1 || handler->iNumElements == 2); |
|
648 |
|
649 // Try to swap parsers to production xml |
|
650 matchData->SetVariantL(KXmlTestSymbianString); |
|
651 handler->iNumElements = 0; |
|
652 parser->ParseBeginL(*matchData); |
|
653 ParseL(*parser, aRFs, KXmlTestSimpleTestFile); |
|
654 test(handler->iNumElements == 6); |
|
655 |
|
656 // Try to swap parser to wbxml production parser |
|
657 matchData->SetMimeTypeL(KXmlTestWbXmlParserMimeType); |
|
658 TRAPD(err, parser->ParseBeginL(*matchData)); |
|
659 test(err == KErrNone); |
|
660 |
|
661 // Try to swap again to test xml parser |
|
662 matchData->SetMimeTypeL(KXmlTestParserMimeType); |
|
663 matchData->SetVariantL(KXmlTestSymbianExtendedString); |
|
664 parser->ParseBeginL(*matchData); |
|
665 ParseL(*parser, aRFs, KXmlTestSimpleTestFile); |
|
666 test(handler->iNumElements == 1 || handler->iNumElements == 2); |
|
667 |
|
668 delete parser; |
|
669 delete handler; |
|
670 CleanupStack::PopAndDestroy(matchData); |
|
671 } |
|
672 |
|
673 |
|
674 //======================================================================== |
|
675 |
|
676 static void XmlCustomResolverTestsL() |
|
677 { |
|
678 CXmlCustomResolverTests *customResolverTests = new (ELeave) CXmlCustomResolverTests(); |
|
679 CleanupStack::PushL(customResolverTests); |
|
680 |
|
681 RFs fs; |
|
682 User::LeaveIfError(fs.Connect()); |
|
683 CleanupClosePushL(fs); |
|
684 |
|
685 customResolverTests->Test1L(fs); |
|
686 customResolverTests->Test2L(); |
|
687 customResolverTests->Test3L(fs); |
|
688 customResolverTests->Test4L(fs); |
|
689 customResolverTests->Test5L(); |
|
690 customResolverTests->Test6L(); |
|
691 customResolverTests->Test7L(); |
|
692 customResolverTests->Test8L(); |
|
693 customResolverTests->Test9L(fs); |
|
694 customResolverTests->Test10L(fs); |
|
695 customResolverTests->Test11L(); |
|
696 customResolverTests->Test12L(); |
|
697 customResolverTests->Test13L(fs); |
|
698 customResolverTests->Test14L(fs); |
|
699 CleanupStack::PopAndDestroy(2, customResolverTests); |
|
700 } |
|
701 |
|
702 static void MainL() |
|
703 { |
|
704 __UHEAP_MARK; |
|
705 XmlCustomResolverTestsL(); |
|
706 REComSession::FinalClose(); |
|
707 __UHEAP_MARKEND; |
|
708 } |
|
709 |
|
710 TInt E32Main() |
|
711 { |
|
712 test.SetLogged(ETrue); |
|
713 test.Title(); |
|
714 test.Start(_L("XML Framework enhancement tests")); |
|
715 |
|
716 CTrapCleanup* c=CTrapCleanup::New(); |
|
717 |
|
718 // start the loader |
|
719 RFs fs; |
|
720 test (fs.Connect()==KErrNone); |
|
721 fs.Close(); |
|
722 |
|
723 test (c!=0); |
|
724 TRAPD(r,MainL()); |
|
725 test (r==KErrNone); |
|
726 delete c; |
|
727 test.End(); |
|
728 test.Close(); |
|
729 |
|
730 return KErrNone; |
|
731 } |
|
732 |
|
733 |
|
734 |