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 "content/browser/loader/upload_data_stream_builder.h" | 5 #include "content/browser/loader/upload_data_stream_builder.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <string> | 10 #include <string> |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 | 97 |
98 TEST(UploadDataStreamBuilderTest, | 98 TEST(UploadDataStreamBuilderTest, |
99 WriteUploadDataStreamWithEmptyFileBackedBlob) { | 99 WriteUploadDataStreamWithEmptyFileBackedBlob) { |
100 base::MessageLoopForIO message_loop; | 100 base::MessageLoopForIO message_loop; |
101 { | 101 { |
102 base::FilePath test_blob_path; | 102 base::FilePath test_blob_path; |
103 ASSERT_TRUE(base::CreateTemporaryFile(&test_blob_path)); | 103 ASSERT_TRUE(base::CreateTemporaryFile(&test_blob_path)); |
104 | 104 |
105 const uint64_t kZeroLength = 0; | 105 const uint64_t kZeroLength = 0; |
106 base::Time blob_time; | 106 base::Time blob_time; |
107 base::Time::FromString("Tue, 15 Nov 1994, 12:45:26 GMT", &blob_time); | 107 ASSERT_TRUE( |
| 108 base::Time::FromString("Tue, 15 Nov 1994, 12:45:26 GMT", &blob_time)); |
108 ASSERT_TRUE(base::TouchFile(test_blob_path, blob_time, blob_time)); | 109 ASSERT_TRUE(base::TouchFile(test_blob_path, blob_time, blob_time)); |
109 | 110 |
110 BlobStorageContext blob_storage_context; | 111 BlobStorageContext blob_storage_context; |
111 | 112 |
112 // A blob created from an empty file added several times. | 113 // A blob created from an empty file added several times. |
113 const std::string blob_id("id-0"); | 114 const std::string blob_id("id-0"); |
114 std::unique_ptr<BlobDataBuilder> blob_data_builder( | 115 std::unique_ptr<BlobDataBuilder> blob_data_builder( |
115 new BlobDataBuilder(blob_id)); | 116 new BlobDataBuilder(blob_id)); |
116 blob_data_builder->AppendFile(test_blob_path, 0, kZeroLength, blob_time); | 117 blob_data_builder->AppendFile(test_blob_path, 0, kZeroLength, blob_time); |
117 std::unique_ptr<BlobDataHandle> handle = | 118 std::unique_ptr<BlobDataHandle> handle = |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 result = | 209 result = |
209 upload->Read(buffer.get(), buffer->size(), read_callback.callback()); | 210 upload->Read(buffer.get(), buffer->size(), read_callback.callback()); |
210 EXPECT_EQ(kBlobDataLength, read_callback.GetResult(result)); | 211 EXPECT_EQ(kBlobDataLength, read_callback.GetResult(result)); |
211 EXPECT_EQ(0, | 212 EXPECT_EQ(0, |
212 std::memcmp(kBlobData.c_str(), buffer->data(), buffer->size())); | 213 std::memcmp(kBlobData.c_str(), buffer->data(), buffer->size())); |
213 } | 214 } |
214 // Clean up for ASAN. | 215 // Clean up for ASAN. |
215 base::RunLoop().RunUntilIdle(); | 216 base::RunLoop().RunUntilIdle(); |
216 } | 217 } |
217 } // namespace content | 218 } // namespace content |
OLD | NEW |