| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/files/file.h" | 5 #include "base/files/file.h" |
| 6 #include "base/files/file_util.h" | 6 #include "base/files/file_util.h" |
| 7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/test/test_file_util.h" | 10 #include "base/test/test_file_util.h" |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 observer_(new StrictMock<MockDownloadDestinationObserver>), | 118 observer_(new StrictMock<MockDownloadDestinationObserver>), |
| 119 observer_factory_(observer_.get()), | 119 observer_factory_(observer_.get()), |
| 120 input_stream_(NULL), | 120 input_stream_(NULL), |
| 121 bytes_(-1), | 121 bytes_(-1), |
| 122 bytes_per_sec_(-1), | 122 bytes_per_sec_(-1), |
| 123 hash_state_("xyzzy"), | 123 hash_state_("xyzzy"), |
| 124 ui_thread_(BrowserThread::UI, &loop_), | 124 ui_thread_(BrowserThread::UI, &loop_), |
| 125 file_thread_(BrowserThread::FILE, &loop_) { | 125 file_thread_(BrowserThread::FILE, &loop_) { |
| 126 } | 126 } |
| 127 | 127 |
| 128 virtual ~DownloadFileTest() { | 128 ~DownloadFileTest() override {} |
| 129 } | |
| 130 | 129 |
| 131 void SetUpdateDownloadInfo(int64 bytes, int64 bytes_per_sec, | 130 void SetUpdateDownloadInfo(int64 bytes, int64 bytes_per_sec, |
| 132 const std::string& hash_state) { | 131 const std::string& hash_state) { |
| 133 bytes_ = bytes; | 132 bytes_ = bytes; |
| 134 bytes_per_sec_ = bytes_per_sec; | 133 bytes_per_sec_ = bytes_per_sec; |
| 135 hash_state_ = hash_state; | 134 hash_state_ = hash_state; |
| 136 } | 135 } |
| 137 | 136 |
| 138 void ConfirmUpdateDownloadInfo() { | 137 void ConfirmUpdateDownloadInfo() { |
| 139 observer_->CurrentUpdateStatus(bytes_, bytes_per_sec_, hash_state_); | 138 observer_->CurrentUpdateStatus(bytes_, bytes_per_sec_, hash_state_); |
| 140 } | 139 } |
| 141 | 140 |
| 142 virtual void SetUp() { | 141 void SetUp() override { |
| 143 EXPECT_CALL(*(observer_.get()), DestinationUpdate(_, _, _)) | 142 EXPECT_CALL(*(observer_.get()), DestinationUpdate(_, _, _)) |
| 144 .Times(AnyNumber()) | 143 .Times(AnyNumber()) |
| 145 .WillRepeatedly(Invoke(this, &DownloadFileTest::SetUpdateDownloadInfo)); | 144 .WillRepeatedly(Invoke(this, &DownloadFileTest::SetUpdateDownloadInfo)); |
| 146 } | 145 } |
| 147 | 146 |
| 148 // Mock calls to this function are forwarded here. | 147 // Mock calls to this function are forwarded here. |
| 149 void RegisterCallback(const base::Closure& sink_callback) { | 148 void RegisterCallback(const base::Closure& sink_callback) { |
| 150 sink_callback_ = sink_callback; | 149 sink_callback_ = sink_callback; |
| 151 } | 150 } |
| 152 | 151 |
| (...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 783 | 782 |
| 784 EXPECT_EQ(static_cast<int64>(strlen(kTestData1) + strlen(kTestData2)), | 783 EXPECT_EQ(static_cast<int64>(strlen(kTestData1) + strlen(kTestData2)), |
| 785 bytes_); | 784 bytes_); |
| 786 EXPECT_EQ(download_file_->GetHashState(), hash_state_); | 785 EXPECT_EQ(download_file_->GetHashState(), hash_state_); |
| 787 | 786 |
| 788 FinishStream(DOWNLOAD_INTERRUPT_REASON_NONE, true); | 787 FinishStream(DOWNLOAD_INTERRUPT_REASON_NONE, true); |
| 789 DestroyDownloadFile(0); | 788 DestroyDownloadFile(0); |
| 790 } | 789 } |
| 791 | 790 |
| 792 } // namespace content | 791 } // namespace content |
| OLD | NEW |