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 1759 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1770 FilePath foobar(data_dir.Append(FILE_PATH_LITERAL("foobar.txt"))); | 1770 FilePath foobar(data_dir.Append(FILE_PATH_LITERAL("foobar.txt"))); |
1771 std::string data("hello"); | 1771 std::string data("hello"); |
1772 ASSERT_TRUE(file_util::WriteFile(foobar, data.c_str(), data.length())); | 1772 ASSERT_TRUE(file_util::WriteFile(foobar, data.c_str(), data.length())); |
1773 | 1773 |
1774 base::Time modification_time; | 1774 base::Time modification_time; |
1775 // Note that this timestamp is divisible by two (seconds) - FAT stores | 1775 // Note that this timestamp is divisible by two (seconds) - FAT stores |
1776 // modification times with 2s resolution. | 1776 // modification times with 2s resolution. |
1777 ASSERT_TRUE(base::Time::FromString(L"Tue, 15 Nov 1994, 12:45:26 GMT", | 1777 ASSERT_TRUE(base::Time::FromString(L"Tue, 15 Nov 1994, 12:45:26 GMT", |
1778 &modification_time)); | 1778 &modification_time)); |
1779 ASSERT_TRUE(file_util::SetLastModifiedTime(foobar, modification_time)); | 1779 ASSERT_TRUE(file_util::SetLastModifiedTime(foobar, modification_time)); |
1780 file_util::FileInfo file_info; | 1780 base::PlatformFileInfo file_info; |
1781 ASSERT_TRUE(file_util::GetFileInfo(foobar, &file_info)); | 1781 ASSERT_TRUE(file_util::GetFileInfo(foobar, &file_info)); |
1782 ASSERT_TRUE(file_info.last_modified == modification_time); | 1782 ASSERT_TRUE(file_info.last_modified == modification_time); |
1783 } | 1783 } |
1784 | 1784 |
1785 TEST_F(FileUtilTest, IsDirectoryEmpty) { | 1785 TEST_F(FileUtilTest, IsDirectoryEmpty) { |
1786 FilePath empty_dir = test_dir_.Append(FILE_PATH_LITERAL("EmptyDir")); | 1786 FilePath empty_dir = test_dir_.Append(FILE_PATH_LITERAL("EmptyDir")); |
1787 | 1787 |
1788 ASSERT_FALSE(file_util::PathExists(empty_dir)); | 1788 ASSERT_FALSE(file_util::PathExists(empty_dir)); |
1789 | 1789 |
1790 ASSERT_TRUE(file_util::CreateDirectory(empty_dir)); | 1790 ASSERT_TRUE(file_util::CreateDirectory(empty_dir)); |
1791 | 1791 |
1792 EXPECT_TRUE(file_util::IsDirectoryEmpty(empty_dir)); | 1792 EXPECT_TRUE(file_util::IsDirectoryEmpty(empty_dir)); |
1793 | 1793 |
1794 FilePath foo(empty_dir.Append(FILE_PATH_LITERAL("foo.txt"))); | 1794 FilePath foo(empty_dir.Append(FILE_PATH_LITERAL("foo.txt"))); |
1795 std::string bar("baz"); | 1795 std::string bar("baz"); |
1796 ASSERT_TRUE(file_util::WriteFile(foo, bar.c_str(), bar.length())); | 1796 ASSERT_TRUE(file_util::WriteFile(foo, bar.c_str(), bar.length())); |
1797 | 1797 |
1798 EXPECT_FALSE(file_util::IsDirectoryEmpty(empty_dir)); | 1798 EXPECT_FALSE(file_util::IsDirectoryEmpty(empty_dir)); |
1799 } | 1799 } |
1800 | 1800 |
1801 } // namespace | 1801 } // namespace |
OLD | NEW |