kerneltest/f32test/server/t_localeutils_cp932.cpp
changeset 0 a41df078684a
child 33 0173bcd7697c
equal deleted inserted replaced
-1:000000000000 0:a41df078684a
       
     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 // f32test\locl\localeutils\t_localeutils_cp932.cpp
       
    15 // 
       
    16 //
       
    17 
       
    18 #define __E32TEST_EXTENSION__
       
    19 
       
    20 
       
    21 #include <e32test.h>
       
    22 #include <HAL.H>
       
    23 #include <f32fsys.h>
       
    24 #include <f32dbg.h>
       
    25 #include "..\server\t_server.h"
       
    26 #include "fat_utils.h"
       
    27 
       
    28 RTest test(_L("T_LOCALEUTILS_CP932"));
       
    29 	
       
    30 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
       
    31 using namespace Fat_Test_Utils;
       
    32 static RRawDisk TheDisk;
       
    33 static TFatBootSector gBootSector;
       
    34 _LIT(KTestLocale, "t_tlocl_cp932.dll");
       
    35 
       
    36 void QuickFormat()
       
    37     {
       
    38     FormatFatDrive(TheFs, CurrentDrive(), ETrue);
       
    39     }
       
    40 
       
    41 void ReadBootSector(TFatBootSector& aBootSector)
       
    42 	{
       
    43 
       
    44     TInt nRes = ReadBootSector(TheFs, CurrentDrive(), KBootSectorNum<<KDefaultSectorLog2, aBootSector);
       
    45     test(nRes == KErrNone);
       
    46 
       
    47     if(!aBootSector.IsValid())
       
    48         {
       
    49         test.Printf(_L("Wrong bootsector! Dump:\n"));
       
    50         aBootSector.PrintDebugInfo();
       
    51         test(0);
       
    52         }
       
    53 	}
       
    54 
       
    55 void GetBootInfo()
       
    56 	{
       
    57 	QuickFormat();
       
    58 	ReadBootSector(gBootSector);
       
    59 	}
       
    60 
       
    61 void doDirNameTest(const TDesC& aLongName, const TDesC& aShortName)
       
    62 	{
       
    63 	TBuf<KMaxFileName> longDirNamePath;
       
    64 	TBuf<KMaxFileName> shortDirNamePath;
       
    65 	TBuf<KMaxFileName> longName;
       
    66 	TBuf<KMaxFileName> shortName;
       
    67 	longDirNamePath = gSessionPath;
       
    68 	longDirNamePath += aLongName;
       
    69 	longDirNamePath.Append('\\');
       
    70 
       
    71 	// Create new directory and check creation
       
    72 	TInt r = TheFs.MkDir(longDirNamePath);
       
    73 	test_KErrNone(r);
       
    74 	TUint dumUint=0;
       
    75 	CDir* dumDir;
       
    76 	r= TheFs.GetDir(longDirNamePath, dumUint, dumUint, dumDir);
       
    77 	test_KErrNone(r);
       
    78 	test_NotNull(dumDir);
       
    79 	delete dumDir;
       
    80 
       
    81 	// Check short name
       
    82 	r = TheFs.GetShortName(longDirNamePath, shortName);
       
    83 	test_KErrNone(r);
       
    84 	r = shortName.Compare(aShortName);
       
    85 	test_Equal(r, 0);
       
    86 	
       
    87 	// Check long name
       
    88 	shortDirNamePath = gSessionPath;
       
    89 	shortDirNamePath += shortName;
       
    90 	shortDirNamePath.Append('\\');
       
    91 	r = TheFs.GetLongName(shortDirNamePath, longName);
       
    92 	test_KErrNone(r);
       
    93 	r = longName.Compare(aLongName);
       
    94 	test_Equal(r, 0);
       
    95 
       
    96 	r = TheFs.RmDir(longDirNamePath);
       
    97 	test_KErrNone(r);
       
    98 	}
       
    99 
       
   100 void doFileNameTest(const TDesC& aLongName, const TDesC& aShortName)
       
   101 	{
       
   102 	TFileName lgnFullPath;
       
   103 	TFileName shnFullPath;
       
   104 	TFileName lgn;
       
   105 	TFileName shn;
       
   106 
       
   107 	TInt r = TheFs.SessionPath(gSessionPath);
       
   108 	test_KErrNone(r);
       
   109 	lgnFullPath = gSessionPath;
       
   110 	lgnFullPath += aLongName;
       
   111 	
       
   112 	MakeFile(lgnFullPath);
       
   113 	
       
   114 	// Check short name	
       
   115 	r = TheFs.GetShortName(lgnFullPath, shn);
       
   116 	test_KErrNone(r);
       
   117 	r = shn.Compare(aShortName);
       
   118 	test_Equal(r, 0);
       
   119 
       
   120 	// Check long name	
       
   121 	shnFullPath = gSessionPath;
       
   122 	shnFullPath += aShortName;
       
   123 
       
   124 	r = TheFs.GetLongName(shnFullPath, lgn);
       
   125 	test_KErrNone(r);
       
   126 	r = lgn.Compare(aLongName);
       
   127 	test_Equal(r, 0);
       
   128 	
       
   129 	test_KErrNone(TheFs.Delete(lgnFullPath));
       
   130 	}
       
   131 #endif //_DEBUG || _DEBUG_RELEASE
       
   132 
       
   133 //----------------------------------------------------------------------------------------------
       
   134 //! @SYMTestCaseID      PBASE-t_fatcharsetconv-0406
       
   135 //! @SYMTestType        CIT
       
   136 //! @SYMDEF             DEF101875
       
   137 //! @SYMTestCaseDesc    This test case is to test the default behaviours of LocaleUtils functions 
       
   138 //!                     in FAT.fsy before FATCharsetConv is integrated (i.e. there is no codepage
       
   139 //!                     dll loaded).
       
   140 //! @SYMTestActions     1. Creates a file with a name containing 3 valid Unicode characters, 
       
   141 //!                        gets its short name and compares it with "___", gets its long name and 
       
   142 //!                        compares it with the original Unicode string;
       
   143 //!                     2. Creates a file with a name containing 4 Unicode characters, each 16-bit 
       
   144 //!                        Unicode character contains two illegal 8-bit characters, test if the 
       
   145 //!                        file can be created successfully, gets its short name and compares it 
       
   146 //!                        with "____", gets its long name and compares it with the original 
       
   147 //!                        Unicode string.
       
   148 //! @SYMTestExpectedResults
       
   149 //!                     1. The file should be created successfully, the comparisons should return 0;
       
   150 //!                     2. The file should be created successfully, the comparisons should return 0;
       
   151 //! @SYMTestPriority    High
       
   152 //! @SYMTestCaseDependencies
       
   153 //!                     This test should be run before any codepage DLL is loaded, 
       
   154 //!	                    i.e., prior to all other test cases defined in this file.
       
   155 //! @SYMTestStatus      Implemented
       
   156 //----------------------------------------------------------------------------------------------
       
   157 void TestBeforeFATCharsetConvInteg()
       
   158 	{
       
   159 	test.Next(_L("Test default unicode handling in FAT implementation"));
       
   160 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
       
   161 	_LIT(KTestNormalUnicodeFileName, 				"\x65B0\x6587\x4EF6.TXT");
       
   162 	_LIT(KTestNormalUnicodeFileNameShortDefualt, 	"___.TXT");
       
   163 	_LIT(KTestFileNameWithIllegalChars, 			"\x222F\x2F3A\x3C3E\x7C00.TXT");
       
   164 	_LIT(KFileNameWithIllegalCharsShort, 			"____.TXT");
       
   165 	
       
   166 	TInt r = TheFs.ControlIo(CurrentDrive(), KControlIoDisableFatUtilityFunctions);
       
   167 	test_KErrNone(r);
       
   168 
       
   169 	// Create file and check creation
       
   170 	MakeFile(KTestNormalUnicodeFileName);
       
   171 	TFileName shn;
       
   172 	// Check short name	to test if there is any codepage DLL loaded already.
       
   173 	r = TheFs.GetShortName(KTestNormalUnicodeFileName, shn);
       
   174 	test_KErrNone(r);
       
   175 
       
   176 	r = shn.Compare(KTestNormalUnicodeFileNameShortDefualt);
       
   177 	test_Equal(r, 0);
       
   178 	
       
   179 	TFileName lgn;
       
   180 	r = TheFs.GetLongName(KTestNormalUnicodeFileNameShortDefualt, lgn);
       
   181 	test_KErrNone(r);
       
   182 	r = lgn.Compare(KTestNormalUnicodeFileName);
       
   183 	test_Equal(r, 0);
       
   184 
       
   185 	// Test illegal 8-bit ASCII chars in 16-bit Unicode chars.
       
   186 	MakeFile(KTestFileNameWithIllegalChars);
       
   187 	r = TheFs.GetShortName(KTestFileNameWithIllegalChars, shn);
       
   188 	test_KErrNone(r);
       
   189 	r = shn.Compare(KFileNameWithIllegalCharsShort);
       
   190 	test_Equal(r, 0);
       
   191 	
       
   192 	test_KErrNone(TheFs.Delete(KTestFileNameWithIllegalChars));
       
   193 	test_KErrNone(TheFs.Delete(KTestNormalUnicodeFileName));
       
   194 
       
   195 	r = TheFs.ControlIo(CurrentDrive(), KControlIoEnableFatUtilityFunctions);
       
   196 	test_KErrNone(r);
       
   197 #else
       
   198 	test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details."));
       
   199 #endif  // _DEBUG) || _DEBUG_RELEASE
       
   200 
       
   201 	}
       
   202 
       
   203 
       
   204 //----------------------------------------------------------------------------------------------
       
   205 //! @SYMTestCaseID      PBASE-t_fatcharsetconv-0407
       
   206 //! @SYMTestType        CIT
       
   207 //! @SYMDEF             DEF101875
       
   208 //! @SYMTestCaseDesc    This test case is to test volume label setting with Unicode characters
       
   209 //! @SYMTestActions     1. Changes locale to load testing codepage dll, check returning error code
       
   210 //!                     2. Sets volume label with Unicode (less than 11 bytes long), test setting 
       
   211 //!                        success, gets volume label and compares it with the original Unicode string;
       
   212 //!                     3. Sets volume label with a Unicode string contains less than 11 characters 
       
   213 //!                        but occupies bigger than 11 bytes, checks the returning error code;
       
   214 //!                     4. Compares the volume label with the Unicode string used in action 2
       
   215 //! @SYMTestExpectedResults
       
   216 //!                     1. KErrNone should be returned;
       
   217 //!                     2. The comparison should return 0;
       
   218 //!                     3. KErrBadName should be returned;
       
   219 //!                     4. The comparison should return 0;
       
   220 //! @SYMTestPriority    High
       
   221 //! @SYMTestStatus      Implemented
       
   222 //----------------------------------------------------------------------------------------------
       
   223 void TestUnicodeVolumeLabel()
       
   224 	{
       
   225 	test.Next(_L("Test unicode volume labels"));
       
   226 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
       
   227 	TInt r = UserSvr::ChangeLocale(KTestLocale);
       
   228 	test_KErrNone(r);
       
   229 
       
   230 	r = TheFs.SessionPath(gSessionPath);
       
   231 	test_KErrNone(r);
       
   232 	TInt driveNum;
       
   233 	r = TheFs.CharToDrive(gSessionPath[0], driveNum);
       
   234 	test_KErrNone(r);
       
   235 	
       
   236 	// Retrieves the original volume label
       
   237 	TVolumeInfo vInfo;
       
   238 	r = TheFs.Volume(vInfo, driveNum);
       
   239 	const TInt KVolumeLabelSize = 11;
       
   240 	TBuf<KVolumeLabelSize> originalVolumeLabel(vInfo.iName);
       
   241 
       
   242 	// Tests setting volume label with unicode characters
       
   243 	_LIT(KUnicodeVolumeLabel, 		"\x65B0\x65B0\x65B0");
       
   244 	
       
   245 	r = TheFs.SetVolumeLabel(KUnicodeVolumeLabel, driveNum);
       
   246 	test_KErrNone(r);
       
   247 	r = TheFs.Volume(vInfo, driveNum);
       
   248 	test_KErrNone(r);
       
   249 	r = vInfo.iName.Compare(KUnicodeVolumeLabel);
       
   250 	test_Equal(r, 0);
       
   251 	
       
   252 	// Tests setting volume label with unicode characters that bigger than 11 bytes
       
   253 	_LIT(KVolumeLabelOverflow,		"\x65B0\x65B0\x65B0\x65B0\x65B0\x65B0");
       
   254 	r = TheFs.SetVolumeLabel(KVolumeLabelOverflow, driveNum);
       
   255 	// locale dll and codepage dll both return diff retrun values so check against both cases.
       
   256 	test((r == KErrBadName) || (r == KErrOverflow));
       
   257 
       
   258 	r = TheFs.Volume(vInfo, driveNum);
       
   259 	test_KErrNone(r);
       
   260 	r = vInfo.iName.Compare(KUnicodeVolumeLabel);
       
   261 	test_Equal(r, 0);
       
   262 	
       
   263 	// Sets back the original volume label
       
   264 	r = TheFs.SetVolumeLabel(originalVolumeLabel, driveNum);
       
   265 	test_KErrNone(r);
       
   266 #else
       
   267 	test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details."));
       
   268 #endif  // _DEBUG) || _DEBUG_RELEASE
       
   269 	}
       
   270 
       
   271 
       
   272 //----------------------------------------------------------------------------------------------
       
   273 //! @SYMTestCaseID      PBASE-t_fatcharsetconv-0408
       
   274 //! @SYMTestType        CIT
       
   275 //! @SYMDEF             DEF101875
       
   276 //! @SYMTestCaseDesc    This test case is to test the "8 bytes" boundary of short name length, 
       
   277 //!                     which is defined in FAT Specification.
       
   278 //! @SYMTestActions     1. Creates files and directories with different Unicode strings that 
       
   279 //!                        have different combinations of length (of characters) and size (of 
       
   280 //!                        bytes occupied), check for error of creation.
       
   281 //!                     2. Gets their short name, compares with expected values, gets their long 
       
   282 //!                        name, compares with original Unicode strings.
       
   283 //!                        The strings and short name tested are as below:
       
   284 //!                        2.1. original string: "Abc"
       
   285 //!                             expected short name: "ABC";
       
   286 //!                        2.2. original string: "\x65B0\x6587\x4EF6\x4EF6"
       
   287 //!                             expected short name: "\x65B0\x6587\x4EF6\x4EF6";
       
   288 //!                        2.3. original string: "\x65B0\x6587\x4EF6(01)"
       
   289 //!                             expected short name: "\x65B0\x6587\x4EF6~1";
       
   290 //!                        2.4. original string: "Abcdefghi"
       
   291 //!                             expected short name: "ABCDEF~1";
       
   292 //!                        2.5. original string: "\x65B0(Abcdefgh)"
       
   293 //!                             expected short name: "\x65B0(ABC~1";
       
   294 //! @SYMTestExpectedResults
       
   295 //!						1. File should be created with no error;
       
   296 //!                     2. Comparisons should return 0;
       
   297 //! @SYMTestPriority    High
       
   298 //! @SYMTestStatus      Implemented
       
   299 //----------------------------------------------------------------------------------------------
       
   300 void TestShortNameBoundary()
       
   301 	{
       
   302 	test.Next(_L("8 bytes' name boundary tests"));
       
   303 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
       
   304 	TInt r = UserSvr::ChangeLocale(KTestLocale);
       
   305 	test_KErrNone(r);
       
   306 
       
   307 	// File names will be used for testing boundaries
       
   308 	_LIT(KTestFileName3C3B, 		"Abc");						// 3 characters, 3 bytes long
       
   309 	_LIT(KTestFileName3C3B_short,	"ABC");						// Expected short name
       
   310 	_LIT(KTestFileName4C8B, 		"\x65B0\x6587\x4EF6\x4EF6");// 4 characters, 8 bytes long
       
   311 	_LIT(KTestFileName4C8B_short,	"\x65B0\x6587\x4EF6\x4EF6");// Expected short name
       
   312 	_LIT(KTestFileName7C10B, 		"\x65B0\x6587\x4EF6(01)");	// 7 characters, 10 bytes long
       
   313 	_LIT(KTestFileName7C10B_short, 	"\x65B0\x6587\x4EF6~1");	// Expected short name
       
   314 	_LIT(KTestFileName9C9B, 		"Abcdefghi");				// 9 characters, 9 bytes long
       
   315 	_LIT(KTestFileName9C9B_short, 	"ABCDEF~1");				// Expected short name
       
   316 	_LIT(KTestFileName9C10B, 		"\x65B0(Abcdefgh)");		// 9 characters, 10 bytes long
       
   317 	_LIT(KTestFileName9C10B_short, 	"\x65B0(ABC~1");			// Expected short name
       
   318 
       
   319 	// Test file creation and long/short name generation
       
   320 	doFileNameTest(KTestFileName3C3B, 		KTestFileName3C3B_short); 
       
   321 	doFileNameTest(KTestFileName4C8B, 		KTestFileName4C8B_short);
       
   322 	doFileNameTest(KTestFileName7C10B, 		KTestFileName7C10B_short);
       
   323 	doFileNameTest(KTestFileName9C9B, 		KTestFileName9C9B_short);
       
   324 	doFileNameTest(KTestFileName9C10B, 		KTestFileName9C10B_short);
       
   325 
       
   326 	doDirNameTest(KTestFileName3C3B, 		KTestFileName3C3B_short);
       
   327 	doDirNameTest(KTestFileName4C8B, 		KTestFileName4C8B_short);
       
   328 	doDirNameTest(KTestFileName7C10B, 		KTestFileName7C10B_short);
       
   329 	doDirNameTest(KTestFileName9C9B, 		KTestFileName9C9B_short);
       
   330 	doDirNameTest(KTestFileName9C10B, 		KTestFileName9C10B_short);
       
   331 #else
       
   332 	test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details."));
       
   333 #endif  // _DEBUG) || _DEBUG_RELEASE
       
   334 	}
       
   335 
       
   336 //----------------------------------------------------------------------------------------------
       
   337 //! @SYMTestCaseID      PBASE-t_fatcharsetconv-0794
       
   338 //!	@SYMTestCaseDesc    This test case is to test the extensions of the short names generated are consistent for file names
       
   339 //!                     consisting of UNICODE characters. In a shortname, if the character at the third location (in 8.3 format)
       
   340 //!						is a head byte of a UNICODE character then it should be ignored.
       
   341 //! @SYMTestActions     1. Creates files and directories with different Unicode strings that 
       
   342 //!                        have different combinations of extension length (of characters) and size (of 
       
   343 //!                        bytes occupied), check for error of creation.
       
   344 //!                     2. Gets their short name, compares with expected values, gets their long 
       
   345 //!                        name, compares with original Unicode strings.
       
   346 //!                        The strings and short name tested are as below:
       
   347 //!                        2.1. original string: "abcdef.\x65B0"
       
   348 //!                             expected short name: "ABCDEF.\x65B0";
       
   349 //!                        2.2. original string: "abcdef.t\x65B0"
       
   350 //!                             expected short name: "ABCDEF.T\x65B0";
       
   351 //!                        2.3. original string: "abcdef.\x65B0t"
       
   352 //!                             expected short name: "ABCDEF.\x65B0T";
       
   353 //!                        2.4. original string: "abcdefg.\x65B0\x65B0"
       
   354 //!                             expected short name: "ABCDEF~1.\x65B0";
       
   355 //!                        
       
   356 //! @SYMTestExpectedResults
       
   357 //!						1. File should be created with no error;
       
   358 //!                     2. Comparisons should return 0;
       
   359 //! @SYMTestPriority    High
       
   360 //! @SYMTestStatus      Implemented
       
   361 //----------------------------------------------------------------------------------------------
       
   362 
       
   363 void TestConsistentShortNameExtGeneration()
       
   364 	{
       
   365 	test.Next(_L("Test consistent short name extensions are generated"));
       
   366 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
       
   367 	TInt r = UserSvr::ChangeLocale(KTestLocale);
       
   368 	test_KErrNone(r);
       
   369 	
       
   370 	// File names will be used for testing boundaries
       
   371 	_LIT(KTestFileNameExt1C2B, 			"abcdefg.\x65B0");		// 1 characters, 2 bytes long ;only one Unicode character in the extension
       
   372 	_LIT(KTestFileNameExt1C2B_short,	"ABCDEFG.\x65B0");		//Expected short name					
       
   373 	_LIT(KTestFileNameExt2C3B2U, 		"abcdefg.t\x65B0");		// 2 characters, 3 bytes long ;Unicode character at the 2nd location of the extension
       
   374 	_LIT(KTestFileNameExt2C3B2U_short, 	"ABCDEFG.T\x65B0");		//Expected short name
       
   375 	_LIT(KTestFileNameExt2C3B1U, 		"abcdefg.\x65B0t");		// 2 characters, 3 bytes long ;Unicode character at the 1st location of the extension
       
   376 	_LIT(KTestFileNameExt2C3B1U_short,	"ABCDEFG.\x65B0T");		//Expected short name
       
   377 	_LIT(KTestFileNameExt2C4B, 			"abcdefg.\x65B0\x65B0");// 2 characters, 4 bytes long ;both are Unicode characters in the extension
       
   378 	_LIT(KTestFileNameExt2C4B_short,	"ABCDEF~1.\x65B0");		//Expected short name				
       
   379 					
       
   380 
       
   381 	// Test file creation and long/short name generation
       
   382 	doFileNameTest(KTestFileNameExt1C2B, 	KTestFileNameExt1C2B_short);
       
   383 	doFileNameTest(KTestFileNameExt2C3B2U, 	KTestFileNameExt2C3B2U_short);
       
   384 	doFileNameTest(KTestFileNameExt2C3B1U, 	KTestFileNameExt2C3B1U_short);
       
   385 	doFileNameTest(KTestFileNameExt2C4B, 	KTestFileNameExt2C4B_short);
       
   386 	
       
   387 	doDirNameTest(KTestFileNameExt1C2B, 	KTestFileNameExt1C2B_short);
       
   388 	doDirNameTest(KTestFileNameExt2C3B2U, 	KTestFileNameExt2C3B2U_short);
       
   389 	doDirNameTest(KTestFileNameExt2C3B1U, 	KTestFileNameExt2C3B1U_short);
       
   390 	doDirNameTest(KTestFileNameExt2C4B, 	KTestFileNameExt2C4B_short);
       
   391 #else
       
   392 	test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details."));
       
   393 #endif  // _DEBUG) || _DEBUG_RELEASE
       
   394 	}
       
   395 
       
   396 
       
   397 //----------------------------------------------------------------------------------------------
       
   398 //! @SYMTestCaseID		PBASE-t_fatcharsetconv-0795
       
   399 //! @SYMTestCaseDesc    This test case is to test whether the short names generated for file names
       
   400 //!                     consisting of UNICODE characters are consistent or not. In a shortname, if the character immediately
       
   401 //!						preceding the tilde(~) is a head byte of a UNICODE character then it should be ignored.
       
   402 //! @SYMTestActions     1. Creates files and directories with different Unicode strings that 
       
   403 //!                        have different combinations of length (of characters) and size (of 
       
   404 //!                        bytes occupied), check for error of creation.
       
   405 //!                     2. Gets their short name, compares with expected values, gets their long 
       
   406 //!                        name, compares with original Unicode strings.
       
   407 //!                        The strings and short name tested are as below:
       
   408 //!                        2.1. original string: "a\x65B0(bcd)"
       
   409 //!                             expected short name: "A\x65B0(BCD)";
       
   410 //!                        2.2. original string: "ab\x65B0(cdef)"
       
   411 //!                             expected short name: "AB\x65B0(C~1")";
       
   412 //!                        2.3. original string: "abc\x65B0(def)"
       
   413 //!                             expected short name: "ABC\x65B0(~1";
       
   414 //!                        2.4. original string: "abcd\x65B0(ef)"
       
   415 //!                             expected short name: "ABCD\x65B0~1";
       
   416 //!                        2.5. original string: "abcde\x65B0(f)"
       
   417 //!                             expected short name: "ABCDE~1";
       
   418 //! @SYMTestExpectedResults
       
   419 //!						1. File should be created with no error;
       
   420 //!                     2. Comparisons should return 0;
       
   421 //! @SYMTestPriority    High
       
   422 //! @SYMTestStatus      Implemented
       
   423 //----------------------------------------------------------------------------------------------
       
   424 void TestConsistentShortNameGeneration()
       
   425 	{
       
   426 	test.Next(_L("Test consistent short name generation"));
       
   427 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
       
   428 	TInt r = UserSvr::ChangeLocale(KTestLocale);
       
   429 	test_KErrNone(r);
       
   430 
       
   431 	//unicode characters.
       
   432 	
       
   433 	_LIT(KTestFileName7C8B2U, 		"a\x65B0(bcd)");			// 7 characters, 8 bytes long ,Unicode character at the 2nd location.
       
   434 	_LIT(KTestFileName7C8B2U_short, "A\x65B0(BCD)");			// Expected short name
       
   435 	_LIT(KTestFileName9C10B3U, 		"ab\x65B0(cdef)");			// 9 characters, 10 bytes long ,Unicode character at the 3rd location.
       
   436 	_LIT(KTestFileName9C10B3U_short,"AB\x65B0(C~1");			// Expected short name
       
   437 	_LIT(KTestFileName9C10B4U, 		"abc\x65B0(def)");			// 9 characters, 10 bytes long ,Unicode character at the 4th location.
       
   438 	_LIT(KTestFileName9C10B4U_short,"ABC\x65B0(~1");			// Expected short name
       
   439 	_LIT(KTestFileName9C10B5U, 		"abcd\x65B0(ef)");			// 9 characters, 10 bytes long ,Unicode character at the 6th location.
       
   440 	_LIT(KTestFileName9C10B5U_short,"ABCD\x65B0~1");			// Expected short name
       
   441 	_LIT(KTestFileName9C10B6U, 		"abcde\x65B0(f)");			// 9 characters, 10 bytes long ,repeat Unicode character at the 6th location.
       
   442 	_LIT(KTestFileName9C10B6U_short,"ABCDE~1");					// Expected short name
       
   443 		
       
   444 	// Test file creation and long/short name generation
       
   445 	doFileNameTest(KTestFileName7C8B2U, 		KTestFileName7C8B2U_short);
       
   446 	doFileNameTest(KTestFileName9C10B3U, 		KTestFileName9C10B3U_short);
       
   447 	doFileNameTest(KTestFileName9C10B4U, 		KTestFileName9C10B4U_short);
       
   448 	doFileNameTest(KTestFileName9C10B5U, 		KTestFileName9C10B5U_short);
       
   449 	doFileNameTest(KTestFileName9C10B6U, 		KTestFileName9C10B6U_short);
       
   450 		 
       
   451 	doDirNameTest(KTestFileName7C8B2U, 			KTestFileName7C8B2U_short);
       
   452 	doDirNameTest(KTestFileName9C10B3U, 		KTestFileName9C10B3U_short);
       
   453 	doDirNameTest(KTestFileName9C10B4U, 		KTestFileName9C10B4U_short);
       
   454 	doDirNameTest(KTestFileName9C10B5U, 		KTestFileName9C10B5U_short);
       
   455 	doDirNameTest(KTestFileName9C10B6U, 		KTestFileName9C10B6U_short);
       
   456 #else
       
   457 	test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details."));
       
   458 #endif  // _DEBUG) || _DEBUG_RELEASE
       
   459 	}
       
   460 
       
   461 //----------------------------------------------------------------------------------------------
       
   462 //! @SYMTestCaseID      PBASE-t_fatcharsetconv-0409
       
   463 //! @SYMTestType        CIT
       
   464 //! @SYMDEF             DEF101875 INC100580
       
   465 //! @SYMTestCaseDesc    This test case is to test creation of files with their Unicode names are 
       
   466 //!                     duplicate to existing files.
       
   467 //! @SYMTestActions     1. Creates a file with its name contains 4 Unicode characters but occupies 
       
   468 //!                        8 bytes ("\x65B0\x6587\x4EF6\x4EF6"), check for creation;
       
   469 //!                     2. Creates a file with 11 bytes' long Unicode name and first 8 bytes are 
       
   470 //!                        identical with the file created in Action 1 ("\x65B0\x6587\x4EF6\x4EF6(A)"), 
       
   471 //!                        check for file creation;
       
   472 //!                     3. Gets the short name of the file created in Action 2, compares it with 
       
   473 //!                        expected short name ("\x65B0\x6587\x4EF6~1"), gets the long name of this 
       
   474 //!                        file and compares it with its original Unicode name;
       
   475 //!                     4. Creates a file with 12 bytes' long Unicode name and first 8 bytes are 
       
   476 //!                        identical with the file created in Action 1 and Action 2 
       
   477 //!                        ("\x65B0\x6587\x4EF6\x4EF6(AB)"), check for file creation;
       
   478 //!                     5. Gets the short name of the file created in Action 4, compares it with 
       
   479 //!                        expected values ("\x65B0\x6587\x4EF6~2"), gets the long name of this file 
       
   480 //!                        and compares it with its original Unicode name;
       
   481 //! @SYMTestExpectedResults
       
   482 //!						1. File creation should return KErrNone;
       
   483 //!                     2. File creation should return KErrNone;
       
   484 //!                     3. Comparisons should return 0;
       
   485 //!                     4. File creation should return KErrNone;
       
   486 //!                     5. Comparisons should return 0;
       
   487 //! @SYMTestPriority    High
       
   488 //! @SYMTestStatus      Implemented
       
   489 //----------------------------------------------------------------------------------------------
       
   490 void TestDuplicateLongFileNames()
       
   491 	{
       
   492 	test.Next(_L("Testing tilde and numbers (\"~n\") are applied correctly for multiple long-named files"));
       
   493 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
       
   494 	TInt r = UserSvr::ChangeLocale(KTestLocale);
       
   495 	test_KErrNone(r);
       
   496 
       
   497 	// These are to test "~1", "~2" behaviours when the first 8 bytes of new files
       
   498 	//  are identical with existing files
       
   499 	_LIT(KTestFileName4C8B, 			"\x65B0\x6587\x4EF6\x4EF6.TXT");
       
   500 	_LIT(KTestFileName7C11B, 			"\x65B0\x6587\x4EF6\x4EF6(A).TXT");	
       
   501 	_LIT(KTestFileName7C11B_short, 		"\x65B0\x6587\x4EF6~1.TXT");
       
   502 	_LIT(KTestFileName8C12B, 			"\x65B0\x6587\x4EF6\x4EF6(AB).TXT");	
       
   503 	_LIT(KTestFileName8C12B_short, 		"\x65B0\x6587\x4EF6~2.TXT");	
       
   504 
       
   505 	////////////////////////////////////////
       
   506 	// 1. Test duplicate long file names
       
   507 	////////////////////////////////////////
       
   508 	TFileName sn;
       
   509 	
       
   510 	MakeFile(KTestFileName4C8B);
       
   511 	MakeFile(KTestFileName7C11B);
       
   512 	
       
   513 	r = TheFs.GetShortName(KTestFileName7C11B, sn);
       
   514 	test_KErrNone(r);
       
   515 	r = sn.Compare(KTestFileName7C11B_short);
       
   516 	test_Equal(r, 0);
       
   517 
       
   518 
       
   519 	MakeFile(KTestFileName8C12B);
       
   520 	
       
   521 	r = TheFs.GetShortName(KTestFileName8C12B, sn);
       
   522 	test_KErrNone(r);
       
   523 	r = sn.Compare(KTestFileName8C12B_short);
       
   524 	test_Equal(r, 0);
       
   525 
       
   526 	test_KErrNone(TheFs.Delete(KTestFileName4C8B));
       
   527 	test_KErrNone(TheFs.Delete(KTestFileName7C11B));
       
   528 	test_KErrNone(TheFs.Delete(KTestFileName8C12B));
       
   529 
       
   530 #else
       
   531 	test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details."));
       
   532 #endif  // _DEBUG) || _DEBUG_RELEASE
       
   533 	}
       
   534 
       
   535 
       
   536 //----------------------------------------------------------------------------------------------
       
   537 //! @SYMTestCaseID      PBASE-t_fatcharsetconv-0410
       
   538 //! @SYMTestType        CIT
       
   539 //! @SYMDEF             DEF101875 INC100580
       
   540 //! @SYMTestCaseDesc    This test case is to test creation of directories with their Unicode names are 
       
   541 //!                     duplicate to existing directories .
       
   542 //! @SYMTestActions     1. Creates a directories  with its name contains 4 Unicode characters but occupies 
       
   543 //!                        8 bytes ("\x65B0\x6587\x4EF6\x4EF6"), check for creation;
       
   544 //!                     2. Creates a directories  with 11 bytes' long Unicode name and first 8 bytes are 
       
   545 //!                        identical with the directories created in Action 1 ("\x65B0\x6587\x4EF6\x4EF6(A)"), 
       
   546 //!                        check for file creation;
       
   547 //!                     3. Gets the short name of the directories created in Action 2, compares it with 
       
   548 //!                        expected short name ("\x65B0\x6587\x4EF6~1"), gets the long name of this 
       
   549 //!                        directories and compares it with its original Unicode name;
       
   550 //!                     4. Creates a directories with 12 bytes' long Unicode name and first 8 bytes are 
       
   551 //!                        identical with the directories created in Action 1 and Action 2 
       
   552 //!                        ("\x65B0\x6587\x4EF6\x4EF6(AB)"), check for directories creation;
       
   553 //!                     5. Gets the short name of the directories created in Action 4, compares it with 
       
   554 //!                        expected values ("\x65B0\x6587\x4EF6~2"), gets the long name of this directories 
       
   555 //!                        and compares it with its original Unicode name;
       
   556 //! @SYMTestExpectedResults
       
   557 //!						1. Dir creation should return KErrNone;
       
   558 //!                     2. Dir creation should return KErrNone;
       
   559 //!                     3. Comparisons should return 0;
       
   560 //!                     4. Dir creation should return KErrNone;
       
   561 //!                     5. Comparisons should return 0;
       
   562 //! @SYMTestPriority    High
       
   563 //! @SYMTestStatus      Implemented
       
   564 //----------------------------------------------------------------------------------------------
       
   565 void TestDuplicateLongDirNames()
       
   566 	{
       
   567 	test.Next(_L("Testing tilde and number appended correctly for duplicate long name dirs"));
       
   568 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
       
   569 	TheFs.SessionPath(gSessionPath);
       
   570 	TInt r = UserSvr::ChangeLocale(KTestLocale);
       
   571 	test_KErrNone(r);
       
   572 
       
   573 	// These are to test "~1", "~2" behaviours when the first 8 bytes of new directories
       
   574 	//  are identical with existing directories
       
   575 	_LIT(KTestDirName4C8B, 				"\\F32-TST\\T_LOCALEUTILS_CP932\\\x65B0\x6587\x4EF6\x4EF6\\");
       
   576 	_LIT(KTestDirName7C11B, 			"\\F32-TST\\T_LOCALEUTILS_CP932\\\x65B0\x6587\x4EF6\x4EF6(A)\\");	
       
   577 	_LIT(KTestDirName7C11B_short, 		"\x65B0\x6587\x4EF6~1");	
       
   578 	_LIT(KTestDirName8C12B, 			"\\F32-TST\\T_LOCALEUTILS_CP932\\\x65B0\x6587\x4EF6\x4EF6(AB)\\");	
       
   579 	_LIT(KTestDirName8C12B_short, 		"\x65B0\x6587\x4EF6~2");	
       
   580 
       
   581 	// Create 1st file with 8 bytes long/short name
       
   582 	MakeDir(KTestDirName4C8B);
       
   583 	MakeDir(KTestDirName7C11B);
       
   584 	TFileName sn;
       
   585 	
       
   586 	r = TheFs.GetShortName(KTestDirName7C11B, sn);
       
   587 	test_KErrNone(r);
       
   588 	r = sn.Compare(KTestDirName7C11B_short);
       
   589 	test_Equal(r, 0);
       
   590 
       
   591 	MakeDir(KTestDirName8C12B);
       
   592 	
       
   593 	r = TheFs.GetShortName(KTestDirName8C12B, sn);
       
   594 	test_KErrNone(r);
       
   595 	r = sn.Compare(KTestDirName8C12B_short);
       
   596 	test_Equal(r, 0);
       
   597 
       
   598 #else
       
   599 	test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details."));
       
   600 #endif  // _DEBUG) || _DEBUG_RELEASE
       
   601 	}
       
   602 
       
   603 //----------------------------------------------------------------------------------------------
       
   604 //! @SYMTestCaseID      PBASE-t_fatcharsetconv-0791
       
   605 //! @SYMTestType        CIT
       
   606 //! @SYMDEF             DEF117345
       
   607 //! @SYMTestCaseDesc    This test case is to test short name with 'E5' as the leading byte is correctly 
       
   608 //!						handled on FAT implementations 
       
   609 //! @SYMTestActions     1. Creates a file with unicode long name "\x88F9.TXT", it will be converted into
       
   610 //!							"\xE5E5.TXT" according to codepage 932 when creating short name.
       
   611 //!                     2. Gets the short name and compare it with its original unicode "\x88F9.TXT", make
       
   612 //!							sure the conversion "\xE5E5.TXT" has been handled correctly  
       
   613 //! @SYMTestExpectedResults
       
   614 //!                     1. Comparisons should return 0;
       
   615 //! @SYMTestPriority    High
       
   616 //! @SYMTestStatus      Implemented
       
   617 //----------------------------------------------------------------------------------------------
       
   618 void TestLeadingE5Handling()
       
   619 	{
       
   620 	test.Next(_L("Test Leading \'E5\' byte handling (DEF117345)"));
       
   621 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
       
   622 	TheFs.SessionPath(gSessionPath);
       
   623 	TInt r = UserSvr::ChangeLocale(KTestLocale);
       
   624 	test_KErrNone(r);
       
   625 
       
   626 	_LIT(KTestFilePathAndName,		"\\F32-TST\\T_LOCALEUTILS_CP932\\\x88F9.TXT");
       
   627 	_LIT(KTestFileShortName, 		"\x88F9.TXT");
       
   628 
       
   629 	MakeFile(KTestFilePathAndName);
       
   630 	TFileName sn;
       
   631 	r = TheFs.GetShortName(KTestFilePathAndName, sn);
       
   632 	test_KErrNone(r);
       
   633 	r = sn.Compare(KTestFileShortName);
       
   634 	test_Equal(r, 0);
       
   635 
       
   636 #else
       
   637 	test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details."));
       
   638 #endif  // _DEBUG) || _DEBUG_RELEASE
       
   639 	}
       
   640 //----------------------------------------------------------------------------------------------
       
   641 //! @SYMTestCaseID      PBASE-t_fatcharsetconv-2320
       
   642 //! @SYMTestType        CIT
       
   643 //! @SYMDEF             PDEF130334
       
   644 //! @SYMTestCaseDesc    This test case is to test creating a file with "\u3005" name correctly 
       
   645 //! @SYMTestActions     1. Creates a file with unicode long name "\u3005.TXT"
       
   646 //!                     2. Gets the short name and compare it with its original unicode "\u3005.TXT"
       
   647 //!						3. Gets the long name and compare it with its original unicode "\u3005.TXT"
       
   648 //! @SYMTestExpectedResults
       
   649 //!                     1. Comparisons should return 0;
       
   650 //! @SYMTestPriority    High
       
   651 //! @SYMTestStatus      Implemented
       
   652 //----------------------------------------------------------------------------------------------
       
   653 void TestDEF130334()
       
   654 	{
       
   655 	test.Next(_L("Test creating a file with \\x3005 name correctly (DEF128521)"));
       
   656 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
       
   657 	TheFs.SessionPath(gSessionPath);
       
   658 	TInt r = UserSvr::ChangeLocale(KTestLocale);
       
   659 	test_KErrNone(r);
       
   660 
       
   661 	_LIT(KTestFilePathAndName,		"\\F32-TST\\T_LOCALEUTILS_CP932\\\x3005.TXT");
       
   662 	_LIT(KTestFileName, 		"\x3005.TXT");
       
   663 
       
   664 	MakeFile(KTestFilePathAndName);
       
   665 	TFileName sn;
       
   666 	r = TheFs.GetShortName(KTestFilePathAndName, sn);
       
   667 	test_KErrNone(r);
       
   668 	r = sn.Compare(KTestFileName);
       
   669 	test_Equal(r, 0);
       
   670 	TFileName ln;
       
   671 	r = TheFs.GetLongName(KTestFilePathAndName, ln);
       
   672 	test_KErrNone(r);
       
   673 	r = ln.Compare(KTestFileName);
       
   674 	test_Equal(r, 0);
       
   675 
       
   676 #else
       
   677 	test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details."));
       
   678 #endif  
       
   679 	}
       
   680 //----------------------------------------------------------------------------------------------
       
   681 //! @SYMTestCaseID      PBASE-t_fatcharsetconv-1359
       
   682 //! @SYMTestType        CIT
       
   683 //! @SYMDEF             INC125768
       
   684 //! @SYMTestCaseDesc    This test case is to test the compatibility of file opening, to make sure files
       
   685 //!						with only one DOS entry which contains unicode short name is accessible on Symbian OS
       
   686 //!						from version 9.3 onwards.
       
   687 //! @SYMTestActions     Manually creates a single entried, unicode named file under root direcotry, then
       
   688 //!							access it via RFs::Entry() API using its uniocde name. Check the entry is accessible.
       
   689 //! @SYMTestExpectedResults
       
   690 //!						RFs::Entry() should return with KErrNone;
       
   691 //! @SYMTestPriority    High
       
   692 //! @SYMTestStatus      Implemented
       
   693 //----------------------------------------------------------------------------------------------
       
   694 void TestCompatibility()
       
   695 	{
       
   696 	test.Next(_L("test file opening compatibility"));
       
   697 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
       
   698 	GetBootInfo();
       
   699 
       
   700 	RFile file;
       
   701 	TFileName fn = _L("\\ABCD");
       
   702 	
       
   703 	TInt r=file.Create(TheFs,fn,EFileRead);
       
   704 	test(r==KErrNone);
       
   705 	file.Close();
       
   706 
       
   707 	//	Assume this file is the first entry in the root directory
       
   708 	r=TheDisk.Open(TheFs,CurrentDrive());
       
   709 	test(r==KErrNone);
       
   710 	
       
   711     //-- read the 1st dir entry, it should be a DOS entry 
       
   712     const TInt posEntry1=gBootSector.RootDirStartSector() << KDefaultSectorLog2; //-- dir entry1 position
       
   713     
       
   714     TFatDirEntry fatEntry1;
       
   715 	TPtr8 ptrEntry1((TUint8*)&fatEntry1,sizeof(TFatDirEntry));
       
   716     test(TheDisk.Read(posEntry1, ptrEntry1)==KErrNone); 
       
   717     test(!fatEntry1.IsVFatEntry());
       
   718 
       
   719     // Manually modify the short name into unicode characters
       
   720     // 	Unicode: 	0x(798F 5C71 96C5 6CBB)
       
   721     //	Shift-JIS: 	0x(959F 8E52 89EB 8EA1)
       
   722 
       
   723     TBuf8<8> unicodeSN = _L8("ABCD1234");
       
   724     unicodeSN[0] = 0x95;
       
   725     unicodeSN[1] = 0x9F;
       
   726     unicodeSN[2] = 0x8E;
       
   727     unicodeSN[3] = 0x52;
       
   728     unicodeSN[4] = 0x89;
       
   729     unicodeSN[5] = 0xEB;
       
   730     unicodeSN[6] = 0x8E;
       
   731     unicodeSN[7] = 0xA1;
       
   732     
       
   733     fatEntry1.SetName(unicodeSN);
       
   734     test(TheDisk.Write(posEntry1, ptrEntry1)==KErrNone);
       
   735     TheDisk.Close();
       
   736 
       
   737     // Access the file using its unicode file name
       
   738 	r = UserSvr::ChangeLocale(KTestLocale);
       
   739 	test_KErrNone(r);
       
   740 
       
   741 	fn = _L("\\ABCD");
       
   742 	fn[1] = 0x798F;
       
   743 	fn[2] = 0x5C71;
       
   744 	fn[3] = 0x96C5;
       
   745 	fn[4] = 0x6CBB;
       
   746 	
       
   747 	TEntry entry;
       
   748 	TInt err = TheFs.Entry(fn, entry);
       
   749 	test(err==KErrNone);
       
   750 	err = TheFs.Delete(fn);
       
   751 	test(err==KErrNone);
       
   752 #else
       
   753 	test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details."));
       
   754 #endif  // _DEBUG) || _DEBUG_RELEASE
       
   755 	}
       
   756 
       
   757 //----------------------------------------------------------------------------------------------
       
   758 //! @SYMTestCaseID      PBASE-t_fatcharsetconv-1395
       
   759 //! @SYMTestType        CIT
       
   760 //! @SYMDEF             INC126563
       
   761 //! @SYMTestCaseDesc    This test case is to test the definition of valid DOS characters on Symbian 
       
   762 //!						FAT/FAT32 complies with FAT Spec.
       
   763 //! @SYMTestActions     Manually creates a file with "0x7F" characters in its name, then check it can
       
   764 //!						ben accessed successfully.
       
   765 //! @SYMTestExpectedResults
       
   766 //!						RFs::Entry() should return with KErrNone;
       
   767 //! @SYMTestPriority    High
       
   768 //! @SYMTestStatus      Implemented
       
   769 //----------------------------------------------------------------------------------------------
       
   770 void TestINC126563()
       
   771 	{
       
   772 	test.Next(_L("Test INC126563: FAT/FAT32: unable to open or delete file whose name contains illegal characters"));
       
   773 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
       
   774 	GetBootInfo();
       
   775 
       
   776 	RFile file;
       
   777 	TFileName fn = _L("\\AB");
       
   778 	
       
   779 	test.Next(_L("create file \"AB\" under root directory"));
       
   780 	TInt r=file.Create(TheFs,fn,EFileRead);
       
   781 	test(r==KErrNone);
       
   782 	file.Close();
       
   783 
       
   784 	test.Next(_L("manually change file name to \"0x7F0x450x7F0x45\" via raw disk accessing"));
       
   785 	//	Assume this file is the first entry in the root directory
       
   786 	r=TheDisk.Open(TheFs,CurrentDrive());
       
   787 	test(r==KErrNone);
       
   788 	
       
   789     //-- read the first dir entry, it should be a DOS entry 
       
   790     const TInt posEntry1=gBootSector.RootDirStartSector() << KDefaultSectorLog2; //-- dir entry1 position
       
   791     
       
   792     TFatDirEntry fatEntry1;
       
   793 	TPtr8 ptrEntry1((TUint8*)&fatEntry1,sizeof(TFatDirEntry));
       
   794     test(TheDisk.Read(posEntry1, ptrEntry1)==KErrNone); 
       
   795     test(!fatEntry1.IsVFatEntry());
       
   796 
       
   797     TBuf8<8> unicodeSN = _L8("ABCD");
       
   798     unicodeSN[0] = 0x7F;
       
   799     unicodeSN[1] = 0x45;
       
   800     unicodeSN[2] = 0x7F;
       
   801     unicodeSN[3] = 0x45;
       
   802     
       
   803     fatEntry1.SetName(unicodeSN);
       
   804     test(TheDisk.Write(posEntry1, ptrEntry1)==KErrNone);
       
   805     TheDisk.Close();
       
   806 
       
   807     // Access the file using its unicode file name
       
   808 	r = UserSvr::ChangeLocale(KTestLocale);
       
   809 	test(KErrNone==r);
       
   810 
       
   811 	test.Next(_L("access entries under root directory via RDir::Open()"));
       
   812 	RDir dir;
       
   813 	r = dir.Open(TheFs, _L("\\"), KEntryAttNormal);
       
   814 	test(KErrNone == r);
       
   815 	TEntryArray entryArray;
       
   816 	r = dir.Read(entryArray);
       
   817 	test(entryArray.Count()==1);
       
   818 	TBuf<0x10> name;
       
   819 	TEntry entry;
       
   820 	entry = entryArray[0];
       
   821 	test.Printf(_L("entryArray[0] = \"%S\"\n"), &entry.iName);
       
   822 	name = entry.iName;
       
   823 	dir.Close();
       
   824 	
       
   825 	TFileName fullname= _L("\\");
       
   826 	fullname.Append(name);
       
   827 	
       
   828 	test.Next(_L("try to open or delete file entries retrieved"));
       
   829 	r = file.Open(TheFs, fullname, EFileRead);
       
   830 	test(KErrNone == r);
       
   831 	file.Close();
       
   832 	
       
   833 	r = TheFs.Delete(fullname);
       
   834 	test(KErrNone == r);
       
   835 #else
       
   836 	test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details."));
       
   837 #endif  // _DEBUG) || _DEBUG_RELEASE
       
   838 	}
       
   839 
       
   840 //----------------------------------------------------------------------------------------------
       
   841 //! @SYMTestCaseID      PBASE-t_fatcharsetconv-1402
       
   842 //! @SYMTestType        CIT
       
   843 //! @SYMDEF             INC127905
       
   844 //! @SYMTestCaseDesc    This test case is to test RFs::ScanDrive() does not incorrectly remove files
       
   845 //!						with unicode short file names.
       
   846 //! @SYMTestActions     Creates a file with unicode file names then check if the file is still accessible
       
   847 //!						after scandrive operations.
       
   848 //! @SYMTestExpectedResults
       
   849 //!						RFs::Delete() should return with KErrNone;
       
   850 //! @SYMTestPriority    High
       
   851 //! @SYMTestStatus      Implemented
       
   852 //----------------------------------------------------------------------------------------------
       
   853 void TestINC127905()
       
   854 	{
       
   855 	test.Next(_L("Test INC127905: Unicode name file deleted after Scandrive"));
       
   856 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
       
   857 	TFileName fn = _L("ABCDE");
       
   858 	fn[0] = 0x3055;
       
   859 	fn[1] = 0x307E;
       
   860 	fn[2] = 0x3056;
       
   861 	fn[3] = 0x307E;
       
   862 	fn[4] = 0x306A;
       
   863 
       
   864 	TInt r = UserSvr::ChangeLocale(KTestLocale);
       
   865 	test(KErrNone==r);
       
   866 	
       
   867 	MakeFile(fn);
       
   868 	
       
   869 	_LIT(KShortName, "\x3055\x307E\x3056~1");
       
   870 	TFileName sn;
       
   871 	r = TheFs.GetShortName(fn, sn);
       
   872 	test(r==KErrNone);
       
   873 	r = sn.Compare(KShortName);
       
   874 	test(r==0);
       
   875 	
       
   876 	r = TheFs.ScanDrive(_L("gSessionPath"));
       
   877 	test(r==KErrNone);
       
   878 
       
   879 	r = TheFs.Delete(fn);
       
   880 	test(r == KErrNone);
       
   881 #else
       
   882 	test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details."));
       
   883 #endif  // _DEBUG) || _DEBUG_RELEASE
       
   884 	}
       
   885 
       
   886 void CallTestsL(void)
       
   887 	{
       
   888 
       
   889 	test.Title();
       
   890 	test.Start(_L("Starting T_LOCALEUTILS_CP932 tests"));
       
   891 
       
   892 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
       
   893 
       
   894 	// Test only runs on Fat file systems
       
   895 	TheFs.SessionPath(gSessionPath);
       
   896 	TInt driveNum = CurrentDrive();
       
   897 	TFSName name;
       
   898 	TInt r = TheFs.FileSystemName(name, driveNum);
       
   899 	if (KErrNone == r)
       
   900 		{
       
   901 		if (name.Compare(_L("Fat")) != 0)
       
   902 			{
       
   903 			test.Printf(_L("Test only runs on 'Fat' drives"));
       
   904 			}
       
   905 		else
       
   906 			{
       
   907 			// Enables codepage dll implementation of LocaleUtils functions for this test only
       
   908 			r = TheFs.ControlIo(driveNum, KControlIoEnableFatUtilityFunctions);
       
   909 			test_KErrNone(r);
       
   910 
       
   911 			CreateTestDirectory(_L("\\F32-TST\\T_LOCALEUTILS_CP932\\"));
       
   912 			TestBeforeFATCharsetConvInteg();
       
   913 			TestUnicodeVolumeLabel();
       
   914 			TestShortNameBoundary();
       
   915 			TestConsistentShortNameGeneration();
       
   916 			TestConsistentShortNameExtGeneration();
       
   917 			TestDuplicateLongFileNames();
       
   918 			TestDuplicateLongDirNames();
       
   919 			TestLeadingE5Handling();
       
   920 			TestDEF130334();
       
   921 			TestINC127905();
       
   922 			DeleteTestDirectory();
       
   923 
       
   924 			TestCompatibility();
       
   925 			TestINC126563();
       
   926 			// Disables codepage dll implementation of LocaleUtils functions for other base tests
       
   927 			r = TheFs.ControlIo(driveNum, KControlIoDisableFatUtilityFunctions);
       
   928 			test_KErrNone(r);
       
   929 			}
       
   930 		}
       
   931 	else
       
   932 		{
       
   933 		test.Printf(_L("Drive %C: is not ready!"), 'A'+driveNum);
       
   934 		test(EFalse);
       
   935 		}
       
   936 #else
       
   937 	test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details."));
       
   938 #endif  // _DEBUG) || _DEBUG_RELEASE
       
   939 	test.End();
       
   940 	}