os/textandloc/charconvfw/charconvplugins/test/rtest/tsrc/main/t_big5.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 /*
     2 * Copyright (c) 1997-2010 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     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".
     8 *
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    11 *
    12 * Contributors:
    13 *
    14 * Description: 
    15 *
    16 */
    17 
    18 
    19 #include <e32std.h>
    20 #include <e32base.h>
    21 #include <f32file.h>
    22 #include <charconv.h>
    23 #include "t_big5.h"
    24 
    25 #define test(cond)                                  \
    26     {                                               \
    27     TBool __bb = (cond);                            \
    28     TEST(__bb);                                     \
    29     if (!__bb)                                      \
    30         {                                           \
    31         ERR_PRINTF1(_L("ERROR: Test Failed"));      \
    32         User::Leave(1);                             \
    33         }                                           \
    34     }
    35 
    36 /**
    37 @SYMTestCaseID          SYSLIB-CHARCONV-CT-0515
    38 @SYMTestCaseDesc        Tests for defect number EDNSHAY-45VJAU
    39 @SYMTestPriority        Medium
    40 @SYMTestActions         Tests for CCnvCharacterSetConverter::ConvertToUnicode() function
    41 @SYMTestExpectedResults Test must not fail
    42 @SYMREQ                 REQ0000
    43 */
    44 void CT_BIG5::DoE32MainL()
    45 	{
    46 	RFs fileServerSession;
    47 	CleanupClosePushL(fileServerSession);
    48 	User::LeaveIfError(fileServerSession.Connect());
    49 	CCnvCharacterSetConverter* characterSetConverter=CCnvCharacterSetConverter::NewLC();
    50 	CArrayFix<CCnvCharacterSetConverter::SCharacterSet>* arrayOfCharacterSetsAvailable=CCnvCharacterSetConverter::CreateArrayOfCharacterSetsAvailableLC(fileServerSession);
    51 	INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-CHARCONV-CT-0515 Available:\n "));
    52 	for (TInt i=arrayOfCharacterSetsAvailable->Count()-1; i>=0; --i)
    53 		{
    54 		const CCnvCharacterSetConverter::SCharacterSet& charactersSet=(*arrayOfCharacterSetsAvailable)[i];
    55 		characterSetConverter->PrepareToConvertToOrFromL(charactersSet.Identifier(), *arrayOfCharacterSetsAvailable, fileServerSession);
    56 		TPtrC charactersSetName(charactersSet.Name());
    57 		if (charactersSet.NameIsFileName())
    58 			{
    59 			charactersSetName.Set(TParsePtrC(charactersSetName).Name());
    60 			}
    61 		INFO_PRINTF2(_L("    %S\n"), &charactersSetName);
    62 		}
    63 	TInt state=CCnvCharacterSetConverter::KStateDefault;
    64 	INFO_PRINTF1(_L("Testing fix for defect number EDNSHAY-45VJAU"));
    65 	characterSetConverter->PrepareToConvertToOrFromL(KCharacterSetIdentifierBig5, *arrayOfCharacterSetsAvailable, fileServerSession);
    66 	TBuf16<28> generatedUnicode;
    67 	test(characterSetConverter->ConvertToUnicode(generatedUnicode, _L8("++   ZAC"), state)==0);
    68 	test(state==CCnvCharacterSetConverter::KStateDefault);
    69 	CleanupStack::PopAndDestroy(3); // arrayOfCharacterSetsAvailable and characterSetConverter and fileServerSession
    70 	}
    71 
    72 CT_BIG5::CT_BIG5()
    73     {
    74     SetTestStepName(KTestStep_T_BIG5);
    75     }
    76 
    77 TVerdict CT_BIG5::doTestStepL()
    78     {
    79     SetTestStepResult(EFail);
    80 
    81     __UHEAP_MARK;
    82     TRAPD(error1, DoE32MainL());
    83     __UHEAP_MARKEND;
    84 
    85     if(error1 == KErrNone)
    86         {
    87         SetTestStepResult(EPass);
    88         }
    89 
    90     return TestStepResult();
    91     }
    92