os/kernelhwsrv/kerneltest/f32test/server/t_fatcharsetconv_SpecificCases.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) 2009 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
#define __E32TEST_EXTENSION__
sl@0
    18
sl@0
    19
#include "T_Fatcharsetconv_aux.h"
sl@0
    20
#include <f32file.h>
sl@0
    21
#include <e32test.h>
sl@0
    22
#include <e32svr.h>
sl@0
    23
#include <HAL.H>
sl@0
    24
#include <f32fsys.h>
sl@0
    25
#include <f32dbg.h>
sl@0
    26
#include "..\server\t_server.h"
sl@0
    27
sl@0
    28
//#include "fat_utils.h"
sl@0
    29
sl@0
    30
extern RFile TheFile;
sl@0
    31
sl@0
    32
#if defined(_DEBUG) || defined(_DEBUG_RELEASE)
sl@0
    33
void TestIllegalCharsWithDll()
sl@0
    34
	{
sl@0
    35
	test.Next(_L("Test Illegal Character handling with DLL"));			
sl@0
    36
	__UHEAP_MARK;
sl@0
    37
	
sl@0
    38
	// logging for failure
sl@0
    39
	gTCType = ESymbianFATSpecific;
sl@0
    40
	RBuf failedOnBuf;
sl@0
    41
	failedOnBuf.CreateL(gLogFailureData.iFuncName);
sl@0
    42
	gTCId = 0;
sl@0
    43
	RBuf tcUniquePath;
sl@0
    44
	tcUniquePath.CreateL(KNone());
sl@0
    45
sl@0
    46
	QuickFormat();
sl@0
    47
	CreateTestDirectory(_L("\\F32-TST\\T_FATCHARSETCONV\\"));
sl@0
    48
	
sl@0
    49
	TInt r = TheFs.ControlIo(CurrentDrive(), KControlIoEnableFatUtilityFunctions);
sl@0
    50
	testAndLog(r==KErrNone);
sl@0
    51
sl@0
    52
	r = UserSvr::ChangeLocale(KTestLocale);
sl@0
    53
	testAndLog(r==KErrNone);
sl@0
    54
sl@0
    55
	_LIT(KTestNormalUnicodeFileName, 				"\x65B0\x6587\x4EF6.TXT");
sl@0
    56
	_LIT(KTestNormalUnicodeFileNameShortDefualt, 	"\x65B0\x6587\x4EF6.TXT");
sl@0
    57
	_LIT(KTestFileNameWithIllegalChars, 			"\x222F\x2F3A\x3C3E\x7C00.TXT");
sl@0
    58
	_LIT(KFileNameWithIllegalCharsShort, 			"___\x7C00.TXT");
sl@0
    59
	_LIT(KTestFileNameWithWildChars, 				"\x235B\x245C\x255D\x265E.TXT");
sl@0
    60
	_LIT(KTestFileNameWithWildCharsShort, 			"____.TXT");
sl@0
    61
sl@0
    62
	TFileName shn;
sl@0
    63
sl@0
    64
	MakeFile(KTestNormalUnicodeFileName);
sl@0
    65
	r = TheFs.GetShortName(KTestNormalUnicodeFileName, shn);
sl@0
    66
	testAndLog(r==KErrNone);
sl@0
    67
	r = shn.Compare(KTestNormalUnicodeFileNameShortDefualt);
sl@0
    68
	testAndLog(r==0);
sl@0
    69
sl@0
    70
	TFileName lgn;
sl@0
    71
	r = TheFs.GetLongName(KTestNormalUnicodeFileNameShortDefualt, lgn);
sl@0
    72
	testAndLog(r==KErrNone);
sl@0
    73
	r = lgn.Compare(KTestNormalUnicodeFileName);
sl@0
    74
	testAndLog(r==0);
sl@0
    75
sl@0
    76
	// Test illegal 8-bit ASCII chars in 16-bit Unicode chars.
sl@0
    77
	MakeFile(KTestFileNameWithIllegalChars);
sl@0
    78
	r = TheFs.GetShortName(KTestFileNameWithIllegalChars, shn);
sl@0
    79
	testAndLog(r==KErrNone);
sl@0
    80
	r = shn.Compare(KFileNameWithIllegalCharsShort);
sl@0
    81
	testAndLog(r==0);
sl@0
    82
	
sl@0
    83
	// Test wildcards, 8-bit ASCII chars in 16-bit Unicode chars.
sl@0
    84
	MakeFile(KTestFileNameWithWildChars);
sl@0
    85
	r = TheFs.GetShortName(KTestFileNameWithWildChars, shn);
sl@0
    86
	test_KErrNone(r);
sl@0
    87
	r = shn.Compare(KTestFileNameWithWildCharsShort);
sl@0
    88
	testAndLog(r==0);
sl@0
    89
	
sl@0
    90
	r=TheFs.Delete(KTestFileNameWithIllegalChars);
sl@0
    91
	testAndLog(r==0);
sl@0
    92
	r=TheFs.Delete(KTestNormalUnicodeFileName);
sl@0
    93
	testAndLog(r==0);
sl@0
    94
	r=TheFs.Delete(KTestFileNameWithWildChars);
sl@0
    95
	testAndLog(r==0);
sl@0
    96
	
sl@0
    97
	r = TheFs.ControlIo(CurrentDrive(), KControlIoDisableFatUtilityFunctions);
sl@0
    98
	testAndLog(r==KErrNone);
sl@0
    99
	failedOnBuf.Close();
sl@0
   100
	tcUniquePath.Close();
sl@0
   101
	__UHEAP_MARKEND;
sl@0
   102
	}
sl@0
   103
sl@0
   104
void TestIllegalCharsWithoutDLL()
sl@0
   105
	{
sl@0
   106
	test.Next(_L("Test Illegal Character handling without DLL"));			
sl@0
   107
	__UHEAP_MARK;
sl@0
   108
	
sl@0
   109
	// logging for failure
sl@0
   110
	gTCType = ESymbianFATSpecific;
sl@0
   111
	RBuf failedOnBuf;
sl@0
   112
	failedOnBuf.CreateL(gLogFailureData.iFuncName);
sl@0
   113
	gTCId = 0;
sl@0
   114
	RBuf tcUniquePath;
sl@0
   115
	tcUniquePath.CreateL(KNone());
sl@0
   116
sl@0
   117
	QuickFormat();
sl@0
   118
	CreateTestDirectory(_L("\\F32-TST\\T_FATCHARSETCONV\\"));
sl@0
   119
sl@0
   120
	TInt r = TheFs.ControlIo(CurrentDrive(), KControlIoDisableFatUtilityFunctions);
sl@0
   121
	testAndLog(r==KErrNone);	
sl@0
   122
sl@0
   123
	_LIT(KTestNormalUnicodeFileName, 				"\x65B0\x6587\x4EF6.TXT");
sl@0
   124
	_LIT(KTestNormalUnicodeFileNameShortDefualt, 	"___.TXT");
sl@0
   125
	_LIT(KTestFileNameWithIllegalChars, 			"\x222F\x2F3A\x3C3E\x7C00.TXT");
sl@0
   126
	_LIT(KFileNameWithIllegalCharsShort, 			"____.TXT");
sl@0
   127
	_LIT(KTestFileNameWithWildChars, 				"\x235B\x245C\x255D\x265E.TXT");
sl@0
   128
	_LIT(KTestFileNameWithWildCharsShort, 			"____~1.TXT");
sl@0
   129
	
sl@0
   130
	TFileName shn;
sl@0
   131
		
sl@0
   132
	MakeFile(KTestNormalUnicodeFileName);
sl@0
   133
	r = TheFs.GetShortName(KTestNormalUnicodeFileName, shn);
sl@0
   134
	testAndLog(r==KErrNone);
sl@0
   135
	r = shn.Compare(KTestNormalUnicodeFileNameShortDefualt);
sl@0
   136
	testAndLog(r==0);
sl@0
   137
	
sl@0
   138
	TFileName lgn;
sl@0
   139
	r = TheFs.GetLongName(KTestNormalUnicodeFileNameShortDefualt, lgn);
sl@0
   140
	testAndLog(r==KErrNone);
sl@0
   141
	r = lgn.Compare(KTestNormalUnicodeFileName);
sl@0
   142
	testAndLog(r==0);
sl@0
   143
sl@0
   144
	// Test illegal 8-bit ASCII chars in 16-bit Unicode chars.
sl@0
   145
	MakeFile(KTestFileNameWithIllegalChars);
sl@0
   146
	r = TheFs.GetShortName(KTestFileNameWithIllegalChars, shn);
sl@0
   147
	testAndLog(r==KErrNone);
sl@0
   148
	r = shn.Compare(KFileNameWithIllegalCharsShort);
sl@0
   149
	testAndLog(r==0);
sl@0
   150
	
sl@0
   151
	// Test illegal 8-bit ASCII chars in 16-bit Unicode chars.
sl@0
   152
	MakeFile(KTestFileNameWithWildChars);
sl@0
   153
	r = TheFs.GetShortName(KTestFileNameWithWildChars, shn);
sl@0
   154
	testAndLog(r==KErrNone);
sl@0
   155
	r = shn.Compare(KTestFileNameWithWildCharsShort);
sl@0
   156
	testAndLog(r==0);
sl@0
   157
	
sl@0
   158
	r=TheFs.Delete(KTestFileNameWithIllegalChars);
sl@0
   159
	testAndLog(r==0);
sl@0
   160
	r=TheFs.Delete(KTestNormalUnicodeFileName);
sl@0
   161
	testAndLog(r==0);
sl@0
   162
	r=TheFs.Delete(KTestFileNameWithWildChars);
sl@0
   163
	testAndLog(r==0);
sl@0
   164
sl@0
   165
	failedOnBuf.Close();
sl@0
   166
	tcUniquePath.Close();
sl@0
   167
	__UHEAP_MARKEND;
sl@0
   168
	}
sl@0
   169
sl@0
   170
void TestFileLengthMax()
sl@0
   171
	{
sl@0
   172
	test.Next(_L("Test accesing a long file with filename length <250 characters"));
sl@0
   173
	__UHEAP_MARK;
sl@0
   174
	
sl@0
   175
	// logging for failure
sl@0
   176
	gTCType = ESymbianFATSpecific;
sl@0
   177
	RBuf failedOnBuf;
sl@0
   178
	failedOnBuf.CreateL(gLogFailureData.iFuncName);
sl@0
   179
	gTCId = 0;
sl@0
   180
	RBuf tcUniquePath;
sl@0
   181
	tcUniquePath.CreateL(KNone());
sl@0
   182
sl@0
   183
	QuickFormat();
sl@0
   184
	CreateTestDirectory(_L("\\F32-TST\\T_FATCHARSETCONV\\"));
sl@0
   185
sl@0
   186
sl@0
   187
	TBuf<KMaxFileName> longName;
sl@0
   188
sl@0
   189
	_LIT(KTestDir1,	"\\TEST\\TESTLONGFILENAMELENGTH\\TESTMORETHAN250CHARACTERS\\") ;
sl@0
   190
	_LIT(KTestDir2,  "\x65B0\x6587\x4EF6\x4EF6(ABCDEFGH)\\(\x65B0\x6587\x4EF6\x4EF6)PQRST\\");
sl@0
   191
	_LIT(KTestDir3,  "MULTILEVEL-FOLDER1\\MULTILEVEL-FOLDER2\\MULTILEVEL-FOLDER3\\");
sl@0
   192
	_LIT(KTestDir4,  "\x65B0\x65B0\x65B0\x65B0(x6587)\\(\x6587\x6587\x6587\x6587)PQRST\\");
sl@0
   193
	_LIT(KTestDir5,  "\x4EF6\x4EF6\x4EF6\x4EF6(x4EF6)\\(\x6587\x6587\x6587\x6587)XYZ\\");	
sl@0
   194
	_LIT(KTestDir6,  "TESTINGINPROGRESS\\");
sl@0
   195
	_LIT(KTestLongFileLength,  "\x4EF6\x4EF6\x4EF6\x4EF6(x4EF6).TXT");
sl@0
   196
	
sl@0
   197
	longName += KTestDir1;
sl@0
   198
	longName += KTestDir2;
sl@0
   199
	longName += KTestDir3;
sl@0
   200
	longName += KTestDir4;
sl@0
   201
	longName += KTestDir5;
sl@0
   202
	longName += KTestDir6;	
sl@0
   203
sl@0
   204
	test.Printf(_L("longName count is  %d "), longName.Length());
sl@0
   205
	TInt r=TheFs.MkDirAll(longName);
sl@0
   206
	
sl@0
   207
	longName += KTestLongFileLength;
sl@0
   208
	test.Printf(_L("longName count is  %d "), longName.Length());
sl@0
   209
sl@0
   210
	testAndLog(longName.Length()<256);
sl@0
   211
sl@0
   212
	r=TheFile.Create(TheFs,longName ,EFileWrite);
sl@0
   213
	testAndLog(r==KErrNone);
sl@0
   214
	TheFile.Close();
sl@0
   215
		
sl@0
   216
	r=TheFile.Open(TheFs,longName ,EFileWrite);
sl@0
   217
	testAndLog(r==KErrNone);
sl@0
   218
	TheFile.Close();
sl@0
   219
sl@0
   220
	TheFs.Delete(longName);
sl@0
   221
sl@0
   222
	failedOnBuf.Close();
sl@0
   223
	tcUniquePath.Close();
sl@0
   224
	__UHEAP_MARKEND;
sl@0
   225
	}
sl@0
   226
	
sl@0
   227
void TestFileLengthExceedMax()
sl@0
   228
	{
sl@0
   229
	test.Next(_L("Test accesing a long file with filename length >250 characters"));
sl@0
   230
	__UHEAP_MARK;
sl@0
   231
sl@0
   232
	// logging for failure
sl@0
   233
	gTCType = ESymbianFATSpecific;
sl@0
   234
	RBuf failedOnBuf;
sl@0
   235
	failedOnBuf.CreateL(gLogFailureData.iFuncName);
sl@0
   236
	gTCId = 0;
sl@0
   237
	RBuf tcUniquePath;
sl@0
   238
	tcUniquePath.CreateL(KNone());
sl@0
   239
sl@0
   240
	QuickFormat();
sl@0
   241
	CreateTestDirectory(_L("\\F32-TST\\T_FATCHARSETCONV\\"));
sl@0
   242
sl@0
   243
	TInt r = TheFs.SessionPath(gSessionPath);
sl@0
   244
	testAndLog(r==KErrNone);
sl@0
   245
	
sl@0
   246
	TBuf<350> longName;
sl@0
   247
sl@0
   248
	_LIT(KTestDir1,	"\\TEST\\TESTLONGFILENAMELENGTH\\TESTMORETHAN260CHARACTERS\\") ;
sl@0
   249
	_LIT(KTestDir2,  "\x65B0\x6587\x4EF6\x4EF6(ABCDEFGH)\\(\x65B0\x6587\x4EF6\x4EF6)PQRST\\");
sl@0
   250
	_LIT(KTestDir3,  "MULTILEVEL-FOLDER1\\MULTILEVEL-FOLDER2\\MULTILEVEL-FOLDER3\\");
sl@0
   251
	_LIT(KTestDir4,  "\x65B0\x65B0\x65B0\x65B0(x6587)\\(\x6587\x6587\x6587\x6587)PQRST\\");
sl@0
   252
	_LIT(KTestDir5,  "\x4EF6\x4EF6\x4EF6\x4EF6(x4EF6)\\(\x6587\x6587\x6587\x6587)XYZ\\");	
sl@0
   253
	_LIT(KTestDir6,  "TESTINGINPROGRESS(TESTLENGTH)>256\\");	
sl@0
   254
	_LIT(KTestLongFileLength,  "\x4EF6\x4EF6\x4EF6\x4EF6(x4EF6).TXT");
sl@0
   255
	
sl@0
   256
	longName = gSessionPath;
sl@0
   257
	longName += KTestDir1;
sl@0
   258
	longName += KTestDir2;
sl@0
   259
	longName += KTestDir3;
sl@0
   260
	longName += KTestDir4;
sl@0
   261
	longName += KTestDir5;
sl@0
   262
	longName += KTestDir6;
sl@0
   263
	
sl@0
   264
	test.Printf(_L("longName length is  %d "), longName.Length());
sl@0
   265
	r=TheFs.MkDirAll(longName);
sl@0
   266
	
sl@0
   267
	longName += KTestLongFileLength;
sl@0
   268
	test.Printf(_L("longName count is  %d "), longName.Length());
sl@0
   269
sl@0
   270
	testAndLog(longName.Length()>256);
sl@0
   271
	
sl@0
   272
	r=TheFile.Create(TheFs,longName ,EFileWrite);
sl@0
   273
	testAndLog(r==KErrBadName);
sl@0
   274
	// TheFile.Close();
sl@0
   275
		
sl@0
   276
	r=TheFile.Open(TheFs,longName ,EFileWrite);
sl@0
   277
	testAndLog(r==KErrBadName);
sl@0
   278
	// TheFile.Close();
sl@0
   279
	
sl@0
   280
	TheFs.Delete(longName);	
sl@0
   281
	failedOnBuf.Close();
sl@0
   282
	tcUniquePath.Close();
sl@0
   283
	__UHEAP_MARKEND;		
sl@0
   284
	}
sl@0
   285
	
sl@0
   286
void TestLeadingE5Handling()
sl@0
   287
	{
sl@0
   288
	test.Next(_L("Test Leading \'E5\' byte handling"));
sl@0
   289
	__UHEAP_MARK;
sl@0
   290
	
sl@0
   291
	// logging for failure
sl@0
   292
	gTCType = ESymbianFATSpecific;
sl@0
   293
	RBuf failedOnBuf;
sl@0
   294
	failedOnBuf.CreateL(gLogFailureData.iFuncName);
sl@0
   295
	gTCId = 0;
sl@0
   296
	RBuf tcUniquePath;
sl@0
   297
	tcUniquePath.CreateL(KNone());
sl@0
   298
sl@0
   299
	QuickFormat();
sl@0
   300
	CreateTestDirectory(_L("\\F32-TST\\T_FATCHARSETCONV\\"));
sl@0
   301
sl@0
   302
	// Enables codepage dll implementation of LocaleUtils functions for this test only
sl@0
   303
	TInt r = TheFs.ControlIo(CurrentDrive(), KControlIoEnableFatUtilityFunctions);
sl@0
   304
	testAndLog(r==KErrNone);
sl@0
   305
	
sl@0
   306
	r = UserSvr::ChangeLocale(KTestLocale);
sl@0
   307
	testAndLog(r==KErrNone);
sl@0
   308
sl@0
   309
	r=TheFs.SessionPath(gSessionPath);
sl@0
   310
	testAndLog(r==KErrNone);
sl@0
   311
sl@0
   312
	_LIT(KTestFilePathAndName,		"\\F32-TST\\T_FATCHARSETCONV\\\x88F9.TXT");
sl@0
   313
	_LIT(KTestFileShortName, 		"\x88F9.TXT");
sl@0
   314
	
sl@0
   315
	MakeFile(KTestFilePathAndName);
sl@0
   316
	TFileName sn;
sl@0
   317
	r = TheFs.GetShortName(KTestFilePathAndName, sn);
sl@0
   318
	testAndLog(r==KErrNone);
sl@0
   319
	r = sn.Compare(KTestFileShortName);
sl@0
   320
	testAndLog(r==KErrNone);
sl@0
   321
	
sl@0
   322
	r=TheFs.Delete(KTestFilePathAndName);
sl@0
   323
	testAndLog(r==KErrNone);
sl@0
   324
sl@0
   325
	// Disables codepage dll implementation of LocaleUtils functions for other base tests
sl@0
   326
	r = TheFs.ControlIo(CurrentDrive(), KControlIoDisableFatUtilityFunctions);
sl@0
   327
	testAndLog(r==KErrNone);
sl@0
   328
	failedOnBuf.Close();
sl@0
   329
	tcUniquePath.Close();
sl@0
   330
	__UHEAP_MARKEND;
sl@0
   331
	}
sl@0
   332
	
sl@0
   333
void TestVFATCase3()
sl@0
   334
	{
sl@0
   335
	test.Next(_L("Test With VFAT entry, and DOS entry using Non-CP932 Japanese file's access"));
sl@0
   336
	__UHEAP_MARK;
sl@0
   337
sl@0
   338
	// logging for failure
sl@0
   339
	gTCType = ESymbianFATSpecific;
sl@0
   340
	RBuf failedOnBuf;
sl@0
   341
	failedOnBuf.CreateL(gLogFailureData.iFuncName);
sl@0
   342
	gTCId = 0;
sl@0
   343
	RBuf tcUniquePath;
sl@0
   344
	tcUniquePath.CreateL(KNone());
sl@0
   345
sl@0
   346
	QuickFormat();
sl@0
   347
	CreateTestDirectory(_L("\\F32-TST\\T_FATCHARSETCONV\\"));
sl@0
   348
sl@0
   349
	_LIT(KTestNormalFileName, 				"\x65B0\x6587\x4EF6.TXT");	
sl@0
   350
	_LIT(KTestNormalFileNameWithUnicode, 	"___.TXT");
sl@0
   351
	
sl@0
   352
	
sl@0
   353
	test.Printf(_L("Create a file without the DLL installed, and get the shortname"));
sl@0
   354
	TInt r=TheFile.Create(TheFs,KTestNormalFileName,EFileRead|EFileWrite);
sl@0
   355
	testAndLog(r==KErrNone);
sl@0
   356
	TFileName sn;
sl@0
   357
	r = TheFs.GetShortName(KTestNormalFileName, sn);
sl@0
   358
	testAndLog(r==KErrNone);
sl@0
   359
	r = sn.Compare(KTestNormalFileNameWithUnicode);
sl@0
   360
	testAndLog(r==0);
sl@0
   361
	TheFile.Close();
sl@0
   362
	
sl@0
   363
	test.Printf(_L("Access the file without the DLL installed"));
sl@0
   364
	r=TheFile.Open(TheFs,KTestNormalFileName,EFileWrite);
sl@0
   365
	testAndLog(r==KErrNone);
sl@0
   366
	
sl@0
   367
	TBuf<50> name;	
sl@0
   368
	r=TheFile.FullName(name);
sl@0
   369
	testAndLog(r==KErrNone);
sl@0
   370
	TheFile.Close();
sl@0
   371
	
sl@0
   372
	r=TheFile.Open(TheFs,KTestNormalFileNameWithUnicode,EFileWrite);
sl@0
   373
	testAndLog(r==KErrNone);
sl@0
   374
	TheFile.Close();
sl@0
   375
	
sl@0
   376
	//load the dll
sl@0
   377
	
sl@0
   378
	r = TheFs.ControlIo(CurrentDrive(), KControlIoEnableFatUtilityFunctions);
sl@0
   379
	testAndLog(r==KErrNone);
sl@0
   380
		
sl@0
   381
	r = UserSvr::ChangeLocale(KTestLocale);
sl@0
   382
	testAndLog(r==KErrNone);
sl@0
   383
	
sl@0
   384
	test.Printf(_L("Access the file with the DLL installed"));
sl@0
   385
	r=TheFile.Open(TheFs,KTestNormalFileName,EFileWrite);
sl@0
   386
	testAndLog(r==KErrNone);
sl@0
   387
sl@0
   388
	r=TheFile.FullName(name);
sl@0
   389
	testAndLog(r==KErrNone);
sl@0
   390
	TheFile.Close();
sl@0
   391
	
sl@0
   392
	r=TheFile.Open(TheFs,KTestNormalFileNameWithUnicode,EFileWrite);
sl@0
   393
	testAndLog(r==KErrNone);
sl@0
   394
	TheFile.Close();
sl@0
   395
	
sl@0
   396
	r=TheFs.Delete(KTestNormalFileName);
sl@0
   397
			
sl@0
   398
    r = TheFs.ControlIo(CurrentDrive(), KControlIoDisableFatUtilityFunctions);
sl@0
   399
	testAndLog(r==KErrNone);
sl@0
   400
	failedOnBuf.Close();
sl@0
   401
	tcUniquePath.Close();
sl@0
   402
	__UHEAP_MARKEND;
sl@0
   403
	}
sl@0
   404
sl@0
   405
void TestVFATCase2()
sl@0
   406
	{
sl@0
   407
	test.Next(_L("Test With VFAT entry, and DOS entry using CP932 Japanese file's access"));
sl@0
   408
	__UHEAP_MARK;
sl@0
   409
	
sl@0
   410
	// logging for failure
sl@0
   411
	gTCType = ESymbianFATSpecific;
sl@0
   412
	RBuf failedOnBuf;
sl@0
   413
	failedOnBuf.CreateL(gLogFailureData.iFuncName);
sl@0
   414
	gTCId = 0;
sl@0
   415
	RBuf tcUniquePath;
sl@0
   416
	tcUniquePath.CreateL(KNone());
sl@0
   417
sl@0
   418
	QuickFormat();
sl@0
   419
	CreateTestDirectory(_L("\\F32-TST\\T_FATCHARSETCONV\\"));
sl@0
   420
sl@0
   421
	TInt r = TheFs.ControlIo(CurrentDrive(), KControlIoEnableFatUtilityFunctions);
sl@0
   422
	test_KErrNone(r);
sl@0
   423
		
sl@0
   424
	r = UserSvr::ChangeLocale(KTestLocale);
sl@0
   425
	test_KErrNone(r);
sl@0
   426
	r=TheFs.SetSessionPath(gSessionPath);
sl@0
   427
	testAndLog(r==KErrNone);
sl@0
   428
	
sl@0
   429
	_LIT(KTestNormalFileName, 		"\x65B0\x6587\x4EF6.TXT");	
sl@0
   430
	_LIT(KTestNormalFileShortName, 	"\x65B0\x6587\x4EF6.TXT");
sl@0
   431
	
sl@0
   432
	test.Printf(_L("Create a file with the DLL installed, and get the shortname"));
sl@0
   433
	r=TheFile.Create(TheFs,KTestNormalFileName,EFileRead|EFileWrite);
sl@0
   434
	testAndLog(r==KErrNone);
sl@0
   435
	TFileName sn;
sl@0
   436
	r = TheFs.GetShortName(KTestNormalFileName, sn);
sl@0
   437
	testAndLog(r==KErrNone);
sl@0
   438
	r = sn.Compare(KTestNormalFileShortName);
sl@0
   439
	testAndLog(r==0);
sl@0
   440
	TheFile.Close();
sl@0
   441
	
sl@0
   442
	test.Printf(_L("Access the file with the DLL installed"));
sl@0
   443
	r=TheFile.Open(TheFs,KTestNormalFileName,EFileWrite);
sl@0
   444
	testAndLog(r==KErrNone);
sl@0
   445
	
sl@0
   446
	TBuf<50> name;	
sl@0
   447
	r=TheFile.FullName(name);
sl@0
   448
	testAndLog(r==KErrNone);
sl@0
   449
	TheFile.Close();
sl@0
   450
	
sl@0
   451
	r=TheFile.Open(TheFs,KTestNormalFileShortName,EFileWrite);
sl@0
   452
	testAndLog(r==KErrNone);
sl@0
   453
	TheFile.Close();
sl@0
   454
	
sl@0
   455
	r = TheFs.ControlIo(CurrentDrive(), KControlIoDisableFatUtilityFunctions);
sl@0
   456
	testAndLog(r==KErrNone);
sl@0
   457
	
sl@0
   458
	test.Printf(_L("Access the file without the DLL installed"));
sl@0
   459
	
sl@0
   460
	r=TheFile.Open(TheFs,KTestNormalFileName,EFileWrite);
sl@0
   461
	testAndLog(r==KErrNone);
sl@0
   462
sl@0
   463
	r=TheFile.FullName(name);
sl@0
   464
	testAndLog(r==KErrNone);
sl@0
   465
	TheFile.Close();
sl@0
   466
	
sl@0
   467
	r=TheFile.Open(TheFs,KTestNormalFileShortName,EFileWrite);
sl@0
   468
	testAndLog(r==KErrNone);
sl@0
   469
	TheFile.Close();
sl@0
   470
	
sl@0
   471
	r=TheFs.Delete(KTestNormalFileName);
sl@0
   472
	failedOnBuf.Close();
sl@0
   473
	tcUniquePath.Close();
sl@0
   474
	__UHEAP_MARKEND;
sl@0
   475
	}
sl@0
   476
	
sl@0
   477
void TestVFATCase1()
sl@0
   478
	{
sl@0
   479
	test.Next(_L("Test Without VFAT entry, but DOS entry uses CP932 Japanese file's access"));
sl@0
   480
	__UHEAP_MARK;
sl@0
   481
	
sl@0
   482
	// logging for failure
sl@0
   483
	gTCType = ESymbianFATSpecific;
sl@0
   484
	RBuf failedOnBuf;
sl@0
   485
	failedOnBuf.CreateL(gLogFailureData.iFuncName);
sl@0
   486
	gTCId = 0;
sl@0
   487
	RBuf tcUniquePath;
sl@0
   488
	tcUniquePath.CreateL(KNone());
sl@0
   489
sl@0
   490
	QuickFormat();
sl@0
   491
	CreateTestDirectory(_L("\\F32-TST\\T_FATCHARSETCONV\\"));
sl@0
   492
sl@0
   493
	GetBootInfo();
sl@0
   494
sl@0
   495
   	RFile file;
sl@0
   496
  	TFileName fn = _L("\\ABCD");
sl@0
   497
  	
sl@0
   498
  	TInt r=file.Create(TheFs,fn,EFileRead);
sl@0
   499
  	testAndLog(r==KErrNone);
sl@0
   500
  	file.Close();
sl@0
   501
  
sl@0
   502
  	//	Assume this file is the first entry in the root directory
sl@0
   503
  	r=TheDisk.Open(TheFs,CurrentDrive());
sl@0
   504
  	testAndLog(r==KErrNone);
sl@0
   505
sl@0
   506
    //-- read the 1st dir entry, it should be a DOS entry 
sl@0
   507
    const TInt posEntry1=gBootSector.RootDirStartSector() << KDefaultSectorLog2; //-- dir entry1 position
sl@0
   508
      
sl@0
   509
    TFatDirEntry fatEntry1;
sl@0
   510
 	TPtr8 ptrEntry1((TUint8*)&fatEntry1,sizeof(TFatDirEntry));
sl@0
   511
	testAndLog(TheDisk.Read(posEntry1, ptrEntry1)==KErrNone); 
sl@0
   512
	testAndLog(!fatEntry1.IsVFatEntry());
sl@0
   513
sl@0
   514
	// Manually modify the short name into unicode characters
sl@0
   515
	// 	Unicode: 	0x(798F 5C71 96C5 6CBB)
sl@0
   516
	//	Shift-JIS: 	0x(959F 8E52 89EB 8EA1)
sl@0
   517
sl@0
   518
	TBuf8<8> unicodeSN = _L8("ABCD1234");
sl@0
   519
	unicodeSN[0] = 0x95;
sl@0
   520
	unicodeSN[1] = 0x9F;
sl@0
   521
	unicodeSN[2] = 0x8E;
sl@0
   522
	unicodeSN[3] = 0x52;
sl@0
   523
	unicodeSN[4] = 0x89;
sl@0
   524
	unicodeSN[5] = 0xEB;
sl@0
   525
	unicodeSN[6] = 0x8E;
sl@0
   526
	unicodeSN[7] = 0xA1;
sl@0
   527
sl@0
   528
	fatEntry1.SetName(unicodeSN);
sl@0
   529
	testAndLog(TheDisk.Write(posEntry1, ptrEntry1)==KErrNone);
sl@0
   530
	TheDisk.Close();
sl@0
   531
sl@0
   532
  	// The Unicode file name of the file that is created
sl@0
   533
  	fn = _L("\\ABCD");
sl@0
   534
  	fn[1] = 0x798F;
sl@0
   535
  	fn[2] = 0x5C71;
sl@0
   536
  	fn[3] = 0x96C5;
sl@0
   537
  	fn[4] = 0x6CBB;
sl@0
   538
  	
sl@0
   539
  	// Access the file using its unicode file name without the DLL loaded.
sl@0
   540
      r = TheFs.ControlIo(CurrentDrive(), KControlIoDisableFatUtilityFunctions);
sl@0
   541
  	test_KErrNone(r);
sl@0
   542
  	
sl@0
   543
  	TEntry entry;
sl@0
   544
  	TInt err = TheFs.Entry(fn, entry);
sl@0
   545
  	testAndLog(err==KErrNotFound);
sl@0
   546
  	
sl@0
   547
      // Access the file using its unicode file name with the DLL loaded.
sl@0
   548
      r = TheFs.ControlIo(CurrentDrive(), KControlIoEnableFatUtilityFunctions);  	
sl@0
   549
	test_KErrNone(r);
sl@0
   550
 	r = UserSvr::ChangeLocale(KTestLocale);  	
sl@0
   551
	test_KErrNone(r);
sl@0
   552
  
sl@0
   553
  	err = TheFs.Entry(fn, entry);
sl@0
   554
  	testAndLog(err==KErrNone);
sl@0
   555
  	
sl@0
   556
  	//file is no more required,delete it.
sl@0
   557
  	err = TheFs.Delete(fn);
sl@0
   558
  	testAndLog(err==KErrNone);
sl@0
   559
  	
sl@0
   560
      r = TheFs.ControlIo(CurrentDrive(), KControlIoDisableFatUtilityFunctions);
sl@0
   561
  	test_KErrNone(r);
sl@0
   562
  	
sl@0
   563
 	r=TheFs.SessionPath(gSessionPath);
sl@0
   564
  	test_KErrNone(r);
sl@0
   565
	failedOnBuf.Close();
sl@0
   566
	tcUniquePath.Close();
sl@0
   567
	__UHEAP_MARKEND;
sl@0
   568
	}
sl@0
   569
sl@0
   570
void DoSymbianSpecificCases()
sl@0
   571
	{
sl@0
   572
	gLogFailureData.iTCTypeName = KSymbianFATSpecific;
sl@0
   573
	gLogFailureData.iAPIName= KNone;
sl@0
   574
sl@0
   575
	// Store current file name
sl@0
   576
	TFileName fileName;
sl@0
   577
	TInt i=0;
sl@0
   578
	while(__FILE__[i]!='\0')
sl@0
   579
		{
sl@0
   580
		fileName.SetLength(i+1);
sl@0
   581
		fileName[i] = __FILE__[i++];
sl@0
   582
		}
sl@0
   583
	gFileName = fileName;
sl@0
   584
sl@0
   585
	gLogFailureData.iFuncName = KTestLeadingE5Handling;
sl@0
   586
	TestLeadingE5Handling();
sl@0
   587
sl@0
   588
	gLogFailureData.iFuncName = KTestIllegalCharsWithDll;
sl@0
   589
	TestIllegalCharsWithDll();
sl@0
   590
sl@0
   591
	gLogFailureData.iFuncName = KTestIllegalCharsWithoutDLL;
sl@0
   592
	TestIllegalCharsWithoutDLL();
sl@0
   593
sl@0
   594
	gLogFailureData.iFuncName = KTestFileLengthMax;
sl@0
   595
	TestFileLengthMax();
sl@0
   596
sl@0
   597
	gLogFailureData.iFuncName = KTestFileLengthExceedMax;
sl@0
   598
	TestFileLengthExceedMax();
sl@0
   599
	
sl@0
   600
	gLogFailureData.iFuncName = KTestVFATCase2;
sl@0
   601
	TestVFATCase2();
sl@0
   602
sl@0
   603
	gLogFailureData.iFuncName = KTestVFATCase3;
sl@0
   604
	TestVFATCase3();
sl@0
   605
sl@0
   606
	gLogFailureData.iFuncName = KTestVFATCase1;
sl@0
   607
	TestVFATCase1();
sl@0
   608
		
sl@0
   609
	}
sl@0
   610
sl@0
   611
#endif //defined(_DEBUG) || defined(_DEBUG_RELEASE)