|
1 /* |
|
2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "TestContentHandler.h" |
|
19 #include "XMLOutputContentHandler.h" |
|
20 #include "xmlengtester.h" |
|
21 |
|
22 #include <e32svr.h> |
|
23 #include <domain/osextensions/StifParser.h> |
|
24 #include <domain/osextensions/Stiftestinterface.h> |
|
25 |
|
26 #include <Xml\Parser.h> |
|
27 #include <Xml\ParserFeature.h> |
|
28 |
|
29 #include <libc\string.h> |
|
30 #include <charconv.h> |
|
31 #include <UTF.H> |
|
32 #include <XmlEngutils.h> |
|
33 using namespace Xml; |
|
34 |
|
35 /************************************** Utils **************************************/ |
|
36 |
|
37 // ----------------------------------------------------------------------------- |
|
38 // CLibxml2Tester::UtilsEscapeForXmlValueL |
|
39 // test method function. |
|
40 // (other items were commented in a header). |
|
41 // ----------------------------------------------------------------------------- |
|
42 // |
|
43 TInt CLibxml2Tester::UtilsEscapeForXmlValueL( CStifItemParser& /*aItem*/ ) |
|
44 { |
|
45 _LIT(KFunctionError,"Error in fuction: EscapeForXmlValueL."); |
|
46 _LIT(KEscapeSuc,"Function use succesfull."); |
|
47 |
|
48 const char * tekst = "Test < & > text."; |
|
49 const char * tekst3 = "Test < & > text."; |
|
50 |
|
51 char *tekst2 = XmlEngEscapeForXmlValueL(tekst); |
|
52 |
|
53 if (this->CompareChars(tekst2,tekst3)) |
|
54 { |
|
55 TestModuleIf().Printf( infoNum++,KTEST_NAME, KEscapeSuc); |
|
56 iLog->Log((TDesC)KEscapeSuc); |
|
57 } |
|
58 else |
|
59 { |
|
60 TestModuleIf().Printf( infoNum++,KTEST_NAME, KFunctionError); |
|
61 iLog->Log((TDesC)KFunctionError); |
|
62 return KErrGeneral; |
|
63 } |
|
64 |
|
65 return KErrNone; |
|
66 |
|
67 } |
|
68 |
|
69 // ----------------------------------------------------------------------------- |
|
70 // CLibxml2Tester::UtilsXmlCharFromDesL |
|
71 // test method function. |
|
72 // (other items were commented in a header). |
|
73 // ----------------------------------------------------------------------------- |
|
74 // |
|
75 TInt CLibxml2Tester::UtilsXmlCharFromDesL( CStifItemParser& /*aItem*/ ) |
|
76 { |
|
77 _LIT(KFunctionError,"Error in fuction: XmlCharFromDesL."); |
|
78 _LIT(KEscapeSuc,"Function use succesfull."); |
|
79 _LIT(KText, "Test Data"); |
|
80 |
|
81 TBufC<10> buf ( KText ); |
|
82 TPtrC desc = buf.Des(); |
|
83 |
|
84 char * tekst = XmlEngXmlCharFromDesL(desc); |
|
85 |
|
86 TBuf8<10> desc8; |
|
87 CnvUtfConverter::ConvertFromUnicodeToUtf8(desc8,desc); |
|
88 |
|
89 if (this->CompareDescAndChar(tekst,desc8)) |
|
90 { |
|
91 TestModuleIf().Printf( infoNum++,KTEST_NAME, KEscapeSuc); |
|
92 iLog->Log((TDesC)KEscapeSuc); |
|
93 } |
|
94 else |
|
95 { |
|
96 TestModuleIf().Printf( infoNum++,KTEST_NAME, KFunctionError); |
|
97 iLog->Log((TDesC)KFunctionError); |
|
98 return KErrGeneral; |
|
99 } |
|
100 |
|
101 return KErrNone; |
|
102 |
|
103 } |
|
104 |
|
105 // ----------------------------------------------------------------------------- |
|
106 // CLibxml2Tester::UtilsXmlCharFromDes8L |
|
107 // test method function. |
|
108 // (other items were commented in a header). |
|
109 // ----------------------------------------------------------------------------- |
|
110 // |
|
111 TInt CLibxml2Tester::UtilsXmlCharFromDes8L( CStifItemParser& /*aItem*/ ) |
|
112 { |
|
113 _LIT(KFunctionError,"Error in fuction: XmlCharFromDesL."); |
|
114 _LIT(KEscapeSuc,"Function use succesfull."); |
|
115 _LIT8(KText, "Test Data"); |
|
116 |
|
117 TBufC8<10> buf ( KText ); |
|
118 TPtrC8 desc = buf.Des(); |
|
119 |
|
120 char * tekst = XmlEngXmlCharFromDes8L(desc); |
|
121 |
|
122 if (this->CompareDescAndChar(tekst,desc)) |
|
123 { |
|
124 TestModuleIf().Printf( infoNum++,KTEST_NAME, KEscapeSuc); |
|
125 iLog->Log((TDesC)KEscapeSuc); |
|
126 } |
|
127 else |
|
128 { |
|
129 TestModuleIf().Printf( infoNum++,KTEST_NAME, KFunctionError); |
|
130 iLog->Log((TDesC)KFunctionError); |
|
131 return KErrGeneral; |
|
132 } |
|
133 |
|
134 return KErrNone; |
|
135 |
|
136 } |