author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Fri, 11 Jun 2010 15:02:23 +0300 | |
changeset 152 | 657f875b013e |
parent 109 | b3a1d9898418 |
child 257 | 3e88ff8f41d5 |
permissions | -rw-r--r-- |
0 | 1 |
// Copyright (c) 1995-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\t_dirs.cpp |
|
15 |
// |
|
16 |
// |
|
17 |
||
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
18 |
#define __E32TEST_EXTENSION__ |
0 | 19 |
#include <f32file.h> |
20 |
#include <e32test.h> |
|
21 |
#include "t_server.h" |
|
22 |
||
23 |
#include "f32_test_utils.h" |
|
24 |
||
25 |
using namespace F32_Test_Utils; |
|
26 |
||
27 |
||
28 |
RTest test(_L("T_DIRS")); |
|
29 |
||
30 |
TTime gTimeNow; |
|
31 |
TBool gTestedZ = EFalse; |
|
32 |
TInt gDriveNum = -1; |
|
33 |
||
34 |
static void Test1() |
|
35 |
// |
|
36 |
// Make a directory with lots of entries |
|
37 |
// |
|
38 |
{ |
|
39 |
||
40 |
RFile f; |
|
41 |
TInt maxEntry=56; |
|
42 |
test.Next(_L("Create a directory with 55 entries")); |
|
43 |
TFileName sessionPath; |
|
44 |
TInt r=TheFs.SessionPath(sessionPath); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
45 |
test_KErrNone(r); |
0 | 46 |
r=TheFs.MkDir(_L("\\F32-TST\\")); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
47 |
test_Value(r, (r == KErrNone)||(r==KErrAlreadyExists)); |
0 | 48 |
r=TheFs.MkDir(_L("\\F32-TST\\TDIRS\\")); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
49 |
test_Value(r, (r == KErrNone)||(r==KErrAlreadyExists)); |
0 | 50 |
|
51 |
for (TInt i=0;i<maxEntry;i++) |
|
52 |
{ |
|
53 |
TFileName baseName=_L("\\F32-TST\\TDIRS\\FILE"); |
|
54 |
baseName.AppendNum(i); |
|
55 |
r=f.Replace(TheFs,baseName,EFileRead); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
56 |
test_KErrNone(r); |
0 | 57 |
r=f.Write(_L8("Hello World")); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
58 |
test_KErrNone(r); |
0 | 59 |
f.Close(); |
60 |
} |
|
61 |
test.Next(_L("Test all entries have been created successfully.")); |
|
62 |
for (TInt j=0;j<=maxEntry;j++) |
|
63 |
{ |
|
64 |
TFileName baseName=_L("\\F32-TST\\TDIRS\\FILE"); |
|
65 |
baseName.AppendNum(j); |
|
66 |
TInt r=f.Open(TheFs,baseName,EFileRead); |
|
67 |
if (r!=KErrNone) |
|
68 |
{ |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
69 |
test_Value(r, r == KErrNotFound && j==maxEntry); |
0 | 70 |
return; |
71 |
} |
|
72 |
TBuf8<16> data; |
|
73 |
r=f.Read(data); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
74 |
test_KErrNone(r); |
0 | 75 |
test(data==_L8("Hello World")); |
76 |
f.Close(); |
|
77 |
} |
|
78 |
} |
|
79 |
||
80 |
static void Test2() |
|
81 |
// |
|
82 |
// List all directory entries |
|
83 |
// |
|
84 |
{ |
|
85 |
||
86 |
test.Printf(_L("List all entries in directory %S\n"),&gSessionPath); |
|
87 |
RDir d; |
|
88 |
||
89 |
TInt r=d.Open(TheFs,gSessionPath,KEntryAttMaskSupported); |
|
90 |
if (r==KErrNone) |
|
91 |
{ |
|
92 |
TEntry e; |
|
93 |
while ((r=d.Read(e))==KErrNone) |
|
94 |
{ |
|
95 |
if (e.IsDir()) |
|
96 |
test.Printf(_L("%- 20S <DIR>\n"),&e.iName); |
|
97 |
else |
|
98 |
test.Printf(_L("%- 20S %+ 8d\n"),&e.iName,e.iSize); |
|
99 |
} |
|
100 |
d.Close(); |
|
101 |
if (r!=KErrEof) |
|
102 |
test.Printf(_L("Error %d\n"),r); |
|
103 |
} |
|
104 |
else |
|
105 |
test.Printf(_L("Error %d\n"),r); |
|
106 |
} |
|
107 |
||
108 |
static void TestZ() |
|
109 |
// |
|
110 |
// Check you cannot open a directory on a file |
|
111 |
// |
|
112 |
{ |
|
113 |
||
114 |
test.Next(_L("Open files and directories on Z:")); |
|
115 |
TEntry entry; |
|
116 |
RDir d; |
|
117 |
||
118 |
TInt r=d.Open(TheFs,PlatSec::ConfigSetting(PlatSec::EPlatSecEnforceSysBin)?_L("\\Sys\\Bin\\ESHELL.EXE\\*"):_L("\\System\\Bin\\ESHELL.EXE\\*"),KEntryAttMaskSupported); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
119 |
test_Value(r, r == KErrPathNotFound); |
0 | 120 |
|
121 |
r=d.Open(TheFs,PlatSec::ConfigSetting(PlatSec::EPlatSecEnforceSysBin)?_L("\\Sys\\Bin\\ESHELL.EXE"):_L("\\System\\Bin\\ESHELL.EXE"),KEntryAttMaskSupported); |
|
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 |
r=d.Read(entry); |
|
125 |
if (r==KErrEof) |
|
126 |
{ |
|
127 |
test.Printf(_L("Error: EShell.EXE not found\n")); |
|
128 |
//test.Getch(); |
|
129 |
} |
|
130 |
else |
|
131 |
{ |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
132 |
test_KErrNone(r); |
0 | 133 |
test(entry.iName.FindF(_L("ESHELL.EXE"))>=0); |
134 |
r=d.Read(entry); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
135 |
test_Value(r, r == KErrEof); |
0 | 136 |
} |
137 |
d.Close(); |
|
138 |
||
139 |
r=d.Open(TheFs,_L("\\*.XQP"),KEntryAttMaskSupported); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
140 |
test_KErrNone(r); |
0 | 141 |
r=d.Read(entry); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
142 |
test_Value(r, r == KErrEof); |
0 | 143 |
d.Close(); |
144 |
||
145 |
r=d.Open(TheFs,PlatSec::ConfigSetting(PlatSec::EPlatSecEnforceSysBin)?_L("\\Sys\\Bin\\"):_L("\\System\\Bin\\"),KEntryAttMaskSupported); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
146 |
test_KErrNone(r); |
0 | 147 |
r=d.Read(entry); |
148 |
||
149 |
if (r==KErrEof) |
|
150 |
{ |
|
151 |
test.Printf(_L("No files found\n")); |
|
152 |
d.Close(); |
|
153 |
} |
|
154 |
else |
|
155 |
{ |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
156 |
test_KErrNone(r); |
0 | 157 |
test.Printf(_L("First Entry = %S\n"),&entry.iName); |
158 |
r=d.Read(entry); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
159 |
test_KErrNone(r); |
0 | 160 |
test.Printf(_L("Second Entry = %S\n"),&entry.iName); |
161 |
d.Close(); |
|
162 |
} |
|
163 |
||
164 |
r=d.Open(TheFs,_L("\\*"),KEntryAttMaskSupported); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
165 |
test_KErrNone(r); |
0 | 166 |
d.Close(); |
167 |
r=d.Open(TheFs,PlatSec::ConfigSetting(PlatSec::EPlatSecEnforceSysBin)?_L("\\Sys\\Bin\\*"):_L("\\System\\Bin\\*"),KEntryAttMaskSupported); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
168 |
test_KErrNone(r); |
0 | 169 |
d.Close(); |
170 |
} |
|
171 |
||
172 |
static void Test3() |
|
173 |
// |
|
174 |
// Check you cannot open a directory on a file |
|
175 |
// |
|
176 |
{ |
|
177 |
||
178 |
test.Next(_L("Open files and directories")); |
|
179 |
TEntry entry; |
|
180 |
RFile f; |
|
181 |
TInt r=f.Replace(TheFs,_L("\\F32-TST\\TDIRS\\TESTFILEORISITA.DIR"),EFileWrite); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
182 |
test_KErrNone(r); |
0 | 183 |
r=f.Write(_L8("TESTDATATESTDATATESTDATATESTDATATESTDATATESTDATATESTDATATESTDATATESTDATATESTDATATESTDATATESTDATA")); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
184 |
test_KErrNone(r); |
0 | 185 |
r=TheFs.Delete(_L("\\F32-TST\\TDIRS\\TESTFILEORISITA.DIR")); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
186 |
test_Value(r, r == KErrInUse); |
0 | 187 |
f.Close(); |
188 |
RDir d; |
|
189 |
r=d.Open(TheFs,_L("\\F32-TST\\TDIRS\\TESTFILEORISITA.DIR\\*"),KEntryAttMaskSupported); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
190 |
test_Value(r, r == KErrPathNotFound); |
0 | 191 |
r=d.Open(TheFs,_L("\\F32-TST\\TDIRS\\*.XQP"),KEntryAttMaskSupported); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
192 |
test_KErrNone(r); |
0 | 193 |
r=d.Read(entry); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
194 |
test_Value(r, r == KErrEof); |
0 | 195 |
d.Close(); |
196 |
r=d.Open(TheFs,_L("\\F32-TST\\TDIRS\\TESTFILEORISITA.DIR"),KEntryAttMaskSupported); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
197 |
test_KErrNone(r); |
0 | 198 |
r=d.Read(entry); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
199 |
test_KErrNone(r); |
0 | 200 |
test(entry.iName.FindF(_L("TESTFILEORISITA.DIR"))>=0); |
201 |
r=d.Read(entry); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
202 |
test_Value(r, r == KErrEof); |
0 | 203 |
d.Close(); |
204 |
r=d.Open(TheFs,_L("\\"),KEntryAttMaskSupported); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
205 |
test_KErrNone(r); |
0 | 206 |
d.Close(); |
207 |
r=d.Open(TheFs,_L("\\F32-TST\\"),KEntryAttMaskSupported); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
208 |
test_KErrNone(r); |
0 | 209 |
d.Close(); |
210 |
r=d.Open(TheFs,_L("\\*"),KEntryAttMaskSupported); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
211 |
test_KErrNone(r); |
0 | 212 |
d.Close(); |
213 |
r=d.Open(TheFs,_L("\\F32-TST\\*"),KEntryAttMaskSupported); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
214 |
test_KErrNone(r); |
0 | 215 |
d.Close(); |
216 |
||
217 |
// create a small file on the root |
|
218 |
test(f.Replace(TheFs, _L("\\TEST.FILE"), EFileWrite) == KErrNone); |
|
219 |
test(f.Write(_L8("1234567890987654321234567890")) == KErrNone); |
|
220 |
f.Close(); |
|
221 |
// try some directory operations on the file |
|
222 |
test(TheFs.RmDir(_L("\\TEST.FILE\\")) == KErrPathNotFound); |
|
223 |
test(TheFs.RmDir(_L("\\TEST.FILE\\ZZZ\\")) == KErrPathNotFound); |
|
224 |
test(TheFs.MkDir(_L("\\TEST.FILE\\ZZZ\\")) == KErrPathNotFound); |
|
225 |
// cleanup |
|
226 |
TheFs.Delete(_L("\\TEST.FILE")); |
|
227 |
||
228 |
||
229 |
r=TheFs.MkDir(_L("\\F32-TST\\EMPTY\\")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
230 |
test_Value(r, r == KErrNone || r==KErrAlreadyExists); |
0 | 231 |
r=d.Open(TheFs,_L("\\F32-TST\\EMPTY\\*"),KEntryAttMaskSupported); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
232 |
test_KErrNone(r); |
0 | 233 |
// r=TheFs.RmDir(_L("\\F32-TST\\EMPTY\\")); |
234 |
r=d.Read(entry); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
235 |
test_Value(r, r == KErrEof); |
0 | 236 |
// r=TheFs.RmDir(_L("\\F32-TST\\EMPTY\\")); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
237 |
// test_Value(r, r == KErrInUse); |
0 | 238 |
r=d.Read(entry); |
239 |
r=d.Read(entry); |
|
240 |
r=d.Read(entry); |
|
241 |
d.Close(); |
|
242 |
r=TheFs.RmDir(_L("\\F32-TST\\EMPTY\\")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
243 |
test_KErrNone(r); |
0 | 244 |
} |
245 |
||
246 |
||
247 |
static void CreateSortNoneTestDirectoryStructure() |
|
248 |
// |
|
249 |
// Create files |
|
250 |
// |
|
251 |
{ |
|
252 |
// Delete the directory to be tested if it already exists as a result of this |
|
253 |
// test being run previously. It's necessary remove it and then recreate it |
|
254 |
// because a later test relies on the time of file/directory creation to be |
|
255 |
// the time this function was run... |
|
256 |
||
257 |
CFileMan* fMan=CFileMan::NewL(TheFs); |
|
258 |
test(fMan!=NULL); |
|
259 |
TInt r=fMan->RmDir(_L("\\F32-TST\\TDIRS\\SORT_NONE\\")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
260 |
test_Value(r, (r == KErrNone)||(r==KErrPathNotFound)); |
0 | 261 |
delete fMan; |
262 |
||
263 |
gTimeNow.HomeTime(); // Set global TTime gTimeNow to time now - for later tests |
|
264 |
r=TheFs.MkDirAll(_L("\\F32-TST\\TDIRS\\SORT_NONE\\")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
265 |
test_Value(r, r == KErrNone || r==KErrAlreadyExists); |
0 | 266 |
MakeFile(_L("\\f32-tst\\tdirs\\sort_none\\file1.txt")); |
267 |
r=TheFs.MkDir(_L("\\F32-TST\\TDIRS\\SORT_NONE\\FILE_DIR1.APP\\")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
268 |
test_Value(r, r == KErrNone || r==KErrAlreadyExists); |
0 | 269 |
MakeFile(_L("\\f32-tst\\tdirs\\sort_none\\file1.app")); |
270 |
r=TheFs.MkDir(_L("\\F32-TST\\TDIRS\\SORT_NONE\\FILE_DIR2.TXT\\")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
271 |
test_Value(r, r == KErrNone || r==KErrAlreadyExists); |
0 | 272 |
MakeFile(_L("\\f32-tst\\tdirs\\sort_none\\file2.txt")); |
273 |
r=TheFs.MkDir(_L("\\F32-TST\\TDIRS\\SORT_NONE\\FILE_DIR3.APP\\")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
274 |
test_Value(r, r == KErrNone || r==KErrAlreadyExists); |
0 | 275 |
MakeFile(_L("\\f32-tst\\tdirs\\sort_none\\ZZZZ")); |
276 |
MakeFile(_L("\\f32-tst\\tdirs\\sort_none\\AAAA")); |
|
277 |
MakeFile(_L("\\f32-tst\\tdirs\\sort_none\\WWWW")); |
|
278 |
MakeFile(_L("\\f32-tst\\tdirs\\sort_none\\file2.app")); |
|
279 |
MakeFile(_L("\\f32-tst\\tdirs\\sort_none\\file3.txt")); |
|
280 |
MakeFile(_L("\\f32-tst\\tdirs\\sort_none\\file3.app")); |
|
281 |
MakeFile(_L("\\f32-tst\\tdirs\\sort_none\\NOEXT1")); |
|
282 |
MakeFile(_L("\\f32-tst\\tdirs\\sort_none\\NOEXT2")); |
|
283 |
MakeFile(_L("\\f32-tst\\tdirs\\sort_none\\EXTMISSING")); |
|
284 |
} |
|
285 |
||
286 |
static void Test4() |
|
287 |
// |
|
288 |
// Test ESortNone |
|
289 |
// |
|
290 |
{ |
|
291 |
||
292 |
test.Next(_L("Test ESortNone")); |
|
293 |
CreateSortNoneTestDirectoryStructure(); |
|
294 |
CDir* dir; |
|
295 |
CDir* dirSorted; |
|
296 |
||
297 |
// |
|
298 |
// GetDir OOM failure passes 'callback' test from client side but not server side |
|
299 |
// |
|
300 |
TheFs.SetAllocFailure(gAllocFailOff); |
|
301 |
||
302 |
TInt r=TheFs.GetDir(_L("\\f32-tst\\tdirs\\sort_none\\*"),KEntryAttMaskSupported,ESortNone,dir); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
303 |
test_KErrNone(r); |
0 | 304 |
TInt count=dir->Count(); |
305 |
test(count==15); |
|
306 |
r=TheFs.GetDir(_L("\\f32-tst\\tdirs\\sort_none\\*"),KEntryAttMaskSupported,ESortByName,dirSorted); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
307 |
test_KErrNone(r); |
0 | 308 |
test(dirSorted->Count()==15); |
309 |
delete dirSorted; |
|
310 |
delete dir; |
|
311 |
||
312 |
r=TheFs.GetDir(_L("\\f32-tst\\tdirs\\sort_none\\*.txt"),KEntryAttNormal,ESortNone,dir); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
313 |
test_KErrNone(r); |
0 | 314 |
test(dir->Count()==3); |
315 |
delete dir; |
|
316 |
r=TheFs.GetDir(_L("\\f32-tst\\tdirs\\sort_none\\*.app"),KEntryAttNormal,ESortNone,dir); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
317 |
test_KErrNone(r); |
0 | 318 |
test(dir->Count()==3); |
319 |
delete dir; |
|
320 |
r=TheFs.GetDir(_L("\\f32-tst\\tdirs\\sort_none\\*.app"),KEntryAttNormal|KEntryAttDir,ESortNone,dir); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
321 |
test_KErrNone(r); |
0 | 322 |
test(dir->Count()==5); |
323 |
delete dir; |
|
324 |
r=TheFs.GetDir(_L("\\f32-tst\\tdirs\\sort_none\\*.app"),KEntryAttNormal|KEntryAttDir,ESortNone|EDirsFirst,dir); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
325 |
test_KErrNone(r); |
0 | 326 |
test(dir->Count()==5); |
327 |
delete dir; |
|
328 |
r=TheFs.GetDir(_L("\\f32-tst\\tdirs\\sort_none\\*.app"),KEntryAttNormal|KEntryAttDir,ESortNone|EDirsLast,dir); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
329 |
test_KErrNone(r); |
0 | 330 |
test(dir->Count()==5); |
331 |
delete dir; |
|
332 |
||
333 |
TheFs.SetAllocFailure(gAllocFailOn); |
|
334 |
} |
|
335 |
||
336 |
static void Test5() |
|
337 |
// |
|
338 |
// Test return values |
|
339 |
// |
|
340 |
{ |
|
341 |
||
342 |
test.Next(_L("Test return values")); |
|
343 |
RDir dir; |
|
344 |
TInt r=dir.Open(TheFs,_L("\\DoesNotExist\\*"),KEntryAttMaskSupported); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
345 |
test_Value(r, r == KErrPathNotFound); |
0 | 346 |
r=dir.Open(TheFs,_L("\\"),KEntryAttMaskSupported); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
347 |
test_KErrNone(r); |
0 | 348 |
dir.Close(); |
349 |
} |
|
350 |
||
351 |
||
352 |
static void Test6() |
|
353 |
// |
|
354 |
// Test that "*.*" matches all files/directories |
|
355 |
// |
|
356 |
{ |
|
357 |
||
358 |
test.Next(_L("Test *.* matches all files")); |
|
359 |
CDir* dirList; |
|
360 |
TInt r=TheFs.GetDir(_L("\\f32-tst\\tdirs\\sort_none\\*.*"),KEntryAttNormal|KEntryAttDir,ESortByName|EDirsLast,dirList); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
361 |
test_KErrNone(r); |
0 | 362 |
TInt count=dirList->Count(); |
363 |
test(count==15); |
|
364 |
TEntry entry=(*dirList)[0]; |
|
365 |
test(entry.iName.FindF(_L("AAAA"))>=0); |
|
366 |
entry=(*dirList)[1]; |
|
367 |
test(entry.iName.FindF(_L("EXTMISSING"))>=0); |
|
368 |
entry=(*dirList)[2]; |
|
369 |
test(entry.iName.FindF(_L("FILE1.APP"))>=0); |
|
370 |
entry=(*dirList)[3]; |
|
371 |
test(entry.iName.FindF(_L("FILE1.TXT"))>=0); |
|
372 |
entry=(*dirList)[4]; |
|
373 |
test(entry.iName.FindF(_L("FILE2.APP"))>=0); |
|
374 |
entry=(*dirList)[5]; |
|
375 |
test(entry.iName.FindF(_L("FILE2.TXT"))>=0); |
|
376 |
entry=(*dirList)[6]; |
|
377 |
test(entry.iName.FindF(_L("FILE3.APP"))>=0); |
|
378 |
entry=(*dirList)[7]; |
|
379 |
test(entry.iName.FindF(_L("FILE3.TXT"))>=0); |
|
380 |
entry=(*dirList)[8]; |
|
381 |
test(entry.iName.FindF(_L("NOEXT1"))>=0); |
|
382 |
entry=(*dirList)[9]; |
|
383 |
test(entry.iName.FindF(_L("NOEXT2"))>=0); |
|
384 |
entry=(*dirList)[10]; |
|
385 |
test(entry.iName.FindF(_L("WWWW"))>=0); |
|
386 |
entry=(*dirList)[11]; |
|
387 |
test(entry.iName.FindF(_L("ZZZZ"))>=0); |
|
388 |
entry=(*dirList)[12]; |
|
389 |
test(entry.iName.FindF(_L("FILE_DIR1.APP"))>=0); |
|
390 |
entry=(*dirList)[13]; |
|
391 |
test(entry.iName.FindF(_L("FILE_DIR2.TXT"))>=0); |
|
392 |
entry=(*dirList)[14]; |
|
393 |
test(entry.iName.FindF(_L("FILE_DIR3.APP"))>=0); |
|
394 |
delete dirList; |
|
395 |
||
396 |
RDir dir; |
|
397 |
r=dir.Open(TheFs,_L("\\f32-tst\\tdirs\\sort_none\\*.*"),KEntryAttNormal|KEntryAttDir); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
398 |
test_KErrNone(r); |
0 | 399 |
|
400 |
TTime time; |
|
401 |
TInt64 difference; |
|
402 |
TInt64 maxOK=1000000; |
|
403 |
maxOK*=60; |
|
404 |
maxOK*=3; |
|
405 |
||
406 |
for (TInt i=0; i<15; i++) |
|
407 |
{ |
|
408 |
r=dir.Read(entry); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
409 |
test_KErrNone(r); |
0 | 410 |
time=entry.iModified; |
411 |
difference=time.Int64()-gTimeNow.Int64(); |
|
412 |
test(difference<maxOK); |
|
413 |
} |
|
414 |
||
415 |
r=dir.Read(entry); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
416 |
test_Value(r, r == KErrEof); |
0 | 417 |
dir.Close(); |
418 |
||
419 |
TheFs.SetAllocFailure(gAllocFailOn); |
|
420 |
} |
|
421 |
||
422 |
||
423 |
static void Test7() |
|
424 |
// |
|
425 |
// Fill up the root directory |
|
426 |
// |
|
427 |
{ |
|
428 |
test.Next(_L("Fill up the root directory")); |
|
429 |
||
430 |
if(!Is_Fat12(TheFs, gDriveNum) && !Is_Fat16(TheFs, gDriveNum)) |
|
431 |
{ |
|
432 |
test.Printf(_L("Skipping. Applicable for FAT12/16 only!\n")); |
|
433 |
return; |
|
434 |
} |
|
435 |
||
436 |
TInt r = FormatDrive(TheFs, gDriveNum, ETrue); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
437 |
test_KErrNone(r); |
0 | 438 |
|
439 |
TBuf<32> baseName=_L("\\RD"); |
|
440 |
TBuf<32> id; |
|
441 |
TBuf<32> fileName; |
|
442 |
TInt count=0; |
|
443 |
||
444 |
RFile f; |
|
445 |
TParsePtrC parser(gSessionPath); |
|
446 |
FOREVER |
|
447 |
{ |
|
448 |
id.Num(count+1); |
|
449 |
fileName=parser.Drive(); |
|
450 |
fileName+=baseName; |
|
451 |
fileName+=id; |
|
452 |
TInt r=f.Replace(TheFs,fileName,EFileWrite); |
|
453 |
if(r==KErrDirFull) |
|
454 |
{ |
|
455 |
break; |
|
456 |
} |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
457 |
test_KErrNone(r); |
0 | 458 |
f.Close(); |
459 |
count++; |
|
460 |
if(count >= 1000) |
|
461 |
{ |
|
462 |
break; |
|
463 |
} |
|
464 |
test.Printf(_L("CreateFile : %d : %S\r"),count,&fileName); |
|
465 |
} |
|
466 |
test.Printf(_L("\n")); |
|
467 |
||
468 |
while (count) |
|
469 |
{ |
|
470 |
id.Num(count); |
|
471 |
fileName=parser.Drive(); |
|
472 |
fileName+=baseName; |
|
473 |
fileName+=id; |
|
474 |
TInt r=TheFs.Delete(fileName); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
475 |
test_KErrNone(r); |
0 | 476 |
test.Printf(_L("DeleteFile : %d : %S\r"),count,&fileName); |
477 |
--count; |
|
478 |
} |
|
479 |
test.Printf(_L("\n")); |
|
480 |
||
481 |
test.Next(_L("Long filenames in root")); |
|
482 |
TFileName longFileName; |
|
483 |
longFileName.SetLength(254); |
|
484 |
// Mem::Fill((TUint8*)longFileName.Ptr(),254,'A'); |
|
485 |
Mem::Fill((TUint8*)longFileName.Ptr(),254*sizeof(TText),'A'); |
|
486 |
longFileName[0]='\\'; |
|
487 |
longFileName[253]='\\'; |
|
488 |
r=TheFs.MkDir(longFileName); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
489 |
test_KErrNone(r); |
0 | 490 |
CDir* dirList=NULL; |
491 |
r=TheFs.GetDir(longFileName,KEntryAttMaskSupported,ESortByName,dirList); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
492 |
test_KErrNone(r); |
0 | 493 |
count=dirList->Count(); |
494 |
test(count==0); |
|
495 |
delete dirList; |
|
496 |
TParse parse; |
|
497 |
r=TheFs.Parse(longFileName,parse); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
498 |
test_KErrNone(r); |
0 | 499 |
TEntry entry; |
500 |
r=TheFs.Entry(longFileName,entry); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
501 |
test_KErrNone(r); |
0 | 502 |
r=TheFs.SetSessionPath(longFileName); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
503 |
test_KErrNone(r); |
0 | 504 |
r=TheFs.GetDir(longFileName,KEntryAttMaskSupported,ESortByName,dirList); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
505 |
test_KErrNone(r); |
0 | 506 |
count=dirList->Count(); |
507 |
test(count==0); |
|
508 |
delete dirList; |
|
509 |
r=TheFs.Parse(longFileName,_L("*"),parse); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
510 |
test_Value(r, r == KErrBadName); |
0 | 511 |
r=f.Open(TheFs,_L("asdf.asdf"),0); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
512 |
test_Value(r, r == KErrBadName); |
0 | 513 |
r=TheFs.Entry(longFileName,entry); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
514 |
test_KErrNone(r); |
0 | 515 |
r=TheFs.RmDir(longFileName); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
516 |
test_KErrNone(r); |
0 | 517 |
} |
518 |
||
519 |
static void Test8() |
|
520 |
// |
|
521 |
// Regression tests |
|
522 |
// |
|
523 |
{ |
|
524 |
||
525 |
test.Next(_L("Open dir and change drives")); |
|
526 |
MakeDir(_L("C:\\MOON\\")); |
|
527 |
RDir dir; |
|
528 |
TInt r=dir.Open(TheFs,_L("C:\\MOON\\"),0); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
529 |
test_KErrNone(r); |
0 | 530 |
TFileName driveName; |
531 |
r=TheFs.GetDriveName(11,driveName); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
532 |
test_KErrNone(r); |
0 | 533 |
TEntryArray entryArray; |
534 |
r=dir.Read(entryArray); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
535 |
test_Value(r, r == KErrEof); |
0 | 536 |
test(entryArray.Count()==0); |
537 |
dir.Close(); |
|
538 |
r=TheFs.RmDir(_L("C:\\MOON\\")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
539 |
test_KErrNone(r); |
0 | 540 |
|
541 |
test.Next(_L("MkDir all on nonexistent drive")); |
|
542 |
r=TheFs.MkDirAll(_L("L:\\MOON")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
543 |
test_Value(r, (r == KErrNotReady)||(r==KErrPathNotFound)); |
0 | 544 |
} |
545 |
||
546 |
static void CleanupL() |
|
547 |
// |
|
548 |
// Clean up tests |
|
549 |
// |
|
550 |
{ |
|
551 |
||
552 |
test.Next(_L("Delete test directory")); |
|
553 |
CFileMan* fMan=CFileMan::NewL(TheFs); |
|
554 |
TInt r=fMan->RmDir(gSessionPath); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
555 |
test_KErrNone(r); |
0 | 556 |
r=fMan->Delete(_L("\\Filluptherootdir*")); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
557 |
test_Value(r, r == KErrNone || r==KErrNotFound); |
0 | 558 |
delete fMan; |
559 |
} |
|
560 |
||
561 |
static void Test9() |
|
562 |
// |
|
563 |
// Test directories with trailing dots (ref. DEF047684) |
|
564 |
// |
|
565 |
{ |
|
566 |
||
567 |
test.Next(_L("Testing directory names with trailing dots")); |
|
568 |
TInt r; |
|
569 |
r=TheFs.MkDir(_L("\\test9..\\")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
570 |
test_Value(r, r == KErrBadName); |
0 | 571 |
r=TheFs.MkDir(_L("\\test9\\")); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
572 |
test_Value(r, (r == KErrNone)||(r==KErrAlreadyExists)); |
0 | 573 |
r=TheFs.Rename(_L("\\test9\\"),_L("\\test9..\\")); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
574 |
test_Value(r, r == KErrBadName); |
0 | 575 |
r= TheFs.RmDir(_L("\\test9\\")); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
576 |
test_KErrNone(r); |
0 | 577 |
r=TheFs.MkDir(_L("\\t.\\")); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
578 |
test_Value(r, r == KErrBadName); |
0 | 579 |
} |
580 |
||
581 |
||
582 |
// |
|
583 |
// Path and File names for sorting by name |
|
584 |
// |
|
585 |
// The correctly sorted directory listing should be: |
|
586 |
// |
|
587 |
// b.doc |
|
588 |
// bb.doc |
|
589 |
// bs.doc |
|
590 |
// |
|
591 |
_LIT(KSortByNamePath, "\\F32-TST\\TDIRS\\SORT_NAME\\"); |
|
592 |
_LIT(KFileBS, "bs.doc"); |
|
593 |
_LIT(KFileBB, "bb.doc"); |
|
594 |
_LIT(KFileB, "b.doc"); |
|
595 |
_LIT(KSortAll, "*.*"); |
|
596 |
_LIT(KPrintFileName, "%S\n"); |
|
597 |
||
598 |
||
599 |
static void DeleteTestDirectoryStructure(const TDesC& aPath) |
|
600 |
// |
|
601 |
// Delete the directory to be tested if it already exists as a result of this |
|
602 |
// test being run previously. |
|
603 |
// |
|
604 |
{ |
|
605 |
||
606 |
CFileMan* fMan=CFileMan::NewL(TheFs); |
|
607 |
test(fMan!=NULL); |
|
608 |
TInt r=fMan->RmDir(aPath); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
609 |
test_Value(r, (r == KErrNone)||(r==KErrPathNotFound)); |
0 | 610 |
delete fMan; |
611 |
} |
|
612 |
||
613 |
||
614 |
static void CreateTestDirectoryStructure(const TDesC& aPath, const TDesC** aFileArray, TInt aNumFiles) |
|
615 |
// |
|
616 |
// Create files |
|
617 |
// |
|
618 |
{ |
|
619 |
DeleteTestDirectoryStructure(aPath); |
|
620 |
||
621 |
gTimeNow.HomeTime(); // Set global TTime gTimeNow to time now - for later tests |
|
622 |
TInt r=TheFs.MkDirAll(aPath); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
623 |
test_Value(r, r == KErrNone || r==KErrAlreadyExists); |
0 | 624 |
|
625 |
TBuf<128> fileName; |
|
626 |
for (TInt i = 0; i < aNumFiles; i++) |
|
627 |
{ |
|
628 |
fileName = aPath; |
|
629 |
fileName.Append(*aFileArray[i]); |
|
630 |
MakeFile(fileName); |
|
631 |
} |
|
632 |
} |
|
633 |
||
634 |
||
635 |
static void TestSortByName() |
|
636 |
// |
|
637 |
// Test that sorting by name works for different length filenames. |
|
638 |
// |
|
639 |
{ |
|
640 |
const TDesC* theFiles[] = {&KFileBS, &KFileBB, &KFileB}; |
|
641 |
TInt numFiles = sizeof(theFiles)/sizeof(theFiles[0]); |
|
642 |
CreateTestDirectoryStructure(KSortByNamePath, theFiles, numFiles); |
|
643 |
||
644 |
test.Next(_L("Test ESortByName")); |
|
645 |
CDir* dirList; |
|
646 |
TBuf<128> sortSpec(KSortByNamePath); |
|
647 |
sortSpec.Append(KSortAll); |
|
648 |
TInt r=TheFs.GetDir(sortSpec, KEntryAttNormal | KEntryAttDir, ESortByName | EDirsLast, dirList); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
649 |
test_KErrNone(r); |
0 | 650 |
TInt count=dirList->Count(); |
651 |
test(count==numFiles); |
|
652 |
||
653 |
||
654 |
TInt i; |
|
655 |
for (i = 0; i < count; i++) |
|
656 |
{ |
|
657 |
test.Printf(KPrintFileName, &(*dirList)[i].iName); |
|
658 |
} |
|
659 |
||
660 |
TEntry entry=(*dirList)[0]; |
|
661 |
test(entry.iName.FindF(KFileB)>=0); |
|
662 |
entry=(*dirList)[1]; |
|
663 |
test(entry.iName.FindF(KFileBB)>=0); |
|
664 |
entry=(*dirList)[2]; |
|
665 |
test(entry.iName.FindF(KFileBS)>=0); |
|
666 |
delete dirList; |
|
667 |
dirList = 0; |
|
668 |
||
669 |
||
670 |
test.Next(_L("Test ESortByName (descending)")); |
|
671 |
||
672 |
||
673 |
r=TheFs.GetDir(sortSpec, KEntryAttNormal | KEntryAttDir, ESortByName | EDirsLast | EDescending, dirList); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
674 |
test_KErrNone(r); |
0 | 675 |
count=dirList->Count(); |
676 |
test(count==numFiles); |
|
677 |
||
678 |
||
679 |
for (i = 0; i < count; i++) |
|
680 |
{ |
|
681 |
test.Printf(KPrintFileName, &(*dirList)[i].iName); |
|
682 |
} |
|
683 |
||
684 |
||
685 |
entry=(*dirList)[0]; |
|
686 |
test(entry.iName.FindF(KFileBS)>=0); |
|
687 |
entry=(*dirList)[1]; |
|
688 |
test(entry.iName.FindF(KFileBB)>=0); |
|
689 |
entry=(*dirList)[2]; |
|
690 |
test(entry.iName.FindF(KFileB)>=0); |
|
691 |
delete dirList; |
|
692 |
dirList = 0; |
|
693 |
||
694 |
||
695 |
DeleteTestDirectoryStructure(KSortByNamePath); |
|
696 |
} |
|
697 |
||
698 |
||
699 |
||
700 |
// |
|
701 |
// Path and File names for sorting by extension |
|
702 |
// |
|
703 |
// The correctly sorted directory listing should be: |
|
704 |
// |
|
705 |
// sortext.a |
|
706 |
// sortext.bbb.a |
|
707 |
// sortext1.ddd.a |
|
708 |
// sortext.aaa.b |
|
709 |
// sortext.b |
|
710 |
// sortext.c |
|
711 |
// sortext.ccc.c |
|
712 |
// |
|
713 |
// as we should sort by the substring after the last '.' |
|
714 |
// |
|
715 |
_LIT(KSortByExtPath, "\\F32-TST\\TDIRS\\SORT_EXT\\"); |
|
716 |
_LIT(KFile1, "sortext.aaa.b"); |
|
717 |
_LIT(KFile2, "sortext.bbb.a"); |
|
718 |
_LIT(KFile3, "sortext.ccc.c"); |
|
719 |
_LIT(KFile4, "sortext1.ddd.a"); |
|
720 |
_LIT(KFile5, "sortext.a"); |
|
721 |
_LIT(KFile6, "sortext.b"); |
|
722 |
_LIT(KFile7, "sortext.c"); |
|
723 |
||
724 |
||
725 |
static void TestSortByExt() |
|
726 |
// |
|
727 |
// Test that sorting by extension works. This includes filenames |
|
728 |
// that contain multiple .'s |
|
729 |
// |
|
730 |
{ |
|
731 |
const TDesC* theFiles[] = {&KFile1, &KFile2, &KFile3, &KFile4, &KFile5, &KFile6, &KFile7}; |
|
732 |
TInt numFiles = sizeof(theFiles)/sizeof(theFiles[0]); |
|
733 |
CreateTestDirectoryStructure(KSortByExtPath, theFiles, numFiles); |
|
734 |
||
735 |
test.Next(_L("Test ESortByExt")); |
|
736 |
||
737 |
CDir* dirList; |
|
738 |
TBuf<128> sortSpec(KSortByExtPath); |
|
739 |
sortSpec.Append(KSortAll); |
|
740 |
TInt r=TheFs.GetDir(sortSpec, KEntryAttNormal | KEntryAttDir, ESortByExt | EDirsLast, dirList); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
741 |
test_KErrNone(r); |
0 | 742 |
TInt count=dirList->Count(); |
743 |
test(count==numFiles); |
|
744 |
||
745 |
||
746 |
TInt i; |
|
747 |
for (i = 0; i < count; i++) |
|
748 |
{ |
|
749 |
test.Printf(KPrintFileName, &(*dirList)[i].iName); |
|
750 |
} |
|
751 |
||
752 |
||
753 |
// |
|
754 |
// Verify that the files have been sorted correctly by extension |
|
755 |
// |
|
756 |
TEntry entry=(*dirList)[0]; |
|
757 |
test(entry.iName.FindF(KFile5)>=0); |
|
758 |
entry=(*dirList)[1]; |
|
759 |
test(entry.iName.FindF(KFile2)>=0); |
|
760 |
entry=(*dirList)[2]; |
|
761 |
test(entry.iName.FindF(KFile4)>=0); |
|
762 |
entry=(*dirList)[3]; |
|
763 |
test(entry.iName.FindF(KFile1)>=0); |
|
764 |
entry=(*dirList)[4]; |
|
765 |
test(entry.iName.FindF(KFile6)>=0); |
|
766 |
entry=(*dirList)[5]; |
|
767 |
test(entry.iName.FindF(KFile7)>=0); |
|
768 |
entry=(*dirList)[6]; |
|
769 |
test(entry.iName.FindF(KFile3)>=0); |
|
770 |
delete dirList; |
|
771 |
dirList = 0; |
|
772 |
||
773 |
||
774 |
test.Next(_L("Test ESortByExt (descending)")); |
|
775 |
||
776 |
r=TheFs.GetDir(sortSpec, KEntryAttNormal | KEntryAttDir, ESortByExt | EDirsLast | EDescending, dirList); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
777 |
test_KErrNone(r); |
0 | 778 |
count=dirList->Count(); |
779 |
test(count==numFiles); |
|
780 |
||
781 |
||
782 |
for (i = 0; i < count; i++) |
|
783 |
{ |
|
784 |
test.Printf(KPrintFileName, &(*dirList)[i].iName); |
|
785 |
} |
|
786 |
||
787 |
||
788 |
// |
|
789 |
// Verify that the files have been sorted correctly by extension |
|
790 |
// Note that this listing should be the reverse of that above. |
|
791 |
// |
|
792 |
entry=(*dirList)[0]; |
|
793 |
test(entry.iName.FindF(KFile3)>=0); |
|
794 |
entry=(*dirList)[1]; |
|
795 |
test(entry.iName.FindF(KFile7)>=0); |
|
796 |
entry=(*dirList)[2]; |
|
797 |
test(entry.iName.FindF(KFile6)>=0); |
|
798 |
entry=(*dirList)[3]; |
|
799 |
test(entry.iName.FindF(KFile1)>=0); |
|
800 |
entry=(*dirList)[4]; |
|
801 |
test(entry.iName.FindF(KFile4)>=0); |
|
802 |
entry=(*dirList)[5]; |
|
803 |
test(entry.iName.FindF(KFile2)>=0); |
|
804 |
entry=(*dirList)[6]; |
|
805 |
test(entry.iName.FindF(KFile5)>=0); |
|
806 |
delete dirList; |
|
807 |
dirList = 0; |
|
808 |
||
809 |
||
810 |
DeleteTestDirectoryStructure(KSortByExtPath); |
|
811 |
} |
|
812 |
||
813 |
//--------------------------------------------- |
|
814 |
//! @SYMTestCaseID PBASE-T_DIRS-1310 |
|
815 |
//! @SYMTestType CT |
|
816 |
//! @SYMREQ DEF125143 |
|
817 |
//! @SYMTestCaseDesc Test that directory name is handled by File Server interfaces properly. |
|
818 |
//! @SYMTestActions Uses RFs::IsValidName(), RFs::MkDir(), RDir::Open(), RFs::RmDir() to test |
|
819 |
//! various dir name handling. |
|
820 |
//! @SYMTestExpectedResults Proper error code is returned. |
|
821 |
//! @SYMTestPriority High |
|
822 |
//! @SYMTestStatus Implemented |
|
823 |
//--------------------------------------------- |
|
824 |
void TestDirNameHandling() |
|
825 |
{ |
|
826 |
test.Next(_L("Test Dir Name Handling Interfaces")); |
|
827 |
TFileName dirTest1; |
|
828 |
dirTest1 = _L("\\F32-TST\\TDIRS\\test1\\FILE.TXT"); |
|
829 |
TFileName dirTest2; |
|
830 |
dirTest2 = _L("\\F32-TST\\TDIRS\\test2.\\FILE.TXT"); |
|
831 |
TFileName dirTest3; |
|
832 |
dirTest3 = _L("\\F32-TST\\TDIRS\\test3. \\FILE.TXT"); |
|
833 |
TFileName dirTest4; |
|
834 |
dirTest4 = _L("\\F32-TST\\TDIRS\\test4. . \\FILE.TXT"); |
|
835 |
TFileName dirTest5; |
|
836 |
dirTest5 = _L("\\F32-TST\\TDIRS\\test5.\\FILE.TXT"); |
|
837 |
TFileName dirTest6; |
|
838 |
dirTest6 = _L("\\F32-TST\\TDIRS\\test6. .\\FILE.TXT"); |
|
839 |
||
840 |
TBool valid = TheFs.IsValidName( dirTest1 ); |
|
841 |
test(valid); |
|
842 |
valid = TheFs.IsValidName( dirTest2 ); |
|
843 |
test(!valid); |
|
844 |
valid = TheFs.IsValidName( dirTest3 ); |
|
845 |
test(!valid); |
|
846 |
valid = TheFs.IsValidName( dirTest4 ); |
|
847 |
test(!valid); |
|
848 |
valid = TheFs.IsValidName( dirTest5 ); |
|
849 |
test(!valid); |
|
850 |
valid = TheFs.IsValidName( dirTest6 ); |
|
851 |
test(!valid); |
|
852 |
||
853 |
dirTest1 = _L("\\F32-TST\\TDIRS\\test1\\"); |
|
854 |
dirTest2 = _L("\\F32-TST\\TDIRS\\test2.\\"); |
|
855 |
dirTest3 = _L("\\F32-TST\\TDIRS\\test3. \\"); |
|
856 |
dirTest4 = _L("\\F32-TST\\TDIRS\\test4. . \\"); |
|
857 |
dirTest5 = _L("\\F32-TST\\TDIRS\\test5.\\"); |
|
858 |
dirTest6 = _L("\\F32-TST\\TDIRS\\test6. .\\"); |
|
859 |
||
860 |
TInt err = TheFs.MkDir(dirTest1); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
861 |
test_KErrNone(err); |
0 | 862 |
err = TheFs.MkDir(dirTest2); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
863 |
test_Value(err, err == KErrBadName); |
0 | 864 |
err = TheFs.MkDir(dirTest3); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
865 |
test_Value(err, err == KErrBadName); |
0 | 866 |
err = TheFs.MkDir(dirTest4); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
867 |
test_Value(err, err == KErrBadName); |
0 | 868 |
err = TheFs.MkDir(dirTest5); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
869 |
test_Value(err, err == KErrBadName); |
0 | 870 |
err = TheFs.MkDir(dirTest6); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
871 |
test_Value(err, err == KErrBadName); |
0 | 872 |
|
873 |
RDir rdir; |
|
874 |
err = rdir.Open(TheFs, dirTest1, 0); |
|
875 |
rdir.Close(); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
876 |
test_KErrNone(err); |
0 | 877 |
|
878 |
err = rdir.Open(TheFs, dirTest2, 0); |
|
879 |
rdir.Close(); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
880 |
test_Value(err, err == KErrBadName); |
0 | 881 |
|
882 |
err = rdir.Open(TheFs, dirTest3, 0); |
|
883 |
rdir.Close(); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
884 |
test_Value(err, err == KErrBadName); |
0 | 885 |
|
886 |
err = rdir.Open(TheFs, dirTest4, 0); |
|
887 |
rdir.Close(); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
888 |
test_Value(err, err == KErrBadName); |
0 | 889 |
|
890 |
err = rdir.Open(TheFs, dirTest5, 0); |
|
891 |
rdir.Close(); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
892 |
test_Value(err, err == KErrBadName); |
0 | 893 |
|
894 |
err = rdir.Open(TheFs, dirTest6, 0); |
|
895 |
rdir.Close(); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
896 |
test_Value(err, err == KErrBadName); |
0 | 897 |
|
898 |
err = TheFs.RmDir(dirTest1); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
899 |
test_KErrNone(err); |
0 | 900 |
err = TheFs.RmDir(dirTest2); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
901 |
test_Value(err, err == KErrBadName); |
0 | 902 |
err = TheFs.RmDir(dirTest3); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
903 |
test_Value(err, err == KErrBadName); |
0 | 904 |
err = TheFs.RmDir(dirTest4); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
905 |
test_Value(err, err == KErrBadName); |
0 | 906 |
err = TheFs.RmDir(dirTest5); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
907 |
test_Value(err, err == KErrBadName); |
0 | 908 |
err = TheFs.RmDir(dirTest6); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
909 |
test_Value(err, err == KErrBadName); |
0 | 910 |
} |
911 |
||
912 |
void CallTestsL() |
|
913 |
// |
|
914 |
// Do all tests |
|
915 |
// |
|
916 |
{ |
|
917 |
||
918 |
//-- set up console output |
|
919 |
F32_Test_Utils::SetConsole(test.Console()); |
|
920 |
||
921 |
TInt nRes=TheFs.CharToDrive(gDriveToTest, gDriveNum); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
922 |
test_KErrNone(nRes); |
0 | 923 |
|
924 |
PrintDrvInfo(TheFs, gDriveNum); |
|
925 |
||
926 |
TurnAllocFailureOff(); |
|
927 |
CreateTestDirectory(_L("\\F32-TST\\TDIRS\\")); |
|
928 |
||
929 |
if (!gTestedZ) |
|
930 |
{ |
|
931 |
TInt r=TheFs.SetSessionPath(_L("Z:\\")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
932 |
test_KErrNone(r); |
0 | 933 |
Test2(); |
934 |
TestZ(); |
|
935 |
r=TheFs.SetSessionPath(gSessionPath); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
936 |
test_KErrNone(r); |
0 | 937 |
test.Next(_L("Run all other tests from \\F32-TST\\TDIRS\\")); |
938 |
gTestedZ=ETrue; |
|
939 |
} |
|
940 |
||
941 |
Test8(); |
|
942 |
||
943 |
Test7(); |
|
944 |
||
945 |
Test1(); |
|
946 |
Test2(); |
|
947 |
Test3(); |
|
948 |
Test4(); |
|
949 |
Test5(); |
|
950 |
Test6(); |
|
951 |
Test9(); |
|
952 |
||
953 |
TestSortByName(); |
|
954 |
TestSortByExt(); |
|
955 |
TestDirNameHandling(); |
|
956 |
||
957 |
CleanupL(); |
|
958 |
} |