| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/download/parallel_download_utils.h" | 5 #include "content/browser/download/parallel_download_utils.h" |
| 6 | 6 |
| 7 #include "content/public/browser/download_save_info.h" | 7 #include "content/public/browser/download_save_info.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 | 9 |
| 10 namespace content { | 10 namespace content { |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 EXPECT_EQ(0, slices[0].received_bytes); | 116 EXPECT_EQ(0, slices[0].received_bytes); |
| 117 | 117 |
| 118 // A total 100 bytes data and a 51 bytes minimum slice size, only one slice is | 118 // A total 100 bytes data and a 51 bytes minimum slice size, only one slice is |
| 119 // returned. | 119 // returned. |
| 120 slices = FindSlicesForRemainingContent(0, 100, 3, 51); | 120 slices = FindSlicesForRemainingContent(0, 100, 3, 51); |
| 121 EXPECT_EQ(1u, slices.size()); | 121 EXPECT_EQ(1u, slices.size()); |
| 122 EXPECT_EQ(0, slices[0].offset); | 122 EXPECT_EQ(0, slices[0].offset); |
| 123 EXPECT_EQ(0, slices[0].received_bytes); | 123 EXPECT_EQ(0, slices[0].received_bytes); |
| 124 } | 124 } |
| 125 | 125 |
| 126 TEST(ParallelDownloadUtilsTest, GetMaxContiguousDataBlockSizeFromBeginning) { |
| 127 std::vector<DownloadItem::ReceivedSlice> slices; |
| 128 slices.emplace_back(500, 500); |
| 129 EXPECT_EQ(0, GetMaxContiguousDataBlockSizeFromBeginning(slices)); |
| 130 |
| 131 DownloadItem::ReceivedSlice slice1(0, 200); |
| 132 AddOrMergeReceivedSliceIntoSortedArray(slice1, slices); |
| 133 EXPECT_EQ(200, GetMaxContiguousDataBlockSizeFromBeginning(slices)); |
| 134 |
| 135 DownloadItem::ReceivedSlice slice2(200, 300); |
| 136 AddOrMergeReceivedSliceIntoSortedArray(slice2, slices); |
| 137 EXPECT_EQ(1000, GetMaxContiguousDataBlockSizeFromBeginning(slices)); |
| 138 } |
| 139 |
| 126 } // namespace content | 140 } // namespace content |
| OLD | NEW |