| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "content/browser/download/parallel_download_utils.h" |
| 6 |
| 7 #include "content/public/browser/download_save_info.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 |
| 10 namespace content { |
| 11 |
| 12 TEST(ParallelDownloadUtilsTest, FindNextSliceToDownload) { |
| 13 std::vector<DownloadItem::ReceivedSlice> slices; |
| 14 DownloadItem::ReceivedSlice slice = FindNextSliceToDownload(slices); |
| 15 EXPECT_EQ(0, slice.offset); |
| 16 EXPECT_EQ(DownloadSaveInfo::kLengthFullContent, slice.received_bytes); |
| 17 |
| 18 slices.emplace_back(0, 500); |
| 19 slice = FindNextSliceToDownload(slices); |
| 20 EXPECT_EQ(500, slice.offset); |
| 21 EXPECT_EQ(DownloadSaveInfo::kLengthFullContent, slice.received_bytes); |
| 22 |
| 23 // Create a gap between slices. |
| 24 slices.emplace_back(1000, 500); |
| 25 slice = FindNextSliceToDownload(slices); |
| 26 EXPECT_EQ(500, slice.offset); |
| 27 EXPECT_EQ(500, slice.received_bytes); |
| 28 |
| 29 // Fill the gap. |
| 30 slices.emplace(slices.begin() + 1, slice); |
| 31 slice = FindNextSliceToDownload(slices); |
| 32 EXPECT_EQ(1500, slice.offset); |
| 33 EXPECT_EQ(DownloadSaveInfo::kLengthFullContent, slice.received_bytes); |
| 34 |
| 35 // Create a new gap at the beginning. |
| 36 slices.erase(slices.begin()); |
| 37 slice = FindNextSliceToDownload(slices); |
| 38 EXPECT_EQ(0, slice.offset); |
| 39 EXPECT_EQ(500, slice.received_bytes); |
| 40 } |
| 41 |
| 42 } // namespace content |
| OLD | NEW |