| OLD | NEW |
| 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 download_item_ = | 58 download_item_ = |
| 59 base::MakeUnique<NiceMock<MockDownloadItemImpl>>(item_delegate_.get()); | 59 base::MakeUnique<NiceMock<MockDownloadItemImpl>>(item_delegate_.get()); |
| 60 job_ = base::MakeUnique<ParallelDownloadJobForTest>( | 60 job_ = base::MakeUnique<ParallelDownloadJobForTest>( |
| 61 download_item_.get(), base::MakeUnique<MockDownloadRequestHandle>(), | 61 download_item_.get(), base::MakeUnique<MockDownloadRequestHandle>(), |
| 62 DownloadCreateInfo()); | 62 DownloadCreateInfo()); |
| 63 } | 63 } |
| 64 | 64 |
| 65 void CreateNewDownloadRequests(int64_t total_bytes, | 65 void CreateNewDownloadRequests(int64_t total_bytes, |
| 66 int64_t bytes_received, | 66 int64_t bytes_received, |
| 67 int request_num) { | 67 int request_num) { |
| 68 job_->request_num_ = request_num; | 68 job_->ForkRequestsForNewDownload(bytes_received, total_bytes, request_num); |
| 69 job_->ForkRequestsForNewDownload(bytes_received, total_bytes); | |
| 70 } | 69 } |
| 71 | 70 |
| 72 content::TestBrowserThreadBundle browser_threads_; | 71 content::TestBrowserThreadBundle browser_threads_; |
| 73 std::unique_ptr<DownloadItemImplDelegate> item_delegate_; | 72 std::unique_ptr<DownloadItemImplDelegate> item_delegate_; |
| 74 std::unique_ptr<MockDownloadItemImpl> download_item_; | 73 std::unique_ptr<MockDownloadItemImpl> download_item_; |
| 75 std::unique_ptr<ParallelDownloadJobForTest> job_; | 74 std::unique_ptr<ParallelDownloadJobForTest> job_; |
| 76 }; | 75 }; |
| 77 | 76 |
| 78 // Test if sub tasks are created correctly. | 77 // Test if sub tasks are created correctly. |
| 79 TEST_F(ParallelDownloadJobTest, CreateNewDownloadRequests) { | 78 TEST_F(ParallelDownloadJobTest, CreateNewDownloadRequests) { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 // Original request: Range:98-98, for 1 byte. | 131 // Original request: Range:98-98, for 1 byte. |
| 133 // Task 1: Range:99-99, for 1 byte. | 132 // Task 1: Range:99-99, for 1 byte. |
| 134 CreateNewDownloadRequests(100, 98, 4); | 133 CreateNewDownloadRequests(100, 98, 4); |
| 135 EXPECT_EQ(1, static_cast<int>(job_->fake_tasks_.size())); | 134 EXPECT_EQ(1, static_cast<int>(job_->fake_tasks_.size())); |
| 136 EXPECT_EQ(99, job_->fake_tasks_[0].first); | 135 EXPECT_EQ(99, job_->fake_tasks_[0].first); |
| 137 EXPECT_EQ(1, job_->fake_tasks_[0].second); | 136 EXPECT_EQ(1, job_->fake_tasks_[0].second); |
| 138 job_->fake_tasks_.clear(); | 137 job_->fake_tasks_.clear(); |
| 139 } | 138 } |
| 140 | 139 |
| 141 } // namespace content | 140 } // namespace content |
| OLD | NEW |