|
1 /* |
|
2 * Copyright (c) 2002-2009 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: ?Description |
|
15 * |
|
16 */ |
|
17 |
|
18 // INCLUDE FILES |
|
19 #include <StifTestModule.h> |
|
20 #include <e32math.h> |
|
21 #include <libc/assert.h> |
|
22 #include <e32panic.h> |
|
23 #include "senfragmentbctest.h" |
|
24 #include "maindomfragment.h" |
|
25 #include "mainfragment.h" |
|
26 #include "TestFragment.h" |
|
27 |
|
28 // ============================ MEMBER FUNCTIONS =============================== |
|
29 |
|
30 // ----------------------------------------------------------------------------- |
|
31 // CSenFragmentBCTest::Case |
|
32 // Returns a test case by number. |
|
33 // |
|
34 // This function contains an array of all available test cases |
|
35 // i.e pair of case name and test function. If case specified by parameter |
|
36 // aCaseNumber is found from array, then that item is returned. |
|
37 // |
|
38 // The reason for this rather complicated function is to specify all the |
|
39 // test cases only in one place. It is not necessary to understand how |
|
40 // function pointers to class member functions works when adding new test |
|
41 // cases. See function body for instructions how to add new test case. |
|
42 // ----------------------------------------------------------------------------- |
|
43 // |
|
44 const TCaseInfo CSenFragmentBCTest::Case ( |
|
45 const TInt aCaseNumber ) const |
|
46 { |
|
47 |
|
48 /** |
|
49 * To add new test cases, implement new test case function and add new |
|
50 * line to KCases array specify the name of the case and the function |
|
51 * doing the test case |
|
52 * In practice, do following |
|
53 * 1) Make copy of existing test case function and change its name |
|
54 * and functionality. Note that the function must be added to |
|
55 * SenFragment.cpp file and to SenFragment.h |
|
56 * header file. |
|
57 * |
|
58 * 2) Add entry to following KCases array either by using: |
|
59 * |
|
60 * 2.1: FUNCENTRY or ENTRY macro |
|
61 * ENTRY macro takes two parameters: test case name and test case |
|
62 * function name. |
|
63 * |
|
64 * FUNCENTRY macro takes only test case function name as a parameter and |
|
65 * uses that as a test case name and test case function name. |
|
66 * |
|
67 * Or |
|
68 * |
|
69 * 2.2: OOM_FUNCENTRY or OOM_ENTRY macro. Note that these macros are used |
|
70 * only with OOM (Out-Of-Memory) testing! |
|
71 * |
|
72 * OOM_ENTRY macro takes five parameters: test case name, test case |
|
73 * function name, TBool which specifies is method supposed to be run using |
|
74 * OOM conditions, TInt value for first heap memory allocation failure and |
|
75 * TInt value for last heap memory allocation failure. |
|
76 * |
|
77 * OOM_FUNCENTRY macro takes test case function name as a parameter and uses |
|
78 * that as a test case name, TBool which specifies is method supposed to be |
|
79 * run using OOM conditions, TInt value for first heap memory allocation |
|
80 * failure and TInt value for last heap memory allocation failure. |
|
81 */ |
|
82 |
|
83 static TCaseInfoInternal const KCases[] = |
|
84 { |
|
85 |
|
86 ENTRY( "NewL - CSenDomFragmentBase", CSenFragmentBCTest::MT_CSenDomFragmentBase_NewLL ), |
|
87 ENTRY( "NewL - CSenDomFragmentBase", CSenFragmentBCTest::MT_CSenDomFragmentBase_NewL_1L ), |
|
88 ENTRY( "NewL - CSenDomFragmentBase", CSenFragmentBCTest::MT_CSenDomFragmentBase_NewL_2L ), |
|
89 ENTRY( "NewL - CSenDomFragmentBase", CSenFragmentBCTest::MT_CSenDomFragmentBase_NewL_3L ), |
|
90 ENTRY( "NewL - CSenDomFragmentBase", CSenFragmentBCTest::MT_CSenDomFragmentBase_NewL_4L ), |
|
91 ENTRY( "NewL - CSenDomFragmentBase", CSenFragmentBCTest::MT_CSenDomFragmentBase_NewL_5L ), |
|
92 ENTRY( "NewL - CSenDomFragmentBase", CSenFragmentBCTest::MT_CSenDomFragmentBase_NewL_6L ), |
|
93 ENTRY( "NewL - CSenDomFragmentBase", CSenFragmentBCTest::MT_CSenDomFragmentBase_NewL_7L ), |
|
94 ENTRY( "AddAttributesL - CSenDomFragmentBase", CSenFragmentBCTest::MT_CSenDomFragmentBase_AddAttributesLL ), |
|
95 ENTRY( "AsXmlL - CSenDomFragmentBase", CSenFragmentBCTest::MT_CSenDomFragmentBase_AsXmlLL ), |
|
96 ENTRY( "ContentL - CSenDomFragmentBase", CSenFragmentBCTest::MT_CSenDomFragmentBase_ContentLL ), |
|
97 ENTRY( "Namespace - CSenDomFragmentBase", CSenFragmentBCTest::MT_CSenDomFragmentBase_NamespaceL ), |
|
98 ENTRY( "ResetContentL - CSenDomFragmentBase", CSenFragmentBCTest::MT_CSenDomFragmentBase_ResetContentLL ), |
|
99 ENTRY( "LocalName - CSenDomFragmentBase", CSenFragmentBCTest::MT_CSenDomFragmentBase_LocalNameL ), |
|
100 ENTRY( "NsUri - CSenDomFragmentBase", CSenFragmentBCTest::MT_CSenDomFragmentBase_NsUriL ), |
|
101 ENTRY( "NsPrefix - CSenDomFragmentBase", CSenFragmentBCTest::MT_CSenDomFragmentBase_NsPrefixL ), |
|
102 ENTRY( "AsElementL - CSenDomFragmentBase", CSenFragmentBCTest::MT_CSenDomFragmentBase_AsElementLL ), |
|
103 ENTRY( "AsDocumentL - CSenDomFragmentBase", CSenFragmentBCTest::MT_CSenDomFragmentBase_AsDocumentLL ), |
|
104 ENTRY( "ExtractElement - CSenDomFragmentBase", CSenFragmentBCTest::MT_CSenDomFragmentBase_ExtractElementL ), |
|
105 ENTRY( "AsXmlUnicodeL - CSenDomFragmentBase", CSenFragmentBCTest::MT_CSenDomFragmentBase_AsXmlUnicodeLL ), |
|
106 ENTRY( "WriteAsXMLToL - CSenDomFragmentBase", CSenFragmentBCTest::MT_CSenDomFragmentBase_WriteAsXMLToLL ), |
|
107 ENTRY( "ConsistsOfL - CSenDomFragmentBase", CSenFragmentBCTest::MT_CSenDomFragmentBase_ConsistsOfLL ), |
|
108 ENTRY( "Parsing1 - CSenDomFragmentBase", CSenFragmentBCTest::MT_CSenDomFragmentBase_Parsing1L ), |
|
109 ENTRY( "Parsing2 - CSenDomFragmentBase", CSenFragmentBCTest::MT_CSenDomFragmentBase_Parsing2L ), |
|
110 ENTRY( "Parsing3 - CSenDomFragmentBase", CSenFragmentBCTest::MT_CSenDomFragmentBase_Parsing3L ), |
|
111 ENTRY( "Parsing4 - CSenDomFragmentBase", CSenFragmentBCTest::MT_CSenDomFragmentBase_Parsing4L ), |
|
112 ENTRY( "Parsing5 - CSenDomFragmentBase", CSenFragmentBCTest::MT_CSenDomFragmentBase_Parsing5L ), |
|
113 ENTRY( "Parsing6 - CSenDomFragmentBase", CSenFragmentBCTest::MT_CSenDomFragmentBase_Parsing6L ), |
|
114 ENTRY( "Parsing7 - CSenDomFragmentBase", CSenFragmentBCTest::MT_CSenDomFragmentBase_Parsing7L ), |
|
115 ENTRY( "Parsing8 - CSenDomFragmentBase", CSenFragmentBCTest::MT_CSenDomFragmentBase_Parsing8L ), |
|
116 //ENTRY( "SetContentOfL - CSenDomFragmentBase", CSenFragmentBCTest::MT_CSenDomFragmentBase_SetContentOfLL ), |
|
117 //ENTRY( "ContentOf - CSenDomFragmentBase", CSenFragmentBCTest::MT_CSenDomFragmentBase_ContentOfL ), |
|
118 ENTRY( "OnWriteStartElementL - CSenDomFragmentBase", CSenFragmentBCTest::MT_CSenDomFragmentBase_OnWriteStartElementLL ), |
|
119 ENTRY( "OnWriteEndElementL - CSenDomFragmentBase", CSenFragmentBCTest::MT_CSenDomFragmentBase_OnWriteEndElementLL ), |
|
120 ENTRY( "OnIgnorableWhiteSpaceL - CSenDomFragmentBase", CSenFragmentBCTest::MT_CSenDomFragmentBase_OnIgnorableWhiteSpaceLL ), |
|
121 ENTRY( "OnSkippedEntityL - CSenDomFragmentBase", CSenFragmentBCTest::MT_CSenDomFragmentBase_OnSkippedEntityLL ), |
|
122 ENTRY( "OnProcessingInstructionL - CSenDomFragmentBase", CSenFragmentBCTest::MT_CSenDomFragmentBase_OnProcessingInstructionLL ), |
|
123 ENTRY( "OnError - CSenDomFragmentBase", CSenFragmentBCTest::MT_CSenDomFragmentBase_OnErrorL ), |
|
124 ENTRY( "GetExtendedInterface - CSenDomFragmentBase", CSenFragmentBCTest::MT_CSenDomFragmentBase_GetExtendedInterfaceL ), |
|
125 ENTRY( "NewL - CSenFragmentBase", CSenFragmentBCTest::MT_CSenFragmentBase_NewLL ), |
|
126 ENTRY( "NewL - CSenFragmentBase", CSenFragmentBCTest::MT_CSenFragmentBase_NewL_2L ), |
|
127 ENTRY( "NewL - CSenFragmentBase", CSenFragmentBCTest::MT_CSenFragmentBase_NewL_3L ), |
|
128 ENTRY( "NewL - CSenFragmentBase", CSenFragmentBCTest::MT_CSenFragmentBase_NewL_4L ), |
|
129 ENTRY( "NewL - CSenFragmentBase", CSenFragmentBCTest::MT_CSenFragmentBase_NewL_5L ), |
|
130 ENTRY( "NewL - CSenFragmentBase", CSenFragmentBCTest::MT_CSenFragmentBase_NewL_6L ), |
|
131 ENTRY( "NewL - CSenFragmentBase", CSenFragmentBCTest::MT_CSenFragmentBase_NewL_7L ), |
|
132 ENTRY( "SetDocument - CSenFragmentBase", CSenFragmentBCTest::MT_CSenFragmentBase_SetDocumentL ), |
|
133 |
|
134 ENTRY( "ContentL - CSenFragmentBase", CSenFragmentBCTest::MT_CSenFragmentBase_ContentLL ), |
|
135 ENTRY( "Namespace - CSenFragmentBase", CSenFragmentBCTest::MT_CSenFragmentBase_NamespaceL ), |
|
136 ENTRY( "ResetContentL - CSenFragmentBase", CSenFragmentBCTest::MT_CSenFragmentBase_ResetContentLL ), |
|
137 ENTRY( "LocalName - CSenFragmentBase", CSenFragmentBCTest::MT_CSenFragmentBase_LocalNameL ), |
|
138 ENTRY( "NsUri - CSenFragmentBase", CSenFragmentBCTest::MT_CSenFragmentBase_NsUriL ), |
|
139 ENTRY( "NsPrefix - CSenFragmentBase", CSenFragmentBCTest::MT_CSenFragmentBase_NsPrefixL ), |
|
140 ENTRY( "AsElementL - CSenFragmentBase", CSenFragmentBCTest::MT_CSenFragmentBase_AsElementLL ), |
|
141 ENTRY( "AsDocumentL - CSenFragmentBase", CSenFragmentBCTest::MT_CSenFragmentBase_AsDocumentLL ), |
|
142 ENTRY( "ExtractElement - CSenFragmentBase", CSenFragmentBCTest::MT_CSenFragmentBase_ExtractElementL ), |
|
143 ENTRY( "AsXmlUnicodeL - CSenFragmentBase", CSenFragmentBCTest::MT_CSenFragmentBase_AsXmlUnicodeLL ), |
|
144 ENTRY( "AsXmlL - CSenFragmentBase", CSenFragmentBCTest::MT_CSenFragmentBase_AsXmlLL ), |
|
145 ENTRY( "WriteAsXMLToL - CSenFragmentBase", CSenFragmentBCTest::MT_CSenFragmentBase_WriteAsXMLToLL ), |
|
146 ENTRY( "ConsistsOfL - CSenFragmentBase", CSenFragmentBCTest::MT_CSenFragmentBase_ConsistsOfLL ), |
|
147 ENTRY( "Parsing1 - CSenFragmentBase", CSenFragmentBCTest::MT_CSenFragmentBase_Parsing1L ), |
|
148 ENTRY( "Parsing2 - CSenFragmentBase", CSenFragmentBCTest::MT_CSenFragmentBase_Parsing2L ), |
|
149 ENTRY( "Parsing3 - CSenFragmentBase", CSenFragmentBCTest::MT_CSenFragmentBase_Parsing3L ), |
|
150 ENTRY( "Parsing4 - CSenFragmentBase", CSenFragmentBCTest::MT_CSenFragmentBase_Parsing4L ), |
|
151 ENTRY( "Parsing5 - CSenFragmentBase", CSenFragmentBCTest::MT_CSenFragmentBase_Parsing5L ), |
|
152 ENTRY( "NewL - CSenParser", CSenFragmentBCTest::MT_CSenParser_NewLL ), |
|
153 ENTRY( "NewLC - CSenParser", CSenFragmentBCTest::MT_CSenParser_NewLCL ), |
|
154 ENTRY( "NewL - CSenParser", CSenFragmentBCTest::MT_CSenParser_NewL_1L ), |
|
155 ENTRY( "NewLC - CSenParser", CSenFragmentBCTest::MT_CSenParser_NewLC_1L ), |
|
156 ENTRY( "NewL - CSenParser", CSenFragmentBCTest::MT_CSenParser_NewL_2L ), |
|
157 ENTRY( "NewLC - CSenParser", CSenFragmentBCTest::MT_CSenParser_NewLC_2L ), |
|
158 // ENTRY( "NewL - CSenParser", CSenFragmentBCTest::MT_CSenParser_NewL_3L ), |
|
159 // ENTRY( "NewLC - CSenParser", CSenFragmentBCTest::MT_CSenParser_NewLC_3L ), |
|
160 ENTRY( "NewL - RSenDocument", CSenFragmentBCTest::MT_RSenDocument_NewLL ), |
|
161 ENTRY( "NewLC - RSenDocument", CSenFragmentBCTest::MT_RSenDocument_NewLCL ), |
|
162 ENTRY( "NewL - RSenDocument", CSenFragmentBCTest::MT_RSenDocument_NewL_1L ), |
|
163 ENTRY( "NewLC - RSenDocument", CSenFragmentBCTest::MT_RSenDocument_NewLC_1L ), |
|
164 ENTRY( "Copy - RSenDocument", CSenFragmentBCTest::MT_RSenDocument_CopyL ), |
|
165 ENTRY( "Close - RSenDocument", CSenFragmentBCTest::MT_RSenDocument_CloseL ), |
|
166 ENTRY( "Destroy - RSenDocument", CSenFragmentBCTest::MT_RSenDocument_DestroyL ), |
|
167 ENTRY( "Destroy - RSenDocument", CSenFragmentBCTest::MT_RSenDocument_DestroyL ), |
|
168 |
|
169 ENTRY( "ManualXmlEngineTlsAttachL - RSenDocument", CSenFragmentBCTest::MT_RSenDocument_ManualXmlEngineTlsAttachLL ), |
|
170 ENTRY( "ManualXmlEngineTlsAttachL - RSenDocument", CSenFragmentBCTest::MT_RSenDocument_ManualXmlEngineTlsCleanupL ), |
|
171 ENTRY( "SetContentL - TestFragmentBase", CSenFragmentBCTest::MT_TestFragmentBase_SetContentLL ), |
|
172 ENTRY( "AddContentL - TestFragmentBase", CSenFragmentBCTest::MT_TestFragmentBase_AddContentLL ), |
|
173 ENTRY( "SetContentOfL - TestDomFragmentBase", CSenFragmentBCTest::MT_TestDomFragmentBase_SetContentOfLL ), |
|
174 //ENTRY( "ContentOf - TestDomFragmentBase", CSenFragmentBCTest::MT_TestDomFragmentBase_ContentOfL ), |
|
175 |
|
176 // Example how to use OOM functionality |
|
177 //OOM_ENTRY( "Loop test with OOM", CSenFragmentBCTest::LoopTest, ETrue, 2, 3), |
|
178 //OOM_FUNCENTRY( CSenFragmentBCTest::PrintTest, ETrue, 1, 3 ), |
|
179 }; |
|
180 |
|
181 // Verify that case number is valid |
|
182 if( (TUint) aCaseNumber >= sizeof( KCases ) / |
|
183 sizeof( TCaseInfoInternal ) ) |
|
184 { |
|
185 // Invalid case, construct empty object |
|
186 TCaseInfo null( (const TText*) L"" ); |
|
187 null.iMethod = NULL; |
|
188 null.iIsOOMTest = EFalse; |
|
189 null.iFirstMemoryAllocation = 0; |
|
190 null.iLastMemoryAllocation = 0; |
|
191 return null; |
|
192 } |
|
193 |
|
194 // Construct TCaseInfo object and return it |
|
195 TCaseInfo tmp ( KCases[ aCaseNumber ].iCaseName ); |
|
196 tmp.iMethod = KCases[ aCaseNumber ].iMethod; |
|
197 tmp.iIsOOMTest = KCases[ aCaseNumber ].iIsOOMTest; |
|
198 tmp.iFirstMemoryAllocation = KCases[ aCaseNumber ].iFirstMemoryAllocation; |
|
199 tmp.iLastMemoryAllocation = KCases[ aCaseNumber ].iLastMemoryAllocation; |
|
200 return tmp; |
|
201 |
|
202 } |
|
203 |
|
204 void CSenFragmentBCTest::SetupL( ){ |
|
205 if ( iXmlReader ){ |
|
206 delete iXmlReader; |
|
207 iXmlReader = NULL; |
|
208 } |
|
209 iXmlReader = CSenXmlReader::NewL(); |
|
210 } |
|
211 |
|
212 void CSenFragmentBCTest::Teardown( ){ |
|
213 if ( iXmlReader){ |
|
214 delete iXmlReader; |
|
215 iXmlReader = NULL; |
|
216 } |
|
217 } |
|
218 |
|
219 TInt CSenFragmentBCTest::MT_CSenDomFragmentBase_NewLL(TTestResult& aResult) |
|
220 { |
|
221 SetupL(); |
|
222 CSenDomFragmentBase* pFragment = CSenDomFragmentBase::NewL(); |
|
223 TL(pFragment != (CSenDomFragmentBase*)NULL); |
|
224 __ASSERT_ALWAYS_NO_LEAVE(delete pFragment); |
|
225 pFragment = NULL; |
|
226 Teardown(); |
|
227 return KErrNone; |
|
228 } |
|
229 |
|
230 |
|
231 TInt CSenFragmentBCTest::MT_CSenDomFragmentBase_NewL_1L(TTestResult& aResult) |
|
232 { |
|
233 SetupL(); |
|
234 RSenDocument document = RSenDocument::NewL(); |
|
235 CleanupClosePushL(document); |
|
236 TXmlEngElement element = document.CreateDocumentElementL(_L8("Test")); |
|
237 element.SetEscapedTextL(_L8("<Element/>")); |
|
238 |
|
239 CSenDomFragmentBase* pFragment = CSenDomFragmentBase::NewL(element); |
|
240 CleanupStack::PushL(pFragment); |
|
241 HBufC8* pAsXml = pFragment->AsXmlL(); |
|
242 CleanupStack::PushL(pAsXml); |
|
243 // Test that when CSenDomFragmentBase is serialized '<' and '>' characters |
|
244 // are encoded (as all basic entities in content should be). |
|
245 if(!( *pAsXml == _L8("<Test><Element/></Test>") ))return KErrArgument; |
|
246 CleanupStack::PopAndDestroy(pAsXml); |
|
247 CleanupStack::PopAndDestroy(pFragment); |
|
248 CleanupStack::Pop(1); |
|
249 //CleanupStack::PopAndDestroy(&document); |
|
250 Teardown(); |
|
251 return KErrNone; |
|
252 } |
|
253 |
|
254 |
|
255 TInt CSenFragmentBCTest::MT_CSenDomFragmentBase_NewL_2L(TTestResult& aResult) |
|
256 { |
|
257 SetupL(); |
|
258 CSenDomFragmentBase* pFragment = CSenDomFragmentBase::NewL(_L8("Test")); |
|
259 CleanupStack::PushL(pFragment); |
|
260 HBufC8* pAsXml = pFragment->AsXmlL(); |
|
261 CleanupStack::PushL(pAsXml); |
|
262 if(!( *pAsXml == _L8("<Test/>") )) return KErrArgument; |
|
263 CleanupStack::PopAndDestroy(pAsXml); |
|
264 CleanupStack::PopAndDestroy(pFragment); |
|
265 Teardown(); |
|
266 return KErrNone; |
|
267 } |
|
268 |
|
269 |
|
270 TInt CSenFragmentBCTest::MT_CSenDomFragmentBase_NewL_3L(TTestResult& aResult) |
|
271 { |
|
272 SetupL(); |
|
273 CSenDomFragmentBase* pFragment = CSenDomFragmentBase::NewL(_L8("NsUri"), |
|
274 _L8("Test")); |
|
275 CleanupStack::PushL(pFragment); |
|
276 HBufC8* pAsXml = pFragment->AsXmlL(); |
|
277 CleanupStack::PushL(pAsXml); |
|
278 if(!( *pAsXml == _L8("<Test xmlns=\"NsUri\"/>") )) return KErrArgument; |
|
279 CleanupStack::PopAndDestroy(pAsXml); |
|
280 CleanupStack::PopAndDestroy(pFragment); |
|
281 Teardown(); |
|
282 return KErrNone; |
|
283 } |
|
284 |
|
285 |
|
286 TInt CSenFragmentBCTest::MT_CSenDomFragmentBase_NewL_4L(TTestResult& aResult) |
|
287 { |
|
288 SetupL(); |
|
289 CSenDomFragmentBase* pFragment = CSenDomFragmentBase::NewL(_L8("NsUri"), |
|
290 _L8("Test"), |
|
291 _L8("t")); |
|
292 CleanupStack::PushL(pFragment); |
|
293 HBufC8* pAsXml = pFragment->AsXmlL(); |
|
294 CleanupStack::PushL(pAsXml); |
|
295 if(!( *pAsXml == _L8("<t:Test xmlns:t=\"NsUri\"/>") )) return KErrArgument; |
|
296 CleanupStack::PopAndDestroy(pAsXml); |
|
297 CleanupStack::PopAndDestroy(pFragment); |
|
298 Teardown(); |
|
299 return KErrNone; |
|
300 } |
|
301 |
|
302 |
|
303 TInt CSenFragmentBCTest::MT_CSenDomFragmentBase_NewL_5L(TTestResult& aResult) |
|
304 { |
|
305 SetupL(); |
|
306 RStringPool stringPool; |
|
307 stringPool.OpenL(); |
|
308 CleanupClosePushL(stringPool); |
|
309 |
|
310 RString nsUriRString = stringPool.OpenStringL(_L8("nsuri")); |
|
311 CleanupClosePushL(nsUriRString); |
|
312 RString nsPrefixRString = stringPool.OpenStringL(_L8("pr")); |
|
313 CleanupClosePushL(nsPrefixRString); |
|
314 RString localNameRString = stringPool.OpenStringL(_L8("LocalName")); |
|
315 CleanupClosePushL(localNameRString); |
|
316 RString valueRString = stringPool.OpenStringL(_L8("Value")); |
|
317 CleanupClosePushL(valueRString); |
|
318 |
|
319 RAttribute attribute; |
|
320 attribute.Open( nsUriRString, nsPrefixRString, localNameRString, |
|
321 valueRString ); |
|
322 // attribute took ownership of all RStrings |
|
323 // => All RStrings can be pop from CleanupStack |
|
324 CleanupStack::Pop(&valueRString); |
|
325 CleanupStack::Pop(&localNameRString); |
|
326 CleanupStack::Pop(&nsPrefixRString); |
|
327 CleanupStack::Pop(&nsUriRString); |
|
328 |
|
329 CleanupClosePushL(attribute); |
|
330 |
|
331 RAttributeArray attrArray; |
|
332 // append the namespace attribute (declaration) |
|
333 attrArray.AppendL(attribute); |
|
334 CleanupClosePushL(attrArray); |
|
335 |
|
336 CSenDomFragmentBase* pFragment = CSenDomFragmentBase::NewL(_L8("NsUri"), |
|
337 _L8("Test"), |
|
338 _L8("t"), |
|
339 attrArray); |
|
340 CleanupStack::PushL(pFragment); |
|
341 HBufC8* pAsXml = pFragment->AsXmlL(); |
|
342 CleanupStack::PushL(pAsXml); |
|
343 if(!( *pAsXml == _L8("<t:Test xmlns:t=\"NsUri\" xmlns:pr=\"nsuri\" pr:LocalName=\"Value\"/>") )) return KErrArgument; |
|
344 CleanupStack::PopAndDestroy(pAsXml); |
|
345 CleanupStack::PopAndDestroy(pFragment); |
|
346 CleanupStack::PopAndDestroy(&attrArray); |
|
347 CleanupStack::PopAndDestroy(&attribute); |
|
348 CleanupStack::PopAndDestroy(&stringPool); |
|
349 Teardown(); |
|
350 return KErrNone; |
|
351 } |
|
352 |
|
353 |
|
354 TInt CSenFragmentBCTest::MT_CSenDomFragmentBase_NewL_6L(TTestResult& aResult) |
|
355 { |
|
356 SetupL(); |
|
357 RSenDocument document = RSenDocument::NewL(); |
|
358 CleanupClosePushL(document); |
|
359 TXmlEngElement parentElement = document.CreateDocumentElementL(_L8("Parent")); |
|
360 |
|
361 RStringPool stringPool; |
|
362 stringPool.OpenL(); |
|
363 CleanupClosePushL(stringPool); |
|
364 |
|
365 RString nsUriRString = stringPool.OpenStringL(_L8("nsuri")); |
|
366 CleanupClosePushL(nsUriRString); |
|
367 RString nsPrefixRString = stringPool.OpenStringL(_L8("pr")); |
|
368 CleanupClosePushL(nsPrefixRString); |
|
369 RString localNameRString = stringPool.OpenStringL(_L8("LocalName")); |
|
370 CleanupClosePushL(localNameRString); |
|
371 RString valueRString = stringPool.OpenStringL(_L8("Value")); |
|
372 CleanupClosePushL(valueRString); |
|
373 |
|
374 RAttribute attribute; |
|
375 attribute.Open(nsUriRString, nsPrefixRString, localNameRString, |
|
376 valueRString); |
|
377 // attribute took ownership of all RStrings |
|
378 // => All RStrings can be pop from CleanupStack |
|
379 CleanupStack::Pop(&valueRString); |
|
380 CleanupStack::Pop(&localNameRString); |
|
381 CleanupStack::Pop(&nsPrefixRString); |
|
382 CleanupStack::Pop(&nsUriRString); |
|
383 |
|
384 CleanupClosePushL(attribute); |
|
385 |
|
386 RAttributeArray attrArray; |
|
387 // append the namespace attribute (declaration) |
|
388 attrArray.AppendL(attribute); |
|
389 CleanupClosePushL(attrArray); |
|
390 |
|
391 CSenDomFragmentBase* pFragment = CSenDomFragmentBase::NewL(_L8("NsUri"), |
|
392 _L8("Test"), |
|
393 _L8("t"), |
|
394 attrArray, |
|
395 parentElement); |
|
396 CleanupStack::PushL(pFragment); |
|
397 HBufC8* pAsXml = pFragment->AsXmlL(); |
|
398 CleanupStack::PushL(pAsXml); |
|
399 if(!( *pAsXml == _L8("<t:Test xmlns:t=\"NsUri\" xmlns:pr=\"nsuri\" pr:LocalName=\"Value\"/>") )) return KErrArgument; |
|
400 |
|
401 RBuf8 buffer; |
|
402 parentElement.OuterXmlL(buffer); |
|
403 |
|
404 if(!( buffer == _L8("<Parent><t:Test xmlns:t=\"NsUri\" xmlns:pr=\"nsuri\" pr:LocalName=\"Value\"/></Parent>") )) return KErrArgument; |
|
405 buffer.Close(); |
|
406 |
|
407 CleanupStack::PopAndDestroy(pAsXml); |
|
408 CleanupStack::PopAndDestroy(pFragment); |
|
409 CleanupStack::PopAndDestroy(&attrArray); |
|
410 CleanupStack::PopAndDestroy(&attribute); |
|
411 CleanupStack::PopAndDestroy(&stringPool); |
|
412 CleanupStack::PopAndDestroy(&document); |
|
413 Teardown(); |
|
414 return KErrNone; |
|
415 } |
|
416 |
|
417 |
|
418 TInt CSenFragmentBCTest::MT_CSenDomFragmentBase_NewL_7L(TTestResult& aResult) |
|
419 { |
|
420 SetupL(); |
|
421 RSenDocument document = RSenDocument::NewL(); |
|
422 CleanupClosePushL(document); |
|
423 TXmlEngElement parentElement = document.CreateDocumentElementL(_L8("Parent")); |
|
424 |
|
425 RStringPool stringPool; |
|
426 stringPool.OpenL(); |
|
427 CleanupClosePushL(stringPool); |
|
428 |
|
429 RString nsUriRString = stringPool.OpenStringL(_L8("nsuri")); |
|
430 CleanupClosePushL(nsUriRString); |
|
431 RString nsPrefixRString = stringPool.OpenStringL(_L8("pr")); |
|
432 CleanupClosePushL(nsPrefixRString); |
|
433 RString localNameRString = stringPool.OpenStringL(_L8("LocalName")); |
|
434 CleanupClosePushL(localNameRString); |
|
435 RString valueRString = stringPool.OpenStringL(_L8("Value")); |
|
436 CleanupClosePushL(valueRString); |
|
437 |
|
438 RAttribute attribute; |
|
439 attribute.Open(nsUriRString, nsPrefixRString, localNameRString, |
|
440 valueRString); |
|
441 // attribute took ownership of all RStrings |
|
442 // => All RStrings can be pop from CleanupStack |
|
443 CleanupStack::Pop(&valueRString); |
|
444 CleanupStack::Pop(&localNameRString); |
|
445 CleanupStack::Pop(&nsPrefixRString); |
|
446 CleanupStack::Pop(&nsUriRString); |
|
447 |
|
448 CleanupClosePushL(attribute); |
|
449 |
|
450 RAttributeArray attrArray; |
|
451 // append the namespace attribute (declaration) |
|
452 attrArray.AppendL(attribute); |
|
453 CleanupClosePushL(attrArray); |
|
454 |
|
455 CSenDomFragmentBase* pFragment = CSenDomFragmentBase::NewL(_L8("NsUri"), |
|
456 _L8("Test"), |
|
457 _L8(""), |
|
458 attrArray, |
|
459 parentElement, |
|
460 document); |
|
461 CleanupStack::PushL(pFragment); |
|
462 HBufC8* pAsXml = pFragment->AsXmlL(); |
|
463 CleanupStack::PushL(pAsXml); |
|
464 if(!( *pAsXml == _L8("<Test xmlns=\"NsUri\" xmlns:pr=\"nsuri\" pr:LocalName=\"Value\"/>") )) return KErrArgument; |
|
465 |
|
466 RBuf8 buffer; |
|
467 parentElement.OuterXmlL(buffer); |
|
468 |
|
469 if(!( buffer == _L8("<Parent><Test xmlns=\"NsUri\" xmlns:pr=\"nsuri\" pr:LocalName=\"Value\"/></Parent>") )) return KErrArgument; |
|
470 buffer.Close(); |
|
471 |
|
472 CleanupStack::PopAndDestroy(pAsXml); |
|
473 CleanupStack::PopAndDestroy(pFragment); |
|
474 CleanupStack::PopAndDestroy(&attrArray); |
|
475 CleanupStack::PopAndDestroy(&attribute); |
|
476 CleanupStack::PopAndDestroy(&stringPool); |
|
477 CleanupStack::PopAndDestroy(&document); |
|
478 Teardown(); |
|
479 return KErrNone; |
|
480 } |
|
481 |
|
482 |
|
483 TInt CSenFragmentBCTest::MT_CSenDomFragmentBase_AddAttributesLL(TTestResult& aResult) |
|
484 { |
|
485 SetupL(); |
|
486 RStringPool stringPool; |
|
487 stringPool.OpenL(); |
|
488 CleanupClosePushL(stringPool); |
|
489 |
|
490 RString nsUriRString = stringPool.OpenStringL(_L8("nsuri")); |
|
491 CleanupClosePushL(nsUriRString); |
|
492 RString nsPrefixRString = stringPool.OpenStringL(_L8("pr")); |
|
493 CleanupClosePushL(nsPrefixRString); |
|
494 RString localNameRString = stringPool.OpenStringL(_L8("LocalName")); |
|
495 CleanupClosePushL(localNameRString); |
|
496 RString valueRString = stringPool.OpenStringL(_L8("Value")); |
|
497 CleanupClosePushL(valueRString); |
|
498 |
|
499 RAttribute attribute; |
|
500 attribute.Open(nsUriRString, nsPrefixRString, localNameRString, |
|
501 valueRString); |
|
502 // attribute took ownership of all RStrings |
|
503 // => All RStrings can be pop from CleanupStack |
|
504 CleanupStack::Pop(4); // nsUriRString, nsPrefixRString, localNameRString, |
|
505 // valueRString |
|
506 CleanupClosePushL(attribute); |
|
507 |
|
508 RAttributeArray attrArray; |
|
509 // append the namespace attribute (declaration) |
|
510 attrArray.AppendL(attribute); |
|
511 CleanupClosePushL(attrArray); |
|
512 |
|
513 CSenDomFragmentBase* pFragment = CSenDomFragmentBase::NewL(_L8("Test")); |
|
514 CleanupStack::PushL(pFragment); |
|
515 |
|
516 pFragment->AddAttributesL(attrArray); |
|
517 HBufC8* pAsXml = pFragment->AsXmlL(); |
|
518 CleanupStack::PushL(pAsXml); |
|
519 if(!( *pAsXml == _L8("<Test xmlns:pr=\"nsuri\" pr:LocalName=\"Value\"/>") )) return KErrArgument; |
|
520 CleanupStack::PopAndDestroy(pAsXml); |
|
521 |
|
522 CleanupStack::PopAndDestroy(pFragment); |
|
523 |
|
524 CleanupStack::PopAndDestroy(&attrArray); |
|
525 CleanupStack::PopAndDestroy(&attribute); |
|
526 CleanupStack::PopAndDestroy(&stringPool); |
|
527 Teardown(); |
|
528 return KErrNone; |
|
529 } |
|
530 |
|
531 |
|
532 TInt CSenFragmentBCTest::MT_CSenDomFragmentBase_AsXmlLL(TTestResult& aResult) |
|
533 { |
|
534 SetupL(); |
|
535 // Test serialization of Dom tree which has two child elements |
|
536 CSenDomFragmentBase* pFragment = CSenDomFragmentBase::NewL(_L8("Test")); |
|
537 CleanupStack::PushL(pFragment); |
|
538 TXmlEngElement element = pFragment->AsElementL(); |
|
539 |
|
540 TXmlEngElement element2 = element.AddNewElementL(_L8("Child"), _L8("nsuri"), _L8("prefix")); |
|
541 |
|
542 element2.AddNewElementL(_L8("Child2"), _L8("nsuri2"), _L8("prefix2")); |
|
543 |
|
544 HBufC8* pAsXml = pFragment->AsXmlL(); |
|
545 CleanupStack::PushL(pAsXml); |
|
546 if(!( *pAsXml == _L8("<Test xmlns:prefix=\"nsuri\"><prefix:Child xmlns:prefix2=\"nsuri2\"><prefix2:Child2/></prefix:Child></Test>") ) ) return KErrArgument; |
|
547 CleanupStack::PopAndDestroy(pAsXml); |
|
548 CleanupStack::PopAndDestroy(pFragment); |
|
549 Teardown(); |
|
550 return KErrNone; |
|
551 } |
|
552 |
|
553 |
|
554 TInt CSenFragmentBCTest::MT_CSenDomFragmentBase_ContentLL(TTestResult& aResult) |
|
555 { |
|
556 SetupL(); |
|
557 RSenDocument document = RSenDocument::NewL(); |
|
558 CleanupClosePushL(document); |
|
559 TXmlEngElement element = document.CreateDocumentElementL(_L8("Test")); |
|
560 element.SetEscapedTextL(_L8("<Element/>")); |
|
561 |
|
562 CSenDomFragmentBase* pFragment = CSenDomFragmentBase::NewL(element); |
|
563 CleanupStack::PushL(pFragment); |
|
564 |
|
565 TPtrC8 content = pFragment->ContentL(); |
|
566 if(!( content == _L8("<Element/>") ) ) return KErrArgument; |
|
567 |
|
568 CleanupStack::PopAndDestroy(pFragment); |
|
569 CleanupStack::PopAndDestroy(&document); |
|
570 Teardown(); |
|
571 return KErrNone; |
|
572 } |
|
573 |
|
574 |
|
575 TInt CSenFragmentBCTest::MT_CSenDomFragmentBase_NamespaceL(TTestResult& aResult) |
|
576 { |
|
577 SetupL(); |
|
578 RStringPool stringPool; |
|
579 stringPool.OpenL(); |
|
580 CleanupClosePushL(stringPool); |
|
581 |
|
582 RString nsUriRString = stringPool.OpenStringL(_L8("nsuri")); |
|
583 CleanupClosePushL(nsUriRString); |
|
584 RString nsPrefixRString = stringPool.OpenStringL(_L8("pr")); |
|
585 CleanupClosePushL(nsPrefixRString); |
|
586 RString localNameRString = stringPool.OpenStringL(_L8("LocalName")); |
|
587 CleanupClosePushL(localNameRString); |
|
588 RString valueRString = stringPool.OpenStringL(_L8("Value")); |
|
589 CleanupClosePushL(valueRString); |
|
590 |
|
591 RAttribute attribute; |
|
592 attribute.Open(stringPool.OpenStringL(_L8("nsuri")), |
|
593 stringPool.OpenStringL(_L8("pr")), |
|
594 stringPool.OpenStringL(_L8("LocalName")), |
|
595 stringPool.OpenStringL(_L8("Value")) ); |
|
596 // attribute took copies of all RStrings |
|
597 // => All RStrings can be destroyed |
|
598 CleanupStack::PopAndDestroy(4); // nsUriRString, nsPrefixRString, localNameRString, |
|
599 // valueRString |
|
600 CleanupClosePushL(attribute); |
|
601 |
|
602 RAttributeArray attrArray; |
|
603 // append the namespace attribute (declaration) |
|
604 attrArray.AppendL(attribute); |
|
605 CleanupClosePushL(attrArray); |
|
606 |
|
607 CSenDomFragmentBase* pFragment = CSenDomFragmentBase::NewL(_L8("NsUri"), |
|
608 _L8("Test"), |
|
609 _L8("t"), |
|
610 attrArray); |
|
611 CleanupStack::PushL(pFragment); |
|
612 |
|
613 TXmlEngNamespace ns = pFragment->Namespace(_L8("pr")); |
|
614 if(!( ns.Uri() == _L8("nsuri") ) ) return KErrArgument; |
|
615 |
|
616 TXmlEngNamespace ns2 = pFragment->Namespace(_L8("x")); |
|
617 if(!( ns2.IsNull() ) ) return KErrArgument; |
|
618 |
|
619 CleanupStack::PopAndDestroy(pFragment); |
|
620 CleanupStack::PopAndDestroy(); // attribute |
|
621 CleanupStack::PopAndDestroy(); // attrArray |
|
622 CleanupStack::PopAndDestroy(); // stringPool |
|
623 Teardown(); |
|
624 return KErrNone; |
|
625 } |
|
626 |
|
627 |
|
628 TInt CSenFragmentBCTest::MT_CSenDomFragmentBase_ResetContentLL(TTestResult& aResult) |
|
629 { |
|
630 SetupL(); |
|
631 RSenDocument document = RSenDocument::NewL(); |
|
632 CleanupClosePushL(document); |
|
633 TXmlEngElement element = document.CreateDocumentElementL(_L8("Test")); |
|
634 element.SetEscapedTextL(_L8("Content")); |
|
635 |
|
636 CSenDomFragmentBase* pFragment = CSenDomFragmentBase::NewL(element); |
|
637 CleanupStack::PushL(pFragment); |
|
638 |
|
639 // Test that CSenFragmentBase has content before reset |
|
640 TPtrC8 content = pFragment->ContentL(); |
|
641 if(!( content == _L8("Content") )) return KErrArgument; |
|
642 |
|
643 pFragment->ResetContentL(); |
|
644 |
|
645 // Test that CSenFragmentBase has no content after reset |
|
646 TPtrC8 content2 = pFragment->ContentL(); |
|
647 if(!( content2 == KNullDesC8 )) return KErrArgument; |
|
648 |
|
649 CleanupStack::PopAndDestroy(pFragment); |
|
650 CleanupStack::PopAndDestroy(&document); |
|
651 Teardown(); |
|
652 return KErrNone; |
|
653 } |
|
654 |
|
655 |
|
656 TInt CSenFragmentBCTest::MT_CSenDomFragmentBase_LocalNameL(TTestResult& aResult) |
|
657 { |
|
658 SetupL(); |
|
659 CSenDomFragmentBase* pFragment = CSenDomFragmentBase::NewL(_L8("NsUri"), |
|
660 _L8("Test"), |
|
661 _L8("t")); |
|
662 CleanupStack::PushL(pFragment); |
|
663 TPtrC8 localName = pFragment->LocalName(); |
|
664 if(!( localName == _L8("Test") ) ) return KErrArgument; |
|
665 CleanupStack::PopAndDestroy(pFragment); |
|
666 Teardown(); |
|
667 return KErrNone; |
|
668 } |
|
669 |
|
670 |
|
671 TInt CSenFragmentBCTest::MT_CSenDomFragmentBase_NsUriL(TTestResult& aResult) |
|
672 { |
|
673 SetupL(); |
|
674 CSenDomFragmentBase* pFragment = CSenDomFragmentBase::NewL(_L8("NsUri"), |
|
675 _L8("Test"), |
|
676 _L8("t")); |
|
677 CleanupStack::PushL(pFragment); |
|
678 TPtrC8 localName = pFragment->NsUri(); |
|
679 if(!( localName == _L8("NsUri") ) ) return KErrArgument; |
|
680 CleanupStack::PopAndDestroy(pFragment); |
|
681 Teardown(); |
|
682 return KErrNone; |
|
683 } |
|
684 |
|
685 |
|
686 TInt CSenFragmentBCTest::MT_CSenDomFragmentBase_NsPrefixL(TTestResult& aResult) |
|
687 { |
|
688 SetupL(); |
|
689 CSenDomFragmentBase* pFragment = CSenDomFragmentBase::NewL(_L8("NsUri"), |
|
690 _L8("Test"), |
|
691 _L8("t")); |
|
692 CleanupStack::PushL(pFragment); |
|
693 TPtrC8 localName = pFragment->NsPrefix(); |
|
694 if(!( localName == _L8("t") ) ) return KErrArgument; |
|
695 CleanupStack::PopAndDestroy(pFragment); |
|
696 Teardown(); |
|
697 return KErrNone; |
|
698 } |
|
699 |
|
700 |
|
701 TInt CSenFragmentBCTest::MT_CSenDomFragmentBase_AsElementLL(TTestResult& aResult) |
|
702 { |
|
703 SetupL(); |
|
704 CSenDomFragmentBase* pFragment = CSenDomFragmentBase::NewL(_L8("NsUri"), |
|
705 _L8("Test"), |
|
706 _L8("t")); |
|
707 CleanupStack::PushL(pFragment); |
|
708 TXmlEngElement element = pFragment->AsElementL(); |
|
709 RBuf8 buffer; |
|
710 CleanupClosePushL(buffer); |
|
711 element.OuterXmlL(buffer); |
|
712 // Serialized element should contain all the Fragment data as XML. |
|
713 if(!( buffer == _L8("<t:Test xmlns:t=\"NsUri\"/>") ) ) return KErrArgument; |
|
714 CleanupStack::PopAndDestroy(&buffer); |
|
715 CleanupStack::PopAndDestroy(pFragment); |
|
716 Teardown(); |
|
717 return KErrNone; |
|
718 } |
|
719 |
|
720 |
|
721 TInt CSenFragmentBCTest::MT_CSenDomFragmentBase_AsDocumentLL(TTestResult& aResult) |
|
722 { |
|
723 SetupL(); |
|
724 CSenDomFragmentBase* pFragment = CSenDomFragmentBase::NewL(_L8("NsUri"), |
|
725 _L8("Test"), |
|
726 _L8("t")); |
|
727 CleanupStack::PushL(pFragment); |
|
728 RSenDocument document = pFragment->AsDocumentL(); |
|
729 TXmlEngElement element = document.DocumentElement(); |
|
730 |
|
731 TXmlEngSerializationOptions options; |
|
732 // Omit following declarations from the beginning of XML Document: |
|
733 // <?xml version=\"1.0\... |
|
734 // encoding="..." |
|
735 // standalone="..." |
|
736 // ?> |
|
737 options.iOptions = options.iOptions | |
|
738 TXmlEngSerializationOptions::KOptionOmitXMLDeclaration; |
|
739 RBuf8 asXml; |
|
740 document.SaveL(asXml, element, options); |
|
741 CleanupClosePushL(asXml); |
|
742 |
|
743 // Serialized document should contain all the Fragment data as XML. |
|
744 if(!( asXml == _L8("<t:Test xmlns:t=\"NsUri\"/>") ) ) return KErrArgument; |
|
745 |
|
746 CleanupStack::PopAndDestroy(&asXml); |
|
747 CleanupStack::PopAndDestroy(pFragment); |
|
748 Teardown(); |
|
749 return KErrNone; |
|
750 } |
|
751 |
|
752 |
|
753 TInt CSenFragmentBCTest::MT_CSenDomFragmentBase_ExtractElementL(TTestResult& aResult) |
|
754 { |
|
755 SetupL(); |
|
756 CSenDomFragmentBase* pFragment = CSenDomFragmentBase::NewL(_L8("NsUri"), |
|
757 _L8("Test"), |
|
758 _L8("t")); |
|
759 CleanupStack::PushL(pFragment); |
|
760 TXmlEngElement element = pFragment->ExtractElement(); |
|
761 if(!( element.Name() == _L8("Test") )) return KErrArgument; |
|
762 element.Remove(); |
|
763 CleanupStack::PopAndDestroy(pFragment); |
|
764 Teardown(); |
|
765 return KErrNone; |
|
766 } |
|
767 |
|
768 TInt CSenFragmentBCTest::MT_CSenDomFragmentBase_AsXmlUnicodeLL(TTestResult& aResult) |
|
769 { |
|
770 SetupL(); |
|
771 // Test serialization of Dom tree which has two child elements |
|
772 CSenDomFragmentBase* pFragment = CSenDomFragmentBase::NewL(_L8("Test")); |
|
773 CleanupStack::PushL(pFragment); |
|
774 TXmlEngElement element = pFragment->AsElementL(); |
|
775 |
|
776 TXmlEngElement element2 = element.AddNewElementL(_L8("Child"), _L8("nsuri"), _L8("prefix")); |
|
777 |
|
778 element2.AddNewElementL(_L8("Child2"), _L8("nsuri2"), _L8("prefix2")); |
|
779 |
|
780 HBufC* pAsXml = pFragment->AsXmlUnicodeL(); |
|
781 CleanupStack::PushL(pAsXml); |
|
782 if(!( *pAsXml == _L("<Test xmlns:prefix=\"nsuri\"><prefix:Child xmlns:prefix2=\"nsuri2\"><prefix2:Child2/></prefix:Child></Test>") )) return KErrArgument; |
|
783 CleanupStack::PopAndDestroy(pAsXml); |
|
784 CleanupStack::PopAndDestroy(pFragment); |
|
785 Teardown(); |
|
786 return KErrNone; |
|
787 } |
|
788 |
|
789 |
|
790 TInt CSenFragmentBCTest::MT_CSenDomFragmentBase_WriteAsXMLToLL(TTestResult& aResult) |
|
791 { |
|
792 SetupL(); |
|
793 // Test serialization of Dom tree which has two child elements |
|
794 CSenDomFragmentBase* pFragment = CSenDomFragmentBase::NewL(_L8("Test")); |
|
795 CleanupStack::PushL(pFragment); |
|
796 TXmlEngElement element = pFragment->AsElementL(); |
|
797 |
|
798 TXmlEngElement element2 = element.AddNewElementL(_L8("Child"), _L8("nsuri"), _L8("prefix")); |
|
799 |
|
800 element2.AddNewElementL(_L8("Child2"), _L8("nsuri2"), _L8("prefix2")); |
|
801 |
|
802 CBufFlat* pBuf = CBufFlat::NewL(200); |
|
803 CleanupStack::PushL(pBuf); |
|
804 RBufWriteStream bufWs(*pBuf); |
|
805 CleanupClosePushL(bufWs); |
|
806 pFragment->WriteAsXMLToL(bufWs); |
|
807 |
|
808 |
|
809 if(!( pBuf->Ptr(0) == _L8("<Test xmlns:prefix=\"nsuri\"><prefix:Child xmlns:prefix2=\"nsuri2\"><prefix2:Child2/></prefix:Child></Test>") )) return KErrArgument; |
|
810 |
|
811 CleanupStack::PopAndDestroy(&bufWs); |
|
812 CleanupStack::PopAndDestroy(pBuf); |
|
813 |
|
814 CleanupStack::PopAndDestroy(pFragment); |
|
815 Teardown(); |
|
816 return KErrNone; |
|
817 } |
|
818 |
|
819 |
|
820 TInt CSenFragmentBCTest::MT_CSenDomFragmentBase_ConsistsOfLL(TTestResult& aResult) |
|
821 { |
|
822 SetupL(); |
|
823 CSenDomFragmentBase* pFragment = CSenDomFragmentBase::NewL(_L8("Test")); |
|
824 CleanupStack::PushL(pFragment); |
|
825 TXmlEngElement element = pFragment->AsElementL(); |
|
826 |
|
827 TXmlEngElement elementchild1 = element.AddNewElementL(_L8("DirectChild")); |
|
828 elementchild1.AddNamespaceDeclarationL(_L8("nsuri"), _L8("prefix")); |
|
829 |
|
830 //TDomUtils domUtils1; |
|
831 //domUtils1.XmlEngRenameElementL(elementchild1, _L8("DirectChild"), _L8("nsuri"), _L8("prefix")); |
|
832 |
|
833 TXmlEngElement elementchild2 = element.AddNewElementL(_L8("DirectChild")); |
|
834 elementchild2.AddNamespaceDeclarationL(_L8("nsuri"), _L8("prefix")); |
|
835 //TDomUtils domUtils2; |
|
836 //domUtils2.XmlEngRenameElementL(elementchild2, _L8("DirectChild"), _L8("nsuri"), _L8("prefix")); |
|
837 elementchild2.AddNewElementL(_L8("Child"), _L8("nsuri2"), _L8("prefix2")); |
|
838 |
|
839 CSenDomFragmentBase* pFragment2 = CSenDomFragmentBase::NewL(_L8("Test")); |
|
840 CleanupStack::PushL(pFragment2); |
|
841 TXmlEngElement element2 = pFragment2->AsElementL(); |
|
842 |
|
843 TXmlEngElement elementchild22 = element2.AddNewElementL(_L8("DirectChild")); |
|
844 elementchild22.AddNamespaceDeclarationL(_L8("nsuri"), _L8("prefix")); |
|
845 //TDomUtils domUtils22; |
|
846 //domUtils22.XmlEngRenameElementL(elementchild22, _L8("DirectChild"), _L8("nsuri"), _L8("prefix")); |
|
847 elementchild22.AddNewElementL(_L8("Child"), _L8("nsuri2"), _L8("prefix2")); |
|
848 |
|
849 // ConsistOfL should return ETrue because |
|
850 // root elements of both fragments match and the only element |
|
851 // of pFragment2 = elementchild22 is exactly the same element as |
|
852 // elementchild2. |
|
853 if(!( pFragment->ConsistsOfL(*pFragment2) )) return KErrArgument; |
|
854 |
|
855 // ConsistOfL should return EFalse because |
|
856 // Even though root elements of both fragments match |
|
857 // there is extra element (= elementchild1) in pFragment. |
|
858 // |
|
859 // elementchild1 (of pFragment) can not be found from pFragment2 |
|
860 // and because of that pFragment2 does not consist of pFragment. |
|
861 if(!( !pFragment2->ConsistsOfL(*pFragment) )) return KErrArgument; |
|
862 CleanupStack::PopAndDestroy(pFragment2); |
|
863 |
|
864 CSenDomFragmentBase* pFragment3 = CSenDomFragmentBase::NewL(_L8("Test")); |
|
865 CleanupStack::PushL(pFragment3); |
|
866 TXmlEngElement element3 = pFragment3->AsElementL(); |
|
867 |
|
868 TXmlEngElement elementchild32 = element3.AddNewElementL(_L8("DirectChild")); |
|
869 elementchild32.AddNamespaceDeclarationL(_L8("nsuri"), _L8("prefix")); |
|
870 //TDomUtils domUtils32; |
|
871 //domUtils32.XmlEngRenameElementL(elementchild32, _L8("DirectChild"), _L8("nsuri"), _L8("prefix")); |
|
872 elementchild32.AddNewElementL(_L8("Child"), _L8("nsuri2"), _L8("prefix2")); |
|
873 elementchild32.SetEscapedTextL(_L8("Text")); |
|
874 |
|
875 // ConsistOfL should return EFalse because |
|
876 // elementchild32 has content ("Text") which doesn't match |
|
877 // to any child element of pFragment. |
|
878 if(!( !pFragment->ConsistsOfL(*pFragment3) )) return KErrArgument; |
|
879 CleanupStack::PopAndDestroy(pFragment3); |
|
880 |
|
881 CleanupStack::PopAndDestroy(pFragment); |
|
882 Teardown(); |
|
883 return KErrNone; |
|
884 } |
|
885 |
|
886 |
|
887 TInt CSenFragmentBCTest::MT_CSenDomFragmentBase_Parsing1L(TTestResult& aResult) |
|
888 { |
|
889 SetupL(); |
|
890 // Parsing of XML document to CSenDomFragmentBase |
|
891 _LIT8(KInputString, "<a:Test xmlns=\"nsuri\" xmlns:a=\"nasuria\" \ |
|
892 xmlns:b=\"nasurib\" a:x=\"value1\" b:z=\"value2\">\ |
|
893 <Element1 xmlns:c=\"nsuric\" c:x=\"value3\">Content1</Element1>\ |
|
894 <Element2 z=\"value4\">Content2</Element2>\ |
|
895 <Element3>Content3</Element3>\ |
|
896 <Element4/></a:Test>"); |
|
897 |
|
898 // Default namespace declaration (xmlns="nsuri") from Parent element (Test) |
|
899 // will be moved to all child elements (Element1, Element2, Element3 and |
|
900 // Element4) when EReportNamespaceMapping is _NOT_ enabled. That's because |
|
901 // the way CParser works <=> Namespaces are reported when namespaces are used |
|
902 // for the first time. |
|
903 _LIT8(KOutputString1, "<a:Test xmlns:a=\"nasuria\" xmlns:b=\"nasurib\" \ |
|
904 a:x=\"value1\" b:z=\"value2\">\ |
|
905 <Element1 xmlns=\"nsuri\" xmlns:c=\"nsuric\" c:x=\"value3\">Content1</Element1>\ |
|
906 <Element2 xmlns=\"nsuri\" z=\"value4\">Content2</Element2>\ |
|
907 <Element3 xmlns=\"nsuri\">Content3</Element3>\ |
|
908 <Element4 xmlns=\"nsuri\"/></a:Test>"); |
|
909 |
|
910 // When EReportNamespaceMapping is enabled all the namespace declarations |
|
911 // are reported in exactly the same element as they are defined in parsed |
|
912 // XML document. |
|
913 // Note: The Order of namespace declarations in root element tag may change. |
|
914 // Namespace declaration for root tag is created when fragment is created |
|
915 // and because of that namespace declaration for root tag will be the first. |
|
916 // In this particular case namespace declaration for prefix "a" will be |
|
917 // the first namespace declaration because it is declared when |
|
918 // CSenDomFragmentBase is created. |
|
919 _LIT8(KOutputString2, "<a:Test xmlns:a=\"nasuria\" xmlns=\"nsuri\" \ |
|
920 xmlns:b=\"nasurib\" a:x=\"value1\" b:z=\"value2\">\ |
|
921 <Element1 xmlns:c=\"nsuric\" c:x=\"value3\">Content1</Element1>\ |
|
922 <Element2 z=\"value4\">Content2</Element2>\ |
|
923 <Element3>Content3</Element3>\ |
|
924 <Element4/></a:Test>"); |
|
925 |
|
926 CSenParser* pParser = CSenParser::NewLC(); |
|
927 |
|
928 CSenDomFragmentBase* pFragment = CSenDomFragmentBase::NewL(_L8("nasuria"),_L8("Test"),_L8("a")); |
|
929 CleanupStack::PushL(pFragment); |
|
930 |
|
931 pParser->ParseL(KInputString, *pFragment); |
|
932 |
|
933 HBufC8* pAsXml = pFragment->AsXmlL(); |
|
934 CleanupStack::PushL(pAsXml); |
|
935 |
|
936 if(!( *pAsXml == KOutputString1 )) return KErrArgument; |
|
937 |
|
938 CleanupStack::PopAndDestroy(pAsXml); |
|
939 CleanupStack::PopAndDestroy(pFragment); |
|
940 /* |
|
941 pParser->EnableFeature(EReportNamespaceMapping); |
|
942 //tma |
|
943 pParser->DisableFeature(EReportNamespaceMapping); |
|
944 TBool fEneabled(EFalse); |
|
945 fEneabled = pParser->IsFeatureEnabled(EReportNamespaceMapping); |
|
946 EUNIT_ASSERT( fEneabled == EFalse); |
|
947 pParser->EnableFeature(EReportNamespaceMapping); |
|
948 //tma |
|
949 */ |
|
950 pParser->EnableFeature(EReportNamespaceMapping); |
|
951 |
|
952 CSenDomFragmentBase* pFragment2 = CSenDomFragmentBase::NewL(_L8("nasuria"),_L8("Test"),_L8("a")); |
|
953 CleanupStack::PushL(pFragment2); |
|
954 |
|
955 pParser->ParseL(KInputString, *pFragment2); |
|
956 |
|
957 HBufC8* pAsXml2 = pFragment2->AsXmlL(); |
|
958 CleanupStack::PushL(pAsXml2); |
|
959 |
|
960 if(!( *pAsXml2 == KOutputString2 )) return KErrArgument; |
|
961 |
|
962 CleanupStack::PopAndDestroy(pAsXml2); |
|
963 CleanupStack::PopAndDestroy(pFragment2); |
|
964 |
|
965 CleanupStack::PopAndDestroy(pParser); |
|
966 Teardown(); |
|
967 return KErrNone; |
|
968 } |
|
969 |
|
970 |
|
971 TInt CSenFragmentBCTest::MT_CSenDomFragmentBase_Parsing2L(TTestResult& aResult) |
|
972 { |
|
973 SetupL(); |
|
974 // Parsing of XML document to CSenDomFragmentBase which uses |
|
975 // delegation. |
|
976 _LIT8(KInputString, "<a:Test xmlns:a=\"nasuria\" xmlns:b=\"nsurib\" \ |
|
977 xmlns=\"nsuri\" a:x=\"value1\" b:z=\"value2\">\ |
|
978 <DelegateFragment>DelegateContent</DelegateFragment>\ |
|
979 <Element1 x=\"value4\">Content1</Element1>\ |
|
980 <Element2>Content2</Element2></a:Test>"); |
|
981 |
|
982 // Default namespace declaration (xmlns="nsuri") from Parent element (Test) |
|
983 // will be moved to all child elements (Element1, Element2, Element3 and |
|
984 // Element4) when EReportNamespaceMapping is _NOT_ enabled. That's because |
|
985 // the way CParser works <=> Namespaces are reported when namespaces are used |
|
986 // for the first time. |
|
987 _LIT8(KOutputString1, "<a:Test xmlns:a=\"nasuria\" xmlns:b=\"nsurib\" \ |
|
988 a:x=\"value1\" b:z=\"value2\">\ |
|
989 <DelegateFragment xmlns=\"nsuri\">DelegateContent</DelegateFragment>\ |
|
990 <Element1 xmlns=\"nsuri\" x=\"value4\">Content1</Element1>\ |
|
991 <Element2 xmlns=\"nsuri\">Content2</Element2></a:Test>"); |
|
992 |
|
993 // When EReportNamespaceMapping is enabled all the namespace declarations |
|
994 // are reported in exactly the same element as they are defined in parsed |
|
995 // XML document. |
|
996 // Note: The Order of namespace declarations in root element tag may change. |
|
997 // Namespace declaration for root tag is created when fragment is created |
|
998 // and because of that namespace declaration for root tag will be the first. |
|
999 _LIT8(KOutputString2, "<a:Test xmlns:a=\"nasuria\" xmlns:b=\"nsurib\" \ |
|
1000 xmlns=\"nsuri\" a:x=\"value1\" b:z=\"value2\">\ |
|
1001 <DelegateFragment>DelegateContent</DelegateFragment>\ |
|
1002 <Element1 x=\"value4\">Content1</Element1>\ |
|
1003 <Element2>Content2</Element2></a:Test>"); |
|
1004 |
|
1005 CSenParser* pParser = CSenParser::NewLC(); |
|
1006 |
|
1007 CMainDomFragment* pFragment = CMainDomFragment::NewL(_L8("nasuria"),_L8("Test"),_L8("a")); |
|
1008 CleanupStack::PushL(pFragment); |
|
1009 |
|
1010 pParser->ParseL(KInputString, *pFragment); |
|
1011 |
|
1012 HBufC8* pAsXml = pFragment->AsXmlL(); |
|
1013 CleanupStack::PushL(pAsXml); |
|
1014 if(!( *pAsXml == KOutputString1 )) return KErrArgument; |
|
1015 CleanupStack::PopAndDestroy(pAsXml); |
|
1016 |
|
1017 CDelegateDomFragment& delegate = pFragment->DelegateFragment(); |
|
1018 HBufC8* pDelegateAsXml = delegate.AsXmlL(); |
|
1019 CleanupStack::PushL(pDelegateAsXml); |
|
1020 // Note: When EReportNamespaceMapping is _NOT_ enabled namespace declaration |
|
1021 // is added to delegate even though that namespace declaration was |
|
1022 // originally declared (but not used) in root element of parsed document. |
|
1023 if(!( *pDelegateAsXml == |
|
1024 _L8("<DelegateFragment xmlns=\"nsuri\">DelegateContent</DelegateFragment>") )) return KErrArgument; |
|
1025 CleanupStack::PopAndDestroy(pDelegateAsXml); |
|
1026 |
|
1027 CleanupStack::PopAndDestroy(pFragment); |
|
1028 |
|
1029 pParser->EnableFeature(EReportNamespaceMapping); |
|
1030 |
|
1031 CMainDomFragment* pFragment2 = CMainDomFragment::NewL(_L8("nasuria"),_L8("Test"),_L8("a")); |
|
1032 CleanupStack::PushL(pFragment2); |
|
1033 |
|
1034 pParser->ParseL(KInputString, *pFragment2); |
|
1035 |
|
1036 HBufC8* pAsXml2 = pFragment2->AsXmlL(); |
|
1037 CleanupStack::PushL(pAsXml2); |
|
1038 if(!( *pAsXml2 == KOutputString2 )) return KErrArgument; |
|
1039 CleanupStack::PopAndDestroy(pAsXml2); |
|
1040 |
|
1041 CDelegateDomFragment& delegate2 = pFragment2->DelegateFragment(); |
|
1042 HBufC8* pDelegateAsXml2 = delegate2.AsXmlL(); |
|
1043 CleanupStack::PushL(pDelegateAsXml2); |
|
1044 if(!( *pDelegateAsXml2 == |
|
1045 _L8("<DelegateFragment>DelegateContent</DelegateFragment>") )) return KErrArgument; |
|
1046 CleanupStack::PopAndDestroy(pDelegateAsXml2); |
|
1047 |
|
1048 CleanupStack::PopAndDestroy(pFragment2); |
|
1049 |
|
1050 CleanupStack::PopAndDestroy(pParser); |
|
1051 Teardown(); |
|
1052 return KErrNone; |
|
1053 } |
|
1054 |
|
1055 |
|
1056 TInt CSenFragmentBCTest::MT_CSenDomFragmentBase_Parsing3L(TTestResult& aResult) |
|
1057 { |
|
1058 SetupL(); |
|
1059 // Parsing of XML document to CSenDomFragmentBase |
|
1060 // In this test same namespaceuri is defined as default namespace in |
|
1061 // root element and 'c' prefixed namespace in Element2. |
|
1062 _LIT8(KInputString, "<a:Test xmlns=\"nsuri\" xmlns:a=\"nasuria\" \ |
|
1063 xmlns:b=\"nasurib\" a:x=\"value1\" b:z=\"value2\" z=\"value3\">\ |
|
1064 <Element1 xmlns:c=\"nsuric\" c:x=\"value4\">Content1</Element1>\ |
|
1065 <x:Element2 xmlns:x=\"nsuri\">Content2</x:Element2>\ |
|
1066 <Element3>Content3</Element3>\ |
|
1067 <Element4/></a:Test>"); |
|
1068 |
|
1069 // Namespace declaration for prefix 'x' (and namespaceuri "nsuri") |
|
1070 // disappears from Element2 after parsing because default namespace |
|
1071 // declaration already declares namespace for uri "nsuri". |
|
1072 // => Double declaration for namespaceuri "nsuri" is not needed. |
|
1073 _LIT8(KOutputString, "<a:Test xmlns:a=\"nasuria\" xmlns=\"nsuri\" \ |
|
1074 xmlns:b=\"nasurib\" a:x=\"value1\" b:z=\"value2\" z=\"value3\">\ |
|
1075 <Element1 xmlns:c=\"nsuric\" c:x=\"value4\">Content1</Element1>\ |
|
1076 <Element2>Content2</Element2>\ |
|
1077 <Element3>Content3</Element3>\ |
|
1078 <Element4/></a:Test>"); |
|
1079 |
|
1080 CSenParser* pParser = CSenParser::NewLC(); |
|
1081 |
|
1082 CSenDomFragmentBase* pFragment = CSenDomFragmentBase::NewL(_L8("nasuria"),_L8("Test"),_L8("a")); |
|
1083 CleanupStack::PushL(pFragment); |
|
1084 pParser->EnableFeature(EReportNamespaceMapping); |
|
1085 |
|
1086 pParser->ParseL(KInputString, *pFragment); |
|
1087 |
|
1088 HBufC8* pAsXml = pFragment->AsXmlL(); |
|
1089 CleanupStack::PushL(pAsXml); |
|
1090 |
|
1091 if(!( *pAsXml == KOutputString )) return KErrArgument; |
|
1092 |
|
1093 CleanupStack::PopAndDestroy(pAsXml); |
|
1094 CleanupStack::PopAndDestroy(pFragment); |
|
1095 CleanupStack::PopAndDestroy(pParser); |
|
1096 Teardown(); |
|
1097 return KErrNone; |
|
1098 } |
|
1099 |
|
1100 |
|
1101 TInt CSenFragmentBCTest::MT_CSenDomFragmentBase_Parsing4L(TTestResult& aResult) |
|
1102 { |
|
1103 SetupL(); |
|
1104 // Parsing of XML document to CSenDomFragmentBase |
|
1105 // In this test nested elements (which have same name) are tested. |
|
1106 _LIT8(KInputString, "<a:Test xmlns=\"nsuri\" xmlns:a=\"nasuria\" \ |
|
1107 xmlns:b=\"nasurib\" a:x=\"value1\" b:z=\"value2\" z=\"value3\">\ |
|
1108 <Element1 xmlns:c=\"nsuric\" c:x=\"value4\">\ |
|
1109 <Element1>Content</Element1>\ |
|
1110 </Element1>\ |
|
1111 <Element3>Content3</Element3>\ |
|
1112 <Element4/></a:Test>"); |
|
1113 |
|
1114 _LIT8(KInputString2, "<Nested xmlns=\"nsuri\">\ |
|
1115 <Nested attr=\"attrvalue\"><Nested><Nested>Content</Nested></Nested></Nested>\ |
|
1116 </Nested>"); |
|
1117 |
|
1118 // Only namespace declaration order changes for output. |
|
1119 _LIT8(KOutputString, "<a:Test xmlns:a=\"nasuria\" xmlns=\"nsuri\" \ |
|
1120 xmlns:b=\"nasurib\" a:x=\"value1\" b:z=\"value2\" z=\"value3\">\ |
|
1121 <Element1 xmlns:c=\"nsuric\" c:x=\"value4\">\ |
|
1122 <Element1>Content</Element1>\ |
|
1123 </Element1>\ |
|
1124 <Element3>Content3</Element3>\ |
|
1125 <Element4/></a:Test>"); |
|
1126 |
|
1127 CSenParser* pParser = CSenParser::NewLC(); |
|
1128 |
|
1129 CSenDomFragmentBase* pFragment = CSenDomFragmentBase::NewL(_L8("nasuria"),_L8("Test"),_L8("a")); |
|
1130 CleanupStack::PushL(pFragment); |
|
1131 pParser->EnableFeature(EReportNamespaceMapping); |
|
1132 |
|
1133 pParser->ParseL(KInputString, *pFragment); |
|
1134 |
|
1135 HBufC8* pAsXml = pFragment->AsXmlL(); |
|
1136 CleanupStack::PushL(pAsXml); |
|
1137 |
|
1138 if(!( *pAsXml == KOutputString )) return KErrArgument; |
|
1139 |
|
1140 CleanupStack::PopAndDestroy(pAsXml); |
|
1141 CleanupStack::PopAndDestroy(pFragment); |
|
1142 |
|
1143 pFragment = CSenDomFragmentBase::NewL(_L8("nsuri"),_L8("Nested")); |
|
1144 CleanupStack::PushL(pFragment); |
|
1145 pParser->EnableFeature(EReportNamespaceMapping); |
|
1146 |
|
1147 pParser->ParseL(KInputString2, *pFragment); |
|
1148 |
|
1149 pAsXml = pFragment->AsXmlL(); |
|
1150 CleanupStack::PushL(pAsXml); |
|
1151 |
|
1152 if(!( *pAsXml == KInputString2 )) return KErrArgument; |
|
1153 |
|
1154 CleanupStack::PopAndDestroy(pAsXml); |
|
1155 CleanupStack::PopAndDestroy(pFragment); |
|
1156 |
|
1157 CleanupStack::PopAndDestroy(pParser); |
|
1158 Teardown(); |
|
1159 return KErrNone; |
|
1160 } |
|
1161 |
|
1162 |
|
1163 TInt CSenFragmentBCTest::MT_CSenDomFragmentBase_Parsing5L(TTestResult& aResult) |
|
1164 { |
|
1165 SetupL(); |
|
1166 // Parsing of XML document to CSenDomFragmentBase |
|
1167 // In this test nulling of default namespace is tested. |
|
1168 /* |
|
1169 _LIT8(KInputString, "<a:Test xmlns=\"nsuri\" xmlns:a=\"nasuria\" \ |
|
1170 xmlns:b=\"nasurib\" a:x=\"value1\" b:z=\"value2\" z=\"value3\">\ |
|
1171 <Element1 xmlns="" xmlns:c=\"nsuric\" c:x=\"value4\">\ |
|
1172 <Element1 >Content</Element1>\ |
|
1173 </Element1>\ |
|
1174 <Element3>Content3</Element3>\ |
|
1175 <Element4/></a:Test>"); |
|
1176 */ |
|
1177 |
|
1178 /* |
|
1179 // Only namespace declaration order changes for output. |
|
1180 _LIT8(KOutputString, "<a:Test xmlns:a=\"nasuria\" xmlns=\"nsuri\" \ |
|
1181 xmlns:b=\"nasurib\" a:x=\"value1\" b:z=\"value2\" z=\"value3\">\ |
|
1182 <Element1 xmlns:c=\"nsuric\" c:x=\"value4\">\ |
|
1183 <Element1>Content</Element1>\ |
|
1184 </Element1>\ |
|
1185 <Element3>Content3</Element3>\ |
|
1186 <Element4/></a:Test>"); |
|
1187 */ |
|
1188 |
|
1189 CSenParser* pParser = CSenParser::NewLC(); |
|
1190 |
|
1191 /*CSenDomFragmentBase* pFragment = CSenDomFragmentBase::NewL(_L8("nasuria"),_L8("Test"),_L8("a")); |
|
1192 CleanupStack::PushL(pFragment); |
|
1193 pParser->EnableFeature(EReportNamespaceMapping); |
|
1194 |
|
1195 pParser->ParseL(KInputString, *pFragment); |
|
1196 |
|
1197 HBufC8* pAsXml = pFragment->AsXmlL(); |
|
1198 CleanupStack::PushL(pAsXml); |
|
1199 |
|
1200 EUNIT_ASSERT( *pAsXml == KOutputString ); |
|
1201 |
|
1202 CleanupStack::PopAndDestroy(pAsXml); |
|
1203 CleanupStack::PopAndDestroy(pFragment);*/ |
|
1204 CleanupStack::PopAndDestroy(pParser); |
|
1205 Teardown(); |
|
1206 return KErrNone; |
|
1207 } |
|
1208 |
|
1209 |
|
1210 TInt CSenFragmentBCTest::MT_CSenDomFragmentBase_Parsing6L(TTestResult& aResult) |
|
1211 { |
|
1212 SetupL(); |
|
1213 // Parsing of XML document to CSenDomFragmentBase |
|
1214 // when constructor CSenDomFragmentBase::NewL() is used. |
|
1215 _LIT8(KInputString, "<a:Test xmlns=\"nsuri\" xmlns:a=\"nasuria\" \ |
|
1216 xmlns:b=\"nasurib\" a:x=\"value1\" b:z=\"value2\">\ |
|
1217 <Element1 xmlns:c=\"nsuric\" c:x=\"value3\">Content1</Element1>\ |
|
1218 <Element2 z=\"value4\">Content2</Element2>\ |
|
1219 <Element3>Content3</Element3>\ |
|
1220 <Element4/></a:Test>"); |
|
1221 |
|
1222 // Default namespace declaration (xmlns="nsuri") from Parent element (Test) |
|
1223 // will be moved to all child elements (Element1, Element2, Element3 and |
|
1224 // Element4) when EReportNamespaceMapping is _NOT_ enabled. That's because |
|
1225 // the way CParser works <=> Namespaces are reported when namespaces are used |
|
1226 // for the first time. |
|
1227 _LIT8(KOutputString, "<a:Test xmlns:a=\"nasuria\" xmlns:b=\"nasurib\" \ |
|
1228 a:x=\"value1\" b:z=\"value2\">\ |
|
1229 <Element1 xmlns=\"nsuri\" xmlns:c=\"nsuric\" c:x=\"value3\">Content1</Element1>\ |
|
1230 <Element2 xmlns=\"nsuri\" z=\"value4\">Content2</Element2>\ |
|
1231 <Element3 xmlns=\"nsuri\">Content3</Element3>\ |
|
1232 <Element4 xmlns=\"nsuri\"/></a:Test>"); |
|
1233 |
|
1234 CSenParser* pParser = CSenParser::NewLC(); |
|
1235 |
|
1236 CSenDomFragmentBase* pFragment = CSenDomFragmentBase::NewL(); |
|
1237 CleanupStack::PushL(pFragment); |
|
1238 |
|
1239 pParser->ParseL(KInputString, *pFragment); |
|
1240 |
|
1241 HBufC8* pAsXml = pFragment->AsXmlL(); |
|
1242 CleanupStack::PushL(pAsXml); |
|
1243 |
|
1244 if(!( *pAsXml == KOutputString )) return KErrArgument; |
|
1245 |
|
1246 CleanupStack::PopAndDestroy(pAsXml); |
|
1247 CleanupStack::PopAndDestroy(pFragment); |
|
1248 |
|
1249 CleanupStack::PopAndDestroy(pParser); |
|
1250 Teardown(); |
|
1251 return KErrNone; |
|
1252 } |
|
1253 |
|
1254 |
|
1255 TInt CSenFragmentBCTest::MT_CSenDomFragmentBase_Parsing7L(TTestResult& aResult) |
|
1256 { |
|
1257 SetupL(); |
|
1258 // Parsing of XML document to CSenDomFragmentBase |
|
1259 // when constructor CSenDomFragmentBase::NewL() is used. |
|
1260 _LIT8(KInputString, "<S:Envelope xmlns:S=\"http://www.w3.org/2003/05/soap-envelope\" \ |
|
1261 xmlns:wsa=\"http://schemas.xmlsoap.org/ws/2004/08/addressing\">\ |
|
1262 <S:Header>\ |
|
1263 <wsa:MessageID>URN:UUID:ACF914D6-86A4-E5CF-4BD2-BD9CC2AD30E1</wsa:MessageID>\ |
|
1264 <wsa:To>http://10.132.11.35/WSStar/STS.aspx</wsa:To>\ |
|
1265 <wsa:Action>http://schemas.xmlsoap.org/ws/2005/02/trust/RST/Issue</wsa:Action>\ |
|
1266 <wsse:Security xmlns:wsse=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\">\ |
|
1267 <wsse:UsernameToken>\ |
|
1268 <wsse:Username>PCNSA15\\wsstar</wsse:Username>\ |
|
1269 <wsse:Password>jaszmn\\3</wsse:Password>\ |
|
1270 </wsse:UsernameToken>\ |
|
1271 </wsse:Security>\ |
|
1272 </S:Header>\ |
|
1273 <S:Body>\ |
|
1274 <wst:RequestSecurityToken xmlns:wst=\"http://schemas.xmlsoap.org/ws/2005/02/trust\">\ |
|
1275 <wst:RequestType>http://schemas.xmlsoap.org/ws/2005/02/trust/Issue</wst:RequestType>\ |
|
1276 <wst:Renewing/>\ |
|
1277 <wst:TokenType>http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV1.1</wst:TokenType>\ |
|
1278 <wsp:AppliesTo xmlns:wsp=\"http://schemas.xmlsoap.org/ws/2004/09/policy\">\ |
|
1279 <wsa:EndpointReference>\ |
|
1280 <wsa:Address>http://10.132.11.35/WSStar/WSService.aspx</wsa:Address>\ |
|
1281 </wsa:EndpointReference>\ |
|
1282 </wsp:AppliesTo>\ |
|
1283 </wst:RequestSecurityToken>\ |
|
1284 </S:Body>\ |
|
1285 </S:Envelope>"); |
|
1286 |
|
1287 // Note: If EReportNamespaceMapping is not enabled output will be following: |
|
1288 // (Namespace declaration for prefix "wsa" jumps from root element to |
|
1289 // elements (MessageID, To, Action and EndpointReference) which actually |
|
1290 // use above mentioned prefix. <=> Root element Envelope does not use |
|
1291 // "wsa" prefix.) |
|
1292 _LIT8(KOutputString, "<S:Envelope xmlns:S=\"http://www.w3.org/2003/05/soap-envelope\">\ |
|
1293 <S:Header>\ |
|
1294 <wsa:MessageID xmlns:wsa=\"http://schemas.xmlsoap.org/ws/2004/08/addressing\">URN:UUID:ACF914D6-86A4-E5CF-4BD2-BD9CC2AD30E1</wsa:MessageID>\ |
|
1295 <wsa:To xmlns:wsa=\"http://schemas.xmlsoap.org/ws/2004/08/addressing\">http://10.132.11.35/WSStar/STS.aspx</wsa:To>\ |
|
1296 <wsa:Action xmlns:wsa=\"http://schemas.xmlsoap.org/ws/2004/08/addressing\">http://schemas.xmlsoap.org/ws/2005/02/trust/RST/Issue</wsa:Action>\ |
|
1297 <wsse:Security xmlns:wsse=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\">\ |
|
1298 <wsse:UsernameToken>\ |
|
1299 <wsse:Username>PCNSA15\\wsstar</wsse:Username>\ |
|
1300 <wsse:Password>jaszmn\\3</wsse:Password>\ |
|
1301 </wsse:UsernameToken>\ |
|
1302 </wsse:Security>\ |
|
1303 </S:Header>\ |
|
1304 <S:Body>\ |
|
1305 <wst:RequestSecurityToken xmlns:wst=\"http://schemas.xmlsoap.org/ws/2005/02/trust\">\ |
|
1306 <wst:RequestType>http://schemas.xmlsoap.org/ws/2005/02/trust/Issue</wst:RequestType>\ |
|
1307 <wst:Renewing/>\ |
|
1308 <wst:TokenType>http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV1.1</wst:TokenType>\ |
|
1309 <wsp:AppliesTo xmlns:wsp=\"http://schemas.xmlsoap.org/ws/2004/09/policy\">\ |
|
1310 <wsa:EndpointReference xmlns:wsa=\"http://schemas.xmlsoap.org/ws/2004/08/addressing\">\ |
|
1311 <wsa:Address>http://10.132.11.35/WSStar/WSService.aspx</wsa:Address>\ |
|
1312 </wsa:EndpointReference>\ |
|
1313 </wsp:AppliesTo>\ |
|
1314 </wst:RequestSecurityToken>\ |
|
1315 </S:Body>\ |
|
1316 </S:Envelope>"); |
|
1317 |
|
1318 CSenParser* parser = CSenParser::NewLC(); |
|
1319 //create a CSenDomFragment |
|
1320 CSenFragmentBase* pBase = CSenDomFragmentBase::NewL(); |
|
1321 CleanupStack::PushL(pBase); |
|
1322 //do the parsing |
|
1323 parser->ParseL(KInputString, *pBase); |
|
1324 |
|
1325 HBufC8* pAsXml = pBase->AsXmlL(); |
|
1326 CleanupStack::PushL(pAsXml); |
|
1327 if(!( *pAsXml == KOutputString )) return KErrArgument; |
|
1328 CleanupStack::PopAndDestroy(pAsXml); |
|
1329 CleanupStack::PopAndDestroy(pBase); |
|
1330 |
|
1331 pBase = CSenDomFragmentBase::NewL(); |
|
1332 CleanupStack::PushL(pBase); |
|
1333 //Enable NamespaceMapping to ensure that namespace declarations will |
|
1334 //remain in exactly the same place as in original XML document |
|
1335 parser->EnableFeature(EReportNamespaceMapping); |
|
1336 //do the parsing |
|
1337 parser->ParseL(KInputString, *pBase); |
|
1338 |
|
1339 pAsXml = pBase->AsXmlL(); |
|
1340 CleanupStack::PushL(pAsXml); |
|
1341 if(!( *pAsXml == KInputString )) return KErrArgument; |
|
1342 CleanupStack::PopAndDestroy(pAsXml); |
|
1343 |
|
1344 CleanupStack::PopAndDestroy(pBase); |
|
1345 CleanupStack::PopAndDestroy(parser); |
|
1346 Teardown(); |
|
1347 return KErrNone; |
|
1348 } |
|
1349 |
|
1350 |
|
1351 TInt CSenFragmentBCTest::MT_CSenDomFragmentBase_Parsing8L(TTestResult& aResult) |
|
1352 { |
|
1353 SetupL(); |
|
1354 // Parsing of XML document to CSenDomFragmentBase |
|
1355 // when constructor CSenDomFragmentBase::NewL() is used. |
|
1356 _LIT8(KInputString, "<S:Envelope xmlns:S=\"http://www.w3.org/2003/05/soap-envelope\" \ |
|
1357 xmlns:wsa=\"http://schemas.xmlsoap.org/ws/2004/08/addressing\">\ |
|
1358 <S:Header>\ |
|
1359 <wsa:MessageID>URN:UUID:ACF914D6-86A4-E5CF-4BD2-BD9CC2AD30E1</wsa:MessageID>\ |
|
1360 <wsa:To>http://10.132.11.35/WSStar/STS.aspx</wsa:To>\ |
|
1361 <wsa:Action>http://schemas.xmlsoap.org/ws/2005/02/trust/RST/Issue</wsa:Action>\ |
|
1362 <wsse:Security xmlns:wsse=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\">\ |
|
1363 <wsse:UsernameToken>\ |
|
1364 <wsse:Username>PCNSA15\\wsstar</wsse:Username>\ |
|
1365 <wsse:Password>jaszmn\\3</wsse:Password>\ |
|
1366 </wsse:UsernameToken>\ |
|
1367 </wsse:Security>\ |
|
1368 </S:Header>\ |
|
1369 <S:Body>\ |
|
1370 <wst:RequestSecurityToken xmlns:wst=\"http://schemas.xmlsoap.org/ws/2005/02/trust\">\ |
|
1371 <wst:RequestType>http://schemas.xmlsoap.org/ws/2005/02/trust/Issue</wst:RequestType>\ |
|
1372 <wst:Renewing/>\ |
|
1373 <wst:TokenType>http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV1.1</wst:TokenType>\ |
|
1374 <wsp:AppliesTo xmlns:wsp=\"http://schemas.xmlsoap.org/ws/2004/09/policy\">\ |
|
1375 <wsa:EndpointReference>\ |
|
1376 <wsa:Address>http://10.132.11.35/WSStar/WSService.aspx</wsa:Address>\ |
|
1377 </wsa:EndpointReference>\ |
|
1378 </wsp:AppliesTo>\ |
|
1379 </wst:RequestSecurityToken>\ |
|
1380 </S:Body>\ |
|
1381 </S:Envelope>"); |
|
1382 |
|
1383 // Note: If EReportNamespaceMapping is not enabled output will be following: |
|
1384 // (Namespace declaration for prefix "wsa" jumps from root element to |
|
1385 // elements (MessageID, To, Action and EndpointReference) which actually |
|
1386 // use above mentioned prefix. <=> Root element Envelope does not use |
|
1387 // "wsa" prefix.) |
|
1388 _LIT8(KOutputString1, "<S:Body xmlns:S=\"http://www.w3.org/2003/05/soap-envelope\">\ |
|
1389 <wst:RequestSecurityToken xmlns:wst=\"http://schemas.xmlsoap.org/ws/2005/02/trust\">\ |
|
1390 <wst:RequestType>http://schemas.xmlsoap.org/ws/2005/02/trust/Issue</wst:RequestType>\ |
|
1391 <wst:Renewing/>\ |
|
1392 <wst:TokenType>http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV1.1</wst:TokenType>\ |
|
1393 <wsp:AppliesTo xmlns:wsp=\"http://schemas.xmlsoap.org/ws/2004/09/policy\">\ |
|
1394 <wsa:EndpointReference xmlns:wsa=\"http://schemas.xmlsoap.org/ws/2004/08/addressing\">\ |
|
1395 <wsa:Address>http://10.132.11.35/WSStar/WSService.aspx</wsa:Address>\ |
|
1396 </wsa:EndpointReference>\ |
|
1397 </wsp:AppliesTo>\ |
|
1398 </wst:RequestSecurityToken>\ |
|
1399 </S:Body>"); |
|
1400 |
|
1401 _LIT8(KOutputString2, "<S:Body xmlns:S=\"http://www.w3.org/2003/05/soap-envelope\">\ |
|
1402 <wst:RequestSecurityToken xmlns:wst=\"http://schemas.xmlsoap.org/ws/2005/02/trust\">\ |
|
1403 <wst:RequestType>http://schemas.xmlsoap.org/ws/2005/02/trust/Issue</wst:RequestType>\ |
|
1404 <wst:Renewing/>\ |
|
1405 <wst:TokenType>http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV1.1</wst:TokenType>\ |
|
1406 <wsp:AppliesTo xmlns:wsp=\"http://schemas.xmlsoap.org/ws/2004/09/policy\">\ |
|
1407 <wsa:EndpointReference xmlns:wsa=\"http://schemas.xmlsoap.org/ws/2004/08/addressing\">\ |
|
1408 <wsa:Address>http://10.132.11.35/WSStar/WSService.aspx</wsa:Address>\ |
|
1409 </wsa:EndpointReference>\ |
|
1410 </wsp:AppliesTo>\ |
|
1411 </wst:RequestSecurityToken>\ |
|
1412 </S:Body>"); |
|
1413 |
|
1414 CSenParser* parser = CSenParser::NewLC(); |
|
1415 //create a CSenDomFragment |
|
1416 CSenFragmentBase* pBase = CSenDomFragmentBase::NewL(_L8("http://www.w3.org/2003/05/soap-envelope"), |
|
1417 _L8("Body"), |
|
1418 _L8("S")); |
|
1419 CleanupStack::PushL(pBase); |
|
1420 //do the parsing |
|
1421 parser->ParseL(KInputString, *pBase); |
|
1422 |
|
1423 HBufC8* pAsXml = pBase->AsXmlL(); |
|
1424 CleanupStack::PushL(pAsXml); |
|
1425 if(!( *pAsXml == KOutputString1 )) return KErrArgument; |
|
1426 CleanupStack::PopAndDestroy(pAsXml); |
|
1427 CleanupStack::PopAndDestroy(pBase); |
|
1428 |
|
1429 pBase = CSenDomFragmentBase::NewL(_L8("http://www.w3.org/2003/05/soap-envelope"), |
|
1430 _L8("Body"), |
|
1431 _L8("S")); |
|
1432 CleanupStack::PushL(pBase); |
|
1433 //Enable NamespaceMapping to ensure that namespace declarations will |
|
1434 //remain in exactly the same place as in original XML document |
|
1435 parser->EnableFeature(EReportNamespaceMapping); |
|
1436 //do the parsing |
|
1437 parser->ParseL(KInputString, *pBase); |
|
1438 |
|
1439 pAsXml = pBase->AsXmlL(); |
|
1440 CleanupStack::PushL(pAsXml); |
|
1441 if(!( *pAsXml == KOutputString2 )) return KErrArgument; |
|
1442 CleanupStack::PopAndDestroy(pAsXml); |
|
1443 |
|
1444 CleanupStack::PopAndDestroy(pBase); |
|
1445 CleanupStack::PopAndDestroy(parser); |
|
1446 Teardown(); |
|
1447 return KErrNone; |
|
1448 } |
|
1449 /* |
|
1450 TInt CSenFragmentBCTest::MT_CSenDomFragmentBase_SetContentOfLL(TTestResult& aResult) |
|
1451 { |
|
1452 SetupL(); |
|
1453 CSenDomFragmentBase* pFragment = CSenDomFragmentBase::NewL(_L8("NsUri"), |
|
1454 _L8("Test"), |
|
1455 _L8("t")); |
|
1456 CleanupStack::PushL(pFragment); |
|
1457 pFragment->SetContentOfL(_L8("name"), _L8("content")); |
|
1458 CleanupStack::PopAndDestroy(pFragment); |
|
1459 Teardown(); |
|
1460 return KErrNone; |
|
1461 } |
|
1462 |
|
1463 |
|
1464 TInt CSenFragmentBCTest::MT_CSenDomFragmentBase_ContentOfL(TTestResult& aResult) |
|
1465 { |
|
1466 SetupL(); |
|
1467 CSenDomFragmentBase* pFragment = CSenDomFragmentBase::NewL(_L8("NsUri"), |
|
1468 _L8("Test"), |
|
1469 _L8("t")); |
|
1470 CleanupStack::PushL(pFragment); |
|
1471 pFragment->ContentOf(_L8("name")); |
|
1472 CleanupStack::PopAndDestroy(pFragment); |
|
1473 Teardown(); |
|
1474 return KErrNone; |
|
1475 } |
|
1476 */ |
|
1477 |
|
1478 TInt CSenFragmentBCTest::MT_CSenDomFragmentBase_OnWriteStartElementLL(TTestResult& aResult) |
|
1479 { |
|
1480 SetupL(); |
|
1481 RTagInfo info; |
|
1482 RAttributeArray array; |
|
1483 CSenDomFragmentBase* pFragment = CSenDomFragmentBase::NewL(_L8("NsUri"), |
|
1484 _L8("Test"), |
|
1485 _L8("t")); |
|
1486 CleanupStack::PushL(pFragment); |
|
1487 pFragment->OnWriteStartElementL(info, array); |
|
1488 CleanupStack::PopAndDestroy(pFragment); |
|
1489 Teardown(); |
|
1490 return KErrNone; |
|
1491 } |
|
1492 |
|
1493 TInt CSenFragmentBCTest::MT_CSenDomFragmentBase_OnWriteEndElementLL(TTestResult& aResult) |
|
1494 { |
|
1495 SetupL(); |
|
1496 RTagInfo info; |
|
1497 |
|
1498 CSenDomFragmentBase* pFragment = CSenDomFragmentBase::NewL(_L8("NsUri"), |
|
1499 _L8("Test"), |
|
1500 _L8("t")); |
|
1501 CleanupStack::PushL(pFragment); |
|
1502 pFragment->OnWriteEndElementL(info); |
|
1503 CleanupStack::PopAndDestroy(pFragment); |
|
1504 Teardown(); |
|
1505 return KErrNone; |
|
1506 } |
|
1507 |
|
1508 TInt CSenFragmentBCTest::MT_CSenDomFragmentBase_OnIgnorableWhiteSpaceLL(TTestResult& aResult) |
|
1509 { |
|
1510 SetupL(); |
|
1511 TInt var = 0; |
|
1512 CSenDomFragmentBase* pFragment = CSenDomFragmentBase::NewL(_L8("NsUri"), |
|
1513 _L8("Test"), |
|
1514 _L8("t")); |
|
1515 CleanupStack::PushL(pFragment); |
|
1516 pFragment->OnIgnorableWhiteSpaceL(_L8("test"), var); |
|
1517 CleanupStack::PopAndDestroy(pFragment); |
|
1518 Teardown(); |
|
1519 return KErrNone; |
|
1520 } |
|
1521 |
|
1522 TInt CSenFragmentBCTest::MT_CSenDomFragmentBase_OnSkippedEntityLL(TTestResult& aResult) |
|
1523 { |
|
1524 SetupL(); |
|
1525 RString str; |
|
1526 TInt var = 0; |
|
1527 |
|
1528 CSenDomFragmentBase* pFragment = CSenDomFragmentBase::NewL(_L8("NsUri"), |
|
1529 _L8("Test"), |
|
1530 _L8("t")); |
|
1531 CleanupStack::PushL(pFragment); |
|
1532 pFragment->OnSkippedEntityL(str, var); |
|
1533 CleanupStack::PopAndDestroy(pFragment); |
|
1534 Teardown(); |
|
1535 return KErrNone; |
|
1536 } |
|
1537 |
|
1538 TInt CSenFragmentBCTest::MT_CSenDomFragmentBase_OnProcessingInstructionLL(TTestResult& aResult) |
|
1539 { |
|
1540 SetupL(); |
|
1541 TInt var = 0; |
|
1542 CSenDomFragmentBase* pFragment = CSenDomFragmentBase::NewL(_L8("NsUri"), |
|
1543 _L8("Test"), |
|
1544 _L8("t")); |
|
1545 CleanupStack::PushL(pFragment); |
|
1546 pFragment->OnProcessingInstructionL(_L8("test"), _L8("test"), var); |
|
1547 CleanupStack::PopAndDestroy(pFragment); |
|
1548 Teardown(); |
|
1549 return KErrNone; |
|
1550 } |
|
1551 |
|
1552 TInt CSenFragmentBCTest::MT_CSenDomFragmentBase_OnErrorL(TTestResult& aResult) |
|
1553 { |
|
1554 SetupL(); |
|
1555 TInt var = 0; |
|
1556 |
|
1557 CSenDomFragmentBase* pFragment = CSenDomFragmentBase::NewL(_L8("NsUri"), |
|
1558 _L8("Test"), |
|
1559 _L8("t")); |
|
1560 CleanupStack::PushL(pFragment); |
|
1561 pFragment->OnError(var); |
|
1562 CleanupStack::PopAndDestroy(pFragment); |
|
1563 Teardown(); |
|
1564 return KErrNone; |
|
1565 } |
|
1566 |
|
1567 TInt CSenFragmentBCTest::MT_CSenDomFragmentBase_GetExtendedInterfaceL(TTestResult& aResult) |
|
1568 { |
|
1569 SetupL(); |
|
1570 const TInt32 var = 0; |
|
1571 |
|
1572 CSenDomFragmentBase* pFragment = CSenDomFragmentBase::NewL(_L8("NsUri"), |
|
1573 _L8("Test"), |
|
1574 _L8("t")); |
|
1575 CleanupStack::PushL(pFragment); |
|
1576 pFragment->GetExtendedInterface(var); |
|
1577 CleanupStack::PopAndDestroy(pFragment); |
|
1578 Teardown(); |
|
1579 return KErrNone; |
|
1580 } |
|
1581 |
|
1582 TInt CSenFragmentBCTest::MT_CSenFragmentBase_NewLL(TTestResult& aResult) |
|
1583 { |
|
1584 SetupL(); |
|
1585 RSenDocument document = RSenDocument::NewL(); |
|
1586 CleanupClosePushL(document); |
|
1587 TXmlEngElement element = document.CreateDocumentElementL(_L8("Test")); |
|
1588 _LIT8(KElement, "<Element/>"); |
|
1589 element.SetTextNoEncL(KElement); |
|
1590 |
|
1591 CSenFragmentBase* pFragment = CSenFragmentBase::NewL(element); |
|
1592 CleanupStack::PushL(pFragment); |
|
1593 HBufC8* pAsXml = pFragment->AsXmlL(); |
|
1594 CleanupStack::PushL(pAsXml); |
|
1595 // Test that when CSenFragmentBase is serialized '<' and '>' characters |
|
1596 // are NOT encoded => The content of CSenFragmentBase can include |
|
1597 // XML elements |
|
1598 if(!( *pAsXml == _L8("<Test><Element/></Test>") )) return KErrArgument; |
|
1599 CleanupStack::PopAndDestroy(pAsXml); |
|
1600 CleanupStack::PopAndDestroy(pFragment); |
|
1601 CleanupStack::PopAndDestroy(&document); |
|
1602 Teardown(); |
|
1603 return KErrNone; |
|
1604 } |
|
1605 |
|
1606 |
|
1607 TInt CSenFragmentBCTest::MT_CSenFragmentBase_NewL_1L(TTestResult& aResult) |
|
1608 { |
|
1609 SetupL(); |
|
1610 CSenFragmentBase* pFragment = CSenFragmentBase::NewL(_L8("Test")); |
|
1611 CleanupStack::PushL(pFragment); |
|
1612 HBufC8* pAsXml = pFragment->AsXmlL(); |
|
1613 CleanupStack::PushL(pAsXml); |
|
1614 if(!( *pAsXml == _L8("<Test/>") )) return KErrArgument; |
|
1615 CleanupStack::PopAndDestroy(pAsXml); |
|
1616 CleanupStack::PopAndDestroy(pFragment); |
|
1617 Teardown(); |
|
1618 return KErrNone; |
|
1619 } |
|
1620 |
|
1621 |
|
1622 TInt CSenFragmentBCTest::MT_CSenFragmentBase_NewL_2L(TTestResult& aResult) |
|
1623 { |
|
1624 SetupL(); |
|
1625 CSenFragmentBase* pFragment = CSenFragmentBase::NewL(_L8("NsUri"), |
|
1626 _L8("Test")); |
|
1627 CleanupStack::PushL(pFragment); |
|
1628 HBufC8* pAsXml = pFragment->AsXmlL(); |
|
1629 CleanupStack::PushL(pAsXml); |
|
1630 if(!( *pAsXml == _L8("<Test xmlns=\"NsUri\"/>") )) return KErrArgument; |
|
1631 CleanupStack::PopAndDestroy(pAsXml); |
|
1632 CleanupStack::PopAndDestroy(pFragment); |
|
1633 Teardown(); |
|
1634 return KErrNone; |
|
1635 } |
|
1636 |
|
1637 |
|
1638 TInt CSenFragmentBCTest::MT_CSenFragmentBase_NewL_3L(TTestResult& aResult) |
|
1639 { |
|
1640 SetupL(); |
|
1641 CSenFragmentBase* pFragment = CSenFragmentBase::NewL(_L8("NsUri"), |
|
1642 _L8("Test"), |
|
1643 _L8("t")); |
|
1644 CleanupStack::PushL(pFragment); |
|
1645 HBufC8* pAsXml = pFragment->AsXmlL(); |
|
1646 CleanupStack::PushL(pAsXml); |
|
1647 if(!( *pAsXml == _L8("<t:Test xmlns:t=\"NsUri\"/>") )) return KErrArgument; |
|
1648 CleanupStack::PopAndDestroy(pAsXml); |
|
1649 CleanupStack::PopAndDestroy(pFragment); |
|
1650 Teardown(); |
|
1651 return KErrNone; |
|
1652 } |
|
1653 |
|
1654 |
|
1655 TInt CSenFragmentBCTest::MT_CSenFragmentBase_NewL_4L(TTestResult& aResult) |
|
1656 { |
|
1657 SetupL(); |
|
1658 RStringPool stringPool; |
|
1659 stringPool.OpenL(); |
|
1660 CleanupClosePushL(stringPool); |
|
1661 |
|
1662 RString nsUriRString = stringPool.OpenStringL(_L8("nsuri")); |
|
1663 CleanupClosePushL(nsUriRString); |
|
1664 RString nsPrefixRString = stringPool.OpenStringL(_L8("pr")); |
|
1665 CleanupClosePushL(nsPrefixRString); |
|
1666 RString localNameRString = stringPool.OpenStringL(_L8("LocalName")); |
|
1667 CleanupClosePushL(localNameRString); |
|
1668 RString valueRString = stringPool.OpenStringL(_L8("Value")); |
|
1669 CleanupClosePushL(valueRString); |
|
1670 |
|
1671 RAttribute attribute; |
|
1672 attribute.Open(nsUriRString, nsPrefixRString, localNameRString, |
|
1673 valueRString ); |
|
1674 // attribute took ownership of all RStrings |
|
1675 // => All RStrings can be pop from CleanupStack |
|
1676 CleanupStack::Pop(&valueRString); |
|
1677 CleanupStack::Pop(&localNameRString); |
|
1678 CleanupStack::Pop(&nsPrefixRString); |
|
1679 CleanupStack::Pop(&nsUriRString); |
|
1680 |
|
1681 CleanupClosePushL(attribute); |
|
1682 |
|
1683 RAttributeArray attrArray; |
|
1684 // append the namespace attribute (declaration) |
|
1685 attrArray.AppendL(attribute); |
|
1686 CleanupClosePushL(attrArray); |
|
1687 |
|
1688 CSenFragmentBase* pFragment = CSenFragmentBase::NewL(_L8("NsUri"), |
|
1689 _L8("Test"), |
|
1690 _L8("t"), |
|
1691 attrArray); |
|
1692 CleanupStack::PushL(pFragment); |
|
1693 HBufC8* pAsXml = pFragment->AsXmlL(); |
|
1694 CleanupStack::PushL(pAsXml); |
|
1695 if(!( *pAsXml == _L8("<t:Test xmlns:t=\"NsUri\" xmlns:pr=\"nsuri\" pr:LocalName=\"Value\"/>") )) return KErrArgument; |
|
1696 CleanupStack::PopAndDestroy(pAsXml); |
|
1697 CleanupStack::PopAndDestroy(pFragment); |
|
1698 CleanupStack::PopAndDestroy(&attrArray); |
|
1699 CleanupStack::PopAndDestroy(&attribute); |
|
1700 CleanupStack::PopAndDestroy(&stringPool); |
|
1701 Teardown(); |
|
1702 return KErrNone; |
|
1703 } |
|
1704 |
|
1705 |
|
1706 TInt CSenFragmentBCTest::MT_CSenFragmentBase_NewL_5L(TTestResult& aResult) |
|
1707 { |
|
1708 SetupL(); |
|
1709 RSenDocument document = RSenDocument::NewL(); |
|
1710 CleanupClosePushL(document); |
|
1711 TXmlEngElement parentElement = document.CreateDocumentElementL(_L8("Parent")); |
|
1712 |
|
1713 RStringPool stringPool; |
|
1714 stringPool.OpenL(); |
|
1715 CleanupClosePushL(stringPool); |
|
1716 |
|
1717 RString nsUriRString = stringPool.OpenStringL(_L8("nsuri")); |
|
1718 CleanupClosePushL(nsUriRString); |
|
1719 RString nsPrefixRString = stringPool.OpenStringL(_L8("pr")); |
|
1720 CleanupClosePushL(nsPrefixRString); |
|
1721 RString localNameRString = stringPool.OpenStringL(_L8("LocalName")); |
|
1722 CleanupClosePushL(localNameRString); |
|
1723 RString valueRString = stringPool.OpenStringL(_L8("Value")); |
|
1724 CleanupClosePushL(valueRString); |
|
1725 |
|
1726 RAttribute attribute; |
|
1727 attribute.Open(nsUriRString, nsPrefixRString, localNameRString, |
|
1728 valueRString); |
|
1729 // attribute took ownership of all RStrings |
|
1730 // => All RStrings can be pop from CleanupStack |
|
1731 CleanupStack::Pop(&valueRString); |
|
1732 CleanupStack::Pop(&localNameRString); |
|
1733 CleanupStack::Pop(&nsPrefixRString); |
|
1734 CleanupStack::Pop(&nsUriRString); |
|
1735 |
|
1736 CleanupClosePushL(attribute); |
|
1737 |
|
1738 RAttributeArray attrArray; |
|
1739 // append the namespace attribute (declaration) |
|
1740 attrArray.AppendL(attribute); |
|
1741 CleanupClosePushL(attrArray); |
|
1742 |
|
1743 CSenFragmentBase* pFragment = CSenFragmentBase::NewL(_L8("NsUri"), |
|
1744 _L8("Test"), |
|
1745 _L8("t"), |
|
1746 attrArray, |
|
1747 parentElement); |
|
1748 CleanupStack::PushL(pFragment); |
|
1749 HBufC8* pAsXml = pFragment->AsXmlL(); |
|
1750 CleanupStack::PushL(pAsXml); |
|
1751 if(!( *pAsXml == _L8("<t:Test xmlns:t=\"NsUri\" xmlns:pr=\"nsuri\" pr:LocalName=\"Value\"/>") )) return KErrArgument; |
|
1752 |
|
1753 RBuf8 buffer; |
|
1754 parentElement.OuterXmlL(buffer); |
|
1755 |
|
1756 if(!( buffer == _L8("<Parent><t:Test xmlns:t=\"NsUri\" xmlns:pr=\"nsuri\" pr:LocalName=\"Value\"/></Parent>") )) return KErrArgument; |
|
1757 buffer.Close(); |
|
1758 |
|
1759 CleanupStack::PopAndDestroy(pAsXml); |
|
1760 CleanupStack::PopAndDestroy(pFragment); |
|
1761 CleanupStack::PopAndDestroy(&attrArray); |
|
1762 CleanupStack::PopAndDestroy(&attribute); |
|
1763 CleanupStack::PopAndDestroy(&stringPool); |
|
1764 CleanupStack::PopAndDestroy(&document); |
|
1765 Teardown(); |
|
1766 return KErrNone; |
|
1767 } |
|
1768 |
|
1769 |
|
1770 TInt CSenFragmentBCTest::MT_CSenFragmentBase_NewL_6L(TTestResult& aResult) |
|
1771 { |
|
1772 SetupL(); |
|
1773 RSenDocument document = RSenDocument::NewL(); |
|
1774 CleanupClosePushL(document); |
|
1775 TXmlEngElement parentElement = document.CreateDocumentElementL(_L8("Parent")); |
|
1776 |
|
1777 RStringPool stringPool; |
|
1778 stringPool.OpenL(); |
|
1779 CleanupClosePushL(stringPool); |
|
1780 |
|
1781 RString nsUriRString = stringPool.OpenStringL(_L8("nsuri")); |
|
1782 CleanupClosePushL(nsUriRString); |
|
1783 RString nsPrefixRString = stringPool.OpenStringL(_L8("pr")); |
|
1784 CleanupClosePushL(nsPrefixRString); |
|
1785 RString localNameRString = stringPool.OpenStringL(_L8("LocalName")); |
|
1786 CleanupClosePushL(localNameRString); |
|
1787 RString valueRString = stringPool.OpenStringL(_L8("Value")); |
|
1788 CleanupClosePushL(valueRString); |
|
1789 |
|
1790 RAttribute attribute; |
|
1791 attribute.Open(nsUriRString, nsPrefixRString, localNameRString, |
|
1792 valueRString); |
|
1793 // attribute took ownership of all RStrings |
|
1794 // => All RStrings can be pop from CleanupStack |
|
1795 CleanupStack::Pop(&valueRString); |
|
1796 CleanupStack::Pop(&localNameRString); |
|
1797 CleanupStack::Pop(&nsPrefixRString); |
|
1798 CleanupStack::Pop(&nsUriRString); |
|
1799 |
|
1800 CleanupClosePushL(attribute); |
|
1801 |
|
1802 RAttributeArray attrArray; |
|
1803 // append the namespace attribute (declaration) |
|
1804 attrArray.AppendL(attribute); |
|
1805 CleanupClosePushL(attrArray); |
|
1806 |
|
1807 CSenFragmentBase* pFragment = CSenFragmentBase::NewL(_L8("NsUri"), |
|
1808 _L8("Test"), |
|
1809 _L8(""), |
|
1810 attrArray, |
|
1811 parentElement, |
|
1812 document); |
|
1813 CleanupStack::PushL(pFragment); |
|
1814 HBufC8* pAsXml = pFragment->AsXmlL(); |
|
1815 CleanupStack::PushL(pAsXml); |
|
1816 if(!( *pAsXml == _L8("<Test xmlns=\"NsUri\" xmlns:pr=\"nsuri\" pr:LocalName=\"Value\"/>") )) return KErrArgument; |
|
1817 |
|
1818 RBuf8 buffer; |
|
1819 parentElement.OuterXmlL(buffer); |
|
1820 |
|
1821 if(!( buffer == _L8("<Parent><Test xmlns=\"NsUri\" xmlns:pr=\"nsuri\" pr:LocalName=\"Value\"/></Parent>") )) return KErrArgument; |
|
1822 buffer.Close(); |
|
1823 |
|
1824 CleanupStack::PopAndDestroy(pAsXml); |
|
1825 CleanupStack::PopAndDestroy(pFragment); |
|
1826 CleanupStack::PopAndDestroy(&attrArray); |
|
1827 CleanupStack::PopAndDestroy(&attribute); |
|
1828 CleanupStack::PopAndDestroy(&stringPool); |
|
1829 CleanupStack::PopAndDestroy(&document); |
|
1830 Teardown(); |
|
1831 return KErrNone; |
|
1832 } |
|
1833 |
|
1834 |
|
1835 TInt CSenFragmentBCTest::MT_CSenFragmentBase_NewL_7L(TTestResult& aResult) |
|
1836 { |
|
1837 SetupL(); |
|
1838 RSenDocument document = RSenDocument::NewL(); |
|
1839 CleanupClosePushL(document); |
|
1840 TXmlEngElement parentElement = document.CreateDocumentElementL(_L8("Parent")); |
|
1841 |
|
1842 RStringPool stringPool; |
|
1843 stringPool.OpenL(); |
|
1844 CleanupClosePushL(stringPool); |
|
1845 |
|
1846 RString nsUriRString = stringPool.OpenStringL(_L8("nsuri")); |
|
1847 CleanupClosePushL(nsUriRString); |
|
1848 RString nsPrefixRString = stringPool.OpenStringL(_L8("pr")); |
|
1849 CleanupClosePushL(nsPrefixRString); |
|
1850 RString localNameRString = stringPool.OpenStringL(_L8("LocalName")); |
|
1851 CleanupClosePushL(localNameRString); |
|
1852 RString valueRString = stringPool.OpenStringL(_L8("Value")); |
|
1853 CleanupClosePushL(valueRString); |
|
1854 |
|
1855 RAttribute attribute; |
|
1856 attribute.Open(nsUriRString, nsPrefixRString, localNameRString, |
|
1857 valueRString); |
|
1858 // attribute took ownership of all RStrings |
|
1859 // => All RStrings can be pop from CleanupStack |
|
1860 CleanupStack::Pop(&valueRString); |
|
1861 CleanupStack::Pop(&localNameRString); |
|
1862 CleanupStack::Pop(&nsPrefixRString); |
|
1863 CleanupStack::Pop(&nsUriRString); |
|
1864 |
|
1865 CleanupClosePushL(attribute); |
|
1866 |
|
1867 RAttributeArray attrArray; |
|
1868 // append the namespace attribute (declaration) |
|
1869 attrArray.AppendL(attribute); |
|
1870 CleanupClosePushL(attrArray); |
|
1871 |
|
1872 CSenFragmentBase* pFragment = CSenFragmentBase::NewL(_L8("NsUri"), |
|
1873 _L8("Test"), |
|
1874 _L8(""), |
|
1875 attrArray, |
|
1876 parentElement, |
|
1877 document); |
|
1878 CleanupStack::PushL(pFragment); |
|
1879 |
|
1880 RSenDocument doc = pFragment->AsDocumentL(); |
|
1881 TXmlEngElement el = pFragment->AsElementL(); |
|
1882 CSenFragmentBase* pFragment2 = CSenFragmentBase::NewL(el, doc); |
|
1883 |
|
1884 CleanupStack::PopAndDestroy(pFragment); |
|
1885 CleanupStack::PushL(pFragment2); |
|
1886 |
|
1887 HBufC8* pAsXml = pFragment2->AsXmlL(); |
|
1888 CleanupStack::PushL(pAsXml); |
|
1889 if(!( *pAsXml == _L8("<Test xmlns=\"NsUri\" xmlns:pr=\"nsuri\" pr:LocalName=\"Value\"/>") )) return KErrArgument; |
|
1890 |
|
1891 RBuf8 buffer; |
|
1892 parentElement.OuterXmlL(buffer); |
|
1893 |
|
1894 if(!( buffer == _L8("<Parent><Test xmlns=\"NsUri\" xmlns:pr=\"nsuri\" pr:LocalName=\"Value\"/></Parent>") )) return KErrArgument; |
|
1895 buffer.Close(); |
|
1896 |
|
1897 CleanupStack::PopAndDestroy(pAsXml); |
|
1898 CleanupStack::PopAndDestroy(pFragment2); |
|
1899 CleanupStack::PopAndDestroy(&attrArray); |
|
1900 CleanupStack::PopAndDestroy(&attribute); |
|
1901 CleanupStack::PopAndDestroy(&stringPool); |
|
1902 CleanupStack::PopAndDestroy(&document); |
|
1903 Teardown(); |
|
1904 return KErrNone; |
|
1905 |
|
1906 } |
|
1907 |
|
1908 TInt CSenFragmentBCTest::MT_CSenFragmentBase_SetDocumentL(TTestResult& aResult) |
|
1909 { |
|
1910 SetupL(); |
|
1911 RSenDocument document ; |
|
1912 document = RSenDocument::NewL(); |
|
1913 |
|
1914 CSenFragmentBase* pFragment = CSenFragmentBase::NewL(_L8("Test")); |
|
1915 CleanupStack::PushL(pFragment); |
|
1916 |
|
1917 pFragment->SetDocument(document); |
|
1918 CleanupStack::PopAndDestroy(pFragment); |
|
1919 Teardown(); |
|
1920 return KErrNone; |
|
1921 } |
|
1922 |
|
1923 |
|
1924 |
|
1925 |
|
1926 TInt CSenFragmentBCTest::MT_CSenFragmentBase_ContentLL(TTestResult& aResult) |
|
1927 { |
|
1928 SetupL(); |
|
1929 RSenDocument document = RSenDocument::NewL(); |
|
1930 CleanupClosePushL(document); |
|
1931 TXmlEngElement element = document.CreateDocumentElementL(_L8("Test")); |
|
1932 element.SetEscapedTextL(_L8("<Element/>")); |
|
1933 |
|
1934 CSenFragmentBase* pFragment = CSenFragmentBase::NewL(element); |
|
1935 CleanupStack::PushL(pFragment); |
|
1936 |
|
1937 TPtrC8 content = pFragment->ContentL(); |
|
1938 if(!( content == _L8("<Element/>") )) return KErrArgument; |
|
1939 |
|
1940 CleanupStack::PopAndDestroy(pFragment); |
|
1941 CleanupStack::PopAndDestroy(&document); |
|
1942 Teardown(); |
|
1943 return KErrNone; |
|
1944 } |
|
1945 |
|
1946 |
|
1947 TInt CSenFragmentBCTest::MT_CSenFragmentBase_NamespaceL(TTestResult& aResult) |
|
1948 { |
|
1949 SetupL(); |
|
1950 RStringPool stringPool; |
|
1951 stringPool.OpenL(); |
|
1952 CleanupClosePushL(stringPool); |
|
1953 |
|
1954 RString nsUriRString = stringPool.OpenStringL(_L8("nsuri")); |
|
1955 CleanupClosePushL(nsUriRString); |
|
1956 RString nsPrefixRString = stringPool.OpenStringL(_L8("pr")); |
|
1957 CleanupClosePushL(nsPrefixRString); |
|
1958 RString localNameRString = stringPool.OpenStringL(_L8("LocalName")); |
|
1959 CleanupClosePushL(localNameRString); |
|
1960 RString valueRString = stringPool.OpenStringL(_L8("Value")); |
|
1961 CleanupClosePushL(valueRString); |
|
1962 |
|
1963 RAttribute attribute; |
|
1964 attribute.Open(stringPool.OpenStringL(_L8("nsuri")), |
|
1965 stringPool.OpenStringL(_L8("pr")), |
|
1966 stringPool.OpenStringL(_L8("LocalName")), |
|
1967 stringPool.OpenStringL(_L8("Value")) ); |
|
1968 // attribute took copies of all RStrings |
|
1969 // => All RStrings can be destroyed |
|
1970 CleanupStack::PopAndDestroy(4); // nsUriRString, nsPrefixRString, localNameRString, |
|
1971 // valueRString |
|
1972 CleanupClosePushL(attribute); |
|
1973 |
|
1974 RAttributeArray attrArray; |
|
1975 // append the namespace attribute (declaration) |
|
1976 attrArray.AppendL(attribute); |
|
1977 CleanupClosePushL(attrArray); |
|
1978 |
|
1979 CSenFragmentBase* pFragment = CSenFragmentBase::NewL(_L8("NsUri"), |
|
1980 _L8("Test"), |
|
1981 _L8("t"), |
|
1982 attrArray); |
|
1983 CleanupStack::PushL(pFragment); |
|
1984 |
|
1985 TXmlEngNamespace ns = pFragment->Namespace(_L8("pr")); |
|
1986 if(!( ns.Uri() == _L8("nsuri") )) return KErrArgument; |
|
1987 |
|
1988 TXmlEngNamespace ns2 = pFragment->Namespace(_L8("x")); |
|
1989 if(!( ns2.IsUndefined() )) return KErrArgument; |
|
1990 |
|
1991 CleanupStack::PopAndDestroy(pFragment); |
|
1992 CleanupStack::PopAndDestroy(); // attribute |
|
1993 CleanupStack::PopAndDestroy(); // attrArray |
|
1994 CleanupStack::PopAndDestroy(); // stringPool |
|
1995 Teardown(); |
|
1996 return KErrNone; |
|
1997 } |
|
1998 |
|
1999 |
|
2000 TInt CSenFragmentBCTest::MT_CSenFragmentBase_ResetContentLL(TTestResult& aResult) |
|
2001 { |
|
2002 SetupL(); |
|
2003 RSenDocument document = RSenDocument::NewL(); |
|
2004 CleanupClosePushL(document); |
|
2005 TXmlEngElement element = document.CreateDocumentElementL(_L8("Test")); |
|
2006 element.SetEscapedTextL(_L8("Content")); |
|
2007 |
|
2008 CSenFragmentBase* pFragment = CSenFragmentBase::NewL(element); |
|
2009 CleanupStack::PushL(pFragment); |
|
2010 |
|
2011 // Test that CSenFragmentBase has content before reset |
|
2012 TPtrC8 content = pFragment->ContentL(); |
|
2013 if(!( content == _L8("Content") )) return KErrArgument; |
|
2014 |
|
2015 pFragment->ResetContentL(); |
|
2016 |
|
2017 // Test that CSenFragmentBase has no content after reset |
|
2018 TPtrC8 content2 = pFragment->ContentL(); |
|
2019 if(!( content2 == KNullDesC8 )) return KErrArgument; |
|
2020 |
|
2021 CleanupStack::PopAndDestroy(pFragment); |
|
2022 CleanupStack::PopAndDestroy(&document); |
|
2023 Teardown(); |
|
2024 return KErrNone; |
|
2025 } |
|
2026 |
|
2027 |
|
2028 TInt CSenFragmentBCTest::MT_CSenFragmentBase_LocalNameL(TTestResult& aResult) |
|
2029 { |
|
2030 SetupL(); |
|
2031 CSenFragmentBase* pFragment = CSenFragmentBase::NewL(_L8("NsUri"), |
|
2032 _L8("Test"), |
|
2033 _L8("t")); |
|
2034 CleanupStack::PushL(pFragment); |
|
2035 TPtrC8 localName = pFragment->LocalName(); |
|
2036 if(!( localName == _L8("Test") )) return KErrArgument; |
|
2037 CleanupStack::PopAndDestroy(pFragment); |
|
2038 Teardown(); |
|
2039 return KErrNone; |
|
2040 } |
|
2041 |
|
2042 |
|
2043 TInt CSenFragmentBCTest::MT_CSenFragmentBase_NsUriL(TTestResult& aResult) |
|
2044 { |
|
2045 SetupL(); |
|
2046 CSenFragmentBase* pFragment = CSenFragmentBase::NewL(_L8("NsUri"), |
|
2047 _L8("Test"), |
|
2048 _L8("t")); |
|
2049 CleanupStack::PushL(pFragment); |
|
2050 TPtrC8 localName = pFragment->NsUri(); |
|
2051 if(!( localName == _L8("NsUri") )) return KErrArgument; |
|
2052 CleanupStack::PopAndDestroy(pFragment); |
|
2053 Teardown(); |
|
2054 return KErrNone; |
|
2055 } |
|
2056 |
|
2057 |
|
2058 TInt CSenFragmentBCTest::MT_CSenFragmentBase_NsPrefixL(TTestResult& aResult) |
|
2059 { |
|
2060 SetupL(); |
|
2061 CSenFragmentBase* pFragment = CSenFragmentBase::NewL(_L8("NsUri"), |
|
2062 _L8("Test"), |
|
2063 _L8("t")); |
|
2064 CleanupStack::PushL(pFragment); |
|
2065 TPtrC8 localName = pFragment->NsPrefix(); |
|
2066 if(!( localName == _L8("t") )) return KErrArgument; |
|
2067 CleanupStack::PopAndDestroy(pFragment); |
|
2068 Teardown(); |
|
2069 return KErrNone; |
|
2070 } |
|
2071 |
|
2072 |
|
2073 TInt CSenFragmentBCTest::MT_CSenFragmentBase_AsElementLL(TTestResult& aResult) |
|
2074 { |
|
2075 SetupL(); |
|
2076 CSenFragmentBase* pFragment = CSenFragmentBase::NewL(_L8("NsUri"), |
|
2077 _L8("Test"), |
|
2078 _L8("t")); |
|
2079 CleanupStack::PushL(pFragment); |
|
2080 TXmlEngElement element = pFragment->AsElementL(); |
|
2081 RBuf8 buffer; |
|
2082 CleanupClosePushL(buffer); |
|
2083 element.OuterXmlL(buffer); |
|
2084 // Serialized element should contain all the Fragment data as XML. |
|
2085 if(!( buffer == _L8("<t:Test xmlns:t=\"NsUri\"/>") )) return KErrArgument; |
|
2086 CleanupStack::PopAndDestroy(&buffer); |
|
2087 CleanupStack::PopAndDestroy(pFragment); |
|
2088 Teardown(); |
|
2089 return KErrNone; |
|
2090 |
|
2091 } |
|
2092 |
|
2093 |
|
2094 TInt CSenFragmentBCTest::MT_CSenFragmentBase_AsDocumentLL(TTestResult& aResult) |
|
2095 { |
|
2096 SetupL(); |
|
2097 CSenFragmentBase* pFragment = CSenFragmentBase::NewL(_L8("NsUri"), |
|
2098 _L8("Test"), |
|
2099 _L8("t")); |
|
2100 CleanupStack::PushL(pFragment); |
|
2101 RSenDocument document = pFragment->AsDocumentL(); |
|
2102 TXmlEngElement element = document.DocumentElement(); |
|
2103 |
|
2104 TXmlEngSerializationOptions options; |
|
2105 // Omit following declarations from the beginning of XML Document: |
|
2106 // <?xml version=\"1.0\... |
|
2107 // encoding="..." |
|
2108 // standalone="..." |
|
2109 // ?> |
|
2110 options.iOptions = options.iOptions | |
|
2111 TXmlEngSerializationOptions::KOptionOmitXMLDeclaration; |
|
2112 RBuf8 asXml; |
|
2113 document.SaveL(asXml, element, options); |
|
2114 CleanupClosePushL(asXml); |
|
2115 |
|
2116 // Serialized document should contain all the Fragment data as XML. |
|
2117 if(!( asXml == _L8("<t:Test xmlns:t=\"NsUri\"/>") )) return KErrArgument; |
|
2118 |
|
2119 CleanupStack::PopAndDestroy(&asXml); |
|
2120 CleanupStack::PopAndDestroy(pFragment); |
|
2121 Teardown(); |
|
2122 return KErrNone; |
|
2123 } |
|
2124 |
|
2125 |
|
2126 TInt CSenFragmentBCTest::MT_CSenFragmentBase_ExtractElementL(TTestResult& aResult) |
|
2127 { |
|
2128 SetupL(); |
|
2129 CSenFragmentBase* pFragment = CSenFragmentBase::NewL(_L8("NsUri"), |
|
2130 _L8("Test"), |
|
2131 _L8("t")); |
|
2132 CleanupStack::PushL(pFragment); |
|
2133 TXmlEngElement element = pFragment->ExtractElement(); |
|
2134 if(!( element.Name() == _L8("Test") )) return KErrArgument; |
|
2135 element.Remove(); |
|
2136 CleanupStack::PopAndDestroy(pFragment); |
|
2137 Teardown(); |
|
2138 return KErrNone; |
|
2139 } |
|
2140 |
|
2141 |
|
2142 TInt CSenFragmentBCTest::MT_CSenFragmentBase_AsXmlUnicodeLL(TTestResult& aResult) |
|
2143 { |
|
2144 SetupL(); |
|
2145 // Test serialization of Dom tree which has two child elements |
|
2146 CSenFragmentBase* pFragment = CSenFragmentBase::NewL(_L8("Test")); |
|
2147 CleanupStack::PushL(pFragment); |
|
2148 TXmlEngElement element = pFragment->AsElementL(); |
|
2149 |
|
2150 TXmlEngElement element2 = element.AddNewElementL(_L8("Child"), _L8("nsuri"), _L8("prefix")); |
|
2151 |
|
2152 element2.AddNewElementL(_L8("Child2"), _L8("nsuri2"), _L8("prefix2")); |
|
2153 |
|
2154 HBufC* pAsXml = pFragment->AsXmlUnicodeL(); |
|
2155 CleanupStack::PushL(pAsXml); |
|
2156 if(!( *pAsXml == _L("<Test xmlns:prefix=\"nsuri\"><prefix:Child xmlns:prefix2=\"nsuri2\"><prefix2:Child2/></prefix:Child></Test>") )) return KErrArgument; |
|
2157 CleanupStack::PopAndDestroy(pAsXml); |
|
2158 CleanupStack::PopAndDestroy(pFragment); |
|
2159 Teardown(); |
|
2160 return KErrNone; |
|
2161 } |
|
2162 |
|
2163 |
|
2164 TInt CSenFragmentBCTest::MT_CSenFragmentBase_AsXmlLL(TTestResult& aResult) |
|
2165 { |
|
2166 SetupL(); |
|
2167 // Test serialization of Dom tree which has two child elements |
|
2168 CSenFragmentBase* pFragment = CSenFragmentBase::NewL(_L8("Test")); |
|
2169 CleanupStack::PushL(pFragment); |
|
2170 TXmlEngElement element = pFragment->AsElementL(); |
|
2171 |
|
2172 TXmlEngElement element2 = element.AddNewElementL(_L8("Child"), _L8("nsuri"), _L8("prefix")); |
|
2173 |
|
2174 element2.AddNewElementL(_L8("Child2"), _L8("nsuri2"), _L8("prefix2")); |
|
2175 |
|
2176 HBufC8* pAsXml = pFragment->AsXmlL(); |
|
2177 CleanupStack::PushL(pAsXml); |
|
2178 if(!( *pAsXml == _L8("<Test xmlns:prefix=\"nsuri\"><prefix:Child xmlns:prefix2=\"nsuri2\"><prefix2:Child2/></prefix:Child></Test>") )) return KErrArgument; |
|
2179 CleanupStack::PopAndDestroy(pAsXml); |
|
2180 CleanupStack::PopAndDestroy(pFragment); |
|
2181 Teardown(); |
|
2182 return KErrNone; |
|
2183 } |
|
2184 |
|
2185 |
|
2186 TInt CSenFragmentBCTest::MT_CSenFragmentBase_WriteAsXMLToLL(TTestResult& aResult) |
|
2187 { |
|
2188 SetupL(); |
|
2189 // Test serialization of Dom tree which has two child elements |
|
2190 CSenFragmentBase* pFragment = CSenFragmentBase::NewL(_L8("Test")); |
|
2191 CleanupStack::PushL(pFragment); |
|
2192 TXmlEngElement element = pFragment->AsElementL(); |
|
2193 |
|
2194 TXmlEngElement element2 = element.AddNewElementL(_L8("Child"), _L8("nsuri"), _L8("prefix")); |
|
2195 |
|
2196 element2.AddNewElementL(_L8("Child2"), _L8("nsuri2"), _L8("prefix2")); |
|
2197 |
|
2198 CBufFlat* pBuf = CBufFlat::NewL(200); |
|
2199 CleanupStack::PushL(pBuf); |
|
2200 RBufWriteStream bufWs(*pBuf); |
|
2201 CleanupClosePushL(bufWs); |
|
2202 pFragment->WriteAsXMLToL(bufWs); |
|
2203 |
|
2204 |
|
2205 if(!( pBuf->Ptr(0) == _L8("<Test xmlns:prefix=\"nsuri\"><prefix:Child xmlns:prefix2=\"nsuri2\"><prefix2:Child2/></prefix:Child></Test>") )) return KErrArgument; |
|
2206 |
|
2207 CleanupStack::PopAndDestroy(&bufWs); |
|
2208 CleanupStack::PopAndDestroy(pBuf); |
|
2209 |
|
2210 CleanupStack::PopAndDestroy(pFragment); |
|
2211 Teardown(); |
|
2212 return KErrNone; |
|
2213 } |
|
2214 |
|
2215 |
|
2216 TInt CSenFragmentBCTest::MT_CSenFragmentBase_ConsistsOfLL(TTestResult& aResult) |
|
2217 { |
|
2218 SetupL(); |
|
2219 CSenFragmentBase* pFragment = CSenFragmentBase::NewL(_L8("Test")); |
|
2220 CleanupStack::PushL(pFragment); |
|
2221 TXmlEngElement element = pFragment->AsElementL(); |
|
2222 |
|
2223 TXmlEngElement elementchild1 = element.AddNewElementL(_L8("DirectChild")); |
|
2224 elementchild1.AddNamespaceDeclarationL(_L8("nsuri"), _L8("prefix")); |
|
2225 //elementchild1.RenameNodeL(_L8("DirectChild"), _L8("nsuri"), _L8("prefix")); |
|
2226 //TDomUtils domUtils1; |
|
2227 //domUtils1.XmlEngRenameElementL(elementchild1, _L8("DirectChild"), _L8("nsuri"), _L8("prefix")); |
|
2228 |
|
2229 TXmlEngElement elementchild2 = element.AddNewElementL(_L8("DirectChild")); |
|
2230 elementchild2.AddNamespaceDeclarationL(_L8("nsuri"), _L8("prefix")); |
|
2231 //elementchild2.RenameNodeL(_L8("DirectChild"), _L8("nsuri"), _L8("prefix")); |
|
2232 //TDomUtils domUtils2; |
|
2233 //domUtils2.XmlEngRenameElementL(elementchild2, _L8("DirectChild"), _L8("nsuri"), _L8("prefix")); |
|
2234 elementchild2.AddNewElementL(_L8("Child"), _L8("nsuri2"), _L8("prefix2")); |
|
2235 |
|
2236 CSenFragmentBase* pFragment2 = CSenFragmentBase::NewL(_L8("Test")); |
|
2237 CleanupStack::PushL(pFragment2); |
|
2238 TXmlEngElement element2 = pFragment2->AsElementL(); |
|
2239 |
|
2240 TXmlEngElement elementchild22 = element2.AddNewElementL(_L8("DirectChild")); |
|
2241 elementchild22.AddNamespaceDeclarationL(_L8("nsuri"), _L8("prefix")); |
|
2242 //elementchild22.RenameNodeL(_L8("DirectChild"), _L8("nsuri"), _L8("prefix")); |
|
2243 //TDomUtils domUtils22; |
|
2244 //domUtils22.XmlEngRenameElementL(elementchild22, _L8("DirectChild"), _L8("nsuri"), _L8("prefix")); |
|
2245 elementchild22.AddNewElementL(_L8("Child"), _L8("nsuri2"), _L8("prefix2")); |
|
2246 |
|
2247 // ConsistOfL should return ETrue because |
|
2248 // root elements of both fragments match and the only element |
|
2249 // of pFragment2 = elementchild22 is exactly the same element as |
|
2250 // elementchild2. |
|
2251 if(!( pFragment->ConsistsOfL(*pFragment2) )) return KErrArgument; |
|
2252 |
|
2253 // ConsistOfL should return EFalse because |
|
2254 // Even though root elements of both fragments match |
|
2255 // there is extra element (= elementchild1) in pFragment. |
|
2256 // |
|
2257 // elementchild1 (of pFragment) can not be found from pFragment2 |
|
2258 // and because of that pFragment2 does not consist of pFragment. |
|
2259 if(!( !pFragment2->ConsistsOfL(*pFragment) )) return KErrArgument; |
|
2260 CleanupStack::PopAndDestroy(pFragment2); |
|
2261 |
|
2262 CSenFragmentBase* pFragment3 = CSenFragmentBase::NewL(_L8("Test")); |
|
2263 CleanupStack::PushL(pFragment3); |
|
2264 TXmlEngElement element3 = pFragment3->AsElementL(); |
|
2265 |
|
2266 TXmlEngElement elementchild32 = element3.AddNewElementL(_L8("DirectChild")); |
|
2267 elementchild32.AddNamespaceDeclarationL(_L8("nsuri"), _L8("prefix")); |
|
2268 //elementchild32.RenameNodeL(_L8("DirectChild"), _L8("nsuri"), _L8("prefix")); |
|
2269 //TDomUtils domUtils32; |
|
2270 //domUtils32.XmlEngRenameElementL(elementchild32, _L8("DirectChild"), _L8("nsuri"), _L8("prefix")); |
|
2271 elementchild32.AddNewElementL(_L8("Child"), _L8("nsuri2"), _L8("prefix2")); |
|
2272 elementchild32.SetEscapedTextL(_L8("Text")); |
|
2273 |
|
2274 // ConsistOfL should return EFalse because |
|
2275 // elementchild32 has content ("Text") which doesn't match |
|
2276 // to any child element of pFragment. |
|
2277 if(!( !pFragment->ConsistsOfL(*pFragment3) )) return KErrArgument; |
|
2278 CleanupStack::PopAndDestroy(pFragment3); |
|
2279 |
|
2280 CleanupStack::PopAndDestroy(pFragment); |
|
2281 Teardown(); |
|
2282 return KErrNone; |
|
2283 } |
|
2284 |
|
2285 |
|
2286 TInt CSenFragmentBCTest::MT_CSenFragmentBase_Parsing1L(TTestResult& aResult) |
|
2287 { |
|
2288 SetupL(); |
|
2289 // Parsing of XML document to CSenFragmentBase |
|
2290 _LIT8(KInputString, "<a:Test xmlns=\"nsuri\" xmlns:a=\"nasuria\" \ |
|
2291 xmlns:b=\"nasurib\" a:x=\"value1\" b:z=\"value2\">\ |
|
2292 <Element1 xmlns:c=\"nsuric\" c:x=\"value4\">Content1</Element1>\ |
|
2293 <Element2>Content2</Element2>\ |
|
2294 <Element3>Content3</Element3>\ |
|
2295 <Element4/></a:Test>"); |
|
2296 |
|
2297 // Default namespace declaration (xmlns="nsuri") from Parent element (Test) |
|
2298 // will be moved to all child elements (Element1, Element2, Element3 and |
|
2299 // Element4) when EReportNamespaceMapping is _NOT_ enabled. That's because |
|
2300 // the way CParser works <=> Namespaces are reported when namespaces are used. |
|
2301 _LIT8(KOutputString1, "<a:Test xmlns:a=\"nasuria\" xmlns:b=\"nasurib\" \ |
|
2302 a:x=\"value1\" b:z=\"value2\">\ |
|
2303 <Element1 xmlns=\"nsuri\" xmlns:c=\"nsuric\" c:x=\"value4\">Content1</Element1>\ |
|
2304 <Element2 xmlns=\"nsuri\">Content2</Element2>\ |
|
2305 <Element3 xmlns=\"nsuri\">Content3</Element3>\ |
|
2306 <Element4 xmlns=\"nsuri\"/></a:Test>"); |
|
2307 |
|
2308 // When EReportNamespaceMapping is enabled all the namespace declarations |
|
2309 // are reported in exactly the same element as they are defined in parsed |
|
2310 // XML document. |
|
2311 // Note: The Order of namespace declarations in root element tag may change. |
|
2312 // Namespace declaration for root tag is created when fragment is created |
|
2313 // and because of that namespace declaration for root tag will be the first. |
|
2314 // In this particular case namespace declaration for prefix "a" will be |
|
2315 // the first namespace declaration because it is declared when |
|
2316 // CSenFragmentBase is created. |
|
2317 _LIT8(KOutputString2, "<a:Test xmlns:a=\"nasuria\" xmlns=\"nsuri\" \ |
|
2318 xmlns:b=\"nasurib\" a:x=\"value1\" b:z=\"value2\">\ |
|
2319 <Element1 xmlns:c=\"nsuric\" c:x=\"value4\">Content1</Element1>\ |
|
2320 <Element2>Content2</Element2>\ |
|
2321 <Element3>Content3</Element3>\ |
|
2322 <Element4/></a:Test>"); |
|
2323 |
|
2324 CSenParser* pParser = CSenParser::NewLC(); |
|
2325 |
|
2326 CSenFragmentBase* pFragment = CSenFragmentBase::NewL(_L8("nasuria"),_L8("Test"),_L8("a")); |
|
2327 CleanupStack::PushL(pFragment); |
|
2328 |
|
2329 /* |
|
2330 //tma |
|
2331 pParser->ParseBeginL(); |
|
2332 |
|
2333 _LIT8(KXmlParserMimeType, "text/xml"); |
|
2334 pParser->ParseBeginL(KXmlParserMimeType); |
|
2335 |
|
2336 CMatchData* pMatchData = CMatchData::NewLC(); |
|
2337 pMatchData->SetMimeTypeL(KXmlParserMimeType); |
|
2338 pParser->ParseBeginL(*pMatchData); |
|
2339 CleanupStack::PopAndDestroy(pMatchData); |
|
2340 //tma |
|
2341 */ |
|
2342 |
|
2343 pParser->ParseL(KInputString, *pFragment); |
|
2344 |
|
2345 HBufC8* pAsXml = pFragment->AsXmlL(); |
|
2346 CleanupStack::PushL(pAsXml); |
|
2347 |
|
2348 if(!( *pAsXml == KOutputString1 )) return KErrArgument; |
|
2349 |
|
2350 CleanupStack::PopAndDestroy(pAsXml); |
|
2351 CleanupStack::PopAndDestroy(pFragment); |
|
2352 |
|
2353 pParser->EnableFeature(EReportNamespaceMapping); |
|
2354 |
|
2355 CSenFragmentBase* pFragment2 = CSenFragmentBase::NewL(_L8("nasuria"),_L8("Test"),_L8("a")); |
|
2356 CleanupStack::PushL(pFragment2); |
|
2357 |
|
2358 pParser->ParseL(KInputString, *pFragment2); |
|
2359 |
|
2360 HBufC8* pAsXml2 = pFragment2->AsXmlL(); |
|
2361 CleanupStack::PushL(pAsXml2); |
|
2362 |
|
2363 if(!( *pAsXml2 == KOutputString2 )) return KErrArgument; |
|
2364 |
|
2365 CleanupStack::PopAndDestroy(pAsXml2); |
|
2366 CleanupStack::PopAndDestroy(pFragment2); |
|
2367 |
|
2368 CleanupStack::PopAndDestroy(pParser); |
|
2369 Teardown(); |
|
2370 return KErrNone; |
|
2371 } |
|
2372 |
|
2373 |
|
2374 TInt CSenFragmentBCTest::MT_CSenFragmentBase_Parsing2L(TTestResult& aResult) |
|
2375 { |
|
2376 SetupL(); |
|
2377 // Parsing of XML document to CSenFragmentBase which uses |
|
2378 // delegation. |
|
2379 _LIT8(KInputString, "<a:Test xmlns:a=\"nasuria\" xmlns:b=\"nsurib\" \ |
|
2380 xmlns=\"nsuri\" a:x=\"value1\" b:z=\"value2\">\ |
|
2381 <DelegateFragment>DelegateContent</DelegateFragment>\ |
|
2382 <Element1 x=\"value4\">Content1</Element1>\ |
|
2383 <Element2>Content2</Element2></a:Test>"); |
|
2384 |
|
2385 // Default namespace declaration (xmlns="nsuri") from Parent element (Test) |
|
2386 // will be moved to all child elements (Element1, Element2, Element3 and |
|
2387 // Element4) when EReportNamespaceMapping is _NOT_ enabled. That's because |
|
2388 // the way CParser works <=> Namespaces are reported when namespaces are used |
|
2389 // for the first time. |
|
2390 // Note: In CSenFragmentBase case DelegateFragment won't be in |
|
2391 // content of parent fragment which did the delegation. |
|
2392 _LIT8(KOutputString1, "<a:Test xmlns:a=\"nasuria\" xmlns:b=\"nsurib\" \ |
|
2393 a:x=\"value1\" b:z=\"value2\">\ |
|
2394 <Element1 xmlns=\"nsuri\" x=\"value4\">Content1</Element1>\ |
|
2395 <Element2 xmlns=\"nsuri\">Content2</Element2></a:Test>"); |
|
2396 |
|
2397 // When EReportNamespaceMapping is enabled all the namespace declarations |
|
2398 // are reported in exactly the same element as they are defined in parsed |
|
2399 // XML document. |
|
2400 // Note: The Order of namespace declarations in root element tag may change. |
|
2401 // Namespace declaration for root tag is created when fragment is created |
|
2402 // and because of that namespace declaration for root tag will be the first. |
|
2403 // Note: In CSenFragmentBase case DelegateFragment won't be in |
|
2404 // content of parent fragment which did the delegation. |
|
2405 _LIT8(KOutputString2, "<a:Test xmlns:a=\"nasuria\" xmlns:b=\"nsurib\" \ |
|
2406 xmlns=\"nsuri\" a:x=\"value1\" b:z=\"value2\">\ |
|
2407 <Element1 x=\"value4\">Content1</Element1>\ |
|
2408 <Element2>Content2</Element2></a:Test>"); |
|
2409 |
|
2410 CSenParser* pParser = CSenParser::NewLC(); |
|
2411 |
|
2412 CMainFragment* pFragment = CMainFragment::NewL(_L8("nasuria"),_L8("Test"),_L8("a")); |
|
2413 CleanupStack::PushL(pFragment); |
|
2414 |
|
2415 pParser->ParseL(KInputString, *pFragment); |
|
2416 |
|
2417 HBufC8* pAsXml = pFragment->AsXmlL(); |
|
2418 CleanupStack::PushL(pAsXml); |
|
2419 if(!( *pAsXml == KOutputString1 )) return KErrArgument; |
|
2420 CleanupStack::PopAndDestroy(pAsXml); |
|
2421 |
|
2422 CDelegateFragment& delegate = pFragment->DelegateFragment(); |
|
2423 HBufC8* pDelegateAsXml = delegate.AsXmlL(); |
|
2424 CleanupStack::PushL(pDelegateAsXml); |
|
2425 if(!( *pDelegateAsXml == |
|
2426 _L8("<DelegateFragment xmlns=\"nsuri\">DelegateContent</DelegateFragment>") )) return KErrArgument; |
|
2427 CleanupStack::PopAndDestroy(pDelegateAsXml); |
|
2428 |
|
2429 CleanupStack::PopAndDestroy(pFragment); |
|
2430 |
|
2431 pParser->EnableFeature(EReportNamespaceMapping); |
|
2432 |
|
2433 CMainFragment* pFragment2 = CMainFragment::NewL(_L8("nasuria"),_L8("Test"),_L8("a")); |
|
2434 CleanupStack::PushL(pFragment2); |
|
2435 |
|
2436 pParser->ParseL(KInputString, *pFragment2); |
|
2437 |
|
2438 HBufC8* pAsXml2 = pFragment2->AsXmlL(); |
|
2439 CleanupStack::PushL(pAsXml2); |
|
2440 if(!( *pAsXml2 == KOutputString2 )) return KErrArgument; |
|
2441 CleanupStack::PopAndDestroy(pAsXml2); |
|
2442 |
|
2443 CDelegateFragment& delegate2 = pFragment2->DelegateFragment(); |
|
2444 HBufC8* pDelegateAsXml2 = delegate2.AsXmlL(); |
|
2445 CleanupStack::PushL(pDelegateAsXml2); |
|
2446 if(!( *pDelegateAsXml2 == |
|
2447 _L8("<DelegateFragment xmlns=\"nsuri\">DelegateContent</DelegateFragment>") )) return KErrArgument; |
|
2448 CleanupStack::PopAndDestroy(pDelegateAsXml2); |
|
2449 |
|
2450 CleanupStack::PopAndDestroy(pFragment2); |
|
2451 |
|
2452 CleanupStack::PopAndDestroy(pParser); |
|
2453 Teardown(); |
|
2454 return KErrNone; |
|
2455 } |
|
2456 |
|
2457 |
|
2458 TInt CSenFragmentBCTest::MT_CSenFragmentBase_Parsing3L(TTestResult& aResult) |
|
2459 { |
|
2460 SetupL(); |
|
2461 // Parsing of XML document to CSenFragmentBase |
|
2462 _LIT8(KInputString, "<a:Test xmlns=\"nsuri\" xmlns:a=\"nasuria\" \ |
|
2463 xmlns:b=\"nasurib\" a:x=\"value1\" b:z=\"value2\" z=\"value3\">\ |
|
2464 <Element1 xmlns:c=\"nsuric\" c:x=\"value4\">Content1</Element1>\ |
|
2465 <x:Element2 xmlns:x=\"nsuri\">Content2</x:Element2>\ |
|
2466 <Element3>Content3</Element3>\ |
|
2467 <Element4/></a:Test>"); |
|
2468 |
|
2469 _LIT8(KOutputString, "<a:Test xmlns:a=\"nasuria\" xmlns=\"nsuri\" \ |
|
2470 xmlns:b=\"nasurib\" a:x=\"value1\" b:z=\"value2\" z=\"value3\">\ |
|
2471 <Element1 xmlns:c=\"nsuric\" c:x=\"value4\">Content1</Element1>\ |
|
2472 <x:Element2 xmlns:x=\"nsuri\">Content2</x:Element2>\ |
|
2473 <Element3>Content3</Element3>\ |
|
2474 <Element4/></a:Test>"); |
|
2475 |
|
2476 CSenParser* pParser = CSenParser::NewLC(); |
|
2477 |
|
2478 CSenFragmentBase* pFragment = CSenFragmentBase::NewL(_L8("nasuria"),_L8("Test"),_L8("a")); |
|
2479 CleanupStack::PushL(pFragment); |
|
2480 pParser->EnableFeature(EReportNamespaceMapping); |
|
2481 |
|
2482 pParser->ParseL(KInputString, *pFragment); |
|
2483 |
|
2484 HBufC8* pAsXml = pFragment->AsXmlL(); |
|
2485 CleanupStack::PushL(pAsXml); |
|
2486 |
|
2487 if(!( *pAsXml == KOutputString )) return KErrArgument; |
|
2488 |
|
2489 CleanupStack::PopAndDestroy(pAsXml); |
|
2490 CleanupStack::PopAndDestroy(pFragment); |
|
2491 CleanupStack::PopAndDestroy(pParser); |
|
2492 Teardown(); |
|
2493 return KErrNone; |
|
2494 } |
|
2495 |
|
2496 |
|
2497 TInt CSenFragmentBCTest::MT_CSenFragmentBase_Parsing4L(TTestResult& aResult) |
|
2498 { |
|
2499 SetupL(); |
|
2500 // Parsing of XML document to CSenFragmentBase |
|
2501 // In this test nested elements (which have same name) are tested. |
|
2502 _LIT8(KInputString, "<a:Test xmlns=\"nsuri\" xmlns:a=\"nasuria\" \ |
|
2503 xmlns:b=\"nasurib\" a:x=\"value1\" b:z=\"value2\" z=\"value3\">\ |
|
2504 <Element1 xmlns:c=\"nsuric\" c:x=\"value4\">\ |
|
2505 <Element1>Content</Element1>\ |
|
2506 </Element1>\ |
|
2507 <Element3>Content3</Element3>\ |
|
2508 <Element4/></a:Test>"); |
|
2509 |
|
2510 _LIT8(KInputString2, "<Nested xmlns=\"nsuri\">\ |
|
2511 <Nested attr=\"attrvalue\"><Nested><Nested>Content</Nested></Nested></Nested>\ |
|
2512 </Nested>"); |
|
2513 |
|
2514 // Only namespace declaration order changes for output. |
|
2515 // Element4 which has no content will be output with |
|
2516 // start and end tags. |
|
2517 _LIT8(KOutputString, "<a:Test xmlns:a=\"nasuria\" xmlns=\"nsuri\" \ |
|
2518 xmlns:b=\"nasurib\" a:x=\"value1\" b:z=\"value2\" z=\"value3\">\ |
|
2519 <Element1 xmlns:c=\"nsuric\" c:x=\"value4\">\ |
|
2520 <Element1>Content</Element1>\ |
|
2521 </Element1>\ |
|
2522 <Element3>Content3</Element3>\ |
|
2523 <Element4/></a:Test>"); |
|
2524 |
|
2525 CSenParser* pParser = CSenParser::NewLC(); |
|
2526 |
|
2527 CSenFragmentBase* pFragment = CSenFragmentBase::NewL(_L8("nasuria"),_L8("Test"),_L8("a")); |
|
2528 CleanupStack::PushL(pFragment); |
|
2529 pParser->EnableFeature(EReportNamespaceMapping); |
|
2530 |
|
2531 pParser->ParseL(KInputString, *pFragment); |
|
2532 |
|
2533 HBufC8* pAsXml = pFragment->AsXmlL(); |
|
2534 CleanupStack::PushL(pAsXml); |
|
2535 |
|
2536 if(!( *pAsXml == KOutputString )) return KErrArgument; |
|
2537 |
|
2538 CleanupStack::PopAndDestroy(pAsXml); |
|
2539 CleanupStack::PopAndDestroy(pFragment); |
|
2540 |
|
2541 pFragment = CSenFragmentBase::NewL(_L8("nsuri"),_L8("Nested")); |
|
2542 CleanupStack::PushL(pFragment); |
|
2543 pParser->EnableFeature(EReportNamespaceMapping); |
|
2544 |
|
2545 pParser->ParseL(KInputString2, *pFragment); |
|
2546 |
|
2547 pAsXml = pFragment->AsXmlL(); |
|
2548 CleanupStack::PushL(pAsXml); |
|
2549 |
|
2550 if(!( *pAsXml == KInputString2 )) return KErrArgument; |
|
2551 |
|
2552 CleanupStack::PopAndDestroy(pAsXml); |
|
2553 CleanupStack::PopAndDestroy(pFragment); |
|
2554 |
|
2555 CleanupStack::PopAndDestroy(pParser); |
|
2556 Teardown(); |
|
2557 return KErrNone; |
|
2558 } |
|
2559 |
|
2560 |
|
2561 TInt CSenFragmentBCTest::MT_CSenFragmentBase_Parsing5L(TTestResult& aResult) |
|
2562 { |
|
2563 SetupL(); |
|
2564 // Parsing of XML document to CSenDomFragmentBase |
|
2565 // when constructor CSenDomFragmentBase::NewL() is used. |
|
2566 _LIT8(KInputString, "<S:Envelope xmlns:S=\"http://www.w3.org/2003/05/soap-envelope\" \ |
|
2567 xmlns:wsa=\"http://schemas.xmlsoap.org/ws/2004/08/addressing\">\ |
|
2568 <S:Header>\ |
|
2569 <wsa:MessageID>URN:UUID:ACF914D6-86A4-E5CF-4BD2-BD9CC2AD30E1</wsa:MessageID>\ |
|
2570 <wsa:To>http://10.132.11.35/WSStar/STS.aspx</wsa:To>\ |
|
2571 <wsa:Action>http://schemas.xmlsoap.org/ws/2005/02/trust/RST/Issue</wsa:Action>\ |
|
2572 <wsse:Security xmlns:wsse=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\">\ |
|
2573 <wsse:UsernameToken>\ |
|
2574 <wsse:Username>PCNSA15\\wsstar</wsse:Username>\ |
|
2575 <wsse:Password>jaszmn\\3</wsse:Password>\ |
|
2576 </wsse:UsernameToken>\ |
|
2577 </wsse:Security>\ |
|
2578 </S:Header>\ |
|
2579 <S:Body>\ |
|
2580 <wst:RequestSecurityToken xmlns:wst=\"http://schemas.xmlsoap.org/ws/2005/02/trust\">\ |
|
2581 <wst:RequestType>http://schemas.xmlsoap.org/ws/2005/02/trust/Issue</wst:RequestType>\ |
|
2582 <wst:Renewing/>\ |
|
2583 <wst:TokenType>http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV1.1</wst:TokenType>\ |
|
2584 <wsp:AppliesTo xmlns:wsp=\"http://schemas.xmlsoap.org/ws/2004/09/policy\">\ |
|
2585 <wsa:EndpointReference>\ |
|
2586 <wsa:Address>http://10.132.11.35/WSStar/WSService.aspx</wsa:Address>\ |
|
2587 </wsa:EndpointReference>\ |
|
2588 </wsp:AppliesTo>\ |
|
2589 </wst:RequestSecurityToken>\ |
|
2590 </S:Body>\ |
|
2591 </S:Envelope>"); |
|
2592 |
|
2593 // Note: If EReportNamespaceMapping is not enabled output will be following: |
|
2594 // (Namespace declaration for prefix "wsa" jumps from root element to |
|
2595 // elements (MessageID, To, Action and EndpointReference) which actually |
|
2596 // use above mentioned prefix. <=> Root element Envelope does not use |
|
2597 // "wsa" prefix.) |
|
2598 _LIT8(KOutputString1, "<S:Body xmlns:S=\"http://www.w3.org/2003/05/soap-envelope\">\ |
|
2599 <wst:RequestSecurityToken xmlns:wst=\"http://schemas.xmlsoap.org/ws/2005/02/trust\">\ |
|
2600 <wst:RequestType>http://schemas.xmlsoap.org/ws/2005/02/trust/Issue</wst:RequestType>\ |
|
2601 <wst:Renewing/>\ |
|
2602 <wst:TokenType>http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV1.1</wst:TokenType>\ |
|
2603 <wsp:AppliesTo xmlns:wsp=\"http://schemas.xmlsoap.org/ws/2004/09/policy\">\ |
|
2604 <wsa:EndpointReference xmlns:wsa=\"http://schemas.xmlsoap.org/ws/2004/08/addressing\">\ |
|
2605 <wsa:Address>http://10.132.11.35/WSStar/WSService.aspx</wsa:Address>\ |
|
2606 </wsa:EndpointReference>\ |
|
2607 </wsp:AppliesTo>\ |
|
2608 </wst:RequestSecurityToken>\ |
|
2609 </S:Body>"); |
|
2610 |
|
2611 _LIT8(KOutputString2, "<S:Body xmlns:S=\"http://www.w3.org/2003/05/soap-envelope\" \ |
|
2612 xmlns:wsa=\"http://schemas.xmlsoap.org/ws/2004/08/addressing\" \ |
|
2613 xmlns:wsse=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\">\ |
|
2614 <wst:RequestSecurityToken xmlns:wst=\"http://schemas.xmlsoap.org/ws/2005/02/trust\">\ |
|
2615 <wst:RequestType>http://schemas.xmlsoap.org/ws/2005/02/trust/Issue</wst:RequestType>\ |
|
2616 <wst:Renewing/>\ |
|
2617 <wst:TokenType>http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV1.1</wst:TokenType>\ |
|
2618 <wsp:AppliesTo xmlns:wsp=\"http://schemas.xmlsoap.org/ws/2004/09/policy\">\ |
|
2619 <wsa:EndpointReference>\ |
|
2620 <wsa:Address>http://10.132.11.35/WSStar/WSService.aspx</wsa:Address>\ |
|
2621 </wsa:EndpointReference>\ |
|
2622 </wsp:AppliesTo>\ |
|
2623 </wst:RequestSecurityToken>\ |
|
2624 </S:Body>"); |
|
2625 |
|
2626 CSenParser* parser = CSenParser::NewLC(); |
|
2627 //create a CSenDomFragment |
|
2628 CSenFragmentBase* pBase = CSenFragmentBase::NewL(_L8("http://www.w3.org/2003/05/soap-envelope"), |
|
2629 _L8("Body"), |
|
2630 _L8("S")); |
|
2631 CleanupStack::PushL(pBase); |
|
2632 //do the parsing |
|
2633 parser->ParseL(KInputString, *pBase); |
|
2634 |
|
2635 HBufC8* pAsXml = pBase->AsXmlL(); |
|
2636 CleanupStack::PushL(pAsXml); |
|
2637 if(!( *pAsXml == KOutputString1 )) return KErrArgument; |
|
2638 CleanupStack::PopAndDestroy(pAsXml); |
|
2639 CleanupStack::PopAndDestroy(pBase); |
|
2640 |
|
2641 pBase = CSenFragmentBase::NewL(_L8("http://www.w3.org/2003/05/soap-envelope"), |
|
2642 _L8("Body"), |
|
2643 _L8("S")); |
|
2644 CleanupStack::PushL(pBase); |
|
2645 //Enable NamespaceMapping to ensure that namespace declarations will |
|
2646 //remain in exactly the same place as in original XML document |
|
2647 parser->EnableFeature(EReportNamespaceMapping); |
|
2648 //do the parsing |
|
2649 parser->ParseL(KInputString, *pBase); |
|
2650 |
|
2651 pAsXml = pBase->AsXmlL(); |
|
2652 CleanupStack::PushL(pAsXml); |
|
2653 if(!( *pAsXml == KOutputString2 )) return KErrArgument; |
|
2654 CleanupStack::PopAndDestroy(pAsXml); |
|
2655 |
|
2656 CleanupStack::PopAndDestroy(pBase); |
|
2657 CleanupStack::PopAndDestroy(parser); |
|
2658 Teardown(); |
|
2659 return KErrNone; |
|
2660 } |
|
2661 |
|
2662 |
|
2663 TInt CSenFragmentBCTest::MT_CSenParser_NewLL(TTestResult& aResult) |
|
2664 { |
|
2665 SetupL(); |
|
2666 CSenParser* pParser = CSenParser::NewL(); |
|
2667 delete pParser; |
|
2668 Teardown(); |
|
2669 return KErrNone; |
|
2670 } |
|
2671 |
|
2672 |
|
2673 TInt CSenFragmentBCTest::MT_CSenParser_NewLCL(TTestResult& aResult) |
|
2674 { |
|
2675 SetupL(); |
|
2676 CSenParser* pParser = CSenParser::NewLC(); |
|
2677 CleanupStack::PopAndDestroy(pParser); |
|
2678 Teardown(); |
|
2679 return KErrNone; |
|
2680 } |
|
2681 |
|
2682 |
|
2683 TInt CSenFragmentBCTest::MT_CSenParser_NewL_1L(TTestResult& aResult) |
|
2684 { |
|
2685 SetupL(); |
|
2686 _LIT8(KXmlParserMimeType, "text/xml"); |
|
2687 CSenFragmentBase* pFragment = CSenFragmentBase::NewL(_L8("Test")); |
|
2688 CleanupStack::PushL(pFragment); |
|
2689 CParser* pParser = CParser::NewL(KXmlParserMimeType, *pFragment); |
|
2690 |
|
2691 // Ownership of the pParser is transfered to pSenParser |
|
2692 CSenParser* pSenParser = CSenParser::NewL(pParser); |
|
2693 delete pSenParser; |
|
2694 |
|
2695 CleanupStack::PopAndDestroy(pFragment); |
|
2696 Teardown(); |
|
2697 return KErrNone; |
|
2698 } |
|
2699 |
|
2700 |
|
2701 TInt CSenFragmentBCTest::MT_CSenParser_NewLC_1L(TTestResult& aResult) |
|
2702 { |
|
2703 SetupL(); |
|
2704 _LIT8(KXmlParserMimeType, "text/xml"); |
|
2705 CSenFragmentBase* pFragment = CSenFragmentBase::NewL(_L8("Test")); |
|
2706 CleanupStack::PushL(pFragment); |
|
2707 CParser* pParser = CParser::NewL(KXmlParserMimeType, *pFragment); |
|
2708 |
|
2709 // Ownership of the pParser is transfered to pSenParser |
|
2710 CSenParser* pSenParser = CSenParser::NewLC(pParser); |
|
2711 CleanupStack::PopAndDestroy(pSenParser); |
|
2712 |
|
2713 CleanupStack::PopAndDestroy(pFragment); |
|
2714 Teardown(); |
|
2715 return KErrNone; |
|
2716 } |
|
2717 |
|
2718 |
|
2719 TInt CSenFragmentBCTest::MT_CSenParser_NewL_2L(TTestResult& aResult) |
|
2720 { |
|
2721 SetupL(); |
|
2722 _LIT8(KXmlParserMimeType, "text/xml"); |
|
2723 CSenParser* pParser = CSenParser::NewL(KXmlParserMimeType); |
|
2724 delete pParser; |
|
2725 Teardown(); |
|
2726 return KErrNone; |
|
2727 } |
|
2728 |
|
2729 |
|
2730 TInt CSenFragmentBCTest::MT_CSenParser_NewLC_2L(TTestResult& aResult) |
|
2731 { |
|
2732 SetupL(); |
|
2733 _LIT8(KXmlParserMimeType, "text/xml"); |
|
2734 CSenParser* pParser = CSenParser::NewLC(KXmlParserMimeType); |
|
2735 CleanupStack::PopAndDestroy(pParser); |
|
2736 Teardown(); |
|
2737 return KErrNone; |
|
2738 } |
|
2739 /* |
|
2740 #if defined( __SERIES60_31__ ) || (!defined( __SERIES60_30__ ) && defined( SYMBIAN_SWI_POST_INSTALL_REVOCATION) ) |
|
2741 |
|
2742 TInt CSenFragmentBCTest::MT_CSenParser_NewL_3L(TTestResult& aResult) |
|
2743 { |
|
2744 SetupL(); |
|
2745 _LIT8(KXmlParserMimeType, "text/xml"); |
|
2746 CMatchData* pMatchData = CMatchData::NewLC(); |
|
2747 pMatchData->SetMimeTypeL(KXmlParserMimeType); |
|
2748 CSenParser* pParser = CSenParser::NewL(*pMatchData); |
|
2749 delete pParser; |
|
2750 CleanupStack::PopAndDestroy(pMatchData); |
|
2751 Teardown(); |
|
2752 return KErrNone; |
|
2753 } |
|
2754 |
|
2755 TInt CSenFragmentBCTest::MT_CSenParser_NewLC_3L(TTestResult& aResult) |
|
2756 { |
|
2757 SetupL(); |
|
2758 _LIT8(KXmlParserMimeType, "text/xml"); |
|
2759 CMatchData* pMatchData = CMatchData::NewLC(); |
|
2760 pMatchData->SetMimeTypeL(KXmlParserMimeType); |
|
2761 CSenParser* pParser = CSenParser::NewLC(*pMatchData); |
|
2762 CleanupStack::PopAndDestroy(pParser); |
|
2763 CleanupStack::PopAndDestroy(pMatchData); |
|
2764 Teardown(); |
|
2765 return KErrNone; |
|
2766 } |
|
2767 |
|
2768 #endif |
|
2769 |
|
2770 */ |
|
2771 TInt CSenFragmentBCTest::MT_RSenDocument_NewLL(TTestResult& aResult) |
|
2772 { |
|
2773 SetupL(); |
|
2774 RSenDocument document = RSenDocument::NewL(); |
|
2775 document.Close(); |
|
2776 if(!( document.IsNull() )) return KErrArgument; |
|
2777 Teardown(); |
|
2778 return KErrNone; |
|
2779 } |
|
2780 |
|
2781 |
|
2782 TInt CSenFragmentBCTest::MT_RSenDocument_NewLCL(TTestResult& aResult) |
|
2783 { |
|
2784 SetupL(); |
|
2785 RSenDocument document = RSenDocument::NewLC(); |
|
2786 CleanupStack::PopAndDestroy(); |
|
2787 |
|
2788 // Can't use IsNull() function because iInternal pointer |
|
2789 // (of document) is not NULLed. Only data for which iInternal |
|
2790 // points to is deleted. |
|
2791 //EUNIT_ASSERT( document.IsNull() ); |
|
2792 Teardown(); |
|
2793 return KErrNone; |
|
2794 } |
|
2795 |
|
2796 TInt CSenFragmentBCTest::MT_RSenDocument_NewL_1L(TTestResult& aResult) |
|
2797 { |
|
2798 SetupL(); |
|
2799 // Can't test RSenDocument::NewL(void* aInternal) |
|
2800 // because there is no way to get proper aInternal |
|
2801 // using public API. |
|
2802 if(!( ETrue )) return KErrArgument; |
|
2803 Teardown(); |
|
2804 return KErrNone; |
|
2805 } |
|
2806 |
|
2807 TInt CSenFragmentBCTest::MT_RSenDocument_NewLC_1L(TTestResult& aResult) |
|
2808 { |
|
2809 SetupL(); |
|
2810 // Can't test RSenDocument::NewLC(void* aInternal) |
|
2811 // because there is no way to get proper aInternal |
|
2812 // using public API. |
|
2813 if(!( ETrue )) return KErrArgument; |
|
2814 Teardown(); |
|
2815 return KErrNone; |
|
2816 } |
|
2817 |
|
2818 TInt CSenFragmentBCTest::MT_RSenDocument_CopyL(TTestResult& aResult) |
|
2819 { |
|
2820 SetupL(); |
|
2821 RSenDocument document1 = RSenDocument::NewL(); |
|
2822 TXmlEngElement element = document1.CreateDocumentElementL(_L8("Test")); |
|
2823 |
|
2824 element.AddTextL(_L8("testcontent")); |
|
2825 |
|
2826 RSenDocument document2 = document1.Copy(); |
|
2827 |
|
2828 // Check that main elements of document1 and document2 |
|
2829 // are pointing to the same "in memory node" after copying. |
|
2830 if(!( element.IsSameNode(document2.DocumentElement()) )) return KErrArgument; |
|
2831 |
|
2832 // Test that document2 contains the same data as document1 |
|
2833 // did contain before closing document1. |
|
2834 document1.Close(); |
|
2835 RBuf8 asXml; |
|
2836 TXmlEngSerializationOptions options; |
|
2837 options.iOptions = options.iOptions | |
|
2838 TXmlEngSerializationOptions::KOptionOmitXMLDeclaration; |
|
2839 document2.SaveL(asXml, element, options); |
|
2840 CleanupClosePushL(asXml); |
|
2841 if(!( asXml == _L8("<Test>testcontent</Test>") )) return KErrArgument; |
|
2842 CleanupStack::PopAndDestroy(&asXml); |
|
2843 |
|
2844 document2.Close(); |
|
2845 if(!( document1.IsNull() && document2.IsNull() )) return KErrArgument; |
|
2846 Teardown(); |
|
2847 return KErrNone; |
|
2848 } |
|
2849 |
|
2850 TInt CSenFragmentBCTest::MT_RSenDocument_CloseL(TTestResult& aResult) |
|
2851 { |
|
2852 SetupL(); |
|
2853 RSenDocument document = RSenDocument::NewL(); |
|
2854 document.Close(); |
|
2855 if(!( document.IsNull() )) return KErrArgument; |
|
2856 Teardown(); |
|
2857 return KErrNone; |
|
2858 } |
|
2859 |
|
2860 TInt CSenFragmentBCTest::MT_RSenDocument_DestroyL(TTestResult& aResult) |
|
2861 { |
|
2862 SetupL(); |
|
2863 RSenDocument document = RSenDocument::NewL(); |
|
2864 document.Destroy(); |
|
2865 if(!( document.IsNull() )) return KErrArgument; |
|
2866 Teardown(); |
|
2867 return KErrNone; |
|
2868 } |
|
2869 |
|
2870 TInt CSenFragmentBCTest::MT_RSenDocument_ManualXmlEngineTlsAttachLL(TTestResult& aResult) |
|
2871 { |
|
2872 SetupL(); |
|
2873 RSenDocument document = RSenDocument::NewL(); |
|
2874 TInt retVal = document.ManualXmlEngineTlsAttachL(); |
|
2875 TL(retVal == KErrNone || retVal == KErrUnknown || retVal == KErrAlreadyExists); |
|
2876 Teardown(); |
|
2877 return KErrNone; |
|
2878 } |
|
2879 |
|
2880 TInt CSenFragmentBCTest::MT_RSenDocument_ManualXmlEngineTlsCleanupL(TTestResult& aResult) |
|
2881 { |
|
2882 SetupL(); |
|
2883 RSenDocument document = RSenDocument::NewL(); |
|
2884 TInt retVal = document.ManualXmlEngineTlsCleanup(); |
|
2885 TL(retVal == KErrNone || retVal == KErrNotFound ); |
|
2886 Teardown(); |
|
2887 return KErrNone; |
|
2888 } |
|
2889 |
|
2890 |
|
2891 TInt CSenFragmentBCTest::MT_TestFragmentBase_SetContentLL(TTestResult& aResult) |
|
2892 { |
|
2893 SetupL(); |
|
2894 CTestFragmentBase* pFragment = CTestFragmentBase::NewL(_L8("Test")); |
|
2895 pFragment->SetContentL(_L8("Test")); |
|
2896 Teardown(); |
|
2897 return KErrNone; |
|
2898 } |
|
2899 |
|
2900 |
|
2901 TInt CSenFragmentBCTest::MT_TestFragmentBase_AddContentLL(TTestResult& aResult) |
|
2902 { |
|
2903 SetupL(); |
|
2904 CTestFragmentBase* pFragment = CTestFragmentBase::NewL(_L8("Test")); |
|
2905 pFragment->AddContentL(_L8("Test")); |
|
2906 Teardown(); |
|
2907 return KErrNone; |
|
2908 } |
|
2909 |
|
2910 |
|
2911 TInt CSenFragmentBCTest::MT_TestDomFragmentBase_SetContentOfLL(TTestResult& aResult) |
|
2912 { |
|
2913 SetupL(); |
|
2914 _LIT8(KText, "Test1"); |
|
2915 CTestDomFragmentBase* pFragment = CTestDomFragmentBase::NewL(_L8("Test")); |
|
2916 pFragment->SetContentOfL(_L8("Test"), _L8("Test1")); |
|
2917 TPtrC8 ptr = pFragment->ContentOf(_L8("Test")); |
|
2918 TL(ptr == KText); |
|
2919 Teardown(); |
|
2920 return KErrNone; |
|
2921 } |
|
2922 /* |
|
2923 TInt CSenFragmentBCTest::MT_TestDomFragmentBase_ContentOfL(TTestResult& aResult) |
|
2924 { |
|
2925 SetupL(); |
|
2926 Teardown(); |
|
2927 return KErrNone; |
|
2928 } |
|
2929 |
|
2930 */ |
|
2931 |
|
2932 // End of File |