Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(123)

Side by Side Diff: content/browser/download/parallel_download_utils_unittest.cc

Issue 2812263004: Properly handle the case when a parallel download becomes non-parallel (Closed)
Patch Set: rebase Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/browser/download/parallel_download_utils.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
OLDNEW
« no previous file with comments | « content/browser/download/parallel_download_utils.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698