author | hgs |
Wed, 12 May 2010 10:34:10 +0100 | |
changeset 133 | 2a0ada0a1bf8 |
parent 33 | 0173bcd7697c |
child 109 | b3a1d9898418 |
permissions | -rw-r--r-- |
0 | 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". |
|
7 |
// |
|
8 |
// Initial Contributors: |
|
9 |
// Nokia Corporation - initial contribution. |
|
10 |
// |
|
11 |
// Contributors: |
|
12 |
// |
|
13 |
// Description: |
|
14 |
// f32test\locl\localeutils\t_localeutils_cp932.cpp |
|
15 |
// |
|
16 |
// |
|
17 |
||
18 |
#define __E32TEST_EXTENSION__ |
|
19 |
||
20 |
||
21 |
#include <e32test.h> |
|
22 |
#include <HAL.H> |
|
23 |
#include <f32fsys.h> |
|
24 |
#include <f32dbg.h> |
|
33
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
25 |
#include <e32svr.h> |
0 | 26 |
#include "..\server\t_server.h" |
27 |
#include "fat_utils.h" |
|
28 |
||
29 |
RTest test(_L("T_LOCALEUTILS_CP932")); |
|
30 |
||
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"); |
|
36 |
||
37 |
void QuickFormat() |
|
38 |
{ |
|
39 |
FormatFatDrive(TheFs, CurrentDrive(), ETrue); |
|
40 |
} |
|
41 |
||
42 |
void ReadBootSector(TFatBootSector& aBootSector) |
|
43 |
{ |
|
44 |
||
45 |
TInt nRes = ReadBootSector(TheFs, CurrentDrive(), KBootSectorNum<<KDefaultSectorLog2, aBootSector); |
|
46 |
test(nRes == KErrNone); |
|
47 |
||
48 |
if(!aBootSector.IsValid()) |
|
49 |
{ |
|
50 |
test.Printf(_L("Wrong bootsector! Dump:\n")); |
|
51 |
aBootSector.PrintDebugInfo(); |
|
52 |
test(0); |
|
53 |
} |
|
54 |
} |
|
55 |
||
56 |
void GetBootInfo() |
|
57 |
{ |
|
58 |
QuickFormat(); |
|
59 |
ReadBootSector(gBootSector); |
|
60 |
} |
|
61 |
||
62 |
void doDirNameTest(const TDesC& aLongName, const TDesC& aShortName) |
|
63 |
{ |
|
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('\\'); |
|
71 |
||
72 |
// Create new directory and check creation |
|
73 |
TInt r = TheFs.MkDir(longDirNamePath); |
|
74 |
test_KErrNone(r); |
|
75 |
TUint dumUint=0; |
|
76 |
CDir* dumDir; |
|
77 |
r= TheFs.GetDir(longDirNamePath, dumUint, dumUint, dumDir); |
|
78 |
test_KErrNone(r); |
|
79 |
test_NotNull(dumDir); |
|
80 |
delete dumDir; |
|
81 |
||
82 |
// Check short name |
|
83 |
r = TheFs.GetShortName(longDirNamePath, shortName); |
|
84 |
test_KErrNone(r); |
|
85 |
r = shortName.Compare(aShortName); |
|
86 |
test_Equal(r, 0); |
|
87 |
||
88 |
// Check long name |
|
89 |
shortDirNamePath = gSessionPath; |
|
90 |
shortDirNamePath += shortName; |
|
91 |
shortDirNamePath.Append('\\'); |
|
92 |
r = TheFs.GetLongName(shortDirNamePath, longName); |
|
93 |
test_KErrNone(r); |
|
94 |
r = longName.Compare(aLongName); |
|
95 |
test_Equal(r, 0); |
|
96 |
||
97 |
r = TheFs.RmDir(longDirNamePath); |
|
98 |
test_KErrNone(r); |
|
99 |
} |
|
100 |
||
101 |
void doFileNameTest(const TDesC& aLongName, const TDesC& aShortName) |
|
102 |
{ |
|
103 |
TFileName lgnFullPath; |
|
104 |
TFileName shnFullPath; |
|
105 |
TFileName lgn; |
|
106 |
TFileName shn; |
|
107 |
||
108 |
TInt r = TheFs.SessionPath(gSessionPath); |
|
109 |
test_KErrNone(r); |
|
110 |
lgnFullPath = gSessionPath; |
|
111 |
lgnFullPath += aLongName; |
|
112 |
||
113 |
MakeFile(lgnFullPath); |
|
114 |
||
115 |
// Check short name |
|
116 |
r = TheFs.GetShortName(lgnFullPath, shn); |
|
117 |
test_KErrNone(r); |
|
118 |
r = shn.Compare(aShortName); |
|
119 |
test_Equal(r, 0); |
|
120 |
||
121 |
// Check long name |
|
122 |
shnFullPath = gSessionPath; |
|
123 |
shnFullPath += aShortName; |
|
124 |
||
125 |
r = TheFs.GetLongName(shnFullPath, lgn); |
|
126 |
test_KErrNone(r); |
|
127 |
r = lgn.Compare(aLongName); |
|
128 |
test_Equal(r, 0); |
|
129 |
||
130 |
test_KErrNone(TheFs.Delete(lgnFullPath)); |
|
131 |
} |
|
132 |
#endif //_DEBUG || _DEBUG_RELEASE |
|
133 |
||
134 |
//---------------------------------------------------------------------------------------------- |
|
135 |
//! @SYMTestCaseID PBASE-t_fatcharsetconv-0406 |
|
136 |
//! @SYMTestType CIT |
|
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 |
|
140 |
//! dll loaded). |
|
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 |
|
148 |
//! Unicode string. |
|
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() |
|
159 |
{ |
|
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"); |
|
166 |
||
167 |
TInt r = TheFs.ControlIo(CurrentDrive(), KControlIoDisableFatUtilityFunctions); |
|
168 |
test_KErrNone(r); |
|
169 |
||
170 |
// Create file and check creation |
|
171 |
MakeFile(KTestNormalUnicodeFileName); |
|
172 |
TFileName shn; |
|
173 |
// Check short name to test if there is any codepage DLL loaded already. |
|
174 |
r = TheFs.GetShortName(KTestNormalUnicodeFileName, shn); |
|
175 |
test_KErrNone(r); |
|
176 |
||
177 |
r = shn.Compare(KTestNormalUnicodeFileNameShortDefualt); |
|
178 |
test_Equal(r, 0); |
|
179 |
||
180 |
TFileName lgn; |
|
181 |
r = TheFs.GetLongName(KTestNormalUnicodeFileNameShortDefualt, lgn); |
|
182 |
test_KErrNone(r); |
|
183 |
r = lgn.Compare(KTestNormalUnicodeFileName); |
|
184 |
test_Equal(r, 0); |
|
185 |
||
186 |
// Test illegal 8-bit ASCII chars in 16-bit Unicode chars. |
|
187 |
MakeFile(KTestFileNameWithIllegalChars); |
|
188 |
r = TheFs.GetShortName(KTestFileNameWithIllegalChars, shn); |
|
189 |
test_KErrNone(r); |
|
190 |
r = shn.Compare(KFileNameWithIllegalCharsShort); |
|
191 |
test_Equal(r, 0); |
|
192 |
||
193 |
test_KErrNone(TheFs.Delete(KTestFileNameWithIllegalChars)); |
|
194 |
test_KErrNone(TheFs.Delete(KTestNormalUnicodeFileName)); |
|
195 |
||
196 |
r = TheFs.ControlIo(CurrentDrive(), KControlIoEnableFatUtilityFunctions); |
|
197 |
test_KErrNone(r); |
|
198 |
#else |
|
199 |
test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details.")); |
|
200 |
#endif // _DEBUG) || _DEBUG_RELEASE |
|
201 |
||
202 |
} |
|
203 |
||
204 |
||
205 |
//---------------------------------------------------------------------------------------------- |
|
206 |
//! @SYMTestCaseID PBASE-t_fatcharsetconv-0407 |
|
207 |
//! @SYMTestType CIT |
|
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() |
|
225 |
{ |
|
226 |
test.Next(_L("Test unicode volume labels")); |
|
227 |
#if defined(_DEBUG) || defined(_DEBUG_RELEASE) |
|
228 |
TInt r = UserSvr::ChangeLocale(KTestLocale); |
|
229 |
test_KErrNone(r); |
|
230 |
||
231 |
r = TheFs.SessionPath(gSessionPath); |
|
232 |
test_KErrNone(r); |
|
233 |
TInt driveNum; |
|
234 |
r = TheFs.CharToDrive(gSessionPath[0], driveNum); |
|
235 |
test_KErrNone(r); |
|
236 |
||
237 |
// Retrieves the original volume label |
|
238 |
TVolumeInfo vInfo; |
|
239 |
r = TheFs.Volume(vInfo, driveNum); |
|
240 |
const TInt KVolumeLabelSize = 11; |
|
241 |
TBuf<KVolumeLabelSize> originalVolumeLabel(vInfo.iName); |
|
242 |
||
243 |
// Tests setting volume label with unicode characters |
|
244 |
_LIT(KUnicodeVolumeLabel, "\x65B0\x65B0\x65B0"); |
|
245 |
||
246 |
r = TheFs.SetVolumeLabel(KUnicodeVolumeLabel, driveNum); |
|
247 |
test_KErrNone(r); |
|
248 |
r = TheFs.Volume(vInfo, driveNum); |
|
249 |
test_KErrNone(r); |
|
250 |
r = vInfo.iName.Compare(KUnicodeVolumeLabel); |
|
251 |
test_Equal(r, 0); |
|
252 |
||
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)); |
|
258 |
||
259 |
r = TheFs.Volume(vInfo, driveNum); |
|
260 |
test_KErrNone(r); |
|
261 |
r = vInfo.iName.Compare(KUnicodeVolumeLabel); |
|
262 |
test_Equal(r, 0); |
|
263 |
||
264 |
// Sets back the original volume label |
|
265 |
r = TheFs.SetVolumeLabel(originalVolumeLabel, driveNum); |
|
266 |
test_KErrNone(r); |
|
267 |
#else |
|
268 |
test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details.")); |
|
269 |
#endif // _DEBUG) || _DEBUG_RELEASE |
|
270 |
} |
|
271 |
||
272 |
||
273 |
//---------------------------------------------------------------------------------------------- |
|
274 |
//! @SYMTestCaseID PBASE-t_fatcharsetconv-0408 |
|
275 |
//! @SYMTestType CIT |
|
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() |
|
302 |
{ |
|
303 |
test.Next(_L("8 bytes' name boundary tests")); |
|
304 |
#if defined(_DEBUG) || defined(_DEBUG_RELEASE) |
|
305 |
TInt r = UserSvr::ChangeLocale(KTestLocale); |
|
306 |
test_KErrNone(r); |
|
307 |
||
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 |
|
319 |
||
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); |
|
326 |
||
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); |
|
332 |
#else |
|
333 |
test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details.")); |
|
334 |
#endif // _DEBUG) || _DEBUG_RELEASE |
|
335 |
} |
|
336 |
||
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"; |
|
356 |
//! |
|
357 |
//! @SYMTestExpectedResults |
|
358 |
//! 1. File should be created with no error; |
|
359 |
//! 2. Comparisons should return 0; |
|
360 |
//! @SYMTestPriority High |
|
361 |
//! @SYMTestStatus Implemented |
|
362 |
//---------------------------------------------------------------------------------------------- |
|
363 |
||
364 |
void TestConsistentShortNameExtGeneration() |
|
365 |
{ |
|
366 |
test.Next(_L("Test consistent short name extensions are generated")); |
|
367 |
#if defined(_DEBUG) || defined(_DEBUG_RELEASE) |
|
368 |
TInt r = UserSvr::ChangeLocale(KTestLocale); |
|
369 |
test_KErrNone(r); |
|
370 |
||
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 |
|
380 |
||
381 |
||
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); |
|
387 |
||
388 |
doDirNameTest(KTestFileNameExt1C2B, KTestFileNameExt1C2B_short); |
|
389 |
doDirNameTest(KTestFileNameExt2C3B2U, KTestFileNameExt2C3B2U_short); |
|
390 |
doDirNameTest(KTestFileNameExt2C3B1U, KTestFileNameExt2C3B1U_short); |
|
391 |
doDirNameTest(KTestFileNameExt2C4B, KTestFileNameExt2C4B_short); |
|
392 |
#else |
|
393 |
test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details.")); |
|
394 |
#endif // _DEBUG) || _DEBUG_RELEASE |
|
395 |
} |
|
396 |
||
397 |
||
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() |
|
426 |
{ |
|
427 |
test.Next(_L("Test consistent short name generation")); |
|
428 |
#if defined(_DEBUG) || defined(_DEBUG_RELEASE) |
|
429 |
TInt r = UserSvr::ChangeLocale(KTestLocale); |
|
430 |
test_KErrNone(r); |
|
431 |
||
432 |
//unicode characters. |
|
433 |
||
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 |
|
444 |
||
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); |
|
451 |
||
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); |
|
457 |
#else |
|
458 |
test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details.")); |
|
459 |
#endif // _DEBUG) || _DEBUG_RELEASE |
|
460 |
} |
|
461 |
||
462 |
//---------------------------------------------------------------------------------------------- |
|
463 |
//! @SYMTestCaseID PBASE-t_fatcharsetconv-0409 |
|
464 |
//! @SYMTestType CIT |
|
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() |
|
492 |
{ |
|
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); |
|
496 |
test_KErrNone(r); |
|
497 |
||
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"); |
|
505 |
||
506 |
//////////////////////////////////////// |
|
507 |
// 1. Test duplicate long file names |
|
508 |
//////////////////////////////////////// |
|
509 |
TFileName sn; |
|
510 |
||
511 |
MakeFile(KTestFileName4C8B); |
|
512 |
MakeFile(KTestFileName7C11B); |
|
513 |
||
514 |
r = TheFs.GetShortName(KTestFileName7C11B, sn); |
|
515 |
test_KErrNone(r); |
|
516 |
r = sn.Compare(KTestFileName7C11B_short); |
|
517 |
test_Equal(r, 0); |
|
518 |
||
519 |
||
520 |
MakeFile(KTestFileName8C12B); |
|
521 |
||
522 |
r = TheFs.GetShortName(KTestFileName8C12B, sn); |
|
523 |
test_KErrNone(r); |
|
524 |
r = sn.Compare(KTestFileName8C12B_short); |
|
525 |
test_Equal(r, 0); |
|
526 |
||
527 |
test_KErrNone(TheFs.Delete(KTestFileName4C8B)); |
|
528 |
test_KErrNone(TheFs.Delete(KTestFileName7C11B)); |
|
529 |
test_KErrNone(TheFs.Delete(KTestFileName8C12B)); |
|
530 |
||
531 |
#else |
|
532 |
test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details.")); |
|
533 |
#endif // _DEBUG) || _DEBUG_RELEASE |
|
534 |
} |
|
535 |
||
536 |
||
537 |
//---------------------------------------------------------------------------------------------- |
|
538 |
//! @SYMTestCaseID PBASE-t_fatcharsetconv-0410 |
|
539 |
//! @SYMTestType CIT |
|
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() |
|
567 |
{ |
|
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); |
|
572 |
test_KErrNone(r); |
|
573 |
||
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"); |
|
581 |
||
582 |
// Create 1st file with 8 bytes long/short name |
|
583 |
MakeDir(KTestDirName4C8B); |
|
584 |
MakeDir(KTestDirName7C11B); |
|
585 |
TFileName sn; |
|
586 |
||
587 |
r = TheFs.GetShortName(KTestDirName7C11B, sn); |
|
588 |
test_KErrNone(r); |
|
589 |
r = sn.Compare(KTestDirName7C11B_short); |
|
590 |
test_Equal(r, 0); |
|
591 |
||
592 |
MakeDir(KTestDirName8C12B); |
|
593 |
||
594 |
r = TheFs.GetShortName(KTestDirName8C12B, sn); |
|
595 |
test_KErrNone(r); |
|
596 |
r = sn.Compare(KTestDirName8C12B_short); |
|
597 |
test_Equal(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 // _DEBUG) || _DEBUG_RELEASE |
|
602 |
} |
|
603 |
||
604 |
//---------------------------------------------------------------------------------------------- |
|
605 |
//! @SYMTestCaseID PBASE-t_fatcharsetconv-0791 |
|
606 |
//! @SYMTestType CIT |
|
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() |
|
620 |
{ |
|
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); |
|
625 |
test_KErrNone(r); |
|
626 |
||
627 |
_LIT(KTestFilePathAndName, "\\F32-TST\\T_LOCALEUTILS_CP932\\\x88F9.TXT"); |
|
628 |
_LIT(KTestFileShortName, "\x88F9.TXT"); |
|
629 |
||
630 |
MakeFile(KTestFilePathAndName); |
|
631 |
TFileName sn; |
|
632 |
r = TheFs.GetShortName(KTestFilePathAndName, sn); |
|
633 |
test_KErrNone(r); |
|
634 |
r = sn.Compare(KTestFileShortName); |
|
635 |
test_Equal(r, 0); |
|
636 |
||
637 |
#else |
|
638 |
test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details.")); |
|
639 |
#endif // _DEBUG) || _DEBUG_RELEASE |
|
640 |
} |
|
641 |
//---------------------------------------------------------------------------------------------- |
|
642 |
//! @SYMTestCaseID PBASE-t_fatcharsetconv-2320 |
|
643 |
//! @SYMTestType CIT |
|
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 |
//---------------------------------------------------------------------------------------------- |
|
654 |
void TestDEF130334() |
|
655 |
{ |
|
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); |
|
660 |
test_KErrNone(r); |
|
661 |
||
662 |
_LIT(KTestFilePathAndName, "\\F32-TST\\T_LOCALEUTILS_CP932\\\x3005.TXT"); |
|
663 |
_LIT(KTestFileName, "\x3005.TXT"); |
|
664 |
||
665 |
MakeFile(KTestFilePathAndName); |
|
666 |
TFileName sn; |
|
667 |
r = TheFs.GetShortName(KTestFilePathAndName, sn); |
|
668 |
test_KErrNone(r); |
|
669 |
r = sn.Compare(KTestFileName); |
|
670 |
test_Equal(r, 0); |
|
671 |
TFileName ln; |
|
672 |
r = TheFs.GetLongName(KTestFilePathAndName, ln); |
|
673 |
test_KErrNone(r); |
|
674 |
r = ln.Compare(KTestFileName); |
|
675 |
test_Equal(r, 0); |
|
676 |
||
677 |
#else |
|
678 |
test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details.")); |
|
679 |
#endif |
|
680 |
} |
|
681 |
//---------------------------------------------------------------------------------------------- |
|
682 |
//! @SYMTestCaseID PBASE-t_fatcharsetconv-1359 |
|
683 |
//! @SYMTestType CIT |
|
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() |
|
696 |
{ |
|
697 |
test.Next(_L("test file opening compatibility")); |
|
698 |
#if defined(_DEBUG) || defined(_DEBUG_RELEASE) |
|
699 |
GetBootInfo(); |
|
700 |
||
701 |
RFile file; |
|
702 |
TFileName fn = _L("\\ABCD"); |
|
703 |
||
704 |
TInt r=file.Create(TheFs,fn,EFileRead); |
|
705 |
test(r==KErrNone); |
|
706 |
file.Close(); |
|
707 |
||
708 |
// Assume this file is the first entry in the root directory |
|
709 |
r=TheDisk.Open(TheFs,CurrentDrive()); |
|
710 |
test(r==KErrNone); |
|
711 |
||
712 |
//-- read the 1st dir entry, it should be a DOS entry |
|
713 |
const TInt posEntry1=gBootSector.RootDirStartSector() << KDefaultSectorLog2; //-- dir entry1 position |
|
714 |
||
715 |
TFatDirEntry fatEntry1; |
|
716 |
TPtr8 ptrEntry1((TUint8*)&fatEntry1,sizeof(TFatDirEntry)); |
|
717 |
test(TheDisk.Read(posEntry1, ptrEntry1)==KErrNone); |
|
718 |
test(!fatEntry1.IsVFatEntry()); |
|
719 |
||
720 |
// Manually modify the short name into unicode characters |
|
721 |
// Unicode: 0x(798F 5C71 96C5 6CBB) |
|
722 |
// Shift-JIS: 0x(959F 8E52 89EB 8EA1) |
|
723 |
||
724 |
TBuf8<8> unicodeSN = _L8("ABCD1234"); |
|
725 |
unicodeSN[0] = 0x95; |
|
726 |
unicodeSN[1] = 0x9F; |
|
727 |
unicodeSN[2] = 0x8E; |
|
728 |
unicodeSN[3] = 0x52; |
|
729 |
unicodeSN[4] = 0x89; |
|
730 |
unicodeSN[5] = 0xEB; |
|
731 |
unicodeSN[6] = 0x8E; |
|
732 |
unicodeSN[7] = 0xA1; |
|
733 |
||
734 |
fatEntry1.SetName(unicodeSN); |
|
735 |
test(TheDisk.Write(posEntry1, ptrEntry1)==KErrNone); |
|
736 |
TheDisk.Close(); |
|
737 |
||
738 |
// Access the file using its unicode file name |
|
739 |
r = UserSvr::ChangeLocale(KTestLocale); |
|
740 |
test_KErrNone(r); |
|
741 |
||
742 |
fn = _L("\\ABCD"); |
|
743 |
fn[1] = 0x798F; |
|
744 |
fn[2] = 0x5C71; |
|
745 |
fn[3] = 0x96C5; |
|
746 |
fn[4] = 0x6CBB; |
|
747 |
||
748 |
TEntry entry; |
|
749 |
TInt err = TheFs.Entry(fn, entry); |
|
750 |
test(err==KErrNone); |
|
751 |
err = TheFs.Delete(fn); |
|
752 |
test(err==KErrNone); |
|
753 |
#else |
|
754 |
test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details.")); |
|
755 |
#endif // _DEBUG) || _DEBUG_RELEASE |
|
756 |
} |
|
757 |
||
758 |
//---------------------------------------------------------------------------------------------- |
|
759 |
//! @SYMTestCaseID PBASE-t_fatcharsetconv-1395 |
|
760 |
//! @SYMTestType CIT |
|
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 |
//---------------------------------------------------------------------------------------------- |
|
771 |
void TestINC126563() |
|
772 |
{ |
|
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) |
|
775 |
GetBootInfo(); |
|
776 |
||
777 |
RFile file; |
|
778 |
TFileName fn = _L("\\AB"); |
|
779 |
||
780 |
test.Next(_L("create file \"AB\" under root directory")); |
|
781 |
TInt r=file.Create(TheFs,fn,EFileRead); |
|
782 |
test(r==KErrNone); |
|
783 |
file.Close(); |
|
784 |
||
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()); |
|
788 |
test(r==KErrNone); |
|
789 |
||
790 |
//-- read the first dir entry, it should be a DOS entry |
|
791 |
const TInt posEntry1=gBootSector.RootDirStartSector() << KDefaultSectorLog2; //-- dir entry1 position |
|
792 |
||
793 |
TFatDirEntry fatEntry1; |
|
794 |
TPtr8 ptrEntry1((TUint8*)&fatEntry1,sizeof(TFatDirEntry)); |
|
795 |
test(TheDisk.Read(posEntry1, ptrEntry1)==KErrNone); |
|
796 |
test(!fatEntry1.IsVFatEntry()); |
|
797 |
||
798 |
TBuf8<8> unicodeSN = _L8("ABCD"); |
|
799 |
unicodeSN[0] = 0x7F; |
|
800 |
unicodeSN[1] = 0x45; |
|
801 |
unicodeSN[2] = 0x7F; |
|
802 |
unicodeSN[3] = 0x45; |
|
803 |
||
804 |
fatEntry1.SetName(unicodeSN); |
|
805 |
test(TheDisk.Write(posEntry1, ptrEntry1)==KErrNone); |
|
806 |
TheDisk.Close(); |
|
807 |
||
808 |
// Access the file using its unicode file name |
|
809 |
r = UserSvr::ChangeLocale(KTestLocale); |
|
810 |
test(KErrNone==r); |
|
811 |
||
812 |
test.Next(_L("access entries under root directory via RDir::Open()")); |
|
813 |
RDir dir; |
|
814 |
r = dir.Open(TheFs, _L("\\"), KEntryAttNormal); |
|
815 |
test(KErrNone == r); |
|
816 |
TEntryArray entryArray; |
|
817 |
r = dir.Read(entryArray); |
|
818 |
test(entryArray.Count()==1); |
|
819 |
TBuf<0x10> name; |
|
820 |
TEntry entry; |
|
821 |
entry = entryArray[0]; |
|
822 |
test.Printf(_L("entryArray[0] = \"%S\"\n"), &entry.iName); |
|
823 |
name = entry.iName; |
|
824 |
dir.Close(); |
|
825 |
||
826 |
TFileName fullname= _L("\\"); |
|
827 |
fullname.Append(name); |
|
828 |
||
829 |
test.Next(_L("try to open or delete file entries retrieved")); |
|
830 |
r = file.Open(TheFs, fullname, EFileRead); |
|
831 |
test(KErrNone == r); |
|
832 |
file.Close(); |
|
833 |
||
834 |
r = TheFs.Delete(fullname); |
|
835 |
test(KErrNone == r); |
|
836 |
#else |
|
837 |
test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details.")); |
|
838 |
#endif // _DEBUG) || _DEBUG_RELEASE |
|
839 |
} |
|
840 |
||
841 |
//---------------------------------------------------------------------------------------------- |
|
842 |
//! @SYMTestCaseID PBASE-t_fatcharsetconv-1402 |
|
843 |
//! @SYMTestType CIT |
|
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 |
//---------------------------------------------------------------------------------------------- |
|
854 |
void TestINC127905() |
|
855 |
{ |
|
856 |
test.Next(_L("Test INC127905: Unicode name file deleted after Scandrive")); |
|
857 |
#if defined(_DEBUG) || defined(_DEBUG_RELEASE) |
|
858 |
TFileName fn = _L("ABCDE"); |
|
859 |
fn[0] = 0x3055; |
|
860 |
fn[1] = 0x307E; |
|
861 |
fn[2] = 0x3056; |
|
862 |
fn[3] = 0x307E; |
|
863 |
fn[4] = 0x306A; |
|
864 |
||
865 |
TInt r = UserSvr::ChangeLocale(KTestLocale); |
|
866 |
test(KErrNone==r); |
|
867 |
||
868 |
MakeFile(fn); |
|
869 |
||
870 |
_LIT(KShortName, "\x3055\x307E\x3056~1"); |
|
871 |
TFileName sn; |
|
872 |
r = TheFs.GetShortName(fn, sn); |
|
873 |
test(r==KErrNone); |
|
874 |
r = sn.Compare(KShortName); |
|
875 |
test(r==0); |
|
876 |
||
877 |
r = TheFs.ScanDrive(_L("gSessionPath")); |
|
878 |
test(r==KErrNone); |
|
879 |
||
880 |
r = TheFs.Delete(fn); |
|
881 |
test(r == KErrNone); |
|
882 |
#else |
|
883 |
test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details.")); |
|
884 |
#endif // _DEBUG) || _DEBUG_RELEASE |
|
885 |
} |
|
886 |
||
887 |
void CallTestsL(void) |
|
888 |
{ |
|
889 |
||
890 |
test.Title(); |
|
891 |
test.Start(_L("Starting T_LOCALEUTILS_CP932 tests")); |
|
892 |
||
893 |
#if defined(_DEBUG) || defined(_DEBUG_RELEASE) |
|
894 |
||
895 |
// Test only runs on Fat file systems |
|
896 |
TheFs.SessionPath(gSessionPath); |
|
897 |
TInt driveNum = CurrentDrive(); |
|
898 |
TFSName name; |
|
899 |
TInt r = TheFs.FileSystemName(name, driveNum); |
|
900 |
if (KErrNone == r) |
|
901 |
{ |
|
902 |
if (name.Compare(_L("Fat")) != 0) |
|
903 |
{ |
|
904 |
test.Printf(_L("Test only runs on 'Fat' drives")); |
|
905 |
} |
|
906 |
else |
|
907 |
{ |
|
908 |
// Enables codepage dll implementation of LocaleUtils functions for this test only |
|
909 |
r = TheFs.ControlIo(driveNum, KControlIoEnableFatUtilityFunctions); |
|
910 |
test_KErrNone(r); |
|
911 |
||
912 |
CreateTestDirectory(_L("\\F32-TST\\T_LOCALEUTILS_CP932\\")); |
|
913 |
TestBeforeFATCharsetConvInteg(); |
|
914 |
TestUnicodeVolumeLabel(); |
|
915 |
TestShortNameBoundary(); |
|
916 |
TestConsistentShortNameGeneration(); |
|
917 |
TestConsistentShortNameExtGeneration(); |
|
918 |
TestDuplicateLongFileNames(); |
|
919 |
TestDuplicateLongDirNames(); |
|
920 |
TestLeadingE5Handling(); |
|
921 |
TestDEF130334(); |
|
922 |
TestINC127905(); |
|
923 |
DeleteTestDirectory(); |
|
924 |
||
925 |
TestCompatibility(); |
|
926 |
TestINC126563(); |
|
927 |
// Disables codepage dll implementation of LocaleUtils functions for other base tests |
|
928 |
r = TheFs.ControlIo(driveNum, KControlIoDisableFatUtilityFunctions); |
|
929 |
test_KErrNone(r); |
|
930 |
} |
|
931 |
} |
|
932 |
else |
|
933 |
{ |
|
934 |
test.Printf(_L("Drive %C: is not ready!"), 'A'+driveNum); |
|
935 |
test(EFalse); |
|
936 |
} |
|
937 |
#else |
|
938 |
test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details.")); |
|
939 |
#endif // _DEBUG) || _DEBUG_RELEASE |
|
940 |
test.End(); |
|
941 |
} |