0
|
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_mtst.cpp
|
|
15 |
// Tests file deleteing
|
|
16 |
//
|
|
17 |
//
|
|
18 |
|
|
19 |
#include <f32file.h>
|
|
20 |
#include <e32test.h>
|
|
21 |
#include "t_server.h"
|
|
22 |
|
|
23 |
RTest test(_L("B_MTST"));
|
|
24 |
//LOCAL_D RFs TheFs;
|
|
25 |
|
|
26 |
const TInt nTimes=20;
|
|
27 |
|
|
28 |
GLDEF_D RFile file1;
|
|
29 |
GLDEF_D RFile file2;
|
|
30 |
GLDEF_D RFile file3;
|
|
31 |
GLDEF_D RFile file4;
|
|
32 |
GLDEF_D RFile file5;
|
|
33 |
GLDEF_D TBuf8<0x200> buf;
|
|
34 |
GLDEF_D TBuf8<0x200> buf1;
|
|
35 |
GLDEF_D TBuf8<0x200> buf2;
|
|
36 |
GLDEF_D TBuf8<0x200> buf3;
|
|
37 |
GLDEF_D TBuf8<0x200> buf4;
|
|
38 |
GLDEF_D TBuf8<0x200> buf5;
|
|
39 |
GLDEF_D TFileName nameBuf1=_L("B_MTST File 1");
|
|
40 |
GLDEF_D TFileName nameBuf2=_L("B_MTST File 2");
|
|
41 |
GLDEF_D TFileName nameBuf3=_L("B_MTST File 3");
|
|
42 |
GLDEF_D TFileName nameBuf4=_L("B_MTST File 4");
|
|
43 |
GLDEF_D TFileName nameBuf5=_L("B_MTST File 5");
|
|
44 |
|
|
45 |
const TInt len1=163;
|
|
46 |
const TInt len2=31;
|
|
47 |
const TInt len3=271;
|
|
48 |
const TInt len4=128;
|
|
49 |
const TInt len5=14;
|
|
50 |
|
|
51 |
LOCAL_C void checkPattern()
|
|
52 |
{
|
|
53 |
test.Printf(_L("Opening: %S\n"),&nameBuf1);
|
|
54 |
TInt r=file1.Open(TheFs,nameBuf1,EFileStream);
|
|
55 |
test(r==KErrNone);
|
|
56 |
test.Printf(_L("Opening: %S\n"),&nameBuf2);
|
|
57 |
r=file2.Open(TheFs,nameBuf2,EFileStream);
|
|
58 |
test(r==KErrNone);
|
|
59 |
test.Printf(_L("Checking test pattern...\n"));
|
|
60 |
for (TInt i=0 ; i<nTimes ; i++)
|
|
61 |
{
|
|
62 |
r=file1.Read(buf,len1);
|
|
63 |
test(r==KErrNone);
|
|
64 |
TInt j;
|
|
65 |
for (j=0 ; j< len1 ; j++)
|
|
66 |
test(buf[j]==j);
|
|
67 |
r=file2.Read(buf,len2);
|
|
68 |
test(r==KErrNone);
|
|
69 |
for (j=0 ; j< len2 ; j++)
|
|
70 |
test(buf[j]=='A');
|
|
71 |
}
|
|
72 |
file1.Close();
|
|
73 |
file2.Close();
|
|
74 |
}
|
|
75 |
|
|
76 |
|
|
77 |
GLDEF_C void CallTestsL(void)
|
|
78 |
{
|
|
79 |
test.Title();
|
|
80 |
test.Next(_L("Generate test patterns"));
|
|
81 |
TInt i;
|
|
82 |
for (i=0 ; i<len1 ; i++)
|
|
83 |
buf1.Append((TUint8)i);
|
|
84 |
for (i=0 ; i<len2 ; i++)
|
|
85 |
buf2.Append('A');
|
|
86 |
for (i=0 ; i<len3 ; i++)
|
|
87 |
buf3.Append('B');
|
|
88 |
for (i=0 ; i<len4 ; i++)
|
|
89 |
buf4.Append('C');
|
|
90 |
for (i=0 ; i<len5 ; i++)
|
|
91 |
buf5.Append('D');
|
|
92 |
|
|
93 |
TInt r=file1.Create(TheFs,nameBuf1,EFileStream|EFileWrite);
|
|
94 |
test(r==KErrNone);
|
|
95 |
test.Printf(_L("Created: %S\n"),&nameBuf1);
|
|
96 |
r=file2.Create(TheFs,nameBuf2,EFileStream|EFileWrite);
|
|
97 |
test(r==KErrNone);
|
|
98 |
test.Printf(_L("Created: %S\n"),&nameBuf2);
|
|
99 |
r=file3.Create(TheFs,nameBuf3,EFileStream|EFileWrite);
|
|
100 |
test(r==KErrNone);
|
|
101 |
test.Printf(_L("Created: %S\n"),&nameBuf3);
|
|
102 |
r=file4.Create(TheFs,nameBuf4,EFileStream|EFileWrite);
|
|
103 |
test(r==KErrNone);
|
|
104 |
test.Printf(_L("Created: %S\n"),&nameBuf4);
|
|
105 |
r=file5.Create(TheFs,nameBuf5,EFileStream|EFileWrite);
|
|
106 |
test(r==KErrNone);
|
|
107 |
test.Printf(_L("Created: %S\n"),&nameBuf5);
|
|
108 |
|
|
109 |
test.Next(_L("Writing test pattern..."));
|
|
110 |
for (i=0 ; i<nTimes ; i++)
|
|
111 |
{
|
|
112 |
r=file1.Write(buf1,len1);
|
|
113 |
test(r==KErrNone);
|
|
114 |
r=file2.Write(buf2,len2);
|
|
115 |
test(r==KErrNone);
|
|
116 |
r=file3.Write(buf3,len3);
|
|
117 |
test(r==KErrNone);
|
|
118 |
r=file4.Write(buf4,len4);
|
|
119 |
test(r==KErrNone);
|
|
120 |
r=file5.Write(buf5,len5);
|
|
121 |
test(r==KErrNone);
|
|
122 |
}
|
|
123 |
file1.Close();
|
|
124 |
file2.Close();
|
|
125 |
|
|
126 |
test.Next(_L("Check pattern"));
|
|
127 |
checkPattern();
|
|
128 |
|
|
129 |
test.Next(_L("Delete"));
|
|
130 |
test.Printf(_L("Deleting: %S\n"),&nameBuf1);
|
|
131 |
r=TheFs.Delete(nameBuf1);
|
|
132 |
test(r==KErrNone);
|
|
133 |
test.Printf(_L("Deleting: %S\n"),&nameBuf2);
|
|
134 |
r=TheFs.Delete(nameBuf2);
|
|
135 |
test(r==KErrNone);
|
|
136 |
|
|
137 |
file3.Close();
|
|
138 |
file4.Close();
|
|
139 |
file5.Close();
|
|
140 |
|
|
141 |
test.Printf(_L("Deleting: %S\n"),&nameBuf3);
|
|
142 |
r=TheFs.Delete(nameBuf3);
|
|
143 |
test(r==KErrNone);
|
|
144 |
test.Printf(_L("Deleting: %S\n"),&nameBuf4);
|
|
145 |
r=TheFs.Delete(nameBuf4);
|
|
146 |
test(r==KErrNone);
|
|
147 |
test.Printf(_L("Deleting: %S\n"),&nameBuf5);
|
|
148 |
r=TheFs.Delete(nameBuf5);
|
|
149 |
test(r==KErrNone);
|
|
150 |
|
|
151 |
// test.Close();
|
|
152 |
}
|
|
153 |
|