charconvfw/fatfilenameconversionplugins/test/T_CP950.CPP
branchRCL_3
changeset 55 336bee5c2d35
parent 54 748ec5531811
equal deleted inserted replaced
54:748ec5531811 55:336bee5c2d35
     1 /*
     1 /*
     2 * Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2006-2009 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 "T_CP950.h"
    19 #include <e32test.h>
    20 #include <e32des8.h>
    20 #include <e32des8.h>
    21 
    21 
    22 #define test(cond)                                          \
    22 LOCAL_D RTest test(_L("T_CP950.exe"));
    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 
       
    33 
    23 
    34 _LIT16(Uni_1, "\x0053\x3125\x3122\xAAAA\x9673\x2593\xFA0C\x3000");
    24 _LIT16(Uni_1, "\x0053\x3125\x3122\xAAAA\x9673\x2593\xFA0C\x3000");
    35 _LIT8(CP950_1, "\x53\xA3\xB6\xA3\xB3\x5F\xB3\xAF\xF9\xFE\xC9\x4A\xA1\x40");
    25 _LIT8(CP950_1, "\x53\xA3\xB6\xA3\xB3\x5F\xB3\xAF\xF9\xFE\xC9\x4A\xA1\x40");
    36 _LIT16(Uni_2, "\x0032\xFFFD\xFE3E\xFFFD\xFFFD");
    26 _LIT16(Uni_2, "\x0032\xFFFD\xFE3E\xFFFD\xFFFD");
    37 _LIT8(CP950_2, "\x32\x80\xA1\x70\xC1\x7F\xA7");
    27 _LIT8(CP950_2, "\x32\x80\xA1\x70\xC1\x7F\xA7");
    49 @SYMTestCaseDesc	    Tests API behaviours of UnicodeConv class
    39 @SYMTestCaseDesc	    Tests API behaviours of UnicodeConv class
    50 @SYMTestPriority 	    High
    40 @SYMTestPriority 	    High
    51 @SYMTestActions  	    Tests for conversions from/to Unicode, using a function pointer
    41 @SYMTestActions  	    Tests for conversions from/to Unicode, using a function pointer
    52 @SYMTestExpectedResults Test must not fail
    42 @SYMTestExpectedResults Test must not fail
    53 */
    43 */
    54 void CT_CP950::TestL()
    44 void Test()
    55 	{
    45 	{
    56     INFO_PRINTF1(_L("@SYMTestCaseID:SYSLIB-FATCHARSETCONV-CT-1776"));
    46 	test.Next(_L("@SYMTestCaseID:SYSLIB-FATCHARSETCONV-CT-1776"));
    57 	RLibrary lib;
    47 	RLibrary lib;
    58 
    48 
    59 	const TUidType serverUid(KNullUid,KNullUid,KPluginUid);
    49 	const TUidType serverUid(KNullUid,KNullUid,KPluginUid);
    60 	// load the dll
    50 	// load the dll
    61 	TInt returnValue = lib.Load(KName,serverUid);
    51 	TInt returnValue = lib.Load(KName,serverUid);
   105 
    95 
   106 	lib.Close();
    96 	lib.Close();
   107 	}
    97 	}
   108 
    98 
   109 // test code for INC080460: FATCharsetConv panics - stops china build booting
    99 // test code for INC080460: FATCharsetConv panics - stops china build booting
   110 void CT_CP950::TestINC080460L()
   100 void TestINC080460()
   111 	{
   101 	{
   112 	RLibrary lib;
   102 	RLibrary lib;
   113 	const TUidType serverUid(KNullUid,KNullUid,KPluginUid);
   103 	const TUidType serverUid(KNullUid,KNullUid,KPluginUid);
   114 
   104 
   115 	// load the dll
   105 	// load the dll
   200 @SYMTestCaseDesc	    Tests API behaviours of UnicodeConv class as part of INC090073
   190 @SYMTestCaseDesc	    Tests API behaviours of UnicodeConv class as part of INC090073
   201 @SYMTestPriority 	    High
   191 @SYMTestPriority 	    High
   202 @SYMTestActions  	    Tests for correct character conversion on certain chinese characters for CP936
   192 @SYMTestActions  	    Tests for correct character conversion on certain chinese characters for CP936
   203 @SYMTestExpectedResults Test must not fail
   193 @SYMTestExpectedResults Test must not fail
   204 */
   194 */
   205 void CT_CP950::TestINC090073L()
   195 void TestINC090073()
   206 	{
   196 	{
   207     INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-FATCHARSETCONV-CT-1847-0003 "));
   197 	test.Next(_L(" @SYMTestCaseID:SYSLIB-FATCHARSETCONV-CT-1847-0003 "));
   208  	_LIT16(unicode, "\x7C91\x8026\x8160\x7633\x6DFC\x715C\x6600\x9785\x86D8\x7A37\x61A9\x80B1\x86A3\x89E5\x80F2\x9B48\x6C19\x7B71\x946B\x6B46\x6615");
   198  	_LIT16(unicode, "\x7C91\x8026\x8160\x7633\x6DFC\x715C\x6600\x9785\x86D8\x7A37\x61A9\x80B1\x86A3\x89E5\x80F2\x9B48\x6C19\x7B71\x946B\x6B46\x6615");
   209 	_LIT8(CP950Code, "\xD3\x4A\xBD\xA2\xDF\x73\xEA\x6F\xD9\xE7\xB7\xD4\xA9\xFB\xBB\xDF\xDB\xB1\xBD\x5E\xBE\xCD\xAA\xD0\xB0\x47\xDF\xFD\xD3\x6A\xEF\x69\xCB\x49\xDF\x4E\xF8\xCA\xDD\xF5\xA9\xFD");
   199 	_LIT8(CP950Code, "\xD3\x4A\xBD\xA2\xDF\x73\xEA\x6F\xD9\xE7\xB7\xD4\xA9\xFB\xBB\xDF\xDB\xB1\xBD\x5E\xBE\xCD\xAA\xD0\xB0\x47\xDF\xFD\xD3\x6A\xEF\x69\xCB\x49\xDF\x4E\xF8\xCA\xDD\xF5\xA9\xFD");
   210 
   200 
   211 	RLibrary lib;
   201 	RLibrary lib;
   212 
   202 
   233 	foreign1.Zero();
   223 	foreign1.Zero();
   234 
   224 
   235 	lib.Close();
   225 	lib.Close();
   236 	}
   226 	}
   237 
   227 
   238 void CT_CP950::OOMTestL()
   228 void OOMTest()
   239 	{
   229 	{
   240     INFO_PRINTF1(_L("OOM testing"));
   230 	test.Next(_L("OOM testing"));
   241 	TInt err, tryCount = 0;
   231 	TInt err, tryCount = 0;
   242 	do
   232 	do
   243 		{
   233 		{
   244 			__UHEAP_MARK;
   234 			__UHEAP_MARK;
   245   		// find out the number of open handles
   235   		// find out the number of open handles
   248 		RThread().HandleCount(startProcessHandleCount, startThreadHandleCount);
   238 		RThread().HandleCount(startProcessHandleCount, startThreadHandleCount);
   249 
   239 
   250 			// Setting Heap failure for OOM test
   240 			// Setting Heap failure for OOM test
   251 		__UHEAP_SETFAIL(RHeap::EDeterministic, ++tryCount);
   241 		__UHEAP_SETFAIL(RHeap::EDeterministic, ++tryCount);
   252 
   242 
   253 		TRAP(err,TestL());
   243 		TRAP(err,Test());
   254 
   244 
   255 		__UHEAP_SETFAIL(RHeap::ENone, 0);
   245 		__UHEAP_SETFAIL(RHeap::ENone, 0);
   256 
   246 
   257 		// check that no handles have leaked
   247 		// check that no handles have leaked
   258 		TInt endProcessHandleCount;
   248 		TInt endProcessHandleCount;
   264 
   254 
   265 		__UHEAP_MARKEND;
   255 		__UHEAP_MARKEND;
   266 		}while (err == KErrNoMemory);
   256 		}while (err == KErrNoMemory);
   267 
   257 
   268 	test(err == KErrNone);
   258 	test(err == KErrNone);
   269 	INFO_PRINTF2(_L("- server succeeded at heap failure rate of %i\n"), tryCount);
   259 	test.Printf(_L("- server succeeded at heap failure rate of %i\n"), tryCount);
   270 	}
   260 	}
   271 
   261 
   272 
   262 
   273 CT_CP950::CT_CP950()
   263 LOCAL_C void DoE32MainL()
   274     {
   264 	{
   275     SetTestStepName(KTestStep_T_CP950);
   265 	Test();
   276     }
   266 	TestINC090073();
   277 
   267 	TestINC080460();
   278 
   268 	OOMTest();
   279 TVerdict CT_CP950::doTestStepL()
   269 	}
   280     {
   270 
   281     SetTestStepResult(EFail);
   271 GLDEF_C TInt E32Main()
   282 
   272 	{
   283     __UHEAP_MARK;
   273 	__UHEAP_MARK;
   284 
   274 
   285     TRAPD(error1, TestL());
   275 	test.Title();
   286     TRAPD(error2, TestINC090073L());
   276 	test.Start(_L("CP950 test..."));
   287     TRAPD(error3, TestINC080460L());
   277 
   288     TRAPD(error4, OOMTestL());
   278 	CTrapCleanup* trapCleanup=CTrapCleanup::New();
   289 
   279 	TRAPD(error, DoE32MainL());
   290     __UHEAP_MARKEND;
   280 	delete trapCleanup;
   291 
   281 
   292     if(error1 == KErrNone && error2 == KErrNone && error3 == KErrNone && error4 == KErrNone)
   282 	test.End();
   293         {
   283 	test.Close();
   294         SetTestStepResult(EPass);
   284 
   295         }
   285 	__UHEAP_MARKEND;
   296 
   286 	return error;
   297     return TestStepResult();
   287 	}
   298     }