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