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