|
1 // Copyright (c) 2003-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 // |
|
15 |
|
16 #include <e32test.h> |
|
17 |
|
18 #include <xml/parserfeature.h> |
|
19 #include <xml/xmlframeworkerrors.h> |
|
20 |
|
21 #include "stabilitytestclass.h" |
|
22 #include "testdocuments.h" |
|
23 |
|
24 using namespace Xml; |
|
25 |
|
26 _LIT8 (KWmlStringDictionaryUri,"4~0"); |
|
27 _LIT8 (KSiStringDictionaryUri, "5~0"); |
|
28 |
|
29 _LIT (KTestDocument1, "z:\\system\\XmlTest\\Wml\\Corrupt\\CorruptTag_AllElements.wmlc"); |
|
30 _LIT (KTestDocument2, "z:\\system\\XmlTest\\Wml\\Corrupt\\CorruptAttr_mob.wmlc"); |
|
31 _LIT (KTestDocument3, "z:\\system\\XmlTest\\Wml\\Corrupt\\CorruptAttrVal_mob.wmlc"); |
|
32 _LIT (KTestDocument4, "z:\\system\\XmlTest\\Wml\\Corrupt\\NonNullTermInlineStr.wmlc"); |
|
33 |
|
34 _LIT (KTestDocument20, "z:\\system\\XmlTest\\ServiceIndication\\Corrupt\\si_inv_act_undf.bdy"); |
|
35 _LIT (KTestDocument21, "z:\\system\\XmlTest\\ServiceIndication\\Corrupt\\si_inv_cd_token.bdy"); |
|
36 _LIT (KTestDocument22, "z:\\system\\XmlTest\\ServiceIndication\\Corrupt\\si_inv_cd_type.bdy"); |
|
37 _LIT (KTestDocument23, "z:\\system\\XmlTest\\ServiceIndication\\Corrupt\\si_inv_char.bdy"); |
|
38 _LIT (KTestDocument24, "z:\\system\\XmlTest\\ServiceIndication\\Corrupt\\si_inv_msg_ter.bdy"); |
|
39 _LIT (KTestDocument25, "z:\\system\\XmlTest\\ServiceIndication\\Corrupt\\si_val_wbx_ver_14.bdy"); |
|
40 _LIT (KTestDocument26,"z:\\system\\XmlTest\\ServiceIndication\\Corrupt\\si_val_wbx_ver_30.bdy"); |
|
41 _LIT (KTestDocument27,"z:\\system\\XmlTest\\ServiceIndication\\Corrupt\\si_val_wbx_ver_FF.bdy"); |
|
42 _LIT (KTestDocument28,"z:\\system\\XmlTest\\ServiceIndication\\Corrupt\\si_inv_hrf_ter.bdy"); |
|
43 _LIT (KTestDocument29,"z:\\system\\XmlTest\\ServiceIndication\\Corrupt\\si_inv_msg_ter2.bdy"); |
|
44 |
|
45 |
|
46 static RTest test(_L("t_WbxmlCorruptParserTests")); |
|
47 |
|
48 |
|
49 /** |
|
50 @SYMTestCaseID SYSLIB-XML-CT-3731 |
|
51 @SYMTestCaseDesc Parsing corrupt files. |
|
52 @SYMTestPriority Medium |
|
53 @SYMTestActions Testing the wbxml parser with various corrupt files. |
|
54 @SYMTestExpectedResults Parser should be able to cope with the corrupt files. |
|
55 @SYMREQ REQ0000 |
|
56 */ |
|
57 static void BehaviourTestsL() |
|
58 { |
|
59 test.Next(_L(" @SYMTestCaseID:SYSLIB-XML-CT-3731 BehaviourTestsL tests... ")); |
|
60 |
|
61 __UHEAP_MARK; |
|
62 |
|
63 TPassOrFailureSettings aPassOrFailureSettings; |
|
64 |
|
65 aPassOrFailureSettings.iDoParseDocument = ETrue; |
|
66 aPassOrFailureSettings.iFilenameProvided = ETrue; |
|
67 aPassOrFailureSettings.iParseMode = EErrorOnUnrecognisedTags| |
|
68 ERawContent; |
|
69 |
|
70 |
|
71 CStabilityTestClass* behaviourTest = CStabilityTestClass::NewL(test); |
|
72 CleanupStack::PushL(behaviourTest); |
|
73 |
|
74 |
|
75 |
|
76 // Wml Tests |
|
77 |
|
78 aPassOrFailureSettings.iStringDictionaryUri = &KWmlStringDictionaryUri; |
|
79 |
|
80 aPassOrFailureSettings.iExpectedCode = KErrXmlUnsupportedElement; |
|
81 behaviourTest->TestBehaviour(KTestDocument1, aPassOrFailureSettings); |
|
82 |
|
83 |
|
84 // |
|
85 |
|
86 aPassOrFailureSettings.iExpectedCode = KErrXmlUnsupportedAttribute; |
|
87 behaviourTest->TestBehaviour(KTestDocument2, aPassOrFailureSettings); |
|
88 |
|
89 |
|
90 // |
|
91 |
|
92 aPassOrFailureSettings.iExpectedCode = KErrXmlUnsupportedAttributeValue; |
|
93 behaviourTest->TestBehaviour(KTestDocument3, aPassOrFailureSettings); |
|
94 |
|
95 |
|
96 // |
|
97 |
|
98 aPassOrFailureSettings.iExpectedCode = KErrNone; |
|
99 behaviourTest->TestBehaviour(KTestDocument4, aPassOrFailureSettings); |
|
100 |
|
101 |
|
102 // Si Tests |
|
103 // |
|
104 |
|
105 aPassOrFailureSettings.iStringDictionaryUri = &KSiStringDictionaryUri; |
|
106 |
|
107 aPassOrFailureSettings.iExpectedCode = KErrXmlDocumentCorrupt; |
|
108 behaviourTest->TestBehaviour(KTestDocument20, aPassOrFailureSettings); |
|
109 |
|
110 |
|
111 // |
|
112 |
|
113 aPassOrFailureSettings.iExpectedCode = KErrXmlUnsupportedAttributeValue; |
|
114 behaviourTest->TestBehaviour(KTestDocument21, aPassOrFailureSettings); |
|
115 |
|
116 |
|
117 // |
|
118 |
|
119 aPassOrFailureSettings.iExpectedCode = KErrXmlDocumentCorrupt; |
|
120 behaviourTest->TestBehaviour(KTestDocument22, aPassOrFailureSettings); |
|
121 |
|
122 |
|
123 // |
|
124 |
|
125 aPassOrFailureSettings.iExpectedCode = KErrXmlUnsupportedCharacterSet; |
|
126 behaviourTest->TestBehaviour(KTestDocument23, aPassOrFailureSettings); |
|
127 |
|
128 |
|
129 // |
|
130 |
|
131 aPassOrFailureSettings.iExpectedCode = KErrXmlDocumentCorrupt; // truncated doc. |
|
132 behaviourTest->TestBehaviour(KTestDocument24, aPassOrFailureSettings); |
|
133 |
|
134 |
|
135 // |
|
136 |
|
137 aPassOrFailureSettings.iExpectedCode = KErrXmlUnsupportedDocumentVersion; |
|
138 behaviourTest->TestBehaviour(KTestDocument25, aPassOrFailureSettings); |
|
139 |
|
140 |
|
141 // |
|
142 |
|
143 aPassOrFailureSettings.iExpectedCode = KErrXmlUnsupportedDocumentVersion; |
|
144 behaviourTest->TestBehaviour(KTestDocument26, aPassOrFailureSettings); |
|
145 |
|
146 |
|
147 // |
|
148 |
|
149 aPassOrFailureSettings.iExpectedCode = KErrXmlUnsupportedDocumentVersion; |
|
150 behaviourTest->TestBehaviour(KTestDocument27, aPassOrFailureSettings); |
|
151 |
|
152 |
|
153 // |
|
154 |
|
155 aPassOrFailureSettings.iExpectedCode = KErrXmlDocumentCorrupt; // truncated doc. |
|
156 behaviourTest->TestBehaviour(KTestDocument28, aPassOrFailureSettings); |
|
157 |
|
158 |
|
159 // |
|
160 |
|
161 aPassOrFailureSettings.iExpectedCode = KErrXmlDocumentCorrupt; // truncated doc. |
|
162 behaviourTest->TestBehaviour(KTestDocument29, aPassOrFailureSettings); |
|
163 |
|
164 |
|
165 |
|
166 CleanupStack::PopAndDestroy(behaviourTest); |
|
167 |
|
168 __UHEAP_MARKEND; |
|
169 } |
|
170 |
|
171 |
|
172 static void MainL() |
|
173 { |
|
174 BehaviourTestsL(); |
|
175 } |
|
176 |
|
177 |
|
178 TInt E32Main() |
|
179 { |
|
180 __UHEAP_MARK; |
|
181 test.Title(); |
|
182 test.Start(_L("initialising")); |
|
183 |
|
184 CTrapCleanup* c=CTrapCleanup::New(); |
|
185 |
|
186 // start the loader |
|
187 RFs fs; |
|
188 test (fs.Connect()==KErrNone); |
|
189 fs.Close(); |
|
190 |
|
191 test (c!=0); |
|
192 TRAPD(r,MainL()); |
|
193 test (r==KErrNone); |
|
194 delete c; |
|
195 test.End(); |
|
196 test.Close(); |
|
197 __UHEAP_MARKEND; |
|
198 return KErrNone; |
|
199 } |
|
200 |
|
201 |