author | John Imhofe <john.imhofe@nokia.com> |
Mon, 21 Dec 2009 16:14:42 +0000 | |
changeset 2 | 4122176ea935 |
parent 0 | a41df078684a |
permissions | -rw-r--r-- |
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
0
diff
changeset
|
1 |
/* |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
0
diff
changeset
|
2 |
* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
0
diff
changeset
|
3 |
* All rights reserved. |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
0
diff
changeset
|
4 |
* This component and the accompanying materials are made available |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
0
diff
changeset
|
5 |
* under the terms of "Eclipse Public License v1.0" |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
0
diff
changeset
|
6 |
* which accompanies this distribution, and is available |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
0
diff
changeset
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
0
diff
changeset
|
8 |
* |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
0
diff
changeset
|
9 |
* Initial Contributors: |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
0
diff
changeset
|
10 |
* Nokia Corporation - initial contribution. |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
0
diff
changeset
|
11 |
* |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
0
diff
changeset
|
12 |
* Contributors: |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
0
diff
changeset
|
13 |
* |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
0
diff
changeset
|
14 |
* Description: |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
0
diff
changeset
|
15 |
* |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
0
diff
changeset
|
16 |
*/ |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
0
diff
changeset
|
17 |
|
0 | 18 |
|
19 |
#include <e32test.h> |
|
20 |
#include <e32des8.h> |
|
21 |
||
22 |
LOCAL_D RTest test(_L("T_CP936.exe")); |
|
23 |
||
24 |
_LIT16(Uni_1, "\x0053\x0059\x004D\x3125\x312F\x3122\xFFFF\x9673\xFA29"); |
|
25 |
_LIT8(CP936_1, "\x53\x59\x4D\xA8\xE5\x5F\xA8\xE2\x5F\xEA\x90\xFE\x4F"); |
|
26 |
_LIT16(Uni_2, "\x0032\x20AC\xFFFD\xFFFD\x7FB1"); |
|
27 |
_LIT8(CP936_2, "\x32\x80\xA1\x70\xC1\x7F\xC1\x7E"); |
|
28 |
||
29 |
_LIT(KName,"CP936"); |
|
30 |
const TUid KPluginUid={0x10206A91}; |
|
31 |
||
32 |
||
33 |
// Used for supressing warning in OOM tests |
|
34 |
#define __UNUSED_VAR(var) var = var |
|
35 |
||
36 |
/** |
|
37 |
@SYMTestCaseID SYSLIB-FATCHARSETCONV-CT-1778 |
|
38 |
@SYMTestCaseDesc Tests API behaviours of UnicodeConv class |
|
39 |
@SYMTestPriority High |
|
40 |
@SYMTestActions Tests for conversions from/to Unicode, using a function pointer |
|
41 |
@SYMTestExpectedResults Test must not fail |
|
42 |
*/ |
|
43 |
void Test() |
|
44 |
{ |
|
45 |
test.Next(_L(" @SYMTestCaseID:SYSLIB-FATCHARSETCONV-CT-1778 ")); |
|
46 |
RLibrary lib; |
|
47 |
||
48 |
const TUidType serverUid(KNullUid,KNullUid,KPluginUid); |
|
49 |
// load the dll |
|
50 |
TInt returnValue = lib.Load(KName,serverUid); |
|
51 |
test(returnValue==0); |
|
52 |
||
53 |
// get a pointer to the specified ordinal function and call it |
|
54 |
TLibraryFunction function1 = lib.Lookup(1); |
|
55 |
TLibraryFunction function2 = lib.Lookup(2); |
|
56 |
TLibraryFunction function3 = lib.Lookup(3); |
|
57 |
||
58 |
//cast the function pointer f to a function of type void with two arguments |
|
59 |
typedef void (*TConvertFromUnicodeL)(TDes8&, const TDesC16&); |
|
60 |
TConvertFromUnicodeL aConvertFromUnicodeL = reinterpret_cast <TConvertFromUnicodeL> (function1); |
|
61 |
||
62 |
typedef void (*TConvertToUnicodeL)(TDes16&, const TDesC8&); |
|
63 |
TConvertToUnicodeL aConvertToUnicodeL = reinterpret_cast <TConvertToUnicodeL> (function2); |
|
64 |
||
65 |
typedef TBool (*TIsLegalShortNameCharacter)(TUint); |
|
66 |
TIsLegalShortNameCharacter aIsLegalShortNameCharacter = reinterpret_cast <TIsLegalShortNameCharacter> (function3); |
|
67 |
||
68 |
||
69 |
TBuf8<20> foreign1; |
|
70 |
TBuf16<20> unicode2; |
|
71 |
||
72 |
const TDesC16& unicode1(Uni_1); |
|
73 |
(*aConvertFromUnicodeL)(foreign1, unicode1); //testing conversion from Unicode |
|
74 |
TInt error = foreign1.Compare(CP936_1); |
|
75 |
test(error==0); |
|
76 |
foreign1.Zero(); |
|
77 |
||
78 |
const TDesC8& foreign2(CP936_2); |
|
79 |
(*aConvertToUnicodeL)(unicode2,foreign2); //testing conversion to Unicode |
|
80 |
error = unicode2.Compare(Uni_2); |
|
81 |
test(error==0); |
|
82 |
unicode2.Zero(); |
|
83 |
||
84 |
||
85 |
//testing for legal short name character |
|
86 |
TInt result = (*aIsLegalShortNameCharacter)(0x005F); //testing for existent character |
|
87 |
test(result==1); |
|
88 |
result = (*aIsLegalShortNameCharacter)(0x003F); //testing for illegal character |
|
89 |
test(result==0); |
|
90 |
result = (*aIsLegalShortNameCharacter)(0x2999); //testing for non-existent character |
|
91 |
test(result==0); |
|
92 |
result = (*aIsLegalShortNameCharacter)(0x4E02); //testing for a double byte character |
|
93 |
test(result==1); |
|
94 |
||
95 |
lib.Close(); |
|
96 |
} |
|
97 |
||
98 |
/** |
|
99 |
@SYMTestCaseID SYSLIB-FATCHARSETCONV-CT-1847-0001 |
|
100 |
@SYMTestCaseDesc Tests API behaviours of UnicodeConv class as part of INC090073 |
|
101 |
@SYMTestPriority High |
|
102 |
@SYMTestActions Tests for correct character conversion on certain chinese characters for CP936 |
|
103 |
@SYMTestExpectedResults Test must not fail |
|
104 |
*/ |
|
105 |
void TestINC090073() |
|
106 |
{ |
|
107 |
test.Next(_L(" @SYMTestCaseID:SYSLIB-FATCHARSETCONV-CT-1847-0001 ")); |
|
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"); |
|
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"); |
|
110 |
||
111 |
RLibrary lib; |
|
112 |
||
113 |
const TUidType serverUid(KNullUid,KNullUid,KPluginUid); |
|
114 |
// load the dll |
|
115 |
TInt returnValue = lib.Load(KName,serverUid); |
|
116 |
test(returnValue==0); |
|
117 |
||
118 |
// get a pointer to the specified ordinal function and call it |
|
119 |
TLibraryFunction function1 = lib.Lookup(1); |
|
120 |
||
121 |
||
122 |
//cast the function pointer f to a function of type void with two arguments |
|
123 |
typedef void (*TConvertFromUnicodeL)(TDes8&, const TDesC16&); |
|
124 |
TConvertFromUnicodeL aConvertFromUnicodeL = reinterpret_cast <TConvertFromUnicodeL> (function1); |
|
125 |
||
126 |
TBuf8<50> foreign1; |
|
127 |
||
128 |
foreign1.Zero(); |
|
129 |
const TDesC16& unicode1(unicode); |
|
130 |
TRAPD(err,(*aConvertFromUnicodeL)(foreign1, unicode1)); //testing conversion from Unicode |
|
131 |
test(err==0); |
|
132 |
TInt error = foreign1.Compare(CP932Code); |
|
133 |
test(error==0); |
|
134 |
foreign1.Zero(); |
|
135 |
||
136 |
lib.Close(); |
|
137 |
} |
|
138 |
||
139 |
void OOMTest() |
|
140 |
{ |
|
141 |
test.Next(_L("OOM testing")); |
|
142 |
TInt err, tryCount = 0; |
|
143 |
do |
|
144 |
{ |
|
145 |
__UHEAP_MARK; |
|
146 |
// find out the number of open handles |
|
147 |
TInt startProcessHandleCount; |
|
148 |
TInt startThreadHandleCount; |
|
149 |
RThread().HandleCount(startProcessHandleCount, startThreadHandleCount); |
|
150 |
||
151 |
// Setting Heap failure for OOM test |
|
152 |
__UHEAP_SETFAIL(RHeap::EDeterministic, ++tryCount); |
|
153 |
||
154 |
TRAP(err,Test()); |
|
155 |
||
156 |
__UHEAP_SETFAIL(RHeap::ENone, 0); |
|
157 |
||
158 |
// check that no handles have leaked |
|
159 |
TInt endProcessHandleCount; |
|
160 |
TInt endThreadHandleCount; |
|
161 |
RThread().HandleCount(endProcessHandleCount, endThreadHandleCount); |
|
162 |
||
163 |
test(startProcessHandleCount == endProcessHandleCount); |
|
164 |
test(startThreadHandleCount == endThreadHandleCount); |
|
165 |
||
166 |
__UHEAP_MARKEND; |
|
167 |
}while (err == KErrNoMemory); |
|
168 |
||
169 |
test(err == KErrNone); |
|
170 |
test.Printf(_L("- server succeeded at heap failure rate of %i\n"), tryCount); |
|
171 |
} |
|
172 |
||
173 |
||
174 |
LOCAL_C void DoE32MainL() |
|
175 |
{ |
|
176 |
__UHEAP_MARK; |
|
177 |
||
178 |
Test(); |
|
179 |
TestINC090073(); |
|
180 |
OOMTest(); |
|
181 |
||
182 |
__UHEAP_MARKEND; |
|
183 |
} |
|
184 |
||
185 |
GLDEF_C TInt E32Main() |
|
186 |
{ |
|
187 |
__UHEAP_MARK; |
|
188 |
||
189 |
test.Title(); |
|
190 |
test.Start(_L("CP936 test...")); |
|
191 |
||
192 |
CTrapCleanup* trapCleanup=CTrapCleanup::New(); |
|
193 |
TRAPD(error, DoE32MainL()); |
|
194 |
test(error==KErrNone); |
|
195 |
||
196 |
delete trapCleanup; |
|
197 |
||
198 |
test.End(); |
|
199 |
test.Close(); |
|
200 |
||
201 |
__UHEAP_MARKEND; |
|
202 |
return error; |
|
203 |
} |