sl@0: /* sl@0: * Copyright (c) 1997-2009 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 "t_imap.h" sl@0: 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: /////////////////////////////////////////////////////////////////////////////////////// sl@0: /** sl@0: @SYMTestCaseID SYSLIB-CHARCONV-CT-0574 sl@0: @SYMTestCaseDesc Tests for converting to Unicode from UTF- 7, from UTF-7 to Unicode sl@0: @SYMTestPriority Medium sl@0: @SYMTestActions Tests for CCnvCharacterSetConverter::ConvertToUnicode(), sl@0: CCnvCharacterSetConverter::ConvertFromUnicode() function sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: void CT_IMAP::TestIMAP() sl@0: { sl@0: RFs fileServerSession; sl@0: CleanupClosePushL(fileServerSession); sl@0: User::LeaveIfError(fileServerSession.Connect()); sl@0: CCnvCharacterSetConverter* characterSetConverter=CCnvCharacterSetConverter::NewLC(); sl@0: TInt state=CCnvCharacterSetConverter::KStateDefault; sl@0: INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-CHARCONV-CT-0574 Testing IMAP UTF-7 ")); sl@0: test(characterSetConverter->PrepareToConvertToOrFromL(KCharacterSetIdentifierImapUtf7, fileServerSession)==CCnvCharacterSetConverter::EAvailable); sl@0: TBuf16<256> originalUnicode; sl@0: TBuf8<256> generatedUtf7; sl@0: TBuf16<256> generatedUnicode; sl@0: // sl@0: INFO_PRINTF1(_L("Empty descriptor")); sl@0: originalUnicode=_L16(""); sl@0: test(characterSetConverter->ConvertFromUnicode(generatedUtf7, originalUnicode)==0); sl@0: test(generatedUtf7==_L8("")); sl@0: test(characterSetConverter->ConvertToUnicode(generatedUnicode, generatedUtf7, state)==0); sl@0: test(state==CCnvCharacterSetConverter::KStateDefault); sl@0: test(generatedUnicode==originalUnicode); sl@0: INFO_PRINTF1(_L("Characters \" +&-~\\\"")); sl@0: originalUnicode=_L16(" +&-~\\"); sl@0: test(characterSetConverter->ConvertFromUnicode(generatedUtf7, originalUnicode)==0); sl@0: test(generatedUtf7==_L8(" +&--~\\")); sl@0: test(characterSetConverter->ConvertToUnicode(generatedUnicode, generatedUtf7, state)==0); sl@0: test(state==CCnvCharacterSetConverter::KStateDefault); sl@0: test(generatedUnicode==originalUnicode); sl@0: INFO_PRINTF1(_L("Example quoted in RFC 2060 (Section 5.1.3)")); sl@0: originalUnicode.Format(_L16("~peter/mail/%c%c%c/%c%c"), 0x65e5, 0x672c, 0x8a9e, 0x53f0, 0x5317); sl@0: test(characterSetConverter->ConvertFromUnicode(generatedUtf7, originalUnicode)==0); sl@0: test(generatedUtf7==_L8("~peter/mail/&ZeVnLIqe-/&U,BTFw-")); sl@0: test(characterSetConverter->ConvertToUnicode(generatedUnicode, generatedUtf7, state)==0); sl@0: test(state==CCnvCharacterSetConverter::KStateDefault); sl@0: test(generatedUnicode==originalUnicode); sl@0: INFO_PRINTF1(_L("Testing fix for defect EDNDSEF-4KMEUH in \"Symbian Defect Tracking v3.0\"")); sl@0: originalUnicode.Format(_L16("%c%c%c%c%c%c%c%c%c"), 0x30ad, 0x30e3, 0x30d3, 0x30cd, 0x30c3, 0x30c8, 0x3068, 0x306f, 0xff1f); sl@0: test(characterSetConverter->ConvertFromUnicode(generatedUtf7, originalUnicode)==0); sl@0: test(generatedUtf7==_L8("&MK0w4zDTMM0wwzDIMGgwb,8f-")); sl@0: test(characterSetConverter->ConvertToUnicode(generatedUnicode, generatedUtf7, state)==0); sl@0: test(state==CCnvCharacterSetConverter::KStateDefault); sl@0: test(generatedUnicode==originalUnicode); sl@0: TBuf8<0x14> generatedUtf7_0x14; sl@0: test(characterSetConverter->ConvertFromUnicode(generatedUtf7_0x14, originalUnicode)==3); sl@0: test(generatedUtf7_0x14==_L8("&MK0w4zDTMM0wwzDI-")); sl@0: test(characterSetConverter->ConvertToUnicode(generatedUnicode, generatedUtf7_0x14, state)==0); sl@0: test(state==CCnvCharacterSetConverter::KStateDefault); sl@0: test(generatedUnicode==originalUnicode.Left(6)); sl@0: CleanupStack::PopAndDestroy(2); // characterSetConverter and fileServerSession sl@0: } sl@0: sl@0: CT_IMAP::CT_IMAP() sl@0: { sl@0: SetTestStepName(KTestStep_T_IMAP); sl@0: } sl@0: sl@0: TVerdict CT_IMAP::doTestStepL() sl@0: { sl@0: SetTestStepResult(EFail); sl@0: sl@0: __UHEAP_MARK; sl@0: sl@0: TRAPD(error1, TestIMAP()); sl@0: 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: }