sl@0: /* sl@0: * Copyright (c) 2000-2010 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * sl@0: */ sl@0: sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include "tiso8859x.h" sl@0: #include "t_iso8859x.h" sl@0: sl@0: #define test(cond) \ sl@0: { \ sl@0: TBool __bb = (cond); \ sl@0: TEST(__bb); \ sl@0: if (!__bb) \ sl@0: { \ sl@0: ERR_PRINTF1(_L("ERROR: Test Failed")); \ sl@0: User::Leave(1); \ sl@0: } \ sl@0: } sl@0: sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-CHARCONV-CT-0541 sl@0: @SYMTestCaseDesc Tests for conversion from ISO 8859 to Unicode sl@0: @SYMTestPriority Medium sl@0: @SYMTestActions Tests for a filename and then convert to Unicode from ISO8859X sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: void CT_ISO8859X::test1L() sl@0: { sl@0: INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-CHARCONV-CT-0541 ")); sl@0: RFs fileServerSession; sl@0: CleanupClosePushL(fileServerSession); sl@0: User::LeaveIfError(fileServerSession.Connect()); sl@0: CCnvCharacterSetConverter* characterSetConverter=CCnvCharacterSetConverter::NewLC(); sl@0: CArrayFix* arrayOfCharacterSetsAvailable=CCnvCharacterSetConverter::CreateArrayOfCharacterSetsAvailableLC(fileServerSession); sl@0: INFO_PRINTF1(_L("Available:\n")); sl@0: TInt i; sl@0: for (i=arrayOfCharacterSetsAvailable->Count()-1; i>=0; --i) sl@0: { sl@0: const CCnvCharacterSetConverter::SCharacterSet& charactersSet=(*arrayOfCharacterSetsAvailable)[i]; sl@0: characterSetConverter->PrepareToConvertToOrFromL(charactersSet.Identifier(), *arrayOfCharacterSetsAvailable, fileServerSession); sl@0: TPtrC charactersSetName(charactersSet.Name()); sl@0: if (charactersSet.NameIsFileName()) sl@0: { sl@0: charactersSetName.Set(TParsePtrC(charactersSetName).Name()); sl@0: } sl@0: INFO_PRINTF2(_L(" %S\n"), &charactersSetName); sl@0: } sl@0: TInt state=CCnvCharacterSetConverter::KStateDefault; sl@0: for (i=0; iPrepareToConvertToOrFromL(iso8859TestData.iItems[i].iCharacterSetIdentifier, *arrayOfCharacterSetsAvailable, fileServerSession); sl@0: TPtrC16 originalUnicode(iso8859TestData.iItems[i].iUnicode, iso8859TestData.iItems[i].iTextLength); sl@0: TPtrC8 expectedIso8859(iso8859TestData.iItems[i].iIso8859, iso8859TestData.iItems[i].iTextLength); sl@0: TBuf16<256> generatedUnicode; sl@0: test(characterSetConverter->ConvertToUnicode(generatedUnicode, expectedIso8859, state)==0); sl@0: test(generatedUnicode==originalUnicode); sl@0: TBuf8<256> generatedIso8859; sl@0: test(characterSetConverter->ConvertFromUnicode(generatedIso8859, originalUnicode)==0); sl@0: test(state==CCnvCharacterSetConverter::KStateDefault); sl@0: test(generatedIso8859==expectedIso8859); sl@0: } sl@0: CleanupStack::PopAndDestroy(3); // arrayOfCharacterSetsAvailable and characterSetConverter and fileServerSession sl@0: } sl@0: sl@0: /** sl@0: Test code for INC042690 - Bi-directional MIME types are not supported in Charconv sl@0: The bi-directional MIME types only indicate how to treat the layout of the mail, sl@0: the actual character conversion should be the same as for the exisiting ISO-8859-6/ISO-8859-8 plugins sl@0: sl@0: @SYMTestCaseID SYSLIB-CHARCONV-CT-0542 sl@0: @SYMTestCaseDesc Tests the Bi-directional MIME sl@0: @SYMTestPriority Medium sl@0: @SYMTestActions Tests for conversions of ISO_8859-6 UID to MIB sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: void CT_ISO8859X::testInc042690L() sl@0: { sl@0: INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-CHARCONV-CT-0542 Test for INC042690 ")); sl@0: sl@0: RFs fileServerSession; sl@0: CleanupClosePushL(fileServerSession); sl@0: User::LeaveIfError(fileServerSession.Connect()); sl@0: CCnvCharacterSetConverter* characterSetConverter=CCnvCharacterSetConverter::NewLC(); sl@0: sl@0: // check that the character set value of '81' is converted to the ISO_8859-6 UID (0x10008a29) sl@0: test(characterSetConverter->ConvertMibEnumOfCharacterSetToIdentifierL(81,fileServerSession)==KCharacterSetIdentifierIso88596); sl@0: INFO_PRINTF1(_L("\nMIB 81->Char Set ISO_8859-6 UID - OK")); sl@0: sl@0: // check that the character set value of '82' is converted to the ISO_8859-6 UID (0x10008a29) sl@0: test(characterSetConverter->ConvertMibEnumOfCharacterSetToIdentifierL(82,fileServerSession)==KCharacterSetIdentifierIso88596); sl@0: INFO_PRINTF1(_L("\nMIB 82->Char Set ISO_8859-6 UID - OK")); sl@0: sl@0: // check that the character set value of '84' is converted to the ISO_8859-8 UID (0x10008a2a) sl@0: test(characterSetConverter->ConvertMibEnumOfCharacterSetToIdentifierL(84,fileServerSession)==KCharacterSetIdentifierIso88598); sl@0: INFO_PRINTF1(_L("\nMIB 84->Char Set ISO_8859-8 UID - OK")); sl@0: sl@0: // check that the character set value of '85' is converted to the ISO_8859-8 UID (0x10008a2a) sl@0: test(characterSetConverter->ConvertMibEnumOfCharacterSetToIdentifierL(85,fileServerSession)==KCharacterSetIdentifierIso88598); sl@0: INFO_PRINTF1(_L("\nMIB 85->Char Set ISO_8859-8 UID - OK")); sl@0: sl@0: // check that the ISO_8859-6 UID (0x10008a29) is converted to the character set value of '9' sl@0: test(characterSetConverter->ConvertCharacterSetIdentifierToMibEnumL(KCharacterSetIdentifierIso88596,fileServerSession)==9); sl@0: INFO_PRINTF1(_L("\nChar Set ISO_8859-6 UID->MIB - OK")); sl@0: sl@0: // check that the ISO_8859-8 UID (0x10008a2a) is converted to the character set value of '11' sl@0: test(characterSetConverter->ConvertCharacterSetIdentifierToMibEnumL(KCharacterSetIdentifierIso88598,fileServerSession)==11); sl@0: INFO_PRINTF1(_L("\nChar Set ISO_8859-8 UID->MIB - OK")); sl@0: sl@0: INFO_PRINTF1(_L("\nTest for INC042690 complete:\n")); sl@0: CleanupStack::PopAndDestroy(2); // characterSetConverter and fileServerSession sl@0: } sl@0: /** sl@0: Test code for INC043911 - IANAMib 1014 not supported sl@0: sl@0: @SYMTestCaseID SYSLIB-CHARCONV-CT-0543 sl@0: @SYMTestCaseDesc Tests for CCnvCharacterSetConverter::ConvertMibEnumOfCharacterSetToIdentifierL() function sl@0: @SYMTestPriority Medium sl@0: @SYMTestActions Tests for a conversions of MIB to UTF-16BE UID sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: void CT_ISO8859X::testInc043911L() sl@0: { sl@0: INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-CHARCONV-CT-0543 Test for INC043911 ")); sl@0: sl@0: RFs fileServerSession; sl@0: CleanupClosePushL(fileServerSession); sl@0: User::LeaveIfError(fileServerSession.Connect()); sl@0: CCnvCharacterSetConverter* characterSetConverter=CCnvCharacterSetConverter::NewLC(); sl@0: sl@0: // check that the character set value of '1013' is converted to the UTF-16BE UID (0x101f4052) sl@0: test(characterSetConverter->ConvertMibEnumOfCharacterSetToIdentifierL(1013,fileServerSession)==KCharacterSetIdentifierUnicodeBig); sl@0: INFO_PRINTF1(_L("\nMIB 1013->Char Set UTF-16BE UID - OK")); sl@0: sl@0: // check that the character set value of '1014' is converted to the UTF-16LE UID (0x101f3fae) sl@0: test(characterSetConverter->ConvertMibEnumOfCharacterSetToIdentifierL(1014,fileServerSession)==KCharacterSetIdentifierUnicodeLittle); sl@0: INFO_PRINTF1(_L("\nMIB 1014->Char Set UTF-16LE UID - OK")); sl@0: sl@0: // check that the character set value of '1015' is converted to the UTF-16 UID (0x101ff492) sl@0: test(characterSetConverter->ConvertMibEnumOfCharacterSetToIdentifierL(1015,fileServerSession)==KCharacterSetIdentifierUcs2); sl@0: INFO_PRINTF1(_L("\nMIB 1015->Char Set UTF-16 UID - OK")); sl@0: sl@0: sl@0: INFO_PRINTF1(_L("\nTest for INC043911 complete:\n")); sl@0: CleanupStack::PopAndDestroy(2); // characterSetConverter and fileServerSession sl@0: } sl@0: /** sl@0: Test code for DEF050040 - Propagated: Baltic (ISO8859-13) missing in Basic.txt sl@0: sl@0: @SYMTestCaseID SYSLIB-CHARCONV-CT-0544 sl@0: @SYMTestCaseDesc Tests for defect number DEF050040 sl@0: @SYMTestPriority Medium sl@0: @SYMTestActions Tests for CCnvCharacterSetConverter::ConvertMibEnumOfCharacterSetToIdentifierL() sl@0: Tests for a conversions of MIB to ISO-8859-13 UID sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: void CT_ISO8859X::testDef050040L() sl@0: { sl@0: INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-CHARCONV-CT-0544 Test for DEF050040 ")); sl@0: sl@0: RFs fileServerSession; sl@0: CleanupClosePushL(fileServerSession); sl@0: User::LeaveIfError(fileServerSession.Connect()); sl@0: CCnvCharacterSetConverter* characterSetConverter=CCnvCharacterSetConverter::NewLC(); sl@0: sl@0: // check that the character set value of '109' is converted to the ISO-8859-13 UID (0x10008a2c) sl@0: test(characterSetConverter->ConvertMibEnumOfCharacterSetToIdentifierL(109,fileServerSession)==KCharacterSetIdentifierIso885913); sl@0: INFO_PRINTF1(_L("\nMIB 109->Char Set ISO-8859-13 UID - OK")); sl@0: sl@0: INFO_PRINTF1(_L("\nTest for DEF050040 complete:\n")); sl@0: CleanupStack::PopAndDestroy(2); // characterSetConverter and fileServerSession sl@0: } sl@0: /** sl@0: @SYMTestCaseID SYSLIB-CHARCONV-CT-0545 sl@0: @SYMTestCaseDesc Tests for conversion of ISO8859 to Unicode sl@0: @SYMTestPriority Medium sl@0: @SYMTestActions Calls up conversion test functions of ISO8859 to Unicode sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: void CT_ISO8859X::DoE32MainL() sl@0: { sl@0: INFO_PRINTF1(_L("@SYMTestCaseID:SYSLIB-CHARCONV-CT-0545 Tests for conversion of ISO8859 to Unicode")); sl@0: test1L(); sl@0: testInc042690L(); sl@0: testInc043911L(); sl@0: testDef050040L(); sl@0: } sl@0: sl@0: CT_ISO8859X::CT_ISO8859X() sl@0: { sl@0: SetTestStepName(KTestStep_T_ISO8859X); sl@0: } sl@0: sl@0: TVerdict CT_ISO8859X::doTestStepL() sl@0: { sl@0: SetTestStepResult(EFail); sl@0: sl@0: __UHEAP_MARK; sl@0: TRAPD(error1, DoE32MainL()); sl@0: __UHEAP_MARKEND; sl@0: sl@0: if(error1 == KErrNone) sl@0: { sl@0: SetTestStepResult(EPass); sl@0: } sl@0: sl@0: return TestStepResult(); sl@0: } sl@0: