sl@0: /* sl@0: * Copyright (c) 1997-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 "t_snm.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-0547 sl@0: @SYMTestCaseDesc Testing SNM files sl@0: @SYMTestPriority Medium sl@0: @SYMTestActions Tests for conversions from UIDs to Standard names and MIB enums sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: void CT_SNM::DoE32MainL() sl@0: { sl@0: RFs fileServerSession; sl@0: CleanupClosePushL(fileServerSession); sl@0: User::LeaveIfError(fileServerSession.Connect()); sl@0: CCnvCharacterSetConverter* characterSetConverter=CCnvCharacterSetConverter::NewLC(); sl@0: INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-CHARCONV-CT-0547 Testing SNM files (conversion between UIDs and Standard names/MIB enums) ")); sl@0: test(characterSetConverter->ConvertStandardNameOfCharacterSetToIdentifierL(_L8("ANSI_X3.4-1968"), fileServerSession)==KCharacterSetIdentifierAscii); sl@0: test(characterSetConverter->ConvertStandardNameOfCharacterSetToIdentifierL(_L8("iso-ir-6"), fileServerSession)==KCharacterSetIdentifierAscii); sl@0: test(characterSetConverter->ConvertStandardNameOfCharacterSetToIdentifierL(_L8("ANSI_X3.4-1986"), fileServerSession)==KCharacterSetIdentifierAscii); sl@0: test(characterSetConverter->ConvertStandardNameOfCharacterSetToIdentifierL(_L8("ISO_646.irv:1991"), fileServerSession)==KCharacterSetIdentifierAscii); sl@0: test(characterSetConverter->ConvertStandardNameOfCharacterSetToIdentifierL(_L8("ISO646-US"), fileServerSession)==KCharacterSetIdentifierAscii); sl@0: test(characterSetConverter->ConvertStandardNameOfCharacterSetToIdentifierL(_L8("us"), fileServerSession)==KCharacterSetIdentifierAscii); sl@0: test(characterSetConverter->ConvertStandardNameOfCharacterSetToIdentifierL(_L8("IBM367"), fileServerSession)==KCharacterSetIdentifierAscii); sl@0: test(characterSetConverter->ConvertStandardNameOfCharacterSetToIdentifierL(_L8("cp367"), fileServerSession)==KCharacterSetIdentifierAscii); sl@0: test(characterSetConverter->ConvertStandardNameOfCharacterSetToIdentifierL(_L8("csASCII"), fileServerSession)==KCharacterSetIdentifierAscii); sl@0: test(characterSetConverter->ConvertMibEnumOfCharacterSetToIdentifierL(3, fileServerSession)==KCharacterSetIdentifierAscii); sl@0: test(characterSetConverter->ConvertStandardNameOfCharacterSetToIdentifierL(_L8("DUMMY CHARACTER SET"), fileServerSession)==0x000eb205); sl@0: test(characterSetConverter->ConvertMibEnumOfCharacterSetToIdentifierL(9415824, fileServerSession)==0x000eb205); sl@0: test(characterSetConverter->ConvertMibEnumOfCharacterSetToIdentifierL(103, fileServerSession)==KCharacterSetIdentifierUtf7); sl@0: test(characterSetConverter->ConvertMibEnumOfCharacterSetToIdentifierL(104, fileServerSession)==KCharacterSetIdentifierUtf7); sl@0: test(characterSetConverter->ConvertMibEnumOfCharacterSetToIdentifierL(18, fileServerSession)==KCharacterSetIdentifierEucJpPacked); sl@0: test(characterSetConverter->ConvertMibEnumOfCharacterSetToIdentifierL(17, fileServerSession)==KCharacterSetIdentifierShiftJis); sl@0: test(characterSetConverter->ConvertMibEnumOfCharacterSetToIdentifierL(2026, fileServerSession)==KCharacterSetIdentifierBig5); sl@0: test(characterSetConverter->ConvertMibEnumOfCharacterSetToIdentifierL(57, fileServerSession)==KCharacterSetIdentifierGbk); sl@0: test(characterSetConverter->ConvertMibEnumOfCharacterSetToIdentifierL(2025, fileServerSession)==KCharacterSetIdentifierGbk); sl@0: test(characterSetConverter->ConvertMibEnumOfCharacterSetToIdentifierL(4, fileServerSession)==KCharacterSetIdentifierIso88591); sl@0: test(characterSetConverter->ConvertMibEnumOfCharacterSetToIdentifierL(1000, fileServerSession)==KCharacterSetIdentifierUcs2); sl@0: test(characterSetConverter->ConvertStandardNameOfCharacterSetToIdentifierL(_L8("UTF-8"), fileServerSession)==KCharacterSetIdentifierUtf8); sl@0: test(characterSetConverter->ConvertStandardNameOfCharacterSetToIdentifierL(_L8("windows-1252"), fileServerSession)==KCharacterSetIdentifierCodePage1252); sl@0: test(characterSetConverter->ConvertStandardNameOfCharacterSetToIdentifierL(_L8("iso-ir-58"), fileServerSession)==KCharacterSetIdentifierGbk); sl@0: test(characterSetConverter->ConvertStandardNameOfCharacterSetToIdentifierL(_L8("chinese"), fileServerSession)==KCharacterSetIdentifierGbk); sl@0: test(characterSetConverter->ConvertStandardNameOfCharacterSetToIdentifierL(_L8("CHINESE"), fileServerSession)==KCharacterSetIdentifierGbk); sl@0: test(characterSetConverter->ConvertStandardNameOfCharacterSetToIdentifierL(_L8("Big5"), fileServerSession)==KCharacterSetIdentifierBig5); sl@0: test(characterSetConverter->ConvertStandardNameOfCharacterSetToIdentifierL(_L8("csISO2022JP"), fileServerSession)==KCharacterSetIdentifierIso2022Jp); sl@0: test(characterSetConverter->ConvertStandardNameOfCharacterSetToIdentifierL(_L8("JIS_Encoding"), fileServerSession)==KCharacterSetIdentifierJis); sl@0: test(characterSetConverter->ConvertCharacterSetIdentifierToMibEnumL(KCharacterSetIdentifierEucJpPacked, fileServerSession)==18); sl@0: test(characterSetConverter->ConvertCharacterSetIdentifierToMibEnumL(KCharacterSetIdentifierUtf7, fileServerSession)==103); sl@0: test(characterSetConverter->ConvertCharacterSetIdentifierToMibEnumL(KCharacterSetIdentifierGbk, fileServerSession)==113); sl@0: HBufC8* const standardName1=characterSetConverter->ConvertCharacterSetIdentifierToStandardNameL(KCharacterSetIdentifierUtf8, fileServerSession); sl@0: test(*standardName1==_L8("UTF-8")); sl@0: delete standardName1; sl@0: HBufC8* const standardName2=characterSetConverter->ConvertCharacterSetIdentifierToStandardNameL(KCharacterSetIdentifierShiftJis, fileServerSession); sl@0: test(*standardName2==_L8("Shift_JIS")); sl@0: delete standardName2; sl@0: HBufC8* const standardName3=characterSetConverter->ConvertCharacterSetIdentifierToStandardNameL(KCharacterSetIdentifierBig5, fileServerSession); sl@0: test(*standardName3==_L8("Big5")); sl@0: delete standardName3; sl@0: CleanupStack::PopAndDestroy(1); // characterSetConverter sl@0: sl@0: //Add more test steps for DEF085268. When a related charset ID with Name is not found in rom drive sl@0: //and system hasn't been scanned yet, it will rescan the system. Otherwise, it will return 0. sl@0: characterSetConverter=CCnvCharacterSetConverter::NewLC(); sl@0: test(characterSetConverter->ConvertStandardNameOfCharacterSetToIdentifierL(_L8("NONEXIST CHARACTER SET 1"), fileServerSession)==0); sl@0: test(characterSetConverter->ConvertStandardNameOfCharacterSetToIdentifierL(_L8("DUMMY CHARACTER SET"), fileServerSession)==0x000eb205); sl@0: test(characterSetConverter->ConvertStandardNameOfCharacterSetToIdentifierL(_L8("NONEXIST CHARACTER SET 2"), fileServerSession)==0); sl@0: CleanupStack::PopAndDestroy(1); // characterSetConverter sl@0: sl@0: //Add more test steps for DEF085268. When a related charset name with ID is not found in rom drive sl@0: //and system hasn't been scanned yet, it will rescan the system. Otherwise, it will return NULL. sl@0: characterSetConverter=CCnvCharacterSetConverter::NewLC(); sl@0: HBufC8* const standardName4=characterSetConverter->ConvertCharacterSetIdentifierToStandardNameL(0xFFFFFFFE, fileServerSession); sl@0: test(standardName4==NULL); sl@0: delete standardName4; sl@0: HBufC8* const standardName5=characterSetConverter->ConvertCharacterSetIdentifierToStandardNameL(0x000eb205, fileServerSession); sl@0: test(*standardName5==_L8("Dummy character set")); sl@0: delete standardName5; sl@0: HBufC8* const standardName6=characterSetConverter->ConvertCharacterSetIdentifierToStandardNameL(0xFFFFFFFF, fileServerSession); sl@0: test(standardName6==NULL); sl@0: delete standardName6; sl@0: CleanupStack::PopAndDestroy(1); // characterSetConverter sl@0: sl@0: sl@0: //Add more test steps for DEF085268. When a related charset ID with MibEnum is not found in rom drive sl@0: //and system hasn't been scanned yet, it will rescan the system. Otherwise, it will return 0. sl@0: characterSetConverter=CCnvCharacterSetConverter::NewLC(); sl@0: test(characterSetConverter->ConvertMibEnumOfCharacterSetToIdentifierL(9999998, fileServerSession)==0); sl@0: test(characterSetConverter->ConvertMibEnumOfCharacterSetToIdentifierL(9415824, fileServerSession)==0x000eb205); sl@0: test(characterSetConverter->ConvertMibEnumOfCharacterSetToIdentifierL(9999999, fileServerSession)==0); sl@0: CleanupStack::PopAndDestroy(1); // characterSetConverter sl@0: sl@0: //Add more test steps for DEF085268. When a related charset MibEnum with ID is not found in rom drive sl@0: //and system hasn't been scanned yet, it will rescan the system. Otherwise, it will return 0. sl@0: characterSetConverter=CCnvCharacterSetConverter::NewLC(); sl@0: test(characterSetConverter->ConvertCharacterSetIdentifierToMibEnumL(0xFFFFFFFE, fileServerSession)==0); sl@0: test(characterSetConverter->ConvertCharacterSetIdentifierToMibEnumL(0x000eb205, fileServerSession)==9415824); sl@0: test(characterSetConverter->ConvertCharacterSetIdentifierToMibEnumL(0xFFFFFFFF, fileServerSession)==0); sl@0: CleanupStack::PopAndDestroy(2); // characterSetConverter and file session sl@0: sl@0: } sl@0: sl@0: CT_SNM::CT_SNM() sl@0: { sl@0: SetTestStepName(KTestStep_T_SNM); sl@0: } sl@0: sl@0: TVerdict CT_SNM::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: