sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
3 |
* All rights reserved.
|
sl@0
|
4 |
* This component and the accompanying materials are made available
|
sl@0
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
sl@0
|
6 |
* which accompanies this distribution, and is available
|
sl@0
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
8 |
*
|
sl@0
|
9 |
* Initial Contributors:
|
sl@0
|
10 |
* Nokia Corporation - initial contribution.
|
sl@0
|
11 |
*
|
sl@0
|
12 |
* Contributors:
|
sl@0
|
13 |
*
|
sl@0
|
14 |
* Description:
|
sl@0
|
15 |
*
|
sl@0
|
16 |
*/
|
sl@0
|
17 |
|
sl@0
|
18 |
|
sl@0
|
19 |
#include <e32std.h>
|
sl@0
|
20 |
#include <e32base.h>
|
sl@0
|
21 |
#include <f32file.h>
|
sl@0
|
22 |
#include <charconv.h>
|
sl@0
|
23 |
#include "t_cp949.h"
|
sl@0
|
24 |
|
sl@0
|
25 |
// Local Functions
|
sl@0
|
26 |
///////////////////////////////////////////////////////////////////////////////////////
|
sl@0
|
27 |
/*
|
sl@0
|
28 |
Below four plugins all use cp949table.dll, and first three are same converter.
|
sl@0
|
29 |
cp949 (code page 949) 0x200100FF
|
sl@0
|
30 |
ksc5601 (Korean) 0x200113CD
|
sl@0
|
31 |
EUCKR (EUC-KR) 0x2000E526
|
sl@0
|
32 |
iso2022kr (Korean) 0x20010101
|
sl@0
|
33 |
*/
|
sl@0
|
34 |
|
sl@0
|
35 |
#define test(cond) \
|
sl@0
|
36 |
{ \
|
sl@0
|
37 |
TBool __bb = (cond); \
|
sl@0
|
38 |
TEST(__bb); \
|
sl@0
|
39 |
if (!__bb) \
|
sl@0
|
40 |
{ \
|
sl@0
|
41 |
ERR_PRINTF1(_L("ERROR: Test Failed")); \
|
sl@0
|
42 |
User::Leave(1); \
|
sl@0
|
43 |
} \
|
sl@0
|
44 |
}
|
sl@0
|
45 |
|
sl@0
|
46 |
const TInt KBufferLength=100;
|
sl@0
|
47 |
|
sl@0
|
48 |
void CT_CP949::TestConversionToUnicodeFromCP949(CCnvCharacterSetConverter& aCharacterSetConverter, const TDesC16& aExpectedUnicode, const TDesC8& aOriginalCP949, TInt aExpectedResult)
|
sl@0
|
49 |
{
|
sl@0
|
50 |
TInt state=CCnvCharacterSetConverter::KStateDefault;
|
sl@0
|
51 |
TBuf16<KBufferLength> generatedUnicode;
|
sl@0
|
52 |
const TInt returnValue=aCharacterSetConverter.ConvertToUnicode(generatedUnicode, aOriginalCP949, state);
|
sl@0
|
53 |
test(returnValue == aExpectedResult );
|
sl@0
|
54 |
test(generatedUnicode==aExpectedUnicode);
|
sl@0
|
55 |
}
|
sl@0
|
56 |
|
sl@0
|
57 |
void CT_CP949::TestConversionFromUnicodeToCP949(CCnvCharacterSetConverter& aCharacterSetConverter, const TDesC16& aOriginalUnicode, const TDesC8& aExpectedCP949, TInt aExpectedResult)
|
sl@0
|
58 |
{
|
sl@0
|
59 |
TBuf8<KBufferLength> generatedCP949;
|
sl@0
|
60 |
const TInt returnValue=aCharacterSetConverter.ConvertFromUnicode(generatedCP949, aOriginalUnicode);
|
sl@0
|
61 |
test(returnValue == aExpectedResult);
|
sl@0
|
62 |
test(generatedCP949==aExpectedCP949);
|
sl@0
|
63 |
}
|
sl@0
|
64 |
|
sl@0
|
65 |
void CT_CP949::TestConversion( CCnvCharacterSetConverter& aCharacterSetConverter )
|
sl@0
|
66 |
{
|
sl@0
|
67 |
TestConversionFromUnicodeToCP949(aCharacterSetConverter, _L16("\x0079"), _L8("\x79"));
|
sl@0
|
68 |
TestConversionToUnicodeFromCP949(aCharacterSetConverter, _L16("\x0079"), _L8("\x79"));
|
sl@0
|
69 |
|
sl@0
|
70 |
TestConversionFromUnicodeToCP949(aCharacterSetConverter, _L16("\xAC02"), _L8("\x81\x41"));
|
sl@0
|
71 |
TestConversionToUnicodeFromCP949(aCharacterSetConverter, _L16("\xAC02"), _L8("\x81\x41"));
|
sl@0
|
72 |
}
|
sl@0
|
73 |
|
sl@0
|
74 |
void CT_CP949::TestConversionIso2022kr( CCnvCharacterSetConverter& aCharacterSetConverter )
|
sl@0
|
75 |
{
|
sl@0
|
76 |
TestConversionFromUnicodeToCP949(aCharacterSetConverter, _L16("\x0079"), _L8("\x1b\x24\x43\x0f\x79"));
|
sl@0
|
77 |
TestConversionToUnicodeFromCP949(aCharacterSetConverter, _L16("\x0079"), _L8("\x1b\x24\x43\x0f\x79"));
|
sl@0
|
78 |
|
sl@0
|
79 |
TestConversionFromUnicodeToCP949(aCharacterSetConverter, _L16("\xc7b8"), _L8("\x1b\x24\x43\x0e\x20\x0f\x41"));
|
sl@0
|
80 |
TestConversionToUnicodeFromCP949(aCharacterSetConverter, _L16("\xc7b8\x0079"), _L8("\x1b\x24\x43\x0f\xa0\x41\x79"));
|
sl@0
|
81 |
|
sl@0
|
82 |
TestConversionFromUnicodeToCP949(aCharacterSetConverter, _L16("\xAC02"), _L8("\x1b\x24\x43\x0f\x81\x41"));
|
sl@0
|
83 |
TestConversionToUnicodeFromCP949(aCharacterSetConverter, _L16("\xAC02"), _L8("\x1b\x24\x43\x0f\x81\x41"));
|
sl@0
|
84 |
}
|
sl@0
|
85 |
|
sl@0
|
86 |
void CT_CP949::DoE32MainL()
|
sl@0
|
87 |
{
|
sl@0
|
88 |
RFs fileServerSession;
|
sl@0
|
89 |
CleanupClosePushL(fileServerSession);
|
sl@0
|
90 |
User::LeaveIfError(fileServerSession.Connect());
|
sl@0
|
91 |
CCnvCharacterSetConverter* characterSetConverter=CCnvCharacterSetConverter::NewLC();
|
sl@0
|
92 |
CArrayFix<CCnvCharacterSetConverter::SCharacterSet>* arrayOfCharacterSetsAvailable=\
|
sl@0
|
93 |
CCnvCharacterSetConverter::CreateArrayOfCharacterSetsAvailableLC(fileServerSession);
|
sl@0
|
94 |
|
sl@0
|
95 |
INFO_PRINTF1(_L("Available:\n"));
|
sl@0
|
96 |
for (TInt i=arrayOfCharacterSetsAvailable->Count()-1; i>=0; --i)
|
sl@0
|
97 |
{
|
sl@0
|
98 |
const CCnvCharacterSetConverter::SCharacterSet& charactersSet=(*arrayOfCharacterSetsAvailable)[i];
|
sl@0
|
99 |
characterSetConverter->PrepareToConvertToOrFromL(charactersSet.Identifier(), *arrayOfCharacterSetsAvailable, fileServerSession);
|
sl@0
|
100 |
TPtrC charactersSetName(charactersSet.Name());
|
sl@0
|
101 |
if (charactersSet.NameIsFileName())
|
sl@0
|
102 |
{
|
sl@0
|
103 |
charactersSetName.Set(TParsePtrC(charactersSetName).Name());
|
sl@0
|
104 |
}
|
sl@0
|
105 |
INFO_PRINTF2(_L(" %S\n"), &charactersSetName);
|
sl@0
|
106 |
}
|
sl@0
|
107 |
|
sl@0
|
108 |
INFO_PRINTF1(_L("Testing CP949"));
|
sl@0
|
109 |
characterSetConverter->PrepareToConvertToOrFromL(KCharacterSetIdentifierCP949, *arrayOfCharacterSetsAvailable, fileServerSession);
|
sl@0
|
110 |
TestConversion( *characterSetConverter );
|
sl@0
|
111 |
|
sl@0
|
112 |
INFO_PRINTF1(_L("Testing ksc5601"));
|
sl@0
|
113 |
characterSetConverter->PrepareToConvertToOrFromL(KCharacterSetIdentifierKsc5601, *arrayOfCharacterSetsAvailable, fileServerSession);
|
sl@0
|
114 |
TestConversion( *characterSetConverter );
|
sl@0
|
115 |
|
sl@0
|
116 |
INFO_PRINTF1(_L("Testing EUCKR"));
|
sl@0
|
117 |
characterSetConverter->PrepareToConvertToOrFromL(KCharacterSetIdentifierEUCKR, *arrayOfCharacterSetsAvailable, fileServerSession);
|
sl@0
|
118 |
TestConversion( *characterSetConverter );
|
sl@0
|
119 |
|
sl@0
|
120 |
INFO_PRINTF1(_L("Testing Iso2022kr"));
|
sl@0
|
121 |
characterSetConverter->PrepareToConvertToOrFromL(KCharacterSetIdentifierIso2022kr, *arrayOfCharacterSetsAvailable, fileServerSession);
|
sl@0
|
122 |
TestConversionIso2022kr( *characterSetConverter );
|
sl@0
|
123 |
|
sl@0
|
124 |
CleanupStack::PopAndDestroy(3);
|
sl@0
|
125 |
}
|
sl@0
|
126 |
|
sl@0
|
127 |
CT_CP949::CT_CP949()
|
sl@0
|
128 |
{
|
sl@0
|
129 |
SetTestStepName(KTestStep_T_CP949);
|
sl@0
|
130 |
}
|
sl@0
|
131 |
|
sl@0
|
132 |
TVerdict CT_CP949::doTestStepL()
|
sl@0
|
133 |
{
|
sl@0
|
134 |
SetTestStepResult(EFail);
|
sl@0
|
135 |
|
sl@0
|
136 |
__UHEAP_MARK;
|
sl@0
|
137 |
TRAPD(error1, DoE32MainL());
|
sl@0
|
138 |
__UHEAP_MARKEND;
|
sl@0
|
139 |
|
sl@0
|
140 |
if(error1 == KErrNone)
|
sl@0
|
141 |
{
|
sl@0
|
142 |
SetTestStepResult(EPass);
|
sl@0
|
143 |
}
|
sl@0
|
144 |
|
sl@0
|
145 |
return TestStepResult();
|
sl@0
|
146 |
}
|
sl@0
|
147 |
|