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