|
1 /* |
|
2 * Copyright (c) 2007 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 |
|
18 |
|
19 #define __E32TEST_EXTENSION__ |
|
20 |
|
21 #include <e32test.h> |
|
22 #include <HAL.H> |
|
23 #include <f32fsys.h> |
|
24 #include <f32dbg.h> |
|
25 #include "..\server\t_server.h" |
|
26 #include "fat_utils.h" |
|
27 |
|
28 |
|
29 #if defined(_DEBUG) || defined(_DEBUG_RELEASE) |
|
30 using namespace Fat_Test_Utils; |
|
31 static RRawDisk TheDisk; |
|
32 static TFatBootSector gBootSector; |
|
33 |
|
34 #define MakeFile_CPTest(filename) \ |
|
35 { \ |
|
36 test.Printf(_L("MakeFile(%S) at LINE:%d\n"),&filename,__LINE__); \ |
|
37 MakeFile(filename); \ |
|
38 } |
|
39 |
|
40 void QuickFormat() |
|
41 { |
|
42 FormatFatDrive(TheFs, CurrentDrive(), ETrue); |
|
43 } |
|
44 |
|
45 void ReadBootSector(TFatBootSector& aBootSector) |
|
46 { |
|
47 TInt nRes = ReadBootSector(TheFs, CurrentDrive(), KBootSectorNum<<KDefaultSectorLog2, aBootSector); |
|
48 test(nRes == KErrNone); |
|
49 |
|
50 if(!aBootSector.IsValid()) |
|
51 { |
|
52 test.Printf(_L("Wrong bootsector! Dump:\n")); |
|
53 aBootSector.PrintDebugInfo(); |
|
54 test(0); |
|
55 } |
|
56 } |
|
57 |
|
58 void GetBootInfo() |
|
59 { |
|
60 QuickFormat(); |
|
61 ReadBootSector(gBootSector); |
|
62 } |
|
63 |
|
64 void doDirNameTest(const TDesC& aLongName, const TDesC& aShortName) |
|
65 { |
|
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('\\'); |
|
73 |
|
74 // Create new directory and check creation |
|
75 TInt r = TheFs.MkDir(longDirNamePath); |
|
76 test(r==KErrNone); |
|
77 |
|
78 TUint dumUint=0; |
|
79 CDir* dumDir; |
|
80 r= TheFs.GetDir(longDirNamePath, dumUint, dumUint, dumDir); |
|
81 test(r==KErrNone); |
|
82 test_NotNull(dumDir); |
|
83 delete dumDir; |
|
84 |
|
85 // Check short name |
|
86 r = TheFs.GetShortName(longDirNamePath, shortName); |
|
87 test(r==KErrNone); |
|
88 r = shortName.Compare(aShortName); |
|
89 test(r==0); |
|
90 |
|
91 // Check long name |
|
92 shortDirNamePath = gSessionPath; |
|
93 shortDirNamePath += shortName; |
|
94 shortDirNamePath.Append('\\'); |
|
95 r = TheFs.GetLongName(shortDirNamePath, longName); |
|
96 test(r==KErrNone); |
|
97 r = longName.Compare(aLongName); |
|
98 test(r==0); |
|
99 |
|
100 r = TheFs.RmDir(longDirNamePath); |
|
101 test(r==KErrNone); |
|
102 } |
|
103 |
|
104 void doFileNameTest(const TDesC& aLongName, const TDesC& aShortName) |
|
105 { |
|
106 TFileName lgnFullPath; |
|
107 TFileName shnFullPath; |
|
108 TFileName lgn; |
|
109 TFileName shn; |
|
110 |
|
111 TInt r = TheFs.SessionPath(gSessionPath); |
|
112 test(r==KErrNone); |
|
113 lgnFullPath = gSessionPath; |
|
114 lgnFullPath += aLongName; |
|
115 |
|
116 MakeFile_CPTest(lgnFullPath); |
|
117 // Check short name |
|
118 r = TheFs.GetShortName(lgnFullPath, shn); |
|
119 test(r==KErrNone); |
|
120 r = shn.Compare(aShortName); |
|
121 test(r==0); |
|
122 |
|
123 // Check long name |
|
124 shnFullPath = gSessionPath; |
|
125 shnFullPath += aShortName; |
|
126 |
|
127 r = TheFs.GetLongName(shnFullPath, lgn); |
|
128 test(r==KErrNone); |
|
129 r = lgn.Compare(aLongName); |
|
130 test(r==0); |
|
131 |
|
132 r = TheFs.Delete(lgnFullPath); |
|
133 test(r==KErrNone); |
|
134 |
|
135 } |
|
136 #endif //_DEBUG || _DEBUG_RELEASE |
|
137 |
|
138 //---------------------------------------------------------------------------------------------- |
|
139 //! @SYMTestCaseID PBASE-t_fatcharsetconv-0407 |
|
140 //! @SYMTestType CIT |
|
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() |
|
158 { |
|
159 test.Next(_L("Test unicode volume labels")); |
|
160 #if defined(_DEBUG) || defined(_DEBUG_RELEASE) |
|
161 |
|
162 TInt r = TheFs.SessionPath(gSessionPath); |
|
163 test(r==KErrNone); |
|
164 TInt driveNum; |
|
165 r = TheFs.CharToDrive(gSessionPath[0], driveNum); |
|
166 test(r==KErrNone); |
|
167 |
|
168 // Retrieves the original volume label |
|
169 TVolumeInfo vInfo; |
|
170 r = TheFs.Volume(vInfo, driveNum); |
|
171 const TInt KVolumeLabelSize = 11; |
|
172 TBuf<KVolumeLabelSize> originalVolumeLabel(vInfo.iName); |
|
173 |
|
174 // Tests setting volume label with unicode characters |
|
175 _LIT(KUnicodeVolumeLabel, "\x65B0\x65B0\x65B0"); |
|
176 |
|
177 r = TheFs.SetVolumeLabel(KUnicodeVolumeLabel, driveNum); |
|
178 test(r==KErrNone); |
|
179 r = TheFs.Volume(vInfo, driveNum); |
|
180 test(r==KErrNone); |
|
181 r = vInfo.iName.Compare(KUnicodeVolumeLabel); |
|
182 test(r==KErrNone); |
|
183 |
|
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); |
|
188 |
|
189 // Sets back the original volume label |
|
190 r = TheFs.SetVolumeLabel(originalVolumeLabel, driveNum); |
|
191 test(r==KErrNone); |
|
192 r = TheFs.Volume(vInfo, driveNum); |
|
193 test(r==KErrNone); |
|
194 r = vInfo.iName.Compare(originalVolumeLabel); |
|
195 test(r==0); |
|
196 #else |
|
197 test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details.")); |
|
198 #endif // _DEBUG) || _DEBUG_RELEASE |
|
199 } |
|
200 |
|
201 //---------------------------------------------------------------------------------------------- |
|
202 //! @SYMTestCaseID PBASE-t_fatcharsetconv-0408 |
|
203 //! @SYMTestType CIT |
|
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() |
|
230 { |
|
231 test.Next(_L("8 bytes' name boundary tests")); |
|
232 #if defined(_DEBUG) || defined(_DEBUG_RELEASE) |
|
233 |
|
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 |
|
245 |
|
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); |
|
252 |
|
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); |
|
258 |
|
259 #else |
|
260 test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details.")); |
|
261 #endif // _DEBUG) || _DEBUG_RELEASE |
|
262 } |
|
263 |
|
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"; |
|
283 //! |
|
284 //! @SYMTestExpectedResults |
|
285 //! 1. File should be created with no error; |
|
286 //! 2. Comparisons should return 0; |
|
287 //! @SYMTestPriority High |
|
288 //! @SYMTestStatus Implemented |
|
289 //---------------------------------------------------------------------------------------------- |
|
290 |
|
291 void TestConsistentShortNameExtGeneration() |
|
292 { |
|
293 test.Next(_L("Test consistent short name extensions are generated")); |
|
294 #if defined(_DEBUG) || defined(_DEBUG_RELEASE) |
|
295 |
|
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 |
|
305 |
|
306 |
|
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); |
|
312 |
|
313 doDirNameTest(KTestFileNameExt1C2B, KTestFileNameExt1C2B_short); |
|
314 doDirNameTest(KTestFileNameExt2C3B2U, KTestFileNameExt2C3B2U_short); |
|
315 doDirNameTest(KTestFileNameExt2C3B1U, KTestFileNameExt2C3B1U_short); |
|
316 doDirNameTest(KTestFileNameExt2C4B, KTestFileNameExt2C4B_short); |
|
317 #else |
|
318 test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details.")); |
|
319 #endif // _DEBUG) || _DEBUG_RELEASE |
|
320 } |
|
321 |
|
322 |
|
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() |
|
351 { |
|
352 test.Next(_L("Test consistent short name generation")); |
|
353 #if defined(_DEBUG) || defined(_DEBUG_RELEASE) |
|
354 |
|
355 //unicode characters. |
|
356 |
|
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 |
|
367 |
|
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); |
|
374 |
|
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); |
|
380 #else |
|
381 test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details.")); |
|
382 #endif // _DEBUG) || _DEBUG_RELEASE |
|
383 } |
|
384 |
|
385 //---------------------------------------------------------------------------------------------- |
|
386 //! @SYMTestCaseID PBASE-t_fatcharsetconv-0409 |
|
387 //! @SYMTestType CIT |
|
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() |
|
415 { |
|
416 test.Next(_L("Testing tilde and numbers (\"~n\") are applied correctly for multiple long-named files")); |
|
417 #if defined(_DEBUG) || defined(_DEBUG_RELEASE) |
|
418 |
|
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"); |
|
426 |
|
427 //////////////////////////////////////// |
|
428 // 1. Test duplicate long file names |
|
429 //////////////////////////////////////// |
|
430 TFileName sn; |
|
431 TInt r; |
|
432 MakeFile_CPTest(KTestFileName4C8B); |
|
433 MakeFile_CPTest(KTestFileName7C11B); |
|
434 r = TheFs.GetShortName(KTestFileName7C11B, sn); |
|
435 test(r==KErrNone); |
|
436 r = sn.Compare(KTestFileName7C11B_short); |
|
437 test(r==0); |
|
438 |
|
439 |
|
440 MakeFile_CPTest(KTestFileName8C12B); |
|
441 r = TheFs.GetShortName(KTestFileName8C12B, sn); |
|
442 test(r==KErrNone); |
|
443 r = sn.Compare(KTestFileName8C12B_short); |
|
444 test(r==0); |
|
445 |
|
446 r = TheFs.Delete(KTestFileName4C8B); |
|
447 test(r==KErrNone); |
|
448 |
|
449 r = TheFs.Delete(KTestFileName7C11B); |
|
450 test(r==KErrNone); |
|
451 |
|
452 r = TheFs.Delete(KTestFileName8C12B); |
|
453 test(r==KErrNone); |
|
454 |
|
455 #else |
|
456 test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details.")); |
|
457 #endif // _DEBUG) || _DEBUG_RELEASE |
|
458 } |
|
459 |
|
460 |
|
461 //---------------------------------------------------------------------------------------------- |
|
462 //! @SYMTestCaseID PBASE-t_fatcharsetconv-0410 |
|
463 //! @SYMTestType CIT |
|
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() |
|
491 { |
|
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); |
|
495 |
|
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"); |
|
503 |
|
504 // Create 1st file with 8 bytes long/short name |
|
505 TInt r; |
|
506 MakeDir(KTestDirName4C8B); |
|
507 MakeDir(KTestDirName7C11B); |
|
508 |
|
509 TFileName sn; |
|
510 |
|
511 r = TheFs.GetShortName(KTestDirName7C11B, sn); |
|
512 test(r==KErrNone); |
|
513 r = sn.Compare(KTestDirName7C11B_short); |
|
514 test(r==0); |
|
515 |
|
516 MakeDir(KTestDirName8C12B); |
|
517 r = TheFs.GetShortName(KTestDirName8C12B, sn); |
|
518 test(r==KErrNone); |
|
519 r = sn.Compare(KTestDirName8C12B_short); |
|
520 test(r==0); |
|
521 |
|
522 #else |
|
523 test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details.")); |
|
524 #endif // _DEBUG) || _DEBUG_RELEASE |
|
525 } |
|
526 |
|
527 //---------------------------------------------------------------------------------------------- |
|
528 //! @SYMTestCaseID PBASE-t_fatcharsetconv-0791 |
|
529 //! @SYMTestType CIT |
|
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() |
|
543 { |
|
544 test.Next(_L("Test Leading \'E5\' byte handling (DEF117345)")); |
|
545 #if defined(_DEBUG) || defined(_DEBUG_RELEASE) |
|
546 TheFs.SessionPath(gSessionPath); |
|
547 |
|
548 _LIT(KTestFilePathAndName, "\\F32-TST\\T_CODEPAGE_PLUGIN\\\x88F9.TXT"); |
|
549 _LIT(KTestFileShortName, "\x88F9.TXT"); |
|
550 |
|
551 TInt r; |
|
552 MakeFile_CPTest(KTestFilePathAndName); |
|
553 TFileName sn; |
|
554 r = TheFs.GetShortName(KTestFilePathAndName, sn); |
|
555 test(r==KErrNone); |
|
556 r = sn.Compare(KTestFileShortName); |
|
557 test(r==0); |
|
558 |
|
559 #else |
|
560 test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details.")); |
|
561 #endif // _DEBUG) || _DEBUG_RELEASE |
|
562 } |
|
563 //---------------------------------------------------------------------------------------------- |
|
564 //! @SYMTestCaseID PBASE-t_fatcharsetconv-2320 |
|
565 //! @SYMTestType CIT |
|
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 //---------------------------------------------------------------------------------------------- |
|
576 void TestDEF130334() |
|
577 { |
|
578 test.Next(_L("Test creating a file with \\x3005 name correctly (DEF128521)")); |
|
579 #if defined(_DEBUG) || defined(_DEBUG_RELEASE) |
|
580 TheFs.SessionPath(gSessionPath); |
|
581 |
|
582 _LIT(KTestFilePathAndName, "\\F32-TST\\T_CODEPAGE_PLUGIN\\\x3005.TXT"); |
|
583 _LIT(KTestFileName, "\x3005.TXT"); |
|
584 |
|
585 TInt r; |
|
586 MakeFile_CPTest(KTestFilePathAndName); |
|
587 |
|
588 TFileName sn; |
|
589 r = TheFs.GetShortName(KTestFilePathAndName, sn); |
|
590 test(r==KErrNone); |
|
591 r = sn.Compare(KTestFileName); |
|
592 test(r==0); |
|
593 TFileName ln; |
|
594 r = TheFs.GetLongName(KTestFilePathAndName, ln); |
|
595 test(r==KErrNone); |
|
596 r = ln.Compare(KTestFileName); |
|
597 test(r==0); |
|
598 |
|
599 #else |
|
600 test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details.")); |
|
601 #endif |
|
602 } |
|
603 //---------------------------------------------------------------------------------------------- |
|
604 //! @SYMTestCaseID PBASE-t_fatcharsetconv-1359 |
|
605 //! @SYMTestType CIT |
|
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() |
|
618 { |
|
619 test.Next(_L("test file opening compatibility")); |
|
620 #if defined(_DEBUG) || defined(_DEBUG_RELEASE) |
|
621 GetBootInfo(); |
|
622 |
|
623 RFile file; |
|
624 TFileName fn = _L("\\ABCD"); |
|
625 |
|
626 TInt r=file.Create(TheFs,fn,EFileRead); |
|
627 test(r==KErrNone); |
|
628 file.Close(); |
|
629 |
|
630 // Assume this file is the first entry in the root directory |
|
631 r=TheDisk.Open(TheFs,CurrentDrive()); |
|
632 test(r==KErrNone); |
|
633 |
|
634 //-- read the 1st dir entry, it should be a DOS entry |
|
635 const TInt posEntry1=gBootSector.RootDirStartSector() << KDefaultSectorLog2; //-- dir entry1 position |
|
636 |
|
637 TFatDirEntry fatEntry1; |
|
638 TPtr8 ptrEntry1((TUint8*)&fatEntry1,sizeof(TFatDirEntry)); |
|
639 test(TheDisk.Read(posEntry1, ptrEntry1)==KErrNone); |
|
640 test(!fatEntry1.IsVFatEntry()); |
|
641 |
|
642 // Manually modify the short name into unicode characters |
|
643 // Unicode: 0x(798F 5C71 96C5 6CBB) |
|
644 // Shift-JIS: 0x(959F 8E52 89EB 8EA1) |
|
645 |
|
646 TBuf8<8> unicodeSN = _L8("ABCD1234"); |
|
647 unicodeSN[0] = 0x95; |
|
648 unicodeSN[1] = 0x9F; |
|
649 unicodeSN[2] = 0x8E; |
|
650 unicodeSN[3] = 0x52; |
|
651 unicodeSN[4] = 0x89; |
|
652 unicodeSN[5] = 0xEB; |
|
653 unicodeSN[6] = 0x8E; |
|
654 unicodeSN[7] = 0xA1; |
|
655 |
|
656 fatEntry1.SetName(unicodeSN); |
|
657 test(TheDisk.Write(posEntry1, ptrEntry1)==KErrNone); |
|
658 TheDisk.Close(); |
|
659 |
|
660 fn = _L("\\ABCD"); |
|
661 fn[1] = 0x798F; |
|
662 fn[2] = 0x5C71; |
|
663 fn[3] = 0x96C5; |
|
664 fn[4] = 0x6CBB; |
|
665 |
|
666 TEntry entry; |
|
667 TInt err = TheFs.Entry(fn, entry); |
|
668 test(err==KErrNone); |
|
669 err = TheFs.Delete(fn); |
|
670 test(err==KErrNone); |
|
671 #else |
|
672 test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details.")); |
|
673 #endif // _DEBUG) || _DEBUG_RELEASE |
|
674 } |
|
675 |
|
676 //---------------------------------------------------------------------------------------------- |
|
677 //! @SYMTestCaseID PBASE-t_fatcharsetconv-1395 |
|
678 //! @SYMTestType CIT |
|
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 //---------------------------------------------------------------------------------------------- |
|
689 void TestINC126563() |
|
690 { |
|
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) |
|
693 GetBootInfo(); |
|
694 |
|
695 RFile file; |
|
696 TFileName fn = _L("\\AB"); |
|
697 |
|
698 test.Next(_L("create file \"AB\" under root directory")); |
|
699 TInt r=file.Create(TheFs,fn,EFileRead); |
|
700 test(r==KErrNone); |
|
701 file.Close(); |
|
702 |
|
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()); |
|
706 test(r==KErrNone); |
|
707 |
|
708 //-- read the first dir entry, it should be a DOS entry |
|
709 const TInt posEntry1=gBootSector.RootDirStartSector() << KDefaultSectorLog2; //-- dir entry1 position |
|
710 |
|
711 TFatDirEntry fatEntry1; |
|
712 TPtr8 ptrEntry1((TUint8*)&fatEntry1,sizeof(TFatDirEntry)); |
|
713 test(TheDisk.Read(posEntry1, ptrEntry1)==KErrNone); |
|
714 test(!fatEntry1.IsVFatEntry()); |
|
715 |
|
716 TBuf8<8> unicodeSN = _L8("ABCD"); |
|
717 unicodeSN[0] = 0x7F; |
|
718 unicodeSN[1] = 0x45; |
|
719 unicodeSN[2] = 0x7F; |
|
720 unicodeSN[3] = 0x45; |
|
721 |
|
722 fatEntry1.SetName(unicodeSN); |
|
723 test(TheDisk.Write(posEntry1, ptrEntry1)==KErrNone); |
|
724 TheDisk.Close(); |
|
725 |
|
726 test.Next(_L("access entries under root directory via RDir::Open()")); |
|
727 RDir dir; |
|
728 r = dir.Open(TheFs, _L("\\"), KEntryAttNormal); |
|
729 test(KErrNone == r); |
|
730 TEntryArray entryArray; |
|
731 r = dir.Read(entryArray); |
|
732 test(entryArray.Count()==1); |
|
733 TBuf<0x10> name; |
|
734 TEntry entry; |
|
735 entry = entryArray[0]; |
|
736 test.Printf(_L("entryArray[0] = \"%S\"\n"), &entry.iName); |
|
737 name = entry.iName; |
|
738 dir.Close(); |
|
739 |
|
740 TFileName fullname= _L("\\"); |
|
741 fullname.Append(name); |
|
742 |
|
743 test.Next(_L("try to open or delete file entries retrieved")); |
|
744 r = file.Open(TheFs, fullname, EFileRead); |
|
745 test(KErrNone == r); |
|
746 file.Close(); |
|
747 |
|
748 r = TheFs.Delete(fullname); |
|
749 test(KErrNone == r); |
|
750 #else |
|
751 test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details.")); |
|
752 #endif // _DEBUG) || _DEBUG_RELEASE |
|
753 } |
|
754 |
|
755 //---------------------------------------------------------------------------------------------- |
|
756 //! @SYMTestCaseID PBASE-t_fatcharsetconv-1402 |
|
757 //! @SYMTestType CIT |
|
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 //---------------------------------------------------------------------------------------------- |
|
768 void TestINC127905() |
|
769 { |
|
770 test.Next(_L("Test INC127905: Unicode name file deleted after Scandrive")); |
|
771 #if defined(_DEBUG) || defined(_DEBUG_RELEASE) |
|
772 TFileName fn = _L("ABCDE"); |
|
773 fn[0] = 0x3055; |
|
774 fn[1] = 0x307E; |
|
775 fn[2] = 0x3056; |
|
776 fn[3] = 0x307E; |
|
777 fn[4] = 0x306A; |
|
778 |
|
779 |
|
780 TInt r; |
|
781 MakeFile_CPTest(fn); |
|
782 |
|
783 _LIT(KShortName, "\x3055\x307E\x3056~1"); |
|
784 TFileName sn; |
|
785 r = TheFs.GetShortName(fn, sn); |
|
786 test(r==KErrNone); |
|
787 r = sn.Compare(KShortName); |
|
788 test(r==0); |
|
789 |
|
790 r = TheFs.ScanDrive(_L("gSessionPath")); |
|
791 test(r==KErrNone); |
|
792 |
|
793 r = TheFs.Delete(fn); |
|
794 test(r == KErrNone); |
|
795 #else |
|
796 test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details.")); |
|
797 #endif // _DEBUG) || _DEBUG_RELEASE |
|
798 } |
|
799 |