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

Unified 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, 10 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/download/parallel_download_utils_unittest.cc
diff --git a/content/browser/download/parallel_download_utils_unittest.cc b/content/browser/download/parallel_download_utils_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..abab9428a6c8786ea138d6e008086c47408fcb04
--- /dev/null
+++ b/content/browser/download/parallel_download_utils_unittest.cc
@@ -0,0 +1,42 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/browser/download/parallel_download_utils.h"
+
+#include "content/public/browser/download_save_info.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace content {
+
+TEST(ParallelDownloadUtilsTest, FindNextSliceToDownload) {
+ std::vector<DownloadItem::ReceivedSlice> slices;
+ DownloadItem::ReceivedSlice slice = FindNextSliceToDownload(slices);
+ EXPECT_EQ(0, slice.offset);
+ EXPECT_EQ(DownloadSaveInfo::kLengthFullContent, slice.received_bytes);
+
+ slices.emplace_back(0, 500);
+ slice = FindNextSliceToDownload(slices);
+ EXPECT_EQ(500, slice.offset);
+ EXPECT_EQ(DownloadSaveInfo::kLengthFullContent, slice.received_bytes);
+
+ // Create a gap between slices.
+ slices.emplace_back(1000, 500);
+ slice = FindNextSliceToDownload(slices);
+ EXPECT_EQ(500, slice.offset);
+ EXPECT_EQ(500, slice.received_bytes);
+
+ // Fill the gap.
+ slices.emplace(slices.begin() + 1, slice);
+ slice = FindNextSliceToDownload(slices);
+ EXPECT_EQ(1500, slice.offset);
+ EXPECT_EQ(DownloadSaveInfo::kLengthFullContent, slice.received_bytes);
+
+ // Create a new gap at the beginning.
+ slices.erase(slices.begin());
+ slice = FindNextSliceToDownload(slices);
+ EXPECT_EQ(0, slice.offset);
+ EXPECT_EQ(500, slice.received_bytes);
+}
+
+} // namespace content
« 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