Update contrib.
1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of the License "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // f32test\locl\localeutils\t_localeutils_cp932.cpp
18 #define __E32TEST_EXTENSION__
26 #include "..\server\t_server.h"
27 #include "fat_utils.h"
29 RTest test(_L("T_LOCALEUTILS_CP932"));
31 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
32 using namespace Fat_Test_Utils;
33 static RRawDisk TheDisk;
34 static TFatBootSector gBootSector;
35 _LIT(KTestLocale, "t_tlocl_cp932.dll");
39 FormatFatDrive(TheFs, CurrentDrive(), ETrue);
42 void ReadBootSector(TFatBootSector& aBootSector)
45 TInt nRes = ReadBootSector(TheFs, CurrentDrive(), KBootSectorNum<<KDefaultSectorLog2, aBootSector);
46 test(nRes == KErrNone);
48 if(!aBootSector.IsValid())
50 test.Printf(_L("Wrong bootsector! Dump:\n"));
51 aBootSector.PrintDebugInfo();
59 ReadBootSector(gBootSector);
62 void doDirNameTest(const TDesC& aLongName, const TDesC& aShortName)
64 TBuf<KMaxFileName> longDirNamePath;
65 TBuf<KMaxFileName> shortDirNamePath;
66 TBuf<KMaxFileName> longName;
67 TBuf<KMaxFileName> shortName;
68 longDirNamePath = gSessionPath;
69 longDirNamePath += aLongName;
70 longDirNamePath.Append('\\');
72 // Create new directory and check creation
73 TInt r = TheFs.MkDir(longDirNamePath);
77 r= TheFs.GetDir(longDirNamePath, dumUint, dumUint, dumDir);
83 r = TheFs.GetShortName(longDirNamePath, shortName);
85 r = shortName.Compare(aShortName);
89 shortDirNamePath = gSessionPath;
90 shortDirNamePath += shortName;
91 shortDirNamePath.Append('\\');
92 r = TheFs.GetLongName(shortDirNamePath, longName);
94 r = longName.Compare(aLongName);
97 r = TheFs.RmDir(longDirNamePath);
101 void doFileNameTest(const TDesC& aLongName, const TDesC& aShortName)
103 TFileName lgnFullPath;
104 TFileName shnFullPath;
108 TInt r = TheFs.SessionPath(gSessionPath);
110 lgnFullPath = gSessionPath;
111 lgnFullPath += aLongName;
113 MakeFile(lgnFullPath);
116 r = TheFs.GetShortName(lgnFullPath, shn);
118 r = shn.Compare(aShortName);
122 shnFullPath = gSessionPath;
123 shnFullPath += aShortName;
125 r = TheFs.GetLongName(shnFullPath, lgn);
127 r = lgn.Compare(aLongName);
130 test_KErrNone(TheFs.Delete(lgnFullPath));
132 #endif //_DEBUG || _DEBUG_RELEASE
134 //----------------------------------------------------------------------------------------------
135 //! @SYMTestCaseID PBASE-t_fatcharsetconv-0406
137 //! @SYMDEF DEF101875
138 //! @SYMTestCaseDesc This test case is to test the default behaviours of LocaleUtils functions
139 //! in FAT.fsy before FATCharsetConv is integrated (i.e. there is no codepage
141 //! @SYMTestActions 1. Creates a file with a name containing 3 valid Unicode characters,
142 //! gets its short name and compares it with "___", gets its long name and
143 //! compares it with the original Unicode string;
144 //! 2. Creates a file with a name containing 4 Unicode characters, each 16-bit
145 //! Unicode character contains two illegal 8-bit characters, test if the
146 //! file can be created successfully, gets its short name and compares it
147 //! with "____", gets its long name and compares it with the original
149 //! @SYMTestExpectedResults
150 //! 1. The file should be created successfully, the comparisons should return 0;
151 //! 2. The file should be created successfully, the comparisons should return 0;
152 //! @SYMTestPriority High
153 //! @SYMTestCaseDependencies
154 //! This test should be run before any codepage DLL is loaded,
155 //! i.e., prior to all other test cases defined in this file.
156 //! @SYMTestStatus Implemented
157 //----------------------------------------------------------------------------------------------
158 void TestBeforeFATCharsetConvInteg()
160 test.Next(_L("Test default unicode handling in FAT implementation"));
161 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
162 _LIT(KTestNormalUnicodeFileName, "\x65B0\x6587\x4EF6.TXT");
163 _LIT(KTestNormalUnicodeFileNameShortDefualt, "___.TXT");
164 _LIT(KTestFileNameWithIllegalChars, "\x222F\x2F3A\x3C3E\x7C00.TXT");
165 _LIT(KFileNameWithIllegalCharsShort, "____.TXT");
167 TInt r = TheFs.ControlIo(CurrentDrive(), KControlIoDisableFatUtilityFunctions);
170 // Create file and check creation
171 MakeFile(KTestNormalUnicodeFileName);
173 // Check short name to test if there is any codepage DLL loaded already.
174 r = TheFs.GetShortName(KTestNormalUnicodeFileName, shn);
177 r = shn.Compare(KTestNormalUnicodeFileNameShortDefualt);
181 r = TheFs.GetLongName(KTestNormalUnicodeFileNameShortDefualt, lgn);
183 r = lgn.Compare(KTestNormalUnicodeFileName);
186 // Test illegal 8-bit ASCII chars in 16-bit Unicode chars.
187 MakeFile(KTestFileNameWithIllegalChars);
188 r = TheFs.GetShortName(KTestFileNameWithIllegalChars, shn);
190 r = shn.Compare(KFileNameWithIllegalCharsShort);
193 test_KErrNone(TheFs.Delete(KTestFileNameWithIllegalChars));
194 test_KErrNone(TheFs.Delete(KTestNormalUnicodeFileName));
196 r = TheFs.ControlIo(CurrentDrive(), KControlIoEnableFatUtilityFunctions);
199 test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details."));
200 #endif // _DEBUG) || _DEBUG_RELEASE
205 //----------------------------------------------------------------------------------------------
206 //! @SYMTestCaseID PBASE-t_fatcharsetconv-0407
208 //! @SYMDEF DEF101875
209 //! @SYMTestCaseDesc This test case is to test volume label setting with Unicode characters
210 //! @SYMTestActions 1. Changes locale to load testing codepage dll, check returning error code
211 //! 2. Sets volume label with Unicode (less than 11 bytes long), test setting
212 //! success, gets volume label and compares it with the original Unicode string;
213 //! 3. Sets volume label with a Unicode string contains less than 11 characters
214 //! but occupies bigger than 11 bytes, checks the returning error code;
215 //! 4. Compares the volume label with the Unicode string used in action 2
216 //! @SYMTestExpectedResults
217 //! 1. KErrNone should be returned;
218 //! 2. The comparison should return 0;
219 //! 3. KErrBadName should be returned;
220 //! 4. The comparison should return 0;
221 //! @SYMTestPriority High
222 //! @SYMTestStatus Implemented
223 //----------------------------------------------------------------------------------------------
224 void TestUnicodeVolumeLabel()
226 test.Next(_L("Test unicode volume labels"));
227 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
228 TInt r = UserSvr::ChangeLocale(KTestLocale);
231 r = TheFs.SessionPath(gSessionPath);
234 r = TheFs.CharToDrive(gSessionPath[0], driveNum);
237 // Retrieves the original volume label
239 r = TheFs.Volume(vInfo, driveNum);
240 const TInt KVolumeLabelSize = 11;
241 TBuf<KVolumeLabelSize> originalVolumeLabel(vInfo.iName);
243 // Tests setting volume label with unicode characters
244 _LIT(KUnicodeVolumeLabel, "\x65B0\x65B0\x65B0");
246 r = TheFs.SetVolumeLabel(KUnicodeVolumeLabel, driveNum);
248 r = TheFs.Volume(vInfo, driveNum);
250 r = vInfo.iName.Compare(KUnicodeVolumeLabel);
253 // Tests setting volume label with unicode characters that bigger than 11 bytes
254 _LIT(KVolumeLabelOverflow, "\x65B0\x65B0\x65B0\x65B0\x65B0\x65B0");
255 r = TheFs.SetVolumeLabel(KVolumeLabelOverflow, driveNum);
256 // locale dll and codepage dll both return diff retrun values so check against both cases.
257 test((r == KErrBadName) || (r == KErrOverflow));
259 r = TheFs.Volume(vInfo, driveNum);
261 r = vInfo.iName.Compare(KUnicodeVolumeLabel);
264 // Sets back the original volume label
265 r = TheFs.SetVolumeLabel(originalVolumeLabel, driveNum);
268 test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details."));
269 #endif // _DEBUG) || _DEBUG_RELEASE
273 //----------------------------------------------------------------------------------------------
274 //! @SYMTestCaseID PBASE-t_fatcharsetconv-0408
276 //! @SYMDEF DEF101875
277 //! @SYMTestCaseDesc This test case is to test the "8 bytes" boundary of short name length,
278 //! which is defined in FAT Specification.
279 //! @SYMTestActions 1. Creates files and directories with different Unicode strings that
280 //! have different combinations of length (of characters) and size (of
281 //! bytes occupied), check for error of creation.
282 //! 2. Gets their short name, compares with expected values, gets their long
283 //! name, compares with original Unicode strings.
284 //! The strings and short name tested are as below:
285 //! 2.1. original string: "Abc"
286 //! expected short name: "ABC";
287 //! 2.2. original string: "\x65B0\x6587\x4EF6\x4EF6"
288 //! expected short name: "\x65B0\x6587\x4EF6\x4EF6";
289 //! 2.3. original string: "\x65B0\x6587\x4EF6(01)"
290 //! expected short name: "\x65B0\x6587\x4EF6~1";
291 //! 2.4. original string: "Abcdefghi"
292 //! expected short name: "ABCDEF~1";
293 //! 2.5. original string: "\x65B0(Abcdefgh)"
294 //! expected short name: "\x65B0(ABC~1";
295 //! @SYMTestExpectedResults
296 //! 1. File should be created with no error;
297 //! 2. Comparisons should return 0;
298 //! @SYMTestPriority High
299 //! @SYMTestStatus Implemented
300 //----------------------------------------------------------------------------------------------
301 void TestShortNameBoundary()
303 test.Next(_L("8 bytes' name boundary tests"));
304 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
305 TInt r = UserSvr::ChangeLocale(KTestLocale);
308 // File names will be used for testing boundaries
309 _LIT(KTestFileName3C3B, "Abc"); // 3 characters, 3 bytes long
310 _LIT(KTestFileName3C3B_short, "ABC"); // Expected short name
311 _LIT(KTestFileName4C8B, "\x65B0\x6587\x4EF6\x4EF6");// 4 characters, 8 bytes long
312 _LIT(KTestFileName4C8B_short, "\x65B0\x6587\x4EF6\x4EF6");// Expected short name
313 _LIT(KTestFileName7C10B, "\x65B0\x6587\x4EF6(01)"); // 7 characters, 10 bytes long
314 _LIT(KTestFileName7C10B_short, "\x65B0\x6587\x4EF6~1"); // Expected short name
315 _LIT(KTestFileName9C9B, "Abcdefghi"); // 9 characters, 9 bytes long
316 _LIT(KTestFileName9C9B_short, "ABCDEF~1"); // Expected short name
317 _LIT(KTestFileName9C10B, "\x65B0(Abcdefgh)"); // 9 characters, 10 bytes long
318 _LIT(KTestFileName9C10B_short, "\x65B0(ABC~1"); // Expected short name
320 // Test file creation and long/short name generation
321 doFileNameTest(KTestFileName3C3B, KTestFileName3C3B_short);
322 doFileNameTest(KTestFileName4C8B, KTestFileName4C8B_short);
323 doFileNameTest(KTestFileName7C10B, KTestFileName7C10B_short);
324 doFileNameTest(KTestFileName9C9B, KTestFileName9C9B_short);
325 doFileNameTest(KTestFileName9C10B, KTestFileName9C10B_short);
327 doDirNameTest(KTestFileName3C3B, KTestFileName3C3B_short);
328 doDirNameTest(KTestFileName4C8B, KTestFileName4C8B_short);
329 doDirNameTest(KTestFileName7C10B, KTestFileName7C10B_short);
330 doDirNameTest(KTestFileName9C9B, KTestFileName9C9B_short);
331 doDirNameTest(KTestFileName9C10B, KTestFileName9C10B_short);
333 test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details."));
334 #endif // _DEBUG) || _DEBUG_RELEASE
337 //----------------------------------------------------------------------------------------------
338 //! @SYMTestCaseID PBASE-t_fatcharsetconv-0794
339 //! @SYMTestCaseDesc This test case is to test the extensions of the short names generated are consistent for file names
340 //! consisting of UNICODE characters. In a shortname, if the character at the third location (in 8.3 format)
341 //! is a head byte of a UNICODE character then it should be ignored.
342 //! @SYMTestActions 1. Creates files and directories with different Unicode strings that
343 //! have different combinations of extension length (of characters) and size (of
344 //! bytes occupied), check for error of creation.
345 //! 2. Gets their short name, compares with expected values, gets their long
346 //! name, compares with original Unicode strings.
347 //! The strings and short name tested are as below:
348 //! 2.1. original string: "abcdef.\x65B0"
349 //! expected short name: "ABCDEF.\x65B0";
350 //! 2.2. original string: "abcdef.t\x65B0"
351 //! expected short name: "ABCDEF.T\x65B0";
352 //! 2.3. original string: "abcdef.\x65B0t"
353 //! expected short name: "ABCDEF.\x65B0T";
354 //! 2.4. original string: "abcdefg.\x65B0\x65B0"
355 //! expected short name: "ABCDEF~1.\x65B0";
357 //! @SYMTestExpectedResults
358 //! 1. File should be created with no error;
359 //! 2. Comparisons should return 0;
360 //! @SYMTestPriority High
361 //! @SYMTestStatus Implemented
362 //----------------------------------------------------------------------------------------------
364 void TestConsistentShortNameExtGeneration()
366 test.Next(_L("Test consistent short name extensions are generated"));
367 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
368 TInt r = UserSvr::ChangeLocale(KTestLocale);
371 // File names will be used for testing boundaries
372 _LIT(KTestFileNameExt1C2B, "abcdefg.\x65B0"); // 1 characters, 2 bytes long ;only one Unicode character in the extension
373 _LIT(KTestFileNameExt1C2B_short, "ABCDEFG.\x65B0"); //Expected short name
374 _LIT(KTestFileNameExt2C3B2U, "abcdefg.t\x65B0"); // 2 characters, 3 bytes long ;Unicode character at the 2nd location of the extension
375 _LIT(KTestFileNameExt2C3B2U_short, "ABCDEFG.T\x65B0"); //Expected short name
376 _LIT(KTestFileNameExt2C3B1U, "abcdefg.\x65B0t"); // 2 characters, 3 bytes long ;Unicode character at the 1st location of the extension
377 _LIT(KTestFileNameExt2C3B1U_short, "ABCDEFG.\x65B0T"); //Expected short name
378 _LIT(KTestFileNameExt2C4B, "abcdefg.\x65B0\x65B0");// 2 characters, 4 bytes long ;both are Unicode characters in the extension
379 _LIT(KTestFileNameExt2C4B_short, "ABCDEF~1.\x65B0"); //Expected short name
382 // Test file creation and long/short name generation
383 doFileNameTest(KTestFileNameExt1C2B, KTestFileNameExt1C2B_short);
384 doFileNameTest(KTestFileNameExt2C3B2U, KTestFileNameExt2C3B2U_short);
385 doFileNameTest(KTestFileNameExt2C3B1U, KTestFileNameExt2C3B1U_short);
386 doFileNameTest(KTestFileNameExt2C4B, KTestFileNameExt2C4B_short);
388 doDirNameTest(KTestFileNameExt1C2B, KTestFileNameExt1C2B_short);
389 doDirNameTest(KTestFileNameExt2C3B2U, KTestFileNameExt2C3B2U_short);
390 doDirNameTest(KTestFileNameExt2C3B1U, KTestFileNameExt2C3B1U_short);
391 doDirNameTest(KTestFileNameExt2C4B, KTestFileNameExt2C4B_short);
393 test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details."));
394 #endif // _DEBUG) || _DEBUG_RELEASE
398 //----------------------------------------------------------------------------------------------
399 //! @SYMTestCaseID PBASE-t_fatcharsetconv-0795
400 //! @SYMTestCaseDesc This test case is to test whether the short names generated for file names
401 //! consisting of UNICODE characters are consistent or not. In a shortname, if the character immediately
402 //! preceding the tilde(~) is a head byte of a UNICODE character then it should be ignored.
403 //! @SYMTestActions 1. Creates files and directories with different Unicode strings that
404 //! have different combinations of length (of characters) and size (of
405 //! bytes occupied), check for error of creation.
406 //! 2. Gets their short name, compares with expected values, gets their long
407 //! name, compares with original Unicode strings.
408 //! The strings and short name tested are as below:
409 //! 2.1. original string: "a\x65B0(bcd)"
410 //! expected short name: "A\x65B0(BCD)";
411 //! 2.2. original string: "ab\x65B0(cdef)"
412 //! expected short name: "AB\x65B0(C~1")";
413 //! 2.3. original string: "abc\x65B0(def)"
414 //! expected short name: "ABC\x65B0(~1";
415 //! 2.4. original string: "abcd\x65B0(ef)"
416 //! expected short name: "ABCD\x65B0~1";
417 //! 2.5. original string: "abcde\x65B0(f)"
418 //! expected short name: "ABCDE~1";
419 //! @SYMTestExpectedResults
420 //! 1. File should be created with no error;
421 //! 2. Comparisons should return 0;
422 //! @SYMTestPriority High
423 //! @SYMTestStatus Implemented
424 //----------------------------------------------------------------------------------------------
425 void TestConsistentShortNameGeneration()
427 test.Next(_L("Test consistent short name generation"));
428 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
429 TInt r = UserSvr::ChangeLocale(KTestLocale);
432 //unicode characters.
434 _LIT(KTestFileName7C8B2U, "a\x65B0(bcd)"); // 7 characters, 8 bytes long ,Unicode character at the 2nd location.
435 _LIT(KTestFileName7C8B2U_short, "A\x65B0(BCD)"); // Expected short name
436 _LIT(KTestFileName9C10B3U, "ab\x65B0(cdef)"); // 9 characters, 10 bytes long ,Unicode character at the 3rd location.
437 _LIT(KTestFileName9C10B3U_short,"AB\x65B0(C~1"); // Expected short name
438 _LIT(KTestFileName9C10B4U, "abc\x65B0(def)"); // 9 characters, 10 bytes long ,Unicode character at the 4th location.
439 _LIT(KTestFileName9C10B4U_short,"ABC\x65B0(~1"); // Expected short name
440 _LIT(KTestFileName9C10B5U, "abcd\x65B0(ef)"); // 9 characters, 10 bytes long ,Unicode character at the 6th location.
441 _LIT(KTestFileName9C10B5U_short,"ABCD\x65B0~1"); // Expected short name
442 _LIT(KTestFileName9C10B6U, "abcde\x65B0(f)"); // 9 characters, 10 bytes long ,repeat Unicode character at the 6th location.
443 _LIT(KTestFileName9C10B6U_short,"ABCDE~1"); // Expected short name
445 // Test file creation and long/short name generation
446 doFileNameTest(KTestFileName7C8B2U, KTestFileName7C8B2U_short);
447 doFileNameTest(KTestFileName9C10B3U, KTestFileName9C10B3U_short);
448 doFileNameTest(KTestFileName9C10B4U, KTestFileName9C10B4U_short);
449 doFileNameTest(KTestFileName9C10B5U, KTestFileName9C10B5U_short);
450 doFileNameTest(KTestFileName9C10B6U, KTestFileName9C10B6U_short);
452 doDirNameTest(KTestFileName7C8B2U, KTestFileName7C8B2U_short);
453 doDirNameTest(KTestFileName9C10B3U, KTestFileName9C10B3U_short);
454 doDirNameTest(KTestFileName9C10B4U, KTestFileName9C10B4U_short);
455 doDirNameTest(KTestFileName9C10B5U, KTestFileName9C10B5U_short);
456 doDirNameTest(KTestFileName9C10B6U, KTestFileName9C10B6U_short);
458 test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details."));
459 #endif // _DEBUG) || _DEBUG_RELEASE
462 //----------------------------------------------------------------------------------------------
463 //! @SYMTestCaseID PBASE-t_fatcharsetconv-0409
465 //! @SYMDEF DEF101875 INC100580
466 //! @SYMTestCaseDesc This test case is to test creation of files with their Unicode names are
467 //! duplicate to existing files.
468 //! @SYMTestActions 1. Creates a file with its name contains 4 Unicode characters but occupies
469 //! 8 bytes ("\x65B0\x6587\x4EF6\x4EF6"), check for creation;
470 //! 2. Creates a file with 11 bytes' long Unicode name and first 8 bytes are
471 //! identical with the file created in Action 1 ("\x65B0\x6587\x4EF6\x4EF6(A)"),
472 //! check for file creation;
473 //! 3. Gets the short name of the file created in Action 2, compares it with
474 //! expected short name ("\x65B0\x6587\x4EF6~1"), gets the long name of this
475 //! file and compares it with its original Unicode name;
476 //! 4. Creates a file with 12 bytes' long Unicode name and first 8 bytes are
477 //! identical with the file created in Action 1 and Action 2
478 //! ("\x65B0\x6587\x4EF6\x4EF6(AB)"), check for file creation;
479 //! 5. Gets the short name of the file created in Action 4, compares it with
480 //! expected values ("\x65B0\x6587\x4EF6~2"), gets the long name of this file
481 //! and compares it with its original Unicode name;
482 //! @SYMTestExpectedResults
483 //! 1. File creation should return KErrNone;
484 //! 2. File creation should return KErrNone;
485 //! 3. Comparisons should return 0;
486 //! 4. File creation should return KErrNone;
487 //! 5. Comparisons should return 0;
488 //! @SYMTestPriority High
489 //! @SYMTestStatus Implemented
490 //----------------------------------------------------------------------------------------------
491 void TestDuplicateLongFileNames()
493 test.Next(_L("Testing tilde and numbers (\"~n\") are applied correctly for multiple long-named files"));
494 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
495 TInt r = UserSvr::ChangeLocale(KTestLocale);
498 // These are to test "~1", "~2" behaviours when the first 8 bytes of new files
499 // are identical with existing files
500 _LIT(KTestFileName4C8B, "\x65B0\x6587\x4EF6\x4EF6.TXT");
501 _LIT(KTestFileName7C11B, "\x65B0\x6587\x4EF6\x4EF6(A).TXT");
502 _LIT(KTestFileName7C11B_short, "\x65B0\x6587\x4EF6~1.TXT");
503 _LIT(KTestFileName8C12B, "\x65B0\x6587\x4EF6\x4EF6(AB).TXT");
504 _LIT(KTestFileName8C12B_short, "\x65B0\x6587\x4EF6~2.TXT");
506 ////////////////////////////////////////
507 // 1. Test duplicate long file names
508 ////////////////////////////////////////
511 MakeFile(KTestFileName4C8B);
512 MakeFile(KTestFileName7C11B);
514 r = TheFs.GetShortName(KTestFileName7C11B, sn);
516 r = sn.Compare(KTestFileName7C11B_short);
520 MakeFile(KTestFileName8C12B);
522 r = TheFs.GetShortName(KTestFileName8C12B, sn);
524 r = sn.Compare(KTestFileName8C12B_short);
527 test_KErrNone(TheFs.Delete(KTestFileName4C8B));
528 test_KErrNone(TheFs.Delete(KTestFileName7C11B));
529 test_KErrNone(TheFs.Delete(KTestFileName8C12B));
532 test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details."));
533 #endif // _DEBUG) || _DEBUG_RELEASE
537 //----------------------------------------------------------------------------------------------
538 //! @SYMTestCaseID PBASE-t_fatcharsetconv-0410
540 //! @SYMDEF DEF101875 INC100580
541 //! @SYMTestCaseDesc This test case is to test creation of directories with their Unicode names are
542 //! duplicate to existing directories .
543 //! @SYMTestActions 1. Creates a directories with its name contains 4 Unicode characters but occupies
544 //! 8 bytes ("\x65B0\x6587\x4EF6\x4EF6"), check for creation;
545 //! 2. Creates a directories with 11 bytes' long Unicode name and first 8 bytes are
546 //! identical with the directories created in Action 1 ("\x65B0\x6587\x4EF6\x4EF6(A)"),
547 //! check for file creation;
548 //! 3. Gets the short name of the directories created in Action 2, compares it with
549 //! expected short name ("\x65B0\x6587\x4EF6~1"), gets the long name of this
550 //! directories and compares it with its original Unicode name;
551 //! 4. Creates a directories with 12 bytes' long Unicode name and first 8 bytes are
552 //! identical with the directories created in Action 1 and Action 2
553 //! ("\x65B0\x6587\x4EF6\x4EF6(AB)"), check for directories creation;
554 //! 5. Gets the short name of the directories created in Action 4, compares it with
555 //! expected values ("\x65B0\x6587\x4EF6~2"), gets the long name of this directories
556 //! and compares it with its original Unicode name;
557 //! @SYMTestExpectedResults
558 //! 1. Dir creation should return KErrNone;
559 //! 2. Dir creation should return KErrNone;
560 //! 3. Comparisons should return 0;
561 //! 4. Dir creation should return KErrNone;
562 //! 5. Comparisons should return 0;
563 //! @SYMTestPriority High
564 //! @SYMTestStatus Implemented
565 //----------------------------------------------------------------------------------------------
566 void TestDuplicateLongDirNames()
568 test.Next(_L("Testing tilde and number appended correctly for duplicate long name dirs"));
569 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
570 TheFs.SessionPath(gSessionPath);
571 TInt r = UserSvr::ChangeLocale(KTestLocale);
574 // These are to test "~1", "~2" behaviours when the first 8 bytes of new directories
575 // are identical with existing directories
576 _LIT(KTestDirName4C8B, "\\F32-TST\\T_LOCALEUTILS_CP932\\\x65B0\x6587\x4EF6\x4EF6\\");
577 _LIT(KTestDirName7C11B, "\\F32-TST\\T_LOCALEUTILS_CP932\\\x65B0\x6587\x4EF6\x4EF6(A)\\");
578 _LIT(KTestDirName7C11B_short, "\x65B0\x6587\x4EF6~1");
579 _LIT(KTestDirName8C12B, "\\F32-TST\\T_LOCALEUTILS_CP932\\\x65B0\x6587\x4EF6\x4EF6(AB)\\");
580 _LIT(KTestDirName8C12B_short, "\x65B0\x6587\x4EF6~2");
582 // Create 1st file with 8 bytes long/short name
583 MakeDir(KTestDirName4C8B);
584 MakeDir(KTestDirName7C11B);
587 r = TheFs.GetShortName(KTestDirName7C11B, sn);
589 r = sn.Compare(KTestDirName7C11B_short);
592 MakeDir(KTestDirName8C12B);
594 r = TheFs.GetShortName(KTestDirName8C12B, sn);
596 r = sn.Compare(KTestDirName8C12B_short);
600 test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details."));
601 #endif // _DEBUG) || _DEBUG_RELEASE
604 //----------------------------------------------------------------------------------------------
605 //! @SYMTestCaseID PBASE-t_fatcharsetconv-0791
607 //! @SYMDEF DEF117345
608 //! @SYMTestCaseDesc This test case is to test short name with 'E5' as the leading byte is correctly
609 //! handled on FAT implementations
610 //! @SYMTestActions 1. Creates a file with unicode long name "\x88F9.TXT", it will be converted into
611 //! "\xE5E5.TXT" according to codepage 932 when creating short name.
612 //! 2. Gets the short name and compare it with its original unicode "\x88F9.TXT", make
613 //! sure the conversion "\xE5E5.TXT" has been handled correctly
614 //! @SYMTestExpectedResults
615 //! 1. Comparisons should return 0;
616 //! @SYMTestPriority High
617 //! @SYMTestStatus Implemented
618 //----------------------------------------------------------------------------------------------
619 void TestLeadingE5Handling()
621 test.Next(_L("Test Leading \'E5\' byte handling (DEF117345)"));
622 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
623 TheFs.SessionPath(gSessionPath);
624 TInt r = UserSvr::ChangeLocale(KTestLocale);
627 _LIT(KTestFilePathAndName, "\\F32-TST\\T_LOCALEUTILS_CP932\\\x88F9.TXT");
628 _LIT(KTestFileShortName, "\x88F9.TXT");
630 MakeFile(KTestFilePathAndName);
632 r = TheFs.GetShortName(KTestFilePathAndName, sn);
634 r = sn.Compare(KTestFileShortName);
638 test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details."));
639 #endif // _DEBUG) || _DEBUG_RELEASE
641 //----------------------------------------------------------------------------------------------
642 //! @SYMTestCaseID PBASE-t_fatcharsetconv-2320
644 //! @SYMDEF PDEF130334
645 //! @SYMTestCaseDesc This test case is to test creating a file with "\u3005" name correctly
646 //! @SYMTestActions 1. Creates a file with unicode long name "\u3005.TXT"
647 //! 2. Gets the short name and compare it with its original unicode "\u3005.TXT"
648 //! 3. Gets the long name and compare it with its original unicode "\u3005.TXT"
649 //! @SYMTestExpectedResults
650 //! 1. Comparisons should return 0;
651 //! @SYMTestPriority High
652 //! @SYMTestStatus Implemented
653 //----------------------------------------------------------------------------------------------
656 test.Next(_L("Test creating a file with \\x3005 name correctly (DEF128521)"));
657 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
658 TheFs.SessionPath(gSessionPath);
659 TInt r = UserSvr::ChangeLocale(KTestLocale);
662 _LIT(KTestFilePathAndName, "\\F32-TST\\T_LOCALEUTILS_CP932\\\x3005.TXT");
663 _LIT(KTestFileName, "\x3005.TXT");
665 MakeFile(KTestFilePathAndName);
667 r = TheFs.GetShortName(KTestFilePathAndName, sn);
669 r = sn.Compare(KTestFileName);
672 r = TheFs.GetLongName(KTestFilePathAndName, ln);
674 r = ln.Compare(KTestFileName);
678 test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details."));
681 //----------------------------------------------------------------------------------------------
682 //! @SYMTestCaseID PBASE-t_fatcharsetconv-1359
684 //! @SYMDEF INC125768
685 //! @SYMTestCaseDesc This test case is to test the compatibility of file opening, to make sure files
686 //! with only one DOS entry which contains unicode short name is accessible on Symbian OS
687 //! from version 9.3 onwards.
688 //! @SYMTestActions Manually creates a single entried, unicode named file under root direcotry, then
689 //! access it via RFs::Entry() API using its uniocde name. Check the entry is accessible.
690 //! @SYMTestExpectedResults
691 //! RFs::Entry() should return with KErrNone;
692 //! @SYMTestPriority High
693 //! @SYMTestStatus Implemented
694 //----------------------------------------------------------------------------------------------
695 void TestCompatibility()
697 test.Next(_L("test file opening compatibility"));
698 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
702 TFileName fn = _L("\\ABCD");
704 TInt r=file.Create(TheFs,fn,EFileRead);
708 // Assume this file is the first entry in the root directory
709 r=TheDisk.Open(TheFs,CurrentDrive());
712 //-- read the 1st dir entry, it should be a DOS entry
713 const TInt posEntry1=gBootSector.RootDirStartSector() << KDefaultSectorLog2; //-- dir entry1 position
715 TFatDirEntry fatEntry1;
716 TPtr8 ptrEntry1((TUint8*)&fatEntry1,sizeof(TFatDirEntry));
717 test(TheDisk.Read(posEntry1, ptrEntry1)==KErrNone);
718 test(!fatEntry1.IsVFatEntry());
720 // Manually modify the short name into unicode characters
721 // Unicode: 0x(798F 5C71 96C5 6CBB)
722 // Shift-JIS: 0x(959F 8E52 89EB 8EA1)
724 TBuf8<8> unicodeSN = _L8("ABCD1234");
734 fatEntry1.SetName(unicodeSN);
735 test(TheDisk.Write(posEntry1, ptrEntry1)==KErrNone);
738 // Access the file using its unicode file name
739 r = UserSvr::ChangeLocale(KTestLocale);
749 TInt err = TheFs.Entry(fn, entry);
751 err = TheFs.Delete(fn);
754 test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details."));
755 #endif // _DEBUG) || _DEBUG_RELEASE
758 //----------------------------------------------------------------------------------------------
759 //! @SYMTestCaseID PBASE-t_fatcharsetconv-1395
761 //! @SYMDEF INC126563
762 //! @SYMTestCaseDesc This test case is to test the definition of valid DOS characters on Symbian
763 //! FAT/FAT32 complies with FAT Spec.
764 //! @SYMTestActions Manually creates a file with "0x7F" characters in its name, then check it can
765 //! ben accessed successfully.
766 //! @SYMTestExpectedResults
767 //! RFs::Entry() should return with KErrNone;
768 //! @SYMTestPriority High
769 //! @SYMTestStatus Implemented
770 //----------------------------------------------------------------------------------------------
773 test.Next(_L("Test INC126563: FAT/FAT32: unable to open or delete file whose name contains illegal characters"));
774 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
778 TFileName fn = _L("\\AB");
780 test.Next(_L("create file \"AB\" under root directory"));
781 TInt r=file.Create(TheFs,fn,EFileRead);
785 test.Next(_L("manually change file name to \"0x7F0x450x7F0x45\" via raw disk accessing"));
786 // Assume this file is the first entry in the root directory
787 r=TheDisk.Open(TheFs,CurrentDrive());
790 //-- read the first dir entry, it should be a DOS entry
791 const TInt posEntry1=gBootSector.RootDirStartSector() << KDefaultSectorLog2; //-- dir entry1 position
793 TFatDirEntry fatEntry1;
794 TPtr8 ptrEntry1((TUint8*)&fatEntry1,sizeof(TFatDirEntry));
795 test(TheDisk.Read(posEntry1, ptrEntry1)==KErrNone);
796 test(!fatEntry1.IsVFatEntry());
798 TBuf8<8> unicodeSN = _L8("ABCD");
804 fatEntry1.SetName(unicodeSN);
805 test(TheDisk.Write(posEntry1, ptrEntry1)==KErrNone);
808 // Access the file using its unicode file name
809 r = UserSvr::ChangeLocale(KTestLocale);
812 test.Next(_L("access entries under root directory via RDir::Open()"));
814 r = dir.Open(TheFs, _L("\\"), KEntryAttNormal);
816 TEntryArray entryArray;
817 r = dir.Read(entryArray);
818 test(entryArray.Count()==1);
821 entry = entryArray[0];
822 test.Printf(_L("entryArray[0] = \"%S\"\n"), &entry.iName);
826 TFileName fullname= _L("\\");
827 fullname.Append(name);
829 test.Next(_L("try to open or delete file entries retrieved"));
830 r = file.Open(TheFs, fullname, EFileRead);
834 r = TheFs.Delete(fullname);
837 test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details."));
838 #endif // _DEBUG) || _DEBUG_RELEASE
841 //----------------------------------------------------------------------------------------------
842 //! @SYMTestCaseID PBASE-t_fatcharsetconv-1402
844 //! @SYMDEF INC127905
845 //! @SYMTestCaseDesc This test case is to test RFs::ScanDrive() does not incorrectly remove files
846 //! with unicode short file names.
847 //! @SYMTestActions Creates a file with unicode file names then check if the file is still accessible
848 //! after scandrive operations.
849 //! @SYMTestExpectedResults
850 //! RFs::Delete() should return with KErrNone;
851 //! @SYMTestPriority High
852 //! @SYMTestStatus Implemented
853 //----------------------------------------------------------------------------------------------
856 test.Next(_L("Test INC127905: Unicode name file deleted after Scandrive"));
857 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
858 TFileName fn = _L("ABCDE");
865 TInt r = UserSvr::ChangeLocale(KTestLocale);
870 _LIT(KShortName, "\x3055\x307E\x3056~1");
872 r = TheFs.GetShortName(fn, sn);
874 r = sn.Compare(KShortName);
877 r = TheFs.ScanDrive(_L("gSessionPath"));
880 r = TheFs.Delete(fn);
883 test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details."));
884 #endif // _DEBUG) || _DEBUG_RELEASE
887 void CallTestsL(void)
891 test.Start(_L("Starting T_LOCALEUTILS_CP932 tests"));
893 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
895 // Test only runs on Fat file systems
896 TheFs.SessionPath(gSessionPath);
897 TInt driveNum = CurrentDrive();
899 TInt r = TheFs.FileSystemName(name, driveNum);
902 if (name.Compare(_L("Fat")) != 0)
904 test.Printf(_L("Test only runs on 'Fat' drives"));
908 // Enables codepage dll implementation of LocaleUtils functions for this test only
909 r = TheFs.ControlIo(driveNum, KControlIoEnableFatUtilityFunctions);
912 CreateTestDirectory(_L("\\F32-TST\\T_LOCALEUTILS_CP932\\"));
913 TestBeforeFATCharsetConvInteg();
914 TestUnicodeVolumeLabel();
915 TestShortNameBoundary();
916 TestConsistentShortNameGeneration();
917 TestConsistentShortNameExtGeneration();
918 TestDuplicateLongFileNames();
919 TestDuplicateLongDirNames();
920 TestLeadingE5Handling();
923 DeleteTestDirectory();
927 // Disables codepage dll implementation of LocaleUtils functions for other base tests
928 r = TheFs.ControlIo(driveNum, KControlIoDisableFatUtilityFunctions);
934 test.Printf(_L("Drive %C: is not ready!"), 'A'+driveNum);
938 test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details."));
939 #endif // _DEBUG) || _DEBUG_RELEASE