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

Side by Side Diff: base/file_util_unittest.cc

Issue 100453006: Move Touch to base namespace, remove SetLastModifiedTime. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <shellapi.h> 9 #include <shellapi.h>
10 #include <shlobj.h> 10 #include <shlobj.h>
(...skipping 1875 matching lines...) Expand 10 before | Expand all | Expand 10 after
1886 } 1886 }
1887 1887
1888 TEST_F(FileUtilTest, TouchFile) { 1888 TEST_F(FileUtilTest, TouchFile) {
1889 FilePath data_dir = 1889 FilePath data_dir =
1890 temp_dir_.path().Append(FILE_PATH_LITERAL("FilePathTest")); 1890 temp_dir_.path().Append(FILE_PATH_LITERAL("FilePathTest"));
1891 1891
1892 // Create a fresh, empty copy of this directory. 1892 // Create a fresh, empty copy of this directory.
1893 if (PathExists(data_dir)) { 1893 if (PathExists(data_dir)) {
1894 ASSERT_TRUE(DeleteFile(data_dir, true)); 1894 ASSERT_TRUE(DeleteFile(data_dir, true));
1895 } 1895 }
1896 ASSERT_TRUE(base::CreateDirectory(data_dir)); 1896 ASSERT_TRUE(CreateDirectory(data_dir));
1897 1897
1898 FilePath foobar(data_dir.Append(FILE_PATH_LITERAL("foobar.txt"))); 1898 FilePath foobar(data_dir.Append(FILE_PATH_LITERAL("foobar.txt")));
1899 std::string data("hello"); 1899 std::string data("hello");
1900 ASSERT_TRUE(file_util::WriteFile(foobar, data.c_str(), data.length())); 1900 ASSERT_TRUE(file_util::WriteFile(foobar, data.c_str(), data.length()));
1901 1901
1902 Time access_time; 1902 Time access_time;
1903 // This timestamp is divisible by one day (in local timezone), 1903 // This timestamp is divisible by one day (in local timezone),
1904 // to make it work on FAT too. 1904 // to make it work on FAT too.
1905 ASSERT_TRUE(Time::FromString("Wed, 16 Nov 1994, 00:00:00", 1905 ASSERT_TRUE(Time::FromString("Wed, 16 Nov 1994, 00:00:00",
1906 &access_time)); 1906 &access_time));
1907 1907
1908 Time modification_time; 1908 Time modification_time;
1909 // Note that this timestamp is divisible by two (seconds) - FAT stores 1909 // Note that this timestamp is divisible by two (seconds) - FAT stores
1910 // modification times with 2s resolution. 1910 // modification times with 2s resolution.
1911 ASSERT_TRUE(Time::FromString("Tue, 15 Nov 1994, 12:45:26 GMT", 1911 ASSERT_TRUE(Time::FromString("Tue, 15 Nov 1994, 12:45:26 GMT",
1912 &modification_time)); 1912 &modification_time));
1913 1913
1914 ASSERT_TRUE(file_util::TouchFile(foobar, access_time, modification_time)); 1914 ASSERT_TRUE(TouchFile(foobar, access_time, modification_time));
1915 PlatformFileInfo file_info; 1915 PlatformFileInfo file_info;
1916 ASSERT_TRUE(GetFileInfo(foobar, &file_info)); 1916 ASSERT_TRUE(GetFileInfo(foobar, &file_info));
1917 EXPECT_EQ(file_info.last_accessed.ToInternalValue(), 1917 EXPECT_EQ(file_info.last_accessed.ToInternalValue(),
1918 access_time.ToInternalValue()); 1918 access_time.ToInternalValue());
1919 EXPECT_EQ(file_info.last_modified.ToInternalValue(), 1919 EXPECT_EQ(file_info.last_modified.ToInternalValue(),
1920 modification_time.ToInternalValue()); 1920 modification_time.ToInternalValue());
1921 } 1921 }
1922 1922
1923 TEST_F(FileUtilTest, IsDirectoryEmpty) { 1923 TEST_F(FileUtilTest, IsDirectoryEmpty) {
1924 FilePath empty_dir = temp_dir_.path().Append(FILE_PATH_LITERAL("EmptyDir")); 1924 FilePath empty_dir = temp_dir_.path().Append(FILE_PATH_LITERAL("EmptyDir"));
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after
2347 int fd = OpenContentUriForRead(path); 2347 int fd = OpenContentUriForRead(path);
2348 EXPECT_EQ(-1, fd); 2348 EXPECT_EQ(-1, fd);
2349 } 2349 }
2350 #endif 2350 #endif
2351 2351
2352 #endif // defined(OS_POSIX) 2352 #endif // defined(OS_POSIX)
2353 2353
2354 } // namespace 2354 } // namespace
2355 2355
2356 } // namespace base 2356 } // namespace base
OLDNEW
« no previous file with comments | « base/file_util.cc ('k') | base/files/file_util_proxy.cc » ('j') | base/files/file_util_proxy.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698