Update contrib.
1 // Copyright (c) 2008-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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // Test attribute settings on files
19 #include <e32std_private.h>
28 RTest test( _L("T_ROFSATTRIB") );
30 _LIT( KFileRsh1, "rsh" );
31 _LIT( KFileRs1, "rs" );
32 _LIT( KFileRh1, "rh" );
33 _LIT( KFileSh1, "sh" );
37 _LIT( KFileR2, "r2" );
38 _LIT( KFileR3, "r3" );
39 _LIT( KFileS2, "s2" );
40 _LIT( KFileS3, "s3" );
41 _LIT( KFileH2, "h2" );
42 _LIT( KFileH3, "h3" );
43 _LIT( KFileRs2, "rs2" );
44 _LIT( KFileRs3, "rs3" );
45 _LIT( KFileRh2, "rh2" );
46 _LIT( KFileRh3, "rh3" );
47 _LIT( KFileRsh2, "rsh2" );
48 _LIT( KFileRsh3, "rsh3" );
50 _LIT( KDirectoryBase, "Attrib\\");
52 LOCAL_D const TUint KFileListAllAttribs[] =
54 KEntryAttReadOnly | KEntryAttSystem | KEntryAttHidden, // KFileRsh1
55 KEntryAttReadOnly | KEntryAttSystem, // KFileRs1
56 KEntryAttReadOnly | KEntryAttHidden, // KFileRh1
57 KEntryAttSystem | KEntryAttHidden,// KFileSh1
58 KEntryAttSystem, // KFileS1
59 KEntryAttHidden, // KFileH1
60 KEntryAttReadOnly, // KFileR1
61 KEntryAttReadOnly, // KFileR2
62 KEntryAttReadOnly, // KFileR3
63 KEntryAttSystem, // KFileS2
64 KEntryAttSystem, // KFileS3
65 KEntryAttHidden, // KFileH2
66 KEntryAttHidden, // KFileH3
67 KEntryAttReadOnly | KEntryAttSystem, // KFileRs2
68 KEntryAttReadOnly | KEntryAttSystem, // KFileRs3
69 KEntryAttReadOnly | KEntryAttHidden, // KFileRh2
70 KEntryAttReadOnly | KEntryAttHidden, // KFileRh3
71 KEntryAttReadOnly | KEntryAttSystem | KEntryAttHidden, // KFileRsh2
72 KEntryAttReadOnly | KEntryAttSystem | KEntryAttHidden, // KFileRsh3
75 LOCAL_D const TDesC* KFileListAll[] =
99 LOCAL_D const TDesC* KFileListReadOnly[] =
116 LOCAL_D const TDesC* KFileListNotHidden[] =
131 LOCAL_D const TDesC* KFileListNotSystem[] =
146 LOCAL_D const TDesC* KFileListNotSystemAndHidden[] =
170 LOCAL_D const TDesC* KFileListNotSystemOrHidden[] =
180 _LIT( KDriveBase, " :\\" );
181 _LIT( KWildCard, "*" );
184 LOCAL_C void TestFileAttribsL(TInt aDriveToTest)
188 TFileName name(KDriveBase);
189 name[0] = TText('A' + aDriveToTest);
190 name.Append( KDirectoryBase );
191 name.Append( KWildCard );
193 TInt r = TheFs.GetDir( name, KEntryAttMatchMask, ESortNone, dir );
195 test( dir->Count() > 0 );
199 for( i = 0; KFileListAll[i]; i++ )
201 e = dir->operator[](i);
202 test.Printf( _L("Found entry %S"), &e.iName );
203 test( e.iName == *KFileListAll[i] );
206 TEST_FOR_MATCH( e.iAtt, KFileListAllAttribs[i] );
208 TEST_FOR_MATCH( i, dir->Count() );
213 LOCAL_C void TestScanFilesL( const TDesC* aFileList[], TUint aAttribMask, TInt aDriveToTest )
215 // Tests scanning a directory with attribute mask
220 TFileName name(KDriveBase);
221 name[0] = TText('A' + aDriveToTest);
222 name.Append( KDirectoryBase );
223 name.Append( KWildCard );
225 TInt r = TheFs.GetDir( name, aAttribMask, ESortNone, dir );
228 test( dir->Count() > 0 );
232 for( i = 0; aFileList[i]; i++ )
234 e = dir->operator[](i);
235 test.Printf( _L("Found entry %S"), &e.iName );
236 test( e.iName == *aFileList[i] );
238 TEST_FOR_MATCH( i, dir->Count() );
246 //************************
249 void DoTestL(TInt aDriveToTest)
252 test.Start( _L("Testing ROFS directory structure") );
254 const TUint KNotSystem = KEntryAttReadOnly | KEntryAttHidden;
255 const TUint KNotHidden = KEntryAttReadOnly | KEntryAttSystem;
256 const TUint KNotSystemOrHidden = KEntryAttNormal;
258 test.Next( _L("Checking attributes of files") );
259 TestFileAttribsL(aDriveToTest);
260 test.Next( _L("Testing not system") );
261 TestScanFilesL( KFileListNotSystem, KNotSystem, aDriveToTest );
262 test.Next( _L("Testing not hidden") );
263 TestScanFilesL( KFileListNotHidden, KNotHidden, aDriveToTest );
264 test.Next( _L("Testing not system or hidden") );
265 TestScanFilesL( KFileListNotSystemOrHidden, KNotSystemOrHidden, aDriveToTest );