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 <e32std.h>
|
|
18 |
|
|
19 |
LOCAL_D RTest test(_L("T_CP1250.exe"));
|
|
20 |
|
|
21 |
_LIT16(Uni_1, "\xFFFF\x0053\x0059\x004D\x0042\x0049\x0041\x004E\xAAAA\x20AC\x02C7\x2015");
|
|
22 |
_LIT8(CP1250_1, "\x5F\x53\x59\x4D\x42\x49\x41\x4E\x5F\x80\xA1\x5F");
|
|
23 |
_LIT16(Uni_2, "\x02C7\xFFFD\x00AD");
|
|
24 |
_LIT8(CP1250_2, "\xA1\x98\xAD");
|
|
25 |
|
|
26 |
_LIT(KName,"CP1250");
|
|
27 |
const TUid KPluginUid={0x10206A9C};
|
|
28 |
|
|
29 |
|
|
30 |
// Used for supressing warning in OOM tests
|
|
31 |
#define __UNUSED_VAR(var) var = var
|
|
32 |
|
|
33 |
/**
|
|
34 |
@SYMTestCaseID SYSLIB-FATCHARSETCONV-CT-1789
|
|
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 |
RLibrary lib;
|
|
43 |
|
|
44 |
const TUidType serverUid(KNullUid,KNullUid,KPluginUid);
|
|
45 |
// load the dll
|
|
46 |
TInt returnValue = lib.Load(KName,serverUid);
|
|
47 |
test(returnValue==0);
|
|
48 |
|
|
49 |
// get a pointer to the specified ordinal function and call it
|
|
50 |
TLibraryFunction function1 = lib.Lookup(1);
|
|
51 |
TLibraryFunction function2 = lib.Lookup(2);
|
|
52 |
TLibraryFunction function3 = lib.Lookup(3);
|
|
53 |
|
|
54 |
//cast the function pointer f to a function of type void with two arguments
|
|
55 |
typedef void (*TConvertFromUnicodeL)(TDes8&, const TDesC16&);
|
|
56 |
TConvertFromUnicodeL aConvertFromUnicodeL = reinterpret_cast <TConvertFromUnicodeL> (function1);
|
|
57 |
|
|
58 |
typedef void (*TConvertToUnicodeL)(TDes16&, const TDesC8&);
|
|
59 |
TConvertToUnicodeL aConvertToUnicodeL = reinterpret_cast <TConvertToUnicodeL> (function2);
|
|
60 |
|
|
61 |
typedef TBool (*TIsLegalShortNameCharacter)(TUint);
|
|
62 |
TIsLegalShortNameCharacter aIsLegalShortNameCharacter = reinterpret_cast <TIsLegalShortNameCharacter> (function3);
|
|
63 |
|
|
64 |
|
|
65 |
TBuf8<15> foreign1;
|
|
66 |
TBuf16<15> unicode2;
|
|
67 |
|
|
68 |
const TDesC16& unicode1(Uni_1);
|
|
69 |
(*aConvertFromUnicodeL)(foreign1, unicode1); //testing conversion from Unicode
|
|
70 |
TInt error = foreign1.Compare(CP1250_1);
|
|
71 |
test(error==0);
|
|
72 |
foreign1.Zero();
|
|
73 |
|
|
74 |
const TDesC8& foreign2(CP1250_2);
|
|
75 |
(*aConvertToUnicodeL)(unicode2,foreign2); //testing conversion to Unicode
|
|
76 |
error = unicode2.Compare(Uni_2);
|
|
77 |
test(error==0);
|
|
78 |
unicode2.Zero();
|
|
79 |
|
|
80 |
|
|
81 |
//testing for legal short name character
|
|
82 |
TInt result = (*aIsLegalShortNameCharacter)(0x005F); //testing for existent character
|
|
83 |
test(result==1);
|
|
84 |
result = (*aIsLegalShortNameCharacter)(0x003F); //testing for illegal character
|
|
85 |
test(result==0);
|
|
86 |
result = (*aIsLegalShortNameCharacter)(0x2999); //testing for non-existent character
|
|
87 |
test(result==0);
|
|
88 |
|
|
89 |
//DEF126905 fixing
|
|
90 |
result = (*aIsLegalShortNameCharacter)(0x007f); //testing for legal character
|
|
91 |
test(result==1);
|
|
92 |
result = (*aIsLegalShortNameCharacter)(0x0016); //testing for illegal character
|
|
93 |
test(result==0);
|
|
94 |
|
|
95 |
lib.Close();
|
|
96 |
}
|
|
97 |
|
|
98 |
void OOMTest()
|
|
99 |
{
|
|
100 |
test.Next(_L("OOM testing"));
|
|
101 |
TInt err, tryCount = 0;
|
|
102 |
do
|
|
103 |
{
|
|
104 |
__UHEAP_MARK;
|
|
105 |
// find out the number of open handles
|
|
106 |
TInt startProcessHandleCount;
|
|
107 |
TInt startThreadHandleCount;
|
|
108 |
RThread().HandleCount(startProcessHandleCount, startThreadHandleCount);
|
|
109 |
|
|
110 |
// Setting Heap failure for OOM test
|
|
111 |
__UHEAP_SETFAIL(RHeap::EDeterministic, ++tryCount);
|
|
112 |
|
|
113 |
TRAP(err,Test());
|
|
114 |
|
|
115 |
__UHEAP_SETFAIL(RHeap::ENone, 0);
|
|
116 |
|
|
117 |
// check that no handles have leaked
|
|
118 |
TInt endProcessHandleCount;
|
|
119 |
TInt endThreadHandleCount;
|
|
120 |
RThread().HandleCount(endProcessHandleCount, endThreadHandleCount);
|
|
121 |
|
|
122 |
test(startProcessHandleCount == endProcessHandleCount);
|
|
123 |
test(startThreadHandleCount == endThreadHandleCount);
|
|
124 |
|
|
125 |
__UHEAP_MARKEND;
|
|
126 |
}while (err == KErrNoMemory);
|
|
127 |
|
|
128 |
test(err == KErrNone);
|
|
129 |
test.Printf(_L("- server succeeded at heap failure rate of %i\n"), tryCount);
|
|
130 |
}
|
|
131 |
|
|
132 |
|
|
133 |
LOCAL_C void DoE32MainL()
|
|
134 |
{
|
|
135 |
Test();
|
|
136 |
OOMTest();
|
|
137 |
}
|
|
138 |
|
|
139 |
|
|
140 |
GLDEF_C TInt E32Main()
|
|
141 |
{
|
|
142 |
__UHEAP_MARK;
|
|
143 |
|
|
144 |
test.Title();
|
|
145 |
test.Start(_L(" @SYMTestCaseID:SYSLIB-FATCHARSETCONV-CT-1789 CP1250 tests... "));
|
|
146 |
|
|
147 |
CTrapCleanup* trapCleanup=CTrapCleanup::New();
|
|
148 |
TRAPD(error, DoE32MainL());
|
|
149 |
delete trapCleanup;
|
|
150 |
|
|
151 |
test.End();
|
|
152 |
test.Close();
|
|
153 |
|
|
154 |
__UHEAP_MARKEND;
|
|
155 |
return error;
|
|
156 |
}
|