OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "build/build_config.h" | 5 #include "build/build_config.h" |
6 | 6 |
7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <windows.h> | 8 #include <windows.h> |
9 #include <winioctl.h> | 9 #include <winioctl.h> |
10 #include <shellapi.h> | 10 #include <shellapi.h> |
(...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
685 // Test recursive case, create a new file | 685 // Test recursive case, create a new file |
686 file_name = temp_dir_.path().Append(FPL("Test DeleteFile 2.txt")); | 686 file_name = temp_dir_.path().Append(FPL("Test DeleteFile 2.txt")); |
687 CreateTextFile(file_name, bogus_content); | 687 CreateTextFile(file_name, bogus_content); |
688 ASSERT_TRUE(file_util::PathExists(file_name)); | 688 ASSERT_TRUE(file_util::PathExists(file_name)); |
689 | 689 |
690 // Make sure it's deleted | 690 // Make sure it's deleted |
691 EXPECT_TRUE(file_util::Delete(file_name, true)); | 691 EXPECT_TRUE(file_util::Delete(file_name, true)); |
692 EXPECT_FALSE(file_util::PathExists(file_name)); | 692 EXPECT_FALSE(file_util::PathExists(file_name)); |
693 } | 693 } |
694 | 694 |
695 | |
kinuko
2010/12/10 23:03:43
Do we need these two empty lines?
| |
696 | |
695 #if defined(OS_WIN) | 697 #if defined(OS_WIN) |
696 // Tests that the Delete function works for wild cards, especially | 698 // Tests that the Delete function works for wild cards, especially |
697 // with the recursion flag. Also coincidentally tests PathExists. | 699 // with the recursion flag. Also coincidentally tests PathExists. |
698 // TODO(erikkay): see if anyone's actually using this feature of the API | 700 // TODO(erikkay): see if anyone's actually using this feature of the API |
699 TEST_F(FileUtilTest, DeleteWildCard) { | 701 TEST_F(FileUtilTest, DISABLED_DeleteWildCard) { |
700 // Create a file and a directory | 702 // Create a file and a directory |
701 FilePath file_name = temp_dir_.path().Append(FPL("Test DeleteWildCard.txt")); | 703 FilePath file_name = temp_dir_.path().Append(FPL("Test DeleteWildCard.txt")); |
702 CreateTextFile(file_name, bogus_content); | 704 CreateTextFile(file_name, bogus_content); |
703 ASSERT_TRUE(file_util::PathExists(file_name)); | 705 ASSERT_TRUE(file_util::PathExists(file_name)); |
704 | 706 |
705 FilePath subdir_path = temp_dir_.path().Append(FPL("DeleteWildCardDir")); | 707 FilePath subdir_path = temp_dir_.path().Append(FPL("DeleteWildCardDir")); |
706 file_util::CreateDirectory(subdir_path); | 708 file_util::CreateDirectory(subdir_path); |
707 ASSERT_TRUE(file_util::PathExists(subdir_path)); | 709 ASSERT_TRUE(file_util::PathExists(subdir_path)); |
708 | 710 |
709 // Create the wildcard path | 711 // Create the wildcard path |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
781 ASSERT_TRUE(file_util::PathExists(test_subdir)); | 783 ASSERT_TRUE(file_util::PathExists(test_subdir)); |
782 | 784 |
783 FilePath file_name = test_subdir.Append(FPL("Test DeleteDirRecursive.txt")); | 785 FilePath file_name = test_subdir.Append(FPL("Test DeleteDirRecursive.txt")); |
784 CreateTextFile(file_name, bogus_content); | 786 CreateTextFile(file_name, bogus_content); |
785 ASSERT_TRUE(file_util::PathExists(file_name)); | 787 ASSERT_TRUE(file_util::PathExists(file_name)); |
786 | 788 |
787 FilePath subdir_path1 = test_subdir.Append(FPL("TestSubDir1")); | 789 FilePath subdir_path1 = test_subdir.Append(FPL("TestSubDir1")); |
788 file_util::CreateDirectory(subdir_path1); | 790 file_util::CreateDirectory(subdir_path1); |
789 ASSERT_TRUE(file_util::PathExists(subdir_path1)); | 791 ASSERT_TRUE(file_util::PathExists(subdir_path1)); |
790 | 792 |
793 FilePath sub_subdir_path1 = subdir_path1.Append(FPL("TestSubSubDir1")); | |
794 file_util::CreateDirectory(sub_subdir_path1); | |
795 ASSERT_TRUE(file_util::PathExists(sub_subdir_path1)); | |
796 | |
797 FilePath subdir_file_name = | |
798 sub_subdir_path1.Append(FPL("DeleteDirRecursiveSubDir.txt")); | |
799 CreateTextFile(subdir_file_name, bogus_content); | |
800 ASSERT_TRUE(file_util::PathExists(subdir_file_name)); | |
801 | |
791 FilePath subdir_path2 = test_subdir.Append(FPL("TestSubDir2")); | 802 FilePath subdir_path2 = test_subdir.Append(FPL("TestSubDir2")); |
792 file_util::CreateDirectory(subdir_path2); | 803 file_util::CreateDirectory(subdir_path2); |
793 ASSERT_TRUE(file_util::PathExists(subdir_path2)); | 804 ASSERT_TRUE(file_util::PathExists(subdir_path2)); |
794 | 805 |
795 // Delete recursively and check that the empty dir got deleted | 806 // Delete recursively and check that the empty dir got deleted |
796 EXPECT_TRUE(file_util::Delete(subdir_path2, true)); | 807 EXPECT_TRUE(file_util::Delete(subdir_path2, true)); |
797 EXPECT_FALSE(file_util::PathExists(subdir_path2)); | 808 EXPECT_FALSE(file_util::PathExists(subdir_path2)); |
798 | 809 |
799 // Delete recursively and check that everything got deleted | 810 // Delete recursively and check that everything got deleted |
800 EXPECT_TRUE(file_util::Delete(test_subdir, true)); | 811 EXPECT_TRUE(file_util::Delete(test_subdir, true)); |
(...skipping 1026 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1827 EXPECT_TRUE(file_util::IsDirectoryEmpty(empty_dir)); | 1838 EXPECT_TRUE(file_util::IsDirectoryEmpty(empty_dir)); |
1828 | 1839 |
1829 FilePath foo(empty_dir.Append(FILE_PATH_LITERAL("foo.txt"))); | 1840 FilePath foo(empty_dir.Append(FILE_PATH_LITERAL("foo.txt"))); |
1830 std::string bar("baz"); | 1841 std::string bar("baz"); |
1831 ASSERT_TRUE(file_util::WriteFile(foo, bar.c_str(), bar.length())); | 1842 ASSERT_TRUE(file_util::WriteFile(foo, bar.c_str(), bar.length())); |
1832 | 1843 |
1833 EXPECT_FALSE(file_util::IsDirectoryEmpty(empty_dir)); | 1844 EXPECT_FALSE(file_util::IsDirectoryEmpty(empty_dir)); |
1834 } | 1845 } |
1835 | 1846 |
1836 } // namespace | 1847 } // namespace |
OLD | NEW |