| 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 <string> | 5 #include <string> |
| 6 #include <vector> | 6 #include <vector> |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| 11 #include "base/scoped_temp_dir.h" | 11 #include "base/scoped_temp_dir.h" |
| 12 #include "googleurl/src/gurl.h" | 12 #include "googleurl/src/gurl.h" |
| 13 #include "net/base/io_buffer.h" | 13 #include "net/base/io_buffer.h" |
| 14 #include "net/url_request/url_request.h" | 14 #include "net/url_request/url_request.h" |
| 15 #include "net/url_request/url_request_context.h" |
| 15 #include "net/url_request/url_request_job.h" | 16 #include "net/url_request/url_request_job.h" |
| 16 #include "net/url_request/url_request_status.h" | 17 #include "net/url_request/url_request_status.h" |
| 17 #include "testing/platform_test.h" | 18 #include "testing/platform_test.h" |
| 18 #include "webkit/fileapi/file_system_context.h" | 19 #include "webkit/fileapi/file_system_context.h" |
| 19 #include "webkit/fileapi/file_system_operation.h" | 20 #include "webkit/fileapi/file_system_operation.h" |
| 20 #include "webkit/fileapi/file_system_test_helper.h" | 21 #include "webkit/fileapi/file_system_test_helper.h" |
| 21 #include "webkit/fileapi/file_writer_delegate.h" | 22 #include "webkit/fileapi/file_writer_delegate.h" |
| 22 #include "webkit/fileapi/sandbox_file_stream_writer.h" | 23 #include "webkit/fileapi/sandbox_file_stream_writer.h" |
| 23 | 24 |
| 24 namespace fileapi { | 25 namespace fileapi { |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 const char* FileWriterDelegateTest::content_ = NULL; | 138 const char* FileWriterDelegateTest::content_ = NULL; |
| 138 | 139 |
| 139 namespace { | 140 namespace { |
| 140 | 141 |
| 141 static std::string g_content; | 142 static std::string g_content; |
| 142 | 143 |
| 143 class FileWriterDelegateTestJob : public net::URLRequestJob { | 144 class FileWriterDelegateTestJob : public net::URLRequestJob { |
| 144 public: | 145 public: |
| 145 FileWriterDelegateTestJob(net::URLRequest* request, | 146 FileWriterDelegateTestJob(net::URLRequest* request, |
| 146 const std::string& content) | 147 const std::string& content) |
| 147 : net::URLRequestJob(request), | 148 : net::URLRequestJob(request, request->context()->network_delegate()), |
| 148 content_(content), | 149 content_(content), |
| 149 remaining_bytes_(content.length()), | 150 remaining_bytes_(content.length()), |
| 150 cursor_(0) { | 151 cursor_(0) { |
| 151 } | 152 } |
| 152 | 153 |
| 153 virtual void Start() OVERRIDE { | 154 virtual void Start() OVERRIDE { |
| 154 MessageLoop::current()->PostTask( | 155 MessageLoop::current()->PostTask( |
| 155 FROM_HERE, | 156 FROM_HERE, |
| 156 base::Bind(&FileWriterDelegateTestJob::NotifyHeadersComplete, this)); | 157 base::Bind(&FileWriterDelegateTestJob::NotifyHeadersComplete, this)); |
| 157 } | 158 } |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 453 file_writer_delegate_.reset(); | 454 file_writer_delegate_.reset(); |
| 454 | 455 |
| 455 EXPECT_EQ(pre_write_usage + allowed_growth, | 456 EXPECT_EQ(pre_write_usage + allowed_growth, |
| 456 test_helper_.GetCachedOriginUsage()); | 457 test_helper_.GetCachedOriginUsage()); |
| 457 EXPECT_EQ(ComputeCurrentOriginUsage(), test_helper_.GetCachedOriginUsage()); | 458 EXPECT_EQ(ComputeCurrentOriginUsage(), test_helper_.GetCachedOriginUsage()); |
| 458 EXPECT_EQ(kOverlap + allowed_growth, result_->bytes_written()); | 459 EXPECT_EQ(kOverlap + allowed_growth, result_->bytes_written()); |
| 459 EXPECT_EQ(base::PLATFORM_FILE_ERROR_NO_SPACE, result_->status()); | 460 EXPECT_EQ(base::PLATFORM_FILE_ERROR_NO_SPACE, result_->status()); |
| 460 } | 461 } |
| 461 | 462 |
| 462 } // namespace fileapi | 463 } // namespace fileapi |
| OLD | NEW |