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

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

Issue 2727143005: Change FindNextSliceToDownload() into FindSlicesToDownload() (Closed)
Patch Set: 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
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_job.h" 5 #include "content/browser/download/parallel_download_job.h"
6 6
7 #include <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 18 matching lines...) Expand all
29 MOCK_CONST_METHOD0(CancelRequest, void()); 29 MOCK_CONST_METHOD0(CancelRequest, void());
30 MOCK_CONST_METHOD0(DebugString, std::string()); 30 MOCK_CONST_METHOD0(DebugString, std::string());
31 }; 31 };
32 32
33 } // namespace 33 } // namespace
34 34
35 class ParallelDownloadJobForTest : public ParallelDownloadJob { 35 class ParallelDownloadJobForTest : public ParallelDownloadJob {
36 public: 36 public:
37 ParallelDownloadJobForTest( 37 ParallelDownloadJobForTest(
38 DownloadItemImpl* download_item, 38 DownloadItemImpl* download_item,
39 std::unique_ptr<DownloadRequestHandleInterface> request_handle) 39 std::unique_ptr<DownloadRequestHandleInterface> request_handle,
40 : ParallelDownloadJob(download_item, std::move(request_handle)) {} 40 const DownloadCreateInfo& create_info)
41 : ParallelDownloadJob(
42 download_item, std::move(request_handle), create_info) {}
41 43
42 void CreateRequest(int64_t offset, int64_t length) override { 44 void CreateRequest(int64_t offset, int64_t length) override {
43 fake_tasks_.push_back(std::pair<int64_t, int64_t>(offset, length)); 45 fake_tasks_.push_back(std::pair<int64_t, int64_t>(offset, length));
44 } 46 }
45 47
46 std::vector<std::pair<int64_t, int64_t>> fake_tasks_; 48 std::vector<std::pair<int64_t, int64_t>> fake_tasks_;
47 49
48 private: 50 private:
49 DISALLOW_COPY_AND_ASSIGN(ParallelDownloadJobForTest); 51 DISALLOW_COPY_AND_ASSIGN(ParallelDownloadJobForTest);
50 }; 52 };
51 53
52 class ParallelDownloadJobTest : public testing::Test { 54 class ParallelDownloadJobTest : public testing::Test {
53 public: 55 public:
54 void SetUp() override { 56 void SetUp() override {
55 item_delegate_ = base::MakeUnique<DownloadItemImplDelegate>(); 57 item_delegate_ = base::MakeUnique<DownloadItemImplDelegate>();
56 download_item_ = 58 download_item_ =
57 base::MakeUnique<NiceMock<MockDownloadItemImpl>>(item_delegate_.get()); 59 base::MakeUnique<NiceMock<MockDownloadItemImpl>>(item_delegate_.get());
58 job_ = base::MakeUnique<ParallelDownloadJobForTest>( 60 job_ = base::MakeUnique<ParallelDownloadJobForTest>(
59 download_item_.get(), base::MakeUnique<MockDownloadRequestHandle>()); 61 download_item_.get(), base::MakeUnique<MockDownloadRequestHandle>(),
62 DownloadCreateInfo());
60 } 63 }
61 64
62 void CreateNewDownloadRequests(int64_t total_bytes, 65 void CreateNewDownloadRequests(int64_t total_bytes,
63 int64_t bytes_received, 66 int64_t bytes_received,
64 int request_num) { 67 int request_num) {
65 job_->request_num_ = request_num; 68 job_->request_num_ = request_num;
66 job_->ForkRequestsForNewDownload(bytes_received, total_bytes); 69 job_->ForkRequestsForNewDownload(bytes_received, total_bytes);
67 } 70 }
68 71
69 content::TestBrowserThreadBundle browser_threads_; 72 content::TestBrowserThreadBundle browser_threads_;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 // Original request: Range:98-98, for 1 byte. 132 // Original request: Range:98-98, for 1 byte.
130 // Task 1: Range:99-99, for 1 byte. 133 // Task 1: Range:99-99, for 1 byte.
131 CreateNewDownloadRequests(100, 98, 4); 134 CreateNewDownloadRequests(100, 98, 4);
132 EXPECT_EQ(1, static_cast<int>(job_->fake_tasks_.size())); 135 EXPECT_EQ(1, static_cast<int>(job_->fake_tasks_.size()));
133 EXPECT_EQ(99, job_->fake_tasks_[0].first); 136 EXPECT_EQ(99, job_->fake_tasks_[0].first);
134 EXPECT_EQ(1, job_->fake_tasks_[0].second); 137 EXPECT_EQ(1, job_->fake_tasks_[0].second);
135 job_->fake_tasks_.clear(); 138 job_->fake_tasks_.clear();
136 } 139 }
137 140
138 } // namespace content 141 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698