os/kernelhwsrv/kerneltest/f32test/server/t_notify.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_notify.cpp
    15 // 
    16 //
    17 
    18 #include <f32file.h>
    19 #include <e32test.h>
    20 #include <e32svr.h>
    21 #include <hal.h>
    22 #include "t_server.h"
    23 
    24 const TInt KHeapSize=0x200;
    25 
    26 // wait for a bit since NotifyChange handled asynchronously and SetDriveName synchronously
    27 const TInt KNotifyChangeAfter=100000;
    28 const TInt KMediaRemountForceMediaChange = 0x00000001;
    29 
    30 RTest test(_L("T_NOTIFY"));
    31 RSemaphore gSleepThread;
    32 TInt gSocketNumber=0;
    33 TInt SocketToDrive[KMaxPBusSockets];
    34 
    35 //#define __INCLUDE_MANUAL_TESTS__
    36 
    37 void do_check_no_pending_requests(TInt aLine)
    38 	{
    39 	RTimer timer;
    40 	TRequestStatus timerStat;
    41 	timer.CreateLocal();
    42 	timer.After(timerStat, 125000);
    43 	User::WaitForAnyRequest();
    44 	if(timerStat==KRequestPending)
    45 		{
    46 		RDebug::Printf("do_check_no_pending_requests failed at line %d",aLine);
    47 		test(0);
    48 		}
    49 	timer.Close();
    50 	}
    51 #define CHECK_NO_PENDING_REQUESTS do_check_no_pending_requests(__LINE__);
    52 
    53 
    54 TBool CheckDriveRead(TInt aDrive)
    55   //Determines if can connect to local drive number and read
    56 	{
    57     TBusLocalDrive TBLD;
    58     TBool TBLDChangedFlag;
    59 
    60     TInt r = TBLD.Connect(aDrive, TBLDChangedFlag);
    61 	test.Printf(_L("Connect returned %d\n"), r);
    62     if (r == KErrNone)
    63 		{
    64         const TInt KSectSize = 512;
    65         TBuf8<KSectSize> sect;
    66         r = TBLD.Read(0, KSectSize, sect);
    67 		test.Printf(_L("Read returned %d\n"), r);
    68         TBLD.Disconnect();
    69 		if(r!=KErrNone)
    70 			return EFalse;
    71 		else
    72 			return ETrue;
    73         }
    74 	 else
    75 		return EFalse;
    76 	}
    77 
    78 void GenerateMediaChange()
    79 	{
    80     TPckgBuf<TInt> pckg;
    81     pckg()=0;
    82 
    83 	RFs fs;
    84 	TInt r = fs.Connect();
    85 	if (r == KErrNone)
    86 		{
    87 		r = fs.RemountDrive(CurrentDrive(), &pckg, (TUint)KMediaRemountForceMediaChange);
    88 		if(r == KErrNotReady)
    89 			{
    90 			r = KErrNone;
    91 			}
    92 		fs.Close();
    93 		}
    94 
    95 	if (r!=KErrNone)
    96 		{
    97 		RProcess me;
    98 		me.Panic(_L("GenMedChg"),r);
    99 		}
   100 	}
   101 
   102 enum TTestCode {ETest1,ETest2,ETest3,ETest4,ETest5,ETest6,ETest7,ETest8,ETest9,ETest10,ETest11,ETest12};
   103 const TUint KGenericEntryChange=0x02;
   104 
   105 static TInt ThreadEntryPoint(TAny* aTestCode)
   106 //
   107 // Thread entry point
   108 //
   109 	{
   110 	RFs fs;
   111 	TInt r=fs.Connect();
   112 	test(r==KErrNone);
   113 	r=fs.SetSessionPath(gSessionPath);
   114 	test(r==KErrNone);
   115 	TTestCode testCode=*(TTestCode*)&aTestCode;
   116 	RFile f;
   117 	switch (testCode)
   118 		{
   119 
   120 	case ETest1:
   121 		r=f.Replace(fs,_L("\\F32-TST\\NOTIFY\\NewFile.txt"),EFileStream);
   122 		test(r==KErrNone);
   123 		f.Close();
   124 		break;
   125 
   126 	case ETest2:
   127 		r=f.Replace(fs,_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Dorothy.doc"),EFileStream);
   128 		test(r==KErrNone);
   129 		f.Close();
   130 		break;
   131 
   132 	case ETest3:
   133 		r=fs.MkDir(_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\SCARECROW\\"));
   134 		test((r==KErrNone)||(r==KErrAlreadyExists));
   135 		break;
   136 
   137 	case ETest4:
   138 		{
   139 		TRequestStatus s;
   140 		fs.NotifyChange(ENotifyAll,s);
   141 		test(s==KRequestPending);
   142 		gSleepThread.Signal();
   143 		User::After(100000000);
   144 		}
   145 		break;
   146 
   147 	case ETest5:
   148 		{
   149 		RFile file;
   150 		TInt r=file.Open(fs,_L("\\F32-TST\\NOTIFY\\kangaroo.txt"),EFileRead|EFileWrite);
   151 		test(r==KErrNone);
   152 		r=file.SetSize(sizeof(TCheckedUid));
   153 		test(r==KErrNone);
   154 		r=file.Write(sizeof(TCheckedUid),_L8("012345678912"));
   155 		test(r==KErrNone);
   156 		TBuf8<64> dum;
   157 		r=file.Read(0,dum);
   158 		test(r==KErrNone);
   159 		file.Close();
   160 
   161 		r=file.Open(fs,_L("\\F32-TST\\NOTIFY\\koala.txt"),EFileRead|EFileWrite);
   162 		test(r==KErrNone);
   163 		r=file.SetSize(50);
   164 		test(r==KErrNone);
   165 		r=file.Write(sizeof(TCheckedUid),_L8("ABCDEFGHIJKLMNOPQRSTUVWXYZ"));
   166 		test(r==KErrNone);
   167 		r=file.Read(0,dum);
   168 		test(r==KErrNone);
   169 		file.Close();
   170 
   171 		r=file.Open(fs,_L("\\F32-TST\\NOTIFY\\dingo.txt"),EFileRead|EFileWrite);
   172 		test(r==KErrNone);
   173 		r=file.SetSize(50);
   174 		test(r==KErrNone);
   175 		r=file.Write(sizeof(TCheckedUid),_L8("01234567890123456789"));
   176 		test(r==KErrNone);
   177 		r=file.Read(0,dum);
   178 		test(r==KErrNone);
   179 		file.Close();
   180 		gSleepThread.Signal();
   181 		}
   182 		break;
   183 
   184 	case ETest6:
   185 		{
   186 		GenerateMediaChange();
   187 		User::After(300000);			// Wait for a bit
   188 		gSleepThread.Signal();
   189 		}
   190 		break;
   191 
   192 	case ETest7:
   193 		{
   194 		RFile file;
   195 		TInt r=file.Open(fs,_L("\\F32-TST\\NOTIFY\\NewFILE.TXT"),EFileRead|EFileWrite);
   196 		test(r==KErrNone);
   197 		r=file.Write(_L8("asdfasdfasdf"));
   198 		test(r==KErrNone);
   199 		file.Close();
   200 		gSleepThread.Signal();
   201 		}
   202 		break;
   203 
   204 	case ETest8:
   205 		{
   206 		r=f.Open(fs,_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\WickedWitch.msg"),EFileRead|EFileWrite);
   207 		test(r==KErrNone);
   208 		f.SetSize(500);
   209 		f.Close();
   210 		break;
   211 		}
   212 
   213 	case ETest9:
   214 		{
   215 		TRequestStatus s;
   216 		TFileName path=_L("\\F32-TST\\NOTIFY\\");
   217 		fs.NotifyChange(ENotifyAll,s,path);
   218 		test(s==KRequestPending);
   219 		gSleepThread.Signal();
   220 		User::After(100000000);
   221 		}
   222 		break;
   223 	case ETest10:
   224 		{
   225 		TFileName path=_L("\\F32-TST\\NOTIFY\\BehindTheCurtain\\");
   226 		r=fs.MkDir(path);
   227 		test(r==KErrNone);
   228 		break;
   229 		}
   230 	case ETest11:
   231 		{
   232 		TFileName path=_L("\\F32-TST\\NOTIFY\\BehindTheCurtain\\PayNoAttention.man");
   233 		RFile file;
   234 		r=file.Replace(fs,path,EFileStream);
   235 		test(r==KErrNone);
   236 		file.Close();
   237 		break;
   238 		}
   239 	case ETest12:
   240 		{
   241 		RFile writer;
   242 		TInt r=writer.Open(fs,_L("\\F32-TST\\NOTIFY\\NewFile.txt"),EFileWrite|EFileShareAny);
   243 		test(r==KErrNone);
   244 		TInt i;
   245 		for(i=0; i<10; i++)
   246 			{
   247 			r=writer.Write(_L8("ABCDEFGHIJKLMNOPQRSTUVWXYZ"));
   248 			test(r==KErrNone);
   249 			User::After(1000000);
   250 			}
   251 		writer.Close();
   252 		break;
   253 		}
   254 	default:
   255 		break;
   256 		}
   257 	return KErrNone;
   258 	}
   259 
   260 #if defined (__EPOC32__)//we have no removable media on Emulator yet
   261 static void WaitForMediaChange()
   262 //
   263 // Wait for media driver to register drive is present
   264 //
   265 	{
   266 
   267 	TEntry entry;
   268 	FOREVER
   269 		{
   270 		User::After(10000);
   271 		TInt r=TheFs.Entry(_L("xxxxxxxx"),entry);
   272 		if (r!=KErrNotReady)
   273 			break;
   274 		}
   275 	}
   276 #endif
   277 
   278 static void Test1()
   279 //
   280 // Test notification of an entry change
   281 //
   282 	{
   283 
   284 	test.Next(_L("Test notification of an entry change"));
   285 	TRequestStatus reqStat(KRequestPending);
   286 	TRequestStatus thrdStat(KRequestPending);
   287 	TInt r;
   288 	TheFs.NotifyChange(ENotifyEntry,reqStat);
   289 	RThread thread;
   290 	r=thread.Create(_L("MyThread"),ThreadEntryPoint,KDefaultStackSize,KHeapSize,KHeapSize,(TAny*)ETest1);
   291 	test(r==KErrNone);
   292 	thread.Logon(thrdStat);
   293 	thread.Resume();
   294 	User::WaitForRequest(thrdStat);
   295 	test(thrdStat==KErrNone);
   296 	thread.Close();
   297 	User::WaitForRequest(reqStat);
   298 	test(reqStat==KErrNone);
   299 
   300 	RFile file;
   301 	r=file.Open(TheFs,_L("\\F32-TST\\NOTIFY\\NewFile.txt"),EFileRead|EFileWrite|EFileShareExclusive);
   302 	test(r==KErrNone);
   303 	file.Write(_L8("Somewhere over the rainbow..."),reqStat);
   304 	User::WaitForRequest(reqStat);
   305 	test(reqStat==KErrNone);
   306 	TBuf8<256> buf;
   307 	file.Read(0, buf,reqStat);
   308 	User::WaitForRequest(reqStat);
   309 	test(reqStat==KErrNone);
   310 	file.Close();
   311 
   312 	r=file.Open(TheFs,_L("\\F32-TST\\NOTIFY\\NewFile.txt"),EFileRead|EFileReadAsyncAll|EFileShareExclusive);
   313 	test(r==KErrArgument);
   314 
   315 	r=file.Open(TheFs,_L("\\F32-TST\\NOTIFY\\NewFile.txt"),EFileRead|EFileReadAsyncAll|EFileShareReadersOnly);
   316 	test(r==KErrArgument);
   317 
   318 	r=file.Open(TheFs,_L("\\F32-TST\\NOTIFY\\NewFile.txt"),EFileRead|EFileReadAsyncAll|EFileShareAny);
   319 	test(r==KErrNone);
   320 	file.Read(0, buf, 100, reqStat);
   321 	test(reqStat==KRequestPending);
   322 	file.Close();
   323 	User::WaitForRequest(reqStat);
   324 	test(reqStat==KErrCancel);
   325 
   326 	r=file.Open(TheFs,_L("\\F32-TST\\NOTIFY\\NewFile.txt"),EFileRead|EFileReadAsyncAll|EFileShareAny);
   327 	test(r==KErrNone);
   328 	file.Read(0, buf, 100, reqStat);
   329 	test(reqStat==KRequestPending);
   330 	file.ReadCancel(reqStat);
   331 	User::WaitForRequest(reqStat);
   332 	test(reqStat==KErrCancel);
   333 	file.Close();
   334 
   335 	r=file.Open(TheFs,_L("\\F32-TST\\NOTIFY\\NewFile.txt"),EFileRead|EFileReadAsyncAll|EFileWrite|EFileShareAny);
   336 	test(r==KErrNone);
   337 	file.Read(0, buf, 100, reqStat);
   338 	test(reqStat==KRequestPending);
   339 	file.SetSize(100);
   340 	User::WaitForRequest(reqStat);
   341 	test(reqStat==KErrNone);
   342 	test(buf.Length() == 100);
   343 	file.Close();
   344 
   345 	test.Next(_L("Repeat Test notification of an entry change"));
   346 	TheFs.NotifyChange(ENotifyEntry,reqStat);
   347 	thread.Create(_L("MyThread2"),ThreadEntryPoint,KDefaultStackSize,KHeapSize,KHeapSize,(TAny*)ETest1);
   348 	thread.Logon(thrdStat);
   349 	thread.Resume();
   350 	User::WaitForRequest(thrdStat);
   351 	test(thrdStat==KErrNone);
   352 	thread.Close();
   353 	User::WaitForRequest(reqStat);
   354 	if (reqStat!=KErrNone)
   355 		{
   356 		test.Printf(_L("ReqStat=%d\n"),reqStat.Int());
   357 		//test.Getch();
   358 		}
   359 	test(reqStat==KErrNone);
   360 
   361 	test.Next(_L("Test Notify cancel"));
   362 	TheFs.NotifyChange(ENotifyEntry,reqStat);
   363 	TheFs.NotifyChangeCancel();
   364 	User::WaitForRequest(reqStat);
   365 
   366 	test.Next(_L("Test notification still works"));
   367 	TheFs.NotifyChange(ENotifyEntry,reqStat);
   368 	thread.Create(_L("MyThread3"),ThreadEntryPoint,KDefaultStackSize,KHeapSize,KHeapSize,(TAny*)ETest1);
   369 	thread.Logon(thrdStat);
   370 	thread.Resume();
   371 	User::WaitForRequest(thrdStat);
   372 	test(thrdStat==KErrNone);
   373 	thread.Close();
   374 	User::WaitForRequest(reqStat);
   375 	test(reqStat==KErrNone);
   376 	}
   377 
   378 static void Test2()
   379 //
   380 // Test notify for multiple clients
   381 //
   382 	{
   383 
   384 	test.Next(_L("Test notification of multiple clients"));
   385 
   386 	TRequestStatus reqStat1(KRequestPending);
   387 	RFs fs1;
   388 	TInt r=fs1.Connect();
   389 	test(r==KErrNone);
   390 	fs1.NotifyChange(ENotifyEntry,reqStat1);
   391 
   392 	TRequestStatus reqStat2(KRequestPending);
   393 	RFs fs2;
   394 	r=fs2.Connect();
   395 	test(r==KErrNone);
   396 	fs2.NotifyChange(ENotifyEntry,reqStat2);
   397 
   398 	test(reqStat1==KRequestPending);
   399 	test(reqStat2==KRequestPending);
   400 	r=TheFs.Delete(_L("\\F32-TST\\NOTIFY\\NEWFILE.TXT"));
   401 	test(r==KErrNone);
   402 	User::WaitForRequest(reqStat1);
   403 	User::WaitForRequest(reqStat2);
   404 	test(reqStat1==KErrNone);
   405 	test(reqStat2==KErrNone);
   406 	}
   407 
   408 static void Test3()
   409 //
   410 // Test notify cancel
   411 //
   412 	{
   413 
   414 	test.Next(_L("Cancel notification"));
   415 	RFs fs1;
   416 	TInt r=fs1.Connect();
   417 	test(r==KErrNone);
   418 
   419 	TRequestStatus status1;
   420 	TRequestStatus status2;
   421 	TRequestStatus status3;
   422 	TRequestStatus status4;
   423 	TRequestStatus status5;
   424 
   425 	fs1.NotifyChange(ENotifyAll,status1);
   426 	fs1.NotifyChange(ENotifyAll,status2);
   427 	fs1.NotifyChange(ENotifyAll,status3);
   428 	fs1.NotifyChange(ENotifyAll,status4);
   429 	fs1.NotifyChange(ENotifyAll,status5);
   430 	test(status1==KRequestPending);
   431 	test(status2==KRequestPending);
   432 	test(status3==KRequestPending);
   433 	test(status4==KRequestPending);
   434 	test(status5==KRequestPending);
   435 
   436 	test.Next(_L("RFs::NotifyCancel()"));
   437 //	Test that one call to RFs::NotifyCancel() cancels all outstanding requests
   438 	fs1.NotifyChangeCancel();
   439 	User::WaitForRequest(status1);
   440 	test(status1==KErrCancel);
   441 	User::WaitForRequest(status2);
   442 	test(status2==KErrCancel);
   443 	User::WaitForRequest(status3);
   444 	test(status3==KErrCancel);
   445 	User::WaitForRequest(status4);
   446 	test(status4==KErrCancel);
   447 	User::WaitForRequest(status5);
   448 	test(status5==KErrCancel);
   449 //	Call the cancel function again to check no further action
   450 	fs1.NotifyChangeCancel();
   451 
   452 //	Test overloaded function to cancel a single request
   453 	test.Next(_L("Cancel notification request using function overload"));
   454 	fs1.NotifyChange(ENotifyAll,status1);
   455 	fs1.NotifyChange(ENotifyAll,status2);
   456 	fs1.NotifyChange(ENotifyAll,status3);
   457 	fs1.NotifyChange(ENotifyAll,status4);
   458 	fs1.NotifyChange(ENotifyAll,status5);
   459 	test(status1==KRequestPending);
   460 	test(status2==KRequestPending);
   461 	test(status3==KRequestPending);
   462 	test(status4==KRequestPending);
   463 	test(status5==KRequestPending);
   464 
   465 //	Cancel the outstanding request with status5
   466 	test.Next(_L("RFs::NotifyCancel()"));
   467 	fs1.NotifyChangeCancel(status5);
   468 	User::WaitForRequest(status5);
   469 	test(status1==KRequestPending);
   470 	test(status2==KRequestPending);
   471 	test(status3==KRequestPending);
   472 	test(status4==KRequestPending);
   473 	test(status5==KErrCancel);
   474 
   475 	fs1.NotifyChangeCancel(status2);
   476 	User::WaitForRequest(status2);
   477 
   478 	test(status1==KRequestPending);
   479 	test(status2==KErrCancel);
   480 	test(status3==KRequestPending);
   481 	test(status4==KRequestPending);
   482 
   483 	fs1.NotifyChangeCancel(status4);
   484 	User::WaitForRequest(status4);
   485 	test(status1==KRequestPending);
   486 	test(status3==KRequestPending);
   487 	test(status4==KErrCancel);
   488 
   489 	fs1.NotifyChangeCancel(status4);	//	Test no side effects on trying to cancel a request
   490 	test(status4==KErrCancel);			//	that has already been cancelled
   491 
   492 	fs1.NotifyChangeCancel(status1);
   493 	User::WaitForRequest(status1);
   494 	test(status1==KErrCancel);
   495 	test(status3==KRequestPending);
   496 	fs1.NotifyChangeCancel(status1);	//	Test no side effects on trying to cancel a request
   497 	test(status1==KErrCancel);			//	that has already been cancelled
   498 
   499 	fs1.NotifyChangeCancel(status3);
   500 	User::WaitForRequest(status3);
   501 	test(status3==KErrCancel);
   502 
   503 	fs1.Close();
   504 	}
   505 
   506 static void Test4()
   507 //
   508 // Test notify client death
   509 //
   510 	{
   511 
   512 	test.Next(_L("Kill client"));
   513 	TInt r=gSleepThread.CreateLocal(0);
   514 	test(r==KErrNone);
   515 	RThread clientThread;
   516 	r=clientThread.Create(_L("ClientThread"),ThreadEntryPoint,0x4000,KHeapSize,KHeapSize,(TAny*)ETest4);
   517 	if (r!=KErrNone)
   518 		{
   519 		test.Printf(_L(" ERROR: Failed to create clientthread %d\n"),r);
   520 		test(0);
   521 		//test.Getch();
   522 		return;
   523 		}
   524 	clientThread.Resume();
   525 	gSleepThread.Wait();
   526 
   527 	TBool jit = User::JustInTime();
   528 	User::SetJustInTime(EFalse);
   529 	clientThread.Panic(_L("Test client thread panic"),KErrGeneral);
   530 	User::SetJustInTime(jit);
   531 
   532 	clientThread.Close();
   533 
   534 	r=TheFs.MkDir(_L("\\F32-TST\\NOTIFY\\"));
   535 	test(r==KErrNone || r==KErrAlreadyExists);
   536 	MakeFile(_L("\\F32-TST\\NOTIFY\\NewFile.Txt"));
   537 	User::After(1000);
   538 	}
   539 
   540 static void Test5()
   541 //
   542 // Test reads and writes do not cause notification
   543 //
   544 	{
   545 
   546 	test.Next(_L("Test reads and writes do not cause notification"));
   547 
   548 
   549 	RFile file;
   550 	TInt r=file.Replace(TheFs,_L("\\F32-TST\\NOTIFY\\kangaroo.txt"),EFileRead|EFileWrite);
   551 	test(r==KErrNone);
   552 	file.Close();
   553 	r=file.Replace(TheFs,_L("\\F32-TST\\NOTIFY\\koala.txt"),EFileRead|EFileWrite);
   554 	test(r==KErrNone);
   555 	file.Close();
   556 	r=file.Replace(TheFs,_L("\\F32-TST\\NOTIFY\\dingo.txt"),EFileRead|EFileWrite);
   557 	test(r==KErrNone);
   558 	file.Close();
   559 
   560 	TRequestStatus reqStat=0;
   561 	TheFs.NotifyChange(ENotifyEntry,reqStat);
   562 	test(reqStat==KRequestPending);
   563 
   564 	r=gSleepThread.CreateLocal(0);
   565 	test(r==KErrNone);
   566 	RThread clientThread;
   567 	r=clientThread.Create(_L("Test5Thread"),ThreadEntryPoint,0x4000,KHeapSize,KHeapSize,(TAny*)ETest5);
   568 	test(r==KErrNone);
   569 	clientThread.Resume();
   570 	gSleepThread.Wait();
   571 	test(reqStat==KRequestPending);
   572 
   573 	r=TheFs.Delete(_L("\\F32-TST\\NOTIFY\\kangaroo.txt"));
   574 	test(r==KErrNone);
   575 	User::WaitForRequest(reqStat);
   576 	test(reqStat==KErrNone);
   577 
   578 	r=TheFs.Delete(_L("\\F32-TST\\NOTIFY\\koala.txt"));
   579 	test(r==KErrNone);
   580 	r=TheFs.Delete(_L("\\F32-TST\\NOTIFY\\dingo.txt"));
   581 	test(r==KErrNone);
   582 
   583 
   584 
   585 	gSleepThread.Close();
   586 	clientThread.Close();
   587 	}
   588 
   589 #if defined (__EPOC32__)//we have no removable media on Emulator yet	.. ??? we do now
   590 static void Test6()
   591 //
   592 //	Test media change notification
   593 //
   594 	{
   595 	TDriveInfo driveInfo;
   596 	TInt r=TheFs.Drive(driveInfo,CurrentDrive());
   597 	test(r==KErrNone);
   598 	// only test on removable media
   599 	if (driveInfo.iDriveAtt&KDriveAttRemovable)
   600         {
   601         TBuf<64> b;
   602         b.Format(_L("Test Media change notification (socket:%d)"),gSocketNumber);
   603         test.Next(b);
   604         TRequestStatus reqStat=0;
   605         TInt r;
   606         TheFs.NotifyChange(ENotifyEntry,reqStat);
   607         test(reqStat==KRequestPending);
   608         r=gSleepThread.CreateLocal(0);
   609         test(r==KErrNone);
   610         RThread clientThread;
   611         r=clientThread.Create(_L("Test6Thread"),ThreadEntryPoint,0x4000,KHeapSize,KHeapSize,(TAny*)ETest6);
   612         test(r==KErrNone);
   613         clientThread.Resume();
   614         gSleepThread.Wait();
   615         TInt reqInt=reqStat.Int();
   616         test(reqInt==KErrNone);
   617         User::WaitForRequest(reqStat);
   618         WaitForMediaChange();
   619         gSleepThread.Close();
   620         clientThread.Close();
   621         }
   622 	
   623         //-- it seems that after generating media change the meia driver isn't ready for some time
   624         User::After(2000000);
   625 	    r=TheFs.Drive(driveInfo,CurrentDrive());
   626 	    test(r==KErrNone);
   627 
   628     
   629     }
   630 #endif
   631 
   632 static void Test7()
   633 //
   634 // Test Write to uid region does not trigger notification
   635 //
   636 	{
   637 
   638 	test.Next(_L("Test Write to uid region does not trigger notification"));
   639 	TRequestStatus reqStat=0;
   640 	MakeFile(_L("NewFile.TXT"));
   641 	TInt r;
   642 	TheFs.NotifyChange(ENotifyEntry,reqStat);
   643 	test(reqStat==KRequestPending);
   644 
   645 	r=gSleepThread.CreateLocal(0);
   646 	test(r==KErrNone);
   647 	RThread clientThread;
   648 	r=clientThread.Create(_L("Test7Thread"),ThreadEntryPoint,0x4000,KHeapSize,KHeapSize,(TAny*)ETest7);
   649 	test(r==KErrNone);
   650 	clientThread.Resume();
   651 	gSleepThread.Wait();
   652 	test(reqStat==KRequestPending);
   653 
   654 	r=TheFs.Delete(_L("Newfile.txt"));
   655 	test(r==KErrNone);
   656 
   657 	User::WaitForRequest(reqStat);
   658 
   659 	gSleepThread.Close();
   660 	clientThread.Close();
   661 	}
   662 
   663 #if defined (__EPOC32__)//we have no removable media on Emulator yet
   664 static void MediaChangeExtendedNotification()
   665 //
   666 //	Test media change notification
   667 //	Always notified of media change - regardless of requested TNotifyType
   668 //
   669 	{
   670 	TDriveInfo driveInfo;
   671 	TInt r=TheFs.Drive(driveInfo,CurrentDrive());
   672 	test(r==KErrNone);
   673 	// only test on removable media
   674 	if (driveInfo.iDriveAtt&KDriveAttRemovable)
   675 		{
   676 		test.Next(_L("Test Media change extended notification"));
   677 		TRequestStatus reqStat=0;
   678 		TFileName path = _L("\\F32-tst\\NOTIFY\\");
   679 		TInt r;
   680 		TheFs.NotifyChange(ENotifyEntry,reqStat,path);
   681 		test(reqStat==KRequestPending);
   682 		r=gSleepThread.CreateLocal(0);
   683 		test(r==KErrNone);
   684 		RThread clientThread;
   685 		gSocketNumber=0;
   686 		r=clientThread.Create(_L("Test6Thread1"),ThreadEntryPoint,0x4000,KHeapSize,KHeapSize,(TAny*)ETest6);	//only generates a media change on removable media
   687 		test(r==KErrNone);
   688 		clientThread.Resume();
   689 		gSleepThread.Wait();
   690 		User::WaitForRequest(reqStat);
   691 		test(reqStat==KErrNone);
   692 		WaitForMediaChange();
   693 		gSleepThread.Close();
   694 		clientThread.Close();
   695 
   696         //-- it seems that after generating media change the meia driver isn't ready for some time
   697         User::After(2000000);
   698 	    r=TheFs.Drive(driveInfo,CurrentDrive());
   699 	    test(r==KErrNone);
   700 
   701 
   702 		TheFs.NotifyChange(ENotifyDisk,reqStat,path);
   703 		test(reqStat==KRequestPending);
   704 		r=gSleepThread.CreateLocal(0);
   705 		test(r==KErrNone);
   706 		r=clientThread.Create(_L("Test6Thread2"),ThreadEntryPoint,0x4000,KHeapSize,KHeapSize,(TAny*)ETest6);
   707 		test(r==KErrNone);
   708 		clientThread.Resume();
   709 		gSleepThread.Wait();
   710 		User::WaitForRequest(reqStat);
   711 		test(reqStat==KErrNone);
   712 		WaitForMediaChange();
   713 		gSleepThread.Close();
   714 		clientThread.Close();
   715 
   716         //-- it seems that after generating media change the meia driver isn't ready for some time
   717         User::After(2000000);
   718 	    r=TheFs.Drive(driveInfo,CurrentDrive());
   719 	    test(r==KErrNone);
   720 
   721 		TheFs.NotifyChange(ENotifyWrite,reqStat,path);
   722 		test(reqStat==KRequestPending);
   723 		r=gSleepThread.CreateLocal(0);
   724 		test(r==KErrNone);
   725 		r=clientThread.Create(_L("Test6Thread3"),ThreadEntryPoint,0x4000,KHeapSize,KHeapSize,(TAny*)ETest6);
   726 		test(r==KErrNone);
   727 		clientThread.Resume();
   728 		gSleepThread.Wait();
   729 		User::WaitForRequest(reqStat);
   730 		test(reqStat==KErrNone);
   731 		WaitForMediaChange();
   732 		gSleepThread.Close();
   733 		clientThread.Close();
   734 
   735         //-- it seems that after generating media change the meia driver isn't ready for some time
   736         User::After(2000000);
   737 	    r=TheFs.Drive(driveInfo,CurrentDrive());
   738 	    test(r==KErrNone);
   739 
   740 		}
   741 	}
   742 #endif
   743 
   744 static void TestRequestAhead()
   745 //
   746 //	Test extended notification works when path initially does not exist
   747 //
   748 	{
   749 	test.Next(_L("Test Request Ahead"));
   750 //	First a simple example
   751 
   752 	TInt r=TheFs.RmDir(_L("\\F32-TST\\NOTIFY\\BehindTheCurtain\\"));
   753 	test((r==KErrNotFound)||(r==KErrPathNotFound)||(r==KErrNone));
   754 
   755 	TFileName path=_L("\\F32-TST\\NOTIFY\\BehindTheCurtain\\");
   756 	TRequestStatus reqStat(KRequestPending);
   757 	TheFs.NotifyChange(ENotifyEntry,reqStat,path);
   758 	test(reqStat==KRequestPending);
   759 
   760 	r=TheFs.MkDir(_L("\\F32-TST\\NOTIFY\\BehindTheCurtain\\"));
   761 	test(r==KErrNone);
   762 
   763 	User::WaitForRequest(reqStat);
   764 	test(reqStat==KErrNone);
   765 
   766 	path=_L("\\F32-TST\\NOTIFY\\BehindTheCurtain\\PayNoAttention.man");
   767 	TheFs.NotifyChange(ENotifyEntry,reqStat,path);
   768 	test(reqStat==KRequestPending);
   769 
   770 	RFile file;
   771 	r=file.Replace(TheFs,path,EFileStream);
   772 	test(r==KErrNone);
   773 	file.Close();
   774 
   775 	User::WaitForRequest(reqStat);
   776 	test(reqStat==KErrNone);
   777 
   778 	r=TheFs.Delete(path);
   779 	test(r==KErrNone);
   780 
   781 	TheFs.NotifyChange(ENotifyEntry,reqStat,path);
   782 	test(reqStat==KRequestPending);
   783 //	Now cancel the outstanding request
   784 	TheFs.NotifyChangeCancel(reqStat);
   785 	User::WaitForRequest(reqStat);
   786 	test(reqStat==KErrCancel);
   787 
   788 //	Repeat with a ENotifyFile request
   789 	TheFs.NotifyChange(ENotifyFile,reqStat,path);
   790 	test(reqStat==KRequestPending);
   791 
   792 	r=file.Replace(TheFs,path,EFileStream);
   793 	test(r==KErrNone);
   794 	file.Close();
   795 
   796 	User::WaitForRequest(reqStat);
   797 	test(reqStat==KErrNone);
   798 
   799 	r=TheFs.Delete(path);
   800 	test(r==KErrNone);
   801 
   802 	TheFs.NotifyChange(ENotifyFile,reqStat,path);
   803 	test(reqStat==KRequestPending);
   804 //	Now cancel the outstanding request
   805 	TheFs.NotifyChangeCancel(reqStat);
   806 	User::WaitForRequest(reqStat);
   807 	test(reqStat==KErrCancel);
   808 
   809 //	Repeat with an ENotifyAttributes request
   810 	TheFs.NotifyChange(ENotifyAttributes,reqStat,path);
   811 	test(reqStat==KRequestPending);
   812 
   813 	r=file.Replace(TheFs,path,EFileStream);
   814 	test(r==KErrNone);
   815 	file.Close();
   816 
   817 	User::WaitForRequest(reqStat);
   818 	test(reqStat==KErrNone);	//	Monitoring attributes but informed anyway
   819 
   820 	r=TheFs.Delete(path);
   821 	test(r==KErrNone);
   822 
   823 	TheFs.NotifyChange(ENotifyAttributes,reqStat,path);
   824 	test(reqStat==KRequestPending);
   825 //	Now cancel the outstanding request
   826 	TheFs.NotifyChangeCancel(reqStat);
   827 	User::WaitForRequest(reqStat);
   828 	test(reqStat==KErrCancel);
   829 
   830 //	Repeat with an ENotifyWrite request
   831 	TheFs.NotifyChange(ENotifyWrite,reqStat,path);
   832 	test(reqStat==KRequestPending);
   833 
   834 	r=file.Replace(TheFs,path,EFileStream);
   835 	test(r==KErrNone);
   836 	file.Close();
   837 
   838 	User::WaitForRequest(reqStat);
   839 	test(reqStat==KErrNone);	//	Monitoring file writing but informed anyway
   840 
   841 	r=TheFs.Delete(path);
   842 	test(r==KErrNone);
   843 
   844 	TheFs.NotifyChange(ENotifyWrite,reqStat,path);
   845 	test(reqStat==KRequestPending);
   846 //	Now cancel the outstanding request
   847 	TheFs.NotifyChangeCancel(reqStat);
   848 	User::WaitForRequest(reqStat);
   849 	test(reqStat==KErrCancel);
   850 
   851 //	Repeat with an ENotifyDisk request
   852 	TheFs.NotifyChange(ENotifyDisk,reqStat,path);
   853 	test(reqStat==KRequestPending);
   854 
   855 	r=file.Replace(TheFs,path,EFileStream);
   856 	test(r==KErrNone);
   857 	file.Close();
   858 
   859 	User::WaitForRequest(reqStat);
   860 	test(reqStat==KErrNone);	//	Monitoring disk activity but informed anyway
   861 
   862 	r=TheFs.Delete(path);
   863 	test(r==KErrNone);
   864 
   865 	TheFs.NotifyChange(ENotifyAttributes,reqStat,path);
   866 	test(reqStat==KRequestPending);
   867 //	Now cancel the outstanding request
   868 	TheFs.NotifyChangeCancel(reqStat);
   869 	User::WaitForRequest(reqStat);
   870 	test(reqStat==KErrCancel);
   871 
   872 //	Now do much the same with directory monitoring
   873 	path=_L("\\F32-TST\\NOTIFY\\BehindTheCurtain\\");
   874 	TheFs.RmDir(path);
   875 
   876 	TheFs.NotifyChange(ENotifyDir,reqStat,path);
   877 	test(reqStat==KRequestPending);
   878 
   879 	TheFs.MkDir(path);
   880 	test(r==KErrNone);
   881 
   882 	User::WaitForRequest(reqStat);
   883 	test(reqStat==KErrNone);
   884 
   885 	TheFs.RmDir(path);
   886 	test(r==KErrNone);
   887 
   888 	TheFs.NotifyChange(ENotifyDir,reqStat,path);
   889 	test(r==KErrNone);
   890 	test(reqStat==KRequestPending);
   891 
   892 //	Now cancel the outstanding request
   893 	TheFs.NotifyChangeCancel(reqStat);
   894 	User::WaitForRequest(reqStat);
   895 	test(reqStat==KErrCancel);
   896 
   897 	TheFs.NotifyChange(ENotifyDir,reqStat,path);
   898 	test(r==KErrNone);
   899 	test(reqStat==KRequestPending);
   900 
   901 //	Get a separate thread to create the directory
   902 	RThread thread;
   903 	thread.Create(_L("RequestAheadyThready"),ThreadEntryPoint,KDefaultStackSize,KHeapSize,KHeapSize,(TAny*)ETest10);
   904 	TRequestStatus thrdStat(KRequestPending);
   905 	thread.Logon(thrdStat);
   906 	thread.Resume();
   907 	thread.Close();
   908 
   909 	User::WaitForRequest(thrdStat);
   910 	test(thrdStat==KErrNone);
   911 	User::WaitForRequest(reqStat);
   912 	test(reqStat==KErrNone);
   913 
   914 	TheFs.RmDir(path);
   915 	test(r==KErrNone);
   916 
   917 //	Check that notification is not received for a non-existent file if only the previously
   918 //	non existent directory that contains it is created
   919 	path=_L("\\F32-TST\\NOTIFY\\BehindTheCurtain\\PayNoAttention.man");
   920 	TheFs.NotifyChange(ENotifyEntry,reqStat,path);
   921 	test(r==KErrNone);
   922 	test(reqStat==KRequestPending);
   923 
   924 	thread.Create(_L("RequestAheadThread"),ThreadEntryPoint,KDefaultStackSize,KHeapSize,KHeapSize,(TAny*)ETest10);
   925 	thread.Logon(thrdStat);
   926 	thread.Resume();
   927 	thread.Close();
   928 
   929 	User::WaitForRequest(thrdStat);
   930 	test(thrdStat==KErrNone);
   931 	test(reqStat==KRequestPending);
   932 
   933 //	Now get a thread to create the file
   934 	thread.Create(_L("RequestAhead"),ThreadEntryPoint,KDefaultStackSize,KHeapSize,KHeapSize,(TAny*)ETest11);
   935 	thread.Logon(thrdStat);
   936 	thread.Resume();
   937 	User::WaitForRequest(thrdStat);
   938 	test(thrdStat==KErrNone);
   939 	thread.Close();
   940 
   941 	User::WaitForRequest(reqStat);
   942 	test(reqStat==KErrNone);
   943 
   944 	TheFs.Delete(path);
   945 	test(r==KErrNone);
   946 
   947 	TheFs.NotifyChange(ENotifyEntry,reqStat,path);
   948 	test(r==KErrNone);
   949 	test(reqStat==KRequestPending);
   950 
   951 //	Now cancel the outstanding request
   952 	TheFs.NotifyChangeCancel(reqStat);
   953 	User::WaitForRequest(reqStat);
   954 	test(reqStat==KErrCancel);
   955 
   956 	path=_L("\\F32-TST\\NOTIFY\\BehindTheCurtain\\");
   957 	TheFs.RmDir(path);
   958 	test(r==KErrNone);
   959 	}
   960 
   961 
   962 static void Test8()
   963 //
   964 // Test extended notification of an entry change
   965 //
   966 	{
   967 //	Test notification of an entry change in directory F32-TST
   968 	test.Next(_L("Test notification of an entry change"));
   969 	TRequestStatus reqStat(KRequestPending);
   970 	TRequestStatus thrdStat(KRequestPending);
   971 	TFileName path=(_L("\\F32-TST\\"));
   972 
   973 	TheFs.NotifyChange(ENotifyEntry,reqStat,path);
   974 	test(reqStat==KRequestPending);
   975 	RThread thread;
   976 	TInt r=thread.Create(_L("MyThread"),ThreadEntryPoint,KDefaultStackSize,KHeapSize,KHeapSize,(TAny*)ETest1);
   977 	test(r==KErrNone);
   978 	thread.Logon(thrdStat);
   979 	thread.Resume();
   980 	User::WaitForRequest(thrdStat);
   981 	test(thrdStat==KErrNone);
   982 	User::WaitForRequest(reqStat);
   983 	test(reqStat==KErrNone);
   984 	thread.Close();
   985 
   986 //	Repeat the test
   987 	test.Next(_L("Repeat Test notification of an entry change"));
   988 	TheFs.NotifyChange(ENotifyEntry,reqStat,path);
   989 	test(reqStat==KRequestPending);
   990 	r=thread.Create(_L("MyThread2"),ThreadEntryPoint,KDefaultStackSize,KHeapSize,KHeapSize,(TAny*)ETest1);
   991 	test(r==KErrNone);
   992 	thread.Logon(thrdStat);
   993 	thread.Resume();
   994 	User::WaitForRequest(thrdStat);
   995 	test(thrdStat==KErrNone);
   996 	User::WaitForRequest(reqStat);
   997 	test(reqStat==KErrNone);
   998 	thread.Close();
   999 
  1000 //	Test it can be cancelled
  1001 	test.Next(_L("Test Notify cancel"));
  1002 	TheFs.NotifyChange(ENotifyEntry,reqStat,path);
  1003 	test(reqStat==KRequestPending);
  1004 	TheFs.NotifyChangeCancel();
  1005 	User::WaitForRequest(reqStat);
  1006 	test(reqStat==KErrCancel);
  1007 
  1008 //	Test it can be notified again
  1009 	test.Next(_L("Test notification still works"));
  1010 	TheFs.NotifyChange(ENotifyEntry,reqStat,path);
  1011 	test(reqStat==KRequestPending);
  1012 	r=thread.Create(_L("MyThread3"),ThreadEntryPoint,KDefaultStackSize,KHeapSize,KHeapSize,(TAny*)ETest1);
  1013 	test(r==KErrNone);
  1014 	thread.Logon(thrdStat);
  1015 	thread.Resume();
  1016 	User::WaitForRequest(thrdStat);
  1017 	test(thrdStat==KErrNone);
  1018 	User::WaitForRequest(reqStat);
  1019 	test(reqStat==KErrNone);
  1020 	thread.Close();
  1021 
  1022 //	Test notification doesn't occur when a change occurs above the directory monitored
  1023 //	(Notification of rename events occurring above the directory which affect the path
  1024 //	will occur - this is tested for in Test18())
  1025 	test.Next(_L("Test changing above monitored directory"));
  1026 	r=TheFs.MkDir(_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\"));
  1027 	test((r==KErrNone)||(r==KErrAlreadyExists));
  1028 	path=_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\");
  1029 	TheFs.NotifyChange(ENotifyEntry,reqStat,path);
  1030 	test(reqStat==KRequestPending);
  1031 	r=thread.Create(_L("MyThread4"),ThreadEntryPoint,KDefaultStackSize,KHeapSize,KHeapSize,(TAny*)ETest1);
  1032 	test(r==KErrNone);
  1033 	thread.Logon(thrdStat);
  1034 	thread.Resume();
  1035 	User::WaitForRequest(thrdStat);
  1036 	test(thrdStat==KErrNone);
  1037 	User::After(500000);
  1038 	thread.Close();
  1039 	test(reqStat==KRequestPending);
  1040 	TheFs.NotifyChangeCancel();
  1041 	User::WaitForRequest(reqStat);
  1042 	test(reqStat==KErrCancel);
  1043 
  1044 //	Test notification occurs when a change is made to the subdirectory monitored
  1045 	test.Next(_L("Create a file in monitored subdirectory"));
  1046 	TheFs.NotifyChange(ENotifyEntry,reqStat,path);
  1047 	test(reqStat==KRequestPending);
  1048 	r=thread.Create(_L("MyThread5"),ThreadEntryPoint,KDefaultStackSize,KHeapSize,KHeapSize,(TAny*)ETest2);
  1049 	test(r==KErrNone);
  1050 	thread.Logon(thrdStat);
  1051 	thread.Resume();
  1052 	User::WaitForRequest(thrdStat);
  1053 	test(thrdStat==KErrNone);
  1054 	User::WaitForRequest(reqStat);
  1055 	test(reqStat==KErrNone);
  1056 	thread.Close();
  1057 
  1058 	test.Next(_L("Create a directory in monitored subdirectory"));
  1059 	TheFs.NotifyChange(ENotifyEntry,reqStat,path);
  1060 	test(reqStat==KRequestPending);
  1061 	r=thread.Create(_L("MyThread6"),ThreadEntryPoint,KDefaultStackSize,KHeapSize,KHeapSize,(TAny*)ETest3);
  1062 	test(r==KErrNone);
  1063 	thread.Logon(thrdStat);
  1064 	thread.Resume();
  1065 	User::WaitForRequest(thrdStat);
  1066 	test(thrdStat==KErrNone);
  1067 	User::WaitForRequest(reqStat);
  1068 	test(reqStat==KErrNone);
  1069 	thread.Close();
  1070 
  1071 	TheFs.NotifyChange(ENotifyEntry,reqStat,path);
  1072 	test(reqStat==KRequestPending);
  1073 	r=TheFs.MkDir(_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\SCARECROW\\TINMAN\\"));
  1074 	test(r==KErrNone);
  1075 	User::WaitForRequest(reqStat);
  1076 	test(reqStat==KErrNone);
  1077 
  1078 
  1079 	r=TheFs.RmDir(_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\SCARECROW\\TINMAN\\"));
  1080 	test(r==KErrNone);
  1081 	r=TheFs.RmDir(_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\SCARECROW\\"));
  1082 	test(r==KErrNone);
  1083 
  1084 //	Test again that notification doesn't occur above the subdirectory being monitored
  1085 	test.Next(_L("Test changing above monitored directory"));
  1086 	r=TheFs.MkDir(_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\"));
  1087 	test((r==KErrNone)||(r==KErrAlreadyExists));
  1088 	path=_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\");
  1089 
  1090 	TheFs.NotifyChange(ENotifyEntry,reqStat,path);
  1091 	test(reqStat==KRequestPending);
  1092 	r=thread.Create(_L("MyThread7"),ThreadEntryPoint,KDefaultStackSize,KHeapSize,KHeapSize,(TAny*)ETest1);
  1093 	test(r==KErrNone);
  1094 	thread.Logon(thrdStat);
  1095 	thread.Resume();
  1096 	User::WaitForRequest(thrdStat);
  1097 	test(thrdStat==KErrNone);
  1098 	User::After(500000);
  1099 	thread.Close();
  1100 	test(reqStat==KRequestPending);
  1101 	TheFs.NotifyChangeCancel();
  1102 	User::WaitForRequest(reqStat);
  1103 	test(reqStat==KErrCancel);
  1104 
  1105 //	Test notification occurs when a change is made to the subdirectory monitored
  1106 	test.Next(_L("Delete a file in monitored subdirectory"));
  1107 	TheFs.NotifyChange(ENotifyEntry,reqStat,path);
  1108 	test(reqStat==KRequestPending);
  1109 	r=TheFs.Delete(_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Dorothy.doc"));
  1110 	test(r==KErrNone);
  1111 	User::WaitForRequest(reqStat);
  1112 	test(reqStat==KErrNone);
  1113 
  1114 	RFile file;
  1115 	r=file.Replace(TheFs,_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\WickedWitch.msg"),EFileStream);
  1116 	test(r==KErrNone);
  1117 	file.Close();
  1118 
  1119 //	Test notification on a specific file
  1120 	test.Next(_L("Monitor changes to a specific file"));
  1121 	path+=_L("WickedWitch.msg");
  1122 	TheFs.NotifyChange(ENotifyAll,reqStat,path);
  1123 	test(reqStat==KRequestPending);
  1124 	r=thread.Create(_L("MyThread8"),ThreadEntryPoint,KDefaultStackSize,KHeapSize,KHeapSize,(TAny*)ETest8);
  1125 	test(r==KErrNone);
  1126 	thread.Logon(thrdStat);
  1127 	thread.Resume();
  1128 	User::WaitForRequest(thrdStat);
  1129 	test(thrdStat==KErrNone);
  1130 	User::WaitForRequest(reqStat);
  1131 	test(reqStat==KErrNone);
  1132 	thread.Close();
  1133 
  1134 //	Test notification does not occur if a change is made above the file
  1135 	TheFs.NotifyChange(ENotifyEntry,reqStat,path);
  1136 	test(reqStat==KRequestPending);
  1137 	thread.Create(_L("MyThread9"),ThreadEntryPoint,KDefaultStackSize,KHeapSize,KHeapSize,(TAny*)ETest2);
  1138 	thread.Logon(thrdStat);
  1139 	thread.Resume();
  1140 	User::WaitForRequest(thrdStat);
  1141 	test(thrdStat==KErrNone);
  1142 	User::After(500000);
  1143 	thread.Close();
  1144 	test(reqStat==KRequestPending);
  1145 	TheFs.NotifyChangeCancel();
  1146 	User::WaitForRequest(reqStat);
  1147 	test(reqStat==KErrCancel);
  1148 
  1149 //	Test notification occurs when a change is made to the file
  1150 	test.Next(_L("Delete monitored file"));
  1151 	TheFs.NotifyChange(ENotifyEntry,reqStat,path);
  1152 	test(reqStat==KRequestPending);
  1153 	r=TheFs.Delete(_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\WickedWitch.Msg"));
  1154 	test(r==KErrNone);
  1155 	User::WaitForRequest(reqStat);
  1156 	test(reqStat==KErrNone);
  1157 
  1158 //	Test notification request is now submitted on the non existent path successfully
  1159 	TheFs.NotifyChange(ENotifyEntry,reqStat,path);
  1160 	test(reqStat==KRequestPending);
  1161 	TheFs.NotifyChangeCancel(reqStat);
  1162 	User::WaitForRequest(reqStat);
  1163 	test(reqStat==KErrCancel);
  1164 
  1165 	path=_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Dorothy.Doc");
  1166 	TheFs.NotifyChange(ENotifyEntry,reqStat,path);
  1167 	test(reqStat==KRequestPending);
  1168 	r=TheFs.Delete(_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Dorothy.Doc"));
  1169 	test(r==KErrNone);
  1170 	User::WaitForRequest(reqStat);
  1171 	test(reqStat==KErrNone);
  1172 
  1173 	path=_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\");
  1174 	TheFs.NotifyChange(ENotifyEntry,reqStat,path);
  1175 	test(reqStat==KRequestPending);
  1176 	r=TheFs.RmDir(_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\"));
  1177 	test(r==KErrNone);
  1178 	User::WaitForRequest(reqStat);
  1179 	test(reqStat==KErrNone);
  1180 
  1181 //	Submit a request for a path which does not yet exist
  1182 	path=_L("\\F32-TST\\NOTIFY\\GOOD_WITCH\\");
  1183 	TheFs.NotifyChange(ENotifyEntry,reqStat,path);
  1184 	test(reqStat==KRequestPending);
  1185 //	Now create the directory we are waiting on
  1186 	r=TheFs.MkDir(path);
  1187 	test(r==KErrNone);
  1188 //	Make sure the notification has now been received
  1189 	User::WaitForRequest(reqStat);
  1190 	test(reqStat==KErrNone);
  1191 
  1192 //	Submit a request for a file which does not yet exist
  1193 	path=_L("\\F32-TST\\NOTIFY\\GOOD_WITCH\\Red-Shoes.red");
  1194 	TheFs.NotifyChange(ENotifyEntry,reqStat,path);
  1195 	test(reqStat==KRequestPending);
  1196 //	Now create the file we are waiting on
  1197 	r=file.Replace(TheFs,path,EFileStream);
  1198 	test(r==KErrNone);
  1199 	file.Close();
  1200 //	Make sure the notification has now been received
  1201 	User::WaitForRequest(reqStat);
  1202 	test(reqStat==KErrNone);
  1203 //	Submit another notification request and delete the file
  1204 	TheFs.NotifyChange(ENotifyEntry,reqStat,path);
  1205 	test(reqStat==KRequestPending);
  1206 	r=TheFs.Delete(path);
  1207 	test(r==KErrNone);
  1208 	User::WaitForRequest(reqStat);
  1209 	test(reqStat==KErrNone);
  1210 	path=_L("\\F32-TST\\NOTIFY\\GOOD_WITCH\\");
  1211 	TheFs.NotifyChange(ENotifyEntry,reqStat,path);
  1212 	test(reqStat==KRequestPending);
  1213 	r=TheFs.RmDir(path);
  1214 	test(r==KErrNone);
  1215 	User::WaitForRequest(reqStat);
  1216 	test(reqStat==KErrNone);
  1217 	// test passing in an empty string
  1218 	TheFs.NotifyChange(ENotifyEntry,reqStat,_L(""));
  1219 	User::WaitForRequest(reqStat);
  1220 	test(reqStat==KErrArgument);
  1221 	}
  1222 
  1223 static void Test9()
  1224 //
  1225 // Test notify for multiple clients
  1226 //
  1227 	{
  1228 
  1229 	test.Next(_L("Test notification of multiple clients"));
  1230 
  1231 //	Create five sessions monitoring various levels of a directory tree
  1232 
  1233 	TInt r=TheFs.MkDir(_L("\\F32-TST\\NOTIFY\\ANIMAL\\"));
  1234 	test((r==KErrNone)||(r==KErrAlreadyExists));
  1235 	RFile file;
  1236 	r=file.Replace(TheFs,_L("\\F32-TST\\NOTIFY\\ANIMAL\\cat.txt"),EFileStream);
  1237 	test(r==KErrNone);
  1238 	file.Close();
  1239 	r=file.Replace(TheFs,_L("\\F32-TST\\NOTIFY\\ANIMAL\\dog.txt"),EFileStream);
  1240 	test(r==KErrNone);
  1241 	file.Close();
  1242 
  1243 	TFileName path1=_L("\\F32-TST\\");
  1244 	TFileName path2=_L("\\F32-TST\\NOTIFY\\");
  1245 	TFileName path3=_L("\\F32-TST\\NOTIFY\\ANIMAL\\");
  1246 	TFileName path4=_L("\\F32-TST\\NOTIFY\\ANIMAL\\cat.txt");
  1247 	TFileName path5=_L("\\F32-TST\\NOTIFY\\ANIMAL\\dog.txt");
  1248 	TFileName path6=_L("?:\\F32-TST\\");
  1249 
  1250 	TRequestStatus reqStat1(KRequestPending);
  1251 	RFs fs1;
  1252 	r=fs1.Connect();
  1253 	test(r==KErrNone);
  1254 	r=fs1.SetSessionPath(gSessionPath);
  1255 	test(r==KErrNone);
  1256 	fs1.NotifyChange(ENotifyEntry,reqStat1,path1);
  1257 
  1258 	TRequestStatus reqStat2(KRequestPending);
  1259 	RFs fs2;
  1260 	r=fs2.Connect();
  1261 	test(r==KErrNone);
  1262 	r=fs2.SetSessionPath(gSessionPath);
  1263 	test(r==KErrNone);
  1264 	fs2.NotifyChange(ENotifyEntry,reqStat2,path2);
  1265 
  1266 	TRequestStatus reqStat3(KRequestPending);
  1267 	RFs fs3;
  1268 	r=fs3.Connect();
  1269 	test(r==KErrNone);
  1270 	r=fs3.SetSessionPath(gSessionPath);
  1271 	test(r==KErrNone);
  1272 	fs3.NotifyChange(ENotifyEntry,reqStat3,path3);
  1273 
  1274 	TRequestStatus reqStat4(KRequestPending);
  1275 	RFs fs4;
  1276 	r=fs4.Connect();
  1277 	test(r==KErrNone);
  1278 	r=fs4.SetSessionPath(gSessionPath);
  1279 	test(r==KErrNone);
  1280 	fs4.NotifyChange(ENotifyEntry,reqStat4,path4);
  1281 
  1282 	TRequestStatus reqStat5(KRequestPending);
  1283 	RFs fs5;
  1284 	r=fs5.Connect();
  1285 	test(r==KErrNone);
  1286 	r=fs5.SetSessionPath(gSessionPath);
  1287 	test(r==KErrNone);
  1288 	fs5.NotifyChange(ENotifyEntry,reqStat5,path5);
  1289 
  1290 	TRequestStatus reqStat6(KRequestPending);
  1291 	RFs fs6;
  1292 	r=fs6.Connect();
  1293 	test(r==KErrNone);
  1294 	r=fs6.SetSessionPath(gSessionPath);
  1295 	test(r==KErrNone);
  1296 	fs6.NotifyChange(ENotifyEntry,reqStat6,path6);
  1297 
  1298 	test(reqStat1==KRequestPending);
  1299 	test(reqStat2==KRequestPending);
  1300 	test(reqStat3==KRequestPending);
  1301 	test(reqStat4==KRequestPending);
  1302 	test(reqStat5==KRequestPending);
  1303 	test(reqStat6==KRequestPending);
  1304 
  1305 //	Make a change a the top level and check that only the session monitoring
  1306 //	that level is notified
  1307 	test.Next(_L("Test only client monitoring top level is notified"));
  1308 	r=file.Replace(TheFs,_L("\\F32-TST\\NewFile.txt"),EFileStream);
  1309 	test(r==KErrNone);
  1310 	file.Close();
  1311 	User::WaitForRequest(reqStat1);
  1312 	test(reqStat1==KErrNone);
  1313 	test(reqStat2==KRequestPending);
  1314 	test(reqStat3==KRequestPending);
  1315 	test(reqStat4==KRequestPending);
  1316 	test(reqStat5==KRequestPending);
  1317 	User::WaitForRequest(reqStat6);
  1318 	test(reqStat6==KErrNone);
  1319 
  1320 	r=TheFs.Delete(_L("\\F32-TST\\NewFile.txt"));
  1321 	test(r==KErrNone);
  1322 
  1323 //	Renew the notify request at the top level and make a change one step lower
  1324 	fs1.NotifyChange(ENotifyEntry,reqStat1,path1);
  1325 	fs6.NotifyChange(ENotifyEntry,reqStat6,path6);
  1326 	test(reqStat1==KRequestPending);
  1327 	test(reqStat6==KRequestPending);
  1328 
  1329 	test.Next(_L("Test clients monitoring levels 1 and 2 are notified"));
  1330 	r=file.Replace(TheFs,_L("\\F32-TST\\NOTIFY\\NewFile.txt"),EFileStream);
  1331 	test(r==KErrNone);
  1332 	file.Close();
  1333 
  1334 	User::WaitForRequest(reqStat1);
  1335 	User::WaitForRequest(reqStat2);
  1336 	test(reqStat1==KErrNone);
  1337 	test(reqStat2==KErrNone);
  1338 	test(reqStat3==KRequestPending);
  1339 	test(reqStat4==KRequestPending);
  1340 	test(reqStat5==KRequestPending);
  1341 	User::WaitForRequest(reqStat6);
  1342 	test(reqStat6==KErrNone);
  1343 
  1344 	r=TheFs.Delete(_L("\\F32-TST\\NOTIFY\\NewFile.txt"));
  1345 	test(r==KErrNone);
  1346 
  1347 //	Renew the notify request at the top and second levels and make a change
  1348 //	one step lower still
  1349 	fs1.NotifyChange(ENotifyEntry,reqStat1,path1);
  1350 	fs2.NotifyChange(ENotifyEntry,reqStat2,path2);
  1351 	fs6.NotifyChange(ENotifyEntry,reqStat6,path6);
  1352 	test(reqStat1==KRequestPending);
  1353 	test(reqStat2==KRequestPending);
  1354 	test(reqStat6==KRequestPending);
  1355 
  1356 	test.Next(_L("Test clients monitoring levels 1,2 and 3 are notified"));
  1357 	r=file.Replace(TheFs,_L("\\F32-TST\\NOTIFY\\ANIMAL\\NewFile.txt"),EFileStream);
  1358 	test(r==KErrNone);
  1359 	file.Close();
  1360 
  1361 	User::WaitForRequest(reqStat1);
  1362 	User::WaitForRequest(reqStat2);
  1363 	User::WaitForRequest(reqStat3);
  1364 	test(reqStat1==KErrNone);
  1365 	test(reqStat2==KErrNone);
  1366 	test(reqStat3==KErrNone);
  1367 	test(reqStat4==KRequestPending);
  1368 	test(reqStat5==KRequestPending);
  1369 	User::WaitForRequest(reqStat6);
  1370 	test(reqStat6==KErrNone);
  1371 
  1372 	r=TheFs.Delete(_L("\\F32-TST\\NOTIFY\\ANIMAL\\NewFile.txt"));
  1373 	test(r==KErrNone);
  1374 
  1375 //	Renew the notify request at the top, second and third levels and make a change
  1376 //	one step lower still
  1377 	fs1.NotifyChange(ENotifyEntry,reqStat1,path1);
  1378 	fs2.NotifyChange(ENotifyEntry,reqStat2,path2);
  1379 	fs3.NotifyChange(ENotifyEntry,reqStat3,path3);
  1380 	fs6.NotifyChange(ENotifyEntry,reqStat6,path6);
  1381 	test(reqStat1==KRequestPending);
  1382 	test(reqStat2==KRequestPending);
  1383 	test(reqStat3==KRequestPending);
  1384 	test(reqStat6==KRequestPending);
  1385 
  1386 	test.Next(_L("Test clients monitoring levels 1 - 4 are notified"));
  1387 	r=TheFs.Delete(_L("\\F32-TST\\NOTIFY\\ANIMAL\\cat.txt"));
  1388 	test(r==KErrNone);
  1389 	User::WaitForRequest(reqStat1);
  1390 	User::WaitForRequest(reqStat2);
  1391 	User::WaitForRequest(reqStat3);
  1392 	User::WaitForRequest(reqStat4);
  1393 	test(reqStat1==KErrNone);
  1394 	test(reqStat2==KErrNone);
  1395 	test(reqStat3==KErrNone);
  1396 	test(reqStat4==KErrNone);
  1397 	test(reqStat5==KRequestPending);
  1398 	User::WaitForRequest(reqStat6);
  1399 	test(reqStat6==KErrNone);
  1400 
  1401 //	Renew the notify request at the top, second and third levels and on the file deleted above
  1402 //	which will be successful, but will not complete (for obvious reasons)
  1403 
  1404 //	Make a change one step lower still
  1405 	fs1.NotifyChange(ENotifyEntry,reqStat1,path1);
  1406 	fs2.NotifyChange(ENotifyEntry,reqStat2,path2);
  1407 	fs3.NotifyChange(ENotifyEntry,reqStat3,path3);
  1408 	fs6.NotifyChange(ENotifyEntry,reqStat6,path6);
  1409 	fs4.NotifyChange(ENotifyEntry,reqStat4,path4);
  1410 	test(reqStat1==KRequestPending);
  1411 	test(reqStat2==KRequestPending);
  1412 	test(reqStat3==KRequestPending);
  1413 	test(reqStat4==KRequestPending);
  1414 	test(reqStat6==KRequestPending);
  1415 
  1416 	test.Next(_L("Test clients monitoring levels 1 - 3 and 5 are notified"));
  1417 	r=TheFs.Delete(_L("\\F32-TST\\NOTIFY\\ANIMAL\\dog.txt"));
  1418 	test(r==KErrNone);
  1419 	User::WaitForRequest(reqStat1);
  1420 	User::WaitForRequest(reqStat2);
  1421 	User::WaitForRequest(reqStat3);
  1422 //	Don't wait for reqStat4
  1423 	User::WaitForRequest(reqStat5);
  1424 	User::WaitForRequest(reqStat6);
  1425 	test(reqStat1==KErrNone);
  1426 	test(reqStat2==KErrNone);
  1427 	test(reqStat3==KErrNone);
  1428 	test(reqStat4==KRequestPending);	//	File does not exist
  1429 	test(reqStat5==KErrNone);
  1430 	test(reqStat6==KErrNone);
  1431 
  1432 	fs4.NotifyChangeCancel(reqStat4);
  1433 	User::WaitForRequest(reqStat4);
  1434 	test(reqStat4==KErrCancel);
  1435 //	Renew the notify request at the top, second and third levels and attempt to renew
  1436 //	the request on the files deleted above (which will fail).
  1437 
  1438 	test.Next(_L("Test clients monitoring levels 1 - 3 are notified"));
  1439 	fs1.NotifyChange(ENotifyEntry,reqStat1,path1);
  1440 	fs2.NotifyChange(ENotifyEntry,reqStat2,path2);
  1441 	fs3.NotifyChange(ENotifyEntry,reqStat3,path3);
  1442 	fs4.NotifyChange(ENotifyEntry,reqStat4,path4);
  1443 	fs6.NotifyChange(ENotifyEntry,reqStat6,path6);
  1444 	fs5.NotifyChange(ENotifyEntry,reqStat5,path5);
  1445 	test(reqStat1==KRequestPending);
  1446 	test(reqStat2==KRequestPending);
  1447 	test(reqStat3==KRequestPending);
  1448 	test(reqStat4==KRequestPending);
  1449 	test(reqStat5==KRequestPending);
  1450 	test(reqStat6==KRequestPending);
  1451 
  1452 	r=TheFs.RmDir(_L("\\F32-TST\\NOTIFY\\ANIMAL\\"));
  1453 	test(r==KErrNone);
  1454 	User::WaitForRequest(reqStat1);
  1455 	User::WaitForRequest(reqStat2);
  1456 	User::WaitForRequest(reqStat3);
  1457 	test(reqStat1==KErrNone);
  1458 	test(reqStat2==KErrNone);
  1459 	test(reqStat3==KErrNone);
  1460 	test(reqStat4==KRequestPending);
  1461 	test(reqStat5==KRequestPending);
  1462 	User::WaitForRequest(reqStat6);
  1463 	test(reqStat6==KErrNone);
  1464 
  1465 //	Renew the notify request at the top and second levels on the third level
  1466 //	which was removed - it'll succeed but won't complete.
  1467 
  1468 	test.Next(_L("Test clients monitoring levels 1 and 2 are notified"));
  1469 	test.Next(_L("Test clients' attempts to monitor levels 3-5 fail"));
  1470 	fs1.NotifyChange(ENotifyEntry,reqStat1,path1);
  1471 	fs2.NotifyChange(ENotifyEntry,reqStat2,path2);
  1472 	fs3.NotifyChange(ENotifyEntry,reqStat3,path3);
  1473 	fs6.NotifyChange(ENotifyEntry,reqStat6,path6);
  1474 
  1475 	test(reqStat1==KRequestPending);
  1476 	test(reqStat2==KRequestPending);
  1477 	test(reqStat3==KRequestPending);
  1478 	test(reqStat4==KRequestPending);
  1479 	test(reqStat5==KRequestPending);
  1480 	test(reqStat6==KRequestPending);
  1481 
  1482 	fs1.NotifyChangeCancel();
  1483 	fs2.NotifyChangeCancel();
  1484 
  1485 	fs1.Close();
  1486 	fs2.Close();
  1487 //	Close the other sessions with requests outstanding to test that there's no evilness
  1488 	fs3.Close();
  1489 	fs4.Close();
  1490 	fs5.Close();
  1491 	fs6.Close();
  1492 
  1493 	User::WaitForRequest(reqStat1);
  1494 	User::WaitForRequest(reqStat2);
  1495 	// Closing file server sessions doesn't seem to complete notifications, is this a bug?
  1496 //	User::WaitForRequest(reqStat3);
  1497 //	User::WaitForRequest(reqStat4);
  1498 //	User::WaitForRequest(reqStat5);
  1499 //	User::WaitForRequest(reqStat6);
  1500 	}
  1501 
  1502 static void Test10()
  1503 //
  1504 // Test notify cancel
  1505 //
  1506 	{
  1507 
  1508 	test.Next(_L("Cancel notification request using simple function"));
  1509 	TFileName path=_L("\\F32-TST\\NOTIFY\\");
  1510 	RFs fs1;
  1511 	TInt r=fs1.Connect();
  1512 	test(r==KErrNone);
  1513 	r=fs1.SetSessionPath(gSessionPath);
  1514 	test(r==KErrNone);
  1515 
  1516 	TRequestStatus status1;
  1517 	TRequestStatus status2;
  1518 	TRequestStatus status3;
  1519 	TRequestStatus status4;
  1520 	TRequestStatus status5;
  1521 
  1522 	fs1.NotifyChange(ENotifyAll,status1,path);
  1523 	fs1.NotifyChange(ENotifyAll,status2,path);
  1524 	fs1.NotifyChange(ENotifyAll,status3,path);
  1525 	fs1.NotifyChange(ENotifyAll,status4,path);
  1526 	fs1.NotifyChange(ENotifyAll,status5,path);
  1527 	test(status1==KRequestPending);
  1528 	test(status2==KRequestPending);
  1529 	test(status3==KRequestPending);
  1530 	test(status4==KRequestPending);
  1531 	test(status5==KRequestPending);
  1532 
  1533 	test.Next(_L("RFs::NotifyCancel()"));
  1534 //	Test that one call to RFs::NotifyCancel() cancels all outstanding requests
  1535 	fs1.NotifyChangeCancel();
  1536 	User::WaitForRequest(status1);
  1537 	test(status1==KErrCancel);
  1538 	User::WaitForRequest(status2);
  1539 	test(status2==KErrCancel);
  1540 	User::WaitForRequest(status3);
  1541 	test(status3==KErrCancel);
  1542 	User::WaitForRequest(status4);
  1543 	test(status4==KErrCancel);
  1544 	User::WaitForRequest(status5);
  1545 	test(status5==KErrCancel);
  1546 //	Call the cancel function again to check no further action
  1547 	fs1.NotifyChangeCancel();
  1548 
  1549 //	Test overloaded function to cancel a single request
  1550 	test.Next(_L("Cancel notification request using function overload"));
  1551 	fs1.NotifyChange(ENotifyAll,status1,path);
  1552 	fs1.NotifyChange(ENotifyAll,status2,path);
  1553 	fs1.NotifyChange(ENotifyAll,status3,path);
  1554 	fs1.NotifyChange(ENotifyAll,status4,path);
  1555 	fs1.NotifyChange(ENotifyAll,status5,path);
  1556 	test(status1==KRequestPending);
  1557 	test(status2==KRequestPending);
  1558 	test(status3==KRequestPending);
  1559 	test(status4==KRequestPending);
  1560 	test(status5==KRequestPending);
  1561 
  1562 //	Cancel the outstanding request with status5
  1563 	test.Next(_L("RFs::NotifyCancel()"));
  1564 	fs1.NotifyChangeCancel(status5);
  1565 	User::WaitForRequest(status5);
  1566 	test(status1==KRequestPending);
  1567 	test(status2==KRequestPending);
  1568 	test(status3==KRequestPending);
  1569 	test(status4==KRequestPending);
  1570 	test(status5==KErrCancel);
  1571 
  1572 	r=TheFs.MkDir(_L("\\F32-TST\\TROPICANA\\"));
  1573 	test(r==KErrNone);
  1574 	test(status1==KRequestPending);
  1575 	test(status2==KRequestPending);
  1576 	test(status3==KRequestPending);
  1577 	test(status4==KRequestPending);
  1578 
  1579 	fs1.NotifyChangeCancel(status2);
  1580 	User::WaitForRequest(status2);
  1581 
  1582 	test(status1==KRequestPending);
  1583 	test(status2==KErrCancel);
  1584 	test(status3==KRequestPending);
  1585 	test(status4==KRequestPending);
  1586 
  1587 	r=TheFs.RmDir(_L("\\F32-TST\\TROPICANA\\"));
  1588 	test(r==KErrNone);
  1589 	test(status1==KRequestPending);
  1590 	test(status3==KRequestPending);
  1591 	test(status4==KRequestPending);
  1592 
  1593 	fs1.NotifyChangeCancel(status4);
  1594 	User::WaitForRequest(status4);
  1595 	test(status1==KRequestPending);
  1596 	test(status3==KRequestPending);
  1597 	test(status4==KErrCancel);
  1598 
  1599 	fs1.NotifyChangeCancel(status4);	//	Test no side effects on trying to cancel a request
  1600 	test(status4==KErrCancel);			//	that has already been cancelled
  1601 
  1602 	fs1.NotifyChangeCancel(status1);
  1603 	User::WaitForRequest(status1);
  1604 	test(status1==KErrCancel);
  1605 	test(status3==KRequestPending);
  1606 	fs1.NotifyChangeCancel(status1);	//	Test no side effects on trying to cancel a request
  1607 	test(status1==KErrCancel);			//	that has already been cancelled
  1608 
  1609 	fs1.NotifyChangeCancel(status3);
  1610 	User::WaitForRequest(status3);
  1611 	test(status3==KErrCancel);
  1612 
  1613 	fs1.Close();
  1614 	}
  1615 
  1616 static void Test11()
  1617 //
  1618 // Test notify client death
  1619 //
  1620 	{
  1621 
  1622 	test.Next(_L("Kill client while it is monitoring changes to a directory"));
  1623 //	Call CreateLocal to create RSemaphore gSleepThread which is local to this process
  1624 	TInt r=gSleepThread.CreateLocal(0);
  1625 	test(r==KErrNone);
  1626 
  1627 	RThread clientThread;
  1628 	r=clientThread.Create(_L("ClientThread"),ThreadEntryPoint,0x4000,KHeapSize,KHeapSize,(TAny*)ETest9);
  1629 	test(r==KErrNone);
  1630 	clientThread.Resume();
  1631 	gSleepThread.Wait();	//	Wait for gSleepThread to be signalled
  1632 							//	Client thread is waiting for notification of changes
  1633 							//	to directory \\F32-TST\\NOTIFY
  1634 
  1635 	TBool jit = User::JustInTime();
  1636 	User::SetJustInTime(EFalse);
  1637 	clientThread.Panic(_L("Test client thread panic"),KErrGeneral);	//	Panic client
  1638 	User::SetJustInTime(jit);
  1639 
  1640 	clientThread.Close();
  1641 
  1642 //	Make a change and check there's no disaster
  1643 	r=TheFs.MkDir(_L("\\F32-TST\\NOTIFY\\"));
  1644 	test(r==KErrNone || r==KErrAlreadyExists);
  1645 	MakeFile(_L("\\F32-TST\\NOTIFY\\NewFile.Txt"));
  1646 	User::After(1000);
  1647 	}
  1648 
  1649 
  1650 static void Test12()
  1651 //
  1652 // Test reads and writes do not cause notification under ENotifyEntry
  1653 // Test reads and writes do cause notification under ENotifyAll
  1654 //
  1655 	{
  1656 
  1657 	test.Next(_L("Test reads and writes do not cause notification under ENotifyEntry"));
  1658 
  1659 	RFile file;
  1660 	TInt r=file.Replace(TheFs,_L("\\F32-TST\\NOTIFY\\kangaroo.txt"),EFileRead|EFileWrite);
  1661 	test(r==KErrNone);
  1662 	file.Close();
  1663 	r=file.Replace(TheFs,_L("\\F32-TST\\NOTIFY\\koala.txt"),EFileRead|EFileWrite);
  1664 	test(r==KErrNone);
  1665 	file.Close();
  1666 	r=file.Replace(TheFs,_L("\\F32-TST\\NOTIFY\\dingo.txt"),EFileRead|EFileWrite);
  1667 	test(r==KErrNone);
  1668 	file.Close();
  1669 
  1670 	TFileName path=_L("\\F32-TST\\NOTIFY\\");
  1671 	TRequestStatus reqStat1(KRequestPending);
  1672 	RFs fs1;
  1673 	r=fs1.Connect();
  1674 	test(r==KErrNone);
  1675 	r=fs1.SetSessionPath(gSessionPath);
  1676 	test(r==KErrNone);
  1677 	fs1.NotifyChange(ENotifyEntry,reqStat1,path);
  1678 
  1679 	TRequestStatus reqStat2(KRequestPending);
  1680 	RFs fs2;
  1681 	r=fs2.Connect();
  1682 	test(r==KErrNone);
  1683 	r=fs2.SetSessionPath(gSessionPath);
  1684 	test(r==KErrNone);
  1685 	fs2.NotifyChange(ENotifyEntry,reqStat2,path);
  1686 
  1687 	TRequestStatus reqStat3(KRequestPending);
  1688 	RFs fs3;
  1689 	r=fs3.Connect();
  1690 	test(r==KErrNone);
  1691 	r=fs3.SetSessionPath(gSessionPath);
  1692 	test(r==KErrNone);
  1693 	fs3.NotifyChange(ENotifyEntry,reqStat3,path);
  1694 
  1695 	test(reqStat1==KRequestPending);
  1696 	test(reqStat2==KRequestPending);
  1697 	test(reqStat3==KRequestPending);
  1698 
  1699 	r=gSleepThread.CreateLocal(0);
  1700 	test(r==KErrNone);
  1701 	RThread thread1;
  1702 	r=thread1.Create(_L("TestThread1"),ThreadEntryPoint,0x4000,KHeapSize,KHeapSize,(TAny*)ETest5);
  1703 	test(r==KErrNone);
  1704 	thread1.Resume();
  1705 	gSleepThread.Wait();
  1706 
  1707 	test(reqStat1==KRequestPending);
  1708 	test(reqStat2==KRequestPending);
  1709 	test(reqStat3==KRequestPending);
  1710 
  1711 	r=TheFs.Delete(_L("\\F32-TST\\NOTIFY\\kangaroo.txt"));
  1712 	test(r==KErrNone);
  1713 	User::WaitForRequest(reqStat1);
  1714 	User::WaitForRequest(reqStat2);
  1715 	User::WaitForRequest(reqStat3);
  1716 	test(reqStat1==KErrNone);	//	All three notifications occur because they
  1717 	test(reqStat2==KErrNone);	//	are all monitoring the top level directory
  1718 	test(reqStat3==KErrNone);	//	Later, we'll test monitoring individual files...
  1719 
  1720 	gSleepThread.Close();
  1721 	thread1.Close();
  1722 
  1723 	test.Next(_L("Test reads and writes do cause notification under ENotifyAll"));
  1724 	r=file.Replace(TheFs,_L("\\F32-TST\\NOTIFY\\kangaroo.txt"),EFileRead|EFileWrite);
  1725 	test(r==KErrNone);
  1726 	file.Close();
  1727 
  1728 	fs1.NotifyChange(ENotifyAll,reqStat1,path);
  1729 	fs2.NotifyChange(ENotifyAll,reqStat2,path);
  1730 	fs3.NotifyChange(ENotifyAll,reqStat3,path);
  1731 
  1732 	test(reqStat1==KRequestPending);
  1733 	test(reqStat2==KRequestPending);
  1734 	test(reqStat3==KRequestPending);
  1735 
  1736 	r=gSleepThread.CreateLocal(0);
  1737 	test(r==KErrNone);
  1738 	RThread thread2;
  1739 	r=thread2.Create(_L("TestThread2"),ThreadEntryPoint,0x4000,KHeapSize,KHeapSize,(TAny*)ETest5);
  1740 	test(r==KErrNone);
  1741 	thread2.Resume();
  1742 	gSleepThread.Wait();
  1743 
  1744 	User::WaitForRequest(reqStat1);
  1745 	User::WaitForRequest(reqStat2);
  1746 	User::WaitForRequest(reqStat3);
  1747 	test(reqStat1==KErrNone);
  1748 	test(reqStat2==KErrNone);
  1749 	test(reqStat3==KErrNone);
  1750 
  1751 	gSleepThread.Close();
  1752 	thread2.Close();
  1753 
  1754 	test.Next(_L("Monitor reads and writes on specific files with either TNotifyType"));
  1755 	TFileName path1=path;
  1756 	TFileName path2=path;
  1757 	TFileName path3=path;
  1758 	path1+=_L("kangaroo.txt");
  1759 	path2+=_L("koala.txt");
  1760 	path3+=_L("dingo.txt");
  1761 
  1762 	fs1.NotifyChange(ENotifyAll,reqStat1,path1);
  1763 	fs2.NotifyChange(ENotifyEntry,reqStat2,path2);
  1764 	fs3.NotifyChange(ENotifyAll,reqStat3,path3);
  1765 
  1766 	test(reqStat1==KRequestPending);
  1767 	test(reqStat2==KRequestPending);
  1768 	test(reqStat3==KRequestPending);
  1769 
  1770 	r=gSleepThread.CreateLocal(0);
  1771 	test(r==KErrNone);
  1772 	RThread thread3;
  1773 	r=thread3.Create(_L("TestThread3"),ThreadEntryPoint,0x4000,KHeapSize,KHeapSize,(TAny*)ETest5);
  1774 	test(r==KErrNone);
  1775 	thread3.Resume();
  1776 	gSleepThread.Wait();
  1777 
  1778 	User::WaitForRequest(reqStat1);
  1779 	test(reqStat1==KErrNone);
  1780 	test(reqStat2==KRequestPending);	//	Monitoring with ENotifyEntry
  1781 	User::WaitForRequest(reqStat3);
  1782 	test(reqStat3==KErrNone);
  1783 
  1784 	r=TheFs.Delete(_L("\\F32-TST\\NOTIFY\\koala.txt"));
  1785 	test(r==KErrNone);
  1786 	User::WaitForRequest(reqStat2);
  1787 	test(reqStat2==KErrNone);
  1788 
  1789 	r=TheFs.Delete(_L("\\F32-TST\\NOTIFY\\kangaroo.txt"));
  1790 	test(r==KErrNone);
  1791 	r=TheFs.Delete(_L("\\F32-TST\\NOTIFY\\dingo.txt"));
  1792 	test(r==KErrNone);
  1793 
  1794 	gSleepThread.Close();
  1795 	thread3.Close();
  1796 	fs1.Close();
  1797 	fs2.Close();
  1798 	fs3.Close();
  1799 	}
  1800 
  1801 
  1802 static void Test13()
  1803 //
  1804 //	Test file notification
  1805 //
  1806 	{
  1807 	RFs fs;	//	Session to be notified of any changes
  1808 	TInt r=fs.Connect();
  1809 	test(r==KErrNone);
  1810 	r=fs.SetSessionPath(gSessionPath);
  1811 	test(r==KErrNone);
  1812 
  1813 
  1814 	r=TheFs.MkDir(_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\"));
  1815 	test(r==KErrNone||r==KErrAlreadyExists);
  1816 
  1817 	RFile file;
  1818 	r=file.Replace(TheFs,_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\WickedWitch.msg"),EFileStream);
  1819 	test(r==KErrNone||KErrAlreadyExists);
  1820 	file.Close();
  1821 
  1822 //	Test notification on a specific file
  1823 	test.Next(_L("Monitor changes to a specific file"));
  1824 	TFileName path=_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\WickedWitch.msg");
  1825 	TRequestStatus reqStat(KRequestPending);
  1826 	TRequestStatus thrdStat(KRequestPending);
  1827 	fs.NotifyChange(ENotifyAll,reqStat,path);
  1828 	test(reqStat==KRequestPending);
  1829 	RThread thread;
  1830 	r=thread.Create(_L("MyThread7"),ThreadEntryPoint,KDefaultStackSize,KHeapSize,KHeapSize,(TAny*)ETest8);
  1831 	test(r==KErrNone);
  1832 	thread.Logon(thrdStat);
  1833 	thread.Resume();
  1834 	User::WaitForRequest(thrdStat);
  1835 	test(thrdStat==KErrNone);
  1836 	User::WaitForRequest(reqStat);
  1837 	test(reqStat==KErrNone);
  1838 	thread.Close();
  1839 //	Test notification does not occur if a change is made above the file
  1840 	fs.NotifyChange(ENotifyEntry,reqStat,path);
  1841 	test(reqStat==KRequestPending);
  1842 	r=thread.Create(_L("MyThread8"),ThreadEntryPoint,KDefaultStackSize,KHeapSize,KHeapSize,(TAny*)ETest1);
  1843 	test(r==KErrNone);
  1844 	thread.Logon(thrdStat);
  1845 	thread.Resume();
  1846 	User::WaitForRequest(thrdStat);
  1847 	test(thrdStat==KErrNone);
  1848 	User::After(500000);
  1849 	thread.Close();
  1850 	test(reqStat==KRequestPending);
  1851 	r=TheFs.Delete(_L("\\F32-TST\\NOTIFY\\NEWFILE.TXT"));
  1852 	test(r==KErrNone);
  1853 
  1854 //	Test notification does not occur if a change is made to another file
  1855 	r=file.Replace(TheFs,_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Lion.log"),EFileStream);
  1856 	test(r==KErrNone);
  1857 	test(reqStat==KRequestPending);
  1858 	file.Close();
  1859 	r=TheFs.Delete(_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Lion.log"));
  1860 	test(r==KErrNone);
  1861 	test(reqStat==KRequestPending);
  1862 
  1863 
  1864 //	Test notification occurs when a change is made to the file
  1865 	test.Next(_L("Delete monitored file"));
  1866 	r=TheFs.Delete(_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\WickedWitch.Msg"));
  1867 	test(r==KErrNone);
  1868 	User::WaitForRequest(reqStat);
  1869 	test(reqStat==KErrNone);
  1870 
  1871 	fs.Close();
  1872 	}
  1873 
  1874 static void Test14()
  1875 
  1876 	{
  1877 //
  1878 //	Test notification request succeeds with all RFile and RFs operations which result in
  1879 //	notifications
  1880 //
  1881 	RFs fs;
  1882 	TInt r=fs.Connect();	//	Session to be notified of any changes
  1883 	test(r==KErrNone);
  1884 	r=fs.SetSessionPath(gSessionPath);
  1885 	test(r==KErrNone);
  1886 
  1887 //	RFile::Write() to a file within the monitored directory
  1888 	test.Next(_L("RFile::Write()"));
  1889 	TFileName path=_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Dorothy.Doc");
  1890 	TRequestStatus reqStat(KRequestPending);
  1891 
  1892 	RFile file;
  1893 
  1894 	fs.NotifyChange(ENotifyAll,reqStat,path);
  1895 	test(reqStat==KRequestPending);
  1896 	r=file.Replace(TheFs,_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Dorothy.doc"),EFileRead|EFileWrite);
  1897 	test(r==KErrNone);
  1898 	User::WaitForRequest(reqStat);
  1899 	test(reqStat==KErrNone);
  1900 	fs.NotifyChange(ENotifyAll,reqStat,path);
  1901 	test(reqStat==KRequestPending);
  1902 	r=file.Write(0,_L8("Pay no attention to the man behind the curtain"));
  1903 	test(r==KErrNone);
  1904 	file.Close();
  1905 	User::WaitForRequest(reqStat);
  1906 	test(reqStat==KErrNone);
  1907 
  1908 //	RFile::Read() a file within the monitored directory - no notification for reads
  1909 	path=_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\");
  1910 	TBuf8<100> temp;
  1911 	fs.NotifyChange(ENotifyAll,reqStat,path);
  1912 	test(reqStat==KRequestPending);
  1913 	r=file.Open(TheFs,_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Dorothy.doc"),EFileRead|EFileWrite);
  1914 	test(r==KErrNone);
  1915 	test(reqStat==KRequestPending);
  1916 	r=file.Read(0,temp,100);
  1917 	test(reqStat==KRequestPending);
  1918 
  1919 //	RFile::SetAtt() of a file within the monitored directory
  1920 	test.Next(_L("RFile::SetAtt()"));
  1921 	r=file.SetAtt(KEntryAttSystem,KEntryAttNormal);
  1922 	test(r==KErrNone);
  1923 	User::WaitForRequest(reqStat);
  1924 	test(reqStat==KErrNone);
  1925 	fs.NotifyChange(ENotifyAll,reqStat,path);
  1926 	test(reqStat==KRequestPending);
  1927 
  1928 //	RFile::SetSize() of a file within the monitored directory
  1929 	test.Next(_L("RFile::SetSize()"));
  1930 	r=file.SetSize(256);
  1931 	test(r==KErrNone);
  1932 	User::WaitForRequest(reqStat);
  1933 	test(reqStat==KErrNone);
  1934 	file.Close();
  1935 
  1936 //	RFile::Temp() to create a temp file within the monitored directory
  1937 	test.Next(_L("RFile::Temp()"));
  1938 	fs.NotifyChange(ENotifyAll,reqStat,path);
  1939 	test(reqStat==KRequestPending);
  1940 	TFileName fileName;
  1941 	r=file.Temp(TheFs,path,fileName,EFileWrite);
  1942 	test(r==KErrNone);
  1943 	User::WaitForRequest(reqStat);
  1944 	test(reqStat==KErrNone);
  1945 	file.Close();
  1946 
  1947 //	RFile::SetModified() to change modification time of a file within monitored dir
  1948 	test.Next(_L("RFile::SetModified()"));
  1949 	fs.NotifyChange(ENotifyAll,reqStat,path);
  1950 	test(reqStat==KRequestPending);
  1951 	TTime now;
  1952 	now.HomeTime();
  1953 	r=file.Open(TheFs,_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Dorothy.doc"),EFileRead|EFileWrite);
  1954 	test(r==KErrNone);
  1955 	test(reqStat==KRequestPending);
  1956 	file.SetModified(now);
  1957 	file.Close();
  1958 	User::WaitForRequest(reqStat);
  1959 	test(reqStat==KErrNone);
  1960 
  1961 //	RFs::SetEntry() to change a directory entry within the monitored directory
  1962 	test.Next(_L("RFs::SetEntry()"));
  1963 	TEntry entry;
  1964 	fs.NotifyChange(ENotifyAll,reqStat,path);
  1965 	r=TheFs.Entry(_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Dorothy.doc"),entry);
  1966 	test(reqStat==KRequestPending);
  1967 	now.HomeTime();
  1968 	r=TheFs.SetEntry(_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Dorothy.doc"),now,KEntryAttHidden,KEntryAttNormal);
  1969 	test(r==KErrNone);
  1970 	User::WaitForRequest(reqStat);
  1971 	test(reqStat==KErrNone);
  1972 
  1973 //	RFile::Set() to change file's modification time and attributes
  1974 	test.Next(_L("RFile::Set()"));
  1975 	fs.NotifyChange(ENotifyAll,reqStat,path);
  1976 	r=file.Open(TheFs,_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Dorothy.doc"),EFileRead|EFileWrite);
  1977 	test(r==KErrNone);
  1978 	test(reqStat==KRequestPending);
  1979 	now.HomeTime();
  1980 	r=file.Set(now,KEntryAttNormal,KEntryAttHidden);
  1981 	file.Close();
  1982 	User::WaitForRequest(reqStat);
  1983 	test(reqStat==KErrNone);
  1984 
  1985 //	RFs::SetDriveName()
  1986 	test.Next(_L("RFs::SetDriveName()"));
  1987 	fs.NotifyChange(ENotifyAll,reqStat,path);
  1988 	test(reqStat==KRequestPending);
  1989 	User::After(KNotifyChangeAfter);
  1990 	r=TheFs.SetDriveName(KDefaultDrive,_L("DRIVETEST"));
  1991 	test(r==KErrNone);
  1992 	User::WaitForRequest(reqStat);
  1993 	test(reqStat==KErrNone);
  1994 	fs.NotifyChange(ENotifyEntry,reqStat,path);
  1995 	User::After(KNotifyChangeAfter);
  1996 	r=TheFs.SetDriveName(KDefaultDrive,_L("TEST"));
  1997 	test(r==KErrNone);
  1998 	test(reqStat==KRequestPending);
  1999 	fs.NotifyChangeCancel(reqStat);
  2000 	User::WaitForRequest(reqStat);
  2001 	test(reqStat==KErrCancel);
  2002 	fs.NotifyChange(ENotifyDisk,reqStat,path);
  2003 	User::After(KNotifyChangeAfter);
  2004 	r=TheFs.SetDriveName(KDefaultDrive,_L("DRIVE"));
  2005 	test(r==KErrNone);
  2006 	test(reqStat==KRequestPending);
  2007 	fs.NotifyChangeCancel(reqStat);
  2008 	User::WaitForRequest(reqStat);
  2009 	test(reqStat==KErrCancel);
  2010 
  2011 
  2012 //	RFs::MkDir()
  2013 	fs.NotifyChange(ENotifyAll,reqStat,path);
  2014 	test(reqStat==KRequestPending);
  2015 	test.Next(_L("RFs::MkDir()"));
  2016 	r=TheFs.MkDir(_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\EMERALD_CITY\\"));
  2017 	test(r==KErrNone);
  2018 	User::WaitForRequest(reqStat);
  2019 	test(reqStat==KErrNone);
  2020 
  2021 //	RFs::RmDir()
  2022 	test.Next(_L("RFs::RmDir()"));
  2023 	fs.NotifyChange(ENotifyAll,reqStat,path);
  2024 	test(reqStat==KRequestPending);
  2025 	r=TheFs.RmDir(_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\EMERALD_CITY\\"));
  2026 	test(r==KErrNone);
  2027 	User::WaitForRequest(reqStat);
  2028 	test(reqStat==KErrNone);
  2029 
  2030 //	RFile::Create()
  2031 	test.Next(_L("RFile::Create()"));
  2032 	fs.NotifyChange(ENotifyAll,reqStat,path);
  2033 	test(reqStat==KRequestPending);
  2034 	r=file.Create(TheFs,_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Good_Witch.bat"),EFileRead|EFileWrite);
  2035 	test(r==KErrNone);
  2036 	User::WaitForRequest(reqStat);
  2037 	test(reqStat==KErrNone);
  2038 	file.Close();
  2039 
  2040 //	RFs::Delete()
  2041 	test.Next(_L("RFs::Delete()"));
  2042 	fs.NotifyChange(ENotifyAll,reqStat,path);
  2043 	test(reqStat==KRequestPending);
  2044 	r=TheFs.Delete(_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Good_Witch.bat"));
  2045 	test(r==KErrNone);
  2046 	User::WaitForRequest(reqStat);
  2047 	test(reqStat==KErrNone);
  2048 
  2049 //	RFile::Replace()
  2050 	test.Next(_L("RFile::Replace()"));
  2051 	fs.NotifyChange(ENotifyAll,reqStat,path);
  2052 	test(reqStat==KRequestPending);
  2053 	r=file.Replace(TheFs,_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Good_Witch.bat"),EFileRead|EFileWrite);
  2054 	test(r==KErrNone);
  2055 	User::WaitForRequest(reqStat);
  2056 	test(reqStat==KErrNone);
  2057 	file.Close();
  2058 
  2059 //	RFs::Delete()
  2060 	test.Next(_L("RFs::Delete()"));
  2061 	fs.NotifyChange(ENotifyAll,reqStat,path);
  2062 	test(reqStat==KRequestPending);
  2063 	r=TheFs.Delete(_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Good_Witch.bat"));
  2064 	test(r==KErrNone);
  2065 	User::WaitForRequest(reqStat);
  2066 	test(reqStat==KErrNone);
  2067 
  2068 //	RFs::SetVolumeLabel() - should only be notification when monitoring relevant TNotifyTypes
  2069 	test.Next(_L("RFs::SetVolumeLabel"));
  2070 	fs.NotifyChange(ENotifyAll,reqStat,path);
  2071 
  2072 	TInt driveNum=CurrentDrive();
  2073 	TVolumeInfo volInfo;
  2074 	TFileName currentVolName;
  2075 
  2076 	r=TheFs.Volume(volInfo,driveNum);
  2077 	test(r==KErrNone);
  2078 	test(reqStat==KRequestPending);
  2079 	currentVolName=volInfo.iName;
  2080 
  2081 	r=TheFs.SetVolumeLabel(_L("VOL"),driveNum);
  2082 	if (r==KErrNone)
  2083 		{
  2084 		User::WaitForRequest(reqStat);
  2085 		test(reqStat==KErrNone);
  2086 		r=TheFs.Volume(volInfo,driveNum);
  2087 		test(r==KErrNone);
  2088 		test(volInfo.iName==_L("VOL"));
  2089 	//	Test notification occurs under ENotifyDisk
  2090 		fs.NotifyChange(ENotifyDisk,reqStat,path);
  2091 		test(reqStat==KRequestPending);
  2092 		r=TheFs.SetVolumeLabel(_L("ABCDEFGHIJK"),driveNum);
  2093 		test(r==KErrNone);
  2094 		User::WaitForRequest(reqStat);
  2095 		test(reqStat==KErrNone);
  2096 		r=TheFs.Volume(volInfo,driveNum);
  2097 		test(r==KErrNone);
  2098 
  2099 		test(volInfo.iName==_L("ABCDEFGHIJK"));
  2100 
  2101 	//	Test notification does not occur under ENotifyAttributes
  2102 		fs.NotifyChange(ENotifyAttributes,reqStat,path);
  2103 		r=TheFs.SetVolumeLabel(_L("TROPICANA"),driveNum);
  2104 		test(r==KErrNone);
  2105 		test(reqStat==KRequestPending);
  2106 		r=TheFs.Volume(volInfo,driveNum);
  2107 		test(r==KErrNone);
  2108 
  2109 		test(volInfo.iName==_L("TROPICANA"));
  2110 
  2111 		fs.NotifyChangeCancel(reqStat);
  2112 		User::WaitForRequest(reqStat);
  2113 		test(reqStat==KErrCancel);
  2114 	//	Test notification occurs under ENotifyEntry
  2115 		fs.NotifyChange(ENotifyEntry,reqStat,path);
  2116 		test(reqStat==KRequestPending);
  2117 		r=TheFs.SetVolumeLabel(currentVolName,driveNum);
  2118 		test(r==KErrNone);
  2119 		User::WaitForRequest(reqStat);
  2120 		test(reqStat==KErrNone);
  2121 		r=TheFs.Volume(volInfo,driveNum);
  2122 		test(r==KErrNone);
  2123 		test(volInfo.iName==currentVolName);
  2124 		}
  2125 
  2126 	else	//	RFs::SetVolumeLabel() doesn't work on subst drives
  2127 		{
  2128 		fs.NotifyChangeCancel();
  2129 		User::WaitForRequest(reqStat);
  2130 		test.Printf(_L("Cannot set volume label on a substed drive\n"));
  2131 		}
  2132 
  2133 
  2134 //	RFs::Rename()
  2135 
  2136 	test.Next(_L("RFs::Rename()"));
  2137 	fs.NotifyChange(ENotifyEntry,reqStat,path);
  2138 	test(reqStat==KRequestPending);
  2139 	r=TheFs.Rename(_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Dorothy.doc"),_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Toto.doc"));
  2140 	test(r==KErrNone);
  2141 	User::WaitForRequest(reqStat);
  2142 	test(reqStat==KErrNone);
  2143 
  2144 	r=TheFs.Rename(_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Toto.doc"),_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Dorothy.doc"));
  2145 	test(r==KErrNone);
  2146 
  2147 #if defined(__WINS__)
  2148 	if(gSessionPath[0]=='Y'||gSessionPath[0]=='X')
  2149 #endif
  2150 		{
  2151 		test.Next(_L("RFs::Rename() with max path length"));
  2152 		TFileName longName=_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\");
  2153 		while(longName.Length()<(KMaxFileName-2))
  2154 			longName+=_L("a");
  2155 		r=TheFs.Rename(_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Dorothy.doc"),longName);
  2156 		test(r==KErrNone);
  2157 		fs.NotifyChange(ENotifyEntry,reqStat,longName);
  2158 		test(reqStat==KRequestPending);
  2159 		r=TheFs.Rename(longName,_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Dorothy.doc"));
  2160 		test(r==KErrNone);
  2161 		User::WaitForRequest(reqStat);
  2162 		test(reqStat==KErrNone);
  2163 		}
  2164 
  2165 	fs.Close();
  2166 	}
  2167 
  2168 
  2169 static void Test15()
  2170 
  2171 	{
  2172 //
  2173 //	Repeat Test15 operations in a subtree of that monitored, and ensure notification
  2174 //	occurs for a variety of RFile and RFs operations
  2175 //
  2176 	RFs fs;					//	Session to be notified when a change occurs
  2177 	TInt r=fs.Connect();
  2178 	test(r==KErrNone);
  2179 	r=fs.SetSessionPath(gSessionPath);
  2180 	test(r==KErrNone);
  2181 
  2182 //	RFile::Write() to a file in the subtree
  2183 	test.Next(_L("RFile::Write()"));
  2184 	TFileName path=_L("\\F32-TST\\NOTIFY\\");
  2185 	TRequestStatus reqStat(KRequestPending);
  2186 	fs.NotifyChange(ENotifyAll,reqStat,path);
  2187 
  2188 	RFile file;
  2189 	r=file.Open(TheFs,_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Dorothy.doc"),EFileRead|EFileWrite);
  2190 	test(r==KErrNone);
  2191 	test(reqStat==KRequestPending);
  2192 	r=file.Write(0,_L8("Pay no attention to the man behind the curtain"));
  2193 	file.Close();
  2194 	User::WaitForRequest(reqStat);
  2195 	test(reqStat==KErrNone);
  2196 
  2197 //	RFile::Read() a file within the monitored directory - no notification for reads
  2198 	fs.NotifyChange(ENotifyAll,reqStat,path);
  2199 	TBuf8<100> temp;
  2200 	r=file.Open(TheFs,_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Dorothy.doc"),EFileRead|EFileWrite);
  2201 	test(r==KErrNone);
  2202 	test(reqStat==KRequestPending);
  2203 	r=file.Read(0,temp,100);
  2204 	test(reqStat==KRequestPending);
  2205 
  2206 //	RFile::SetAtt() of a file within the monitored directory
  2207 	test.Next(_L("RFile::SetAtt()"));
  2208 	r=file.SetAtt(KEntryAttNormal,KEntryAttHidden);
  2209 	test(r==KErrNone);
  2210 	User::WaitForRequest(reqStat);
  2211 	test(reqStat==KErrNone);
  2212 
  2213 //	RFile::SetSize() of a file within the monitored directory
  2214 	test.Next(_L("RFile::SetSize()"));
  2215 	fs.NotifyChange(ENotifyAll,reqStat,path);
  2216 	test(reqStat==KRequestPending);
  2217 	r=file.SetSize(256);
  2218 	test(r==KErrNone);
  2219 	User::WaitForRequest(reqStat);
  2220 	test(reqStat==KErrNone);
  2221 	file.Close();
  2222 
  2223 //	RFile::Temp() to create a temp file in the subtree
  2224 	test.Next(_L("RFile::Temp()"));
  2225 	fs.NotifyChange(ENotifyAll,reqStat,path);
  2226 	test(reqStat==KRequestPending);
  2227 	TFileName fileName;
  2228 	r=file.Temp(TheFs,_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\"),fileName,EFileWrite);
  2229 	test(r==KErrNone);
  2230 	User::WaitForRequest(reqStat);
  2231 	test(reqStat==KErrNone);
  2232 	file.Close();
  2233 
  2234 //	RFile::SetModified() to change modification time of a file within monitored dir
  2235 	test.Next(_L("RFile::SetModified()"));
  2236 	fs.NotifyChange(ENotifyAll,reqStat,path);
  2237 	TTime now;
  2238 	now.HomeTime();
  2239 	r=file.Open(TheFs,_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Dorothy.doc"),EFileRead|EFileWrite);
  2240 	test(r==KErrNone);
  2241 	test(reqStat==KRequestPending);
  2242 	file.SetModified(now);
  2243 	file.Close();
  2244 	User::WaitForRequest(reqStat);
  2245 	test(reqStat==KErrNone);
  2246 
  2247 //	RFs::Entry() to change a directory entry within the monitored directory
  2248 	test.Next(_L("RFs::Entry()"));
  2249 	fs.NotifyChange(ENotifyAll,reqStat,path);
  2250 	TEntry entry;
  2251 	r=TheFs.Entry(_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Dorothy.doc"),entry);
  2252 	test(reqStat==KRequestPending);
  2253 	now.HomeTime();
  2254 	r=TheFs.SetEntry(_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Dorothy.doc"),now,KEntryAttHidden,KEntryAttNormal);
  2255 	test(r==KErrNone);
  2256 	User::WaitForRequest(reqStat);
  2257 	test(reqStat==KErrNone);
  2258 
  2259 //	RFile::Set() to change file's modification time and attributes
  2260 	test.Next(_L("RFile::Set()"));
  2261 	fs.NotifyChange(ENotifyAll,reqStat,path);
  2262 	r=file.Open(TheFs,_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Dorothy.doc"),EFileRead|EFileWrite);
  2263 	test(r==KErrNone);
  2264 	test(reqStat==KRequestPending);
  2265 	now.HomeTime();
  2266 	r=file.Set(now,KEntryAttNormal,KEntryAttHidden);
  2267 	file.Close();
  2268 	User::WaitForRequest(reqStat);
  2269 	test(reqStat==KErrNone);
  2270 
  2271 //	RFs::SetDriveName()
  2272 	test.Next(_L("RFs::SetDriveName()"));
  2273 	fs.NotifyChange(ENotifyAll,reqStat,path);
  2274 	test(reqStat==KRequestPending);
  2275 	User::After(KNotifyChangeAfter);
  2276 	r=TheFs.SetDriveName(KDefaultDrive,_L("DRIVETEST"));
  2277 	test(r==KErrNone);
  2278 	User::WaitForRequest(reqStat);
  2279 	test(reqStat==KErrNone);
  2280 	fs.NotifyChange(ENotifyEntry,reqStat,path);
  2281 	r=TheFs.SetDriveName(KDefaultDrive,_L("TEST"));
  2282 	test(r==KErrNone);
  2283 	test(reqStat==KRequestPending);
  2284 	User::After(KNotifyChangeAfter);
  2285 	fs.NotifyChangeCancel(reqStat);
  2286 	User::WaitForRequest(reqStat);
  2287 	test(reqStat==KErrCancel);
  2288 	fs.NotifyChange(ENotifyDisk,reqStat,path);
  2289 	User::After(KNotifyChangeAfter);
  2290 	r=TheFs.SetDriveName(KDefaultDrive,_L("DRIVE"));
  2291 	test(r==KErrNone);
  2292 	test(reqStat==KRequestPending);
  2293 	fs.NotifyChangeCancel(reqStat);
  2294 	User::WaitForRequest(reqStat);
  2295 	test(reqStat==KErrCancel);
  2296 
  2297 //	RFs::MkDir()
  2298 	test.Next(_L("RFs::MkDir()"));
  2299 	fs.NotifyChange(ENotifyAll,reqStat,path);
  2300 	test(reqStat==KRequestPending);
  2301 	r=TheFs.MkDir(_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\EMERALD_CITY\\"));
  2302 	test(r==KErrNone);
  2303 	User::WaitForRequest(reqStat);
  2304 	test(reqStat==KErrNone);
  2305 
  2306 //	RFs::RmDir()
  2307 	test.Next(_L("RFs::RmDir()"));
  2308 	fs.NotifyChange(ENotifyAll,reqStat,path);
  2309 	test(reqStat==KRequestPending);
  2310 	r=TheFs.RmDir(_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\EMERALD_CITY\\"));
  2311 	test(r==KErrNone);
  2312 	User::WaitForRequest(reqStat);
  2313 	test(reqStat==KErrNone);
  2314 
  2315 //	RFile::Create()
  2316 	test.Next(_L("RFile::Create()"));
  2317 	fs.NotifyChange(ENotifyAll,reqStat,path);
  2318 	test(reqStat==KRequestPending);
  2319 	r=file.Create(TheFs,_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Good_Witch.bat"),EFileRead|EFileWrite);
  2320 	test(r==KErrNone);
  2321 	User::WaitForRequest(reqStat);
  2322 	test(reqStat==KErrNone);
  2323 	file.Close();
  2324 
  2325 //	RFs::Delete()
  2326 	test.Next(_L("RFs::Delete()"));
  2327 	fs.NotifyChange(ENotifyAll,reqStat,path);
  2328 	test(reqStat==KRequestPending);
  2329 	r=TheFs.Delete(_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Good_Witch.bat"));
  2330 	test(r==KErrNone);
  2331 	User::WaitForRequest(reqStat);
  2332 	test(reqStat==KErrNone);
  2333 
  2334 //	RFile::Replace()
  2335 	test.Next(_L("RFile::Replace()"));
  2336 	fs.NotifyChange(ENotifyAll,reqStat,path);
  2337 	test(reqStat==KRequestPending);
  2338 	r=file.Replace(TheFs,_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Good_Witch.bat"),EFileRead|EFileWrite);
  2339 	test(r==KErrNone);
  2340 	User::WaitForRequest(reqStat);
  2341 	test(reqStat==KErrNone);
  2342 	file.Close();
  2343 
  2344 //	RFs::Delete()
  2345 	test.Next(_L("RFs::Delete()"));
  2346 	fs.NotifyChange(ENotifyAll,reqStat,path);
  2347 	test(reqStat==KRequestPending);
  2348 	r=TheFs.Delete(_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Good_Witch.bat"));
  2349 	test(r==KErrNone);
  2350 	User::WaitForRequest(reqStat);
  2351 	test(reqStat==KErrNone);
  2352 
  2353 //	RFs::SetVolumeLabel() - should be notification under relevant TNotifyType monitoring
  2354 //	The operation is non-path specific so all outstanding interested requests are notified
  2355 	test.Next(_L("RFs::SetVolumeLabel()"));
  2356 
  2357 	fs.NotifyChange(ENotifyAll,reqStat,path);
  2358 
  2359 	TInt driveNum=CurrentDrive();
  2360 	TVolumeInfo volInfo;
  2361 	TFileName currentVolName;
  2362 	r=TheFs.Volume(volInfo,driveNum);
  2363 	test(r==KErrNone);
  2364 	test(reqStat==KRequestPending);
  2365 	currentVolName=volInfo.iName;
  2366 
  2367 	r=TheFs.SetVolumeLabel(_L("VOL"),driveNum);
  2368 	if (r==KErrNone)
  2369 		{
  2370 		User::WaitForRequest(reqStat);
  2371 		test(reqStat==KErrNone);
  2372 		r=TheFs.Volume(volInfo,driveNum);
  2373 		test(r==KErrNone);
  2374 		test(volInfo.iName==_L("VOL"));
  2375 	//	Test notification occurs under ENotifyDisk
  2376 		fs.NotifyChange(ENotifyDisk,reqStat,path);
  2377 		test(reqStat==KRequestPending);
  2378 		r=TheFs.SetVolumeLabel(_L("ABCDEFGHIJK"),driveNum);
  2379 		test(r==KErrNone);
  2380 		User::WaitForRequest(reqStat);
  2381 		test(reqStat==KErrNone);
  2382 		r=TheFs.Volume(volInfo,driveNum);
  2383 		test(r==KErrNone);
  2384 
  2385 		test(volInfo.iName==_L("ABCDEFGHIJK"));
  2386 
  2387 	//	Test notification does not occur under ENotifyAttributes
  2388 		fs.NotifyChange(ENotifyAttributes,reqStat,path);
  2389 		r=TheFs.SetVolumeLabel(_L("TROPICANA"),driveNum);
  2390 		test(r==KErrNone);
  2391 		test(reqStat==KRequestPending);
  2392 		r=TheFs.Volume(volInfo,driveNum);
  2393 		test(r==KErrNone);
  2394 
  2395 		test(volInfo.iName==_L("TROPICANA"));
  2396 
  2397 		fs.NotifyChangeCancel(reqStat);
  2398 		User::WaitForRequest(reqStat);
  2399 		test(reqStat==KErrCancel);
  2400 	//	Test notification occurs under ENotifyEntry
  2401 		fs.NotifyChange(ENotifyEntry,reqStat,path);
  2402 		test(reqStat==KRequestPending);
  2403 		r=TheFs.SetVolumeLabel(currentVolName,driveNum);
  2404 		test(r==KErrNone);
  2405 		User::WaitForRequest(reqStat);
  2406 		test(reqStat==KErrNone);
  2407 		r=TheFs.Volume(volInfo,driveNum);
  2408 		test(r==KErrNone);
  2409 		test(volInfo.iName==currentVolName);
  2410 		}
  2411 
  2412 	else	//	RFs::SetVolumeLabel() doesn't work on subst drives
  2413 		{
  2414 		fs.NotifyChangeCancel();
  2415 		User::WaitForRequest(reqStat);
  2416 		test.Printf(_L("Cannot set volume label on a substed drive\n"));
  2417 		}
  2418 
  2419 
  2420 
  2421 //	Test that notification is made when change is made to monitored directory
  2422 	fs.NotifyChange(ENotifyAll,reqStat,path);
  2423 	test(reqStat==KRequestPending);
  2424 	r=TheFs.MkDir(_L("\\F32-TST\\NOTIFY\\EMERALD_CITY\\"));
  2425 	test(r==KErrNone);
  2426 	User::WaitForRequest(reqStat);
  2427 	test(reqStat==KErrNone);
  2428 
  2429 	fs.NotifyChange(ENotifyAll,reqStat,path);
  2430 	test(reqStat==KRequestPending);
  2431 	r=TheFs.RmDir(_L("\\F32-TST\\NOTIFY\\EMERALD_CITY\\"));
  2432 	test(r==KErrNone);
  2433 	User::WaitForRequest(reqStat);
  2434 	test(reqStat==KErrNone);
  2435 	fs.Close();
  2436 	}
  2437 
  2438 
  2439 static void Test16()
  2440 
  2441 	{
  2442 //
  2443 //	Repeat Test15 operations in a subtree of that monitored, and ensure notification
  2444 //	does occur for a variety of file operations when subtree watching is on
  2445 //
  2446 	RFs fs;
  2447 	TInt r=fs.Connect();	//	Session to be notified when a change occurs
  2448 	test(r==KErrNone);
  2449 	r=fs.SetSessionPath(gSessionPath);
  2450 	test(r==KErrNone);
  2451 
  2452 //	RFile::Write() to a file in the subtree
  2453 	TFileName path=_L("\\F32-TST\\NOTIFY\\");
  2454 	TRequestStatus reqStat(KRequestPending);
  2455 	fs.NotifyChange(ENotifyAll,reqStat,path);
  2456 
  2457 	RFile file;
  2458 	r=file.Open(TheFs,_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Dorothy.doc"),EFileRead|EFileWrite);
  2459 	test(r==KErrNone);
  2460 	test(reqStat==KRequestPending);
  2461 	r=file.Write(0,_L8("Pay no attention to the man behind the curtain"));
  2462 	file.Close();
  2463 	User::WaitForRequest(reqStat);
  2464 	test(reqStat==KErrNone);
  2465 
  2466 //	RFile::Read() a file within the monitored directory - no notification for reads
  2467 	fs.NotifyChange(ENotifyAll,reqStat,path);
  2468 	TBuf8<100> temp;
  2469 	r=file.Open(TheFs,_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Dorothy.doc"),EFileRead|EFileWrite);
  2470 	test(r==KErrNone);
  2471 	test(reqStat==KRequestPending);
  2472 	r=file.Read(0,temp,100);
  2473 	test(reqStat==KRequestPending);
  2474 
  2475 //	RFile::SetAtt() of a file within the monitored directory
  2476 	r=file.SetAtt(KEntryAttNormal,KEntryAttHidden);
  2477 	test(r==KErrNone);
  2478 	User::WaitForRequest(reqStat);
  2479 	test(reqStat==KErrNone);
  2480 
  2481 //	RFile::SetSize() of a file within the monitored directory
  2482 	fs.NotifyChange(ENotifyAll,reqStat,path);
  2483 	test(reqStat==KRequestPending);
  2484 	r=file.SetSize(256);
  2485 	test(r==KErrNone);
  2486 	User::WaitForRequest(reqStat);
  2487 	test(reqStat==KErrNone);
  2488 	file.Close();
  2489 
  2490 
  2491 //	RFile::SetModified() to change modification time of a file within monitored dir
  2492 	fs.NotifyChange(ENotifyAll,reqStat,path);
  2493 	TTime now;
  2494 	now.HomeTime();
  2495 	r=file.Open(TheFs,_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Dorothy.doc"),EFileRead|EFileWrite);
  2496 	test(r==KErrNone);
  2497 	test(reqStat==KRequestPending);
  2498 	file.SetModified(now);
  2499 	file.Close();
  2500 	User::WaitForRequest(reqStat);
  2501 	test(reqStat==KErrNone);
  2502 
  2503 //	RFs::Entry() to change a directory entry within the monitored directory
  2504 	fs.NotifyChange(ENotifyAll,reqStat,path);
  2505 	TEntry entry;
  2506 	r=TheFs.Entry(_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Dorothy.doc"),entry);
  2507 	test(reqStat==KRequestPending);
  2508 	now.HomeTime();
  2509 	r=TheFs.SetEntry(_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Dorothy.doc"),now,KEntryAttHidden,KEntryAttNormal);
  2510 	test(r==KErrNone);
  2511 	User::WaitForRequest(reqStat);
  2512 	test(reqStat==KErrNone);
  2513 
  2514 //	RFile::Set() to change file's modification time and attributes
  2515 	fs.NotifyChange(ENotifyAll,reqStat,path);
  2516 	r=file.Open(TheFs,_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Dorothy.doc"),EFileRead|EFileWrite);
  2517 	test(r==KErrNone);
  2518 	test(reqStat==KRequestPending);
  2519 	now.HomeTime();
  2520 	r=file.Set(now,KEntryAttNormal,KEntryAttHidden);
  2521 	file.Close();
  2522 	User::WaitForRequest(reqStat);
  2523 	test(reqStat==KErrNone);
  2524 
  2525 //	RFs::SetDriveName() - should be no notification ever with extended notification
  2526 	fs.NotifyChange(ENotifyAll,reqStat,path);
  2527 	test(reqStat==KRequestPending);
  2528 	User::After(KNotifyChangeAfter);
  2529 	r=TheFs.SetDriveName(KDefaultDrive,_L("DRIVETEST"));
  2530 	test(r==KErrNone);
  2531 	User::WaitForRequest(reqStat);
  2532 	test(reqStat==KErrNone);
  2533 	fs.NotifyChange(ENotifyEntry,reqStat,path);
  2534 	User::After(KNotifyChangeAfter);
  2535 	r=TheFs.SetDriveName(KDefaultDrive,_L("TEST"));
  2536 	test(r==KErrNone);
  2537 	test(reqStat==KRequestPending);
  2538 	fs.NotifyChangeCancel(reqStat);
  2539 	User::WaitForRequest(reqStat);
  2540 	fs.NotifyChange(ENotifyDisk,reqStat,path);
  2541 	User::After(KNotifyChangeAfter);
  2542 	r=TheFs.SetDriveName(KDefaultDrive,_L("DRIVE"));
  2543 	test(r==KErrNone);
  2544 	test(reqStat==KRequestPending);
  2545 	fs.NotifyChangeCancel(reqStat);
  2546 	User::WaitForRequest(reqStat);
  2547 	test(reqStat==KErrCancel);
  2548 
  2549 
  2550 //	RFs::MkDir()
  2551 	fs.NotifyChange(ENotifyAll,reqStat,path);
  2552 	test(reqStat==KRequestPending);
  2553 	r=TheFs.MkDir(_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\EMERALD_CITY\\"));
  2554 	test(r==KErrNone);
  2555 	User::WaitForRequest(reqStat);
  2556 	test(reqStat==KErrNone);
  2557 
  2558 //	RFs::RmDir()
  2559 	fs.NotifyChange(ENotifyAll,reqStat,path);
  2560 	test(reqStat==KRequestPending);
  2561 	r=TheFs.RmDir(_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\EMERALD_CITY\\"));
  2562 	test(r==KErrNone);
  2563 	User::WaitForRequest(reqStat);
  2564 	test(reqStat==KErrNone);
  2565 
  2566 //	RFile::Create()
  2567 	fs.NotifyChange(ENotifyAll,reqStat,path);
  2568 	test(reqStat==KRequestPending);
  2569 	r=file.Create(TheFs,_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Good_Witch.bat"),EFileRead|EFileWrite);
  2570 	test(r==KErrNone);
  2571 	User::WaitForRequest(reqStat);
  2572 	test(reqStat==KErrNone);
  2573 	file.Close();
  2574 
  2575 //	RFs::Delete()
  2576 	fs.NotifyChange(ENotifyAll,reqStat,path);
  2577 	test(reqStat==KRequestPending);
  2578 	r=TheFs.Delete(_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Good_Witch.bat"));
  2579 	test(r==KErrNone);
  2580 	User::WaitForRequest(reqStat);
  2581 	test(reqStat==KErrNone);
  2582 
  2583 //	RFile::Replace()
  2584 	fs.NotifyChange(ENotifyAll,reqStat,path);
  2585 	test(reqStat==KRequestPending);
  2586 	r=file.Replace(TheFs,_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Good_Witch.bat"),EFileRead|EFileWrite);
  2587 	test(r==KErrNone);
  2588 	User::WaitForRequest(reqStat);
  2589 	test(reqStat==KErrNone);
  2590 	file.Close();
  2591 
  2592 //	RFs::Delete()
  2593 	fs.NotifyChange(ENotifyAll,reqStat,path);
  2594 	test(reqStat==KRequestPending);
  2595 	r=TheFs.Delete(_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Good_Witch.bat"));
  2596 	test(r==KErrNone);
  2597 	User::WaitForRequest(reqStat);
  2598 	test(reqStat==KErrNone);
  2599 
  2600 //	RFs::SetVolumeLabel()
  2601 //	Not path specific, so all outstanding requests of correct TNotifyType are notified
  2602 	fs.NotifyChange(ENotifyAll,reqStat,path);
  2603 	TInt driveNum=CurrentDrive();
  2604 	TVolumeInfo volInfo;
  2605 	TFileName currentVolName;
  2606 	r=TheFs.Volume(volInfo,driveNum);
  2607 	test(r==KErrNone);
  2608 	test(reqStat==KRequestPending);
  2609 	currentVolName=volInfo.iName;
  2610 
  2611 	r=TheFs.SetVolumeLabel(_L("VOL"),driveNum);
  2612 	if (r==KErrNone)
  2613 		{
  2614 		User::WaitForRequest(reqStat);
  2615 		test(reqStat==KErrNone);
  2616 		r=TheFs.Volume(volInfo,driveNum);
  2617 		test(r==KErrNone);
  2618 		test(volInfo.iName==_L("VOL"));
  2619 	//	Test notification occurs under ENotifyDisk
  2620 		fs.NotifyChange(ENotifyDisk,reqStat,path);
  2621 		test(reqStat==KRequestPending);
  2622 		r=TheFs.SetVolumeLabel(_L("ABCDEFGHIJK"),driveNum);
  2623 		test(r==KErrNone);
  2624 		User::WaitForRequest(reqStat);
  2625 		test(reqStat==KErrNone);
  2626 		r=TheFs.Volume(volInfo,driveNum);
  2627 		test(r==KErrNone);
  2628 
  2629 		test(volInfo.iName==_L("ABCDEFGHIJK"));
  2630 
  2631 	//	Test notification does not occur under ENotifyAttributes
  2632 		fs.NotifyChange(ENotifyAttributes,reqStat,path);
  2633 		r=TheFs.SetVolumeLabel(_L("TROPICANA"),driveNum);
  2634 		test(r==KErrNone);
  2635 		test(reqStat==KRequestPending);
  2636 		r=TheFs.Volume(volInfo,driveNum);
  2637 		test(r==KErrNone);
  2638 
  2639 		test(volInfo.iName==_L("TROPICANA"));
  2640 
  2641 		fs.NotifyChangeCancel(reqStat);
  2642 		User::WaitForRequest(reqStat);
  2643 		test(reqStat==KErrCancel);
  2644 	//	Test notification occurs under ENotifyEntry
  2645 		fs.NotifyChange(ENotifyEntry,reqStat,path);
  2646 		test(reqStat==KRequestPending);
  2647 		r=TheFs.SetVolumeLabel(currentVolName,driveNum);
  2648 		test(r==KErrNone);
  2649 		User::WaitForRequest(reqStat);
  2650 		test(reqStat==KErrNone);
  2651 		r=TheFs.Volume(volInfo,driveNum);
  2652 		test(r==KErrNone);
  2653 		test(volInfo.iName==currentVolName);
  2654 		}
  2655 
  2656 	else	//	RFs::SetVolumeLabel() doesn't work on subst drives
  2657 		{
  2658 		fs.NotifyChangeCancel();
  2659 		User::WaitForRequest(reqStat);
  2660 		test.Printf(_L("Cannot set volume label on a substed drive\n"));
  2661 		}
  2662 
  2663 //	RFs::Rename()
  2664 	fs.NotifyChange(ENotifyEntry,reqStat,path);
  2665 	test(reqStat==KRequestPending);
  2666 	r=TheFs.Rename(_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Dorothy.doc"),_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Toto.doc"));
  2667 	test(r==KErrNone);
  2668 	User::WaitForRequest(reqStat);
  2669 	test(reqStat==KErrNone);
  2670 
  2671 //	Test that notification is made when change is made to monitored directory
  2672 	fs.NotifyChange(ENotifyAll,reqStat,path);
  2673 	test(reqStat==KRequestPending);
  2674 	r=TheFs.MkDir(_L("\\F32-TST\\NOTIFY\\EMERALD_CITY\\"));
  2675 	test(r==KErrNone);
  2676 	User::WaitForRequest(reqStat);
  2677 	test(reqStat==KErrNone);
  2678 
  2679 	fs.NotifyChange(ENotifyAll,reqStat,path);
  2680 	test(reqStat==KRequestPending);
  2681 	r=TheFs.RmDir(_L("\\F32-TST\\NOTIFY\\EMERALD_CITY\\"));
  2682 	test(r==KErrNone);
  2683 	User::WaitForRequest(reqStat);
  2684 	test(reqStat==KErrNone);
  2685 	fs.Close();
  2686 	}
  2687 
  2688 
  2689 static void Test17()
  2690 //
  2691 //	Test multiple requests from a single session
  2692 //
  2693 	{
  2694 
  2695 	test.Next(_L("Test reads and writes do not cause notification under ENotifyEntry"));
  2696 
  2697 	RFile file;
  2698 	TInt r=file.Replace(TheFs,_L("\\F32-TST\\NOTIFY\\kangaroo.txt"),EFileRead|EFileWrite);
  2699 	test(r==KErrNone);
  2700 	file.Close();
  2701 	r=file.Replace(TheFs,_L("\\F32-TST\\NOTIFY\\koala.txt"),EFileRead|EFileWrite);
  2702 	test(r==KErrNone);
  2703 	file.Close();
  2704 	r=file.Replace(TheFs,_L("\\F32-TST\\NOTIFY\\dingo.txt"),EFileRead|EFileWrite);
  2705 	test(r==KErrNone);
  2706 	file.Close();
  2707 
  2708 	RFs fs;
  2709 	r=fs.Connect();
  2710 	test(r==KErrNone);
  2711 	r=fs.SetSessionPath(gSessionPath);
  2712 	test(r==KErrNone);
  2713 
  2714 	TRequestStatus reqStat1(KRequestPending);
  2715 	TFileName path1=_L("\\F32-TST\\NOTIFY\\");
  2716 	fs.NotifyChange(ENotifyEntry,reqStat1,path1);
  2717 
  2718 	TRequestStatus status1(KRequestPending);
  2719 	TRequestStatus status2(KRequestPending);
  2720 	TRequestStatus status3(KRequestPending);
  2721 	TRequestStatus status4(KRequestPending);
  2722 	TRequestStatus status5(KRequestPending);
  2723 	TRequestStatus status6(KRequestPending);
  2724 
  2725 	TRequestStatus statusExtended1(KRequestPending);
  2726 	TRequestStatus statusExtended2(KRequestPending);
  2727 	TRequestStatus statusExtended3(KRequestPending);
  2728 	TRequestStatus statusExtended4(KRequestPending);
  2729 	TRequestStatus statusExtended5(KRequestPending);
  2730 	TRequestStatus statusExtended6(KRequestPending);
  2731 
  2732 //	Request multiple notifications using standard change notification request
  2733 	fs.NotifyChange(ENotifyEntry,status1);
  2734 	fs.NotifyChange(ENotifyEntry,status2);
  2735 	fs.NotifyChange(ENotifyEntry,status3);
  2736 	fs.NotifyChange(ENotifyEntry,status4);
  2737 	fs.NotifyChange(ENotifyEntry,status5);
  2738 	fs.NotifyChange(ENotifyEntry,status6);
  2739 
  2740 //	Request multiple notifications using extended change notification request
  2741 	fs.NotifyChange(ENotifyEntry,statusExtended1,path1);
  2742 	fs.NotifyChange(ENotifyEntry,statusExtended2,path1);
  2743 	fs.NotifyChange(ENotifyEntry,statusExtended3,path1);
  2744 	fs.NotifyChange(ENotifyEntry,statusExtended4,path1);
  2745 	fs.NotifyChange(ENotifyEntry,statusExtended5,path1);
  2746 	fs.NotifyChange(ENotifyEntry,statusExtended6,path1);
  2747 
  2748 	TRequestStatus reqStat2(KRequestPending);
  2749 	TFileName path2=_L("\\F32-TST\\NOTIFY\\kangaroo.txt");
  2750 	fs.NotifyChange(ENotifyEntry,reqStat2,path2);
  2751 
  2752 	TRequestStatus reqStat3(KRequestPending);
  2753 	TFileName path3=_L("\\F32-TST\\NOTIFY\\koala.txt");
  2754 	fs.NotifyChange(ENotifyEntry,reqStat3,path3);
  2755 
  2756 	TRequestStatus reqStat4(KRequestPending);
  2757 	TFileName path4=_L("\\F32-TST\\NOTIFY\\dingo.txt");
  2758 	fs.NotifyChange(ENotifyEntry,reqStat4,path4);
  2759 
  2760 
  2761 	r=gSleepThread.CreateLocal(0);
  2762 	test(r==KErrNone);
  2763 	RThread thread1;
  2764 	r=thread1.Create(_L("TestThread1"),ThreadEntryPoint,0x4000,KHeapSize,KHeapSize,(TAny*)ETest5);
  2765 	test(r==KErrNone);
  2766 	thread1.Resume();
  2767 	gSleepThread.Wait();
  2768 
  2769 	test(status1==KRequestPending);
  2770 	test(status2==KRequestPending);
  2771 	test(status3==KRequestPending);
  2772 	test(status4==KRequestPending);
  2773 	test(status5==KRequestPending);
  2774 	test(status6==KRequestPending);
  2775 
  2776 	test(statusExtended1==KRequestPending);
  2777 	test(statusExtended2==KRequestPending);
  2778 	test(statusExtended3==KRequestPending);
  2779 	test(statusExtended4==KRequestPending);
  2780 	test(statusExtended5==KRequestPending);
  2781 	test(statusExtended6==KRequestPending);
  2782 
  2783 	test(reqStat1==KRequestPending);
  2784 	test(reqStat2==KRequestPending);
  2785 	test(reqStat3==KRequestPending);
  2786 	test(reqStat4==KRequestPending);
  2787 
  2788 	r=TheFs.Delete(_L("\\F32-TST\\NOTIFY\\kangaroo.txt"));
  2789 	test(r==KErrNone);
  2790 	User::WaitForRequest(reqStat1);
  2791 	test(reqStat1==KErrNone);
  2792 	User::WaitForRequest(status1);
  2793 	test(status1==KErrNone);
  2794 	User::WaitForRequest(status2);
  2795 	test(status2==KErrNone);
  2796 	User::WaitForRequest(status3);
  2797 	test(status3==KErrNone);
  2798 	User::WaitForRequest(status4);
  2799 	test(status4==KErrNone);
  2800 	User::WaitForRequest(status5);
  2801 	test(status5==KErrNone);
  2802 	User::WaitForRequest(status6);
  2803 	test(status6==KErrNone);
  2804 
  2805 	User::WaitForRequest(statusExtended1);
  2806 	test(statusExtended1==KErrNone);
  2807 	User::WaitForRequest(statusExtended2);
  2808 	test(statusExtended2==KErrNone);
  2809 	User::WaitForRequest(statusExtended3);
  2810 	test(statusExtended3==KErrNone);
  2811 	User::WaitForRequest(statusExtended4);
  2812 	test(statusExtended4==KErrNone);
  2813 	User::WaitForRequest(statusExtended5);
  2814 	test(statusExtended5==KErrNone);
  2815 	User::WaitForRequest(statusExtended6);
  2816 	test(statusExtended6==KErrNone);
  2817 
  2818 	User::WaitForRequest(reqStat2);
  2819 	test(reqStat2==KErrNone);
  2820 	test(reqStat3==KRequestPending);
  2821 	test(reqStat4==KRequestPending);
  2822 	fs.NotifyChangeCancel();	//	Cancels both remaining notification requests
  2823 
  2824 	User::WaitForRequest(reqStat3);
  2825 	User::WaitForRequest(reqStat4);
  2826 
  2827 	gSleepThread.Close();
  2828 	thread1.Close();
  2829 
  2830 	test.Next(_L("Test reads and writes do cause notification under ENotifyAll"));
  2831 	r=file.Replace(TheFs,_L("\\F32-TST\\NOTIFY\\kangaroo.txt"),EFileRead|EFileWrite);
  2832 	test(r==KErrNone);
  2833 	file.Close();
  2834 
  2835 	fs.NotifyChange(ENotifyAll,reqStat1,path1);
  2836 	fs.NotifyChange(ENotifyEntry,reqStat2,path2);
  2837 	fs.NotifyChange(ENotifyAll,reqStat3,path3);
  2838 	fs.NotifyChange(ENotifyEntry,reqStat4,path4);
  2839 	test(reqStat1==KRequestPending);
  2840 	test(reqStat2==KRequestPending);
  2841 	test(reqStat3==KRequestPending);
  2842 	test(reqStat4==KRequestPending);
  2843 
  2844 	r=gSleepThread.CreateLocal(0);
  2845 	test(r==KErrNone);
  2846 	RThread thread2;
  2847 	r=thread2.Create(_L("TestThread2"),ThreadEntryPoint,0x4000,KHeapSize,KHeapSize,(TAny*)ETest5);
  2848 	test(r==KErrNone);
  2849 	thread2.Resume();
  2850 	gSleepThread.Wait();
  2851 
  2852 	User::WaitForRequest(reqStat1);
  2853 	test(reqStat1==KErrNone);
  2854 	test(reqStat2==KRequestPending);
  2855 	User::WaitForRequest(reqStat3);
  2856 	test(reqStat3==KErrNone);
  2857 	test(reqStat4==KRequestPending);
  2858 
  2859 	gSleepThread.Close();
  2860 	thread2.Close();
  2861 
  2862 	fs.NotifyChange(ENotifyAll,reqStat1,path1);
  2863 	fs.NotifyChange(ENotifyAll,reqStat3,path3);
  2864 
  2865 	test(reqStat1==KRequestPending);
  2866 	test(reqStat2==KRequestPending);
  2867 	test(reqStat3==KRequestPending);
  2868 	test(reqStat4==KRequestPending);
  2869 
  2870 	r=gSleepThread.CreateLocal(0);
  2871 	test(r==KErrNone);
  2872 	RThread thread3;
  2873 	r=thread3.Create(_L("TestThread3"),ThreadEntryPoint,0x4000,KHeapSize,KHeapSize,(TAny*)ETest5);
  2874 	test(r==KErrNone);
  2875 	thread3.Resume();
  2876 	gSleepThread.Wait();
  2877 
  2878 	User::WaitForRequest(reqStat1);
  2879 	test(reqStat1==KErrNone);
  2880 	test(reqStat2==KRequestPending);	//	Monitoring with ENotifyEntry
  2881 	User::WaitForRequest(reqStat3);
  2882 	test(reqStat3==KErrNone);
  2883 	test(reqStat4==KRequestPending);	//	Monitoring with ENotifyEntry
  2884 
  2885 	RFs fs2;
  2886 	r=fs2.Connect();
  2887 	test(r==KErrNone);
  2888 	r=fs2.SetSessionPath(gSessionPath);
  2889 	test(r==KErrNone);
  2890 
  2891 	TRequestStatus reqStat(KRequestPending);
  2892 	fs2.NotifyChange(ENotifyEntry,reqStat);
  2893 	test(reqStat==KRequestPending);
  2894 
  2895 	r=TheFs.Delete(_L("\\F32-TST\\NOTIFY\\kangaroo.txt"));
  2896 	test(r==KErrNone);
  2897 	User::WaitForRequest(reqStat2);
  2898 	test(reqStat2==KErrNone);
  2899 	test(reqStat4==KRequestPending);
  2900 	User::WaitForRequest(reqStat);
  2901 	test(reqStat==KErrNone);
  2902 
  2903 	fs2.NotifyChange(ENotifyAll,reqStat);
  2904 	test(reqStat==KRequestPending);
  2905 	r=TheFs.Delete(_L("\\F32-TST\\NOTIFY\\koala.txt"));
  2906 	test(r==KErrNone);
  2907 	User::WaitForRequest(reqStat);
  2908 	test(reqStat==KErrNone);
  2909 	test(reqStat4==KRequestPending);
  2910 	r=TheFs.Delete(_L("\\F32-TST\\NOTIFY\\dingo.txt"));
  2911 	test(r==KErrNone);
  2912 	User::WaitForRequest(reqStat4);
  2913 	test(reqStat4==KErrNone);
  2914 
  2915 	gSleepThread.Close();
  2916 	thread3.Close();
  2917 	fs.Close();
  2918 	}
  2919 
  2920 static void Test18()
  2921 
  2922 	{
  2923 //
  2924 //	Test notification request succeeds or fails as appropriate to the notification type
  2925 //	with all file operations which result in notifications
  2926 //	enum TNotifyType {ENotifyEntry=0x00,ENotifyAll=0x01,ENotifyFile=0x04,ENotifyDir=0x08,
  2927 //				ENotifyAttributes=0x10,ENotifyWrite=0x20,ENotifyDisk=0x40};
  2928 //
  2929 	RFs fs;
  2930 	TInt r=fs.Connect();	//	Session to be notified of any changes
  2931 	test(r==KErrNone);
  2932 	r=fs.SetSessionPath(gSessionPath);
  2933 	test(r==KErrNone);
  2934 
  2935 //	RFile::Write() to a file within the monitored directory
  2936 	test.Next(_L("RFile::Write()"));
  2937 	TFileName path=_L("\\F32-TST\\NOTIFY\\NewFile.txt");
  2938 	TRequestStatus reqStat(KRequestPending);
  2939 	TRequestStatus reqStat2(KRequestPending);
  2940 	TRequestStatus reqStat3(KRequestPending);
  2941 	TRequestStatus reqStat4(KRequestPending);
  2942 	TRequestStatus reqStat5(KRequestPending);
  2943 	TRequestStatus reqStat6(KRequestPending);
  2944 	TRequestStatus reqStat7(KRequestPending);
  2945 
  2946 
  2947 	RFile file;
  2948 	r=file.Replace(TheFs,_L("\\F32-TST\\NOTIFY\\NewFile.txt"),EFileRead|EFileWrite);
  2949 	test(r==KErrNone);
  2950 
  2951 	fs.NotifyChange(ENotifyAll,reqStat,path);
  2952 	fs.NotifyChange(ENotifyFile,reqStat2,path);
  2953 	fs.NotifyChange(ENotifyWrite,reqStat3,path);
  2954 	fs.NotifyChange(ENotifyDir,reqStat4,path);
  2955 	fs.NotifyChange(ENotifyEntry,reqStat5,path);
  2956 	fs.NotifyChange(ENotifyAttributes,reqStat6,path);
  2957 	fs.NotifyChange(ENotifyDisk,reqStat7,path);
  2958 
  2959 
  2960 	test(reqStat==KRequestPending);
  2961 	test(reqStat2==KRequestPending);
  2962 	test(reqStat3==KRequestPending);
  2963 	User::WaitForRequest(reqStat4);
  2964 	test(reqStat4==KErrArgument); //	Cannot monitor a file with ENotifyDir
  2965 	test(reqStat5==KRequestPending);
  2966 	test(reqStat6==KRequestPending);
  2967 	fs.NotifyChange(ENotifyEntry,reqStat4,path);
  2968 	test(reqStat4==KRequestPending);
  2969 
  2970 	r=file.Write(0,_L8("Pay no attention to the man behind the curtain"));
  2971 	file.Close();
  2972 
  2973 	User::WaitForRequest(reqStat);
  2974 	test(reqStat==KErrNone);
  2975 	test(reqStat2==KRequestPending);	//	Monitoring with ENotifyFile
  2976 	User::WaitForRequest(reqStat3);
  2977 	test(reqStat3==KErrNone);
  2978 	test(reqStat4==KRequestPending);	//	Monitoring with ENotifyEntry
  2979 	test(reqStat5==KRequestPending);
  2980 	test(reqStat6==KRequestPending);
  2981 	test(reqStat7==KRequestPending);
  2982 	fs.NotifyChangeCancel();			//	Cancels all outstanding notification requests
  2983 
  2984 	User::WaitForRequest(reqStat2);
  2985 	test(reqStat2==KErrCancel);
  2986 	User::WaitForRequest(reqStat4);
  2987 	test(reqStat4==KErrCancel);
  2988 	User::WaitForRequest(reqStat5);
  2989 	test(reqStat5==KErrCancel);
  2990 	User::WaitForRequest(reqStat6);
  2991 	test(reqStat6==KErrCancel);
  2992 	User::WaitForRequest(reqStat7);
  2993 	test(reqStat7==KErrCancel);
  2994 
  2995 	r=file.Open(TheFs,_L("\\F32-TST\\NOTIFY\\NewFile.txt"),EFileRead|EFileWrite);
  2996 	test(r==KErrNone);
  2997 
  2998 //	RFile::SetAtt() of a file within the monitored directory
  2999 	fs.NotifyChange(ENotifyAll,reqStat,path);
  3000 	fs.NotifyChange(ENotifyFile,reqStat2,path);
  3001 	fs.NotifyChange(ENotifyEntry,reqStat3,path);
  3002 	fs.NotifyChange(ENotifyAttributes,reqStat4,path);
  3003 	fs.NotifyChange(ENotifyDir,reqStat5,path);
  3004 	fs.NotifyChange(ENotifyWrite,reqStat6,path);
  3005 	fs.NotifyChange(ENotifyDisk,reqStat7,path);
  3006 
  3007 	test(reqStat==KRequestPending);
  3008 	test(reqStat2==KRequestPending);
  3009 	test(reqStat3==KRequestPending);
  3010 	test(reqStat4==KRequestPending);
  3011 	User::WaitForRequest(reqStat5);
  3012 	test(reqStat5==KErrArgument);
  3013 	test(reqStat6==KRequestPending);
  3014 	test(reqStat7==KRequestPending);
  3015 
  3016 	test.Next(_L("RFile::SetAtt()"));
  3017 	r=file.SetAtt(KEntryAttSystem,KEntryAttNormal);
  3018 	test(r==KErrNone);
  3019 	User::WaitForRequest(reqStat);
  3020 	User::WaitForRequest(reqStat4);
  3021 	test(reqStat==KErrNone);
  3022 	test(reqStat2==KRequestPending);	//	Monitoring with ENotifyFile
  3023 	test(reqStat3==KRequestPending);	//	Monitoring with ENotifyEntry
  3024 	test(reqStat4==KErrNone);				//	Monitoring a file - can't use ENotifyDir
  3025 	test(reqStat6==KRequestPending);
  3026 	test(reqStat7==KRequestPending);
  3027 
  3028 	fs.NotifyChange(ENotifyWrite,reqStat,path);
  3029 	test(reqStat==KRequestPending);
  3030 	fs.NotifyChange(ENotifyDir,reqStat4,path);
  3031 	User::WaitForRequest(reqStat4);
  3032 	test(reqStat4==KErrArgument);
  3033 	r=file.SetAtt(KEntryAttNormal,KEntryAttSystem);
  3034 	test(r==KErrNone);
  3035 	test(reqStat==KRequestPending);		//	Monitoring with ENotifyWrite
  3036 	fs.NotifyChangeCancel();	//	Cancel outstanding notification request
  3037 
  3038 	User::WaitForRequest(reqStat);
  3039 	test(reqStat==KErrCancel);
  3040 	User::WaitForRequest(reqStat2);
  3041 	test(reqStat2==KErrCancel);
  3042 	User::WaitForRequest(reqStat3);
  3043 	test(reqStat3==KErrCancel);
  3044 	User::WaitForRequest(reqStat6);
  3045 	test(reqStat6==KErrCancel);
  3046 	User::WaitForRequest(reqStat7);
  3047 	test(reqStat7==KErrCancel);
  3048 
  3049 	fs.NotifyChange(ENotifyAll,reqStat,path);
  3050 	fs.NotifyChange(ENotifyFile,reqStat2,path);
  3051 	fs.NotifyChange(ENotifyEntry,reqStat3,path);
  3052 	fs.NotifyChange(ENotifyAttributes,reqStat4,path);
  3053 
  3054 	test(reqStat==KRequestPending);
  3055 	test(reqStat2==KRequestPending);
  3056 	test(reqStat3==KRequestPending);
  3057 	test(reqStat4==KRequestPending);
  3058 
  3059 //	RFile::SetSize() of a file within the monitored directory
  3060 	test.Next(_L("RFile::SetSize()"));
  3061 	r=file.SetSize(256);
  3062 	test(r==KErrNone);
  3063 	User::WaitForRequest(reqStat);
  3064 	User::WaitForRequest(reqStat4);
  3065 	test(reqStat==KErrNone);
  3066 	test(reqStat2==KRequestPending);	//	Monitoring with ENotifyFile
  3067 	test(reqStat3==KRequestPending);	//	Monitoring with ENotifyEntry
  3068 	test(reqStat4==KErrNone);
  3069 
  3070 	fs.NotifyChange(ENotifyWrite,reqStat,path);
  3071 	test(reqStat==KRequestPending);
  3072 	fs.NotifyChange(ENotifyDir,reqStat4,path);
  3073 	User::WaitForRequest(reqStat4);
  3074 	test(reqStat4==KErrArgument);
  3075 	r=file.SetSize(200);
  3076 	test(r==KErrNone);
  3077 	User::After(1000000);
  3078 	test(reqStat==KRequestPending);		//	Monitoring with ENotifyWrite
  3079 
  3080 	file.Close();
  3081 	fs.NotifyChangeCancel();			//	Cancels all outstanding notification requests
  3082 
  3083 	User::WaitForRequest(reqStat);
  3084 	test(reqStat==KErrCancel);
  3085 	User::WaitForRequest(reqStat2);
  3086 	test(reqStat2==KErrCancel);
  3087 	User::WaitForRequest(reqStat3);
  3088 	test(reqStat3==KErrCancel);
  3089 
  3090 //	RFile::Temp() to create a temp file within the monitored directory
  3091 	test.Next(_L("RFile::Temp()"));
  3092 	path=_L("\\F32-TST\\NOTIFY\\");
  3093 
  3094 	fs.NotifyChange(ENotifyAll,reqStat,path);
  3095 	fs.NotifyChange(ENotifyDir,reqStat2,path);
  3096 	fs.NotifyChange(ENotifyEntry,reqStat3,path);
  3097 	fs.NotifyChange(ENotifyAttributes,reqStat4,path);
  3098 
  3099 	test(reqStat==KRequestPending);
  3100 	test(reqStat2==KRequestPending);
  3101 	test(reqStat3==KRequestPending);
  3102 	test(reqStat4==KRequestPending);
  3103 
  3104 	TFileName fileName;
  3105 	r=file.Temp(TheFs,path,fileName,EFileWrite);
  3106 	test(r==KErrNone);
  3107 	User::WaitForRequest(reqStat);
  3108 	test(reqStat==KErrNone);
  3109 	test(reqStat2==KRequestPending);
  3110 	test(reqStat3==KRequestPending);	//	Monitoring ENotifyEntry
  3111 	test(reqStat4==KRequestPending);	//	Monitoring ENotifyAttributes
  3112 	file.Close();
  3113 	fs.NotifyChangeCancel();
  3114 
  3115 	User::WaitForRequest(reqStat2);
  3116 	test(reqStat2==KErrCancel);
  3117 	User::WaitForRequest(reqStat3);
  3118 	test(reqStat3==KErrCancel);
  3119 	User::WaitForRequest(reqStat4);
  3120 	test(reqStat4==KErrCancel);
  3121 
  3122 	fs.NotifyChange(ENotifyFile,reqStat,path);
  3123 	fs.NotifyChange(ENotifyDisk,reqStat2,path);
  3124 	fs.NotifyChange(ENotifyWrite,reqStat3,path);
  3125 	r=file.Temp(TheFs,path,fileName,EFileWrite);
  3126 	test(r==KErrNone);
  3127 	test(reqStat==KRequestPending);		//	Monitoring ENotifyFile
  3128 	test(reqStat2==KRequestPending);	//	Monitoring ENotifyDisk
  3129 	test(reqStat3==KRequestPending);	//	Monitoring ENotifyWrite
  3130 	file.Close();
  3131 
  3132 	fs.NotifyChangeCancel();	//	Cancels all outstanding notification requests
  3133 
  3134 	User::WaitForRequest(reqStat);
  3135 	test(reqStat==KErrCancel);
  3136 	User::WaitForRequest(reqStat2);
  3137 	test(reqStat2==KErrCancel);
  3138 	User::WaitForRequest(reqStat3);
  3139 	test(reqStat3==KErrCancel);
  3140 
  3141 //	RFile::SetModified() to change modification time of a file within monitored dir
  3142 	test.Next(_L("RFile::SetModified()"));
  3143 	path=_L("\\F32-TST\\NOTIFY\\NewFile.txt");
  3144 	fs.NotifyChange(ENotifyAll,reqStat,path);
  3145 	fs.NotifyChange(ENotifyEntry,reqStat2,path);
  3146 	fs.NotifyChange(ENotifyAttributes,reqStat3,path);
  3147 	fs.NotifyChange(ENotifyFile,reqStat4,path);
  3148 
  3149 	test(reqStat==KRequestPending);
  3150 	test(reqStat2==KRequestPending);
  3151 	test(reqStat3==KRequestPending);
  3152 	test(reqStat4==KRequestPending);
  3153 
  3154 	TTime now;
  3155 	now.HomeTime();
  3156 	r=file.Open(TheFs,_L("\\F32-TST\\NOTIFY\\NewFile.txt"),EFileRead|EFileWrite);
  3157 	test(r==KErrNone);
  3158 	test(reqStat==KRequestPending);
  3159 	file.SetModified(now);
  3160 	file.Close();
  3161 	User::WaitForRequest(reqStat);
  3162 	test(reqStat==KErrNone);
  3163 	test(reqStat2==KRequestPending);
  3164 	User::WaitForRequest(reqStat3);
  3165 	test(reqStat3==KErrNone);
  3166 	test(reqStat4==KRequestPending);
  3167 	fs.NotifyChangeCancel();
  3168 
  3169 	User::WaitForRequest(reqStat2);
  3170 	test(reqStat2==KErrCancel);
  3171 	User::WaitForRequest(reqStat4);
  3172 	test(reqStat4==KErrCancel);
  3173 
  3174 //	RFs::SetEntry() to change a directory entry within the monitored directory
  3175 	test.Next(_L("RFs::SetEntry()"));
  3176 	TEntry entry;
  3177 	fs.NotifyChange(ENotifyAll,reqStat,path);
  3178 	fs.NotifyChange(ENotifyEntry,reqStat2,path);
  3179 	fs.NotifyChange(ENotifyAttributes,reqStat3,path);
  3180 	fs.NotifyChange(ENotifyDisk,reqStat4,path);
  3181 
  3182 	test(reqStat==KRequestPending);
  3183 	test(reqStat2==KRequestPending);
  3184 	test(reqStat3==KRequestPending);
  3185 	test(reqStat4==KRequestPending);
  3186 
  3187 	r=TheFs.Entry(_L("\\F32-TST\\NOTIFY\\NewFile.txt"),entry);
  3188 	test(reqStat==KRequestPending);
  3189 	now.HomeTime();
  3190 	r=TheFs.SetEntry(_L("\\F32-TST\\NOTIFY\\NewFile.txt"),now,KEntryAttHidden,KEntryAttNormal);
  3191 	test(r==KErrNone);
  3192 	User::WaitForRequest(reqStat);
  3193 	User::WaitForRequest(reqStat3);
  3194 	test(reqStat==KErrNone);
  3195 	test(reqStat2==KRequestPending);
  3196 	test(reqStat3==KErrNone);
  3197 	test(reqStat4==KRequestPending);
  3198 	fs.NotifyChangeCancel();
  3199 
  3200 	User::WaitForRequest(reqStat2);
  3201 	test(reqStat2==KErrCancel);
  3202 	User::WaitForRequest(reqStat4);
  3203 	test(reqStat4==KErrCancel);
  3204 
  3205 //	RFile::Set() to change file's modification time and attributes
  3206 	test.Next(_L("RFile::Set()"));
  3207 	fs.NotifyChange(ENotifyAll,reqStat,path);
  3208 	fs.NotifyChange(ENotifyEntry,reqStat2,path);
  3209 	fs.NotifyChange(ENotifyAttributes,reqStat3,path);
  3210 	fs.NotifyChange(ENotifyWrite,reqStat4,path);
  3211 
  3212 	test(reqStat==KRequestPending);
  3213 	test(reqStat2==KRequestPending);
  3214 	test(reqStat3==KRequestPending);
  3215 	test(reqStat4==KRequestPending);
  3216 
  3217 	r=file.Open(TheFs,_L("\\F32-TST\\NOTIFY\\NewFile.txt"),EFileRead|EFileWrite);
  3218 	test(r==KErrNone);
  3219 	test(reqStat==KRequestPending);
  3220 	now.HomeTime();
  3221 	r=file.Set(now,KEntryAttNormal,KEntryAttHidden);
  3222 	file.Close();
  3223 	User::WaitForRequest(reqStat);
  3224 	User::WaitForRequest(reqStat3);
  3225 	test(reqStat==KErrNone);
  3226 	test(reqStat2==KRequestPending);
  3227 	test(reqStat3==KErrNone);
  3228 	test(reqStat4==KRequestPending);
  3229 	fs.NotifyChangeCancel();
  3230 
  3231 	User::WaitForRequest(reqStat2);
  3232 	test(reqStat2==KErrCancel);
  3233 	User::WaitForRequest(reqStat4);
  3234 	test(reqStat4==KErrCancel);
  3235 
  3236 //	RFs::SetDriveName()
  3237 
  3238 	test.Next(_L("RFs::SetDriveName()"));
  3239 	fs.NotifyChange(ENotifyAll,reqStat,path);
  3240 	fs.NotifyChange(ENotifyEntry,reqStat2,path);
  3241 	fs.NotifyChange(ENotifyDisk,reqStat3,path);
  3242 	fs.NotifyChange(ENotifyAttributes,reqStat4,path);
  3243 
  3244 	test(reqStat==KRequestPending);
  3245 	test(reqStat2==KRequestPending);
  3246 	test(reqStat3==KRequestPending);
  3247 	test(reqStat4==KRequestPending);
  3248 	User::After(KNotifyChangeAfter);
  3249 
  3250 	r=TheFs.SetDriveName(KDefaultDrive,_L("DRIVETEST"));
  3251 	test(r==KErrNone);
  3252 	User::WaitForRequest(reqStat);
  3253 	test(reqStat==KErrNone);
  3254 	test(reqStat2==KRequestPending);
  3255 	test(reqStat3==KRequestPending);
  3256 	test(reqStat4==KRequestPending);
  3257 	fs.NotifyChangeCancel();
  3258 
  3259 	User::WaitForRequest(reqStat2);
  3260 	test(reqStat2==KErrCancel);
  3261 	User::WaitForRequest(reqStat3);
  3262 	test(reqStat3==KErrCancel);
  3263 	User::WaitForRequest(reqStat4);
  3264 	test(reqStat4==KErrCancel);
  3265 
  3266 //	RFs::MkDir()
  3267 	test.Next(_L("RFs::MkDir()"));
  3268 	path=_L("\\F32-TST\\NOTIFY\\");
  3269 
  3270 	fs.NotifyChange(ENotifyAll,reqStat,path);
  3271 	fs.NotifyChange(ENotifyEntry,reqStat2,path);
  3272 	fs.NotifyChange(ENotifyDir,reqStat3,path);
  3273 	fs.NotifyChange(ENotifyFile,reqStat4,path);
  3274 
  3275 	test(reqStat==KRequestPending);
  3276 	test(reqStat2==KRequestPending);
  3277 	test(reqStat3==KRequestPending);
  3278 	test(reqStat4==KRequestPending);
  3279 
  3280 	r=TheFs.MkDir(_L("\\F32-TST\\NOTIFY\\EMERALD_CITY\\"));
  3281 	test(r==KErrNone);
  3282 	User::WaitForRequest(reqStat);
  3283 	User::WaitForRequest(reqStat2);
  3284 	User::WaitForRequest(reqStat3);
  3285 	test(reqStat==KErrNone);
  3286 	test(reqStat2==KErrNone);
  3287 	test(reqStat3==KErrNone);
  3288 	test(reqStat4==KRequestPending);
  3289 
  3290 //	RFs::RmDir()
  3291 	test.Next(_L("RFs::RmDir()"));
  3292 	fs.NotifyChange(ENotifyAll,reqStat,path);
  3293 	fs.NotifyChange(ENotifyDir,reqStat2,path);
  3294 	fs.NotifyChange(ENotifyWrite,reqStat3,path);
  3295 
  3296 	test(reqStat==KRequestPending);
  3297 	test(reqStat2==KRequestPending);
  3298 	test(reqStat3==KRequestPending);
  3299 
  3300 	r=TheFs.RmDir(_L("\\F32-TST\\NOTIFY\\EMERALD_CITY\\"));
  3301 	test(r==KErrNone);
  3302 	User::WaitForRequest(reqStat);
  3303 	User::WaitForRequest(reqStat2);
  3304 	test(reqStat==KErrNone);
  3305 	test(reqStat2==KErrNone);
  3306 	test(reqStat3==KRequestPending);
  3307 	test(reqStat4==KRequestPending);
  3308 	fs.NotifyChangeCancel();
  3309 
  3310 	User::WaitForRequest(reqStat3);
  3311 	test(reqStat3==KErrCancel);
  3312 	User::WaitForRequest(reqStat4);
  3313 	test(reqStat4==KErrCancel);
  3314 
  3315 //	RFile::Create()
  3316 	test.Next(_L("RFile::Create()"));
  3317 	fs.NotifyChange(ENotifyAll,reqStat,path);
  3318 	fs.NotifyChange(ENotifyEntry,reqStat2,path);
  3319 	fs.NotifyChange(ENotifyDir,reqStat3,path);
  3320 	fs.NotifyChange(ENotifyFile,reqStat4,path);
  3321 
  3322 	test(reqStat==KRequestPending);
  3323 	test(reqStat2==KRequestPending);
  3324 	test(reqStat3==KRequestPending);
  3325 	test(reqStat4==KRequestPending);
  3326 
  3327 	r=file.Create(TheFs,_L("\\F32-TST\\NOTIFY\\Good_Witch.bat"),EFileRead|EFileWrite);
  3328 	test(r==KErrNone);
  3329 	User::WaitForRequest(reqStat);
  3330 	User::WaitForRequest(reqStat2);
  3331 	User::WaitForRequest(reqStat4);
  3332 	test(reqStat==KErrNone);
  3333 	test(reqStat2==KErrNone);
  3334 	test(reqStat3==KRequestPending);	//	Monitoring ENotifyDir
  3335 	test(reqStat4==KErrNone);
  3336 	file.Close();
  3337 	fs.NotifyChangeCancel(reqStat3);
  3338 	User::WaitForRequest(reqStat3);
  3339 
  3340 	fs.NotifyChange(ENotifyAll,reqStat,path);
  3341 	fs.NotifyChange(ENotifyEntry,reqStat2,path);
  3342 	fs.NotifyChange(ENotifyDisk,reqStat3,path);
  3343 	fs.NotifyChange(ENotifyWrite,reqStat4,path);
  3344 
  3345 	test(reqStat==KRequestPending);
  3346 	test(reqStat2==KRequestPending);
  3347 	test(reqStat3==KRequestPending);
  3348 	test(reqStat4==KRequestPending);
  3349 
  3350 	r=file.Create(TheFs,_L("\\F32-TST\\NOTIFY\\Bad_Witch.bat"),EFileRead|EFileWrite);
  3351 	test(r==KErrNone);
  3352 	User::WaitForRequest(reqStat);
  3353 	User::WaitForRequest(reqStat2);
  3354 	test(reqStat==KErrNone);
  3355 	test(reqStat2==KErrNone);
  3356 	test(reqStat3==KRequestPending);
  3357 	test(reqStat4==KRequestPending);
  3358 	file.Close();
  3359 	fs.NotifyChangeCancel();
  3360 
  3361 	User::WaitForRequest(reqStat3);
  3362 	test(reqStat3==KErrCancel);
  3363 	User::WaitForRequest(reqStat4);
  3364 	test(reqStat4==KErrCancel);
  3365 
  3366 //	RFs::Delete()
  3367 	test.Next(_L("RFs::Delete()"));
  3368 	fs.NotifyChange(ENotifyAll,reqStat,path);
  3369 	fs.NotifyChange(ENotifyEntry,reqStat2,path);
  3370 	fs.NotifyChange(ENotifyDir,reqStat3,path);
  3371 	fs.NotifyChange(ENotifyFile,reqStat4,path);
  3372 
  3373 	test(reqStat==KRequestPending);
  3374 	test(reqStat2==KRequestPending);
  3375 	test(reqStat3==KRequestPending);
  3376 	test(reqStat4==KRequestPending);
  3377 
  3378 	r=TheFs.Delete(_L("\\F32-TST\\NOTIFY\\Good_Witch.bat"));
  3379 	test(r==KErrNone);
  3380 	User::WaitForRequest(reqStat);
  3381 	User::WaitForRequest(reqStat2);
  3382 	User::WaitForRequest(reqStat4);
  3383 	test(reqStat==KErrNone);
  3384 	test(reqStat2==KErrNone);
  3385 	test(reqStat3==KRequestPending);	//	Monitoring ENotifyDir
  3386 	test(reqStat4==KErrNone);
  3387 	fs.NotifyChangeCancel(reqStat3);
  3388 	User::WaitForRequest(reqStat3);
  3389 	test(reqStat3==KErrCancel);
  3390 
  3391 	fs.NotifyChange(ENotifyAll,reqStat,path);
  3392 	fs.NotifyChange(ENotifyEntry,reqStat2,path);
  3393 	fs.NotifyChange(ENotifyAttributes,reqStat3,path);
  3394 	fs.NotifyChange(ENotifyAll,reqStat4,path);
  3395 
  3396 	test(reqStat==KRequestPending);
  3397 	test(reqStat2==KRequestPending);
  3398 	test(reqStat3==KRequestPending);
  3399 	test(reqStat4==KRequestPending);
  3400 
  3401 	r=TheFs.Delete(_L("\\F32-TST\\NOTIFY\\Bad_Witch.bat"));
  3402 	test(r==KErrNone);
  3403 	User::WaitForRequest(reqStat);
  3404 	User::WaitForRequest(reqStat2);
  3405 	User::WaitForRequest(reqStat4);
  3406 	test(reqStat==KErrNone);
  3407 	test(reqStat2==KErrNone);
  3408 	test(reqStat3==KRequestPending);
  3409 	test(reqStat4==KErrNone);
  3410 	fs.NotifyChangeCancel(reqStat3);
  3411 	User::WaitForRequest(reqStat3);
  3412 	test(reqStat3==KErrCancel);
  3413 
  3414 //	RFile::Replace()
  3415 	test.Next(_L("RFile::Replace()"));
  3416 	fs.NotifyChange(ENotifyAll,reqStat,path);
  3417 	fs.NotifyChange(ENotifyEntry,reqStat2,path);
  3418 	fs.NotifyChange(ENotifyFile,reqStat3,path);
  3419 	fs.NotifyChange(ENotifyDir,reqStat4,path);
  3420 
  3421 	test(reqStat==KRequestPending);
  3422 	test(reqStat2==KRequestPending);
  3423 	test(reqStat3==KRequestPending);
  3424 	test(reqStat4==KRequestPending);
  3425 
  3426 	r=file.Replace(TheFs,_L("\\F32-TST\\NOTIFY\\Good_Witch.bat"),EFileRead|EFileWrite);
  3427 	test(r==KErrNone);
  3428 	User::WaitForRequest(reqStat);
  3429 	User::WaitForRequest(reqStat2);
  3430 	User::WaitForRequest(reqStat3);
  3431 	test(reqStat==KErrNone);
  3432 	test(reqStat2==KErrNone);
  3433 	test(reqStat3==KErrNone);
  3434 	test(reqStat4==KRequestPending);
  3435 	file.Close();
  3436 	fs.NotifyChangeCancel();
  3437 
  3438 	test(reqStat==KErrNone);
  3439 	test(reqStat2==KErrNone);
  3440 	test(reqStat3==KErrNone);
  3441 	User::WaitForRequest(reqStat4);
  3442 	test(reqStat4==KErrCancel);
  3443 
  3444 //	RFs::Delete()
  3445 	test.Next(_L("RFs::Delete()"));
  3446 	path=_L("\\F32-TST\\NOTIFY\\Good_Witch.bat");
  3447 	fs.NotifyChange(ENotifyAll,reqStat,path);
  3448 	fs.NotifyChange(ENotifyEntry,reqStat2,path);
  3449 	fs.NotifyChange(ENotifyFile,reqStat3,path);
  3450 	fs.NotifyChange(ENotifyDir,reqStat4,path);
  3451 
  3452 	test(reqStat==KRequestPending);
  3453 	test(reqStat2==KRequestPending);
  3454 	test(reqStat3==KRequestPending);
  3455 	User::WaitForRequest(reqStat4);
  3456 	test(reqStat4==KErrArgument);
  3457 
  3458 	r=TheFs.Delete(_L("\\F32-TST\\NOTIFY\\Good_Witch.bat"));
  3459 	test(r==KErrNone);
  3460 	User::WaitForRequest(reqStat);
  3461 	User::WaitForRequest(reqStat2);
  3462 	User::WaitForRequest(reqStat3);
  3463 	test(reqStat==KErrNone);
  3464 	test(reqStat2==KErrNone);
  3465 	test(reqStat3==KErrNone);
  3466 	test(reqStat4==KErrArgument);
  3467 
  3468 //	RFs::SetVolumeLabel()
  3469 	test.Next(_L("RFs::SetVolumeLabel()"));
  3470 	path=_L("\\F32-TST\\NOTIFY\\");
  3471 	fs.NotifyChange(ENotifyAll,reqStat,path);
  3472 	fs.NotifyChange(ENotifyEntry,reqStat2,path);
  3473 	fs.NotifyChange(ENotifyFile,reqStat3,path);
  3474 	fs.NotifyChange(ENotifyDir,reqStat4,path);
  3475 	fs.NotifyChange(ENotifyWrite,reqStat5,path);
  3476 	fs.NotifyChange(ENotifyAttributes,reqStat6,path);
  3477 	fs.NotifyChange(ENotifyDisk,reqStat7,path);
  3478 
  3479 	test(reqStat==KRequestPending);
  3480 	test(reqStat2==KRequestPending);
  3481 	test(reqStat3==KRequestPending);
  3482 	test(reqStat4==KRequestPending);
  3483 	test(reqStat5==KRequestPending);
  3484 	test(reqStat6==KRequestPending);
  3485 	test(reqStat7==KRequestPending);
  3486 
  3487 	TInt driveNum=CurrentDrive();
  3488 	TVolumeInfo volInfo;
  3489 	TFileName currentVolName;
  3490 	r=TheFs.Volume(volInfo,driveNum);
  3491 	test(r==KErrNone);
  3492 	test(reqStat==KRequestPending);
  3493 	currentVolName=volInfo.iName;
  3494 
  3495 	r=TheFs.SetVolumeLabel(_L("VOL"),driveNum);
  3496 	if (r==KErrNone)
  3497 		{
  3498 		User::WaitForRequest(reqStat);
  3499 		User::WaitForRequest(reqStat2);
  3500 		User::WaitForRequest(reqStat7);
  3501 
  3502 		test(reqStat==KErrNone);
  3503 		test(reqStat2==KErrNone);
  3504 		test(reqStat3==KRequestPending);
  3505 		test(reqStat4==KRequestPending);
  3506 		test(reqStat5==KRequestPending);
  3507 		test(reqStat6==KRequestPending);
  3508 		test(reqStat7==KErrNone);
  3509 
  3510 		fs.NotifyChange(ENotifyAll,reqStat,path);
  3511 		fs.NotifyChange(ENotifyEntry,reqStat2,path);
  3512 		fs.NotifyChange(ENotifyDisk,reqStat7,path);
  3513 
  3514 		test(reqStat==KRequestPending);
  3515 		test(reqStat2==KRequestPending);
  3516 		test(reqStat7==KRequestPending);
  3517 
  3518 		r=TheFs.SetVolumeLabel(currentVolName,driveNum);
  3519 		test(r==KErrNone);
  3520 
  3521 		User::WaitForRequest(reqStat);
  3522 		User::WaitForRequest(reqStat2);
  3523 		User::WaitForRequest(reqStat7);
  3524 
  3525 		test(reqStat==KErrNone);
  3526 		test(reqStat2==KErrNone);
  3527 		test(reqStat3==KRequestPending);
  3528 		test(reqStat4==KRequestPending);
  3529 		test(reqStat5==KRequestPending);
  3530 		test(reqStat6==KRequestPending);
  3531 		test(reqStat7==KErrNone);
  3532 
  3533 		r=TheFs.Volume(volInfo,driveNum);
  3534 		test(r==KErrNone);
  3535 		test(volInfo.iName==currentVolName);
  3536 
  3537 		fs.NotifyChangeCancel();
  3538 
  3539 		User::WaitForRequest(reqStat3);
  3540 		test(reqStat3==KErrCancel);
  3541 		User::WaitForRequest(reqStat4);
  3542 		test(reqStat4==KErrCancel);
  3543 		User::WaitForRequest(reqStat5);
  3544 		test(reqStat5==KErrCancel);
  3545 		User::WaitForRequest(reqStat6);
  3546 		test(reqStat6==KErrCancel);
  3547 		}
  3548 
  3549 	else	//	RFs::SetVolumeLabel() doesn't work on subst drives
  3550 		{
  3551 		fs.NotifyChangeCancel();
  3552 		User::WaitForRequest(reqStat);
  3553 		User::WaitForRequest(reqStat2);
  3554 		User::WaitForRequest(reqStat3);
  3555 		User::WaitForRequest(reqStat4);
  3556 		User::WaitForRequest(reqStat5);
  3557 		User::WaitForRequest(reqStat6);
  3558 		User::WaitForRequest(reqStat7);
  3559 		test.Printf(_L("Cannot set volume label on a substed drive!\n"));
  3560 		}
  3561 
  3562 
  3563 //	RFile::Rename()
  3564 	test.Next(_L("RFile::Rename()"));
  3565 	path=_L("\\F32-TST\\NOTIFY\\");
  3566 
  3567 	file.Open(TheFs,_L("\\F32-TST\\NOTIFY\\NewFile.txt"),EFileShareExclusive|EFileWrite);
  3568 	fs.NotifyChange(ENotifyAll,reqStat,path);
  3569 	fs.NotifyChange(ENotifyEntry,reqStat2,path);
  3570 	fs.NotifyChange(ENotifyFile,reqStat3,path);
  3571 	fs.NotifyChange(ENotifyDir,reqStat4,path);
  3572 
  3573 	test(reqStat==KRequestPending);
  3574 	test(reqStat2==KRequestPending);
  3575 	test(reqStat3==KRequestPending);
  3576 	test(reqStat4==KRequestPending);
  3577 
  3578 	r=file.Rename(_L("\\F32-TST\\NOTIFY\\OldFile.abc"));
  3579 	test(r==KErrNone||r==KErrAlreadyExists);
  3580 	User::WaitForRequest(reqStat);
  3581 	User::WaitForRequest(reqStat2);
  3582 	User::WaitForRequest(reqStat3);
  3583 	test(reqStat==KErrNone);
  3584 	test(reqStat2==KErrNone);
  3585 	test(reqStat3==KErrNone);
  3586 	test(reqStat4==KRequestPending);	//	Monitoring ENotifyDir
  3587 	file.Close();
  3588 	fs.NotifyChangeCancel();
  3589 	User::WaitForRequest(reqStat4);
  3590 	test(reqStat4==KErrCancel);
  3591 
  3592 	path=_L("\\F32-TST\\NOTIFY\\OldFile.abc");
  3593 
  3594 	r=file.Open(TheFs,_L("\\F32-TST\\NOTIFY\\OldFile.abc"),EFileShareExclusive|EFileWrite);
  3595 	test(r==KErrNone);
  3596 	fs.NotifyChange(ENotifyAll,reqStat,path);
  3597 	fs.NotifyChange(ENotifyEntry,reqStat2,path);
  3598 	fs.NotifyChange(ENotifyFile,reqStat3,path);
  3599 	fs.NotifyChange(ENotifyDir,reqStat4,path);
  3600 
  3601 	test(reqStat==KRequestPending);
  3602 	test(reqStat2==KRequestPending);
  3603 	test(reqStat3==KRequestPending);
  3604 	User::WaitForRequest(reqStat4);
  3605 	test(reqStat4==KErrArgument);
  3606 
  3607 	r=file.Rename(_L("\\F32-TST\\NOTIFY\\NewFile.xyz"));
  3608 	test(r==KErrNone);
  3609 	User::WaitForRequest(reqStat);
  3610 	User::WaitForRequest(reqStat2);
  3611 	User::WaitForRequest(reqStat3);
  3612 	test(reqStat==KErrNone);
  3613 	test(reqStat2==KErrNone);
  3614 	test(reqStat3==KErrNone);
  3615 	test(reqStat4==KErrArgument);
  3616 	file.Close();
  3617 
  3618 //	RFs::Rename()
  3619 	test.Next(_L("RFs::Rename()"));
  3620 	path=_L("\\F32-TST\\NOTIFY\\");
  3621 	fs.NotifyChange(ENotifyAll,reqStat,path);
  3622 	fs.NotifyChange(ENotifyEntry,reqStat2,path);
  3623 	fs.NotifyChange(ENotifyFile,reqStat3,path);
  3624 	fs.NotifyChange(ENotifyDir,reqStat4,path);
  3625 
  3626 	test(reqStat==KRequestPending);
  3627 	test(reqStat2==KRequestPending);
  3628 	test(reqStat3==KRequestPending);
  3629 	test(reqStat4==KRequestPending);
  3630 
  3631 	r=TheFs.Rename(_L("\\F32-TST\\NOTIFY\\NewFile.xyz"),_L("\\F32-TST\\NOTIFY\\NewerFile.cat"));
  3632 	test(r==KErrNone);
  3633 	User::WaitForRequest(reqStat);
  3634 	User::WaitForRequest(reqStat2);
  3635 	User::WaitForRequest(reqStat3);
  3636 	test(reqStat==KErrNone);
  3637 	test(reqStat2==KErrNone);
  3638 	test(reqStat3==KErrNone);
  3639 	test(reqStat4==KRequestPending);	//	Changed a file not a directory entry
  3640 	fs.NotifyChangeCancel();
  3641 
  3642 	test(reqStat==KErrNone);
  3643 	test(reqStat2==KErrNone);
  3644 	test(reqStat3==KErrNone);
  3645 	User::WaitForRequest(reqStat4);
  3646 	test(reqStat4==KErrCancel);
  3647 
  3648 	path=_L("\\F32-TST\\NOTIFY\\NewerFile.cat");
  3649 	fs.NotifyChange(ENotifyAll,reqStat,path);
  3650 	fs.NotifyChange(ENotifyEntry,reqStat2,path);
  3651 	fs.NotifyChange(ENotifyFile,reqStat3,path);
  3652 	fs.NotifyChange(ENotifyDir,reqStat4,path);
  3653 
  3654 	test(reqStat==KRequestPending);
  3655 	test(reqStat2==KRequestPending);
  3656 	test(reqStat3==KRequestPending);
  3657 	User::WaitForRequest(reqStat4);
  3658 	test(reqStat4==KErrArgument);
  3659 
  3660 	r=TheFs.Rename(_L("\\F32-TST\\NOTIFY\\NewerFile.cat"),_L("\\F32-TST\\NOTIFY\\Original.dog"));
  3661 	test(r==KErrNone);
  3662 	User::WaitForRequest(reqStat);
  3663 	User::WaitForRequest(reqStat2);
  3664 	User::WaitForRequest(reqStat3);
  3665 	test(reqStat==KErrNone);
  3666 	test(reqStat2==KErrNone);
  3667 	test(reqStat3==KErrNone);
  3668 
  3669 	path=_L("\\F32-TST\\NOTIFY\\");
  3670 	fs.NotifyChange(ENotifyAll,reqStat,path);
  3671 	fs.NotifyChange(ENotifyEntry,reqStat2,path);
  3672 	fs.NotifyChange(ENotifyFile,reqStat3,path);
  3673 	fs.NotifyChange(ENotifyDir,reqStat4,path);
  3674 
  3675 	test(reqStat==KRequestPending);
  3676 	test(reqStat2==KRequestPending);
  3677 	test(reqStat3==KRequestPending);
  3678 	test(reqStat4==KRequestPending);
  3679 
  3680 	r=TheFs.Rename(_L("\\F32-TST\\NOTIFY\\"),_L("\\F32-TST\\NOTIFY_TEMP\\"));
  3681 	test(r==KErrNone);
  3682 	User::WaitForRequest(reqStat);
  3683 	User::WaitForRequest(reqStat2);
  3684 	User::WaitForRequest(reqStat3);
  3685 	User::WaitForRequest(reqStat4);
  3686 	test(reqStat==KErrNone);
  3687 	test(reqStat2==KErrNone);
  3688 	test(reqStat3==KErrNone);	//	Changed a directory entry but notified anyway despite
  3689 	test(reqStat4==KErrNone);	//	requesting file notification only because the path we
  3690 								//	were monitoring has changed
  3691 
  3692 	path=_L("\\F32-TST\\NOTIFY_TEMP\\Original.dog");
  3693 	fs.NotifyChange(ENotifyAll,reqStat,path);
  3694 	fs.NotifyChange(ENotifyEntry,reqStat2,path);
  3695 	fs.NotifyChange(ENotifyFile,reqStat3,path);
  3696 	fs.NotifyChange(ENotifyDir,reqStat4,path);
  3697 
  3698 	test(reqStat==KRequestPending);
  3699 	test(reqStat2==KRequestPending);
  3700 	test(reqStat3==KRequestPending);
  3701 	User::WaitForRequest(reqStat4);
  3702 	test(reqStat4==KErrArgument);
  3703 
  3704 	r=TheFs.Rename(_L("\\F32-TST\\NOTIFY_TEMP\\"),_L("\\F32-TST\\NOTIFY\\"));
  3705 	test(r==KErrNone);
  3706 	User::WaitForRequest(reqStat);
  3707 	User::WaitForRequest(reqStat2);
  3708 	User::WaitForRequest(reqStat3);
  3709 	test(reqStat==KErrNone);			//	Modified a directory above the level at which we
  3710 	test(reqStat2==KErrNone);			//	are monitoring for changes - we must be notified
  3711 	test(reqStat3==KErrNone);			//	anyway because the path has changed
  3712 
  3713 	fs.NotifyChange(ENotifyAll,reqStat,path);
  3714 	test(reqStat==KRequestPending);
  3715 	fs.NotifyChange(ENotifyEntry,reqStat2,path);
  3716 	test(reqStat2==KRequestPending);
  3717 	fs.NotifyChange(ENotifyFile,reqStat3,path);
  3718 	test(reqStat3==KRequestPending);
  3719 
  3720 	fs.NotifyChangeCancel(reqStat);
  3721 	User::WaitForRequest(reqStat);
  3722 	test(reqStat==KErrCancel);
  3723 	fs.NotifyChangeCancel(reqStat2);
  3724 	User::WaitForRequest(reqStat2);
  3725 	test(reqStat2==KErrCancel);
  3726 	fs.NotifyChangeCancel(reqStat3);
  3727 	User::WaitForRequest(reqStat3);
  3728 	test(reqStat3==KErrCancel);
  3729 
  3730 	path=_L("\\F32-TST\\NOTIFY\\Original.dog");
  3731 	fs.NotifyChange(ENotifyAll,reqStat,path);
  3732 	fs.NotifyChange(ENotifyEntry,reqStat2,path);
  3733 	fs.NotifyChange(ENotifyFile,reqStat3,path);
  3734 
  3735 	test(reqStat==KRequestPending);
  3736 	test(reqStat2==KRequestPending);
  3737 	test(reqStat3==KRequestPending);
  3738 
  3739 	r=TheFs.Delete(_L("\\F32-TST\\NOTIFY\\Original.dog"));
  3740 	test(r==KErrNone);
  3741 	User::WaitForRequest(reqStat);
  3742 	User::WaitForRequest(reqStat2);
  3743 	User::WaitForRequest(reqStat3);
  3744 	test(reqStat==KErrNone);
  3745 	test(reqStat2==KErrNone);
  3746 	test(reqStat3==KErrNone);
  3747 
  3748 	path=_L("\\F32-TST\\NOTIFY\\");
  3749 	fs.NotifyChange(ENotifyAll,reqStat,path);
  3750 	fs.NotifyChange(ENotifyEntry,reqStat2,path);
  3751 	fs.NotifyChange(ENotifyDir,reqStat3,path);
  3752 
  3753 	test(reqStat==KRequestPending);
  3754 	test(reqStat2==KRequestPending);
  3755 	test(reqStat3==KRequestPending);
  3756 
  3757 	r=TheFs.Rename(_L("\\F32-TST\\"),_L("\\F32-TEST\\"));
  3758 	test(r==KErrNone);
  3759 	User::WaitForRequest(reqStat);
  3760 	User::WaitForRequest(reqStat2);
  3761 	User::WaitForRequest(reqStat3);
  3762 	test(reqStat==KErrNone);			//	Modified a directory above the level at which we
  3763 	test(reqStat2==KErrNone);			//	are monitoring for changes but we receive notification
  3764 	test(reqStat3==KErrNone);			//	because the notification path has been changed
  3765 
  3766 	fs.NotifyChange(ENotifyAll,reqStat,path);
  3767 	//	Notification request is submitted, despite the subject's disappearance
  3768 	test(reqStat==KRequestPending);
  3769 	fs.NotifyChange(ENotifyEntry,reqStat2,path);
  3770 	//	Notification request is submitted, despite the subject's disappearance
  3771 	test(reqStat2==KRequestPending);
  3772 	fs.NotifyChange(ENotifyFile,reqStat3,path);
  3773 	//	Notification request is submitted, despite the subject's disappearance
  3774 	test(reqStat3==KRequestPending);
  3775 
  3776 	fs.NotifyChangeCancel(reqStat);
  3777 	User::WaitForRequest(reqStat);
  3778 	test(reqStat==KErrCancel);
  3779 	fs.NotifyChangeCancel(reqStat2);
  3780 	User::WaitForRequest(reqStat2);
  3781 	test(reqStat2==KErrCancel);
  3782 	fs.NotifyChangeCancel(reqStat3);
  3783 	User::WaitForRequest(reqStat3);
  3784 	test(reqStat3==KErrCancel);
  3785 
  3786 	path=_L("\\F32-TEST\\NOTIFY\\");
  3787 	fs.NotifyChange(ENotifyAll,reqStat,path);
  3788 	fs.NotifyChange(ENotifyEntry,reqStat2,path);
  3789 	fs.NotifyChange(ENotifyDir,reqStat3,path);
  3790 
  3791 	test(reqStat==KRequestPending);
  3792 	test(reqStat2==KRequestPending);
  3793 	test(reqStat3==KRequestPending);
  3794 
  3795 	r=TheFs.Rename(_L("\\F32-TEST\\NOTIFY\\"),_L("\\F32-TEST\\NOTIFY_CHANGED\\"));
  3796 	test(r==KErrNone);
  3797 
  3798 	User::WaitForRequest(reqStat);
  3799 	User::WaitForRequest(reqStat2);
  3800 	User::WaitForRequest(reqStat3);
  3801 
  3802 	test(reqStat==KErrNone);			//	Rename the directory we were monitoring
  3803 	test(reqStat2==KErrNone);
  3804 	test(reqStat3==KErrNone);
  3805 
  3806 //	Tidy up the test directory before continuing (while testing notifications of renaming to the monitored directory)
  3807 
  3808 	path=_L("\\F32-TST\\NOTIFY_CHANGED\\");
  3809 	fs.NotifyChange(ENotifyAll,reqStat,path);
  3810 	fs.NotifyChange(ENotifyEntry,reqStat2,path);
  3811 	fs.NotifyChange(ENotifyDir,reqStat3,path);
  3812 	fs.NotifyChange(ENotifyFile,reqStat4,path);
  3813 
  3814 	test(reqStat==KRequestPending);
  3815 	test(reqStat2==KRequestPending);
  3816 	test(reqStat3==KRequestPending);
  3817 	test(reqStat4==KRequestPending);
  3818 
  3819 	r=TheFs.Rename(_L("\\F32-TEST\\"),_L("\\F32-TST\\"));
  3820 	test(r==KErrNone);
  3821 
  3822 	User::WaitForRequest(reqStat);
  3823 	User::WaitForRequest(reqStat2);
  3824 	User::WaitForRequest(reqStat3);
  3825 
  3826 	test(reqStat==KErrNone);			//	Renaming to (under) the directory we were monitoring
  3827 	test(reqStat2==KErrNone);
  3828 	test(reqStat3==KErrNone);
  3829 	test(reqStat4==KRequestPending);
  3830 
  3831 	fs.NotifyChangeCancel(reqStat4);
  3832 	User::WaitForRequest(reqStat4);
  3833 	test(reqStat4==KErrCancel);
  3834 
  3835 	path=_L("\\F32-TST\\NOTIFY\\");
  3836 	fs.NotifyChange(ENotifyAll,reqStat,path);
  3837 	fs.NotifyChange(ENotifyEntry,reqStat2,path);
  3838 	fs.NotifyChange(ENotifyDir,reqStat3,path);
  3839 	fs.NotifyChange(ENotifyFile,reqStat4,path);
  3840 
  3841 	test(reqStat==KRequestPending);
  3842 	test(reqStat2==KRequestPending);
  3843 	test(reqStat3==KRequestPending);
  3844 	test(reqStat4==KRequestPending);
  3845 
  3846 	r=TheFs.Rename(_L("\\F32-TST\\NOTIFY_CHANGED\\"),_L("\\F32-TST\\NOTIFY\\"));
  3847 	test(r==KErrNone);
  3848 
  3849 	User::WaitForRequest(reqStat);
  3850 	User::WaitForRequest(reqStat2);
  3851 	User::WaitForRequest(reqStat3);
  3852 
  3853 	test(reqStat==KErrNone);			//	Renaming to the directory we were monitoring
  3854 	test(reqStat2==KErrNone);
  3855 	test(reqStat3==KErrNone);
  3856 	test(reqStat4==KRequestPending);
  3857 
  3858 	fs.NotifyChangeCancel(reqStat4);
  3859 	User::WaitForRequest(reqStat4);
  3860 	test(reqStat4==KErrCancel);
  3861 
  3862 //	Test combinations of notify types
  3863 	test.Next(_L("Test combinations of notify types"));
  3864 
  3865 	path=_L("\\F32-TST\\NOTIFY\\");
  3866 	fs.NotifyChange(ENotifyAll,reqStat,path);
  3867 	fs.NotifyChange((TNotifyType)(KGenericEntryChange|ENotifyAttributes),reqStat2,path);
  3868 	fs.NotifyChange((TNotifyType)(ENotifyDir|ENotifyFile),reqStat3,path);
  3869 	fs.NotifyChange((TNotifyType)(ENotifyDisk|ENotifyAttributes),reqStat4,path);
  3870 
  3871 	test(reqStat==KRequestPending);
  3872 	test(reqStat2==KRequestPending);
  3873 	test(reqStat3==KRequestPending);
  3874 	test(reqStat4==KRequestPending);
  3875 
  3876 	r=file.Create(TheFs,_L("\\F32-TST\\NOTIFY\\Munchkin.msg"),EFileRead|EFileWrite);
  3877 	test(r==KErrNone);
  3878 	User::WaitForRequest(reqStat);
  3879 	User::WaitForRequest(reqStat2);
  3880 	User::WaitForRequest(reqStat3);
  3881 	test(reqStat==KErrNone);
  3882 	test(reqStat2==KErrNone);
  3883 	test(reqStat3==KErrNone);
  3884 	test(reqStat4==KRequestPending);	//	Monitoring ENotifyAttributes|ENotifyDisk
  3885 	file.Close();
  3886 	fs.NotifyChangeCancel(reqStat4);
  3887 	User::WaitForRequest(reqStat4);
  3888 	test(reqStat4==KErrCancel);
  3889 
  3890 //	RFile::SetModified()
  3891 	fs.NotifyChange(ENotifyAll,reqStat,path);
  3892 	fs.NotifyChange((TNotifyType)(KGenericEntryChange|ENotifyAttributes),reqStat2,path);
  3893 	fs.NotifyChange((TNotifyType)(ENotifyDir|ENotifyFile),reqStat3,path);
  3894 	fs.NotifyChange((TNotifyType)(ENotifyDisk|ENotifyAttributes),reqStat4,path);
  3895 
  3896 	test(reqStat==KRequestPending);
  3897 	test(reqStat2==KRequestPending);
  3898 	test(reqStat3==KRequestPending);
  3899 	test(reqStat4==KRequestPending);
  3900 
  3901 	TTime nowTime;
  3902 	nowTime.HomeTime();
  3903 	r=file.Open(TheFs,_L("\\F32-TST\\NOTIFY\\Munchkin.msg"),EFileRead|EFileWrite);
  3904 	test(r==KErrNone);
  3905 	test(reqStat==KRequestPending);
  3906 	file.SetModified(now);
  3907 	file.Close();
  3908 	User::WaitForRequest(reqStat);
  3909 	User::WaitForRequest(reqStat2);
  3910 	User::WaitForRequest(reqStat4);
  3911 	test(reqStat==KErrNone);
  3912 	test(reqStat2==KErrNone);
  3913 	test(reqStat3==KRequestPending);
  3914 	test(reqStat4==KErrNone);
  3915 	fs.NotifyChangeCancel();
  3916 	User::WaitForRequest(reqStat3);
  3917 	test(reqStat3==KErrCancel);
  3918 
  3919 //	RFile::Write()
  3920 	fs.NotifyChange(ENotifyAll,reqStat,path);
  3921 	fs.NotifyChange((TNotifyType)(KGenericEntryChange|ENotifyAttributes),reqStat2,path);
  3922 	fs.NotifyChange((TNotifyType)(ENotifyFile|ENotifyWrite),reqStat3,path);
  3923 	fs.NotifyChange((TNotifyType)(ENotifyDir|ENotifyWrite),reqStat4,path);
  3924 
  3925 	test(reqStat==KRequestPending);
  3926 	test(reqStat2==KRequestPending);
  3927 	test(reqStat3==KRequestPending);
  3928 	test(reqStat4==KRequestPending);
  3929 
  3930 	r=file.Open(TheFs,_L("\\F32-TST\\NOTIFY\\Munchkin.msg"),EFileRead|EFileWrite);
  3931 	test(r==KErrNone);
  3932 	r=file.Write(0,_L8("Pay no attention to the man behind the curtain"));
  3933 	file.Close();
  3934 	User::WaitForRequest(reqStat);
  3935 	User::WaitForRequest(reqStat3);
  3936 	User::WaitForRequest(reqStat4);
  3937 	test(reqStat==KErrNone);
  3938 	test(reqStat2==KRequestPending);
  3939 	test(reqStat3==KErrNone);
  3940 	test(reqStat4==KErrNone);
  3941 	fs.NotifyChangeCancel(reqStat2);	//	Cancels all outstanding notification requests
  3942 	User::WaitForRequest(reqStat2);
  3943 	test(reqStat2==KErrCancel);
  3944 
  3945 //	RFs::Delete()
  3946 	test.Next(_L("RFs::Delete()"));
  3947 	fs.NotifyChange(ENotifyAll,reqStat,path);
  3948 	fs.NotifyChange((TNotifyType)(KGenericEntryChange|ENotifyAttributes),reqStat2,path);
  3949 	fs.NotifyChange((TNotifyType)(ENotifyFile|ENotifyWrite),reqStat3,path);
  3950 	fs.NotifyChange((TNotifyType)(ENotifyDir|ENotifyWrite),reqStat4,path);
  3951 
  3952 	test(reqStat==KRequestPending);
  3953 	test(reqStat2==KRequestPending);
  3954 	test(reqStat3==KRequestPending);
  3955 	test(reqStat4==KRequestPending);
  3956 
  3957 	r=TheFs.Delete(_L("\\F32-TST\\NOTIFY\\Munchkin.msg"));
  3958 	test(r==KErrNone);
  3959 	User::WaitForRequest(reqStat);
  3960 	User::WaitForRequest(reqStat2);
  3961 	User::WaitForRequest(reqStat3);
  3962 	test(reqStat==KErrNone);
  3963 	test(reqStat2==KErrNone);
  3964 	test(reqStat3==KErrNone);
  3965 	test(reqStat4==KRequestPending);
  3966 	fs.NotifyChangeCancel(reqStat4);
  3967 	User::WaitForRequest(reqStat4);
  3968 	test(reqStat4==KErrCancel);
  3969 
  3970 	fs.Close();
  3971 	}
  3972 
  3973 #if defined __EPOC32__ && defined __INCLUDE_MANUAL_TESTS__
  3974 // Manual media change test
  3975 // assumes the media is intially present and then prompts
  3976 // the user to remove the media
  3977 static void Test99()
  3978 	{
  3979 	TBuf<64> b;
  3980 	b.Format(_L("Test Manual Media change notification (socket:%d)"),gSocketNumber);
  3981 	test.Next(b);
  3982 	TRequestStatus reqStat=0;
  3983 
  3984 	RFs fs;
  3985 	TInt r=fs.Connect();
  3986 	test(r==KErrNone);
  3987 
  3988 	TDriveInfo driveInfo;
  3989 	TInt driveNum = EDriveC + SocketToDrive[gSocketNumber];
  3990 
  3991 	// verify TDriveInfo.iType == EMediaHardDisk
  3992 	r = fs.Drive(driveInfo, driveNum);
  3993 	test (r == KErrNone);
  3994 	test.Printf(_L("iType = %d\n"), driveInfo.iType);
  3995 	test(driveInfo.iType == EMediaHardDisk);
  3996 
  3997 
  3998 	// ask the user to eject the media
  3999 	TheFs.NotifyChange(ENotifyEntry,reqStat);
  4000 	test(reqStat==KRequestPending);
  4001 	test.Printf(_L("Please eject media on drive %C...\n"), 'A' + driveNum);
  4002 	User::WaitForRequest(reqStat);
  4003 	test.Printf(_L("Done.\n"));
  4004 	TInt reqInt=reqStat.Int();
  4005 	test(reqInt==KErrNone);
  4006 	User::WaitForRequest(reqStat);
  4007 
  4008 	// verify TDriveInfo.iType == EMediaNotPresent
  4009 	r = fs.Drive(driveInfo, driveNum);
  4010 	test (r == KErrNone);
  4011 	test.Printf(_L("iType = %d\n"), driveInfo.iType);
  4012 	test(driveInfo.iType == EMediaNotPresent);
  4013 
  4014 
  4015 	// ask the user to re-insert the media
  4016 	TheFs.NotifyChange(ENotifyEntry,reqStat);
  4017 	test(reqStat==KRequestPending);
  4018 	test.Printf(_L("Please re-insert media...\n"));
  4019 	User::WaitForRequest(reqStat);
  4020 	test.Printf(_L("Done.\n"));
  4021 	reqInt = reqStat.Int();
  4022 	test(reqInt==KErrNone);
  4023 	User::WaitForRequest(reqStat);
  4024 
  4025 	// verify TDriveInfo.iType == EMediaHardDisk
  4026 	r = fs.Drive(driveInfo, driveNum);
  4027 	test (r == KErrNone);
  4028 	test.Printf(_L("iType = %d\n"), driveInfo.iType);
  4029 	test(driveInfo.iType == EMediaHardDisk);
  4030 
  4031 	fs.Close();
  4032 	}
  4033 #endif	// __INCLUDE_MANUAL_TESTS__
  4034 
  4035 
  4036 //---------------------------------------------
  4037 //! @SYMTestCaseID PBASE-T_NOTIFY-0042
  4038 //! @SYMTestType UT
  4039 //! @SYMREQ REQ5664
  4040 //! @SYMTestCaseDesc Test asynchronous RFile API's
  4041 //! @SYMTestActions Test normal asynchronous read, share modes, read cancellation, race conditions
  4042 //! (with RFile::SetSize() and RFile::Write()), multiple asynchronous readers.
  4043 //! @SYMTestExpectedResults Expected behaviour reached.
  4044 //! @SYMTestPriority High
  4045 //! @SYMTestStatus Implemented
  4046 //---------------------------------------------
  4047 static void TestAsyncReader()
  4048 //
  4049 // Test asynchronous read notifications
  4050 //
  4051 	{
  4052 	TRequestStatus readStat1(KRequestPending);
  4053 	TRequestStatus readStat2(KRequestPending);
  4054 	TRequestStatus thrdStat(KRequestPending);
  4055 
  4056 	MakeFile(_L("\\F32-TST\\NOTIFY\\NewFile.Txt"));
  4057 
  4058 	test.Next(_L("Test original behaviour of asynchronous read API"));
  4059 	RFile reader;
  4060 	TInt r=reader.Open(TheFs,_L("\\F32-TST\\NOTIFY\\NewFile.txt"),EFileRead|EFileShareAny);
  4061 	test(r==KErrNone);
  4062 	TBuf8<596> readBuf;
  4063 	reader.Read(0, readBuf, 100, readStat1);
  4064 	User::WaitForRequest(readStat1);
  4065 	test(readStat1==KErrNone);
  4066 	test(readBuf.Length()==0);
  4067 	reader.Close();
  4068 
  4069 	test.Next(_L("Test asynchronous read fails in EFileShareExclusive mode"));
  4070 	r=reader.Open(TheFs,_L("\\F32-TST\\NOTIFY\\NewFile.txt"),EFileRead|EFileReadAsyncAll|EFileShareExclusive);
  4071 	test(r==KErrArgument);
  4072 
  4073 	test.Next(_L("Test asynchronous read fails in EFileShareReadersOnly mode"));
  4074 	r=reader.Open(TheFs,_L("\\F32-TST\\NOTIFY\\NewFile.txt"),EFileRead|EFileReadAsyncAll|EFileShareReadersOnly);
  4075 	test(r==KErrArgument);
  4076 
  4077 	test.Next(_L("Test asynchronous read is cancelled when file is closed"));
  4078 	r=reader.Open(TheFs,_L("\\F32-TST\\NOTIFY\\NewFile.txt"),EFileRead|EFileReadAsyncAll|EFileShareAny);
  4079 	test(r==KErrNone);
  4080 	reader.Read(0, readBuf, 100, readStat1);
  4081 	test(readStat1==KRequestPending);
  4082 	reader.Close();
  4083 	User::WaitForRequest(readStat1);
  4084 	test(readStat1==KErrCancel);
  4085 
  4086 	test.Next(_L("Test asynchronous read can be cancelled"));
  4087 	r=reader.Open(TheFs,_L("\\F32-TST\\NOTIFY\\NewFile.txt"),EFileRead|EFileReadAsyncAll|EFileShareAny);
  4088 	test(r==KErrNone);
  4089 	reader.Read(0, readBuf, 100, readStat1);
  4090 	test(readStat1==KRequestPending);
  4091 	reader.ReadCancel(readStat1);
  4092 	User::WaitForRequest(readStat1);
  4093 	test(readStat1==KErrCancel);
  4094 	reader.Close();
  4095 
  4096 	// DEF105438: File server thread safety issues
  4097 	// Up the priority of this thread so that we can cancel the request before the drive thread
  4098 	// runs (to test whether cancelling still works...)
  4099 	test.Next(_L("Test asynchronous read is cancelled when running at high priority"));
  4100 	r=reader.Open(TheFs,_L("\\F32-TST\\NOTIFY\\NewFile.txt"),EFileRead|EFileReadAsyncAll|EFileShareAny);
  4101 	test(r==KErrNone);
  4102 	RThread	thisThread;
  4103 	thisThread.SetPriority(EPriorityRealTime);
  4104 	reader.Read(0, readBuf, 100, readStat1);
  4105 	test(readStat1==KRequestPending);
  4106 	reader.ReadCancel(readStat1);
  4107 	test.Printf(_L("readStat1 %d"), readStat1.Int());
  4108 	User::WaitForRequest(readStat1);
  4109 	test(readStat1==KErrCancel);
  4110 	reader.Close();
  4111 	thisThread.SetPriority(EPriorityNormal);
  4112 
  4113 	test.Next(_L("Test asynchronous read is notified due to RFile::SetSize()"));
  4114 	r=reader.Open(TheFs,_L("\\F32-TST\\NOTIFY\\NewFile.txt"),EFileRead|EFileReadAsyncAll|EFileWrite|EFileShareAny);
  4115 	test(r==KErrNone);
  4116 	reader.Read(0, readBuf, 100, readStat1);
  4117 	test(readStat1==KRequestPending);
  4118 	r = reader.SetSize(100);
  4119 	test(r==KErrNone);
  4120 	User::WaitForRequest(readStat1);
  4121 	test(readStat1==KErrNone);
  4122 	test(readBuf.Length() == 100);
  4123 	r=reader.SetSize(0);
  4124 	test(r==KErrNone);
  4125 	reader.Close();
  4126 
  4127 	test.Next(_L("Test asynchronous read is notified due to RFile::Write()"));
  4128 	r=reader.Open(TheFs,_L("\\F32-TST\\NOTIFY\\NewFile.txt"),EFileRead|EFileReadAsyncAll|EFileWrite|EFileShareAny);
  4129 	test(r==KErrNone);
  4130 	reader.Read(0, readBuf, 26, readStat1);
  4131 	test(readStat1==KRequestPending);
  4132 	RFile writer;
  4133 	r=writer.Open(TheFs,_L("\\F32-TST\\NOTIFY\\NewFile.txt"),EFileWrite|EFileShareAny);
  4134 	writer.Write(_L8("ABCDEFGHIJKLMNOPQRSTUVWXYZ"));
  4135 	User::WaitForRequest(readStat1);
  4136 	test(readStat1==KErrNone);
  4137 	test(readBuf.Length() == 26);
  4138 	reader.Close();
  4139 	writer.Close();
  4140 
  4141 	test.Next(_L("Test multiple asynchronous readers notified from separate thread"));
  4142 	r=reader.Open(TheFs,_L("\\F32-TST\\NOTIFY\\NewFile.txt"),EFileRead|EFileReadAsyncAll|EFileWrite|EFileShareAny);
  4143 	test(r==KErrNone);
  4144 	r=reader.SetSize(0);
  4145 	test(r==KErrNone);
  4146 	const TInt KReadLen = 26;
  4147 	test.Printf(_L(">Read%d[%d]\n"), 0, KReadLen);
  4148 	reader.Read(0, readBuf, KReadLen, readStat1);
  4149 	TBuf8<596> readBuf2;
  4150 	test.Printf(_L(">Read%d[%d]\n"), 1, KReadLen);
  4151 	reader.Read(KReadLen, readBuf2, KReadLen, readStat2);
  4152 	test(readStat1==KRequestPending);
  4153 	test(readStat2==KRequestPending);
  4154 
  4155 	RThread thread;
  4156 	r=thread.Create(_L("MyThread"),ThreadEntryPoint,KDefaultStackSize,KHeapSize,KHeapSize,(TAny*)ETest12);
  4157 	test(r==KErrNone);
  4158 	thread.Logon(thrdStat);
  4159 	thread.Resume();
  4160 	thread.Close();
  4161 
  4162 	RTimer timer;
  4163 	TRequestStatus timerStat(KRequestPending);
  4164 	timer.CreateLocal();
  4165 	timer.After(timerStat, 30000000);	// 30 seconds timeout (the following async test should take 10 seconds)
  4166 	test(timerStat==KRequestPending);
  4167 
  4168 	#define ODDPASS  (pass&0x01)
  4169 	#define REQSTAT  (ODDPASS ? readStat2 : readStat1)
  4170 	#define PENDSTAT (ODDPASS ? readStat1 : readStat2)
  4171 	#define COMPLEN  (ODDPASS ? KReadLen  : (pass+1)*KReadLen)
  4172 	#define READLEN  (ODDPASS ? KReadLen  : (pass+3)*KReadLen)
  4173 	#define READPOS  (ODDPASS ? (pass+2)*KReadLen : 0)
  4174 	#define READBUF  (ODDPASS ? readBuf2 : readBuf)
  4175 
  4176 	TInt pass = 0;
  4177 	FOREVER
  4178 		{
  4179         User::WaitForRequest(REQSTAT, timerStat);
  4180 		test(REQSTAT==KErrNone);
  4181 		test(timerStat==KRequestPending);
  4182 		test(READBUF.Length() == COMPLEN);
  4183 		test(READBUF.Right(KReadLen) == _L8("ABCDEFGHIJKLMNOPQRSTUVWXYZ"));
  4184 		test.Printf(_L(">Read%d[%d]\n"), pass&0x01, READLEN);
  4185 		reader.Read(READPOS, READBUF, READLEN, REQSTAT);
  4186 		test(REQSTAT==KRequestPending);
  4187 		if(++pass==10)
  4188 			break;
  4189 		}
  4190 
  4191 	test.Next(_L("Close reader and test multiple outstanding requests are cancelled"));
  4192 	timer.Close();
  4193 	User::WaitForRequest(timerStat);
  4194 	reader.Close();
  4195 	User::WaitForRequest(readStat1);
  4196 	test(readStat1==KErrCancel);
  4197 	User::WaitForRequest(readStat2);
  4198 	test(readStat2==KErrCancel);
  4199 
  4200 	User::WaitForRequest(thrdStat);
  4201 	test(thrdStat==KErrNone);
  4202 	}
  4203 
  4204 
  4205 //-----------------------------------------------------------------------
  4206 
  4207 /**
  4208     Testing that TheFs.NotifyChange() works for the root directory of the drive
  4209 */
  4210 void TestRootDirNotifyChange()
  4211 {
  4212     test.Next(_L("Testing RFs::NotifyChange() on drive's root directory."));
  4213 
  4214     TInt nRes;
  4215     TRequestStatus reqStatNotify1(KRequestPending);
  4216 
  4217     _LIT(KTestPath, "\\"); //-- root dir, actually
  4218 
  4219     //-- set up notifier
  4220     TheFs.NotifyChange(ENotifyAll, reqStatNotify1, KTestPath);
  4221     test(reqStatNotify1.Int() == KRequestPending);
  4222 
  4223     //-- create a file in the root dir
  4224     RFile       file;
  4225     TFileName   fileName(KTestPath);
  4226 
  4227     fileName.Append(_L("TestFile.tst"));
  4228 
  4229     nRes=file.Replace(TheFs, fileName, EFileWrite|EFileRead);
  4230     test(nRes == KErrNone || nRes ==KErrAlreadyExists);
  4231     file.Close();
  4232 
  4233     //-- check that the notifier worked
  4234     User::WaitForRequest(reqStatNotify1);
  4235     test(reqStatNotify1.Int() == KErrNone);
  4236 
  4237 }
  4238 
  4239 
  4240 
  4241 //-----------------------------------------------------------------------
  4242 
  4243 //
  4244 // Do all tests
  4245 //
  4246 GLDEF_C void CallTestsL()
  4247 	{
  4248 
  4249 	CreateTestDirectory(_L("\\F32-TST\\NOTIFY\\"));
  4250 
  4251 //	Test RFs::NotifyChange()
  4252 	CHECK_NO_PENDING_REQUESTS;
  4253 	Test1();
  4254 	CHECK_NO_PENDING_REQUESTS;
  4255 	Test2();
  4256 	CHECK_NO_PENDING_REQUESTS;
  4257 	Test3();
  4258 	CHECK_NO_PENDING_REQUESTS;
  4259 	Test4();
  4260 	CHECK_NO_PENDING_REQUESTS;
  4261 	Test5();
  4262 	CHECK_NO_PENDING_REQUESTS;
  4263 
  4264 #if defined (__EPOC32__)//we have no removable media on Emulator yet	.. ??? we do now
  4265 #if defined __INCLUDE_MANUAL_TESTS__
  4266 
  4267 	// Media change notification on every socket supported
  4268 	TInt i;
  4269 	for (i=0; i<KMaxPBusSockets; i++)
  4270 		SocketToDrive[i]=-1;
  4271 	TDriveInfoV1Buf dinfo;
  4272 	UserHal::DriveInfo(dinfo);
  4273 	TDriveInfoV1 &di=dinfo();
  4274 	TInt driveCount=dinfo().iTotalSupportedDrives;
  4275 	TInt socketCount=dinfo().iTotalSockets;
  4276 	TInt drv;
  4277 	test.Printf(_L("Socket count: %d\n"), socketCount);
  4278 	TUint32 mask=~(0xffffffffu<<socketCount);
  4279 
  4280 	for (drv=0; drv<driveCount; drv++)
  4281 		{
  4282 		TBool flag=EFalse;
  4283 		RLocalDrive d;
  4284 		TInt r=d.Connect(drv,flag);
  4285 
  4286 		//Not all the drives are used at present
  4287 		if (r == KErrNotSupported)
  4288 			continue;
  4289 
  4290 		test(r==KErrNone);
  4291 		TInt sockNum = 0;
  4292 		if (d.IsRemovable(sockNum)>0)
  4293 			{
  4294 			if (mask & (1<<sockNum))
  4295 				{
  4296 				SocketToDrive[sockNum]=drv;
  4297 				mask &= ~(1<<sockNum);
  4298 				}
  4299 			}
  4300 		d.Close();
  4301 		}
  4302 
  4303 
  4304 	// Manual media change test
  4305 	for (gSocketNumber=socketCount-1; gSocketNumber>=0; gSocketNumber--)
  4306 		{
  4307 		if (SocketToDrive[gSocketNumber] != -1)
  4308 			{
  4309 			test.Printf(_L("Testing socket %u, drive %u...\n"),
  4310 				gSocketNumber, SocketToDrive[gSocketNumber]);
  4311 			Test99();
  4312 			}
  4313 		}
  4314 #endif
  4315     Test6();
  4316 #endif
  4317 	CHECK_NO_PENDING_REQUESTS;
  4318 	Test7();
  4319 	CHECK_NO_PENDING_REQUESTS;
  4320 
  4321 
  4322 #if defined (__EPOC32__)//we have no removable media on Emulator yet
  4323 
  4324 //	Test RFs::NotifyChange() extended notification
  4325 	TInt uid;
  4326 	test(HAL::Get(HAL::EMachineUid,uid)==KErrNone);
  4327 	if(uid!=HAL::EMachineUid_Cogent && uid!=HAL::EMachineUid_IQ80310 &&
  4328 				uid != HAL::EMachineUid_Integrator && uid!=HAL::EMachineUid_X86PC)
  4329 		MediaChangeExtendedNotification();
  4330 
  4331 #endif
  4332 
  4333 	CHECK_NO_PENDING_REQUESTS;
  4334 	TestRequestAhead();
  4335 	CHECK_NO_PENDING_REQUESTS;
  4336 	Test8();
  4337 	CHECK_NO_PENDING_REQUESTS;
  4338 	Test9();
  4339 	CHECK_NO_PENDING_REQUESTS;
  4340 	Test10();
  4341 	CHECK_NO_PENDING_REQUESTS;
  4342 	Test11();
  4343 	CHECK_NO_PENDING_REQUESTS;
  4344 	Test12();
  4345 	CHECK_NO_PENDING_REQUESTS;
  4346 	Test13();
  4347 	CHECK_NO_PENDING_REQUESTS;
  4348 	Test14();
  4349 	CHECK_NO_PENDING_REQUESTS;
  4350 	Test15();
  4351 	CHECK_NO_PENDING_REQUESTS;
  4352 	Test16();
  4353 	CHECK_NO_PENDING_REQUESTS;
  4354 	Test17();
  4355 	CHECK_NO_PENDING_REQUESTS;
  4356 	Test18();
  4357 	CHECK_NO_PENDING_REQUESTS;
  4358 	TestAsyncReader();
  4359 	CHECK_NO_PENDING_REQUESTS;
  4360 	DeleteTestDirectory();
  4361 	CHECK_NO_PENDING_REQUESTS;
  4362     TestRootDirNotifyChange();
  4363 	CHECK_NO_PENDING_REQUESTS;
  4364 	}