0
|
1 |
// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
2 |
// All rights reserved.
|
|
3 |
// This component and the accompanying materials are made available
|
|
4 |
// under the terms of the License "Eclipse Public License v1.0"
|
|
5 |
// which accompanies this distribution, and is available
|
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
//
|
|
15 |
|
|
16 |
#include <e32test.h>
|
|
17 |
#include <e32des8.h>
|
|
18 |
|
|
19 |
LOCAL_D RTest test(_L("T_CP932.exe"));
|
|
20 |
|
|
21 |
_LIT16(Uni_1, "\x0053\x0059\x004D\x3125\x6349\xAAAA\x9673\x9ED1\x3000\xFF9F");
|
|
22 |
_LIT8(CP932_1, "\x53\x59\x4D\x5F\x91\xA8\x5F\x92\xC2\xEE\xEC\x81\x40\xDF");
|
|
23 |
_LIT16(Uni_2, "\x0032\x0070\xFFFD\xFF61\x8D77\xFFFD\xFFFD");
|
|
24 |
_LIT8(CP932_2, "\x32\x70\x80\xA1\x8B\x4E\xA0\x96\x7F");
|
|
25 |
_LIT16(Uni_3, "\x4E00\x5141\x674F\x95C7\x58F1");
|
|
26 |
_LIT8(CP932_3, "\x88\xEA\x88\xF2\x88\xC7\x88\xC5\x88\xEB");
|
|
27 |
|
|
28 |
_LIT(KName,"CP932");
|
|
29 |
const TUid KPluginUid={0x10206A92};
|
|
30 |
|
|
31 |
|
|
32 |
// Used for supressing warning in OOM tests
|
|
33 |
#define __UNUSED_VAR(var) var = var
|
|
34 |
|
|
35 |
/**
|
|
36 |
@SYMTestCaseID SYSLIB-FATCHARSETCONV-CT-1779
|
|
37 |
@SYMTestCaseDesc Tests API behaviours of UnicodeConv class
|
|
38 |
@SYMTestPriority High
|
|
39 |
@SYMTestActions Tests for conversions from/to Unicode, using a function pointer
|
|
40 |
@SYMTestExpectedResults Test must not fail
|
|
41 |
*/void Test()
|
|
42 |
{
|
|
43 |
test.Next(_L(" @SYMTestCaseID:SYSLIB-FATCHARSETCONV-CT-1779 "));
|
|
44 |
RLibrary lib;
|
|
45 |
|
|
46 |
const TUidType serverUid(KNullUid,KNullUid,KPluginUid);
|
|
47 |
// load the dll
|
|
48 |
TInt returnValue = lib.Load(KName,serverUid);
|
|
49 |
test(returnValue==0);
|
|
50 |
|
|
51 |
// get a pointer to the specified ordinal function and call it
|
|
52 |
TLibraryFunction function1 = lib.Lookup(1);
|
|
53 |
TLibraryFunction function2 = lib.Lookup(2);
|
|
54 |
TLibraryFunction function3 = lib.Lookup(3);
|
|
55 |
|
|
56 |
//cast the function pointer f to a function of type void with two arguments
|
|
57 |
typedef void (*TConvertFromUnicodeL)(TDes8&, const TDesC16&);
|
|
58 |
TConvertFromUnicodeL aConvertFromUnicodeL = reinterpret_cast <TConvertFromUnicodeL> (function1);
|
|
59 |
|
|
60 |
typedef void (*TConvertToUnicodeL)(TDes16&, const TDesC8&);
|
|
61 |
TConvertToUnicodeL aConvertToUnicodeL = reinterpret_cast <TConvertToUnicodeL> (function2);
|
|
62 |
|
|
63 |
typedef TBool (*TIsLegalShortNameCharacter)(TUint);
|
|
64 |
TIsLegalShortNameCharacter aIsLegalShortNameCharacter = reinterpret_cast <TIsLegalShortNameCharacter> (function3);
|
|
65 |
|
|
66 |
|
|
67 |
TBuf8<15> foreign1;
|
|
68 |
TBuf8<15> foreign3;
|
|
69 |
TBuf16<15> unicode2;
|
|
70 |
|
|
71 |
const TDesC16& unicode1(Uni_1);
|
|
72 |
(*aConvertFromUnicodeL)(foreign1, unicode1); //testing conversion from Unicode
|
|
73 |
TInt error = foreign1.Compare(CP932_1);
|
|
74 |
test(error==0);
|
|
75 |
foreign1.Zero();
|
|
76 |
|
|
77 |
const TDesC16& unicode3(Uni_3);
|
|
78 |
(*aConvertFromUnicodeL)(foreign3, unicode3); //testing conversion from Unicode for INC112715
|
|
79 |
error = foreign3.Compare(CP932_3);
|
|
80 |
test(error==0);
|
|
81 |
foreign3.Zero();
|
|
82 |
|
|
83 |
const TDesC8& foreign2(CP932_2);
|
|
84 |
(*aConvertToUnicodeL)(unicode2,foreign2); //testing conversion to Unicode
|
|
85 |
error = unicode2.Compare(Uni_2);
|
|
86 |
test(error==0);
|
|
87 |
unicode2.Zero();
|
|
88 |
|
|
89 |
|
|
90 |
//testing for legal short name character
|
|
91 |
TInt result = (*aIsLegalShortNameCharacter)(0x005F); //testing for existent character
|
|
92 |
test(result==1);
|
|
93 |
result = (*aIsLegalShortNameCharacter)(0x003F); //testing for illegal character
|
|
94 |
test(result==0);
|
|
95 |
result = (*aIsLegalShortNameCharacter)(0x2999); //testing for non-existent character
|
|
96 |
test(result==0);
|
|
97 |
result = (*aIsLegalShortNameCharacter)(0xFF61); //testing for a double byte character
|
|
98 |
test(result==1);
|
|
99 |
|
|
100 |
lib.Close();
|
|
101 |
}
|
|
102 |
|
|
103 |
/**
|
|
104 |
@SYMTestCaseID SYSLIB-FATCHARSETCONV-CT-1847
|
|
105 |
@SYMTestCaseDesc Tests API behaviours of UnicodeConv class as part of INC090073
|
|
106 |
@SYMTestPriority High
|
|
107 |
@SYMTestActions Tests for correct character conversion on certain chinese characters
|
|
108 |
@SYMTestExpectedResults Test must not fail
|
|
109 |
*/
|
|
110 |
void TestINC090073()
|
|
111 |
{
|
|
112 |
test.Next(_L(" @SYMTestCaseID:SYSLIB-FATCHARSETCONV-CT-1847 "));
|
|
113 |
_LIT16(unicode, "\x6DFC\x715C\x9785\x7A37\x61A9\x80B1\x86A3\x7B71\x6615\x6600");
|
|
114 |
_LIT8(CP932Code, "\xED\xE6\xED\xF6\xE8\xD7\xE2\x6C\x8C\x65\x8D\x6E\xE5\x6E\xE2\xAA\xED\xB3\xED\xB2");
|
|
115 |
|
|
116 |
RLibrary lib;
|
|
117 |
|
|
118 |
const TUidType serverUid(KNullUid,KNullUid,KPluginUid);
|
|
119 |
// load the dll
|
|
120 |
TInt returnValue = lib.Load(KName,serverUid);
|
|
121 |
test(returnValue==0);
|
|
122 |
|
|
123 |
// get a pointer to the specified ordinal function and call it
|
|
124 |
TLibraryFunction function1 = lib.Lookup(1);
|
|
125 |
|
|
126 |
|
|
127 |
//cast the function pointer f to a function of type void with two arguments
|
|
128 |
typedef void (*TConvertFromUnicodeL)(TDes8&, const TDesC16&);
|
|
129 |
TConvertFromUnicodeL aConvertFromUnicodeL = reinterpret_cast <TConvertFromUnicodeL> (function1);
|
|
130 |
|
|
131 |
TBuf8<20> foreign1;
|
|
132 |
|
|
133 |
const TDesC16& unicode1(unicode);
|
|
134 |
(*aConvertFromUnicodeL)(foreign1, unicode1); //testing conversion from Unicode
|
|
135 |
TInt error = foreign1.Compare(CP932Code);
|
|
136 |
test(error==0);
|
|
137 |
foreign1.Zero();
|
|
138 |
|
|
139 |
lib.Close();
|
|
140 |
}
|
|
141 |
|
|
142 |
void OOMTest()
|
|
143 |
{
|
|
144 |
test.Next(_L("OOM testing"));
|
|
145 |
TInt err, tryCount = 0;
|
|
146 |
do
|
|
147 |
{
|
|
148 |
__UHEAP_MARK;
|
|
149 |
// find out the number of open handles
|
|
150 |
TInt startProcessHandleCount;
|
|
151 |
TInt startThreadHandleCount;
|
|
152 |
RThread().HandleCount(startProcessHandleCount, startThreadHandleCount);
|
|
153 |
|
|
154 |
// Setting Heap failure for OOM test
|
|
155 |
__UHEAP_SETFAIL(RHeap::EDeterministic, ++tryCount);
|
|
156 |
|
|
157 |
TRAP(err,Test());
|
|
158 |
|
|
159 |
__UHEAP_SETFAIL(RHeap::ENone, 0);
|
|
160 |
|
|
161 |
// check that no handles have leaked
|
|
162 |
TInt endProcessHandleCount;
|
|
163 |
TInt endThreadHandleCount;
|
|
164 |
RThread().HandleCount(endProcessHandleCount, endThreadHandleCount);
|
|
165 |
|
|
166 |
test(startProcessHandleCount == endProcessHandleCount);
|
|
167 |
test(startThreadHandleCount == endThreadHandleCount);
|
|
168 |
|
|
169 |
__UHEAP_MARKEND;
|
|
170 |
}while (err == KErrNoMemory);
|
|
171 |
|
|
172 |
test(err == KErrNone);
|
|
173 |
test.Printf(_L("- server succeeded at heap failure rate of %i\n"), tryCount);
|
|
174 |
}
|
|
175 |
|
|
176 |
|
|
177 |
LOCAL_C void DoE32MainL()
|
|
178 |
{
|
|
179 |
__UHEAP_MARK;
|
|
180 |
|
|
181 |
Test();
|
|
182 |
TestINC090073();
|
|
183 |
OOMTest();
|
|
184 |
|
|
185 |
__UHEAP_MARKEND;
|
|
186 |
}
|
|
187 |
|
|
188 |
GLDEF_C TInt E32Main()
|
|
189 |
{
|
|
190 |
__UHEAP_MARK;
|
|
191 |
|
|
192 |
test.Title();
|
|
193 |
test.Start(_L("CP932 test..."));
|
|
194 |
|
|
195 |
CTrapCleanup* trapCleanup=CTrapCleanup::New();
|
|
196 |
TRAPD(error, DoE32MainL());
|
|
197 |
test(error==KErrNone);
|
|
198 |
|
|
199 |
delete trapCleanup;
|
|
200 |
|
|
201 |
test.End();
|
|
202 |
test.Close();
|
|
203 |
|
|
204 |
__UHEAP_MARKEND;
|
|
205 |
return error;
|
|
206 |
}
|