os/kernelhwsrv/kerneltest/f32test/server/t_scan.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/kerneltest/f32test/server/t_scan.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,540 @@
     1.4 +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of the License "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +#include <f32file.h>
    1.20 +#include <e32test.h>
    1.21 +#include "t_server.h"
    1.22 +
    1.23 +GLDEF_D RTest test(_L("T_SCAN"));
    1.24 +
    1.25 +LOCAL_C void BuildTestDir()
    1.26 +//
    1.27 +// Build up a test directory structure
    1.28 +//
    1.29 +
    1.30 +/*
    1.31 +//               SCANTEST
    1.32 +//                  | 
    1.33 +//  File1 File2 Left File3 Right Empty(Directory)
    1.34 +//             /  \        /  \
    1.35 +//           Dir2  Dir3 File4 File5
    1.36 +//            |      |
    1.37 +//           File6 Dir4----Hidden---HiddenFile       
    1.38 +//                   |      /  \
    1.39 +//                 File7 File8 System
    1.40 +//                              |
    1.41 +//                             File9
    1.42 +*/
    1.43 +	{
    1.44 +
    1.45 +	MakeDir(_L("\\F32-TST\\SCANTEST\\Empty\\"));
    1.46 +
    1.47 +	MakeFile(_L("\\F32-TST\\SCANTEST\\File1"));
    1.48 +	MakeFile(_L("\\F32-TST\\SCANTEST\\File2"));
    1.49 +	MakeFile(_L("\\F32-TST\\SCANTEST\\File3"));
    1.50 +	
    1.51 +	MakeFile(_L("\\F32-TST\\SCANTEST\\Right\\File4"));
    1.52 +	MakeFile(_L("\\F32-TST\\SCANTEST\\Right\\File5"));
    1.53 +
    1.54 +	MakeFile(_L("\\F32-TST\\SCANTEST\\Left\\Dir2\\File6"));
    1.55 +	MakeFile(_L("\\F32-TST\\SCANTEST\\Left\\Dir3\\Dir4\\File7"));
    1.56 +
    1.57 +	MakeFile(_L("\\F32-TST\\SCANTEST\\Left\\Dir3\\Dir4\\Hidden\\File8"));
    1.58 +	MakeFile(_L("\\F32-TST\\SCANTEST\\Left\\Dir3\\Dir4\\Hidden\\HiddenFile"));
    1.59 +	MakeFile(_L("\\F32-TST\\SCANTEST\\Left\\Dir3\\Dir4\\Hidden\\System\\File9"));
    1.60 +
    1.61 +	TInt r;
    1.62 +	r=TheFs.SetAtt(_L("\\F32-TST\\SCANTEST\\Left\\Dir3\\Dir4\\Hidden"), KEntryAttHidden, 0);
    1.63 +	test(r==KErrNone);
    1.64 +	r=TheFs.SetAtt(_L("\\F32-TST\\SCANTEST\\Left\\Dir3\\Dir4\\Hidden\\HiddenFile"), KEntryAttHidden, 0);
    1.65 +	test(r==KErrNone);
    1.66 +	r=TheFs.SetAtt(_L("\\F32-TST\\SCANTEST\\Left\\Dir3\\Dir4\\Hidden\\System"), KEntryAttSystem, 0);
    1.67 +	test(r==KErrNone);
    1.68 +	}
    1.69 +
    1.70 +LOCAL_C void Test1()
    1.71 +//
    1.72 +// Test all methods
    1.73 +//
    1.74 +	{
    1.75 +	
    1.76 +	test.Next(_L("Create scanner"));
    1.77 +	CDirScan* scanner=CDirScan::NewL(TheFs);
    1.78 +	TParse dirName;
    1.79 +	TheFs.Parse(_L("\\F32-TST\\SCANTEST\\"),dirName);
    1.80 +	scanner->SetScanDataL(dirName.FullName(),KEntryAttDir,ESortByName);
    1.81 +	CDir* entryList;
    1.82 +//
    1.83 +	test.Next(_L("Scan top level directory"));
    1.84 +	scanner->NextL(entryList);
    1.85 +	TInt count=entryList->Count();
    1.86 +	test(count==6);
    1.87 +	TEntry entry=(*entryList)[0];
    1.88 +	test(entry.iName==_L("Empty"));
    1.89 +	entry=(*entryList)[1];
    1.90 +	test(entry.iName==_L("File1"));
    1.91 +	entry=(*entryList)[2];
    1.92 +	test(entry.iName==_L("File2"));
    1.93 +	entry=(*entryList)[3];
    1.94 +	test(entry.iName==_L("File3"));
    1.95 +	entry=(*entryList)[4];
    1.96 +	test(entry.iName==_L("Left"));
    1.97 +	entry=(*entryList)[5];
    1.98 +	test(entry.iName==_L("Right"));
    1.99 +	delete entryList;
   1.100 +//
   1.101 +	test.Next(_L("Reset scanner"));
   1.102 +	scanner->SetScanDataL(dirName.FullName(),KEntryAttDir,ESortByName);
   1.103 +//
   1.104 +	test.Next(_L("Scan ascending: ScanTest directory"));
   1.105 +	scanner->NextL(entryList);
   1.106 +	count=entryList->Count();
   1.107 +	test(count==6);
   1.108 +	entry=(*entryList)[0];
   1.109 +	test(entry.iName==_L("Empty"));
   1.110 +	entry=(*entryList)[1];
   1.111 +	test(entry.iName==_L("File1"));
   1.112 +	entry=(*entryList)[2];
   1.113 +	test(entry.iName==_L("File2"));
   1.114 +	entry=(*entryList)[3];
   1.115 +	test(entry.iName==_L("File3"));
   1.116 +	entry=(*entryList)[4];
   1.117 +	test(entry.iName==_L("Left"));
   1.118 +	entry=(*entryList)[5];
   1.119 +	test(entry.iName==_L("Right"));
   1.120 +	delete entryList;
   1.121 +//
   1.122 +	test.Next(_L("Check next directory: Empty"));
   1.123 +	scanner->NextL(entryList);
   1.124 +	count=entryList->Count();
   1.125 +	test(count==0);
   1.126 +	delete entryList;
   1.127 +//
   1.128 +	test.Next(_L("Check next directory: Left"));
   1.129 +	scanner->NextL(entryList);
   1.130 +	count=entryList->Count();
   1.131 +	test(count==2);
   1.132 +	entry=(*entryList)[0];
   1.133 +	test(entry.iName==_L("Dir2"));
   1.134 +	entry=(*entryList)[1];
   1.135 +	test(entry.iName==_L("Dir3"));
   1.136 +	delete entryList;
   1.137 +//
   1.138 +	test.Next(_L("Check next directory: Left\\Dir2"));
   1.139 +	scanner->NextL(entryList);
   1.140 +	count=entryList->Count();
   1.141 +	test(count==1);
   1.142 +	entry=(*entryList)[0];
   1.143 +	//test(entry.iName==_L("File6"));
   1.144 +	delete entryList;
   1.145 +//
   1.146 +	test.Next(_L("Check next directory: Left\\Dir3"));
   1.147 +	scanner->NextL(entryList);
   1.148 +	count=entryList->Count();
   1.149 +	test(count==1);
   1.150 +	entry=(*entryList)[0];
   1.151 +	test(entry.iName==_L("Dir4"));
   1.152 +	delete entryList;
   1.153 +//
   1.154 +	test.Next(_L("Check next directory: Left\\Dir3\\Dir4"));
   1.155 +	scanner->NextL(entryList);
   1.156 +	count=entryList->Count();
   1.157 +	test(count==1);
   1.158 +	entry=(*entryList)[0];
   1.159 +	test(entry.iName==_L("File7"));
   1.160 +	delete entryList;
   1.161 +//
   1.162 +	test.Next(_L("Check next directory: Right"));
   1.163 +	scanner->NextL(entryList);
   1.164 +	count=entryList->Count();
   1.165 +	test(count==2);
   1.166 +	entry=(*entryList)[0];
   1.167 +	test(entry.iName==_L("File4"));
   1.168 +	entry=(*entryList)[1];
   1.169 +	test(entry.iName==_L("File5"));
   1.170 +	delete entryList;
   1.171 +//
   1.172 +	test.Next(_L("End of scan"));
   1.173 +	scanner->NextL(entryList);
   1.174 +	test(entryList==NULL);
   1.175 +	delete entryList;
   1.176 +	delete scanner;
   1.177 +	}	
   1.178 +
   1.179 +LOCAL_C void Test2()
   1.180 +//
   1.181 +// Scan subset of test directory structure and test abs/rel paths
   1.182 +//
   1.183 +	{
   1.184 +
   1.185 +	test.Next(_L("Scan descending: ScanTest\\Left "));
   1.186 +	CDirScan* scanner=CDirScan::NewL(TheFs);
   1.187 +	TParse dirName;
   1.188 +	TheFs.Parse(_L("\\F32-TST\\SCANTEST\\LEFT\\"),dirName);
   1.189 +	scanner->SetScanDataL(dirName.FullName(),KEntryAttNormal,ESortByName|EDescending);
   1.190 +//
   1.191 +	test.Next(_L("Check next directory: Left"));
   1.192 +	CDir* entryList;
   1.193 +	scanner->NextL(entryList);
   1.194 +	TInt count=entryList->Count();
   1.195 +	test(count==0);
   1.196 +	test(scanner->AbbreviatedPath()==_L("\\"));
   1.197 +	TheFs.Parse(_L("\\F32-TST\\SCANTEST\\LEFT\\"),dirName);
   1.198 +	test(scanner->FullPath()==dirName.FullName());
   1.199 +	delete entryList;
   1.200 +//
   1.201 +	test.Next(_L("Check next directory: Left\\Dir3"));
   1.202 +	scanner->NextL(entryList);
   1.203 +	count=entryList->Count();
   1.204 +	test(count==0);
   1.205 +	test(scanner->AbbreviatedPath()==_L("\\Dir3\\"));
   1.206 +	TheFs.Parse(_L("\\F32-TST\\SCANTEST\\LEFT\\Dir3\\"),dirName);
   1.207 +	test(scanner->FullPath()==dirName.FullName());
   1.208 +	delete entryList;
   1.209 +//
   1.210 +	test.Next(_L("Check next directory: Left\\Dir3\\Dir4"));
   1.211 +	scanner->NextL(entryList);
   1.212 +	count=entryList->Count();
   1.213 +	test(count==1);
   1.214 +	test((*entryList)[0].iName==_L("File7"));
   1.215 +	test(scanner->AbbreviatedPath()==_L("\\Dir3\\Dir4\\"));
   1.216 +	TheFs.Parse(_L("\\F32-TST\\SCANTEST\\LEFT\\Dir3\\Dir4\\"),dirName);
   1.217 +	test(scanner->FullPath()==dirName.FullName());
   1.218 +	delete entryList;
   1.219 +//
   1.220 +	test.Next(_L("Check next directory: Left\\Dir2"));
   1.221 +	scanner->NextL(entryList);
   1.222 +	count=entryList->Count();
   1.223 +	test(count==1);
   1.224 +	test((*entryList)[0].iName==_L("File6"));
   1.225 +	test(scanner->AbbreviatedPath()==_L("\\Dir2\\"));
   1.226 +	TheFs.Parse(_L("\\F32-TST\\SCANTEST\\LEFT\\Dir2\\"),dirName);
   1.227 +	test(scanner->FullPath()==dirName.FullName());
   1.228 +	delete entryList;
   1.229 +	delete scanner;
   1.230 +	}
   1.231 +
   1.232 +LOCAL_C void Test3()
   1.233 +//
   1.234 +// Print directory structure
   1.235 +//
   1.236 +	{
   1.237 +
   1.238 +	test.Next(_L("List directory structure"));
   1.239 +	TheFs.SetAllocFailure(gAllocFailOff);
   1.240 +	TFileName sessionPath;
   1.241 +	TInt r=TheFs.SessionPath(sessionPath);
   1.242 +	test(r==KErrNone);
   1.243 +	r=TheFs.SetSessionPath(_L("N:\\"));
   1.244 +	test(r==KErrNone);
   1.245 +	TAutoClose<RFs> fs;
   1.246 +	r=fs.iObj.Connect();
   1.247 +	test(r==KErrNone);
   1.248 +	CDirScan* scanner=CDirScan::NewL(fs.iObj);
   1.249 +	TParse dirName;
   1.250 +	TheFs.Parse(sessionPath,dirName);
   1.251 +	scanner->SetScanDataL(dirName.FullName(),KEntryAttDir,ESortByName);
   1.252 +	CDir* entryList;
   1.253 +	FOREVER
   1.254 +		{
   1.255 +		scanner->NextL(entryList);
   1.256 +		if (entryList==NULL)
   1.257 +			break;
   1.258 +		TInt count=entryList->Count();
   1.259 +		while (count--)
   1.260 +			{
   1.261 +			TEntry data=(*entryList)[count];
   1.262 +			TBuf<KMaxFileName> path=scanner->AbbreviatedPath();
   1.263 +			test.Printf(_L("%S%S\n"),&path,&data.iName);
   1.264 +			}
   1.265 +		delete entryList;
   1.266 +		entryList=NULL;
   1.267 +		}
   1.268 +	delete scanner;
   1.269 +	r=TheFs.SetSessionPath(sessionPath);
   1.270 +	test(r==KErrNone);
   1.271 +	TheFs.SetAllocFailure(gAllocFailOn);
   1.272 +	}
   1.273 +
   1.274 +LOCAL_C void Test4()
   1.275 +//
   1.276 +// Scan for a matching filename
   1.277 +//
   1.278 +	{
   1.279 +
   1.280 +	test.Start(_L("Scan for a matching filename"));
   1.281 +	MakeFile(_L("\\F32-TST\\SCANTEST\\MaTCHteST.EXTENSION"));
   1.282 +	MakeFile(_L("\\F32-TST\\SCANTEST\\MATCH.EXT"));
   1.283 +	MakeFile(_L("\\F32-TST\\SCANTEST\\LEFT\\DIR3\\ANOTherteST.EXTENSION"));
   1.284 +	MakeFile(_L("\\F32-TST\\SCANTEST\\LEFT\\DIR3\\APPDLL.DLL"));
   1.285 +	MakeFile(_L("\\F32-TST\\SCANTEST\\LEFT\\DIR3\\TEST.EXTENSION"));
   1.286 +	MakeFile(_L("\\F32-TST\\SCANTEST\\LEFT\\DIR3\\DIR4\\MaTCHteST.EXTENSION"));
   1.287 +
   1.288 +	CDir* entryList;
   1.289 +	CDirScan* scanner=CDirScan::NewL(TheFs);
   1.290 +	TParse dirName;
   1.291 +
   1.292 +	test.Next(_L("Scan for MAT??.EXT")); // can't test for MAT*.EXT because shortname of MaTCHteST.EXTENSION
   1.293 +	TheFs.Parse(_L("\\F32-TST\\SCANTEST\\MAT??.EXT"),dirName); // is MATCHT~1.EXT !!!
   1.294 +	scanner->SetScanDataL(dirName.FullName(),KEntryAttNormal,ESortByName);
   1.295 +	scanner->NextL(entryList);
   1.296 +	test((TInt)entryList);
   1.297 +	test(entryList->Count()==1);
   1.298 +	test((*entryList)[0].iName.MatchF(_L("MATCH.EXT"))!=KErrNotFound);
   1.299 +	test(scanner->AbbreviatedPath()==_L("\\"));
   1.300 +	TheFs.Parse(_L("\\F32-TST\\SCANTEST\\"),dirName);
   1.301 +	test(scanner->FullPath()==dirName.FullName());
   1.302 +	delete entryList;
   1.303 +	FOREVER
   1.304 +		{
   1.305 +		scanner->NextL(entryList);
   1.306 +		if (entryList==NULL)
   1.307 +			break;
   1.308 +		test(entryList->Count()==0);
   1.309 +		delete entryList;
   1.310 +		}
   1.311 +
   1.312 +	test.Next(_L("Scan for *.EXTENSION"));
   1.313 +	TheFs.Parse(_L("\\F32-TST\\SCANTEST\\*.EXTENSION"),dirName);
   1.314 +	scanner->SetScanDataL(dirName.FullName(),KEntryAttNormal,ESortByName);
   1.315 +	scanner->NextL(entryList);
   1.316 +	test((TInt)entryList);
   1.317 +	test(entryList->Count()==1);
   1.318 +	test((*entryList)[0].iName.MatchF(_L("MATCHTEST.EXTENSION"))!=KErrNotFound);
   1.319 +	test(scanner->AbbreviatedPath()==_L("\\"));
   1.320 +	TheFs.Parse(_L("\\F32-TST\\SCANTEST\\"),dirName);
   1.321 +	test(scanner->FullPath()==dirName.FullName());
   1.322 +	do {
   1.323 +		delete entryList;
   1.324 +		scanner->NextL(entryList);
   1.325 +		test((TInt)entryList);
   1.326 +		} while (entryList->Count()==0);
   1.327 +	test(entryList->Count()==2);
   1.328 +	test((*entryList)[0].iName.MatchF(_L("ANOTHERTEST.EXTENSION"))!=KErrNotFound);
   1.329 +	test((*entryList)[1].iName.MatchF(_L("test.EXTENSION"))!=KErrNotFound);
   1.330 +	test(scanner->AbbreviatedPath().MatchF(_L("\\LEFT\\DIR3\\"))!=KErrNotFound);
   1.331 +	TheFs.Parse(_L("\\F32-TST\\SCANTEST\\LEFT\\DIR3\\"),dirName);
   1.332 +	test(scanner->FullPath().MatchF(dirName.FullName())!=KErrNotFound);
   1.333 +	do {
   1.334 +		delete entryList;
   1.335 +		scanner->NextL(entryList);
   1.336 +		test((TInt)entryList);
   1.337 +		} while (entryList->Count()==0);
   1.338 +	test(entryList->Count()==1);
   1.339 +	test((*entryList)[0].iName.MatchF(_L("MATCHTEST.EXTENSION"))!=KErrNotFound);
   1.340 +	test(scanner->AbbreviatedPath().MatchF(_L("\\LEFT\\DIR3\\DIR4\\"))!=KErrNotFound);
   1.341 +	TheFs.Parse(_L("\\F32-TST\\SCANTEST\\LEFT\\DIR3\\DIR4\\"),dirName);
   1.342 +	test(scanner->FullPath().MatchF(dirName.FullName())!=KErrNotFound);
   1.343 +	delete entryList;
   1.344 +	FOREVER
   1.345 +		{
   1.346 +		scanner->NextL(entryList);
   1.347 +		if (entryList==NULL)
   1.348 +			break;
   1.349 +		test(entryList->Count()==0);
   1.350 +		delete entryList;
   1.351 +		}
   1.352 +
   1.353 +	test.Next(_L("Scan for APPDLL.DLL"));
   1.354 +	TheFs.Parse(_L("\\F32-TST\\SCANTEST\\APPDLL.DLL"),dirName);
   1.355 +	scanner->SetScanDataL(dirName.FullName(),KEntryAttNormal,ESortByName);
   1.356 +	FOREVER
   1.357 +		{
   1.358 +		scanner->NextL(entryList);
   1.359 +		if (entryList->Count()!=0)
   1.360 +			break;
   1.361 +		test((TInt)entryList);
   1.362 +		delete entryList;
   1.363 +		}
   1.364 +	test(entryList->Count()==1);
   1.365 +	test((*entryList)[0].iName==_L("APPDLL.DLL"));
   1.366 +	test(scanner->AbbreviatedPath().MatchF(_L("\\LEFT\\DIR3\\"))!=KErrNotFound);
   1.367 +	TheFs.Parse(_L("\\F32-TST\\SCANTEST\\LEFT\\DIR3\\"),dirName);
   1.368 +	test(scanner->FullPath().MatchF(dirName.FullName())!=KErrNotFound);
   1.369 +	delete entryList;
   1.370 +	FOREVER
   1.371 +		{
   1.372 +		scanner->NextL(entryList);
   1.373 +		if (entryList==NULL)
   1.374 +			break;
   1.375 +		test(entryList->Count()==0);
   1.376 +		delete entryList;
   1.377 +		}
   1.378 +	delete scanner;
   1.379 +	test.End();
   1.380 +	}		
   1.381 +
   1.382 +LOCAL_C void Test5()
   1.383 +//
   1.384 +// Do a scan of Z:
   1.385 +//
   1.386 +	{
   1.387 +
   1.388 +	test.Next(_L("List Z: directory structure"));
   1.389 +	CDirScan* scanner=CDirScan::NewLC(TheFs);
   1.390 +	TPtrC romPath(_L("Z:\\"));
   1.391 +	TParse dirName;
   1.392 +	TInt r=TheFs.Parse(romPath,dirName);
   1.393 +	test(r==KErrNone);
   1.394 +	scanner->SetScanDataL(dirName.FullName(),KEntryAttDir,ESortByName);
   1.395 +	CDir* entryList;
   1.396 +	FOREVER
   1.397 +		{
   1.398 +		scanner->NextL(entryList);
   1.399 +		if (entryList==NULL)
   1.400 +			break;
   1.401 +		TInt count=entryList->Count();
   1.402 +		while (count--)
   1.403 +			{
   1.404 +			TEntry data=(*entryList)[count];
   1.405 +			TBuf<KMaxFileName> path=scanner->AbbreviatedPath();
   1.406 +			test.Printf(_L("%S%S\n"),&path,&data.iName);
   1.407 +			}
   1.408 +		delete entryList;
   1.409 +		entryList=NULL;
   1.410 +		}
   1.411 +	CleanupStack::PopAndDestroy();
   1.412 +	}
   1.413 +
   1.414 +LOCAL_C void Test6()
   1.415 +//
   1.416 +// Scan up a directory tree
   1.417 +//
   1.418 +	{
   1.419 +
   1.420 +	test.Next(_L("Test ascending scan"));
   1.421 +	MakeFile(_L("\\F32-TST\\SCANTEST\\MaTCHteST.EXTENSION"));
   1.422 +	MakeFile(_L("\\F32-TST\\SCANTEST\\MATCH.EXT"));
   1.423 +	MakeFile(_L("\\F32-TST\\SCANTEST\\LEFT\\DIR3\\ANOTherteST.EXTENSION"));
   1.424 +	MakeFile(_L("\\F32-TST\\SCANTEST\\LEFT\\DIR3\\APPDLL.DLL"));
   1.425 +	MakeFile(_L("\\F32-TST\\SCANTEST\\LEFT\\DIR3\\TEST.EXTENSION"));
   1.426 +	MakeFile(_L("\\F32-TST\\SCANTEST\\LEFT\\DIR3\\DIR4\\MaTCHteST.EXTENSION"));
   1.427 +	
   1.428 +	CDir* entryList;
   1.429 +	CDirScan* scanner=CDirScan::NewL(TheFs);
   1.430 +	TParse dirName;
   1.431 +
   1.432 +	test.Next(_L("Scan for MAT*.EXT"));
   1.433 +	TheFs.Parse(_L("\\F32-TST\\SCANTEST\\"),dirName);
   1.434 +//	TheFs.Parse(_L("\\F32-TST\\SCANTEST\\LEFT\\DIR3\\DIR4\\MaTCHteST.EXTENSION"),dirName);
   1.435 +//	scanner->SetScanDataL(dirName.FullName(),KEntryAttNormal,ESortByName,CDirScan::EScanUpTree);
   1.436 +	scanner->SetScanDataL(dirName.FullName(),KEntryAttDir,ESortByName,CDirScan::EScanUpTree);
   1.437 +	
   1.438 +	FOREVER
   1.439 +		{
   1.440 +		scanner->NextL(entryList);
   1.441 +		if (entryList==NULL)
   1.442 +			break;
   1.443 +		TInt count=entryList->Count();
   1.444 +		while(count--)
   1.445 +			{
   1.446 +			TEntry entry=(*entryList)[count];
   1.447 +			test.Printf(_L("entry.iName = %S\n"),&entry.iName);
   1.448 +		//	test(entry.iName==_L("MATCH.EXT"));
   1.449 +			}
   1.450 +		delete entryList;
   1.451 +		}
   1.452 +	
   1.453 +	delete scanner;
   1.454 +	}
   1.455 +
   1.456 +
   1.457 +LOCAL_C void Test7()
   1.458 +//
   1.459 +// Test scanning hidden directories
   1.460 +//
   1.461 +	{
   1.462 +
   1.463 +	CDir* entryList;
   1.464 +	CDirScan* scanner=CDirScan::NewL(TheFs);
   1.465 +	TParse dirName;
   1.466 +
   1.467 +	test.Next(_L("Scan in hidden directories for files"));
   1.468 +	TheFs.Parse(_L("\\F32-TST\\SCANTEST\\LEFT\\DIR3\\*"),dirName);
   1.469 +	scanner->SetScanDataL(dirName.FullName(),KEntryAttHidden,ESortByName,CDirScan::EScanDownTree);
   1.470 +	
   1.471 +	TInt hiddenCount=0;
   1.472 +	FOREVER
   1.473 +		{
   1.474 +		scanner->NextL(entryList);
   1.475 +		if (entryList==NULL)
   1.476 +			break;
   1.477 +		TInt count=entryList->Count();
   1.478 +		while(count--)
   1.479 +			{
   1.480 +			TEntry entry=(*entryList)[count];
   1.481 +			test.Printf(_L("entry.iName = %S\n"),&entry.iName);
   1.482 +			if (entry.IsHidden())
   1.483 +				hiddenCount++;
   1.484 +			if (entry.iName==_L("File8"))
   1.485 +				hiddenCount++;
   1.486 +			}
   1.487 +		delete entryList;
   1.488 +		}
   1.489 +	test(hiddenCount==2);
   1.490 +
   1.491 +	test.Next(_L("Scan for system and hidden directories and files"));
   1.492 +	TheFs.Parse(_L("\\F32-TST\\SCANTEST\\LEFT\\DIR3\\*"),dirName);
   1.493 +	scanner->SetScanDataL(dirName.FullName(),KEntryAttSystem|KEntryAttHidden|KEntryAttDir,ESortByName,CDirScan::EScanDownTree);
   1.494 +
   1.495 +	hiddenCount=0;
   1.496 +	FOREVER
   1.497 +		{
   1.498 +		scanner->NextL(entryList);
   1.499 +		if (entryList==NULL)
   1.500 +			break;
   1.501 +		TInt count=entryList->Count();
   1.502 +		while(count--)
   1.503 +			{
   1.504 +			TEntry entry=(*entryList)[count];
   1.505 +			test.Printf(_L("entry.iName = %S\n"),&entry.iName);
   1.506 +			if (entry.IsHidden())
   1.507 +				hiddenCount++;
   1.508 +			if (entry.iName==_L("File8"))
   1.509 +				hiddenCount++;
   1.510 +			if (entry.IsSystem())
   1.511 +				hiddenCount++;
   1.512 +			if (entry.iName==_L("File9"))
   1.513 +				hiddenCount++;
   1.514 +			}
   1.515 +		delete entryList;
   1.516 +		}
   1.517 +	test(hiddenCount==5);
   1.518 +	
   1.519 +	delete scanner;
   1.520 +	}
   1.521 +
   1.522 +GLDEF_C void CallTestsL()
   1.523 +//
   1.524 +// Call all tests
   1.525 +//
   1.526 +	{
   1.527 +
   1.528 +	CreateTestDirectory(_L("\\F32-TST\\SCANTEST\\"));
   1.529 +	DeleteTestDirectory();
   1.530 +	BuildTestDir();
   1.531 +	Test1();
   1.532 +	Test2();
   1.533 +	Test3();
   1.534 +	Test4();
   1.535 +	Test5();
   1.536 +	DeleteTestDirectory();
   1.537 +	Test6();
   1.538 +	DeleteTestDirectory();
   1.539 +
   1.540 +	BuildTestDir();
   1.541 +	Test7();
   1.542 +	DeleteTestDirectory();
   1.543 +	}