| 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/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/file_util.h" | 6 #include "base/file_util.h" |
| 7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "base/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
| 12 #include "base/time.h" | 12 #include "base/time.h" |
| 13 #include "net/base/io_buffer.h" | 13 #include "net/base/io_buffer.h" |
| 14 #include "net/http/http_request_headers.h" | 14 #include "net/http/http_request_headers.h" |
| 15 #include "net/http/http_response_headers.h" | 15 #include "net/http/http_response_headers.h" |
| 16 #include "net/url_request/url_request.h" | 16 #include "net/url_request/url_request.h" |
| 17 #include "net/url_request/url_request_context.h" | 17 #include "net/url_request/url_request_context.h" |
| 18 #include "net/url_request/url_request_job_factory_impl.h" | 18 #include "net/url_request/url_request_job_factory_impl.h" |
| 19 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
| 20 #include "webkit/blob/blob_data.h" | 20 #include "webkit/blob/blob_data.h" |
| 21 #include "webkit/blob/blob_url_request_job.h" | 21 #include "webkit/blob/blob_url_request_job.h" |
| 22 #include "webkit/fileapi/external_mount_points.h" | |
| 23 #include "webkit/fileapi/file_system_context.h" | 22 #include "webkit/fileapi/file_system_context.h" |
| 24 #include "webkit/fileapi/file_system_file_util.h" | 23 #include "webkit/fileapi/file_system_file_util.h" |
| 25 #include "webkit/fileapi/file_system_operation_context.h" | 24 #include "webkit/fileapi/file_system_operation_context.h" |
| 26 #include "webkit/fileapi/file_system_task_runners.h" | |
| 27 #include "webkit/fileapi/file_system_url.h" | 25 #include "webkit/fileapi/file_system_url.h" |
| 28 #include "webkit/fileapi/mock_file_system_options.h" | 26 #include "webkit/fileapi/mock_file_system_context.h" |
| 29 | 27 |
| 30 namespace webkit_blob { | 28 namespace webkit_blob { |
| 31 | 29 |
| 32 namespace { | 30 namespace { |
| 33 | 31 |
| 34 const int kBufferSize = 1024; | 32 const int kBufferSize = 1024; |
| 35 const char kTestData1[] = "Hello"; | 33 const char kTestData1[] = "Hello"; |
| 36 const char kTestData2[] = "Here it is data."; | 34 const char kTestData2[] = "Here it is data."; |
| 37 const char kTestFileData1[] = "0123456789"; | 35 const char kTestFileData1[] = "0123456789"; |
| 38 const char kTestFileData2[] = "This is sample file."; | 36 const char kTestFileData2[] = "This is sample file."; |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 url_request_job_factory_.SetProtocolHandler("blob", | 160 url_request_job_factory_.SetProtocolHandler("blob", |
| 163 new MockProtocolHandler(this)); | 161 new MockProtocolHandler(this)); |
| 164 url_request_context_.set_job_factory(&url_request_job_factory_); | 162 url_request_context_.set_job_factory(&url_request_job_factory_); |
| 165 } | 163 } |
| 166 | 164 |
| 167 virtual void TearDown() { | 165 virtual void TearDown() { |
| 168 } | 166 } |
| 169 | 167 |
| 170 void SetUpFileSystem() { | 168 void SetUpFileSystem() { |
| 171 // Prepare file system. | 169 // Prepare file system. |
| 172 file_system_context_ = new fileapi::FileSystemContext( | 170 file_system_context_ = fileapi::CreateFileSystemContextForTesting( |
| 173 fileapi::FileSystemTaskRunners::CreateMockTaskRunners(), | 171 NULL, temp_dir_.path()); |
| 174 fileapi::ExternalMountPoints::CreateRefCounted().get(), | |
| 175 NULL, | |
| 176 NULL, | |
| 177 temp_dir_.path(), | |
| 178 fileapi::CreateDisallowFileAccessOptions()); | |
| 179 | 172 |
| 180 file_system_context_->OpenFileSystem( | 173 file_system_context_->OpenFileSystem( |
| 181 GURL(kFileSystemURLOrigin), | 174 GURL(kFileSystemURLOrigin), |
| 182 kFileSystemType, | 175 kFileSystemType, |
| 183 true, // create | 176 true, // create |
| 184 base::Bind(&BlobURLRequestJobTest::OnValidateFileSystem, | 177 base::Bind(&BlobURLRequestJobTest::OnValidateFileSystem, |
| 185 base::Unretained(this))); | 178 base::Unretained(this))); |
| 186 MessageLoop::current()->RunUntilIdle(); | 179 MessageLoop::current()->RunUntilIdle(); |
| 187 ASSERT_TRUE(file_system_root_url_.is_valid()); | 180 ASSERT_TRUE(file_system_root_url_.is_valid()); |
| 188 | 181 |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 EXPECT_TRUE(request_->response_headers()->GetMimeType(&content_type)); | 443 EXPECT_TRUE(request_->response_headers()->GetMimeType(&content_type)); |
| 451 EXPECT_EQ(kTestContentType, content_type); | 444 EXPECT_EQ(kTestContentType, content_type); |
| 452 void* iter = NULL; | 445 void* iter = NULL; |
| 453 std::string content_disposition; | 446 std::string content_disposition; |
| 454 EXPECT_TRUE(request_->response_headers()->EnumerateHeader( | 447 EXPECT_TRUE(request_->response_headers()->EnumerateHeader( |
| 455 &iter, "Content-Disposition", &content_disposition)); | 448 &iter, "Content-Disposition", &content_disposition)); |
| 456 EXPECT_EQ(kTestContentDisposition, content_disposition); | 449 EXPECT_EQ(kTestContentDisposition, content_disposition); |
| 457 } | 450 } |
| 458 | 451 |
| 459 } // namespace webkit_blob | 452 } // namespace webkit_blob |
| OLD | NEW |