| OLD | NEW |
| 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 "base/files/file_util_proxy.h" | 5 #include "base/files/file_util_proxy.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 EXPECT_FALSE(file_util::PathExists(test_path())); | 162 EXPECT_FALSE(file_util::PathExists(test_path())); |
| 163 } | 163 } |
| 164 | 164 |
| 165 TEST_F(FileUtilProxyTest, Close) { | 165 TEST_F(FileUtilProxyTest, Close) { |
| 166 // Creates a file. | 166 // Creates a file. |
| 167 PlatformFile file = GetTestPlatformFile( | 167 PlatformFile file = GetTestPlatformFile( |
| 168 PLATFORM_FILE_CREATE | PLATFORM_FILE_WRITE); | 168 PLATFORM_FILE_CREATE | PLATFORM_FILE_WRITE); |
| 169 | 169 |
| 170 #if defined(OS_WIN) | 170 #if defined(OS_WIN) |
| 171 // This fails on Windows if the file is not closed. | 171 // This fails on Windows if the file is not closed. |
| 172 EXPECT_FALSE(file_util::Move(test_path(), | 172 EXPECT_FALSE(base::Move(test_path(), |
| 173 test_dir_path().AppendASCII("new"))); | 173 test_dir_path().AppendASCII("new"))); |
| 174 #endif | 174 #endif |
| 175 | 175 |
| 176 FileUtilProxy::Close( | 176 FileUtilProxy::Close( |
| 177 file_task_runner(), | 177 file_task_runner(), |
| 178 file, | 178 file, |
| 179 Bind(&FileUtilProxyTest::DidFinish, weak_factory_.GetWeakPtr())); | 179 Bind(&FileUtilProxyTest::DidFinish, weak_factory_.GetWeakPtr())); |
| 180 MessageLoop::current()->Run(); | 180 MessageLoop::current()->Run(); |
| 181 EXPECT_EQ(PLATFORM_FILE_OK, error_); | 181 EXPECT_EQ(PLATFORM_FILE_OK, error_); |
| 182 | 182 |
| 183 // Now it should pass on all platforms. | 183 // Now it should pass on all platforms. |
| 184 EXPECT_TRUE(file_util::Move(test_path(), test_dir_path().AppendASCII("new"))); | 184 EXPECT_TRUE(base::Move(test_path(), test_dir_path().AppendASCII("new"))); |
| 185 } | 185 } |
| 186 | 186 |
| 187 TEST_F(FileUtilProxyTest, CreateTemporary) { | 187 TEST_F(FileUtilProxyTest, CreateTemporary) { |
| 188 FileUtilProxy::CreateTemporary( | 188 FileUtilProxy::CreateTemporary( |
| 189 file_task_runner(), 0 /* additional_file_flags */, | 189 file_task_runner(), 0 /* additional_file_flags */, |
| 190 Bind(&FileUtilProxyTest::DidCreateTemporary, weak_factory_.GetWeakPtr())); | 190 Bind(&FileUtilProxyTest::DidCreateTemporary, weak_factory_.GetWeakPtr())); |
| 191 MessageLoop::current()->Run(); | 191 MessageLoop::current()->Run(); |
| 192 EXPECT_EQ(PLATFORM_FILE_OK, error_); | 192 EXPECT_EQ(PLATFORM_FILE_OK, error_); |
| 193 EXPECT_TRUE(file_util::PathExists(path_)); | 193 EXPECT_TRUE(file_util::PathExists(path_)); |
| 194 EXPECT_NE(kInvalidPlatformFileValue, file_); | 194 EXPECT_NE(kInvalidPlatformFileValue, file_); |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 char buffer[53]; | 402 char buffer[53]; |
| 403 EXPECT_EQ(53, file_util::ReadFile(test_path(), buffer, 53)); | 403 EXPECT_EQ(53, file_util::ReadFile(test_path(), buffer, 53)); |
| 404 int i = 0; | 404 int i = 0; |
| 405 for (; i < 10; ++i) | 405 for (; i < 10; ++i) |
| 406 EXPECT_EQ(kTestData[i], buffer[i]); | 406 EXPECT_EQ(kTestData[i], buffer[i]); |
| 407 for (; i < 53; ++i) | 407 for (; i < 53; ++i) |
| 408 EXPECT_EQ(0, buffer[i]); | 408 EXPECT_EQ(0, buffer[i]); |
| 409 } | 409 } |
| 410 | 410 |
| 411 } // namespace base | 411 } // namespace base |
| OLD | NEW |