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 <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 // Setup blob data for testing. | 98 // Setup blob data for testing. |
99 base::Time time1, time2; | 99 base::Time time1, time2; |
100 base::Time::FromString("Tue, 15 Nov 1994, 12:45:26 GMT", &time1); | 100 base::Time::FromString("Tue, 15 Nov 1994, 12:45:26 GMT", &time1); |
101 base::Time::FromString("Mon, 14 Nov 1994, 11:30:49 GMT", &time2); | 101 base::Time::FromString("Mon, 14 Nov 1994, 11:30:49 GMT", &time2); |
102 | 102 |
103 BlobStorageContext blob_storage_context; | 103 BlobStorageContext blob_storage_context; |
104 | 104 |
105 const std::string blob_id0("id-0"); | 105 const std::string blob_id0("id-0"); |
106 scoped_refptr<BlobData> blob_data(new BlobData(blob_id0)); | 106 scoped_refptr<BlobData> blob_data(new BlobData(blob_id0)); |
107 scoped_ptr<BlobDataHandle> handle1 = | 107 scoped_ptr<BlobDataHandle> handle1 = |
108 blob_storage_context.AddFinishedBlob(blob_data); | 108 blob_storage_context.AddFinishedBlob(blob_data.get()); |
109 | 109 |
110 const std::string blob_id1("id-1"); | 110 const std::string blob_id1("id-1"); |
111 blob_data = new BlobData(blob_id1); | 111 blob_data = new BlobData(blob_id1); |
112 blob_data->AppendData("BlobData"); | 112 blob_data->AppendData("BlobData"); |
113 blob_data->AppendFile( | 113 blob_data->AppendFile( |
114 base::FilePath(FILE_PATH_LITERAL("BlobFile.txt")), 0, 20, time1); | 114 base::FilePath(FILE_PATH_LITERAL("BlobFile.txt")), 0, 20, time1); |
115 scoped_ptr<BlobDataHandle> handle2 = | 115 scoped_ptr<BlobDataHandle> handle2 = |
116 blob_storage_context.AddFinishedBlob(blob_data); | 116 blob_storage_context.AddFinishedBlob(blob_data.get()); |
117 | 117 |
118 // Setup upload data elements for comparison. | 118 // Setup upload data elements for comparison. |
119 ResourceRequestBody::Element blob_element1, blob_element2; | 119 ResourceRequestBody::Element blob_element1, blob_element2; |
120 blob_element1.SetToBytes( | 120 blob_element1.SetToBytes( |
121 blob_data->items().at(0).bytes() + | 121 blob_data->items().at(0).bytes() + |
122 static_cast<int>(blob_data->items().at(0).offset()), | 122 static_cast<int>(blob_data->items().at(0).offset()), |
123 static_cast<int>(blob_data->items().at(0).length())); | 123 static_cast<int>(blob_data->items().at(0).length())); |
124 blob_element2.SetToFilePathRange( | 124 blob_element2.SetToFilePathRange( |
125 blob_data->items().at(1).path(), | 125 blob_data->items().at(1).path(), |
126 blob_data->items().at(1).offset(), | 126 blob_data->items().at(1).offset(), |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 EXPECT_TRUE(AreElementsEqual( | 298 EXPECT_TRUE(AreElementsEqual( |
299 *upload->element_readers()[6], blob_element2)); | 299 *upload->element_readers()[6], blob_element2)); |
300 EXPECT_TRUE(AreElementsEqual( | 300 EXPECT_TRUE(AreElementsEqual( |
301 *upload->element_readers()[7], upload_element2)); | 301 *upload->element_readers()[7], upload_element2)); |
302 } | 302 } |
303 // Clean up for ASAN. | 303 // Clean up for ASAN. |
304 base::RunLoop().RunUntilIdle(); | 304 base::RunLoop().RunUntilIdle(); |
305 } | 305 } |
306 | 306 |
307 } // namespace content | 307 } // namespace content |
OLD | NEW |