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

Unified Diff: base/file_util_unittest.cc

Issue 3404018: Add a TouchFile function that operates on FilePaths + fixing a bug... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/file_util_posix.cc ('k') | base/file_util_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/file_util_unittest.cc
===================================================================
--- base/file_util_unittest.cc (revision 60236)
+++ base/file_util_unittest.cc (working copy)
@@ -1753,7 +1753,7 @@
#endif
}
-TEST_F(FileUtilTest, LastModified) {
+TEST_F(FileUtilTest, TouchFile) {
FilePath data_dir =
temp_dir_.path().Append(FILE_PATH_LITERAL("FilePathTest"));
@@ -1767,15 +1767,25 @@
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) {
« no previous file with comments | « base/file_util_posix.cc ('k') | base/file_util_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698