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