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_CP949.exe"));
|
|
20 |
|
|
21 |
_LIT16(Uni_1, "\xFFFF\x0053\x0059\x004D\x0042\x0049\x0041\x004E\xAC21\xC6AA\xFFFF\x9673\x8A70");
|
|
22 |
_LIT8(CP949_1, "\x5F\x53\x59\x4D\x42\x49\x41\x4E\x81\x4D\x9F\x42\x5F\xF2\xE7\xFD\xFE");
|
|
23 |
_LIT16(Uni_2, "\xFFFD\x005F\x304A\xFFFD\xFFFD");
|
|
24 |
_LIT8(CP949_2, "\xAA\x40\x5F\xAA\xAA\xFF\xFE");
|
|
25 |
|
|
26 |
_LIT(KName,"CP949");
|
|
27 |
const TUid KPluginUid={0x10206A90};
|
|
28 |
|
|
29 |
|
|
30 |
// Used for supressing warning in OOM tests
|
|
31 |
#define __UNUSED_VAR(var) var = var
|
|
32 |
|
|
33 |
/**
|
|
34 |
@SYMTestCaseID SYSLIB-FATCHARSETCONV-CT-1777
|
|
35 |
@SYMTestCaseDesc Tests API behaviours of UnicodeConv class
|
|
36 |
@SYMTestPriority High
|
|
37 |
@SYMTestActions Tests for conversions from/to Unicode, using a function pointer
|
|
38 |
@SYMTestExpectedResults Test must not fail
|
|
39 |
*/
|
|
40 |
void Test()
|
|
41 |
{
|
|
42 |
test.Next(_L(" @SYMTestCaseID:SYSLIB-FATCHARSETCONV-CT-1777 "));
|
|
43 |
RLibrary lib;
|
|
44 |
|
|
45 |
const TUidType serverUid(KNullUid,KNullUid,KPluginUid);
|
|
46 |
// load the dll
|
|
47 |
TInt returnValue = lib.Load(KName,serverUid);
|
|
48 |
test(returnValue==0);
|
|
49 |
|
|
50 |
// get a pointer to the specified ordinal function and call it
|
|
51 |
TLibraryFunction function1 = lib.Lookup(1);
|
|
52 |
TLibraryFunction function2 = lib.Lookup(2);
|
|
53 |
TLibraryFunction function3 = lib.Lookup(3);
|
|
54 |
|
|
55 |
//cast the function pointer f to a function of type void with two arguments
|
|
56 |
typedef void (*TConvertFromUnicodeL)(TDes8&, const TDesC16&);
|
|
57 |
TConvertFromUnicodeL aConvertFromUnicodeL = reinterpret_cast <TConvertFromUnicodeL> (function1);
|
|
58 |
|
|
59 |
typedef void (*TConvertToUnicodeL)(TDes16&, const TDesC8&);
|
|
60 |
TConvertToUnicodeL aConvertToUnicodeL = reinterpret_cast <TConvertToUnicodeL> (function2);
|
|
61 |
|
|
62 |
typedef TBool (*TIsLegalShortNameCharacter)(TUint);
|
|
63 |
TIsLegalShortNameCharacter aIsLegalShortNameCharacter = reinterpret_cast <TIsLegalShortNameCharacter> (function3);
|
|
64 |
|
|
65 |
|
|
66 |
TBuf8<20> foreign1;
|
|
67 |
TBuf16<15> unicode2;
|
|
68 |
|
|
69 |
const TDesC16& unicode1(Uni_1);
|
|
70 |
TRAPD(err,(*aConvertFromUnicodeL)(foreign1, unicode1)); //testing conversion from Unicode
|
|
71 |
test(err==0);
|
|
72 |
TInt error = foreign1.Compare(CP949_1);
|
|
73 |
test(error==0);
|
|
74 |
foreign1.Zero();
|
|
75 |
|
|
76 |
const TDesC8& foreign2(CP949_2);
|
|
77 |
(*aConvertToUnicodeL)(unicode2,foreign2); //testing conversion to Unicode
|
|
78 |
error = unicode2.Compare(Uni_2);
|
|
79 |
test(error==0);
|
|
80 |
unicode2.Zero();
|
|
81 |
|
|
82 |
|
|
83 |
//testing for legal short name character
|
|
84 |
TInt result = (*aIsLegalShortNameCharacter)(0x005F); //testing for existent character
|
|
85 |
test(result==1);
|
|
86 |
result = (*aIsLegalShortNameCharacter)(0x003F); //testing for illegal character
|
|
87 |
test(result==0);
|
|
88 |
result = (*aIsLegalShortNameCharacter)(0x2999); //testing for non-existent character
|
|
89 |
test(result==0);
|
|
90 |
result = (*aIsLegalShortNameCharacter)(0xAC02); //testing for double byte character
|
|
91 |
test(result==1);
|
|
92 |
|
|
93 |
lib.Close();
|
|
94 |
}
|
|
95 |
|
|
96 |
/**
|
|
97 |
@SYMTestCaseID SYSLIB-FATCHARSETCONV-CT-1847-0002
|
|
98 |
@SYMTestCaseDesc Tests API behaviours of UnicodeConv class as part of INC090073
|
|
99 |
@SYMTestPriority High
|
|
100 |
@SYMTestActions Tests for correct character conversion on certain chinese characters for CP936
|
|
101 |
@SYMTestExpectedResults Test must not fail
|
|
102 |
*/
|
|
103 |
void TestINC090073()
|
|
104 |
{
|
|
105 |
test.Next(_L(" @SYMTestCaseID:SYSLIB-FATCHARSETCONV-CT-1847-0002 "));
|
|
106 |
_LIT16(unicode, "\x715C\x7A37\x61A9\x80B1\x86A3\x6B46\x6615");
|
|
107 |
_LIT8(CP932Code, "\xE9\xF2\xF2\xC3\xCC\xA8\xCE\xDD\xCD\xF7\xFD\xE4\xFD\xDA");
|
|
108 |
|
|
109 |
RLibrary lib;
|
|
110 |
|
|
111 |
const TUidType serverUid(KNullUid,KNullUid,KPluginUid);
|
|
112 |
// load the dll
|
|
113 |
TInt returnValue = lib.Load(KName,serverUid);
|
|
114 |
test(returnValue==0);
|
|
115 |
|
|
116 |
// get a pointer to the specified ordinal function and call it
|
|
117 |
TLibraryFunction function1 = lib.Lookup(1);
|
|
118 |
|
|
119 |
|
|
120 |
//cast the function pointer f to a function of type void with two arguments
|
|
121 |
typedef void (*TConvertFromUnicodeL)(TDes8&, const TDesC16&);
|
|
122 |
TConvertFromUnicodeL aConvertFromUnicodeL = reinterpret_cast <TConvertFromUnicodeL> (function1);
|
|
123 |
|
|
124 |
TBuf8<15> foreign1;
|
|
125 |
|
|
126 |
foreign1.Zero();
|
|
127 |
const TDesC16& unicode1(unicode);
|
|
128 |
TRAPD(err,(*aConvertFromUnicodeL)(foreign1, unicode1)); //testing conversion from Unicode
|
|
129 |
test(err==0);
|
|
130 |
TInt error = foreign1.Compare(CP932Code);
|
|
131 |
test(error==0);
|
|
132 |
foreign1.Zero();
|
|
133 |
|
|
134 |
lib.Close();
|
|
135 |
}
|
|
136 |
|
|
137 |
void OOMTest()
|
|
138 |
{
|
|
139 |
test.Next(_L("OOM testing"));
|
|
140 |
TInt err, tryCount = 0;
|
|
141 |
do
|
|
142 |
{
|
|
143 |
__UHEAP_MARK;
|
|
144 |
// find out the number of open handles
|
|
145 |
TInt startProcessHandleCount;
|
|
146 |
TInt startThreadHandleCount;
|
|
147 |
RThread().HandleCount(startProcessHandleCount, startThreadHandleCount);
|
|
148 |
|
|
149 |
// Setting Heap failure for OOM test
|
|
150 |
__UHEAP_SETFAIL(RHeap::EDeterministic, ++tryCount);
|
|
151 |
|
|
152 |
TRAP(err,Test());
|
|
153 |
|
|
154 |
__UHEAP_SETFAIL(RHeap::ENone, 0);
|
|
155 |
|
|
156 |
// check that no handles have leaked
|
|
157 |
TInt endProcessHandleCount;
|
|
158 |
TInt endThreadHandleCount;
|
|
159 |
RThread().HandleCount(endProcessHandleCount, endThreadHandleCount);
|
|
160 |
|
|
161 |
test(startProcessHandleCount == endProcessHandleCount);
|
|
162 |
test(startThreadHandleCount == endThreadHandleCount);
|
|
163 |
|
|
164 |
__UHEAP_MARKEND;
|
|
165 |
}while (err == KErrNoMemory);
|
|
166 |
|
|
167 |
test(err == KErrNone);
|
|
168 |
test.Printf(_L("- server succeeded at heap failure rate of %i\n"), tryCount);
|
|
169 |
}
|
|
170 |
|
|
171 |
|
|
172 |
LOCAL_C void DoE32MainL()
|
|
173 |
{
|
|
174 |
__UHEAP_MARK;
|
|
175 |
|
|
176 |
Test();
|
|
177 |
TestINC090073();
|
|
178 |
OOMTest();
|
|
179 |
|
|
180 |
__UHEAP_MARKEND;
|
|
181 |
}
|
|
182 |
|
|
183 |
GLDEF_C TInt E32Main()
|
|
184 |
{
|
|
185 |
__UHEAP_MARK;
|
|
186 |
|
|
187 |
test.Title();
|
|
188 |
test.Start(_L("CP949 test..."));
|
|
189 |
|
|
190 |
CTrapCleanup* trapCleanup=CTrapCleanup::New();
|
|
191 |
TRAPD(error, DoE32MainL());
|
|
192 |
test(error==KErrNone);
|
|
193 |
|
|
194 |
delete trapCleanup;
|
|
195 |
|
|
196 |
test.End();
|
|
197 |
test.Close();
|
|
198 |
|
|
199 |
__UHEAP_MARKEND;
|
|
200 |
return error;
|
|
201 |
}
|