os/textandloc/charconvfw/charconvplugins/test/rtest/tsrc/main/t_turkishlockingsingle.cpp
First public contribution.
2 * Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of "Eclipse Public License v1.0"
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
23 #include "t_turkishlockingsingle.h"
25 const TUint KCharacterSetIdentifier=KCharacterSetIdentifierTurkishLockingAndSingleSms7Bit;
28 _LIT(KInputUnicodeFilename, "c:\\test\\data\\turkish_locking_single_uni_input.dat");
29 _LIT(KInputForeignFilename, "c:\\test\\data\\turkish_locking_single_for_input.dat");
30 _LIT(KExpectUnicodeFilename, "c:\\test\\data\\turkish_locking_single_uni_expect.dat");
31 _LIT(KExpectForeignFilename, "c:\\test\\data\\turkish_locking_single_for_expect.dat");
33 _LIT(KInputUnicodeFilename, "z:\\test\\data\\turkish_locking_single_uni_input.dat");
34 _LIT(KInputForeignFilename, "z:\\test\\data\\turkish_locking_single_for_input.dat");
35 _LIT(KExpectUnicodeFilename, "z:\\test\\data\\turkish_locking_single_uni_expect.dat");
36 _LIT(KExpectForeignFilename, "z:\\test\\data\\turkish_locking_single_for_expect.dat");
39 static CCnvCharacterSetConverter* characterSetConverter;
40 static RFs fileServerSession;
41 static TBuf8<970> temp;
42 static TBuf16<485> originalUnicode;
43 static TBuf8<485> generatedForeign;
44 static TBuf16<485> generatedUnicode;
48 TBool __bb = (cond); \
52 ERR_PRINTF1(_L("ERROR: Test Failed")); \
57 void CT_TURKISHLOCKINGSINGLE::ReadDescL(TDes8& aDes, const TDesC& aFilename, RFs& aFs)
60 TInt err = file.Open(aFs, aFilename, EFileRead);
61 test(err == KErrNone);
62 CleanupClosePushL(file);
63 err = file.Read(aDes);
64 test(err == KErrNone);
65 CleanupStack::PopAndDestroy(&file);
68 //translate from unicode big endian TDesC8 to TDes16
69 void CT_TURKISHLOCKINGSINGLE::Unicode_Big(TDesC8& aSource, TDes16& aTarget)
71 TInt length = aSource.Length();
73 for(i=0;i<length-1;i++)
75 TInt32 temp = *(aSource.Ptr()+(i))*16*16 + *(aSource.Ptr()+i+1);
83 @SYMTestCaseID SYSLIB-CHARCONV-UT-4021
84 @SYMTestCaseDesc Testcase to test new converter name can be listed
86 @SYMTestActions Test for CreateArrayOfCharacterSetsAvailableLC()
87 @SYMTestExpectedResults The test passed, if Available character sets are listed in epocwind.out
91 void CT_TURKISHLOCKINGSINGLE::ListAlltheConvertersL()
93 CArrayFix<CCnvCharacterSetConverter::SCharacterSet>* arrayOfCharacterSetsAvailable=\
94 CCnvCharacterSetConverter::CreateArrayOfCharacterSetsAvailableLC(fileServerSession);
95 INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-CHARCONV-UT-4021 Available:\n "));
96 for (TInt i=arrayOfCharacterSetsAvailable->Count()-1; i>=0; --i)
98 const CCnvCharacterSetConverter::SCharacterSet& charactersSet=(*arrayOfCharacterSetsAvailable)[i];
99 TPtrC charactersSetName(charactersSet.Name());
100 if (charactersSet.NameIsFileName())
102 charactersSetName.Set(TParsePtrC(charactersSetName).Name());
104 INFO_PRINTF2(_L(" %S\n"), &charactersSetName);
106 CleanupStack::PopAndDestroy(arrayOfCharacterSetsAvailable);
110 @SYMTestCaseID SYSLIB-CHARCONV-UT-4022
111 @SYMTestCaseDesc Testcase to test new converter can be prepared
112 @SYMTestPriority High
113 @SYMTestActions Test for PrepareToConvertToOrFromL()
114 @SYMTestExpectedResults The test passed, If EAvailable is returned
118 void CT_TURKISHLOCKINGSINGLE::PrepareNewConverterL()
120 INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-CHARCONV-UT-4022 Testing new converter can be prepared "));
121 CCnvCharacterSetConverter::TAvailability avaible = characterSetConverter->PrepareToConvertToOrFromL(KCharacterSetIdentifier, fileServerSession);
122 test( CCnvCharacterSetConverter::EAvailable == avaible );
126 @SYMTestCaseID SYSLIB-CHARCONV-UT-4023
127 @SYMTestCaseDesc Convert Unicode code to foreign character set
128 @SYMTestPriority High
129 @SYMTestActions Test for ConvertFromUnicode()
130 @SYMTestExpectedResults Test must not fail
134 void CT_TURKISHLOCKINGSINGLE::ConvertFromUnicodeToForeignL()
136 INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-CHARCONV-UT-4023 Testing encoding from Unicode to Foreign "));
137 ReadDescL(temp, KInputUnicodeFilename, fileServerSession);
138 Unicode_Big(temp, originalUnicode);
139 test(characterSetConverter->ConvertFromUnicode(generatedForeign, originalUnicode) == 0);
140 ReadDescL(temp, KExpectForeignFilename, fileServerSession);
141 test(generatedForeign == temp);
145 @SYMTestCaseID SYSLIB-CHARCONV-UT-4024
146 @SYMTestCaseDesc Convert foreign character set to Unicode code
147 @SYMTestPriority High
148 @SYMTestActions Test for ConvertToUnicode() with legal foreign characters, 0x00 - 0x7F
149 @SYMTestExpectedResults Test must not fail
153 void CT_TURKISHLOCKINGSINGLE::ConvertFromForeignToUnicodeL()
155 INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-CHARCONV-UT-4024 Testing encoding from Foreign to Unicode "));
156 ReadDescL(generatedForeign, KInputForeignFilename, fileServerSession);
157 TInt state=CCnvCharacterSetConverter::KStateDefault;
158 test( 0 == characterSetConverter->ConvertToUnicode(generatedUnicode, generatedForeign, state));
159 ReadDescL(temp, KExpectUnicodeFilename, fileServerSession);
160 originalUnicode.Zero();
161 Unicode_Big(temp, originalUnicode);
162 test(generatedUnicode == originalUnicode);
166 @SYMTestCaseID SYSLIB-CHARCONV-UT-4025
167 @SYMTestCaseDesc Convert illegal character from foreign character set to unicode
168 @SYMTestPriority High
169 @SYMTestActions Test for ConvertToUnicode() with illegal foreign characters 0x1B
170 @SYMTestExpectedResults Test must not fail
174 void CT_TURKISHLOCKINGSINGLE::ConvertIllegalForeignCharacter()
177 INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-CHARCONV-UT-4025 Testing EErrorIllFormedInput "));
178 generatedForeign.SetLength(1);
179 generatedForeign[0] = 0x1b; //the escape character
180 TInt state=CCnvCharacterSetConverter::KStateDefault;
181 test( -20 == characterSetConverter->ConvertToUnicode(generatedUnicode, generatedForeign, state));
185 @SYMTestCaseID SYSLIB-CHARCONV-UT-4026
186 @SYMTestCaseDesc Convert out of range characters from foreign character set to Unicode
187 @SYMTestPriority High
188 @SYMTestActions Test for ConvertToUnicode() for some out of range foreign characters 0x80 - 0xFF
189 @SYMTestExpectedResults Test must not fail
193 void CT_TURKISHLOCKINGSINGLE::ConvertOutOfRangeForeignCharacters()
195 //test foreign chararcter point which is not in the scope, e.g. 0x80 in GSM03.38, which should always mapped to 0xFFFD
196 INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-CHARCONV-UT-4026 Testing Characters not in the Scope "));
197 generatedForeign.SetLength(1);
198 generatedForeign[0] = 0x80;
199 TInt state=CCnvCharacterSetConverter::KStateDefault;
200 _LIT16(KExpected2, "\xfffd"); //the expected foreign
201 test( 0 == characterSetConverter->ConvertToUnicode(generatedUnicode, generatedForeign, state));
202 test( generatedUnicode == KExpected2 );
205 void CT_TURKISHLOCKINGSINGLE::DoE32MainL()
207 CleanupClosePushL(fileServerSession);
208 User::LeaveIfError(fileServerSession.Connect());
209 characterSetConverter=CCnvCharacterSetConverter::NewLC();
211 ListAlltheConvertersL();
212 PrepareNewConverterL();
213 ConvertFromUnicodeToForeignL();
214 ConvertFromForeignToUnicodeL();
215 ConvertIllegalForeignCharacter();
216 ConvertOutOfRangeForeignCharacters();
218 CleanupStack::PopAndDestroy(2);
222 CT_TURKISHLOCKINGSINGLE::CT_TURKISHLOCKINGSINGLE()
224 SetTestStepName(KTestStep_T_TURKISHLOCKINGSINGLE);
227 TVerdict CT_TURKISHLOCKINGSINGLE::doTestStepL()
229 SetTestStepResult(EFail);
232 TRAPD(error1, DoE32MainL());
235 if(error1 == KErrNone)
237 SetTestStepResult(EPass);
240 return TestStepResult();