charconvfw/fatfilenameconversionplugins/test/T_CP932.CPP
branchRCL_3
changeset 54 748ec5531811
parent 0 1fb32624e06b
child 55 336bee5c2d35
equal deleted inserted replaced
36:f902e87c146f 54:748ec5531811
     1 /*
     1 /*
     2 * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    14 * Description: 
    14 * Description: 
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 
    18 
    19 #include <e32test.h>
    19 #include "T_CP932.h"
    20 #include <e32des8.h>
    20 #include <e32des8.h>
    21 
    21 
    22 LOCAL_D RTest test(_L("T_CP932.exe"));
    22 #define test(cond)                                          \
       
    23     {                                                       \
       
    24     TBool __bb = (cond);                                    \
       
    25     TEST(__bb);                                             \
       
    26     if (!__bb)                                              \
       
    27         {                                                   \
       
    28         ERR_PRINTF1(_L("ERROR: Test Failed"));              \
       
    29         User::Leave(1);                                     \
       
    30         }                                                   \
       
    31     }
       
    32 
    23 
    33 
    24 _LIT16(Uni_1, "\x0053\x0059\x004D\x3125\x6349\xAAAA\x9673\x9ED1\x3000\xFF9F");
    34 _LIT16(Uni_1, "\x0053\x0059\x004D\x3125\x6349\xAAAA\x9673\x9ED1\x3000\xFF9F");
    25 _LIT8(CP932_1, "\x53\x59\x4D\x5F\x91\xA8\x5F\x92\xC2\xEE\xEC\x81\x40\xDF");
    35 _LIT8(CP932_1, "\x53\x59\x4D\x5F\x91\xA8\x5F\x92\xC2\xEE\xEC\x81\x40\xDF");
    26 _LIT16(Uni_2, "\x0032\x0070\xFFFD\xFF61\x8D77\xFFFD\xFFFD");
    36 _LIT16(Uni_2, "\x0032\x0070\xFFFD\xFF61\x8D77\xFFFD\xFFFD");
    27 _LIT8(CP932_2, "\x32\x70\x80\xA1\x8B\x4E\xA0\x96\x7F");
    37 _LIT8(CP932_2, "\x32\x70\x80\xA1\x8B\x4E\xA0\x96\x7F");
    39 @SYMTestCaseID          SYSLIB-FATCHARSETCONV-CT-1779
    49 @SYMTestCaseID          SYSLIB-FATCHARSETCONV-CT-1779
    40 @SYMTestCaseDesc	    Tests API behaviours of UnicodeConv class
    50 @SYMTestCaseDesc	    Tests API behaviours of UnicodeConv class
    41 @SYMTestPriority 	    High
    51 @SYMTestPriority 	    High
    42 @SYMTestActions  	    Tests for conversions from/to Unicode, using a function pointer
    52 @SYMTestActions  	    Tests for conversions from/to Unicode, using a function pointer
    43 @SYMTestExpectedResults Test must not fail 
    53 @SYMTestExpectedResults Test must not fail 
    44 */void Test()
    54 */
       
    55 void CT_CP932::TestL()
    45 	{ 
    56 	{ 
    46 		test.Next(_L(" @SYMTestCaseID:SYSLIB-FATCHARSETCONV-CT-1779 "));
    57     INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-FATCHARSETCONV-CT-1779 "));
    47 	RLibrary lib;
    58 	RLibrary lib;
    48 
    59 
    49 	const TUidType serverUid(KNullUid,KNullUid,KPluginUid);	
    60 	const TUidType serverUid(KNullUid,KNullUid,KPluginUid);	
    50 	// load the dll	
    61 	// load the dll	
    51 	TInt returnValue = lib.Load(KName,serverUid);
    62 	TInt returnValue = lib.Load(KName,serverUid);
   108 @SYMTestCaseDesc	    Tests API behaviours of UnicodeConv class as part of INC090073
   119 @SYMTestCaseDesc	    Tests API behaviours of UnicodeConv class as part of INC090073
   109 @SYMTestPriority 	    High
   120 @SYMTestPriority 	    High
   110 @SYMTestActions  	    Tests for correct character conversion on certain chinese characters 
   121 @SYMTestActions  	    Tests for correct character conversion on certain chinese characters 
   111 @SYMTestExpectedResults Test must not fail 
   122 @SYMTestExpectedResults Test must not fail 
   112 */	
   123 */	
   113 void TestINC090073()
   124 void CT_CP932::TestINC090073L()
   114 	{
   125 	{
   115 		test.Next(_L(" @SYMTestCaseID:SYSLIB-FATCHARSETCONV-CT-1847 "));
   126     INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-FATCHARSETCONV-CT-1847 "));
   116  	_LIT16(unicode, "\x6DFC\x715C\x9785\x7A37\x61A9\x80B1\x86A3\x7B71\x6615\x6600");
   127  	_LIT16(unicode, "\x6DFC\x715C\x9785\x7A37\x61A9\x80B1\x86A3\x7B71\x6615\x6600");
   117 	_LIT8(CP932Code, "\xED\xE6\xED\xF6\xE8\xD7\xE2\x6C\x8C\x65\x8D\x6E\xE5\x6E\xE2\xAA\xED\xB3\xED\xB2");
   128 	_LIT8(CP932Code, "\xED\xE6\xED\xF6\xE8\xD7\xE2\x6C\x8C\x65\x8D\x6E\xE5\x6E\xE2\xAA\xED\xB3\xED\xB2");
   118 
   129 
   119 	RLibrary lib;
   130 	RLibrary lib;
   120 
   131 
   140 	foreign1.Zero();
   151 	foreign1.Zero();
   141 
   152 
   142 	lib.Close();
   153 	lib.Close();
   143 	}	
   154 	}	
   144 
   155 
   145 void OOMTest()
   156 void CT_CP932::OOMTestL()
   146 	{
   157 	{
   147 	test.Next(_L("OOM testing"));
   158     INFO_PRINTF1(_L("OOM testing"));
   148 	TInt err, tryCount = 0;
   159 	TInt err, tryCount = 0;
   149 	do	
   160 	do	
   150 		{
   161 		{
   151 			__UHEAP_MARK;
   162 			__UHEAP_MARK;
   152   		// find out the number of open handles
   163   		// find out the number of open handles
   155 		RThread().HandleCount(startProcessHandleCount, startThreadHandleCount);
   166 		RThread().HandleCount(startProcessHandleCount, startThreadHandleCount);
   156 		
   167 		
   157 			// Setting Heap failure for OOM test
   168 			// Setting Heap failure for OOM test
   158 		__UHEAP_SETFAIL(RHeap::EDeterministic, ++tryCount);
   169 		__UHEAP_SETFAIL(RHeap::EDeterministic, ++tryCount);
   159 
   170 
   160 		TRAP(err,Test());
   171 		TRAP(err,TestL());
   161 			
   172 			
   162 		__UHEAP_SETFAIL(RHeap::ENone, 0);
   173 		__UHEAP_SETFAIL(RHeap::ENone, 0);
   163 		
   174 		
   164 		// check that no handles have leaked
   175 		// check that no handles have leaked
   165 		TInt endProcessHandleCount;
   176 		TInt endProcessHandleCount;
   171 
   182 
   172 		__UHEAP_MARKEND;
   183 		__UHEAP_MARKEND;
   173 		}while (err == KErrNoMemory);
   184 		}while (err == KErrNoMemory);
   174 		
   185 		
   175 	test(err == KErrNone);
   186 	test(err == KErrNone);
   176 	test.Printf(_L("- server succeeded at heap failure rate of %i\n"), tryCount);
   187 	INFO_PRINTF2(_L("- server succeeded at heap failure rate of %i\n"), tryCount);
   177 	}
   188 	}
   178 
   189 
   179 
   190 
   180 LOCAL_C void DoE32MainL()
   191 CT_CP932::CT_CP932()
   181 	{
   192     {
   182 	__UHEAP_MARK;
   193     SetTestStepName(KTestStep_T_CP932);
   183 
   194     }
   184 	Test();
   195 
   185 	TestINC090073();
   196 
   186 	OOMTest();
   197 TVerdict CT_CP932::doTestStepL()
   187 
   198     {
   188 	__UHEAP_MARKEND;
   199     SetTestStepResult(EFail);
   189 	}
   200 
   190 
   201     __UHEAP_MARK;
   191 GLDEF_C TInt E32Main()
   202 
   192 	{
   203     TRAPD(error1, TestL());
   193 	__UHEAP_MARK;
   204     TRAPD(error2, TestINC090073L());
   194 
   205     TRAPD(error3, OOMTestL());
   195 	test.Title();
   206 
   196 	test.Start(_L("CP932 test..."));
   207     __UHEAP_MARKEND;
   197 
   208 
   198 	CTrapCleanup* trapCleanup=CTrapCleanup::New();
   209     if(error1 == KErrNone && error2 == KErrNone && error3 == KErrNone)
   199 	TRAPD(error, DoE32MainL());
   210         {
   200 	test(error==KErrNone);
   211         SetTestStepResult(EPass);
   201 
   212         }
   202 	delete trapCleanup;
   213 
   203 
   214     return TestStepResult();
   204 	test.End();
   215     }
   205 	test.Close();
       
   206 
       
   207 	__UHEAP_MARKEND;
       
   208 	return error;
       
   209 	}