charconvfw/charconvplugins/test/rtest/tsrc/main/t_big5.cpp
changeset 51 a7c938434754
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/charconvfw/charconvplugins/test/rtest/tsrc/main/t_big5.cpp	Wed Aug 18 11:34:25 2010 +0300
@@ -0,0 +1,92 @@
+/*
+* Copyright (c) 1997-2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#include <e32std.h>
+#include <e32base.h>
+#include <f32file.h>
+#include <charconv.h>
+#include "t_big5.h"
+
+#define test(cond)                                  \
+    {                                               \
+    TBool __bb = (cond);                            \
+    TEST(__bb);                                     \
+    if (!__bb)                                      \
+        {                                           \
+        ERR_PRINTF1(_L("ERROR: Test Failed"));      \
+        User::Leave(1);                             \
+        }                                           \
+    }
+
+/**
+@SYMTestCaseID          SYSLIB-CHARCONV-CT-0515
+@SYMTestCaseDesc        Tests for defect number EDNSHAY-45VJAU
+@SYMTestPriority        Medium
+@SYMTestActions         Tests for CCnvCharacterSetConverter::ConvertToUnicode() function
+@SYMTestExpectedResults Test must not fail
+@SYMREQ                 REQ0000
+*/
+void CT_BIG5::DoE32MainL()
+	{
+	RFs fileServerSession;
+	CleanupClosePushL(fileServerSession);
+	User::LeaveIfError(fileServerSession.Connect());
+	CCnvCharacterSetConverter* characterSetConverter=CCnvCharacterSetConverter::NewLC();
+	CArrayFix<CCnvCharacterSetConverter::SCharacterSet>* arrayOfCharacterSetsAvailable=CCnvCharacterSetConverter::CreateArrayOfCharacterSetsAvailableLC(fileServerSession);
+	INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-CHARCONV-CT-0515 Available:\n "));
+	for (TInt i=arrayOfCharacterSetsAvailable->Count()-1; i>=0; --i)
+		{
+		const CCnvCharacterSetConverter::SCharacterSet& charactersSet=(*arrayOfCharacterSetsAvailable)[i];
+		characterSetConverter->PrepareToConvertToOrFromL(charactersSet.Identifier(), *arrayOfCharacterSetsAvailable, fileServerSession);
+		TPtrC charactersSetName(charactersSet.Name());
+		if (charactersSet.NameIsFileName())
+			{
+			charactersSetName.Set(TParsePtrC(charactersSetName).Name());
+			}
+		INFO_PRINTF2(_L("    %S\n"), &charactersSetName);
+		}
+	TInt state=CCnvCharacterSetConverter::KStateDefault;
+	INFO_PRINTF1(_L("Testing fix for defect number EDNSHAY-45VJAU"));
+	characterSetConverter->PrepareToConvertToOrFromL(KCharacterSetIdentifierBig5, *arrayOfCharacterSetsAvailable, fileServerSession);
+	TBuf16<28> generatedUnicode;
+	test(characterSetConverter->ConvertToUnicode(generatedUnicode, _L8("++   ZAC"), state)==0);
+	test(state==CCnvCharacterSetConverter::KStateDefault);
+	CleanupStack::PopAndDestroy(3); // arrayOfCharacterSetsAvailable and characterSetConverter and fileServerSession
+	}
+
+CT_BIG5::CT_BIG5()
+    {
+    SetTestStepName(KTestStep_T_BIG5);
+    }
+
+TVerdict CT_BIG5::doTestStepL()
+    {
+    SetTestStepResult(EFail);
+
+    __UHEAP_MARK;
+    TRAPD(error1, DoE32MainL());
+    __UHEAP_MARKEND;
+
+    if(error1 == KErrNone)
+        {
+        SetTestStepResult(EPass);
+        }
+
+    return TestStepResult();
+    }
+