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