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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // f32test\server\t_locate.cpp
17 #define __E32TEST_EXTENSION__
24 GLDEF_D RTest test(_L("T_LOCATE"));
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;
33 LOCAL_D TFileName gRemovableDriveFile;
34 LOCAL_D TFileName gInternalDriveFile;
35 LOCAL_D TFileName gInternalDriveFile2;
38 LOCAL_D TChar removableDriveLetter;
39 LOCAL_D TChar internalDriveLetter;
42 LOCAL_D TInt removableFlag=0;
43 LOCAL_D TInt internalFlag=0;
47 LOCAL_C void Md(const TDesC& aDirName)
53 TInt r=TheFs.MkDirAll(aDirName);
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);
61 LOCAL_C void Mf(const TDesC& aFileName)
68 TInt r = file.Replace(TheFs,aFileName,0);
69 if (r == KErrPathNotFound)
71 test.Printf(_L("Mf: Path Not Found\n"));
73 r=file.Replace(TheFs,aFileName,0);
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"));
81 test_Value(r, r == KErrNone || r == KErrAlreadyExists);
85 LOCAL_C void MakeLocateTestDirectoryStructure()
87 // Create files for test
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\\"));
99 TheFs.SetErrorCondition(-47,5);
101 for (TInt i=0;i<5;i++)
103 TInt r=TheFs.Drive(drive);
106 TInt r=TheFs.MkDirAll(_L("alskdjfl"));
108 r=TheFs.MkDirAll(_L("alskdjfl"));
110 TheFs.SetErrorCondition(KErrNone);
111 r=TheFs.Drive(drive);
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"));
146 LOCAL_C void CreateFilesInRemovableDrive()
151 TDriveList driveList;
154 err = TheFs.DriveList(driveList);
155 test( err == KErrNone );
157 for (TInt i = 0; i < KMaxDrives; i++)
162 err = TheFs.Drive(info, i);
163 test( err == KErrNone );
165 if( info.iDriveAtt & KDriveAttRemovable )
168 if ( ( info.iType != EMediaNotPresent) && (info.iType != EMediaUnknown) && (info.iType != EMediaCdRom) )
170 TheFs.DriveToChar(i,removableDriveLetter) ;
171 gRemovableDriveFile.Append (removableDriveLetter);
172 gRemovableDriveFile.Append (_L(":\\F32-TST\\LOCTEST\\BIN\\FINDFILE.AAA") );
174 Mf(gRemovableDriveFile);
193 LOCAL_C void CreateFilesInInternalDrive()
197 TDriveList driveList;
200 err = TheFs.DriveList(driveList);
201 test( err == KErrNone );
203 for (TInt i = 0; i < KMaxDrives; i++)
208 err = TheFs.Drive(info, i);
209 test( err == KErrNone );
211 if( info.iDriveAtt & KDriveAttInternal )
214 TheFs.DriveToChar(i,internalDriveLetter) ;
215 gInternalDriveFile.Append (internalDriveLetter);
216 gInternalDriveFile.Append (_L(":\\F32-TST\\LOCTEST\\BIN\\INT\\FINDINTERNALFILE.AAA") );
218 gInternalDriveFile2.Append (internalDriveLetter);
219 gInternalDriveFile2.Append (_L(":\\F32-TST\\LOCTEST\\BIN\\INT\\FINDINTERNALFILE_B.AAA") );
221 Mf(gInternalDriveFile);
222 Mf(gInternalDriveFile2);
238 LOCAL_C void DeleteRemovableDirectory()
241 //Delete the directory structure we created in the removalbe drive
242 if ( removableFlag == 1 )
244 CFileMan* fMan=CFileMan::NewL(TheFs);
248 gPathRem.Append (removableDriveLetter);
249 gPathRem.Append (_L(":\\F32-TST\\") );
250 TInt r=fMan->RmDir(gPathRem);
257 LOCAL_C void DeleteInternalDirectory()
260 //Delete the directory structure we created in the internal drive
263 if( internalFlag == 1 )
265 CFileMan* fMan=CFileMan::NewL(TheFs);
269 gPathInt.Append (internalDriveLetter);
270 gPathInt.Append (_L(":\\F32-TST\\") );
271 TInt r=fMan->RmDir(gPathInt);
279 LOCAL_C void MountRemoteFilesystem()
282 test.Next(_L("Mount Remote Drive simulator on Q:\n"));
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);
291 r=TheFs.MountFileSystem(_L("DELAYFS"),EDriveQ);
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);
299 Mf(_L("Q:\\F32-TST\\LOCTEST\\BIN\\FINDFILE.AAA"));
305 LOCAL_C void DisMountRemoteFilesystem()
308 test.Printf(_L("Dismounting the remote Drives \n"));
310 TInt r=TheFs.DismountFileSystem(_L("DELAYFS"),EDriveQ);
312 test.Printf(_L("Dismounting the Remote Drive returned %d\n"),r);
325 test.Next(_L("Test FindByPath"));
328 TInt r=fs.iObj.Connect();
330 TFindFile finder(fs.iObj);
332 r=finder.FindByPath(_L("file1.aaa"),&path);
335 fileParse.Set(finder.File(),NULL,NULL);
336 test(fileParse.Path()==_L("\\F32-TST\\LOCTEST\\BIN1\\"));
337 test(fileParse.NameAndExt()==_L("file1.aaa"));
339 test(r==KErrNotFound);
343 r=finder.FindByPath(_L("file1.aaa"),&path);
345 fileParse.Set(finder.File(),NULL,NULL);
346 test(fileParse.Path()==_L("\\F32-TST\\LOCTEST\\BIN1\\"));
347 test(fileParse.NameAndExt()==_L("file1.aaa"));
350 fileParse.Set(finder.File(),NULL,NULL);
351 test(fileParse.Path()==_L("\\F32-TST\\LOCTEST\\BIN1\\BIN4\\"));
352 test(fileParse.NameAndExt()==_L("file1.aaa"));
354 test(r==KErrNotFound);
356 test.Next(_L("Test FindByDir"));
357 TPtrC dir=_L("\\F32-TST\\LOCTEST\\BIN2\\");
358 r=finder.FindByDir(_L("file2.bbb"),dir);
360 TFileName defaultPath;
361 r=TheFs.SessionPath(defaultPath);
362 defaultPath.SetLength(2);
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
371 fileParse.Set(finder.File(),NULL,NULL);
372 if (defaultPath==_L("C:"))
373 test(fileParse.Drive()==_L("Y:"));
375 test(fileParse.Drive()==_L("C:"));
376 test(fileParse.Path()==_L("\\F32-TST\\LOCTEST\\BIN2\\"));
377 test(_L("file2.bbb").MatchF(fileParse.NameAndExt())!=KErrNotFound);
380 test(r==KErrNotFound);
389 test.Next(_L("Test extremes"));
391 TInt r=fs.iObj.Connect();
394 TFindFile finder(fs.iObj);
395 r=finder.FindByPath(_L("file1.aaa"),&temp);
396 test(r==KErrNotFound);
398 test(r==KErrNotFound);
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);
408 test(r==KErrNotFound);
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);
416 test(r==KErrNotFound);
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);
427 // Test FindByDrives in a path=_L("c:\xyz;z:\lmnop;\abc;\y:\help");
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);
440 TFindFile finder(fs.iObj);
441 r=finder.FindByPath(_L("file1.aaa"),&path);
442 test(r==KErrNotFound);
444 test(r==KErrNotFound);
446 path.Set(_L("\\F32-TST\\LOCTEST\\BIN2\\"));
447 r=finder.FindByPath(_L("file2.bbb"),&path);
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"));
455 test(r==KErrNotFound || r==KErrNone);
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"));
463 test(r==KErrNotFound);
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);
470 test(r==KErrNotFound);
472 r=finder.FindByPath(_L("file2.bbb"),&path);
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"));
479 test(r==KErrNotFound || r==KErrNone);
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"));
487 test(r==KErrNotFound);
493 // Test wildcard findbypath
497 test.Next(_L("FindByPath with wild filenames"));
498 TFindFile finder(TheFs);
504 TInt r=finder.FindWildByPath(_L("*.aaa"),&gPath3,dir);
509 test(entry.iName.MatchF(_L("FILE.AAA"))!=KErrNotFound);
511 test(entry.iName.MatchF(_L("FILE1.AAA"))!=KErrNotFound);
513 test(entry.iName.MatchF(_L("WORK.AAA"))!=KErrNotFound);
515 fileParse.Set(finder.File(),NULL,NULL);
516 path=fileParse.FullName();
517 test(path==_L("*.aaa"));
520 r=finder.FindWild(dir);
525 test(entry.iName.MatchF(_L("FILE1.AAA"))!=KErrNotFound);
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"));
533 r=finder.FindWild(dir);
534 test(r==KErrNotFound);
535 r=finder.FindWild(dir);
536 test(r==KErrNotFound);
538 r=finder.FindWildByPath(_L("*FILE.AAA*"), &gPath1, dir);
540 test(dir->Count()==1);
542 test(entry.iName.MatchF(_L("FILE.AAA"))!=KErrNotFound);
544 r=finder.FindWildByPath(_L("*FILE.AAA"), &gPath1, dir);
546 test(dir->Count()==1);
548 test(entry.iName.MatchF(_L("FILE.AAA"))!=KErrNotFound);
550 r=finder.FindWildByPath(_L("FILE.AAA*"), &gPath1, dir);
552 test(dir->Count()==1);
554 test(entry.iName.MatchF(_L("FILE.AAA"))!=KErrNotFound);
556 r=finder.FindWildByPath(_L("CONFUSED.DOG"), &gPath1, dir);
558 test(dir->Count()==1);
560 test(entry.iName.MatchF(_L("CONFUSED.DOG"))!=KErrNotFound);
562 r=finder.FindWildByPath(_L("*CONFUSED.DOG"), &gPath1, dir);
564 test(dir->Count()==1);
566 test(entry.iName.MatchF(_L("CONFUSED.DOG"))!=KErrNotFound);
568 r=finder.FindWildByPath(_L("CONFUSED.DOG*"), &gPath1, dir);
570 test(dir->Count()==1);
572 test(entry.iName.MatchF(_L("CONFUSED.DOG"))!=KErrNotFound);
574 r=finder.FindWildByPath(_L("*CONFUSED.DOG*"), &gPath1, dir);
576 test(dir->Count()==1);
578 test(entry.iName.MatchF(_L("CONFUSED.DOG"))!=KErrNotFound);
584 // Test wildcard findbydir
588 test.Next(_L("FindByDir with wild filenames"));
589 TFindFile finder(TheFs);
595 TInt r=finder.FindWildByDir(_L("FILE*"),_L("\\F32-TST\\LOCTEST\\BIN3\\"),dir);
600 test(entry.iName.MatchF(_L("FILE3.CCC"))!=KErrNotFound);
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);
609 r=finder.FindWild(dir);
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);
620 r=finder.FindWild(dir);
621 test(r==KErrNotFound);
622 r=finder.FindWild(dir);
623 test(r==KErrNotFound);
628 // Test file not found
632 test.Next(_L("Test file not found"));
634 TInt r=ff.FindByDir(_L("NOEXIST.EXE"),_L("\\System\\Programs\\"));
635 test(r==KErrNotFound);
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.
650 //---------------------------------------------
651 //! @SYMTestCaseID PBASE-T_LOCATE-0553
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 //---------------------------------------------
673 TInt r=fs.iObj.Connect();
675 TFindFile finder(fs.iObj);
677 r=finder.FindByPath(_L("findfile.aaa"),&path);
681 test.Next(_L("Test FindByPath without specifying any mask"));
683 if (removableFlag == 1)
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
690 test(r==KErrNotFound); //remote drives are excluded by default
694 test(r==KErrNotFound);
698 test.Next(_L("Search for the specified file in all Drives, including remotes ones \n"));
701 r=finder.SetFindMask( KDriveAttAll) ;
703 r=finder.FindByPath(_L("findfile.aaa"),&path);
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.
711 if (removableFlag == 1)
715 fileParse.Set(finder.File(),NULL,NULL);
717 test(fileParse.Path()==_L("\\F32-TST\\LOCTEST\\BIN\\"));
718 test(fileParse.NameAndExt()==_L("findfile.aaa")); //either the remote or removable one.
721 test(r==KErrNotFound);
725 test(r==KErrNotFound);
730 test.Next(_L("Search exclusively in remote drives \n"));
732 r=finder.SetFindMask( KDriveAttExclusive| KDriveAttRemote);
734 r=finder.FindByPath(_L("findfile.aaa"),&path);
736 fileParse.Set(finder.File(),NULL,NULL);
737 test(fileParse.Path()==_L("\\F32-TST\\LOCTEST\\BIN\\"));
738 test(fileParse.NameAndExt()==_L("findfile.aaa"));
740 test(r==KErrNotFound);
743 test.Next(_L("Search excluding removables and remote \n"));
745 r=finder.SetFindMask( KDriveAttExclude | KDriveAttRemovable |KDriveAttRemote );
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
751 test.Next(_L("Search in Internal Drives \n"));
753 r=finder.SetFindMask(KDriveAttInternal ) ;
755 r=finder.FindByPath(_L("findfile.aaa"),&path);
756 test(r==KErrNotFound); //filename.aaa exists only in the Removable drive and the remote one.
762 //---------------------------------------------
763 //! @SYMTestCaseID PBASE-T_LOCATE-0554
766 //! @SYMTestCaseDesc Test that SetFindMask(TUint aMask) returns the correct value for all combinations of matching masks.
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 //---------------------------------------------
782 test.Next(_L("Test SetFindMask with all mask combinations \n"));
786 TInt r=fs.iObj.Connect();
788 TFindFile finder(fs.iObj);
793 r=finder.SetFindMask(KDriveAttAll) ;
795 r=finder.FindByPath(_L("findfile.aaa"),&path);
797 fileParse.Set(finder.File(),NULL,NULL);
798 test(fileParse.Path()==_L("\\F32-TST\\LOCTEST\\BIN\\"));
799 test(fileParse.NameAndExt()==_L("findfile.aaa"));
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
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}};
821 for(TUint matchIdx = 0; matchIdx < sizeof(testCombinations) / sizeof(TCombinations); matchIdx++)
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++)
828 r= finder.SetFindMask( testCombinations[matchIdx].iMatchMask | testAtt ) ;
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);
834 // test.Printf(_L("\nTest mask : %d \n"),testCombinations[matchIdx].iMatchMask | testAtt );
836 test( r == (testAtt == 0 ? testCombinations[matchIdx].iExpectedResultNoAtts : testCombinations[matchIdx].iExpectedResultWithAtts) );
841 r = finder.FindByPath(_L("findfile.aaa"),&path);
842 test (r== KErrNone || r ==KErrNotFound);
856 // Test wildcard findbydir and FindByWildPath in Removable and Internal Drives
859 //---------------------------------------------
860 //! @SYMTestCaseID PBASE-T_LOCATE-0555
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 //---------------------------------------------
878 TInt r=fs.iObj.Connect();
881 TFindFile finder(fs.iObj);
891 if ( removableFlag == 1 )
894 test.Next(_L("FindByDir with wild filenames when a find mask is specified"));
896 TInt r=finder.SetFindMask(KDriveAttRemovable);
898 r=finder.FindWildByDir(_L("FIND*"),_L("\\F32-TST\\LOCTEST\\BIN\\"),dir);
903 test(entry.iName.MatchF(_L("FINDFILE.AAA"))!=KErrNotFound);
906 r=finder.FindWild(dir);
907 test(r==KErrNotFound);
910 r=finder.SetFindMask(KDriveAttExclude| KDriveAttRemovable);
912 r=finder.FindWildByDir(_L("FIND*"),_L("\\F32-TST\\LOCTEST\\BIN\\"),dir);
913 test(r==KErrNotFound);
916 test.Next(_L("Test FindByDir when a find mask is specified"));
919 TPtrC dir2=_L("\\F32-TST\\LOCTEST\\BIN\\");
921 r=finder.SetFindMask(KDriveAttExclude | KDriveAttRemote );
923 r=finder.FindByDir(_L("findfile.aaa"),dir2);
927 test(r==KErrNotFound);
934 //---------------------------------------------
935 //! @SYMTestCaseID PBASE-T_LOCATE-0556
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 //---------------------------------------------
951 if( internalFlag == 1 )
955 test.Next(_L("Test that SetFindMask does not affect Find functions that have a drive letter specified"));
958 gPath5.Append (internalDriveLetter);
959 gPath5.Append (_L(":\\F32-TST\\LOCTEST\\BIN\\INT\\") );
962 r=finder.FindWildByPath(_L("FIND*.AAA"), &gPath5, dir3);
964 test(dir3->Count()==2);
967 test( (entry.iName.MatchF(_L("FINDINTERNALFILE_B.AAA"))!=KErrNotFound) || (entry.iName.MatchF(_L("FINDINTERNALFILE.AAA"))!=KErrNotFound) );
971 test( (entry.iName.MatchF(_L("FINDINTERNALFILE_B.AAA"))!=KErrNotFound ) || (entry.iName.MatchF(_L("FINDINTERNALFILE.AAA"))!=KErrNotFound) );
978 r=finder.SetFindMask(KDriveAttExclude| KDriveAttInternal);
980 r=finder.FindWildByPath(_L("FIND*.AAA"), &gPath5, dir3);
982 test(dir3->Count()==2);
987 r=finder.FindWild(dir3);
988 test(r==KErrNotFound);
999 GLDEF_C void CallTestsL()
1006 gPath3=_L("C:\\F32-TST\\LOCTEST\\BIN1\\;C:\\F32-TST\\LOCTEST\\BIN2\\");
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\\"));
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\\;"));
1023 gPath4.Append(_L("\\F32-TST\\LOCTEST\\BIN\\"));
1027 CreateTestDirectory(_L("\\F32-TST\\LOCTEST\\"));
1028 MakeLocateTestDirectoryStructure();
1036 MountRemoteFilesystem();
1037 CreateFilesInRemovableDrive(); //used in Test7/8/9
1042 CreateFilesInInternalDrive(); //used in Test9
1045 DisMountRemoteFilesystem();
1047 DeleteTestDirectory();
1049 //Explicity delete the directories created
1050 DeleteRemovableDirectory();
1051 DeleteInternalDirectory();