First public contribution.
2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
19 #define __E32TEST_EXTENSION__
25 #include "..\server\t_server.h"
26 #include "fat_utils.h"
29 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
30 using namespace Fat_Test_Utils;
31 static RRawDisk TheDisk;
32 static TFatBootSector gBootSector;
34 #define MakeFile_CPTest(filename) \
36 test.Printf(_L("MakeFile(%S) at LINE:%d\n"),&filename,__LINE__); \
42 FormatFatDrive(TheFs, CurrentDrive(), ETrue);
45 void ReadBootSector(TFatBootSector& aBootSector)
47 TInt nRes = ReadBootSector(TheFs, CurrentDrive(), KBootSectorNum<<KDefaultSectorLog2, aBootSector);
48 test(nRes == KErrNone);
50 if(!aBootSector.IsValid())
52 test.Printf(_L("Wrong bootsector! Dump:\n"));
53 aBootSector.PrintDebugInfo();
61 ReadBootSector(gBootSector);
64 void doDirNameTest(const TDesC& aLongName, const TDesC& aShortName)
66 TBuf<KMaxFileName> longDirNamePath;
67 TBuf<KMaxFileName> shortDirNamePath;
68 TBuf<KMaxFileName> longName;
69 TBuf<KMaxFileName> shortName;
70 longDirNamePath = gSessionPath;
71 longDirNamePath += aLongName;
72 longDirNamePath.Append('\\');
74 // Create new directory and check creation
75 TInt r = TheFs.MkDir(longDirNamePath);
80 r= TheFs.GetDir(longDirNamePath, dumUint, dumUint, dumDir);
86 r = TheFs.GetShortName(longDirNamePath, shortName);
88 r = shortName.Compare(aShortName);
92 shortDirNamePath = gSessionPath;
93 shortDirNamePath += shortName;
94 shortDirNamePath.Append('\\');
95 r = TheFs.GetLongName(shortDirNamePath, longName);
97 r = longName.Compare(aLongName);
100 r = TheFs.RmDir(longDirNamePath);
104 void doFileNameTest(const TDesC& aLongName, const TDesC& aShortName)
106 TFileName lgnFullPath;
107 TFileName shnFullPath;
111 TInt r = TheFs.SessionPath(gSessionPath);
113 lgnFullPath = gSessionPath;
114 lgnFullPath += aLongName;
116 MakeFile_CPTest(lgnFullPath);
118 r = TheFs.GetShortName(lgnFullPath, shn);
120 r = shn.Compare(aShortName);
124 shnFullPath = gSessionPath;
125 shnFullPath += aShortName;
127 r = TheFs.GetLongName(shnFullPath, lgn);
129 r = lgn.Compare(aLongName);
132 r = TheFs.Delete(lgnFullPath);
136 #endif //_DEBUG || _DEBUG_RELEASE
138 //----------------------------------------------------------------------------------------------
139 //! @SYMTestCaseID PBASE-t_fatcharsetconv-0407
141 //! @SYMDEF DEF101875
142 //! @SYMTestCaseDesc This test case is to test volume label setting with Unicode characters
143 //! @SYMTestActions 1. Changes locale to load testing codepage dll, check returning error code
144 //! 2. Sets volume label with Unicode (less than 11 bytes long), test setting
145 //! success, gets volume label and compares it with the original Unicode string;
146 //! 3. Sets volume label with a Unicode string contains less than 11 characters
147 //! but occupies bigger than 11 bytes, checks the returning error code;
148 //! 4. Compares the volume label with the Unicode string used in action 2
149 //! @SYMTestExpectedResults
150 //! 1. KErrNone should be returned;
151 //! 2. The comparison should return 0;
152 //! 3. KErrBadName should be returned;
153 //! 4. The comparison should return 0;
154 //! @SYMTestPriority High
155 //! @SYMTestStatus Implemented
156 //----------------------------------------------------------------------------------------------
157 void TestUnicodeVolumeLabel()
159 test.Next(_L("Test unicode volume labels"));
160 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
162 TInt r = TheFs.SessionPath(gSessionPath);
165 r = TheFs.CharToDrive(gSessionPath[0], driveNum);
168 // Retrieves the original volume label
170 r = TheFs.Volume(vInfo, driveNum);
171 const TInt KVolumeLabelSize = 11;
172 TBuf<KVolumeLabelSize> originalVolumeLabel(vInfo.iName);
174 // Tests setting volume label with unicode characters
175 _LIT(KUnicodeVolumeLabel, "\x65B0\x65B0\x65B0");
177 r = TheFs.SetVolumeLabel(KUnicodeVolumeLabel, driveNum);
179 r = TheFs.Volume(vInfo, driveNum);
181 r = vInfo.iName.Compare(KUnicodeVolumeLabel);
184 // Tests setting volume label with unicode characters that bigger than 11 bytes
185 _LIT(KVolumeLabelOverflow, "\x65B0\x65B0\x65B0\x65B0\x65B0\x65B0");
186 r = TheFs.SetVolumeLabel(KVolumeLabelOverflow, driveNum);
187 test(r==KErrOverflow);
189 // Sets back the original volume label
190 r = TheFs.SetVolumeLabel(originalVolumeLabel, driveNum);
192 r = TheFs.Volume(vInfo, driveNum);
194 r = vInfo.iName.Compare(originalVolumeLabel);
197 test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details."));
198 #endif // _DEBUG) || _DEBUG_RELEASE
201 //----------------------------------------------------------------------------------------------
202 //! @SYMTestCaseID PBASE-t_fatcharsetconv-0408
204 //! @SYMDEF DEF101875
205 //! @SYMTestCaseDesc This test case is to test the "8 bytes" boundary of short name length,
206 //! which is defined in FAT Specification.
207 //! @SYMTestActions 1. Creates files and directories with different Unicode strings that
208 //! have different combinations of length (of characters) and size (of
209 //! bytes occupied), check for error of creation.
210 //! 2. Gets their short name, compares with expected values, gets their long
211 //! name, compares with original Unicode strings.
212 //! The strings and short name tested are as below:
213 //! 2.1. original string: "Abc"
214 //! expected short name: "ABC";
215 //! 2.2. original string: "\x65B0\x6587\x4EF6\x4EF6"
216 //! expected short name: "\x65B0\x6587\x4EF6\x4EF6";
217 //! 2.3. original string: "\x65B0\x6587\x4EF6(01)"
218 //! expected short name: "\x65B0\x6587\x4EF6~1";
219 //! 2.4. original string: "Abcdefghi"
220 //! expected short name: "ABCDEF~1";
221 //! 2.5. original string: "\x65B0(Abcdefgh)"
222 //! expected short name: "\x65B0(ABC~1";
223 //! @SYMTestExpectedResults
224 //! 1. File should be created with no error;
225 //! 2. Comparisons should return 0;
226 //! @SYMTestPriority High
227 //! @SYMTestStatus Implemented
228 //----------------------------------------------------------------------------------------------
229 void TestShortNameBoundary()
231 test.Next(_L("8 bytes' name boundary tests"));
232 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
234 // File names will be used for testing boundaries
235 _LIT(KTestFileName3C3B, "Abc"); // 3 characters, 3 bytes long
236 _LIT(KTestFileName3C3B_short, "ABC"); // Expected short name
237 _LIT(KTestFileName4C8B, "\x65B0\x6587\x4EF6\x4EF6");// 4 characters, 8 bytes long
238 _LIT(KTestFileName4C8B_short, "\x65B0\x6587\x4EF6\x4EF6");// Expected short name
239 _LIT(KTestFileName7C10B, "\x65B0\x6587\x4EF6(01)"); // 7 characters, 10 bytes long
240 _LIT(KTestFileName7C10B_short, "\x65B0\x6587\x4EF6~1"); // Expected short name
241 _LIT(KTestFileName9C9B, "Abcdefghi"); // 9 characters, 9 bytes long
242 _LIT(KTestFileName9C9B_short, "ABCDEF~1"); // Expected short name
243 _LIT(KTestFileName9C10B, "\x65B0(Abcdefgh)"); // 9 characters, 10 bytes long
244 _LIT(KTestFileName9C10B_short, "\x65B0(ABC~1"); // Expected short name
246 // Test file creation and long/short name generation
247 doFileNameTest(KTestFileName3C3B, KTestFileName3C3B_short);
248 doFileNameTest(KTestFileName4C8B, KTestFileName4C8B_short);
249 doFileNameTest(KTestFileName7C10B, KTestFileName7C10B_short);
250 doFileNameTest(KTestFileName9C9B, KTestFileName9C9B_short);
251 doFileNameTest(KTestFileName9C10B, KTestFileName9C10B_short);
253 doDirNameTest(KTestFileName3C3B, KTestFileName3C3B_short);
254 doDirNameTest(KTestFileName4C8B, KTestFileName4C8B_short);
255 doDirNameTest(KTestFileName7C10B, KTestFileName7C10B_short);
256 doDirNameTest(KTestFileName9C9B, KTestFileName9C9B_short);
257 doDirNameTest(KTestFileName9C10B, KTestFileName9C10B_short);
260 test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details."));
261 #endif // _DEBUG) || _DEBUG_RELEASE
264 //----------------------------------------------------------------------------------------------
265 //! @SYMTestCaseID PBASE-t_fatcharsetconv-0794
266 //! @SYMTestCaseDesc This test case is to test the extensions of the short names generated are consistent for file names
267 //! consisting of UNICODE characters. In a shortname, if the character at the third location (in 8.3 format)
268 //! is a head byte of a UNICODE character then it should be ignored.
269 //! @SYMTestActions 1. Creates files and directories with different Unicode strings that
270 //! have different combinations of extension length (of characters) and size (of
271 //! bytes occupied), check for error of creation.
272 //! 2. Gets their short name, compares with expected values, gets their long
273 //! name, compares with original Unicode strings.
274 //! The strings and short name tested are as below:
275 //! 2.1. original string: "abcdef.\x65B0"
276 //! expected short name: "ABCDEF.\x65B0";
277 //! 2.2. original string: "abcdef.t\x65B0"
278 //! expected short name: "ABCDEF.T\x65B0";
279 //! 2.3. original string: "abcdef.\x65B0t"
280 //! expected short name: "ABCDEF.\x65B0T";
281 //! 2.4. original string: "abcdefg.\x65B0\x65B0"
282 //! expected short name: "ABCDEF~1.\x65B0";
284 //! @SYMTestExpectedResults
285 //! 1. File should be created with no error;
286 //! 2. Comparisons should return 0;
287 //! @SYMTestPriority High
288 //! @SYMTestStatus Implemented
289 //----------------------------------------------------------------------------------------------
291 void TestConsistentShortNameExtGeneration()
293 test.Next(_L("Test consistent short name extensions are generated"));
294 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
296 // File names will be used for testing boundaries
297 _LIT(KTestFileNameExt1C2B, "abcdefg.\x65B0"); // 1 characters, 2 bytes long ;only one Unicode character in the extension
298 _LIT(KTestFileNameExt1C2B_short, "ABCDEFG.\x65B0"); //Expected short name
299 _LIT(KTestFileNameExt2C3B2U, "abcdefg.t\x65B0"); // 2 characters, 3 bytes long ;Unicode character at the 2nd location of the extension
300 _LIT(KTestFileNameExt2C3B2U_short, "ABCDEFG.T\x65B0"); //Expected short name
301 _LIT(KTestFileNameExt2C3B1U, "abcdefg.\x65B0t"); // 2 characters, 3 bytes long ;Unicode character at the 1st location of the extension
302 _LIT(KTestFileNameExt2C3B1U_short, "ABCDEFG.\x65B0T"); //Expected short name
303 _LIT(KTestFileNameExt2C4B, "abcdefg.\x65B0\x65B0");// 2 characters, 4 bytes long ;both are Unicode characters in the extension
304 _LIT(KTestFileNameExt2C4B_short, "ABCDEF~1.\x65B0"); //Expected short name
307 // Test file creation and long/short name generation
308 doFileNameTest(KTestFileNameExt1C2B, KTestFileNameExt1C2B_short);
309 doFileNameTest(KTestFileNameExt2C3B2U, KTestFileNameExt2C3B2U_short);
310 doFileNameTest(KTestFileNameExt2C3B1U, KTestFileNameExt2C3B1U_short);
311 doFileNameTest(KTestFileNameExt2C4B, KTestFileNameExt2C4B_short);
313 doDirNameTest(KTestFileNameExt1C2B, KTestFileNameExt1C2B_short);
314 doDirNameTest(KTestFileNameExt2C3B2U, KTestFileNameExt2C3B2U_short);
315 doDirNameTest(KTestFileNameExt2C3B1U, KTestFileNameExt2C3B1U_short);
316 doDirNameTest(KTestFileNameExt2C4B, KTestFileNameExt2C4B_short);
318 test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details."));
319 #endif // _DEBUG) || _DEBUG_RELEASE
323 //----------------------------------------------------------------------------------------------
324 //! @SYMTestCaseID PBASE-t_fatcharsetconv-0795
325 //! @SYMTestCaseDesc This test case is to test whether the short names generated for file names
326 //! consisting of UNICODE characters are consistent or not. In a shortname, if the character immediately
327 //! preceding the tilde(~) is a head byte of a UNICODE character then it should be ignored.
328 //! @SYMTestActions 1. Creates files and directories with different Unicode strings that
329 //! have different combinations of length (of characters) and size (of
330 //! bytes occupied), check for error of creation.
331 //! 2. Gets their short name, compares with expected values, gets their long
332 //! name, compares with original Unicode strings.
333 //! The strings and short name tested are as below:
334 //! 2.1. original string: "a\x65B0(bcd)"
335 //! expected short name: "A\x65B0(BCD)";
336 //! 2.2. original string: "ab\x65B0(cdef)"
337 //! expected short name: "AB\x65B0(C~1")";
338 //! 2.3. original string: "abc\x65B0(def)"
339 //! expected short name: "ABC\x65B0(~1";
340 //! 2.4. original string: "abcd\x65B0(ef)"
341 //! expected short name: "ABCD\x65B0~1";
342 //! 2.5. original string: "abcde\x65B0(f)"
343 //! expected short name: "ABCDE~1";
344 //! @SYMTestExpectedResults
345 //! 1. File should be created with no error;
346 //! 2. Comparisons should return 0;
347 //! @SYMTestPriority High
348 //! @SYMTestStatus Implemented
349 //----------------------------------------------------------------------------------------------
350 void TestConsistentShortNameGeneration()
352 test.Next(_L("Test consistent short name generation"));
353 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
355 //unicode characters.
357 _LIT(KTestFileName7C8B2U, "a\x65B0(bcd)"); // 7 characters, 8 bytes long ,Unicode character at the 2nd location.
358 _LIT(KTestFileName7C8B2U_short, "A\x65B0(BCD)"); // Expected short name
359 _LIT(KTestFileName9C10B3U, "ab\x65B0(cdef)"); // 9 characters, 10 bytes long ,Unicode character at the 3rd location.
360 _LIT(KTestFileName9C10B3U_short,"AB\x65B0(C~1"); // Expected short name
361 _LIT(KTestFileName9C10B4U, "abc\x65B0(def)"); // 9 characters, 10 bytes long ,Unicode character at the 4th location.
362 _LIT(KTestFileName9C10B4U_short,"ABC\x65B0(~1"); // Expected short name
363 _LIT(KTestFileName9C10B5U, "abcd\x65B0(ef)"); // 9 characters, 10 bytes long ,Unicode character at the 6th location.
364 _LIT(KTestFileName9C10B5U_short,"ABCD\x65B0~1"); // Expected short name
365 _LIT(KTestFileName9C10B6U, "abcde\x65B0(f)"); // 9 characters, 10 bytes long ,repeat Unicode character at the 6th location.
366 _LIT(KTestFileName9C10B6U_short,"ABCDE~1"); // Expected short name
368 // Test file creation and long/short name generation
369 doFileNameTest(KTestFileName7C8B2U, KTestFileName7C8B2U_short);
370 doFileNameTest(KTestFileName9C10B3U, KTestFileName9C10B3U_short);
371 doFileNameTest(KTestFileName9C10B4U, KTestFileName9C10B4U_short);
372 doFileNameTest(KTestFileName9C10B5U, KTestFileName9C10B5U_short);
373 doFileNameTest(KTestFileName9C10B6U, KTestFileName9C10B6U_short);
375 doDirNameTest(KTestFileName7C8B2U, KTestFileName7C8B2U_short);
376 doDirNameTest(KTestFileName9C10B3U, KTestFileName9C10B3U_short);
377 doDirNameTest(KTestFileName9C10B4U, KTestFileName9C10B4U_short);
378 doDirNameTest(KTestFileName9C10B5U, KTestFileName9C10B5U_short);
379 doDirNameTest(KTestFileName9C10B6U, KTestFileName9C10B6U_short);
381 test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details."));
382 #endif // _DEBUG) || _DEBUG_RELEASE
385 //----------------------------------------------------------------------------------------------
386 //! @SYMTestCaseID PBASE-t_fatcharsetconv-0409
388 //! @SYMDEF DEF101875 INC100580
389 //! @SYMTestCaseDesc This test case is to test creation of files with their Unicode names are
390 //! duplicate to existing files.
391 //! @SYMTestActions 1. Creates a file with its name contains 4 Unicode characters but occupies
392 //! 8 bytes ("\x65B0\x6587\x4EF6\x4EF6"), check for creation;
393 //! 2. Creates a file with 11 bytes' long Unicode name and first 8 bytes are
394 //! identical with the file created in Action 1 ("\x65B0\x6587\x4EF6\x4EF6(A)"),
395 //! check for file creation;
396 //! 3. Gets the short name of the file created in Action 2, compares it with
397 //! expected short name ("\x65B0\x6587\x4EF6~1"), gets the long name of this
398 //! file and compares it with its original Unicode name;
399 //! 4. Creates a file with 12 bytes' long Unicode name and first 8 bytes are
400 //! identical with the file created in Action 1 and Action 2
401 //! ("\x65B0\x6587\x4EF6\x4EF6(AB)"), check for file creation;
402 //! 5. Gets the short name of the file created in Action 4, compares it with
403 //! expected values ("\x65B0\x6587\x4EF6~2"), gets the long name of this file
404 //! and compares it with its original Unicode name;
405 //! @SYMTestExpectedResults
406 //! 1. File creation should return KErrNone;
407 //! 2. File creation should return KErrNone;
408 //! 3. Comparisons should return 0;
409 //! 4. File creation should return KErrNone;
410 //! 5. Comparisons should return 0;
411 //! @SYMTestPriority High
412 //! @SYMTestStatus Implemented
413 //----------------------------------------------------------------------------------------------
414 void TestDuplicateLongFileNames()
416 test.Next(_L("Testing tilde and numbers (\"~n\") are applied correctly for multiple long-named files"));
417 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
419 // These are to test "~1", "~2" behaviours when the first 8 bytes of new files
420 // are identical with existing files
421 _LIT(KTestFileName4C8B, "\x65B0\x6587\x4EF6\x4EF6.TXT");
422 _LIT(KTestFileName7C11B, "\x65B0\x6587\x4EF6\x4EF6(A).TXT");
423 _LIT(KTestFileName7C11B_short, "\x65B0\x6587\x4EF6~1.TXT");
424 _LIT(KTestFileName8C12B, "\x65B0\x6587\x4EF6\x4EF6(AB).TXT");
425 _LIT(KTestFileName8C12B_short, "\x65B0\x6587\x4EF6~2.TXT");
427 ////////////////////////////////////////
428 // 1. Test duplicate long file names
429 ////////////////////////////////////////
432 MakeFile_CPTest(KTestFileName4C8B);
433 MakeFile_CPTest(KTestFileName7C11B);
434 r = TheFs.GetShortName(KTestFileName7C11B, sn);
436 r = sn.Compare(KTestFileName7C11B_short);
440 MakeFile_CPTest(KTestFileName8C12B);
441 r = TheFs.GetShortName(KTestFileName8C12B, sn);
443 r = sn.Compare(KTestFileName8C12B_short);
446 r = TheFs.Delete(KTestFileName4C8B);
449 r = TheFs.Delete(KTestFileName7C11B);
452 r = TheFs.Delete(KTestFileName8C12B);
456 test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details."));
457 #endif // _DEBUG) || _DEBUG_RELEASE
461 //----------------------------------------------------------------------------------------------
462 //! @SYMTestCaseID PBASE-t_fatcharsetconv-0410
464 //! @SYMDEF DEF101875 INC100580
465 //! @SYMTestCaseDesc This test case is to test creation of directories with their Unicode names are
466 //! duplicate to existing directories .
467 //! @SYMTestActions 1. Creates a directories with its name contains 4 Unicode characters but occupies
468 //! 8 bytes ("\x65B0\x6587\x4EF6\x4EF6"), check for creation;
469 //! 2. Creates a directories with 11 bytes' long Unicode name and first 8 bytes are
470 //! identical with the directories created in Action 1 ("\x65B0\x6587\x4EF6\x4EF6(A)"),
471 //! check for file creation;
472 //! 3. Gets the short name of the directories created in Action 2, compares it with
473 //! expected short name ("\x65B0\x6587\x4EF6~1"), gets the long name of this
474 //! directories and compares it with its original Unicode name;
475 //! 4. Creates a directories with 12 bytes' long Unicode name and first 8 bytes are
476 //! identical with the directories created in Action 1 and Action 2
477 //! ("\x65B0\x6587\x4EF6\x4EF6(AB)"), check for directories creation;
478 //! 5. Gets the short name of the directories created in Action 4, compares it with
479 //! expected values ("\x65B0\x6587\x4EF6~2"), gets the long name of this directories
480 //! and compares it with its original Unicode name;
481 //! @SYMTestExpectedResults
482 //! 1. Dir creation should return KErrNone;
483 //! 2. Dir creation should return KErrNone;
484 //! 3. Comparisons should return 0;
485 //! 4. Dir creation should return KErrNone;
486 //! 5. Comparisons should return 0;
487 //! @SYMTestPriority High
488 //! @SYMTestStatus Implemented
489 //----------------------------------------------------------------------------------------------
490 void TestDuplicateLongDirNames()
492 test.Next(_L("Testing tilde and number appended correctly for duplicate long name dirs"));
493 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
494 TheFs.SessionPath(gSessionPath);
496 // These are to test "~1", "~2" behaviours when the first 8 bytes of new directories
497 // are identical with existing directories
498 _LIT(KTestDirName4C8B, "\\F32-TST\\T_CODEPAGE_PLUGIN\\\x65B0\x6587\x4EF6\x4EF6\\");
499 _LIT(KTestDirName7C11B, "\\F32-TST\\T_CODEPAGE_PLUGIN\\\x65B0\x6587\x4EF6\x4EF6(A)\\");
500 _LIT(KTestDirName7C11B_short, "\x65B0\x6587\x4EF6~1");
501 _LIT(KTestDirName8C12B, "\\F32-TST\\T_CODEPAGE_PLUGIN\\\x65B0\x6587\x4EF6\x4EF6(AB)\\");
502 _LIT(KTestDirName8C12B_short, "\x65B0\x6587\x4EF6~2");
504 // Create 1st file with 8 bytes long/short name
506 MakeDir(KTestDirName4C8B);
507 MakeDir(KTestDirName7C11B);
511 r = TheFs.GetShortName(KTestDirName7C11B, sn);
513 r = sn.Compare(KTestDirName7C11B_short);
516 MakeDir(KTestDirName8C12B);
517 r = TheFs.GetShortName(KTestDirName8C12B, sn);
519 r = sn.Compare(KTestDirName8C12B_short);
523 test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details."));
524 #endif // _DEBUG) || _DEBUG_RELEASE
527 //----------------------------------------------------------------------------------------------
528 //! @SYMTestCaseID PBASE-t_fatcharsetconv-0791
530 //! @SYMDEF DEF117345
531 //! @SYMTestCaseDesc This test case is to test short name with 'E5' as the leading byte is correctly
532 //! handled on FAT implementations
533 //! @SYMTestActions 1. Creates a file with unicode long name "\x88F9.TXT", it will be converted into
534 //! "\xE5E5.TXT" according to codepage 932 when creating short name.
535 //! 2. Gets the short name and compare it with its original unicode "\x88F9.TXT", make
536 //! sure the conversion "\xE5E5.TXT" has been handled correctly
537 //! @SYMTestExpectedResults
538 //! 1. Comparisons should return 0;
539 //! @SYMTestPriority High
540 //! @SYMTestStatus Implemented
541 //----------------------------------------------------------------------------------------------
542 void TestLeadingE5Handling()
544 test.Next(_L("Test Leading \'E5\' byte handling (DEF117345)"));
545 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
546 TheFs.SessionPath(gSessionPath);
548 _LIT(KTestFilePathAndName, "\\F32-TST\\T_CODEPAGE_PLUGIN\\\x88F9.TXT");
549 _LIT(KTestFileShortName, "\x88F9.TXT");
552 MakeFile_CPTest(KTestFilePathAndName);
554 r = TheFs.GetShortName(KTestFilePathAndName, sn);
556 r = sn.Compare(KTestFileShortName);
560 test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details."));
561 #endif // _DEBUG) || _DEBUG_RELEASE
563 //----------------------------------------------------------------------------------------------
564 //! @SYMTestCaseID PBASE-t_fatcharsetconv-2320
566 //! @SYMDEF PDEF130334
567 //! @SYMTestCaseDesc This test case is to test creating a file with "\u3005" name correctly
568 //! @SYMTestActions 1. Creates a file with unicode long name "\u3005.TXT"
569 //! 2. Gets the short name and compare it with its original unicode "\u3005.TXT"
570 //! 3. Gets the long name and compare it with its original unicode "\u3005.TXT"
571 //! @SYMTestExpectedResults
572 //! 1. Comparisons should return 0;
573 //! @SYMTestPriority High
574 //! @SYMTestStatus Implemented
575 //----------------------------------------------------------------------------------------------
578 test.Next(_L("Test creating a file with \\x3005 name correctly (DEF128521)"));
579 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
580 TheFs.SessionPath(gSessionPath);
582 _LIT(KTestFilePathAndName, "\\F32-TST\\T_CODEPAGE_PLUGIN\\\x3005.TXT");
583 _LIT(KTestFileName, "\x3005.TXT");
586 MakeFile_CPTest(KTestFilePathAndName);
589 r = TheFs.GetShortName(KTestFilePathAndName, sn);
591 r = sn.Compare(KTestFileName);
594 r = TheFs.GetLongName(KTestFilePathAndName, ln);
596 r = ln.Compare(KTestFileName);
600 test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details."));
603 //----------------------------------------------------------------------------------------------
604 //! @SYMTestCaseID PBASE-t_fatcharsetconv-1359
606 //! @SYMDEF INC125768
607 //! @SYMTestCaseDesc This test case is to test the compatibility of file opening, to make sure files
608 //! with only one DOS entry which contains unicode short name is accessible on Symbian OS
609 //! from version 9.3 onwards.
610 //! @SYMTestActions Manually creates a single entried, unicode named file under root direcotry, then
611 //! access it via RFs::Entry() API using its uniocde name. Check the entry is accessible.
612 //! @SYMTestExpectedResults
613 //! RFs::Entry() should return with KErrNone;
614 //! @SYMTestPriority High
615 //! @SYMTestStatus Implemented
616 //----------------------------------------------------------------------------------------------
617 void TestCompatibility()
619 test.Next(_L("test file opening compatibility"));
620 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
624 TFileName fn = _L("\\ABCD");
626 TInt r=file.Create(TheFs,fn,EFileRead);
630 // Assume this file is the first entry in the root directory
631 r=TheDisk.Open(TheFs,CurrentDrive());
634 //-- read the 1st dir entry, it should be a DOS entry
635 const TInt posEntry1=gBootSector.RootDirStartSector() << KDefaultSectorLog2; //-- dir entry1 position
637 TFatDirEntry fatEntry1;
638 TPtr8 ptrEntry1((TUint8*)&fatEntry1,sizeof(TFatDirEntry));
639 test(TheDisk.Read(posEntry1, ptrEntry1)==KErrNone);
640 test(!fatEntry1.IsVFatEntry());
642 // Manually modify the short name into unicode characters
643 // Unicode: 0x(798F 5C71 96C5 6CBB)
644 // Shift-JIS: 0x(959F 8E52 89EB 8EA1)
646 TBuf8<8> unicodeSN = _L8("ABCD1234");
656 fatEntry1.SetName(unicodeSN);
657 test(TheDisk.Write(posEntry1, ptrEntry1)==KErrNone);
667 TInt err = TheFs.Entry(fn, entry);
669 err = TheFs.Delete(fn);
672 test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details."));
673 #endif // _DEBUG) || _DEBUG_RELEASE
676 //----------------------------------------------------------------------------------------------
677 //! @SYMTestCaseID PBASE-t_fatcharsetconv-1395
679 //! @SYMDEF INC126563
680 //! @SYMTestCaseDesc This test case is to test the definition of valid DOS characters on Symbian
681 //! FAT/FAT32 complies with FAT Spec.
682 //! @SYMTestActions Manually creates a file with "0x7F" characters in its name, then check it can
683 //! ben accessed successfully.
684 //! @SYMTestExpectedResults
685 //! RFs::Entry() should return with KErrNone;
686 //! @SYMTestPriority High
687 //! @SYMTestStatus Implemented
688 //----------------------------------------------------------------------------------------------
691 test.Next(_L("Test INC126563: FAT/FAT32: unable to open or delete file whose name contains illegal characters"));
692 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
696 TFileName fn = _L("\\AB");
698 test.Next(_L("create file \"AB\" under root directory"));
699 TInt r=file.Create(TheFs,fn,EFileRead);
703 test.Next(_L("manually change file name to \"0x7F0x450x7F0x45\" via raw disk accessing"));
704 // Assume this file is the first entry in the root directory
705 r=TheDisk.Open(TheFs,CurrentDrive());
708 //-- read the first dir entry, it should be a DOS entry
709 const TInt posEntry1=gBootSector.RootDirStartSector() << KDefaultSectorLog2; //-- dir entry1 position
711 TFatDirEntry fatEntry1;
712 TPtr8 ptrEntry1((TUint8*)&fatEntry1,sizeof(TFatDirEntry));
713 test(TheDisk.Read(posEntry1, ptrEntry1)==KErrNone);
714 test(!fatEntry1.IsVFatEntry());
716 TBuf8<8> unicodeSN = _L8("ABCD");
722 fatEntry1.SetName(unicodeSN);
723 test(TheDisk.Write(posEntry1, ptrEntry1)==KErrNone);
726 test.Next(_L("access entries under root directory via RDir::Open()"));
728 r = dir.Open(TheFs, _L("\\"), KEntryAttNormal);
730 TEntryArray entryArray;
731 r = dir.Read(entryArray);
732 test(entryArray.Count()==1);
735 entry = entryArray[0];
736 test.Printf(_L("entryArray[0] = \"%S\"\n"), &entry.iName);
740 TFileName fullname= _L("\\");
741 fullname.Append(name);
743 test.Next(_L("try to open or delete file entries retrieved"));
744 r = file.Open(TheFs, fullname, EFileRead);
748 r = TheFs.Delete(fullname);
751 test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details."));
752 #endif // _DEBUG) || _DEBUG_RELEASE
755 //----------------------------------------------------------------------------------------------
756 //! @SYMTestCaseID PBASE-t_fatcharsetconv-1402
758 //! @SYMDEF INC127905
759 //! @SYMTestCaseDesc This test case is to test RFs::ScanDrive() does not incorrectly remove files
760 //! with unicode short file names.
761 //! @SYMTestActions Creates a file with unicode file names then check if the file is still accessible
762 //! after scandrive operations.
763 //! @SYMTestExpectedResults
764 //! RFs::Delete() should return with KErrNone;
765 //! @SYMTestPriority High
766 //! @SYMTestStatus Implemented
767 //----------------------------------------------------------------------------------------------
770 test.Next(_L("Test INC127905: Unicode name file deleted after Scandrive"));
771 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
772 TFileName fn = _L("ABCDE");
783 _LIT(KShortName, "\x3055\x307E\x3056~1");
785 r = TheFs.GetShortName(fn, sn);
787 r = sn.Compare(KShortName);
790 r = TheFs.ScanDrive(_L("gSessionPath"));
793 r = TheFs.Delete(fn);
796 test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details."));
797 #endif // _DEBUG) || _DEBUG_RELEASE