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

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

Issue 2728673003: Add a utility function to calculate the next slice to download (Closed)
Patch Set: addressing comments Created 3 years, 9 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') | content/test/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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
OLDNEW
« no previous file with comments | « content/browser/download/parallel_download_utils.cc ('k') | content/test/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698