summaryrefslogtreecommitdiffstats
path: root/base/file_util_unittest.cc
diff options
context:
space:
mode:
authordumi@chromium.org <dumi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-23 19:13:40 +0000
committerdumi@chromium.org <dumi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-23 19:13:40 +0000
commitb82ff7e8291ac0e4cb4235b2ca27c141549974f3 (patch)
tree998e8b7eaf336996b4ff1be50e5f9784bb283059 /base/file_util_unittest.cc
parent64559868446e51a2c16819608f5923f609dc027c (diff)
downloadchromium_src-b82ff7e8291ac0e4cb4235b2ca27c141549974f3.zip
chromium_src-b82ff7e8291ac0e4cb4235b2ca27c141549974f3.tar.gz
chromium_src-b82ff7e8291ac0e4cb4235b2ca27c141549974f3.tar.bz2
Add a TouchFile function that operates on FilePaths + fixing a bug
related to FILE_WRITE_ATTRIBUTES on Windows. BUG=none TEST=FileUtilTest::TouchFile Review URL: http://codereview.chromium.org/3404018 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@60322 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/file_util_unittest.cc')
-rw-r--r--base/file_util_unittest.cc16
1 files changed, 13 insertions, 3 deletions
diff --git a/base/file_util_unittest.cc b/base/file_util_unittest.cc
index 068e5e50..ca36b6a 100644
--- a/base/file_util_unittest.cc
+++ b/base/file_util_unittest.cc
@@ -1753,7 +1753,7 @@ TEST_F(FileUtilTest, Contains) {
#endif
}
-TEST_F(FileUtilTest, LastModified) {
+TEST_F(FileUtilTest, TouchFile) {
FilePath data_dir =
temp_dir_.path().Append(FILE_PATH_LITERAL("FilePathTest"));
@@ -1767,15 +1767,25 @@ TEST_F(FileUtilTest, LastModified) {
std::string data("hello");
ASSERT_TRUE(file_util::WriteFile(foobar, data.c_str(), data.length()));
+ base::Time access_time;
+ // This timestamp is divisible by one day (in local timezone),
+ // to make it work on FAT too.
+ ASSERT_TRUE(base::Time::FromString(L"Wed, 16 Nov 1994, 00:00:00",
+ &access_time));
+
base::Time modification_time;
// Note that this timestamp is divisible by two (seconds) - FAT stores
// modification times with 2s resolution.
ASSERT_TRUE(base::Time::FromString(L"Tue, 15 Nov 1994, 12:45:26 GMT",
&modification_time));
- ASSERT_TRUE(file_util::SetLastModifiedTime(foobar, modification_time));
+
+ ASSERT_TRUE(file_util::TouchFile(foobar, access_time, modification_time));
base::PlatformFileInfo file_info;
ASSERT_TRUE(file_util::GetFileInfo(foobar, &file_info));
- ASSERT_TRUE(file_info.last_modified == modification_time);
+ EXPECT_EQ(file_info.last_accessed.ToInternalValue(),
+ access_time.ToInternalValue());
+ EXPECT_EQ(file_info.last_modified.ToInternalValue(),
+ modification_time.ToInternalValue());
}
TEST_F(FileUtilTest, IsDirectoryEmpty) {