16 // |
16 // |
17 |
17 |
18 #include <f32file.h> |
18 #include <f32file.h> |
19 #include <e32test.h> |
19 #include <e32test.h> |
20 #include "t_server.h" |
20 #include "t_server.h" |
21 |
21 #include "f32_test_utils.h" |
22 #if defined(__WINS__) |
22 |
23 #define WIN32_LEAN_AND_MEAN |
23 using namespace F32_Test_Utils; |
24 #pragma warning (disable:4201) // warning C4201: nonstandard extension used : nameless struct/union |
24 TInt gDriveNum = -1; |
25 #pragma warning (default:4201) // warning C4201: nonstandard extension used : nameless struct/union |
25 |
26 #endif |
26 RTest test(_L("T_RENAME")); |
27 |
|
28 #if defined(_UNICODE) |
|
29 #if !defined(UNICODE) |
|
30 #define UNICODE |
|
31 #endif |
|
32 #endif |
|
33 |
|
34 GLDEF_D RTest test(_L("T_RENAME")); |
|
35 |
27 |
36 TBuf8<26> alphaBuffer=_L8("ABCDEFGHIJKLMNOPQRSTUVWXYZ"); |
28 TBuf8<26> alphaBuffer=_L8("ABCDEFGHIJKLMNOPQRSTUVWXYZ"); |
37 TPtr8 alphaPtr((TText8*)alphaBuffer.Ptr(),alphaBuffer.Size(),alphaBuffer.Size()); |
29 TPtr8 alphaPtr((TText8*)alphaBuffer.Ptr(),alphaBuffer.Size(),alphaBuffer.Size()); |
38 |
30 |
39 TBuf8<17> BeckBuffer=_L8("A Devil's Haircut"); |
31 TBuf8<17> BeckBuffer=_L8("A Devil's Haircut"); |
40 TPtr8 BeckPtr((TText8*)BeckBuffer.Ptr(),BeckBuffer.Size(),BeckBuffer.Size()); |
32 TPtr8 BeckPtr((TText8*)BeckBuffer.Ptr(),BeckBuffer.Size(),BeckBuffer.Size()); |
41 |
33 |
42 /* |
34 |
43 |
35 static void CreateTestFiles() |
44 What this test is for: |
|
45 Tests bug fix for the bug which created two files of the same name |
|
46 |
|
47 */ |
|
48 |
|
49 LOCAL_C void CreateTestFiles() |
|
50 // |
|
51 // |
|
52 // |
|
53 { |
36 { |
54 test.Next(_L("Create test files")); |
37 test.Next(_L("Create test files")); |
55 TInt r=TheFs.MkDir(_L("\\F32-TST\\")); |
38 TInt r=TheFs.MkDir(_L("\\F32-TST\\")); |
56 test(r==KErrNone || r==KErrAlreadyExists); |
39 test(r==KErrNone || r==KErrAlreadyExists); |
57 |
40 |
77 r=file.Write(BeckPtr); |
60 r=file.Write(BeckPtr); |
78 test(r==KErrNone); |
61 test(r==KErrNone); |
79 file.Close(); |
62 file.Close(); |
80 |
63 |
81 } |
64 } |
82 /* |
65 |
83 LOCAL_C void CleanUp() |
66 static TInt CountFiles(TPtrC aDirectory, TPtrC aFileName) |
84 // |
|
85 // Delete any files created by the tests |
|
86 // |
|
87 { |
|
88 TInt r=TheFs.Delete(_L("\\F32-TST\\TESTFILE")); |
|
89 test(r==KErrNone); |
|
90 r=TheFs.Delete(_L("\\F32-TST\\RFSFILE")); |
|
91 test(r==KErrNone); |
|
92 r=TheFs.Delete(_L("\\F32-TST\\EIKFILE")); |
|
93 test(r==KErrNone); |
|
94 r=TheFs.Delete(_L("\\F32-TST\\TEST")); |
|
95 test(r==KErrNone); |
|
96 r=TheFs.RmDir(_L("\\F32-TST\\SYSTEM\\")); |
|
97 test(r==KErrNone); |
|
98 } |
|
99 */ |
|
100 |
|
101 LOCAL_C TInt CountFiles(TPtrC aDirectory, TPtrC aFileName) |
|
102 // |
67 // |
103 // Return the number of files of aFileName found in aDirectory |
68 // Return the number of files of aFileName found in aDirectory |
104 // |
69 // |
105 { |
70 { |
106 RDir dir; |
71 |
|
72 RDir dir; |
107 TFileName sessionPath; |
73 TFileName sessionPath; |
108 TInt r=TheFs.SessionPath(sessionPath); |
74 TInt r=TheFs.SessionPath(sessionPath); |
109 test(r==KErrNone); |
75 test(r==KErrNone); |
110 TFileName path=_L("?:"); |
76 TFileName path=_L("?:"); |
111 path[0]=sessionPath[0]; |
77 path[0]=sessionPath[0]; |
426 test(r==KErrNone); |
392 test(r==KErrNone); |
427 fileCount=CountFiles(_L("\\F32-TST\\"),_L("TEST1")); |
393 fileCount=CountFiles(_L("\\F32-TST\\"),_L("TEST1")); |
428 test(fileCount==0); |
394 test(fileCount==0); |
429 test(r==KErrNone); |
395 test(r==KErrNone); |
430 |
396 |
431 // Clean up |
397 } |
432 RFormat format; |
398 |
433 TInt count; |
399 |
434 TFileName sessionPath; |
400 void CallTestsL(void) |
435 r=TheFs.SessionPath(sessionPath); |
|
436 r=format.Open(TheFs,sessionPath,EQuickFormat,count); |
|
437 if (r == KErrAccessDenied) |
|
438 return; |
|
439 test(r==KErrNone); |
|
440 while(count && r==KErrNone) |
|
441 r=format.Next(count); |
|
442 format.Close(); |
|
443 } |
|
444 |
|
445 |
|
446 GLDEF_C void CallTestsL(void) |
|
447 // |
|
448 // Do all tests |
|
449 // |
|
450 { |
401 { |
451 |
402 |
452 test.Title(); |
403 test.Title(); |
453 test.Start(_L("Testing rename")); |
404 test.Start(_L("Testing rename")); |
454 |
405 |
455 TheFs.MkDir(_L("\\F32-TST\\SYSTEM\\")); |
406 //-- set up console output |
|
407 F32_Test_Utils::SetConsole(test.Console()); |
|
408 |
|
409 TInt nRes=TheFs.CharToDrive(gDriveToTest, gDriveNum); |
|
410 test(nRes==KErrNone); |
|
411 |
|
412 PrintDrvInfo(TheFs, gDriveNum); |
|
413 |
|
414 if(!Is_Win32(TheFs, gDriveNum)) |
|
415 { |
|
416 nRes = FormatDrive(TheFs, gDriveNum, ETrue); |
|
417 test(nRes==KErrNone); |
|
418 } |
|
419 |
|
420 |
|
421 MakeDir(_L("\\F32-TST\\SYSTEM\\")); |
456 CreateTestFiles(); |
422 CreateTestFiles(); |
457 TestRFsRename(); |
423 TestRFsRename(); |
458 TestRFileRename(); |
424 TestRFileRename(); |
459 TestEikonRename(); |
425 TestEikonRename(); |
460 TestReplaceAndRename(); |
426 TestReplaceAndRename(); |
461 |
427 |
|
428 if(!Is_Win32(TheFs, gDriveNum)) |
|
429 { |
|
430 nRes = FormatDrive(TheFs, gDriveNum, ETrue); |
|
431 test(nRes==KErrNone); |
|
432 } |
|
433 |
462 test.End(); |
434 test.End(); |
463 test.Close(); |
435 test.Close(); |
464 } |
436 } |
465 |
437 |