charconvfw/fatfilenameconversionplugins/test/T_CP1250.CPP
branchRCL_3
changeset 17 336bee5c2d35
parent 16 748ec5531811
equal deleted inserted replaced
16:748ec5531811 17: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_CP1250.h"
    19 #include <e32test.h>
    20 #include <e32std.h>
    20 #include <e32std.h>
    21 
    21 
    22 #define test(cond)                                          \
    22 LOCAL_D RTest test(_L("T_CP1250.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, "\xFFFF\x0053\x0059\x004D\x0042\x0049\x0041\x004E\xAAAA\x20AC\x02C7\x2015");
    24 _LIT16(Uni_1, "\xFFFF\x0053\x0059\x004D\x0042\x0049\x0041\x004E\xAAAA\x20AC\x02C7\x2015");
    35 _LIT8(CP1250_1, "\x5F\x53\x59\x4D\x42\x49\x41\x4E\x5F\x80\xA1\x5F");
    25 _LIT8(CP1250_1, "\x5F\x53\x59\x4D\x42\x49\x41\x4E\x5F\x80\xA1\x5F");
    36 _LIT16(Uni_2, "\x02C7\xFFFD\x00AD");
    26 _LIT16(Uni_2, "\x02C7\xFFFD\x00AD");
    37 _LIT8(CP1250_2, "\xA1\x98\xAD");
    27 _LIT8(CP1250_2, "\xA1\x98\xAD");
    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_CP1250::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
   106 	test(result==0);
    96 	test(result==0);
   107 
    97 
   108 	lib.Close();
    98 	lib.Close();
   109 	}
    99 	}
   110 
   100 
   111 void CT_CP1250::OOMTestL()
   101 void OOMTest()
   112 	{
   102 	{
   113     INFO_PRINTF1(_L("OOM testing"));
   103 	test.Next(_L("OOM testing"));
   114 	TInt err, tryCount = 0;
   104 	TInt err, tryCount = 0;
   115 	do
   105 	do
   116 		{
   106 		{
   117 			__UHEAP_MARK;
   107 			__UHEAP_MARK;
   118   		// find out the number of open handles
   108   		// find out the number of open handles
   121 		RThread().HandleCount(startProcessHandleCount, startThreadHandleCount);
   111 		RThread().HandleCount(startProcessHandleCount, startThreadHandleCount);
   122 
   112 
   123 			// Setting Heap failure for OOM test
   113 			// Setting Heap failure for OOM test
   124 		__UHEAP_SETFAIL(RHeap::EDeterministic, ++tryCount);
   114 		__UHEAP_SETFAIL(RHeap::EDeterministic, ++tryCount);
   125 
   115 
   126 		TRAP(err,TestL());
   116 		TRAP(err,Test());
   127 
   117 
   128 		__UHEAP_SETFAIL(RHeap::ENone, 0);
   118 		__UHEAP_SETFAIL(RHeap::ENone, 0);
   129 
   119 
   130 		// check that no handles have leaked
   120 		// check that no handles have leaked
   131 		TInt endProcessHandleCount;
   121 		TInt endProcessHandleCount;
   137 
   127 
   138 		__UHEAP_MARKEND;
   128 		__UHEAP_MARKEND;
   139 		}while (err == KErrNoMemory);
   129 		}while (err == KErrNoMemory);
   140 
   130 
   141 	test(err == KErrNone);
   131 	test(err == KErrNone);
   142 	INFO_PRINTF2(_L("- server succeeded at heap failure rate of %i\n"), tryCount);
   132 	test.Printf(_L("- server succeeded at heap failure rate of %i\n"), tryCount);
   143 	}
   133 	}
   144 
   134 
   145 
   135 
   146 CT_CP1250::CT_CP1250()
   136 LOCAL_C void DoE32MainL()
   147     {
   137 	{
   148     SetTestStepName(KTestStep_T_CP1250);
   138 	Test();
   149     }
   139 	OOMTest();
       
   140 	}
   150 
   141 
   151 
   142 
   152 TVerdict CT_CP1250::doTestStepL()
   143 GLDEF_C TInt E32Main()
   153     {
   144 	{
   154     SetTestStepResult(EFail);
   145 	__UHEAP_MARK;
   155 
   146 
   156     __UHEAP_MARK;
   147 	test.Title();
       
   148 	test.Start(_L(" @SYMTestCaseID:SYSLIB-FATCHARSETCONV-CT-1789 CP1250 tests... "));
   157 
   149 
   158     TRAPD(error1, TestL());
   150 	CTrapCleanup* trapCleanup=CTrapCleanup::New();
   159     TRAPD(error2, OOMTestL());
   151 	TRAPD(error, DoE32MainL());
       
   152 	delete trapCleanup;
   160 
   153 
   161     __UHEAP_MARKEND;
   154 	test.End();
       
   155 	test.Close();
   162 
   156 
   163     if(error1 == KErrNone && error2 == KErrNone)
   157 	__UHEAP_MARKEND;
   164         {
   158 	return error;
   165         SetTestStepResult(EPass);
   159 	}
   166         }
       
   167 
       
   168     return TestStepResult();
       
   169     }