kerneltest/f32test/server/t_locate.cpp
branchRCL_3
changeset 80 597aaf25e343
parent 62 4a8fed1c0ef6
child 256 c1f20ce4abcf
equal deleted inserted replaced
62:4a8fed1c0ef6 80:597aaf25e343
   539 	test(r==KErrNone);
   539 	test(r==KErrNone);
   540 	test(dir->Count()==1);
   540 	test(dir->Count()==1);
   541 	entry=(*dir)[0];
   541 	entry=(*dir)[0];
   542 	test(entry.iName.MatchF(_L("FILE.AAA"))!=KErrNotFound);
   542 	test(entry.iName.MatchF(_L("FILE.AAA"))!=KErrNotFound);
   543 	delete dir;
   543 	delete dir;
       
   544 	
   544 	r=finder.FindWildByPath(_L("*FILE.AAA"), &gPath1, dir);
   545 	r=finder.FindWildByPath(_L("*FILE.AAA"), &gPath1, dir);
   545 	test(r==KErrNone);
   546 	test(r==KErrNone);
   546 	test(dir->Count()==1);
   547 	test(dir->Count()==1);
   547 	entry=(*dir)[0];
   548 	entry=(*dir)[0];
   548 	test(entry.iName.MatchF(_L("FILE.AAA"))!=KErrNotFound);
   549 	test(entry.iName.MatchF(_L("FILE.AAA"))!=KErrNotFound);
   549 	delete dir;
   550 	delete dir;
       
   551 	
   550 	r=finder.FindWildByPath(_L("FILE.AAA*"), &gPath1, dir);
   552 	r=finder.FindWildByPath(_L("FILE.AAA*"), &gPath1, dir);
   551 	test(r==KErrNone);
   553 	test(r==KErrNone);
   552 	test(dir->Count()==1);
   554 	test(dir->Count()==1);
   553 	entry=(*dir)[0];
   555 	entry=(*dir)[0];
   554 	test(entry.iName.MatchF(_L("FILE.AAA"))!=KErrNotFound);
   556 	test(entry.iName.MatchF(_L("FILE.AAA"))!=KErrNotFound);
   555 	delete dir;
   557 	delete dir;
       
   558 
       
   559     
   556 	r=finder.FindWildByPath(_L("CONFUSED.DOG"), &gPath1, dir);
   560 	r=finder.FindWildByPath(_L("CONFUSED.DOG"), &gPath1, dir);
   557 	test(r==KErrNone);
   561 	test(r==KErrNone);
   558 	test(dir->Count()==1);
   562 	test(dir->Count()==1);
   559 	entry=(*dir)[0];
   563 	entry=(*dir)[0];
   560 	test(entry.iName.MatchF(_L("CONFUSED.DOG"))!=KErrNotFound);
   564 	test(entry.iName.MatchF(_L("CONFUSED.DOG"))!=KErrNotFound);
   561 	delete dir;
   565 	delete dir;
       
   566 
   562 	r=finder.FindWildByPath(_L("*CONFUSED.DOG"), &gPath1, dir);
   567 	r=finder.FindWildByPath(_L("*CONFUSED.DOG"), &gPath1, dir);
   563 	test(r==KErrNone);
   568 	test(r==KErrNone);
   564 	test(dir->Count()==1);
   569 	test(dir->Count()==1);
   565 	entry=(*dir)[0];
   570 	entry=(*dir)[0];
   566 	test(entry.iName.MatchF(_L("CONFUSED.DOG"))!=KErrNotFound);
   571 	test(entry.iName.MatchF(_L("CONFUSED.DOG"))!=KErrNotFound);
   991 		}
   996 		}
   992 
   997 
   993 
   998 
   994 	}
   999 	}
   995 
  1000 
   996 
  1001 //---------------------------------------------------------------------------------------
   997 
  1002 /**
   998 
  1003     Test that callinng TFindFile methods that allocate CDir objects doesn't lead to memory leaks if some error occurs.
   999 GLDEF_C void CallTestsL()
  1004 */
       
  1005 void TestFailures()
       
  1006     {
       
  1007 
       
  1008 	test.Next(_L("Test TFindFile failures\n"));	
       
  1009 
       
  1010 #ifndef _DEBUG
       
  1011     test.Printf(_L("This test can't be performed in UREL mode, skipping\n"));
       
  1012     return;	
       
  1013 #else
       
  1014 
       
  1015 	TFindFile finder(TheFs);
       
  1016 	CDir* pDir;
       
  1017 	TInt nRes;
       
  1018     TInt cnt=0;
       
  1019 
       
  1020     _LIT(KPath, "\\F32-TST\\LOCTEST\\");
       
  1021 
       
  1022     const TInt KMyError = -756; //-- specific error code we will simulate
       
  1023     
       
  1024     //------------------------------------
       
  1025     test.Printf(_L("Test FindWildByPath failures\n"));	
       
  1026     
       
  1027     __UHEAP_MARK;
       
  1028     nRes = finder.FindWildByPath(_L("*"), &gPath1, pDir);
       
  1029     test(nRes == KErrNone);
       
  1030     test(pDir && pDir->Count() > 1);
       
  1031     delete pDir;
       
  1032 
       
  1033  
       
  1034     for(cnt = 0; ;cnt++)
       
  1035         {
       
  1036         nRes =TheFs.SetErrorCondition(KMyError, cnt);
       
  1037         test(nRes == KErrNone);
       
  1038 
       
  1039         pDir = (CDir*)0xaabbccdd;
       
  1040         nRes = finder.FindWildByPath(_L("*"), &gPath1, pDir);
       
  1041         
       
  1042         //-- on error the memory allocated internally for CDir shall be freed and the pointer CDir* shall be set to NULL 
       
  1043         if(nRes == KErrNone)
       
  1044             {
       
  1045             test.Printf(_L("Test FindWildByPath->FindWild() failures\n"));	
       
  1046             test(pDir && pDir->Count() > 1);
       
  1047             delete pDir;
       
  1048             pDir = (CDir*)0xaabbccdd;
       
  1049 
       
  1050             TheFs.SetErrorCondition(KMyError);
       
  1051             nRes = finder.FindWild(pDir);
       
  1052             test(nRes != KErrNone);
       
  1053             test(pDir == NULL); 
       
  1054             
       
  1055             break;
       
  1056             }
       
  1057         else
       
  1058             {
       
  1059             test(pDir == NULL);
       
  1060             }
       
  1061 
       
  1062         }
       
  1063 
       
  1064    __UHEAP_MARKEND;
       
  1065    TheFs.SetErrorCondition(KErrNone);
       
  1066 
       
  1067 
       
  1068    //------------------------------------
       
  1069    test.Printf(_L("Test FindWildByDir failures\n"));	
       
  1070     
       
  1071    __UHEAP_MARK;
       
  1072    nRes = finder.FindWildByDir(_L("*"), KPath, pDir);
       
  1073    test(nRes == KErrNone);
       
  1074    test(pDir && pDir->Count() > 1);
       
  1075    delete pDir;
       
  1076    
       
  1077    for(cnt = 0; ;cnt++)
       
  1078         {
       
  1079         nRes =TheFs.SetErrorCondition(KMyError, cnt);
       
  1080         test(nRes == KErrNone);
       
  1081 
       
  1082         pDir = (CDir*)0xaabbccdd;
       
  1083         nRes = finder.FindWildByDir(_L("*"), KPath, pDir);
       
  1084         
       
  1085         //-- on error the memory allocated internally for CDir shall be freed and the pointer CDir* shall be set to NULL  
       
  1086         if(nRes == KErrNone)
       
  1087             {
       
  1088             test.Printf(_L("Test FindWildByDir->FindWild() failures\n"));	
       
  1089             test(pDir && pDir->Count() > 1);
       
  1090             delete pDir;
       
  1091             pDir = (CDir*)0xaabbccdd;
       
  1092 
       
  1093             TheFs.SetErrorCondition(KMyError);
       
  1094             nRes = finder.FindWild(pDir);
       
  1095             test(nRes != KErrNone);
       
  1096             test(pDir == NULL);
       
  1097             
       
  1098             break;
       
  1099             }
       
  1100         else
       
  1101             {
       
  1102             test(pDir == NULL);
       
  1103             }
       
  1104 
       
  1105         }
       
  1106 
       
  1107    __UHEAP_MARKEND;
       
  1108    TheFs.SetErrorCondition(KErrNone);
       
  1109 #endif
       
  1110 }
       
  1111 
       
  1112 //---------------------------------------------------------------------------------------
       
  1113 void CallTestsL()
  1000 //
  1114 //
  1001 // Do all tests
  1115 // Do all tests
  1002 //
  1116 //
  1003 	{
  1117 	{
  1004 
  1118 
  1024 		
  1138 		
  1025 	
  1139 	
  1026 
  1140 
  1027 		CreateTestDirectory(_L("\\F32-TST\\LOCTEST\\"));
  1141 		CreateTestDirectory(_L("\\F32-TST\\LOCTEST\\"));
  1028 		MakeLocateTestDirectoryStructure();
  1142 		MakeLocateTestDirectoryStructure();
       
  1143 		
       
  1144         TestFailures();
  1029 		Test1();
  1145 		Test1();
  1030 		Test2();
  1146 		Test2();
  1031 		Test3();
  1147 		Test3();
  1032 		Test4();
  1148 		Test4();
  1033 		Test5();
  1149 		Test5();