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

Side by Side Diff: base/files/file_util_unittest.cc

Issue 693493004: Revert of Allow POSIX callers to specify a new file's mode. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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
« no previous file with comments | « base/files/file_util_posix.cc ('k') | content/browser/download/base_file_posix.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 2125 matching lines...) Expand 10 before | Expand all | Expand 10 after
2136 2136
2137 ASSERT_TRUE(TouchFile(foobar, access_time, modification_time)); 2137 ASSERT_TRUE(TouchFile(foobar, access_time, modification_time));
2138 File::Info file_info; 2138 File::Info file_info;
2139 ASSERT_TRUE(GetFileInfo(foobar, &file_info)); 2139 ASSERT_TRUE(GetFileInfo(foobar, &file_info));
2140 EXPECT_EQ(access_time.ToInternalValue(), 2140 EXPECT_EQ(access_time.ToInternalValue(),
2141 file_info.last_accessed.ToInternalValue()); 2141 file_info.last_accessed.ToInternalValue());
2142 EXPECT_EQ(modification_time.ToInternalValue(), 2142 EXPECT_EQ(modification_time.ToInternalValue(),
2143 file_info.last_modified.ToInternalValue()); 2143 file_info.last_modified.ToInternalValue());
2144 } 2144 }
2145 2145
2146 #if defined(OS_POSIX) && !defined(OS_ANDROID)
2147 TEST_F(FileUtilTest, WriteFileWithMode) {
2148 FilePath data_dir =
2149 temp_dir_.path().Append(FILE_PATH_LITERAL("FilePathTest"));
2150
2151 // Create a fresh, empty copy of this directory.
2152 if (PathExists(data_dir)) {
2153 ASSERT_TRUE(DeleteFile(data_dir, true));
2154 }
2155 ASSERT_TRUE(CreateDirectory(data_dir));
2156
2157 FilePath foobar(data_dir.Append(FILE_PATH_LITERAL("foobar.txt")));
2158 std::string data("hello");
2159 mode_t mode = 0644;
2160 ASSERT_TRUE(WriteFileWithMode(foobar, data.c_str(), data.length(), mode));
2161
2162 struct stat status;
2163 ASSERT_EQ(0, stat(foobar.value().c_str(), &status));
2164 ASSERT_EQ(mode, status.st_mode & 0777);
2165 }
2166 #endif
2167
2168 TEST_F(FileUtilTest, IsDirectoryEmpty) { 2146 TEST_F(FileUtilTest, IsDirectoryEmpty) {
2169 FilePath empty_dir = temp_dir_.path().Append(FILE_PATH_LITERAL("EmptyDir")); 2147 FilePath empty_dir = temp_dir_.path().Append(FILE_PATH_LITERAL("EmptyDir"));
2170 2148
2171 ASSERT_FALSE(PathExists(empty_dir)); 2149 ASSERT_FALSE(PathExists(empty_dir));
2172 2150
2173 ASSERT_TRUE(CreateDirectory(empty_dir)); 2151 ASSERT_TRUE(CreateDirectory(empty_dir));
2174 2152
2175 EXPECT_TRUE(IsDirectoryEmpty(empty_dir)); 2153 EXPECT_TRUE(IsDirectoryEmpty(empty_dir));
2176 2154
2177 FilePath foo(empty_dir.Append(FILE_PATH_LITERAL("foo.txt"))); 2155 FilePath foo(empty_dir.Append(FILE_PATH_LITERAL("foo.txt")));
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after
2629 // Trying to close it should crash. This is important for security. 2607 // Trying to close it should crash. This is important for security.
2630 EXPECT_DEATH(CloseWithScopedFD(fds[1]), ""); 2608 EXPECT_DEATH(CloseWithScopedFD(fds[1]), "");
2631 #endif 2609 #endif
2632 } 2610 }
2633 2611
2634 #endif // defined(OS_POSIX) 2612 #endif // defined(OS_POSIX)
2635 2613
2636 } // namespace 2614 } // namespace
2637 2615
2638 } // namespace base 2616 } // namespace base
OLDNEW
« no previous file with comments | « base/files/file_util_posix.cc ('k') | content/browser/download/base_file_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698