equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
3 * All rights reserved. |
3 * All rights reserved. |
4 * This component and the accompanying materials are made available |
4 * This component and the accompanying materials are made available |
5 * under the terms of "Eclipse Public License v1.0" |
5 * under the terms of "Eclipse Public License v1.0" |
6 * which accompanies this distribution, and is available |
6 * which accompanies this distribution, and is available |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
14 * Description: |
14 * Description: |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 |
18 |
19 #include "T_CP936.h" |
19 #include <e32test.h> |
20 |
20 #include <e32des8.h> |
21 #define test(cond) \ |
21 |
22 { \ |
22 LOCAL_D RTest test(_L("T_CP936.exe")); |
23 TBool __bb = (cond); \ |
|
24 TEST(__bb); \ |
|
25 if (!__bb) \ |
|
26 { \ |
|
27 ERR_PRINTF1(_L("ERROR: Test Failed")); \ |
|
28 User::Leave(1); \ |
|
29 } \ |
|
30 } |
|
31 |
23 |
32 _LIT16(Uni_1, "\x0053\x0059\x004D\x3125\x312F\x3122\xFFFF\x9673\xFA29"); |
24 _LIT16(Uni_1, "\x0053\x0059\x004D\x3125\x312F\x3122\xFFFF\x9673\xFA29"); |
33 _LIT8(CP936_1, "\x53\x59\x4D\xA8\xE5\x5F\xA8\xE2\x5F\xEA\x90\xFE\x4F"); |
25 _LIT8(CP936_1, "\x53\x59\x4D\xA8\xE5\x5F\xA8\xE2\x5F\xEA\x90\xFE\x4F"); |
34 _LIT16(Uni_2, "\x0032\x20AC\xFFFD\xFFFD\x7FB1"); |
26 _LIT16(Uni_2, "\x0032\x20AC\xFFFD\xFFFD\x7FB1"); |
35 _LIT8(CP936_2, "\x32\x80\xA1\x70\xC1\x7F\xC1\x7E"); |
27 _LIT8(CP936_2, "\x32\x80\xA1\x70\xC1\x7F\xC1\x7E"); |
46 @SYMTestCaseDesc Tests API behaviours of UnicodeConv class |
38 @SYMTestCaseDesc Tests API behaviours of UnicodeConv class |
47 @SYMTestPriority High |
39 @SYMTestPriority High |
48 @SYMTestActions Tests for conversions from/to Unicode, using a function pointer |
40 @SYMTestActions Tests for conversions from/to Unicode, using a function pointer |
49 @SYMTestExpectedResults Test must not fail |
41 @SYMTestExpectedResults Test must not fail |
50 */ |
42 */ |
51 void CT_CP936::TestL() |
43 void Test() |
52 { |
44 { |
53 INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-FATCHARSETCONV-CT-1778 ")); |
45 test.Next(_L(" @SYMTestCaseID:SYSLIB-FATCHARSETCONV-CT-1778 ")); |
54 |
|
55 RLibrary lib; |
46 RLibrary lib; |
56 |
47 |
57 const TUidType serverUid(KNullUid,KNullUid,KPluginUid); |
48 const TUidType serverUid(KNullUid,KNullUid,KPluginUid); |
58 // load the dll |
49 // load the dll |
59 TInt returnValue = lib.Load(KName,serverUid); |
50 TInt returnValue = lib.Load(KName,serverUid); |
109 @SYMTestCaseDesc Tests API behaviours of UnicodeConv class as part of INC090073 |
100 @SYMTestCaseDesc Tests API behaviours of UnicodeConv class as part of INC090073 |
110 @SYMTestPriority High |
101 @SYMTestPriority High |
111 @SYMTestActions Tests for correct character conversion on certain chinese characters for CP936 |
102 @SYMTestActions Tests for correct character conversion on certain chinese characters for CP936 |
112 @SYMTestExpectedResults Test must not fail |
103 @SYMTestExpectedResults Test must not fail |
113 */ |
104 */ |
114 void CT_CP936::TestINC090073L() |
105 void TestINC090073() |
115 { |
106 { |
116 INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-FATCHARSETCONV-CT-1847-0001 ")); |
107 test.Next(_L(" @SYMTestCaseID:SYSLIB-FATCHARSETCONV-CT-1847-0001 ")); |
117 |
|
118 _LIT16(unicode, "\x7CCD\x74EF\x8026\x8F8F\x94F3\x7633\x6DFC\x9785\x7F81\x7A37\x61A9\x80B1\x86A3\x89E5\x80F2\x9B48\x9E47\x6C19\x7B71\x946B\x6B46\x6615"); |
108 _LIT16(unicode, "\x7CCD\x74EF\x8026\x8F8F\x94F3\x7633\x6DFC\x9785\x7F81\x7A37\x61A9\x80B1\x86A3\x89E5\x80F2\x9B48\x9E47\x6C19\x7B71\x946B\x6B46\x6615"); |
119 _LIT8(CP932Code, "\xF4\xD9\xEA\xB1\xF1\xEE\xEA\xA3\xEF\xA5\xF1\xAC\xED\xB5\xF7\xB1\xEE\xBF\xF0\xA2\xED\xAC\xEB\xC5\xF2\xBC\xF6\xA1\xEB\xDC\xF7\xCC\xF0\xC2\xEB\xAF\xF3\xE3\xF6\xCE\xEC\xA7\xEA\xBF"); |
109 _LIT8(CP932Code, "\xF4\xD9\xEA\xB1\xF1\xEE\xEA\xA3\xEF\xA5\xF1\xAC\xED\xB5\xF7\xB1\xEE\xBF\xF0\xA2\xED\xAC\xEB\xC5\xF2\xBC\xF6\xA1\xEB\xDC\xF7\xCC\xF0\xC2\xEB\xAF\xF3\xE3\xF6\xCE\xEC\xA7\xEA\xBF"); |
120 |
110 |
121 RLibrary lib; |
111 RLibrary lib; |
122 |
112 |
132 //cast the function pointer f to a function of type void with two arguments |
122 //cast the function pointer f to a function of type void with two arguments |
133 typedef void (*TConvertFromUnicodeL)(TDes8&, const TDesC16&); |
123 typedef void (*TConvertFromUnicodeL)(TDes8&, const TDesC16&); |
134 TConvertFromUnicodeL aConvertFromUnicodeL = reinterpret_cast <TConvertFromUnicodeL> (function1); |
124 TConvertFromUnicodeL aConvertFromUnicodeL = reinterpret_cast <TConvertFromUnicodeL> (function1); |
135 |
125 |
136 TBuf8<50> foreign1; |
126 TBuf8<50> foreign1; |
137 |
127 |
138 foreign1.Zero(); |
128 foreign1.Zero(); |
139 const TDesC16& unicode1(unicode); |
129 const TDesC16& unicode1(unicode); |
140 TRAPD(err,(*aConvertFromUnicodeL)(foreign1, unicode1)); //testing conversion from Unicode |
130 TRAPD(err,(*aConvertFromUnicodeL)(foreign1, unicode1)); //testing conversion from Unicode |
141 test(err==0); |
131 test(err==0); |
142 TInt error = foreign1.Compare(CP932Code); |
132 TInt error = foreign1.Compare(CP932Code); |
144 foreign1.Zero(); |
134 foreign1.Zero(); |
145 |
135 |
146 lib.Close(); |
136 lib.Close(); |
147 } |
137 } |
148 |
138 |
149 void CT_CP936::OOMTestL() |
139 void OOMTest() |
150 { |
140 { |
151 INFO_PRINTF1(_L("OOM testing")); |
141 test.Next(_L("OOM testing")); |
152 TInt err, tryCount = 0; |
142 TInt err, tryCount = 0; |
153 do |
143 do |
154 { |
144 { |
155 __UHEAP_MARK; |
145 __UHEAP_MARK; |
156 // find out the number of open handles |
146 // find out the number of open handles |
159 RThread().HandleCount(startProcessHandleCount, startThreadHandleCount); |
149 RThread().HandleCount(startProcessHandleCount, startThreadHandleCount); |
160 |
150 |
161 // Setting Heap failure for OOM test |
151 // Setting Heap failure for OOM test |
162 __UHEAP_SETFAIL(RHeap::EDeterministic, ++tryCount); |
152 __UHEAP_SETFAIL(RHeap::EDeterministic, ++tryCount); |
163 |
153 |
164 TRAP(err,TestL()); |
154 TRAP(err,Test()); |
165 |
155 |
166 __UHEAP_SETFAIL(RHeap::ENone, 0); |
156 __UHEAP_SETFAIL(RHeap::ENone, 0); |
167 |
157 |
168 // check that no handles have leaked |
158 // check that no handles have leaked |
169 TInt endProcessHandleCount; |
159 TInt endProcessHandleCount; |
175 |
165 |
176 __UHEAP_MARKEND; |
166 __UHEAP_MARKEND; |
177 }while (err == KErrNoMemory); |
167 }while (err == KErrNoMemory); |
178 |
168 |
179 test(err == KErrNone); |
169 test(err == KErrNone); |
180 INFO_PRINTF2(_L("- server succeeded at heap failure rate of %i"), tryCount); |
170 test.Printf(_L("- server succeeded at heap failure rate of %i\n"), tryCount); |
181 } |
171 } |
182 |
172 |
183 CT_CP936::CT_CP936() |
173 |
184 { |
174 LOCAL_C void DoE32MainL() |
185 SetTestStepName(KTestStep_T_CP936); |
175 { |
186 } |
176 __UHEAP_MARK; |
187 |
177 |
188 TVerdict CT_CP936::doTestStepL() |
178 Test(); |
189 { |
179 TestINC090073(); |
190 SetTestStepResult(EFail); |
180 OOMTest(); |
191 |
181 |
192 __UHEAP_MARK; |
182 __UHEAP_MARKEND; |
193 |
183 } |
194 TRAPD(error1, TestL()); |
184 |
195 TRAPD(error2, TestINC090073L()); |
185 GLDEF_C TInt E32Main() |
196 TRAPD(error3, OOMTestL()); |
186 { |
197 |
187 __UHEAP_MARK; |
198 __UHEAP_MARKEND; |
188 |
199 |
189 test.Title(); |
200 if(error1 == KErrNone && error2 == KErrNone && error3 == KErrNone) |
190 test.Start(_L("CP936 test...")); |
201 { |
191 |
202 SetTestStepResult(EPass); |
192 CTrapCleanup* trapCleanup=CTrapCleanup::New(); |
203 } |
193 TRAPD(error, DoE32MainL()); |
204 |
194 test(error==KErrNone); |
205 return TestStepResult(); |
195 |
206 } |
196 delete trapCleanup; |
|
197 |
|
198 test.End(); |
|
199 test.Close(); |
|
200 |
|
201 __UHEAP_MARKEND; |
|
202 return error; |
|
203 } |