| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // NOTE: These tests are run as part of "unit_tests" (in chrome/test/unit) | 5 // NOTE: These tests are run as part of "unit_tests" (in chrome/test/unit) |
| 6 // rather than as part of test_shell_tests because they rely on being able | 6 // rather than as part of test_shell_tests because they rely on being able |
| 7 // to instantiate a MessageLoop of type TYPE_IO. test_shell_tests uses | 7 // to instantiate a MessageLoop of type TYPE_IO. test_shell_tests uses |
| 8 // TYPE_UI, which URLRequest doesn't allow. | 8 // TYPE_UI, which URLRequest doesn't allow. |
| 9 // | 9 // |
| 10 | 10 |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 class FileWriterDelegateTestJob : public net::URLRequestJob { | 139 class FileWriterDelegateTestJob : public net::URLRequestJob { |
| 140 public: | 140 public: |
| 141 FileWriterDelegateTestJob(net::URLRequest* request, | 141 FileWriterDelegateTestJob(net::URLRequest* request, |
| 142 const std::string& content) | 142 const std::string& content) |
| 143 : net::URLRequestJob(request), | 143 : net::URLRequestJob(request), |
| 144 content_(content), | 144 content_(content), |
| 145 remaining_bytes_(content.length()), | 145 remaining_bytes_(content.length()), |
| 146 cursor_(0) { | 146 cursor_(0) { |
| 147 } | 147 } |
| 148 | 148 |
| 149 void Start() { | 149 virtual void Start() OVERRIDE { |
| 150 MessageLoop::current()->PostTask( | 150 MessageLoop::current()->PostTask( |
| 151 FROM_HERE, | 151 FROM_HERE, |
| 152 base::Bind(&FileWriterDelegateTestJob::NotifyHeadersComplete, this)); | 152 base::Bind(&FileWriterDelegateTestJob::NotifyHeadersComplete, this)); |
| 153 } | 153 } |
| 154 | 154 |
| 155 bool ReadRawData(net::IOBuffer* buf, int buf_size, int *bytes_read) { | 155 virtual bool ReadRawData(net::IOBuffer* buf, int buf_size, int *bytes_read) |
| 156 OVERRIDE { |
| 156 if (remaining_bytes_ < buf_size) | 157 if (remaining_bytes_ < buf_size) |
| 157 buf_size = static_cast<int>(remaining_bytes_); | 158 buf_size = static_cast<int>(remaining_bytes_); |
| 158 | 159 |
| 159 for (int i = 0; i < buf_size; ++i) | 160 for (int i = 0; i < buf_size; ++i) |
| 160 buf->data()[i] = content_[cursor_++]; | 161 buf->data()[i] = content_[cursor_++]; |
| 161 remaining_bytes_ -= buf_size; | 162 remaining_bytes_ -= buf_size; |
| 162 | 163 |
| 163 SetStatus(net::URLRequestStatus()); | 164 SetStatus(net::URLRequestStatus()); |
| 164 *bytes_read = buf_size; | 165 *bytes_read = buf_size; |
| 165 return true; | 166 return true; |
| 166 } | 167 } |
| 167 | 168 |
| 169 virtual int GetResponseCode() const OVERRIDE { |
| 170 return 200; |
| 171 } |
| 172 |
| 168 private: | 173 private: |
| 169 std::string content_; | 174 std::string content_; |
| 170 int remaining_bytes_; | 175 int remaining_bytes_; |
| 171 int cursor_; | 176 int cursor_; |
| 172 }; | 177 }; |
| 173 | 178 |
| 174 class MockDispatcher : public FileSystemCallbackDispatcher { | 179 class MockDispatcher : public FileSystemCallbackDispatcher { |
| 175 public: | 180 public: |
| 176 explicit MockDispatcher(Result* result) : result_(result) {} | 181 explicit MockDispatcher(Result* result) : result_(result) {} |
| 177 | 182 |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 451 EXPECT_EQ(base::PLATFORM_FILE_ERROR_NO_SPACE, result_->status()); | 456 EXPECT_EQ(base::PLATFORM_FILE_ERROR_NO_SPACE, result_->status()); |
| 452 EXPECT_TRUE(result_->complete()); | 457 EXPECT_TRUE(result_->complete()); |
| 453 } | 458 } |
| 454 | 459 |
| 455 class FileWriterDelegateUnlimitedTest : public FileWriterDelegateTest { | 460 class FileWriterDelegateUnlimitedTest : public FileWriterDelegateTest { |
| 456 protected: | 461 protected: |
| 457 virtual void SetUpTestHelper(const FilePath& path) OVERRIDE; | 462 virtual void SetUpTestHelper(const FilePath& path) OVERRIDE; |
| 458 }; | 463 }; |
| 459 | 464 |
| 460 } // namespace fileapi | 465 } // namespace fileapi |
| OLD | NEW |