Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1115)

Side by Side Diff: base/files/file_path_watcher_browsertest.cc

Issue 18584011: Rename base::Delete to base::DeleteFile (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/file_util_win.cc ('k') | base/files/file_util_proxy.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/files/file_path_watcher.h" 5 #include "base/files/file_path_watcher.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <windows.h> 8 #include <windows.h>
9 #include <aclapi.h> 9 #include <aclapi.h>
10 #elif defined(OS_POSIX) 10 #elif defined(OS_POSIX)
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 } 267 }
268 268
269 TEST_F(FilePathWatcherTest, DeletedFile) { 269 TEST_F(FilePathWatcherTest, DeletedFile) {
270 ASSERT_TRUE(WriteFile(test_file(), "content")); 270 ASSERT_TRUE(WriteFile(test_file(), "content"));
271 271
272 FilePathWatcher watcher; 272 FilePathWatcher watcher;
273 scoped_ptr<TestDelegate> delegate(new TestDelegate(collector())); 273 scoped_ptr<TestDelegate> delegate(new TestDelegate(collector()));
274 ASSERT_TRUE(SetupWatch(test_file(), &watcher, delegate.get(), false)); 274 ASSERT_TRUE(SetupWatch(test_file(), &watcher, delegate.get(), false));
275 275
276 // Now make sure we get notified if the file is deleted. 276 // Now make sure we get notified if the file is deleted.
277 base::Delete(test_file(), false); 277 base::DeleteFile(test_file(), false);
278 ASSERT_TRUE(WaitForEvents()); 278 ASSERT_TRUE(WaitForEvents());
279 DeleteDelegateOnFileThread(delegate.release()); 279 DeleteDelegateOnFileThread(delegate.release());
280 } 280 }
281 281
282 // Used by the DeleteDuringNotify test below. 282 // Used by the DeleteDuringNotify test below.
283 // Deletes the FilePathWatcher when it's notified. 283 // Deletes the FilePathWatcher when it's notified.
284 class Deleter : public TestDelegateBase { 284 class Deleter : public TestDelegateBase {
285 public: 285 public:
286 Deleter(FilePathWatcher* watcher, MessageLoop* loop) 286 Deleter(FilePathWatcher* watcher, MessageLoop* loop)
287 : watcher_(watcher), 287 : watcher_(watcher),
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 356
357 ASSERT_TRUE(WriteFile(file, "content")); 357 ASSERT_TRUE(WriteFile(file, "content"));
358 358
359 VLOG(1) << "Waiting for file creation"; 359 VLOG(1) << "Waiting for file creation";
360 ASSERT_TRUE(WaitForEvents()); 360 ASSERT_TRUE(WaitForEvents());
361 361
362 ASSERT_TRUE(WriteFile(file, "content v2")); 362 ASSERT_TRUE(WriteFile(file, "content v2"));
363 VLOG(1) << "Waiting for file change"; 363 VLOG(1) << "Waiting for file change";
364 ASSERT_TRUE(WaitForEvents()); 364 ASSERT_TRUE(WaitForEvents());
365 365
366 ASSERT_TRUE(base::Delete(file, false)); 366 ASSERT_TRUE(base::DeleteFile(file, false));
367 VLOG(1) << "Waiting for file deletion"; 367 VLOG(1) << "Waiting for file deletion";
368 ASSERT_TRUE(WaitForEvents()); 368 ASSERT_TRUE(WaitForEvents());
369 DeleteDelegateOnFileThread(delegate.release()); 369 DeleteDelegateOnFileThread(delegate.release());
370 } 370 }
371 371
372 // Exercises watch reconfiguration for the case that directories on the path 372 // Exercises watch reconfiguration for the case that directories on the path
373 // are rapidly created. 373 // are rapidly created.
374 TEST_F(FilePathWatcherTest, DirectoryChain) { 374 TEST_F(FilePathWatcherTest, DirectoryChain) {
375 FilePath path(temp_dir_.path()); 375 FilePath path(temp_dir_.path());
376 std::vector<std::string> dir_names; 376 std::vector<std::string> dir_names;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 #endif 408 #endif
409 TEST_F(FilePathWatcherTest, DisappearingDirectory) { 409 TEST_F(FilePathWatcherTest, DisappearingDirectory) {
410 FilePathWatcher watcher; 410 FilePathWatcher watcher;
411 FilePath dir(temp_dir_.path().AppendASCII("dir")); 411 FilePath dir(temp_dir_.path().AppendASCII("dir"));
412 FilePath file(dir.AppendASCII("file")); 412 FilePath file(dir.AppendASCII("file"));
413 ASSERT_TRUE(file_util::CreateDirectory(dir)); 413 ASSERT_TRUE(file_util::CreateDirectory(dir));
414 ASSERT_TRUE(WriteFile(file, "content")); 414 ASSERT_TRUE(WriteFile(file, "content"));
415 scoped_ptr<TestDelegate> delegate(new TestDelegate(collector())); 415 scoped_ptr<TestDelegate> delegate(new TestDelegate(collector()));
416 ASSERT_TRUE(SetupWatch(file, &watcher, delegate.get(), false)); 416 ASSERT_TRUE(SetupWatch(file, &watcher, delegate.get(), false));
417 417
418 ASSERT_TRUE(base::Delete(dir, true)); 418 ASSERT_TRUE(base::DeleteFile(dir, true));
419 ASSERT_TRUE(WaitForEvents()); 419 ASSERT_TRUE(WaitForEvents());
420 DeleteDelegateOnFileThread(delegate.release()); 420 DeleteDelegateOnFileThread(delegate.release());
421 } 421 }
422 422
423 // Tests that a file that is deleted and reappears is tracked correctly. 423 // Tests that a file that is deleted and reappears is tracked correctly.
424 TEST_F(FilePathWatcherTest, DeleteAndRecreate) { 424 TEST_F(FilePathWatcherTest, DeleteAndRecreate) {
425 ASSERT_TRUE(WriteFile(test_file(), "content")); 425 ASSERT_TRUE(WriteFile(test_file(), "content"));
426 FilePathWatcher watcher; 426 FilePathWatcher watcher;
427 scoped_ptr<TestDelegate> delegate(new TestDelegate(collector())); 427 scoped_ptr<TestDelegate> delegate(new TestDelegate(collector()));
428 ASSERT_TRUE(SetupWatch(test_file(), &watcher, delegate.get(), false)); 428 ASSERT_TRUE(SetupWatch(test_file(), &watcher, delegate.get(), false));
429 429
430 ASSERT_TRUE(base::Delete(test_file(), false)); 430 ASSERT_TRUE(base::DeleteFile(test_file(), false));
431 VLOG(1) << "Waiting for file deletion"; 431 VLOG(1) << "Waiting for file deletion";
432 ASSERT_TRUE(WaitForEvents()); 432 ASSERT_TRUE(WaitForEvents());
433 433
434 ASSERT_TRUE(WriteFile(test_file(), "content")); 434 ASSERT_TRUE(WriteFile(test_file(), "content"));
435 VLOG(1) << "Waiting for file creation"; 435 VLOG(1) << "Waiting for file creation";
436 ASSERT_TRUE(WaitForEvents()); 436 ASSERT_TRUE(WaitForEvents());
437 DeleteDelegateOnFileThread(delegate.release()); 437 DeleteDelegateOnFileThread(delegate.release());
438 } 438 }
439 439
440 TEST_F(FilePathWatcherTest, WatchDirectory) { 440 TEST_F(FilePathWatcherTest, WatchDirectory) {
(...skipping 12 matching lines...) Expand all
453 VLOG(1) << "Waiting for file1 creation"; 453 VLOG(1) << "Waiting for file1 creation";
454 ASSERT_TRUE(WaitForEvents()); 454 ASSERT_TRUE(WaitForEvents());
455 455
456 #if !defined(OS_MACOSX) 456 #if !defined(OS_MACOSX)
457 // Mac implementation does not detect files modified in a directory. 457 // Mac implementation does not detect files modified in a directory.
458 ASSERT_TRUE(WriteFile(file1, "content v2")); 458 ASSERT_TRUE(WriteFile(file1, "content v2"));
459 VLOG(1) << "Waiting for file1 modification"; 459 VLOG(1) << "Waiting for file1 modification";
460 ASSERT_TRUE(WaitForEvents()); 460 ASSERT_TRUE(WaitForEvents());
461 #endif // !OS_MACOSX 461 #endif // !OS_MACOSX
462 462
463 ASSERT_TRUE(base::Delete(file1, false)); 463 ASSERT_TRUE(base::DeleteFile(file1, false));
464 VLOG(1) << "Waiting for file1 deletion"; 464 VLOG(1) << "Waiting for file1 deletion";
465 ASSERT_TRUE(WaitForEvents()); 465 ASSERT_TRUE(WaitForEvents());
466 466
467 ASSERT_TRUE(WriteFile(file2, "content")); 467 ASSERT_TRUE(WriteFile(file2, "content"));
468 VLOG(1) << "Waiting for file2 creation"; 468 VLOG(1) << "Waiting for file2 creation";
469 ASSERT_TRUE(WaitForEvents()); 469 ASSERT_TRUE(WaitForEvents());
470 DeleteDelegateOnFileThread(delegate.release()); 470 DeleteDelegateOnFileThread(delegate.release());
471 } 471 }
472 472
473 TEST_F(FilePathWatcherTest, MoveParent) { 473 TEST_F(FilePathWatcherTest, MoveParent) {
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 535
536 // Write into "$dir/subdir/subdir_child_dir/child_dir_file1". 536 // Write into "$dir/subdir/subdir_child_dir/child_dir_file1".
537 ASSERT_TRUE(WriteFile(child_dir_file1, "content")); 537 ASSERT_TRUE(WriteFile(child_dir_file1, "content"));
538 ASSERT_TRUE(WaitForEvents()); 538 ASSERT_TRUE(WaitForEvents());
539 539
540 // Modify "$dir/subdir/subdir_child_dir/child_dir_file1" attributes. 540 // Modify "$dir/subdir/subdir_child_dir/child_dir_file1" attributes.
541 ASSERT_TRUE(file_util::MakeFileUnreadable(child_dir_file1)); 541 ASSERT_TRUE(file_util::MakeFileUnreadable(child_dir_file1));
542 ASSERT_TRUE(WaitForEvents()); 542 ASSERT_TRUE(WaitForEvents());
543 543
544 // Delete "$dir/subdir/subdir_file1". 544 // Delete "$dir/subdir/subdir_file1".
545 ASSERT_TRUE(base::Delete(subdir_file1, false)); 545 ASSERT_TRUE(base::DeleteFile(subdir_file1, false));
546 ASSERT_TRUE(WaitForEvents()); 546 ASSERT_TRUE(WaitForEvents());
547 547
548 // Delete "$dir/subdir/subdir_child_dir/child_dir_file1". 548 // Delete "$dir/subdir/subdir_child_dir/child_dir_file1".
549 ASSERT_TRUE(base::Delete(child_dir_file1, false)); 549 ASSERT_TRUE(base::DeleteFile(child_dir_file1, false));
550 ASSERT_TRUE(WaitForEvents()); 550 ASSERT_TRUE(WaitForEvents());
551 DeleteDelegateOnFileThread(delegate.release()); 551 DeleteDelegateOnFileThread(delegate.release());
552 } 552 }
553 #else 553 #else
554 TEST_F(FilePathWatcherTest, RecursiveWatch) { 554 TEST_F(FilePathWatcherTest, RecursiveWatch) {
555 FilePathWatcher watcher; 555 FilePathWatcher watcher;
556 FilePath dir(temp_dir_.path().AppendASCII("dir")); 556 FilePath dir(temp_dir_.path().AppendASCII("dir"));
557 scoped_ptr<TestDelegate> delegate(new TestDelegate(collector())); 557 scoped_ptr<TestDelegate> delegate(new TestDelegate(collector()));
558 // Non-Windows implementaion does not support recursive watching. 558 // Non-Windows implementaion does not support recursive watching.
559 ASSERT_FALSE(SetupWatch(dir, &watcher, delegate.get(), true)); 559 ASSERT_FALSE(SetupWatch(dir, &watcher, delegate.get(), true));
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 TEST_F(FilePathWatcherTest, DeleteLink) { 627 TEST_F(FilePathWatcherTest, DeleteLink) {
628 // Unfortunately this test case only works if the link target exists. 628 // Unfortunately this test case only works if the link target exists.
629 // TODO(craig) fix this as part of crbug.com/91561. 629 // TODO(craig) fix this as part of crbug.com/91561.
630 ASSERT_TRUE(WriteFile(test_file(), "content")); 630 ASSERT_TRUE(WriteFile(test_file(), "content"));
631 ASSERT_TRUE(file_util::CreateSymbolicLink(test_file(), test_link())); 631 ASSERT_TRUE(file_util::CreateSymbolicLink(test_file(), test_link()));
632 FilePathWatcher watcher; 632 FilePathWatcher watcher;
633 scoped_ptr<TestDelegate> delegate(new TestDelegate(collector())); 633 scoped_ptr<TestDelegate> delegate(new TestDelegate(collector()));
634 ASSERT_TRUE(SetupWatch(test_link(), &watcher, delegate.get(), false)); 634 ASSERT_TRUE(SetupWatch(test_link(), &watcher, delegate.get(), false));
635 635
636 // Now make sure we get notified if the link is deleted. 636 // Now make sure we get notified if the link is deleted.
637 ASSERT_TRUE(base::Delete(test_link(), false)); 637 ASSERT_TRUE(base::DeleteFile(test_link(), false));
638 ASSERT_TRUE(WaitForEvents()); 638 ASSERT_TRUE(WaitForEvents());
639 DeleteDelegateOnFileThread(delegate.release()); 639 DeleteDelegateOnFileThread(delegate.release());
640 } 640 }
641 641
642 // Verify that modifying a target file that a link is pointing to 642 // Verify that modifying a target file that a link is pointing to
643 // when we are watching the link is caught. 643 // when we are watching the link is caught.
644 TEST_F(FilePathWatcherTest, ModifiedLinkedFile) { 644 TEST_F(FilePathWatcherTest, ModifiedLinkedFile) {
645 ASSERT_TRUE(WriteFile(test_file(), "content")); 645 ASSERT_TRUE(WriteFile(test_file(), "content"));
646 ASSERT_TRUE(file_util::CreateSymbolicLink(test_file(), test_link())); 646 ASSERT_TRUE(file_util::CreateSymbolicLink(test_file(), test_link()));
647 FilePathWatcher watcher; 647 FilePathWatcher watcher;
(...skipping 26 matching lines...) Expand all
674 // when we are watching the link is caught. 674 // when we are watching the link is caught.
675 TEST_F(FilePathWatcherTest, DeleteTargetLinkedFile) { 675 TEST_F(FilePathWatcherTest, DeleteTargetLinkedFile) {
676 ASSERT_TRUE(WriteFile(test_file(), "content")); 676 ASSERT_TRUE(WriteFile(test_file(), "content"));
677 ASSERT_TRUE(file_util::CreateSymbolicLink(test_file(), test_link())); 677 ASSERT_TRUE(file_util::CreateSymbolicLink(test_file(), test_link()));
678 FilePathWatcher watcher; 678 FilePathWatcher watcher;
679 scoped_ptr<TestDelegate> delegate(new TestDelegate(collector())); 679 scoped_ptr<TestDelegate> delegate(new TestDelegate(collector()));
680 // Note that we are watching the symlink. 680 // Note that we are watching the symlink.
681 ASSERT_TRUE(SetupWatch(test_link(), &watcher, delegate.get(), false)); 681 ASSERT_TRUE(SetupWatch(test_link(), &watcher, delegate.get(), false));
682 682
683 // Now make sure we get notified if the target file is deleted. 683 // Now make sure we get notified if the target file is deleted.
684 ASSERT_TRUE(base::Delete(test_file(), false)); 684 ASSERT_TRUE(base::DeleteFile(test_file(), false));
685 ASSERT_TRUE(WaitForEvents()); 685 ASSERT_TRUE(WaitForEvents());
686 DeleteDelegateOnFileThread(delegate.release()); 686 DeleteDelegateOnFileThread(delegate.release());
687 } 687 }
688 688
689 // Verify that watching a file whose parent directory is a link that 689 // Verify that watching a file whose parent directory is a link that
690 // doesn't exist yet works if the symlink is created eventually. 690 // doesn't exist yet works if the symlink is created eventually.
691 TEST_F(FilePathWatcherTest, LinkedDirectoryPart1) { 691 TEST_F(FilePathWatcherTest, LinkedDirectoryPart1) {
692 FilePathWatcher watcher; 692 FilePathWatcher watcher;
693 FilePath dir(temp_dir_.path().AppendASCII("dir")); 693 FilePath dir(temp_dir_.path().AppendASCII("dir"));
694 FilePath link_dir(temp_dir_.path().AppendASCII("dir.lnk")); 694 FilePath link_dir(temp_dir_.path().AppendASCII("dir.lnk"));
695 FilePath file(dir.AppendASCII("file")); 695 FilePath file(dir.AppendASCII("file"));
696 FilePath linkfile(link_dir.AppendASCII("file")); 696 FilePath linkfile(link_dir.AppendASCII("file"));
697 scoped_ptr<TestDelegate> delegate(new TestDelegate(collector())); 697 scoped_ptr<TestDelegate> delegate(new TestDelegate(collector()));
698 // dir/file should exist. 698 // dir/file should exist.
699 ASSERT_TRUE(file_util::CreateDirectory(dir)); 699 ASSERT_TRUE(file_util::CreateDirectory(dir));
700 ASSERT_TRUE(WriteFile(file, "content")); 700 ASSERT_TRUE(WriteFile(file, "content"));
701 // Note that we are watching dir.lnk/file which doesn't exist yet. 701 // Note that we are watching dir.lnk/file which doesn't exist yet.
702 ASSERT_TRUE(SetupWatch(linkfile, &watcher, delegate.get(), false)); 702 ASSERT_TRUE(SetupWatch(linkfile, &watcher, delegate.get(), false));
703 703
704 ASSERT_TRUE(file_util::CreateSymbolicLink(dir, link_dir)); 704 ASSERT_TRUE(file_util::CreateSymbolicLink(dir, link_dir));
705 VLOG(1) << "Waiting for link creation"; 705 VLOG(1) << "Waiting for link creation";
706 ASSERT_TRUE(WaitForEvents()); 706 ASSERT_TRUE(WaitForEvents());
707 707
708 ASSERT_TRUE(WriteFile(file, "content v2")); 708 ASSERT_TRUE(WriteFile(file, "content v2"));
709 VLOG(1) << "Waiting for file change"; 709 VLOG(1) << "Waiting for file change";
710 ASSERT_TRUE(WaitForEvents()); 710 ASSERT_TRUE(WaitForEvents());
711 711
712 ASSERT_TRUE(base::Delete(file, false)); 712 ASSERT_TRUE(base::DeleteFile(file, false));
713 VLOG(1) << "Waiting for file deletion"; 713 VLOG(1) << "Waiting for file deletion";
714 ASSERT_TRUE(WaitForEvents()); 714 ASSERT_TRUE(WaitForEvents());
715 DeleteDelegateOnFileThread(delegate.release()); 715 DeleteDelegateOnFileThread(delegate.release());
716 } 716 }
717 717
718 // Verify that watching a file whose parent directory is a 718 // Verify that watching a file whose parent directory is a
719 // dangling symlink works if the directory is created eventually. 719 // dangling symlink works if the directory is created eventually.
720 TEST_F(FilePathWatcherTest, LinkedDirectoryPart2) { 720 TEST_F(FilePathWatcherTest, LinkedDirectoryPart2) {
721 FilePathWatcher watcher; 721 FilePathWatcher watcher;
722 FilePath dir(temp_dir_.path().AppendASCII("dir")); 722 FilePath dir(temp_dir_.path().AppendASCII("dir"));
723 FilePath link_dir(temp_dir_.path().AppendASCII("dir.lnk")); 723 FilePath link_dir(temp_dir_.path().AppendASCII("dir.lnk"));
724 FilePath file(dir.AppendASCII("file")); 724 FilePath file(dir.AppendASCII("file"));
725 FilePath linkfile(link_dir.AppendASCII("file")); 725 FilePath linkfile(link_dir.AppendASCII("file"));
726 scoped_ptr<TestDelegate> delegate(new TestDelegate(collector())); 726 scoped_ptr<TestDelegate> delegate(new TestDelegate(collector()));
727 // Now create the link from dir.lnk pointing to dir but 727 // Now create the link from dir.lnk pointing to dir but
728 // neither dir nor dir/file exist yet. 728 // neither dir nor dir/file exist yet.
729 ASSERT_TRUE(file_util::CreateSymbolicLink(dir, link_dir)); 729 ASSERT_TRUE(file_util::CreateSymbolicLink(dir, link_dir));
730 // Note that we are watching dir.lnk/file. 730 // Note that we are watching dir.lnk/file.
731 ASSERT_TRUE(SetupWatch(linkfile, &watcher, delegate.get(), false)); 731 ASSERT_TRUE(SetupWatch(linkfile, &watcher, delegate.get(), false));
732 732
733 ASSERT_TRUE(file_util::CreateDirectory(dir)); 733 ASSERT_TRUE(file_util::CreateDirectory(dir));
734 ASSERT_TRUE(WriteFile(file, "content")); 734 ASSERT_TRUE(WriteFile(file, "content"));
735 VLOG(1) << "Waiting for dir/file creation"; 735 VLOG(1) << "Waiting for dir/file creation";
736 ASSERT_TRUE(WaitForEvents()); 736 ASSERT_TRUE(WaitForEvents());
737 737
738 ASSERT_TRUE(WriteFile(file, "content v2")); 738 ASSERT_TRUE(WriteFile(file, "content v2"));
739 VLOG(1) << "Waiting for file change"; 739 VLOG(1) << "Waiting for file change";
740 ASSERT_TRUE(WaitForEvents()); 740 ASSERT_TRUE(WaitForEvents());
741 741
742 ASSERT_TRUE(base::Delete(file, false)); 742 ASSERT_TRUE(base::DeleteFile(file, false));
743 VLOG(1) << "Waiting for file deletion"; 743 VLOG(1) << "Waiting for file deletion";
744 ASSERT_TRUE(WaitForEvents()); 744 ASSERT_TRUE(WaitForEvents());
745 DeleteDelegateOnFileThread(delegate.release()); 745 DeleteDelegateOnFileThread(delegate.release());
746 } 746 }
747 747
748 // Verify that watching a file with a symlink on the path 748 // Verify that watching a file with a symlink on the path
749 // to the file works. 749 // to the file works.
750 TEST_F(FilePathWatcherTest, LinkedDirectoryPart3) { 750 TEST_F(FilePathWatcherTest, LinkedDirectoryPart3) {
751 FilePathWatcher watcher; 751 FilePathWatcher watcher;
752 FilePath dir(temp_dir_.path().AppendASCII("dir")); 752 FilePath dir(temp_dir_.path().AppendASCII("dir"));
753 FilePath link_dir(temp_dir_.path().AppendASCII("dir.lnk")); 753 FilePath link_dir(temp_dir_.path().AppendASCII("dir.lnk"));
754 FilePath file(dir.AppendASCII("file")); 754 FilePath file(dir.AppendASCII("file"));
755 FilePath linkfile(link_dir.AppendASCII("file")); 755 FilePath linkfile(link_dir.AppendASCII("file"));
756 scoped_ptr<TestDelegate> delegate(new TestDelegate(collector())); 756 scoped_ptr<TestDelegate> delegate(new TestDelegate(collector()));
757 ASSERT_TRUE(file_util::CreateDirectory(dir)); 757 ASSERT_TRUE(file_util::CreateDirectory(dir));
758 ASSERT_TRUE(file_util::CreateSymbolicLink(dir, link_dir)); 758 ASSERT_TRUE(file_util::CreateSymbolicLink(dir, link_dir));
759 // Note that we are watching dir.lnk/file but the file doesn't exist yet. 759 // Note that we are watching dir.lnk/file but the file doesn't exist yet.
760 ASSERT_TRUE(SetupWatch(linkfile, &watcher, delegate.get(), false)); 760 ASSERT_TRUE(SetupWatch(linkfile, &watcher, delegate.get(), false));
761 761
762 ASSERT_TRUE(WriteFile(file, "content")); 762 ASSERT_TRUE(WriteFile(file, "content"));
763 VLOG(1) << "Waiting for file creation"; 763 VLOG(1) << "Waiting for file creation";
764 ASSERT_TRUE(WaitForEvents()); 764 ASSERT_TRUE(WaitForEvents());
765 765
766 ASSERT_TRUE(WriteFile(file, "content v2")); 766 ASSERT_TRUE(WriteFile(file, "content v2"));
767 VLOG(1) << "Waiting for file change"; 767 VLOG(1) << "Waiting for file change";
768 ASSERT_TRUE(WaitForEvents()); 768 ASSERT_TRUE(WaitForEvents());
769 769
770 ASSERT_TRUE(base::Delete(file, false)); 770 ASSERT_TRUE(base::DeleteFile(file, false));
771 VLOG(1) << "Waiting for file deletion"; 771 VLOG(1) << "Waiting for file deletion";
772 ASSERT_TRUE(WaitForEvents()); 772 ASSERT_TRUE(WaitForEvents());
773 DeleteDelegateOnFileThread(delegate.release()); 773 DeleteDelegateOnFileThread(delegate.release());
774 } 774 }
775 775
776 #endif // OS_LINUX 776 #endif // OS_LINUX
777 777
778 enum Permission { 778 enum Permission {
779 Read, 779 Read,
780 Write, 780 Write,
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
900 ASSERT_TRUE(ChangeFilePermissions(test_dir1, Execute, false)); 900 ASSERT_TRUE(ChangeFilePermissions(test_dir1, Execute, false));
901 ASSERT_TRUE(WaitForEvents()); 901 ASSERT_TRUE(WaitForEvents());
902 ASSERT_TRUE(ChangeFilePermissions(test_dir1, Execute, true)); 902 ASSERT_TRUE(ChangeFilePermissions(test_dir1, Execute, true));
903 DeleteDelegateOnFileThread(delegate.release()); 903 DeleteDelegateOnFileThread(delegate.release());
904 } 904 }
905 905
906 #endif // OS_MACOSX 906 #endif // OS_MACOSX
907 } // namespace 907 } // namespace
908 908
909 } // namespace base 909 } // namespace base
OLDNEW
« no previous file with comments | « base/file_util_win.cc ('k') | base/files/file_util_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698