OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 1795 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1806 | 1806 |
1807 EXPECT_TRUE(file_util::IsDirectoryEmpty(empty_dir)); | 1807 EXPECT_TRUE(file_util::IsDirectoryEmpty(empty_dir)); |
1808 | 1808 |
1809 FilePath foo(empty_dir.Append(FILE_PATH_LITERAL("foo.txt"))); | 1809 FilePath foo(empty_dir.Append(FILE_PATH_LITERAL("foo.txt"))); |
1810 std::string bar("baz"); | 1810 std::string bar("baz"); |
1811 ASSERT_TRUE(file_util::WriteFile(foo, bar.c_str(), bar.length())); | 1811 ASSERT_TRUE(file_util::WriteFile(foo, bar.c_str(), bar.length())); |
1812 | 1812 |
1813 EXPECT_FALSE(file_util::IsDirectoryEmpty(empty_dir)); | 1813 EXPECT_FALSE(file_util::IsDirectoryEmpty(empty_dir)); |
1814 } | 1814 } |
1815 | 1815 |
1816 TEST_F(FileUtilTest, AreReferringToSameObject) { | |
1817 FilePath dir1 = temp_dir_.path().Append(FILE_PATH_LITERAL("Directory")); | |
1818 FilePath dir2 = temp_dir_.path().Append(FILE_PATH_LITERAL("Directory")); | |
1819 ASSERT_FALSE(file_util::PathExists(dir1)); | |
1820 ASSERT_TRUE(file_util::CreateDirectory(dir1)); | |
1821 ASSERT_TRUE(file_util::AreReferringToSameObject(dir1, dir2)); | |
1822 ASSERT_FALSE(file_util::AreReferringToSameObject(temp_dir_.path(), dir2)); | |
1823 | |
1824 #if defined(OS_POSIX) | |
1825 FilePath sym = temp_dir_.path().Append(FILE_PATH_LITERAL("Symlink")); | |
1826 ASSERT_FALSE(file_util::AreReferringToSameObject(dir1, sym)); | |
1827 ASSERT_TRUE(file_util::CreateSymbolicLink(dir1, sym)); | |
1828 ASSERT_TRUE(file_util::AreReferringToSameObject(dir1, sym)); | |
1829 #endif // OS_POSIX | |
1830 } | |
1831 | |
1832 #if defined(OS_MACOSX) | |
1833 TEST_F(FileUtilTest, Trash) { | |
1834 FilePath to_trash = temp_dir_.path().Append(FILE_PATH_LITERAL("TrashFile")); | |
1835 ASSERT_FALSE(file_util::PathExists(to_trash)); | |
1836 std::string bar("baz"); | |
1837 ASSERT_TRUE(file_util::WriteFile(to_trash, bar.c_str(), bar.length())); | |
1838 ASSERT_TRUE(file_util::PathExists(to_trash)); | |
1839 ASSERT_FALSE(file_util::IsInTrash(to_trash)); | |
1840 | |
1841 FilePath trashed; | |
1842 ASSERT_TRUE(file_util::MoveToTrash(to_trash, &trashed)); | |
1843 ASSERT_TRUE(file_util::IsInTrash(trashed)); | |
1844 ASSERT_FALSE(file_util::IsInTrash(to_trash)); | |
1845 ASSERT_FALSE(file_util::PathExists(to_trash)); | |
1846 ASSERT_FALSE(file_util::MoveToTrash(to_trash, &trashed)); | |
1847 } | |
Mark Mentovai
2011/03/11 20:13:52
Don’t leave it in the trash. Delete it.
| |
1848 #endif // OS_MACOSX | |
1849 | |
1816 } // namespace | 1850 } // namespace |
OLD | NEW |