os/textandloc/charconvfw/charconvplugins/test/rtest/tsrc/main/t_big5.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/textandloc/charconvfw/charconvplugins/test/rtest/tsrc/main/t_big5.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,92 @@
     1.4 +/*
     1.5 +* Copyright (c) 1997-2010 Nokia Corporation and/or its subsidiary(-ies).
     1.6 +* All rights reserved.
     1.7 +* This component and the accompanying materials are made available
     1.8 +* under the terms of "Eclipse Public License v1.0"
     1.9 +* which accompanies this distribution, and is available
    1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.11 +*
    1.12 +* Initial Contributors:
    1.13 +* Nokia Corporation - initial contribution.
    1.14 +*
    1.15 +* Contributors:
    1.16 +*
    1.17 +* Description: 
    1.18 +*
    1.19 +*/
    1.20 +
    1.21 +
    1.22 +#include <e32std.h>
    1.23 +#include <e32base.h>
    1.24 +#include <f32file.h>
    1.25 +#include <charconv.h>
    1.26 +#include "t_big5.h"
    1.27 +
    1.28 +#define test(cond)                                  \
    1.29 +    {                                               \
    1.30 +    TBool __bb = (cond);                            \
    1.31 +    TEST(__bb);                                     \
    1.32 +    if (!__bb)                                      \
    1.33 +        {                                           \
    1.34 +        ERR_PRINTF1(_L("ERROR: Test Failed"));      \
    1.35 +        User::Leave(1);                             \
    1.36 +        }                                           \
    1.37 +    }
    1.38 +
    1.39 +/**
    1.40 +@SYMTestCaseID          SYSLIB-CHARCONV-CT-0515
    1.41 +@SYMTestCaseDesc        Tests for defect number EDNSHAY-45VJAU
    1.42 +@SYMTestPriority        Medium
    1.43 +@SYMTestActions         Tests for CCnvCharacterSetConverter::ConvertToUnicode() function
    1.44 +@SYMTestExpectedResults Test must not fail
    1.45 +@SYMREQ                 REQ0000
    1.46 +*/
    1.47 +void CT_BIG5::DoE32MainL()
    1.48 +	{
    1.49 +	RFs fileServerSession;
    1.50 +	CleanupClosePushL(fileServerSession);
    1.51 +	User::LeaveIfError(fileServerSession.Connect());
    1.52 +	CCnvCharacterSetConverter* characterSetConverter=CCnvCharacterSetConverter::NewLC();
    1.53 +	CArrayFix<CCnvCharacterSetConverter::SCharacterSet>* arrayOfCharacterSetsAvailable=CCnvCharacterSetConverter::CreateArrayOfCharacterSetsAvailableLC(fileServerSession);
    1.54 +	INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-CHARCONV-CT-0515 Available:\n "));
    1.55 +	for (TInt i=arrayOfCharacterSetsAvailable->Count()-1; i>=0; --i)
    1.56 +		{
    1.57 +		const CCnvCharacterSetConverter::SCharacterSet& charactersSet=(*arrayOfCharacterSetsAvailable)[i];
    1.58 +		characterSetConverter->PrepareToConvertToOrFromL(charactersSet.Identifier(), *arrayOfCharacterSetsAvailable, fileServerSession);
    1.59 +		TPtrC charactersSetName(charactersSet.Name());
    1.60 +		if (charactersSet.NameIsFileName())
    1.61 +			{
    1.62 +			charactersSetName.Set(TParsePtrC(charactersSetName).Name());
    1.63 +			}
    1.64 +		INFO_PRINTF2(_L("    %S\n"), &charactersSetName);
    1.65 +		}
    1.66 +	TInt state=CCnvCharacterSetConverter::KStateDefault;
    1.67 +	INFO_PRINTF1(_L("Testing fix for defect number EDNSHAY-45VJAU"));
    1.68 +	characterSetConverter->PrepareToConvertToOrFromL(KCharacterSetIdentifierBig5, *arrayOfCharacterSetsAvailable, fileServerSession);
    1.69 +	TBuf16<28> generatedUnicode;
    1.70 +	test(characterSetConverter->ConvertToUnicode(generatedUnicode, _L8("++   ZAC"), state)==0);
    1.71 +	test(state==CCnvCharacterSetConverter::KStateDefault);
    1.72 +	CleanupStack::PopAndDestroy(3); // arrayOfCharacterSetsAvailable and characterSetConverter and fileServerSession
    1.73 +	}
    1.74 +
    1.75 +CT_BIG5::CT_BIG5()
    1.76 +    {
    1.77 +    SetTestStepName(KTestStep_T_BIG5);
    1.78 +    }
    1.79 +
    1.80 +TVerdict CT_BIG5::doTestStepL()
    1.81 +    {
    1.82 +    SetTestStepResult(EFail);
    1.83 +
    1.84 +    __UHEAP_MARK;
    1.85 +    TRAPD(error1, DoE32MainL());
    1.86 +    __UHEAP_MARKEND;
    1.87 +
    1.88 +    if(error1 == KErrNone)
    1.89 +        {
    1.90 +        SetTestStepResult(EPass);
    1.91 +        }
    1.92 +
    1.93 +    return TestStepResult();
    1.94 +    }
    1.95 +