|
1 // Copyright (c) 1996-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\server\b_rep.cpp |
|
15 // |
|
16 // |
|
17 |
|
18 #include <f32file.h> |
|
19 #include <e32test.h> |
|
20 #include "t_server.h" |
|
21 |
|
22 GLDEF_D RTest test(_L("B_REP")); |
|
23 LOCAL_D RFile TheFile; |
|
24 GLDEF_D TFileName nameBuf1=_L("B_REP Test File.PAR"); |
|
25 GLDEF_D TBuf8<0x200> testPat1; |
|
26 GLDEF_D TBuf8<0x200> chkPat1; |
|
27 |
|
28 const TInt noTimes=500; |
|
29 const TInt len=24; |
|
30 |
|
31 void DoTest() |
|
32 { |
|
33 |
|
34 TBuf8<0x10> buf; |
|
35 TBuf8<0x10> testBuf; |
|
36 buf.SetLength(sizeof(TInt)); |
|
37 TInt r; |
|
38 for (TInt numb=0;numb<noTimes;numb++) |
|
39 { |
|
40 if ((numb&0x1f)==0) |
|
41 test.Printf(_L("%d\r"),numb); |
|
42 |
|
43 // Replace file and write data |
|
44 r=TheFile.Replace(TheFs,nameBuf1,EFileStream); |
|
45 test(r==KErrNone); |
|
46 r=TheFile.Write(testPat1); |
|
47 test(r==KErrNone); |
|
48 |
|
49 Mem::Copy(&buf[0],&numb,sizeof(TInt)); |
|
50 r=TheFile.Write(buf); |
|
51 test(r==KErrNone); |
|
52 |
|
53 // Seek to 0 and check data |
|
54 TInt pos=0; |
|
55 r=TheFile.Seek(ESeekStart,pos); |
|
56 test(r==KErrNone); |
|
57 test(pos==0); |
|
58 r=TheFile.Read(chkPat1,len); |
|
59 test(r==KErrNone); |
|
60 test(chkPat1==testPat1); |
|
61 r=TheFile.Read(testBuf,sizeof(TInt)); |
|
62 test(r==KErrNone); |
|
63 TInt chkNumb=*((TInt*)testBuf.Ptr()); |
|
64 test(chkNumb==numb); |
|
65 |
|
66 // Close, then re-open file and check data |
|
67 TheFile.Close(); |
|
68 r=TheFile.Open(TheFs,nameBuf1,EFileStream); |
|
69 test(r==KErrNone); |
|
70 r=TheFile.Read(chkPat1,len); |
|
71 test(r==KErrNone); |
|
72 test(chkPat1==testPat1); |
|
73 r=TheFile.Read(testBuf,sizeof(TInt)); |
|
74 test(r==KErrNone); |
|
75 chkNumb=*((TInt*)testBuf.Ptr()); |
|
76 test(chkNumb==numb); |
|
77 TheFile.Close(); |
|
78 } |
|
79 test.Printf(_L("\n")); |
|
80 r=TheFs.Delete(nameBuf1); |
|
81 test(r==KErrNone); |
|
82 } |
|
83 |
|
84 GLDEF_C void CallTestsL(void) |
|
85 { |
|
86 testPat1=_L8("TextProcessorPa"); |
|
87 testPat1.Append(0); |
|
88 testPat1.Append(0); |
|
89 testPat1.Append(0); |
|
90 testPat1.Append(0x16); |
|
91 testPat1.Append(0); |
|
92 testPat1.Append(0); |
|
93 testPat1.Append(0); |
|
94 testPat1.Append(4); |
|
95 testPat1.Append(0x10); |
|
96 |
|
97 test.Start(_L("Root")); |
|
98 |
|
99 DoTest(); |
|
100 |
|
101 test.Next(_L("Subdirectory")); |
|
102 gSessionPath=_L("\\F32-TST\\TEST1\\"); |
|
103 TInt r=TheFs.SetSessionPath(gSessionPath); |
|
104 test(r==KErrNone); |
|
105 r=TheFs.MkDirAll(gSessionPath); |
|
106 test(r==KErrNone || r==KErrAlreadyExists); |
|
107 |
|
108 DoTest(); |
|
109 |
|
110 test.End(); |
|
111 } |