charconvfw/charconvplugins/test/rtest/tsrc/main/tbig5.cpp
changeset 53 11e2bb0d14ba
parent 46 6124ff6478cc
child 59 7d891bb52a7d
equal deleted inserted replaced
46:6124ff6478cc 53:11e2bb0d14ba
     1 /*
       
     2 * Copyright (c) 1997-2009 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 <e32test.h>
       
    22 #include <f32file.h>
       
    23 #include <charconv.h>
       
    24 
       
    25 ///////////////////////////////////////////////////////////////////////////////////////
       
    26 
       
    27 RTest TheTest(_L("TBig5"));
       
    28 
       
    29 ///////////////////////////////////////////////////////////////////////////////////////
       
    30 ///////////////////////////////////////////////////////////////////////////////////////
       
    31 //Tests macroses and functions.
       
    32 //If (!aValue) then the test will be panicked, the test data files will be deleted.
       
    33 static void Check(TInt aValue, TInt aLine)
       
    34 	{
       
    35 	if(!aValue)
       
    36 		{
       
    37 		TheTest(EFalse, aLine);
       
    38 		}
       
    39 	}
       
    40 //If (aValue != aExpected) then the test will be panicked, the test data files will be deleted.
       
    41 static void Check(TInt aValue, TInt aExpected, TInt aLine)
       
    42 	{
       
    43 	if(aValue != aExpected)
       
    44 		{
       
    45 		RDebug::Print(_L("*** Expected error: %d, got: %d\r\n"), aExpected, aValue);
       
    46 		TheTest(EFalse, aLine);
       
    47 		}
       
    48 	}
       
    49 //Use these to test conditions.
       
    50 #define TEST(arg) ::Check((arg), __LINE__)
       
    51 #define TEST2(aValue, aExpected) ::Check(aValue, aExpected, __LINE__)
       
    52 
       
    53 ///////////////////////////////////////////////////////////////////////////////////////
       
    54 ///////////////////////////////////////////////////////////////////////////////////////
       
    55 /**
       
    56 @SYMTestCaseID          SYSLIB-CHARCONV-CT-0515
       
    57 @SYMTestCaseDesc        Tests for defect number EDNSHAY-45VJAU
       
    58 @SYMTestPriority        Medium
       
    59 @SYMTestActions         Tests for CCnvCharacterSetConverter::ConvertToUnicode() function
       
    60 @SYMTestExpectedResults Test must not fail
       
    61 @SYMREQ                 REQ0000
       
    62 */
       
    63 LOCAL_C void DoE32MainL()
       
    64 	{
       
    65 	RFs fileServerSession;
       
    66 	CleanupClosePushL(fileServerSession);
       
    67 	User::LeaveIfError(fileServerSession.Connect());
       
    68 	CCnvCharacterSetConverter* characterSetConverter=CCnvCharacterSetConverter::NewLC();
       
    69 	CArrayFix<CCnvCharacterSetConverter::SCharacterSet>* arrayOfCharacterSetsAvailable=CCnvCharacterSetConverter::CreateArrayOfCharacterSetsAvailableLC(fileServerSession);
       
    70 	TheTest.Start(_L(" @SYMTestCaseID:SYSLIB-CHARCONV-CT-0515 Available:\n "));
       
    71 	for (TInt i=arrayOfCharacterSetsAvailable->Count()-1; i>=0; --i)
       
    72 		{
       
    73 		const CCnvCharacterSetConverter::SCharacterSet& charactersSet=(*arrayOfCharacterSetsAvailable)[i];
       
    74 		characterSetConverter->PrepareToConvertToOrFromL(charactersSet.Identifier(), *arrayOfCharacterSetsAvailable, fileServerSession);
       
    75 		TPtrC charactersSetName(charactersSet.Name());
       
    76 		if (charactersSet.NameIsFileName())
       
    77 			{
       
    78 			charactersSetName.Set(TParsePtrC(charactersSetName).Name());
       
    79 			}
       
    80 		TheTest.Printf(_L("    %S\n"), &charactersSetName);
       
    81 		}
       
    82 	TInt state=CCnvCharacterSetConverter::KStateDefault;
       
    83 	TheTest.Next(_L("Testing fix for defect number EDNSHAY-45VJAU"));
       
    84 	characterSetConverter->PrepareToConvertToOrFromL(KCharacterSetIdentifierBig5, *arrayOfCharacterSetsAvailable, fileServerSession);
       
    85 	TBuf16<28> generatedUnicode;
       
    86 	TEST(characterSetConverter->ConvertToUnicode(generatedUnicode, _L8("++   ZAC"), state)==0);
       
    87 	TEST(state==CCnvCharacterSetConverter::KStateDefault);
       
    88 	CleanupStack::PopAndDestroy(3); // arrayOfCharacterSetsAvailable and characterSetConverter and fileServerSession
       
    89 	}
       
    90 
       
    91 GLDEF_C TInt E32Main()
       
    92 	{
       
    93 	__UHEAP_MARK;
       
    94 
       
    95 	TheTest.Title();
       
    96 
       
    97 	CTrapCleanup* trapCleanup=CTrapCleanup::New();
       
    98 	TEST(trapCleanup != NULL);
       
    99 
       
   100 	TRAPD(error, DoE32MainL());
       
   101 	TEST2(error, KErrNone);
       
   102 
       
   103 	delete trapCleanup;
       
   104 
       
   105 	TheTest.End();
       
   106 	TheTest.Close();
       
   107 
       
   108 	__UHEAP_MARKEND;
       
   109 	return KErrNone;
       
   110 	}
       
   111