| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/bind.h" | 6 #include "base/bind.h" |
| 7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
| 9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 } | 72 } |
| 73 | 73 |
| 74 private: | 74 private: |
| 75 BlobURLRequestJobTest* test_; | 75 BlobURLRequestJobTest* test_; |
| 76 }; | 76 }; |
| 77 | 77 |
| 78 BlobURLRequestJobTest() | 78 BlobURLRequestJobTest() |
| 79 : blob_data_(new BlobData()), | 79 : blob_data_(new BlobData()), |
| 80 expected_status_code_(0) {} | 80 expected_status_code_(0) {} |
| 81 | 81 |
| 82 virtual void SetUp() { | 82 void SetUp() override { |
| 83 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 83 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| 84 | 84 |
| 85 temp_file1_ = temp_dir_.path().AppendASCII("BlobFile1.dat"); | 85 temp_file1_ = temp_dir_.path().AppendASCII("BlobFile1.dat"); |
| 86 ASSERT_EQ(static_cast<int>(arraysize(kTestFileData1) - 1), | 86 ASSERT_EQ(static_cast<int>(arraysize(kTestFileData1) - 1), |
| 87 base::WriteFile(temp_file1_, kTestFileData1, | 87 base::WriteFile(temp_file1_, kTestFileData1, |
| 88 arraysize(kTestFileData1) - 1)); | 88 arraysize(kTestFileData1) - 1)); |
| 89 base::File::Info file_info1; | 89 base::File::Info file_info1; |
| 90 base::GetFileInfo(temp_file1_, &file_info1); | 90 base::GetFileInfo(temp_file1_, &file_info1); |
| 91 temp_file_modification_time1_ = file_info1.last_modified; | 91 temp_file_modification_time1_ = file_info1.last_modified; |
| 92 | 92 |
| 93 temp_file2_ = temp_dir_.path().AppendASCII("BlobFile2.dat"); | 93 temp_file2_ = temp_dir_.path().AppendASCII("BlobFile2.dat"); |
| 94 ASSERT_EQ(static_cast<int>(arraysize(kTestFileData2) - 1), | 94 ASSERT_EQ(static_cast<int>(arraysize(kTestFileData2) - 1), |
| 95 base::WriteFile(temp_file2_, kTestFileData2, | 95 base::WriteFile(temp_file2_, kTestFileData2, |
| 96 arraysize(kTestFileData2) - 1)); | 96 arraysize(kTestFileData2) - 1)); |
| 97 base::File::Info file_info2; | 97 base::File::Info file_info2; |
| 98 base::GetFileInfo(temp_file2_, &file_info2); | 98 base::GetFileInfo(temp_file2_, &file_info2); |
| 99 temp_file_modification_time2_ = file_info2.last_modified; | 99 temp_file_modification_time2_ = file_info2.last_modified; |
| 100 | 100 |
| 101 url_request_job_factory_.SetProtocolHandler("blob", | 101 url_request_job_factory_.SetProtocolHandler("blob", |
| 102 new MockProtocolHandler(this)); | 102 new MockProtocolHandler(this)); |
| 103 url_request_context_.set_job_factory(&url_request_job_factory_); | 103 url_request_context_.set_job_factory(&url_request_job_factory_); |
| 104 } | 104 } |
| 105 | 105 |
| 106 virtual void TearDown() { | 106 void TearDown() override {} |
| 107 } | |
| 108 | 107 |
| 109 void SetUpFileSystem() { | 108 void SetUpFileSystem() { |
| 110 // Prepare file system. | 109 // Prepare file system. |
| 111 file_system_context_ = CreateFileSystemContextForTesting( | 110 file_system_context_ = CreateFileSystemContextForTesting( |
| 112 NULL, temp_dir_.path()); | 111 NULL, temp_dir_.path()); |
| 113 | 112 |
| 114 file_system_context_->OpenFileSystem( | 113 file_system_context_->OpenFileSystem( |
| 115 GURL(kFileSystemURLOrigin), | 114 GURL(kFileSystemURLOrigin), |
| 116 kFileSystemType, | 115 kFileSystemType, |
| 117 storage::OPEN_FILE_SYSTEM_CREATE_IF_NONEXISTENT, | 116 storage::OPEN_FILE_SYSTEM_CREATE_IF_NONEXISTENT, |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 EXPECT_TRUE(request_->response_headers()->GetMimeType(&content_type)); | 407 EXPECT_TRUE(request_->response_headers()->GetMimeType(&content_type)); |
| 409 EXPECT_EQ(kTestContentType, content_type); | 408 EXPECT_EQ(kTestContentType, content_type); |
| 410 void* iter = NULL; | 409 void* iter = NULL; |
| 411 std::string content_disposition; | 410 std::string content_disposition; |
| 412 EXPECT_TRUE(request_->response_headers()->EnumerateHeader( | 411 EXPECT_TRUE(request_->response_headers()->EnumerateHeader( |
| 413 &iter, "Content-Disposition", &content_disposition)); | 412 &iter, "Content-Disposition", &content_disposition)); |
| 414 EXPECT_EQ(kTestContentDisposition, content_disposition); | 413 EXPECT_EQ(kTestContentDisposition, content_disposition); |
| 415 } | 414 } |
| 416 | 415 |
| 417 } // namespace content | 416 } // namespace content |
| OLD | NEW |