os/kernelhwsrv/kerneltest/f32test/server/t_cp_plugin.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of the License "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 // 
    15 //
    16 //
    17 
    18 
    19 #include <f32file.h>
    20 #include <e32ldr.h>
    21 #include <e32ldr_private.h>
    22 #include <e32test.h>
    23 #include <hal.h>
    24 #include "t_server.h"
    25 #include "f32dbg.h"
    26 
    27 
    28 GLDEF_D RTest test(_L("T_CP_PLUGIN"));
    29 
    30 // function decalarations
    31 void DoCodePagePluginTest();
    32 void TestUnicodeVolumeLabel();
    33 void TestShortNameBoundary();
    34 void TestConsistentShortNameGeneration();
    35 void TestConsistentShortNameExtGeneration();
    36 void TestDuplicateLongFileNames();
    37 void TestDuplicateLongDirNames();
    38 void TestLeadingE5Handling();
    39 void TestDEF130334();
    40 void TestINC127905();
    41 void DeleteTestDirectory();
    42 void TestCompatibility();
    43 void TestINC126563();
    44 
    45 // Codepage dll name
    46 _LIT(KCP932Name,"T_CP932");
    47 
    48 TInt LoadCodePageDll(const TDesC& aCodePageDllName)
    49 	{
    50 	RDebug::Printf("++ T_CP_PLUGIN.CPP LoadCodePageDll");
    51 	
    52 	TInt err = KErrNone;
    53 	if(aCodePageDllName.Length())
    54 		{
    55 		RDebug::Print(_L("IS: codepageDllName = %S"), &aCodePageDllName);
    56 		RLoader loader;
    57 		err = loader.Connect();
    58 		if (err==KErrNone)
    59 			{
    60 			err = loader.SendReceive(ELoadCodePage, TIpcArgs(0, &aCodePageDllName, 0));
    61 			RDebug::Printf("\n T_CP_PLUGIN.CPP : LoadCodePageDll : loader.SendReceive == %d", err);
    62 			loader.Close();
    63 			}
    64 		}
    65 	RDebug::Printf("-- T_CP_PLUGIN.CPP LoadCodePageDll");
    66 	return err;
    67 	}
    68 
    69 void DoCodePagePluginTest()
    70 	{
    71 	RDebug::Printf("++ T_CP_PLUGIN.CPP DoCodePagePluginTestL");
    72 
    73 	CreateTestDirectory(_L("\\F32-TST\\T_CP_PLUGIN\\"));
    74 	TestUnicodeVolumeLabel();
    75 	TestShortNameBoundary();
    76 	TestConsistentShortNameGeneration();
    77 	TestConsistentShortNameExtGeneration();
    78 	TestDuplicateLongFileNames();
    79 	TestDuplicateLongDirNames();
    80 	TestLeadingE5Handling();
    81 	TestDEF130334();
    82 	TestINC127905();
    83 	DeleteTestDirectory();
    84 	TestCompatibility();
    85 	TestINC126563();
    86 	
    87 	RDebug::Printf("-- T_CP_PLUGIN.CPP DoCodePagePluginTestL");
    88 	}
    89 
    90 
    91 void CallTestsL(void)
    92 	{
    93 
    94 	test.Title();
    95 	test.Start(_L("Starting T_CP_PLUGIN tests"));
    96 
    97 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
    98 
    99 	// Test only runs on Fat file systems
   100 	TheFs.SessionPath(gSessionPath);
   101 	TInt driveNum = CurrentDrive();
   102 	TFSName name;
   103 	TInt r = TheFs.FileSystemName(name, driveNum);
   104 	if (KErrNone == r)
   105 		{
   106 		if (name.Compare(_L("Fat")) != 0)
   107 			{
   108 			test.Printf(_L("Test only runs on 'FAT' drives"));
   109 			}
   110 		else
   111 			{
   112 			TBuf<16> CodepageDllName(KCP932Name);
   113 			r = LoadCodePageDll(CodepageDllName);
   114 			test(r == KErrNone || r == KErrAlreadyExists);
   115 
   116 			if(r == KErrNone)
   117 				{
   118 				// should not allow loading again codepage dll.
   119 				r = LoadCodePageDll(CodepageDllName);
   120 				test(r == KErrAlreadyExists);
   121 
   122 				}
   123 
   124 			// Enables codepage dll implementation of LocaleUtils functions
   125 			TInt r = TheFs.ControlIo(CurrentDrive(), KControlIoEnableFatUtilityFunctions);
   126 			test(KErrNone == r);
   127 
   128 			DoCodePagePluginTest();
   129 
   130 			// Disables codepage dll implementation of LocaleUtils functions for other base tests
   131 			r = TheFs.ControlIo(driveNum, KControlIoDisableFatUtilityFunctions);
   132 			test(r == KErrNone);
   133 			}
   134 		}
   135 	else
   136 		{
   137 		test.Printf(_L("Drive %C: is not ready!"), 'A'+driveNum);
   138 		test(EFalse);
   139 		}
   140 #else
   141 	test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details."));
   142 #endif  // _DEBUG) || _DEBUG_RELEASE
   143 	test.End();
   144 	}
   145