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