Update contrib.
1 // Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of the License "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // f32test\server\t_notify.cpp
24 const TInt KHeapSize=0x200;
26 // wait for a bit since NotifyChange handled asynchronously and SetDriveName synchronously
27 const TInt KNotifyChangeAfter=100000;
28 const TInt KMediaRemountForceMediaChange = 0x00000001;
30 RTest test(_L("T_NOTIFY"));
31 RSemaphore gSleepThread;
33 TInt SocketToDrive[KMaxPBusSockets];
35 //#define __INCLUDE_MANUAL_TESTS__
37 void do_check_no_pending_requests(TInt aLine)
40 TRequestStatus timerStat;
42 timer.After(timerStat, 125000);
43 User::WaitForAnyRequest();
44 if(timerStat==KRequestPending)
46 RDebug::Printf("do_check_no_pending_requests failed at line %d",aLine);
51 #define CHECK_NO_PENDING_REQUESTS do_check_no_pending_requests(__LINE__);
54 TBool CheckDriveRead(TInt aDrive)
55 //Determines if can connect to local drive number and read
58 TBool TBLDChangedFlag;
60 TInt r = TBLD.Connect(aDrive, TBLDChangedFlag);
61 test.Printf(_L("Connect returned %d\n"), r);
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);
78 void GenerateMediaChange()
84 TInt r = fs.Connect();
87 r = fs.RemountDrive(CurrentDrive(), &pckg, (TUint)KMediaRemountForceMediaChange);
98 me.Panic(_L("GenMedChg"),r);
102 enum TTestCode {ETest1,ETest2,ETest3,ETest4,ETest5,ETest6,ETest7,ETest8,ETest9,ETest10,ETest11,ETest12};
103 const TUint KGenericEntryChange=0x02;
105 static TInt ThreadEntryPoint(TAny* aTestCode)
107 // Thread entry point
113 r=fs.SetSessionPath(gSessionPath);
115 TTestCode testCode=*(TTestCode*)&aTestCode;
121 r=f.Replace(fs,_L("\\F32-TST\\NOTIFY\\NewFile.txt"),EFileStream);
127 r=f.Replace(fs,_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Dorothy.doc"),EFileStream);
133 r=fs.MkDir(_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\SCARECROW\\"));
134 test((r==KErrNone)||(r==KErrAlreadyExists));
140 fs.NotifyChange(ENotifyAll,s);
141 test(s==KRequestPending);
142 gSleepThread.Signal();
143 User::After(100000000);
150 TInt r=file.Open(fs,_L("\\F32-TST\\NOTIFY\\kangaroo.txt"),EFileRead|EFileWrite);
152 r=file.SetSize(sizeof(TCheckedUid));
154 r=file.Write(sizeof(TCheckedUid),_L8("012345678912"));
161 r=file.Open(fs,_L("\\F32-TST\\NOTIFY\\koala.txt"),EFileRead|EFileWrite);
165 r=file.Write(sizeof(TCheckedUid),_L8("ABCDEFGHIJKLMNOPQRSTUVWXYZ"));
171 r=file.Open(fs,_L("\\F32-TST\\NOTIFY\\dingo.txt"),EFileRead|EFileWrite);
175 r=file.Write(sizeof(TCheckedUid),_L8("01234567890123456789"));
180 gSleepThread.Signal();
186 GenerateMediaChange();
187 User::After(300000); // Wait for a bit
188 gSleepThread.Signal();
195 TInt r=file.Open(fs,_L("\\F32-TST\\NOTIFY\\NewFILE.TXT"),EFileRead|EFileWrite);
197 r=file.Write(_L8("asdfasdfasdf"));
200 gSleepThread.Signal();
206 r=f.Open(fs,_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\WickedWitch.msg"),EFileRead|EFileWrite);
216 TFileName path=_L("\\F32-TST\\NOTIFY\\");
217 fs.NotifyChange(ENotifyAll,s,path);
218 test(s==KRequestPending);
219 gSleepThread.Signal();
220 User::After(100000000);
225 TFileName path=_L("\\F32-TST\\NOTIFY\\BehindTheCurtain\\");
232 TFileName path=_L("\\F32-TST\\NOTIFY\\BehindTheCurtain\\PayNoAttention.man");
234 r=file.Replace(fs,path,EFileStream);
242 TInt r=writer.Open(fs,_L("\\F32-TST\\NOTIFY\\NewFile.txt"),EFileWrite|EFileShareAny);
247 r=writer.Write(_L8("ABCDEFGHIJKLMNOPQRSTUVWXYZ"));
249 User::After(1000000);
260 #if defined (__EPOC32__)//we have no removable media on Emulator yet
261 static void WaitForMediaChange()
263 // Wait for media driver to register drive is present
271 TInt r=TheFs.Entry(_L("xxxxxxxx"),entry);
280 // Test notification of an entry change
284 test.Next(_L("Test notification of an entry change"));
285 TRequestStatus reqStat(KRequestPending);
286 TRequestStatus thrdStat(KRequestPending);
288 TheFs.NotifyChange(ENotifyEntry,reqStat);
290 r=thread.Create(_L("MyThread"),ThreadEntryPoint,KDefaultStackSize,KHeapSize,KHeapSize,(TAny*)ETest1);
292 thread.Logon(thrdStat);
294 User::WaitForRequest(thrdStat);
295 test(thrdStat==KErrNone);
297 User::WaitForRequest(reqStat);
298 test(reqStat==KErrNone);
301 r=file.Open(TheFs,_L("\\F32-TST\\NOTIFY\\NewFile.txt"),EFileRead|EFileWrite|EFileShareExclusive);
303 file.Write(_L8("Somewhere over the rainbow..."),reqStat);
304 User::WaitForRequest(reqStat);
305 test(reqStat==KErrNone);
307 file.Read(0, buf,reqStat);
308 User::WaitForRequest(reqStat);
309 test(reqStat==KErrNone);
312 r=file.Open(TheFs,_L("\\F32-TST\\NOTIFY\\NewFile.txt"),EFileRead|EFileReadAsyncAll|EFileShareExclusive);
313 test(r==KErrArgument);
315 r=file.Open(TheFs,_L("\\F32-TST\\NOTIFY\\NewFile.txt"),EFileRead|EFileReadAsyncAll|EFileShareReadersOnly);
316 test(r==KErrArgument);
318 r=file.Open(TheFs,_L("\\F32-TST\\NOTIFY\\NewFile.txt"),EFileRead|EFileReadAsyncAll|EFileShareAny);
320 file.Read(0, buf, 100, reqStat);
321 test(reqStat==KRequestPending);
323 User::WaitForRequest(reqStat);
324 test(reqStat==KErrCancel);
326 r=file.Open(TheFs,_L("\\F32-TST\\NOTIFY\\NewFile.txt"),EFileRead|EFileReadAsyncAll|EFileShareAny);
328 file.Read(0, buf, 100, reqStat);
329 test(reqStat==KRequestPending);
330 file.ReadCancel(reqStat);
331 User::WaitForRequest(reqStat);
332 test(reqStat==KErrCancel);
335 r=file.Open(TheFs,_L("\\F32-TST\\NOTIFY\\NewFile.txt"),EFileRead|EFileReadAsyncAll|EFileWrite|EFileShareAny);
337 file.Read(0, buf, 100, reqStat);
338 test(reqStat==KRequestPending);
340 User::WaitForRequest(reqStat);
341 test(reqStat==KErrNone);
342 test(buf.Length() == 100);
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);
350 User::WaitForRequest(thrdStat);
351 test(thrdStat==KErrNone);
353 User::WaitForRequest(reqStat);
354 if (reqStat!=KErrNone)
356 test.Printf(_L("ReqStat=%d\n"),reqStat.Int());
359 test(reqStat==KErrNone);
361 test.Next(_L("Test Notify cancel"));
362 TheFs.NotifyChange(ENotifyEntry,reqStat);
363 TheFs.NotifyChangeCancel();
364 User::WaitForRequest(reqStat);
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);
371 User::WaitForRequest(thrdStat);
372 test(thrdStat==KErrNone);
374 User::WaitForRequest(reqStat);
375 test(reqStat==KErrNone);
380 // Test notify for multiple clients
384 test.Next(_L("Test notification of multiple clients"));
386 TRequestStatus reqStat1(KRequestPending);
388 TInt r=fs1.Connect();
390 fs1.NotifyChange(ENotifyEntry,reqStat1);
392 TRequestStatus reqStat2(KRequestPending);
396 fs2.NotifyChange(ENotifyEntry,reqStat2);
398 test(reqStat1==KRequestPending);
399 test(reqStat2==KRequestPending);
400 r=TheFs.Delete(_L("\\F32-TST\\NOTIFY\\NEWFILE.TXT"));
402 User::WaitForRequest(reqStat1);
403 User::WaitForRequest(reqStat2);
404 test(reqStat1==KErrNone);
405 test(reqStat2==KErrNone);
410 // Test notify cancel
414 test.Next(_L("Cancel notification"));
416 TInt r=fs1.Connect();
419 TRequestStatus status1;
420 TRequestStatus status2;
421 TRequestStatus status3;
422 TRequestStatus status4;
423 TRequestStatus status5;
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);
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();
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);
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);
475 fs1.NotifyChangeCancel(status2);
476 User::WaitForRequest(status2);
478 test(status1==KRequestPending);
479 test(status2==KErrCancel);
480 test(status3==KRequestPending);
481 test(status4==KRequestPending);
483 fs1.NotifyChangeCancel(status4);
484 User::WaitForRequest(status4);
485 test(status1==KRequestPending);
486 test(status3==KRequestPending);
487 test(status4==KErrCancel);
489 fs1.NotifyChangeCancel(status4); // Test no side effects on trying to cancel a request
490 test(status4==KErrCancel); // that has already been cancelled
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
499 fs1.NotifyChangeCancel(status3);
500 User::WaitForRequest(status3);
501 test(status3==KErrCancel);
508 // Test notify client death
512 test.Next(_L("Kill client"));
513 TInt r=gSleepThread.CreateLocal(0);
515 RThread clientThread;
516 r=clientThread.Create(_L("ClientThread"),ThreadEntryPoint,0x4000,KHeapSize,KHeapSize,(TAny*)ETest4);
519 test.Printf(_L(" ERROR: Failed to create clientthread %d\n"),r);
524 clientThread.Resume();
527 TBool jit = User::JustInTime();
528 User::SetJustInTime(EFalse);
529 clientThread.Panic(_L("Test client thread panic"),KErrGeneral);
530 User::SetJustInTime(jit);
532 clientThread.Close();
534 r=TheFs.MkDir(_L("\\F32-TST\\NOTIFY\\"));
535 test(r==KErrNone || r==KErrAlreadyExists);
536 MakeFile(_L("\\F32-TST\\NOTIFY\\NewFile.Txt"));
542 // Test reads and writes do not cause notification
546 test.Next(_L("Test reads and writes do not cause notification"));
550 TInt r=file.Replace(TheFs,_L("\\F32-TST\\NOTIFY\\kangaroo.txt"),EFileRead|EFileWrite);
553 r=file.Replace(TheFs,_L("\\F32-TST\\NOTIFY\\koala.txt"),EFileRead|EFileWrite);
556 r=file.Replace(TheFs,_L("\\F32-TST\\NOTIFY\\dingo.txt"),EFileRead|EFileWrite);
560 TRequestStatus reqStat=0;
561 TheFs.NotifyChange(ENotifyEntry,reqStat);
562 test(reqStat==KRequestPending);
564 r=gSleepThread.CreateLocal(0);
566 RThread clientThread;
567 r=clientThread.Create(_L("Test5Thread"),ThreadEntryPoint,0x4000,KHeapSize,KHeapSize,(TAny*)ETest5);
569 clientThread.Resume();
571 test(reqStat==KRequestPending);
573 r=TheFs.Delete(_L("\\F32-TST\\NOTIFY\\kangaroo.txt"));
575 User::WaitForRequest(reqStat);
576 test(reqStat==KErrNone);
578 r=TheFs.Delete(_L("\\F32-TST\\NOTIFY\\koala.txt"));
580 r=TheFs.Delete(_L("\\F32-TST\\NOTIFY\\dingo.txt"));
585 gSleepThread.Close();
586 clientThread.Close();
589 #if defined (__EPOC32__)//we have no removable media on Emulator yet .. ??? we do now
592 // Test media change notification
595 TDriveInfo driveInfo;
596 TInt r=TheFs.Drive(driveInfo,CurrentDrive());
598 // only test on removable media
599 if (driveInfo.iDriveAtt&KDriveAttRemovable)
602 b.Format(_L("Test Media change notification (socket:%d)"),gSocketNumber);
604 TRequestStatus reqStat=0;
606 TheFs.NotifyChange(ENotifyEntry,reqStat);
607 test(reqStat==KRequestPending);
608 r=gSleepThread.CreateLocal(0);
610 RThread clientThread;
611 r=clientThread.Create(_L("Test6Thread"),ThreadEntryPoint,0x4000,KHeapSize,KHeapSize,(TAny*)ETest6);
613 clientThread.Resume();
615 TInt reqInt=reqStat.Int();
616 test(reqInt==KErrNone);
617 User::WaitForRequest(reqStat);
618 WaitForMediaChange();
619 gSleepThread.Close();
620 clientThread.Close();
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());
634 // Test Write to uid region does not trigger notification
638 test.Next(_L("Test Write to uid region does not trigger notification"));
639 TRequestStatus reqStat=0;
640 MakeFile(_L("NewFile.TXT"));
642 TheFs.NotifyChange(ENotifyEntry,reqStat);
643 test(reqStat==KRequestPending);
645 r=gSleepThread.CreateLocal(0);
647 RThread clientThread;
648 r=clientThread.Create(_L("Test7Thread"),ThreadEntryPoint,0x4000,KHeapSize,KHeapSize,(TAny*)ETest7);
650 clientThread.Resume();
652 test(reqStat==KRequestPending);
654 r=TheFs.Delete(_L("Newfile.txt"));
657 User::WaitForRequest(reqStat);
659 gSleepThread.Close();
660 clientThread.Close();
663 #if defined (__EPOC32__)//we have no removable media on Emulator yet
664 static void MediaChangeExtendedNotification()
666 // Test media change notification
667 // Always notified of media change - regardless of requested TNotifyType
670 TDriveInfo driveInfo;
671 TInt r=TheFs.Drive(driveInfo,CurrentDrive());
673 // only test on removable media
674 if (driveInfo.iDriveAtt&KDriveAttRemovable)
676 test.Next(_L("Test Media change extended notification"));
677 TRequestStatus reqStat=0;
678 TFileName path = _L("\\F32-tst\\NOTIFY\\");
680 TheFs.NotifyChange(ENotifyEntry,reqStat,path);
681 test(reqStat==KRequestPending);
682 r=gSleepThread.CreateLocal(0);
684 RThread clientThread;
686 r=clientThread.Create(_L("Test6Thread1"),ThreadEntryPoint,0x4000,KHeapSize,KHeapSize,(TAny*)ETest6); //only generates a media change on removable media
688 clientThread.Resume();
690 User::WaitForRequest(reqStat);
691 test(reqStat==KErrNone);
692 WaitForMediaChange();
693 gSleepThread.Close();
694 clientThread.Close();
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());
702 TheFs.NotifyChange(ENotifyDisk,reqStat,path);
703 test(reqStat==KRequestPending);
704 r=gSleepThread.CreateLocal(0);
706 r=clientThread.Create(_L("Test6Thread2"),ThreadEntryPoint,0x4000,KHeapSize,KHeapSize,(TAny*)ETest6);
708 clientThread.Resume();
710 User::WaitForRequest(reqStat);
711 test(reqStat==KErrNone);
712 WaitForMediaChange();
713 gSleepThread.Close();
714 clientThread.Close();
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());
721 TheFs.NotifyChange(ENotifyWrite,reqStat,path);
722 test(reqStat==KRequestPending);
723 r=gSleepThread.CreateLocal(0);
725 r=clientThread.Create(_L("Test6Thread3"),ThreadEntryPoint,0x4000,KHeapSize,KHeapSize,(TAny*)ETest6);
727 clientThread.Resume();
729 User::WaitForRequest(reqStat);
730 test(reqStat==KErrNone);
731 WaitForMediaChange();
732 gSleepThread.Close();
733 clientThread.Close();
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());
744 static void TestRequestAhead()
746 // Test extended notification works when path initially does not exist
749 test.Next(_L("Test Request Ahead"));
750 // First a simple example
752 TInt r=TheFs.RmDir(_L("\\F32-TST\\NOTIFY\\BehindTheCurtain\\"));
753 test((r==KErrNotFound)||(r==KErrPathNotFound)||(r==KErrNone));
755 TFileName path=_L("\\F32-TST\\NOTIFY\\BehindTheCurtain\\");
756 TRequestStatus reqStat(KRequestPending);
757 TheFs.NotifyChange(ENotifyEntry,reqStat,path);
758 test(reqStat==KRequestPending);
760 r=TheFs.MkDir(_L("\\F32-TST\\NOTIFY\\BehindTheCurtain\\"));
763 User::WaitForRequest(reqStat);
764 test(reqStat==KErrNone);
766 path=_L("\\F32-TST\\NOTIFY\\BehindTheCurtain\\PayNoAttention.man");
767 TheFs.NotifyChange(ENotifyEntry,reqStat,path);
768 test(reqStat==KRequestPending);
771 r=file.Replace(TheFs,path,EFileStream);
775 User::WaitForRequest(reqStat);
776 test(reqStat==KErrNone);
778 r=TheFs.Delete(path);
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);
788 // Repeat with a ENotifyFile request
789 TheFs.NotifyChange(ENotifyFile,reqStat,path);
790 test(reqStat==KRequestPending);
792 r=file.Replace(TheFs,path,EFileStream);
796 User::WaitForRequest(reqStat);
797 test(reqStat==KErrNone);
799 r=TheFs.Delete(path);
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);
809 // Repeat with an ENotifyAttributes request
810 TheFs.NotifyChange(ENotifyAttributes,reqStat,path);
811 test(reqStat==KRequestPending);
813 r=file.Replace(TheFs,path,EFileStream);
817 User::WaitForRequest(reqStat);
818 test(reqStat==KErrNone); // Monitoring attributes but informed anyway
820 r=TheFs.Delete(path);
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);
830 // Repeat with an ENotifyWrite request
831 TheFs.NotifyChange(ENotifyWrite,reqStat,path);
832 test(reqStat==KRequestPending);
834 r=file.Replace(TheFs,path,EFileStream);
838 User::WaitForRequest(reqStat);
839 test(reqStat==KErrNone); // Monitoring file writing but informed anyway
841 r=TheFs.Delete(path);
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);
851 // Repeat with an ENotifyDisk request
852 TheFs.NotifyChange(ENotifyDisk,reqStat,path);
853 test(reqStat==KRequestPending);
855 r=file.Replace(TheFs,path,EFileStream);
859 User::WaitForRequest(reqStat);
860 test(reqStat==KErrNone); // Monitoring disk activity but informed anyway
862 r=TheFs.Delete(path);
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);
872 // Now do much the same with directory monitoring
873 path=_L("\\F32-TST\\NOTIFY\\BehindTheCurtain\\");
876 TheFs.NotifyChange(ENotifyDir,reqStat,path);
877 test(reqStat==KRequestPending);
882 User::WaitForRequest(reqStat);
883 test(reqStat==KErrNone);
888 TheFs.NotifyChange(ENotifyDir,reqStat,path);
890 test(reqStat==KRequestPending);
892 // Now cancel the outstanding request
893 TheFs.NotifyChangeCancel(reqStat);
894 User::WaitForRequest(reqStat);
895 test(reqStat==KErrCancel);
897 TheFs.NotifyChange(ENotifyDir,reqStat,path);
899 test(reqStat==KRequestPending);
901 // Get a separate thread to create the directory
903 thread.Create(_L("RequestAheadyThready"),ThreadEntryPoint,KDefaultStackSize,KHeapSize,KHeapSize,(TAny*)ETest10);
904 TRequestStatus thrdStat(KRequestPending);
905 thread.Logon(thrdStat);
909 User::WaitForRequest(thrdStat);
910 test(thrdStat==KErrNone);
911 User::WaitForRequest(reqStat);
912 test(reqStat==KErrNone);
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);
922 test(reqStat==KRequestPending);
924 thread.Create(_L("RequestAheadThread"),ThreadEntryPoint,KDefaultStackSize,KHeapSize,KHeapSize,(TAny*)ETest10);
925 thread.Logon(thrdStat);
929 User::WaitForRequest(thrdStat);
930 test(thrdStat==KErrNone);
931 test(reqStat==KRequestPending);
933 // Now get a thread to create the file
934 thread.Create(_L("RequestAhead"),ThreadEntryPoint,KDefaultStackSize,KHeapSize,KHeapSize,(TAny*)ETest11);
935 thread.Logon(thrdStat);
937 User::WaitForRequest(thrdStat);
938 test(thrdStat==KErrNone);
941 User::WaitForRequest(reqStat);
942 test(reqStat==KErrNone);
947 TheFs.NotifyChange(ENotifyEntry,reqStat,path);
949 test(reqStat==KRequestPending);
951 // Now cancel the outstanding request
952 TheFs.NotifyChangeCancel(reqStat);
953 User::WaitForRequest(reqStat);
954 test(reqStat==KErrCancel);
956 path=_L("\\F32-TST\\NOTIFY\\BehindTheCurtain\\");
964 // Test extended notification of an entry change
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\\"));
973 TheFs.NotifyChange(ENotifyEntry,reqStat,path);
974 test(reqStat==KRequestPending);
976 TInt r=thread.Create(_L("MyThread"),ThreadEntryPoint,KDefaultStackSize,KHeapSize,KHeapSize,(TAny*)ETest1);
978 thread.Logon(thrdStat);
980 User::WaitForRequest(thrdStat);
981 test(thrdStat==KErrNone);
982 User::WaitForRequest(reqStat);
983 test(reqStat==KErrNone);
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);
992 thread.Logon(thrdStat);
994 User::WaitForRequest(thrdStat);
995 test(thrdStat==KErrNone);
996 User::WaitForRequest(reqStat);
997 test(reqStat==KErrNone);
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);
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);
1014 thread.Logon(thrdStat);
1016 User::WaitForRequest(thrdStat);
1017 test(thrdStat==KErrNone);
1018 User::WaitForRequest(reqStat);
1019 test(reqStat==KErrNone);
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);
1033 thread.Logon(thrdStat);
1035 User::WaitForRequest(thrdStat);
1036 test(thrdStat==KErrNone);
1037 User::After(500000);
1039 test(reqStat==KRequestPending);
1040 TheFs.NotifyChangeCancel();
1041 User::WaitForRequest(reqStat);
1042 test(reqStat==KErrCancel);
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);
1050 thread.Logon(thrdStat);
1052 User::WaitForRequest(thrdStat);
1053 test(thrdStat==KErrNone);
1054 User::WaitForRequest(reqStat);
1055 test(reqStat==KErrNone);
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);
1063 thread.Logon(thrdStat);
1065 User::WaitForRequest(thrdStat);
1066 test(thrdStat==KErrNone);
1067 User::WaitForRequest(reqStat);
1068 test(reqStat==KErrNone);
1071 TheFs.NotifyChange(ENotifyEntry,reqStat,path);
1072 test(reqStat==KRequestPending);
1073 r=TheFs.MkDir(_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\SCARECROW\\TINMAN\\"));
1075 User::WaitForRequest(reqStat);
1076 test(reqStat==KErrNone);
1079 r=TheFs.RmDir(_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\SCARECROW\\TINMAN\\"));
1081 r=TheFs.RmDir(_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\SCARECROW\\"));
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\\");
1090 TheFs.NotifyChange(ENotifyEntry,reqStat,path);
1091 test(reqStat==KRequestPending);
1092 r=thread.Create(_L("MyThread7"),ThreadEntryPoint,KDefaultStackSize,KHeapSize,KHeapSize,(TAny*)ETest1);
1094 thread.Logon(thrdStat);
1096 User::WaitForRequest(thrdStat);
1097 test(thrdStat==KErrNone);
1098 User::After(500000);
1100 test(reqStat==KRequestPending);
1101 TheFs.NotifyChangeCancel();
1102 User::WaitForRequest(reqStat);
1103 test(reqStat==KErrCancel);
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"));
1111 User::WaitForRequest(reqStat);
1112 test(reqStat==KErrNone);
1115 r=file.Replace(TheFs,_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\WickedWitch.msg"),EFileStream);
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);
1126 thread.Logon(thrdStat);
1128 User::WaitForRequest(thrdStat);
1129 test(thrdStat==KErrNone);
1130 User::WaitForRequest(reqStat);
1131 test(reqStat==KErrNone);
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);
1140 User::WaitForRequest(thrdStat);
1141 test(thrdStat==KErrNone);
1142 User::After(500000);
1144 test(reqStat==KRequestPending);
1145 TheFs.NotifyChangeCancel();
1146 User::WaitForRequest(reqStat);
1147 test(reqStat==KErrCancel);
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"));
1155 User::WaitForRequest(reqStat);
1156 test(reqStat==KErrNone);
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);
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"));
1170 User::WaitForRequest(reqStat);
1171 test(reqStat==KErrNone);
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\\"));
1178 User::WaitForRequest(reqStat);
1179 test(reqStat==KErrNone);
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);
1188 // Make sure the notification has now been received
1189 User::WaitForRequest(reqStat);
1190 test(reqStat==KErrNone);
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);
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);
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);
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);
1225 // Test notify for multiple clients
1229 test.Next(_L("Test notification of multiple clients"));
1231 // Create five sessions monitoring various levels of a directory tree
1233 TInt r=TheFs.MkDir(_L("\\F32-TST\\NOTIFY\\ANIMAL\\"));
1234 test((r==KErrNone)||(r==KErrAlreadyExists));
1236 r=file.Replace(TheFs,_L("\\F32-TST\\NOTIFY\\ANIMAL\\cat.txt"),EFileStream);
1239 r=file.Replace(TheFs,_L("\\F32-TST\\NOTIFY\\ANIMAL\\dog.txt"),EFileStream);
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\\");
1250 TRequestStatus reqStat1(KRequestPending);
1254 r=fs1.SetSessionPath(gSessionPath);
1256 fs1.NotifyChange(ENotifyEntry,reqStat1,path1);
1258 TRequestStatus reqStat2(KRequestPending);
1262 r=fs2.SetSessionPath(gSessionPath);
1264 fs2.NotifyChange(ENotifyEntry,reqStat2,path2);
1266 TRequestStatus reqStat3(KRequestPending);
1270 r=fs3.SetSessionPath(gSessionPath);
1272 fs3.NotifyChange(ENotifyEntry,reqStat3,path3);
1274 TRequestStatus reqStat4(KRequestPending);
1278 r=fs4.SetSessionPath(gSessionPath);
1280 fs4.NotifyChange(ENotifyEntry,reqStat4,path4);
1282 TRequestStatus reqStat5(KRequestPending);
1286 r=fs5.SetSessionPath(gSessionPath);
1288 fs5.NotifyChange(ENotifyEntry,reqStat5,path5);
1290 TRequestStatus reqStat6(KRequestPending);
1294 r=fs6.SetSessionPath(gSessionPath);
1296 fs6.NotifyChange(ENotifyEntry,reqStat6,path6);
1298 test(reqStat1==KRequestPending);
1299 test(reqStat2==KRequestPending);
1300 test(reqStat3==KRequestPending);
1301 test(reqStat4==KRequestPending);
1302 test(reqStat5==KRequestPending);
1303 test(reqStat6==KRequestPending);
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);
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);
1320 r=TheFs.Delete(_L("\\F32-TST\\NewFile.txt"));
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);
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);
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);
1344 r=TheFs.Delete(_L("\\F32-TST\\NOTIFY\\NewFile.txt"));
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);
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);
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);
1372 r=TheFs.Delete(_L("\\F32-TST\\NOTIFY\\ANIMAL\\NewFile.txt"));
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);
1386 test.Next(_L("Test clients monitoring levels 1 - 4 are notified"));
1387 r=TheFs.Delete(_L("\\F32-TST\\NOTIFY\\ANIMAL\\cat.txt"));
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);
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)
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);
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"));
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);
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).
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);
1452 r=TheFs.RmDir(_L("\\F32-TST\\NOTIFY\\ANIMAL\\"));
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);
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.
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);
1475 test(reqStat1==KRequestPending);
1476 test(reqStat2==KRequestPending);
1477 test(reqStat3==KRequestPending);
1478 test(reqStat4==KRequestPending);
1479 test(reqStat5==KRequestPending);
1480 test(reqStat6==KRequestPending);
1482 fs1.NotifyChangeCancel();
1483 fs2.NotifyChangeCancel();
1487 // Close the other sessions with requests outstanding to test that there's no evilness
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);
1502 static void Test10()
1504 // Test notify cancel
1508 test.Next(_L("Cancel notification request using simple function"));
1509 TFileName path=_L("\\F32-TST\\NOTIFY\\");
1511 TInt r=fs1.Connect();
1513 r=fs1.SetSessionPath(gSessionPath);
1516 TRequestStatus status1;
1517 TRequestStatus status2;
1518 TRequestStatus status3;
1519 TRequestStatus status4;
1520 TRequestStatus status5;
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);
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();
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);
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);
1572 r=TheFs.MkDir(_L("\\F32-TST\\TROPICANA\\"));
1574 test(status1==KRequestPending);
1575 test(status2==KRequestPending);
1576 test(status3==KRequestPending);
1577 test(status4==KRequestPending);
1579 fs1.NotifyChangeCancel(status2);
1580 User::WaitForRequest(status2);
1582 test(status1==KRequestPending);
1583 test(status2==KErrCancel);
1584 test(status3==KRequestPending);
1585 test(status4==KRequestPending);
1587 r=TheFs.RmDir(_L("\\F32-TST\\TROPICANA\\"));
1589 test(status1==KRequestPending);
1590 test(status3==KRequestPending);
1591 test(status4==KRequestPending);
1593 fs1.NotifyChangeCancel(status4);
1594 User::WaitForRequest(status4);
1595 test(status1==KRequestPending);
1596 test(status3==KRequestPending);
1597 test(status4==KErrCancel);
1599 fs1.NotifyChangeCancel(status4); // Test no side effects on trying to cancel a request
1600 test(status4==KErrCancel); // that has already been cancelled
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
1609 fs1.NotifyChangeCancel(status3);
1610 User::WaitForRequest(status3);
1611 test(status3==KErrCancel);
1616 static void Test11()
1618 // Test notify client death
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);
1627 RThread clientThread;
1628 r=clientThread.Create(_L("ClientThread"),ThreadEntryPoint,0x4000,KHeapSize,KHeapSize,(TAny*)ETest9);
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
1635 TBool jit = User::JustInTime();
1636 User::SetJustInTime(EFalse);
1637 clientThread.Panic(_L("Test client thread panic"),KErrGeneral); // Panic client
1638 User::SetJustInTime(jit);
1640 clientThread.Close();
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"));
1650 static void Test12()
1652 // Test reads and writes do not cause notification under ENotifyEntry
1653 // Test reads and writes do cause notification under ENotifyAll
1657 test.Next(_L("Test reads and writes do not cause notification under ENotifyEntry"));
1660 TInt r=file.Replace(TheFs,_L("\\F32-TST\\NOTIFY\\kangaroo.txt"),EFileRead|EFileWrite);
1663 r=file.Replace(TheFs,_L("\\F32-TST\\NOTIFY\\koala.txt"),EFileRead|EFileWrite);
1666 r=file.Replace(TheFs,_L("\\F32-TST\\NOTIFY\\dingo.txt"),EFileRead|EFileWrite);
1670 TFileName path=_L("\\F32-TST\\NOTIFY\\");
1671 TRequestStatus reqStat1(KRequestPending);
1675 r=fs1.SetSessionPath(gSessionPath);
1677 fs1.NotifyChange(ENotifyEntry,reqStat1,path);
1679 TRequestStatus reqStat2(KRequestPending);
1683 r=fs2.SetSessionPath(gSessionPath);
1685 fs2.NotifyChange(ENotifyEntry,reqStat2,path);
1687 TRequestStatus reqStat3(KRequestPending);
1691 r=fs3.SetSessionPath(gSessionPath);
1693 fs3.NotifyChange(ENotifyEntry,reqStat3,path);
1695 test(reqStat1==KRequestPending);
1696 test(reqStat2==KRequestPending);
1697 test(reqStat3==KRequestPending);
1699 r=gSleepThread.CreateLocal(0);
1702 r=thread1.Create(_L("TestThread1"),ThreadEntryPoint,0x4000,KHeapSize,KHeapSize,(TAny*)ETest5);
1705 gSleepThread.Wait();
1707 test(reqStat1==KRequestPending);
1708 test(reqStat2==KRequestPending);
1709 test(reqStat3==KRequestPending);
1711 r=TheFs.Delete(_L("\\F32-TST\\NOTIFY\\kangaroo.txt"));
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...
1720 gSleepThread.Close();
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);
1728 fs1.NotifyChange(ENotifyAll,reqStat1,path);
1729 fs2.NotifyChange(ENotifyAll,reqStat2,path);
1730 fs3.NotifyChange(ENotifyAll,reqStat3,path);
1732 test(reqStat1==KRequestPending);
1733 test(reqStat2==KRequestPending);
1734 test(reqStat3==KRequestPending);
1736 r=gSleepThread.CreateLocal(0);
1739 r=thread2.Create(_L("TestThread2"),ThreadEntryPoint,0x4000,KHeapSize,KHeapSize,(TAny*)ETest5);
1742 gSleepThread.Wait();
1744 User::WaitForRequest(reqStat1);
1745 User::WaitForRequest(reqStat2);
1746 User::WaitForRequest(reqStat3);
1747 test(reqStat1==KErrNone);
1748 test(reqStat2==KErrNone);
1749 test(reqStat3==KErrNone);
1751 gSleepThread.Close();
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");
1762 fs1.NotifyChange(ENotifyAll,reqStat1,path1);
1763 fs2.NotifyChange(ENotifyEntry,reqStat2,path2);
1764 fs3.NotifyChange(ENotifyAll,reqStat3,path3);
1766 test(reqStat1==KRequestPending);
1767 test(reqStat2==KRequestPending);
1768 test(reqStat3==KRequestPending);
1770 r=gSleepThread.CreateLocal(0);
1773 r=thread3.Create(_L("TestThread3"),ThreadEntryPoint,0x4000,KHeapSize,KHeapSize,(TAny*)ETest5);
1776 gSleepThread.Wait();
1778 User::WaitForRequest(reqStat1);
1779 test(reqStat1==KErrNone);
1780 test(reqStat2==KRequestPending); // Monitoring with ENotifyEntry
1781 User::WaitForRequest(reqStat3);
1782 test(reqStat3==KErrNone);
1784 r=TheFs.Delete(_L("\\F32-TST\\NOTIFY\\koala.txt"));
1786 User::WaitForRequest(reqStat2);
1787 test(reqStat2==KErrNone);
1789 r=TheFs.Delete(_L("\\F32-TST\\NOTIFY\\kangaroo.txt"));
1791 r=TheFs.Delete(_L("\\F32-TST\\NOTIFY\\dingo.txt"));
1794 gSleepThread.Close();
1802 static void Test13()
1804 // Test file notification
1807 RFs fs; // Session to be notified of any changes
1808 TInt r=fs.Connect();
1810 r=fs.SetSessionPath(gSessionPath);
1814 r=TheFs.MkDir(_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\"));
1815 test(r==KErrNone||r==KErrAlreadyExists);
1818 r=file.Replace(TheFs,_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\WickedWitch.msg"),EFileStream);
1819 test(r==KErrNone||KErrAlreadyExists);
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);
1830 r=thread.Create(_L("MyThread7"),ThreadEntryPoint,KDefaultStackSize,KHeapSize,KHeapSize,(TAny*)ETest8);
1832 thread.Logon(thrdStat);
1834 User::WaitForRequest(thrdStat);
1835 test(thrdStat==KErrNone);
1836 User::WaitForRequest(reqStat);
1837 test(reqStat==KErrNone);
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);
1844 thread.Logon(thrdStat);
1846 User::WaitForRequest(thrdStat);
1847 test(thrdStat==KErrNone);
1848 User::After(500000);
1850 test(reqStat==KRequestPending);
1851 r=TheFs.Delete(_L("\\F32-TST\\NOTIFY\\NEWFILE.TXT"));
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);
1857 test(reqStat==KRequestPending);
1859 r=TheFs.Delete(_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Lion.log"));
1861 test(reqStat==KRequestPending);
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"));
1868 User::WaitForRequest(reqStat);
1869 test(reqStat==KErrNone);
1874 static void Test14()
1878 // Test notification request succeeds with all RFile and RFs operations which result in
1882 TInt r=fs.Connect(); // Session to be notified of any changes
1884 r=fs.SetSessionPath(gSessionPath);
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);
1894 fs.NotifyChange(ENotifyAll,reqStat,path);
1895 test(reqStat==KRequestPending);
1896 r=file.Replace(TheFs,_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Dorothy.doc"),EFileRead|EFileWrite);
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"));
1905 User::WaitForRequest(reqStat);
1906 test(reqStat==KErrNone);
1908 // RFile::Read() a file within the monitored directory - no notification for reads
1909 path=_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\");
1911 fs.NotifyChange(ENotifyAll,reqStat,path);
1912 test(reqStat==KRequestPending);
1913 r=file.Open(TheFs,_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Dorothy.doc"),EFileRead|EFileWrite);
1915 test(reqStat==KRequestPending);
1916 r=file.Read(0,temp,100);
1917 test(reqStat==KRequestPending);
1919 // RFile::SetAtt() of a file within the monitored directory
1920 test.Next(_L("RFile::SetAtt()"));
1921 r=file.SetAtt(KEntryAttSystem,KEntryAttNormal);
1923 User::WaitForRequest(reqStat);
1924 test(reqStat==KErrNone);
1925 fs.NotifyChange(ENotifyAll,reqStat,path);
1926 test(reqStat==KRequestPending);
1928 // RFile::SetSize() of a file within the monitored directory
1929 test.Next(_L("RFile::SetSize()"));
1930 r=file.SetSize(256);
1932 User::WaitForRequest(reqStat);
1933 test(reqStat==KErrNone);
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);
1941 r=file.Temp(TheFs,path,fileName,EFileWrite);
1943 User::WaitForRequest(reqStat);
1944 test(reqStat==KErrNone);
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);
1953 r=file.Open(TheFs,_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Dorothy.doc"),EFileRead|EFileWrite);
1955 test(reqStat==KRequestPending);
1956 file.SetModified(now);
1958 User::WaitForRequest(reqStat);
1959 test(reqStat==KErrNone);
1961 // RFs::SetEntry() to change a directory entry within the monitored directory
1962 test.Next(_L("RFs::SetEntry()"));
1964 fs.NotifyChange(ENotifyAll,reqStat,path);
1965 r=TheFs.Entry(_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Dorothy.doc"),entry);
1966 test(reqStat==KRequestPending);
1968 r=TheFs.SetEntry(_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Dorothy.doc"),now,KEntryAttHidden,KEntryAttNormal);
1970 User::WaitForRequest(reqStat);
1971 test(reqStat==KErrNone);
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);
1978 test(reqStat==KRequestPending);
1980 r=file.Set(now,KEntryAttNormal,KEntryAttHidden);
1982 User::WaitForRequest(reqStat);
1983 test(reqStat==KErrNone);
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"));
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"));
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"));
2006 test(reqStat==KRequestPending);
2007 fs.NotifyChangeCancel(reqStat);
2008 User::WaitForRequest(reqStat);
2009 test(reqStat==KErrCancel);
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\\"));
2018 User::WaitForRequest(reqStat);
2019 test(reqStat==KErrNone);
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\\"));
2027 User::WaitForRequest(reqStat);
2028 test(reqStat==KErrNone);
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);
2036 User::WaitForRequest(reqStat);
2037 test(reqStat==KErrNone);
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"));
2046 User::WaitForRequest(reqStat);
2047 test(reqStat==KErrNone);
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);
2055 User::WaitForRequest(reqStat);
2056 test(reqStat==KErrNone);
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"));
2065 User::WaitForRequest(reqStat);
2066 test(reqStat==KErrNone);
2068 // RFs::SetVolumeLabel() - should only be notification when monitoring relevant TNotifyTypes
2069 test.Next(_L("RFs::SetVolumeLabel"));
2070 fs.NotifyChange(ENotifyAll,reqStat,path);
2072 TInt driveNum=CurrentDrive();
2073 TVolumeInfo volInfo;
2074 TFileName currentVolName;
2076 r=TheFs.Volume(volInfo,driveNum);
2078 test(reqStat==KRequestPending);
2079 currentVolName=volInfo.iName;
2081 r=TheFs.SetVolumeLabel(_L("VOL"),driveNum);
2084 User::WaitForRequest(reqStat);
2085 test(reqStat==KErrNone);
2086 r=TheFs.Volume(volInfo,driveNum);
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);
2094 User::WaitForRequest(reqStat);
2095 test(reqStat==KErrNone);
2096 r=TheFs.Volume(volInfo,driveNum);
2099 test(volInfo.iName==_L("ABCDEFGHIJK"));
2101 // Test notification does not occur under ENotifyAttributes
2102 fs.NotifyChange(ENotifyAttributes,reqStat,path);
2103 r=TheFs.SetVolumeLabel(_L("TROPICANA"),driveNum);
2105 test(reqStat==KRequestPending);
2106 r=TheFs.Volume(volInfo,driveNum);
2109 test(volInfo.iName==_L("TROPICANA"));
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);
2119 User::WaitForRequest(reqStat);
2120 test(reqStat==KErrNone);
2121 r=TheFs.Volume(volInfo,driveNum);
2123 test(volInfo.iName==currentVolName);
2126 else // RFs::SetVolumeLabel() doesn't work on subst drives
2128 fs.NotifyChangeCancel();
2129 User::WaitForRequest(reqStat);
2130 test.Printf(_L("Cannot set volume label on a substed drive\n"));
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"));
2141 User::WaitForRequest(reqStat);
2142 test(reqStat==KErrNone);
2144 r=TheFs.Rename(_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Toto.doc"),_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Dorothy.doc"));
2147 #if defined(__WINS__)
2148 if(gSessionPath[0]=='Y'||gSessionPath[0]=='X')
2151 test.Next(_L("RFs::Rename() with max path length"));
2152 TFileName longName=_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\");
2153 while(longName.Length()<(KMaxFileName-2))
2155 r=TheFs.Rename(_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Dorothy.doc"),longName);
2157 fs.NotifyChange(ENotifyEntry,reqStat,longName);
2158 test(reqStat==KRequestPending);
2159 r=TheFs.Rename(longName,_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Dorothy.doc"));
2161 User::WaitForRequest(reqStat);
2162 test(reqStat==KErrNone);
2169 static void Test15()
2173 // Repeat Test15 operations in a subtree of that monitored, and ensure notification
2174 // occurs for a variety of RFile and RFs operations
2176 RFs fs; // Session to be notified when a change occurs
2177 TInt r=fs.Connect();
2179 r=fs.SetSessionPath(gSessionPath);
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);
2189 r=file.Open(TheFs,_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Dorothy.doc"),EFileRead|EFileWrite);
2191 test(reqStat==KRequestPending);
2192 r=file.Write(0,_L8("Pay no attention to the man behind the curtain"));
2194 User::WaitForRequest(reqStat);
2195 test(reqStat==KErrNone);
2197 // RFile::Read() a file within the monitored directory - no notification for reads
2198 fs.NotifyChange(ENotifyAll,reqStat,path);
2200 r=file.Open(TheFs,_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Dorothy.doc"),EFileRead|EFileWrite);
2202 test(reqStat==KRequestPending);
2203 r=file.Read(0,temp,100);
2204 test(reqStat==KRequestPending);
2206 // RFile::SetAtt() of a file within the monitored directory
2207 test.Next(_L("RFile::SetAtt()"));
2208 r=file.SetAtt(KEntryAttNormal,KEntryAttHidden);
2210 User::WaitForRequest(reqStat);
2211 test(reqStat==KErrNone);
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);
2219 User::WaitForRequest(reqStat);
2220 test(reqStat==KErrNone);
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);
2228 r=file.Temp(TheFs,_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\"),fileName,EFileWrite);
2230 User::WaitForRequest(reqStat);
2231 test(reqStat==KErrNone);
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);
2239 r=file.Open(TheFs,_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Dorothy.doc"),EFileRead|EFileWrite);
2241 test(reqStat==KRequestPending);
2242 file.SetModified(now);
2244 User::WaitForRequest(reqStat);
2245 test(reqStat==KErrNone);
2247 // RFs::Entry() to change a directory entry within the monitored directory
2248 test.Next(_L("RFs::Entry()"));
2249 fs.NotifyChange(ENotifyAll,reqStat,path);
2251 r=TheFs.Entry(_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Dorothy.doc"),entry);
2252 test(reqStat==KRequestPending);
2254 r=TheFs.SetEntry(_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Dorothy.doc"),now,KEntryAttHidden,KEntryAttNormal);
2256 User::WaitForRequest(reqStat);
2257 test(reqStat==KErrNone);
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);
2264 test(reqStat==KRequestPending);
2266 r=file.Set(now,KEntryAttNormal,KEntryAttHidden);
2268 User::WaitForRequest(reqStat);
2269 test(reqStat==KErrNone);
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"));
2278 User::WaitForRequest(reqStat);
2279 test(reqStat==KErrNone);
2280 fs.NotifyChange(ENotifyEntry,reqStat,path);
2281 r=TheFs.SetDriveName(KDefaultDrive,_L("TEST"));
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"));
2292 test(reqStat==KRequestPending);
2293 fs.NotifyChangeCancel(reqStat);
2294 User::WaitForRequest(reqStat);
2295 test(reqStat==KErrCancel);
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\\"));
2303 User::WaitForRequest(reqStat);
2304 test(reqStat==KErrNone);
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\\"));
2312 User::WaitForRequest(reqStat);
2313 test(reqStat==KErrNone);
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);
2321 User::WaitForRequest(reqStat);
2322 test(reqStat==KErrNone);
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"));
2331 User::WaitForRequest(reqStat);
2332 test(reqStat==KErrNone);
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);
2340 User::WaitForRequest(reqStat);
2341 test(reqStat==KErrNone);
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"));
2350 User::WaitForRequest(reqStat);
2351 test(reqStat==KErrNone);
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()"));
2357 fs.NotifyChange(ENotifyAll,reqStat,path);
2359 TInt driveNum=CurrentDrive();
2360 TVolumeInfo volInfo;
2361 TFileName currentVolName;
2362 r=TheFs.Volume(volInfo,driveNum);
2364 test(reqStat==KRequestPending);
2365 currentVolName=volInfo.iName;
2367 r=TheFs.SetVolumeLabel(_L("VOL"),driveNum);
2370 User::WaitForRequest(reqStat);
2371 test(reqStat==KErrNone);
2372 r=TheFs.Volume(volInfo,driveNum);
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);
2380 User::WaitForRequest(reqStat);
2381 test(reqStat==KErrNone);
2382 r=TheFs.Volume(volInfo,driveNum);
2385 test(volInfo.iName==_L("ABCDEFGHIJK"));
2387 // Test notification does not occur under ENotifyAttributes
2388 fs.NotifyChange(ENotifyAttributes,reqStat,path);
2389 r=TheFs.SetVolumeLabel(_L("TROPICANA"),driveNum);
2391 test(reqStat==KRequestPending);
2392 r=TheFs.Volume(volInfo,driveNum);
2395 test(volInfo.iName==_L("TROPICANA"));
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);
2405 User::WaitForRequest(reqStat);
2406 test(reqStat==KErrNone);
2407 r=TheFs.Volume(volInfo,driveNum);
2409 test(volInfo.iName==currentVolName);
2412 else // RFs::SetVolumeLabel() doesn't work on subst drives
2414 fs.NotifyChangeCancel();
2415 User::WaitForRequest(reqStat);
2416 test.Printf(_L("Cannot set volume label on a substed drive\n"));
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\\"));
2426 User::WaitForRequest(reqStat);
2427 test(reqStat==KErrNone);
2429 fs.NotifyChange(ENotifyAll,reqStat,path);
2430 test(reqStat==KRequestPending);
2431 r=TheFs.RmDir(_L("\\F32-TST\\NOTIFY\\EMERALD_CITY\\"));
2433 User::WaitForRequest(reqStat);
2434 test(reqStat==KErrNone);
2439 static void Test16()
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
2447 TInt r=fs.Connect(); // Session to be notified when a change occurs
2449 r=fs.SetSessionPath(gSessionPath);
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);
2458 r=file.Open(TheFs,_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Dorothy.doc"),EFileRead|EFileWrite);
2460 test(reqStat==KRequestPending);
2461 r=file.Write(0,_L8("Pay no attention to the man behind the curtain"));
2463 User::WaitForRequest(reqStat);
2464 test(reqStat==KErrNone);
2466 // RFile::Read() a file within the monitored directory - no notification for reads
2467 fs.NotifyChange(ENotifyAll,reqStat,path);
2469 r=file.Open(TheFs,_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Dorothy.doc"),EFileRead|EFileWrite);
2471 test(reqStat==KRequestPending);
2472 r=file.Read(0,temp,100);
2473 test(reqStat==KRequestPending);
2475 // RFile::SetAtt() of a file within the monitored directory
2476 r=file.SetAtt(KEntryAttNormal,KEntryAttHidden);
2478 User::WaitForRequest(reqStat);
2479 test(reqStat==KErrNone);
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);
2486 User::WaitForRequest(reqStat);
2487 test(reqStat==KErrNone);
2491 // RFile::SetModified() to change modification time of a file within monitored dir
2492 fs.NotifyChange(ENotifyAll,reqStat,path);
2495 r=file.Open(TheFs,_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Dorothy.doc"),EFileRead|EFileWrite);
2497 test(reqStat==KRequestPending);
2498 file.SetModified(now);
2500 User::WaitForRequest(reqStat);
2501 test(reqStat==KErrNone);
2503 // RFs::Entry() to change a directory entry within the monitored directory
2504 fs.NotifyChange(ENotifyAll,reqStat,path);
2506 r=TheFs.Entry(_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Dorothy.doc"),entry);
2507 test(reqStat==KRequestPending);
2509 r=TheFs.SetEntry(_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Dorothy.doc"),now,KEntryAttHidden,KEntryAttNormal);
2511 User::WaitForRequest(reqStat);
2512 test(reqStat==KErrNone);
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);
2518 test(reqStat==KRequestPending);
2520 r=file.Set(now,KEntryAttNormal,KEntryAttHidden);
2522 User::WaitForRequest(reqStat);
2523 test(reqStat==KErrNone);
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"));
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"));
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"));
2544 test(reqStat==KRequestPending);
2545 fs.NotifyChangeCancel(reqStat);
2546 User::WaitForRequest(reqStat);
2547 test(reqStat==KErrCancel);
2551 fs.NotifyChange(ENotifyAll,reqStat,path);
2552 test(reqStat==KRequestPending);
2553 r=TheFs.MkDir(_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\EMERALD_CITY\\"));
2555 User::WaitForRequest(reqStat);
2556 test(reqStat==KErrNone);
2559 fs.NotifyChange(ENotifyAll,reqStat,path);
2560 test(reqStat==KRequestPending);
2561 r=TheFs.RmDir(_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\EMERALD_CITY\\"));
2563 User::WaitForRequest(reqStat);
2564 test(reqStat==KErrNone);
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);
2571 User::WaitForRequest(reqStat);
2572 test(reqStat==KErrNone);
2576 fs.NotifyChange(ENotifyAll,reqStat,path);
2577 test(reqStat==KRequestPending);
2578 r=TheFs.Delete(_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Good_Witch.bat"));
2580 User::WaitForRequest(reqStat);
2581 test(reqStat==KErrNone);
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);
2588 User::WaitForRequest(reqStat);
2589 test(reqStat==KErrNone);
2593 fs.NotifyChange(ENotifyAll,reqStat,path);
2594 test(reqStat==KRequestPending);
2595 r=TheFs.Delete(_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Good_Witch.bat"));
2597 User::WaitForRequest(reqStat);
2598 test(reqStat==KErrNone);
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);
2608 test(reqStat==KRequestPending);
2609 currentVolName=volInfo.iName;
2611 r=TheFs.SetVolumeLabel(_L("VOL"),driveNum);
2614 User::WaitForRequest(reqStat);
2615 test(reqStat==KErrNone);
2616 r=TheFs.Volume(volInfo,driveNum);
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);
2624 User::WaitForRequest(reqStat);
2625 test(reqStat==KErrNone);
2626 r=TheFs.Volume(volInfo,driveNum);
2629 test(volInfo.iName==_L("ABCDEFGHIJK"));
2631 // Test notification does not occur under ENotifyAttributes
2632 fs.NotifyChange(ENotifyAttributes,reqStat,path);
2633 r=TheFs.SetVolumeLabel(_L("TROPICANA"),driveNum);
2635 test(reqStat==KRequestPending);
2636 r=TheFs.Volume(volInfo,driveNum);
2639 test(volInfo.iName==_L("TROPICANA"));
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);
2649 User::WaitForRequest(reqStat);
2650 test(reqStat==KErrNone);
2651 r=TheFs.Volume(volInfo,driveNum);
2653 test(volInfo.iName==currentVolName);
2656 else // RFs::SetVolumeLabel() doesn't work on subst drives
2658 fs.NotifyChangeCancel();
2659 User::WaitForRequest(reqStat);
2660 test.Printf(_L("Cannot set volume label on a substed drive\n"));
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"));
2668 User::WaitForRequest(reqStat);
2669 test(reqStat==KErrNone);
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\\"));
2676 User::WaitForRequest(reqStat);
2677 test(reqStat==KErrNone);
2679 fs.NotifyChange(ENotifyAll,reqStat,path);
2680 test(reqStat==KRequestPending);
2681 r=TheFs.RmDir(_L("\\F32-TST\\NOTIFY\\EMERALD_CITY\\"));
2683 User::WaitForRequest(reqStat);
2684 test(reqStat==KErrNone);
2689 static void Test17()
2691 // Test multiple requests from a single session
2695 test.Next(_L("Test reads and writes do not cause notification under ENotifyEntry"));
2698 TInt r=file.Replace(TheFs,_L("\\F32-TST\\NOTIFY\\kangaroo.txt"),EFileRead|EFileWrite);
2701 r=file.Replace(TheFs,_L("\\F32-TST\\NOTIFY\\koala.txt"),EFileRead|EFileWrite);
2704 r=file.Replace(TheFs,_L("\\F32-TST\\NOTIFY\\dingo.txt"),EFileRead|EFileWrite);
2711 r=fs.SetSessionPath(gSessionPath);
2714 TRequestStatus reqStat1(KRequestPending);
2715 TFileName path1=_L("\\F32-TST\\NOTIFY\\");
2716 fs.NotifyChange(ENotifyEntry,reqStat1,path1);
2718 TRequestStatus status1(KRequestPending);
2719 TRequestStatus status2(KRequestPending);
2720 TRequestStatus status3(KRequestPending);
2721 TRequestStatus status4(KRequestPending);
2722 TRequestStatus status5(KRequestPending);
2723 TRequestStatus status6(KRequestPending);
2725 TRequestStatus statusExtended1(KRequestPending);
2726 TRequestStatus statusExtended2(KRequestPending);
2727 TRequestStatus statusExtended3(KRequestPending);
2728 TRequestStatus statusExtended4(KRequestPending);
2729 TRequestStatus statusExtended5(KRequestPending);
2730 TRequestStatus statusExtended6(KRequestPending);
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);
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);
2748 TRequestStatus reqStat2(KRequestPending);
2749 TFileName path2=_L("\\F32-TST\\NOTIFY\\kangaroo.txt");
2750 fs.NotifyChange(ENotifyEntry,reqStat2,path2);
2752 TRequestStatus reqStat3(KRequestPending);
2753 TFileName path3=_L("\\F32-TST\\NOTIFY\\koala.txt");
2754 fs.NotifyChange(ENotifyEntry,reqStat3,path3);
2756 TRequestStatus reqStat4(KRequestPending);
2757 TFileName path4=_L("\\F32-TST\\NOTIFY\\dingo.txt");
2758 fs.NotifyChange(ENotifyEntry,reqStat4,path4);
2761 r=gSleepThread.CreateLocal(0);
2764 r=thread1.Create(_L("TestThread1"),ThreadEntryPoint,0x4000,KHeapSize,KHeapSize,(TAny*)ETest5);
2767 gSleepThread.Wait();
2769 test(status1==KRequestPending);
2770 test(status2==KRequestPending);
2771 test(status3==KRequestPending);
2772 test(status4==KRequestPending);
2773 test(status5==KRequestPending);
2774 test(status6==KRequestPending);
2776 test(statusExtended1==KRequestPending);
2777 test(statusExtended2==KRequestPending);
2778 test(statusExtended3==KRequestPending);
2779 test(statusExtended4==KRequestPending);
2780 test(statusExtended5==KRequestPending);
2781 test(statusExtended6==KRequestPending);
2783 test(reqStat1==KRequestPending);
2784 test(reqStat2==KRequestPending);
2785 test(reqStat3==KRequestPending);
2786 test(reqStat4==KRequestPending);
2788 r=TheFs.Delete(_L("\\F32-TST\\NOTIFY\\kangaroo.txt"));
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);
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);
2818 User::WaitForRequest(reqStat2);
2819 test(reqStat2==KErrNone);
2820 test(reqStat3==KRequestPending);
2821 test(reqStat4==KRequestPending);
2822 fs.NotifyChangeCancel(); // Cancels both remaining notification requests
2824 User::WaitForRequest(reqStat3);
2825 User::WaitForRequest(reqStat4);
2827 gSleepThread.Close();
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);
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);
2844 r=gSleepThread.CreateLocal(0);
2847 r=thread2.Create(_L("TestThread2"),ThreadEntryPoint,0x4000,KHeapSize,KHeapSize,(TAny*)ETest5);
2850 gSleepThread.Wait();
2852 User::WaitForRequest(reqStat1);
2853 test(reqStat1==KErrNone);
2854 test(reqStat2==KRequestPending);
2855 User::WaitForRequest(reqStat3);
2856 test(reqStat3==KErrNone);
2857 test(reqStat4==KRequestPending);
2859 gSleepThread.Close();
2862 fs.NotifyChange(ENotifyAll,reqStat1,path1);
2863 fs.NotifyChange(ENotifyAll,reqStat3,path3);
2865 test(reqStat1==KRequestPending);
2866 test(reqStat2==KRequestPending);
2867 test(reqStat3==KRequestPending);
2868 test(reqStat4==KRequestPending);
2870 r=gSleepThread.CreateLocal(0);
2873 r=thread3.Create(_L("TestThread3"),ThreadEntryPoint,0x4000,KHeapSize,KHeapSize,(TAny*)ETest5);
2876 gSleepThread.Wait();
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
2888 r=fs2.SetSessionPath(gSessionPath);
2891 TRequestStatus reqStat(KRequestPending);
2892 fs2.NotifyChange(ENotifyEntry,reqStat);
2893 test(reqStat==KRequestPending);
2895 r=TheFs.Delete(_L("\\F32-TST\\NOTIFY\\kangaroo.txt"));
2897 User::WaitForRequest(reqStat2);
2898 test(reqStat2==KErrNone);
2899 test(reqStat4==KRequestPending);
2900 User::WaitForRequest(reqStat);
2901 test(reqStat==KErrNone);
2903 fs2.NotifyChange(ENotifyAll,reqStat);
2904 test(reqStat==KRequestPending);
2905 r=TheFs.Delete(_L("\\F32-TST\\NOTIFY\\koala.txt"));
2907 User::WaitForRequest(reqStat);
2908 test(reqStat==KErrNone);
2909 test(reqStat4==KRequestPending);
2910 r=TheFs.Delete(_L("\\F32-TST\\NOTIFY\\dingo.txt"));
2912 User::WaitForRequest(reqStat4);
2913 test(reqStat4==KErrNone);
2915 gSleepThread.Close();
2920 static void Test18()
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};
2930 TInt r=fs.Connect(); // Session to be notified of any changes
2932 r=fs.SetSessionPath(gSessionPath);
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);
2948 r=file.Replace(TheFs,_L("\\F32-TST\\NOTIFY\\NewFile.txt"),EFileRead|EFileWrite);
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);
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);
2970 r=file.Write(0,_L8("Pay no attention to the man behind the curtain"));
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
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);
2995 r=file.Open(TheFs,_L("\\F32-TST\\NOTIFY\\NewFile.txt"),EFileRead|EFileWrite);
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);
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);
3016 test.Next(_L("RFile::SetAtt()"));
3017 r=file.SetAtt(KEntryAttSystem,KEntryAttNormal);
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);
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);
3035 test(reqStat==KRequestPending); // Monitoring with ENotifyWrite
3036 fs.NotifyChangeCancel(); // Cancel outstanding notification request
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);
3049 fs.NotifyChange(ENotifyAll,reqStat,path);
3050 fs.NotifyChange(ENotifyFile,reqStat2,path);
3051 fs.NotifyChange(ENotifyEntry,reqStat3,path);
3052 fs.NotifyChange(ENotifyAttributes,reqStat4,path);
3054 test(reqStat==KRequestPending);
3055 test(reqStat2==KRequestPending);
3056 test(reqStat3==KRequestPending);
3057 test(reqStat4==KRequestPending);
3059 // RFile::SetSize() of a file within the monitored directory
3060 test.Next(_L("RFile::SetSize()"));
3061 r=file.SetSize(256);
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);
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);
3077 User::After(1000000);
3078 test(reqStat==KRequestPending); // Monitoring with ENotifyWrite
3081 fs.NotifyChangeCancel(); // Cancels all outstanding notification requests
3083 User::WaitForRequest(reqStat);
3084 test(reqStat==KErrCancel);
3085 User::WaitForRequest(reqStat2);
3086 test(reqStat2==KErrCancel);
3087 User::WaitForRequest(reqStat3);
3088 test(reqStat3==KErrCancel);
3090 // RFile::Temp() to create a temp file within the monitored directory
3091 test.Next(_L("RFile::Temp()"));
3092 path=_L("\\F32-TST\\NOTIFY\\");
3094 fs.NotifyChange(ENotifyAll,reqStat,path);
3095 fs.NotifyChange(ENotifyDir,reqStat2,path);
3096 fs.NotifyChange(ENotifyEntry,reqStat3,path);
3097 fs.NotifyChange(ENotifyAttributes,reqStat4,path);
3099 test(reqStat==KRequestPending);
3100 test(reqStat2==KRequestPending);
3101 test(reqStat3==KRequestPending);
3102 test(reqStat4==KRequestPending);
3105 r=file.Temp(TheFs,path,fileName,EFileWrite);
3107 User::WaitForRequest(reqStat);
3108 test(reqStat==KErrNone);
3109 test(reqStat2==KRequestPending);
3110 test(reqStat3==KRequestPending); // Monitoring ENotifyEntry
3111 test(reqStat4==KRequestPending); // Monitoring ENotifyAttributes
3113 fs.NotifyChangeCancel();
3115 User::WaitForRequest(reqStat2);
3116 test(reqStat2==KErrCancel);
3117 User::WaitForRequest(reqStat3);
3118 test(reqStat3==KErrCancel);
3119 User::WaitForRequest(reqStat4);
3120 test(reqStat4==KErrCancel);
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);
3127 test(reqStat==KRequestPending); // Monitoring ENotifyFile
3128 test(reqStat2==KRequestPending); // Monitoring ENotifyDisk
3129 test(reqStat3==KRequestPending); // Monitoring ENotifyWrite
3132 fs.NotifyChangeCancel(); // Cancels all outstanding notification requests
3134 User::WaitForRequest(reqStat);
3135 test(reqStat==KErrCancel);
3136 User::WaitForRequest(reqStat2);
3137 test(reqStat2==KErrCancel);
3138 User::WaitForRequest(reqStat3);
3139 test(reqStat3==KErrCancel);
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);
3149 test(reqStat==KRequestPending);
3150 test(reqStat2==KRequestPending);
3151 test(reqStat3==KRequestPending);
3152 test(reqStat4==KRequestPending);
3156 r=file.Open(TheFs,_L("\\F32-TST\\NOTIFY\\NewFile.txt"),EFileRead|EFileWrite);
3158 test(reqStat==KRequestPending);
3159 file.SetModified(now);
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();
3169 User::WaitForRequest(reqStat2);
3170 test(reqStat2==KErrCancel);
3171 User::WaitForRequest(reqStat4);
3172 test(reqStat4==KErrCancel);
3174 // RFs::SetEntry() to change a directory entry within the monitored directory
3175 test.Next(_L("RFs::SetEntry()"));
3177 fs.NotifyChange(ENotifyAll,reqStat,path);
3178 fs.NotifyChange(ENotifyEntry,reqStat2,path);
3179 fs.NotifyChange(ENotifyAttributes,reqStat3,path);
3180 fs.NotifyChange(ENotifyDisk,reqStat4,path);
3182 test(reqStat==KRequestPending);
3183 test(reqStat2==KRequestPending);
3184 test(reqStat3==KRequestPending);
3185 test(reqStat4==KRequestPending);
3187 r=TheFs.Entry(_L("\\F32-TST\\NOTIFY\\NewFile.txt"),entry);
3188 test(reqStat==KRequestPending);
3190 r=TheFs.SetEntry(_L("\\F32-TST\\NOTIFY\\NewFile.txt"),now,KEntryAttHidden,KEntryAttNormal);
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();
3200 User::WaitForRequest(reqStat2);
3201 test(reqStat2==KErrCancel);
3202 User::WaitForRequest(reqStat4);
3203 test(reqStat4==KErrCancel);
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);
3212 test(reqStat==KRequestPending);
3213 test(reqStat2==KRequestPending);
3214 test(reqStat3==KRequestPending);
3215 test(reqStat4==KRequestPending);
3217 r=file.Open(TheFs,_L("\\F32-TST\\NOTIFY\\NewFile.txt"),EFileRead|EFileWrite);
3219 test(reqStat==KRequestPending);
3221 r=file.Set(now,KEntryAttNormal,KEntryAttHidden);
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();
3231 User::WaitForRequest(reqStat2);
3232 test(reqStat2==KErrCancel);
3233 User::WaitForRequest(reqStat4);
3234 test(reqStat4==KErrCancel);
3236 // RFs::SetDriveName()
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);
3244 test(reqStat==KRequestPending);
3245 test(reqStat2==KRequestPending);
3246 test(reqStat3==KRequestPending);
3247 test(reqStat4==KRequestPending);
3248 User::After(KNotifyChangeAfter);
3250 r=TheFs.SetDriveName(KDefaultDrive,_L("DRIVETEST"));
3252 User::WaitForRequest(reqStat);
3253 test(reqStat==KErrNone);
3254 test(reqStat2==KRequestPending);
3255 test(reqStat3==KRequestPending);
3256 test(reqStat4==KRequestPending);
3257 fs.NotifyChangeCancel();
3259 User::WaitForRequest(reqStat2);
3260 test(reqStat2==KErrCancel);
3261 User::WaitForRequest(reqStat3);
3262 test(reqStat3==KErrCancel);
3263 User::WaitForRequest(reqStat4);
3264 test(reqStat4==KErrCancel);
3267 test.Next(_L("RFs::MkDir()"));
3268 path=_L("\\F32-TST\\NOTIFY\\");
3270 fs.NotifyChange(ENotifyAll,reqStat,path);
3271 fs.NotifyChange(ENotifyEntry,reqStat2,path);
3272 fs.NotifyChange(ENotifyDir,reqStat3,path);
3273 fs.NotifyChange(ENotifyFile,reqStat4,path);
3275 test(reqStat==KRequestPending);
3276 test(reqStat2==KRequestPending);
3277 test(reqStat3==KRequestPending);
3278 test(reqStat4==KRequestPending);
3280 r=TheFs.MkDir(_L("\\F32-TST\\NOTIFY\\EMERALD_CITY\\"));
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);
3291 test.Next(_L("RFs::RmDir()"));
3292 fs.NotifyChange(ENotifyAll,reqStat,path);
3293 fs.NotifyChange(ENotifyDir,reqStat2,path);
3294 fs.NotifyChange(ENotifyWrite,reqStat3,path);
3296 test(reqStat==KRequestPending);
3297 test(reqStat2==KRequestPending);
3298 test(reqStat3==KRequestPending);
3300 r=TheFs.RmDir(_L("\\F32-TST\\NOTIFY\\EMERALD_CITY\\"));
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();
3310 User::WaitForRequest(reqStat3);
3311 test(reqStat3==KErrCancel);
3312 User::WaitForRequest(reqStat4);
3313 test(reqStat4==KErrCancel);
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);
3322 test(reqStat==KRequestPending);
3323 test(reqStat2==KRequestPending);
3324 test(reqStat3==KRequestPending);
3325 test(reqStat4==KRequestPending);
3327 r=file.Create(TheFs,_L("\\F32-TST\\NOTIFY\\Good_Witch.bat"),EFileRead|EFileWrite);
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);
3337 fs.NotifyChangeCancel(reqStat3);
3338 User::WaitForRequest(reqStat3);
3340 fs.NotifyChange(ENotifyAll,reqStat,path);
3341 fs.NotifyChange(ENotifyEntry,reqStat2,path);
3342 fs.NotifyChange(ENotifyDisk,reqStat3,path);
3343 fs.NotifyChange(ENotifyWrite,reqStat4,path);
3345 test(reqStat==KRequestPending);
3346 test(reqStat2==KRequestPending);
3347 test(reqStat3==KRequestPending);
3348 test(reqStat4==KRequestPending);
3350 r=file.Create(TheFs,_L("\\F32-TST\\NOTIFY\\Bad_Witch.bat"),EFileRead|EFileWrite);
3352 User::WaitForRequest(reqStat);
3353 User::WaitForRequest(reqStat2);
3354 test(reqStat==KErrNone);
3355 test(reqStat2==KErrNone);
3356 test(reqStat3==KRequestPending);
3357 test(reqStat4==KRequestPending);
3359 fs.NotifyChangeCancel();
3361 User::WaitForRequest(reqStat3);
3362 test(reqStat3==KErrCancel);
3363 User::WaitForRequest(reqStat4);
3364 test(reqStat4==KErrCancel);
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);
3373 test(reqStat==KRequestPending);
3374 test(reqStat2==KRequestPending);
3375 test(reqStat3==KRequestPending);
3376 test(reqStat4==KRequestPending);
3378 r=TheFs.Delete(_L("\\F32-TST\\NOTIFY\\Good_Witch.bat"));
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);
3391 fs.NotifyChange(ENotifyAll,reqStat,path);
3392 fs.NotifyChange(ENotifyEntry,reqStat2,path);
3393 fs.NotifyChange(ENotifyAttributes,reqStat3,path);
3394 fs.NotifyChange(ENotifyAll,reqStat4,path);
3396 test(reqStat==KRequestPending);
3397 test(reqStat2==KRequestPending);
3398 test(reqStat3==KRequestPending);
3399 test(reqStat4==KRequestPending);
3401 r=TheFs.Delete(_L("\\F32-TST\\NOTIFY\\Bad_Witch.bat"));
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);
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);
3421 test(reqStat==KRequestPending);
3422 test(reqStat2==KRequestPending);
3423 test(reqStat3==KRequestPending);
3424 test(reqStat4==KRequestPending);
3426 r=file.Replace(TheFs,_L("\\F32-TST\\NOTIFY\\Good_Witch.bat"),EFileRead|EFileWrite);
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);
3436 fs.NotifyChangeCancel();
3438 test(reqStat==KErrNone);
3439 test(reqStat2==KErrNone);
3440 test(reqStat3==KErrNone);
3441 User::WaitForRequest(reqStat4);
3442 test(reqStat4==KErrCancel);
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);
3452 test(reqStat==KRequestPending);
3453 test(reqStat2==KRequestPending);
3454 test(reqStat3==KRequestPending);
3455 User::WaitForRequest(reqStat4);
3456 test(reqStat4==KErrArgument);
3458 r=TheFs.Delete(_L("\\F32-TST\\NOTIFY\\Good_Witch.bat"));
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);
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);
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);
3487 TInt driveNum=CurrentDrive();
3488 TVolumeInfo volInfo;
3489 TFileName currentVolName;
3490 r=TheFs.Volume(volInfo,driveNum);
3492 test(reqStat==KRequestPending);
3493 currentVolName=volInfo.iName;
3495 r=TheFs.SetVolumeLabel(_L("VOL"),driveNum);
3498 User::WaitForRequest(reqStat);
3499 User::WaitForRequest(reqStat2);
3500 User::WaitForRequest(reqStat7);
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);
3510 fs.NotifyChange(ENotifyAll,reqStat,path);
3511 fs.NotifyChange(ENotifyEntry,reqStat2,path);
3512 fs.NotifyChange(ENotifyDisk,reqStat7,path);
3514 test(reqStat==KRequestPending);
3515 test(reqStat2==KRequestPending);
3516 test(reqStat7==KRequestPending);
3518 r=TheFs.SetVolumeLabel(currentVolName,driveNum);
3521 User::WaitForRequest(reqStat);
3522 User::WaitForRequest(reqStat2);
3523 User::WaitForRequest(reqStat7);
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);
3533 r=TheFs.Volume(volInfo,driveNum);
3535 test(volInfo.iName==currentVolName);
3537 fs.NotifyChangeCancel();
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);
3549 else // RFs::SetVolumeLabel() doesn't work on subst drives
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"));
3564 test.Next(_L("RFile::Rename()"));
3565 path=_L("\\F32-TST\\NOTIFY\\");
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);
3573 test(reqStat==KRequestPending);
3574 test(reqStat2==KRequestPending);
3575 test(reqStat3==KRequestPending);
3576 test(reqStat4==KRequestPending);
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
3588 fs.NotifyChangeCancel();
3589 User::WaitForRequest(reqStat4);
3590 test(reqStat4==KErrCancel);
3592 path=_L("\\F32-TST\\NOTIFY\\OldFile.abc");
3594 r=file.Open(TheFs,_L("\\F32-TST\\NOTIFY\\OldFile.abc"),EFileShareExclusive|EFileWrite);
3596 fs.NotifyChange(ENotifyAll,reqStat,path);
3597 fs.NotifyChange(ENotifyEntry,reqStat2,path);
3598 fs.NotifyChange(ENotifyFile,reqStat3,path);
3599 fs.NotifyChange(ENotifyDir,reqStat4,path);
3601 test(reqStat==KRequestPending);
3602 test(reqStat2==KRequestPending);
3603 test(reqStat3==KRequestPending);
3604 User::WaitForRequest(reqStat4);
3605 test(reqStat4==KErrArgument);
3607 r=file.Rename(_L("\\F32-TST\\NOTIFY\\NewFile.xyz"));
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);
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);
3626 test(reqStat==KRequestPending);
3627 test(reqStat2==KRequestPending);
3628 test(reqStat3==KRequestPending);
3629 test(reqStat4==KRequestPending);
3631 r=TheFs.Rename(_L("\\F32-TST\\NOTIFY\\NewFile.xyz"),_L("\\F32-TST\\NOTIFY\\NewerFile.cat"));
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();
3642 test(reqStat==KErrNone);
3643 test(reqStat2==KErrNone);
3644 test(reqStat3==KErrNone);
3645 User::WaitForRequest(reqStat4);
3646 test(reqStat4==KErrCancel);
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);
3654 test(reqStat==KRequestPending);
3655 test(reqStat2==KRequestPending);
3656 test(reqStat3==KRequestPending);
3657 User::WaitForRequest(reqStat4);
3658 test(reqStat4==KErrArgument);
3660 r=TheFs.Rename(_L("\\F32-TST\\NOTIFY\\NewerFile.cat"),_L("\\F32-TST\\NOTIFY\\Original.dog"));
3662 User::WaitForRequest(reqStat);
3663 User::WaitForRequest(reqStat2);
3664 User::WaitForRequest(reqStat3);
3665 test(reqStat==KErrNone);
3666 test(reqStat2==KErrNone);
3667 test(reqStat3==KErrNone);
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);
3675 test(reqStat==KRequestPending);
3676 test(reqStat2==KRequestPending);
3677 test(reqStat3==KRequestPending);
3678 test(reqStat4==KRequestPending);
3680 r=TheFs.Rename(_L("\\F32-TST\\NOTIFY\\"),_L("\\F32-TST\\NOTIFY_TEMP\\"));
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
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);
3698 test(reqStat==KRequestPending);
3699 test(reqStat2==KRequestPending);
3700 test(reqStat3==KRequestPending);
3701 User::WaitForRequest(reqStat4);
3702 test(reqStat4==KErrArgument);
3704 r=TheFs.Rename(_L("\\F32-TST\\NOTIFY_TEMP\\"),_L("\\F32-TST\\NOTIFY\\"));
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
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);
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);
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);
3735 test(reqStat==KRequestPending);
3736 test(reqStat2==KRequestPending);
3737 test(reqStat3==KRequestPending);
3739 r=TheFs.Delete(_L("\\F32-TST\\NOTIFY\\Original.dog"));
3741 User::WaitForRequest(reqStat);
3742 User::WaitForRequest(reqStat2);
3743 User::WaitForRequest(reqStat3);
3744 test(reqStat==KErrNone);
3745 test(reqStat2==KErrNone);
3746 test(reqStat3==KErrNone);
3748 path=_L("\\F32-TST\\NOTIFY\\");
3749 fs.NotifyChange(ENotifyAll,reqStat,path);
3750 fs.NotifyChange(ENotifyEntry,reqStat2,path);
3751 fs.NotifyChange(ENotifyDir,reqStat3,path);
3753 test(reqStat==KRequestPending);
3754 test(reqStat2==KRequestPending);
3755 test(reqStat3==KRequestPending);
3757 r=TheFs.Rename(_L("\\F32-TST\\"),_L("\\F32-TEST\\"));
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
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);
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);
3786 path=_L("\\F32-TEST\\NOTIFY\\");
3787 fs.NotifyChange(ENotifyAll,reqStat,path);
3788 fs.NotifyChange(ENotifyEntry,reqStat2,path);
3789 fs.NotifyChange(ENotifyDir,reqStat3,path);
3791 test(reqStat==KRequestPending);
3792 test(reqStat2==KRequestPending);
3793 test(reqStat3==KRequestPending);
3795 r=TheFs.Rename(_L("\\F32-TEST\\NOTIFY\\"),_L("\\F32-TEST\\NOTIFY_CHANGED\\"));
3798 User::WaitForRequest(reqStat);
3799 User::WaitForRequest(reqStat2);
3800 User::WaitForRequest(reqStat3);
3802 test(reqStat==KErrNone); // Rename the directory we were monitoring
3803 test(reqStat2==KErrNone);
3804 test(reqStat3==KErrNone);
3806 // Tidy up the test directory before continuing (while testing notifications of renaming to the monitored directory)
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);
3814 test(reqStat==KRequestPending);
3815 test(reqStat2==KRequestPending);
3816 test(reqStat3==KRequestPending);
3817 test(reqStat4==KRequestPending);
3819 r=TheFs.Rename(_L("\\F32-TEST\\"),_L("\\F32-TST\\"));
3822 User::WaitForRequest(reqStat);
3823 User::WaitForRequest(reqStat2);
3824 User::WaitForRequest(reqStat3);
3826 test(reqStat==KErrNone); // Renaming to (under) the directory we were monitoring
3827 test(reqStat2==KErrNone);
3828 test(reqStat3==KErrNone);
3829 test(reqStat4==KRequestPending);
3831 fs.NotifyChangeCancel(reqStat4);
3832 User::WaitForRequest(reqStat4);
3833 test(reqStat4==KErrCancel);
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);
3841 test(reqStat==KRequestPending);
3842 test(reqStat2==KRequestPending);
3843 test(reqStat3==KRequestPending);
3844 test(reqStat4==KRequestPending);
3846 r=TheFs.Rename(_L("\\F32-TST\\NOTIFY_CHANGED\\"),_L("\\F32-TST\\NOTIFY\\"));
3849 User::WaitForRequest(reqStat);
3850 User::WaitForRequest(reqStat2);
3851 User::WaitForRequest(reqStat3);
3853 test(reqStat==KErrNone); // Renaming to the directory we were monitoring
3854 test(reqStat2==KErrNone);
3855 test(reqStat3==KErrNone);
3856 test(reqStat4==KRequestPending);
3858 fs.NotifyChangeCancel(reqStat4);
3859 User::WaitForRequest(reqStat4);
3860 test(reqStat4==KErrCancel);
3862 // Test combinations of notify types
3863 test.Next(_L("Test combinations of notify types"));
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);
3871 test(reqStat==KRequestPending);
3872 test(reqStat2==KRequestPending);
3873 test(reqStat3==KRequestPending);
3874 test(reqStat4==KRequestPending);
3876 r=file.Create(TheFs,_L("\\F32-TST\\NOTIFY\\Munchkin.msg"),EFileRead|EFileWrite);
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
3886 fs.NotifyChangeCancel(reqStat4);
3887 User::WaitForRequest(reqStat4);
3888 test(reqStat4==KErrCancel);
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);
3896 test(reqStat==KRequestPending);
3897 test(reqStat2==KRequestPending);
3898 test(reqStat3==KRequestPending);
3899 test(reqStat4==KRequestPending);
3903 r=file.Open(TheFs,_L("\\F32-TST\\NOTIFY\\Munchkin.msg"),EFileRead|EFileWrite);
3905 test(reqStat==KRequestPending);
3906 file.SetModified(now);
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);
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);
3925 test(reqStat==KRequestPending);
3926 test(reqStat2==KRequestPending);
3927 test(reqStat3==KRequestPending);
3928 test(reqStat4==KRequestPending);
3930 r=file.Open(TheFs,_L("\\F32-TST\\NOTIFY\\Munchkin.msg"),EFileRead|EFileWrite);
3932 r=file.Write(0,_L8("Pay no attention to the man behind the curtain"));
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);
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);
3952 test(reqStat==KRequestPending);
3953 test(reqStat2==KRequestPending);
3954 test(reqStat3==KRequestPending);
3955 test(reqStat4==KRequestPending);
3957 r=TheFs.Delete(_L("\\F32-TST\\NOTIFY\\Munchkin.msg"));
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);
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()
3980 b.Format(_L("Test Manual Media change notification (socket:%d)"),gSocketNumber);
3982 TRequestStatus reqStat=0;
3985 TInt r=fs.Connect();
3988 TDriveInfo driveInfo;
3989 TInt driveNum = EDriveC + SocketToDrive[gSocketNumber];
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);
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);
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);
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);
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);
4033 #endif // __INCLUDE_MANUAL_TESTS__
4036 //---------------------------------------------
4037 //! @SYMTestCaseID PBASE-T_NOTIFY-0042
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()
4049 // Test asynchronous read notifications
4052 TRequestStatus readStat1(KRequestPending);
4053 TRequestStatus readStat2(KRequestPending);
4054 TRequestStatus thrdStat(KRequestPending);
4056 MakeFile(_L("\\F32-TST\\NOTIFY\\NewFile.Txt"));
4058 test.Next(_L("Test original behaviour of asynchronous read API"));
4060 TInt r=reader.Open(TheFs,_L("\\F32-TST\\NOTIFY\\NewFile.txt"),EFileRead|EFileShareAny);
4063 reader.Read(0, readBuf, 100, readStat1);
4064 User::WaitForRequest(readStat1);
4065 test(readStat1==KErrNone);
4066 test(readBuf.Length()==0);
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);
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);
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);
4080 reader.Read(0, readBuf, 100, readStat1);
4081 test(readStat1==KRequestPending);
4083 User::WaitForRequest(readStat1);
4084 test(readStat1==KErrCancel);
4086 test.Next(_L("Test asynchronous read can be cancelled"));
4087 r=reader.Open(TheFs,_L("\\F32-TST\\NOTIFY\\NewFile.txt"),EFileRead|EFileReadAsyncAll|EFileShareAny);
4089 reader.Read(0, readBuf, 100, readStat1);
4090 test(readStat1==KRequestPending);
4091 reader.ReadCancel(readStat1);
4092 User::WaitForRequest(readStat1);
4093 test(readStat1==KErrCancel);
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);
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);
4111 thisThread.SetPriority(EPriorityNormal);
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);
4116 reader.Read(0, readBuf, 100, readStat1);
4117 test(readStat1==KRequestPending);
4118 r = reader.SetSize(100);
4120 User::WaitForRequest(readStat1);
4121 test(readStat1==KErrNone);
4122 test(readBuf.Length() == 100);
4123 r=reader.SetSize(0);
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);
4130 reader.Read(0, readBuf, 26, readStat1);
4131 test(readStat1==KRequestPending);
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);
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);
4144 r=reader.SetSize(0);
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);
4156 r=thread.Create(_L("MyThread"),ThreadEntryPoint,KDefaultStackSize,KHeapSize,KHeapSize,(TAny*)ETest12);
4158 thread.Logon(thrdStat);
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);
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)
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);
4191 test.Next(_L("Close reader and test multiple outstanding requests are cancelled"));
4193 User::WaitForRequest(timerStat);
4195 User::WaitForRequest(readStat1);
4196 test(readStat1==KErrCancel);
4197 User::WaitForRequest(readStat2);
4198 test(readStat2==KErrCancel);
4200 User::WaitForRequest(thrdStat);
4201 test(thrdStat==KErrNone);
4205 //-----------------------------------------------------------------------
4208 Testing that TheFs.NotifyChange() works for the root directory of the drive
4210 void TestRootDirNotifyChange()
4212 test.Next(_L("Testing RFs::NotifyChange() on drive's root directory."));
4215 TRequestStatus reqStatNotify1(KRequestPending);
4217 _LIT(KTestPath, "\\"); //-- root dir, actually
4219 //-- set up notifier
4220 TheFs.NotifyChange(ENotifyAll, reqStatNotify1, KTestPath);
4221 test(reqStatNotify1.Int() == KRequestPending);
4223 //-- create a file in the root dir
4225 TFileName fileName(KTestPath);
4227 fileName.Append(_L("TestFile.tst"));
4229 nRes=file.Replace(TheFs, fileName, EFileWrite|EFileRead);
4230 test(nRes == KErrNone || nRes ==KErrAlreadyExists);
4233 //-- check that the notifier worked
4234 User::WaitForRequest(reqStatNotify1);
4235 test(reqStatNotify1.Int() == KErrNone);
4241 //-----------------------------------------------------------------------
4246 GLDEF_C void CallTestsL()
4249 CreateTestDirectory(_L("\\F32-TST\\NOTIFY\\"));
4251 // Test RFs::NotifyChange()
4252 CHECK_NO_PENDING_REQUESTS;
4254 CHECK_NO_PENDING_REQUESTS;
4256 CHECK_NO_PENDING_REQUESTS;
4258 CHECK_NO_PENDING_REQUESTS;
4260 CHECK_NO_PENDING_REQUESTS;
4262 CHECK_NO_PENDING_REQUESTS;
4264 #if defined (__EPOC32__)//we have no removable media on Emulator yet .. ??? we do now
4265 #if defined __INCLUDE_MANUAL_TESTS__
4267 // Media change notification on every socket supported
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;
4277 test.Printf(_L("Socket count: %d\n"), socketCount);
4278 TUint32 mask=~(0xffffffffu<<socketCount);
4280 for (drv=0; drv<driveCount; drv++)
4284 TInt r=d.Connect(drv,flag);
4286 //Not all the drives are used at present
4287 if (r == KErrNotSupported)
4292 if (d.IsRemovable(sockNum)>0)
4294 if (mask & (1<<sockNum))
4296 SocketToDrive[sockNum]=drv;
4297 mask &= ~(1<<sockNum);
4304 // Manual media change test
4305 for (gSocketNumber=socketCount-1; gSocketNumber>=0; gSocketNumber--)
4307 if (SocketToDrive[gSocketNumber] != -1)
4309 test.Printf(_L("Testing socket %u, drive %u...\n"),
4310 gSocketNumber, SocketToDrive[gSocketNumber]);
4317 CHECK_NO_PENDING_REQUESTS;
4319 CHECK_NO_PENDING_REQUESTS;
4322 #if defined (__EPOC32__)//we have no removable media on Emulator yet
4324 // Test RFs::NotifyChange() extended notification
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();
4333 CHECK_NO_PENDING_REQUESTS;
4335 CHECK_NO_PENDING_REQUESTS;
4337 CHECK_NO_PENDING_REQUESTS;
4339 CHECK_NO_PENDING_REQUESTS;
4341 CHECK_NO_PENDING_REQUESTS;
4343 CHECK_NO_PENDING_REQUESTS;
4345 CHECK_NO_PENDING_REQUESTS;
4347 CHECK_NO_PENDING_REQUESTS;
4349 CHECK_NO_PENDING_REQUESTS;
4351 CHECK_NO_PENDING_REQUESTS;
4353 CHECK_NO_PENDING_REQUESTS;
4355 CHECK_NO_PENDING_REQUESTS;
4357 CHECK_NO_PENDING_REQUESTS;
4359 CHECK_NO_PENDING_REQUESTS;
4360 DeleteTestDirectory();
4361 CHECK_NO_PENDING_REQUESTS;
4362 TestRootDirNotifyChange();
4363 CHECK_NO_PENDING_REQUESTS;