charconvfw/fatfilenameconversionplugins/test/T_CP874.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_CP874.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_CP874.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\x0059\x004D\x0042\x0049\x0041\x004E\x3125\x0E45\xFFFF");
    24 _LIT16(Uni_1, "\x0053\x0059\x004D\x0042\x0049\x0041\x004E\x3125\x0E45\xFFFF");
    35 _LIT8(CP874_1, "\x53\x59\x4D\x42\x49\x41\x4E\x5F\xE5\x5F");
    25 _LIT8(CP874_1, "\x53\x59\x4D\x42\x49\x41\x4E\x5F\xE5\x5F");
    36 _LIT16(Uni_2, "\x0032\x20AC\x0E01\xFFFD");
    26 _LIT16(Uni_2, "\x0032\x20AC\x0E01\xFFFD");
    37 _LIT8(CP874_2, "\x32\x80\xA1\x8A");
    27 _LIT8(CP874_2, "\x32\x80\xA1\x8A");
    48 @SYMTestCaseDesc	    Tests API behaviours of UnicodeConv class
    38 @SYMTestCaseDesc	    Tests API behaviours of UnicodeConv class
    49 @SYMTestPriority 	    High
    39 @SYMTestPriority 	    High
    50 @SYMTestActions  	    Tests for conversions from/to Unicode, using a function pointer
    40 @SYMTestActions  	    Tests for conversions from/to Unicode, using a function pointer
    51 @SYMTestExpectedResults Test must not fail
    41 @SYMTestExpectedResults Test must not fail
    52 */
    42 */
    53 void CT_CP874::TestL()
    43 void Test()
    54 	{
    44 	{
    55 	RLibrary lib;
    45 	RLibrary lib;
    56 
    46 
    57 	const TUidType serverUid(KNullUid,KNullUid,KPluginUid);
    47 	const TUidType serverUid(KNullUid,KNullUid,KPluginUid);
    58 	// load the dll
    48 	// load the dll
   100 	test(result==0);
    90 	test(result==0);
   101 
    91 
   102 	lib.Close();
    92 	lib.Close();
   103 	}
    93 	}
   104 
    94 
   105 void CT_CP874::OOMTestL()
    95 void OOMTest()
   106 	{
    96 	{
   107     INFO_PRINTF1(_L("OOM testing"));
    97 	test.Next(_L("OOM testing"));
   108 	TInt err, tryCount = 0;
    98 	TInt err, tryCount = 0;
   109 	do
    99 	do
   110 		{
   100 		{
   111 			__UHEAP_MARK;
   101 			__UHEAP_MARK;
   112   		// find out the number of open handles
   102   		// find out the number of open handles
   115 		RThread().HandleCount(startProcessHandleCount, startThreadHandleCount);
   105 		RThread().HandleCount(startProcessHandleCount, startThreadHandleCount);
   116 
   106 
   117 			// Setting Heap failure for OOM test
   107 			// Setting Heap failure for OOM test
   118 		__UHEAP_SETFAIL(RHeap::EDeterministic, ++tryCount);
   108 		__UHEAP_SETFAIL(RHeap::EDeterministic, ++tryCount);
   119 
   109 
   120 		TRAP(err,TestL());
   110 		TRAP(err,Test());
   121 
   111 
   122 		__UHEAP_SETFAIL(RHeap::ENone, 0);
   112 		__UHEAP_SETFAIL(RHeap::ENone, 0);
   123 
   113 
   124 		// check that no handles have leaked
   114 		// check that no handles have leaked
   125 		TInt endProcessHandleCount;
   115 		TInt endProcessHandleCount;
   131 
   121 
   132 		__UHEAP_MARKEND;
   122 		__UHEAP_MARKEND;
   133 		}while (err == KErrNoMemory);
   123 		}while (err == KErrNoMemory);
   134 
   124 
   135 	test(err == KErrNone);
   125 	test(err == KErrNone);
   136 	INFO_PRINTF2(_L("- server succeeded at heap failure rate of %i\n"), tryCount);
   126 	test.Printf(_L("- server succeeded at heap failure rate of %i\n"), tryCount);
   137 	}
   127 	}
   138 
   128 
   139 
   129 
   140 CT_CP874::CT_CP874()
   130 LOCAL_C void DoE32MainL()
   141     {
   131 	{
   142     SetTestStepName(KTestStep_T_CP874);
   132 	Test();
   143     }
   133 	OOMTest();
       
   134 	}
   144 
   135 
       
   136 GLDEF_C TInt E32Main()
       
   137 	{
       
   138 	__UHEAP_MARK;
   145 
   139 
   146 TVerdict CT_CP874::doTestStepL()
   140 	test.Title();
   147     {
   141 	test.Start(_L(" @SYMTestCaseID:SYSLIB-FATCHARSETCONV-CT-1780 CP874 test... "));
   148     SetTestStepResult(EFail);
       
   149 
   142 
   150     __UHEAP_MARK;
   143 	CTrapCleanup* trapCleanup=CTrapCleanup::New();
       
   144 	TRAPD(error, DoE32MainL());
       
   145 	delete trapCleanup;
   151 
   146 
   152     TRAPD(error1, TestL());
   147 	test.End();
   153     TRAPD(error2, OOMTestL());
   148 	test.Close();
   154 
   149 
   155     __UHEAP_MARKEND;
   150 	__UHEAP_MARKEND;
       
   151 	return error;
       
   152 	}
   156 
   153 
   157     if(error1 == KErrNone && error2 == KErrNone)
       
   158         {
       
   159         SetTestStepResult(EPass);
       
   160         }
       
   161 
       
   162     return TestStepResult();
       
   163     }
       
   164