| 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 int bytes_written) { | 81 int bytes_written) { |
| 82 error_ = error; | 82 error_ = error; |
| 83 bytes_written_ = bytes_written; | 83 bytes_written_ = bytes_written; |
| 84 MessageLoop::current()->QuitWhenIdle(); | 84 MessageLoop::current()->QuitWhenIdle(); |
| 85 } | 85 } |
| 86 | 86 |
| 87 protected: | 87 protected: |
| 88 PlatformFile GetTestPlatformFile(int flags) { | 88 PlatformFile GetTestPlatformFile(int flags) { |
| 89 if (file_ != kInvalidPlatformFileValue) | 89 if (file_ != kInvalidPlatformFileValue) |
| 90 return file_; | 90 return file_; |
| 91 bool created; | 91 |
| 92 PlatformFileError error; | 92 File file(test_path(), flags); |
| 93 file_ = CreatePlatformFile(test_path(), flags, &created, &error); | 93 EXPECT_TRUE(file.IsValid()); |
| 94 EXPECT_EQ(PLATFORM_FILE_OK, error); | 94 file_ = file.TakePlatformFile(); |
| 95 EXPECT_NE(kInvalidPlatformFileValue, file_); | |
| 96 return file_; | 95 return file_; |
| 97 } | 96 } |
| 98 | 97 |
| 99 TaskRunner* file_task_runner() const { | 98 TaskRunner* file_task_runner() const { |
| 100 return file_thread_.message_loop_proxy().get(); | 99 return file_thread_.message_loop_proxy().get(); |
| 101 } | 100 } |
| 102 const FilePath& test_dir_path() const { return dir_.path(); } | 101 const FilePath& test_dir_path() const { return dir_.path(); } |
| 103 const FilePath test_path() const { return dir_.path().AppendASCII("test"); } | 102 const FilePath test_path() const { return dir_.path().AppendASCII("test"); } |
| 104 | 103 |
| 105 MessageLoopForIO message_loop_; | 104 MessageLoopForIO message_loop_; |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 char buffer[53]; | 400 char buffer[53]; |
| 402 EXPECT_EQ(53, base::ReadFile(test_path(), buffer, 53)); | 401 EXPECT_EQ(53, base::ReadFile(test_path(), buffer, 53)); |
| 403 int i = 0; | 402 int i = 0; |
| 404 for (; i < 10; ++i) | 403 for (; i < 10; ++i) |
| 405 EXPECT_EQ(kTestData[i], buffer[i]); | 404 EXPECT_EQ(kTestData[i], buffer[i]); |
| 406 for (; i < 53; ++i) | 405 for (; i < 53; ++i) |
| 407 EXPECT_EQ(0, buffer[i]); | 406 EXPECT_EQ(0, buffer[i]); |
| 408 } | 407 } |
| 409 | 408 |
| 410 } // namespace base | 409 } // namespace base |
| OLD | NEW |