os/kernelhwsrv/kerneltest/f32test/server/t_locate.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of the License "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 // f32test\server\t_locate.cpp
    15 // 
    16 //
    17 #define __E32TEST_EXTENSION__
    18 #include <f32file.h>
    19 #include <e32test.h>
    20 #include "t_server.h"
    21 
    22 
    23 
    24 GLDEF_D RTest test(_L("T_LOCATE"));
    25 
    26 LOCAL_D TFileName gPath1;
    27 LOCAL_D TFileName gPath2;
    28 LOCAL_D TFileName gPath3;
    29 LOCAL_D TFileName gPath4;
    30 LOCAL_D TFileName gPath5;
    31 
    32 
    33 LOCAL_D TFileName gRemovableDriveFile;
    34 LOCAL_D TFileName gInternalDriveFile;
    35 LOCAL_D TFileName gInternalDriveFile2;
    36 
    37 
    38 LOCAL_D TChar removableDriveLetter;  
    39 LOCAL_D TChar internalDriveLetter; 
    40 
    41 
    42 LOCAL_D TInt removableFlag=0;
    43 LOCAL_D TInt internalFlag=0;
    44 
    45 
    46 
    47 LOCAL_C void Md(const TDesC& aDirName)
    48 //
    49 // Make a dir
    50 //
    51 	{
    52 
    53 	TInt r=TheFs.MkDirAll(aDirName);
    54 	if (r == KErrCorrupt)
    55 		test.Printf(_L("Media corruption; previous test may have aborted; else, check hardware\n"));
    56 	else if (r == KErrNotReady)
    57 		test.Printf(_L("No medium present / drive not ready, previous test may have hung; else, check hardware\n"));
    58 	test_Value(r, r == KErrNone || r == KErrAlreadyExists);
    59 	}
    60 
    61 LOCAL_C void Mf(const TDesC& aFileName)
    62 //
    63 // Make a file
    64 //
    65 	{
    66 
    67 	RFile file;
    68 	TInt r = file.Replace(TheFs,aFileName,0);
    69 	if (r == KErrPathNotFound)
    70 		{
    71 		test.Printf(_L("Mf: Path Not Found\n"));
    72 		Md(aFileName);
    73 		r=file.Replace(TheFs,aFileName,0);
    74 		}
    75 
    76 	if (r == KErrCorrupt)
    77 		test.Printf(_L("Media corruption; previous test may have aborted; else, check hardware\n"));
    78 	else if (r == KErrNotReady)
    79 		test.Printf(_L("No medium present / drive not ready, previous test may have hung; else, check hardware\n"));
    80 
    81 	test_Value(r, r == KErrNone || r == KErrAlreadyExists);
    82 	file.Close();
    83 	}
    84 
    85 LOCAL_C void MakeLocateTestDirectoryStructure()
    86 //
    87 // Create files for test
    88 //
    89 	{
    90 	test.Next(_L("Create LOCTEST directories"));
    91 	Md(_L("\\F32-TST\\LOCTEST\\BIN1\\"));
    92 	Md(_L("\\F32-TST\\LOCTEST\\BIN2\\"));
    93 	Md(_L("\\F32-TST\\LOCTEST\\BIN3\\"));
    94 	Md(_L("\\F32-TST\\LOCTEST\\BIN1\\BIN4\\"));
    95 		
    96 	
    97 	
    98 #if defined(_DEBUG)
    99 	TheFs.SetErrorCondition(-47,5);
   100 	TDriveInfo drive;
   101 	for (TInt i=0;i<5;i++)
   102 		{
   103 		TInt r=TheFs.Drive(drive);
   104 		test(r==KErrNone);
   105 		}
   106 	TInt r=TheFs.MkDirAll(_L("alskdjfl"));
   107 	test(r==-47);
   108 	r=TheFs.MkDirAll(_L("alskdjfl"));
   109 	test(r==-47);
   110 	TheFs.SetErrorCondition(KErrNone);
   111 	r=TheFs.Drive(drive);
   112 	test(r==KErrNone);
   113 #endif
   114 //
   115 	test.Next(_L("Create LOCTEST files"));
   116 	Mf(_L("\\F32-TST\\LOCTEST\\FILE1.AAA"));
   117 	Mf(_L("\\F32-TST\\LOCTEST\\FILE2.BBB"));
   118 	Mf(_L("\\F32-TST\\LOCTEST\\FILE3.CCC"));
   119 	Mf(_L("\\F32-TST\\LOCTEST\\WORK.AAA"));
   120 	Mf(_L("\\F32-TST\\LOCTEST\\HOME.CCC"));
   121 	Mf(_L("\\F32-TST\\LOCTEST\\FILE.AAA"));
   122 	Mf(_L("C:\\F32-TST\\LOCTEST\\BIN1\\FILE1.AAA"));
   123 	Mf(_L("C:\\F32-TST\\LOCTEST\\BIN1\\WORK.AAA"));
   124 	Mf(_L("C:\\F32-TST\\LOCTEST\\BIN1\\WORK.BBB"));
   125 	Mf(_L("\\F32-TST\\LOCTEST\\BIN1\\FILE1.AAA"));
   126 	Mf(_L("\\F32-TST\\LOCTEST\\BIN1\\WORK.AAA"));
   127 	Mf(_L("\\F32-TST\\LOCTEST\\BIN1\\WORK.BBB"));
   128 	Mf(_L("\\F32-TST\\LOCTEST\\BIN1\\CONFUSED.DOG"));
   129 	Mf(_L("\\F32-TST\\LOCTEST\\BIN2\\FILE1.BBB"));
   130 	Mf(_L("\\F32-TST\\LOCTEST\\BIN2\\WORK.BBB"));
   131 	Mf(_L("\\F32-TST\\LOCTEST\\BIN2\\FILE2.BBB"));
   132 	Mf(_L("\\F32-TST\\LOCTEST\\BIN2\\FILE3.BBB"));
   133 	Mf(_L("\\F32-TST\\LOCTEST\\BIN3\\FILE3.CCC"));
   134 	Mf(_L("\\F32-TST\\LOCTEST\\BIN3\\WORK.CCC"));
   135 	Mf(_L("\\F32-TST\\LOCTEST\\BIN3\\PLAY.CCC"));
   136 	Mf(_L("\\F32-TST\\LOCTEST\\BIN1\\BIN4\\FILE1.AAA"));
   137 	Mf(_L("\\F32-TST\\LOCTEST\\BIN1\\BIN4\\FILE2.BBB"));
   138 	Mf(_L("\\F32-TST\\LOCTEST\\BIN1\\BIN4\\FILE3.CCC"));
   139 	Mf(_L("\\F32-TST\\LOCTEST\\BIN1\\BIN4\\FILE4.DDD"));
   140 	
   141 	
   142 	
   143 	}
   144 	
   145 
   146 LOCAL_C void CreateFilesInRemovableDrive()	
   147 	{
   148 	
   149 
   150     TInt err;
   151     TDriveList driveList;
   152     TDriveInfo info;
   153 
   154 	 err = TheFs.DriveList(driveList);
   155     test( err == KErrNone );
   156     
   157     for (TInt i = 0; i < KMaxDrives; i++) 
   158         {
   159         
   160         if (driveList[i]) 
   161             {
   162             err = TheFs.Drive(info, i);
   163             test( err == KErrNone ); 
   164                         
   165             if( info.iDriveAtt  & KDriveAttRemovable )  
   166             	{
   167 								
   168 				if ( ( info.iType != EMediaNotPresent) && (info.iType != EMediaUnknown) && (info.iType != EMediaCdRom) )
   169 					{
   170 					TheFs.DriveToChar(i,removableDriveLetter) ;
   171 					gRemovableDriveFile.Append (removableDriveLetter);
   172 					gRemovableDriveFile.Append (_L(":\\F32-TST\\LOCTEST\\BIN\\FINDFILE.AAA") );
   173 
   174 					Mf(gRemovableDriveFile);
   175 					removableFlag=1;
   176 					break;
   177 					}
   178 				else 
   179 					continue;
   180       				
   181  
   182             	}
   183            				
   184             
   185             }
   186     
   187         }
   188 
   189 	}
   190 	
   191 	
   192 
   193 LOCAL_C void CreateFilesInInternalDrive()	
   194 	{
   195 	
   196     TInt err;
   197     TDriveList driveList;
   198     TDriveInfo info;
   199 
   200 	 err = TheFs.DriveList(driveList);
   201     test( err == KErrNone );
   202     
   203     for (TInt i = 0; i < KMaxDrives; i++) 
   204         {
   205         
   206         if (driveList[i]) 
   207             {
   208             err = TheFs.Drive(info, i);
   209             test( err == KErrNone ); 
   210                         
   211             if( info.iDriveAtt  & KDriveAttInternal  ) 
   212             	{			
   213 				
   214 				TheFs.DriveToChar(i,internalDriveLetter) ;
   215 				gInternalDriveFile.Append (internalDriveLetter);
   216 				gInternalDriveFile.Append (_L(":\\F32-TST\\LOCTEST\\BIN\\INT\\FINDINTERNALFILE.AAA") );
   217 				
   218 				gInternalDriveFile2.Append (internalDriveLetter);
   219 				gInternalDriveFile2.Append (_L(":\\F32-TST\\LOCTEST\\BIN\\INT\\FINDINTERNALFILE_B.AAA") );
   220 				
   221 				Mf(gInternalDriveFile);
   222 				Mf(gInternalDriveFile2);
   223 				internalFlag=1;	
   224  				
   225             	break;
   226             	}
   227             
   228             }
   229     
   230         }
   231 	
   232 	
   233 	}
   234 	
   235 
   236 
   237 
   238 LOCAL_C void DeleteRemovableDirectory()
   239 	{	
   240 
   241 	//Delete the directory structure we created in the removalbe drive	
   242 	if ( removableFlag == 1 )
   243 		{
   244 		CFileMan* fMan=CFileMan::NewL(TheFs);
   245 		test(fMan!=NULL);
   246 	
   247 		TFileName gPathRem;
   248 		gPathRem.Append (removableDriveLetter);
   249 		gPathRem.Append (_L(":\\F32-TST\\") );
   250 		TInt r=fMan->RmDir(gPathRem);
   251 		test(r==KErrNone);
   252 	
   253 		delete fMan;
   254 		}
   255 	}
   256 
   257 LOCAL_C void DeleteInternalDirectory()
   258 	{	
   259 
   260 	//Delete the directory structure we created in the internal drive		
   261 
   262 
   263 	if( internalFlag == 1 )
   264 		{
   265 		CFileMan* fMan=CFileMan::NewL(TheFs);
   266 		test(fMan!=NULL);
   267 	
   268 		TFileName gPathInt;
   269 		gPathInt.Append (internalDriveLetter);
   270 		gPathInt.Append (_L(":\\F32-TST\\") );
   271 		TInt r=fMan->RmDir(gPathInt);
   272 		test(r==KErrNone);
   273 	
   274 		delete fMan;
   275 		}
   276 	}
   277 
   278 	
   279 LOCAL_C void MountRemoteFilesystem()	
   280 	{
   281 		
   282   	test.Next(_L("Mount Remote Drive simulator on Q:\n"));
   283 	
   284 	
   285 	TInt r=TheFs.AddFileSystem(_L("CFAFSDLY"));
   286 	test.Printf(_L("Add remote file system\n"));
   287 	test.Printf(_L("AddFileSystem returned %d\n"),r);
   288 	test (r==KErrNone || r==KErrAlreadyExists);
   289 
   290 
   291 	r=TheFs.MountFileSystem(_L("DELAYFS"),EDriveQ);
   292 
   293 	
   294 	test.Printf(_L("Mount remote file system\n"));
   295 	test.Printf(_L("MountFileSystem returned %d\n"),r);
   296 	test(r==KErrNone || r==KErrCorrupt || r==KErrNotReady || r==KErrAlreadyExists);
   297 
   298 	
   299 	Mf(_L("Q:\\F32-TST\\LOCTEST\\BIN\\FINDFILE.AAA"));
   300 
   301 	}
   302 	
   303 
   304 	
   305 LOCAL_C void DisMountRemoteFilesystem()	
   306 	{
   307 
   308 	test.Printf(_L("Dismounting the remote Drives \n"));
   309  	
   310  	TInt r=TheFs.DismountFileSystem(_L("DELAYFS"),EDriveQ);
   311  	 
   312  	test.Printf(_L("Dismounting the Remote Drive returned %d\n"),r);
   313  	
   314  	test(r==KErrNone );
   315 	}
   316 
   317 
   318 	
   319 
   320 LOCAL_C void Test1()
   321 //
   322 // Do simple tests
   323 //
   324 	{
   325 	test.Next(_L("Test FindByPath"));
   326 	
   327 	TAutoClose<RFs> fs;
   328 	TInt r=fs.iObj.Connect();
   329 	test(r==KErrNone);
   330 	TFindFile finder(fs.iObj);
   331 	TPtrC path=gPath1;
   332 	r=finder.FindByPath(_L("file1.aaa"),&path);
   333 	test(r==KErrNone);
   334 	TParse fileParse;
   335 	fileParse.Set(finder.File(),NULL,NULL);
   336 	test(fileParse.Path()==_L("\\F32-TST\\LOCTEST\\BIN1\\"));
   337 	test(fileParse.NameAndExt()==_L("file1.aaa"));
   338 	r=finder.Find();
   339 	test(r==KErrNotFound);
   340 
   341 
   342 	path.Set(gPath2);
   343 	r=finder.FindByPath(_L("file1.aaa"),&path);
   344 	test(r==KErrNone);
   345 	fileParse.Set(finder.File(),NULL,NULL);
   346 	test(fileParse.Path()==_L("\\F32-TST\\LOCTEST\\BIN1\\"));
   347 	test(fileParse.NameAndExt()==_L("file1.aaa"));
   348 	r=finder.Find();
   349 	test(r==KErrNone);
   350 	fileParse.Set(finder.File(),NULL,NULL);
   351 	test(fileParse.Path()==_L("\\F32-TST\\LOCTEST\\BIN1\\BIN4\\"));
   352 	test(fileParse.NameAndExt()==_L("file1.aaa"));
   353 	r=finder.Find();
   354 	test(r==KErrNotFound);
   355 //
   356 	test.Next(_L("Test FindByDir"));
   357 	TPtrC dir=_L("\\F32-TST\\LOCTEST\\BIN2\\");
   358 	r=finder.FindByDir(_L("file2.bbb"),dir);
   359 	test(r==KErrNone);
   360 	TFileName defaultPath;
   361 	r=TheFs.SessionPath(defaultPath);
   362 	defaultPath.SetLength(2);
   363 	test(r==KErrNone);
   364 	fileParse.Set(finder.File(),NULL,NULL);
   365 	test(fileParse.Drive()==defaultPath);
   366 	test(fileParse.Path()==_L("\\F32-TST\\LOCTEST\\BIN2\\"));
   367 	test(_L("file2.bbb").MatchF(fileParse.NameAndExt())!=KErrNotFound); // MatchF only sees wildcards in its argument
   368 	r=finder.Find();
   369 	if (r==KErrNone)
   370 		{
   371 		fileParse.Set(finder.File(),NULL,NULL);
   372 		if (defaultPath==_L("C:"))
   373 			test(fileParse.Drive()==_L("Y:"));
   374 		else
   375 			test(fileParse.Drive()==_L("C:"));
   376 		test(fileParse.Path()==_L("\\F32-TST\\LOCTEST\\BIN2\\"));
   377 		test(_L("file2.bbb").MatchF(fileParse.NameAndExt())!=KErrNotFound);
   378 		r=finder.Find();
   379 		}
   380 	test(r==KErrNotFound);
   381 	}
   382 
   383 LOCAL_C void Test2()
   384 //
   385 // Test extremes
   386 //
   387 	{
   388 
   389 	test.Next(_L("Test extremes"));
   390 	TAutoClose<RFs> fs;
   391 	TInt r=fs.iObj.Connect();
   392 	test(r==KErrNone);
   393 	TBuf<4> temp=_L("");
   394 	TFindFile finder(fs.iObj);
   395 	r=finder.FindByPath(_L("file1.aaa"),&temp);
   396 	test(r==KErrNotFound);
   397 	r=finder.Find();
   398 	test(r==KErrNotFound);
   399 //
   400 	TPtrC path=_L("blarg.7");
   401 	r=finder.FindByPath(_L(""),&path);	
   402 	test(r==KErrArgument);
   403 	r=finder.FindByPath(_L("*"),&path);
   404 	test(r==KErrNotFound);
   405 	r=finder.FindByPath(_L("xmvid"),&path);
   406 	test(r==KErrNotFound);
   407 	r=finder.Find();
   408 	test(r==KErrNotFound);
   409 //
   410 	path.Set(_L("C:\\F32-TST\\LOCTEST\\BIN1\\;\\F32-TST\\LOCTEST\\BIN2\\;Z:\\F32-TST\\LOCTEST\\BIN1\\BIN4\\;\\F32-TST\\LOCTEST\\BIN3\\;"));
   411 	r=finder.FindByPath(_L(""),&path);
   412 	test(r==KErrArgument);
   413 	r=finder.FindByPath(_L("xyz.abc"),&path);
   414 	test(r==KErrNotFound);
   415 	r=finder.Find();
   416 	test(r==KErrNotFound);
   417 	
   418 	test.Next(_L("Test FindByDir with empty file spec"));
   419 	TPtrC dir2=_L("\\F32-TST\\LOCTEST\\");
   420 	r=finder.FindByDir(_L(""),dir2);
   421 	test(r==KErrArgument);		
   422 	
   423 	}
   424 
   425 LOCAL_C void Test3()
   426 //
   427 // Test FindByDrives in a path=_L("c:\xyz;z:\lmnop;\abc;\y:\help");
   428 //
   429 	{
   430 
   431 	test.Next(_L("Test FindInDrivesByPath"));
   432 	TPtrC path=_L("\\F32-TST\\LOCTEST\\BIN2\\");
   433 	TFileName defaultPath;
   434 	TInt r=TheFs.SessionPath(defaultPath);
   435 	defaultPath.SetLength(2);
   436 //
   437 	TAutoClose<RFs> fs;
   438 	r=fs.iObj.Connect();
   439 	test(r==KErrNone);
   440 	TFindFile finder(fs.iObj);
   441 	r=finder.FindByPath(_L("file1.aaa"),&path);
   442 	test(r==KErrNotFound);
   443 	r=finder.Find();
   444 	test(r==KErrNotFound);
   445 //
   446 	path.Set(_L("\\F32-TST\\LOCTEST\\BIN2\\"));
   447 	r=finder.FindByPath(_L("file2.bbb"),&path);
   448 	test(r==KErrNone);
   449 	TParse fileParse;
   450 	fileParse.Set(finder.File(),NULL,NULL);
   451 	test(fileParse.Drive()==defaultPath);
   452 	test(fileParse.Path()==_L("\\F32-TST\\LOCTEST\\BIN2\\"));
   453 	test(fileParse.NameAndExt()==_L("file2.bbb"));
   454 	r=finder.Find();
   455 	test(r==KErrNotFound || r==KErrNone);
   456 	if (r==KErrNone)
   457 		{
   458 		fileParse.Set(finder.File(),NULL,NULL);
   459 		test(fileParse.Drive()!=defaultPath);
   460 		test(fileParse.Path()==_L("\\F32-TST\\LOCTEST\\BIN2\\"));
   461 		test(fileParse.NameAndExt()==_L("file2.bbb"));
   462 		r=finder.Find();
   463 		test(r==KErrNotFound);
   464 		}
   465 //
   466 	path.Set(_L("C:\\F32-TST\\LOCTEST\\BIN1\\;;\\F32-TST\\LOCTEST\\BIN2\\;Z:\\F32-TST\\LOCTEST\\BIN1\\BIN4\\;\\F32-TST\\LOCTEST\\BIN3\\;"));
   467 	r=finder.FindByPath(_L("xyz.abc"),&path);
   468 	test(r==KErrNotFound);
   469 	r=finder.Find();
   470 	test(r==KErrNotFound);
   471 //
   472 	r=finder.FindByPath(_L("file2.bbb"),&path);
   473 	test(r==KErrNone);
   474 	fileParse.Set(finder.File(),NULL,NULL);
   475 	test(fileParse.Drive()==defaultPath);
   476 	test(fileParse.Path()==_L("\\F32-TST\\LOCTEST\\BIN2\\"));
   477 	test(fileParse.NameAndExt()==_L("file2.bbb"));
   478 	r=finder.Find();
   479 	test(r==KErrNotFound || r==KErrNone);
   480 	if (r==KErrNone)
   481 		{
   482 		fileParse.Set(finder.File(),NULL,NULL);
   483 		test(fileParse.Drive()!=defaultPath);
   484 		test(fileParse.Path()==_L("\\F32-TST\\LOCTEST\\BIN2\\"));
   485 		test(fileParse.NameAndExt()==_L("file2.bbb"));
   486 		r=finder.Find();
   487 		test(r==KErrNotFound);
   488 		}
   489 	}
   490 
   491 LOCAL_C void Test4()
   492 //
   493 // Test wildcard findbypath
   494 //
   495 	{
   496 
   497 	test.Next(_L("FindByPath with wild filenames"));
   498 	TFindFile finder(TheFs);
   499 	CDir* dir;
   500 	TInt count;
   501 	TEntry entry;
   502 	TFileName path;
   503 
   504 	TInt r=finder.FindWildByPath(_L("*.aaa"),&gPath3,dir);
   505 	test(r==KErrNone);
   506 	count=dir->Count();
   507 	test(count==3);
   508 	entry=(*dir)[0];
   509 	test(entry.iName.MatchF(_L("FILE.AAA"))!=KErrNotFound);
   510 	entry=(*dir)[1];
   511 	test(entry.iName.MatchF(_L("FILE1.AAA"))!=KErrNotFound);
   512 	entry=(*dir)[2];
   513 	test(entry.iName.MatchF(_L("WORK.AAA"))!=KErrNotFound);
   514 	TParse fileParse;
   515 	fileParse.Set(finder.File(),NULL,NULL);
   516 	path=fileParse.FullName();
   517 	test(path==_L("*.aaa"));
   518 	delete dir;
   519 
   520 	r=finder.FindWild(dir);
   521 	test(r==KErrNone);
   522 	count=dir->Count();
   523 	test(count==2);
   524 	entry=(*dir)[0];
   525 	test(entry.iName.MatchF(_L("FILE1.AAA"))!=KErrNotFound);
   526 	entry=(*dir)[1];
   527 	test(entry.iName.MatchF(_L("WORK.AAA"))!=KErrNotFound);
   528 	fileParse.Set(finder.File(),NULL,NULL);
   529 	path=fileParse.FullName();
   530 	test(path==_L("C:\\F32-TST\\LOCTEST\\BIN1\\*.aaa"));
   531 	delete dir;
   532 
   533 	r=finder.FindWild(dir);
   534 	test(r==KErrNotFound);
   535 	r=finder.FindWild(dir);
   536 	test(r==KErrNotFound);
   537 
   538 	r=finder.FindWildByPath(_L("*FILE.AAA*"), &gPath1, dir);
   539 	test(r==KErrNone);
   540 	test(dir->Count()==1);
   541 	entry=(*dir)[0];
   542 	test(entry.iName.MatchF(_L("FILE.AAA"))!=KErrNotFound);
   543 	delete dir;
   544 	r=finder.FindWildByPath(_L("*FILE.AAA"), &gPath1, dir);
   545 	test(r==KErrNone);
   546 	test(dir->Count()==1);
   547 	entry=(*dir)[0];
   548 	test(entry.iName.MatchF(_L("FILE.AAA"))!=KErrNotFound);
   549 	delete dir;
   550 	r=finder.FindWildByPath(_L("FILE.AAA*"), &gPath1, dir);
   551 	test(r==KErrNone);
   552 	test(dir->Count()==1);
   553 	entry=(*dir)[0];
   554 	test(entry.iName.MatchF(_L("FILE.AAA"))!=KErrNotFound);
   555 	delete dir;
   556 	r=finder.FindWildByPath(_L("CONFUSED.DOG"), &gPath1, dir);
   557 	test(r==KErrNone);
   558 	test(dir->Count()==1);
   559 	entry=(*dir)[0];
   560 	test(entry.iName.MatchF(_L("CONFUSED.DOG"))!=KErrNotFound);
   561 	delete dir;
   562 	r=finder.FindWildByPath(_L("*CONFUSED.DOG"), &gPath1, dir);
   563 	test(r==KErrNone);
   564 	test(dir->Count()==1);
   565 	entry=(*dir)[0];
   566 	test(entry.iName.MatchF(_L("CONFUSED.DOG"))!=KErrNotFound);
   567 	delete dir;
   568 	r=finder.FindWildByPath(_L("CONFUSED.DOG*"), &gPath1, dir);
   569 	test(r==KErrNone);
   570 	test(dir->Count()==1);
   571 	entry=(*dir)[0];
   572 	test(entry.iName.MatchF(_L("CONFUSED.DOG"))!=KErrNotFound);
   573 	delete dir;
   574 	r=finder.FindWildByPath(_L("*CONFUSED.DOG*"), &gPath1, dir);
   575 	test(r==KErrNone);
   576 	test(dir->Count()==1);
   577 	entry=(*dir)[0];
   578 	test(entry.iName.MatchF(_L("CONFUSED.DOG"))!=KErrNotFound);
   579 	delete dir;
   580 	}
   581 
   582 LOCAL_C void Test5()
   583 //
   584 // Test wildcard findbydir
   585 //
   586 	{
   587 
   588 	test.Next(_L("FindByDir with wild filenames"));
   589 	TFindFile finder(TheFs);
   590 	CDir* dir;
   591 	TInt count;
   592 	TEntry entry;
   593 	TFileName path;
   594 
   595 	TInt r=finder.FindWildByDir(_L("FILE*"),_L("\\F32-TST\\LOCTEST\\BIN3\\"),dir);
   596 	test(r==KErrNone);
   597 	count=dir->Count();
   598 	test(count==1);
   599 	entry=(*dir)[0];
   600 	test(entry.iName.MatchF(_L("FILE3.CCC"))!=KErrNotFound);
   601 	TParse fileParse;
   602 	fileParse.Set(finder.File(),NULL,NULL);
   603 	path=fileParse.FullName();
   604 	TFileName tpath=_L("?:\\F32-TST\\LOCTEST\\BIN3\\FILE*");
   605     tpath[0]=gSessionPath[0];
   606 	test(path.CompareF(tpath)==0);
   607 	delete dir;
   608 
   609 	r=finder.FindWild(dir);
   610 	if (r==KErrNotFound)
   611 		return;
   612 	test(r==KErrNone);
   613 	entry=(*dir)[0];
   614 	test(entry.iName.MatchF(_L("FILE3.CCC"))!=KErrNotFound);
   615 	fileParse.Set(finder.File(),NULL,NULL);
   616 	path=fileParse.FullName();
   617 	test(path.CompareF(tpath)==0);
   618 	delete dir;
   619 
   620 	r=finder.FindWild(dir);
   621 	test(r==KErrNotFound);
   622 	r=finder.FindWild(dir);
   623 	test(r==KErrNotFound);
   624 	}
   625 
   626 LOCAL_C void Test6()
   627 //
   628 // Test file not found
   629 //
   630 	{
   631 
   632 	test.Next(_L("Test file not found"));
   633 	TFindFile ff(TheFs);
   634 	TInt r=ff.FindByDir(_L("NOEXIST.EXE"),_L("\\System\\Programs\\"));
   635 	test(r==KErrNotFound);
   636 	}
   637 
   638 
   639 
   640 
   641 //  The following test has the requirement that the only remote drive is the one we mount 
   642 //  during the test(DELAYFS) and which doesn't have any other attributes set. If this is not the
   643 //  case then test conditions must be changed, in order for the test to stop failing.
   644 // 	Even more if a removable drive is not present in the target platform then findfile.aaa
   645 //	only exists in the remote one and this is why we have a distinction in the test results.
   646 //
   647 
   648 
   649 
   650   	//--------------------------------------------- 
   651 	//! @SYMTestCaseID			PBASE-T_LOCATE-0553
   652 	//! @SYMTestType			UT 
   653 	//! @SYMREQ					CR909
   654 	//! @SYMTestCaseDesc		When using the various Find functions of class TFindFile,by default remote drives are 
   655 	//!							excluded from the list of drives that are searched. Using function 
   656 	//!							SetFindMask(TUint aMask) it is possible to specify a combination of attributes that
   657 	//!						    the drives to be searched must match.
   658 	//! @SYMTestActions			Call function FindByPath/Find without specifying a mask. Check that remote drives are not 
   659 	//!							included. Then call SetFindMask(TUint aMask) using various combinations and verify 
   660 	//!							that FindByPath or Find return appopriate results.
   661 	//! @SYMTestExpectedResults	Test that file findfile.aaa is found or not depending on the specified mask.
   662 	//! @SYMTestPriority		High
   663 	//! @SYMTestStatus			Implemented 
   664 	//--------------------------------------------- 
   665 
   666 
   667 
   668 LOCAL_C void Test7()
   669 
   670 	{
   671 	
   672 	TAutoClose<RFs> fs;
   673 	TInt r=fs.iObj.Connect();
   674 	test(r==KErrNone);
   675 	TFindFile finder(fs.iObj);
   676 	TPtrC path=gPath4;
   677 	r=finder.FindByPath(_L("findfile.aaa"),&path); 	
   678 	
   679 	TParse fileParse;
   680 	
   681 	test.Next(_L("Test FindByPath without specifying any mask"));
   682 	
   683 	if (removableFlag == 1)
   684 		{
   685 			test(r==KErrNone); 
   686 			fileParse.Set(finder.File(),NULL,NULL);
   687 			test(fileParse.Path()==_L("\\F32-TST\\LOCTEST\\BIN\\"));
   688 			test(fileParse.NameAndExt()==_L("findfile.aaa")); //The filename.aaa in the removable Drive
   689 			r=finder.Find();
   690 			test(r==KErrNotFound);     //remote drives are excluded by default
   691 		
   692 		}
   693 	else
   694 		test(r==KErrNotFound);
   695 
   696 	
   697 
   698 	test.Next(_L("Search for the specified file in all Drives, including remotes ones \n"));
   699 
   700 
   701 	r=finder.SetFindMask(	KDriveAttAll) ;
   702 	test(r==KErrNone);
   703 	r=finder.FindByPath(_L("findfile.aaa"),&path);
   704 	test(r==KErrNone);
   705 	fileParse.Set(finder.File(),NULL,NULL);
   706 	test(fileParse.Path()==_L("\\F32-TST\\LOCTEST\\BIN\\"));   
   707 	test(fileParse.NameAndExt()==_L("findfile.aaa"));      //either the remote or removable one.
   708 	r=finder.Find();
   709 	
   710 	
   711 	if (removableFlag == 1)
   712 		{	
   713 		test(r==KErrNone);
   714 	
   715 		fileParse.Set(finder.File(),NULL,NULL);
   716 
   717 		test(fileParse.Path()==_L("\\F32-TST\\LOCTEST\\BIN\\"));
   718 		test(fileParse.NameAndExt()==_L("findfile.aaa"));         //either the remote or removable one.
   719 
   720 		r=finder.Find();
   721 		test(r==KErrNotFound);
   722 		}
   723 	else 
   724 		{
   725 		test(r==KErrNotFound);	
   726 			
   727 		}
   728 		
   729 		
   730 	test.Next(_L("Search exclusively in remote drives \n"));
   731 
   732 	r=finder.SetFindMask(	KDriveAttExclusive| KDriveAttRemote); 
   733 	test(r==KErrNone);
   734 	r=finder.FindByPath(_L("findfile.aaa"),&path);
   735 	test(r==KErrNone);
   736 	fileParse.Set(finder.File(),NULL,NULL);
   737 	test(fileParse.Path()==_L("\\F32-TST\\LOCTEST\\BIN\\"));
   738 	test(fileParse.NameAndExt()==_L("findfile.aaa"));
   739 	r=finder.Find();
   740 	test(r==KErrNotFound);
   741 
   742 	
   743 	test.Next(_L("Search excluding removables and remote \n"));
   744 
   745 	r=finder.SetFindMask(	KDriveAttExclude | KDriveAttRemovable |KDriveAttRemote ); 
   746 	test(r==KErrNone);
   747 	r=finder.FindByPath(_L("findfile.aaa"),&path);   
   748 	test(r==KErrNotFound);   //filename.aaa exists in the remote drive and if present to the removable one
   749 
   750 
   751 	test.Next(_L("Search in Internal Drives \n"));
   752 
   753 	r=finder.SetFindMask(KDriveAttInternal ) ;
   754 	test(r==KErrNone);
   755 	r=finder.FindByPath(_L("findfile.aaa"),&path);   
   756 	test(r==KErrNotFound);   //filename.aaa exists only in the Removable drive and the remote one.
   757 
   758 
   759 	}
   760 
   761 	
   762 	 //--------------------------------------------- 
   763 	//! @SYMTestCaseID			PBASE-T_LOCATE-0554
   764 	//! @SYMTestType			UT 
   765 	//! @SYMREQ					CR909
   766 	//! @SYMTestCaseDesc		Test that SetFindMask(TUint aMask) returns the correct value for all combinations of matching masks.						
   767 	//!							
   768 	//! @SYMTestActions			Call SetFindMask for every combination of mask and check that the correct value is returned.   
   769 	//!							A structure is used to store the expected value for each combination.
   770 	//! @SYMTestExpectedResults	For every combination either KErrNone or KErrArgument must be returned.
   771 	//! @SYMTestPriority		High.
   772 	//! @SYMTestStatus			Implemented 
   773 	//--------------------------------------------- 
   774 	
   775 
   776 
   777 
   778 LOCAL_C void Test8()
   779 
   780 	{
   781 
   782 	test.Next(_L("Test SetFindMask with all mask combinations \n"));	
   783 	
   784 	
   785 	TAutoClose<RFs> fs;
   786 	TInt r=fs.iObj.Connect();
   787 	test(r==KErrNone);
   788 	TFindFile finder(fs.iObj);
   789 	TPtrC path=gPath4;	
   790 	TParse fileParse;
   791 		
   792 
   793 	r=finder.SetFindMask(KDriveAttAll) ;
   794 	test(r==KErrNone);
   795 	r=finder.FindByPath(_L("findfile.aaa"),&path);
   796 	test(r==KErrNone);
   797 	fileParse.Set(finder.File(),NULL,NULL);
   798 	test(fileParse.Path()==_L("\\F32-TST\\LOCTEST\\BIN\\"));   
   799 	test(fileParse.NameAndExt()==_L("findfile.aaa"));
   800 
   801 
   802 	struct TCombinations
   803 		{
   804 		TUint iMatchMask;			  // The Match Mask to be combined with drive attributes
   805 		TInt  iExpectedResultNoAtts;	  // Expected result when flag used on it's own
   806 		TInt  iExpectedResultWithAtts;  // Expected result when flag used in combination with drive flags
   807 		};
   808 
   809 	TCombinations testCombinations[] = {
   810 		{ 0,														KErrNone,     KErrNone},
   811 		{ KDriveAttAll,												KErrNone,     KErrArgument },
   812 		{ KDriveAttExclude,											KErrArgument, KErrNone },
   813 		{ KDriveAttExclusive,										KErrArgument, KErrNone },
   814 		{ KDriveAttExclude | KDriveAttExclusive,					KErrArgument, KErrNone },
   815 		{ KDriveAttAll	   | KDriveAttExclude,						KErrArgument, KErrArgument },
   816 		{ KDriveAttAll     | KDriveAttExclusive,					KErrArgument, KErrArgument},
   817 		{ KDriveAttAll     | KDriveAttExclude | KDriveAttExclusive, KErrArgument, KErrArgument}};
   818 
   819 
   820 	
   821 	for(TUint matchIdx = 0; matchIdx < sizeof(testCombinations) / sizeof(TCombinations); matchIdx++)
   822 		{
   823 		test.Printf(_L("\nTest mask : KDriveAttAll[%c] KDriveAttExclude[%c] KDriveAttExclusive[%c]\n"), testCombinations[matchIdx].iMatchMask & KDriveAttAll       ? 'X' : ' ',
   824 																										 testCombinations[matchIdx].iMatchMask & KDriveAttExclude   ? 'X' : ' ',
   825 																										 testCombinations[matchIdx].iMatchMask & KDriveAttExclusive ? 'X' : ' ');
   826 		for(TUint testAtt = 0; testAtt <= KMaxTUint8; testAtt++)
   827 			{
   828 			r= finder.SetFindMask( testCombinations[matchIdx].iMatchMask | testAtt ) ;
   829 	 		
   830 		//	test.Printf(_L("            ATT : 0x%08x \n"), testAtt);
   831 		//	test.Printf(_L("Expected Result : %d     \n"), testAtt == 0 ? testCombinations[matchIdx].iExpectedResultNoAtts : testCombinations[matchIdx].iExpectedResultWithAtts);
   832 		//	test.Printf(_L("  Actual Result : 0x%08x \n"), err);
   833 		
   834 		//	test.Printf(_L("\nTest mask : %d \n"),testCombinations[matchIdx].iMatchMask | testAtt );
   835 			
   836 			test( r == (testAtt == 0 ? testCombinations[matchIdx].iExpectedResultNoAtts : testCombinations[matchIdx].iExpectedResultWithAtts) );
   837 			
   838 			
   839 			if (r== KErrNone)
   840 				{
   841 				r  = finder.FindByPath(_L("findfile.aaa"),&path);
   842 				test (r== KErrNone || r ==KErrNotFound);
   843 				}
   844 			
   845 			}
   846 		}
   847 
   848 	}
   849 	
   850 	
   851 
   852 
   853 
   854 LOCAL_C void Test9()
   855 //
   856 // Test wildcard findbydir and FindByWildPath in Removable and Internal Drives
   857 //
   858 
   859 	//--------------------------------------------- 
   860 	//! @SYMTestCaseID			PBASE-T_LOCATE-0555
   861 	//! @SYMTestType			UT 
   862 	//! @SYMREQ					CR909
   863 	//! @SYMTestCaseDesc		Check that FindWildByDir and FindByDir functions behave correctly when a mask has been specified 
   864 	//! 						through SetFindMask.
   865 	//! @SYMTestActions			Call FindWildByDir with a filename containing wildchars and a specific path. Then call SetFindMask
   866 	//!							to exclude Removable drives and call FindWildByDir again.Even more call FindByDir for the file in
   867 	//!							the removable drive and for the same directory as before. 
   868 	//! @SYMTestExpectedResults The number of files found when excluding the removable drive(if a removable drive exists in the
   869 	//!							target platform) must differ by one. The FinByDir must find the same results.
   870 	//! @SYMTestPriority		High
   871 	//! @SYMTestStatus			Implemented 
   872 	//--------------------------------------------- 
   873 
   874 
   875 	{		
   876 
   877 	TAutoClose<RFs> fs;
   878 	TInt r=fs.iObj.Connect();
   879 	test(r==KErrNone);
   880 	
   881 	TFindFile finder(fs.iObj);
   882 	
   883 	CDir* dir;
   884 	CDir* dir3;
   885 	
   886 	TInt count;
   887 	TEntry entry;	
   888 
   889 
   890 
   891 	if ( removableFlag == 1 )
   892 		{
   893 		
   894 		test.Next(_L("FindByDir with wild filenames when a find mask is specified"));
   895 		
   896 		TInt r=finder.SetFindMask(KDriveAttRemovable);
   897 		test(r==KErrNone);
   898 		r=finder.FindWildByDir(_L("FIND*"),_L("\\F32-TST\\LOCTEST\\BIN\\"),dir);
   899 		test(r==KErrNone);
   900 		count=dir->Count();
   901 		test(count==1);
   902 		entry=(*dir)[0];
   903 		test(entry.iName.MatchF(_L("FINDFILE.AAA"))!=KErrNotFound); 
   904 		delete dir;	
   905 
   906 		r=finder.FindWild(dir);
   907 		test(r==KErrNotFound);	
   908 		
   909 		
   910 		r=finder.SetFindMask(KDriveAttExclude| KDriveAttRemovable);
   911 		test(r==KErrNone);
   912 		r=finder.FindWildByDir(_L("FIND*"),_L("\\F32-TST\\LOCTEST\\BIN\\"),dir);
   913 		test(r==KErrNotFound);
   914 		
   915 		
   916 		test.Next(_L("Test FindByDir when a find mask is specified"));
   917 		
   918 		
   919 		TPtrC dir2=_L("\\F32-TST\\LOCTEST\\BIN\\");
   920 		
   921 		r=finder.SetFindMask(KDriveAttExclude | KDriveAttRemote );
   922 		test(r==KErrNone);
   923 		r=finder.FindByDir(_L("findfile.aaa"),dir2);
   924 		test(r==KErrNone);
   925 	
   926 		r=finder.Find();
   927 		test(r==KErrNotFound);	
   928 		
   929 
   930 		}
   931 	
   932 
   933 
   934 	//--------------------------------------------- 
   935 	//! @SYMTestCaseID			PBASE-T_LOCATE-0556
   936 	//! @SYMTestType			UT 
   937 	//! @SYMREQ					CR909
   938 	//! @SYMTestCaseDesc		FindByWildPath and FindByPath functions when supplied with a path that also contains 
   939 	//!							a Drive letter, they will not need to check other Drives. Therefore calling SetFindMask 
   940 	//!							does not affect the drives returned. 
   941 	//! @SYMTestActions			Call FindWildByPath with an appropriate path in the internal drive. Then call SetFindMask
   942 	//!							to exclude Internal drives and call FindWildByPath again.
   943 	//! @SYMTestExpectedResults The number of files found in both cases must be the same since no other drive is searched.
   944 	//! @SYMTestPriority		High
   945 	//! @SYMTestStatus			Implemented 
   946 	//--------------------------------------------- 
   947 
   948 
   949 
   950 
   951 	if( internalFlag == 1 )
   952 		{
   953 		
   954 		
   955 		test.Next(_L("Test that SetFindMask does not affect Find functions that have a drive letter specified"));
   956 		
   957 
   958 		gPath5.Append (internalDriveLetter);
   959 		gPath5.Append (_L(":\\F32-TST\\LOCTEST\\BIN\\INT\\") );
   960 
   961 		
   962 		r=finder.FindWildByPath(_L("FIND*.AAA"), &gPath5, dir3);
   963  		test(r==KErrNone);
   964 		test(dir3->Count()==2);
   965 		
   966 		entry=(*dir3)[0];		
   967 		test(  (entry.iName.MatchF(_L("FINDINTERNALFILE_B.AAA"))!=KErrNotFound)  || (entry.iName.MatchF(_L("FINDINTERNALFILE.AAA"))!=KErrNotFound)  );
   968 		
   969 				
   970 		entry=(*dir3)[1];
   971 		test(  (entry.iName.MatchF(_L("FINDINTERNALFILE_B.AAA"))!=KErrNotFound )  || (entry.iName.MatchF(_L("FINDINTERNALFILE.AAA"))!=KErrNotFound)  );		
   972 
   973 		
   974 		delete dir3;
   975 		
   976 		
   977 		
   978 		r=finder.SetFindMask(KDriveAttExclude| KDriveAttInternal);
   979 		test(r==KErrNone);
   980 		r=finder.FindWildByPath(_L("FIND*.AAA"), &gPath5, dir3);	
   981  		test(r==KErrNone);
   982 		test(dir3->Count()==2);
   983 		
   984 		delete dir3;
   985 		
   986 		
   987 		r=finder.FindWild(dir3);
   988 		test(r==KErrNotFound);
   989 				
   990 				
   991 		}
   992 
   993 
   994 	}
   995 
   996 
   997 
   998 
   999 GLDEF_C void CallTestsL()
  1000 //
  1001 // Do all tests
  1002 //
  1003 	{
  1004 
  1005 		
  1006 		gPath3=_L("C:\\F32-TST\\LOCTEST\\BIN1\\;C:\\F32-TST\\LOCTEST\\BIN2\\");
  1007 
  1008 		gPath1=_L("");
  1009 		gPath1.Append(gSessionPath[0]);
  1010 		gPath1.Append(_L(":\\F32-TST\\LOCTEST\\BIN1\\;"));
  1011 		gPath1.Append(gSessionPath[0]);
  1012 		gPath1.Append(_L(":\\F32-TST\\LOCTEST\\BIN2\\"));
  1013 	
  1014 		gPath2=gPath1;
  1015 		gPath2.Append(';');
  1016 		gPath2.Append(gSessionPath[0]);
  1017 		gPath2.Append(_L(":\\F32-TST\\LOCTEST\\BIN1\\BIN4\\;"));
  1018 		if (gSessionPath[0]!='C')
  1019 			gPath2.Append(gSessionPath.Left(2));
  1020 		gPath2.Append(_L("\\F32-TST\\LOCTEST\\BIN3\\;"));
  1021 		
  1022 		gPath4=_L("");
  1023 		gPath4.Append(_L("\\F32-TST\\LOCTEST\\BIN\\"));
  1024 		
  1025 	
  1026 
  1027 		CreateTestDirectory(_L("\\F32-TST\\LOCTEST\\"));
  1028 		MakeLocateTestDirectoryStructure();
  1029 		Test1();
  1030 		Test2();
  1031 		Test3();
  1032 		Test4();
  1033 		Test5();
  1034 		Test6();
  1035 	
  1036 		MountRemoteFilesystem();      
  1037 		CreateFilesInRemovableDrive();  //used in Test7/8/9   	
  1038 	
  1039 		Test7();
  1040 		Test8();
  1041 	
  1042 		CreateFilesInInternalDrive();  //used in Test9
  1043 		Test9();
  1044 			
  1045 		DisMountRemoteFilesystem();	
  1046 		
  1047 		DeleteTestDirectory();
  1048 		
  1049 		//Explicity delete the directories created
  1050 		DeleteRemovableDirectory();
  1051 		DeleteInternalDirectory();
  1052 
  1053 
  1054 	
  1055 	}