author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Fri, 14 May 2010 17:13:29 +0300 | |
changeset 109 | b3a1d9898418 |
parent 0 | a41df078684a |
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 |
// |
|
15 |
||
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
16 |
#define __E32TEST_EXTENSION__ |
0 | 17 |
#include <f32file.h> |
18 |
#include <e32test.h> |
|
19 |
#include "t_server.h" |
|
20 |
||
21 |
GLDEF_D RTest test(_L("T_GDIR")); |
|
22 |
||
23 |
LOCAL_D const TInt KFilesMax=9; |
|
24 |
LOCAL_D const TInt KUidFilesMax=7; |
|
25 |
LOCAL_D const TInt KDirsMax=4; |
|
26 |
LOCAL_D TBool gFirstRun=ETrue; |
|
27 |
LOCAL_D TPtrC test_dir(_L("\\F32-TST\\GDIR\\")); |
|
28 |
LOCAL_D TPtrC test_dir_1(_L("\\F32-TST\\GDIR\\*")); |
|
29 |
||
30 |
class TUidFile |
|
31 |
{ |
|
32 |
public: |
|
33 |
TUidFile(const TText* aFileName,TUidType aUidType,const TText8* aContents); |
|
34 |
public: |
|
35 |
const TText* iFileName; |
|
36 |
TUidType iUidType; |
|
37 |
const TText8* iContents; |
|
38 |
}; |
|
39 |
||
40 |
TUidFile::TUidFile(const TText* aFileName,TUidType aUidType,const TText8* aContents) |
|
41 |
: iFileName(aFileName), iUidType(aUidType), iContents(aContents) |
|
42 |
{} |
|
43 |
||
44 |
LOCAL_D TUidFile uidFiles[] = |
|
45 |
{ |
|
46 |
TUidFile(_S("File1.TXT"), TUidType(TUid::Uid(1),TUid::Uid(2),TUid::Uid(731)),_S8("blarg blarg blarg")), |
|
47 |
TUidFile(_S("asdf.asdf"), TUidType(TUid::Uid(55),TUid::Uid(2),TUid::Uid(731)),_S8("blarg")), |
|
48 |
TUidFile(_S("another fiel"), TUidType(TUid::Uid(104),TUid::Uid(22),TUid::Uid(731)),_S8("blarg2")), |
|
49 |
TUidFile(_S("another fiel1"), TUidType(TUid::Uid(7),TUid::Uid(23),TUid::Uid(131)),_S8("")), |
|
50 |
TUidFile(_S("another fiel2"), TUidType(TUid::Uid(8),TUid::Uid(2),TUid::Uid(531)),_S8("asdf")), |
|
51 |
TUidFile(_S("another fiel3"), TUidType(TUid::Uid(9),TUid::Uid(22),TUid::Uid(531)),_S8("blar")), |
|
52 |
TUidFile(_S("another fiel4"), TUidType(TUid::Uid(10),TUid::Uid(23),TUid::Uid(231)),_S8("blarg blarg blarg asdlfjasdfasdfasdfasdfasdfadfafa")) |
|
53 |
}; |
|
54 |
||
55 |
LOCAL_D const TText* fileNames[] = |
|
56 |
{ |
|
57 |
_S("B1.B3"),_S("B2.B2"),_S("B3.B1"), |
|
58 |
_S("A1.A3"),_S("A2.A2"),_S("A3.A1"), |
|
59 |
_S("Z1.Z3"),_S("Z2.Z2"),_S("Z3.Z1") |
|
60 |
}; |
|
61 |
||
62 |
LOCAL_D const TText* dirNames[] = |
|
63 |
{ |
|
64 |
_S("DB1"), |
|
65 |
_S("DA1"), |
|
66 |
_S("DZ1"), |
|
67 |
_S("DD1") |
|
68 |
}; |
|
69 |
||
70 |
inline TName files(TInt anIndex) |
|
71 |
{return(TName(fileNames[anIndex]));} |
|
72 |
inline TName dirs(TInt anIndex) |
|
73 |
{return(TName(dirNames[anIndex]));} |
|
74 |
||
75 |
LOCAL_C void displayDir(const CDir& aDir,TInt& aDirCount,TInt& aFileCount) |
|
76 |
// |
|
77 |
// Display the contents of a directory list. |
|
78 |
// |
|
79 |
{ |
|
80 |
||
81 |
TInt count=aDir.Count(); |
|
82 |
TInt i=0; |
|
83 |
TInt fCount=0; |
|
84 |
TInt dCount=0; |
|
85 |
while (i<count) |
|
86 |
{ |
|
87 |
const TEntry& e=aDir[i++]; |
|
88 |
if (e.IsDir()) |
|
89 |
{ |
|
90 |
dCount++; |
|
91 |
test.Printf(_L("%- 16S <DIR>\n"),&e.iName); |
|
92 |
} |
|
93 |
else |
|
94 |
{ |
|
95 |
fCount++; |
|
96 |
test.Printf(_L("%- 16S %+ 8d\n"),&e.iName,e.iSize); |
|
97 |
} |
|
98 |
} |
|
99 |
test.Printf(_L("Dirs = %d Files = %d\n"),dCount,fCount); |
|
100 |
aFileCount=fCount; |
|
101 |
aDirCount=dCount; |
|
102 |
} |
|
103 |
||
104 |
LOCAL_C void createFile(const TUidFile& aFileName) |
|
105 |
// |
|
106 |
// Create a file in the test directory. |
|
107 |
// |
|
108 |
{ |
|
109 |
||
110 |
TCheckedUid checkedUid(aFileName.iUidType); |
|
111 |
TPtrC fileName(aFileName.iFileName); |
|
112 |
TAutoClose<RFile> file; |
|
113 |
TInt r=file.iObj.Replace(TheFs,fileName,EFileWrite); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
114 |
test_KErrNone(r); |
0 | 115 |
TPtrC8 uidBuf((TUint8*)&checkedUid,sizeof(TCheckedUid)); |
116 |
r=file.iObj.Write(uidBuf); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
117 |
test_KErrNone(r); |
0 | 118 |
TPtrC8 contents(aFileName.iContents); |
119 |
r=file.iObj.Write(contents); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
120 |
test_KErrNone(r); |
0 | 121 |
} |
122 |
||
123 |
LOCAL_C void createFile(TInt anIndex) |
|
124 |
// |
|
125 |
// Create a file in the test directory. |
|
126 |
// |
|
127 |
{ |
|
128 |
||
129 |
TFileName fName; |
|
130 |
TName name=files(anIndex); |
|
131 |
fName.Format(_L("%S%S"),&test_dir,&name); |
|
132 |
TBuf<0x80> mes; |
|
133 |
mes.Format(_L("Create file %S"),&fName); |
|
134 |
test.Next(mes); |
|
135 |
// |
|
136 |
TAutoClose<RFile> file; |
|
137 |
TInt r=file.iObj.Replace(TheFs,fName,EFileWrite); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
138 |
test_KErrNone(r); |
0 | 139 |
TBuf8<36> b((TUint8*)"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"); |
140 |
b.SetLength(anIndex+1); |
|
141 |
r=file.iObj.Write(b); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
142 |
test_KErrNone(r); |
0 | 143 |
} |
144 |
||
145 |
LOCAL_C void createDir(TInt anIndex) |
|
146 |
// |
|
147 |
// Create a dir in the test directory. |
|
148 |
// |
|
149 |
{ |
|
150 |
||
151 |
TFileName dName; |
|
152 |
TName name=dirs(anIndex); |
|
153 |
dName.Format(_L("%S%S\\"),&test_dir,&name); |
|
154 |
TBuf<0x80> mes; |
|
155 |
mes.Format(_L("Create dir %S"),&dName); |
|
156 |
test.Next(mes); |
|
157 |
// |
|
158 |
TInt r=TheFs.MkDir(dName); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
159 |
test_KErrNone(r); |
0 | 160 |
} |
161 |
||
162 |
LOCAL_C void testSetup() |
|
163 |
// |
|
164 |
// Setup the test environment. |
|
165 |
// |
|
166 |
{ |
|
167 |
||
168 |
test.Next(_L("Remove test directory")); |
|
169 |
CDir* pD; |
|
170 |
TInt r=TheFs.GetDir(test_dir_1,KEntryAttMaskSupported,EDirsLast,pD); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
171 |
test_Value(r, r == KErrNone || r==KErrNotFound || r==KErrPathNotFound); |
0 | 172 |
if (r==KErrNone) |
173 |
{ |
|
174 |
TInt count=pD->Count(); |
|
175 |
TInt i=0; |
|
176 |
while (i<count) |
|
177 |
{ |
|
178 |
const TEntry& e=(*pD)[i++]; |
|
179 |
if (e.IsDir()) |
|
180 |
{ |
|
181 |
TFileName name; |
|
182 |
name.Format(_L("%S%S\\"),&test_dir,&e.iName); |
|
183 |
r=TheFs.RmDir(name); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
184 |
test_KErrNone(r); |
0 | 185 |
} |
186 |
else |
|
187 |
{ |
|
188 |
TFileName name; |
|
189 |
name.Format(_L("%S%S"),&test_dir,&e.iName); |
|
190 |
r=TheFs.Delete(name); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
191 |
test_KErrNone(r); |
0 | 192 |
} |
193 |
} |
|
194 |
} |
|
195 |
// |
|
196 |
delete pD; |
|
197 |
// |
|
198 |
test.Next(_L("Create test files")); |
|
199 |
TInt i=0; |
|
200 |
while (i<KFilesMax) |
|
201 |
createFile(i++); |
|
202 |
// |
|
203 |
test.Next(_L("Create test directories")); |
|
204 |
i=0; |
|
205 |
while (i<KDirsMax) |
|
206 |
createDir(i++); |
|
207 |
} |
|
208 |
||
209 |
LOCAL_C void testDir() |
|
210 |
// |
|
211 |
// Setup the test environment. |
|
212 |
// |
|
213 |
{ |
|
214 |
||
215 |
TInt dCount; |
|
216 |
TInt fCount; |
|
217 |
test.Next(_L("Test directory handling")); |
|
218 |
CDir* pD; |
|
219 |
TInt r=TheFs.GetDir(test_dir_1,KEntryAttMaskSupported,EDirsLast,pD); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
220 |
test_KErrNone(r); |
0 | 221 |
displayDir(*pD,dCount,fCount); |
222 |
test(dCount==4 && fCount==9); |
|
223 |
delete pD; |
|
224 |
// |
|
225 |
test.Next(_L("Attributes: NULL")); |
|
226 |
r=TheFs.GetDir(test_dir_1,NULL,EDirsLast,pD); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
227 |
test_KErrNone(r); |
0 | 228 |
displayDir(*pD,dCount,fCount); |
229 |
test(dCount==0 && fCount==9); |
|
230 |
delete pD; |
|
231 |
// |
|
232 |
test.Next(_L("Attributes: KEntryAttDir & EDescending sort")); |
|
233 |
r=TheFs.GetDir(test_dir_1,KEntryAttDir,ESortByName|EDescending,pD); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
234 |
test_KErrNone(r); |
0 | 235 |
displayDir(*pD,dCount,fCount); |
236 |
test(dCount==4 && fCount==9); |
|
237 |
delete pD; |
|
238 |
// |
|
239 |
test.Next(_L("Attributes: Excl,Dir")); |
|
240 |
r=TheFs.GetDir(test_dir_1,KEntryAttMatchExclusive|KEntryAttDir,ESortByName|EDescending,pD); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
241 |
test_KErrNone(r); |
0 | 242 |
displayDir(*pD,dCount,fCount); |
243 |
test(dCount==4 && fCount==0); |
|
244 |
delete pD; |
|
245 |
// |
|
246 |
CDir* pD2; |
|
247 |
// |
|
248 |
test.Next(_L("Test split directories and files")); |
|
249 |
r=TheFs.GetDir(test_dir_1,KEntryAttMaskSupported,ESortByName,pD,pD2); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
250 |
test_KErrNone(r); |
0 | 251 |
test.Printf(_L("FileList:\n")); |
252 |
displayDir(*pD,dCount,fCount); |
|
253 |
test(dCount==4 && fCount==9); |
|
254 |
test.Printf(_L("DirList:\n")); |
|
255 |
displayDir(*pD2,dCount,fCount); |
|
256 |
test(dCount==4 && fCount==0); |
|
257 |
delete pD; |
|
258 |
delete pD2; |
|
259 |
// |
|
260 |
test.Next(_L("Attributes: NULL")); |
|
261 |
r=TheFs.GetDir(test_dir_1,NULL,ESortByName,pD,pD2); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
262 |
test_KErrNone(r); |
0 | 263 |
test.Printf(_L("FileList:\n")); |
264 |
displayDir(*pD,dCount,fCount); |
|
265 |
test(dCount==0 && fCount==9); |
|
266 |
test.Printf(_L("DirList:\n")); |
|
267 |
displayDir(*pD2,dCount,fCount); |
|
268 |
test(dCount==4 && fCount==0); |
|
269 |
delete pD; |
|
270 |
delete pD2; |
|
271 |
// |
|
272 |
test.Next(_L("Attributes: KEntryAttDir")); |
|
273 |
r=TheFs.GetDir(test_dir_1,KEntryAttDir,ESortByName,pD,pD2); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
274 |
test_KErrNone(r); |
0 | 275 |
test.Printf(_L("FileList:\n")); |
276 |
displayDir(*pD,dCount,fCount); |
|
277 |
test(dCount==4 && fCount==9); |
|
278 |
test.Printf(_L("DirList:\n")); |
|
279 |
displayDir(*pD2,dCount,fCount); |
|
280 |
test(dCount==4 && fCount==0); |
|
281 |
delete pD; |
|
282 |
delete pD2; |
|
283 |
// |
|
284 |
test.Next(_L("Attributes: Excl,Dir")); |
|
285 |
r=TheFs.GetDir(test_dir_1,KEntryAttMatchExclusive|KEntryAttDir,ESortByName,pD,pD2); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
286 |
test_KErrNone(r); |
0 | 287 |
test.Printf(_L("FileList:\n")); |
288 |
displayDir(*pD,dCount,fCount); |
|
289 |
test(dCount==4 && fCount==0); |
|
290 |
test.Printf(_L("DirList:\n")); |
|
291 |
displayDir(*pD2,dCount,fCount); |
|
292 |
test(dCount==4 && fCount==0); |
|
293 |
delete pD; |
|
294 |
delete pD2; |
|
295 |
} |
|
296 |
||
297 |
LOCAL_C void testZDirectory() |
|
298 |
// |
|
299 |
// Display Z directory |
|
300 |
// |
|
301 |
{ |
|
302 |
||
303 |
test.Next(_L("Test Z:")); |
|
304 |
TInt dCount,fCount; |
|
305 |
CDir* pD; |
|
306 |
TInt r=TheFs.GetDir(_L("Z:\\*"),KEntryAttMaskSupported,EDirsFirst,pD); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
307 |
test_KErrNone(r); |
0 | 308 |
displayDir(*pD,dCount,fCount); |
309 |
delete pD; |
|
310 |
} |
|
311 |
||
312 |
LOCAL_C void testDisplayFiles() |
|
313 |
// |
|
314 |
// Display some files |
|
315 |
// |
|
316 |
{ |
|
317 |
||
318 |
test.Next(_L("Display contents of current directory")); |
|
319 |
CDir* pD; |
|
320 |
TInt r=TheFs.GetDir(gSessionPath,KEntryAttMaskSupported,EDirsFirst,pD); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
321 |
test_KErrNone(r); |
0 | 322 |
TInt dCount,fCount; |
323 |
displayDir(*pD,dCount,fCount); |
|
324 |
delete pD; |
|
325 |
||
326 |
TParsePtrC session(gSessionPath); |
|
327 |
TParse parser; |
|
328 |
TBuf<16> noName=_L("asdf.idd"); |
|
329 |
parser.Set(session.Drive(),&noName,NULL); |
|
330 |
r=TheFs.GetDir(parser.FullName(),KEntryAttMaskSupported,EDirsFirst,pD); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
331 |
test_KErrNone(r); |
0 | 332 |
test(pD->Count()==0); |
333 |
delete pD; |
|
334 |
} |
|
335 |
||
336 |
LOCAL_C void MatchUidFile(TInt aUidFile,TInt anEntryNum,const CDir* aFileList) |
|
337 |
// |
|
338 |
// Check aUidFile matches anEntryNum |
|
339 |
// |
|
340 |
{ |
|
341 |
||
342 |
test(aUidFile<KUidFilesMax); |
|
343 |
TInt count=aFileList->Count(); |
|
344 |
test(anEntryNum<count); |
|
345 |
TEntry entry=(*aFileList)[anEntryNum]; |
|
346 |
||
347 |
TPtrC uidFileName(uidFiles[aUidFile].iFileName); |
|
348 |
test(entry.iName==uidFileName); |
|
349 |
test(entry.iType==uidFiles[aUidFile].iUidType); |
|
350 |
||
351 |
RFile f; |
|
352 |
TInt r=f.Open(TheFs,entry.iName,EFileRead); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
353 |
test_KErrNone(r); |
0 | 354 |
TBuf8<256> contents; |
355 |
r=f.Read(sizeof(TCheckedUid),contents); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
356 |
test_KErrNone(r); |
0 | 357 |
TPtrC8 uidFileContents(uidFiles[aUidFile].iContents); |
358 |
test(contents==uidFileContents); |
|
359 |
r=f.Read(contents); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
360 |
test_KErrNone(r); |
0 | 361 |
test(contents.Length()==0); |
362 |
f.Close(); |
|
363 |
} |
|
364 |
||
365 |
LOCAL_C TInt PrintUid(TInt anEntryNum,const CDir* aFileList) |
|
366 |
// |
|
367 |
// Check aUidFile matches anEntryNum |
|
368 |
// |
|
369 |
{ |
|
370 |
||
371 |
TInt count=aFileList->Count(); |
|
372 |
test(anEntryNum<count); |
|
373 |
TEntry entry=(*aFileList)[anEntryNum]; |
|
374 |
test.Printf(_L("Entry name = %S UID=%d\n"),&entry.iName,entry.iType[2]); |
|
375 |
return(entry.iType[2].iUid); |
|
376 |
} |
|
377 |
||
378 |
LOCAL_C void testGetDirByUid() |
|
379 |
// |
|
380 |
// Get directory contents by matching UIDs |
|
381 |
// |
|
382 |
{ |
|
383 |
||
384 |
test.Next(_L("Get directory contents by matching UIDs")); |
|
385 |
TInt i=KUidFilesMax; |
|
386 |
while(i--) |
|
387 |
createFile(uidFiles[i]); |
|
388 |
||
389 |
TBuf<16> matchName=_L("*.txt"); |
|
390 |
TUidType matchUid(TUid::Null(),TUid::Uid(2),TUid::Null()); |
|
391 |
CDir* fileList; |
|
392 |
TInt r=TheFs.GetDir(matchName,matchUid,EAscending,fileList); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
393 |
test_KErrNone(r); |
0 | 394 |
TInt count=fileList->Count(); |
395 |
test(count==1); |
|
396 |
MatchUidFile(0,0,fileList); |
|
397 |
delete fileList; |
|
398 |
||
399 |
matchName=_L("*.*"); |
|
400 |
matchUid=TUidType(TUid::Uid(1),TUid::Uid(2),TUid::Uid(731)); |
|
401 |
r=TheFs.GetDir(matchName,matchUid,EAscending,fileList); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
402 |
test_KErrNone(r); |
0 | 403 |
count=fileList->Count(); |
404 |
test(count==1); |
|
405 |
MatchUidFile(0,0,fileList); |
|
406 |
delete fileList; |
|
407 |
||
408 |
matchName=_L("*.*"); |
|
409 |
matchUid=TUidType(TUid::Null(),TUid::Uid(2),TUid::Null()); |
|
410 |
r=TheFs.GetDir(matchName,matchUid,ESortByName|EAscending,fileList); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
411 |
test_KErrNone(r); |
0 | 412 |
count=fileList->Count(); |
413 |
test(count==3); |
|
414 |
MatchUidFile(0,2,fileList); |
|
415 |
MatchUidFile(1,1,fileList); |
|
416 |
MatchUidFile(4,0,fileList); |
|
417 |
delete fileList; |
|
418 |
||
419 |
matchName=_L("*.*"); |
|
420 |
matchUid=TUidType(TUid::Null(),TUid::Null(),TUid::Uid(731)); |
|
421 |
r=TheFs.GetDir(matchName,matchUid,ESortByName|EAscending,fileList); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
422 |
test_KErrNone(r); |
0 | 423 |
count=fileList->Count(); |
424 |
test(count==3); |
|
425 |
MatchUidFile(2,0,fileList); |
|
426 |
MatchUidFile(1,1,fileList); |
|
427 |
MatchUidFile(0,2,fileList); |
|
428 |
delete fileList; |
|
429 |
||
430 |
matchName=_L("*.*"); |
|
431 |
r=TheFs.GetDir(matchName,KEntryAttNormal,ESortByUid|EAscending,fileList); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
432 |
test_KErrNone(r); |
0 | 433 |
count=fileList->Count(); |
434 |
MatchUidFile(4,0,fileList); |
|
435 |
MatchUidFile(1,1,fileList); |
|
436 |
MatchUidFile(0,2,fileList); |
|
437 |
MatchUidFile(5,3,fileList); |
|
438 |
MatchUidFile(2,4,fileList); |
|
439 |
MatchUidFile(3,5,fileList); |
|
440 |
MatchUidFile(6,6,fileList); |
|
441 |
for (i=7;i<count;i++) |
|
442 |
{ |
|
443 |
TEntry entry; |
|
444 |
entry=(*fileList)[i]; |
|
445 |
test(entry.iType[2].iUid==0); |
|
446 |
PrintUid(i,fileList); |
|
447 |
} |
|
448 |
test(i==count); |
|
449 |
delete fileList; |
|
450 |
} |
|
451 |
||
452 |
LOCAL_C void testZGetDirByUid() |
|
453 |
// |
|
454 |
// Get directory contents by matching UIDs from Z: |
|
455 |
// |
|
456 |
{ |
|
457 |
||
458 |
TUidType matchUid(TUid::Null(),TUid::Uid(0x1000008c),TUid::Null()); |
|
459 |
CDir* fileList; |
|
460 |
TInt r=TheFs.GetDir(PlatSec::ConfigSetting(PlatSec::EPlatSecEnforceSysBin)?_L("Z:\\SYS\\BIN\\"):_L("Z:\\SYSTEM\\BIN\\"),matchUid,EAscending,fileList); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
461 |
test_KErrNone(r); |
0 | 462 |
TInt count=fileList->Count(); |
463 |
#if defined(__WINS__) |
|
464 |
test(count==0); |
|
465 |
#else |
|
466 |
test.Printf(_L("Count=%d\n"),count); |
|
467 |
while(count--) |
|
468 |
PrintUid(count,fileList); |
|
469 |
// test(count==1); |
|
470 |
// TEntry entry; |
|
471 |
// entry=(*fileList)[0]; |
|
472 |
// test(entry.iName.MatchF(_L("EFILE.EXE"))!=KErrNotFound); |
|
473 |
#endif |
|
474 |
delete fileList; |
|
475 |
} |
|
476 |
||
477 |
LOCAL_C void testGetFilesExcept() |
|
478 |
// |
|
479 |
// Get all files except read only ... |
|
480 |
// |
|
481 |
{ |
|
482 |
||
483 |
MakeFile(_L("\\F32-TST\\GDIR\\RONLY1.CCC"),KEntryAttReadOnly); |
|
484 |
MakeFile(_L("\\F32-TST\\GDIR\\RONLY2.CCC"),KEntryAttReadOnly); |
|
485 |
MakeFile(_L("\\F32-TST\\GDIR\\RW1.CCC")); |
|
486 |
MakeFile(_L("\\F32-TST\\GDIR\\RW2.CCC")); |
|
487 |
MakeFile(_L("\\F32-TST\\GDIR\\SYSTEM1.CCC"),KEntryAttSystem); |
|
488 |
MakeFile(_L("\\F32-TST\\GDIR\\SYSTEM2.CCC"),KEntryAttSystem); |
|
489 |
||
490 |
test.Next(_L("Can match only read only files")); |
|
491 |
TUint onlyRO=KEntryAttReadOnly|KEntryAttMatchExclusive; |
|
492 |
CDir* fileList; |
|
493 |
TInt r=TheFs.GetDir(_L("\\F32-TST\\GDIR\\*.CCC"),onlyRO,EAscending,fileList); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
494 |
test_KErrNone(r); |
0 | 495 |
TInt count=fileList->Count(); |
496 |
test(count==2); |
|
497 |
||
498 |
TEntry entry; |
|
499 |
entry=(*fileList)[0]; |
|
500 |
test(entry.iName.MatchF(_L("RONLY1.CCC"))!=KErrNotFound); |
|
501 |
entry=(*fileList)[1]; |
|
502 |
test(entry.iName.MatchF(_L("RONLY2.CCC"))!=KErrNotFound); |
|
503 |
delete fileList; |
|
504 |
||
505 |
test.Next(_L("Can match everything except read only files")); |
|
506 |
TUint excludeRO=KEntryAttReadOnly|KEntryAttMatchExclude; |
|
507 |
r=TheFs.GetDir(_L("\\F32-TST\\GDIR\\*.CCC"),excludeRO,EAscending,fileList); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
508 |
test_KErrNone(r); |
0 | 509 |
count=fileList->Count(); |
510 |
test(count==4); |
|
511 |
||
512 |
entry=(*fileList)[0]; |
|
513 |
test(entry.iName.MatchF(_L("RW1.CCC"))!=KErrNotFound); |
|
514 |
entry=(*fileList)[1]; |
|
515 |
test(entry.iName.MatchF(_L("RW2.CCC"))!=KErrNotFound); |
|
516 |
entry=(*fileList)[2]; |
|
517 |
test(entry.iName.MatchF(_L("SYSTEM1.CCC"))!=KErrNotFound); |
|
518 |
entry=(*fileList)[3]; |
|
519 |
test(entry.iName.MatchF(_L("SYSTEM2.CCC"))!=KErrNotFound); |
|
520 |
delete fileList; |
|
521 |
||
522 |
test.Next(_L("Can match everything except system and readonly files")); |
|
523 |
TUint excludeSystemAndRO=KEntryAttReadOnly|KEntryAttSystem|KEntryAttMatchExclude; |
|
524 |
r=TheFs.GetDir(_L("\\F32-TST\\GDIR\\*.CCC"),excludeSystemAndRO,EAscending,fileList); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
525 |
test_KErrNone(r); |
0 | 526 |
count=fileList->Count(); |
527 |
test(count==2); |
|
528 |
||
529 |
entry=(*fileList)[0]; |
|
530 |
test(entry.iName.MatchF(_L("RW1.CCC"))!=KErrNotFound); |
|
531 |
entry=(*fileList)[1]; |
|
532 |
test(entry.iName.MatchF(_L("RW2.CCC"))!=KErrNotFound); |
|
533 |
delete fileList; |
|
534 |
||
535 |
r=TheFs.SetAtt(_L("\\F32-TST\\GDIR\\RONLY1.CCC"),0,KEntryAttReadOnly); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
536 |
test_KErrNone(r); |
0 | 537 |
r=TheFs.SetAtt(_L("\\F32-TST\\GDIR\\RONLY2.CCC"),0,KEntryAttReadOnly); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
538 |
test_KErrNone(r); |
0 | 539 |
} |
540 |
||
541 |
LOCAL_C void testGetHidden() |
|
542 |
// |
|
543 |
// Match hidden files and directories |
|
544 |
// |
|
545 |
{ |
|
546 |
||
547 |
test.Next(_L("Match hidden files and directories")); |
|
548 |
MakeFile(_L("File.qqq")); |
|
549 |
MakeFile(_L("FileHidden.qqq")); |
|
550 |
MakeFile(_L("FileSystem.qqq")); |
|
551 |
MakeFile(_L("FileHiddenSystem.qqq")); |
|
552 |
MakeDir(_L("\\F32-TST\\GDIR\\Dir.qqq\\")); |
|
553 |
MakeDir(_L("\\F32-TST\\GDIR\\Dirhidden.qqq\\")); |
|
554 |
MakeDir(_L("\\F32-TST\\GDIR\\Dirsystem.qqq\\")); |
|
555 |
MakeDir(_L("\\F32-TST\\GDIR\\Dirhiddensystem.qqq\\")); |
|
556 |
||
557 |
TInt r=TheFs.SetAtt(_L("FileHidden.qqq"),KEntryAttHidden,0); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
558 |
test_KErrNone(r); |
0 | 559 |
r=TheFs.SetAtt(_L("Filesystem.qqq"),KEntryAttSystem,0); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
560 |
test_KErrNone(r); |
0 | 561 |
r=TheFs.SetAtt(_L("FilehiddenSystem.qqq"),KEntryAttSystem|KEntryAttHidden,0); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
562 |
test_KErrNone(r); |
0 | 563 |
r=TheFs.SetAtt(_L("dirhidden.qqq"),KEntryAttHidden,0); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
564 |
test_KErrNone(r); |
0 | 565 |
r=TheFs.SetAtt(_L("dirsystem.qqq"),KEntryAttSystem,0); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
566 |
test_KErrNone(r); |
0 | 567 |
r=TheFs.SetAtt(_L("dirhiddensystem.qqq"),KEntryAttSystem|KEntryAttHidden,0); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
568 |
test_KErrNone(r); |
0 | 569 |
|
570 |
// Files and directories not hidden or system |
|
571 |
CDir* dir; |
|
572 |
r=TheFs.GetDir(_L("*.qqq"),KEntryAttDir,ESortByName,dir); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
573 |
test_KErrNone(r); |
0 | 574 |
TInt count=dir->Count(); |
575 |
test(count==2); |
|
576 |
TEntry entry; |
|
577 |
entry=(*dir)[0]; |
|
578 |
test(entry.iName.MatchF(_L("dir.qqq"))!=KErrNotFound); |
|
579 |
entry=(*dir)[1]; |
|
580 |
test(entry.iName.MatchF(_L("file.qqq"))!=KErrNotFound); |
|
581 |
delete dir; |
|
582 |
||
583 |
// Files only |
|
584 |
r=TheFs.GetDir(_L("*.qqq"),KEntryAttNormal,ESortByName,dir); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
585 |
test_KErrNone(r); |
0 | 586 |
count=dir->Count(); |
587 |
test(count==1); |
|
588 |
entry=(*dir)[0]; |
|
589 |
test(entry.iName.MatchF(_L("file.qqq"))!=KErrNotFound); |
|
590 |
delete dir; |
|
591 |
||
592 |
// Directories only |
|
593 |
r=TheFs.GetDir(_L("*.qqq"),KEntryAttDir|KEntryAttMatchExclusive,ESortByName,dir); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
594 |
test_KErrNone(r); |
0 | 595 |
count=dir->Count(); |
596 |
test(count==1); |
|
597 |
entry=(*dir)[0]; |
|
598 |
test(entry.iName.MatchF(_L("dir.qqq"))!=KErrNotFound); |
|
599 |
delete dir; |
|
600 |
||
601 |
// Files + hidden |
|
602 |
r=TheFs.GetDir(_L("*.qqq"),KEntryAttHidden,ESortByName,dir); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
603 |
test_KErrNone(r); |
0 | 604 |
count=dir->Count(); |
605 |
test(count==2); |
|
606 |
entry=(*dir)[0]; |
|
607 |
test(entry.iName.MatchF(_L("file.qqq"))!=KErrNotFound); |
|
608 |
entry=(*dir)[1]; |
|
609 |
test(entry.iName.MatchF(_L("filehidden.qqq"))!=KErrNotFound); |
|
610 |
delete dir; |
|
611 |
||
612 |
// Files + system |
|
613 |
r=TheFs.GetDir(_L("*.qqq"),KEntryAttHidden,ESortByName,dir); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
614 |
test_KErrNone(r); |
0 | 615 |
count=dir->Count(); |
616 |
test(count==2); |
|
617 |
entry=(*dir)[0]; |
|
618 |
test(entry.iName.MatchF(_L("file.qqq"))!=KErrNotFound); |
|
619 |
entry=(*dir)[1]; |
|
620 |
test(entry.iName.MatchF(_L("filehidden.qqq"))!=KErrNotFound); |
|
621 |
delete dir; |
|
622 |
||
623 |
// Files + hidden + system |
|
624 |
r=TheFs.GetDir(_L("*.qqq"),KEntryAttHidden|KEntryAttSystem,ESortByName,dir); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
625 |
test_KErrNone(r); |
0 | 626 |
count=dir->Count(); |
627 |
test(count==4); |
|
628 |
entry=(*dir)[0]; |
|
629 |
test(entry.iName.MatchF(_L("file.qqq"))!=KErrNotFound); |
|
630 |
entry=(*dir)[1]; |
|
631 |
test(entry.iName.MatchF(_L("filehidden.qqq"))!=KErrNotFound); |
|
632 |
entry=(*dir)[2]; |
|
633 |
test(entry.iName.MatchF(_L("filehiddensystem.qqq"))!=KErrNotFound); |
|
634 |
entry=(*dir)[3]; |
|
635 |
test(entry.iName.MatchF(_L("filesystem.qqq"))!=KErrNotFound); |
|
636 |
delete dir; |
|
637 |
||
638 |
// Dirs + hidden |
|
639 |
r=TheFs.GetDir(_L("*.qqq"),KEntryAttHidden|KEntryAttDir|KEntryAttMatchExclusive,ESortByName,dir); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
640 |
test_KErrNone(r); |
0 | 641 |
count=dir->Count(); |
642 |
test(count==2); |
|
643 |
entry=(*dir)[0]; |
|
644 |
test(entry.iName.MatchF(_L("dir.qqq"))!=KErrNotFound); |
|
645 |
entry=(*dir)[1]; |
|
646 |
test(entry.iName.MatchF(_L("dirhidden.qqq"))!=KErrNotFound); |
|
647 |
delete dir; |
|
648 |
||
649 |
// Dirs + system |
|
650 |
r=TheFs.GetDir(_L("*.qqq"),KEntryAttSystem|KEntryAttDir|KEntryAttMatchExclusive,ESortByName,dir); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
651 |
test_KErrNone(r); |
0 | 652 |
count=dir->Count(); |
653 |
test(count==2); |
|
654 |
entry=(*dir)[0]; |
|
655 |
test(entry.iName.MatchF(_L("dir.qqq"))!=KErrNotFound); |
|
656 |
entry=(*dir)[1]; |
|
657 |
test(entry.iName.MatchF(_L("dirsystem.qqq"))!=KErrNotFound); |
|
658 |
delete dir; |
|
659 |
||
660 |
// Dirs + hidden + system |
|
661 |
r=TheFs.GetDir(_L("*.qqq"),KEntryAttHidden|KEntryAttSystem|KEntryAttDir|KEntryAttMatchExclusive,ESortByName,dir); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
662 |
test_KErrNone(r); |
0 | 663 |
count=dir->Count(); |
664 |
test(count==4); |
|
665 |
entry=(*dir)[0]; |
|
666 |
test(entry.iName.MatchF(_L("dir.qqq"))!=KErrNotFound); |
|
667 |
entry=(*dir)[1]; |
|
668 |
test(entry.iName.MatchF(_L("dirhidden.qqq"))!=KErrNotFound); |
|
669 |
entry=(*dir)[2]; |
|
670 |
test(entry.iName.MatchF(_L("dirhiddensystem.qqq"))!=KErrNotFound); |
|
671 |
entry=(*dir)[3]; |
|
672 |
test(entry.iName.MatchF(_L("dirsystem.qqq"))!=KErrNotFound); |
|
673 |
||
674 |
delete dir; |
|
675 |
||
676 |
// Files + Dirs + hidden |
|
677 |
r=TheFs.GetDir(_L("*.qqq"),KEntryAttHidden|KEntryAttDir,ESortByName,dir); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
678 |
test_KErrNone(r); |
0 | 679 |
count=dir->Count(); |
680 |
test(count==4); |
|
681 |
entry=(*dir)[0]; |
|
682 |
test(entry.iName.MatchF(_L("dir.qqq"))!=KErrNotFound); |
|
683 |
entry=(*dir)[1]; |
|
684 |
test(entry.iName.MatchF(_L("dirhidden.qqq"))!=KErrNotFound); |
|
685 |
entry=(*dir)[2]; |
|
686 |
test(entry.iName.MatchF(_L("file.qqq"))!=KErrNotFound); |
|
687 |
entry=(*dir)[3]; |
|
688 |
test(entry.iName.MatchF(_L("filehidden.qqq"))!=KErrNotFound); |
|
689 |
delete dir; |
|
690 |
||
691 |
// Files + Dirs + system |
|
692 |
r=TheFs.GetDir(_L("*.qqq"),KEntryAttSystem|KEntryAttDir,ESortByName,dir); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
693 |
test_KErrNone(r); |
0 | 694 |
count=dir->Count(); |
695 |
test(count==4); |
|
696 |
entry=(*dir)[0]; |
|
697 |
test(entry.iName.MatchF(_L("dir.qqq"))!=KErrNotFound); |
|
698 |
entry=(*dir)[1]; |
|
699 |
test(entry.iName.MatchF(_L("dirsystem.qqq"))!=KErrNotFound); |
|
700 |
entry=(*dir)[2]; |
|
701 |
test(entry.iName.MatchF(_L("file.qqq"))!=KErrNotFound); |
|
702 |
entry=(*dir)[3]; |
|
703 |
test(entry.iName.MatchF(_L("filesystem.qqq"))!=KErrNotFound); |
|
704 |
delete dir; |
|
705 |
||
706 |
// Files + Dirs + hidden + system |
|
707 |
r=TheFs.GetDir(_L("*.qqq"),KEntryAttHidden|KEntryAttSystem|KEntryAttDir,ESortByName,dir); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
708 |
test_KErrNone(r); |
0 | 709 |
count=dir->Count(); |
710 |
test(count==8); |
|
711 |
entry=(*dir)[0]; |
|
712 |
test(entry.iName.MatchF(_L("dir.qqq"))!=KErrNotFound); |
|
713 |
entry=(*dir)[1]; |
|
714 |
test(entry.iName.MatchF(_L("dirhidden.qqq"))!=KErrNotFound); |
|
715 |
entry=(*dir)[2]; |
|
716 |
test(entry.iName.MatchF(_L("dirhiddensystem.qqq"))!=KErrNotFound); |
|
717 |
entry=(*dir)[3]; |
|
718 |
test(entry.iName.MatchF(_L("dirsystem.qqq"))!=KErrNotFound); |
|
719 |
entry=(*dir)[4]; |
|
720 |
test(entry.iName.MatchF(_L("file.qqq"))!=KErrNotFound); |
|
721 |
entry=(*dir)[5]; |
|
722 |
test(entry.iName.MatchF(_L("filehidden.qqq"))!=KErrNotFound); |
|
723 |
entry=(*dir)[6]; |
|
724 |
test(entry.iName.MatchF(_L("filehiddensystem.qqq"))!=KErrNotFound); |
|
725 |
entry=(*dir)[7]; |
|
726 |
test(entry.iName.MatchF(_L("filesystem.qqq"))!=KErrNotFound); |
|
727 |
delete dir; |
|
728 |
} |
|
729 |
||
730 |
LOCAL_D TFileName gDirDescendingBaseName=_L("\\F32-TST\\GDIR\\TDIRDESCENDING\\"); |
|
731 |
LOCAL_D TFileName gDirDescendingEntryName[6]= |
|
732 |
{ |
|
733 |
_L("\\F32-TST\\GDIR\\TDIRDESCENDING\\aaaa"), |
|
734 |
_L("\\F32-TST\\GDIR\\TDIRDESCENDING\\ssss"), |
|
735 |
_L("\\F32-TST\\GDIR\\TDIRDESCENDING\\ZZZZ"), |
|
736 |
_L("\\F32-TST\\GDIR\\TDIRDESCENDING\\aaaa.directory\\"), |
|
737 |
_L("\\F32-TST\\GDIR\\TDIRDESCENDING\\SSSS.dir\\"), |
|
738 |
_L("\\F32-TST\\GDIR\\TDIRDESCENDING\\ZZZZDirectory\\") |
|
739 |
}; |
|
740 |
||
741 |
LOCAL_C void TestDirDescendingOrder(const TDesC& aResult,const CDir& aDirList) |
|
742 |
// |
|
743 |
// Test aDirList against aResult |
|
744 |
// |
|
745 |
{ |
|
746 |
||
747 |
TLex lex(aResult); |
|
748 |
TInt count=0; |
|
749 |
while (!lex.Eos()) |
|
750 |
{ |
|
751 |
lex.Mark(); |
|
752 |
while(lex.Get().IsDigit()) {}; |
|
753 |
TLex temp(lex.MarkedToken()); |
|
754 |
TInt result; |
|
755 |
temp.Val(result); |
|
756 |
TFileName base=gDirDescendingBaseName; |
|
757 |
TEntry entry=aDirList[count]; |
|
758 |
base+=entry.iName; |
|
759 |
if (entry.IsDir()) |
|
760 |
base+=_L("\\"); |
|
761 |
test(base==gDirDescendingEntryName[result]); |
|
762 |
count++; |
|
763 |
} |
|
764 |
} |
|
765 |
||
766 |
LOCAL_C void testDirDescending() |
|
767 |
// |
|
768 |
// Test EDirDescending |
|
769 |
// |
|
770 |
{ |
|
771 |
||
772 |
test.Next(_L("Test EDirDescending")); |
|
773 |
MakeDir(gDirDescendingBaseName); |
|
774 |
MakeFile(gDirDescendingEntryName[0]); |
|
775 |
MakeFile(gDirDescendingEntryName[1]); |
|
776 |
MakeFile(gDirDescendingEntryName[2]); |
|
777 |
MakeDir(gDirDescendingEntryName[3]); |
|
778 |
MakeDir(gDirDescendingEntryName[4]); |
|
779 |
MakeDir(gDirDescendingEntryName[5]); |
|
780 |
||
781 |
// Test DirFirst - EDescending |
|
782 |
CDir* dir; |
|
783 |
TUint sortOrder=ESortByName|EDirsFirst|EDescending; |
|
784 |
TInt r=TheFs.GetDir(gDirDescendingBaseName,KEntryAttMaskSupported,sortOrder,dir); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
785 |
test_KErrNone(r); |
0 | 786 |
// TBuf8<16> result=_L("2,1,0,3,4,5"); |
787 |
TBuf<16> result=_L("2,1,0,3,4,5"); |
|
788 |
||
789 |
TestDirDescendingOrder(result,*dir); |
|
790 |
delete dir; |
|
791 |
// Test DirFirst - EAscending |
|
792 |
sortOrder=ESortByName|EDirsFirst; |
|
793 |
r=TheFs.GetDir(gDirDescendingBaseName,KEntryAttMaskSupported,sortOrder,dir); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
794 |
test_KErrNone(r); |
0 | 795 |
result=_L("3,4,5,0,1,2"); |
796 |
TestDirDescendingOrder(result,*dir); |
|
797 |
delete dir; |
|
798 |
||
799 |
// Test DirLast - EDescending |
|
800 |
sortOrder=ESortByName|EDirsLast|EDescending; |
|
801 |
r=TheFs.GetDir(gDirDescendingBaseName,KEntryAttMaskSupported,sortOrder,dir); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
802 |
test_KErrNone(r); |
0 | 803 |
result=_L("3,4,5,2,1,0"); |
804 |
TestDirDescendingOrder(result,*dir); |
|
805 |
delete dir; |
|
806 |
// Test DirLast - EAscending |
|
807 |
sortOrder=ESortByName|EDirsLast; |
|
808 |
r=TheFs.GetDir(gDirDescendingBaseName,KEntryAttMaskSupported,sortOrder,dir); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
809 |
test_KErrNone(r); |
0 | 810 |
result=_L("0,1,2,3,4,5"); |
811 |
TestDirDescendingOrder(result,*dir); |
|
812 |
delete dir; |
|
813 |
||
814 |
// Test DirFirst - EDirDescending |
|
815 |
sortOrder=ESortByName|EDirsFirst|EDirDescending; |
|
816 |
r=TheFs.GetDir(gDirDescendingBaseName,KEntryAttMaskSupported,sortOrder,dir); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
817 |
test_KErrNone(r); |
0 | 818 |
result=_L("5,4,3,0,1,2"); |
819 |
TestDirDescendingOrder(result,*dir); |
|
820 |
delete dir; |
|
821 |
// Test DirLast - EDirDescending |
|
822 |
sortOrder=ESortByName|EDirsLast|EDirDescending; |
|
823 |
r=TheFs.GetDir(gDirDescendingBaseName,KEntryAttMaskSupported,sortOrder,dir); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
824 |
test_KErrNone(r); |
0 | 825 |
result=_L("0,1,2,5,4,3"); |
826 |
TestDirDescendingOrder(result,*dir); |
|
827 |
delete dir; |
|
828 |
||
829 |
// Test DirFirst - EDescending|EDirDescending |
|
830 |
sortOrder=ESortByName|EDirsFirst|EDescending|EDirDescending; |
|
831 |
r=TheFs.GetDir(gDirDescendingBaseName,KEntryAttMaskSupported,sortOrder,dir); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
832 |
test_KErrNone(r); |
0 | 833 |
result=_L("2,1,0,5,4,3"); |
834 |
TestDirDescendingOrder(result,*dir); |
|
835 |
delete dir; |
|
836 |
// Test DirLast - EDescending|EDirDescending |
|
837 |
sortOrder=ESortByName|EDirsLast|EDirDescending|EDescending; |
|
838 |
r=TheFs.GetDir(gDirDescendingBaseName,KEntryAttMaskSupported,sortOrder,dir); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
839 |
test_KErrNone(r); |
0 | 840 |
result=_L("5,4,3,2,1,0"); |
841 |
TestDirDescendingOrder(result,*dir); |
|
842 |
delete dir; |
|
843 |
||
844 |
// Test DirNoOrder - EDescending|EDirDescending |
|
845 |
sortOrder=ESortByName|EDescending|EDirDescending; |
|
846 |
r=TheFs.GetDir(gDirDescendingBaseName,KEntryAttMaskSupported,sortOrder,dir); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
847 |
test_KErrNone(r); |
0 | 848 |
result=_L("5,2,4,1,3,0"); |
849 |
TestDirDescendingOrder(result,*dir); |
|
850 |
delete dir; |
|
851 |
// Test DirNoOrder - EDescending |
|
852 |
sortOrder=ESortByName|EDescending; |
|
853 |
r=TheFs.GetDir(gDirDescendingBaseName,KEntryAttMaskSupported,sortOrder,dir); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
854 |
test_KErrNone(r); |
0 | 855 |
result=_L("5,2,4,1,3,0"); |
856 |
TestDirDescendingOrder(result,*dir); |
|
857 |
delete dir; |
|
858 |
// Test DirNoOrder - EAscending |
|
859 |
sortOrder=ESortByName; |
|
860 |
r=TheFs.GetDir(gDirDescendingBaseName,KEntryAttMaskSupported,sortOrder,dir); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
861 |
test_KErrNone(r); |
0 | 862 |
result=_L("0,3,1,4,2,5"); |
863 |
TestDirDescendingOrder(result,*dir); |
|
864 |
delete dir; |
|
865 |
} |
|
866 |
||
867 |
//--------------------------------------------- |
|
868 |
//! @SYMTestCaseID PBASE-T_GDIR-0815 |
|
869 |
//! @SYMTestType UT |
|
870 |
//! @SYMREQ DEF122894 |
|
871 |
//! @SYMTestCaseDesc This testcase tests the boundary condition of file name collation (8 characters). |
|
872 |
//! @SYMTestActions Creates file "xxxxxxxx2.dat" and "Xxxxxxxx1.dat" under same directory, |
|
873 |
//! retrieves dir list via GetDir(), sort list by name, check order of the file listed. |
|
874 |
//! @SYMTestExpectedResults File "Xxxxxxxx1.dat" should be listed before "xxxxxxxx2.dat". |
|
875 |
//! @SYMTestPriority High |
|
876 |
//! @SYMTestStatus Implemented |
|
877 |
//--------------------------------------------- |
|
878 |
void TestDEF122894() |
|
879 |
{ |
|
880 |
test.Next(_L("Test \"DEF122894: Defect in RFs GetDir() API\"")); |
|
881 |
MakeFile(_L("\\F32-TST\\GDIR\\DEF122894\\xxxxxxxx2.dat")); |
|
882 |
MakeFile(_L("\\F32-TST\\GDIR\\DEF122894\\Xxxxxxxx1.dat")); |
|
883 |
CDir* dir; |
|
884 |
TInt r=TheFs.GetDir(_L("\\F32-TST\\GDIR\\DEF122894\\"),KEntryAttMaskSupported,ESortByName|EAscending,dir); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
885 |
test_KErrNone(r); |
0 | 886 |
test(dir->Count() == 2); |
887 |
TEntry entry1, entry2; |
|
888 |
entry1 = (*dir)[0]; |
|
889 |
entry2 = (*dir)[1]; |
|
890 |
test(entry1.iName.Compare(_L("Xxxxxxxx1.dat")) == 0); |
|
891 |
test(entry2.iName.Compare(_L("xxxxxxxx2.dat")) == 0); |
|
892 |
delete dir; |
|
893 |
} |
|
894 |
||
895 |
GLDEF_C void CallTestsL() |
|
896 |
// |
|
897 |
// Test directory handling. |
|
898 |
// |
|
899 |
{ |
|
900 |
||
901 |
CreateTestDirectory(_L("\\F32-TST\\GDIR\\")); |
|
902 |
if (gFirstRun) |
|
903 |
{ |
|
904 |
gFirstRun=EFalse; |
|
905 |
testZDirectory(); |
|
906 |
testZGetDirByUid(); |
|
907 |
} |
|
908 |
||
909 |
testSetup(); |
|
910 |
testDir(); |
|
911 |
testDisplayFiles(); |
|
912 |
testGetDirByUid(); |
|
913 |
testGetFilesExcept(); |
|
914 |
testGetHidden(); |
|
915 |
testDirDescending(); |
|
916 |
TestDEF122894(); |
|
917 |
DeleteTestDirectory(); |
|
918 |
} |
|
919 |