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

Side by Side Diff: content/browser/fileapi/local_file_util_unittest.cc

Issue 89523002: Move Posix file utils to the base namespace. (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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 <string> 5 #include <string>
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/files/scoped_temp_dir.h" 9 #include "base/files/scoped_temp_dir.h"
10 #include "base/message_loop/message_loop_proxy.h" 10 #include "base/message_loop/message_loop_proxy.h"
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 ASSERT_TRUE(created); 131 ASSERT_TRUE(created);
132 132
133 EXPECT_TRUE(FileExists(file_name)); 133 EXPECT_TRUE(FileExists(file_name));
134 EXPECT_EQ(0, GetSize(file_name)); 134 EXPECT_EQ(0, GetSize(file_name));
135 135
136 scoped_ptr<FileSystemOperationContext> context(NewContext()); 136 scoped_ptr<FileSystemOperationContext> context(NewContext());
137 EXPECT_EQ(base::PLATFORM_FILE_OK, 137 EXPECT_EQ(base::PLATFORM_FILE_OK,
138 file_util()->Close(context.get(), file_handle)); 138 file_util()->Close(context.get(), file_handle));
139 } 139 }
140 140
141 // file_util::CreateSymbolicLink is only supported on POSIX. 141 // base::CreateSymbolicLink is only supported on POSIX.
142 #if defined(OS_POSIX) 142 #if defined(OS_POSIX)
143 TEST_F(LocalFileUtilTest, CreateFailForSymlink) { 143 TEST_F(LocalFileUtilTest, CreateFailForSymlink) {
144 // Create symlink target file. 144 // Create symlink target file.
145 const char *target_name = "symlink_target"; 145 const char *target_name = "symlink_target";
146 base::PlatformFile target_handle; 146 base::PlatformFile target_handle;
147 bool symlink_target_created = false; 147 bool symlink_target_created = false;
148 ASSERT_EQ(base::PLATFORM_FILE_OK, 148 ASSERT_EQ(base::PLATFORM_FILE_OK,
149 CreateFile(target_name, &target_handle, &symlink_target_created)); 149 CreateFile(target_name, &target_handle, &symlink_target_created));
150 ASSERT_TRUE(symlink_target_created); 150 ASSERT_TRUE(symlink_target_created);
151 base::FilePath target_path = LocalPath(target_name); 151 base::FilePath target_path = LocalPath(target_name);
152 152
153 // Create symlink where target must be real file. 153 // Create symlink where target must be real file.
154 const char *symlink_name = "symlink_file"; 154 const char *symlink_name = "symlink_file";
155 base::FilePath symlink_path = LocalPath(symlink_name); 155 base::FilePath symlink_path = LocalPath(symlink_name);
156 ASSERT_TRUE(file_util::CreateSymbolicLink(target_path, symlink_path)); 156 ASSERT_TRUE(base::CreateSymbolicLink(target_path, symlink_path));
157 ASSERT_TRUE(FileExists(symlink_name)); 157 ASSERT_TRUE(FileExists(symlink_name));
158 158
159 // Try to open the symlink file which should fail. 159 // Try to open the symlink file which should fail.
160 scoped_ptr<FileSystemOperationContext> context(NewContext()); 160 scoped_ptr<FileSystemOperationContext> context(NewContext());
161 FileSystemURL url = CreateURL(symlink_name); 161 FileSystemURL url = CreateURL(symlink_name);
162 int file_flags = base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ; 162 int file_flags = base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ;
163 base::PlatformFile file_handle; 163 base::PlatformFile file_handle;
164 bool created = false; 164 bool created = false;
165 EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND, file_util()->CreateOrOpen( 165 EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND, file_util()->CreateOrOpen(
166 context.get(), url, file_flags, &file_handle, &created)); 166 context.get(), url, file_flags, &file_handle, &created));
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 CreateURL(from_dir), 379 CreateURL(from_dir),
380 CreateURL(to_dir))); 380 CreateURL(to_dir)));
381 381
382 EXPECT_FALSE(DirectoryExists(from_dir)); 382 EXPECT_FALSE(DirectoryExists(from_dir));
383 EXPECT_TRUE(DirectoryExists(to_dir)); 383 EXPECT_TRUE(DirectoryExists(to_dir));
384 EXPECT_TRUE(FileExists(to_file)); 384 EXPECT_TRUE(FileExists(to_file));
385 EXPECT_EQ(1020, GetSize(to_file)); 385 EXPECT_EQ(1020, GetSize(to_file));
386 } 386 }
387 387
388 } // namespace fileapi 388 } // namespace fileapi
OLDNEW
« no previous file with comments | « content/browser/fileapi/dragged_file_util_unittest.cc ('k') | content/common/set_process_title.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698